From: Alexandra Winter <wintera@linux.ibm.com>
To: "D. Wythe" <alibuda@linux.alibaba.com>,
Dust Li <dust.li@linux.alibaba.com>,
Sidraya Jayagond <sidraya@linux.ibm.com>,
Wenjia Zhang <wenjia@linux.ibm.com>,
David Miller <davem@davemloft.net>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Eric Dumazet <edumazet@google.com>,
Andrew Lunn <andrew+netdev@lunn.ch>
Cc: Julian Ruess <julianr@linux.ibm.com>,
Aswin Karuvally <aswin@linux.ibm.com>,
Halil Pasic <pasic@linux.ibm.com>,
Mahanta Jambigi <mjambigi@linux.ibm.com>,
Tony Lu <tonylu@linux.alibaba.com>,
Wen Gu <guwen@linux.alibaba.com>,
linux-rdma@vger.kernel.org, netdev@vger.kernel.org,
linux-s390@vger.kernel.org, Heiko Carstens <hca@linux.ibm.com>,
Vasily Gorbik <gor@linux.ibm.com>,
Alexander Gordeev <agordeev@linux.ibm.com>,
Christian Borntraeger <borntraeger@linux.ibm.com>,
Sven Schnelle <svens@linux.ibm.com>,
Simon Horman <horms@kernel.org>,
Eric Biggers <ebiggers@kernel.org>,
Ard Biesheuvel <ardb@kernel.org>,
Herbert Xu <herbert@gondor.apana.org.au>,
Harald Freudenberger <freude@linux.ibm.com>,
Konstantin Shkolnyy <kshk@linux.ibm.com>,
Dan Williams <dan.j.williams@intel.com>,
Dave Jiang <dave.jiang@intel.com>,
Jonathan Cameron <Jonathan.Cameron@huawei.com>,
Shannon Nelson <sln@onemain.com>,
Geert Uytterhoeven <geert@linux-m68k.org>,
Jason Gunthorpe <jgg@ziepe.ca>
Subject: [PATCH net-next v3 06/14] dibs: Define dibs loopback
Date: Thu, 18 Sep 2025 13:04:52 +0200 [thread overview]
Message-ID: <20250918110500.1731261-7-wintera@linux.ibm.com> (raw)
In-Reply-To: <20250918110500.1731261-1-wintera@linux.ibm.com>
The first stage of loopback-ism was implemented as part of the
SMC module [1]. Now that we have the dibs layer, provide access to a
dibs_loopback device to all dibs clients.
This is the first step of moving loopback-ism from net/smc/smc_loopback.*
to drivers/dibs/dibs_loopback.*. One global structure lo_dev is allocated
and added to the dibs devices. Follow-on patches will move functionality.
Same as smc_loopback, dibs_loopback is provided by a config option.
Note that there is no way to dynamically add or remove the loopback
device. That could be a future improvement.
When moving code to drivers/dibs, replace ism_ prefix with dibs_ prefix.
As this is mostly a move of existing code, copyright and authors are
unchanged.
Link: https://lore.kernel.org/lkml/20240428060738.60843-1-guwen@linux.alibaba.com/ [1]
Signed-off-by: Alexandra Winter <wintera@linux.ibm.com>
---
arch/s390/configs/debug_defconfig | 1 +
arch/s390/configs/defconfig | 1 +
drivers/dibs/Kconfig | 11 +++++
drivers/dibs/Makefile | 1 +
drivers/dibs/dibs_loopback.c | 78 +++++++++++++++++++++++++++++++
drivers/dibs/dibs_loopback.h | 38 +++++++++++++++
drivers/dibs/dibs_main.c | 11 ++++-
7 files changed, 140 insertions(+), 1 deletion(-)
create mode 100644 drivers/dibs/dibs_loopback.c
create mode 100644 drivers/dibs/dibs_loopback.h
diff --git a/arch/s390/configs/debug_defconfig b/arch/s390/configs/debug_defconfig
index 7bc54f053a3b..5a2ed07b6198 100644
--- a/arch/s390/configs/debug_defconfig
+++ b/arch/s390/configs/debug_defconfig
@@ -121,6 +121,7 @@ CONFIG_UNIX_DIAG=m
CONFIG_XFRM_USER=m
CONFIG_NET_KEY=m
CONFIG_DIBS=y
+CONFIG_DIBS_LO=y
CONFIG_SMC_DIAG=m
CONFIG_SMC_LO=y
CONFIG_INET=y
diff --git a/arch/s390/configs/defconfig b/arch/s390/configs/defconfig
index 4bf6f3311f7d..4cbdd7e2ff9f 100644
--- a/arch/s390/configs/defconfig
+++ b/arch/s390/configs/defconfig
@@ -112,6 +112,7 @@ CONFIG_UNIX_DIAG=m
CONFIG_XFRM_USER=m
CONFIG_NET_KEY=m
CONFIG_DIBS=y
+CONFIG_DIBS_LO=y
CONFIG_SMC_DIAG=m
CONFIG_SMC_LO=y
CONFIG_INET=y
diff --git a/drivers/dibs/Kconfig b/drivers/dibs/Kconfig
index 09c12f6838ad..5dc347b9b235 100644
--- a/drivers/dibs/Kconfig
+++ b/drivers/dibs/Kconfig
@@ -10,3 +10,14 @@ config DIBS
Select this option to provide the abstraction layer between
dibs devices and dibs clients like the SMC protocol.
The module name is dibs.
+
+config DIBS_LO
+ bool "intra-OS shortcut with dibs loopback"
+ depends on DIBS
+ default n
+ help
+ DIBS_LO enables the creation of an software-emulated dibs device
+ named lo which can be used for transferring data when communication
+ occurs within the same OS. This helps in convenient testing of
+ dibs clients, since dibs loopback is independent of architecture or
+ hardware.
diff --git a/drivers/dibs/Makefile b/drivers/dibs/Makefile
index 825dec431bfc..85805490c77f 100644
--- a/drivers/dibs/Makefile
+++ b/drivers/dibs/Makefile
@@ -5,3 +5,4 @@
dibs-y += dibs_main.o
obj-$(CONFIG_DIBS) += dibs.o
+dibs-$(CONFIG_DIBS_LO) += dibs_loopback.o
\ No newline at end of file
diff --git a/drivers/dibs/dibs_loopback.c b/drivers/dibs/dibs_loopback.c
new file mode 100644
index 000000000000..225514a452a8
--- /dev/null
+++ b/drivers/dibs/dibs_loopback.c
@@ -0,0 +1,78 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Functions for dibs loopback/loopback-ism device.
+ *
+ * Copyright (c) 2024, Alibaba Inc.
+ *
+ * Author: Wen Gu <guwen@linux.alibaba.com>
+ * Tony Lu <tonylu@linux.alibaba.com>
+ *
+ */
+
+#include <linux/dibs.h>
+#include <linux/slab.h>
+#include <linux/types.h>
+
+#include "dibs_loopback.h"
+
+/* global loopback device */
+static struct dibs_lo_dev *lo_dev;
+
+static void dibs_lo_dev_exit(struct dibs_lo_dev *ldev)
+{
+ dibs_dev_del(ldev->dibs);
+}
+
+static int dibs_lo_dev_probe(void)
+{
+ struct dibs_lo_dev *ldev;
+ struct dibs_dev *dibs;
+ int ret;
+
+ ldev = kzalloc(sizeof(*ldev), GFP_KERNEL);
+ if (!ldev)
+ return -ENOMEM;
+
+ dibs = dibs_dev_alloc();
+ if (!dibs) {
+ kfree(ldev);
+ return -ENOMEM;
+ }
+
+ ldev->dibs = dibs;
+
+ ret = dibs_dev_add(dibs);
+ if (ret)
+ goto err_reg;
+ lo_dev = ldev;
+ return 0;
+
+err_reg:
+ /* pairs with dibs_dev_alloc() */
+ kfree(dibs);
+ kfree(ldev);
+
+ return ret;
+}
+
+static void dibs_lo_dev_remove(void)
+{
+ if (!lo_dev)
+ return;
+
+ dibs_lo_dev_exit(lo_dev);
+ /* pairs with dibs_dev_alloc() */
+ kfree(lo_dev->dibs);
+ kfree(lo_dev);
+ lo_dev = NULL;
+}
+
+int dibs_loopback_init(void)
+{
+ return dibs_lo_dev_probe();
+}
+
+void dibs_loopback_exit(void)
+{
+ dibs_lo_dev_remove();
+}
diff --git a/drivers/dibs/dibs_loopback.h b/drivers/dibs/dibs_loopback.h
new file mode 100644
index 000000000000..fd03b6333a24
--- /dev/null
+++ b/drivers/dibs/dibs_loopback.h
@@ -0,0 +1,38 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * dibs loopback (aka loopback-ism) device structure definitions.
+ *
+ * Copyright (c) 2024, Alibaba Inc.
+ *
+ * Author: Wen Gu <guwen@linux.alibaba.com>
+ * Tony Lu <tonylu@linux.alibaba.com>
+ *
+ */
+
+#ifndef _DIBS_LOOPBACK_H
+#define _DIBS_LOOPBACK_H
+
+#include <linux/dibs.h>
+#include <linux/types.h>
+#include <linux/wait.h>
+
+#if IS_ENABLED(CONFIG_DIBS_LO)
+
+struct dibs_lo_dev {
+ struct dibs_dev *dibs;
+};
+
+int dibs_loopback_init(void);
+void dibs_loopback_exit(void);
+#else
+static inline int dibs_loopback_init(void)
+{
+ return 0;
+}
+
+static inline void dibs_loopback_exit(void)
+{
+}
+#endif
+
+#endif /* _DIBS_LOOPBACK_H */
diff --git a/drivers/dibs/dibs_main.c b/drivers/dibs/dibs_main.c
index 2f420e077417..a7e33be36158 100644
--- a/drivers/dibs/dibs_main.c
+++ b/drivers/dibs/dibs_main.c
@@ -15,6 +15,8 @@
#include <linux/err.h>
#include <linux/dibs.h>
+#include "dibs_loopback.h"
+
MODULE_DESCRIPTION("Direct Internal Buffer Sharing class");
MODULE_LICENSE("GPL");
@@ -96,14 +98,21 @@ EXPORT_SYMBOL_GPL(dibs_dev_del);
static int __init dibs_init(void)
{
+ int rc;
+
memset(clients, 0, sizeof(clients));
max_client = 0;
- return 0;
+ rc = dibs_loopback_init();
+ if (rc)
+ pr_err("%s fails with %d\n", __func__, rc);
+
+ return rc;
}
static void __exit dibs_exit(void)
{
+ dibs_loopback_exit();
}
module_init(dibs_init);
--
2.48.1
next prev parent reply other threads:[~2025-09-18 11:05 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-18 11:04 [PATCH net-next v3 00/14] dibs - Direct Internal Buffer Sharing Alexandra Winter
2025-09-18 11:04 ` [PATCH net-next v3 01/14] net/smc: Remove error handling of unregister_dmb() Alexandra Winter
2025-09-18 11:04 ` [PATCH net-next v3 02/14] net/smc: Decouple sf and attached send_buf in smc_loopback Alexandra Winter
2025-09-18 11:04 ` [PATCH net-next v3 03/14] dibs: Create drivers/dibs Alexandra Winter
2025-09-18 11:04 ` [PATCH net-next v3 04/14] dibs: Register smc as dibs_client Alexandra Winter
2025-09-18 11:04 ` [PATCH net-next v3 05/14] dibs: Register ism as dibs device Alexandra Winter
2025-09-18 11:04 ` Alexandra Winter [this message]
2025-09-18 11:04 ` [PATCH net-next v3 07/14] dibs: Define dibs_client_ops and dibs_dev_ops Alexandra Winter
2025-09-18 11:04 ` [PATCH net-next v3 08/14] dibs: Move struct device to dibs_dev Alexandra Winter
2025-09-18 11:04 ` [PATCH net-next v3 09/14] dibs: Create class dibs Alexandra Winter
2025-09-18 11:04 ` [PATCH net-next v3 10/14] dibs: Local gid for dibs devices Alexandra Winter
2025-09-18 11:04 ` [PATCH net-next v3 11/14] dibs: Move vlan support to dibs_dev_ops Alexandra Winter
2025-09-18 11:04 ` [PATCH net-next v3 12/14] dibs: Move query_remote_gid() " Alexandra Winter
2025-09-18 11:04 ` [PATCH net-next v3 13/14] dibs: Move data path to dibs layer Alexandra Winter
2025-09-24 9:07 ` [PATCH net-next v3 13/14] dibs: Move data path to dibs layer: manual merge Matthieu Baerts
2025-09-24 17:34 ` Alexandra Winter
2025-09-25 6:00 ` Sidraya Jayagond
2025-09-25 17:57 ` Jakub Kicinski
2025-09-29 18:29 ` Matthieu Baerts
2025-09-18 11:05 ` [PATCH net-next v3 14/14] dibs: Move event handling to dibs layer Alexandra Winter
2025-09-23 9:20 ` [PATCH net-next v3 00/14] dibs - Direct Internal Buffer Sharing patchwork-bot+netdevbpf
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250918110500.1731261-7-wintera@linux.ibm.com \
--to=wintera@linux.ibm.com \
--cc=Jonathan.Cameron@huawei.com \
--cc=agordeev@linux.ibm.com \
--cc=alibuda@linux.alibaba.com \
--cc=andrew+netdev@lunn.ch \
--cc=ardb@kernel.org \
--cc=aswin@linux.ibm.com \
--cc=borntraeger@linux.ibm.com \
--cc=dan.j.williams@intel.com \
--cc=dave.jiang@intel.com \
--cc=davem@davemloft.net \
--cc=dust.li@linux.alibaba.com \
--cc=ebiggers@kernel.org \
--cc=edumazet@google.com \
--cc=freude@linux.ibm.com \
--cc=geert@linux-m68k.org \
--cc=gor@linux.ibm.com \
--cc=guwen@linux.alibaba.com \
--cc=hca@linux.ibm.com \
--cc=herbert@gondor.apana.org.au \
--cc=horms@kernel.org \
--cc=jgg@ziepe.ca \
--cc=julianr@linux.ibm.com \
--cc=kshk@linux.ibm.com \
--cc=kuba@kernel.org \
--cc=linux-rdma@vger.kernel.org \
--cc=linux-s390@vger.kernel.org \
--cc=mjambigi@linux.ibm.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=pasic@linux.ibm.com \
--cc=sidraya@linux.ibm.com \
--cc=sln@onemain.com \
--cc=svens@linux.ibm.com \
--cc=tonylu@linux.alibaba.com \
--cc=wenjia@linux.ibm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.