2 * FiberChannel transport specific attributes exported to sysfs.
4 * Copyright (c) 2003 Silicon Graphics, Inc. All rights reserved.
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 * Copyright (C) 2004-2005 James Smart, Emulex Corporation
23 * Rewrite for host, target, device, and remote port attributes,
24 * statistics, and service functions...
27 #include <linux/module.h>
28 #include <linux/init.h>
29 #include <linux/sched.h> /* workqueue stuff, HZ */
30 #include <scsi/scsi_device.h>
31 #include <scsi/scsi_host.h>
32 #include <scsi/scsi_transport.h>
33 #include <scsi/scsi_transport_fc.h>
34 #include <scsi/scsi_cmnd.h>
35 #include "scsi_priv.h"
37 static int fc_queue_work(struct Scsi_Host *, struct work_struct *);
40 * Redefine so that we can have same named attributes in the
41 * sdev/starget/host objects.
43 #define FC_CLASS_DEVICE_ATTR(_prefix,_name,_mode,_show,_store) \
44 struct class_device_attribute class_device_attr_##_prefix##_##_name = \
45 __ATTR(_name,_mode,_show,_store)
47 #define fc_enum_name_search(title, table_type, table) \
48 static const char *get_fc_##title##_name(enum table_type table_key) \
53 for (i = 0; i < ARRAY_SIZE(table); i++) { \
54 if (table[i].value == table_key) { \
55 name = table[i].name; \
62 #define fc_enum_name_match(title, table_type, table) \
63 static int get_fc_##title##_match(const char *table_key, \
64 enum table_type *value) \
68 for (i = 0; i < ARRAY_SIZE(table); i++) { \
69 if (strncmp(table_key, table[i].name, \
70 table[i].matchlen) == 0) { \
71 *value = table[i].value; \
72 return 0; /* success */ \
75 return 1; /* failure */ \
79 /* Convert fc_port_type values to ascii string name */
81 enum fc_port_type value;
83 } fc_port_type_names[] = {
84 { FC_PORTTYPE_UNKNOWN, "Unknown" },
85 { FC_PORTTYPE_OTHER, "Other" },
86 { FC_PORTTYPE_NOTPRESENT, "Not Present" },
87 { FC_PORTTYPE_NPORT, "NPort (fabric via point-to-point)" },
88 { FC_PORTTYPE_NLPORT, "NLPort (fabric via loop)" },
89 { FC_PORTTYPE_LPORT, "LPort (private loop)" },
90 { FC_PORTTYPE_PTP, "Point-To-Point (direct nport connection" },
92 fc_enum_name_search(port_type, fc_port_type, fc_port_type_names)
93 #define FC_PORTTYPE_MAX_NAMELEN 50
96 /* Convert fc_port_state values to ascii string name */
98 enum fc_port_state value;
100 } fc_port_state_names[] = {
101 { FC_PORTSTATE_UNKNOWN, "Unknown" },
102 { FC_PORTSTATE_NOTPRESENT, "Not Present" },
103 { FC_PORTSTATE_ONLINE, "Online" },
104 { FC_PORTSTATE_OFFLINE, "Offline" },
105 { FC_PORTSTATE_BLOCKED, "Blocked" },
106 { FC_PORTSTATE_BYPASSED, "Bypassed" },
107 { FC_PORTSTATE_DIAGNOSTICS, "Diagnostics" },
108 { FC_PORTSTATE_LINKDOWN, "Linkdown" },
109 { FC_PORTSTATE_ERROR, "Error" },
110 { FC_PORTSTATE_LOOPBACK, "Loopback" },
111 { FC_PORTSTATE_DELETED, "Deleted" },
113 fc_enum_name_search(port_state, fc_port_state, fc_port_state_names)
114 #define FC_PORTSTATE_MAX_NAMELEN 20
117 /* Convert fc_tgtid_binding_type values to ascii string name */
118 static const struct {
119 enum fc_tgtid_binding_type value;
122 } fc_tgtid_binding_type_names[] = {
123 { FC_TGTID_BIND_NONE, "none", 4 },
124 { FC_TGTID_BIND_BY_WWPN, "wwpn (World Wide Port Name)", 4 },
125 { FC_TGTID_BIND_BY_WWNN, "wwnn (World Wide Node Name)", 4 },
126 { FC_TGTID_BIND_BY_ID, "port_id (FC Address)", 7 },
128 fc_enum_name_search(tgtid_bind_type, fc_tgtid_binding_type,
129 fc_tgtid_binding_type_names)
130 fc_enum_name_match(tgtid_bind_type, fc_tgtid_binding_type,
131 fc_tgtid_binding_type_names)
132 #define FC_BINDTYPE_MAX_NAMELEN 30
135 #define fc_bitfield_name_search(title, table) \
137 get_fc_##title##_names(u32 table_key, char *buf) \
143 for (i = 0; i < ARRAY_SIZE(table); i++) { \
144 if (table[i].value & table_key) { \
145 len += sprintf(buf + len, "%s%s", \
146 prefix, table[i].name); \
150 len += sprintf(buf + len, "\n"); \
155 /* Convert FC_COS bit values to ascii string name */
156 static const struct {
160 { FC_COS_CLASS1, "Class 1" },
161 { FC_COS_CLASS2, "Class 2" },
162 { FC_COS_CLASS3, "Class 3" },
163 { FC_COS_CLASS4, "Class 4" },
164 { FC_COS_CLASS6, "Class 6" },
166 fc_bitfield_name_search(cos, fc_cos_names)
169 /* Convert FC_PORTSPEED bit values to ascii string name */
170 static const struct {
173 } fc_port_speed_names[] = {
174 { FC_PORTSPEED_1GBIT, "1 Gbit" },
175 { FC_PORTSPEED_2GBIT, "2 Gbit" },
176 { FC_PORTSPEED_4GBIT, "4 Gbit" },
177 { FC_PORTSPEED_10GBIT, "10 Gbit" },
178 { FC_PORTSPEED_NOT_NEGOTIATED, "Not Negotiated" },
180 fc_bitfield_name_search(port_speed, fc_port_speed_names)
184 show_fc_fc4s (char *buf, u8 *fc4_list)
188 for (i = 0; i < FC_FC4_LIST_SIZE; i++, fc4_list++)
189 len += sprintf(buf + len , "0x%02x ", *fc4_list);
190 len += sprintf(buf + len, "\n");
195 /* Convert FC_RPORT_ROLE bit values to ascii string name */
196 static const struct {
199 } fc_remote_port_role_names[] = {
200 { FC_RPORT_ROLE_FCP_TARGET, "FCP Target" },
201 { FC_RPORT_ROLE_FCP_INITIATOR, "FCP Initiator" },
202 { FC_RPORT_ROLE_IP_PORT, "IP Port" },
204 fc_bitfield_name_search(remote_port_roles, fc_remote_port_role_names)
207 * Define roles that are specific to port_id. Values are relative to ROLE_MASK.
209 #define FC_WELLKNOWN_PORTID_MASK 0xfffff0
210 #define FC_WELLKNOWN_ROLE_MASK 0x00000f
211 #define FC_FPORT_PORTID 0x00000e
212 #define FC_FABCTLR_PORTID 0x00000d
213 #define FC_DIRSRVR_PORTID 0x00000c
214 #define FC_TIMESRVR_PORTID 0x00000b
215 #define FC_MGMTSRVR_PORTID 0x00000a
218 static void fc_timeout_deleted_rport(void *data);
219 static void fc_scsi_scan_rport(void *data);
222 * Attribute counts pre object type...
223 * Increase these values if you add attributes
225 #define FC_STARGET_NUM_ATTRS 3
226 #define FC_RPORT_NUM_ATTRS 9
227 #define FC_HOST_NUM_ATTRS 17
230 struct scsi_transport_template t;
231 struct fc_function_template *f;
234 * For attributes : each object has :
235 * An array of the actual attributes structures
236 * An array of null-terminated pointers to the attribute
237 * structures - used for mid-layer interaction.
239 * The attribute containers for the starget and host are are
240 * part of the midlayer. As the remote port is specific to the
241 * fc transport, we must provide the attribute container.
243 struct class_device_attribute private_starget_attrs[
244 FC_STARGET_NUM_ATTRS];
245 struct class_device_attribute *starget_attrs[FC_STARGET_NUM_ATTRS + 1];
247 struct class_device_attribute private_host_attrs[FC_HOST_NUM_ATTRS];
248 struct class_device_attribute *host_attrs[FC_HOST_NUM_ATTRS + 1];
250 struct transport_container rport_attr_cont;
251 struct class_device_attribute private_rport_attrs[FC_RPORT_NUM_ATTRS];
252 struct class_device_attribute *rport_attrs[FC_RPORT_NUM_ATTRS + 1];
255 #define to_fc_internal(tmpl) container_of(tmpl, struct fc_internal, t)
257 static int fc_target_setup(struct transport_container *tc, struct device *dev,
258 struct class_device *cdev)
260 struct scsi_target *starget = to_scsi_target(dev);
261 struct fc_rport *rport = starget_to_rport(starget);
264 * if parent is remote port, use values from remote port.
265 * Otherwise, this host uses the fc_transport, but not the
266 * remote port interface. As such, initialize to known non-values.
269 fc_starget_node_name(starget) = rport->node_name;
270 fc_starget_port_name(starget) = rport->port_name;
271 fc_starget_port_id(starget) = rport->port_id;
273 fc_starget_node_name(starget) = -1;
274 fc_starget_port_name(starget) = -1;
275 fc_starget_port_id(starget) = -1;
281 static DECLARE_TRANSPORT_CLASS(fc_transport_class,
287 static int fc_host_setup(struct transport_container *tc, struct device *dev,
288 struct class_device *cdev)
290 struct Scsi_Host *shost = dev_to_shost(dev);
291 struct fc_host_attrs *fc_host = shost_to_fc_host(shost);
294 * Set default values easily detected by the midlayer as
295 * failure cases. The scsi lldd is responsible for initializing
296 * all transport attributes to valid values per host.
298 fc_host->node_name = -1;
299 fc_host->port_name = -1;
300 fc_host->permanent_port_name = -1;
301 fc_host->supported_classes = FC_COS_UNSPECIFIED;
302 memset(fc_host->supported_fc4s, 0,
303 sizeof(fc_host->supported_fc4s));
304 memset(fc_host->symbolic_name, 0,
305 sizeof(fc_host->symbolic_name));
306 fc_host->supported_speeds = FC_PORTSPEED_UNKNOWN;
307 fc_host->maxframe_size = -1;
308 memset(fc_host->serial_number, 0,
309 sizeof(fc_host->serial_number));
311 fc_host->port_id = -1;
312 fc_host->port_type = FC_PORTTYPE_UNKNOWN;
313 fc_host->port_state = FC_PORTSTATE_UNKNOWN;
314 memset(fc_host->active_fc4s, 0,
315 sizeof(fc_host->active_fc4s));
316 fc_host->speed = FC_PORTSPEED_UNKNOWN;
317 fc_host->fabric_name = -1;
319 fc_host->tgtid_bind_type = FC_TGTID_BIND_BY_WWPN;
321 INIT_LIST_HEAD(&fc_host->rports);
322 INIT_LIST_HEAD(&fc_host->rport_bindings);
323 fc_host->next_rport_number = 0;
324 fc_host->next_target_id = 0;
326 snprintf(fc_host->work_q_name, KOBJ_NAME_LEN, "fc_wq_%d",
328 fc_host->work_q = create_singlethread_workqueue(
329 fc_host->work_q_name);
330 if (!fc_host->work_q)
333 snprintf(fc_host->devloss_work_q_name, KOBJ_NAME_LEN, "fc_dl_%d",
335 fc_host->devloss_work_q = create_singlethread_workqueue(
336 fc_host->devloss_work_q_name);
337 if (!fc_host->devloss_work_q) {
338 destroy_workqueue(fc_host->work_q);
339 fc_host->work_q = NULL;
346 static DECLARE_TRANSPORT_CLASS(fc_host_class,
353 * Setup and Remove actions for remote ports are handled
354 * in the service functions below.
356 static DECLARE_TRANSPORT_CLASS(fc_rport_class,
367 * dev_loss_tmo: the default number of seconds that the FC transport
368 * should insulate the loss of a remote port.
369 * The maximum will be capped by the value of SCSI_DEVICE_BLOCK_MAX_TIMEOUT.
371 static unsigned int fc_dev_loss_tmo = 60; /* seconds */
373 module_param_named(dev_loss_tmo, fc_dev_loss_tmo, int, S_IRUGO|S_IWUSR);
374 MODULE_PARM_DESC(dev_loss_tmo,
375 "Maximum number of seconds that the FC transport should"
376 " insulate the loss of a remote port. Once this value is"
377 " exceeded, the scsi target is removed. Value should be"
378 " between 1 and SCSI_DEVICE_BLOCK_MAX_TIMEOUT.");
381 static __init int fc_transport_init(void)
383 int error = transport_class_register(&fc_host_class);
386 error = transport_class_register(&fc_rport_class);
389 return transport_class_register(&fc_transport_class);
392 static void __exit fc_transport_exit(void)
394 transport_class_unregister(&fc_transport_class);
395 transport_class_unregister(&fc_rport_class);
396 transport_class_unregister(&fc_host_class);
400 * FC Remote Port Attribute Management
403 #define fc_rport_show_function(field, format_string, sz, cast) \
405 show_fc_rport_##field (struct class_device *cdev, char *buf) \
407 struct fc_rport *rport = transport_class_to_rport(cdev); \
408 struct Scsi_Host *shost = rport_to_shost(rport); \
409 struct fc_internal *i = to_fc_internal(shost->transportt); \
410 if ((i->f->get_rport_##field) && \
411 !((rport->port_state == FC_PORTSTATE_BLOCKED) || \
412 (rport->port_state == FC_PORTSTATE_DELETED) || \
413 (rport->port_state == FC_PORTSTATE_NOTPRESENT))) \
414 i->f->get_rport_##field(rport); \
415 return snprintf(buf, sz, format_string, cast rport->field); \
418 #define fc_rport_store_function(field) \
420 store_fc_rport_##field(struct class_device *cdev, const char *buf, \
424 struct fc_rport *rport = transport_class_to_rport(cdev); \
425 struct Scsi_Host *shost = rport_to_shost(rport); \
426 struct fc_internal *i = to_fc_internal(shost->transportt); \
427 if ((rport->port_state == FC_PORTSTATE_BLOCKED) || \
428 (rport->port_state == FC_PORTSTATE_DELETED) || \
429 (rport->port_state == FC_PORTSTATE_NOTPRESENT)) \
431 val = simple_strtoul(buf, NULL, 0); \
432 i->f->set_rport_##field(rport, val); \
436 #define fc_rport_rd_attr(field, format_string, sz) \
437 fc_rport_show_function(field, format_string, sz, ) \
438 static FC_CLASS_DEVICE_ATTR(rport, field, S_IRUGO, \
439 show_fc_rport_##field, NULL)
441 #define fc_rport_rd_attr_cast(field, format_string, sz, cast) \
442 fc_rport_show_function(field, format_string, sz, (cast)) \
443 static FC_CLASS_DEVICE_ATTR(rport, field, S_IRUGO, \
444 show_fc_rport_##field, NULL)
446 #define fc_rport_rw_attr(field, format_string, sz) \
447 fc_rport_show_function(field, format_string, sz, ) \
448 fc_rport_store_function(field) \
449 static FC_CLASS_DEVICE_ATTR(rport, field, S_IRUGO | S_IWUSR, \
450 show_fc_rport_##field, \
451 store_fc_rport_##field)
454 #define fc_private_rport_show_function(field, format_string, sz, cast) \
456 show_fc_rport_##field (struct class_device *cdev, char *buf) \
458 struct fc_rport *rport = transport_class_to_rport(cdev); \
459 return snprintf(buf, sz, format_string, cast rport->field); \
462 #define fc_private_rport_rd_attr(field, format_string, sz) \
463 fc_private_rport_show_function(field, format_string, sz, ) \
464 static FC_CLASS_DEVICE_ATTR(rport, field, S_IRUGO, \
465 show_fc_rport_##field, NULL)
467 #define fc_private_rport_rd_attr_cast(field, format_string, sz, cast) \
468 fc_private_rport_show_function(field, format_string, sz, (cast)) \
469 static FC_CLASS_DEVICE_ATTR(rport, field, S_IRUGO, \
470 show_fc_rport_##field, NULL)
473 #define fc_private_rport_rd_enum_attr(title, maxlen) \
475 show_fc_rport_##title (struct class_device *cdev, char *buf) \
477 struct fc_rport *rport = transport_class_to_rport(cdev); \
479 name = get_fc_##title##_name(rport->title); \
482 return snprintf(buf, maxlen, "%s\n", name); \
484 static FC_CLASS_DEVICE_ATTR(rport, title, S_IRUGO, \
485 show_fc_rport_##title, NULL)
488 #define SETUP_RPORT_ATTRIBUTE_RD(field) \
489 i->private_rport_attrs[count] = class_device_attr_rport_##field; \
490 i->private_rport_attrs[count].attr.mode = S_IRUGO; \
491 i->private_rport_attrs[count].store = NULL; \
492 i->rport_attrs[count] = &i->private_rport_attrs[count]; \
493 if (i->f->show_rport_##field) \
496 #define SETUP_PRIVATE_RPORT_ATTRIBUTE_RD(field) \
497 i->private_rport_attrs[count] = class_device_attr_rport_##field; \
498 i->private_rport_attrs[count].attr.mode = S_IRUGO; \
499 i->private_rport_attrs[count].store = NULL; \
500 i->rport_attrs[count] = &i->private_rport_attrs[count]; \
503 #define SETUP_RPORT_ATTRIBUTE_RW(field) \
504 i->private_rport_attrs[count] = class_device_attr_rport_##field; \
505 if (!i->f->set_rport_##field) { \
506 i->private_rport_attrs[count].attr.mode = S_IRUGO; \
507 i->private_rport_attrs[count].store = NULL; \
509 i->rport_attrs[count] = &i->private_rport_attrs[count]; \
510 if (i->f->show_rport_##field) \
514 /* The FC Transport Remote Port Attributes: */
516 /* Fixed Remote Port Attributes */
518 fc_private_rport_rd_attr(maxframe_size, "%u bytes\n", 20);
521 show_fc_rport_supported_classes (struct class_device *cdev, char *buf)
523 struct fc_rport *rport = transport_class_to_rport(cdev);
524 if (rport->supported_classes == FC_COS_UNSPECIFIED)
525 return snprintf(buf, 20, "unspecified\n");
526 return get_fc_cos_names(rport->supported_classes, buf);
528 static FC_CLASS_DEVICE_ATTR(rport, supported_classes, S_IRUGO,
529 show_fc_rport_supported_classes, NULL);
531 /* Dynamic Remote Port Attributes */
534 * dev_loss_tmo attribute
536 fc_rport_show_function(dev_loss_tmo, "%d\n", 20, )
538 store_fc_rport_dev_loss_tmo(struct class_device *cdev, const char *buf,
542 struct fc_rport *rport = transport_class_to_rport(cdev);
543 struct Scsi_Host *shost = rport_to_shost(rport);
544 struct fc_internal *i = to_fc_internal(shost->transportt);
545 if ((rport->port_state == FC_PORTSTATE_BLOCKED) ||
546 (rport->port_state == FC_PORTSTATE_DELETED) ||
547 (rport->port_state == FC_PORTSTATE_NOTPRESENT))
549 val = simple_strtoul(buf, NULL, 0);
550 if ((val < 0) || (val > SCSI_DEVICE_BLOCK_MAX_TIMEOUT))
552 i->f->set_rport_dev_loss_tmo(rport, val);
555 static FC_CLASS_DEVICE_ATTR(rport, dev_loss_tmo, S_IRUGO | S_IWUSR,
556 show_fc_rport_dev_loss_tmo, store_fc_rport_dev_loss_tmo);
559 /* Private Remote Port Attributes */
561 fc_private_rport_rd_attr_cast(node_name, "0x%llx\n", 20, unsigned long long);
562 fc_private_rport_rd_attr_cast(port_name, "0x%llx\n", 20, unsigned long long);
563 fc_private_rport_rd_attr(port_id, "0x%06x\n", 20);
566 show_fc_rport_roles (struct class_device *cdev, char *buf)
568 struct fc_rport *rport = transport_class_to_rport(cdev);
570 /* identify any roles that are port_id specific */
571 if ((rport->port_id != -1) &&
572 (rport->port_id & FC_WELLKNOWN_PORTID_MASK) ==
573 FC_WELLKNOWN_PORTID_MASK) {
574 switch (rport->port_id & FC_WELLKNOWN_ROLE_MASK) {
575 case FC_FPORT_PORTID:
576 return snprintf(buf, 30, "Fabric Port\n");
577 case FC_FABCTLR_PORTID:
578 return snprintf(buf, 30, "Fabric Controller\n");
579 case FC_DIRSRVR_PORTID:
580 return snprintf(buf, 30, "Directory Server\n");
581 case FC_TIMESRVR_PORTID:
582 return snprintf(buf, 30, "Time Server\n");
583 case FC_MGMTSRVR_PORTID:
584 return snprintf(buf, 30, "Management Server\n");
586 return snprintf(buf, 30, "Unknown Fabric Entity\n");
589 if (rport->roles == FC_RPORT_ROLE_UNKNOWN)
590 return snprintf(buf, 20, "unknown\n");
591 return get_fc_remote_port_roles_names(rport->roles, buf);
594 static FC_CLASS_DEVICE_ATTR(rport, roles, S_IRUGO,
595 show_fc_rport_roles, NULL);
597 fc_private_rport_rd_enum_attr(port_state, FC_PORTSTATE_MAX_NAMELEN);
598 fc_private_rport_rd_attr(scsi_target_id, "%d\n", 20);
603 * FC SCSI Target Attribute Management
607 * Note: in the target show function we recognize when the remote
608 * port is in the heirarchy and do not allow the driver to get
609 * involved in sysfs functions. The driver only gets involved if
610 * it's the "old" style that doesn't use rports.
612 #define fc_starget_show_function(field, format_string, sz, cast) \
614 show_fc_starget_##field (struct class_device *cdev, char *buf) \
616 struct scsi_target *starget = transport_class_to_starget(cdev); \
617 struct Scsi_Host *shost = dev_to_shost(starget->dev.parent); \
618 struct fc_internal *i = to_fc_internal(shost->transportt); \
619 struct fc_rport *rport = starget_to_rport(starget); \
621 fc_starget_##field(starget) = rport->field; \
622 else if (i->f->get_starget_##field) \
623 i->f->get_starget_##field(starget); \
624 return snprintf(buf, sz, format_string, \
625 cast fc_starget_##field(starget)); \
628 #define fc_starget_rd_attr(field, format_string, sz) \
629 fc_starget_show_function(field, format_string, sz, ) \
630 static FC_CLASS_DEVICE_ATTR(starget, field, S_IRUGO, \
631 show_fc_starget_##field, NULL)
633 #define fc_starget_rd_attr_cast(field, format_string, sz, cast) \
634 fc_starget_show_function(field, format_string, sz, (cast)) \
635 static FC_CLASS_DEVICE_ATTR(starget, field, S_IRUGO, \
636 show_fc_starget_##field, NULL)
638 #define SETUP_STARGET_ATTRIBUTE_RD(field) \
639 i->private_starget_attrs[count] = class_device_attr_starget_##field; \
640 i->private_starget_attrs[count].attr.mode = S_IRUGO; \
641 i->private_starget_attrs[count].store = NULL; \
642 i->starget_attrs[count] = &i->private_starget_attrs[count]; \
643 if (i->f->show_starget_##field) \
646 #define SETUP_STARGET_ATTRIBUTE_RW(field) \
647 i->private_starget_attrs[count] = class_device_attr_starget_##field; \
648 if (!i->f->set_starget_##field) { \
649 i->private_starget_attrs[count].attr.mode = S_IRUGO; \
650 i->private_starget_attrs[count].store = NULL; \
652 i->starget_attrs[count] = &i->private_starget_attrs[count]; \
653 if (i->f->show_starget_##field) \
656 /* The FC Transport SCSI Target Attributes: */
657 fc_starget_rd_attr_cast(node_name, "0x%llx\n", 20, unsigned long long);
658 fc_starget_rd_attr_cast(port_name, "0x%llx\n", 20, unsigned long long);
659 fc_starget_rd_attr(port_id, "0x%06x\n", 20);
663 * Host Attribute Management
666 #define fc_host_show_function(field, format_string, sz, cast) \
668 show_fc_host_##field (struct class_device *cdev, char *buf) \
670 struct Scsi_Host *shost = transport_class_to_shost(cdev); \
671 struct fc_internal *i = to_fc_internal(shost->transportt); \
672 if (i->f->get_host_##field) \
673 i->f->get_host_##field(shost); \
674 return snprintf(buf, sz, format_string, cast fc_host_##field(shost)); \
677 #define fc_host_store_function(field) \
679 store_fc_host_##field(struct class_device *cdev, const char *buf, \
683 struct Scsi_Host *shost = transport_class_to_shost(cdev); \
684 struct fc_internal *i = to_fc_internal(shost->transportt); \
686 val = simple_strtoul(buf, NULL, 0); \
687 i->f->set_host_##field(shost, val); \
691 #define fc_host_rd_attr(field, format_string, sz) \
692 fc_host_show_function(field, format_string, sz, ) \
693 static FC_CLASS_DEVICE_ATTR(host, field, S_IRUGO, \
694 show_fc_host_##field, NULL)
696 #define fc_host_rd_attr_cast(field, format_string, sz, cast) \
697 fc_host_show_function(field, format_string, sz, (cast)) \
698 static FC_CLASS_DEVICE_ATTR(host, field, S_IRUGO, \
699 show_fc_host_##field, NULL)
701 #define fc_host_rw_attr(field, format_string, sz) \
702 fc_host_show_function(field, format_string, sz, ) \
703 fc_host_store_function(field) \
704 static FC_CLASS_DEVICE_ATTR(host, field, S_IRUGO | S_IWUSR, \
705 show_fc_host_##field, \
706 store_fc_host_##field)
708 #define fc_host_rd_enum_attr(title, maxlen) \
710 show_fc_host_##title (struct class_device *cdev, char *buf) \
712 struct Scsi_Host *shost = transport_class_to_shost(cdev); \
713 struct fc_internal *i = to_fc_internal(shost->transportt); \
715 if (i->f->get_host_##title) \
716 i->f->get_host_##title(shost); \
717 name = get_fc_##title##_name(fc_host_##title(shost)); \
720 return snprintf(buf, maxlen, "%s\n", name); \
722 static FC_CLASS_DEVICE_ATTR(host, title, S_IRUGO, show_fc_host_##title, NULL)
724 #define SETUP_HOST_ATTRIBUTE_RD(field) \
725 i->private_host_attrs[count] = class_device_attr_host_##field; \
726 i->private_host_attrs[count].attr.mode = S_IRUGO; \
727 i->private_host_attrs[count].store = NULL; \
728 i->host_attrs[count] = &i->private_host_attrs[count]; \
729 if (i->f->show_host_##field) \
732 #define SETUP_HOST_ATTRIBUTE_RW(field) \
733 i->private_host_attrs[count] = class_device_attr_host_##field; \
734 if (!i->f->set_host_##field) { \
735 i->private_host_attrs[count].attr.mode = S_IRUGO; \
736 i->private_host_attrs[count].store = NULL; \
738 i->host_attrs[count] = &i->private_host_attrs[count]; \
739 if (i->f->show_host_##field) \
743 #define fc_private_host_show_function(field, format_string, sz, cast) \
745 show_fc_host_##field (struct class_device *cdev, char *buf) \
747 struct Scsi_Host *shost = transport_class_to_shost(cdev); \
748 return snprintf(buf, sz, format_string, cast fc_host_##field(shost)); \
751 #define fc_private_host_rd_attr(field, format_string, sz) \
752 fc_private_host_show_function(field, format_string, sz, ) \
753 static FC_CLASS_DEVICE_ATTR(host, field, S_IRUGO, \
754 show_fc_host_##field, NULL)
756 #define fc_private_host_rd_attr_cast(field, format_string, sz, cast) \
757 fc_private_host_show_function(field, format_string, sz, (cast)) \
758 static FC_CLASS_DEVICE_ATTR(host, field, S_IRUGO, \
759 show_fc_host_##field, NULL)
761 #define SETUP_PRIVATE_HOST_ATTRIBUTE_RD(field) \
762 i->private_host_attrs[count] = class_device_attr_host_##field; \
763 i->private_host_attrs[count].attr.mode = S_IRUGO; \
764 i->private_host_attrs[count].store = NULL; \
765 i->host_attrs[count] = &i->private_host_attrs[count]; \
768 #define SETUP_PRIVATE_HOST_ATTRIBUTE_RW(field) \
770 i->private_host_attrs[count] = class_device_attr_host_##field; \
771 i->host_attrs[count] = &i->private_host_attrs[count]; \
776 /* Fixed Host Attributes */
779 show_fc_host_supported_classes (struct class_device *cdev, char *buf)
781 struct Scsi_Host *shost = transport_class_to_shost(cdev);
783 if (fc_host_supported_classes(shost) == FC_COS_UNSPECIFIED)
784 return snprintf(buf, 20, "unspecified\n");
786 return get_fc_cos_names(fc_host_supported_classes(shost), buf);
788 static FC_CLASS_DEVICE_ATTR(host, supported_classes, S_IRUGO,
789 show_fc_host_supported_classes, NULL);
792 show_fc_host_supported_fc4s (struct class_device *cdev, char *buf)
794 struct Scsi_Host *shost = transport_class_to_shost(cdev);
795 return (ssize_t)show_fc_fc4s(buf, fc_host_supported_fc4s(shost));
797 static FC_CLASS_DEVICE_ATTR(host, supported_fc4s, S_IRUGO,
798 show_fc_host_supported_fc4s, NULL);
801 show_fc_host_supported_speeds (struct class_device *cdev, char *buf)
803 struct Scsi_Host *shost = transport_class_to_shost(cdev);
805 if (fc_host_supported_speeds(shost) == FC_PORTSPEED_UNKNOWN)
806 return snprintf(buf, 20, "unknown\n");
808 return get_fc_port_speed_names(fc_host_supported_speeds(shost), buf);
810 static FC_CLASS_DEVICE_ATTR(host, supported_speeds, S_IRUGO,
811 show_fc_host_supported_speeds, NULL);
814 fc_private_host_rd_attr_cast(node_name, "0x%llx\n", 20, unsigned long long);
815 fc_private_host_rd_attr_cast(port_name, "0x%llx\n", 20, unsigned long long);
816 fc_private_host_rd_attr_cast(permanent_port_name, "0x%llx\n", 20,
818 fc_private_host_rd_attr(symbolic_name, "%s\n", (FC_SYMBOLIC_NAME_SIZE +1));
819 fc_private_host_rd_attr(maxframe_size, "%u bytes\n", 20);
820 fc_private_host_rd_attr(serial_number, "%s\n", (FC_SERIAL_NUMBER_SIZE +1));
823 /* Dynamic Host Attributes */
826 show_fc_host_active_fc4s (struct class_device *cdev, char *buf)
828 struct Scsi_Host *shost = transport_class_to_shost(cdev);
829 struct fc_internal *i = to_fc_internal(shost->transportt);
831 if (i->f->get_host_active_fc4s)
832 i->f->get_host_active_fc4s(shost);
834 return (ssize_t)show_fc_fc4s(buf, fc_host_active_fc4s(shost));
836 static FC_CLASS_DEVICE_ATTR(host, active_fc4s, S_IRUGO,
837 show_fc_host_active_fc4s, NULL);
840 show_fc_host_speed (struct class_device *cdev, char *buf)
842 struct Scsi_Host *shost = transport_class_to_shost(cdev);
843 struct fc_internal *i = to_fc_internal(shost->transportt);
845 if (i->f->get_host_speed)
846 i->f->get_host_speed(shost);
848 if (fc_host_speed(shost) == FC_PORTSPEED_UNKNOWN)
849 return snprintf(buf, 20, "unknown\n");
851 return get_fc_port_speed_names(fc_host_speed(shost), buf);
853 static FC_CLASS_DEVICE_ATTR(host, speed, S_IRUGO,
854 show_fc_host_speed, NULL);
857 fc_host_rd_attr(port_id, "0x%06x\n", 20);
858 fc_host_rd_enum_attr(port_type, FC_PORTTYPE_MAX_NAMELEN);
859 fc_host_rd_enum_attr(port_state, FC_PORTSTATE_MAX_NAMELEN);
860 fc_host_rd_attr_cast(fabric_name, "0x%llx\n", 20, unsigned long long);
863 /* Private Host Attributes */
866 show_fc_private_host_tgtid_bind_type(struct class_device *cdev, char *buf)
868 struct Scsi_Host *shost = transport_class_to_shost(cdev);
871 name = get_fc_tgtid_bind_type_name(fc_host_tgtid_bind_type(shost));
874 return snprintf(buf, FC_BINDTYPE_MAX_NAMELEN, "%s\n", name);
877 #define get_list_head_entry(pos, head, member) \
878 pos = list_entry((head)->next, typeof(*pos), member)
881 store_fc_private_host_tgtid_bind_type(struct class_device *cdev,
882 const char *buf, size_t count)
884 struct Scsi_Host *shost = transport_class_to_shost(cdev);
885 struct fc_rport *rport;
886 enum fc_tgtid_binding_type val;
889 if (get_fc_tgtid_bind_type_match(buf, &val))
892 /* if changing bind type, purge all unused consistent bindings */
893 if (val != fc_host_tgtid_bind_type(shost)) {
894 spin_lock_irqsave(shost->host_lock, flags);
895 while (!list_empty(&fc_host_rport_bindings(shost))) {
896 get_list_head_entry(rport,
897 &fc_host_rport_bindings(shost), peers);
898 list_del(&rport->peers);
899 rport->port_state = FC_PORTSTATE_DELETED;
900 fc_queue_work(shost, &rport->rport_delete_work);
902 spin_unlock_irqrestore(shost->host_lock, flags);
905 fc_host_tgtid_bind_type(shost) = val;
909 static FC_CLASS_DEVICE_ATTR(host, tgtid_bind_type, S_IRUGO | S_IWUSR,
910 show_fc_private_host_tgtid_bind_type,
911 store_fc_private_host_tgtid_bind_type);
914 store_fc_private_host_issue_lip(struct class_device *cdev,
915 const char *buf, size_t count)
917 struct Scsi_Host *shost = transport_class_to_shost(cdev);
918 struct fc_internal *i = to_fc_internal(shost->transportt);
921 /* ignore any data value written to the attribute */
922 if (i->f->issue_fc_host_lip) {
923 ret = i->f->issue_fc_host_lip(shost);
924 return ret ? ret: count;
930 static FC_CLASS_DEVICE_ATTR(host, issue_lip, S_IWUSR, NULL,
931 store_fc_private_host_issue_lip);
934 * Host Statistics Management
937 /* Show a given an attribute in the statistics group */
939 fc_stat_show(const struct class_device *cdev, char *buf, unsigned long offset)
941 struct Scsi_Host *shost = transport_class_to_shost(cdev);
942 struct fc_internal *i = to_fc_internal(shost->transportt);
943 struct fc_host_statistics *stats;
944 ssize_t ret = -ENOENT;
946 if (offset > sizeof(struct fc_host_statistics) ||
947 offset % sizeof(u64) != 0)
950 if (i->f->get_fc_host_stats) {
951 stats = (i->f->get_fc_host_stats)(shost);
953 ret = snprintf(buf, 20, "0x%llx\n",
954 (unsigned long long)*(u64 *)(((u8 *) stats) + offset));
960 /* generate a read-only statistics attribute */
961 #define fc_host_statistic(name) \
962 static ssize_t show_fcstat_##name(struct class_device *cd, char *buf) \
964 return fc_stat_show(cd, buf, \
965 offsetof(struct fc_host_statistics, name)); \
967 static FC_CLASS_DEVICE_ATTR(host, name, S_IRUGO, show_fcstat_##name, NULL)
969 fc_host_statistic(seconds_since_last_reset);
970 fc_host_statistic(tx_frames);
971 fc_host_statistic(tx_words);
972 fc_host_statistic(rx_frames);
973 fc_host_statistic(rx_words);
974 fc_host_statistic(lip_count);
975 fc_host_statistic(nos_count);
976 fc_host_statistic(error_frames);
977 fc_host_statistic(dumped_frames);
978 fc_host_statistic(link_failure_count);
979 fc_host_statistic(loss_of_sync_count);
980 fc_host_statistic(loss_of_signal_count);
981 fc_host_statistic(prim_seq_protocol_err_count);
982 fc_host_statistic(invalid_tx_word_count);
983 fc_host_statistic(invalid_crc_count);
984 fc_host_statistic(fcp_input_requests);
985 fc_host_statistic(fcp_output_requests);
986 fc_host_statistic(fcp_control_requests);
987 fc_host_statistic(fcp_input_megabytes);
988 fc_host_statistic(fcp_output_megabytes);
991 fc_reset_statistics(struct class_device *cdev, const char *buf,
994 struct Scsi_Host *shost = transport_class_to_shost(cdev);
995 struct fc_internal *i = to_fc_internal(shost->transportt);
997 /* ignore any data value written to the attribute */
998 if (i->f->reset_fc_host_stats) {
999 i->f->reset_fc_host_stats(shost);
1005 static FC_CLASS_DEVICE_ATTR(host, reset_statistics, S_IWUSR, NULL,
1006 fc_reset_statistics);
1009 static struct attribute *fc_statistics_attrs[] = {
1010 &class_device_attr_host_seconds_since_last_reset.attr,
1011 &class_device_attr_host_tx_frames.attr,
1012 &class_device_attr_host_tx_words.attr,
1013 &class_device_attr_host_rx_frames.attr,
1014 &class_device_attr_host_rx_words.attr,
1015 &class_device_attr_host_lip_count.attr,
1016 &class_device_attr_host_nos_count.attr,
1017 &class_device_attr_host_error_frames.attr,
1018 &class_device_attr_host_dumped_frames.attr,
1019 &class_device_attr_host_link_failure_count.attr,
1020 &class_device_attr_host_loss_of_sync_count.attr,
1021 &class_device_attr_host_loss_of_signal_count.attr,
1022 &class_device_attr_host_prim_seq_protocol_err_count.attr,
1023 &class_device_attr_host_invalid_tx_word_count.attr,
1024 &class_device_attr_host_invalid_crc_count.attr,
1025 &class_device_attr_host_fcp_input_requests.attr,
1026 &class_device_attr_host_fcp_output_requests.attr,
1027 &class_device_attr_host_fcp_control_requests.attr,
1028 &class_device_attr_host_fcp_input_megabytes.attr,
1029 &class_device_attr_host_fcp_output_megabytes.attr,
1030 &class_device_attr_host_reset_statistics.attr,
1034 static struct attribute_group fc_statistics_group = {
1035 .name = "statistics",
1036 .attrs = fc_statistics_attrs,
1039 static int fc_host_match(struct attribute_container *cont,
1042 struct Scsi_Host *shost;
1043 struct fc_internal *i;
1045 if (!scsi_is_host_device(dev))
1048 shost = dev_to_shost(dev);
1049 if (!shost->transportt || shost->transportt->host_attrs.ac.class
1050 != &fc_host_class.class)
1053 i = to_fc_internal(shost->transportt);
1055 return &i->t.host_attrs.ac == cont;
1058 static int fc_target_match(struct attribute_container *cont,
1061 struct Scsi_Host *shost;
1062 struct fc_internal *i;
1064 if (!scsi_is_target_device(dev))
1067 shost = dev_to_shost(dev->parent);
1068 if (!shost->transportt || shost->transportt->host_attrs.ac.class
1069 != &fc_host_class.class)
1072 i = to_fc_internal(shost->transportt);
1074 return &i->t.target_attrs.ac == cont;
1077 static void fc_rport_dev_release(struct device *dev)
1079 struct fc_rport *rport = dev_to_rport(dev);
1080 put_device(dev->parent);
1084 int scsi_is_fc_rport(const struct device *dev)
1086 return dev->release == fc_rport_dev_release;
1088 EXPORT_SYMBOL(scsi_is_fc_rport);
1090 static int fc_rport_match(struct attribute_container *cont,
1093 struct Scsi_Host *shost;
1094 struct fc_internal *i;
1096 if (!scsi_is_fc_rport(dev))
1099 shost = dev_to_shost(dev->parent);
1100 if (!shost->transportt || shost->transportt->host_attrs.ac.class
1101 != &fc_host_class.class)
1104 i = to_fc_internal(shost->transportt);
1106 return &i->rport_attr_cont.ac == cont;
1111 * fc_timed_out - FC Transport I/O timeout intercept handler
1113 * @scmd: The SCSI command which timed out
1115 * This routine protects against error handlers getting invoked while a
1116 * rport is in a blocked state, typically due to a temporarily loss of
1117 * connectivity. If the error handlers are allowed to proceed, requests
1118 * to abort i/o, reset the target, etc will likely fail as there is no way
1119 * to communicate with the device to perform the requested function. These
1120 * failures may result in the midlayer taking the device offline, requiring
1121 * manual intervention to restore operation.
1123 * This routine, called whenever an i/o times out, validates the state of
1124 * the underlying rport. If the rport is blocked, it returns
1125 * EH_RESET_TIMER, which will continue to reschedule the timeout.
1126 * Eventually, either the device will return, or devloss_tmo will fire,
1127 * and when the timeout then fires, it will be handled normally.
1128 * If the rport is not blocked, normal error handling continues.
1131 * This routine assumes no locks are held on entry.
1133 static enum scsi_eh_timer_return
1134 fc_timed_out(struct scsi_cmnd *scmd)
1136 struct fc_rport *rport = starget_to_rport(scsi_target(scmd->device));
1138 if (rport->port_state == FC_PORTSTATE_BLOCKED)
1139 return EH_RESET_TIMER;
1141 return EH_NOT_HANDLED;
1145 * Must be called with shost->host_lock held
1147 static int fc_user_scan(struct Scsi_Host *shost, uint channel,
1150 struct fc_rport *rport;
1152 list_for_each_entry(rport, &fc_host_rports(shost), peers) {
1153 if (rport->scsi_target_id == -1)
1156 if ((channel == SCAN_WILD_CARD || channel == rport->channel) &&
1157 (id == SCAN_WILD_CARD || id == rport->scsi_target_id)) {
1158 scsi_scan_target(&rport->dev, rport->channel,
1159 rport->scsi_target_id, lun, 1);
1166 struct scsi_transport_template *
1167 fc_attach_transport(struct fc_function_template *ft)
1170 struct fc_internal *i = kzalloc(sizeof(struct fc_internal),
1176 i->t.target_attrs.ac.attrs = &i->starget_attrs[0];
1177 i->t.target_attrs.ac.class = &fc_transport_class.class;
1178 i->t.target_attrs.ac.match = fc_target_match;
1179 i->t.target_size = sizeof(struct fc_starget_attrs);
1180 transport_container_register(&i->t.target_attrs);
1182 i->t.host_attrs.ac.attrs = &i->host_attrs[0];
1183 i->t.host_attrs.ac.class = &fc_host_class.class;
1184 i->t.host_attrs.ac.match = fc_host_match;
1185 i->t.host_size = sizeof(struct fc_host_attrs);
1186 if (ft->get_fc_host_stats)
1187 i->t.host_attrs.statistics = &fc_statistics_group;
1188 transport_container_register(&i->t.host_attrs);
1190 i->rport_attr_cont.ac.attrs = &i->rport_attrs[0];
1191 i->rport_attr_cont.ac.class = &fc_rport_class.class;
1192 i->rport_attr_cont.ac.match = fc_rport_match;
1193 transport_container_register(&i->rport_attr_cont);
1197 /* Transport uses the shost workq for scsi scanning */
1198 i->t.create_work_queue = 1;
1200 i->t.eh_timed_out = fc_timed_out;
1202 i->t.user_scan = fc_user_scan;
1205 * Setup SCSI Target Attributes.
1208 SETUP_STARGET_ATTRIBUTE_RD(node_name);
1209 SETUP_STARGET_ATTRIBUTE_RD(port_name);
1210 SETUP_STARGET_ATTRIBUTE_RD(port_id);
1212 BUG_ON(count > FC_STARGET_NUM_ATTRS);
1214 i->starget_attrs[count] = NULL;
1218 * Setup SCSI Host Attributes.
1221 SETUP_HOST_ATTRIBUTE_RD(node_name);
1222 SETUP_HOST_ATTRIBUTE_RD(port_name);
1223 SETUP_HOST_ATTRIBUTE_RD(permanent_port_name);
1224 SETUP_HOST_ATTRIBUTE_RD(supported_classes);
1225 SETUP_HOST_ATTRIBUTE_RD(supported_fc4s);
1226 SETUP_HOST_ATTRIBUTE_RD(symbolic_name);
1227 SETUP_HOST_ATTRIBUTE_RD(supported_speeds);
1228 SETUP_HOST_ATTRIBUTE_RD(maxframe_size);
1229 SETUP_HOST_ATTRIBUTE_RD(serial_number);
1231 SETUP_HOST_ATTRIBUTE_RD(port_id);
1232 SETUP_HOST_ATTRIBUTE_RD(port_type);
1233 SETUP_HOST_ATTRIBUTE_RD(port_state);
1234 SETUP_HOST_ATTRIBUTE_RD(active_fc4s);
1235 SETUP_HOST_ATTRIBUTE_RD(speed);
1236 SETUP_HOST_ATTRIBUTE_RD(fabric_name);
1238 /* Transport-managed attributes */
1239 SETUP_PRIVATE_HOST_ATTRIBUTE_RW(tgtid_bind_type);
1240 if (ft->issue_fc_host_lip)
1241 SETUP_PRIVATE_HOST_ATTRIBUTE_RW(issue_lip);
1243 BUG_ON(count > FC_HOST_NUM_ATTRS);
1245 i->host_attrs[count] = NULL;
1248 * Setup Remote Port Attributes.
1251 SETUP_RPORT_ATTRIBUTE_RD(maxframe_size);
1252 SETUP_RPORT_ATTRIBUTE_RD(supported_classes);
1253 SETUP_RPORT_ATTRIBUTE_RW(dev_loss_tmo);
1254 SETUP_PRIVATE_RPORT_ATTRIBUTE_RD(node_name);
1255 SETUP_PRIVATE_RPORT_ATTRIBUTE_RD(port_name);
1256 SETUP_PRIVATE_RPORT_ATTRIBUTE_RD(port_id);
1257 SETUP_PRIVATE_RPORT_ATTRIBUTE_RD(roles);
1258 SETUP_PRIVATE_RPORT_ATTRIBUTE_RD(port_state);
1259 SETUP_PRIVATE_RPORT_ATTRIBUTE_RD(scsi_target_id);
1261 BUG_ON(count > FC_RPORT_NUM_ATTRS);
1263 i->rport_attrs[count] = NULL;
1267 EXPORT_SYMBOL(fc_attach_transport);
1269 void fc_release_transport(struct scsi_transport_template *t)
1271 struct fc_internal *i = to_fc_internal(t);
1273 transport_container_unregister(&i->t.target_attrs);
1274 transport_container_unregister(&i->t.host_attrs);
1275 transport_container_unregister(&i->rport_attr_cont);
1279 EXPORT_SYMBOL(fc_release_transport);
1282 * fc_queue_work - Queue work to the fc_host workqueue.
1283 * @shost: Pointer to Scsi_Host bound to fc_host.
1284 * @work: Work to queue for execution.
1287 * 1 - work queued for execution
1288 * 0 - work is already queued
1289 * -EINVAL - work queue doesn't exist
1292 fc_queue_work(struct Scsi_Host *shost, struct work_struct *work)
1294 if (unlikely(!fc_host_work_q(shost))) {
1296 "ERROR: FC host '%s' attempted to queue work, "
1297 "when no workqueue created.\n", shost->hostt->name);
1303 return queue_work(fc_host_work_q(shost), work);
1307 * fc_flush_work - Flush a fc_host's workqueue.
1308 * @shost: Pointer to Scsi_Host bound to fc_host.
1311 fc_flush_work(struct Scsi_Host *shost)
1313 if (!fc_host_work_q(shost)) {
1315 "ERROR: FC host '%s' attempted to flush work, "
1316 "when no workqueue created.\n", shost->hostt->name);
1321 flush_workqueue(fc_host_work_q(shost));
1325 * fc_queue_devloss_work - Schedule work for the fc_host devloss workqueue.
1326 * @shost: Pointer to Scsi_Host bound to fc_host.
1327 * @work: Work to queue for execution.
1328 * @delay: jiffies to delay the work queuing
1331 * 0 on success / != 0 for error
1334 fc_queue_devloss_work(struct Scsi_Host *shost, struct work_struct *work,
1335 unsigned long delay)
1337 if (unlikely(!fc_host_devloss_work_q(shost))) {
1339 "ERROR: FC host '%s' attempted to queue work, "
1340 "when no workqueue created.\n", shost->hostt->name);
1346 return queue_delayed_work(fc_host_devloss_work_q(shost), work, delay);
1350 * fc_flush_devloss - Flush a fc_host's devloss workqueue.
1351 * @shost: Pointer to Scsi_Host bound to fc_host.
1354 fc_flush_devloss(struct Scsi_Host *shost)
1356 if (!fc_host_devloss_work_q(shost)) {
1358 "ERROR: FC host '%s' attempted to flush work, "
1359 "when no workqueue created.\n", shost->hostt->name);
1364 flush_workqueue(fc_host_devloss_work_q(shost));
1369 * fc_remove_host - called to terminate any fc_transport-related elements
1371 * @rport: remote port to be unblocked.
1373 * This routine is expected to be called immediately preceeding the
1374 * a driver's call to scsi_remove_host().
1376 * WARNING: A driver utilizing the fc_transport, which fails to call
1377 * this routine prior to scsi_remote_host(), will leave dangling
1378 * objects in /sys/class/fc_remote_ports. Access to any of these
1379 * objects can result in a system crash !!!
1382 * This routine assumes no locks are held on entry.
1385 fc_remove_host(struct Scsi_Host *shost)
1387 struct fc_rport *rport, *next_rport;
1388 struct workqueue_struct *work_q;
1389 struct fc_host_attrs *fc_host = shost_to_fc_host(shost);
1391 /* Remove any remote ports */
1392 list_for_each_entry_safe(rport, next_rport,
1393 &fc_host->rports, peers) {
1394 list_del(&rport->peers);
1395 rport->port_state = FC_PORTSTATE_DELETED;
1396 fc_queue_work(shost, &rport->rport_delete_work);
1399 list_for_each_entry_safe(rport, next_rport,
1400 &fc_host->rport_bindings, peers) {
1401 list_del(&rport->peers);
1402 rport->port_state = FC_PORTSTATE_DELETED;
1403 fc_queue_work(shost, &rport->rport_delete_work);
1406 /* flush all scan work items */
1407 scsi_flush_work(shost);
1409 /* flush all stgt delete, and rport delete work items, then kill it */
1410 if (fc_host->work_q) {
1411 work_q = fc_host->work_q;
1412 fc_host->work_q = NULL;
1413 destroy_workqueue(work_q);
1416 /* flush all devloss work items, then kill it */
1417 if (fc_host->devloss_work_q) {
1418 work_q = fc_host->devloss_work_q;
1419 fc_host->devloss_work_q = NULL;
1420 destroy_workqueue(work_q);
1423 EXPORT_SYMBOL(fc_remove_host);
1427 * fc_starget_delete - called to delete the scsi decendents of an rport
1428 * (target and all sdevs)
1430 * @data: remote port to be operated on.
1433 fc_starget_delete(void *data)
1435 struct fc_rport *rport = (struct fc_rport *)data;
1436 struct Scsi_Host *shost = rport_to_shost(rport);
1437 unsigned long flags;
1439 spin_lock_irqsave(shost->host_lock, flags);
1440 if (rport->flags & FC_RPORT_DEVLOSS_PENDING) {
1441 spin_unlock_irqrestore(shost->host_lock, flags);
1442 if (!cancel_delayed_work(&rport->dev_loss_work))
1443 fc_flush_devloss(shost);
1444 spin_lock_irqsave(shost->host_lock, flags);
1445 rport->flags &= ~FC_RPORT_DEVLOSS_PENDING;
1447 spin_unlock_irqrestore(shost->host_lock, flags);
1449 scsi_remove_target(&rport->dev);
1454 * fc_rport_final_delete - finish rport termination and delete it.
1456 * @data: remote port to be deleted.
1459 fc_rport_final_delete(void *data)
1461 struct fc_rport *rport = (struct fc_rport *)data;
1462 struct device *dev = &rport->dev;
1463 struct Scsi_Host *shost = rport_to_shost(rport);
1465 /* Delete SCSI target and sdevs */
1466 if (rport->scsi_target_id != -1)
1467 fc_starget_delete(data);
1470 * if a scan is pending, flush the SCSI Host work_q so that
1471 * that we can reclaim the rport scan work element.
1473 if (rport->flags & FC_RPORT_SCAN_PENDING)
1474 scsi_flush_work(shost);
1476 transport_remove_device(dev);
1478 transport_destroy_device(dev);
1479 put_device(&shost->shost_gendev); /* for fc_host->rport list */
1480 put_device(dev); /* for self-reference */
1485 * fc_rport_create - allocates and creates a remote FC port.
1486 * @shost: scsi host the remote port is connected to.
1487 * @channel: Channel on shost port connected to.
1488 * @ids: The world wide names, fc address, and FC4 port
1489 * roles for the remote port.
1491 * Allocates and creates the remoter port structure, including the
1492 * class and sysfs creation.
1495 * This routine assumes no locks are held on entry.
1498 fc_rport_create(struct Scsi_Host *shost, int channel,
1499 struct fc_rport_identifiers *ids)
1501 struct fc_host_attrs *fc_host = shost_to_fc_host(shost);
1502 struct fc_internal *fci = to_fc_internal(shost->transportt);
1503 struct fc_rport *rport;
1505 unsigned long flags;
1509 size = (sizeof(struct fc_rport) + fci->f->dd_fcrport_size);
1510 rport = kzalloc(size, GFP_KERNEL);
1511 if (unlikely(!rport)) {
1512 printk(KERN_ERR "%s: allocation failure\n", __FUNCTION__);
1516 rport->maxframe_size = -1;
1517 rport->supported_classes = FC_COS_UNSPECIFIED;
1518 rport->dev_loss_tmo = fc_dev_loss_tmo;
1519 memcpy(&rport->node_name, &ids->node_name, sizeof(rport->node_name));
1520 memcpy(&rport->port_name, &ids->port_name, sizeof(rport->port_name));
1521 rport->port_id = ids->port_id;
1522 rport->roles = ids->roles;
1523 rport->port_state = FC_PORTSTATE_ONLINE;
1524 if (fci->f->dd_fcrport_size)
1525 rport->dd_data = &rport[1];
1526 rport->channel = channel;
1528 INIT_WORK(&rport->dev_loss_work, fc_timeout_deleted_rport, rport);
1529 INIT_WORK(&rport->scan_work, fc_scsi_scan_rport, rport);
1530 INIT_WORK(&rport->stgt_delete_work, fc_starget_delete, rport);
1531 INIT_WORK(&rport->rport_delete_work, fc_rport_final_delete, rport);
1533 spin_lock_irqsave(shost->host_lock, flags);
1535 rport->number = fc_host->next_rport_number++;
1536 if (rport->roles & FC_RPORT_ROLE_FCP_TARGET)
1537 rport->scsi_target_id = fc_host->next_target_id++;
1539 rport->scsi_target_id = -1;
1540 list_add_tail(&rport->peers, &fc_host->rports);
1541 get_device(&shost->shost_gendev); /* for fc_host->rport list */
1543 spin_unlock_irqrestore(shost->host_lock, flags);
1546 device_initialize(dev); /* takes self reference */
1547 dev->parent = get_device(&shost->shost_gendev); /* parent reference */
1548 dev->release = fc_rport_dev_release;
1549 sprintf(dev->bus_id, "rport-%d:%d-%d",
1550 shost->host_no, channel, rport->number);
1551 transport_setup_device(dev);
1553 error = device_add(dev);
1555 printk(KERN_ERR "FC Remote Port device_add failed\n");
1558 transport_add_device(dev);
1559 transport_configure_device(dev);
1561 if (rport->roles & FC_RPORT_ROLE_FCP_TARGET) {
1562 /* initiate a scan of the target */
1563 rport->flags |= FC_RPORT_SCAN_PENDING;
1564 scsi_queue_work(shost, &rport->scan_work);
1570 transport_destroy_device(dev);
1571 spin_lock_irqsave(shost->host_lock, flags);
1572 list_del(&rport->peers);
1573 put_device(&shost->shost_gendev); /* for fc_host->rport list */
1574 spin_unlock_irqrestore(shost->host_lock, flags);
1575 put_device(dev->parent);
1581 * fc_remote_port_add - notifies the fc transport of the existence
1582 * of a remote FC port.
1583 * @shost: scsi host the remote port is connected to.
1584 * @channel: Channel on shost port connected to.
1585 * @ids: The world wide names, fc address, and FC4 port
1586 * roles for the remote port.
1588 * The LLDD calls this routine to notify the transport of the existence
1589 * of a remote port. The LLDD provides the unique identifiers (wwpn,wwn)
1590 * of the port, it's FC address (port_id), and the FC4 roles that are
1591 * active for the port.
1593 * For ports that are FCP targets (aka scsi targets), the FC transport
1594 * maintains consistent target id bindings on behalf of the LLDD.
1595 * A consistent target id binding is an assignment of a target id to
1596 * a remote port identifier, which persists while the scsi host is
1597 * attached. The remote port can disappear, then later reappear, and
1598 * it's target id assignment remains the same. This allows for shifts
1599 * in FC addressing (if binding by wwpn or wwnn) with no apparent
1600 * changes to the scsi subsystem which is based on scsi host number and
1601 * target id values. Bindings are only valid during the attachment of
1602 * the scsi host. If the host detaches, then later re-attaches, target
1603 * id bindings may change.
1605 * This routine is responsible for returning a remote port structure.
1606 * The routine will search the list of remote ports it maintains
1607 * internally on behalf of consistent target id mappings. If found, the
1608 * remote port structure will be reused. Otherwise, a new remote port
1609 * structure will be allocated.
1611 * Whenever a remote port is allocated, a new fc_remote_port class
1612 * device is created.
1614 * Should not be called from interrupt context.
1617 * This routine assumes no locks are held on entry.
1620 fc_remote_port_add(struct Scsi_Host *shost, int channel,
1621 struct fc_rport_identifiers *ids)
1623 struct fc_internal *fci = to_fc_internal(shost->transportt);
1624 struct fc_host_attrs *fc_host = shost_to_fc_host(shost);
1625 struct fc_rport *rport;
1626 unsigned long flags;
1629 /* ensure any stgt delete functions are done */
1630 fc_flush_work(shost);
1633 * Search the list of "active" rports, for an rport that has been
1634 * deleted, but we've held off the real delete while the target
1635 * is in a "blocked" state.
1637 spin_lock_irqsave(shost->host_lock, flags);
1639 list_for_each_entry(rport, &fc_host->rports, peers) {
1641 if ((rport->port_state == FC_PORTSTATE_BLOCKED) &&
1642 (rport->channel == channel)) {
1644 switch (fc_host->tgtid_bind_type) {
1645 case FC_TGTID_BIND_BY_WWPN:
1646 case FC_TGTID_BIND_NONE:
1647 if (rport->port_name == ids->port_name)
1650 case FC_TGTID_BIND_BY_WWNN:
1651 if (rport->node_name == ids->node_name)
1654 case FC_TGTID_BIND_BY_ID:
1655 if (rport->port_id == ids->port_id)
1661 struct work_struct *work =
1662 &rport->dev_loss_work;
1664 memcpy(&rport->node_name, &ids->node_name,
1665 sizeof(rport->node_name));
1666 memcpy(&rport->port_name, &ids->port_name,
1667 sizeof(rport->port_name));
1668 rport->port_id = ids->port_id;
1670 rport->port_state = FC_PORTSTATE_ONLINE;
1671 rport->roles = ids->roles;
1673 spin_unlock_irqrestore(shost->host_lock, flags);
1675 if (fci->f->dd_fcrport_size)
1676 memset(rport->dd_data, 0,
1677 fci->f->dd_fcrport_size);
1680 * If we were blocked, we were a target.
1681 * If no longer a target, we leave the timer
1682 * running in case the port changes roles
1683 * prior to the timer expiring. If the timer
1684 * fires, the target will be torn down.
1686 if (!(ids->roles & FC_RPORT_ROLE_FCP_TARGET))
1689 /* restart the target */
1692 * Stop the target timer first. Take no action
1693 * on the del_timer failure as the state
1694 * machine state change will validate the
1697 if (!cancel_delayed_work(work))
1698 fc_flush_devloss(shost);
1700 spin_lock_irqsave(shost->host_lock, flags);
1702 rport->flags &= ~FC_RPORT_DEVLOSS_PENDING;
1704 /* initiate a scan of the target */
1705 rport->flags |= FC_RPORT_SCAN_PENDING;
1706 scsi_queue_work(shost, &rport->scan_work);
1708 spin_unlock_irqrestore(shost->host_lock, flags);
1710 scsi_target_unblock(&rport->dev);
1717 /* Search the bindings array */
1718 if (fc_host->tgtid_bind_type != FC_TGTID_BIND_NONE) {
1720 /* search for a matching consistent binding */
1722 list_for_each_entry(rport, &fc_host->rport_bindings,
1724 if (rport->channel != channel)
1727 switch (fc_host->tgtid_bind_type) {
1728 case FC_TGTID_BIND_BY_WWPN:
1729 if (rport->port_name == ids->port_name)
1732 case FC_TGTID_BIND_BY_WWNN:
1733 if (rport->node_name == ids->node_name)
1736 case FC_TGTID_BIND_BY_ID:
1737 if (rport->port_id == ids->port_id)
1740 case FC_TGTID_BIND_NONE: /* to keep compiler happy */
1745 list_move_tail(&rport->peers, &fc_host->rports);
1751 memcpy(&rport->node_name, &ids->node_name,
1752 sizeof(rport->node_name));
1753 memcpy(&rport->port_name, &ids->port_name,
1754 sizeof(rport->port_name));
1755 rport->port_id = ids->port_id;
1756 rport->roles = ids->roles;
1757 rport->port_state = FC_PORTSTATE_ONLINE;
1759 if (fci->f->dd_fcrport_size)
1760 memset(rport->dd_data, 0,
1761 fci->f->dd_fcrport_size);
1763 if (rport->roles & FC_RPORT_ROLE_FCP_TARGET) {
1764 /* initiate a scan of the target */
1765 rport->flags |= FC_RPORT_SCAN_PENDING;
1766 scsi_queue_work(shost, &rport->scan_work);
1767 spin_unlock_irqrestore(shost->host_lock, flags);
1768 scsi_target_unblock(&rport->dev);
1770 spin_unlock_irqrestore(shost->host_lock, flags);
1776 spin_unlock_irqrestore(shost->host_lock, flags);
1778 /* No consistent binding found - create new remote port entry */
1779 rport = fc_rport_create(shost, channel, ids);
1783 EXPORT_SYMBOL(fc_remote_port_add);
1787 * fc_remote_port_delete - notifies the fc transport that a remote
1788 * port is no longer in existence.
1789 * @rport: The remote port that no longer exists
1791 * The LLDD calls this routine to notify the transport that a remote
1792 * port is no longer part of the topology. Note: Although a port
1793 * may no longer be part of the topology, it may persist in the remote
1794 * ports displayed by the fc_host. We do this under 2 conditions:
1795 * - If the port was a scsi target, we delay its deletion by "blocking" it.
1796 * This allows the port to temporarily disappear, then reappear without
1797 * disrupting the SCSI device tree attached to it. During the "blocked"
1798 * period the port will still exist.
1799 * - If the port was a scsi target and disappears for longer than we
1800 * expect, we'll delete the port and the tear down the SCSI device tree
1801 * attached to it. However, we want to semi-persist the target id assigned
1802 * to that port if it eventually does exist. The port structure will
1803 * remain (although with minimal information) so that the target id
1806 * If the remote port is not an FCP Target, it will be fully torn down
1807 * and deallocated, including the fc_remote_port class device.
1809 * If the remote port is an FCP Target, the port will be placed in a
1810 * temporary blocked state. From the LLDD's perspective, the rport no
1811 * longer exists. From the SCSI midlayer's perspective, the SCSI target
1812 * exists, but all sdevs on it are blocked from further I/O. The following
1814 * If the remote port does not return (signaled by a LLDD call to
1815 * fc_remote_port_add()) within the dev_loss_tmo timeout, then the
1816 * scsi target is removed - killing all outstanding i/o and removing the
1817 * scsi devices attached ot it. The port structure will be marked Not
1818 * Present and be partially cleared, leaving only enough information to
1819 * recognize the remote port relative to the scsi target id binding if
1820 * it later appears. The port will remain as long as there is a valid
1821 * binding (e.g. until the user changes the binding type or unloads the
1822 * scsi host with the binding).
1824 * If the remote port returns within the dev_loss_tmo value (and matches
1825 * according to the target id binding type), the port structure will be
1826 * reused. If it is no longer a SCSI target, the target will be torn
1827 * down. If it continues to be a SCSI target, then the target will be
1828 * unblocked (allowing i/o to be resumed), and a scan will be activated
1829 * to ensure that all luns are detected.
1831 * Called from normal process context only - cannot be called from interrupt.
1834 * This routine assumes no locks are held on entry.
1837 fc_remote_port_delete(struct fc_rport *rport)
1839 struct Scsi_Host *shost = rport_to_shost(rport);
1840 int timeout = rport->dev_loss_tmo;
1841 unsigned long flags;
1844 * No need to flush the fc_host work_q's, as all adds are synchronous.
1846 * We do need to reclaim the rport scan work element, so eventually
1847 * (in fc_rport_final_delete()) we'll flush the scsi host work_q if
1848 * there's still a scan pending.
1851 spin_lock_irqsave(shost->host_lock, flags);
1853 /* If no scsi target id mapping, delete it */
1854 if (rport->scsi_target_id == -1) {
1855 list_del(&rport->peers);
1856 rport->port_state = FC_PORTSTATE_DELETED;
1857 fc_queue_work(shost, &rport->rport_delete_work);
1858 spin_unlock_irqrestore(shost->host_lock, flags);
1862 rport->port_state = FC_PORTSTATE_BLOCKED;
1864 rport->flags |= FC_RPORT_DEVLOSS_PENDING;
1866 spin_unlock_irqrestore(shost->host_lock, flags);
1868 scsi_target_block(&rport->dev);
1870 /* cap the length the devices can be blocked until they are deleted */
1871 fc_queue_devloss_work(shost, &rport->dev_loss_work, timeout * HZ);
1873 EXPORT_SYMBOL(fc_remote_port_delete);
1876 * fc_remote_port_rolechg - notifies the fc transport that the roles
1877 * on a remote may have changed.
1878 * @rport: The remote port that changed.
1880 * The LLDD calls this routine to notify the transport that the roles
1881 * on a remote port may have changed. The largest effect of this is
1882 * if a port now becomes a FCP Target, it must be allocated a
1883 * scsi target id. If the port is no longer a FCP target, any
1884 * scsi target id value assigned to it will persist in case the
1885 * role changes back to include FCP Target. No changes in the scsi
1886 * midlayer will be invoked if the role changes (in the expectation
1887 * that the role will be resumed. If it doesn't normal error processing
1890 * Should not be called from interrupt context.
1893 * This routine assumes no locks are held on entry.
1896 fc_remote_port_rolechg(struct fc_rport *rport, u32 roles)
1898 struct Scsi_Host *shost = rport_to_shost(rport);
1899 struct fc_host_attrs *fc_host = shost_to_fc_host(shost);
1900 unsigned long flags;
1903 spin_lock_irqsave(shost->host_lock, flags);
1904 if (roles & FC_RPORT_ROLE_FCP_TARGET) {
1905 if (rport->scsi_target_id == -1) {
1906 rport->scsi_target_id = fc_host->next_target_id++;
1908 } else if (!(rport->roles & FC_RPORT_ROLE_FCP_TARGET))
1912 rport->roles = roles;
1914 spin_unlock_irqrestore(shost->host_lock, flags);
1918 * There may have been a delete timer running on the
1919 * port. Ensure that it is cancelled as we now know
1920 * the port is an FCP Target.
1921 * Note: we know the rport is exists and in an online
1922 * state as the LLDD would not have had an rport
1923 * reference to pass us.
1925 * Take no action on the del_timer failure as the state
1926 * machine state change will validate the
1929 if (!cancel_delayed_work(&rport->dev_loss_work))
1930 fc_flush_devloss(shost);
1932 spin_lock_irqsave(shost->host_lock, flags);
1933 rport->flags &= ~FC_RPORT_DEVLOSS_PENDING;
1934 spin_unlock_irqrestore(shost->host_lock, flags);
1936 /* ensure any stgt delete functions are done */
1937 fc_flush_work(shost);
1939 /* initiate a scan of the target */
1940 spin_lock_irqsave(shost->host_lock, flags);
1941 rport->flags |= FC_RPORT_SCAN_PENDING;
1942 scsi_queue_work(shost, &rport->scan_work);
1943 spin_unlock_irqrestore(shost->host_lock, flags);
1944 scsi_target_unblock(&rport->dev);
1947 EXPORT_SYMBOL(fc_remote_port_rolechg);
1950 * fc_timeout_deleted_rport - Timeout handler for a deleted remote port that
1951 * was a SCSI target (thus was blocked), and failed
1952 * to return in the alloted time.
1954 * @data: rport target that failed to reappear in the alloted time.
1957 fc_timeout_deleted_rport(void *data)
1959 struct fc_rport *rport = (struct fc_rport *)data;
1960 struct Scsi_Host *shost = rport_to_shost(rport);
1961 struct fc_host_attrs *fc_host = shost_to_fc_host(shost);
1962 unsigned long flags;
1964 spin_lock_irqsave(shost->host_lock, flags);
1966 rport->flags &= ~FC_RPORT_DEVLOSS_PENDING;
1969 * If the port is ONLINE, then it came back. Validate it's still an
1970 * FCP target. If not, tear down the scsi_target on it.
1972 if ((rport->port_state == FC_PORTSTATE_ONLINE) &&
1973 !(rport->roles & FC_RPORT_ROLE_FCP_TARGET)) {
1974 dev_printk(KERN_ERR, &rport->dev,
1975 "blocked FC remote port time out: no longer"
1976 " a FCP target, removing starget\n");
1977 spin_unlock_irqrestore(shost->host_lock, flags);
1978 scsi_target_unblock(&rport->dev);
1979 fc_queue_work(shost, &rport->stgt_delete_work);
1983 if (rport->port_state != FC_PORTSTATE_BLOCKED) {
1984 spin_unlock_irqrestore(shost->host_lock, flags);
1985 dev_printk(KERN_ERR, &rport->dev,
1986 "blocked FC remote port time out: leaving target alone\n");
1990 if (fc_host->tgtid_bind_type == FC_TGTID_BIND_NONE) {
1991 list_del(&rport->peers);
1992 rport->port_state = FC_PORTSTATE_DELETED;
1993 dev_printk(KERN_ERR, &rport->dev,
1994 "blocked FC remote port time out: removing target\n");
1995 fc_queue_work(shost, &rport->rport_delete_work);
1996 spin_unlock_irqrestore(shost->host_lock, flags);
2000 dev_printk(KERN_ERR, &rport->dev,
2001 "blocked FC remote port time out: removing target and "
2002 "saving binding\n");
2004 list_move_tail(&rport->peers, &fc_host->rport_bindings);
2007 * Note: We do not remove or clear the hostdata area. This allows
2008 * host-specific target data to persist along with the
2009 * scsi_target_id. It's up to the host to manage it's hostdata area.
2013 * Reinitialize port attributes that may change if the port comes back.
2015 rport->maxframe_size = -1;
2016 rport->supported_classes = FC_COS_UNSPECIFIED;
2017 rport->roles = FC_RPORT_ROLE_UNKNOWN;
2018 rport->port_state = FC_PORTSTATE_NOTPRESENT;
2020 /* remove the identifiers that aren't used in the consisting binding */
2021 switch (fc_host->tgtid_bind_type) {
2022 case FC_TGTID_BIND_BY_WWPN:
2023 rport->node_name = -1;
2024 rport->port_id = -1;
2026 case FC_TGTID_BIND_BY_WWNN:
2027 rport->port_name = -1;
2028 rport->port_id = -1;
2030 case FC_TGTID_BIND_BY_ID:
2031 rport->node_name = -1;
2032 rport->port_name = -1;
2034 case FC_TGTID_BIND_NONE: /* to keep compiler happy */
2039 * As this only occurs if the remote port (scsi target)
2040 * went away and didn't come back - we'll remove
2041 * all attached scsi devices.
2043 spin_unlock_irqrestore(shost->host_lock, flags);
2045 scsi_target_unblock(&rport->dev);
2046 fc_queue_work(shost, &rport->stgt_delete_work);
2050 * fc_scsi_scan_rport - called to perform a scsi scan on a remote port.
2052 * @data: remote port to be scanned.
2055 fc_scsi_scan_rport(void *data)
2057 struct fc_rport *rport = (struct fc_rport *)data;
2058 struct Scsi_Host *shost = rport_to_shost(rport);
2059 unsigned long flags;
2061 if ((rport->port_state == FC_PORTSTATE_ONLINE) &&
2062 (rport->roles & FC_RPORT_ROLE_FCP_TARGET)) {
2063 scsi_scan_target(&rport->dev, rport->channel,
2064 rport->scsi_target_id, SCAN_WILD_CARD, 1);
2067 spin_lock_irqsave(shost->host_lock, flags);
2068 rport->flags &= ~FC_RPORT_SCAN_PENDING;
2069 spin_unlock_irqrestore(shost->host_lock, flags);
2073 MODULE_AUTHOR("Martin Hicks");
2074 MODULE_DESCRIPTION("FC Transport Attributes");
2075 MODULE_LICENSE("GPL");
2077 module_init(fc_transport_init);
2078 module_exit(fc_transport_exit);