Skip to content

Commit

Permalink
IB/srp: Add SCSI host attributes to show target port
Browse files Browse the repository at this point in the history
Add SCSI host attributes in sysfs that show the ID extension, IOC
GUID, service ID, P_Key and destination GID for each target port that
the SRP initiator connects to.

Signed-off-by: Roland Dreier <rolandd@cisco.com>
  • Loading branch information
Roland Dreier committed Mar 20, 2006
1 parent 87fd1a1 commit 6ecb0c8
Showing 1 changed file with 83 additions and 1 deletion.
84 changes: 83 additions & 1 deletion drivers/infiniband/ulp/srp/ib_srp.c
Original file line number Diff line number Diff line change
Expand Up @@ -1237,6 +1237,87 @@ static int srp_reset_host(struct scsi_cmnd *scmnd)
return ret;
}

static ssize_t show_id_ext(struct class_device *cdev, char *buf)
{
struct srp_target_port *target = host_to_target(class_to_shost(cdev));

if (target->state == SRP_TARGET_DEAD ||
target->state == SRP_TARGET_REMOVED)
return -ENODEV;

return sprintf(buf, "0x%016llx\n",
(unsigned long long) be64_to_cpu(target->id_ext));
}

static ssize_t show_ioc_guid(struct class_device *cdev, char *buf)
{
struct srp_target_port *target = host_to_target(class_to_shost(cdev));

if (target->state == SRP_TARGET_DEAD ||
target->state == SRP_TARGET_REMOVED)
return -ENODEV;

return sprintf(buf, "0x%016llx\n",
(unsigned long long) be64_to_cpu(target->ioc_guid));
}

static ssize_t show_service_id(struct class_device *cdev, char *buf)
{
struct srp_target_port *target = host_to_target(class_to_shost(cdev));

if (target->state == SRP_TARGET_DEAD ||
target->state == SRP_TARGET_REMOVED)
return -ENODEV;

return sprintf(buf, "0x%016llx\n",
(unsigned long long) be64_to_cpu(target->service_id));
}

static ssize_t show_pkey(struct class_device *cdev, char *buf)
{
struct srp_target_port *target = host_to_target(class_to_shost(cdev));

if (target->state == SRP_TARGET_DEAD ||
target->state == SRP_TARGET_REMOVED)
return -ENODEV;

return sprintf(buf, "0x%04x\n", be16_to_cpu(target->path.pkey));
}

static ssize_t show_dgid(struct class_device *cdev, char *buf)
{
struct srp_target_port *target = host_to_target(class_to_shost(cdev));

if (target->state == SRP_TARGET_DEAD ||
target->state == SRP_TARGET_REMOVED)
return -ENODEV;

return sprintf(buf, "%04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x\n",
be16_to_cpu(((__be16 *) target->path.dgid.raw)[0]),
be16_to_cpu(((__be16 *) target->path.dgid.raw)[1]),
be16_to_cpu(((__be16 *) target->path.dgid.raw)[2]),
be16_to_cpu(((__be16 *) target->path.dgid.raw)[3]),
be16_to_cpu(((__be16 *) target->path.dgid.raw)[4]),
be16_to_cpu(((__be16 *) target->path.dgid.raw)[5]),
be16_to_cpu(((__be16 *) target->path.dgid.raw)[6]),
be16_to_cpu(((__be16 *) target->path.dgid.raw)[7]));
}

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 struct class_device_attribute *srp_host_attrs[] = {
&class_device_attr_id_ext,
&class_device_attr_ioc_guid,
&class_device_attr_service_id,
&class_device_attr_pkey,
&class_device_attr_dgid,
NULL
};

static struct scsi_host_template srp_template = {
.module = THIS_MODULE,
.name = DRV_NAME,
Expand All @@ -1249,7 +1330,8 @@ static struct scsi_host_template srp_template = {
.this_id = -1,
.sg_tablesize = SRP_MAX_INDIRECT,
.cmd_per_lun = SRP_SQ_SIZE,
.use_clustering = ENABLE_CLUSTERING
.use_clustering = ENABLE_CLUSTERING,
.shost_attrs = srp_host_attrs
};

static int srp_add_target(struct srp_host *host, struct srp_target_port *target)
Expand Down

0 comments on commit 6ecb0c8

Please sign in to comment.