mirror of
https://github.com/torvalds/linux.git
synced 2026-04-18 06:44:00 -04:00
dibs: Create class dibs
Create '/sys/class/dibs' to represent multiple kinds of dibs devices in sysfs. Show s390/ism devices as well as dibs_loopback devices. Show attribute fabric_id using dibs_ops.get_fabric_id(). This can help users understand which dibs devices are connected to the same fabric in different systems and which dibs devices are loopback devices (fabric_id 0xffff) Instead of using the same name as the pci device, give the ism devices their own readable names based on uid or fid from the HW definition. smc_loopback was never visible in sysfs. dibs_loopback is now represented as a virtual device. For the SMC feature "software defined pnet-id" either the ib device name or the PCI-ID (actually the parent device name) can be used for SMC-R entries. Mimic this behaviour for SMC-D, and check the parent device name as well. So device name or PCI-ID can be used for ism and device name can be used for dibs-loopback. Note that this: IB_DEVICE_NAME_MAX - 1 == smc_pnet_policy.[SMC_PNETID_IBNAME].len is the length of smcd_name. Future SW-pnetid cleanup patches to could use a meaningful define, but that would touch too much unrelated code here. Examples: --------- ism before: > ls /sys/bus/pci/devices/0000:00:00.0/0000:00:00.0 uevent ism now: > ls /sys/bus/pci/devices/0000:00:00.0/dibs/ism30 device -> ../../../0000:00:00.0/ fabric_id subsystem -> ../../../../../class/dibs/ uevent dibs loopback: > ls /sys/devices/virtual/dibs/lo/ fabric_id subsystem -> ../../../../class/dibs/ uevent dibs class: > ls -l /sys/class/dibs/ ism30 -> ../../devices/pci0000:00/0000:00:00.0/dibs/ism30/ lo -> ../../devices/virtual/dibs/lo/ For comparison: > ls -l /sys/class/net/ enc8410 -> ../../devices/qeth/0.0.8410/net/enc8410/ ens1693 -> ../../devices/pci0001:00/0001:00:00.0/net/ens1693/ lo -> ../../devices/virtual/net/lo/ Signed-off-by: Julian Ruess <julianr@linux.ibm.com> Co-developed-by: Alexandra Winter <wintera@linux.ibm.com> Signed-off-by: Alexandra Winter <wintera@linux.ibm.com> Link: https://patch.msgid.link/20250918110500.1731261-10-wintera@linux.ibm.com Signed-off-by: Paolo Abeni <pabeni@redhat.com>
This commit is contained in:
committed by
Paolo Abeni
parent
845c334a01
commit
8047373498
@@ -20,6 +20,8 @@
|
||||
MODULE_DESCRIPTION("Direct Internal Buffer Sharing class");
|
||||
MODULE_LICENSE("GPL");
|
||||
|
||||
static struct class *dibs_class;
|
||||
|
||||
/* use an array rather a list for fast mapping: */
|
||||
static struct dibs_client *clients[MAX_DIBS_CLIENTS];
|
||||
static u8 max_client;
|
||||
@@ -105,12 +107,35 @@ struct dibs_dev *dibs_dev_alloc(void)
|
||||
if (!dibs)
|
||||
return dibs;
|
||||
dibs->dev.release = dibs_dev_release;
|
||||
dibs->dev.class = dibs_class;
|
||||
device_initialize(&dibs->dev);
|
||||
|
||||
return dibs;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(dibs_dev_alloc);
|
||||
|
||||
static ssize_t fabric_id_show(struct device *dev, struct device_attribute *attr,
|
||||
char *buf)
|
||||
{
|
||||
struct dibs_dev *dibs;
|
||||
u16 fabric_id;
|
||||
|
||||
dibs = container_of(dev, struct dibs_dev, dev);
|
||||
fabric_id = dibs->ops->get_fabric_id(dibs);
|
||||
|
||||
return sysfs_emit(buf, "0x%04x\n", fabric_id);
|
||||
}
|
||||
static DEVICE_ATTR_RO(fabric_id);
|
||||
|
||||
static struct attribute *dibs_dev_attrs[] = {
|
||||
&dev_attr_fabric_id.attr,
|
||||
NULL,
|
||||
};
|
||||
|
||||
static const struct attribute_group dibs_dev_attr_group = {
|
||||
.attrs = dibs_dev_attrs,
|
||||
};
|
||||
|
||||
int dibs_dev_add(struct dibs_dev *dibs)
|
||||
{
|
||||
int i, ret;
|
||||
@@ -119,6 +144,11 @@ int dibs_dev_add(struct dibs_dev *dibs)
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
ret = sysfs_create_group(&dibs->dev.kobj, &dibs_dev_attr_group);
|
||||
if (ret) {
|
||||
dev_err(&dibs->dev, "sysfs_create_group failed for dibs_dev\n");
|
||||
goto err_device_del;
|
||||
}
|
||||
mutex_lock(&dibs_dev_list.mutex);
|
||||
mutex_lock(&clients_lock);
|
||||
for (i = 0; i < max_client; ++i) {
|
||||
@@ -130,6 +160,11 @@ int dibs_dev_add(struct dibs_dev *dibs)
|
||||
mutex_unlock(&dibs_dev_list.mutex);
|
||||
|
||||
return 0;
|
||||
|
||||
err_device_del:
|
||||
device_del(&dibs->dev);
|
||||
return ret;
|
||||
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(dibs_dev_add);
|
||||
|
||||
@@ -158,6 +193,10 @@ static int __init dibs_init(void)
|
||||
memset(clients, 0, sizeof(clients));
|
||||
max_client = 0;
|
||||
|
||||
dibs_class = class_create("dibs");
|
||||
if (IS_ERR(&dibs_class))
|
||||
return PTR_ERR(&dibs_class);
|
||||
|
||||
rc = dibs_loopback_init();
|
||||
if (rc)
|
||||
pr_err("%s fails with %d\n", __func__, rc);
|
||||
@@ -168,6 +207,7 @@ static int __init dibs_init(void)
|
||||
static void __exit dibs_exit(void)
|
||||
{
|
||||
dibs_loopback_exit();
|
||||
class_destroy(dibs_class);
|
||||
}
|
||||
|
||||
module_init(dibs_init);
|
||||
|
||||
Reference in New Issue
Block a user