blob: 5567d93a6f96e0974b958f0dd48e6585d0235fa8 [file] [log] [blame]
Namjae Jeon0626e662021-03-16 13:07:11 +09001/* 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
Namjae Jeon92239582021-07-16 17:16:11 +090010/* SMB DIRECT negotiation request packet [MS-SMBD] 2.2.1 */
Namjae Jeon0626e662021-03-16 13:07:11 +090011struct smb_direct_negotiate_req {
12 __le16 min_version;
13 __le16 max_version;
14 __le16 reserved;
15 __le16 credits_requested;
16 __le32 preferred_send_size;
17 __le32 max_receive_size;
18 __le32 max_fragmented_size;
19} __packed;
20
Namjae Jeon92239582021-07-16 17:16:11 +090021/* SMB DIRECT negotiation response packet [MS-SMBD] 2.2.2 */
Namjae Jeon0626e662021-03-16 13:07:11 +090022struct smb_direct_negotiate_resp {
23 __le16 min_version;
24 __le16 max_version;
25 __le16 negotiated_version;
26 __le16 reserved;
27 __le16 credits_requested;
28 __le16 credits_granted;
29 __le32 status;
30 __le32 max_readwrite_size;
31 __le32 preferred_send_size;
32 __le32 max_receive_size;
33 __le32 max_fragmented_size;
34} __packed;
35
36#define SMB_DIRECT_RESPONSE_REQUESTED 0x0001
37
Namjae Jeon92239582021-07-16 17:16:11 +090038/* SMB DIRECT data transfer packet with payload [MS-SMBD] 2.2.3 */
Namjae Jeon0626e662021-03-16 13:07:11 +090039struct smb_direct_data_transfer {
40 __le16 credits_requested;
41 __le16 credits_granted;
42 __le16 flags;
43 __le16 reserved;
44 __le32 remaining_data_length;
45 __le32 data_offset;
46 __le32 data_length;
47 __le32 padding;
48 __u8 buffer[];
49} __packed;
50
51#ifdef CONFIG_SMB_SERVER_SMBDIRECT
52int ksmbd_rdma_init(void);
Hyunchul Lee31928a02021-12-29 23:02:15 +090053void ksmbd_rdma_destroy(void);
Hyunchul Lee03d8d4f2021-07-13 16:09:34 +090054bool ksmbd_rdma_capable_netdev(struct net_device *netdev);
Namjae Jeon0626e662021-03-16 13:07:11 +090055#else
56static inline int ksmbd_rdma_init(void) { return 0; }
57static inline int ksmbd_rdma_destroy(void) { return 0; }
Hyunchul Lee03d8d4f2021-07-13 16:09:34 +090058static inline bool ksmbd_rdma_capable_netdev(struct net_device *netdev) { return false; }
Namjae Jeon0626e662021-03-16 13:07:11 +090059#endif
60
61#endif /* __KSMBD_TRANSPORT_RDMA_H__ */