[openib-general] [PATCH 06/12] SRP: Changing ibsrpdm

Ishai Rabinovitz ishai at mellanox.co.il
Mon May 1 04:28:48 PDT 2006


Support a display of list of target from user level.

Signed-off-by: Ishai Rabinovitz <ishai at mellanox.co.il>
Index: last_stable/drivers/infiniband/ulp/srp/ib_srp.c
===================================================================
--- last_stable.orig/drivers/infiniband/ulp/srp/ib_srp.c	2006-04-21 01:13:04.000000000 +0300
+++ last_stable/drivers/infiniband/ulp/srp/ib_srp.c	2006-04-21 03:56:05.000000000 +0300
@@ -1730,6 +1730,63 @@ end:
 
 static CLASS_DEVICE_ATTR(remove_target, S_IWUSR, NULL, srp_remove_target);
 
+#define TARGET_INFO_BUF_SIZE 126
+
+static ssize_t list_targets(struct class_device *class_dev, char *buf)
+{
+	struct srp_host *host =
+		container_of(class_dev, struct srp_host, class_dev);
+	struct srp_target_port *target;
+	int printed=0, ret;
+
+	mutex_lock(&host->target_mutex);
+	list_for_each_entry(target, &host->target_list, list)
+		if (target->state == SRP_TARGET_LIVE) {
+			ret = sprintf(buf+printed,
+				"id_ext=%016llx,ioc_guid=%016llx,"
+				"dgid=%04x%04x%04x%04x%04x%04x%04x%04x,"
+				"pkey=%04x,service_id=%016llx\n",
+				(unsigned long long)
+					be64_to_cpu(target->id_ext),
+				(unsigned long long)
+					be64_to_cpu(target->ioc_guid),
+				(int) be16_to_cpu(*(__be16 *)
+					&target->path.dgid.raw[0]),
+				(int) be16_to_cpu(*(__be16 *)
+					&target->path.dgid.raw[2]),
+				(int) be16_to_cpu(*(__be16 *)
+					&target->path.dgid.raw[4]),
+				(int) be16_to_cpu(*(__be16 *)
+					&target->path.dgid.raw[6]),
+				(int) be16_to_cpu(*(__be16 *)
+					&target->path.dgid.raw[8]),
+				(int) be16_to_cpu(*(__be16 *)
+					&target->path.dgid.raw[10]),
+				(int) be16_to_cpu(*(__be16 *)
+					&target->path.dgid.raw[12]),
+				(int) be16_to_cpu(*(__be16 *)
+					&target->path.dgid.raw[14]),
+				be16_to_cpu(target->path.pkey),
+				(unsigned long long)
+					be64_to_cpu(target->service_id));
+			if (ret <= 0)
+				goto end;
+
+			printed += ret;
+
+			if (printed + TARGET_INFO_BUF_SIZE > PAGE_SIZE - 1)
+				break;
+		}
+
+	ret = printed;
+
+end:
+	mutex_unlock(&host->target_mutex);
+	return ret;
+}
+
+static CLASS_DEVICE_ATTR(list_targets, S_IRUGO, list_targets, NULL);
+
 static ssize_t show_ibdev(struct class_device *class_dev, char *buf)
 {
 	struct srp_host *host =
@@ -1789,6 +1846,8 @@ static struct srp_host *srp_add_port(str
 		goto err_class;
 	if (class_device_create_file(&host->class_dev, &class_device_attr_remove_target))
 		goto err_class;
+	if (class_device_create_file(&host->class_dev, &class_device_attr_list_targets))
+		goto err_class;
 	if (class_device_create_file(&host->class_dev, &class_device_attr_ibdev))
 		goto err_class;
 	if (class_device_create_file(&host->class_dev, &class_device_attr_port))
-- 
Ishai Rabinovitz



More information about the general mailing list