IB/srp: Export sgid to sysfs
authorBart Van Assche <bvanassche@acm.org>
Sat, 26 Oct 2013 12:38:12 +0000 (14:38 +0200)
committerRoland Dreier <roland@purestorage.com>
Fri, 8 Nov 2013 22:43:16 +0000 (14:43 -0800)
On an initiator system with multiple IB ports it is not yet possible
to figure out what the originating port of an SRP connection is. Hence
make the source GID available in sysfs.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Acked-by: David Dillow <dillowda@ornl.gov>
Signed-off-by: Roland Dreier <roland@purestorage.com>
Documentation/ABI/stable/sysfs-driver-ib_srp
drivers/infiniband/ulp/srp/ib_srp.c

index 18e9b279ebb14b07bc82a3428efbf8eccf7fe710..b95067eb5f18ac5ec99c3f5cba0bb698e9495774 100644 (file)
@@ -155,6 +155,13 @@ Contact:   linux-rdma@vger.kernel.org
 Description:   InfiniBand service ID used for establishing communication with
                the SRP target.
 
+What:          /sys/class/scsi_host/host<n>/sgid
+Date:          February 1, 2014
+KernelVersion: 3.13
+Contact:       linux-rdma@vger.kernel.org
+Description:   InfiniBand GID of the source port used for communication with
+               the SRP target.
+
 What:          /sys/class/scsi_host/host<n>/zero_req_lim
 Date:          September 20, 2006
 KernelVersion: 2.6.18
index ebbe01bdd306b071a6ebd09615e729b1da4cf6e2..62e1f2a1c522518edd8197991e64f9e7a573976e 100644 (file)
@@ -1965,6 +1965,14 @@ static ssize_t show_pkey(struct device *dev, struct device_attribute *attr,
        return sprintf(buf, "0x%04x\n", be16_to_cpu(target->path.pkey));
 }
 
+static ssize_t show_sgid(struct device *dev, struct device_attribute *attr,
+                        char *buf)
+{
+       struct srp_target_port *target = host_to_target(class_to_shost(dev));
+
+       return sprintf(buf, "%pI6\n", target->path.sgid.raw);
+}
+
 static ssize_t show_dgid(struct device *dev, struct device_attribute *attr,
                         char *buf)
 {
@@ -2049,6 +2057,7 @@ static DEVICE_ATTR(id_ext,            S_IRUGO, show_id_ext,          NULL);
 static DEVICE_ATTR(ioc_guid,       S_IRUGO, show_ioc_guid,        NULL);
 static DEVICE_ATTR(service_id,     S_IRUGO, show_service_id,      NULL);
 static DEVICE_ATTR(pkey,           S_IRUGO, show_pkey,            NULL);
+static DEVICE_ATTR(sgid,           S_IRUGO, show_sgid,            NULL);
 static DEVICE_ATTR(dgid,           S_IRUGO, show_dgid,            NULL);
 static DEVICE_ATTR(orig_dgid,      S_IRUGO, show_orig_dgid,       NULL);
 static DEVICE_ATTR(req_lim,         S_IRUGO, show_req_lim,         NULL);
@@ -2065,6 +2074,7 @@ static struct device_attribute *srp_host_attrs[] = {
        &dev_attr_ioc_guid,
        &dev_attr_service_id,
        &dev_attr_pkey,
+       &dev_attr_sgid,
        &dev_attr_dgid,
        &dev_attr_orig_dgid,
        &dev_attr_req_lim,