Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[SCSI] Lpfc 8.3.28: FC and SCSI Discovery Fixes

FC and SCSI Discovery Fixes:

- Clear the virtual fabrics bit (word 1 bit 30) when sending the FLOGI
and FDISC. (CR 124339)
- Return a MLQUEUE_DEVICE_BUSY if the driver detects that an I/O is being
retried too quickly (CR 124668)
- Remove NDLP reference put in lpfc_cmpl_els_logo_acc for all but fabric
nodes (CR 123924)
- Only retry FDISCs every second and stop retrying after devloss number
of retries (CR 13939)
- Check to see if vports are unloading before adding them to the vport
work array. (CR 124996)
- Fixed illegal state transition during driver unload (CR 124191)
- Added missing protection on setting/clearing of vport->fc_flag bit (CR 126002)
- Set NPIV flag in lpfc_mbx_process_link_up for all ports sli3 and
above. (CR 126094)
- Clear FCP command bytes that are not used. (CR 126209)

Signed-off-by: Alex Iannicelli <alex.iannicelli@emulex.com>
Signed-off-by: James Smart <james.smart@emulex.com>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>

authored by

James Smart and committed by
James Bottomley
df9e1b59 cb69f7de

+75 -19
+18 -5
drivers/scsi/lpfc/lpfc_els.c
··· 1075 1075 /* Setup CSPs accordingly for Fabric */ 1076 1076 sp->cmn.e_d_tov = 0; 1077 1077 sp->cmn.w2.r_a_tov = 0; 1078 + sp->cmn.virtual_fabric_support = 0; 1078 1079 sp->cls1.classValid = 0; 1079 1080 sp->cls2.seqDelivery = 1; 1080 1081 sp->cls3.seqDelivery = 1; ··· 3067 3066 if (did == FDMI_DID) 3068 3067 retry = 1; 3069 3068 3070 - if (((cmd == ELS_CMD_FLOGI) || (cmd == ELS_CMD_FDISC)) && 3069 + if ((cmd == ELS_CMD_FLOGI) && 3071 3070 (phba->fc_topology != LPFC_TOPOLOGY_LOOP) && 3072 3071 !lpfc_error_lost_link(irsp)) { 3073 3072 /* FLOGI retry policy */ 3074 3073 retry = 1; 3075 - /* retry forever */ 3074 + /* retry FLOGI forever */ 3076 3075 maxretry = 0; 3077 3076 if (cmdiocb->retry >= 100) 3078 3077 delay = 5000; 3079 3078 else if (cmdiocb->retry >= 32) 3080 3079 delay = 1000; 3080 + } else if ((cmd == ELS_CMD_FDISC) && !lpfc_error_lost_link(irsp)) { 3081 + /* retry FDISCs every second up to devloss */ 3082 + retry = 1; 3083 + maxretry = vport->cfg_devloss_tmo; 3084 + delay = 1000; 3081 3085 } 3082 3086 3083 3087 cmdiocb->retry++; ··· 3395 3389 3396 3390 /* 3397 3391 * The driver received a LOGO from the rport and has ACK'd it. 3398 - * At this point, the driver is done so release the IOCB and 3399 - * remove the ndlp reference. 3392 + * At this point, the driver is done so release the IOCB 3400 3393 */ 3401 3394 lpfc_els_free_iocb(phba, cmdiocb); 3402 - lpfc_nlp_put(ndlp); 3395 + 3396 + /* 3397 + * Remove the ndlp reference if it's a fabric node that has 3398 + * sent us an unsolicted LOGO. 3399 + */ 3400 + if (ndlp->nlp_type & NLP_FABRIC) 3401 + lpfc_nlp_put(ndlp); 3402 + 3403 3403 return; 3404 3404 } 3405 3405 ··· 7243 7231 /* Setup CSPs accordingly for Fabric */ 7244 7232 sp->cmn.e_d_tov = 0; 7245 7233 sp->cmn.w2.r_a_tov = 0; 7234 + sp->cmn.virtual_fabric_support = 0; 7246 7235 sp->cls1.classValid = 0; 7247 7236 sp->cls2.seqDelivery = 1; 7248 7237 sp->cls3.seqDelivery = 1;
+23 -6
drivers/scsi/lpfc/lpfc_hbadisc.c
··· 2646 2646 { 2647 2647 struct lpfc_vport *vport = mboxq->vport; 2648 2648 2649 - /* VFI not supported on interface type 0, just do the flogi */ 2650 - if (mboxq->u.mb.mbxStatus && (bf_get(lpfc_sli_intf_if_type, 2651 - &phba->sli4_hba.sli_intf) != LPFC_SLI_INTF_IF_TYPE_0)) { 2649 + /* 2650 + * VFI not supported on interface type 0, just do the flogi 2651 + * Also continue if the VFI is in use - just use the same one. 2652 + */ 2653 + if (mboxq->u.mb.mbxStatus && 2654 + (bf_get(lpfc_sli_intf_if_type, &phba->sli4_hba.sli_intf) != 2655 + LPFC_SLI_INTF_IF_TYPE_0) && 2656 + mboxq->u.mb.mbxStatus != MBX_VFI_IN_USE) { 2652 2657 lpfc_printf_vlog(vport, KERN_ERR, 2653 2658 LOG_MBOX, 2654 2659 "2891 Init VFI mailbox failed 0x%x\n", ··· 2927 2922 { 2928 2923 struct lpfc_vport *vport = phba->pport; 2929 2924 LPFC_MBOXQ_t *sparam_mbox, *cfglink_mbox = NULL; 2925 + struct Scsi_Host *shost; 2930 2926 int i; 2931 2927 struct lpfc_dmabuf *mp; 2932 2928 int rc; ··· 2951 2945 phba->fc_topology = bf_get(lpfc_mbx_read_top_topology, la); 2952 2946 phba->link_flag &= ~LS_NPIV_FAB_SUPPORTED; 2953 2947 2948 + shost = lpfc_shost_from_vport(vport); 2954 2949 if (phba->fc_topology == LPFC_TOPOLOGY_LOOP) { 2955 2950 phba->sli3_options &= ~LPFC_SLI3_NPIV_ENABLED; 2956 2951 ··· 2963 2956 "1309 Link Up Event npiv not supported in loop " 2964 2957 "topology\n"); 2965 2958 /* Get Loop Map information */ 2966 - if (bf_get(lpfc_mbx_read_top_il, la)) 2959 + if (bf_get(lpfc_mbx_read_top_il, la)) { 2960 + spin_lock_irq(shost->host_lock); 2967 2961 vport->fc_flag |= FC_LBIT; 2962 + spin_unlock_irq(shost->host_lock); 2963 + } 2968 2964 2969 2965 vport->fc_myDID = bf_get(lpfc_mbx_read_top_alpa_granted, la); 2970 2966 i = la->lilpBde64.tus.f.bdeSize; ··· 3012 3002 } else { 3013 3003 if (!(phba->sli3_options & LPFC_SLI3_NPIV_ENABLED)) { 3014 3004 if (phba->max_vpi && phba->cfg_enable_npiv && 3015 - (phba->sli_rev == 3)) 3005 + (phba->sli_rev >= LPFC_SLI_REV3)) 3016 3006 phba->sli3_options |= LPFC_SLI3_NPIV_ENABLED; 3017 3007 } 3018 3008 vport->fc_myDID = phba->fc_pref_DID; 3009 + spin_lock_irq(shost->host_lock); 3019 3010 vport->fc_flag |= FC_LBIT; 3011 + spin_unlock_irq(shost->host_lock); 3020 3012 } 3021 3013 spin_unlock_irq(&phba->hbalock); 3022 3014 ··· 3605 3593 MAILBOX_t *mb = &pmb->u.mb; 3606 3594 struct lpfc_dmabuf *mp = (struct lpfc_dmabuf *) (pmb->context1); 3607 3595 struct lpfc_nodelist *ndlp; 3596 + struct Scsi_Host *shost; 3608 3597 3609 3598 ndlp = (struct lpfc_nodelist *) pmb->context2; 3610 3599 pmb->context1 = NULL; ··· 3651 3638 * vport discovery */ 3652 3639 if (!(vport->fc_flag & FC_LOGO_RCVD_DID_CHNG)) 3653 3640 lpfc_start_fdiscs(phba); 3654 - else 3641 + else { 3642 + shost = lpfc_shost_from_vport(vport); 3643 + spin_lock_irq(shost->host_lock); 3655 3644 vport->fc_flag &= ~FC_LOGO_RCVD_DID_CHNG ; 3645 + spin_unlock_irq(shost->host_lock); 3646 + } 3656 3647 lpfc_do_scr_ns_plogi(phba, vport); 3657 3648 } 3658 3649
+6
drivers/scsi/lpfc/lpfc_hw.h
··· 349 349 * Word 1 Bit 31 in FLOGI response is clean address bit 350 350 */ 351 351 #define clean_address_bit request_multiple_Nport /* Word 1, bit 31 */ 352 + /* 353 + * Word 1 Bit 30 in common service parameter is overloaded. 354 + * Word 1 Bit 30 in FLOGI request is Virtual Fabrics 355 + * Word 1 Bit 30 in PLOGI request is random offset 356 + */ 357 + #define virtual_fabric_support randomOffset /* Word 1, bit 30 */ 352 358 #ifdef __BIG_ENDIAN_BITFIELD 353 359 uint16_t request_multiple_Nport:1; /* FC Word 1, bit 31 */ 354 360 uint16_t randomOffset:1; /* FC Word 1, bit 30 */
+2
drivers/scsi/lpfc/lpfc_hw4.h
··· 1830 1830 #define lpfc_init_vfi_hop_count_MASK 0x000000FF 1831 1831 #define lpfc_init_vfi_hop_count_WORD word4 1832 1832 }; 1833 + #define MBX_VFI_IN_USE 0x9F02 1834 + 1833 1835 1834 1836 struct lpfc_mbx_reg_vfi { 1835 1837 uint32_t word1;
+9 -1
drivers/scsi/lpfc/lpfc_nportdisc.c
··· 783 783 } 784 784 785 785 static uint32_t 786 + lpfc_device_recov_unused_node(struct lpfc_vport *vport, 787 + struct lpfc_nodelist *ndlp, 788 + void *arg, uint32_t evt) 789 + { 790 + return ndlp->nlp_state; 791 + } 792 + 793 + static uint32_t 786 794 lpfc_rcv_plogi_plogi_issue(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, 787 795 void *arg, uint32_t evt) 788 796 { ··· 2155 2147 lpfc_disc_illegal, /* CMPL_ADISC */ 2156 2148 lpfc_disc_illegal, /* CMPL_REG_LOGIN */ 2157 2149 lpfc_device_rm_unused_node, /* DEVICE_RM */ 2158 - lpfc_disc_illegal, /* DEVICE_RECOVERY */ 2150 + lpfc_device_recov_unused_node, /* DEVICE_RECOVERY */ 2159 2151 2160 2152 lpfc_rcv_plogi_plogi_issue, /* RCV_PLOGI PLOGI_ISSUE */ 2161 2153 lpfc_rcv_prli_plogi_issue, /* RCV_PRLI */
+11 -2
drivers/scsi/lpfc/lpfc_scsi.c
··· 2913 2913 int_to_scsilun(lpfc_cmd->pCmd->device->lun, 2914 2914 &lpfc_cmd->fcp_cmnd->fcp_lun); 2915 2915 2916 - memcpy(&fcp_cmnd->fcpCdb[0], scsi_cmnd->cmnd, 16); 2917 - 2916 + memset(&fcp_cmnd->fcpCdb[0], 0, LPFC_FCP_CDB_LEN); 2917 + memcpy(&fcp_cmnd->fcpCdb[0], scsi_cmnd->cmnd, scsi_cmnd->cmd_len); 2918 2918 if (scsi_populate_tag_msg(scsi_cmnd, tag)) { 2919 2919 switch (tag[0]) { 2920 2920 case HEAD_OF_QUEUE_TAG: ··· 3238 3238 cmnd->result = err; 3239 3239 goto out_fail_command; 3240 3240 } 3241 + /* 3242 + * Do not let the mid-layer retry I/O too fast. If an I/O is retried 3243 + * without waiting a bit then indicate that the device is busy. 3244 + */ 3245 + if (cmnd->retries && 3246 + time_before(jiffies, (cmnd->jiffies_at_alloc + 3247 + msecs_to_jiffies(LPFC_RETRY_PAUSE * 3248 + cmnd->retries)))) 3249 + return SCSI_MLQUEUE_DEVICE_BUSY; 3241 3250 ndlp = rdata->pnode; 3242 3251 3243 3252 if ((scsi_get_prot_op(cmnd) != SCSI_PROT_NORMAL) &&
+3 -2
drivers/scsi/lpfc/lpfc_scsi.h
··· 21 21 #include <asm/byteorder.h> 22 22 23 23 struct lpfc_hba; 24 + #define LPFC_FCP_CDB_LEN 16 24 25 25 26 #define list_remove_head(list, entry, type, member) \ 26 27 do { \ ··· 103 102 #define WRITE_DATA 0x01 /* Bit 0 */ 104 103 #define READ_DATA 0x02 /* Bit 1 */ 105 104 106 - uint8_t fcpCdb[16]; /* SRB cdb field is copied here */ 105 + uint8_t fcpCdb[LPFC_FCP_CDB_LEN]; /* SRB cdb field is copied here */ 107 106 uint32_t fcpDl; /* Total transfer length */ 108 107 109 108 }; ··· 154 153 155 154 #define LPFC_SCSI_DMA_EXT_SIZE 264 156 155 #define LPFC_BPL_SIZE 1024 157 - 156 + #define LPFC_RETRY_PAUSE 300 158 157 #define MDAC_DIRECT_CMD 0x22
+3 -3
drivers/scsi/lpfc/lpfc_vport.c
··· 774 774 return NULL; 775 775 spin_lock_irq(&phba->hbalock); 776 776 list_for_each_entry(port_iterator, &phba->port_list, listentry) { 777 + if (port_iterator->load_flag & FC_UNLOADING) 778 + continue; 777 779 if (!scsi_host_get(lpfc_shost_from_vport(port_iterator))) { 778 - if (!(port_iterator->load_flag & FC_UNLOADING)) 779 - lpfc_printf_vlog(port_iterator, KERN_ERR, 780 - LOG_VPORT, 780 + lpfc_printf_vlog(port_iterator, KERN_ERR, LOG_VPORT, 781 781 "1801 Create vport work array FAILED: " 782 782 "cannot do scsi_host_get\n"); 783 783 continue;