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

dibs: Local gid for dibs devices

Define a uuid_t GID attribute to identify a dibs device.

SMC uses 64 Bit and 128 Bit Global Identifiers (GIDs) per device, that
need to be sent via the SMC protocol. Because the smc code uses integers,
network endianness and host endianness need to be considered. Avoid this
in the dibs layer by using uuid_t byte arrays. Future patches could change
SMC to use uuid_t. For now conversion helper functions are introduced.

ISM devices provide 64 Bit GIDs. Map them to dibs uuid_t GIDs like this:
 _________________________________________
| 64 Bit ISM-vPCI GID | 00000000_00000000 |
 -----------------------------------------
If interpreted as UUID [1], this would be interpreted as the UIID variant,
that is reserved for NCS backward compatibility. So it will not collide
with UUIDs that were generated according to the standard.

smc_loopback already uses version 4 UUIDs as 128 Bit GIDs, move that to
dibs loopback. A temporary change to smc_lo_query_rgid() is required,
that will be moved to dibs_loopback with a follow-on patch.

Provide gid of a dibs device as sysfs read-only attribute.

Link: https://datatracker.ietf.org/doc/html/rfc4122

 [1]
Signed-off-by: default avatarAlexandra Winter <wintera@linux.ibm.com>
Reviewed-by: default avatarJulian Ruess <julianr@linux.ibm.com>
Reviewed-by: default avatarMahanta Jambigi <mjambigi@linux.ibm.com>
Link: https://patch.msgid.link/20250918110500.1731261-11-wintera@linux.ibm.com


Signed-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
parent 80473734
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -46,6 +46,7 @@ static int dibs_lo_dev_probe(void)

	ldev->dibs = dibs;
	dibs->drv_priv = ldev;
	uuid_gen(&dibs->gid);
	dibs->ops = &dibs_lo_ops;

	dibs->dev.parent = NULL;
+12 −0
Original line number Diff line number Diff line
@@ -114,6 +114,17 @@ struct dibs_dev *dibs_dev_alloc(void)
}
EXPORT_SYMBOL_GPL(dibs_dev_alloc);

static ssize_t gid_show(struct device *dev, struct device_attribute *attr,
			char *buf)
{
	struct dibs_dev *dibs;

	dibs = container_of(dev, struct dibs_dev, dev);

	return sysfs_emit(buf, "%pUb\n", &dibs->gid);
}
static DEVICE_ATTR_RO(gid);

static ssize_t fabric_id_show(struct device *dev, struct device_attribute *attr,
			      char *buf)
{
@@ -128,6 +139,7 @@ static ssize_t fabric_id_show(struct device *dev, struct device_attribute *attr,
static DEVICE_ATTR_RO(fabric_id);

static struct attribute *dibs_dev_attrs[] = {
	&dev_attr_gid.attr,
	&dev_attr_fabric_id.attr,
	NULL,
};
+9 −0
Original line number Diff line number Diff line
@@ -67,6 +67,15 @@ union ism_reg_ieq {
	} response;
} __aligned(16);

/* ISM-vPCI devices provide 64 Bit GIDs
 * Map them to ISM UUID GIDs like this:
 *  _________________________________________
 * | 64 Bit ISM-vPCI GID | 00000000_00000000 |
 *  -----------------------------------------
 * This will be interpreted as a UIID variant, that is reserved
 * for NCS backward compatibility. So it will not collide with
 * proper UUIDs.
 */
union ism_read_gid {
	struct {
		struct ism_req_hdr hdr;
+9 −21
Original line number Diff line number Diff line
@@ -272,8 +272,9 @@ static int unregister_ieq(struct ism_dev *ism)
	return 0;
}

static int ism_read_local_gid(struct ism_dev *ism)
static int ism_read_local_gid(struct dibs_dev *dibs)
{
	struct ism_dev *ism = dibs->drv_priv;
	union ism_read_gid cmd;
	int ret;

@@ -285,7 +286,8 @@ static int ism_read_local_gid(struct ism_dev *ism)
	if (ret)
		goto out;

	ism->local_gid = cmd.response.gid;
	memset(&dibs->gid, 0, sizeof(dibs->gid));
	memcpy(&dibs->gid, &cmd.response.gid, sizeof(cmd.response.gid));
out:
	return ret;
}
@@ -563,10 +565,6 @@ static int ism_dev_init(struct ism_dev *ism)
	if (ret)
		goto unreg_sba;

	ret = ism_read_local_gid(ism);
	if (ret)
		goto unreg_ieq;

	if (!ism_add_vlan_id(ism, ISM_RESERVED_VLANID))
		/* hardware is V2 capable */
		ism_v2_capable = true;
@@ -588,8 +586,6 @@ static int ism_dev_init(struct ism_dev *ism)
	query_info(ism);
	return 0;

unreg_ieq:
	unregister_ieq(ism);
unreg_sba:
	unregister_sba(ism);
free_irq:
@@ -672,6 +668,11 @@ static int ism_probe(struct pci_dev *pdev, const struct pci_device_id *id)
	if (ret)
		goto err_dibs;

	/* after ism_dev_init() we can call ism function to set gid */
	ret = ism_read_local_gid(dibs);
	if (ret)
		goto err_ism;

	dibs->dev.parent = &pdev->dev;

	zdev = to_zpci(pdev);
@@ -841,18 +842,6 @@ static int smcd_supports_v2(void)
	return ism_v2_capable;
}

static u64 ism_get_local_gid(struct ism_dev *ism)
{
	return ism->local_gid;
}

static void smcd_get_local_gid(struct smcd_dev *smcd,
			       struct smcd_gid *smcd_gid)
{
	smcd_gid->gid = ism_get_local_gid(smcd->priv);
	smcd_gid->gid_ext = 0;
}

static const struct smcd_ops ism_smcd_ops = {
	.query_remote_gid = smcd_query_rgid,
	.register_dmb = smcd_register_dmb,
@@ -864,7 +853,6 @@ static const struct smcd_ops ism_smcd_ops = {
	.signal_event = smcd_signal_ieq,
	.move_data = smcd_move,
	.supports_v2 = smcd_supports_v2,
	.get_local_gid = smcd_get_local_gid,
};

const struct smcd_ops *ism_get_smcd_ops(void)
+3 −0
Original line number Diff line number Diff line
@@ -10,6 +10,8 @@
#define _DIBS_H

#include <linux/device.h>
#include <linux/uuid.h>

/* DIBS - Direct Internal Buffer Sharing - concept
 * -----------------------------------------------
 * In the case of multiple system sharing the same hardware, dibs fabrics can
@@ -138,6 +140,7 @@ struct dibs_dev {
	struct device dev;
	/* To be filled by device driver, before calling dibs_dev_add(): */
	const struct dibs_dev_ops *ops;
	uuid_t gid;
	/* priv pointer for device driver */
	void *drv_priv;

Loading