1/* SPDX-License-Identifier: GPL-2.0-or-later */
2/*
3 * Copyright (C) 2017, Microsoft Corporation.
4 *
5 * Author(s): Long Li <longli@microsoft.com>
6 */
7#ifndef _SMBDIRECT_H
8#define _SMBDIRECT_H
9
10#ifdef CONFIG_CIFS_SMB_DIRECT
11#define cifs_rdma_enabled(server) ((server)->rdma)
12
13#include "cifsglob.h"
14#include <rdma/ib_verbs.h>
15#include <rdma/rdma_cm.h>
16#include <linux/mempool.h>
17
18#include "../common/smbdirect/smbdirect.h"
19#include "../common/smbdirect/smbdirect_socket.h"
20
21extern int rdma_readwrite_threshold;
22extern int smbd_max_frmr_depth;
23extern int smbd_keep_alive_interval;
24extern int smbd_max_receive_size;
25extern int smbd_max_fragmented_recv_size;
26extern int smbd_max_send_size;
27extern int smbd_send_credit_target;
28extern int smbd_receive_credit_max;
29
30/*
31 * The context for the SMBDirect transport
32 * Everything related to the transport is here. It has several logical parts
33 * 1. RDMA related structures
34 * 2. SMBDirect connection parameters
35 * 3. Memory registrations
36 * 4. Receive and reassembly queues for data receive path
37 * 5. mempools for allocating packets
38 */
39struct smbd_connection {
40 struct smbdirect_socket socket;
41};
42
43/* Create a SMBDirect session */
44struct smbd_connection *smbd_get_connection(
45 struct TCP_Server_Info *server, struct sockaddr *dstaddr);
46
47const struct smbdirect_socket_parameters *smbd_get_parameters(struct smbd_connection *conn);
48
49/* Reconnect SMBDirect session */
50int smbd_reconnect(struct TCP_Server_Info *server);
51/* Destroy SMBDirect session */
52void smbd_destroy(struct TCP_Server_Info *server);
53
54/* Interface for carrying upper layer I/O through send/recv */
55int smbd_recv(struct smbd_connection *info, struct msghdr *msg);
56int smbd_send(struct TCP_Server_Info *server,
57 int num_rqst, struct smb_rqst *rqst);
58
59/* Interfaces to register and deregister MR for RDMA read/write */
60struct smbdirect_mr_io *smbd_register_mr(
61 struct smbd_connection *info, struct iov_iter *iter,
62 bool writing, bool need_invalidate);
63void smbd_deregister_mr(struct smbdirect_mr_io *mr);
64
65#else
66#define cifs_rdma_enabled(server) 0
67struct smbd_connection {};
68static inline void *smbd_get_connection(
69 struct TCP_Server_Info *server, struct sockaddr *dstaddr) {return NULL;}
70static inline int smbd_reconnect(struct TCP_Server_Info *server) {return -1; }
71static inline void smbd_destroy(struct TCP_Server_Info *server) {}
72static inline int smbd_recv(struct smbd_connection *info, struct msghdr *msg) {return -1; }
73static inline int smbd_send(struct TCP_Server_Info *server, int num_rqst, struct smb_rqst *rqst) {return -1; }
74#endif
75
76#endif
77

source code of linux/fs/smb/client/smbdirect.h