[openib-general] [PATCH] IB/srp: add port/device attributes

Michael S. Tsirkin mst at mellanox.co.il
Sun Aug 13 04:55:04 PDT 2006


Hi, Roland!

There does not, at the moment, seem to exist a way to find out
which HCA port the specific SRP host is connected through.

This is needed to for things like availability or balancing
where we want to connect to the same target through multiple distinct
ports.

While not really a bugfix, maybe the following is small enough for 2.6.18?
We will use it in srptools that will ship with OFED.

Signed-off-by: Ishai Rabinovitz <ishai at mellanox.co.il>
Signed-off-by: Michael S. Tsirkin <mst at mellanox.co.il>

Index: source/drivers/infiniband/ulp/srp/ib_srp.c
===================================================================
--- source.orig/drivers/infiniband/ulp/srp/ib_srp.c	2006-08-13 13:34:23.000000000 +0300
+++ source/drivers/infiniband/ulp/srp/ib_srp.c	2006-08-13 14:02:56.000000000 +0300
@@ -1461,12 +1461,29 @@ static ssize_t show_zero_req_lim(struct 
 	return sprintf(buf, "%d\n", target->zero_req_lim);
 }
 
+static ssize_t show_srp_port(struct class_device *cdev, char *buf)
+{
+	struct srp_target_port *target = host_to_target(class_to_shost(cdev));
+
+	return sprintf(buf, "%d\n", target->srp_host->port);
+}
+
+static ssize_t show_srp_device(struct class_device *cdev, char *buf)
+{
+	struct srp_target_port *target = host_to_target(class_to_shost(cdev));
+
+	return sprintf(buf, "%s\n", target->srp_host->dev->dev->name);
+}
+
+
 static CLASS_DEVICE_ATTR(id_ext,	S_IRUGO, show_id_ext,		NULL);
 static CLASS_DEVICE_ATTR(ioc_guid,	S_IRUGO, show_ioc_guid,		NULL);
 static CLASS_DEVICE_ATTR(service_id,	S_IRUGO, show_service_id,	NULL);
 static CLASS_DEVICE_ATTR(pkey,		S_IRUGO, show_pkey,		NULL);
 static CLASS_DEVICE_ATTR(dgid,		S_IRUGO, show_dgid,		NULL);
 static CLASS_DEVICE_ATTR(zero_req_lim,	S_IRUGO, show_zero_req_lim,	NULL);
+static CLASS_DEVICE_ATTR(srp_port,	S_IRUGO, show_srp_port,		NULL);
+static CLASS_DEVICE_ATTR(srp_device,	S_IRUGO, show_srp_device,	NULL);
 
 static struct class_device_attribute *srp_host_attrs[] = {
 	&class_device_attr_id_ext,
@@ -1475,6 +1492,8 @@ static struct class_device_attribute *sr
 	&class_device_attr_pkey,
 	&class_device_attr_dgid,
 	&class_device_attr_zero_req_lim,
+	&class_device_attr_srp_port,
+	&class_device_attr_srp_device,
 	NULL
 };
 

-- 
MST




More information about the general mailing list