xref: /linux/fs/smb/server/transport_rdma.h (revision 8e07e0e3964ca4e23ce7b68e2096fe660a888942)
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 /*
3  *   Copyright (C) 2017, Microsoft Corporation.
4  *   Copyright (C) 2018, LG Electronics.
5  */
6 
7 #ifndef __KSMBD_TRANSPORT_RDMA_H__
8 #define __KSMBD_TRANSPORT_RDMA_H__
9 
10 #define SMBD_DEFAULT_IOSIZE (8 * 1024 * 1024)
11 #define SMBD_MIN_IOSIZE (512 * 1024)
12 #define SMBD_MAX_IOSIZE (16 * 1024 * 1024)
13 
14 /* SMB DIRECT negotiation request packet [MS-SMBD] 2.2.1 */
15 struct smb_direct_negotiate_req {
16 	__le16 min_version;
17 	__le16 max_version;
18 	__le16 reserved;
19 	__le16 credits_requested;
20 	__le32 preferred_send_size;
21 	__le32 max_receive_size;
22 	__le32 max_fragmented_size;
23 } __packed;
24 
25 /* SMB DIRECT negotiation response packet [MS-SMBD] 2.2.2 */
26 struct smb_direct_negotiate_resp {
27 	__le16 min_version;
28 	__le16 max_version;
29 	__le16 negotiated_version;
30 	__le16 reserved;
31 	__le16 credits_requested;
32 	__le16 credits_granted;
33 	__le32 status;
34 	__le32 max_readwrite_size;
35 	__le32 preferred_send_size;
36 	__le32 max_receive_size;
37 	__le32 max_fragmented_size;
38 } __packed;
39 
40 #define SMB_DIRECT_RESPONSE_REQUESTED 0x0001
41 
42 /* SMB DIRECT data transfer packet with payload [MS-SMBD] 2.2.3 */
43 struct smb_direct_data_transfer {
44 	__le16 credits_requested;
45 	__le16 credits_granted;
46 	__le16 flags;
47 	__le16 reserved;
48 	__le32 remaining_data_length;
49 	__le32 data_offset;
50 	__le32 data_length;
51 	__le32 padding;
52 	__u8 buffer[];
53 } __packed;
54 
55 #ifdef CONFIG_SMB_SERVER_SMBDIRECT
56 int ksmbd_rdma_init(void);
57 void ksmbd_rdma_destroy(void);
58 bool ksmbd_rdma_capable_netdev(struct net_device *netdev);
59 void init_smbd_max_io_size(unsigned int sz);
60 unsigned int get_smbd_max_read_write_size(void);
61 #else
62 static inline int ksmbd_rdma_init(void) { return 0; }
63 static inline int ksmbd_rdma_destroy(void) { return 0; }
64 static inline bool ksmbd_rdma_capable_netdev(struct net_device *netdev) { return false; }
65 static inline void init_smbd_max_io_size(unsigned int sz) { }
66 static inline unsigned int get_smbd_max_read_write_size(void) { return 0; }
67 #endif
68 
69 #endif /* __KSMBD_TRANSPORT_RDMA_H__ */
70