xref: /linux/fs/smb/client/smbdirect.h (revision 4e273bca232ec71bbf072f10f7d395a28e85e4e1)
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 
15 #include <linux/smbdirect.h>
16 
17 extern int rdma_readwrite_threshold;
18 extern int smbd_max_frmr_depth;
19 extern int smbd_keep_alive_interval;
20 extern int smbd_max_receive_size;
21 extern int smbd_max_fragmented_recv_size;
22 extern int smbd_max_send_size;
23 extern int smbd_send_credit_target;
24 extern int smbd_receive_credit_max;
25 
26 struct smbd_connection {
27 	struct smbdirect_socket *socket;
28 };
29 
30 /* Create a SMBDirect session */
31 struct smbd_connection *smbd_get_connection(
32 	struct TCP_Server_Info *server, struct sockaddr *dstaddr);
33 
34 const struct smbdirect_socket_parameters *smbd_get_parameters(struct smbd_connection *conn);
35 
36 /* Reconnect SMBDirect session */
37 int smbd_reconnect(struct TCP_Server_Info *server);
38 /* Destroy SMBDirect session */
39 void smbd_destroy(struct TCP_Server_Info *server);
40 
41 /* Interface for carrying upper layer I/O through send/recv */
42 int smbd_recv(struct smbd_connection *info, struct msghdr *msg);
43 int smbd_send(struct TCP_Server_Info *server,
44 	int num_rqst, struct smb_rqst *rqst);
45 
46 /* Interfaces to register and deregister MR for RDMA read/write */
47 struct smbdirect_mr_io *smbd_register_mr(
48 	struct smbd_connection *info, struct iov_iter *iter,
49 	bool writing, bool need_invalidate);
50 void smbd_mr_fill_buffer_descriptor(struct smbdirect_mr_io *mr,
51 				    struct smbdirect_buffer_descriptor_v1 *v1);
52 void smbd_deregister_mr(struct smbdirect_mr_io *mr);
53 
54 void smbd_debug_proc_show(struct TCP_Server_Info *server, struct seq_file *m);
55 
56 #else
57 #define cifs_rdma_enabled(server)	0
58 struct smbd_connection {};
59 static inline void *smbd_get_connection(
60 	struct TCP_Server_Info *server, struct sockaddr *dstaddr) {return NULL;}
61 static inline int smbd_reconnect(struct TCP_Server_Info *server) {return -1; }
62 static inline void smbd_destroy(struct TCP_Server_Info *server) {}
63 static inline int smbd_recv(struct smbd_connection *info, struct msghdr *msg) {return -1; }
64 static inline int smbd_send(struct TCP_Server_Info *server, int num_rqst, struct smb_rqst *rqst) {return -1; }
65 #endif
66 
67 #endif
68