* [PATCH 1/5] smb: common: split out smb_direct related header files
2025-05-27 16:12 [PATCH 0/5] smb:common: introduce and use common smb_direct headers (step1) Stefan Metzmacher
@ 2025-05-27 16:12 ` Stefan Metzmacher
2025-05-27 18:50 ` Tom Talpey
2025-05-27 16:12 ` [PATCH 2/5] smb: client: make use of common smb_direct headers Stefan Metzmacher
` (3 subsequent siblings)
4 siblings, 1 reply; 9+ messages in thread
From: Stefan Metzmacher @ 2025-05-27 16:12 UTC (permalink / raw)
To: linux-cifs
Cc: metze, Steve French, Tom Talpey, Long Li, Namjae Jeon,
Hyunchul Lee, samba-technical
This is just a start moving into a common smb_direct layer.
Cc: Steve French <smfrench@gmail.com>
Cc: Tom Talpey <tom@talpey.com>
Cc: Long Li <longli@microsoft.com>
Cc: Namjae Jeon <linkinjeon@kernel.org>
Cc: Hyunchul Lee <hyc.lee@gmail.com>
Cc: linux-cifs@vger.kernel.org
Cc: samba-technical@lists.samba.org
Signed-off-by: Stefan Metzmacher <metze@samba.org>
---
fs/smb/common/smb_direct/smb_direct.h | 11 +++++
fs/smb/common/smb_direct/smb_direct_pdu.h | 51 +++++++++++++++++++++++
fs/smb/server/transport_rdma.h | 43 +------------------
3 files changed, 64 insertions(+), 41 deletions(-)
create mode 100644 fs/smb/common/smb_direct/smb_direct.h
create mode 100644 fs/smb/common/smb_direct/smb_direct_pdu.h
diff --git a/fs/smb/common/smb_direct/smb_direct.h b/fs/smb/common/smb_direct/smb_direct.h
new file mode 100644
index 000000000000..c745c37a3fea
--- /dev/null
+++ b/fs/smb/common/smb_direct/smb_direct.h
@@ -0,0 +1,11 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+/*
+ * Copyright (C) 2025, Stefan Metzmacher <metze@samba.org>
+ */
+
+#ifndef __FS_SMB_COMMON_SMB_DIRECT_SMB_DIRECT_H__
+#define __FS_SMB_COMMON_SMB_DIRECT_SMB_DIRECT_H__
+
+#include "smb_direct_pdu.h"
+
+#endif /* __FS_SMB_COMMON_SMB_DIRECT_SMB_DIRECT_H__ */
diff --git a/fs/smb/common/smb_direct/smb_direct_pdu.h b/fs/smb/common/smb_direct/smb_direct_pdu.h
new file mode 100644
index 000000000000..ab73cd8f807a
--- /dev/null
+++ b/fs/smb/common/smb_direct/smb_direct_pdu.h
@@ -0,0 +1,51 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+/*
+ * Copyright (C) 2017, Microsoft Corporation.
+ * Copyright (C) 2018, LG Electronics.
+ */
+
+#ifndef __FS_SMB_COMMON_SMB_DIRECT_SMB_DIRECT_PDU_H__
+#define __FS_SMB_COMMON_SMB_DIRECT_SMB_DIRECT_PDU_H__
+
+/* SMB DIRECT negotiation request packet [MS-SMBD] 2.2.1 */
+struct smb_direct_negotiate_req {
+ __le16 min_version;
+ __le16 max_version;
+ __le16 reserved;
+ __le16 credits_requested;
+ __le32 preferred_send_size;
+ __le32 max_receive_size;
+ __le32 max_fragmented_size;
+} __packed;
+
+/* SMB DIRECT negotiation response packet [MS-SMBD] 2.2.2 */
+struct smb_direct_negotiate_resp {
+ __le16 min_version;
+ __le16 max_version;
+ __le16 negotiated_version;
+ __le16 reserved;
+ __le16 credits_requested;
+ __le16 credits_granted;
+ __le32 status;
+ __le32 max_readwrite_size;
+ __le32 preferred_send_size;
+ __le32 max_receive_size;
+ __le32 max_fragmented_size;
+} __packed;
+
+#define SMB_DIRECT_RESPONSE_REQUESTED 0x0001
+
+/* SMB DIRECT data transfer packet with payload [MS-SMBD] 2.2.3 */
+struct smb_direct_data_transfer {
+ __le16 credits_requested;
+ __le16 credits_granted;
+ __le16 flags;
+ __le16 reserved;
+ __le32 remaining_data_length;
+ __le32 data_offset;
+ __le32 data_length;
+ __le32 padding;
+ __u8 buffer[];
+} __packed;
+
+#endif /* __FS_SMB_COMMON_SMB_DIRECT_SMB_DIRECT_PDU_H__ */
diff --git a/fs/smb/server/transport_rdma.h b/fs/smb/server/transport_rdma.h
index 77aee4e5c9dc..71909b6d8021 100644
--- a/fs/smb/server/transport_rdma.h
+++ b/fs/smb/server/transport_rdma.h
@@ -7,51 +7,12 @@
#ifndef __KSMBD_TRANSPORT_RDMA_H__
#define __KSMBD_TRANSPORT_RDMA_H__
+#include "../common/smb_direct/smb_direct.h"
+
#define SMBD_DEFAULT_IOSIZE (8 * 1024 * 1024)
#define SMBD_MIN_IOSIZE (512 * 1024)
#define SMBD_MAX_IOSIZE (16 * 1024 * 1024)
-/* SMB DIRECT negotiation request packet [MS-SMBD] 2.2.1 */
-struct smb_direct_negotiate_req {
- __le16 min_version;
- __le16 max_version;
- __le16 reserved;
- __le16 credits_requested;
- __le32 preferred_send_size;
- __le32 max_receive_size;
- __le32 max_fragmented_size;
-} __packed;
-
-/* SMB DIRECT negotiation response packet [MS-SMBD] 2.2.2 */
-struct smb_direct_negotiate_resp {
- __le16 min_version;
- __le16 max_version;
- __le16 negotiated_version;
- __le16 reserved;
- __le16 credits_requested;
- __le16 credits_granted;
- __le32 status;
- __le32 max_readwrite_size;
- __le32 preferred_send_size;
- __le32 max_receive_size;
- __le32 max_fragmented_size;
-} __packed;
-
-#define SMB_DIRECT_RESPONSE_REQUESTED 0x0001
-
-/* SMB DIRECT data transfer packet with payload [MS-SMBD] 2.2.3 */
-struct smb_direct_data_transfer {
- __le16 credits_requested;
- __le16 credits_granted;
- __le16 flags;
- __le16 reserved;
- __le32 remaining_data_length;
- __le32 data_offset;
- __le32 data_length;
- __le32 padding;
- __u8 buffer[];
-} __packed;
-
#ifdef CONFIG_SMB_SERVER_SMBDIRECT
int ksmbd_rdma_init(void);
void ksmbd_rdma_destroy(void);
--
2.34.1
^ permalink raw reply related [flat|nested] 9+ messages in thread* Re: [PATCH 1/5] smb: common: split out smb_direct related header files
2025-05-27 16:12 ` [PATCH 1/5] smb: common: split out smb_direct related header files Stefan Metzmacher
@ 2025-05-27 18:50 ` Tom Talpey
2025-05-27 19:14 ` Steve French
2025-05-27 19:59 ` Stefan Metzmacher
0 siblings, 2 replies; 9+ messages in thread
From: Tom Talpey @ 2025-05-27 18:50 UTC (permalink / raw)
To: Stefan Metzmacher
Cc: Steve French, Long Li, Namjae Jeon, Hyunchul Lee, samba-technical,
linux-cifs
I love the idea. Couple of questions on the pathnames...
On 5/27/2025 12:12 PM, Stefan Metzmacher wrote:
> This is just a start moving into a common smb_direct layer.
>
> Cc: Steve French <smfrench@gmail.com>
> Cc: Tom Talpey <tom@talpey.com>
> Cc: Long Li <longli@microsoft.com>
> Cc: Namjae Jeon <linkinjeon@kernel.org>
> Cc: Hyunchul Lee <hyc.lee@gmail.com>
> Cc: linux-cifs@vger.kernel.org
> Cc: samba-technical@lists.samba.org
> Signed-off-by: Stefan Metzmacher <metze@samba.org>
> ---
> fs/smb/common/smb_direct/smb_direct.h | 11 +++++
> fs/smb/common/smb_direct/smb_direct_pdu.h | 51 +++++++++++++++++++++++
Why the underscore in "smb_direct", in both components? The protocol
doesn't use this, and it seems awkward and search-unfriendly.
> fs/smb/server/transport_rdma.h | 43 +------------------
> 3 files changed, 64 insertions(+), 41 deletions(-)
> create mode 100644 fs/smb/common/smb_direct/smb_direct.h
> create mode 100644 fs/smb/common/smb_direct/smb_direct_pdu.h
>
> diff --git a/fs/smb/common/smb_direct/smb_direct.h b/fs/smb/common/smb_direct/smb_direct.h
> new file mode 100644
> index 000000000000..c745c37a3fea
> --- /dev/null
> +++ b/fs/smb/common/smb_direct/smb_direct.h
> @@ -0,0 +1,11 @@
> +/* SPDX-License-Identifier: GPL-2.0-or-later */
> +/*
> + * Copyright (C) 2025, Stefan Metzmacher <metze@samba.org>
> + */
> +
> +#ifndef __FS_SMB_COMMON_SMB_DIRECT_SMB_DIRECT_H__
> +#define __FS_SMB_COMMON_SMB_DIRECT_SMB_DIRECT_H__
> +
> +#include "smb_direct_pdu.h"
And, why the empty redirection? It seems unnecessary, do I assume it
will later contain API signatures for the planned common layer? Perhaps
it should say this, to avoid confusion while that work is being done.
I'll review more later, but a first pass looks good!
Tom.
> +
> +#endif /* __FS_SMB_COMMON_SMB_DIRECT_SMB_DIRECT_H__ */
> diff --git a/fs/smb/common/smb_direct/smb_direct_pdu.h b/fs/smb/common/smb_direct/smb_direct_pdu.h
> new file mode 100644
> index 000000000000..ab73cd8f807a
> --- /dev/null
> +++ b/fs/smb/common/smb_direct/smb_direct_pdu.h
> @@ -0,0 +1,51 @@
> +/* SPDX-License-Identifier: GPL-2.0-or-later */
> +/*
> + * Copyright (C) 2017, Microsoft Corporation.
> + * Copyright (C) 2018, LG Electronics.
> + */
> +
> +#ifndef __FS_SMB_COMMON_SMB_DIRECT_SMB_DIRECT_PDU_H__
> +#define __FS_SMB_COMMON_SMB_DIRECT_SMB_DIRECT_PDU_H__
> +
> +/* SMB DIRECT negotiation request packet [MS-SMBD] 2.2.1 */
> +struct smb_direct_negotiate_req {
> + __le16 min_version;
> + __le16 max_version;
> + __le16 reserved;
> + __le16 credits_requested;
> + __le32 preferred_send_size;
> + __le32 max_receive_size;
> + __le32 max_fragmented_size;
> +} __packed;
> +
> +/* SMB DIRECT negotiation response packet [MS-SMBD] 2.2.2 */
> +struct smb_direct_negotiate_resp {
> + __le16 min_version;
> + __le16 max_version;
> + __le16 negotiated_version;
> + __le16 reserved;
> + __le16 credits_requested;
> + __le16 credits_granted;
> + __le32 status;
> + __le32 max_readwrite_size;
> + __le32 preferred_send_size;
> + __le32 max_receive_size;
> + __le32 max_fragmented_size;
> +} __packed;
> +
> +#define SMB_DIRECT_RESPONSE_REQUESTED 0x0001
> +
> +/* SMB DIRECT data transfer packet with payload [MS-SMBD] 2.2.3 */
> +struct smb_direct_data_transfer {
> + __le16 credits_requested;
> + __le16 credits_granted;
> + __le16 flags;
> + __le16 reserved;
> + __le32 remaining_data_length;
> + __le32 data_offset;
> + __le32 data_length;
> + __le32 padding;
> + __u8 buffer[];
> +} __packed;
> +
> +#endif /* __FS_SMB_COMMON_SMB_DIRECT_SMB_DIRECT_PDU_H__ */
> diff --git a/fs/smb/server/transport_rdma.h b/fs/smb/server/transport_rdma.h
> index 77aee4e5c9dc..71909b6d8021 100644
> --- a/fs/smb/server/transport_rdma.h
> +++ b/fs/smb/server/transport_rdma.h
> @@ -7,51 +7,12 @@
> #ifndef __KSMBD_TRANSPORT_RDMA_H__
> #define __KSMBD_TRANSPORT_RDMA_H__
>
> +#include "../common/smb_direct/smb_direct.h"
> +
> #define SMBD_DEFAULT_IOSIZE (8 * 1024 * 1024)
> #define SMBD_MIN_IOSIZE (512 * 1024)
> #define SMBD_MAX_IOSIZE (16 * 1024 * 1024)
>
> -/* SMB DIRECT negotiation request packet [MS-SMBD] 2.2.1 */
> -struct smb_direct_negotiate_req {
> - __le16 min_version;
> - __le16 max_version;
> - __le16 reserved;
> - __le16 credits_requested;
> - __le32 preferred_send_size;
> - __le32 max_receive_size;
> - __le32 max_fragmented_size;
> -} __packed;
> -
> -/* SMB DIRECT negotiation response packet [MS-SMBD] 2.2.2 */
> -struct smb_direct_negotiate_resp {
> - __le16 min_version;
> - __le16 max_version;
> - __le16 negotiated_version;
> - __le16 reserved;
> - __le16 credits_requested;
> - __le16 credits_granted;
> - __le32 status;
> - __le32 max_readwrite_size;
> - __le32 preferred_send_size;
> - __le32 max_receive_size;
> - __le32 max_fragmented_size;
> -} __packed;
> -
> -#define SMB_DIRECT_RESPONSE_REQUESTED 0x0001
> -
> -/* SMB DIRECT data transfer packet with payload [MS-SMBD] 2.2.3 */
> -struct smb_direct_data_transfer {
> - __le16 credits_requested;
> - __le16 credits_granted;
> - __le16 flags;
> - __le16 reserved;
> - __le32 remaining_data_length;
> - __le32 data_offset;
> - __le32 data_length;
> - __le32 padding;
> - __u8 buffer[];
> -} __packed;
> -
> #ifdef CONFIG_SMB_SERVER_SMBDIRECT
> int ksmbd_rdma_init(void);
> void ksmbd_rdma_destroy(void);
^ permalink raw reply [flat|nested] 9+ messages in thread* Re: [PATCH 1/5] smb: common: split out smb_direct related header files
2025-05-27 18:50 ` Tom Talpey
@ 2025-05-27 19:14 ` Steve French
2025-05-27 19:59 ` Stefan Metzmacher
1 sibling, 0 replies; 9+ messages in thread
From: Steve French @ 2025-05-27 19:14 UTC (permalink / raw)
To: Tom Talpey
Cc: Stefan Metzmacher, Long Li, Namjae Jeon, Hyunchul Lee,
samba-technical, linux-cifs
On Tue, May 27, 2025 at 1:50 PM Tom Talpey <tom@talpey.com> wrote:
>
> I love the idea. Couple of questions on the pathnames...
>
> On 5/27/2025 12:12 PM, Stefan Metzmacher wrote:
> > This is just a start moving into a common smb_direct layer.
> >
> > Cc: Steve French <smfrench@gmail.com>
> > Cc: Tom Talpey <tom@talpey.com>
> > Cc: Long Li <longli@microsoft.com>
> > Cc: Namjae Jeon <linkinjeon@kernel.org>
> > Cc: Hyunchul Lee <hyc.lee@gmail.com>
> > Cc: linux-cifs@vger.kernel.org
> > Cc: samba-technical@lists.samba.org
> > Signed-off-by: Stefan Metzmacher <metze@samba.org>
> > ---
> > fs/smb/common/smb_direct/smb_direct.h | 11 +++++
> > fs/smb/common/smb_direct/smb_direct_pdu.h | 51 +++++++++++++++++++++++
>
> Why the underscore in "smb_direct", in both components? The protocol
> doesn't use this, and it seems awkward and search-unfriendly.
I agree that it would be less confusing if smbdirect instead of
smb_direct in the file/directory names
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 1/5] smb: common: split out smb_direct related header files
2025-05-27 18:50 ` Tom Talpey
2025-05-27 19:14 ` Steve French
@ 2025-05-27 19:59 ` Stefan Metzmacher
1 sibling, 0 replies; 9+ messages in thread
From: Stefan Metzmacher @ 2025-05-27 19:59 UTC (permalink / raw)
To: Tom Talpey
Cc: Steve French, Long Li, Namjae Jeon, Hyunchul Lee, samba-technical,
linux-cifs
Am 27.05.25 um 20:50 schrieb Tom Talpey:
> I love the idea. Couple of questions on the pathnames...
>
> On 5/27/2025 12:12 PM, Stefan Metzmacher wrote:
>> This is just a start moving into a common smb_direct layer.
>>
>> Cc: Steve French <smfrench@gmail.com>
>> Cc: Tom Talpey <tom@talpey.com>
>> Cc: Long Li <longli@microsoft.com>
>> Cc: Namjae Jeon <linkinjeon@kernel.org>
>> Cc: Hyunchul Lee <hyc.lee@gmail.com>
>> Cc: linux-cifs@vger.kernel.org
>> Cc: samba-technical@lists.samba.org
>> Signed-off-by: Stefan Metzmacher <metze@samba.org>
>> ---
>> fs/smb/common/smb_direct/smb_direct.h | 11 +++++
>> fs/smb/common/smb_direct/smb_direct_pdu.h | 51 +++++++++++++++++++++++
>
> Why the underscore in "smb_direct", in both components? The protocol
> doesn't use this, and it seems awkward and search-unfriendly.
Yes, I'd also prefer smbdirect and I just used it because I had
my existing wip driver under that name, but that should not matter.
The other reason was that the existing structures used smb_direct_
as prefix, but I'll also change that.
>> fs/smb/server/transport_rdma.h | 43 +------------------
>> 3 files changed, 64 insertions(+), 41 deletions(-)
>> create mode 100644 fs/smb/common/smb_direct/smb_direct.h
>> create mode 100644 fs/smb/common/smb_direct/smb_direct_pdu.h
>>
>> diff --git a/fs/smb/common/smb_direct/smb_direct.h b/fs/smb/common/smb_direct/smb_direct.h
>> new file mode 100644
>> index 000000000000..c745c37a3fea
>> --- /dev/null
>> +++ b/fs/smb/common/smb_direct/smb_direct.h
>> @@ -0,0 +1,11 @@
>> +/* SPDX-License-Identifier: GPL-2.0-or-later */
>> +/*
>> + * Copyright (C) 2025, Stefan Metzmacher <metze@samba.org>
>> + */
>> +
>> +#ifndef __FS_SMB_COMMON_SMB_DIRECT_SMB_DIRECT_H__
>> +#define __FS_SMB_COMMON_SMB_DIRECT_SMB_DIRECT_H__
>> +
>> +#include "smb_direct_pdu.h"
>
> And, why the empty redirection? It seems unnecessary, do I assume it
> will later contain API signatures for the planned common layer? Perhaps
> it should say this, to avoid confusion while that work is being done.
I'll think about it maybe I'll remove the redirection.
In the end the pdu definitions belong only in a single common .c files,
but it will take a lot of steps to get there.
I'll post a v2 tomorrow or next week.
Thanks!
metze
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 2/5] smb: client: make use of common smb_direct headers
2025-05-27 16:12 [PATCH 0/5] smb:common: introduce and use common smb_direct headers (step1) Stefan Metzmacher
2025-05-27 16:12 ` [PATCH 1/5] smb: common: split out smb_direct related header files Stefan Metzmacher
@ 2025-05-27 16:12 ` Stefan Metzmacher
2025-05-27 16:13 ` [PATCH 3/5] smb: common: add smb_direct_buffer_descriptor_v1 Stefan Metzmacher
` (2 subsequent siblings)
4 siblings, 0 replies; 9+ messages in thread
From: Stefan Metzmacher @ 2025-05-27 16:12 UTC (permalink / raw)
To: linux-cifs
Cc: metze, Steve French, Tom Talpey, Long Li, Namjae Jeon,
Hyunchul Lee, samba-technical
Cc: Steve French <smfrench@gmail.com>
Cc: Tom Talpey <tom@talpey.com>
Cc: Long Li <longli@microsoft.com>
Cc: Namjae Jeon <linkinjeon@kernel.org>
Cc: Hyunchul Lee <hyc.lee@gmail.com>
Cc: linux-cifs@vger.kernel.org
Cc: samba-technical@lists.samba.org
Signed-off-by: Stefan Metzmacher <metze@samba.org>
---
fs/smb/client/smbdirect.c | 22 ++++++++++----------
fs/smb/client/smbdirect.h | 43 ++-------------------------------------
2 files changed, 13 insertions(+), 52 deletions(-)
diff --git a/fs/smb/client/smbdirect.c b/fs/smb/client/smbdirect.c
index b0b7254661e9..ec307faa94d2 100644
--- a/fs/smb/client/smbdirect.c
+++ b/fs/smb/client/smbdirect.c
@@ -299,7 +299,7 @@ static void send_done(struct ib_cq *cq, struct ib_wc *wc)
mempool_free(request, request->info->request_mempool);
}
-static void dump_smbd_negotiate_resp(struct smbd_negotiate_resp *resp)
+static void dump_smb_direct_negotiate_resp(struct smb_direct_negotiate_resp *resp)
{
log_rdma_event(INFO, "resp message min_version %u max_version %u negotiated_version %u credits_requested %u credits_granted %u status %u max_readwrite_size %u preferred_send_size %u max_receive_size %u max_fragmented_size %u\n",
resp->min_version, resp->max_version,
@@ -318,9 +318,9 @@ static bool process_negotiation_response(
struct smbd_response *response, int packet_length)
{
struct smbd_connection *info = response->info;
- struct smbd_negotiate_resp *packet = smbd_response_payload(response);
+ struct smb_direct_negotiate_resp *packet = smbd_response_payload(response);
- if (packet_length < sizeof(struct smbd_negotiate_resp)) {
+ if (packet_length < sizeof(struct smb_direct_negotiate_resp)) {
log_rdma_event(ERR,
"error: packet_length=%d\n", packet_length);
return false;
@@ -448,7 +448,7 @@ static void smbd_post_send_credits(struct work_struct *work)
/* Called from softirq, when recv is done */
static void recv_done(struct ib_cq *cq, struct ib_wc *wc)
{
- struct smbd_data_transfer *data_transfer;
+ struct smb_direct_data_transfer *data_transfer;
struct smbd_response *response =
container_of(wc->wr_cqe, struct smbd_response, cqe);
struct smbd_connection *info = response->info;
@@ -474,7 +474,7 @@ static void recv_done(struct ib_cq *cq, struct ib_wc *wc)
switch (response->type) {
/* SMBD negotiation response */
case SMBD_NEGOTIATE_RESP:
- dump_smbd_negotiate_resp(smbd_response_payload(response));
+ dump_smb_direct_negotiate_resp(smbd_response_payload(response));
info->full_packet_received = true;
info->negotiate_done =
process_negotiation_response(response, wc->byte_len);
@@ -686,7 +686,7 @@ static int smbd_post_send_negotiate_req(struct smbd_connection *info)
struct ib_send_wr send_wr;
int rc = -ENOMEM;
struct smbd_request *request;
- struct smbd_negotiate_req *packet;
+ struct smb_direct_negotiate_req *packet;
request = mempool_alloc(info->request_mempool, GFP_KERNEL);
if (!request)
@@ -837,7 +837,7 @@ static int smbd_post_send_iter(struct smbd_connection *info,
int header_length;
int data_length;
struct smbd_request *request;
- struct smbd_data_transfer *packet;
+ struct smb_direct_data_transfer *packet;
int new_credits = 0;
wait_credit:
@@ -938,10 +938,10 @@ static int smbd_post_send_iter(struct smbd_connection *info,
le32_to_cpu(packet->remaining_data_length));
/* Map the packet to DMA */
- header_length = sizeof(struct smbd_data_transfer);
+ header_length = sizeof(struct smb_direct_data_transfer);
/* If this is a packet without payload, don't send padding */
if (!data_length)
- header_length = offsetof(struct smbd_data_transfer, padding);
+ header_length = offsetof(struct smb_direct_data_transfer, padding);
request->sge[0].addr = ib_dma_map_single(info->id->device,
(void *)packet,
@@ -1432,7 +1432,7 @@ static int allocate_caches_and_workqueue(struct smbd_connection *info)
kmem_cache_create(
name,
sizeof(struct smbd_request) +
- sizeof(struct smbd_data_transfer),
+ sizeof(struct smb_direct_data_transfer),
0, SLAB_HWCACHE_ALIGN, NULL);
if (!info->request_cache)
return -ENOMEM;
@@ -1735,7 +1735,7 @@ static int smbd_recv_buf(struct smbd_connection *info, char *buf,
unsigned int size)
{
struct smbd_response *response;
- struct smbd_data_transfer *data_transfer;
+ struct smb_direct_data_transfer *data_transfer;
int to_copy, to_read, data_read, offset;
u32 data_length, remaining_data_length, data_offset;
int rc;
diff --git a/fs/smb/client/smbdirect.h b/fs/smb/client/smbdirect.h
index c08e3665150d..9c5b78a33311 100644
--- a/fs/smb/client/smbdirect.h
+++ b/fs/smb/client/smbdirect.h
@@ -15,6 +15,8 @@
#include <rdma/rdma_cm.h>
#include <linux/mempool.h>
+#include "../common/smb_direct/smb_direct.h"
+
extern int rdma_readwrite_threshold;
extern int smbd_max_frmr_depth;
extern int smbd_keep_alive_interval;
@@ -177,47 +179,6 @@ enum smbd_message_type {
SMBD_TRANSFER_DATA,
};
-#define SMB_DIRECT_RESPONSE_REQUESTED 0x0001
-
-/* SMBD negotiation request packet [MS-SMBD] 2.2.1 */
-struct smbd_negotiate_req {
- __le16 min_version;
- __le16 max_version;
- __le16 reserved;
- __le16 credits_requested;
- __le32 preferred_send_size;
- __le32 max_receive_size;
- __le32 max_fragmented_size;
-} __packed;
-
-/* SMBD negotiation response packet [MS-SMBD] 2.2.2 */
-struct smbd_negotiate_resp {
- __le16 min_version;
- __le16 max_version;
- __le16 negotiated_version;
- __le16 reserved;
- __le16 credits_requested;
- __le16 credits_granted;
- __le32 status;
- __le32 max_readwrite_size;
- __le32 preferred_send_size;
- __le32 max_receive_size;
- __le32 max_fragmented_size;
-} __packed;
-
-/* SMBD data transfer packet with payload [MS-SMBD] 2.2.3 */
-struct smbd_data_transfer {
- __le16 credits_requested;
- __le16 credits_granted;
- __le16 flags;
- __le16 reserved;
- __le32 remaining_data_length;
- __le32 data_offset;
- __le32 data_length;
- __le32 padding;
- __u8 buffer[];
-} __packed;
-
/* The packet fields for a registered RDMA buffer */
struct smbd_buffer_descriptor_v1 {
__le64 offset;
--
2.34.1
^ permalink raw reply related [flat|nested] 9+ messages in thread* [PATCH 3/5] smb: common: add smb_direct_buffer_descriptor_v1
2025-05-27 16:12 [PATCH 0/5] smb:common: introduce and use common smb_direct headers (step1) Stefan Metzmacher
2025-05-27 16:12 ` [PATCH 1/5] smb: common: split out smb_direct related header files Stefan Metzmacher
2025-05-27 16:12 ` [PATCH 2/5] smb: client: make use of common smb_direct headers Stefan Metzmacher
@ 2025-05-27 16:13 ` Stefan Metzmacher
2025-05-27 16:13 ` [PATCH 4/5] smb: client: make use of common smb_direct_buffer_descriptor_v1 Stefan Metzmacher
2025-05-27 16:13 ` [PATCH 5/5] smb: server: " Stefan Metzmacher
4 siblings, 0 replies; 9+ messages in thread
From: Stefan Metzmacher @ 2025-05-27 16:13 UTC (permalink / raw)
To: linux-cifs
Cc: metze, Steve French, Tom Talpey, Long Li, Namjae Jeon,
Hyunchul Lee, samba-technical
Will be used in client and server in the next commits.
Cc: Steve French <smfrench@gmail.com>
Cc: Tom Talpey <tom@talpey.com>
Cc: Long Li <longli@microsoft.com>
Cc: Namjae Jeon <linkinjeon@kernel.org>
Cc: Hyunchul Lee <hyc.lee@gmail.com>
Cc: linux-cifs@vger.kernel.org
Cc: samba-technical@lists.samba.org
Signed-off-by: Stefan Metzmacher <metze@samba.org>
---
fs/smb/common/smb_direct/smb_direct_pdu.h | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/fs/smb/common/smb_direct/smb_direct_pdu.h b/fs/smb/common/smb_direct/smb_direct_pdu.h
index ab73cd8f807a..9a0b1762b828 100644
--- a/fs/smb/common/smb_direct/smb_direct_pdu.h
+++ b/fs/smb/common/smb_direct/smb_direct_pdu.h
@@ -48,4 +48,11 @@ struct smb_direct_data_transfer {
__u8 buffer[];
} __packed;
+/* SMB DIRECT buffer descriptor V1 structure [MS-SMBD] 2.2.3.1 */
+struct smb_direct_buffer_descriptor_v1 {
+ __le64 offset;
+ __le32 token;
+ __le32 length;
+} __packed;
+
#endif /* __FS_SMB_COMMON_SMB_DIRECT_SMB_DIRECT_PDU_H__ */
--
2.34.1
^ permalink raw reply related [flat|nested] 9+ messages in thread* [PATCH 4/5] smb: client: make use of common smb_direct_buffer_descriptor_v1
2025-05-27 16:12 [PATCH 0/5] smb:common: introduce and use common smb_direct headers (step1) Stefan Metzmacher
` (2 preceding siblings ...)
2025-05-27 16:13 ` [PATCH 3/5] smb: common: add smb_direct_buffer_descriptor_v1 Stefan Metzmacher
@ 2025-05-27 16:13 ` Stefan Metzmacher
2025-05-27 16:13 ` [PATCH 5/5] smb: server: " Stefan Metzmacher
4 siblings, 0 replies; 9+ messages in thread
From: Stefan Metzmacher @ 2025-05-27 16:13 UTC (permalink / raw)
To: linux-cifs
Cc: metze, Steve French, Tom Talpey, Long Li, Namjae Jeon,
Hyunchul Lee, samba-technical
Cc: Steve French <smfrench@gmail.com>
Cc: Tom Talpey <tom@talpey.com>
Cc: Long Li <longli@microsoft.com>
Cc: Namjae Jeon <linkinjeon@kernel.org>
Cc: Hyunchul Lee <hyc.lee@gmail.com>
Cc: linux-cifs@vger.kernel.org
Cc: samba-technical@lists.samba.org
Signed-off-by: Stefan Metzmacher <metze@samba.org>
---
fs/smb/client/smb2pdu.c | 16 ++++++++--------
fs/smb/client/smbdirect.h | 7 -------
2 files changed, 8 insertions(+), 15 deletions(-)
diff --git a/fs/smb/client/smb2pdu.c b/fs/smb/client/smb2pdu.c
index 701a138b82c8..09b9bb1afd01 100644
--- a/fs/smb/client/smb2pdu.c
+++ b/fs/smb/client/smb2pdu.c
@@ -4442,10 +4442,10 @@ smb2_new_read_req(void **buf, unsigned int *total_len,
#ifdef CONFIG_CIFS_SMB_DIRECT
/*
* If we want to do a RDMA write, fill in and append
- * smbd_buffer_descriptor_v1 to the end of read request
+ * smb_direct_buffer_descriptor_v1 to the end of read request
*/
if (rdata && smb3_use_rdma_offload(io_parms)) {
- struct smbd_buffer_descriptor_v1 *v1;
+ struct smb_direct_buffer_descriptor_v1 *v1;
bool need_invalidate = server->dialect == SMB30_PROT_ID;
rdata->mr = smbd_register_mr(server->smbd_conn, &rdata->subreq.io_iter,
@@ -4459,8 +4459,8 @@ smb2_new_read_req(void **buf, unsigned int *total_len,
req->ReadChannelInfoOffset =
cpu_to_le16(offsetof(struct smb2_read_req, Buffer));
req->ReadChannelInfoLength =
- cpu_to_le16(sizeof(struct smbd_buffer_descriptor_v1));
- v1 = (struct smbd_buffer_descriptor_v1 *) &req->Buffer[0];
+ cpu_to_le16(sizeof(struct smb_direct_buffer_descriptor_v1));
+ v1 = (struct smb_direct_buffer_descriptor_v1 *) &req->Buffer[0];
v1->offset = cpu_to_le64(rdata->mr->mr->iova);
v1->token = cpu_to_le32(rdata->mr->mr->rkey);
v1->length = cpu_to_le32(rdata->mr->mr->length);
@@ -4968,10 +4968,10 @@ smb2_async_writev(struct cifs_io_subrequest *wdata)
#ifdef CONFIG_CIFS_SMB_DIRECT
/*
* If we want to do a server RDMA read, fill in and append
- * smbd_buffer_descriptor_v1 to the end of write request
+ * smb_direct_buffer_descriptor_v1 to the end of write request
*/
if (smb3_use_rdma_offload(io_parms)) {
- struct smbd_buffer_descriptor_v1 *v1;
+ struct smb_direct_buffer_descriptor_v1 *v1;
bool need_invalidate = server->dialect == SMB30_PROT_ID;
wdata->mr = smbd_register_mr(server->smbd_conn, &wdata->subreq.io_iter,
@@ -4990,8 +4990,8 @@ smb2_async_writev(struct cifs_io_subrequest *wdata)
req->WriteChannelInfoOffset =
cpu_to_le16(offsetof(struct smb2_write_req, Buffer));
req->WriteChannelInfoLength =
- cpu_to_le16(sizeof(struct smbd_buffer_descriptor_v1));
- v1 = (struct smbd_buffer_descriptor_v1 *) &req->Buffer[0];
+ cpu_to_le16(sizeof(struct smb_direct_buffer_descriptor_v1));
+ v1 = (struct smb_direct_buffer_descriptor_v1 *) &req->Buffer[0];
v1->offset = cpu_to_le64(wdata->mr->mr->iova);
v1->token = cpu_to_le32(wdata->mr->mr->rkey);
v1->length = cpu_to_le32(wdata->mr->mr->length);
diff --git a/fs/smb/client/smbdirect.h b/fs/smb/client/smbdirect.h
index 9c5b78a33311..a6ed8910e864 100644
--- a/fs/smb/client/smbdirect.h
+++ b/fs/smb/client/smbdirect.h
@@ -179,13 +179,6 @@ enum smbd_message_type {
SMBD_TRANSFER_DATA,
};
-/* The packet fields for a registered RDMA buffer */
-struct smbd_buffer_descriptor_v1 {
- __le64 offset;
- __le32 token;
- __le32 length;
-} __packed;
-
/* Maximum number of SGEs used by smbdirect.c in any send work request */
#define SMBDIRECT_MAX_SEND_SGE 6
--
2.34.1
^ permalink raw reply related [flat|nested] 9+ messages in thread* [PATCH 5/5] smb: server: make use of common smb_direct_buffer_descriptor_v1
2025-05-27 16:12 [PATCH 0/5] smb:common: introduce and use common smb_direct headers (step1) Stefan Metzmacher
` (3 preceding siblings ...)
2025-05-27 16:13 ` [PATCH 4/5] smb: client: make use of common smb_direct_buffer_descriptor_v1 Stefan Metzmacher
@ 2025-05-27 16:13 ` Stefan Metzmacher
4 siblings, 0 replies; 9+ messages in thread
From: Stefan Metzmacher @ 2025-05-27 16:13 UTC (permalink / raw)
To: linux-cifs
Cc: metze, Steve French, Tom Talpey, Long Li, Namjae Jeon,
Hyunchul Lee, samba-technical
Cc: Steve French <smfrench@gmail.com>
Cc: Tom Talpey <tom@talpey.com>
Cc: Long Li <longli@microsoft.com>
Cc: Namjae Jeon <linkinjeon@kernel.org>
Cc: Hyunchul Lee <hyc.lee@gmail.com>
Cc: linux-cifs@vger.kernel.org
Cc: samba-technical@lists.samba.org
Signed-off-by: Stefan Metzmacher <metze@samba.org>
---
fs/smb/server/connection.c | 4 ++--
fs/smb/server/connection.h | 8 ++++----
fs/smb/server/smb2pdu.c | 10 +++++-----
fs/smb/server/smb2pdu.h | 8 ++------
fs/smb/server/transport_rdma.c | 6 +++---
fs/smb/server/transport_rdma.h | 2 --
6 files changed, 16 insertions(+), 22 deletions(-)
diff --git a/fs/smb/server/connection.c b/fs/smb/server/connection.c
index 83764c230e9d..0f576edda6c1 100644
--- a/fs/smb/server/connection.c
+++ b/fs/smb/server/connection.c
@@ -243,7 +243,7 @@ int ksmbd_conn_write(struct ksmbd_work *work)
int ksmbd_conn_rdma_read(struct ksmbd_conn *conn,
void *buf, unsigned int buflen,
- struct smb2_buffer_desc_v1 *desc,
+ struct smb_direct_buffer_descriptor_v1 *desc,
unsigned int desc_len)
{
int ret = -EINVAL;
@@ -257,7 +257,7 @@ int ksmbd_conn_rdma_read(struct ksmbd_conn *conn,
int ksmbd_conn_rdma_write(struct ksmbd_conn *conn,
void *buf, unsigned int buflen,
- struct smb2_buffer_desc_v1 *desc,
+ struct smb_direct_buffer_descriptor_v1 *desc,
unsigned int desc_len)
{
int ret = -EINVAL;
diff --git a/fs/smb/server/connection.h b/fs/smb/server/connection.h
index 14620e147dda..f6f1952f796b 100644
--- a/fs/smb/server/connection.h
+++ b/fs/smb/server/connection.h
@@ -126,11 +126,11 @@ struct ksmbd_transport_ops {
unsigned int remote_key);
int (*rdma_read)(struct ksmbd_transport *t,
void *buf, unsigned int len,
- struct smb2_buffer_desc_v1 *desc,
+ struct smb_direct_buffer_descriptor_v1 *desc,
unsigned int desc_len);
int (*rdma_write)(struct ksmbd_transport *t,
void *buf, unsigned int len,
- struct smb2_buffer_desc_v1 *desc,
+ struct smb_direct_buffer_descriptor_v1 *desc,
unsigned int desc_len);
};
@@ -155,11 +155,11 @@ bool ksmbd_conn_lookup_dialect(struct ksmbd_conn *c);
int ksmbd_conn_write(struct ksmbd_work *work);
int ksmbd_conn_rdma_read(struct ksmbd_conn *conn,
void *buf, unsigned int buflen,
- struct smb2_buffer_desc_v1 *desc,
+ struct smb_direct_buffer_descriptor_v1 *desc,
unsigned int desc_len);
int ksmbd_conn_rdma_write(struct ksmbd_conn *conn,
void *buf, unsigned int buflen,
- struct smb2_buffer_desc_v1 *desc,
+ struct smb_direct_buffer_descriptor_v1 *desc,
unsigned int desc_len);
void ksmbd_conn_enqueue_request(struct ksmbd_work *work);
void ksmbd_conn_try_dequeue_request(struct ksmbd_work *work);
diff --git a/fs/smb/server/smb2pdu.c b/fs/smb/server/smb2pdu.c
index 8d414239b3fe..9428f9e08a93 100644
--- a/fs/smb/server/smb2pdu.c
+++ b/fs/smb/server/smb2pdu.c
@@ -6617,7 +6617,7 @@ static noinline int smb2_read_pipe(struct ksmbd_work *work)
}
static int smb2_set_remote_key_for_rdma(struct ksmbd_work *work,
- struct smb2_buffer_desc_v1 *desc,
+ struct smb_direct_buffer_descriptor_v1 *desc,
__le32 Channel,
__le16 ChannelInfoLength)
{
@@ -6653,7 +6653,7 @@ static ssize_t smb2_read_rdma_channel(struct ksmbd_work *work,
int err;
err = ksmbd_conn_rdma_write(work->conn, data_buf, length,
- (struct smb2_buffer_desc_v1 *)
+ (struct smb_direct_buffer_descriptor_v1 *)
((char *)req + le16_to_cpu(req->ReadChannelInfoOffset)),
le16_to_cpu(req->ReadChannelInfoLength));
if (err)
@@ -6724,7 +6724,7 @@ int smb2_read(struct ksmbd_work *work)
goto out;
}
err = smb2_set_remote_key_for_rdma(work,
- (struct smb2_buffer_desc_v1 *)
+ (struct smb_direct_buffer_descriptor_v1 *)
((char *)req + ch_offset),
req->Channel,
req->ReadChannelInfoLength);
@@ -6919,7 +6919,7 @@ static ssize_t smb2_write_rdma_channel(struct ksmbd_work *work,
return -ENOMEM;
ret = ksmbd_conn_rdma_read(work->conn, data_buf, length,
- (struct smb2_buffer_desc_v1 *)
+ (struct smb_direct_buffer_descriptor_v1 *)
((char *)req + le16_to_cpu(req->WriteChannelInfoOffset)),
le16_to_cpu(req->WriteChannelInfoLength));
if (ret < 0) {
@@ -6984,7 +6984,7 @@ int smb2_write(struct ksmbd_work *work)
goto out;
}
err = smb2_set_remote_key_for_rdma(work,
- (struct smb2_buffer_desc_v1 *)
+ (struct smb_direct_buffer_descriptor_v1 *)
((char *)req + ch_offset),
req->Channel,
req->WriteChannelInfoLength);
diff --git a/fs/smb/server/smb2pdu.h b/fs/smb/server/smb2pdu.h
index 17a0b18a8406..be79eeef540b 100644
--- a/fs/smb/server/smb2pdu.h
+++ b/fs/smb/server/smb2pdu.h
@@ -10,6 +10,8 @@
#include "ntlmssp.h"
#include "smbacl.h"
+#include "../common/smb_direct/smb_direct.h"
+
/*Create Action Flags*/
#define FILE_SUPERSEDED 0x00000000
#define FILE_OPENED 0x00000001
@@ -133,12 +135,6 @@ struct create_posix_rsp {
u8 SidBuffer[44];
} __packed;
-struct smb2_buffer_desc_v1 {
- __le64 offset;
- __le32 token;
- __le32 length;
-} __packed;
-
#define SMB2_0_IOCTL_IS_FSCTL 0x00000001
struct smb_sockaddr_in {
diff --git a/fs/smb/server/transport_rdma.c b/fs/smb/server/transport_rdma.c
index 4998df04ab95..642d419d9a52 100644
--- a/fs/smb/server/transport_rdma.c
+++ b/fs/smb/server/transport_rdma.c
@@ -1354,7 +1354,7 @@ static void write_done(struct ib_cq *cq, struct ib_wc *wc)
static int smb_direct_rdma_xmit(struct smb_direct_transport *t,
void *buf, int buf_len,
- struct smb2_buffer_desc_v1 *desc,
+ struct smb_direct_buffer_descriptor_v1 *desc,
unsigned int desc_len,
bool is_read)
{
@@ -1484,7 +1484,7 @@ static int smb_direct_rdma_xmit(struct smb_direct_transport *t,
static int smb_direct_rdma_write(struct ksmbd_transport *t,
void *buf, unsigned int buflen,
- struct smb2_buffer_desc_v1 *desc,
+ struct smb_direct_buffer_descriptor_v1 *desc,
unsigned int desc_len)
{
return smb_direct_rdma_xmit(smb_trans_direct_transfort(t), buf, buflen,
@@ -1493,7 +1493,7 @@ static int smb_direct_rdma_write(struct ksmbd_transport *t,
static int smb_direct_rdma_read(struct ksmbd_transport *t,
void *buf, unsigned int buflen,
- struct smb2_buffer_desc_v1 *desc,
+ struct smb_direct_buffer_descriptor_v1 *desc,
unsigned int desc_len)
{
return smb_direct_rdma_xmit(smb_trans_direct_transfort(t), buf, buflen,
diff --git a/fs/smb/server/transport_rdma.h b/fs/smb/server/transport_rdma.h
index 71909b6d8021..0fb692c40e21 100644
--- a/fs/smb/server/transport_rdma.h
+++ b/fs/smb/server/transport_rdma.h
@@ -7,8 +7,6 @@
#ifndef __KSMBD_TRANSPORT_RDMA_H__
#define __KSMBD_TRANSPORT_RDMA_H__
-#include "../common/smb_direct/smb_direct.h"
-
#define SMBD_DEFAULT_IOSIZE (8 * 1024 * 1024)
#define SMBD_MIN_IOSIZE (512 * 1024)
#define SMBD_MAX_IOSIZE (16 * 1024 * 1024)
--
2.34.1
^ permalink raw reply related [flat|nested] 9+ messages in thread