Skip to content

Commit 3633b3d

Browse files
Ishai RabinovitzRoland Dreier
authored andcommitted
IB/srp: Add orig_dgid sysfs attribute to scsi_host
Add an orig_dgid attribute in sysfs for SRP scsi_hosts, so that userspace can tell what the original dgid value written to the add_target file was, even if the connection is redirected to a different port while connecting. Signed-off-by: Ishai Rabinovitz <[email protected]> Signed-off-by: Roland Dreier <[email protected]>
1 parent d6ef7d6 commit 3633b3d

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

drivers/infiniband/ulp/srp/ib_srp.c

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1468,6 +1468,25 @@ static ssize_t show_dgid(struct class_device *cdev, char *buf)
14681468
be16_to_cpu(((__be16 *) target->path.dgid.raw)[7]));
14691469
}
14701470

1471+
static ssize_t show_orig_dgid(struct class_device *cdev, char *buf)
1472+
{
1473+
struct srp_target_port *target = host_to_target(class_to_shost(cdev));
1474+
1475+
if (target->state == SRP_TARGET_DEAD ||
1476+
target->state == SRP_TARGET_REMOVED)
1477+
return -ENODEV;
1478+
1479+
return sprintf(buf, "%04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x\n",
1480+
be16_to_cpu(target->orig_dgid[0]),
1481+
be16_to_cpu(target->orig_dgid[1]),
1482+
be16_to_cpu(target->orig_dgid[2]),
1483+
be16_to_cpu(target->orig_dgid[3]),
1484+
be16_to_cpu(target->orig_dgid[4]),
1485+
be16_to_cpu(target->orig_dgid[5]),
1486+
be16_to_cpu(target->orig_dgid[6]),
1487+
be16_to_cpu(target->orig_dgid[7]));
1488+
}
1489+
14711490
static ssize_t show_zero_req_lim(struct class_device *cdev, char *buf)
14721491
{
14731492
struct srp_target_port *target = host_to_target(class_to_shost(cdev));
@@ -1498,6 +1517,7 @@ static CLASS_DEVICE_ATTR(ioc_guid, S_IRUGO, show_ioc_guid, NULL);
14981517
static CLASS_DEVICE_ATTR(service_id, S_IRUGO, show_service_id, NULL);
14991518
static CLASS_DEVICE_ATTR(pkey, S_IRUGO, show_pkey, NULL);
15001519
static CLASS_DEVICE_ATTR(dgid, S_IRUGO, show_dgid, NULL);
1520+
static CLASS_DEVICE_ATTR(orig_dgid, S_IRUGO, show_orig_dgid, NULL);
15011521
static CLASS_DEVICE_ATTR(zero_req_lim, S_IRUGO, show_zero_req_lim, NULL);
15021522
static CLASS_DEVICE_ATTR(local_ib_port, S_IRUGO, show_local_ib_port, NULL);
15031523
static CLASS_DEVICE_ATTR(local_ib_device, S_IRUGO, show_local_ib_device, NULL);
@@ -1508,6 +1528,7 @@ static struct class_device_attribute *srp_host_attrs[] = {
15081528
&class_device_attr_service_id,
15091529
&class_device_attr_pkey,
15101530
&class_device_attr_dgid,
1531+
&class_device_attr_orig_dgid,
15111532
&class_device_attr_zero_req_lim,
15121533
&class_device_attr_local_ib_port,
15131534
&class_device_attr_local_ib_device,
@@ -1662,6 +1683,7 @@ static int srp_parse_options(const char *buf, struct srp_target_port *target)
16621683
target->path.dgid.raw[i] = simple_strtoul(dgid, NULL, 16);
16631684
}
16641685
kfree(p);
1686+
memcpy(target->orig_dgid, target->path.dgid.raw, 16);
16651687
break;
16661688

16671689
case SRP_OPT_PKEY:

drivers/infiniband/ulp/srp/ib_srp.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ struct srp_target_port {
129129
unsigned int scsi_id;
130130

131131
struct ib_sa_path_rec path;
132+
__be16 orig_dgid[8];
132133
struct ib_sa_query *path_query;
133134
int path_query_id;
134135

0 commit comments

Comments
 (0)