aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/scsi_transport_srp.c
diff options
context:
space:
mode:
authorFUJITA Tomonori <tomof@acm.org>2007-07-11 02:08:15 -0400
committerJames Bottomley <jejb@mulgrave.localdomain>2007-10-12 14:37:46 -0400
commitaebd5e476ecc8ceb53577b20f2a352ff4ceffd8d (patch)
tree43103d35db1aa80440515db3fc968b0d96dd1d5e /drivers/scsi/scsi_transport_srp.c
parent3236822b1c9b67ad10745d965515b528818f1120 (diff)
[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>
Diffstat (limited to 'drivers/scsi/scsi_transport_srp.c')
-rw-r--r--drivers/scsi/scsi_transport_srp.c29
1 files changed, 28 insertions, 1 deletions
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
42struct srp_internal { 42struct 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
108static CLASS_DEVICE_ATTR(port_id, S_IRUGO, show_srp_rport_id, NULL); 108static CLASS_DEVICE_ATTR(port_id, S_IRUGO, show_srp_rport_id, NULL);
109 109
110static 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
118static ssize_t
119show_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
133static CLASS_DEVICE_ATTR(roles, S_IRUGO, show_srp_rport_roles, NULL);
134
110static void srp_rport_release(struct device *dev) 135static 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;