From: Stefan Metzmacher Date: Fri, 18 Jul 2025 16:44:15 +0000 (+0200) Subject: smb: smbdirect: introduce the basic smbdirect.ko X-Git-Tag: v7.1-rc1~128^2~84 X-Git-Url: http://git.ipfire.org/gitweb/?a=commitdiff_plain;h=f9a804da479cc41172f1039b4ffde06a09920506;p=thirdparty%2Fkernel%2Flinux.git smb: smbdirect: introduce the basic smbdirect.ko This exports the functions needed by cifs.ko and ksmbd.ko. It doesn't yet provide a generic socket layer, but it is a good start to introduce that on top. It will be much easier after Davids refactoring using MSG_SPLICE_PAGES, will make it easier to use the socket layer without an additional copy. Cc: Steve French Cc: Tom Talpey Cc: Long Li Cc: Namjae Jeon Cc: David Howells Cc: linux-cifs@vger.kernel.org Cc: samba-technical@lists.samba.org Signed-off-by: Stefan Metzmacher Acked-by: Namjae Jeon Signed-off-by: Steve French --- diff --git a/fs/smb/Kconfig b/fs/smb/Kconfig index 85f7ad5fbc5e7..b4b2cfdc2a6bf 100644 --- a/fs/smb/Kconfig +++ b/fs/smb/Kconfig @@ -4,6 +4,7 @@ source "fs/smb/client/Kconfig" source "fs/smb/server/Kconfig" +source "fs/smb/common/smbdirect/Kconfig" config SMBFS tristate diff --git a/fs/smb/common/Makefile b/fs/smb/common/Makefile index 9e0730a385fb1..e6ee65c31b5dc 100644 --- a/fs/smb/common/Makefile +++ b/fs/smb/common/Makefile @@ -4,3 +4,4 @@ # obj-$(CONFIG_SMBFS) += cifs_md4.o +obj-$(CONFIG_SMB_COMMON_SMBDIRECT) += smbdirect/ diff --git a/fs/smb/common/smbdirect/Kconfig b/fs/smb/common/smbdirect/Kconfig new file mode 100644 index 0000000000000..a46a2e6ec87ad --- /dev/null +++ b/fs/smb/common/smbdirect/Kconfig @@ -0,0 +1,9 @@ +# SPDX-License-Identifier: GPL-2.0-or-later +# +# smbdirect configuration + +config SMB_COMMON_SMBDIRECT + def_tristate n + depends on INFINIBAND && INFINIBAND_ADDR_TRANS + depends on m || INFINIBAND=y + select SG_POOL diff --git a/fs/smb/common/smbdirect/Makefile b/fs/smb/common/smbdirect/Makefile new file mode 100644 index 0000000000000..b41271facfc35 --- /dev/null +++ b/fs/smb/common/smbdirect/Makefile @@ -0,0 +1,17 @@ +# SPDX-License-Identifier: GPL-2.0-or-later +# +# Makefile for smbdirect support +# + +obj-$(CONFIG_SMB_COMMON_SMBDIRECT) += smbdirect.o + +smbdirect-y := \ + smbdirect_socket.o \ + smbdirect_connection.o \ + smbdirect_mr.o \ + smbdirect_rw.o \ + smbdirect_debug.o \ + smbdirect_connect.o \ + smbdirect_listen.o \ + smbdirect_accept.o \ + smbdirect_main.o diff --git a/fs/smb/common/smbdirect/smbdirect_internal.h b/fs/smb/common/smbdirect/smbdirect_internal.h index f8432c8c1a5f8..901540d0cbbff 100644 --- a/fs/smb/common/smbdirect/smbdirect_internal.h +++ b/fs/smb/common/smbdirect/smbdirect_internal.h @@ -13,6 +13,15 @@ #include "smbdirect.h" #include "smbdirect_pdu.h" #include "smbdirect_public.h" + +#include + +struct smbdirect_module_state { + struct mutex mutex; +}; + +extern struct smbdirect_module_state smbdirect_globals; + #include "smbdirect_socket.h" #ifdef SMBDIRECT_USE_INLINE_C_FILES diff --git a/fs/smb/common/smbdirect/smbdirect_main.c b/fs/smb/common/smbdirect/smbdirect_main.c new file mode 100644 index 0000000000000..c61ae8d7f4f02 --- /dev/null +++ b/fs/smb/common/smbdirect/smbdirect_main.c @@ -0,0 +1,40 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Copyright (c) 2025, Stefan Metzmacher + */ + +#include "smbdirect_internal.h" +#include + +struct smbdirect_module_state smbdirect_globals = { + .mutex = __MUTEX_INITIALIZER(smbdirect_globals.mutex), +}; + +static __init int smbdirect_module_init(void) +{ + pr_notice("subsystem loading...\n"); + mutex_lock(&smbdirect_globals.mutex); + + /* TODO... */ + + mutex_unlock(&smbdirect_globals.mutex); + pr_notice("subsystem loaded\n"); + return 0; +} + +static __exit void smbdirect_module_exit(void) +{ + pr_notice("subsystem unloading...\n"); + mutex_lock(&smbdirect_globals.mutex); + + /* TODO... */ + + mutex_unlock(&smbdirect_globals.mutex); + pr_notice("subsystem unloaded\n"); +} + +module_init(smbdirect_module_init); +module_exit(smbdirect_module_exit); + +MODULE_DESCRIPTION("smbdirect subsystem"); +MODULE_LICENSE("GPL");