aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/lpfc/lpfc.h
diff options
context:
space:
mode:
authorJames Smart <James.Smart@Emulex.Com>2007-06-17 20:56:38 -0400
committerJames Bottomley <jejb@mulgrave.il.steeleye.com>2007-06-17 23:27:39 -0400
commit92d7f7b0cde3ad2260e7462b40867b57efd49851 (patch)
treefadb1d8f1a817c2f85937b5e9c3b830bdecb5555 /drivers/scsi/lpfc/lpfc.h
parented957684294618602b48f1950b0c9bbcb036583f (diff)
[SCSI] lpfc: NPIV: add NPIV support on top of SLI-3
NPIV support is added to the driver. It utilizes the interfaces of the fc transport for the creation and deletion of vports. Within the driver, a new Scsi_Host is created for each NPIV instance, and is paired with a new instance of a FC port. This allows N FC Port elements to share a single Adapter. Signed-off-by: James Smart <James.Smart@emulex.com> Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
Diffstat (limited to 'drivers/scsi/lpfc/lpfc.h')
-rw-r--r--drivers/scsi/lpfc/lpfc.h156
1 files changed, 111 insertions, 45 deletions
diff --git a/drivers/scsi/lpfc/lpfc.h b/drivers/scsi/lpfc/lpfc.h
index 74f4d18842cc..4b9019d7d508 100644
--- a/drivers/scsi/lpfc/lpfc.h
+++ b/drivers/scsi/lpfc/lpfc.h
@@ -34,6 +34,17 @@ struct lpfc_sli2_slim;
34#define LPFC_IOCB_LIST_CNT 2250 /* list of IOCBs for fast-path usage. */ 34#define LPFC_IOCB_LIST_CNT 2250 /* list of IOCBs for fast-path usage. */
35#define LPFC_Q_RAMP_UP_INTERVAL 120 /* lun q_depth ramp up interval */ 35#define LPFC_Q_RAMP_UP_INTERVAL 120 /* lun q_depth ramp up interval */
36 36
37/*
38 * Following time intervals are used of adjusting SCSI device
39 * queue depths when there are driver resource error or Firmware
40 * resource error.
41 */
42#define QUEUE_RAMP_DOWN_INTERVAL (1 * HZ) /* 1 Second */
43#define QUEUE_RAMP_UP_INTERVAL (300 * HZ) /* 5 minutes */
44
45/* Number of exchanges reserved for discovery to complete */
46#define LPFC_DISC_IOCB_BUFF_COUNT 20
47
37/* Define macros for 64 bit support */ 48/* Define macros for 64 bit support */
38#define putPaddrLow(addr) ((uint32_t) (0xffffffff & (u64)(addr))) 49#define putPaddrLow(addr) ((uint32_t) (0xffffffff & (u64)(addr)))
39#define putPaddrHigh(addr) ((uint32_t) (0xffffffff & (((u64)(addr))>>32))) 50#define putPaddrHigh(addr) ((uint32_t) (0xffffffff & (((u64)(addr))>>32)))
@@ -97,6 +108,29 @@ typedef struct lpfc_vpd {
97 uint32_t sli2FwRev; 108 uint32_t sli2FwRev;
98 uint8_t sli2FwName[16]; 109 uint8_t sli2FwName[16];
99 } rev; 110 } rev;
111 struct {
112#ifdef __BIG_ENDIAN_BITFIELD
113 uint32_t rsvd2 :24; /* Reserved */
114 uint32_t cmv : 1; /* Configure Max VPIs */
115 uint32_t ccrp : 1; /* Config Command Ring Polling */
116 uint32_t csah : 1; /* Configure Synchronous Abort Handling */
117 uint32_t chbs : 1; /* Cofigure Host Backing store */
118 uint32_t cinb : 1; /* Enable Interrupt Notification Block */
119 uint32_t cerbm : 1; /* Configure Enhanced Receive Buf Mgmt */
120 uint32_t cmx : 1; /* Configure Max XRIs */
121 uint32_t cmr : 1; /* Configure Max RPIs */
122#else /* __LITTLE_ENDIAN */
123 uint32_t cmr : 1; /* Configure Max RPIs */
124 uint32_t cmx : 1; /* Configure Max XRIs */
125 uint32_t cerbm : 1; /* Configure Enhanced Receive Buf Mgmt */
126 uint32_t cinb : 1; /* Enable Interrupt Notification Block */
127 uint32_t chbs : 1; /* Cofigure Host Backing store */
128 uint32_t csah : 1; /* Configure Synchronous Abort Handling */
129 uint32_t ccrp : 1; /* Config Command Ring Polling */
130 uint32_t cmv : 1; /* Configure Max VPIs */
131 uint32_t rsvd2 :24; /* Reserved */
132#endif
133 } sli3Feat;
100} lpfc_vpd_t; 134} lpfc_vpd_t;
101 135
102struct lpfc_scsi_buf; 136struct lpfc_scsi_buf;
@@ -129,6 +163,7 @@ struct lpfc_stats {
129 uint32_t elsRcvRPS; 163 uint32_t elsRcvRPS;
130 uint32_t elsRcvRPL; 164 uint32_t elsRcvRPL;
131 uint32_t elsXmitFLOGI; 165 uint32_t elsXmitFLOGI;
166 uint32_t elsXmitFDISC;
132 uint32_t elsXmitPLOGI; 167 uint32_t elsXmitPLOGI;
133 uint32_t elsXmitPRLI; 168 uint32_t elsXmitPRLI;
134 uint32_t elsXmitADISC; 169 uint32_t elsXmitADISC;
@@ -174,18 +209,21 @@ struct lpfc_sysfs_mbox {
174 209
175struct lpfc_hba; 210struct lpfc_hba;
176 211
212
177enum discovery_state { 213enum discovery_state {
178 LPFC_STATE_UNKNOWN = 0, /* HBA state is unknown */ 214 LPFC_VPORT_UNKNOWN = 0, /* vport state is unknown */
179 LPFC_LOCAL_CFG_LINK = 6, /* local NPORT Id configured */ 215 LPFC_VPORT_FAILED = 1, /* vport has failed */
180 LPFC_FLOGI = 7, /* FLOGI sent to Fabric */ 216 LPFC_LOCAL_CFG_LINK = 6, /* local NPORT Id configured */
181 LPFC_FABRIC_CFG_LINK = 8, /* Fabric assigned NPORT Id 217 LPFC_FLOGI = 7, /* FLOGI sent to Fabric */
182 * configured */ 218 LPFC_FDISC = 8, /* FDISC sent for vport */
183 LPFC_NS_REG = 9, /* Register with NameServer */ 219 LPFC_FABRIC_CFG_LINK = 9, /* Fabric assigned NPORT Id
184 LPFC_NS_QRY = 10, /* Query NameServer for NPort ID list */ 220 * configured */
185 LPFC_BUILD_DISC_LIST = 11, /* Build ADISC and PLOGI lists for 221 LPFC_NS_REG = 10, /* Register with NameServer */
186 * device authentication / discovery */ 222 LPFC_NS_QRY = 11, /* Query NameServer for NPort ID list */
187 LPFC_DISC_AUTH = 12, /* Processing ADISC list */ 223 LPFC_BUILD_DISC_LIST = 12, /* Build ADISC and PLOGI lists for
188 LPFC_VPORT_READY = 32, 224 * device authentication / discovery */
225 LPFC_DISC_AUTH = 13, /* Processing ADISC list */
226 LPFC_VPORT_READY = 32,
189}; 227};
190 228
191enum hba_state { 229enum hba_state {
@@ -195,8 +233,9 @@ enum hba_state {
195 LPFC_INIT_MBX_CMDS = 3, /* Initialize HBA with mbox commands */ 233 LPFC_INIT_MBX_CMDS = 3, /* Initialize HBA with mbox commands */
196 LPFC_LINK_DOWN = 4, /* HBA initialized, link is down */ 234 LPFC_LINK_DOWN = 4, /* HBA initialized, link is down */
197 LPFC_LINK_UP = 5, /* Link is up - issue READ_LA */ 235 LPFC_LINK_UP = 5, /* Link is up - issue READ_LA */
198 LPFC_CLEAR_LA = 13, /* authentication cmplt - issue 236 LPFC_CLEAR_LA = 6, /* authentication cmplt - issue
199 * CLEAR_LA */ 237 * CLEAR_LA */
238 LPFC_HBA_READY = 32,
200 LPFC_HBA_ERROR = -1 239 LPFC_HBA_ERROR = -1
201}; 240};
202 241
@@ -209,26 +248,30 @@ struct lpfc_vport {
209#define LPFC_FABRIC_PORT 3 248#define LPFC_FABRIC_PORT 3
210 enum discovery_state port_state; 249 enum discovery_state port_state;
211 250
251 uint16_t vpi;
212 252
213 uint32_t fc_flag; /* FC flags */ 253 uint32_t fc_flag; /* FC flags */
214/* Several of these flags are HBA centric and should be moved to 254/* Several of these flags are HBA centric and should be moved to
215 * phba->link_flag (e.g. FC_PTP, FC_PUBLIC_LOOP) 255 * phba->link_flag (e.g. FC_PTP, FC_PUBLIC_LOOP)
216 */ 256 */
217#define FC_PT2PT 0x1 /* pt2pt with no fabric */ 257#define FC_PT2PT 0x1 /* pt2pt with no fabric */
218#define FC_PT2PT_PLOGI 0x2 /* pt2pt initiate PLOGI */ 258#define FC_PT2PT_PLOGI 0x2 /* pt2pt initiate PLOGI */
219#define FC_DISC_TMO 0x4 /* Discovery timer running */ 259#define FC_DISC_TMO 0x4 /* Discovery timer running */
220#define FC_PUBLIC_LOOP 0x8 /* Public loop */ 260#define FC_PUBLIC_LOOP 0x8 /* Public loop */
221#define FC_LBIT 0x10 /* LOGIN bit in loopinit set */ 261#define FC_LBIT 0x10 /* LOGIN bit in loopinit set */
222#define FC_RSCN_MODE 0x20 /* RSCN cmd rcv'ed */ 262#define FC_RSCN_MODE 0x20 /* RSCN cmd rcv'ed */
223#define FC_NLP_MORE 0x40 /* More node to process in node tbl */ 263#define FC_NLP_MORE 0x40 /* More node to process in node tbl */
224#define FC_OFFLINE_MODE 0x80 /* Interface is offline for diag */ 264#define FC_OFFLINE_MODE 0x80 /* Interface is offline for diag */
225#define FC_FABRIC 0x100 /* We are fabric attached */ 265#define FC_FABRIC 0x100 /* We are fabric attached */
226#define FC_ESTABLISH_LINK 0x200 /* Reestablish Link */ 266#define FC_ESTABLISH_LINK 0x200 /* Reestablish Link */
227#define FC_RSCN_DISCOVERY 0x400 /* Authenticate all devices after RSCN*/ 267#define FC_RSCN_DISCOVERY 0x400 /* Auth all devices after RSCN */
228#define FC_SCSI_SCAN_TMO 0x4000 /* scsi scan timer running */ 268#define FC_SCSI_SCAN_TMO 0x4000 /* scsi scan timer running */
229#define FC_ABORT_DISCOVERY 0x8000 /* we want to abort discovery */ 269#define FC_ABORT_DISCOVERY 0x8000 /* we want to abort discovery */
230#define FC_NDISC_ACTIVE 0x10000 /* NPort discovery active */ 270#define FC_NDISC_ACTIVE 0x10000 /* NPort discovery active */
231#define FC_BYPASSED_MODE 0x20000 /* NPort is in bypassed mode */ 271#define FC_BYPASSED_MODE 0x20000 /* NPort is in bypassed mode */
272#define FC_RFF_NOT_SUPPORTED 0x40000 /* RFF_ID was rejected by switch */
273#define FC_VPORT_NEEDS_REG_VPI 0x80000 /* Needs to have its vpi registered */
274#define FC_RSCN_DEFERRED 0x100000 /* A deferred RSCN being processed */
232 275
233 struct list_head fc_nodes; 276 struct list_head fc_nodes;
234 277
@@ -269,6 +312,9 @@ struct lpfc_vport {
269#define WORKER_ELS_TMO 0x2 /* ELS timeout */ 312#define WORKER_ELS_TMO 0x2 /* ELS timeout */
270#define WORKER_MBOX_TMO 0x4 /* MBOX timeout */ 313#define WORKER_MBOX_TMO 0x4 /* MBOX timeout */
271#define WORKER_FDMI_TMO 0x8 /* FDMI timeout */ 314#define WORKER_FDMI_TMO 0x8 /* FDMI timeout */
315#define WORKER_FABRIC_BLOCK_TMO 0x10 /* fabric block timout */
316#define WORKER_RAMP_DOWN_QUEUE 0x20 /* Decrease Q depth */
317#define WORKER_RAMP_UP_QUEUE 0x40 /* Increase Q depth */
272 318
273 struct timer_list fc_fdmitmo; 319 struct timer_list fc_fdmitmo;
274 struct timer_list els_tmofunc; 320 struct timer_list els_tmofunc;
@@ -278,10 +324,10 @@ struct lpfc_vport {
278 uint8_t load_flag; 324 uint8_t load_flag;
279#define FC_LOADING 0x1 /* HBA in process of loading drvr */ 325#define FC_LOADING 0x1 /* HBA in process of loading drvr */
280#define FC_UNLOADING 0x2 /* HBA in process of unloading drvr */ 326#define FC_UNLOADING 0x2 /* HBA in process of unloading drvr */
281 327 char *vname; /* Application assigned name */
328 struct fc_vport *fc_vport;
282}; 329};
283 330
284
285struct hbq_s { 331struct hbq_s {
286 uint16_t entry_count; /* Current number of HBQ slots */ 332 uint16_t entry_count; /* Current number of HBQ slots */
287 uint32_t next_hbqPutIdx; /* Index to next HBQ slot to use */ 333 uint32_t next_hbqPutIdx; /* Index to next HBQ slot to use */
@@ -289,33 +335,38 @@ struct hbq_s {
289 uint32_t local_hbqGetIdx; /* Local copy of Get index from Port */ 335 uint32_t local_hbqGetIdx; /* Local copy of Get index from Port */
290}; 336};
291 337
292#define MAX_HBQS 16 338#define LPFC_MAX_HBQS 16
339/* this matches the possition in the lpfc_hbq_defs array */
340#define LPFC_ELS_HBQ 0
293 341
294struct lpfc_hba { 342struct lpfc_hba {
295 struct lpfc_sli sli; 343 struct lpfc_sli sli;
296 uint32_t sli_rev; /* SLI2 or SLI3 */ 344 uint32_t sli_rev; /* SLI2 or SLI3 */
297 uint32_t sli3_options; /* Mask of enabled SLI3 options */ 345 uint32_t sli3_options; /* Mask of enabled SLI3 options */
298#define LPFC_SLI3_ENABLED 0x01 346#define LPFC_SLI3_ENABLED 0x01
299#define LPFC_SLI3_HBQ_ENABLED 0x02 347#define LPFC_SLI3_HBQ_ENABLED 0x02
300#define LPFC_SLI3_INB_ENABLED 0x04 348#define LPFC_SLI3_NPIV_ENABLED 0x04
349#define LPFC_SLI3_VPORT_TEARDOWN 0x08
301 uint32_t iocb_cmd_size; 350 uint32_t iocb_cmd_size;
302 uint32_t iocb_rsp_size; 351 uint32_t iocb_rsp_size;
303 352
304 enum hba_state link_state; 353 enum hba_state link_state;
305 uint32_t link_flag; /* link state flags */ 354 uint32_t link_flag; /* link state flags */
306#define LS_LOOPBACK_MODE 0x40000 /* NPort is in Loopback mode */ 355#define LS_LOOPBACK_MODE 0x1 /* NPort is in Loopback mode */
307 /* This flag is set while issuing */ 356 /* This flag is set while issuing */
308 /* INIT_LINK mailbox command */ 357 /* INIT_LINK mailbox command */
309#define LS_IGNORE_ERATT 0x80000 /* intr handler should ignore ERATT */ 358#define LS_NPIV_FAB_SUPPORTED 0x2 /* Fabric supports NPIV */
359#define LS_IGNORE_ERATT 0x3 /* intr handler should ignore ERATT */
310 360
311 struct lpfc_sli2_slim *slim2p; 361 struct lpfc_sli2_slim *slim2p;
312 struct lpfc_dmabuf hbqslimp; 362 struct lpfc_dmabuf hbqslimp;
313 363
314 dma_addr_t slim2p_mapping; 364 dma_addr_t slim2p_mapping;
315 365
316
317 uint16_t pci_cfg_value; 366 uint16_t pci_cfg_value;
318 367
368 uint8_t work_found;
369#define LPFC_MAX_WORKER_ITERATION 4
319 370
320 uint8_t fc_linkspeed; /* Link speed after last READ_LA */ 371 uint8_t fc_linkspeed; /* Link speed after last READ_LA */
321 372
@@ -325,7 +376,7 @@ struct lpfc_hba {
325 struct timer_list fc_estabtmo; /* link establishment timer */ 376 struct timer_list fc_estabtmo; /* link establishment timer */
326 /* These fields used to be binfo */ 377 /* These fields used to be binfo */
327 uint32_t fc_pref_DID; /* preferred D_ID */ 378 uint32_t fc_pref_DID; /* preferred D_ID */
328 uint8_t fc_pref_ALPA; /* preferred AL_PA */ 379 uint8_t fc_pref_ALPA; /* preferred AL_PA */
329 uint32_t fc_edtov; /* E_D_TOV timer value */ 380 uint32_t fc_edtov; /* E_D_TOV timer value */
330 uint32_t fc_arbtov; /* ARB_TOV timer value */ 381 uint32_t fc_arbtov; /* ARB_TOV timer value */
331 uint32_t fc_ratov; /* R_A_TOV timer value */ 382 uint32_t fc_ratov; /* R_A_TOV timer value */
@@ -355,6 +406,8 @@ struct lpfc_hba {
355 uint32_t cfg_nodev_tmo; 406 uint32_t cfg_nodev_tmo;
356 uint32_t cfg_devloss_tmo; 407 uint32_t cfg_devloss_tmo;
357 uint32_t cfg_hba_queue_depth; 408 uint32_t cfg_hba_queue_depth;
409 uint32_t cfg_peer_port_login;
410 uint32_t cfg_vport_restrict_login;
358 uint32_t cfg_fcp_class; 411 uint32_t cfg_fcp_class;
359 uint32_t cfg_use_adisc; 412 uint32_t cfg_use_adisc;
360 uint32_t cfg_ack0; 413 uint32_t cfg_ack0;
@@ -391,11 +444,9 @@ struct lpfc_hba {
391 wait_queue_head_t *work_wait; 444 wait_queue_head_t *work_wait;
392 struct task_struct *worker_thread; 445 struct task_struct *worker_thread;
393 446
394 struct hbq_dmabuf *hbq_buffer_pool; 447 struct list_head hbq_buffer_list;
395 uint32_t hbq_buffer_count;
396 uint32_t hbq_buff_count; /* Current hbq buffers */
397 uint32_t hbq_count; /* Count of configured HBQs */ 448 uint32_t hbq_count; /* Count of configured HBQs */
398 struct hbq_s hbqs[MAX_HBQS]; /* local copy of hbq indicies */ 449 struct hbq_s hbqs[LPFC_MAX_HBQS]; /* local copy of hbq indicies */
399 450
400 unsigned long pci_bar0_map; /* Physical address for PCI BAR0 */ 451 unsigned long pci_bar0_map; /* Physical address for PCI BAR0 */
401 unsigned long pci_bar2_map; /* Physical address for PCI BAR2 */ 452 unsigned long pci_bar2_map; /* Physical address for PCI BAR2 */
@@ -413,7 +464,7 @@ struct lpfc_hba {
413 464
414 struct lpfc_hgp __iomem *host_gp; /* Host side get/put pointers */ 465 struct lpfc_hgp __iomem *host_gp; /* Host side get/put pointers */
415 uint32_t __iomem *hbq_put; /* Address in SLIM to HBQ put ptrs */ 466 uint32_t __iomem *hbq_put; /* Address in SLIM to HBQ put ptrs */
416 uint32_t __iomem *hbq_get; /* Address in SLIM to HBQ get ptrs */ 467 uint32_t *hbq_get; /* Host mem address of HBQ get ptrs */
417 468
418 int brd_no; /* FC board number */ 469 int brd_no; /* FC board number */
419 470
@@ -464,6 +515,22 @@ struct lpfc_hba {
464 struct fc_host_statistics link_stats; 515 struct fc_host_statistics link_stats;
465 struct list_head port_list; 516 struct list_head port_list;
466 struct lpfc_vport *pport; /* physical lpfc_vport pointer */ 517 struct lpfc_vport *pport; /* physical lpfc_vport pointer */
518 uint16_t max_vpi; /* Maximum virtual nports */
519 uint16_t vpi_cnt; /* Nport count */
520#define LPFC_MAX_VPI 100 /* Max number of VPorts supported */
521 unsigned long *vpi_bmask; /* vpi allocation table */
522
523 /* Data structure used by fabric iocb scheduler */
524 struct list_head fabric_iocb_list;
525 atomic_t fabric_iocb_count;
526 struct timer_list fabric_block_timer;
527 unsigned long bit_flags;
528#define FABRIC_COMANDS_BLOCKED 0
529 atomic_t num_rsrc_err;
530 atomic_t num_cmd_success;
531 unsigned long last_rsrc_error_time;
532 unsigned long last_ramp_down_time;
533 unsigned long last_ramp_up_time;
467}; 534};
468 535
469static inline struct Scsi_Host * 536static inline struct Scsi_Host *
@@ -485,10 +552,9 @@ static inline int
485lpfc_is_link_up(struct lpfc_hba *phba) 552lpfc_is_link_up(struct lpfc_hba *phba)
486{ 553{
487 return phba->link_state == LPFC_LINK_UP || 554 return phba->link_state == LPFC_LINK_UP ||
488 phba->link_state == LPFC_CLEAR_LA; 555 phba->link_state == LPFC_CLEAR_LA ||
556 phba->link_state == LPFC_HBA_READY;
489} 557}
490 558
491
492
493#define FC_REG_DUMP_EVENT 0x10 /* Register for Dump events */ 559#define FC_REG_DUMP_EVENT 0x10 /* Register for Dump events */
494 560