diff options
Diffstat (limited to 'drivers/scsi/lpfc/lpfc_mbox.c')
-rw-r--r-- | drivers/scsi/lpfc/lpfc_mbox.c | 624 |
1 files changed, 520 insertions, 104 deletions
diff --git a/drivers/scsi/lpfc/lpfc_mbox.c b/drivers/scsi/lpfc/lpfc_mbox.c index 7a9be4c5b7cb..7465fe746fe9 100644 --- a/drivers/scsi/lpfc/lpfc_mbox.c +++ b/drivers/scsi/lpfc/lpfc_mbox.c | |||
@@ -1,7 +1,7 @@ | |||
1 | /******************************************************************* | 1 | /******************************************************************* |
2 | * This file is part of the Emulex Linux Device Driver for * | 2 | * This file is part of the Emulex Linux Device Driver for * |
3 | * Fibre Channel Host Bus Adapters. * | 3 | * Fibre Channel Host Bus Adapters. * |
4 | * Copyright (C) 2004-2007 Emulex. All rights reserved. * | 4 | * Copyright (C) 2004-2008 Emulex. All rights reserved. * |
5 | * EMULEX and SLI are trademarks of Emulex. * | 5 | * EMULEX and SLI are trademarks of Emulex. * |
6 | * www.emulex.com * | 6 | * www.emulex.com * |
7 | * Portions Copyright (C) 2004-2005 Christoph Hellwig * | 7 | * Portions Copyright (C) 2004-2005 Christoph Hellwig * |
@@ -30,6 +30,7 @@ | |||
30 | 30 | ||
31 | #include "lpfc_hw.h" | 31 | #include "lpfc_hw.h" |
32 | #include "lpfc_sli.h" | 32 | #include "lpfc_sli.h" |
33 | #include "lpfc_nl.h" | ||
33 | #include "lpfc_disc.h" | 34 | #include "lpfc_disc.h" |
34 | #include "lpfc_scsi.h" | 35 | #include "lpfc_scsi.h" |
35 | #include "lpfc.h" | 36 | #include "lpfc.h" |
@@ -37,10 +38,20 @@ | |||
37 | #include "lpfc_crtn.h" | 38 | #include "lpfc_crtn.h" |
38 | #include "lpfc_compat.h" | 39 | #include "lpfc_compat.h" |
39 | 40 | ||
40 | /**********************************************/ | 41 | /** |
41 | 42 | * lpfc_dump_mem: Prepare a mailbox command for retrieving HBA's VPD memory. | |
42 | /* mailbox command */ | 43 | * @phba: pointer to lpfc hba data structure. |
43 | /**********************************************/ | 44 | * @pmb: pointer to the driver internal queue element for mailbox command. |
45 | * @offset: offset for dumping VPD memory mailbox command. | ||
46 | * | ||
47 | * The dump mailbox command provides a method for the device driver to obtain | ||
48 | * various types of information from the HBA device. | ||
49 | * | ||
50 | * This routine prepares the mailbox command for dumping HBA Vital Product | ||
51 | * Data (VPD) memory. This mailbox command is to be used for retrieving a | ||
52 | * portion (DMP_RSP_SIZE bytes) of a HBA's VPD from the HBA at an address | ||
53 | * offset specified by the offset parameter. | ||
54 | **/ | ||
44 | void | 55 | void |
45 | lpfc_dump_mem(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmb, uint16_t offset) | 56 | lpfc_dump_mem(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmb, uint16_t offset) |
46 | { | 57 | { |
@@ -65,10 +76,17 @@ lpfc_dump_mem(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmb, uint16_t offset) | |||
65 | return; | 76 | return; |
66 | } | 77 | } |
67 | 78 | ||
68 | /**********************************************/ | 79 | /** |
69 | /* lpfc_read_nv Issue a READ NVPARAM */ | 80 | * lpfc_read_nv: Prepare a mailbox command for reading HBA's NVRAM param. |
70 | /* mailbox command */ | 81 | * @phba: pointer to lpfc hba data structure. |
71 | /**********************************************/ | 82 | * @pmb: pointer to the driver internal queue element for mailbox command. |
83 | * | ||
84 | * The read NVRAM mailbox command returns the HBA's non-volatile parameters | ||
85 | * that are used as defaults when the Fibre Channel link is brought on-line. | ||
86 | * | ||
87 | * This routine prepares the mailbox command for reading information stored | ||
88 | * in the HBA's NVRAM. Specifically, the HBA's WWNN and WWPN. | ||
89 | **/ | ||
72 | void | 90 | void |
73 | lpfc_read_nv(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmb) | 91 | lpfc_read_nv(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmb) |
74 | { | 92 | { |
@@ -81,10 +99,19 @@ lpfc_read_nv(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmb) | |||
81 | return; | 99 | return; |
82 | } | 100 | } |
83 | 101 | ||
84 | /**********************************************/ | 102 | /** |
85 | /* lpfc_config_async Issue a */ | 103 | * lpfc_config_async: Prepare a mailbox command for enabling HBA async event. |
86 | /* MBX_ASYNC_EVT_ENABLE mailbox command */ | 104 | * @phba: pointer to lpfc hba data structure. |
87 | /**********************************************/ | 105 | * @pmb: pointer to the driver internal queue element for mailbox command. |
106 | * @ring: ring number for the asynchronous event to be configured. | ||
107 | * | ||
108 | * The asynchronous event enable mailbox command is used to enable the | ||
109 | * asynchronous event posting via the ASYNC_STATUS_CN IOCB response and | ||
110 | * specifies the default ring to which events are posted. | ||
111 | * | ||
112 | * This routine prepares the mailbox command for enabling HBA asynchronous | ||
113 | * event support on a IOCB ring. | ||
114 | **/ | ||
88 | void | 115 | void |
89 | lpfc_config_async(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmb, | 116 | lpfc_config_async(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmb, |
90 | uint32_t ring) | 117 | uint32_t ring) |
@@ -99,10 +126,19 @@ lpfc_config_async(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmb, | |||
99 | return; | 126 | return; |
100 | } | 127 | } |
101 | 128 | ||
102 | /**********************************************/ | 129 | /** |
103 | /* lpfc_heart_beat Issue a HEART_BEAT */ | 130 | * lpfc_heart_beat: Prepare a mailbox command for heart beat. |
104 | /* mailbox command */ | 131 | * @phba: pointer to lpfc hba data structure. |
105 | /**********************************************/ | 132 | * @pmb: pointer to the driver internal queue element for mailbox command. |
133 | * | ||
134 | * The heart beat mailbox command is used to detect an unresponsive HBA, which | ||
135 | * is defined as any device where no error attention is sent and both mailbox | ||
136 | * and rings are not processed. | ||
137 | * | ||
138 | * This routine prepares the mailbox command for issuing a heart beat in the | ||
139 | * form of mailbox command to the HBA. The timely completion of the heart | ||
140 | * beat mailbox command indicates the health of the HBA. | ||
141 | **/ | ||
106 | void | 142 | void |
107 | lpfc_heart_beat(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmb) | 143 | lpfc_heart_beat(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmb) |
108 | { | 144 | { |
@@ -115,10 +151,26 @@ lpfc_heart_beat(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmb) | |||
115 | return; | 151 | return; |
116 | } | 152 | } |
117 | 153 | ||
118 | /**********************************************/ | 154 | /** |
119 | /* lpfc_read_la Issue a READ LA */ | 155 | * lpfc_read_la: Prepare a mailbox command for reading HBA link attention. |
120 | /* mailbox command */ | 156 | * @phba: pointer to lpfc hba data structure. |
121 | /**********************************************/ | 157 | * @pmb: pointer to the driver internal queue element for mailbox command. |
158 | * @mp: DMA buffer memory for reading the link attention information into. | ||
159 | * | ||
160 | * The read link attention mailbox command is issued to read the Link Event | ||
161 | * Attention information indicated by the HBA port when the Link Event bit | ||
162 | * of the Host Attention (HSTATT) register is set to 1. A Link Event | ||
163 | * Attention occurs based on an exception detected at the Fibre Channel link | ||
164 | * interface. | ||
165 | * | ||
166 | * This routine prepares the mailbox command for reading HBA link attention | ||
167 | * information. A DMA memory has been set aside and address passed to the | ||
168 | * HBA through @mp for the HBA to DMA link attention information into the | ||
169 | * memory as part of the execution of the mailbox command. | ||
170 | * | ||
171 | * Return codes | ||
172 | * 0 - Success (currently always return 0) | ||
173 | **/ | ||
122 | int | 174 | int |
123 | lpfc_read_la(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmb, struct lpfc_dmabuf *mp) | 175 | lpfc_read_la(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmb, struct lpfc_dmabuf *mp) |
124 | { | 176 | { |
@@ -143,10 +195,21 @@ lpfc_read_la(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmb, struct lpfc_dmabuf *mp) | |||
143 | return (0); | 195 | return (0); |
144 | } | 196 | } |
145 | 197 | ||
146 | /**********************************************/ | 198 | /** |
147 | /* lpfc_clear_la Issue a CLEAR LA */ | 199 | * lpfc_clear_la: Prepare a mailbox command for clearing HBA link attention. |
148 | /* mailbox command */ | 200 | * @phba: pointer to lpfc hba data structure. |
149 | /**********************************************/ | 201 | * @pmb: pointer to the driver internal queue element for mailbox command. |
202 | * | ||
203 | * The clear link attention mailbox command is issued to clear the link event | ||
204 | * attention condition indicated by the Link Event bit of the Host Attention | ||
205 | * (HSTATT) register. The link event attention condition is cleared only if | ||
206 | * the event tag specified matches that of the current link event counter. | ||
207 | * The current event tag is read using the read link attention event mailbox | ||
208 | * command. | ||
209 | * | ||
210 | * This routine prepares the mailbox command for clearing HBA link attention | ||
211 | * information. | ||
212 | **/ | ||
150 | void | 213 | void |
151 | lpfc_clear_la(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmb) | 214 | lpfc_clear_la(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmb) |
152 | { | 215 | { |
@@ -161,10 +224,20 @@ lpfc_clear_la(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmb) | |||
161 | return; | 224 | return; |
162 | } | 225 | } |
163 | 226 | ||
164 | /**************************************************/ | 227 | /** |
165 | /* lpfc_config_link Issue a CONFIG LINK */ | 228 | * lpfc_config_link: Prepare a mailbox command for configuring link on a HBA. |
166 | /* mailbox command */ | 229 | * @phba: pointer to lpfc hba data structure. |
167 | /**************************************************/ | 230 | * @pmb: pointer to the driver internal queue element for mailbox command. |
231 | * | ||
232 | * The configure link mailbox command is used before the initialize link | ||
233 | * mailbox command to override default value and to configure link-oriented | ||
234 | * parameters such as DID address and various timers. Typically, this | ||
235 | * command would be used after an F_Port login to set the returned DID address | ||
236 | * and the fabric timeout values. This command is not valid before a configure | ||
237 | * port command has configured the HBA port. | ||
238 | * | ||
239 | * This routine prepares the mailbox command for configuring link on a HBA. | ||
240 | **/ | ||
168 | void | 241 | void |
169 | lpfc_config_link(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmb) | 242 | lpfc_config_link(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmb) |
170 | { | 243 | { |
@@ -199,10 +272,98 @@ lpfc_config_link(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmb) | |||
199 | return; | 272 | return; |
200 | } | 273 | } |
201 | 274 | ||
202 | /**********************************************/ | 275 | /** |
203 | /* lpfc_init_link Issue an INIT LINK */ | 276 | * lpfc_config_msi: Prepare a mailbox command for configuring msi-x. |
204 | /* mailbox command */ | 277 | * @phba: pointer to lpfc hba data structure. |
205 | /**********************************************/ | 278 | * @pmb: pointer to the driver internal queue element for mailbox command. |
279 | * | ||
280 | * The configure MSI-X mailbox command is used to configure the HBA's SLI-3 | ||
281 | * MSI-X multi-message interrupt vector association to interrupt attention | ||
282 | * conditions. | ||
283 | * | ||
284 | * Return codes | ||
285 | * 0 - Success | ||
286 | * -EINVAL - Failure | ||
287 | **/ | ||
288 | int | ||
289 | lpfc_config_msi(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb) | ||
290 | { | ||
291 | MAILBOX_t *mb = &pmb->mb; | ||
292 | uint32_t attentionConditions[2]; | ||
293 | |||
294 | /* Sanity check */ | ||
295 | if (phba->cfg_use_msi != 2) { | ||
296 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, | ||
297 | "0475 Not configured for supporting MSI-X " | ||
298 | "cfg_use_msi: 0x%x\n", phba->cfg_use_msi); | ||
299 | return -EINVAL; | ||
300 | } | ||
301 | |||
302 | if (phba->sli_rev < 3) { | ||
303 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, | ||
304 | "0476 HBA not supporting SLI-3 or later " | ||
305 | "SLI Revision: 0x%x\n", phba->sli_rev); | ||
306 | return -EINVAL; | ||
307 | } | ||
308 | |||
309 | /* Clear mailbox command fields */ | ||
310 | memset(pmb, 0, sizeof(LPFC_MBOXQ_t)); | ||
311 | |||
312 | /* | ||
313 | * SLI-3, Message Signaled Interrupt Fearure. | ||
314 | */ | ||
315 | |||
316 | /* Multi-message attention configuration */ | ||
317 | attentionConditions[0] = (HA_R0ATT | HA_R1ATT | HA_R2ATT | HA_ERATT | | ||
318 | HA_LATT | HA_MBATT); | ||
319 | attentionConditions[1] = 0; | ||
320 | |||
321 | mb->un.varCfgMSI.attentionConditions[0] = attentionConditions[0]; | ||
322 | mb->un.varCfgMSI.attentionConditions[1] = attentionConditions[1]; | ||
323 | |||
324 | /* | ||
325 | * Set up message number to HA bit association | ||
326 | */ | ||
327 | #ifdef __BIG_ENDIAN_BITFIELD | ||
328 | /* RA0 (FCP Ring) */ | ||
329 | mb->un.varCfgMSI.messageNumberByHA[HA_R0_POS] = 1; | ||
330 | /* RA1 (Other Protocol Extra Ring) */ | ||
331 | mb->un.varCfgMSI.messageNumberByHA[HA_R1_POS] = 1; | ||
332 | #else /* __LITTLE_ENDIAN_BITFIELD */ | ||
333 | /* RA0 (FCP Ring) */ | ||
334 | mb->un.varCfgMSI.messageNumberByHA[HA_R0_POS^3] = 1; | ||
335 | /* RA1 (Other Protocol Extra Ring) */ | ||
336 | mb->un.varCfgMSI.messageNumberByHA[HA_R1_POS^3] = 1; | ||
337 | #endif | ||
338 | /* Multi-message interrupt autoclear configuration*/ | ||
339 | mb->un.varCfgMSI.autoClearHA[0] = attentionConditions[0]; | ||
340 | mb->un.varCfgMSI.autoClearHA[1] = attentionConditions[1]; | ||
341 | |||
342 | /* For now, HBA autoclear does not work reliably, disable it */ | ||
343 | mb->un.varCfgMSI.autoClearHA[0] = 0; | ||
344 | mb->un.varCfgMSI.autoClearHA[1] = 0; | ||
345 | |||
346 | /* Set command and owner bit */ | ||
347 | mb->mbxCommand = MBX_CONFIG_MSI; | ||
348 | mb->mbxOwner = OWN_HOST; | ||
349 | |||
350 | return 0; | ||
351 | } | ||
352 | |||
353 | /** | ||
354 | * lpfc_init_link: Prepare a mailbox command for initialize link on a HBA. | ||
355 | * @phba: pointer to lpfc hba data structure. | ||
356 | * @pmb: pointer to the driver internal queue element for mailbox command. | ||
357 | * @topology: the link topology for the link to be initialized to. | ||
358 | * @linkspeed: the link speed for the link to be initialized to. | ||
359 | * | ||
360 | * The initialize link mailbox command is used to initialize the Fibre | ||
361 | * Channel link. This command must follow a configure port command that | ||
362 | * establishes the mode of operation. | ||
363 | * | ||
364 | * This routine prepares the mailbox command for initializing link on a HBA | ||
365 | * with the specified link topology and speed. | ||
366 | **/ | ||
206 | void | 367 | void |
207 | lpfc_init_link(struct lpfc_hba * phba, | 368 | lpfc_init_link(struct lpfc_hba * phba, |
208 | LPFC_MBOXQ_t * pmb, uint32_t topology, uint32_t linkspeed) | 369 | LPFC_MBOXQ_t * pmb, uint32_t topology, uint32_t linkspeed) |
@@ -269,10 +430,27 @@ lpfc_init_link(struct lpfc_hba * phba, | |||
269 | return; | 430 | return; |
270 | } | 431 | } |
271 | 432 | ||
272 | /**********************************************/ | 433 | /** |
273 | /* lpfc_read_sparam Issue a READ SPARAM */ | 434 | * lpfc_read_sparam: Prepare a mailbox command for reading HBA parameters. |
274 | /* mailbox command */ | 435 | * @phba: pointer to lpfc hba data structure. |
275 | /**********************************************/ | 436 | * @pmb: pointer to the driver internal queue element for mailbox command. |
437 | * @vpi: virtual N_Port identifier. | ||
438 | * | ||
439 | * The read service parameter mailbox command is used to read the HBA port | ||
440 | * service parameters. The service parameters are read into the buffer | ||
441 | * specified directly by a BDE in the mailbox command. These service | ||
442 | * parameters may then be used to build the payload of an N_Port/F_POrt | ||
443 | * login request and reply (LOGI/ACC). | ||
444 | * | ||
445 | * This routine prepares the mailbox command for reading HBA port service | ||
446 | * parameters. The DMA memory is allocated in this function and the addresses | ||
447 | * are populated into the mailbox command for the HBA to DMA the service | ||
448 | * parameters into. | ||
449 | * | ||
450 | * Return codes | ||
451 | * 0 - Success | ||
452 | * 1 - DMA memory allocation failed | ||
453 | **/ | ||
276 | int | 454 | int |
277 | lpfc_read_sparam(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb, int vpi) | 455 | lpfc_read_sparam(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb, int vpi) |
278 | { | 456 | { |
@@ -312,10 +490,21 @@ lpfc_read_sparam(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb, int vpi) | |||
312 | return (0); | 490 | return (0); |
313 | } | 491 | } |
314 | 492 | ||
315 | /********************************************/ | 493 | /** |
316 | /* lpfc_unreg_did Issue a UNREG_DID */ | 494 | * lpfc_unreg_did: Prepare a mailbox command for unregistering DID. |
317 | /* mailbox command */ | 495 | * @phba: pointer to lpfc hba data structure. |
318 | /********************************************/ | 496 | * @vpi: virtual N_Port identifier. |
497 | * @did: remote port identifier. | ||
498 | * @pmb: pointer to the driver internal queue element for mailbox command. | ||
499 | * | ||
500 | * The unregister DID mailbox command is used to unregister an N_Port/F_Port | ||
501 | * login for an unknown RPI by specifying the DID of a remote port. This | ||
502 | * command frees an RPI context in the HBA port. This has the effect of | ||
503 | * performing an implicit N_Port/F_Port logout. | ||
504 | * | ||
505 | * This routine prepares the mailbox command for unregistering a remote | ||
506 | * N_Port/F_Port (DID) login. | ||
507 | **/ | ||
319 | void | 508 | void |
320 | lpfc_unreg_did(struct lpfc_hba * phba, uint16_t vpi, uint32_t did, | 509 | lpfc_unreg_did(struct lpfc_hba * phba, uint16_t vpi, uint32_t did, |
321 | LPFC_MBOXQ_t * pmb) | 510 | LPFC_MBOXQ_t * pmb) |
@@ -333,10 +522,19 @@ lpfc_unreg_did(struct lpfc_hba * phba, uint16_t vpi, uint32_t did, | |||
333 | return; | 522 | return; |
334 | } | 523 | } |
335 | 524 | ||
336 | /**********************************************/ | 525 | /** |
337 | /* lpfc_read_nv Issue a READ CONFIG */ | 526 | * lpfc_read_config: Prepare a mailbox command for reading HBA configuration. |
338 | /* mailbox command */ | 527 | * @phba: pointer to lpfc hba data structure. |
339 | /**********************************************/ | 528 | * @pmb: pointer to the driver internal queue element for mailbox command. |
529 | * | ||
530 | * The read configuration mailbox command is used to read the HBA port | ||
531 | * configuration parameters. This mailbox command provides a method for | ||
532 | * seeing any parameters that may have changed via various configuration | ||
533 | * mailbox commands. | ||
534 | * | ||
535 | * This routine prepares the mailbox command for reading out HBA configuration | ||
536 | * parameters. | ||
537 | **/ | ||
340 | void | 538 | void |
341 | lpfc_read_config(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmb) | 539 | lpfc_read_config(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmb) |
342 | { | 540 | { |
@@ -350,10 +548,18 @@ lpfc_read_config(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmb) | |||
350 | return; | 548 | return; |
351 | } | 549 | } |
352 | 550 | ||
353 | /*************************************************/ | 551 | /** |
354 | /* lpfc_read_lnk_stat Issue a READ LINK STATUS */ | 552 | * lpfc_read_lnk_stat: Prepare a mailbox command for reading HBA link stats. |
355 | /* mailbox command */ | 553 | * @phba: pointer to lpfc hba data structure. |
356 | /*************************************************/ | 554 | * @pmb: pointer to the driver internal queue element for mailbox command. |
555 | * | ||
556 | * The read link status mailbox command is used to read the link status from | ||
557 | * the HBA. Link status includes all link-related error counters. These | ||
558 | * counters are maintained by the HBA and originated in the link hardware | ||
559 | * unit. Note that all of these counters wrap. | ||
560 | * | ||
561 | * This routine prepares the mailbox command for reading out HBA link status. | ||
562 | **/ | ||
357 | void | 563 | void |
358 | lpfc_read_lnk_stat(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmb) | 564 | lpfc_read_lnk_stat(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmb) |
359 | { | 565 | { |
@@ -367,10 +573,30 @@ lpfc_read_lnk_stat(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmb) | |||
367 | return; | 573 | return; |
368 | } | 574 | } |
369 | 575 | ||
370 | /********************************************/ | 576 | /** |
371 | /* lpfc_reg_login Issue a REG_LOGIN */ | 577 | * lpfc_reg_login: Prepare a mailbox command for registering remote login. |
372 | /* mailbox command */ | 578 | * @phba: pointer to lpfc hba data structure. |
373 | /********************************************/ | 579 | * @vpi: virtual N_Port identifier. |
580 | * @did: remote port identifier. | ||
581 | * @param: pointer to memory holding the server parameters. | ||
582 | * @pmb: pointer to the driver internal queue element for mailbox command. | ||
583 | * @flag: action flag to be passed back for the complete function. | ||
584 | * | ||
585 | * The registration login mailbox command is used to register an N_Port or | ||
586 | * F_Port login. This registration allows the HBA to cache the remote N_Port | ||
587 | * service parameters internally and thereby make the appropriate FC-2 | ||
588 | * decisions. The remote port service parameters are handed off by the driver | ||
589 | * to the HBA using a descriptor entry that directly identifies a buffer in | ||
590 | * host memory. In exchange, the HBA returns an RPI identifier. | ||
591 | * | ||
592 | * This routine prepares the mailbox command for registering remote port login. | ||
593 | * The function allocates DMA buffer for passing the service parameters to the | ||
594 | * HBA with the mailbox command. | ||
595 | * | ||
596 | * Return codes | ||
597 | * 0 - Success | ||
598 | * 1 - DMA memory allocation failed | ||
599 | **/ | ||
374 | int | 600 | int |
375 | lpfc_reg_login(struct lpfc_hba *phba, uint16_t vpi, uint32_t did, | 601 | lpfc_reg_login(struct lpfc_hba *phba, uint16_t vpi, uint32_t did, |
376 | uint8_t *param, LPFC_MBOXQ_t *pmb, uint32_t flag) | 602 | uint8_t *param, LPFC_MBOXQ_t *pmb, uint32_t flag) |
@@ -418,10 +644,20 @@ lpfc_reg_login(struct lpfc_hba *phba, uint16_t vpi, uint32_t did, | |||
418 | return (0); | 644 | return (0); |
419 | } | 645 | } |
420 | 646 | ||
421 | /**********************************************/ | 647 | /** |
422 | /* lpfc_unreg_login Issue a UNREG_LOGIN */ | 648 | * lpfc_unreg_login: Prepare a mailbox command for unregistering remote login. |
423 | /* mailbox command */ | 649 | * @phba: pointer to lpfc hba data structure. |
424 | /**********************************************/ | 650 | * @vpi: virtual N_Port identifier. |
651 | * @rpi: remote port identifier | ||
652 | * @pmb: pointer to the driver internal queue element for mailbox command. | ||
653 | * | ||
654 | * The unregistration login mailbox command is used to unregister an N_Port | ||
655 | * or F_Port login. This command frees an RPI context in the HBA. It has the | ||
656 | * effect of performing an implicit N_Port/F_Port logout. | ||
657 | * | ||
658 | * This routine prepares the mailbox command for unregistering remote port | ||
659 | * login. | ||
660 | **/ | ||
425 | void | 661 | void |
426 | lpfc_unreg_login(struct lpfc_hba *phba, uint16_t vpi, uint32_t rpi, | 662 | lpfc_unreg_login(struct lpfc_hba *phba, uint16_t vpi, uint32_t rpi, |
427 | LPFC_MBOXQ_t * pmb) | 663 | LPFC_MBOXQ_t * pmb) |
@@ -440,10 +676,21 @@ lpfc_unreg_login(struct lpfc_hba *phba, uint16_t vpi, uint32_t rpi, | |||
440 | return; | 676 | return; |
441 | } | 677 | } |
442 | 678 | ||
443 | /**************************************************/ | 679 | /** |
444 | /* lpfc_reg_vpi Issue a REG_VPI */ | 680 | * lpfc_reg_vpi: Prepare a mailbox command for registering vport identifier. |
445 | /* mailbox command */ | 681 | * @phba: pointer to lpfc hba data structure. |
446 | /**************************************************/ | 682 | * @vpi: virtual N_Port identifier. |
683 | * @sid: Fibre Channel S_ID (N_Port_ID assigned to a virtual N_Port). | ||
684 | * @pmb: pointer to the driver internal queue element for mailbox command. | ||
685 | * | ||
686 | * The registration vport identifier mailbox command is used to activate a | ||
687 | * virtual N_Port after it has acquired an N_Port_ID. The HBA validates the | ||
688 | * N_Port_ID against the information in the selected virtual N_Port context | ||
689 | * block and marks it active to allow normal processing of IOCB commands and | ||
690 | * received unsolicited exchanges. | ||
691 | * | ||
692 | * This routine prepares the mailbox command for registering a virtual N_Port. | ||
693 | **/ | ||
447 | void | 694 | void |
448 | lpfc_reg_vpi(struct lpfc_hba *phba, uint16_t vpi, uint32_t sid, | 695 | lpfc_reg_vpi(struct lpfc_hba *phba, uint16_t vpi, uint32_t sid, |
449 | LPFC_MBOXQ_t *pmb) | 696 | LPFC_MBOXQ_t *pmb) |
@@ -461,10 +708,22 @@ lpfc_reg_vpi(struct lpfc_hba *phba, uint16_t vpi, uint32_t sid, | |||
461 | 708 | ||
462 | } | 709 | } |
463 | 710 | ||
464 | /**************************************************/ | 711 | /** |
465 | /* lpfc_unreg_vpi Issue a UNREG_VNPI */ | 712 | * lpfc_unreg_vpi: Prepare a mailbox command for unregistering vport id. |
466 | /* mailbox command */ | 713 | * @phba: pointer to lpfc hba data structure. |
467 | /**************************************************/ | 714 | * @vpi: virtual N_Port identifier. |
715 | * @pmb: pointer to the driver internal queue element for mailbox command. | ||
716 | * | ||
717 | * The unregistration vport identifier mailbox command is used to inactivate | ||
718 | * a virtual N_Port. The driver must have logged out and unregistered all | ||
719 | * remote N_Ports to abort any activity on the virtual N_Port. The HBA will | ||
720 | * unregisters any default RPIs associated with the specified vpi, aborting | ||
721 | * any active exchanges. The HBA will post the mailbox response after making | ||
722 | * the virtual N_Port inactive. | ||
723 | * | ||
724 | * This routine prepares the mailbox command for unregistering a virtual | ||
725 | * N_Port. | ||
726 | **/ | ||
468 | void | 727 | void |
469 | lpfc_unreg_vpi(struct lpfc_hba *phba, uint16_t vpi, LPFC_MBOXQ_t *pmb) | 728 | lpfc_unreg_vpi(struct lpfc_hba *phba, uint16_t vpi, LPFC_MBOXQ_t *pmb) |
470 | { | 729 | { |
@@ -479,12 +738,19 @@ lpfc_unreg_vpi(struct lpfc_hba *phba, uint16_t vpi, LPFC_MBOXQ_t *pmb) | |||
479 | 738 | ||
480 | } | 739 | } |
481 | 740 | ||
741 | /** | ||
742 | * lpfc_config_pcb_setup: Set up IOCB rings in the Port Control Block (PCB) | ||
743 | * @phba: pointer to lpfc hba data structure. | ||
744 | * | ||
745 | * This routine sets up and initializes the IOCB rings in the Port Control | ||
746 | * Block (PCB). | ||
747 | **/ | ||
482 | static void | 748 | static void |
483 | lpfc_config_pcb_setup(struct lpfc_hba * phba) | 749 | lpfc_config_pcb_setup(struct lpfc_hba * phba) |
484 | { | 750 | { |
485 | struct lpfc_sli *psli = &phba->sli; | 751 | struct lpfc_sli *psli = &phba->sli; |
486 | struct lpfc_sli_ring *pring; | 752 | struct lpfc_sli_ring *pring; |
487 | PCB_t *pcbp = &phba->slim2p->pcb; | 753 | PCB_t *pcbp = phba->pcb; |
488 | dma_addr_t pdma_addr; | 754 | dma_addr_t pdma_addr; |
489 | uint32_t offset; | 755 | uint32_t offset; |
490 | uint32_t iocbCnt = 0; | 756 | uint32_t iocbCnt = 0; |
@@ -513,29 +779,43 @@ lpfc_config_pcb_setup(struct lpfc_hba * phba) | |||
513 | continue; | 779 | continue; |
514 | } | 780 | } |
515 | /* Command ring setup for ring */ | 781 | /* Command ring setup for ring */ |
516 | pring->cmdringaddr = (void *) &phba->slim2p->IOCBs[iocbCnt]; | 782 | pring->cmdringaddr = (void *)&phba->IOCBs[iocbCnt]; |
517 | pcbp->rdsc[i].cmdEntries = pring->numCiocb; | 783 | pcbp->rdsc[i].cmdEntries = pring->numCiocb; |
518 | 784 | ||
519 | offset = (uint8_t *) &phba->slim2p->IOCBs[iocbCnt] - | 785 | offset = (uint8_t *) &phba->IOCBs[iocbCnt] - |
520 | (uint8_t *) phba->slim2p; | 786 | (uint8_t *) phba->slim2p.virt; |
521 | pdma_addr = phba->slim2p_mapping + offset; | 787 | pdma_addr = phba->slim2p.phys + offset; |
522 | pcbp->rdsc[i].cmdAddrHigh = putPaddrHigh(pdma_addr); | 788 | pcbp->rdsc[i].cmdAddrHigh = putPaddrHigh(pdma_addr); |
523 | pcbp->rdsc[i].cmdAddrLow = putPaddrLow(pdma_addr); | 789 | pcbp->rdsc[i].cmdAddrLow = putPaddrLow(pdma_addr); |
524 | iocbCnt += pring->numCiocb; | 790 | iocbCnt += pring->numCiocb; |
525 | 791 | ||
526 | /* Response ring setup for ring */ | 792 | /* Response ring setup for ring */ |
527 | pring->rspringaddr = (void *) &phba->slim2p->IOCBs[iocbCnt]; | 793 | pring->rspringaddr = (void *) &phba->IOCBs[iocbCnt]; |
528 | 794 | ||
529 | pcbp->rdsc[i].rspEntries = pring->numRiocb; | 795 | pcbp->rdsc[i].rspEntries = pring->numRiocb; |
530 | offset = (uint8_t *)&phba->slim2p->IOCBs[iocbCnt] - | 796 | offset = (uint8_t *)&phba->IOCBs[iocbCnt] - |
531 | (uint8_t *)phba->slim2p; | 797 | (uint8_t *)phba->slim2p.virt; |
532 | pdma_addr = phba->slim2p_mapping + offset; | 798 | pdma_addr = phba->slim2p.phys + offset; |
533 | pcbp->rdsc[i].rspAddrHigh = putPaddrHigh(pdma_addr); | 799 | pcbp->rdsc[i].rspAddrHigh = putPaddrHigh(pdma_addr); |
534 | pcbp->rdsc[i].rspAddrLow = putPaddrLow(pdma_addr); | 800 | pcbp->rdsc[i].rspAddrLow = putPaddrLow(pdma_addr); |
535 | iocbCnt += pring->numRiocb; | 801 | iocbCnt += pring->numRiocb; |
536 | } | 802 | } |
537 | } | 803 | } |
538 | 804 | ||
805 | /** | ||
806 | * lpfc_read_rev: Prepare a mailbox command for reading HBA revision. | ||
807 | * @phba: pointer to lpfc hba data structure. | ||
808 | * @pmb: pointer to the driver internal queue element for mailbox command. | ||
809 | * | ||
810 | * The read revision mailbox command is used to read the revision levels of | ||
811 | * the HBA components. These components include hardware units, resident | ||
812 | * firmware, and available firmware. HBAs that supports SLI-3 mode of | ||
813 | * operation provide different response information depending on the version | ||
814 | * requested by the driver. | ||
815 | * | ||
816 | * This routine prepares the mailbox command for reading HBA revision | ||
817 | * information. | ||
818 | **/ | ||
539 | void | 819 | void |
540 | lpfc_read_rev(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmb) | 820 | lpfc_read_rev(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmb) |
541 | { | 821 | { |
@@ -548,6 +828,16 @@ lpfc_read_rev(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmb) | |||
548 | return; | 828 | return; |
549 | } | 829 | } |
550 | 830 | ||
831 | /** | ||
832 | * lpfc_build_hbq_profile2: Set up the HBQ Selection Profile 2. | ||
833 | * @hbqmb: pointer to the HBQ configuration data structure in mailbox command. | ||
834 | * @hbq_desc: pointer to the HBQ selection profile descriptor. | ||
835 | * | ||
836 | * The Host Buffer Queue (HBQ) Selection Profile 2 specifies that the HBA | ||
837 | * tests the incoming frames' R_CTL/TYPE fields with works 10:15 and performs | ||
838 | * the Sequence Length Test using the fields in the Selection Profile 2 | ||
839 | * extension in words 20:31. | ||
840 | **/ | ||
551 | static void | 841 | static void |
552 | lpfc_build_hbq_profile2(struct config_hbq_var *hbqmb, | 842 | lpfc_build_hbq_profile2(struct config_hbq_var *hbqmb, |
553 | struct lpfc_hbq_init *hbq_desc) | 843 | struct lpfc_hbq_init *hbq_desc) |
@@ -557,6 +847,16 @@ lpfc_build_hbq_profile2(struct config_hbq_var *hbqmb, | |||
557 | hbqmb->profiles.profile2.seqlenoff = hbq_desc->seqlenoff; | 847 | hbqmb->profiles.profile2.seqlenoff = hbq_desc->seqlenoff; |
558 | } | 848 | } |
559 | 849 | ||
850 | /** | ||
851 | * lpfc_build_hbq_profile3: Set up the HBQ Selection Profile 3. | ||
852 | * @hbqmb: pointer to the HBQ configuration data structure in mailbox command. | ||
853 | * @hbq_desc: pointer to the HBQ selection profile descriptor. | ||
854 | * | ||
855 | * The Host Buffer Queue (HBQ) Selection Profile 3 specifies that the HBA | ||
856 | * tests the incoming frame's R_CTL/TYPE fields with words 10:15 and performs | ||
857 | * the Sequence Length Test and Byte Field Test using the fields in the | ||
858 | * Selection Profile 3 extension in words 20:31. | ||
859 | **/ | ||
560 | static void | 860 | static void |
561 | lpfc_build_hbq_profile3(struct config_hbq_var *hbqmb, | 861 | lpfc_build_hbq_profile3(struct config_hbq_var *hbqmb, |
562 | struct lpfc_hbq_init *hbq_desc) | 862 | struct lpfc_hbq_init *hbq_desc) |
@@ -569,6 +869,17 @@ lpfc_build_hbq_profile3(struct config_hbq_var *hbqmb, | |||
569 | sizeof(hbqmb->profiles.profile3.cmdmatch)); | 869 | sizeof(hbqmb->profiles.profile3.cmdmatch)); |
570 | } | 870 | } |
571 | 871 | ||
872 | /** | ||
873 | * lpfc_build_hbq_profile5: Set up the HBQ Selection Profile 5. | ||
874 | * @hbqmb: pointer to the HBQ configuration data structure in mailbox command. | ||
875 | * @hbq_desc: pointer to the HBQ selection profile descriptor. | ||
876 | * | ||
877 | * The Host Buffer Queue (HBQ) Selection Profile 5 specifies a header HBQ. The | ||
878 | * HBA tests the initial frame of an incoming sequence using the frame's | ||
879 | * R_CTL/TYPE fields with words 10:15 and performs the Sequence Length Test | ||
880 | * and Byte Field Test using the fields in the Selection Profile 5 extension | ||
881 | * words 20:31. | ||
882 | **/ | ||
572 | static void | 883 | static void |
573 | lpfc_build_hbq_profile5(struct config_hbq_var *hbqmb, | 884 | lpfc_build_hbq_profile5(struct config_hbq_var *hbqmb, |
574 | struct lpfc_hbq_init *hbq_desc) | 885 | struct lpfc_hbq_init *hbq_desc) |
@@ -581,6 +892,20 @@ lpfc_build_hbq_profile5(struct config_hbq_var *hbqmb, | |||
581 | sizeof(hbqmb->profiles.profile5.cmdmatch)); | 892 | sizeof(hbqmb->profiles.profile5.cmdmatch)); |
582 | } | 893 | } |
583 | 894 | ||
895 | /** | ||
896 | * lpfc_config_hbq: Prepare a mailbox command for configuring an HBQ. | ||
897 | * @phba: pointer to lpfc hba data structure. | ||
898 | * @id: HBQ identifier. | ||
899 | * @hbq_desc: pointer to the HBA descriptor data structure. | ||
900 | * @hbq_entry_index: index of the HBQ entry data structures. | ||
901 | * @pmb: pointer to the driver internal queue element for mailbox command. | ||
902 | * | ||
903 | * The configure HBQ (Host Buffer Queue) mailbox command is used to configure | ||
904 | * an HBQ. The configuration binds events that require buffers to a particular | ||
905 | * ring and HBQ based on a selection profile. | ||
906 | * | ||
907 | * This routine prepares the mailbox command for configuring an HBQ. | ||
908 | **/ | ||
584 | void | 909 | void |
585 | lpfc_config_hbq(struct lpfc_hba *phba, uint32_t id, | 910 | lpfc_config_hbq(struct lpfc_hba *phba, uint32_t id, |
586 | struct lpfc_hbq_init *hbq_desc, | 911 | struct lpfc_hbq_init *hbq_desc, |
@@ -641,8 +966,23 @@ lpfc_config_hbq(struct lpfc_hba *phba, uint32_t id, | |||
641 | return; | 966 | return; |
642 | } | 967 | } |
643 | 968 | ||
644 | 969 | /** | |
645 | 970 | * lpfc_config_ring: Prepare a mailbox command for configuring an IOCB ring. | |
971 | * @phba: pointer to lpfc hba data structure. | ||
972 | * @ring: | ||
973 | * @pmb: pointer to the driver internal queue element for mailbox command. | ||
974 | * | ||
975 | * The configure ring mailbox command is used to configure an IOCB ring. This | ||
976 | * configuration binds from one to six of HBA RC_CTL/TYPE mask entries to the | ||
977 | * ring. This is used to map incoming sequences to a particular ring whose | ||
978 | * RC_CTL/TYPE mask entry matches that of the sequence. The driver should not | ||
979 | * attempt to configure a ring whose number is greater than the number | ||
980 | * specified in the Port Control Block (PCB). It is an error to issue the | ||
981 | * configure ring command more than once with the same ring number. The HBA | ||
982 | * returns an error if the driver attempts this. | ||
983 | * | ||
984 | * This routine prepares the mailbox command for configuring IOCB ring. | ||
985 | **/ | ||
646 | void | 986 | void |
647 | lpfc_config_ring(struct lpfc_hba * phba, int ring, LPFC_MBOXQ_t * pmb) | 987 | lpfc_config_ring(struct lpfc_hba * phba, int ring, LPFC_MBOXQ_t * pmb) |
648 | { | 988 | { |
@@ -684,6 +1024,20 @@ lpfc_config_ring(struct lpfc_hba * phba, int ring, LPFC_MBOXQ_t * pmb) | |||
684 | return; | 1024 | return; |
685 | } | 1025 | } |
686 | 1026 | ||
1027 | /** | ||
1028 | * lpfc_config_port: Prepare a mailbox command for configuring port. | ||
1029 | * @phba: pointer to lpfc hba data structure. | ||
1030 | * @pmb: pointer to the driver internal queue element for mailbox command. | ||
1031 | * | ||
1032 | * The configure port mailbox command is used to identify the Port Control | ||
1033 | * Block (PCB) in the driver memory. After this command is issued, the | ||
1034 | * driver must not access the mailbox in the HBA without first resetting | ||
1035 | * the HBA. The HBA may copy the PCB information to internal storage for | ||
1036 | * subsequent use; the driver can not change the PCB information unless it | ||
1037 | * resets the HBA. | ||
1038 | * | ||
1039 | * This routine prepares the mailbox command for configuring port. | ||
1040 | **/ | ||
687 | void | 1041 | void |
688 | lpfc_config_port(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb) | 1042 | lpfc_config_port(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb) |
689 | { | 1043 | { |
@@ -702,8 +1056,8 @@ lpfc_config_port(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb) | |||
702 | 1056 | ||
703 | mb->un.varCfgPort.pcbLen = sizeof(PCB_t); | 1057 | mb->un.varCfgPort.pcbLen = sizeof(PCB_t); |
704 | 1058 | ||
705 | offset = (uint8_t *)&phba->slim2p->pcb - (uint8_t *)phba->slim2p; | 1059 | offset = (uint8_t *)phba->pcb - (uint8_t *)phba->slim2p.virt; |
706 | pdma_addr = phba->slim2p_mapping + offset; | 1060 | pdma_addr = phba->slim2p.phys + offset; |
707 | mb->un.varCfgPort.pcbLow = putPaddrLow(pdma_addr); | 1061 | mb->un.varCfgPort.pcbLow = putPaddrLow(pdma_addr); |
708 | mb->un.varCfgPort.pcbHigh = putPaddrHigh(pdma_addr); | 1062 | mb->un.varCfgPort.pcbHigh = putPaddrHigh(pdma_addr); |
709 | 1063 | ||
@@ -711,12 +1065,13 @@ lpfc_config_port(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb) | |||
711 | 1065 | ||
712 | if (phba->sli_rev == 3 && phba->vpd.sli3Feat.cerbm) { | 1066 | if (phba->sli_rev == 3 && phba->vpd.sli3Feat.cerbm) { |
713 | mb->un.varCfgPort.cerbm = 1; /* Request HBQs */ | 1067 | mb->un.varCfgPort.cerbm = 1; /* Request HBQs */ |
1068 | mb->un.varCfgPort.ccrp = 1; /* Command Ring Polling */ | ||
1069 | mb->un.varCfgPort.cinb = 1; /* Interrupt Notification Block */ | ||
714 | mb->un.varCfgPort.max_hbq = lpfc_sli_hbq_count(); | 1070 | mb->un.varCfgPort.max_hbq = lpfc_sli_hbq_count(); |
715 | if (phba->max_vpi && phba->cfg_enable_npiv && | 1071 | if (phba->max_vpi && phba->cfg_enable_npiv && |
716 | phba->vpd.sli3Feat.cmv) { | 1072 | phba->vpd.sli3Feat.cmv) { |
717 | mb->un.varCfgPort.max_vpi = phba->max_vpi; | 1073 | mb->un.varCfgPort.max_vpi = phba->max_vpi; |
718 | mb->un.varCfgPort.cmv = 1; | 1074 | mb->un.varCfgPort.cmv = 1; |
719 | phba->sli3_options |= LPFC_SLI3_NPIV_ENABLED; | ||
720 | } else | 1075 | } else |
721 | mb->un.varCfgPort.max_vpi = phba->max_vpi = 0; | 1076 | mb->un.varCfgPort.max_vpi = phba->max_vpi = 0; |
722 | } else | 1077 | } else |
@@ -724,16 +1079,15 @@ lpfc_config_port(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb) | |||
724 | mb->un.varCfgPort.sli_mode = phba->sli_rev; | 1079 | mb->un.varCfgPort.sli_mode = phba->sli_rev; |
725 | 1080 | ||
726 | /* Now setup pcb */ | 1081 | /* Now setup pcb */ |
727 | phba->slim2p->pcb.type = TYPE_NATIVE_SLI2; | 1082 | phba->pcb->type = TYPE_NATIVE_SLI2; |
728 | phba->slim2p->pcb.feature = FEATURE_INITIAL_SLI2; | 1083 | phba->pcb->feature = FEATURE_INITIAL_SLI2; |
729 | 1084 | ||
730 | /* Setup Mailbox pointers */ | 1085 | /* Setup Mailbox pointers */ |
731 | phba->slim2p->pcb.mailBoxSize = offsetof(MAILBOX_t, us) + | 1086 | phba->pcb->mailBoxSize = sizeof(MAILBOX_t); |
732 | sizeof(struct sli2_desc); | 1087 | offset = (uint8_t *)phba->mbox - (uint8_t *)phba->slim2p.virt; |
733 | offset = (uint8_t *)&phba->slim2p->mbx - (uint8_t *)phba->slim2p; | 1088 | pdma_addr = phba->slim2p.phys + offset; |
734 | pdma_addr = phba->slim2p_mapping + offset; | 1089 | phba->pcb->mbAddrHigh = putPaddrHigh(pdma_addr); |
735 | phba->slim2p->pcb.mbAddrHigh = putPaddrHigh(pdma_addr); | 1090 | phba->pcb->mbAddrLow = putPaddrLow(pdma_addr); |
736 | phba->slim2p->pcb.mbAddrLow = putPaddrLow(pdma_addr); | ||
737 | 1091 | ||
738 | /* | 1092 | /* |
739 | * Setup Host Group ring pointer. | 1093 | * Setup Host Group ring pointer. |
@@ -794,13 +1148,13 @@ lpfc_config_port(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb) | |||
794 | } | 1148 | } |
795 | 1149 | ||
796 | /* mask off BAR0's flag bits 0 - 3 */ | 1150 | /* mask off BAR0's flag bits 0 - 3 */ |
797 | phba->slim2p->pcb.hgpAddrLow = (bar_low & PCI_BASE_ADDRESS_MEM_MASK) + | 1151 | phba->pcb->hgpAddrLow = (bar_low & PCI_BASE_ADDRESS_MEM_MASK) + |
798 | (void __iomem *) phba->host_gp - | 1152 | (void __iomem *)phba->host_gp - |
799 | (void __iomem *)phba->MBslimaddr; | 1153 | (void __iomem *)phba->MBslimaddr; |
800 | if (bar_low & PCI_BASE_ADDRESS_MEM_TYPE_64) | 1154 | if (bar_low & PCI_BASE_ADDRESS_MEM_TYPE_64) |
801 | phba->slim2p->pcb.hgpAddrHigh = bar_high; | 1155 | phba->pcb->hgpAddrHigh = bar_high; |
802 | else | 1156 | else |
803 | phba->slim2p->pcb.hgpAddrHigh = 0; | 1157 | phba->pcb->hgpAddrHigh = 0; |
804 | /* write HGP data to SLIM at the required longword offset */ | 1158 | /* write HGP data to SLIM at the required longword offset */ |
805 | memset(&hgp, 0, sizeof(struct lpfc_hgp)); | 1159 | memset(&hgp, 0, sizeof(struct lpfc_hgp)); |
806 | 1160 | ||
@@ -810,17 +1164,19 @@ lpfc_config_port(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb) | |||
810 | } | 1164 | } |
811 | 1165 | ||
812 | /* Setup Port Group ring pointer */ | 1166 | /* Setup Port Group ring pointer */ |
813 | if (phba->sli_rev == 3) | 1167 | if (phba->sli3_options & LPFC_SLI3_INB_ENABLED) { |
814 | pgp_offset = (uint8_t *)&phba->slim2p->mbx.us.s3_pgp.port - | 1168 | pgp_offset = offsetof(struct lpfc_sli2_slim, |
815 | (uint8_t *)phba->slim2p; | 1169 | mbx.us.s3_inb_pgp.port); |
816 | else | 1170 | phba->hbq_get = phba->mbox->us.s3_inb_pgp.hbq_get; |
817 | pgp_offset = (uint8_t *)&phba->slim2p->mbx.us.s2.port - | 1171 | } else if (phba->sli_rev == 3) { |
818 | (uint8_t *)phba->slim2p; | 1172 | pgp_offset = offsetof(struct lpfc_sli2_slim, |
819 | 1173 | mbx.us.s3_pgp.port); | |
820 | pdma_addr = phba->slim2p_mapping + pgp_offset; | 1174 | phba->hbq_get = phba->mbox->us.s3_pgp.hbq_get; |
821 | phba->slim2p->pcb.pgpAddrHigh = putPaddrHigh(pdma_addr); | 1175 | } else |
822 | phba->slim2p->pcb.pgpAddrLow = putPaddrLow(pdma_addr); | 1176 | pgp_offset = offsetof(struct lpfc_sli2_slim, mbx.us.s2.port); |
823 | phba->hbq_get = &phba->slim2p->mbx.us.s3_pgp.hbq_get[0]; | 1177 | pdma_addr = phba->slim2p.phys + pgp_offset; |
1178 | phba->pcb->pgpAddrHigh = putPaddrHigh(pdma_addr); | ||
1179 | phba->pcb->pgpAddrLow = putPaddrLow(pdma_addr); | ||
824 | 1180 | ||
825 | /* Use callback routine to setp rings in the pcb */ | 1181 | /* Use callback routine to setp rings in the pcb */ |
826 | lpfc_config_pcb_setup(phba); | 1182 | lpfc_config_pcb_setup(phba); |
@@ -835,10 +1191,24 @@ lpfc_config_port(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb) | |||
835 | } | 1191 | } |
836 | 1192 | ||
837 | /* Swap PCB if needed */ | 1193 | /* Swap PCB if needed */ |
838 | lpfc_sli_pcimem_bcopy(&phba->slim2p->pcb, &phba->slim2p->pcb, | 1194 | lpfc_sli_pcimem_bcopy(phba->pcb, phba->pcb, sizeof(PCB_t)); |
839 | sizeof(PCB_t)); | ||
840 | } | 1195 | } |
841 | 1196 | ||
1197 | /** | ||
1198 | * lpfc_kill_board: Prepare a mailbox command for killing board. | ||
1199 | * @phba: pointer to lpfc hba data structure. | ||
1200 | * @pmb: pointer to the driver internal queue element for mailbox command. | ||
1201 | * | ||
1202 | * The kill board mailbox command is used to tell firmware to perform a | ||
1203 | * graceful shutdown of a channel on a specified board to prepare for reset. | ||
1204 | * When the kill board mailbox command is received, the ER3 bit is set to 1 | ||
1205 | * in the Host Status register and the ER Attention bit is set to 1 in the | ||
1206 | * Host Attention register of the HBA function that received the kill board | ||
1207 | * command. | ||
1208 | * | ||
1209 | * This routine prepares the mailbox command for killing the board in | ||
1210 | * preparation for a graceful shutdown. | ||
1211 | **/ | ||
842 | void | 1212 | void |
843 | lpfc_kill_board(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmb) | 1213 | lpfc_kill_board(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmb) |
844 | { | 1214 | { |
@@ -850,6 +1220,16 @@ lpfc_kill_board(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmb) | |||
850 | return; | 1220 | return; |
851 | } | 1221 | } |
852 | 1222 | ||
1223 | /** | ||
1224 | * lpfc_mbox_put: Put a mailbox cmd into the tail of driver's mailbox queue. | ||
1225 | * @phba: pointer to lpfc hba data structure. | ||
1226 | * @mbq: pointer to the driver internal queue element for mailbox command. | ||
1227 | * | ||
1228 | * Driver maintains a internal mailbox command queue implemented as a linked | ||
1229 | * list. When a mailbox command is issued, it shall be put into the mailbox | ||
1230 | * command queue such that they shall be processed orderly as HBA can process | ||
1231 | * one mailbox command at a time. | ||
1232 | **/ | ||
853 | void | 1233 | void |
854 | lpfc_mbox_put(struct lpfc_hba * phba, LPFC_MBOXQ_t * mbq) | 1234 | lpfc_mbox_put(struct lpfc_hba * phba, LPFC_MBOXQ_t * mbq) |
855 | { | 1235 | { |
@@ -864,6 +1244,20 @@ lpfc_mbox_put(struct lpfc_hba * phba, LPFC_MBOXQ_t * mbq) | |||
864 | return; | 1244 | return; |
865 | } | 1245 | } |
866 | 1246 | ||
1247 | /** | ||
1248 | * lpfc_mbox_get: Remove a mailbox cmd from the head of driver's mailbox queue. | ||
1249 | * @phba: pointer to lpfc hba data structure. | ||
1250 | * | ||
1251 | * Driver maintains a internal mailbox command queue implemented as a linked | ||
1252 | * list. When a mailbox command is issued, it shall be put into the mailbox | ||
1253 | * command queue such that they shall be processed orderly as HBA can process | ||
1254 | * one mailbox command at a time. After HBA finished processing a mailbox | ||
1255 | * command, the driver will remove a pending mailbox command from the head of | ||
1256 | * the mailbox command queue and send to the HBA for processing. | ||
1257 | * | ||
1258 | * Return codes | ||
1259 | * pointer to the driver internal queue element for mailbox command. | ||
1260 | **/ | ||
867 | LPFC_MBOXQ_t * | 1261 | LPFC_MBOXQ_t * |
868 | lpfc_mbox_get(struct lpfc_hba * phba) | 1262 | lpfc_mbox_get(struct lpfc_hba * phba) |
869 | { | 1263 | { |
@@ -877,6 +1271,17 @@ lpfc_mbox_get(struct lpfc_hba * phba) | |||
877 | return mbq; | 1271 | return mbq; |
878 | } | 1272 | } |
879 | 1273 | ||
1274 | /** | ||
1275 | * lpfc_mbox_cmpl_put: Put mailbox command into mailbox command complete list. | ||
1276 | * @phba: pointer to lpfc hba data structure. | ||
1277 | * @mbq: pointer to the driver internal queue element for mailbox command. | ||
1278 | * | ||
1279 | * This routine put the completed mailbox command into the mailbox command | ||
1280 | * complete list. This routine is called from driver interrupt handler | ||
1281 | * context.The mailbox complete list is used by the driver worker thread | ||
1282 | * to process mailbox complete callback functions outside the driver interrupt | ||
1283 | * handler. | ||
1284 | **/ | ||
880 | void | 1285 | void |
881 | lpfc_mbox_cmpl_put(struct lpfc_hba * phba, LPFC_MBOXQ_t * mbq) | 1286 | lpfc_mbox_cmpl_put(struct lpfc_hba * phba, LPFC_MBOXQ_t * mbq) |
882 | { | 1287 | { |
@@ -887,6 +1292,17 @@ lpfc_mbox_cmpl_put(struct lpfc_hba * phba, LPFC_MBOXQ_t * mbq) | |||
887 | return; | 1292 | return; |
888 | } | 1293 | } |
889 | 1294 | ||
1295 | /** | ||
1296 | * lpfc_mbox_tmo_val: Retrieve mailbox command timeout value. | ||
1297 | * @phba: pointer to lpfc hba data structure. | ||
1298 | * @cmd: mailbox command code. | ||
1299 | * | ||
1300 | * This routine retrieves the proper timeout value according to the mailbox | ||
1301 | * command code. | ||
1302 | * | ||
1303 | * Return codes | ||
1304 | * Timeout value to be used for the given mailbox command | ||
1305 | **/ | ||
890 | int | 1306 | int |
891 | lpfc_mbox_tmo_val(struct lpfc_hba *phba, int cmd) | 1307 | lpfc_mbox_tmo_val(struct lpfc_hba *phba, int cmd) |
892 | { | 1308 | { |