]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
dibs: Register smc as dibs_client
authorAlexandra Winter <wintera@linux.ibm.com>
Thu, 18 Sep 2025 11:04:50 +0000 (13:04 +0200)
committerPaolo Abeni <pabeni@redhat.com>
Tue, 23 Sep 2025 09:13:21 +0000 (11:13 +0200)
Formally register smc as dibs client. Functionality will be moved by
follow-on patches from ism_client to dibs_client until eventually
ism_client can be removed.
As DIBS is only a shim layer without any dependencies, we can depend SMC
on DIBS without adding indirect dependencies. A follow-on patch will
remove dependency of SMC on ISM.

Signed-off-by: Alexandra Winter <wintera@linux.ibm.com>
Reviewed-by: Julian Ruess <julianr@linux.ibm.com>
Link: https://patch.msgid.link/20250918110500.1731261-5-wintera@linux.ibm.com
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
arch/s390/configs/debug_defconfig
arch/s390/configs/defconfig
drivers/dibs/dibs_main.c
include/linux/dibs.h
net/smc/Kconfig
net/smc/smc_ism.c

index 5e616bc988ac355b94d87c1153c09d3f9bfffc89..7bc54f053a3beaf888acc2122e201d0cb7e296a8 100644 (file)
@@ -120,6 +120,7 @@ CONFIG_UNIX=y
 CONFIG_UNIX_DIAG=m
 CONFIG_XFRM_USER=m
 CONFIG_NET_KEY=m
+CONFIG_DIBS=y
 CONFIG_SMC_DIAG=m
 CONFIG_SMC_LO=y
 CONFIG_INET=y
index 094599cdaf4d9b8473dad2cdcf6d3fca165cca90..4bf6f3311f7d2c5d9e5628d21beea4528839d72b 100644 (file)
@@ -111,6 +111,7 @@ CONFIG_UNIX=y
 CONFIG_UNIX_DIAG=m
 CONFIG_XFRM_USER=m
 CONFIG_NET_KEY=m
+CONFIG_DIBS=y
 CONFIG_SMC_DIAG=m
 CONFIG_SMC_LO=y
 CONFIG_INET=y
index 68e189932fcf36d82e80eb0793fe40eba22dff57..a5d2be9c324674ddac2f26da8083e1df25b45350 100644 (file)
@@ -20,6 +20,41 @@ MODULE_LICENSE("GPL");
 /* use an array rather a list for fast mapping: */
 static struct dibs_client *clients[MAX_DIBS_CLIENTS];
 static u8 max_client;
+static DEFINE_MUTEX(clients_lock);
+
+int dibs_register_client(struct dibs_client *client)
+{
+       int i, rc = -ENOSPC;
+
+       mutex_lock(&clients_lock);
+       for (i = 0; i < MAX_DIBS_CLIENTS; ++i) {
+               if (!clients[i]) {
+                       clients[i] = client;
+                       client->id = i;
+                       if (i == max_client)
+                               max_client++;
+                       rc = 0;
+                       break;
+               }
+       }
+       mutex_unlock(&clients_lock);
+
+       return rc;
+}
+EXPORT_SYMBOL_GPL(dibs_register_client);
+
+int dibs_unregister_client(struct dibs_client *client)
+{
+       int rc = 0;
+
+       mutex_lock(&clients_lock);
+       clients[client->id] = NULL;
+       if (client->id + 1 == max_client)
+               max_client--;
+       mutex_unlock(&clients_lock);
+       return rc;
+}
+EXPORT_SYMBOL_GPL(dibs_unregister_client);
 
 static int __init dibs_init(void)
 {
index 3f4175aaa732f444876505a19eddb6c8849960cd..7bedeaf52c1bd3c3a89128a518f99aa8dd3e3160 100644 (file)
  * clients.
  */
 
+/* DIBS client
+ * -----------
+ */
 #define MAX_DIBS_CLIENTS       8
 
 struct dibs_client {
+       /* client name for logging and debugging purposes */
        const char *name;
+       /* client index - provided and used by dibs layer */
+       u8 id;
 };
 
+/* Functions to be called by dibs clients:
+ */
+/**
+ * dibs_register_client() - register a client with dibs layer
+ * @client: this client
+ *
+ * Return: zero on success.
+ */
+int dibs_register_client(struct dibs_client *client);
+/**
+ * dibs_unregister_client() - unregister a client with dibs layer
+ * @client: this client
+ *
+ * Return: zero on success.
+ */
+int dibs_unregister_client(struct dibs_client *client);
+
 #endif /* _DIBS_H */
index ba5e6a2dd2fd768f7aaab2b8501e0cabe7fedbec..40dd60c1d23f30e50abbde40bbc1582319eb2f8d 100644 (file)
@@ -1,7 +1,7 @@
 # SPDX-License-Identifier: GPL-2.0-only
 config SMC
        tristate "SMC socket protocol family"
-       depends on INET && INFINIBAND
+       depends on INET && INFINIBAND && DIBS
        depends on m || ISM != m
        help
          SMC-R provides a "sockets over RDMA" solution making use of
index 503a9f93b392d4390f63f642f45f92b882261627..a7a965e3c0ce61feb63e2c9951c3afec17be6f2c 100644 (file)
@@ -18,6 +18,7 @@
 #include "smc_pnet.h"
 #include "smc_netlink.h"
 #include "linux/ism.h"
+#include "linux/dibs.h"
 
 struct smcd_dev_list smcd_dev_list = {
        .list = LIST_HEAD_INIT(smcd_dev_list.list),
@@ -42,6 +43,9 @@ static struct ism_client smc_ism_client = {
        .handle_irq = smcd_handle_irq,
 };
 #endif
+static struct dibs_client smc_dibs_client = {
+       .name = "SMC-D",
+};
 
 static void smc_ism_create_system_eid(void)
 {
@@ -623,11 +627,13 @@ int smc_ism_init(void)
 #if IS_ENABLED(CONFIG_ISM)
        rc = ism_register_client(&smc_ism_client);
 #endif
+       rc = dibs_register_client(&smc_dibs_client);
        return rc;
 }
 
 void smc_ism_exit(void)
 {
+       dibs_unregister_client(&smc_dibs_client);
 #if IS_ENABLED(CONFIG_ISM)
        ism_unregister_client(&smc_ism_client);
 #endif