diff options
Diffstat (limited to 'drivers/scsi/lpfc/lpfc_hbadisc.c')
-rw-r--r-- | drivers/scsi/lpfc/lpfc_hbadisc.c | 437 |
1 files changed, 315 insertions, 122 deletions
diff --git a/drivers/scsi/lpfc/lpfc_hbadisc.c b/drivers/scsi/lpfc/lpfc_hbadisc.c index a345dde16c86..a5d1695dac3d 100644 --- a/drivers/scsi/lpfc/lpfc_hbadisc.c +++ b/drivers/scsi/lpfc/lpfc_hbadisc.c | |||
@@ -20,6 +20,7 @@ | |||
20 | *******************************************************************/ | 20 | *******************************************************************/ |
21 | 21 | ||
22 | #include <linux/blkdev.h> | 22 | #include <linux/blkdev.h> |
23 | #include <linux/delay.h> | ||
23 | #include <linux/slab.h> | 24 | #include <linux/slab.h> |
24 | #include <linux/pci.h> | 25 | #include <linux/pci.h> |
25 | #include <linux/kthread.h> | 26 | #include <linux/kthread.h> |
@@ -63,6 +64,7 @@ static uint8_t lpfcAlpaArray[] = { | |||
63 | static void lpfc_disc_timeout_handler(struct lpfc_vport *); | 64 | static void lpfc_disc_timeout_handler(struct lpfc_vport *); |
64 | static void lpfc_disc_flush_list(struct lpfc_vport *vport); | 65 | static void lpfc_disc_flush_list(struct lpfc_vport *vport); |
65 | static void lpfc_unregister_fcfi_cmpl(struct lpfc_hba *, LPFC_MBOXQ_t *); | 66 | static void lpfc_unregister_fcfi_cmpl(struct lpfc_hba *, LPFC_MBOXQ_t *); |
67 | static int lpfc_fcf_inuse(struct lpfc_hba *); | ||
66 | 68 | ||
67 | void | 69 | void |
68 | lpfc_terminate_rport_io(struct fc_rport *rport) | 70 | lpfc_terminate_rport_io(struct fc_rport *rport) |
@@ -160,11 +162,17 @@ lpfc_dev_loss_tmo_callbk(struct fc_rport *rport) | |||
160 | return; | 162 | return; |
161 | } | 163 | } |
162 | 164 | ||
163 | /* | 165 | /** |
164 | * This function is called from the worker thread when dev_loss_tmo | 166 | * lpfc_dev_loss_tmo_handler - Remote node devloss timeout handler |
165 | * expire. | 167 | * @ndlp: Pointer to remote node object. |
166 | */ | 168 | * |
167 | static void | 169 | * This function is called from the worker thread when devloss timeout timer |
170 | * expires. For SLI4 host, this routine shall return 1 when at lease one | ||
171 | * remote node, including this @ndlp, is still in use of FCF; otherwise, this | ||
172 | * routine shall return 0 when there is no remote node is still in use of FCF | ||
173 | * when devloss timeout happened to this @ndlp. | ||
174 | **/ | ||
175 | static int | ||
168 | lpfc_dev_loss_tmo_handler(struct lpfc_nodelist *ndlp) | 176 | lpfc_dev_loss_tmo_handler(struct lpfc_nodelist *ndlp) |
169 | { | 177 | { |
170 | struct lpfc_rport_data *rdata; | 178 | struct lpfc_rport_data *rdata; |
@@ -175,17 +183,21 @@ lpfc_dev_loss_tmo_handler(struct lpfc_nodelist *ndlp) | |||
175 | int put_node; | 183 | int put_node; |
176 | int put_rport; | 184 | int put_rport; |
177 | int warn_on = 0; | 185 | int warn_on = 0; |
186 | int fcf_inuse = 0; | ||
178 | 187 | ||
179 | rport = ndlp->rport; | 188 | rport = ndlp->rport; |
180 | 189 | ||
181 | if (!rport) | 190 | if (!rport) |
182 | return; | 191 | return fcf_inuse; |
183 | 192 | ||
184 | rdata = rport->dd_data; | 193 | rdata = rport->dd_data; |
185 | name = (uint8_t *) &ndlp->nlp_portname; | 194 | name = (uint8_t *) &ndlp->nlp_portname; |
186 | vport = ndlp->vport; | 195 | vport = ndlp->vport; |
187 | phba = vport->phba; | 196 | phba = vport->phba; |
188 | 197 | ||
198 | if (phba->sli_rev == LPFC_SLI_REV4) | ||
199 | fcf_inuse = lpfc_fcf_inuse(phba); | ||
200 | |||
189 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_RPORT, | 201 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_RPORT, |
190 | "rport devlosstmo:did:x%x type:x%x id:x%x", | 202 | "rport devlosstmo:did:x%x type:x%x id:x%x", |
191 | ndlp->nlp_DID, ndlp->nlp_type, rport->scsi_target_id); | 203 | ndlp->nlp_DID, ndlp->nlp_type, rport->scsi_target_id); |
@@ -209,7 +221,7 @@ lpfc_dev_loss_tmo_handler(struct lpfc_nodelist *ndlp) | |||
209 | lpfc_nlp_put(ndlp); | 221 | lpfc_nlp_put(ndlp); |
210 | if (put_rport) | 222 | if (put_rport) |
211 | put_device(&rport->dev); | 223 | put_device(&rport->dev); |
212 | return; | 224 | return fcf_inuse; |
213 | } | 225 | } |
214 | 226 | ||
215 | if (ndlp->nlp_state == NLP_STE_MAPPED_NODE) { | 227 | if (ndlp->nlp_state == NLP_STE_MAPPED_NODE) { |
@@ -220,7 +232,7 @@ lpfc_dev_loss_tmo_handler(struct lpfc_nodelist *ndlp) | |||
220 | *name, *(name+1), *(name+2), *(name+3), | 232 | *name, *(name+1), *(name+2), *(name+3), |
221 | *(name+4), *(name+5), *(name+6), *(name+7), | 233 | *(name+4), *(name+5), *(name+6), *(name+7), |
222 | ndlp->nlp_DID); | 234 | ndlp->nlp_DID); |
223 | return; | 235 | return fcf_inuse; |
224 | } | 236 | } |
225 | 237 | ||
226 | if (ndlp->nlp_type & NLP_FABRIC) { | 238 | if (ndlp->nlp_type & NLP_FABRIC) { |
@@ -233,7 +245,7 @@ lpfc_dev_loss_tmo_handler(struct lpfc_nodelist *ndlp) | |||
233 | lpfc_nlp_put(ndlp); | 245 | lpfc_nlp_put(ndlp); |
234 | if (put_rport) | 246 | if (put_rport) |
235 | put_device(&rport->dev); | 247 | put_device(&rport->dev); |
236 | return; | 248 | return fcf_inuse; |
237 | } | 249 | } |
238 | 250 | ||
239 | if (ndlp->nlp_sid != NLP_NO_SID) { | 251 | if (ndlp->nlp_sid != NLP_NO_SID) { |
@@ -280,6 +292,74 @@ lpfc_dev_loss_tmo_handler(struct lpfc_nodelist *ndlp) | |||
280 | (ndlp->nlp_state != NLP_STE_PRLI_ISSUE)) | 292 | (ndlp->nlp_state != NLP_STE_PRLI_ISSUE)) |
281 | lpfc_disc_state_machine(vport, ndlp, NULL, NLP_EVT_DEVICE_RM); | 293 | lpfc_disc_state_machine(vport, ndlp, NULL, NLP_EVT_DEVICE_RM); |
282 | 294 | ||
295 | return fcf_inuse; | ||
296 | } | ||
297 | |||
298 | /** | ||
299 | * lpfc_sli4_post_dev_loss_tmo_handler - SLI4 post devloss timeout handler | ||
300 | * @phba: Pointer to hba context object. | ||
301 | * @fcf_inuse: SLI4 FCF in-use state reported from devloss timeout handler. | ||
302 | * @nlp_did: remote node identifer with devloss timeout. | ||
303 | * | ||
304 | * This function is called from the worker thread after invoking devloss | ||
305 | * timeout handler and releasing the reference count for the ndlp with | ||
306 | * which the devloss timeout was handled for SLI4 host. For the devloss | ||
307 | * timeout of the last remote node which had been in use of FCF, when this | ||
308 | * routine is invoked, it shall be guaranteed that none of the remote are | ||
309 | * in-use of FCF. When devloss timeout to the last remote using the FCF, | ||
310 | * if the FIP engine is neither in FCF table scan process nor roundrobin | ||
311 | * failover process, the in-use FCF shall be unregistered. If the FIP | ||
312 | * engine is in FCF discovery process, the devloss timeout state shall | ||
313 | * be set for either the FCF table scan process or roundrobin failover | ||
314 | * process to unregister the in-use FCF. | ||
315 | **/ | ||
316 | static void | ||
317 | lpfc_sli4_post_dev_loss_tmo_handler(struct lpfc_hba *phba, int fcf_inuse, | ||
318 | uint32_t nlp_did) | ||
319 | { | ||
320 | /* If devloss timeout happened to a remote node when FCF had no | ||
321 | * longer been in-use, do nothing. | ||
322 | */ | ||
323 | if (!fcf_inuse) | ||
324 | return; | ||
325 | |||
326 | if ((phba->hba_flag & HBA_FIP_SUPPORT) && !lpfc_fcf_inuse(phba)) { | ||
327 | spin_lock_irq(&phba->hbalock); | ||
328 | if (phba->fcf.fcf_flag & FCF_DISCOVERY) { | ||
329 | if (phba->hba_flag & HBA_DEVLOSS_TMO) { | ||
330 | spin_unlock_irq(&phba->hbalock); | ||
331 | return; | ||
332 | } | ||
333 | phba->hba_flag |= HBA_DEVLOSS_TMO; | ||
334 | lpfc_printf_log(phba, KERN_INFO, LOG_FIP, | ||
335 | "2847 Last remote node (x%x) using " | ||
336 | "FCF devloss tmo\n", nlp_did); | ||
337 | } | ||
338 | if (phba->fcf.fcf_flag & FCF_REDISC_PROG) { | ||
339 | spin_unlock_irq(&phba->hbalock); | ||
340 | lpfc_printf_log(phba, KERN_INFO, LOG_FIP, | ||
341 | "2868 Devloss tmo to FCF rediscovery " | ||
342 | "in progress\n"); | ||
343 | return; | ||
344 | } | ||
345 | if (!(phba->hba_flag & (FCF_TS_INPROG | FCF_RR_INPROG))) { | ||
346 | spin_unlock_irq(&phba->hbalock); | ||
347 | lpfc_printf_log(phba, KERN_INFO, LOG_FIP, | ||
348 | "2869 Devloss tmo to idle FIP engine, " | ||
349 | "unreg in-use FCF and rescan.\n"); | ||
350 | /* Unregister in-use FCF and rescan */ | ||
351 | lpfc_unregister_fcf_rescan(phba); | ||
352 | return; | ||
353 | } | ||
354 | spin_unlock_irq(&phba->hbalock); | ||
355 | if (phba->hba_flag & FCF_TS_INPROG) | ||
356 | lpfc_printf_log(phba, KERN_INFO, LOG_FIP, | ||
357 | "2870 FCF table scan in progress\n"); | ||
358 | if (phba->hba_flag & FCF_RR_INPROG) | ||
359 | lpfc_printf_log(phba, KERN_INFO, LOG_FIP, | ||
360 | "2871 FLOGI roundrobin FCF failover " | ||
361 | "in progress\n"); | ||
362 | } | ||
283 | lpfc_unregister_unused_fcf(phba); | 363 | lpfc_unregister_unused_fcf(phba); |
284 | } | 364 | } |
285 | 365 | ||
@@ -408,6 +488,8 @@ lpfc_work_list_done(struct lpfc_hba *phba) | |||
408 | struct lpfc_work_evt *evtp = NULL; | 488 | struct lpfc_work_evt *evtp = NULL; |
409 | struct lpfc_nodelist *ndlp; | 489 | struct lpfc_nodelist *ndlp; |
410 | int free_evt; | 490 | int free_evt; |
491 | int fcf_inuse; | ||
492 | uint32_t nlp_did; | ||
411 | 493 | ||
412 | spin_lock_irq(&phba->hbalock); | 494 | spin_lock_irq(&phba->hbalock); |
413 | while (!list_empty(&phba->work_list)) { | 495 | while (!list_empty(&phba->work_list)) { |
@@ -427,12 +509,17 @@ lpfc_work_list_done(struct lpfc_hba *phba) | |||
427 | break; | 509 | break; |
428 | case LPFC_EVT_DEV_LOSS: | 510 | case LPFC_EVT_DEV_LOSS: |
429 | ndlp = (struct lpfc_nodelist *)(evtp->evt_arg1); | 511 | ndlp = (struct lpfc_nodelist *)(evtp->evt_arg1); |
430 | lpfc_dev_loss_tmo_handler(ndlp); | 512 | fcf_inuse = lpfc_dev_loss_tmo_handler(ndlp); |
431 | free_evt = 0; | 513 | free_evt = 0; |
432 | /* decrement the node reference count held for | 514 | /* decrement the node reference count held for |
433 | * this queued work | 515 | * this queued work |
434 | */ | 516 | */ |
517 | nlp_did = ndlp->nlp_DID; | ||
435 | lpfc_nlp_put(ndlp); | 518 | lpfc_nlp_put(ndlp); |
519 | if (phba->sli_rev == LPFC_SLI_REV4) | ||
520 | lpfc_sli4_post_dev_loss_tmo_handler(phba, | ||
521 | fcf_inuse, | ||
522 | nlp_did); | ||
436 | break; | 523 | break; |
437 | case LPFC_EVT_ONLINE: | 524 | case LPFC_EVT_ONLINE: |
438 | if (phba->link_state < LPFC_LINK_DOWN) | 525 | if (phba->link_state < LPFC_LINK_DOWN) |
@@ -707,6 +794,8 @@ lpfc_cleanup_rpis(struct lpfc_vport *vport, int remove) | |||
707 | : NLP_EVT_DEVICE_RECOVERY); | 794 | : NLP_EVT_DEVICE_RECOVERY); |
708 | } | 795 | } |
709 | if (phba->sli3_options & LPFC_SLI3_VPORT_TEARDOWN) { | 796 | if (phba->sli3_options & LPFC_SLI3_VPORT_TEARDOWN) { |
797 | if (phba->sli_rev == LPFC_SLI_REV4) | ||
798 | lpfc_sli4_unreg_all_rpis(vport); | ||
710 | lpfc_mbx_unreg_vpi(vport); | 799 | lpfc_mbx_unreg_vpi(vport); |
711 | spin_lock_irq(shost->host_lock); | 800 | spin_lock_irq(shost->host_lock); |
712 | vport->fc_flag |= FC_VPORT_NEEDS_REG_VPI; | 801 | vport->fc_flag |= FC_VPORT_NEEDS_REG_VPI; |
@@ -1021,8 +1110,7 @@ lpfc_mbx_cmpl_reg_fcfi(struct lpfc_hba *phba, LPFC_MBOXQ_t *mboxq) | |||
1021 | "2017 REG_FCFI mbxStatus error x%x " | 1110 | "2017 REG_FCFI mbxStatus error x%x " |
1022 | "HBA state x%x\n", | 1111 | "HBA state x%x\n", |
1023 | mboxq->u.mb.mbxStatus, vport->port_state); | 1112 | mboxq->u.mb.mbxStatus, vport->port_state); |
1024 | mempool_free(mboxq, phba->mbox_mem_pool); | 1113 | goto fail_out; |
1025 | return; | ||
1026 | } | 1114 | } |
1027 | 1115 | ||
1028 | /* Start FCoE discovery by sending a FLOGI. */ | 1116 | /* Start FCoE discovery by sending a FLOGI. */ |
@@ -1031,20 +1119,30 @@ lpfc_mbx_cmpl_reg_fcfi(struct lpfc_hba *phba, LPFC_MBOXQ_t *mboxq) | |||
1031 | spin_lock_irq(&phba->hbalock); | 1119 | spin_lock_irq(&phba->hbalock); |
1032 | phba->fcf.fcf_flag |= FCF_REGISTERED; | 1120 | phba->fcf.fcf_flag |= FCF_REGISTERED; |
1033 | spin_unlock_irq(&phba->hbalock); | 1121 | spin_unlock_irq(&phba->hbalock); |
1122 | |||
1034 | /* If there is a pending FCoE event, restart FCF table scan. */ | 1123 | /* If there is a pending FCoE event, restart FCF table scan. */ |
1035 | if (lpfc_check_pending_fcoe_event(phba, 1)) { | 1124 | if (lpfc_check_pending_fcoe_event(phba, LPFC_UNREG_FCF)) |
1036 | mempool_free(mboxq, phba->mbox_mem_pool); | 1125 | goto fail_out; |
1037 | return; | 1126 | |
1038 | } | 1127 | /* Mark successful completion of FCF table scan */ |
1039 | spin_lock_irq(&phba->hbalock); | 1128 | spin_lock_irq(&phba->hbalock); |
1040 | phba->fcf.fcf_flag |= (FCF_SCAN_DONE | FCF_IN_USE); | 1129 | phba->fcf.fcf_flag |= (FCF_SCAN_DONE | FCF_IN_USE); |
1041 | phba->hba_flag &= ~FCF_DISC_INPROGRESS; | 1130 | phba->hba_flag &= ~FCF_TS_INPROG; |
1042 | spin_unlock_irq(&phba->hbalock); | 1131 | if (vport->port_state != LPFC_FLOGI) { |
1043 | if (vport->port_state != LPFC_FLOGI) | 1132 | phba->hba_flag |= FCF_RR_INPROG; |
1133 | spin_unlock_irq(&phba->hbalock); | ||
1044 | lpfc_initial_flogi(vport); | 1134 | lpfc_initial_flogi(vport); |
1135 | goto out; | ||
1136 | } | ||
1137 | spin_unlock_irq(&phba->hbalock); | ||
1138 | goto out; | ||
1045 | 1139 | ||
1140 | fail_out: | ||
1141 | spin_lock_irq(&phba->hbalock); | ||
1142 | phba->hba_flag &= ~FCF_RR_INPROG; | ||
1143 | spin_unlock_irq(&phba->hbalock); | ||
1144 | out: | ||
1046 | mempool_free(mboxq, phba->mbox_mem_pool); | 1145 | mempool_free(mboxq, phba->mbox_mem_pool); |
1047 | return; | ||
1048 | } | 1146 | } |
1049 | 1147 | ||
1050 | /** | 1148 | /** |
@@ -1241,10 +1339,9 @@ lpfc_register_fcf(struct lpfc_hba *phba) | |||
1241 | int rc; | 1339 | int rc; |
1242 | 1340 | ||
1243 | spin_lock_irq(&phba->hbalock); | 1341 | spin_lock_irq(&phba->hbalock); |
1244 | |||
1245 | /* If the FCF is not availabe do nothing. */ | 1342 | /* If the FCF is not availabe do nothing. */ |
1246 | if (!(phba->fcf.fcf_flag & FCF_AVAILABLE)) { | 1343 | if (!(phba->fcf.fcf_flag & FCF_AVAILABLE)) { |
1247 | phba->hba_flag &= ~FCF_DISC_INPROGRESS; | 1344 | phba->hba_flag &= ~(FCF_TS_INPROG | FCF_RR_INPROG); |
1248 | spin_unlock_irq(&phba->hbalock); | 1345 | spin_unlock_irq(&phba->hbalock); |
1249 | return; | 1346 | return; |
1250 | } | 1347 | } |
@@ -1252,19 +1349,22 @@ lpfc_register_fcf(struct lpfc_hba *phba) | |||
1252 | /* The FCF is already registered, start discovery */ | 1349 | /* The FCF is already registered, start discovery */ |
1253 | if (phba->fcf.fcf_flag & FCF_REGISTERED) { | 1350 | if (phba->fcf.fcf_flag & FCF_REGISTERED) { |
1254 | phba->fcf.fcf_flag |= (FCF_SCAN_DONE | FCF_IN_USE); | 1351 | phba->fcf.fcf_flag |= (FCF_SCAN_DONE | FCF_IN_USE); |
1255 | phba->hba_flag &= ~FCF_DISC_INPROGRESS; | 1352 | phba->hba_flag &= ~FCF_TS_INPROG; |
1256 | spin_unlock_irq(&phba->hbalock); | 1353 | if (phba->pport->port_state != LPFC_FLOGI) { |
1257 | if (phba->pport->port_state != LPFC_FLOGI) | 1354 | phba->hba_flag |= FCF_RR_INPROG; |
1355 | spin_unlock_irq(&phba->hbalock); | ||
1258 | lpfc_initial_flogi(phba->pport); | 1356 | lpfc_initial_flogi(phba->pport); |
1357 | return; | ||
1358 | } | ||
1359 | spin_unlock_irq(&phba->hbalock); | ||
1259 | return; | 1360 | return; |
1260 | } | 1361 | } |
1261 | spin_unlock_irq(&phba->hbalock); | 1362 | spin_unlock_irq(&phba->hbalock); |
1262 | 1363 | ||
1263 | fcf_mbxq = mempool_alloc(phba->mbox_mem_pool, | 1364 | fcf_mbxq = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); |
1264 | GFP_KERNEL); | ||
1265 | if (!fcf_mbxq) { | 1365 | if (!fcf_mbxq) { |
1266 | spin_lock_irq(&phba->hbalock); | 1366 | spin_lock_irq(&phba->hbalock); |
1267 | phba->hba_flag &= ~FCF_DISC_INPROGRESS; | 1367 | phba->hba_flag &= ~(FCF_TS_INPROG | FCF_RR_INPROG); |
1268 | spin_unlock_irq(&phba->hbalock); | 1368 | spin_unlock_irq(&phba->hbalock); |
1269 | return; | 1369 | return; |
1270 | } | 1370 | } |
@@ -1275,7 +1375,7 @@ lpfc_register_fcf(struct lpfc_hba *phba) | |||
1275 | rc = lpfc_sli_issue_mbox(phba, fcf_mbxq, MBX_NOWAIT); | 1375 | rc = lpfc_sli_issue_mbox(phba, fcf_mbxq, MBX_NOWAIT); |
1276 | if (rc == MBX_NOT_FINISHED) { | 1376 | if (rc == MBX_NOT_FINISHED) { |
1277 | spin_lock_irq(&phba->hbalock); | 1377 | spin_lock_irq(&phba->hbalock); |
1278 | phba->hba_flag &= ~FCF_DISC_INPROGRESS; | 1378 | phba->hba_flag &= ~(FCF_TS_INPROG | FCF_RR_INPROG); |
1279 | spin_unlock_irq(&phba->hbalock); | 1379 | spin_unlock_irq(&phba->hbalock); |
1280 | mempool_free(fcf_mbxq, phba->mbox_mem_pool); | 1380 | mempool_free(fcf_mbxq, phba->mbox_mem_pool); |
1281 | } | 1381 | } |
@@ -1493,7 +1593,7 @@ lpfc_check_pending_fcoe_event(struct lpfc_hba *phba, uint8_t unreg_fcf) | |||
1493 | * FCF discovery, no need to restart FCF discovery. | 1593 | * FCF discovery, no need to restart FCF discovery. |
1494 | */ | 1594 | */ |
1495 | if ((phba->link_state >= LPFC_LINK_UP) && | 1595 | if ((phba->link_state >= LPFC_LINK_UP) && |
1496 | (phba->fcoe_eventtag == phba->fcoe_eventtag_at_fcf_scan)) | 1596 | (phba->fcoe_eventtag == phba->fcoe_eventtag_at_fcf_scan)) |
1497 | return 0; | 1597 | return 0; |
1498 | 1598 | ||
1499 | lpfc_printf_log(phba, KERN_INFO, LOG_FIP, | 1599 | lpfc_printf_log(phba, KERN_INFO, LOG_FIP, |
@@ -1517,14 +1617,14 @@ lpfc_check_pending_fcoe_event(struct lpfc_hba *phba, uint8_t unreg_fcf) | |||
1517 | lpfc_sli4_fcf_scan_read_fcf_rec(phba, LPFC_FCOE_FCF_GET_FIRST); | 1617 | lpfc_sli4_fcf_scan_read_fcf_rec(phba, LPFC_FCOE_FCF_GET_FIRST); |
1518 | } else { | 1618 | } else { |
1519 | /* | 1619 | /* |
1520 | * Do not continue FCF discovery and clear FCF_DISC_INPROGRESS | 1620 | * Do not continue FCF discovery and clear FCF_TS_INPROG |
1521 | * flag | 1621 | * flag |
1522 | */ | 1622 | */ |
1523 | lpfc_printf_log(phba, KERN_INFO, LOG_FIP | LOG_DISCOVERY, | 1623 | lpfc_printf_log(phba, KERN_INFO, LOG_FIP | LOG_DISCOVERY, |
1524 | "2833 Stop FCF discovery process due to link " | 1624 | "2833 Stop FCF discovery process due to link " |
1525 | "state change (x%x)\n", phba->link_state); | 1625 | "state change (x%x)\n", phba->link_state); |
1526 | spin_lock_irq(&phba->hbalock); | 1626 | spin_lock_irq(&phba->hbalock); |
1527 | phba->hba_flag &= ~FCF_DISC_INPROGRESS; | 1627 | phba->hba_flag &= ~(FCF_TS_INPROG | FCF_RR_INPROG); |
1528 | phba->fcf.fcf_flag &= ~(FCF_REDISC_FOV | FCF_DISCOVERY); | 1628 | phba->fcf.fcf_flag &= ~(FCF_REDISC_FOV | FCF_DISCOVERY); |
1529 | spin_unlock_irq(&phba->hbalock); | 1629 | spin_unlock_irq(&phba->hbalock); |
1530 | } | 1630 | } |
@@ -1729,6 +1829,65 @@ lpfc_sli4_fcf_record_match(struct lpfc_hba *phba, | |||
1729 | } | 1829 | } |
1730 | 1830 | ||
1731 | /** | 1831 | /** |
1832 | * lpfc_sli4_fcf_rr_next_proc - processing next roundrobin fcf | ||
1833 | * @vport: Pointer to vport object. | ||
1834 | * @fcf_index: index to next fcf. | ||
1835 | * | ||
1836 | * This function processing the roundrobin fcf failover to next fcf index. | ||
1837 | * When this function is invoked, there will be a current fcf registered | ||
1838 | * for flogi. | ||
1839 | * Return: 0 for continue retrying flogi on currently registered fcf; | ||
1840 | * 1 for stop flogi on currently registered fcf; | ||
1841 | */ | ||
1842 | int lpfc_sli4_fcf_rr_next_proc(struct lpfc_vport *vport, uint16_t fcf_index) | ||
1843 | { | ||
1844 | struct lpfc_hba *phba = vport->phba; | ||
1845 | int rc; | ||
1846 | |||
1847 | if (fcf_index == LPFC_FCOE_FCF_NEXT_NONE) { | ||
1848 | spin_lock_irq(&phba->hbalock); | ||
1849 | if (phba->hba_flag & HBA_DEVLOSS_TMO) { | ||
1850 | spin_unlock_irq(&phba->hbalock); | ||
1851 | lpfc_printf_log(phba, KERN_INFO, LOG_FIP, | ||
1852 | "2872 Devloss tmo with no eligible " | ||
1853 | "FCF, unregister in-use FCF (x%x) " | ||
1854 | "and rescan FCF table\n", | ||
1855 | phba->fcf.current_rec.fcf_indx); | ||
1856 | lpfc_unregister_fcf_rescan(phba); | ||
1857 | goto stop_flogi_current_fcf; | ||
1858 | } | ||
1859 | /* Mark the end to FLOGI roundrobin failover */ | ||
1860 | phba->hba_flag &= ~FCF_RR_INPROG; | ||
1861 | /* Allow action to new fcf asynchronous event */ | ||
1862 | phba->fcf.fcf_flag &= ~(FCF_AVAILABLE | FCF_SCAN_DONE); | ||
1863 | spin_unlock_irq(&phba->hbalock); | ||
1864 | lpfc_printf_log(phba, KERN_INFO, LOG_FIP, | ||
1865 | "2865 No FCF available, stop roundrobin FCF " | ||
1866 | "failover and change port state:x%x/x%x\n", | ||
1867 | phba->pport->port_state, LPFC_VPORT_UNKNOWN); | ||
1868 | phba->pport->port_state = LPFC_VPORT_UNKNOWN; | ||
1869 | goto stop_flogi_current_fcf; | ||
1870 | } else { | ||
1871 | lpfc_printf_log(phba, KERN_INFO, LOG_FIP | LOG_ELS, | ||
1872 | "2794 Try FLOGI roundrobin FCF failover to " | ||
1873 | "(x%x)\n", fcf_index); | ||
1874 | rc = lpfc_sli4_fcf_rr_read_fcf_rec(phba, fcf_index); | ||
1875 | if (rc) | ||
1876 | lpfc_printf_log(phba, KERN_WARNING, LOG_FIP | LOG_ELS, | ||
1877 | "2761 FLOGI roundrobin FCF failover " | ||
1878 | "failed (rc:x%x) to read FCF (x%x)\n", | ||
1879 | rc, phba->fcf.current_rec.fcf_indx); | ||
1880 | else | ||
1881 | goto stop_flogi_current_fcf; | ||
1882 | } | ||
1883 | return 0; | ||
1884 | |||
1885 | stop_flogi_current_fcf: | ||
1886 | lpfc_can_disctmo(vport); | ||
1887 | return 1; | ||
1888 | } | ||
1889 | |||
1890 | /** | ||
1732 | * lpfc_mbx_cmpl_fcf_scan_read_fcf_rec - fcf scan read_fcf mbox cmpl handler. | 1891 | * lpfc_mbx_cmpl_fcf_scan_read_fcf_rec - fcf scan read_fcf mbox cmpl handler. |
1733 | * @phba: pointer to lpfc hba data structure. | 1892 | * @phba: pointer to lpfc hba data structure. |
1734 | * @mboxq: pointer to mailbox object. | 1893 | * @mboxq: pointer to mailbox object. |
@@ -1756,7 +1915,7 @@ lpfc_mbx_cmpl_fcf_scan_read_fcf_rec(struct lpfc_hba *phba, LPFC_MBOXQ_t *mboxq) | |||
1756 | int rc; | 1915 | int rc; |
1757 | 1916 | ||
1758 | /* If there is pending FCoE event restart FCF table scan */ | 1917 | /* If there is pending FCoE event restart FCF table scan */ |
1759 | if (lpfc_check_pending_fcoe_event(phba, 0)) { | 1918 | if (lpfc_check_pending_fcoe_event(phba, LPFC_SKIP_UNREG_FCF)) { |
1760 | lpfc_sli4_mbox_cmd_free(phba, mboxq); | 1919 | lpfc_sli4_mbox_cmd_free(phba, mboxq); |
1761 | return; | 1920 | return; |
1762 | } | 1921 | } |
@@ -1765,12 +1924,12 @@ lpfc_mbx_cmpl_fcf_scan_read_fcf_rec(struct lpfc_hba *phba, LPFC_MBOXQ_t *mboxq) | |||
1765 | new_fcf_record = lpfc_sli4_fcf_rec_mbox_parse(phba, mboxq, | 1924 | new_fcf_record = lpfc_sli4_fcf_rec_mbox_parse(phba, mboxq, |
1766 | &next_fcf_index); | 1925 | &next_fcf_index); |
1767 | if (!new_fcf_record) { | 1926 | if (!new_fcf_record) { |
1768 | lpfc_printf_log(phba, KERN_WARNING, LOG_FIP, | 1927 | lpfc_printf_log(phba, KERN_ERR, LOG_FIP, |
1769 | "2765 Mailbox command READ_FCF_RECORD " | 1928 | "2765 Mailbox command READ_FCF_RECORD " |
1770 | "failed to retrieve a FCF record.\n"); | 1929 | "failed to retrieve a FCF record.\n"); |
1771 | /* Let next new FCF event trigger fast failover */ | 1930 | /* Let next new FCF event trigger fast failover */ |
1772 | spin_lock_irq(&phba->hbalock); | 1931 | spin_lock_irq(&phba->hbalock); |
1773 | phba->hba_flag &= ~FCF_DISC_INPROGRESS; | 1932 | phba->hba_flag &= ~FCF_TS_INPROG; |
1774 | spin_unlock_irq(&phba->hbalock); | 1933 | spin_unlock_irq(&phba->hbalock); |
1775 | lpfc_sli4_mbox_cmd_free(phba, mboxq); | 1934 | lpfc_sli4_mbox_cmd_free(phba, mboxq); |
1776 | return; | 1935 | return; |
@@ -1787,13 +1946,12 @@ lpfc_mbx_cmpl_fcf_scan_read_fcf_rec(struct lpfc_hba *phba, LPFC_MBOXQ_t *mboxq) | |||
1787 | /* | 1946 | /* |
1788 | * If the fcf record does not match with connect list entries | 1947 | * If the fcf record does not match with connect list entries |
1789 | * read the next entry; otherwise, this is an eligible FCF | 1948 | * read the next entry; otherwise, this is an eligible FCF |
1790 | * record for round robin FCF failover. | 1949 | * record for roundrobin FCF failover. |
1791 | */ | 1950 | */ |
1792 | if (!rc) { | 1951 | if (!rc) { |
1793 | lpfc_printf_log(phba, KERN_WARNING, LOG_FIP, | 1952 | lpfc_printf_log(phba, KERN_WARNING, LOG_FIP, |
1794 | "2781 FCF record (x%x) failed FCF " | 1953 | "2781 FCF (x%x) failed connection " |
1795 | "connection list check, fcf_avail:x%x, " | 1954 | "list check: (x%x/x%x)\n", |
1796 | "fcf_valid:x%x\n", | ||
1797 | bf_get(lpfc_fcf_record_fcf_index, | 1955 | bf_get(lpfc_fcf_record_fcf_index, |
1798 | new_fcf_record), | 1956 | new_fcf_record), |
1799 | bf_get(lpfc_fcf_record_fcf_avail, | 1957 | bf_get(lpfc_fcf_record_fcf_avail, |
@@ -1803,6 +1961,16 @@ lpfc_mbx_cmpl_fcf_scan_read_fcf_rec(struct lpfc_hba *phba, LPFC_MBOXQ_t *mboxq) | |||
1803 | if ((phba->fcf.fcf_flag & FCF_IN_USE) && | 1961 | if ((phba->fcf.fcf_flag & FCF_IN_USE) && |
1804 | lpfc_sli4_fcf_record_match(phba, &phba->fcf.current_rec, | 1962 | lpfc_sli4_fcf_record_match(phba, &phba->fcf.current_rec, |
1805 | new_fcf_record, LPFC_FCOE_IGNORE_VID)) { | 1963 | new_fcf_record, LPFC_FCOE_IGNORE_VID)) { |
1964 | if (bf_get(lpfc_fcf_record_fcf_index, new_fcf_record) != | ||
1965 | phba->fcf.current_rec.fcf_indx) { | ||
1966 | lpfc_printf_log(phba, KERN_ERR, LOG_FIP, | ||
1967 | "2862 FCF (x%x) matches property " | ||
1968 | "of in-use FCF (x%x)\n", | ||
1969 | bf_get(lpfc_fcf_record_fcf_index, | ||
1970 | new_fcf_record), | ||
1971 | phba->fcf.current_rec.fcf_indx); | ||
1972 | goto read_next_fcf; | ||
1973 | } | ||
1806 | /* | 1974 | /* |
1807 | * In case the current in-use FCF record becomes | 1975 | * In case the current in-use FCF record becomes |
1808 | * invalid/unavailable during FCF discovery that | 1976 | * invalid/unavailable during FCF discovery that |
@@ -1813,9 +1981,8 @@ lpfc_mbx_cmpl_fcf_scan_read_fcf_rec(struct lpfc_hba *phba, LPFC_MBOXQ_t *mboxq) | |||
1813 | !(phba->fcf.fcf_flag & FCF_REDISC_FOV)) { | 1981 | !(phba->fcf.fcf_flag & FCF_REDISC_FOV)) { |
1814 | lpfc_printf_log(phba, KERN_WARNING, LOG_FIP, | 1982 | lpfc_printf_log(phba, KERN_WARNING, LOG_FIP, |
1815 | "2835 Invalid in-use FCF " | 1983 | "2835 Invalid in-use FCF " |
1816 | "record (x%x) reported, " | 1984 | "(x%x), enter FCF failover " |
1817 | "entering fast FCF failover " | 1985 | "table scan.\n", |
1818 | "mode scanning.\n", | ||
1819 | phba->fcf.current_rec.fcf_indx); | 1986 | phba->fcf.current_rec.fcf_indx); |
1820 | spin_lock_irq(&phba->hbalock); | 1987 | spin_lock_irq(&phba->hbalock); |
1821 | phba->fcf.fcf_flag |= FCF_REDISC_FOV; | 1988 | phba->fcf.fcf_flag |= FCF_REDISC_FOV; |
@@ -1844,22 +2011,29 @@ lpfc_mbx_cmpl_fcf_scan_read_fcf_rec(struct lpfc_hba *phba, LPFC_MBOXQ_t *mboxq) | |||
1844 | if (phba->fcf.fcf_flag & FCF_IN_USE) { | 2011 | if (phba->fcf.fcf_flag & FCF_IN_USE) { |
1845 | if (lpfc_sli4_fcf_record_match(phba, &phba->fcf.current_rec, | 2012 | if (lpfc_sli4_fcf_record_match(phba, &phba->fcf.current_rec, |
1846 | new_fcf_record, vlan_id)) { | 2013 | new_fcf_record, vlan_id)) { |
1847 | phba->fcf.fcf_flag |= FCF_AVAILABLE; | 2014 | if (bf_get(lpfc_fcf_record_fcf_index, new_fcf_record) == |
1848 | if (phba->fcf.fcf_flag & FCF_REDISC_PEND) | 2015 | phba->fcf.current_rec.fcf_indx) { |
1849 | /* Stop FCF redisc wait timer if pending */ | 2016 | phba->fcf.fcf_flag |= FCF_AVAILABLE; |
1850 | __lpfc_sli4_stop_fcf_redisc_wait_timer(phba); | 2017 | if (phba->fcf.fcf_flag & FCF_REDISC_PEND) |
1851 | else if (phba->fcf.fcf_flag & FCF_REDISC_FOV) | 2018 | /* Stop FCF redisc wait timer */ |
1852 | /* If in fast failover, mark it's completed */ | 2019 | __lpfc_sli4_stop_fcf_redisc_wait_timer( |
1853 | phba->fcf.fcf_flag &= ~FCF_REDISC_FOV; | 2020 | phba); |
1854 | spin_unlock_irq(&phba->hbalock); | 2021 | else if (phba->fcf.fcf_flag & FCF_REDISC_FOV) |
1855 | lpfc_printf_log(phba, KERN_INFO, LOG_FIP, | 2022 | /* Fast failover, mark completed */ |
1856 | "2836 The new FCF record (x%x) " | 2023 | phba->fcf.fcf_flag &= ~FCF_REDISC_FOV; |
1857 | "matches the in-use FCF record " | 2024 | spin_unlock_irq(&phba->hbalock); |
1858 | "(x%x)\n", | 2025 | lpfc_printf_log(phba, KERN_INFO, LOG_FIP, |
1859 | phba->fcf.current_rec.fcf_indx, | 2026 | "2836 New FCF matches in-use " |
2027 | "FCF (x%x)\n", | ||
2028 | phba->fcf.current_rec.fcf_indx); | ||
2029 | goto out; | ||
2030 | } else | ||
2031 | lpfc_printf_log(phba, KERN_ERR, LOG_FIP, | ||
2032 | "2863 New FCF (x%x) matches " | ||
2033 | "property of in-use FCF (x%x)\n", | ||
1860 | bf_get(lpfc_fcf_record_fcf_index, | 2034 | bf_get(lpfc_fcf_record_fcf_index, |
1861 | new_fcf_record)); | 2035 | new_fcf_record), |
1862 | goto out; | 2036 | phba->fcf.current_rec.fcf_indx); |
1863 | } | 2037 | } |
1864 | /* | 2038 | /* |
1865 | * Read next FCF record from HBA searching for the matching | 2039 | * Read next FCF record from HBA searching for the matching |
@@ -1953,8 +2127,8 @@ lpfc_mbx_cmpl_fcf_scan_read_fcf_rec(struct lpfc_hba *phba, LPFC_MBOXQ_t *mboxq) | |||
1953 | */ | 2127 | */ |
1954 | if (fcf_rec) { | 2128 | if (fcf_rec) { |
1955 | lpfc_printf_log(phba, KERN_INFO, LOG_FIP, | 2129 | lpfc_printf_log(phba, KERN_INFO, LOG_FIP, |
1956 | "2840 Update current FCF record " | 2130 | "2840 Update initial FCF candidate " |
1957 | "with initial FCF record (x%x)\n", | 2131 | "with FCF (x%x)\n", |
1958 | bf_get(lpfc_fcf_record_fcf_index, | 2132 | bf_get(lpfc_fcf_record_fcf_index, |
1959 | new_fcf_record)); | 2133 | new_fcf_record)); |
1960 | __lpfc_update_fcf_record(phba, fcf_rec, new_fcf_record, | 2134 | __lpfc_update_fcf_record(phba, fcf_rec, new_fcf_record, |
@@ -1984,20 +2158,28 @@ read_next_fcf: | |||
1984 | */ | 2158 | */ |
1985 | if (!(phba->fcf.failover_rec.flag & RECORD_VALID)) { | 2159 | if (!(phba->fcf.failover_rec.flag & RECORD_VALID)) { |
1986 | lpfc_printf_log(phba, KERN_WARNING, LOG_FIP, | 2160 | lpfc_printf_log(phba, KERN_WARNING, LOG_FIP, |
1987 | "2782 No suitable FCF record " | 2161 | "2782 No suitable FCF found: " |
1988 | "found during this round of " | 2162 | "(x%x/x%x)\n", |
1989 | "post FCF rediscovery scan: " | ||
1990 | "fcf_evt_tag:x%x, fcf_index: " | ||
1991 | "x%x\n", | ||
1992 | phba->fcoe_eventtag_at_fcf_scan, | 2163 | phba->fcoe_eventtag_at_fcf_scan, |
1993 | bf_get(lpfc_fcf_record_fcf_index, | 2164 | bf_get(lpfc_fcf_record_fcf_index, |
1994 | new_fcf_record)); | 2165 | new_fcf_record)); |
2166 | spin_lock_irq(&phba->hbalock); | ||
2167 | if (phba->hba_flag & HBA_DEVLOSS_TMO) { | ||
2168 | phba->hba_flag &= ~FCF_TS_INPROG; | ||
2169 | spin_unlock_irq(&phba->hbalock); | ||
2170 | /* Unregister in-use FCF and rescan */ | ||
2171 | lpfc_printf_log(phba, KERN_INFO, | ||
2172 | LOG_FIP, | ||
2173 | "2864 On devloss tmo " | ||
2174 | "unreg in-use FCF and " | ||
2175 | "rescan FCF table\n"); | ||
2176 | lpfc_unregister_fcf_rescan(phba); | ||
2177 | return; | ||
2178 | } | ||
1995 | /* | 2179 | /* |
1996 | * Let next new FCF event trigger fast | 2180 | * Let next new FCF event trigger fast failover |
1997 | * failover | ||
1998 | */ | 2181 | */ |
1999 | spin_lock_irq(&phba->hbalock); | 2182 | phba->hba_flag &= ~FCF_TS_INPROG; |
2000 | phba->hba_flag &= ~FCF_DISC_INPROGRESS; | ||
2001 | spin_unlock_irq(&phba->hbalock); | 2183 | spin_unlock_irq(&phba->hbalock); |
2002 | return; | 2184 | return; |
2003 | } | 2185 | } |
@@ -2015,9 +2197,8 @@ read_next_fcf: | |||
2015 | 2197 | ||
2016 | /* Replace in-use record with the new record */ | 2198 | /* Replace in-use record with the new record */ |
2017 | lpfc_printf_log(phba, KERN_INFO, LOG_FIP, | 2199 | lpfc_printf_log(phba, KERN_INFO, LOG_FIP, |
2018 | "2842 Replace the current in-use " | 2200 | "2842 Replace in-use FCF (x%x) " |
2019 | "FCF record (x%x) with failover FCF " | 2201 | "with failover FCF (x%x)\n", |
2020 | "record (x%x)\n", | ||
2021 | phba->fcf.current_rec.fcf_indx, | 2202 | phba->fcf.current_rec.fcf_indx, |
2022 | phba->fcf.failover_rec.fcf_indx); | 2203 | phba->fcf.failover_rec.fcf_indx); |
2023 | memcpy(&phba->fcf.current_rec, | 2204 | memcpy(&phba->fcf.current_rec, |
@@ -2029,15 +2210,8 @@ read_next_fcf: | |||
2029 | * FCF failover. | 2210 | * FCF failover. |
2030 | */ | 2211 | */ |
2031 | spin_lock_irq(&phba->hbalock); | 2212 | spin_lock_irq(&phba->hbalock); |
2032 | phba->fcf.fcf_flag &= | 2213 | phba->fcf.fcf_flag &= ~FCF_REDISC_FOV; |
2033 | ~(FCF_REDISC_FOV | FCF_REDISC_RRU); | ||
2034 | spin_unlock_irq(&phba->hbalock); | 2214 | spin_unlock_irq(&phba->hbalock); |
2035 | /* | ||
2036 | * Set up the initial registered FCF index for FLOGI | ||
2037 | * round robin FCF failover. | ||
2038 | */ | ||
2039 | phba->fcf.fcf_rr_init_indx = | ||
2040 | phba->fcf.failover_rec.fcf_indx; | ||
2041 | /* Register to the new FCF record */ | 2215 | /* Register to the new FCF record */ |
2042 | lpfc_register_fcf(phba); | 2216 | lpfc_register_fcf(phba); |
2043 | } else { | 2217 | } else { |
@@ -2069,28 +2243,6 @@ read_next_fcf: | |||
2069 | LPFC_FCOE_FCF_GET_FIRST); | 2243 | LPFC_FCOE_FCF_GET_FIRST); |
2070 | return; | 2244 | return; |
2071 | } | 2245 | } |
2072 | |||
2073 | /* | ||
2074 | * Otherwise, initial scan or post linkdown rescan, | ||
2075 | * register with the best FCF record found so far | ||
2076 | * through the FCF scanning process. | ||
2077 | */ | ||
2078 | |||
2079 | /* | ||
2080 | * Mark the initial FCF discovery completed and | ||
2081 | * the start of the first round of the roundrobin | ||
2082 | * FCF failover. | ||
2083 | */ | ||
2084 | spin_lock_irq(&phba->hbalock); | ||
2085 | phba->fcf.fcf_flag &= | ||
2086 | ~(FCF_INIT_DISC | FCF_REDISC_RRU); | ||
2087 | spin_unlock_irq(&phba->hbalock); | ||
2088 | /* | ||
2089 | * Set up the initial registered FCF index for FLOGI | ||
2090 | * round robin FCF failover | ||
2091 | */ | ||
2092 | phba->fcf.fcf_rr_init_indx = | ||
2093 | phba->fcf.current_rec.fcf_indx; | ||
2094 | /* Register to the new FCF record */ | 2246 | /* Register to the new FCF record */ |
2095 | lpfc_register_fcf(phba); | 2247 | lpfc_register_fcf(phba); |
2096 | } | 2248 | } |
@@ -2106,11 +2258,11 @@ out: | |||
2106 | } | 2258 | } |
2107 | 2259 | ||
2108 | /** | 2260 | /** |
2109 | * lpfc_mbx_cmpl_fcf_rr_read_fcf_rec - fcf round robin read_fcf mbox cmpl hdler | 2261 | * lpfc_mbx_cmpl_fcf_rr_read_fcf_rec - fcf roundrobin read_fcf mbox cmpl hdler |
2110 | * @phba: pointer to lpfc hba data structure. | 2262 | * @phba: pointer to lpfc hba data structure. |
2111 | * @mboxq: pointer to mailbox object. | 2263 | * @mboxq: pointer to mailbox object. |
2112 | * | 2264 | * |
2113 | * This is the callback function for FLOGI failure round robin FCF failover | 2265 | * This is the callback function for FLOGI failure roundrobin FCF failover |
2114 | * read FCF record mailbox command from the eligible FCF record bmask for | 2266 | * read FCF record mailbox command from the eligible FCF record bmask for |
2115 | * performing the failover. If the FCF read back is not valid/available, it | 2267 | * performing the failover. If the FCF read back is not valid/available, it |
2116 | * fails through to retrying FLOGI to the currently registered FCF again. | 2268 | * fails through to retrying FLOGI to the currently registered FCF again. |
@@ -2125,17 +2277,18 @@ lpfc_mbx_cmpl_fcf_rr_read_fcf_rec(struct lpfc_hba *phba, LPFC_MBOXQ_t *mboxq) | |||
2125 | { | 2277 | { |
2126 | struct fcf_record *new_fcf_record; | 2278 | struct fcf_record *new_fcf_record; |
2127 | uint32_t boot_flag, addr_mode; | 2279 | uint32_t boot_flag, addr_mode; |
2128 | uint16_t next_fcf_index; | 2280 | uint16_t next_fcf_index, fcf_index; |
2129 | uint16_t current_fcf_index; | 2281 | uint16_t current_fcf_index; |
2130 | uint16_t vlan_id; | 2282 | uint16_t vlan_id; |
2283 | int rc; | ||
2131 | 2284 | ||
2132 | /* If link state is not up, stop the round robin failover process */ | 2285 | /* If link state is not up, stop the roundrobin failover process */ |
2133 | if (phba->link_state < LPFC_LINK_UP) { | 2286 | if (phba->link_state < LPFC_LINK_UP) { |
2134 | spin_lock_irq(&phba->hbalock); | 2287 | spin_lock_irq(&phba->hbalock); |
2135 | phba->fcf.fcf_flag &= ~FCF_DISCOVERY; | 2288 | phba->fcf.fcf_flag &= ~FCF_DISCOVERY; |
2289 | phba->hba_flag &= ~FCF_RR_INPROG; | ||
2136 | spin_unlock_irq(&phba->hbalock); | 2290 | spin_unlock_irq(&phba->hbalock); |
2137 | lpfc_sli4_mbox_cmd_free(phba, mboxq); | 2291 | goto out; |
2138 | return; | ||
2139 | } | 2292 | } |
2140 | 2293 | ||
2141 | /* Parse the FCF record from the non-embedded mailbox command */ | 2294 | /* Parse the FCF record from the non-embedded mailbox command */ |
@@ -2145,23 +2298,47 @@ lpfc_mbx_cmpl_fcf_rr_read_fcf_rec(struct lpfc_hba *phba, LPFC_MBOXQ_t *mboxq) | |||
2145 | lpfc_printf_log(phba, KERN_WARNING, LOG_FIP, | 2298 | lpfc_printf_log(phba, KERN_WARNING, LOG_FIP, |
2146 | "2766 Mailbox command READ_FCF_RECORD " | 2299 | "2766 Mailbox command READ_FCF_RECORD " |
2147 | "failed to retrieve a FCF record.\n"); | 2300 | "failed to retrieve a FCF record.\n"); |
2148 | goto out; | 2301 | goto error_out; |
2149 | } | 2302 | } |
2150 | 2303 | ||
2151 | /* Get the needed parameters from FCF record */ | 2304 | /* Get the needed parameters from FCF record */ |
2152 | lpfc_match_fcf_conn_list(phba, new_fcf_record, &boot_flag, | 2305 | rc = lpfc_match_fcf_conn_list(phba, new_fcf_record, &boot_flag, |
2153 | &addr_mode, &vlan_id); | 2306 | &addr_mode, &vlan_id); |
2154 | 2307 | ||
2155 | /* Log the FCF record information if turned on */ | 2308 | /* Log the FCF record information if turned on */ |
2156 | lpfc_sli4_log_fcf_record_info(phba, new_fcf_record, vlan_id, | 2309 | lpfc_sli4_log_fcf_record_info(phba, new_fcf_record, vlan_id, |
2157 | next_fcf_index); | 2310 | next_fcf_index); |
2158 | 2311 | ||
2312 | fcf_index = bf_get(lpfc_fcf_record_fcf_index, new_fcf_record); | ||
2313 | if (!rc) { | ||
2314 | lpfc_printf_log(phba, KERN_INFO, LOG_FIP, | ||
2315 | "2848 Remove ineligible FCF (x%x) from " | ||
2316 | "from roundrobin bmask\n", fcf_index); | ||
2317 | /* Clear roundrobin bmask bit for ineligible FCF */ | ||
2318 | lpfc_sli4_fcf_rr_index_clear(phba, fcf_index); | ||
2319 | /* Perform next round of roundrobin FCF failover */ | ||
2320 | fcf_index = lpfc_sli4_fcf_rr_next_index_get(phba); | ||
2321 | rc = lpfc_sli4_fcf_rr_next_proc(phba->pport, fcf_index); | ||
2322 | if (rc) | ||
2323 | goto out; | ||
2324 | goto error_out; | ||
2325 | } | ||
2326 | |||
2327 | if (fcf_index == phba->fcf.current_rec.fcf_indx) { | ||
2328 | lpfc_printf_log(phba, KERN_INFO, LOG_FIP, | ||
2329 | "2760 Perform FLOGI roundrobin FCF failover: " | ||
2330 | "FCF (x%x) back to FCF (x%x)\n", | ||
2331 | phba->fcf.current_rec.fcf_indx, fcf_index); | ||
2332 | /* Wait 500 ms before retrying FLOGI to current FCF */ | ||
2333 | msleep(500); | ||
2334 | lpfc_initial_flogi(phba->pport); | ||
2335 | goto out; | ||
2336 | } | ||
2337 | |||
2159 | /* Upload new FCF record to the failover FCF record */ | 2338 | /* Upload new FCF record to the failover FCF record */ |
2160 | lpfc_printf_log(phba, KERN_INFO, LOG_FIP, | 2339 | lpfc_printf_log(phba, KERN_INFO, LOG_FIP, |
2161 | "2834 Update the current FCF record (x%x) " | 2340 | "2834 Update current FCF (x%x) with new FCF (x%x)\n", |
2162 | "with the next FCF record (x%x)\n", | 2341 | phba->fcf.failover_rec.fcf_indx, fcf_index); |
2163 | phba->fcf.failover_rec.fcf_indx, | ||
2164 | bf_get(lpfc_fcf_record_fcf_index, new_fcf_record)); | ||
2165 | spin_lock_irq(&phba->hbalock); | 2342 | spin_lock_irq(&phba->hbalock); |
2166 | __lpfc_update_fcf_record(phba, &phba->fcf.failover_rec, | 2343 | __lpfc_update_fcf_record(phba, &phba->fcf.failover_rec, |
2167 | new_fcf_record, addr_mode, vlan_id, | 2344 | new_fcf_record, addr_mode, vlan_id, |
@@ -2178,14 +2355,13 @@ lpfc_mbx_cmpl_fcf_rr_read_fcf_rec(struct lpfc_hba *phba, LPFC_MBOXQ_t *mboxq) | |||
2178 | sizeof(struct lpfc_fcf_rec)); | 2355 | sizeof(struct lpfc_fcf_rec)); |
2179 | 2356 | ||
2180 | lpfc_printf_log(phba, KERN_INFO, LOG_FIP, | 2357 | lpfc_printf_log(phba, KERN_INFO, LOG_FIP, |
2181 | "2783 FLOGI round robin FCF failover from FCF " | 2358 | "2783 Perform FLOGI roundrobin FCF failover: FCF " |
2182 | "(x%x) to FCF (x%x).\n", | 2359 | "(x%x) to FCF (x%x)\n", current_fcf_index, fcf_index); |
2183 | current_fcf_index, | ||
2184 | bf_get(lpfc_fcf_record_fcf_index, new_fcf_record)); | ||
2185 | 2360 | ||
2361 | error_out: | ||
2362 | lpfc_register_fcf(phba); | ||
2186 | out: | 2363 | out: |
2187 | lpfc_sli4_mbox_cmd_free(phba, mboxq); | 2364 | lpfc_sli4_mbox_cmd_free(phba, mboxq); |
2188 | lpfc_register_fcf(phba); | ||
2189 | } | 2365 | } |
2190 | 2366 | ||
2191 | /** | 2367 | /** |
@@ -2194,10 +2370,10 @@ out: | |||
2194 | * @mboxq: pointer to mailbox object. | 2370 | * @mboxq: pointer to mailbox object. |
2195 | * | 2371 | * |
2196 | * This is the callback function of read FCF record mailbox command for | 2372 | * This is the callback function of read FCF record mailbox command for |
2197 | * updating the eligible FCF bmask for FLOGI failure round robin FCF | 2373 | * updating the eligible FCF bmask for FLOGI failure roundrobin FCF |
2198 | * failover when a new FCF event happened. If the FCF read back is | 2374 | * failover when a new FCF event happened. If the FCF read back is |
2199 | * valid/available and it passes the connection list check, it updates | 2375 | * valid/available and it passes the connection list check, it updates |
2200 | * the bmask for the eligible FCF record for round robin failover. | 2376 | * the bmask for the eligible FCF record for roundrobin failover. |
2201 | */ | 2377 | */ |
2202 | void | 2378 | void |
2203 | lpfc_mbx_cmpl_read_fcf_rec(struct lpfc_hba *phba, LPFC_MBOXQ_t *mboxq) | 2379 | lpfc_mbx_cmpl_read_fcf_rec(struct lpfc_hba *phba, LPFC_MBOXQ_t *mboxq) |
@@ -2639,7 +2815,7 @@ lpfc_mbx_process_link_up(struct lpfc_hba *phba, READ_LA_VAR *la) | |||
2639 | * and get the FCF Table. | 2815 | * and get the FCF Table. |
2640 | */ | 2816 | */ |
2641 | spin_lock_irq(&phba->hbalock); | 2817 | spin_lock_irq(&phba->hbalock); |
2642 | if (phba->hba_flag & FCF_DISC_INPROGRESS) { | 2818 | if (phba->hba_flag & FCF_TS_INPROG) { |
2643 | spin_unlock_irq(&phba->hbalock); | 2819 | spin_unlock_irq(&phba->hbalock); |
2644 | return; | 2820 | return; |
2645 | } | 2821 | } |
@@ -3906,6 +4082,11 @@ lpfc_unreg_all_rpis(struct lpfc_vport *vport) | |||
3906 | LPFC_MBOXQ_t *mbox; | 4082 | LPFC_MBOXQ_t *mbox; |
3907 | int rc; | 4083 | int rc; |
3908 | 4084 | ||
4085 | if (phba->sli_rev == LPFC_SLI_REV4) { | ||
4086 | lpfc_sli4_unreg_all_rpis(vport); | ||
4087 | return; | ||
4088 | } | ||
4089 | |||
3909 | mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); | 4090 | mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); |
3910 | if (mbox) { | 4091 | if (mbox) { |
3911 | lpfc_unreg_login(phba, vport->vpi, 0xffff, mbox); | 4092 | lpfc_unreg_login(phba, vport->vpi, 0xffff, mbox); |
@@ -3992,6 +4173,16 @@ lpfc_cleanup_node(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp) | |||
3992 | } | 4173 | } |
3993 | 4174 | ||
3994 | spin_lock_irq(&phba->hbalock); | 4175 | spin_lock_irq(&phba->hbalock); |
4176 | /* Cleanup REG_LOGIN completions which are not yet processed */ | ||
4177 | list_for_each_entry(mb, &phba->sli.mboxq_cmpl, list) { | ||
4178 | if ((mb->u.mb.mbxCommand != MBX_REG_LOGIN64) || | ||
4179 | (ndlp != (struct lpfc_nodelist *) mb->context2)) | ||
4180 | continue; | ||
4181 | |||
4182 | mb->context2 = NULL; | ||
4183 | mb->mbox_cmpl = lpfc_sli_def_mbox_cmpl; | ||
4184 | } | ||
4185 | |||
3995 | list_for_each_entry_safe(mb, nextmb, &phba->sli.mboxq, list) { | 4186 | list_for_each_entry_safe(mb, nextmb, &phba->sli.mboxq, list) { |
3996 | if ((mb->u.mb.mbxCommand == MBX_REG_LOGIN64) && | 4187 | if ((mb->u.mb.mbxCommand == MBX_REG_LOGIN64) && |
3997 | (ndlp == (struct lpfc_nodelist *) mb->context2)) { | 4188 | (ndlp == (struct lpfc_nodelist *) mb->context2)) { |
@@ -5170,6 +5361,8 @@ lpfc_unregister_fcf_prep(struct lpfc_hba *phba) | |||
5170 | if (ndlp) | 5361 | if (ndlp) |
5171 | lpfc_cancel_retry_delay_tmo(vports[i], ndlp); | 5362 | lpfc_cancel_retry_delay_tmo(vports[i], ndlp); |
5172 | lpfc_cleanup_pending_mbox(vports[i]); | 5363 | lpfc_cleanup_pending_mbox(vports[i]); |
5364 | if (phba->sli_rev == LPFC_SLI_REV4) | ||
5365 | lpfc_sli4_unreg_all_rpis(vports[i]); | ||
5173 | lpfc_mbx_unreg_vpi(vports[i]); | 5366 | lpfc_mbx_unreg_vpi(vports[i]); |
5174 | shost = lpfc_shost_from_vport(vports[i]); | 5367 | shost = lpfc_shost_from_vport(vports[i]); |
5175 | spin_lock_irq(shost->host_lock); | 5368 | spin_lock_irq(shost->host_lock); |