aboutsummaryrefslogtreecommitdiffstats
path: root/include/scsi/scsi_transport_fc.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/scsi/scsi_transport_fc.h')
-rw-r--r--include/scsi/scsi_transport_fc.h186
1 files changed, 173 insertions, 13 deletions
diff --git a/include/scsi/scsi_transport_fc.h b/include/scsi/scsi_transport_fc.h
index 1e797308640a..a0d80bcaa93d 100644
--- a/include/scsi/scsi_transport_fc.h
+++ b/include/scsi/scsi_transport_fc.h
@@ -1,4 +1,4 @@
1/* 1/*
2 * FiberChannel transport specific attributes exported to sysfs. 2 * FiberChannel transport specific attributes exported to sysfs.
3 * 3 *
4 * Copyright (c) 2003 Silicon Graphics, Inc. All rights reserved. 4 * Copyright (c) 2003 Silicon Graphics, Inc. All rights reserved.
@@ -19,7 +19,7 @@
19 * 19 *
20 * ======== 20 * ========
21 * 21 *
22 * Copyright (C) 2004-2005 James Smart, Emulex Corporation 22 * Copyright (C) 2004-2007 James Smart, Emulex Corporation
23 * Rewrite for host, target, device, and remote port attributes, 23 * Rewrite for host, target, device, and remote port attributes,
24 * statistics, and service functions... 24 * statistics, and service functions...
25 * 25 *
@@ -62,8 +62,10 @@ enum fc_port_type {
62 FC_PORTTYPE_NLPORT, /* (Public) Loop w/ FLPort */ 62 FC_PORTTYPE_NLPORT, /* (Public) Loop w/ FLPort */
63 FC_PORTTYPE_LPORT, /* (Private) Loop w/o FLPort */ 63 FC_PORTTYPE_LPORT, /* (Private) Loop w/o FLPort */
64 FC_PORTTYPE_PTP, /* Point to Point w/ another NPort */ 64 FC_PORTTYPE_PTP, /* Point to Point w/ another NPort */
65 FC_PORTTYPE_NPIV, /* VPORT based on NPIV */
65}; 66};
66 67
68
67/* 69/*
68 * fc_port_state: If you alter this, you also need to alter scsi_transport_fc.c 70 * fc_port_state: If you alter this, you also need to alter scsi_transport_fc.c
69 * (for the ascii descriptions). 71 * (for the ascii descriptions).
@@ -83,7 +85,26 @@ enum fc_port_state {
83}; 85};
84 86
85 87
86/* 88/*
89 * fc_vport_state: If you alter this, you also need to alter
90 * scsi_transport_fc.c (for the ascii descriptions).
91 */
92enum fc_vport_state {
93 FC_VPORT_UNKNOWN,
94 FC_VPORT_ACTIVE,
95 FC_VPORT_DISABLED,
96 FC_VPORT_LINKDOWN,
97 FC_VPORT_INITIALIZING,
98 FC_VPORT_NO_FABRIC_SUPP,
99 FC_VPORT_NO_FABRIC_RSCS,
100 FC_VPORT_FABRIC_LOGOUT,
101 FC_VPORT_FABRIC_REJ_WWN,
102 FC_VPORT_FAILED,
103};
104
105
106
107/*
87 * FC Classes of Service 108 * FC Classes of Service
88 * Note: values are not enumerated, as they can be "or'd" together 109 * Note: values are not enumerated, as they can be "or'd" together
89 * for reporting (e.g. report supported_classes). If you alter this list, 110 * for reporting (e.g. report supported_classes). If you alter this list,
@@ -96,7 +117,7 @@ enum fc_port_state {
96#define FC_COS_CLASS4 0x10 117#define FC_COS_CLASS4 0x10
97#define FC_COS_CLASS6 0x40 118#define FC_COS_CLASS6 0x40
98 119
99/* 120/*
100 * FC Port Speeds 121 * FC Port Speeds
101 * Note: values are not enumerated, as they can be "or'd" together 122 * Note: values are not enumerated, as they can be "or'd" together
102 * for reporting (e.g. report supported_speeds). If you alter this list, 123 * for reporting (e.g. report supported_speeds). If you alter this list,
@@ -124,16 +145,114 @@ enum fc_tgtid_binding_type {
124}; 145};
125 146
126/* 147/*
127 * FC Remote Port Roles 148 * FC Port Roles
128 * Note: values are not enumerated, as they can be "or'd" together 149 * Note: values are not enumerated, as they can be "or'd" together
129 * for reporting (e.g. report roles). If you alter this list, 150 * for reporting (e.g. report roles). If you alter this list,
130 * you also need to alter scsi_transport_fc.c (for the ascii descriptions). 151 * you also need to alter scsi_transport_fc.c (for the ascii descriptions).
131 */ 152 */
132#define FC_RPORT_ROLE_UNKNOWN 0x00 153#define FC_PORT_ROLE_UNKNOWN 0x00
133#define FC_RPORT_ROLE_FCP_TARGET 0x01 154#define FC_PORT_ROLE_FCP_TARGET 0x01
134#define FC_RPORT_ROLE_FCP_INITIATOR 0x02 155#define FC_PORT_ROLE_FCP_INITIATOR 0x02
135#define FC_RPORT_ROLE_IP_PORT 0x04 156#define FC_PORT_ROLE_IP_PORT 0x04
157
158/* The following are for compatibility */
159#define FC_RPORT_ROLE_UNKNOWN FC_PORT_ROLE_UNKNOWN
160#define FC_RPORT_ROLE_FCP_TARGET FC_PORT_ROLE_FCP_TARGET
161#define FC_RPORT_ROLE_FCP_INITIATOR FC_PORT_ROLE_FCP_INITIATOR
162#define FC_RPORT_ROLE_IP_PORT FC_PORT_ROLE_IP_PORT
163
164
165/* Macro for use in defining Virtual Port attributes */
166#define FC_VPORT_ATTR(_name,_mode,_show,_store) \
167struct class_device_attribute class_device_attr_vport_##_name = \
168 __ATTR(_name,_mode,_show,_store)
169
170
171/*
172 * FC Virtual Port Attributes
173 *
174 * This structure exists for each FC port is a virtual FC port. Virtual
175 * ports share the physical link with the Physical port. Each virtual
176 * ports has a unique presense on the SAN, and may be instantiated via
177 * NPIV, Virtual Fabrics, or via additional ALPAs. As the vport is a
178 * unique presense, each vport has it's own view of the fabric,
179 * authentication priviledge, and priorities.
180 *
181 * A virtual port may support 1 or more FC4 roles. Typically it is a
182 * FCP Initiator. It could be a FCP Target, or exist sole for an IP over FC
183 * roles. FC port attributes for the vport will be reported on any
184 * fc_host class object allocated for an FCP Initiator.
185 *
186 * --
187 *
188 * Fixed attributes are not expected to change. The driver is
189 * expected to set these values after receiving the fc_vport structure
190 * via the vport_create() call from the transport.
191 * The transport fully manages all get functions w/o driver interaction.
192 *
193 * Dynamic attributes are expected to change. The driver participates
194 * in all get/set operations via functions provided by the driver.
195 *
196 * Private attributes are transport-managed values. They are fully
197 * managed by the transport w/o driver interaction.
198 */
136 199
200#define FC_VPORT_SYMBOLIC_NAMELEN 64
201struct fc_vport {
202 /* Fixed Attributes */
203
204 /* Dynamic Attributes */
205
206 /* Private (Transport-managed) Attributes */
207 enum fc_vport_state vport_state;
208 enum fc_vport_state vport_last_state;
209 u64 node_name;
210 u64 port_name;
211 u32 roles;
212 u32 vport_id; /* Admin Identifier for the vport */
213 enum fc_port_type vport_type;
214 char symbolic_name[FC_VPORT_SYMBOLIC_NAMELEN];
215
216 /* exported data */
217 void *dd_data; /* Used for driver-specific storage */
218
219 /* internal data */
220 struct Scsi_Host *shost; /* Physical Port Parent */
221 unsigned int channel;
222 u32 number;
223 u8 flags;
224 struct list_head peers;
225 struct device dev;
226 struct work_struct vport_delete_work;
227} __attribute__((aligned(sizeof(unsigned long))));
228
229/* bit field values for struct fc_vport "flags" field: */
230#define FC_VPORT_CREATING 0x01
231#define FC_VPORT_DELETING 0x02
232#define FC_VPORT_DELETED 0x04
233#define FC_VPORT_DEL 0x06 /* Any DELETE state */
234
235#define dev_to_vport(d) \
236 container_of(d, struct fc_vport, dev)
237#define transport_class_to_vport(classdev) \
238 dev_to_vport(classdev->dev)
239#define vport_to_shost(v) \
240 (v->shost)
241#define vport_to_shost_channel(v) \
242 (v->channel)
243#define vport_to_parent(v) \
244 (v->dev.parent)
245
246
247/* Error return codes for vport_create() callback */
248#define VPCERR_UNSUPPORTED -ENOSYS /* no driver/adapter
249 support */
250#define VPCERR_BAD_WWN -ENOTUNIQ /* driver validation
251 of WWNs failed */
252#define VPCERR_NO_FABRIC_SUPP -EOPNOTSUPP /* Fabric connection
253 is loop or the
254 Fabric Port does
255 not support NPIV */
137 256
138/* 257/*
139 * fc_rport_identifiers: This set of data contains all elements 258 * fc_rport_identifiers: This set of data contains all elements
@@ -149,6 +268,7 @@ struct fc_rport_identifiers {
149 u32 roles; 268 u32 roles;
150}; 269};
151 270
271
152/* Macro for use in defining Remote Port attributes */ 272/* Macro for use in defining Remote Port attributes */
153#define FC_RPORT_ATTR(_name,_mode,_show,_store) \ 273#define FC_RPORT_ATTR(_name,_mode,_show,_store) \
154struct class_device_attribute class_device_attr_rport_##_name = \ 274struct class_device_attribute class_device_attr_rport_##_name = \
@@ -278,7 +398,7 @@ struct fc_host_statistics {
278 u64 prim_seq_protocol_err_count; 398 u64 prim_seq_protocol_err_count;
279 u64 invalid_tx_word_count; 399 u64 invalid_tx_word_count;
280 u64 invalid_crc_count; 400 u64 invalid_crc_count;
281 401
282 /* fc4 statistics (only FCP supported currently) */ 402 /* fc4 statistics (only FCP supported currently) */
283 u64 fcp_input_requests; 403 u64 fcp_input_requests;
284 u64 fcp_output_requests; 404 u64 fcp_output_requests;
@@ -343,6 +463,7 @@ struct fc_host_attrs {
343 u8 supported_fc4s[FC_FC4_LIST_SIZE]; 463 u8 supported_fc4s[FC_FC4_LIST_SIZE];
344 u32 supported_speeds; 464 u32 supported_speeds;
345 u32 maxframe_size; 465 u32 maxframe_size;
466 u16 max_npiv_vports;
346 char serial_number[FC_SERIAL_NUMBER_SIZE]; 467 char serial_number[FC_SERIAL_NUMBER_SIZE];
347 468
348 /* Dynamic Attributes */ 469 /* Dynamic Attributes */
@@ -361,8 +482,11 @@ struct fc_host_attrs {
361 /* internal data */ 482 /* internal data */
362 struct list_head rports; 483 struct list_head rports;
363 struct list_head rport_bindings; 484 struct list_head rport_bindings;
485 struct list_head vports;
364 u32 next_rport_number; 486 u32 next_rport_number;
365 u32 next_target_id; 487 u32 next_target_id;
488 u32 next_vport_number;
489 u16 npiv_vports_inuse;
366 490
367 /* work queues for rport state manipulation */ 491 /* work queues for rport state manipulation */
368 char work_q_name[KOBJ_NAME_LEN]; 492 char work_q_name[KOBJ_NAME_LEN];
@@ -388,6 +512,8 @@ struct fc_host_attrs {
388 (((struct fc_host_attrs *)(x)->shost_data)->supported_speeds) 512 (((struct fc_host_attrs *)(x)->shost_data)->supported_speeds)
389#define fc_host_maxframe_size(x) \ 513#define fc_host_maxframe_size(x) \
390 (((struct fc_host_attrs *)(x)->shost_data)->maxframe_size) 514 (((struct fc_host_attrs *)(x)->shost_data)->maxframe_size)
515#define fc_host_max_npiv_vports(x) \
516 (((struct fc_host_attrs *)(x)->shost_data)->max_npiv_vports)
391#define fc_host_serial_number(x) \ 517#define fc_host_serial_number(x) \
392 (((struct fc_host_attrs *)(x)->shost_data)->serial_number) 518 (((struct fc_host_attrs *)(x)->shost_data)->serial_number)
393#define fc_host_port_id(x) \ 519#define fc_host_port_id(x) \
@@ -412,10 +538,16 @@ struct fc_host_attrs {
412 (((struct fc_host_attrs *)(x)->shost_data)->rports) 538 (((struct fc_host_attrs *)(x)->shost_data)->rports)
413#define fc_host_rport_bindings(x) \ 539#define fc_host_rport_bindings(x) \
414 (((struct fc_host_attrs *)(x)->shost_data)->rport_bindings) 540 (((struct fc_host_attrs *)(x)->shost_data)->rport_bindings)
541#define fc_host_vports(x) \
542 (((struct fc_host_attrs *)(x)->shost_data)->vports)
415#define fc_host_next_rport_number(x) \ 543#define fc_host_next_rport_number(x) \
416 (((struct fc_host_attrs *)(x)->shost_data)->next_rport_number) 544 (((struct fc_host_attrs *)(x)->shost_data)->next_rport_number)
417#define fc_host_next_target_id(x) \ 545#define fc_host_next_target_id(x) \
418 (((struct fc_host_attrs *)(x)->shost_data)->next_target_id) 546 (((struct fc_host_attrs *)(x)->shost_data)->next_target_id)
547#define fc_host_next_vport_number(x) \
548 (((struct fc_host_attrs *)(x)->shost_data)->next_vport_number)
549#define fc_host_npiv_vports_inuse(x) \
550 (((struct fc_host_attrs *)(x)->shost_data)->npiv_vports_inuse)
419#define fc_host_work_q_name(x) \ 551#define fc_host_work_q_name(x) \
420 (((struct fc_host_attrs *)(x)->shost_data)->work_q_name) 552 (((struct fc_host_attrs *)(x)->shost_data)->work_q_name)
421#define fc_host_work_q(x) \ 553#define fc_host_work_q(x) \
@@ -452,14 +584,20 @@ struct fc_function_template {
452 void (*dev_loss_tmo_callbk)(struct fc_rport *); 584 void (*dev_loss_tmo_callbk)(struct fc_rport *);
453 void (*terminate_rport_io)(struct fc_rport *); 585 void (*terminate_rport_io)(struct fc_rport *);
454 586
587 void (*set_vport_symbolic_name)(struct fc_vport *);
588 int (*vport_create)(struct fc_vport *, bool);
589 int (*vport_disable)(struct fc_vport *, bool);
590 int (*vport_delete)(struct fc_vport *);
591
455 /* allocation lengths for host-specific data */ 592 /* allocation lengths for host-specific data */
456 u32 dd_fcrport_size; 593 u32 dd_fcrport_size;
594 u32 dd_fcvport_size;
457 595
458 /* 596 /*
459 * The driver sets these to tell the transport class it 597 * The driver sets these to tell the transport class it
460 * wants the attributes displayed in sysfs. If the show_ flag 598 * wants the attributes displayed in sysfs. If the show_ flag
461 * is not set, the attribute will be private to the transport 599 * is not set, the attribute will be private to the transport
462 * class 600 * class
463 */ 601 */
464 602
465 /* remote port fixed attributes */ 603 /* remote port fixed attributes */
@@ -512,7 +650,7 @@ fc_remote_port_chkready(struct fc_rport *rport)
512 650
513 switch (rport->port_state) { 651 switch (rport->port_state) {
514 case FC_PORTSTATE_ONLINE: 652 case FC_PORTSTATE_ONLINE:
515 if (rport->roles & FC_RPORT_ROLE_FCP_TARGET) 653 if (rport->roles & FC_PORT_ROLE_FCP_TARGET)
516 result = 0; 654 result = 0;
517 else if (rport->flags & FC_RPORT_DEVLOSS_PENDING) 655 else if (rport->flags & FC_RPORT_DEVLOSS_PENDING)
518 result = DID_IMM_RETRY << 16; 656 result = DID_IMM_RETRY << 16;
@@ -549,6 +687,27 @@ static inline void u64_to_wwn(u64 inm, u8 *wwn)
549 wwn[7] = inm & 0xff; 687 wwn[7] = inm & 0xff;
550} 688}
551 689
690/**
691 * fc_vport_set_state() - called to set a vport's state. Saves the old state,
692 * excepting the transitory states of initializing and sending the ELS
693 * traffic to instantiate the vport on the link.
694 *
695 * Assumes the driver has surrounded this with the proper locking to ensure
696 * a coherent state change.
697 *
698 * @vport: virtual port whose state is changing
699 * @new_state: new state
700 **/
701static inline void
702fc_vport_set_state(struct fc_vport *vport, enum fc_vport_state new_state)
703{
704 if ((new_state != FC_VPORT_UNKNOWN) &&
705 (new_state != FC_VPORT_INITIALIZING))
706 vport->vport_last_state = vport->vport_state;
707 vport->vport_state = new_state;
708}
709
710
552struct scsi_transport_template *fc_attach_transport( 711struct scsi_transport_template *fc_attach_transport(
553 struct fc_function_template *); 712 struct fc_function_template *);
554void fc_release_transport(struct scsi_transport_template *); 713void fc_release_transport(struct scsi_transport_template *);
@@ -567,5 +726,6 @@ void fc_host_post_vendor_event(struct Scsi_Host *shost, u32 event_number,
567 * be sure to read the Vendor Type and ID formatting requirements 726 * be sure to read the Vendor Type and ID formatting requirements
568 * specified in scsi_netlink.h 727 * specified in scsi_netlink.h
569 */ 728 */
729int fc_vport_terminate(struct fc_vport *vport);
570 730
571#endif /* SCSI_TRANSPORT_FC_H */ 731#endif /* SCSI_TRANSPORT_FC_H */