smb: smbdirect: introduce smbdirect_socket_init()

This will make it easier to keep the initialization
in a single place.

For now it's an __always_inline function as we only
share the header files. Once move to common functions
we'll have a dedicated smbdirect.ko that exports functions...

Cc: Steve French <smfrench@gmail.com>
Cc: Tom Talpey <tom@talpey.com>
Cc: Long Li <longli@microsoft.com>
Acked-by: Namjae Jeon <linkinjeon@kernel.org>
Cc: linux-cifs@vger.kernel.org
Cc: samba-technical@lists.samba.org
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Signed-off-by: Steve French <stfrench@microsoft.com>
This commit is contained in:
Stefan Metzmacher 2025-08-08 15:08:33 +02:00 committed by Steve French
parent 371d3ab51c
commit 17e1d07430

View File

@ -136,6 +136,24 @@ struct smbdirect_socket {
} recv_io;
};
static __always_inline void smbdirect_socket_init(struct smbdirect_socket *sc)
{
/*
* This also sets status = SMBDIRECT_SOCKET_CREATED
*/
BUILD_BUG_ON(SMBDIRECT_SOCKET_CREATED != 0);
memset(sc, 0, sizeof(*sc));
init_waitqueue_head(&sc->status_wait);
INIT_LIST_HEAD(&sc->recv_io.free.list);
spin_lock_init(&sc->recv_io.free.lock);
INIT_LIST_HEAD(&sc->recv_io.reassembly.list);
spin_lock_init(&sc->recv_io.reassembly.lock);
init_waitqueue_head(&sc->recv_io.reassembly.wait_queue);
}
struct smbdirect_send_io {
struct smbdirect_socket *socket;
struct ib_cqe cqe;