aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/lpfc/lpfc_hbadisc.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/scsi/lpfc/lpfc_hbadisc.c')
-rw-r--r--drivers/scsi/lpfc/lpfc_hbadisc.c539
1 files changed, 237 insertions, 302 deletions
diff --git a/drivers/scsi/lpfc/lpfc_hbadisc.c b/drivers/scsi/lpfc/lpfc_hbadisc.c
index f2f4639eab59..c81c2b3228d6 100644
--- a/drivers/scsi/lpfc/lpfc_hbadisc.c
+++ b/drivers/scsi/lpfc/lpfc_hbadisc.c
@@ -83,10 +83,17 @@ lpfc_terminate_rport_io(struct fc_rport *rport)
83 ndlp->nlp_sid, ndlp->nlp_DID, ndlp->nlp_flag); 83 ndlp->nlp_sid, ndlp->nlp_DID, ndlp->nlp_flag);
84 84
85 if (ndlp->nlp_sid != NLP_NO_SID) { 85 if (ndlp->nlp_sid != NLP_NO_SID) {
86 lpfc_sli_abort_iocb(phba, &phba->sli.ring[phba->sli.fcp_ring], 86 lpfc_sli_abort_iocb(ndlp->vport,
87 ndlp->nlp_sid, 0, 0, LPFC_CTX_TGT); 87 &phba->sli.ring[phba->sli.fcp_ring],
88 ndlp->nlp_sid, 0, LPFC_CTX_TGT);
88 } 89 }
89 90
91 /*
92 * A device is normally blocked for rediscovery and unblocked when
93 * devloss timeout happens. In case a vport is removed or driver
94 * unloaded before devloss timeout happens, we need to unblock here.
95 */
96 scsi_target_unblock(&rport->dev);
90 return; 97 return;
91} 98}
92 99
@@ -194,32 +201,30 @@ lpfc_dev_loss_tmo_handler(struct lpfc_nodelist *ndlp)
194 if (ndlp->nlp_sid != NLP_NO_SID) { 201 if (ndlp->nlp_sid != NLP_NO_SID) {
195 warn_on = 1; 202 warn_on = 1;
196 /* flush the target */ 203 /* flush the target */
197 lpfc_sli_abort_iocb(phba, &phba->sli.ring[phba->sli.fcp_ring], 204 lpfc_sli_abort_iocb(vport, &phba->sli.ring[phba->sli.fcp_ring],
198 ndlp->nlp_sid, 0, 0, LPFC_CTX_TGT); 205 ndlp->nlp_sid, 0, LPFC_CTX_TGT);
199 } 206 }
200 if (vport->load_flag & FC_UNLOADING) 207 if (vport->load_flag & FC_UNLOADING)
201 warn_on = 0; 208 warn_on = 0;
202 209
203 if (warn_on) { 210 if (warn_on) {
204 lpfc_printf_log(phba, KERN_ERR, LOG_DISCOVERY, 211 lpfc_printf_vlog(vport, KERN_ERR, LOG_DISCOVERY,
205 "%d (%d):0203 Devloss timeout on " 212 "0203 Devloss timeout on "
206 "WWPN %x:%x:%x:%x:%x:%x:%x:%x " 213 "WWPN %x:%x:%x:%x:%x:%x:%x:%x "
207 "NPort x%x Data: x%x x%x x%x\n", 214 "NPort x%x Data: x%x x%x x%x\n",
208 phba->brd_no, vport->vpi, 215 *name, *(name+1), *(name+2), *(name+3),
209 *name, *(name+1), *(name+2), *(name+3), 216 *(name+4), *(name+5), *(name+6), *(name+7),
210 *(name+4), *(name+5), *(name+6), *(name+7), 217 ndlp->nlp_DID, ndlp->nlp_flag,
211 ndlp->nlp_DID, ndlp->nlp_flag, 218 ndlp->nlp_state, ndlp->nlp_rpi);
212 ndlp->nlp_state, ndlp->nlp_rpi);
213 } else { 219 } else {
214 lpfc_printf_log(phba, KERN_INFO, LOG_DISCOVERY, 220 lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY,
215 "%d (%d):0204 Devloss timeout on " 221 "0204 Devloss timeout on "
216 "WWPN %x:%x:%x:%x:%x:%x:%x:%x " 222 "WWPN %x:%x:%x:%x:%x:%x:%x:%x "
217 "NPort x%x Data: x%x x%x x%x\n", 223 "NPort x%x Data: x%x x%x x%x\n",
218 phba->brd_no, vport->vpi, 224 *name, *(name+1), *(name+2), *(name+3),
219 *name, *(name+1), *(name+2), *(name+3), 225 *(name+4), *(name+5), *(name+6), *(name+7),
220 *(name+4), *(name+5), *(name+6), *(name+7), 226 ndlp->nlp_DID, ndlp->nlp_flag,
221 ndlp->nlp_DID, ndlp->nlp_flag, 227 ndlp->nlp_state, ndlp->nlp_rpi);
222 ndlp->nlp_state, ndlp->nlp_rpi);
223 } 228 }
224 229
225 if (!(vport->load_flag & FC_UNLOADING) && 230 if (!(vport->load_flag & FC_UNLOADING) &&
@@ -344,12 +349,14 @@ lpfc_work_list_done(struct lpfc_hba *phba)
344 349
345} 350}
346 351
347void 352static void
348lpfc_work_done(struct lpfc_hba *phba) 353lpfc_work_done(struct lpfc_hba *phba)
349{ 354{
350 struct lpfc_sli_ring *pring; 355 struct lpfc_sli_ring *pring;
351 uint32_t ha_copy, status, control, work_port_events; 356 uint32_t ha_copy, status, control, work_port_events;
357 struct lpfc_vport **vports;
352 struct lpfc_vport *vport; 358 struct lpfc_vport *vport;
359 int i;
353 360
354 spin_lock_irq(&phba->hbalock); 361 spin_lock_irq(&phba->hbalock);
355 ha_copy = phba->work_ha; 362 ha_copy = phba->work_ha;
@@ -364,48 +371,41 @@ lpfc_work_done(struct lpfc_hba *phba)
364 371
365 if (ha_copy & HA_LATT) 372 if (ha_copy & HA_LATT)
366 lpfc_handle_latt(phba); 373 lpfc_handle_latt(phba);
367 374 vports = lpfc_create_vport_work_array(phba);
368 spin_lock_irq(&phba->hbalock); 375 if (vports != NULL)
369 list_for_each_entry(vport, &phba->port_list, listentry) { 376 for(i = 0; i < LPFC_MAX_VPORTS; i++) {
370 struct Scsi_Host *shost = lpfc_shost_from_vport(vport); 377 /*
371 378 * We could have no vports in array if unloading, so if
372 if (!scsi_host_get(shost)) { 379 * this happens then just use the pport
373 continue; 380 */
381 if (vports[i] == NULL && i == 0)
382 vport = phba->pport;
383 else
384 vport = vports[i];
385 if (vport == NULL)
386 break;
387 work_port_events = vport->work_port_events;
388 if (work_port_events & WORKER_DISC_TMO)
389 lpfc_disc_timeout_handler(vport);
390 if (work_port_events & WORKER_ELS_TMO)
391 lpfc_els_timeout_handler(vport);
392 if (work_port_events & WORKER_HB_TMO)
393 lpfc_hb_timeout_handler(phba);
394 if (work_port_events & WORKER_MBOX_TMO)
395 lpfc_mbox_timeout_handler(phba);
396 if (work_port_events & WORKER_FABRIC_BLOCK_TMO)
397 lpfc_unblock_fabric_iocbs(phba);
398 if (work_port_events & WORKER_FDMI_TMO)
399 lpfc_fdmi_timeout_handler(vport);
400 if (work_port_events & WORKER_RAMP_DOWN_QUEUE)
401 lpfc_ramp_down_queue_handler(phba);
402 if (work_port_events & WORKER_RAMP_UP_QUEUE)
403 lpfc_ramp_up_queue_handler(phba);
404 spin_lock_irq(&vport->work_port_lock);
405 vport->work_port_events &= ~work_port_events;
406 spin_unlock_irq(&vport->work_port_lock);
374 } 407 }
375 spin_unlock_irq(&phba->hbalock); 408 lpfc_destroy_vport_work_array(vports);
376 work_port_events = vport->work_port_events;
377
378 if (work_port_events & WORKER_DISC_TMO)
379 lpfc_disc_timeout_handler(vport);
380
381 if (work_port_events & WORKER_ELS_TMO)
382 lpfc_els_timeout_handler(vport);
383
384 if (work_port_events & WORKER_HB_TMO)
385 lpfc_hb_timeout_handler(phba);
386
387 if (work_port_events & WORKER_MBOX_TMO)
388 lpfc_mbox_timeout_handler(phba);
389
390 if (work_port_events & WORKER_FABRIC_BLOCK_TMO)
391 lpfc_unblock_fabric_iocbs(phba);
392
393 if (work_port_events & WORKER_FDMI_TMO)
394 lpfc_fdmi_timeout_handler(vport);
395
396 if (work_port_events & WORKER_RAMP_DOWN_QUEUE)
397 lpfc_ramp_down_queue_handler(phba);
398
399 if (work_port_events & WORKER_RAMP_UP_QUEUE)
400 lpfc_ramp_up_queue_handler(phba);
401
402 spin_lock_irq(&vport->work_port_lock);
403 vport->work_port_events &= ~work_port_events;
404 spin_unlock_irq(&vport->work_port_lock);
405 scsi_host_put(shost);
406 spin_lock_irq(&phba->hbalock);
407 }
408 spin_unlock_irq(&phba->hbalock);
409 409
410 pring = &phba->sli.ring[LPFC_ELS_RING]; 410 pring = &phba->sli.ring[LPFC_ELS_RING];
411 status = (ha_copy & (HA_RXMASK << (4*LPFC_ELS_RING))); 411 status = (ha_copy & (HA_RXMASK << (4*LPFC_ELS_RING)));
@@ -426,10 +426,19 @@ lpfc_work_done(struct lpfc_hba *phba)
426 spin_lock_irq(&phba->hbalock); 426 spin_lock_irq(&phba->hbalock);
427 control = readl(phba->HCregaddr); 427 control = readl(phba->HCregaddr);
428 if (!(control & (HC_R0INT_ENA << LPFC_ELS_RING))) { 428 if (!(control & (HC_R0INT_ENA << LPFC_ELS_RING))) {
429 lpfc_debugfs_slow_ring_trc(phba,
430 "WRK Enable ring: cntl:x%x hacopy:x%x",
431 control, ha_copy, 0);
432
429 control |= (HC_R0INT_ENA << LPFC_ELS_RING); 433 control |= (HC_R0INT_ENA << LPFC_ELS_RING);
430 writel(control, phba->HCregaddr); 434 writel(control, phba->HCregaddr);
431 readl(phba->HCregaddr); /* flush */ 435 readl(phba->HCregaddr); /* flush */
432 } 436 }
437 else {
438 lpfc_debugfs_slow_ring_trc(phba,
439 "WRK Ring ok: cntl:x%x hacopy:x%x",
440 control, ha_copy, 0);
441 }
433 spin_unlock_irq(&phba->hbalock); 442 spin_unlock_irq(&phba->hbalock);
434 } 443 }
435 lpfc_work_list_done(phba); 444 lpfc_work_list_done(phba);
@@ -439,32 +448,22 @@ static int
439check_work_wait_done(struct lpfc_hba *phba) 448check_work_wait_done(struct lpfc_hba *phba)
440{ 449{
441 struct lpfc_vport *vport; 450 struct lpfc_vport *vport;
442 struct lpfc_sli_ring *pring; 451 struct lpfc_sli_ring *pring = &phba->sli.ring[LPFC_ELS_RING];
443 int rc = 0; 452 int rc = 0;
444 453
445 spin_lock_irq(&phba->hbalock); 454 spin_lock_irq(&phba->hbalock);
446 list_for_each_entry(vport, &phba->port_list, listentry) { 455 list_for_each_entry(vport, &phba->port_list, listentry) {
447 if (vport->work_port_events) { 456 if (vport->work_port_events) {
448 rc = 1; 457 rc = 1;
449 goto exit; 458 break;
450 } 459 }
451 } 460 }
452 461 if (rc || phba->work_ha || (!list_empty(&phba->work_list)) ||
453 if (phba->work_ha || (!list_empty(&phba->work_list)) || 462 kthread_should_stop() || pring->flag & LPFC_DEFERRED_RING_EVENT) {
454 kthread_should_stop()) {
455 rc = 1;
456 goto exit;
457 }
458
459 pring = &phba->sli.ring[LPFC_ELS_RING];
460 if (pring->flag & LPFC_DEFERRED_RING_EVENT)
461 rc = 1; 463 rc = 1;
462exit:
463 if (rc)
464 phba->work_found++; 464 phba->work_found++;
465 else 465 } else
466 phba->work_found = 0; 466 phba->work_found = 0;
467
468 spin_unlock_irq(&phba->hbalock); 467 spin_unlock_irq(&phba->hbalock);
469 return rc; 468 return rc;
470} 469}
@@ -592,7 +591,6 @@ lpfc_linkdown_port(struct lpfc_vport *vport)
592 591
593 /* free any ndlp's on unused list */ 592 /* free any ndlp's on unused list */
594 list_for_each_entry_safe(ndlp, next_ndlp, &vport->fc_nodes, nlp_listp) 593 list_for_each_entry_safe(ndlp, next_ndlp, &vport->fc_nodes, nlp_listp)
595 /* free any ndlp's in unused state */
596 if (ndlp->nlp_state == NLP_STE_UNUSED_NODE) 594 if (ndlp->nlp_state == NLP_STE_UNUSED_NODE)
597 lpfc_drop_node(vport, ndlp); 595 lpfc_drop_node(vport, ndlp);
598 596
@@ -605,8 +603,9 @@ lpfc_linkdown(struct lpfc_hba *phba)
605{ 603{
606 struct lpfc_vport *vport = phba->pport; 604 struct lpfc_vport *vport = phba->pport;
607 struct Scsi_Host *shost = lpfc_shost_from_vport(vport); 605 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
608 struct lpfc_vport *port_iterator; 606 struct lpfc_vport **vports;
609 LPFC_MBOXQ_t *mb; 607 LPFC_MBOXQ_t *mb;
608 int i;
610 609
611 if (phba->link_state == LPFC_LINK_DOWN) { 610 if (phba->link_state == LPFC_LINK_DOWN) {
612 return 0; 611 return 0;
@@ -617,13 +616,13 @@ lpfc_linkdown(struct lpfc_hba *phba)
617 phba->pport->fc_flag &= ~FC_LBIT; 616 phba->pport->fc_flag &= ~FC_LBIT;
618 } 617 }
619 spin_unlock_irq(&phba->hbalock); 618 spin_unlock_irq(&phba->hbalock);
620 619 vports = lpfc_create_vport_work_array(phba);
621 list_for_each_entry(port_iterator, &phba->port_list, listentry) { 620 if (vports != NULL)
622 621 for(i = 0; i < LPFC_MAX_VPORTS && vports[i] != NULL; i++) {
623 /* Issue a LINK DOWN event to all nodes */ 622 /* Issue a LINK DOWN event to all nodes */
624 lpfc_linkdown_port(port_iterator); 623 lpfc_linkdown_port(vports[i]);
625 } 624 }
626 625 lpfc_destroy_vport_work_array(vports);
627 /* Clean up any firmware default rpi's */ 626 /* Clean up any firmware default rpi's */
628 mb = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); 627 mb = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL);
629 if (mb) { 628 if (mb) {
@@ -724,7 +723,8 @@ lpfc_linkup_port(struct lpfc_vport *vport)
724static int 723static int
725lpfc_linkup(struct lpfc_hba *phba) 724lpfc_linkup(struct lpfc_hba *phba)
726{ 725{
727 struct lpfc_vport *vport; 726 struct lpfc_vport **vports;
727 int i;
728 728
729 phba->link_state = LPFC_LINK_UP; 729 phba->link_state = LPFC_LINK_UP;
730 730
@@ -732,9 +732,11 @@ lpfc_linkup(struct lpfc_hba *phba)
732 clear_bit(FABRIC_COMANDS_BLOCKED, &phba->bit_flags); 732 clear_bit(FABRIC_COMANDS_BLOCKED, &phba->bit_flags);
733 del_timer_sync(&phba->fabric_block_timer); 733 del_timer_sync(&phba->fabric_block_timer);
734 734
735 list_for_each_entry(vport, &phba->port_list, listentry) { 735 vports = lpfc_create_vport_work_array(phba);
736 lpfc_linkup_port(vport); 736 if (vports != NULL)
737 } 737 for(i = 0; i < LPFC_MAX_VPORTS && vports[i] != NULL; i++)
738 lpfc_linkup_port(vports[i]);
739 lpfc_destroy_vport_work_array(vports);
738 if (phba->sli3_options & LPFC_SLI3_NPIV_ENABLED) 740 if (phba->sli3_options & LPFC_SLI3_NPIV_ENABLED)
739 lpfc_issue_clear_la(phba, phba->pport); 741 lpfc_issue_clear_la(phba, phba->pport);
740 742
@@ -764,12 +766,10 @@ lpfc_mbx_cmpl_clear_la(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb)
764 /* Check for error */ 766 /* Check for error */
765 if ((mb->mbxStatus) && (mb->mbxStatus != 0x1601)) { 767 if ((mb->mbxStatus) && (mb->mbxStatus != 0x1601)) {
766 /* CLEAR_LA mbox error <mbxStatus> state <hba_state> */ 768 /* CLEAR_LA mbox error <mbxStatus> state <hba_state> */
767 lpfc_printf_log(phba, KERN_ERR, LOG_MBOX, 769 lpfc_printf_vlog(vport, KERN_ERR, LOG_MBOX,
768 "%d (%d):0320 CLEAR_LA mbxStatus error x%x hba " 770 "0320 CLEAR_LA mbxStatus error x%x hba "
769 "state x%x\n", 771 "state x%x\n",
770 phba->brd_no, vport->vpi, mb->mbxStatus, 772 mb->mbxStatus, vport->port_state);
771 vport->port_state);
772
773 phba->link_state = LPFC_HBA_ERROR; 773 phba->link_state = LPFC_HBA_ERROR;
774 goto out; 774 goto out;
775 } 775 }
@@ -801,10 +801,8 @@ lpfc_mbx_cmpl_clear_la(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb)
801 801
802out: 802out:
803 /* Device Discovery completes */ 803 /* Device Discovery completes */
804 lpfc_printf_log(phba, KERN_INFO, LOG_DISCOVERY, 804 lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY,
805 "%d (%d):0225 Device Discovery completes\n", 805 "0225 Device Discovery completes\n");
806 phba->brd_no, vport->vpi);
807
808 mempool_free(pmb, phba->mbox_mem_pool); 806 mempool_free(pmb, phba->mbox_mem_pool);
809 807
810 spin_lock_irq(shost->host_lock); 808 spin_lock_irq(shost->host_lock);
@@ -861,19 +859,17 @@ lpfc_mbx_cmpl_local_config_link(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb)
861 return; 859 return;
862 860
863out: 861out:
864 lpfc_printf_log(phba, KERN_ERR, LOG_MBOX, 862 lpfc_printf_vlog(vport, KERN_ERR, LOG_MBOX,
865 "%d (%d):0306 CONFIG_LINK mbxStatus error x%x " 863 "0306 CONFIG_LINK mbxStatus error x%x "
866 "HBA state x%x\n", 864 "HBA state x%x\n",
867 phba->brd_no, vport->vpi, pmb->mb.mbxStatus, 865 pmb->mb.mbxStatus, vport->port_state);
868 vport->port_state);
869
870 mempool_free(pmb, phba->mbox_mem_pool); 866 mempool_free(pmb, phba->mbox_mem_pool);
871 867
872 lpfc_linkdown(phba); 868 lpfc_linkdown(phba);
873 869
874 lpfc_printf_log(phba, KERN_ERR, LOG_DISCOVERY, 870 lpfc_printf_vlog(vport, KERN_ERR, LOG_DISCOVERY,
875 "%d (%d):0200 CONFIG_LINK bad hba state x%x\n", 871 "0200 CONFIG_LINK bad hba state x%x\n",
876 phba->brd_no, vport->vpi, vport->port_state); 872 vport->port_state);
877 873
878 lpfc_issue_clear_la(phba, vport); 874 lpfc_issue_clear_la(phba, vport);
879 return; 875 return;
@@ -890,12 +886,10 @@ lpfc_mbx_cmpl_read_sparam(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb)
890 /* Check for error */ 886 /* Check for error */
891 if (mb->mbxStatus) { 887 if (mb->mbxStatus) {
892 /* READ_SPARAM mbox error <mbxStatus> state <hba_state> */ 888 /* READ_SPARAM mbox error <mbxStatus> state <hba_state> */
893 lpfc_printf_log(phba, KERN_ERR, LOG_MBOX, 889 lpfc_printf_vlog(vport, KERN_ERR, LOG_MBOX,
894 "%d (%d):0319 READ_SPARAM mbxStatus error x%x " 890 "0319 READ_SPARAM mbxStatus error x%x "
895 "hba state x%x>\n", 891 "hba state x%x>\n",
896 phba->brd_no, vport->vpi, mb->mbxStatus, 892 mb->mbxStatus, vport->port_state);
897 vport->port_state);
898
899 lpfc_linkdown(phba); 893 lpfc_linkdown(phba);
900 goto out; 894 goto out;
901 } 895 }
@@ -978,7 +972,7 @@ lpfc_mbx_process_link_up(struct lpfc_hba *phba, READ_LA_VAR *la)
978 if (i == 0) { 972 if (i == 0) {
979 phba->alpa_map[0] = 0; 973 phba->alpa_map[0] = 0;
980 } else { 974 } else {
981 if (phba->cfg_log_verbose & LOG_LINK_EVENT) { 975 if (vport->cfg_log_verbose & LOG_LINK_EVENT) {
982 int numalpa, j, k; 976 int numalpa, j, k;
983 union { 977 union {
984 uint8_t pamap[16]; 978 uint8_t pamap[16];
@@ -1004,10 +998,9 @@ lpfc_mbx_process_link_up(struct lpfc_hba *phba, READ_LA_VAR *la)
1004 lpfc_printf_log(phba, 998 lpfc_printf_log(phba,
1005 KERN_WARNING, 999 KERN_WARNING,
1006 LOG_LINK_EVENT, 1000 LOG_LINK_EVENT,
1007 "%d:1304 Link Up Event " 1001 "1304 Link Up Event "
1008 "ALPA map Data: x%x " 1002 "ALPA map Data: x%x "
1009 "x%x x%x x%x\n", 1003 "x%x x%x x%x\n",
1010 phba->brd_no,
1011 un.pa.wd1, un.pa.wd2, 1004 un.pa.wd1, un.pa.wd2,
1012 un.pa.wd3, un.pa.wd4); 1005 un.pa.wd3, un.pa.wd4);
1013 } 1006 }
@@ -1015,7 +1008,7 @@ lpfc_mbx_process_link_up(struct lpfc_hba *phba, READ_LA_VAR *la)
1015 } 1008 }
1016 } else { 1009 } else {
1017 if (!(phba->sli3_options & LPFC_SLI3_NPIV_ENABLED)) { 1010 if (!(phba->sli3_options & LPFC_SLI3_NPIV_ENABLED)) {
1018 if (phba->max_vpi && phba->cfg_npiv_enable && 1011 if (phba->max_vpi && phba->cfg_enable_npiv &&
1019 (phba->sli_rev == 3)) 1012 (phba->sli_rev == 3))
1020 phba->sli3_options |= LPFC_SLI3_NPIV_ENABLED; 1013 phba->sli3_options |= LPFC_SLI3_NPIV_ENABLED;
1021 } 1014 }
@@ -1055,11 +1048,9 @@ lpfc_mbx_process_link_up(struct lpfc_hba *phba, READ_LA_VAR *la)
1055 } 1048 }
1056out: 1049out:
1057 lpfc_vport_set_state(vport, FC_VPORT_FAILED); 1050 lpfc_vport_set_state(vport, FC_VPORT_FAILED);
1058 lpfc_printf_log(phba, KERN_ERR, LOG_MBOX, 1051 lpfc_printf_vlog(vport, KERN_ERR, LOG_MBOX,
1059 "%d (%d):0263 Discovery Mailbox error: state: 0x%x : %p %p\n", 1052 "0263 Discovery Mailbox error: state: 0x%x : %p %p\n",
1060 phba->brd_no, vport->vpi, 1053 vport->port_state, sparam_mbox, cfglink_mbox);
1061 vport->port_state, sparam_mbox, cfglink_mbox);
1062
1063 lpfc_issue_clear_la(phba, vport); 1054 lpfc_issue_clear_la(phba, vport);
1064 return; 1055 return;
1065} 1056}
@@ -1100,8 +1091,8 @@ lpfc_mbx_cmpl_read_la(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb)
1100 /* Check for error */ 1091 /* Check for error */
1101 if (mb->mbxStatus) { 1092 if (mb->mbxStatus) {
1102 lpfc_printf_log(phba, KERN_INFO, LOG_LINK_EVENT, 1093 lpfc_printf_log(phba, KERN_INFO, LOG_LINK_EVENT,
1103 "%d:1307 READ_LA mbox error x%x state x%x\n", 1094 "1307 READ_LA mbox error x%x state x%x\n",
1104 phba->brd_no, mb->mbxStatus, vport->port_state); 1095 mb->mbxStatus, vport->port_state);
1105 lpfc_mbx_issue_link_down(phba); 1096 lpfc_mbx_issue_link_down(phba);
1106 phba->link_state = LPFC_HBA_ERROR; 1097 phba->link_state = LPFC_HBA_ERROR;
1107 goto lpfc_mbx_cmpl_read_la_free_mbuf; 1098 goto lpfc_mbx_cmpl_read_la_free_mbuf;
@@ -1132,26 +1123,26 @@ lpfc_mbx_cmpl_read_la(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb)
1132 phba->fc_stat.LinkUp++; 1123 phba->fc_stat.LinkUp++;
1133 if (phba->link_flag & LS_LOOPBACK_MODE) { 1124 if (phba->link_flag & LS_LOOPBACK_MODE) {
1134 lpfc_printf_log(phba, KERN_INFO, LOG_LINK_EVENT, 1125 lpfc_printf_log(phba, KERN_INFO, LOG_LINK_EVENT,
1135 "%d:1306 Link Up Event in loop back mode " 1126 "1306 Link Up Event in loop back mode "
1136 "x%x received Data: x%x x%x x%x x%x\n", 1127 "x%x received Data: x%x x%x x%x x%x\n",
1137 phba->brd_no, la->eventTag, phba->fc_eventTag, 1128 la->eventTag, phba->fc_eventTag,
1138 la->granted_AL_PA, la->UlnkSpeed, 1129 la->granted_AL_PA, la->UlnkSpeed,
1139 phba->alpa_map[0]); 1130 phba->alpa_map[0]);
1140 } else { 1131 } else {
1141 lpfc_printf_log(phba, KERN_ERR, LOG_LINK_EVENT, 1132 lpfc_printf_log(phba, KERN_ERR, LOG_LINK_EVENT,
1142 "%d:1303 Link Up Event x%x received " 1133 "1303 Link Up Event x%x received "
1143 "Data: x%x x%x x%x x%x\n", 1134 "Data: x%x x%x x%x x%x\n",
1144 phba->brd_no, la->eventTag, phba->fc_eventTag, 1135 la->eventTag, phba->fc_eventTag,
1145 la->granted_AL_PA, la->UlnkSpeed, 1136 la->granted_AL_PA, la->UlnkSpeed,
1146 phba->alpa_map[0]); 1137 phba->alpa_map[0]);
1147 } 1138 }
1148 lpfc_mbx_process_link_up(phba, la); 1139 lpfc_mbx_process_link_up(phba, la);
1149 } else { 1140 } else {
1150 phba->fc_stat.LinkDown++; 1141 phba->fc_stat.LinkDown++;
1151 lpfc_printf_log(phba, KERN_ERR, LOG_LINK_EVENT, 1142 lpfc_printf_log(phba, KERN_ERR, LOG_LINK_EVENT,
1152 "%d:1305 Link Down Event x%x received " 1143 "1305 Link Down Event x%x received "
1153 "Data: x%x x%x x%x\n", 1144 "Data: x%x x%x x%x\n",
1154 phba->brd_no, la->eventTag, phba->fc_eventTag, 1145 la->eventTag, phba->fc_eventTag,
1155 phba->pport->port_state, vport->fc_flag); 1146 phba->pport->port_state, vport->fc_flag);
1156 lpfc_mbx_issue_link_down(phba); 1147 lpfc_mbx_issue_link_down(phba);
1157 } 1148 }
@@ -1199,10 +1190,9 @@ lpfc_mbx_cmpl_unreg_vpi(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb)
1199 case 0x0011: 1190 case 0x0011:
1200 case 0x0020: 1191 case 0x0020:
1201 case 0x9700: 1192 case 0x9700:
1202 lpfc_printf_log(phba, KERN_INFO, LOG_NODE, 1193 lpfc_printf_vlog(vport, KERN_INFO, LOG_NODE,
1203 "%d (%d):0911 cmpl_unreg_vpi, " 1194 "0911 cmpl_unreg_vpi, mb status = 0x%x\n",
1204 "mb status = 0x%x\n", 1195 mb->mbxStatus);
1205 phba->brd_no, vport->vpi, mb->mbxStatus);
1206 break; 1196 break;
1207 } 1197 }
1208 vport->unreg_vpi_cmpl = VPORT_OK; 1198 vport->unreg_vpi_cmpl = VPORT_OK;
@@ -1231,9 +1221,8 @@ lpfc_mbx_unreg_vpi(struct lpfc_vport *vport)
1231 mbox->mbox_cmpl = lpfc_mbx_cmpl_unreg_vpi; 1221 mbox->mbox_cmpl = lpfc_mbx_cmpl_unreg_vpi;
1232 rc = lpfc_sli_issue_mbox(phba, mbox, (MBX_NOWAIT | MBX_STOP_IOCB)); 1222 rc = lpfc_sli_issue_mbox(phba, mbox, (MBX_NOWAIT | MBX_STOP_IOCB));
1233 if (rc == MBX_NOT_FINISHED) { 1223 if (rc == MBX_NOT_FINISHED) {
1234 lpfc_printf_log(phba, KERN_ERR, LOG_MBOX | LOG_VPORT, 1224 lpfc_printf_vlog(vport, KERN_ERR, LOG_MBOX | LOG_VPORT,
1235 "%d (%d):1800 Could not issue unreg_vpi\n", 1225 "1800 Could not issue unreg_vpi\n");
1236 phba->brd_no, vport->vpi);
1237 mempool_free(mbox, phba->mbox_mem_pool); 1226 mempool_free(mbox, phba->mbox_mem_pool);
1238 vport->unreg_vpi_cmpl = VPORT_ERROR; 1227 vport->unreg_vpi_cmpl = VPORT_ERROR;
1239 } 1228 }
@@ -1250,9 +1239,9 @@ lpfc_mbx_cmpl_reg_vpi(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb)
1250 case 0x0011: 1239 case 0x0011:
1251 case 0x9601: 1240 case 0x9601:
1252 case 0x9602: 1241 case 0x9602:
1253 lpfc_printf_log(phba, KERN_INFO, LOG_NODE, 1242 lpfc_printf_vlog(vport, KERN_INFO, LOG_NODE,
1254 "%d (%d):0912 cmpl_reg_vpi, mb status = 0x%x\n", 1243 "0912 cmpl_reg_vpi, mb status = 0x%x\n",
1255 phba->brd_no, vport->vpi, mb->mbxStatus); 1244 mb->mbxStatus);
1256 lpfc_vport_set_state(vport, FC_VPORT_FAILED); 1245 lpfc_vport_set_state(vport, FC_VPORT_FAILED);
1257 spin_lock_irq(shost->host_lock); 1246 spin_lock_irq(shost->host_lock);
1258 vport->fc_flag &= ~(FC_FABRIC | FC_PUBLIC_LOOP); 1247 vport->fc_flag &= ~(FC_FABRIC | FC_PUBLIC_LOOP);
@@ -1289,15 +1278,15 @@ void
1289lpfc_mbx_cmpl_fabric_reg_login(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb) 1278lpfc_mbx_cmpl_fabric_reg_login(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb)
1290{ 1279{
1291 struct lpfc_vport *vport = pmb->vport; 1280 struct lpfc_vport *vport = pmb->vport;
1292 struct lpfc_vport *next_vport;
1293 MAILBOX_t *mb = &pmb->mb; 1281 MAILBOX_t *mb = &pmb->mb;
1294 struct lpfc_dmabuf *mp = (struct lpfc_dmabuf *) (pmb->context1); 1282 struct lpfc_dmabuf *mp = (struct lpfc_dmabuf *) (pmb->context1);
1295 struct lpfc_nodelist *ndlp; 1283 struct lpfc_nodelist *ndlp;
1296 ndlp = (struct lpfc_nodelist *) pmb->context2; 1284 struct lpfc_vport **vports;
1285 int i;
1297 1286
1287 ndlp = (struct lpfc_nodelist *) pmb->context2;
1298 pmb->context1 = NULL; 1288 pmb->context1 = NULL;
1299 pmb->context2 = NULL; 1289 pmb->context2 = NULL;
1300
1301 if (mb->mbxStatus) { 1290 if (mb->mbxStatus) {
1302 lpfc_mbuf_free(phba, mp->virt, mp->phys); 1291 lpfc_mbuf_free(phba, mp->virt, mp->phys);
1303 kfree(mp); 1292 kfree(mp);
@@ -1314,10 +1303,9 @@ lpfc_mbx_cmpl_fabric_reg_login(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb)
1314 } 1303 }
1315 1304
1316 lpfc_vport_set_state(vport, FC_VPORT_FAILED); 1305 lpfc_vport_set_state(vport, FC_VPORT_FAILED);
1317 lpfc_printf_log(phba, KERN_ERR, LOG_MBOX, 1306 lpfc_printf_vlog(vport, KERN_ERR, LOG_MBOX,
1318 "%d (%d):0258 Register Fabric login error: 0x%x\n", 1307 "0258 Register Fabric login error: 0x%x\n",
1319 phba->brd_no, vport->vpi, mb->mbxStatus); 1308 mb->mbxStatus);
1320
1321 return; 1309 return;
1322 } 1310 }
1323 1311
@@ -1328,21 +1316,26 @@ lpfc_mbx_cmpl_fabric_reg_login(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb)
1328 lpfc_nlp_put(ndlp); /* Drop the reference from the mbox */ 1316 lpfc_nlp_put(ndlp); /* Drop the reference from the mbox */
1329 1317
1330 if (vport->port_state == LPFC_FABRIC_CFG_LINK) { 1318 if (vport->port_state == LPFC_FABRIC_CFG_LINK) {
1331 list_for_each_entry(next_vport, &phba->port_list, listentry) { 1319 vports = lpfc_create_vport_work_array(phba);
1332 if (next_vport->port_type == LPFC_PHYSICAL_PORT) 1320 if (vports != NULL)
1333 continue; 1321 for(i = 0;
1334 1322 i < LPFC_MAX_VPORTS && vports[i] != NULL;
1335 if (phba->link_flag & LS_NPIV_FAB_SUPPORTED) 1323 i++) {
1336 lpfc_initial_fdisc(next_vport); 1324 if (vports[i]->port_type == LPFC_PHYSICAL_PORT)
1337 else if (phba->sli3_options & LPFC_SLI3_NPIV_ENABLED) { 1325 continue;
1338 lpfc_vport_set_state(vport, 1326 if (phba->link_flag & LS_NPIV_FAB_SUPPORTED)
1339 FC_VPORT_NO_FABRIC_SUPP); 1327 lpfc_initial_fdisc(vports[i]);
1340 lpfc_printf_log(phba, KERN_ERR, LOG_ELS, 1328 else if (phba->sli3_options &
1341 "%d (%d):0259 No NPIV Fabric " 1329 LPFC_SLI3_NPIV_ENABLED) {
1342 "support\n", 1330 lpfc_vport_set_state(vports[i],
1343 phba->brd_no, vport->vpi); 1331 FC_VPORT_NO_FABRIC_SUPP);
1332 lpfc_printf_vlog(vport, KERN_ERR,
1333 LOG_ELS,
1334 "0259 No NPIV "
1335 "Fabric support\n");
1336 }
1344 } 1337 }
1345 } 1338 lpfc_destroy_vport_work_array(vports);
1346 lpfc_do_scr_ns_plogi(phba, vport); 1339 lpfc_do_scr_ns_plogi(phba, vport);
1347 } 1340 }
1348 1341
@@ -1386,9 +1379,9 @@ out:
1386 return; 1379 return;
1387 } 1380 }
1388 lpfc_vport_set_state(vport, FC_VPORT_FAILED); 1381 lpfc_vport_set_state(vport, FC_VPORT_FAILED);
1389 lpfc_printf_log(phba, KERN_ERR, LOG_ELS, 1382 lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS,
1390 "%d (%d):0260 Register NameServer error: 0x%x\n", 1383 "0260 Register NameServer error: 0x%x\n",
1391 phba->brd_no, vport->vpi, mb->mbxStatus); 1384 mb->mbxStatus);
1392 return; 1385 return;
1393 } 1386 }
1394 1387
@@ -1598,7 +1591,7 @@ lpfc_nlp_state_name(char *buffer, size_t size, int state)
1598 [NLP_STE_NPR_NODE] = "NPR", 1591 [NLP_STE_NPR_NODE] = "NPR",
1599 }; 1592 };
1600 1593
1601 if (state < ARRAY_SIZE(states) && states[state]) 1594 if (state < NLP_STE_MAX_STATE && states[state])
1602 strlcpy(buffer, states[state], size); 1595 strlcpy(buffer, states[state], size);
1603 else 1596 else
1604 snprintf(buffer, size, "unknown (%d)", state); 1597 snprintf(buffer, size, "unknown (%d)", state);
@@ -1613,12 +1606,11 @@ lpfc_nlp_set_state(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
1613 int old_state = ndlp->nlp_state; 1606 int old_state = ndlp->nlp_state;
1614 char name1[16], name2[16]; 1607 char name1[16], name2[16];
1615 1608
1616 lpfc_printf_log(vport->phba, KERN_INFO, LOG_NODE, 1609 lpfc_printf_vlog(vport, KERN_INFO, LOG_NODE,
1617 "%d (%d):0904 NPort state transition x%06x, %s -> %s\n", 1610 "0904 NPort state transition x%06x, %s -> %s\n",
1618 vport->phba->brd_no, vport->vpi, 1611 ndlp->nlp_DID,
1619 ndlp->nlp_DID, 1612 lpfc_nlp_state_name(name1, sizeof(name1), old_state),
1620 lpfc_nlp_state_name(name1, sizeof(name1), old_state), 1613 lpfc_nlp_state_name(name2, sizeof(name2), state));
1621 lpfc_nlp_state_name(name2, sizeof(name2), state));
1622 1614
1623 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_NODE, 1615 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_NODE,
1624 "node statechg did:x%x old:%d ste:%d", 1616 "node statechg did:x%x old:%d ste:%d",
@@ -1664,16 +1656,7 @@ lpfc_dequeue_node(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp)
1664void 1656void
1665lpfc_drop_node(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp) 1657lpfc_drop_node(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp)
1666{ 1658{
1667 struct Scsi_Host *shost = lpfc_shost_from_vport(vport); 1659 lpfc_nlp_set_state(vport, ndlp, NLP_STE_UNUSED_NODE);
1668
1669 if ((ndlp->nlp_flag & NLP_DELAY_TMO) != 0)
1670 lpfc_cancel_retry_delay_tmo(vport, ndlp);
1671 if (ndlp->nlp_state && !list_empty(&ndlp->nlp_listp))
1672 lpfc_nlp_counters(vport, ndlp->nlp_state, -1);
1673 spin_lock_irq(shost->host_lock);
1674 list_del_init(&ndlp->nlp_listp);
1675 ndlp->nlp_flag &= ~NLP_TARGET_REMOVE;
1676 spin_unlock_irq(shost->host_lock);
1677 lpfc_nlp_put(ndlp); 1660 lpfc_nlp_put(ndlp);
1678} 1661}
1679 1662
@@ -1710,12 +1693,12 @@ lpfc_set_disctmo(struct lpfc_vport *vport)
1710 spin_unlock_irq(shost->host_lock); 1693 spin_unlock_irq(shost->host_lock);
1711 1694
1712 /* Start Discovery Timer state <hba_state> */ 1695 /* Start Discovery Timer state <hba_state> */
1713 lpfc_printf_log(phba, KERN_INFO, LOG_DISCOVERY, 1696 lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY,
1714 "%d (%d):0247 Start Discovery Timer state x%x " 1697 "0247 Start Discovery Timer state x%x "
1715 "Data: x%x x%lx x%x x%x\n", 1698 "Data: x%x x%lx x%x x%x\n",
1716 phba->brd_no, vport->vpi, vport->port_state, tmo, 1699 vport->port_state, tmo,
1717 (unsigned long)&vport->fc_disctmo, vport->fc_plogi_cnt, 1700 (unsigned long)&vport->fc_disctmo, vport->fc_plogi_cnt,
1718 vport->fc_adisc_cnt); 1701 vport->fc_adisc_cnt);
1719 1702
1720 return; 1703 return;
1721} 1704}
@@ -1727,7 +1710,6 @@ int
1727lpfc_can_disctmo(struct lpfc_vport *vport) 1710lpfc_can_disctmo(struct lpfc_vport *vport)
1728{ 1711{
1729 struct Scsi_Host *shost = lpfc_shost_from_vport(vport); 1712 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
1730 struct lpfc_hba *phba = vport->phba;
1731 unsigned long iflags; 1713 unsigned long iflags;
1732 1714
1733 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD, 1715 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD,
@@ -1746,13 +1728,11 @@ lpfc_can_disctmo(struct lpfc_vport *vport)
1746 } 1728 }
1747 1729
1748 /* Cancel Discovery Timer state <hba_state> */ 1730 /* Cancel Discovery Timer state <hba_state> */
1749 lpfc_printf_log(phba, KERN_INFO, LOG_DISCOVERY, 1731 lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY,
1750 "%d (%d):0248 Cancel Discovery Timer state x%x " 1732 "0248 Cancel Discovery Timer state x%x "
1751 "Data: x%x x%x x%x\n", 1733 "Data: x%x x%x x%x\n",
1752 phba->brd_no, vport->vpi, vport->port_state, 1734 vport->port_state, vport->fc_flag,
1753 vport->fc_flag, vport->fc_plogi_cnt, 1735 vport->fc_plogi_cnt, vport->fc_adisc_cnt);
1754 vport->fc_adisc_cnt);
1755
1756 return 0; 1736 return 0;
1757} 1737}
1758 1738
@@ -1935,10 +1915,9 @@ lpfc_unreg_default_rpis(struct lpfc_vport *vport)
1935 rc = lpfc_sli_issue_mbox(phba, mbox, 1915 rc = lpfc_sli_issue_mbox(phba, mbox,
1936 (MBX_NOWAIT | MBX_STOP_IOCB)); 1916 (MBX_NOWAIT | MBX_STOP_IOCB));
1937 if (rc == MBX_NOT_FINISHED) { 1917 if (rc == MBX_NOT_FINISHED) {
1938 lpfc_printf_log(phba, KERN_ERR, LOG_MBOX | LOG_VPORT, 1918 lpfc_printf_vlog(vport, KERN_ERR, LOG_MBOX | LOG_VPORT,
1939 "%d (%d):1815 Could not issue " 1919 "1815 Could not issue "
1940 "unreg_did (default rpis)\n", 1920 "unreg_did (default rpis)\n");
1941 phba->brd_no, vport->vpi);
1942 mempool_free(mbox, phba->mbox_mem_pool); 1921 mempool_free(mbox, phba->mbox_mem_pool);
1943 } 1922 }
1944 } 1923 }
@@ -1957,12 +1936,11 @@ lpfc_cleanup_node(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp)
1957 struct lpfc_dmabuf *mp; 1936 struct lpfc_dmabuf *mp;
1958 1937
1959 /* Cleanup node for NPort <nlp_DID> */ 1938 /* Cleanup node for NPort <nlp_DID> */
1960 lpfc_printf_log(phba, KERN_INFO, LOG_NODE, 1939 lpfc_printf_vlog(vport, KERN_INFO, LOG_NODE,
1961 "%d (%d):0900 Cleanup node for NPort x%x " 1940 "0900 Cleanup node for NPort x%x "
1962 "Data: x%x x%x x%x\n", 1941 "Data: x%x x%x x%x\n",
1963 phba->brd_no, vport->vpi, ndlp->nlp_DID, ndlp->nlp_flag, 1942 ndlp->nlp_DID, ndlp->nlp_flag,
1964 ndlp->nlp_state, ndlp->nlp_rpi); 1943 ndlp->nlp_state, ndlp->nlp_rpi);
1965
1966 lpfc_dequeue_node(vport, ndlp); 1944 lpfc_dequeue_node(vport, ndlp);
1967 1945
1968 /* cleanup any ndlp on mbox q waiting for reglogin cmpl */ 1946 /* cleanup any ndlp on mbox q waiting for reglogin cmpl */
@@ -2094,7 +2072,6 @@ lpfc_matchdid(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
2094static struct lpfc_nodelist * 2072static struct lpfc_nodelist *
2095__lpfc_findnode_did(struct lpfc_vport *vport, uint32_t did) 2073__lpfc_findnode_did(struct lpfc_vport *vport, uint32_t did)
2096{ 2074{
2097 struct lpfc_hba *phba = vport->phba;
2098 struct lpfc_nodelist *ndlp; 2075 struct lpfc_nodelist *ndlp;
2099 uint32_t data1; 2076 uint32_t data1;
2100 2077
@@ -2104,20 +2081,18 @@ __lpfc_findnode_did(struct lpfc_vport *vport, uint32_t did)
2104 ((uint32_t) ndlp->nlp_xri << 16) | 2081 ((uint32_t) ndlp->nlp_xri << 16) |
2105 ((uint32_t) ndlp->nlp_type << 8) | 2082 ((uint32_t) ndlp->nlp_type << 8) |
2106 ((uint32_t) ndlp->nlp_rpi & 0xff)); 2083 ((uint32_t) ndlp->nlp_rpi & 0xff));
2107 lpfc_printf_log(phba, KERN_INFO, LOG_NODE, 2084 lpfc_printf_vlog(vport, KERN_INFO, LOG_NODE,
2108 "%d (%d):0929 FIND node DID " 2085 "0929 FIND node DID "
2109 " Data: x%p x%x x%x x%x\n", 2086 "Data: x%p x%x x%x x%x\n",
2110 phba->brd_no, vport->vpi, 2087 ndlp, ndlp->nlp_DID,
2111 ndlp, ndlp->nlp_DID, 2088 ndlp->nlp_flag, data1);
2112 ndlp->nlp_flag, data1);
2113 return ndlp; 2089 return ndlp;
2114 } 2090 }
2115 } 2091 }
2116 2092
2117 /* FIND node did <did> NOT FOUND */ 2093 /* FIND node did <did> NOT FOUND */
2118 lpfc_printf_log(phba, KERN_INFO, LOG_NODE, 2094 lpfc_printf_vlog(vport, KERN_INFO, LOG_NODE,
2119 "%d (%d):0932 FIND node did x%x NOT FOUND.\n", 2095 "0932 FIND node did x%x NOT FOUND.\n", did);
2120 phba->brd_no, vport->vpi, did);
2121 return NULL; 2096 return NULL;
2122} 2097}
2123 2098
@@ -2208,7 +2183,7 @@ lpfc_disc_list_loopmap(struct lpfc_vport *vport)
2208 /* If cfg_scan_down is set, start from highest 2183 /* If cfg_scan_down is set, start from highest
2209 * ALPA (0xef) to lowest (0x1). 2184 * ALPA (0xef) to lowest (0x1).
2210 */ 2185 */
2211 if (phba->cfg_scan_down) 2186 if (vport->cfg_scan_down)
2212 index = j; 2187 index = j;
2213 else 2188 else
2214 index = FC_MAXLOOP - j - 1; 2189 index = FC_MAXLOOP - j - 1;
@@ -2309,12 +2284,11 @@ lpfc_disc_start(struct lpfc_vport *vport)
2309 vport->num_disc_nodes = 0; 2284 vport->num_disc_nodes = 0;
2310 2285
2311 /* Start Discovery state <hba_state> */ 2286 /* Start Discovery state <hba_state> */
2312 lpfc_printf_log(phba, KERN_INFO, LOG_DISCOVERY, 2287 lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY,
2313 "%d (%d):0202 Start Discovery hba state x%x " 2288 "0202 Start Discovery hba state x%x "
2314 "Data: x%x x%x x%x\n", 2289 "Data: x%x x%x x%x\n",
2315 phba->brd_no, vport->vpi, vport->port_state, 2290 vport->port_state, vport->fc_flag, vport->fc_plogi_cnt,
2316 vport->fc_flag, vport->fc_plogi_cnt, 2291 vport->fc_adisc_cnt);
2317 vport->fc_adisc_cnt);
2318 2292
2319 /* First do ADISCs - if any */ 2293 /* First do ADISCs - if any */
2320 num_sent = lpfc_els_disc_adisc(vport); 2294 num_sent = lpfc_els_disc_adisc(vport);
@@ -2532,10 +2506,8 @@ lpfc_disc_timeout_handler(struct lpfc_vport *vport)
2532 * FAN 2506 * FAN
2533 */ 2507 */
2534 /* FAN timeout */ 2508 /* FAN timeout */
2535 lpfc_printf_log(phba, KERN_WARNING, LOG_DISCOVERY, 2509 lpfc_printf_vlog(vport, KERN_WARNING, LOG_DISCOVERY,
2536 "%d (%d):0221 FAN timeout\n", 2510 "0221 FAN timeout\n");
2537 phba->brd_no, vport->vpi);
2538
2539 /* Start discovery by sending FLOGI, clean up old rpis */ 2511 /* Start discovery by sending FLOGI, clean up old rpis */
2540 list_for_each_entry_safe(ndlp, next_ndlp, &vport->fc_nodes, 2512 list_for_each_entry_safe(ndlp, next_ndlp, &vport->fc_nodes,
2541 nlp_listp) { 2513 nlp_listp) {
@@ -2562,10 +2534,9 @@ lpfc_disc_timeout_handler(struct lpfc_vport *vport)
2562 case LPFC_FLOGI: 2534 case LPFC_FLOGI:
2563 /* port_state is identically LPFC_FLOGI while waiting for FLOGI cmpl */ 2535 /* port_state is identically LPFC_FLOGI while waiting for FLOGI cmpl */
2564 /* Initial FLOGI timeout */ 2536 /* Initial FLOGI timeout */
2565 lpfc_printf_log(phba, KERN_ERR, LOG_DISCOVERY, 2537 lpfc_printf_vlog(vport, KERN_ERR, LOG_DISCOVERY,
2566 "%d (%d):0222 Initial %s timeout\n", 2538 "0222 Initial %s timeout\n",
2567 phba->brd_no, vport->vpi, 2539 vport->vpi ? "FLOGI" : "FDISC");
2568 vport->vpi ? "FLOGI" : "FDISC");
2569 2540
2570 /* Assume no Fabric and go on with discovery. 2541 /* Assume no Fabric and go on with discovery.
2571 * Check for outstanding ELS FLOGI to abort. 2542 * Check for outstanding ELS FLOGI to abort.
@@ -2581,11 +2552,9 @@ lpfc_disc_timeout_handler(struct lpfc_vport *vport)
2581 case LPFC_FABRIC_CFG_LINK: 2552 case LPFC_FABRIC_CFG_LINK:
2582 /* hba_state is identically LPFC_FABRIC_CFG_LINK while waiting for 2553 /* hba_state is identically LPFC_FABRIC_CFG_LINK while waiting for
2583 NameServer login */ 2554 NameServer login */
2584 lpfc_printf_log(phba, KERN_ERR, LOG_DISCOVERY, 2555 lpfc_printf_vlog(vport, KERN_ERR, LOG_DISCOVERY,
2585 "%d (%d):0223 Timeout while waiting for " 2556 "0223 Timeout while waiting for "
2586 "NameServer login\n", 2557 "NameServer login\n");
2587 phba->brd_no, vport->vpi);
2588
2589 /* Next look for NameServer ndlp */ 2558 /* Next look for NameServer ndlp */
2590 ndlp = lpfc_findnode_did(vport, NameServer_DID); 2559 ndlp = lpfc_findnode_did(vport, NameServer_DID);
2591 if (ndlp) 2560 if (ndlp)
@@ -2596,11 +2565,10 @@ lpfc_disc_timeout_handler(struct lpfc_vport *vport)
2596 2565
2597 case LPFC_NS_QRY: 2566 case LPFC_NS_QRY:
2598 /* Check for wait for NameServer Rsp timeout */ 2567 /* Check for wait for NameServer Rsp timeout */
2599 lpfc_printf_log(phba, KERN_ERR, LOG_DISCOVERY, 2568 lpfc_printf_vlog(vport, KERN_ERR, LOG_DISCOVERY,
2600 "%d (%d):0224 NameServer Query timeout " 2569 "0224 NameServer Query timeout "
2601 "Data: x%x x%x\n", 2570 "Data: x%x x%x\n",
2602 phba->brd_no, vport->vpi, 2571 vport->fc_ns_retry, LPFC_MAX_NS_RETRY);
2603 vport->fc_ns_retry, LPFC_MAX_NS_RETRY);
2604 2572
2605 if (vport->fc_ns_retry < LPFC_MAX_NS_RETRY) { 2573 if (vport->fc_ns_retry < LPFC_MAX_NS_RETRY) {
2606 /* Try it one more time */ 2574 /* Try it one more time */
@@ -2627,10 +2595,9 @@ lpfc_disc_timeout_handler(struct lpfc_vport *vport)
2627 /* Setup and issue mailbox INITIALIZE LINK command */ 2595 /* Setup and issue mailbox INITIALIZE LINK command */
2628 initlinkmbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); 2596 initlinkmbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL);
2629 if (!initlinkmbox) { 2597 if (!initlinkmbox) {
2630 lpfc_printf_log(phba, KERN_ERR, LOG_DISCOVERY, 2598 lpfc_printf_vlog(vport, KERN_ERR, LOG_DISCOVERY,
2631 "%d (%d):0206 Device Discovery " 2599 "0206 Device Discovery "
2632 "completion error\n", 2600 "completion error\n");
2633 phba->brd_no, vport->vpi);
2634 phba->link_state = LPFC_HBA_ERROR; 2601 phba->link_state = LPFC_HBA_ERROR;
2635 break; 2602 break;
2636 } 2603 }
@@ -2651,9 +2618,8 @@ lpfc_disc_timeout_handler(struct lpfc_vport *vport)
2651 2618
2652 case LPFC_DISC_AUTH: 2619 case LPFC_DISC_AUTH:
2653 /* Node Authentication timeout */ 2620 /* Node Authentication timeout */
2654 lpfc_printf_log(phba, KERN_ERR, LOG_DISCOVERY, 2621 lpfc_printf_vlog(vport, KERN_ERR, LOG_DISCOVERY,
2655 "%d (%d):0227 Node Authentication timeout\n", 2622 "0227 Node Authentication timeout\n");
2656 phba->brd_no, vport->vpi);
2657 lpfc_disc_flush_list(vport); 2623 lpfc_disc_flush_list(vport);
2658 2624
2659 /* 2625 /*
@@ -2670,11 +2636,10 @@ lpfc_disc_timeout_handler(struct lpfc_vport *vport)
2670 2636
2671 case LPFC_VPORT_READY: 2637 case LPFC_VPORT_READY:
2672 if (vport->fc_flag & FC_RSCN_MODE) { 2638 if (vport->fc_flag & FC_RSCN_MODE) {
2673 lpfc_printf_log(phba, KERN_ERR, LOG_DISCOVERY, 2639 lpfc_printf_vlog(vport, KERN_ERR, LOG_DISCOVERY,
2674 "%d (%d):0231 RSCN timeout Data: x%x " 2640 "0231 RSCN timeout Data: x%x "
2675 "x%x\n", 2641 "x%x\n",
2676 phba->brd_no, vport->vpi, 2642 vport->fc_ns_retry, LPFC_MAX_NS_RETRY);
2677 vport->fc_ns_retry, LPFC_MAX_NS_RETRY);
2678 2643
2679 /* Cleanup any outstanding ELS commands */ 2644 /* Cleanup any outstanding ELS commands */
2680 lpfc_els_flush_cmd(vport); 2645 lpfc_els_flush_cmd(vport);
@@ -2685,20 +2650,17 @@ lpfc_disc_timeout_handler(struct lpfc_vport *vport)
2685 break; 2650 break;
2686 2651
2687 default: 2652 default:
2688 lpfc_printf_log(phba, KERN_ERR, LOG_DISCOVERY, 2653 lpfc_printf_vlog(vport, KERN_ERR, LOG_DISCOVERY,
2689 "%d (%d):0229 Unexpected discovery timeout, " 2654 "0229 Unexpected discovery timeout, "
2690 "vport State x%x\n", 2655 "vport State x%x\n", vport->port_state);
2691 phba->brd_no, vport->vpi, vport->port_state);
2692
2693 break; 2656 break;
2694 } 2657 }
2695 2658
2696 switch (phba->link_state) { 2659 switch (phba->link_state) {
2697 case LPFC_CLEAR_LA: 2660 case LPFC_CLEAR_LA:
2698 /* CLEAR LA timeout */ 2661 /* CLEAR LA timeout */
2699 lpfc_printf_log(phba, KERN_ERR, LOG_DISCOVERY, 2662 lpfc_printf_vlog(vport, KERN_ERR, LOG_DISCOVERY,
2700 "%d (%d):0228 CLEAR LA timeout\n", 2663 "0228 CLEAR LA timeout\n");
2701 phba->brd_no, vport->vpi);
2702 clrlaerr = 1; 2664 clrlaerr = 1;
2703 break; 2665 break;
2704 2666
@@ -2709,10 +2671,9 @@ lpfc_disc_timeout_handler(struct lpfc_vport *vport)
2709 case LPFC_LINK_DOWN: 2671 case LPFC_LINK_DOWN:
2710 case LPFC_LINK_UP: 2672 case LPFC_LINK_UP:
2711 case LPFC_HBA_ERROR: 2673 case LPFC_HBA_ERROR:
2712 lpfc_printf_log(phba, KERN_ERR, LOG_DISCOVERY, 2674 lpfc_printf_vlog(vport, KERN_ERR, LOG_DISCOVERY,
2713 "%d (%d):0230 Unexpected timeout, hba link " 2675 "0230 Unexpected timeout, hba link "
2714 "state x%x\n", 2676 "state x%x\n", phba->link_state);
2715 phba->brd_no, vport->vpi, phba->link_state);
2716 clrlaerr = 1; 2677 clrlaerr = 1;
2717 break; 2678 break;
2718 2679
@@ -2757,7 +2718,7 @@ lpfc_mbx_cmpl_fdmi_reg_login(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb)
2757 * fdmi-on=2 (supporting RPA/hostnmae) 2718 * fdmi-on=2 (supporting RPA/hostnmae)
2758 */ 2719 */
2759 2720
2760 if (phba->cfg_fdmi_on == 1) 2721 if (vport->cfg_fdmi_on == 1)
2761 lpfc_fdmi_cmd(vport, ndlp, SLI_MGMT_DHBA); 2722 lpfc_fdmi_cmd(vport, ndlp, SLI_MGMT_DHBA);
2762 else 2723 else
2763 mod_timer(&vport->fc_fdmitmo, jiffies + HZ * 60); 2724 mod_timer(&vport->fc_fdmitmo, jiffies + HZ * 60);
@@ -2854,32 +2815,6 @@ lpfc_findnode_wwpn(struct lpfc_vport *vport, struct lpfc_name *wwpn)
2854} 2815}
2855 2816
2856void 2817void
2857lpfc_dev_loss_delay(unsigned long ptr)
2858{
2859 struct lpfc_nodelist *ndlp = (struct lpfc_nodelist *) ptr;
2860 struct lpfc_vport *vport = ndlp->vport;
2861 struct lpfc_hba *phba = vport->phba;
2862 struct lpfc_work_evt *evtp = &ndlp->dev_loss_evt;
2863 unsigned long flags;
2864
2865 evtp = &ndlp->dev_loss_evt;
2866
2867 spin_lock_irqsave(&phba->hbalock, flags);
2868 if (!list_empty(&evtp->evt_listp)) {
2869 spin_unlock_irqrestore(&phba->hbalock, flags);
2870 return;
2871 }
2872
2873 evtp->evt_arg1 = ndlp;
2874 evtp->evt = LPFC_EVT_DEV_LOSS_DELAY;
2875 list_add_tail(&evtp->evt_listp, &phba->work_list);
2876 if (phba->work_wait)
2877 lpfc_worker_wake_up(phba);
2878 spin_unlock_irqrestore(&phba->hbalock, flags);
2879 return;
2880}
2881
2882void
2883lpfc_nlp_init(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, 2818lpfc_nlp_init(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
2884 uint32_t did) 2819 uint32_t did)
2885{ 2820{
@@ -2902,7 +2837,7 @@ lpfc_nlp_init(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
2902 return; 2837 return;
2903} 2838}
2904 2839
2905void 2840static void
2906lpfc_nlp_release(struct kref *kref) 2841lpfc_nlp_release(struct kref *kref)
2907{ 2842{
2908 struct lpfc_nodelist *ndlp = container_of(kref, struct lpfc_nodelist, 2843 struct lpfc_nodelist *ndlp = container_of(kref, struct lpfc_nodelist,