Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[SCSI] transport_srp: add rport roles attribute

This adds a 'roles' attribute to rport like transport_fc. The role can
be initiator or target. That is, the initiator driver creates target
remote ports and the target driver creates initiator remote ports.

Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Signed-off-by: Mike Christie <michaelc@cs.wisc.edu>
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>

authored by

FUJITA Tomonori and committed by
James Bottomley
aebd5e47 3236822b

+35 -1
+1
drivers/infiniband/ulp/srp/ib_srp.c
··· 1545 1545 1546 1546 memcpy(ids.port_id, &target->id_ext, 8); 1547 1547 memcpy(ids.port_id + 8, &target->ioc_guid, 8); 1548 + ids.roles = SRP_RPORT_ROLE_TARGET; 1548 1549 rport = srp_rport_add(target->scsi_host, &ids); 1549 1550 if (IS_ERR(rport)) { 1550 1551 scsi_remove_host(target->scsi_host);
+1
drivers/scsi/ibmvscsi/ibmvscsi.c
··· 1599 1599 /* we don't have a proper target_port_id so let's use the fake one */ 1600 1600 memcpy(ids.port_id, hostdata->madapter_info.partition_name, 1601 1601 sizeof(ids.port_id)); 1602 + ids.roles = SRP_RPORT_ROLE_TARGET; 1602 1603 rport = srp_rport_add(host, &ids); 1603 1604 if (IS_ERR(rport)) 1604 1605 goto add_srp_port_failed;
+28 -1
drivers/scsi/scsi_transport_srp.c
··· 37 37 #define to_srp_host_attrs(host) ((struct srp_host_attrs *)(host)->shost_data) 38 38 39 39 #define SRP_HOST_ATTRS 0 40 - #define SRP_RPORT_ATTRS 3 40 + #define SRP_RPORT_ATTRS 2 41 41 42 42 struct srp_internal { 43 43 struct scsi_transport_template t; ··· 106 106 } 107 107 108 108 static CLASS_DEVICE_ATTR(port_id, S_IRUGO, show_srp_rport_id, NULL); 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); 109 134 110 135 static void srp_rport_release(struct device *dev) 111 136 { ··· 207 182 rport->dev.release = srp_rport_release; 208 183 209 184 memcpy(rport->port_id, ids->port_id, sizeof(rport->port_id)); 185 + rport->roles = ids->roles; 210 186 211 187 id = atomic_inc_return(&to_srp_host_attrs(shost)->next_port_id); 212 188 sprintf(rport->dev.bus_id, "port-%d:%d", shost->host_no, id); ··· 292 266 293 267 count = 0; 294 268 SETUP_RPORT_ATTRIBUTE_RD(port_id); 269 + SETUP_RPORT_ATTRIBUTE_RD(roles); 295 270 i->rport_attrs[count] = NULL; 296 271 297 272 i->f = ft;
+5
include/scsi/scsi_transport_srp.h
··· 5 5 #include <linux/types.h> 6 6 #include <linux/mutex.h> 7 7 8 + #define SRP_RPORT_ROLE_INITIATOR 0 9 + #define SRP_RPORT_ROLE_TARGET 1 10 + 8 11 struct srp_rport_identifiers { 9 12 u8 port_id[16]; 13 + u8 roles; 10 14 }; 11 15 12 16 struct srp_rport { 13 17 struct device dev; 14 18 15 19 u8 port_id[16]; 20 + u8 roles; 16 21 }; 17 22 18 23 struct srp_function_template {