Commit d324a2ca authored by Alexandra Winter's avatar Alexandra Winter Committed by Paolo Abeni
Browse files

dibs: Register smc as dibs_client



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: default avatarAlexandra Winter <wintera@linux.ibm.com>
Reviewed-by: default avatarJulian Ruess <julianr@linux.ibm.com>
Link: https://patch.msgid.link/20250918110500.1731261-5-wintera@linux.ibm.com


Signed-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
parent 35758b00
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -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
+1 −0
Original line number Diff line number Diff line
@@ -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
+35 −0
Original line number Diff line number Diff line
@@ -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)
{
+23 −0
Original line number Diff line number Diff line
@@ -33,10 +33,33 @@
 * 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 */
+1 −1
Original line number Diff line number Diff line
# 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
Loading