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.c239
1 files changed, 161 insertions, 78 deletions
diff --git a/drivers/scsi/lpfc/lpfc_hbadisc.c b/drivers/scsi/lpfc/lpfc_hbadisc.c
index a5d1695dac3d..f9f160ab2ee9 100644
--- a/drivers/scsi/lpfc/lpfc_hbadisc.c
+++ b/drivers/scsi/lpfc/lpfc_hbadisc.c
@@ -607,6 +607,8 @@ lpfc_work_done(struct lpfc_hba *phba)
607 607
608 /* Process SLI4 events */ 608 /* Process SLI4 events */
609 if (phba->pci_dev_grp == LPFC_PCI_DEV_OC) { 609 if (phba->pci_dev_grp == LPFC_PCI_DEV_OC) {
610 if (phba->hba_flag & HBA_RRQ_ACTIVE)
611 lpfc_handle_rrq_active(phba);
610 if (phba->hba_flag & FCP_XRI_ABORT_EVENT) 612 if (phba->hba_flag & FCP_XRI_ABORT_EVENT)
611 lpfc_sli4_fcp_xri_abort_event_proc(phba); 613 lpfc_sli4_fcp_xri_abort_event_proc(phba);
612 if (phba->hba_flag & ELS_XRI_ABORT_EVENT) 614 if (phba->hba_flag & ELS_XRI_ABORT_EVENT)
@@ -966,6 +968,7 @@ lpfc_linkup(struct lpfc_hba *phba)
966 struct lpfc_vport **vports; 968 struct lpfc_vport **vports;
967 int i; 969 int i;
968 970
971 lpfc_cleanup_wt_rrqs(phba);
969 phba->link_state = LPFC_LINK_UP; 972 phba->link_state = LPFC_LINK_UP;
970 973
971 /* Unblock fabric iocbs if they are blocked */ 974 /* Unblock fabric iocbs if they are blocked */
@@ -1064,7 +1067,7 @@ lpfc_mbx_cmpl_local_config_link(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb)
1064 1067
1065 mempool_free(pmb, phba->mbox_mem_pool); 1068 mempool_free(pmb, phba->mbox_mem_pool);
1066 1069
1067 if (phba->fc_topology == TOPOLOGY_LOOP && 1070 if (phba->fc_topology == LPFC_TOPOLOGY_LOOP &&
1068 vport->fc_flag & FC_PUBLIC_LOOP && 1071 vport->fc_flag & FC_PUBLIC_LOOP &&
1069 !(vport->fc_flag & FC_LBIT)) { 1072 !(vport->fc_flag & FC_LBIT)) {
1070 /* Need to wait for FAN - use discovery timer 1073 /* Need to wait for FAN - use discovery timer
@@ -1078,9 +1081,8 @@ lpfc_mbx_cmpl_local_config_link(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb)
1078 /* Start discovery by sending a FLOGI. port_state is identically 1081 /* Start discovery by sending a FLOGI. port_state is identically
1079 * LPFC_FLOGI while waiting for FLOGI cmpl 1082 * LPFC_FLOGI while waiting for FLOGI cmpl
1080 */ 1083 */
1081 if (vport->port_state != LPFC_FLOGI) { 1084 if (vport->port_state != LPFC_FLOGI)
1082 lpfc_initial_flogi(vport); 1085 lpfc_initial_flogi(vport);
1083 }
1084 return; 1086 return;
1085 1087
1086out: 1088out:
@@ -1131,7 +1133,7 @@ lpfc_mbx_cmpl_reg_fcfi(struct lpfc_hba *phba, LPFC_MBOXQ_t *mboxq)
1131 if (vport->port_state != LPFC_FLOGI) { 1133 if (vport->port_state != LPFC_FLOGI) {
1132 phba->hba_flag |= FCF_RR_INPROG; 1134 phba->hba_flag |= FCF_RR_INPROG;
1133 spin_unlock_irq(&phba->hbalock); 1135 spin_unlock_irq(&phba->hbalock);
1134 lpfc_initial_flogi(vport); 1136 lpfc_issue_init_vfi(vport);
1135 goto out; 1137 goto out;
1136 } 1138 }
1137 spin_unlock_irq(&phba->hbalock); 1139 spin_unlock_irq(&phba->hbalock);
@@ -1353,7 +1355,7 @@ lpfc_register_fcf(struct lpfc_hba *phba)
1353 if (phba->pport->port_state != LPFC_FLOGI) { 1355 if (phba->pport->port_state != LPFC_FLOGI) {
1354 phba->hba_flag |= FCF_RR_INPROG; 1356 phba->hba_flag |= FCF_RR_INPROG;
1355 spin_unlock_irq(&phba->hbalock); 1357 spin_unlock_irq(&phba->hbalock);
1356 lpfc_initial_flogi(phba->pport); 1358 lpfc_issue_init_vfi(phba->pport);
1357 return; 1359 return;
1358 } 1360 }
1359 spin_unlock_irq(&phba->hbalock); 1361 spin_unlock_irq(&phba->hbalock);
@@ -2331,7 +2333,7 @@ lpfc_mbx_cmpl_fcf_rr_read_fcf_rec(struct lpfc_hba *phba, LPFC_MBOXQ_t *mboxq)
2331 phba->fcf.current_rec.fcf_indx, fcf_index); 2333 phba->fcf.current_rec.fcf_indx, fcf_index);
2332 /* Wait 500 ms before retrying FLOGI to current FCF */ 2334 /* Wait 500 ms before retrying FLOGI to current FCF */
2333 msleep(500); 2335 msleep(500);
2334 lpfc_initial_flogi(phba->pport); 2336 lpfc_issue_init_vfi(phba->pport);
2335 goto out; 2337 goto out;
2336 } 2338 }
2337 2339
@@ -2422,6 +2424,63 @@ out:
2422} 2424}
2423 2425
2424/** 2426/**
2427 * lpfc_init_vfi_cmpl - Completion handler for init_vfi mbox command.
2428 * @phba: pointer to lpfc hba data structure.
2429 * @mboxq: pointer to mailbox data structure.
2430 *
2431 * This function handles completion of init vfi mailbox command.
2432 */
2433void
2434lpfc_init_vfi_cmpl(struct lpfc_hba *phba, LPFC_MBOXQ_t *mboxq)
2435{
2436 struct lpfc_vport *vport = mboxq->vport;
2437
2438 if (mboxq->u.mb.mbxStatus && (mboxq->u.mb.mbxStatus != 0x4002)) {
2439 lpfc_printf_vlog(vport, KERN_ERR,
2440 LOG_MBOX,
2441 "2891 Init VFI mailbox failed 0x%x\n",
2442 mboxq->u.mb.mbxStatus);
2443 mempool_free(mboxq, phba->mbox_mem_pool);
2444 lpfc_vport_set_state(vport, FC_VPORT_FAILED);
2445 return;
2446 }
2447 lpfc_initial_flogi(vport);
2448 mempool_free(mboxq, phba->mbox_mem_pool);
2449 return;
2450}
2451
2452/**
2453 * lpfc_issue_init_vfi - Issue init_vfi mailbox command.
2454 * @vport: pointer to lpfc_vport data structure.
2455 *
2456 * This function issue a init_vfi mailbox command to initialize the VFI and
2457 * VPI for the physical port.
2458 */
2459void
2460lpfc_issue_init_vfi(struct lpfc_vport *vport)
2461{
2462 LPFC_MBOXQ_t *mboxq;
2463 int rc;
2464 struct lpfc_hba *phba = vport->phba;
2465
2466 mboxq = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL);
2467 if (!mboxq) {
2468 lpfc_printf_vlog(vport, KERN_ERR,
2469 LOG_MBOX, "2892 Failed to allocate "
2470 "init_vfi mailbox\n");
2471 return;
2472 }
2473 lpfc_init_vfi(mboxq, vport);
2474 mboxq->mbox_cmpl = lpfc_init_vfi_cmpl;
2475 rc = lpfc_sli_issue_mbox(phba, mboxq, MBX_NOWAIT);
2476 if (rc == MBX_NOT_FINISHED) {
2477 lpfc_printf_vlog(vport, KERN_ERR,
2478 LOG_MBOX, "2893 Failed to issue init_vfi mailbox\n");
2479 mempool_free(mboxq, vport->phba->mbox_mem_pool);
2480 }
2481}
2482
2483/**
2425 * lpfc_init_vpi_cmpl - Completion handler for init_vpi mbox command. 2484 * lpfc_init_vpi_cmpl - Completion handler for init_vpi mbox command.
2426 * @phba: pointer to lpfc hba data structure. 2485 * @phba: pointer to lpfc hba data structure.
2427 * @mboxq: pointer to mailbox data structure. 2486 * @mboxq: pointer to mailbox data structure.
@@ -2528,7 +2587,7 @@ lpfc_start_fdiscs(struct lpfc_hba *phba)
2528 FC_VPORT_FAILED); 2587 FC_VPORT_FAILED);
2529 continue; 2588 continue;
2530 } 2589 }
2531 if (phba->fc_topology == TOPOLOGY_LOOP) { 2590 if (phba->fc_topology == LPFC_TOPOLOGY_LOOP) {
2532 lpfc_vport_set_state(vports[i], 2591 lpfc_vport_set_state(vports[i],
2533 FC_VPORT_LINKDOWN); 2592 FC_VPORT_LINKDOWN);
2534 continue; 2593 continue;
@@ -2564,7 +2623,7 @@ lpfc_mbx_cmpl_reg_vfi(struct lpfc_hba *phba, LPFC_MBOXQ_t *mboxq)
2564 "2018 REG_VFI mbxStatus error x%x " 2623 "2018 REG_VFI mbxStatus error x%x "
2565 "HBA state x%x\n", 2624 "HBA state x%x\n",
2566 mboxq->u.mb.mbxStatus, vport->port_state); 2625 mboxq->u.mb.mbxStatus, vport->port_state);
2567 if (phba->fc_topology == TOPOLOGY_LOOP) { 2626 if (phba->fc_topology == LPFC_TOPOLOGY_LOOP) {
2568 /* FLOGI failed, use loop map to make discovery list */ 2627 /* FLOGI failed, use loop map to make discovery list */
2569 lpfc_disc_list_loopmap(vport); 2628 lpfc_disc_list_loopmap(vport);
2570 /* Start discovery */ 2629 /* Start discovery */
@@ -2582,8 +2641,18 @@ lpfc_mbx_cmpl_reg_vfi(struct lpfc_hba *phba, LPFC_MBOXQ_t *mboxq)
2582 spin_unlock_irq(shost->host_lock); 2641 spin_unlock_irq(shost->host_lock);
2583 2642
2584 if (vport->port_state == LPFC_FABRIC_CFG_LINK) { 2643 if (vport->port_state == LPFC_FABRIC_CFG_LINK) {
2585 lpfc_start_fdiscs(phba); 2644 /* For private loop just start discovery and we are done. */
2586 lpfc_do_scr_ns_plogi(phba, vport); 2645 if ((phba->fc_topology == LPFC_TOPOLOGY_LOOP) &&
2646 (phba->alpa_map[0] == 0) &&
2647 !(vport->fc_flag & FC_PUBLIC_LOOP)) {
2648 /* Use loop map to make discovery list */
2649 lpfc_disc_list_loopmap(vport);
2650 /* Start discovery */
2651 lpfc_disc_start(vport);
2652 } else {
2653 lpfc_start_fdiscs(phba);
2654 lpfc_do_scr_ns_plogi(phba, vport);
2655 }
2587 } 2656 }
2588 2657
2589fail_free_mem: 2658fail_free_mem:
@@ -2644,7 +2713,7 @@ out:
2644} 2713}
2645 2714
2646static void 2715static void
2647lpfc_mbx_process_link_up(struct lpfc_hba *phba, READ_LA_VAR *la) 2716lpfc_mbx_process_link_up(struct lpfc_hba *phba, struct lpfc_mbx_read_top *la)
2648{ 2717{
2649 struct lpfc_vport *vport = phba->pport; 2718 struct lpfc_vport *vport = phba->pport;
2650 LPFC_MBOXQ_t *sparam_mbox, *cfglink_mbox = NULL; 2719 LPFC_MBOXQ_t *sparam_mbox, *cfglink_mbox = NULL;
@@ -2654,31 +2723,24 @@ lpfc_mbx_process_link_up(struct lpfc_hba *phba, READ_LA_VAR *la)
2654 struct fcf_record *fcf_record; 2723 struct fcf_record *fcf_record;
2655 2724
2656 spin_lock_irq(&phba->hbalock); 2725 spin_lock_irq(&phba->hbalock);
2657 switch (la->UlnkSpeed) { 2726 switch (bf_get(lpfc_mbx_read_top_link_spd, la)) {
2658 case LA_1GHZ_LINK: 2727 case LPFC_LINK_SPEED_1GHZ:
2659 phba->fc_linkspeed = LA_1GHZ_LINK; 2728 case LPFC_LINK_SPEED_2GHZ:
2660 break; 2729 case LPFC_LINK_SPEED_4GHZ:
2661 case LA_2GHZ_LINK: 2730 case LPFC_LINK_SPEED_8GHZ:
2662 phba->fc_linkspeed = LA_2GHZ_LINK; 2731 case LPFC_LINK_SPEED_10GHZ:
2663 break; 2732 case LPFC_LINK_SPEED_16GHZ:
2664 case LA_4GHZ_LINK: 2733 phba->fc_linkspeed = bf_get(lpfc_mbx_read_top_link_spd, la);
2665 phba->fc_linkspeed = LA_4GHZ_LINK;
2666 break;
2667 case LA_8GHZ_LINK:
2668 phba->fc_linkspeed = LA_8GHZ_LINK;
2669 break;
2670 case LA_10GHZ_LINK:
2671 phba->fc_linkspeed = LA_10GHZ_LINK;
2672 break; 2734 break;
2673 default: 2735 default:
2674 phba->fc_linkspeed = LA_UNKNW_LINK; 2736 phba->fc_linkspeed = LPFC_LINK_SPEED_UNKNOWN;
2675 break; 2737 break;
2676 } 2738 }
2677 2739
2678 phba->fc_topology = la->topology; 2740 phba->fc_topology = bf_get(lpfc_mbx_read_top_topology, la);
2679 phba->link_flag &= ~LS_NPIV_FAB_SUPPORTED; 2741 phba->link_flag &= ~LS_NPIV_FAB_SUPPORTED;
2680 2742
2681 if (phba->fc_topology == TOPOLOGY_LOOP) { 2743 if (phba->fc_topology == LPFC_TOPOLOGY_LOOP) {
2682 phba->sli3_options &= ~LPFC_SLI3_NPIV_ENABLED; 2744 phba->sli3_options &= ~LPFC_SLI3_NPIV_ENABLED;
2683 2745
2684 /* if npiv is enabled and this adapter supports npiv log 2746 /* if npiv is enabled and this adapter supports npiv log
@@ -2689,11 +2751,11 @@ lpfc_mbx_process_link_up(struct lpfc_hba *phba, READ_LA_VAR *la)
2689 "1309 Link Up Event npiv not supported in loop " 2751 "1309 Link Up Event npiv not supported in loop "
2690 "topology\n"); 2752 "topology\n");
2691 /* Get Loop Map information */ 2753 /* Get Loop Map information */
2692 if (la->il) 2754 if (bf_get(lpfc_mbx_read_top_il, la))
2693 vport->fc_flag |= FC_LBIT; 2755 vport->fc_flag |= FC_LBIT;
2694 2756
2695 vport->fc_myDID = la->granted_AL_PA; 2757 vport->fc_myDID = bf_get(lpfc_mbx_read_top_alpa_granted, la);
2696 i = la->un.lilpBde64.tus.f.bdeSize; 2758 i = la->lilpBde64.tus.f.bdeSize;
2697 2759
2698 if (i == 0) { 2760 if (i == 0) {
2699 phba->alpa_map[0] = 0; 2761 phba->alpa_map[0] = 0;
@@ -2764,7 +2826,7 @@ lpfc_mbx_process_link_up(struct lpfc_hba *phba, READ_LA_VAR *la)
2764 goto out; 2826 goto out;
2765 } 2827 }
2766 2828
2767 if (!(phba->hba_flag & HBA_FCOE_SUPPORT)) { 2829 if (!(phba->hba_flag & HBA_FCOE_MODE)) {
2768 cfglink_mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); 2830 cfglink_mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL);
2769 if (!cfglink_mbox) 2831 if (!cfglink_mbox)
2770 goto out; 2832 goto out;
@@ -2874,17 +2936,17 @@ lpfc_mbx_issue_link_down(struct lpfc_hba *phba)
2874 2936
2875 2937
2876/* 2938/*
2877 * This routine handles processing a READ_LA mailbox 2939 * This routine handles processing a READ_TOPOLOGY mailbox
2878 * command upon completion. It is setup in the LPFC_MBOXQ 2940 * command upon completion. It is setup in the LPFC_MBOXQ
2879 * as the completion routine when the command is 2941 * as the completion routine when the command is
2880 * handed off to the SLI layer. 2942 * handed off to the SLI layer.
2881 */ 2943 */
2882void 2944void
2883lpfc_mbx_cmpl_read_la(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb) 2945lpfc_mbx_cmpl_read_topology(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb)
2884{ 2946{
2885 struct lpfc_vport *vport = pmb->vport; 2947 struct lpfc_vport *vport = pmb->vport;
2886 struct Scsi_Host *shost = lpfc_shost_from_vport(vport); 2948 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
2887 READ_LA_VAR *la; 2949 struct lpfc_mbx_read_top *la;
2888 MAILBOX_t *mb = &pmb->u.mb; 2950 MAILBOX_t *mb = &pmb->u.mb;
2889 struct lpfc_dmabuf *mp = (struct lpfc_dmabuf *) (pmb->context1); 2951 struct lpfc_dmabuf *mp = (struct lpfc_dmabuf *) (pmb->context1);
2890 2952
@@ -2897,15 +2959,15 @@ lpfc_mbx_cmpl_read_la(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb)
2897 mb->mbxStatus, vport->port_state); 2959 mb->mbxStatus, vport->port_state);
2898 lpfc_mbx_issue_link_down(phba); 2960 lpfc_mbx_issue_link_down(phba);
2899 phba->link_state = LPFC_HBA_ERROR; 2961 phba->link_state = LPFC_HBA_ERROR;
2900 goto lpfc_mbx_cmpl_read_la_free_mbuf; 2962 goto lpfc_mbx_cmpl_read_topology_free_mbuf;
2901 } 2963 }
2902 2964
2903 la = (READ_LA_VAR *) &pmb->u.mb.un.varReadLA; 2965 la = (struct lpfc_mbx_read_top *) &pmb->u.mb.un.varReadTop;
2904 2966
2905 memcpy(&phba->alpa_map[0], mp->virt, 128); 2967 memcpy(&phba->alpa_map[0], mp->virt, 128);
2906 2968
2907 spin_lock_irq(shost->host_lock); 2969 spin_lock_irq(shost->host_lock);
2908 if (la->pb) 2970 if (bf_get(lpfc_mbx_read_top_pb, la))
2909 vport->fc_flag |= FC_BYPASSED_MODE; 2971 vport->fc_flag |= FC_BYPASSED_MODE;
2910 else 2972 else
2911 vport->fc_flag &= ~FC_BYPASSED_MODE; 2973 vport->fc_flag &= ~FC_BYPASSED_MODE;
@@ -2914,41 +2976,48 @@ lpfc_mbx_cmpl_read_la(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb)
2914 if ((phba->fc_eventTag < la->eventTag) || 2976 if ((phba->fc_eventTag < la->eventTag) ||
2915 (phba->fc_eventTag == la->eventTag)) { 2977 (phba->fc_eventTag == la->eventTag)) {
2916 phba->fc_stat.LinkMultiEvent++; 2978 phba->fc_stat.LinkMultiEvent++;
2917 if (la->attType == AT_LINK_UP) 2979 if (bf_get(lpfc_mbx_read_top_att_type, la) == LPFC_ATT_LINK_UP)
2918 if (phba->fc_eventTag != 0) 2980 if (phba->fc_eventTag != 0)
2919 lpfc_linkdown(phba); 2981 lpfc_linkdown(phba);
2920 } 2982 }
2921 2983
2922 phba->fc_eventTag = la->eventTag; 2984 phba->fc_eventTag = la->eventTag;
2923 spin_lock_irq(&phba->hbalock); 2985 spin_lock_irq(&phba->hbalock);
2924 if (la->mm) 2986 if (bf_get(lpfc_mbx_read_top_mm, la))
2925 phba->sli.sli_flag |= LPFC_MENLO_MAINT; 2987 phba->sli.sli_flag |= LPFC_MENLO_MAINT;
2926 else 2988 else
2927 phba->sli.sli_flag &= ~LPFC_MENLO_MAINT; 2989 phba->sli.sli_flag &= ~LPFC_MENLO_MAINT;
2928 spin_unlock_irq(&phba->hbalock); 2990 spin_unlock_irq(&phba->hbalock);
2929 2991
2930 phba->link_events++; 2992 phba->link_events++;
2931 if (la->attType == AT_LINK_UP && (!la->mm)) { 2993 if ((bf_get(lpfc_mbx_read_top_att_type, la) == LPFC_ATT_LINK_UP) &&
2994 (!bf_get(lpfc_mbx_read_top_mm, la))) {
2932 phba->fc_stat.LinkUp++; 2995 phba->fc_stat.LinkUp++;
2933 if (phba->link_flag & LS_LOOPBACK_MODE) { 2996 if (phba->link_flag & LS_LOOPBACK_MODE) {
2934 lpfc_printf_log(phba, KERN_ERR, LOG_LINK_EVENT, 2997 lpfc_printf_log(phba, KERN_ERR, LOG_LINK_EVENT,
2935 "1306 Link Up Event in loop back mode " 2998 "1306 Link Up Event in loop back mode "
2936 "x%x received Data: x%x x%x x%x x%x\n", 2999 "x%x received Data: x%x x%x x%x x%x\n",
2937 la->eventTag, phba->fc_eventTag, 3000 la->eventTag, phba->fc_eventTag,
2938 la->granted_AL_PA, la->UlnkSpeed, 3001 bf_get(lpfc_mbx_read_top_alpa_granted,
3002 la),
3003 bf_get(lpfc_mbx_read_top_link_spd, la),
2939 phba->alpa_map[0]); 3004 phba->alpa_map[0]);
2940 } else { 3005 } else {
2941 lpfc_printf_log(phba, KERN_ERR, LOG_LINK_EVENT, 3006 lpfc_printf_log(phba, KERN_ERR, LOG_LINK_EVENT,
2942 "1303 Link Up Event x%x received " 3007 "1303 Link Up Event x%x received "
2943 "Data: x%x x%x x%x x%x x%x x%x %d\n", 3008 "Data: x%x x%x x%x x%x x%x x%x %d\n",
2944 la->eventTag, phba->fc_eventTag, 3009 la->eventTag, phba->fc_eventTag,
2945 la->granted_AL_PA, la->UlnkSpeed, 3010 bf_get(lpfc_mbx_read_top_alpa_granted,
3011 la),
3012 bf_get(lpfc_mbx_read_top_link_spd, la),
2946 phba->alpa_map[0], 3013 phba->alpa_map[0],
2947 la->mm, la->fa, 3014 bf_get(lpfc_mbx_read_top_mm, la),
3015 bf_get(lpfc_mbx_read_top_fa, la),
2948 phba->wait_4_mlo_maint_flg); 3016 phba->wait_4_mlo_maint_flg);
2949 } 3017 }
2950 lpfc_mbx_process_link_up(phba, la); 3018 lpfc_mbx_process_link_up(phba, la);
2951 } else if (la->attType == AT_LINK_DOWN) { 3019 } else if (bf_get(lpfc_mbx_read_top_att_type, la) ==
3020 LPFC_ATT_LINK_DOWN) {
2952 phba->fc_stat.LinkDown++; 3021 phba->fc_stat.LinkDown++;
2953 if (phba->link_flag & LS_LOOPBACK_MODE) { 3022 if (phba->link_flag & LS_LOOPBACK_MODE) {
2954 lpfc_printf_log(phba, KERN_ERR, LOG_LINK_EVENT, 3023 lpfc_printf_log(phba, KERN_ERR, LOG_LINK_EVENT,
@@ -2964,11 +3033,13 @@ lpfc_mbx_cmpl_read_la(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb)
2964 "Data: x%x x%x x%x x%x x%x\n", 3033 "Data: x%x x%x x%x x%x x%x\n",
2965 la->eventTag, phba->fc_eventTag, 3034 la->eventTag, phba->fc_eventTag,
2966 phba->pport->port_state, vport->fc_flag, 3035 phba->pport->port_state, vport->fc_flag,
2967 la->mm, la->fa); 3036 bf_get(lpfc_mbx_read_top_mm, la),
3037 bf_get(lpfc_mbx_read_top_fa, la));
2968 } 3038 }
2969 lpfc_mbx_issue_link_down(phba); 3039 lpfc_mbx_issue_link_down(phba);
2970 } 3040 }
2971 if (la->mm && la->attType == AT_LINK_UP) { 3041 if ((bf_get(lpfc_mbx_read_top_mm, la)) &&
3042 (bf_get(lpfc_mbx_read_top_att_type, la) == LPFC_ATT_LINK_UP)) {
2972 if (phba->link_state != LPFC_LINK_DOWN) { 3043 if (phba->link_state != LPFC_LINK_DOWN) {
2973 phba->fc_stat.LinkDown++; 3044 phba->fc_stat.LinkDown++;
2974 lpfc_printf_log(phba, KERN_ERR, LOG_LINK_EVENT, 3045 lpfc_printf_log(phba, KERN_ERR, LOG_LINK_EVENT,
@@ -2996,14 +3067,15 @@ lpfc_mbx_cmpl_read_la(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb)
2996 } 3067 }
2997 } 3068 }
2998 3069
2999 if (la->fa) { 3070 if (bf_get(lpfc_mbx_read_top_fa, la)) {
3000 if (la->mm) 3071 if (bf_get(lpfc_mbx_read_top_mm, la))
3001 lpfc_issue_clear_la(phba, vport); 3072 lpfc_issue_clear_la(phba, vport);
3002 lpfc_printf_log(phba, KERN_INFO, LOG_LINK_EVENT, 3073 lpfc_printf_log(phba, KERN_INFO, LOG_LINK_EVENT,
3003 "1311 fa %d\n", la->fa); 3074 "1311 fa %d\n",
3075 bf_get(lpfc_mbx_read_top_fa, la));
3004 } 3076 }
3005 3077
3006lpfc_mbx_cmpl_read_la_free_mbuf: 3078lpfc_mbx_cmpl_read_topology_free_mbuf:
3007 lpfc_mbuf_free(phba, mp->virt, mp->phys); 3079 lpfc_mbuf_free(phba, mp->virt, mp->phys);
3008 kfree(mp); 3080 kfree(mp);
3009 mempool_free(pmb, phba->mbox_mem_pool); 3081 mempool_free(pmb, phba->mbox_mem_pool);
@@ -3030,8 +3102,8 @@ lpfc_mbx_cmpl_reg_login(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb)
3030 if (ndlp->nlp_flag & NLP_REG_LOGIN_SEND) 3102 if (ndlp->nlp_flag & NLP_REG_LOGIN_SEND)
3031 ndlp->nlp_flag &= ~NLP_REG_LOGIN_SEND; 3103 ndlp->nlp_flag &= ~NLP_REG_LOGIN_SEND;
3032 3104
3033 if (ndlp->nlp_flag & NLP_IGNR_REG_CMPL || 3105 if (ndlp->nlp_flag & NLP_IGNR_REG_CMPL ||
3034 ndlp->nlp_state != NLP_STE_REG_LOGIN_ISSUE) { 3106 ndlp->nlp_state != NLP_STE_REG_LOGIN_ISSUE) {
3035 /* We rcvd a rscn after issuing this 3107 /* We rcvd a rscn after issuing this
3036 * mbox reg login, we may have cycled 3108 * mbox reg login, we may have cycled
3037 * back through the state and be 3109 * back through the state and be
@@ -3043,10 +3115,6 @@ lpfc_mbx_cmpl_reg_login(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb)
3043 spin_lock_irq(shost->host_lock); 3115 spin_lock_irq(shost->host_lock);
3044 ndlp->nlp_flag &= ~NLP_IGNR_REG_CMPL; 3116 ndlp->nlp_flag &= ~NLP_IGNR_REG_CMPL;
3045 spin_unlock_irq(shost->host_lock); 3117 spin_unlock_irq(shost->host_lock);
3046 if (phba->sli_rev == LPFC_SLI_REV4)
3047 lpfc_sli4_free_rpi(phba,
3048 pmb->u.mb.un.varRegLogin.rpi);
3049
3050 } else 3118 } else
3051 /* Good status, call state machine */ 3119 /* Good status, call state machine */
3052 lpfc_disc_state_machine(vport, ndlp, pmb, 3120 lpfc_disc_state_machine(vport, ndlp, pmb,
@@ -3092,6 +3160,7 @@ lpfc_mbx_cmpl_unreg_vpi(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb)
3092 spin_unlock_irq(shost->host_lock); 3160 spin_unlock_irq(shost->host_lock);
3093 vport->unreg_vpi_cmpl = VPORT_OK; 3161 vport->unreg_vpi_cmpl = VPORT_OK;
3094 mempool_free(pmb, phba->mbox_mem_pool); 3162 mempool_free(pmb, phba->mbox_mem_pool);
3163 lpfc_cleanup_vports_rrqs(vport);
3095 /* 3164 /*
3096 * This shost reference might have been taken at the beginning of 3165 * This shost reference might have been taken at the beginning of
3097 * lpfc_vport_delete() 3166 * lpfc_vport_delete()
@@ -3333,7 +3402,7 @@ lpfc_mbx_cmpl_fabric_reg_login(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb)
3333 kfree(mp); 3402 kfree(mp);
3334 mempool_free(pmb, phba->mbox_mem_pool); 3403 mempool_free(pmb, phba->mbox_mem_pool);
3335 3404
3336 if (phba->fc_topology == TOPOLOGY_LOOP) { 3405 if (phba->fc_topology == LPFC_TOPOLOGY_LOOP) {
3337 /* FLOGI failed, use loop map to make discovery list */ 3406 /* FLOGI failed, use loop map to make discovery list */
3338 lpfc_disc_list_loopmap(vport); 3407 lpfc_disc_list_loopmap(vport);
3339 3408
@@ -3355,7 +3424,7 @@ lpfc_mbx_cmpl_fabric_reg_login(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb)
3355 } 3424 }
3356 3425
3357 ndlp->nlp_rpi = mb->un.varWords[0]; 3426 ndlp->nlp_rpi = mb->un.varWords[0];
3358 ndlp->nlp_flag |= NLP_RPI_VALID; 3427 ndlp->nlp_flag |= NLP_RPI_REGISTERED;
3359 ndlp->nlp_type |= NLP_FABRIC; 3428 ndlp->nlp_type |= NLP_FABRIC;
3360 lpfc_nlp_set_state(vport, ndlp, NLP_STE_UNMAPPED_NODE); 3429 lpfc_nlp_set_state(vport, ndlp, NLP_STE_UNMAPPED_NODE);
3361 3430
@@ -3413,7 +3482,7 @@ out:
3413 /* If no other thread is using the ndlp, free it */ 3482 /* If no other thread is using the ndlp, free it */
3414 lpfc_nlp_not_used(ndlp); 3483 lpfc_nlp_not_used(ndlp);
3415 3484
3416 if (phba->fc_topology == TOPOLOGY_LOOP) { 3485 if (phba->fc_topology == LPFC_TOPOLOGY_LOOP) {
3417 /* 3486 /*
3418 * RegLogin failed, use loop map to make discovery 3487 * RegLogin failed, use loop map to make discovery
3419 * list 3488 * list
@@ -3429,7 +3498,7 @@ out:
3429 } 3498 }
3430 3499
3431 ndlp->nlp_rpi = mb->un.varWords[0]; 3500 ndlp->nlp_rpi = mb->un.varWords[0];
3432 ndlp->nlp_flag |= NLP_RPI_VALID; 3501 ndlp->nlp_flag |= NLP_RPI_REGISTERED;
3433 ndlp->nlp_type |= NLP_FABRIC; 3502 ndlp->nlp_type |= NLP_FABRIC;
3434 lpfc_nlp_set_state(vport, ndlp, NLP_STE_UNMAPPED_NODE); 3503 lpfc_nlp_set_state(vport, ndlp, NLP_STE_UNMAPPED_NODE);
3435 3504
@@ -3762,6 +3831,8 @@ lpfc_initialize_node(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
3762 NLP_INT_NODE_ACT(ndlp); 3831 NLP_INT_NODE_ACT(ndlp);
3763 atomic_set(&ndlp->cmd_pending, 0); 3832 atomic_set(&ndlp->cmd_pending, 0);
3764 ndlp->cmd_qdepth = vport->cfg_tgt_queue_depth; 3833 ndlp->cmd_qdepth = vport->cfg_tgt_queue_depth;
3834 if (vport->phba->sli_rev == LPFC_SLI_REV4)
3835 ndlp->nlp_rpi = lpfc_sli4_alloc_rpi(vport->phba);
3765} 3836}
3766 3837
3767struct lpfc_nodelist * 3838struct lpfc_nodelist *
@@ -3975,7 +4046,7 @@ lpfc_no_rpi(struct lpfc_hba *phba, struct lpfc_nodelist *ndlp)
3975 * by firmware with a no rpi error. 4046 * by firmware with a no rpi error.
3976 */ 4047 */
3977 psli = &phba->sli; 4048 psli = &phba->sli;
3978 if (ndlp->nlp_flag & NLP_RPI_VALID) { 4049 if (ndlp->nlp_flag & NLP_RPI_REGISTERED) {
3979 /* Now process each ring */ 4050 /* Now process each ring */
3980 for (i = 0; i < psli->num_rings; i++) { 4051 for (i = 0; i < psli->num_rings; i++) {
3981 pring = &psli->ring[i]; 4052 pring = &psli->ring[i];
@@ -4023,7 +4094,7 @@ lpfc_unreg_rpi(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp)
4023 LPFC_MBOXQ_t *mbox; 4094 LPFC_MBOXQ_t *mbox;
4024 int rc; 4095 int rc;
4025 4096
4026 if (ndlp->nlp_flag & NLP_RPI_VALID) { 4097 if (ndlp->nlp_flag & NLP_RPI_REGISTERED) {
4027 mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); 4098 mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL);
4028 if (mbox) { 4099 if (mbox) {
4029 lpfc_unreg_login(phba, vport->vpi, ndlp->nlp_rpi, mbox); 4100 lpfc_unreg_login(phba, vport->vpi, ndlp->nlp_rpi, mbox);
@@ -4035,8 +4106,9 @@ lpfc_unreg_rpi(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp)
4035 } 4106 }
4036 lpfc_no_rpi(phba, ndlp); 4107 lpfc_no_rpi(phba, ndlp);
4037 4108
4038 ndlp->nlp_rpi = 0; 4109 if (phba->sli_rev != LPFC_SLI_REV4)
4039 ndlp->nlp_flag &= ~NLP_RPI_VALID; 4110 ndlp->nlp_rpi = 0;
4111 ndlp->nlp_flag &= ~NLP_RPI_REGISTERED;
4040 ndlp->nlp_flag &= ~NLP_NPR_ADISC; 4112 ndlp->nlp_flag &= ~NLP_NPR_ADISC;
4041 return 1; 4113 return 1;
4042 } 4114 }
@@ -4059,11 +4131,16 @@ lpfc_unreg_hba_rpis(struct lpfc_hba *phba)
4059 int i; 4131 int i;
4060 4132
4061 vports = lpfc_create_vport_work_array(phba); 4133 vports = lpfc_create_vport_work_array(phba);
4134 if (!vports) {
4135 lpfc_printf_log(phba, KERN_ERR, LOG_DISCOVERY,
4136 "2884 Vport array allocation failed \n");
4137 return;
4138 }
4062 for (i = 0; i <= phba->max_vports && vports[i] != NULL; i++) { 4139 for (i = 0; i <= phba->max_vports && vports[i] != NULL; i++) {
4063 shost = lpfc_shost_from_vport(vports[i]); 4140 shost = lpfc_shost_from_vport(vports[i]);
4064 spin_lock_irq(shost->host_lock); 4141 spin_lock_irq(shost->host_lock);
4065 list_for_each_entry(ndlp, &vports[i]->fc_nodes, nlp_listp) { 4142 list_for_each_entry(ndlp, &vports[i]->fc_nodes, nlp_listp) {
4066 if (ndlp->nlp_flag & NLP_RPI_VALID) { 4143 if (ndlp->nlp_flag & NLP_RPI_REGISTERED) {
4067 /* The mempool_alloc might sleep */ 4144 /* The mempool_alloc might sleep */
4068 spin_unlock_irq(shost->host_lock); 4145 spin_unlock_irq(shost->host_lock);
4069 lpfc_unreg_rpi(vports[i], ndlp); 4146 lpfc_unreg_rpi(vports[i], ndlp);
@@ -4192,9 +4269,6 @@ lpfc_cleanup_node(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp)
4192 kfree(mp); 4269 kfree(mp);
4193 } 4270 }
4194 list_del(&mb->list); 4271 list_del(&mb->list);
4195 if (phba->sli_rev == LPFC_SLI_REV4)
4196 lpfc_sli4_free_rpi(phba,
4197 mb->u.mb.un.varRegLogin.rpi);
4198 mempool_free(mb, phba->mbox_mem_pool); 4272 mempool_free(mb, phba->mbox_mem_pool);
4199 /* We shall not invoke the lpfc_nlp_put to decrement 4273 /* We shall not invoke the lpfc_nlp_put to decrement
4200 * the ndlp reference count as we are in the process 4274 * the ndlp reference count as we are in the process
@@ -4236,15 +4310,15 @@ lpfc_nlp_remove(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp)
4236 4310
4237 lpfc_cancel_retry_delay_tmo(vport, ndlp); 4311 lpfc_cancel_retry_delay_tmo(vport, ndlp);
4238 if ((ndlp->nlp_flag & NLP_DEFER_RM) && 4312 if ((ndlp->nlp_flag & NLP_DEFER_RM) &&
4239 !(ndlp->nlp_flag & NLP_REG_LOGIN_SEND) && 4313 !(ndlp->nlp_flag & NLP_REG_LOGIN_SEND) &&
4240 !(ndlp->nlp_flag & NLP_RPI_VALID)) { 4314 !(ndlp->nlp_flag & NLP_RPI_REGISTERED)) {
4241 /* For this case we need to cleanup the default rpi 4315 /* For this case we need to cleanup the default rpi
4242 * allocated by the firmware. 4316 * allocated by the firmware.
4243 */ 4317 */
4244 if ((mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL)) 4318 if ((mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL))
4245 != NULL) { 4319 != NULL) {
4246 rc = lpfc_reg_rpi(phba, vport->vpi, ndlp->nlp_DID, 4320 rc = lpfc_reg_rpi(phba, vport->vpi, ndlp->nlp_DID,
4247 (uint8_t *) &vport->fc_sparam, mbox, 0); 4321 (uint8_t *) &vport->fc_sparam, mbox, ndlp->nlp_rpi);
4248 if (rc) { 4322 if (rc) {
4249 mempool_free(mbox, phba->mbox_mem_pool); 4323 mempool_free(mbox, phba->mbox_mem_pool);
4250 } 4324 }
@@ -4436,7 +4510,7 @@ lpfc_disc_list_loopmap(struct lpfc_vport *vport)
4436 if (!lpfc_is_link_up(phba)) 4510 if (!lpfc_is_link_up(phba))
4437 return; 4511 return;
4438 4512
4439 if (phba->fc_topology != TOPOLOGY_LOOP) 4513 if (phba->fc_topology != LPFC_TOPOLOGY_LOOP)
4440 return; 4514 return;
4441 4515
4442 /* Check for loop map present or not */ 4516 /* Check for loop map present or not */
@@ -4788,7 +4862,10 @@ lpfc_disc_timeout_handler(struct lpfc_vport *vport)
4788 } 4862 }
4789 } 4863 }
4790 if (vport->port_state != LPFC_FLOGI) { 4864 if (vport->port_state != LPFC_FLOGI) {
4791 lpfc_initial_flogi(vport); 4865 if (phba->sli_rev <= LPFC_SLI_REV3)
4866 lpfc_initial_flogi(vport);
4867 else
4868 lpfc_issue_init_vfi(vport);
4792 return; 4869 return;
4793 } 4870 }
4794 break; 4871 break;
@@ -4979,7 +5056,7 @@ lpfc_mbx_cmpl_fdmi_reg_login(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb)
4979 pmb->context2 = NULL; 5056 pmb->context2 = NULL;
4980 5057
4981 ndlp->nlp_rpi = mb->un.varWords[0]; 5058 ndlp->nlp_rpi = mb->un.varWords[0];
4982 ndlp->nlp_flag |= NLP_RPI_VALID; 5059 ndlp->nlp_flag |= NLP_RPI_REGISTERED;
4983 ndlp->nlp_type |= NLP_FABRIC; 5060 ndlp->nlp_type |= NLP_FABRIC;
4984 lpfc_nlp_set_state(vport, ndlp, NLP_STE_UNMAPPED_NODE); 5061 lpfc_nlp_set_state(vport, ndlp, NLP_STE_UNMAPPED_NODE);
4985 5062
@@ -5103,6 +5180,8 @@ lpfc_nlp_release(struct kref *kref)
5103 spin_lock_irqsave(&phba->ndlp_lock, flags); 5180 spin_lock_irqsave(&phba->ndlp_lock, flags);
5104 NLP_CLR_NODE_ACT(ndlp); 5181 NLP_CLR_NODE_ACT(ndlp);
5105 spin_unlock_irqrestore(&phba->ndlp_lock, flags); 5182 spin_unlock_irqrestore(&phba->ndlp_lock, flags);
5183 if (phba->sli_rev == LPFC_SLI_REV4)
5184 lpfc_sli4_free_rpi(phba, ndlp->nlp_rpi);
5106 5185
5107 /* free ndlp memory for final ndlp release */ 5186 /* free ndlp memory for final ndlp release */
5108 if (NLP_CHK_FREE_REQ(ndlp)) { 5187 if (NLP_CHK_FREE_REQ(ndlp)) {
@@ -5254,6 +5333,10 @@ lpfc_fcf_inuse(struct lpfc_hba *phba)
5254 5333
5255 vports = lpfc_create_vport_work_array(phba); 5334 vports = lpfc_create_vport_work_array(phba);
5256 5335
5336 /* If driver cannot allocate memory, indicate fcf is in use */
5337 if (!vports)
5338 return 1;
5339
5257 for (i = 0; i <= phba->max_vports && vports[i] != NULL; i++) { 5340 for (i = 0; i <= phba->max_vports && vports[i] != NULL; i++) {
5258 shost = lpfc_shost_from_vport(vports[i]); 5341 shost = lpfc_shost_from_vport(vports[i]);
5259 spin_lock_irq(shost->host_lock); 5342 spin_lock_irq(shost->host_lock);
@@ -5269,7 +5352,7 @@ lpfc_fcf_inuse(struct lpfc_hba *phba)
5269 "logged in\n", 5352 "logged in\n",
5270 ndlp->nlp_rpi, ndlp->nlp_DID, 5353 ndlp->nlp_rpi, ndlp->nlp_DID,
5271 ndlp->nlp_flag); 5354 ndlp->nlp_flag);
5272 if (ndlp->nlp_flag & NLP_RPI_VALID) 5355 if (ndlp->nlp_flag & NLP_RPI_REGISTERED)
5273 ret = 1; 5356 ret = 1;
5274 } 5357 }
5275 } 5358 }
@@ -5550,7 +5633,7 @@ lpfc_unregister_unused_fcf(struct lpfc_hba *phba)
5550 * registered, do nothing. 5633 * registered, do nothing.
5551 */ 5634 */
5552 spin_lock_irq(&phba->hbalock); 5635 spin_lock_irq(&phba->hbalock);
5553 if (!(phba->hba_flag & HBA_FCOE_SUPPORT) || 5636 if (!(phba->hba_flag & HBA_FCOE_MODE) ||
5554 !(phba->fcf.fcf_flag & FCF_REGISTERED) || 5637 !(phba->fcf.fcf_flag & FCF_REGISTERED) ||
5555 !(phba->hba_flag & HBA_FIP_SUPPORT) || 5638 !(phba->hba_flag & HBA_FIP_SUPPORT) ||
5556 (phba->fcf.fcf_flag & FCF_DISCOVERY) || 5639 (phba->fcf.fcf_flag & FCF_DISCOVERY) ||