diff options
-rw-r--r-- | drivers/infiniband/ulp/srp/ib_srp.c | 1 | ||||
-rw-r--r-- | drivers/scsi/ibmvscsi/ibmvscsi.c | 1 | ||||
-rw-r--r-- | drivers/scsi/scsi_transport_srp.c | 29 | ||||
-rw-r--r-- | include/scsi/scsi_transport_srp.h | 5 |
4 files changed, 35 insertions, 1 deletions
diff --git a/drivers/infiniband/ulp/srp/ib_srp.c b/drivers/infiniband/ulp/srp/ib_srp.c index d8d056e004bb..e616c4fc6ff0 100644 --- a/drivers/infiniband/ulp/srp/ib_srp.c +++ b/drivers/infiniband/ulp/srp/ib_srp.c | |||
@@ -1545,6 +1545,7 @@ static int srp_add_target(struct srp_host *host, struct srp_target_port *target) | |||
1545 | 1545 | ||
1546 | memcpy(ids.port_id, &target->id_ext, 8); | 1546 | memcpy(ids.port_id, &target->id_ext, 8); |
1547 | memcpy(ids.port_id + 8, &target->ioc_guid, 8); | 1547 | memcpy(ids.port_id + 8, &target->ioc_guid, 8); |
1548 | ids.roles = SRP_RPORT_ROLE_TARGET; | ||
1548 | rport = srp_rport_add(target->scsi_host, &ids); | 1549 | rport = srp_rport_add(target->scsi_host, &ids); |
1549 | if (IS_ERR(rport)) { | 1550 | if (IS_ERR(rport)) { |
1550 | scsi_remove_host(target->scsi_host); | 1551 | scsi_remove_host(target->scsi_host); |
diff --git a/drivers/scsi/ibmvscsi/ibmvscsi.c b/drivers/scsi/ibmvscsi/ibmvscsi.c index e6f937eeb78f..93bd01b1e4b5 100644 --- a/drivers/scsi/ibmvscsi/ibmvscsi.c +++ b/drivers/scsi/ibmvscsi/ibmvscsi.c | |||
@@ -1599,6 +1599,7 @@ static int ibmvscsi_probe(struct vio_dev *vdev, const struct vio_device_id *id) | |||
1599 | /* we don't have a proper target_port_id so let's use the fake one */ | 1599 | /* we don't have a proper target_port_id so let's use the fake one */ |
1600 | memcpy(ids.port_id, hostdata->madapter_info.partition_name, | 1600 | memcpy(ids.port_id, hostdata->madapter_info.partition_name, |
1601 | sizeof(ids.port_id)); | 1601 | sizeof(ids.port_id)); |
1602 | ids.roles = SRP_RPORT_ROLE_TARGET; | ||
1602 | rport = srp_rport_add(host, &ids); | 1603 | rport = srp_rport_add(host, &ids); |
1603 | if (IS_ERR(rport)) | 1604 | if (IS_ERR(rport)) |
1604 | goto add_srp_port_failed; | 1605 | goto add_srp_port_failed; |
diff --git a/drivers/scsi/scsi_transport_srp.c b/drivers/scsi/scsi_transport_srp.c index dcb3d2aa780c..608abd8aef20 100644 --- a/drivers/scsi/scsi_transport_srp.c +++ b/drivers/scsi/scsi_transport_srp.c | |||
@@ -37,7 +37,7 @@ struct srp_host_attrs { | |||
37 | #define to_srp_host_attrs(host) ((struct srp_host_attrs *)(host)->shost_data) | 37 | #define to_srp_host_attrs(host) ((struct srp_host_attrs *)(host)->shost_data) |
38 | 38 | ||
39 | #define SRP_HOST_ATTRS 0 | 39 | #define SRP_HOST_ATTRS 0 |
40 | #define SRP_RPORT_ATTRS 3 | 40 | #define SRP_RPORT_ATTRS 2 |
41 | 41 | ||
42 | struct srp_internal { | 42 | struct srp_internal { |
43 | struct scsi_transport_template t; | 43 | struct scsi_transport_template t; |
@@ -107,6 +107,31 @@ show_srp_rport_id(struct class_device *cdev, char *buf) | |||
107 | 107 | ||
108 | static CLASS_DEVICE_ATTR(port_id, S_IRUGO, show_srp_rport_id, NULL); | 108 | static CLASS_DEVICE_ATTR(port_id, S_IRUGO, show_srp_rport_id, NULL); |
109 | 109 | ||
110 | static const struct { | ||
111 | u32 value; | ||
112 | char *name; | ||
113 | } srp_rport_role_names[] = { | ||
114 | {SRP_RPORT_ROLE_INITIATOR, "SRP Initiator"}, | ||
115 | {SRP_RPORT_ROLE_TARGET, "SRP Target"}, | ||
116 | }; | ||
117 | |||
118 | static ssize_t | ||
119 | show_srp_rport_roles(struct class_device *cdev, char *buf) | ||
120 | { | ||
121 | struct srp_rport *rport = transport_class_to_srp_rport(cdev); | ||
122 | int i; | ||
123 | char *name = NULL; | ||
124 | |||
125 | for (i = 0; i < ARRAY_SIZE(srp_rport_role_names); i++) | ||
126 | if (srp_rport_role_names[i].value == rport->roles) { | ||
127 | name = srp_rport_role_names[i].name; | ||
128 | break; | ||
129 | } | ||
130 | return sprintf(buf, "%s\n", name ? : "unknown"); | ||
131 | } | ||
132 | |||
133 | static CLASS_DEVICE_ATTR(roles, S_IRUGO, show_srp_rport_roles, NULL); | ||
134 | |||
110 | static void srp_rport_release(struct device *dev) | 135 | static void srp_rport_release(struct device *dev) |
111 | { | 136 | { |
112 | struct srp_rport *rport = dev_to_rport(dev); | 137 | struct srp_rport *rport = dev_to_rport(dev); |
@@ -182,6 +207,7 @@ struct srp_rport *srp_rport_add(struct Scsi_Host *shost, | |||
182 | rport->dev.release = srp_rport_release; | 207 | rport->dev.release = srp_rport_release; |
183 | 208 | ||
184 | memcpy(rport->port_id, ids->port_id, sizeof(rport->port_id)); | 209 | memcpy(rport->port_id, ids->port_id, sizeof(rport->port_id)); |
210 | rport->roles = ids->roles; | ||
185 | 211 | ||
186 | id = atomic_inc_return(&to_srp_host_attrs(shost)->next_port_id); | 212 | id = atomic_inc_return(&to_srp_host_attrs(shost)->next_port_id); |
187 | sprintf(rport->dev.bus_id, "port-%d:%d", shost->host_no, id); | 213 | sprintf(rport->dev.bus_id, "port-%d:%d", shost->host_no, id); |
@@ -266,6 +292,7 @@ srp_attach_transport(struct srp_function_template *ft) | |||
266 | 292 | ||
267 | count = 0; | 293 | count = 0; |
268 | SETUP_RPORT_ATTRIBUTE_RD(port_id); | 294 | SETUP_RPORT_ATTRIBUTE_RD(port_id); |
295 | SETUP_RPORT_ATTRIBUTE_RD(roles); | ||
269 | i->rport_attrs[count] = NULL; | 296 | i->rport_attrs[count] = NULL; |
270 | 297 | ||
271 | i->f = ft; | 298 | i->f = ft; |
diff --git a/include/scsi/scsi_transport_srp.h b/include/scsi/scsi_transport_srp.h index adbfca402a69..08b4a28a77b8 100644 --- a/include/scsi/scsi_transport_srp.h +++ b/include/scsi/scsi_transport_srp.h | |||
@@ -5,14 +5,19 @@ | |||
5 | #include <linux/types.h> | 5 | #include <linux/types.h> |
6 | #include <linux/mutex.h> | 6 | #include <linux/mutex.h> |
7 | 7 | ||
8 | #define SRP_RPORT_ROLE_INITIATOR 0 | ||
9 | #define SRP_RPORT_ROLE_TARGET 1 | ||
10 | |||
8 | struct srp_rport_identifiers { | 11 | struct srp_rport_identifiers { |
9 | u8 port_id[16]; | 12 | u8 port_id[16]; |
13 | u8 roles; | ||
10 | }; | 14 | }; |
11 | 15 | ||
12 | struct srp_rport { | 16 | struct srp_rport { |
13 | struct device dev; | 17 | struct device dev; |
14 | 18 | ||
15 | u8 port_id[16]; | 19 | u8 port_id[16]; |
20 | u8 roles; | ||
16 | }; | 21 | }; |
17 | 22 | ||
18 | struct srp_function_template { | 23 | struct srp_function_template { |