diff options
Diffstat (limited to 'drivers/scsi/lpfc/lpfc_nportdisc.c')
-rw-r--r-- | drivers/scsi/lpfc/lpfc_nportdisc.c | 391 |
1 files changed, 227 insertions, 164 deletions
diff --git a/drivers/scsi/lpfc/lpfc_nportdisc.c b/drivers/scsi/lpfc/lpfc_nportdisc.c index fbead786031..3d77bd999b7 100644 --- a/drivers/scsi/lpfc/lpfc_nportdisc.c +++ b/drivers/scsi/lpfc/lpfc_nportdisc.c @@ -1,7 +1,7 @@ /******************************************************************* * This file is part of the Emulex Linux Device Driver for * * Fibre Channel Host Bus Adapters. * - * Copyright (C) 2004-2005 Emulex. All rights reserved. * + * Copyright (C) 2004-2006 Emulex. All rights reserved. * * EMULEX and SLI are trademarks of Emulex. * * www.emulex.com * * Portions Copyright (C) 2004-2005 Christoph Hellwig * @@ -46,13 +46,13 @@ lpfc_check_adisc(struct lpfc_hba * phba, struct lpfc_nodelist * ndlp, * table entry for that node. */ if (memcmp(nn, &ndlp->nlp_nodename, sizeof (struct lpfc_name)) != 0) - return (0); + return 0; if (memcmp(pn, &ndlp->nlp_portname, sizeof (struct lpfc_name)) != 0) - return (0); + return 0; /* we match, return success */ - return (1); + return 1; } int @@ -150,8 +150,7 @@ lpfc_check_elscmpl_iocb(struct lpfc_hba * phba, lp = (uint32_t *) prsp->virt; ptr = (void *)((uint8_t *)lp + sizeof(uint32_t)); } - } - else { + } else { /* Force ulpStatus error since we are returning NULL ptr */ if (!(irsp->ulpStatus)) { irsp->ulpStatus = IOSTAT_LOCAL_REJECT; @@ -159,7 +158,7 @@ lpfc_check_elscmpl_iocb(struct lpfc_hba * phba, } ptr = NULL; } - return (ptr); + return ptr; } @@ -260,13 +259,9 @@ lpfc_els_abort(struct lpfc_hba * phba, struct lpfc_nodelist * ndlp, } while(found); /* If we are delaying issuing an ELS command, cancel it */ - if (ndlp->nlp_flag & NLP_DELAY_TMO) { - ndlp->nlp_flag &= ~NLP_DELAY_TMO; - del_timer_sync(&ndlp->nlp_delayfunc); - if (!list_empty(&ndlp->els_retry_evt.evt_listp)) - list_del_init(&ndlp->els_retry_evt.evt_listp); - } - return (0); + if (ndlp->nlp_flag & NLP_DELAY_TMO) + lpfc_cancel_retry_delay_tmo(phba, ndlp); + return 0; } static int @@ -300,12 +295,10 @@ lpfc_rcv_plogi(struct lpfc_hba * phba, /* Start discovery - this should just do CLEAR_LA */ lpfc_disc_start(phba); - } - else { + } else { lpfc_initial_flogi(phba); } - } - else { + } else { stat.un.b.lsRjtRsnCode = LSRJT_LOGICAL_BSY; stat.un.b.lsRjtRsnCodeExp = LSEXP_NOTHING_MORE; lpfc_els_rsp_reject(phba, stat.un.lsRjtError, cmdiocb, @@ -321,7 +314,7 @@ lpfc_rcv_plogi(struct lpfc_hba * phba, stat.un.b.lsRjtRsnCode = LSRJT_UNABLE_TPC; stat.un.b.lsRjtRsnCodeExp = LSEXP_SPARM_OPTIONS; lpfc_els_rsp_reject(phba, stat.un.lsRjtError, cmdiocb, ndlp); - return (0); + return 0; } icmd = &cmdiocb->iocb; @@ -353,7 +346,7 @@ lpfc_rcv_plogi(struct lpfc_hba * phba, ((sp->cmn.bbRcvSizeMsb & 0x0F) << 8) | sp->cmn.bbRcvSizeLsb; /* no need to reg_login if we are already in one of these states */ - switch(ndlp->nlp_state) { + switch (ndlp->nlp_state) { case NLP_STE_NPR_NODE: if (!(ndlp->nlp_flag & NLP_NPR_ADISC)) break; @@ -362,7 +355,7 @@ lpfc_rcv_plogi(struct lpfc_hba * phba, case NLP_STE_UNMAPPED_NODE: case NLP_STE_MAPPED_NODE: lpfc_els_rsp_acc(phba, ELS_CMD_PLOGI, cmdiocb, ndlp, NULL, 0); - return (1); + return 1; } if ((phba->fc_flag & FC_PT2PT) @@ -398,24 +391,16 @@ lpfc_rcv_plogi(struct lpfc_hba * phba, */ mbox->mbox_cmpl = lpfc_mbx_cmpl_reg_login; mbox->context2 = ndlp; - ndlp->nlp_flag |= NLP_ACC_REGLOGIN; + ndlp->nlp_flag |= (NLP_ACC_REGLOGIN | NLP_RCV_PLOGI); - /* If there is an outstanding PLOGI issued, abort it before - * sending ACC rsp to PLOGI recieved. - */ - if (ndlp->nlp_state == NLP_STE_PLOGI_ISSUE) { - /* software abort outstanding PLOGI */ - lpfc_els_abort(phba, ndlp, 1); - } - ndlp->nlp_flag |= NLP_RCV_PLOGI; lpfc_els_rsp_acc(phba, ELS_CMD_PLOGI, cmdiocb, ndlp, mbox, 0); - return (1); + return 1; out: stat.un.b.lsRjtRsnCode = LSRJT_UNABLE_TPC; stat.un.b.lsRjtRsnCodeExp = LSEXP_OUT_OF_RESOURCE; lpfc_els_rsp_reject(phba, stat.un.lsRjtError, cmdiocb, ndlp); - return (0); + return 0; } static int @@ -451,12 +436,11 @@ lpfc_rcv_padisc(struct lpfc_hba * phba, (lpfc_check_adisc(phba, ndlp, pnn, ppn))) { if (cmd == ELS_CMD_ADISC) { lpfc_els_rsp_adisc_acc(phba, cmdiocb, ndlp); - } - else { + } else { lpfc_els_rsp_acc(phba, ELS_CMD_PLOGI, cmdiocb, ndlp, NULL, 0); } - return (1); + return 1; } /* Reject this request because invalid parameters */ stat.un.b.lsRjtRsvd0 = 0; @@ -465,16 +449,17 @@ lpfc_rcv_padisc(struct lpfc_hba * phba, stat.un.b.vendorUnique = 0; lpfc_els_rsp_reject(phba, stat.un.lsRjtError, cmdiocb, ndlp); - ndlp->nlp_last_elscmd = (unsigned long)ELS_CMD_PLOGI; /* 1 sec timeout */ mod_timer(&ndlp->nlp_delayfunc, jiffies + HZ); spin_lock_irq(phba->host->host_lock); ndlp->nlp_flag |= NLP_DELAY_TMO; spin_unlock_irq(phba->host->host_lock); + ndlp->nlp_last_elscmd = ELS_CMD_PLOGI; + ndlp->nlp_prev_state = ndlp->nlp_state; ndlp->nlp_state = NLP_STE_NPR_NODE; lpfc_nlp_list(phba, ndlp, NLP_NPR_LIST); - return (0); + return 0; } static int @@ -489,25 +474,33 @@ lpfc_rcv_logo(struct lpfc_hba * phba, ndlp->nlp_flag |= NLP_LOGO_ACC; lpfc_els_rsp_acc(phba, ELS_CMD_ACC, cmdiocb, ndlp, NULL, 0); - if (!(ndlp->nlp_type & NLP_FABRIC)) { + if (!(ndlp->nlp_type & NLP_FABRIC) || + (ndlp->nlp_state == NLP_STE_ADISC_ISSUE)) { /* Only try to re-login if this is NOT a Fabric Node */ - ndlp->nlp_last_elscmd = (unsigned long)ELS_CMD_PLOGI; mod_timer(&ndlp->nlp_delayfunc, jiffies + HZ * 1); spin_lock_irq(phba->host->host_lock); ndlp->nlp_flag |= NLP_DELAY_TMO; spin_unlock_irq(phba->host->host_lock); - } - ndlp->nlp_state = NLP_STE_NPR_NODE; - lpfc_nlp_list(phba, ndlp, NLP_NPR_LIST); + ndlp->nlp_last_elscmd = ELS_CMD_PLOGI; + ndlp->nlp_prev_state = ndlp->nlp_state; + ndlp->nlp_state = NLP_STE_NPR_NODE; + lpfc_nlp_list(phba, ndlp, NLP_NPR_LIST); + } else { + ndlp->nlp_prev_state = ndlp->nlp_state; + ndlp->nlp_state = NLP_STE_UNUSED_NODE; + lpfc_nlp_list(phba, ndlp, NLP_UNUSED_LIST); + } + spin_lock_irq(phba->host->host_lock); ndlp->nlp_flag &= ~NLP_NPR_ADISC; + spin_unlock_irq(phba->host->host_lock); /* The driver has to wait until the ACC completes before it continues * processing the LOGO. The action will resume in * lpfc_cmpl_els_logo_acc routine. Since part of processing includes an * unreg_login, the driver waits so the ACC does not get aborted. */ - return (0); + return 0; } static void @@ -555,20 +548,12 @@ lpfc_disc_set_adisc(struct lpfc_hba * phba, if ((phba->cfg_use_adisc == 0) && !(phba->fc_flag & FC_RSCN_MODE)) { if (!(ndlp->nlp_fcp_info & NLP_FCP_2_DEVICE)) - return (0); + return 0; } spin_lock_irq(phba->host->host_lock); ndlp->nlp_flag |= NLP_NPR_ADISC; spin_unlock_irq(phba->host->host_lock); - return (1); -} - -static uint32_t -lpfc_disc_noop(struct lpfc_hba * phba, - struct lpfc_nodelist * ndlp, void *arg, uint32_t evt) -{ - /* This routine does nothing, just return the current state */ - return (ndlp->nlp_state); + return 1; } static uint32_t @@ -583,7 +568,7 @@ lpfc_disc_illegal(struct lpfc_hba * phba, phba->brd_no, ndlp->nlp_DID, evt, ndlp->nlp_state, ndlp->nlp_rpi, ndlp->nlp_flag); - return (ndlp->nlp_state); + return ndlp->nlp_state; } /* Start of Discovery State Machine routines */ @@ -597,12 +582,13 @@ lpfc_rcv_plogi_unused_node(struct lpfc_hba * phba, cmdiocb = (struct lpfc_iocbq *) arg; if (lpfc_rcv_plogi(phba, ndlp, cmdiocb)) { + ndlp->nlp_prev_state = NLP_STE_UNUSED_NODE; ndlp->nlp_state = NLP_STE_UNUSED_NODE; lpfc_nlp_list(phba, ndlp, NLP_UNUSED_LIST); - return (ndlp->nlp_state); + return ndlp->nlp_state; } lpfc_nlp_list(phba, ndlp, NLP_NO_LIST); - return (NLP_STE_FREED_NODE); + return NLP_STE_FREED_NODE; } static uint32_t @@ -611,7 +597,7 @@ lpfc_rcv_els_unused_node(struct lpfc_hba * phba, { lpfc_issue_els_logo(phba, ndlp, 0); lpfc_nlp_list(phba, ndlp, NLP_UNUSED_LIST); - return (ndlp->nlp_state); + return ndlp->nlp_state; } static uint32_t @@ -628,7 +614,7 @@ lpfc_rcv_logo_unused_node(struct lpfc_hba * phba, lpfc_els_rsp_acc(phba, ELS_CMD_ACC, cmdiocb, ndlp, NULL, 0); lpfc_nlp_list(phba, ndlp, NLP_UNUSED_LIST); - return (ndlp->nlp_state); + return ndlp->nlp_state; } static uint32_t @@ -636,7 +622,7 @@ lpfc_cmpl_logo_unused_node(struct lpfc_hba * phba, struct lpfc_nodelist * ndlp, void *arg, uint32_t evt) { lpfc_nlp_list(phba, ndlp, NLP_NO_LIST); - return (NLP_STE_FREED_NODE); + return NLP_STE_FREED_NODE; } static uint32_t @@ -644,7 +630,7 @@ lpfc_device_rm_unused_node(struct lpfc_hba * phba, struct lpfc_nodelist * ndlp, void *arg, uint32_t evt) { lpfc_nlp_list(phba, ndlp, NLP_NO_LIST); - return (NLP_STE_FREED_NODE); + return NLP_STE_FREED_NODE; } static uint32_t @@ -677,12 +663,26 @@ lpfc_rcv_plogi_plogi_issue(struct lpfc_hba * phba, struct lpfc_nodelist * ndlp, stat.un.b.lsRjtRsnCode = LSRJT_UNABLE_TPC; stat.un.b.lsRjtRsnCodeExp = LSEXP_CMD_IN_PROGRESS; lpfc_els_rsp_reject(phba, stat.un.lsRjtError, cmdiocb, ndlp); - } - else { + } else { lpfc_rcv_plogi(phba, ndlp, cmdiocb); } /* if our portname was less */ - return (ndlp->nlp_state); + return ndlp->nlp_state; +} + +static uint32_t +lpfc_rcv_logo_plogi_issue(struct lpfc_hba * phba, + struct lpfc_nodelist * ndlp, void *arg, uint32_t evt) +{ + struct lpfc_iocbq *cmdiocb; + + cmdiocb = (struct lpfc_iocbq *) arg; + + /* software abort outstanding PLOGI */ + lpfc_els_abort(phba, ndlp, 1); + + lpfc_rcv_logo(phba, ndlp, cmdiocb); + return ndlp->nlp_state; } static uint32_t @@ -695,24 +695,24 @@ lpfc_rcv_els_plogi_issue(struct lpfc_hba * phba, /* software abort outstanding PLOGI */ lpfc_els_abort(phba, ndlp, 1); - mod_timer(&ndlp->nlp_delayfunc, jiffies + HZ * 1); - spin_lock_irq(phba->host->host_lock); - ndlp->nlp_flag |= NLP_DELAY_TMO; - spin_unlock_irq(phba->host->host_lock); if (evt == NLP_EVT_RCV_LOGO) { lpfc_els_rsp_acc(phba, ELS_CMD_ACC, cmdiocb, ndlp, NULL, 0); - } - else { + } else { lpfc_issue_els_logo(phba, ndlp, 0); } /* Put ndlp in npr list set plogi timer for 1 sec */ - ndlp->nlp_last_elscmd = (unsigned long)ELS_CMD_PLOGI; + mod_timer(&ndlp->nlp_delayfunc, jiffies + HZ * 1); + spin_lock_irq(phba->host->host_lock); + ndlp->nlp_flag |= NLP_DELAY_TMO; + spin_unlock_irq(phba->host->host_lock); + ndlp->nlp_last_elscmd = ELS_CMD_PLOGI; + ndlp->nlp_prev_state = NLP_STE_PLOGI_ISSUE; ndlp->nlp_state = NLP_STE_NPR_NODE; lpfc_nlp_list(phba, ndlp, NLP_NPR_LIST); - return (ndlp->nlp_state); + return ndlp->nlp_state; } static uint32_t @@ -731,7 +731,8 @@ lpfc_cmpl_plogi_plogi_issue(struct lpfc_hba * phba, rspiocb = cmdiocb->context_un.rsp_iocb; if (ndlp->nlp_flag & NLP_ACC_REGLOGIN) { - return (ndlp->nlp_state); + /* Recovery from PLOGI collision logic */ + return ndlp->nlp_state; } irsp = &rspiocb->iocb; @@ -791,7 +792,7 @@ lpfc_cmpl_plogi_plogi_issue(struct lpfc_hba * phba, * execute first, queue this command to * be processed later. */ - switch(ndlp->nlp_DID) { + switch (ndlp->nlp_DID) { case NameServer_DID: mbox->mbox_cmpl = lpfc_mbx_cmpl_ns_reg_login; @@ -812,7 +813,7 @@ lpfc_cmpl_plogi_plogi_issue(struct lpfc_hba * phba, NLP_STE_REG_LOGIN_ISSUE; lpfc_nlp_list(phba, ndlp, NLP_REGLOGIN_LIST); - return (ndlp->nlp_state); + return ndlp->nlp_state; } mempool_free(mbox, phba->mbox_mem_pool); } else { @@ -824,7 +825,7 @@ lpfc_cmpl_plogi_plogi_issue(struct lpfc_hba * phba, /* Free this node since the driver cannot login or has the wrong sparm */ lpfc_nlp_list(phba, ndlp, NLP_NO_LIST); - return (NLP_STE_FREED_NODE); + return NLP_STE_FREED_NODE; } static uint32_t @@ -835,7 +836,7 @@ lpfc_device_rm_plogi_issue(struct lpfc_hba * phba, lpfc_els_abort(phba, ndlp, 1); lpfc_nlp_list(phba, ndlp, NLP_NO_LIST); - return (NLP_STE_FREED_NODE); + return NLP_STE_FREED_NODE; } static uint32_t @@ -846,13 +847,14 @@ lpfc_device_recov_plogi_issue(struct lpfc_hba * phba, /* software abort outstanding PLOGI */ lpfc_els_abort(phba, ndlp, 1); + ndlp->nlp_prev_state = NLP_STE_PLOGI_ISSUE; ndlp->nlp_state = NLP_STE_NPR_NODE; lpfc_nlp_list(phba, ndlp, NLP_NPR_LIST); spin_lock_irq(phba->host->host_lock); ndlp->nlp_flag &= ~NLP_NPR_2B_DISC; spin_unlock_irq(phba->host->host_lock); - return (ndlp->nlp_state); + return ndlp->nlp_state; } static uint32_t @@ -868,13 +870,14 @@ lpfc_rcv_plogi_adisc_issue(struct lpfc_hba * phba, cmdiocb = (struct lpfc_iocbq *) arg; if (lpfc_rcv_plogi(phba, ndlp, cmdiocb)) { - return (ndlp->nlp_state); + return ndlp->nlp_state; } + ndlp->nlp_prev_state = NLP_STE_ADISC_ISSUE; ndlp->nlp_state = NLP_STE_PLOGI_ISSUE; lpfc_nlp_list(phba, ndlp, NLP_PLOGI_LIST); - lpfc_issue_els_plogi(phba, ndlp, 0); + lpfc_issue_els_plogi(phba, ndlp->nlp_DID, 0); - return (ndlp->nlp_state); + return ndlp->nlp_state; } static uint32_t @@ -887,7 +890,7 @@ lpfc_rcv_prli_adisc_issue(struct lpfc_hba * phba, cmdiocb = (struct lpfc_iocbq *) arg; lpfc_els_rsp_prli_acc(phba, cmdiocb, ndlp); - return (ndlp->nlp_state); + return ndlp->nlp_state; } static uint32_t @@ -903,7 +906,7 @@ lpfc_rcv_logo_adisc_issue(struct lpfc_hba * phba, lpfc_els_abort(phba, ndlp, 0); lpfc_rcv_logo(phba, ndlp, cmdiocb); - return (ndlp->nlp_state); + return ndlp->nlp_state; } static uint32_t @@ -916,7 +919,7 @@ lpfc_rcv_padisc_adisc_issue(struct lpfc_hba * phba, cmdiocb = (struct lpfc_iocbq *) arg; lpfc_rcv_padisc(phba, ndlp, cmdiocb); - return (ndlp->nlp_state); + return ndlp->nlp_state; } static uint32_t @@ -930,7 +933,7 @@ lpfc_rcv_prlo_adisc_issue(struct lpfc_hba * phba, /* Treat like rcv logo */ lpfc_rcv_logo(phba, ndlp, cmdiocb); - return (ndlp->nlp_state); + return ndlp->nlp_state; } static uint32_t @@ -950,29 +953,33 @@ lpfc_cmpl_adisc_adisc_issue(struct lpfc_hba * phba, if ((irsp->ulpStatus) || (!lpfc_check_adisc(phba, ndlp, &ap->nodeName, &ap->portName))) { - ndlp->nlp_last_elscmd = (unsigned long)ELS_CMD_PLOGI; /* 1 sec timeout */ mod_timer(&ndlp->nlp_delayfunc, jiffies + HZ); spin_lock_irq(phba->host->host_lock); ndlp->nlp_flag |= NLP_DELAY_TMO; spin_unlock_irq(phba->host->host_lock); + ndlp->nlp_last_elscmd = ELS_CMD_PLOGI; memset(&ndlp->nlp_nodename, 0, sizeof (struct lpfc_name)); memset(&ndlp->nlp_portname, 0, sizeof (struct lpfc_name)); + ndlp->nlp_prev_state = NLP_STE_ADISC_ISSUE; ndlp->nlp_state = NLP_STE_NPR_NODE; lpfc_nlp_list(phba, ndlp, NLP_NPR_LIST); lpfc_unreg_rpi(phba, ndlp); - return (ndlp->nlp_state); + return ndlp->nlp_state; } + if (ndlp->nlp_type & NLP_FCP_TARGET) { + ndlp->nlp_prev_state = NLP_STE_ADISC_ISSUE; ndlp->nlp_state = NLP_STE_MAPPED_NODE; lpfc_nlp_list(phba, ndlp, NLP_MAPPED_LIST); } else { + ndlp->nlp_prev_state = NLP_STE_ADISC_ISSUE; ndlp->nlp_state = NLP_STE_UNMAPPED_NODE; lpfc_nlp_list(phba, ndlp, NLP_UNMAPPED_LIST); } - return (ndlp->nlp_state); + return ndlp->nlp_state; } static uint32_t @@ -984,7 +991,7 @@ lpfc_device_rm_adisc_issue(struct lpfc_hba * phba, lpfc_els_abort(phba, ndlp, 1); lpfc_nlp_list(phba, ndlp, NLP_NO_LIST); - return (NLP_STE_FREED_NODE); + return NLP_STE_FREED_NODE; } static uint32_t @@ -995,14 +1002,15 @@ lpfc_device_recov_adisc_issue(struct lpfc_hba * phba, /* software abort outstanding ADISC */ lpfc_els_abort(phba, ndlp, 1); + ndlp->nlp_prev_state = NLP_STE_ADISC_ISSUE; ndlp->nlp_state = NLP_STE_NPR_NODE; lpfc_nlp_list(phba, ndlp, NLP_NPR_LIST); spin_lock_irq(phba->host->host_lock); ndlp->nlp_flag &= ~NLP_NPR_2B_DISC; + ndlp->nlp_flag |= NLP_NPR_ADISC; spin_unlock_irq(phba->host->host_lock); - lpfc_disc_set_adisc(phba, ndlp); - return (ndlp->nlp_state); + return ndlp->nlp_state; } static uint32_t @@ -1015,7 +1023,7 @@ lpfc_rcv_plogi_reglogin_issue(struct lpfc_hba * phba, cmdiocb = (struct lpfc_iocbq *) arg; lpfc_rcv_plogi(phba, ndlp, cmdiocb); - return (ndlp->nlp_state); + return ndlp->nlp_state; } static uint32_t @@ -1028,7 +1036,7 @@ lpfc_rcv_prli_reglogin_issue(struct lpfc_hba * phba, cmdiocb = (struct lpfc_iocbq *) arg; lpfc_els_rsp_prli_acc(phba, cmdiocb, ndlp); - return (ndlp->nlp_state); + return ndlp->nlp_state; } static uint32_t @@ -1041,7 +1049,7 @@ lpfc_rcv_logo_reglogin_issue(struct lpfc_hba * phba, cmdiocb = (struct lpfc_iocbq *) arg; lpfc_rcv_logo(phba, ndlp, cmdiocb); - return (ndlp->nlp_state); + return ndlp->nlp_state; } static uint32_t @@ -1054,7 +1062,7 @@ lpfc_rcv_padisc_reglogin_issue(struct lpfc_hba * phba, cmdiocb = (struct lpfc_iocbq *) arg; lpfc_rcv_padisc(phba, ndlp, cmdiocb); - return (ndlp->nlp_state); + return ndlp->nlp_state; } static uint32_t @@ -1066,7 +1074,7 @@ lpfc_rcv_prlo_reglogin_issue(struct lpfc_hba * phba, cmdiocb = (struct lpfc_iocbq *) arg; lpfc_els_rsp_acc(phba, ELS_CMD_ACC, cmdiocb, ndlp, NULL, 0); - return (ndlp->nlp_state); + return ndlp->nlp_state; } static uint32_t @@ -1090,31 +1098,34 @@ lpfc_cmpl_reglogin_reglogin_issue(struct lpfc_hba * phba, phba->brd_no, did, mb->mbxStatus, phba->hba_state); + /* Put ndlp in npr list set plogi timer for 1 sec */ mod_timer(&ndlp->nlp_delayfunc, jiffies + HZ * 1); spin_lock_irq(phba->host->host_lock); ndlp->nlp_flag |= NLP_DELAY_TMO; spin_unlock_irq(phba->host->host_lock); + ndlp->nlp_last_elscmd = ELS_CMD_PLOGI; lpfc_issue_els_logo(phba, ndlp, 0); - /* Put ndlp in npr list set plogi timer for 1 sec */ - ndlp->nlp_last_elscmd = (unsigned long)ELS_CMD_PLOGI; + ndlp->nlp_prev_state = NLP_STE_REG_LOGIN_ISSUE; ndlp->nlp_state = NLP_STE_NPR_NODE; lpfc_nlp_list(phba, ndlp, NLP_NPR_LIST); - return (ndlp->nlp_state); + return ndlp->nlp_state; } ndlp->nlp_rpi = mb->un.varWords[0]; /* Only if we are not a fabric nport do we issue PRLI */ if (!(ndlp->nlp_type & NLP_FABRIC)) { + ndlp->nlp_prev_state = NLP_STE_REG_LOGIN_ISSUE; ndlp->nlp_state = NLP_STE_PRLI_ISSUE; lpfc_nlp_list(phba, ndlp, NLP_PRLI_LIST); lpfc_issue_els_prli(phba, ndlp, 0); } else { + ndlp->nlp_prev_state = NLP_STE_REG_LOGIN_ISSUE; ndlp->nlp_state = NLP_STE_UNMAPPED_NODE; lpfc_nlp_list(phba, ndlp, NLP_UNMAPPED_LIST); } - return (ndlp->nlp_state); + return ndlp->nlp_state; } static uint32_t @@ -1123,7 +1134,7 @@ lpfc_device_rm_reglogin_issue(struct lpfc_hba * phba, uint32_t evt) { lpfc_nlp_list(phba, ndlp, NLP_NO_LIST); - return (NLP_STE_FREED_NODE); + return NLP_STE_FREED_NODE; } static uint32_t @@ -1131,12 +1142,13 @@ lpfc_device_recov_reglogin_issue(struct lpfc_hba * phba, struct lpfc_nodelist * ndlp, void *arg, uint32_t evt) { + ndlp->nlp_prev_state = NLP_STE_REG_LOGIN_ISSUE; ndlp->nlp_state = NLP_STE_NPR_NODE; lpfc_nlp_list(phba, ndlp, NLP_NPR_LIST); spin_lock_irq(phba->host->host_lock); ndlp->nlp_flag &= ~NLP_NPR_2B_DISC; spin_unlock_irq(phba->host->host_lock); - return (ndlp->nlp_state); + return ndlp->nlp_state; } static uint32_t @@ -1148,7 +1160,7 @@ lpfc_rcv_plogi_prli_issue(struct lpfc_hba * phba, cmdiocb = (struct lpfc_iocbq *) arg; lpfc_rcv_plogi(phba, ndlp, cmdiocb); - return (ndlp->nlp_state); + return ndlp->nlp_state; } static uint32_t @@ -1160,7 +1172,7 @@ lpfc_rcv_prli_prli_issue(struct lpfc_hba * phba, cmdiocb = (struct lpfc_iocbq *) arg; lpfc_els_rsp_prli_acc(phba, cmdiocb, ndlp); - return (ndlp->nlp_state); + return ndlp->nlp_state; } static uint32_t @@ -1175,7 +1187,7 @@ lpfc_rcv_logo_prli_issue(struct lpfc_hba * phba, lpfc_els_abort(phba, ndlp, 1); lpfc_rcv_logo(phba, ndlp, cmdiocb); - return (ndlp->nlp_state); + return ndlp->nlp_state; } static uint32_t @@ -1187,7 +1199,7 @@ lpfc_rcv_padisc_prli_issue(struct lpfc_hba * phba, cmdiocb = (struct lpfc_iocbq *) arg; lpfc_rcv_padisc(phba, ndlp, cmdiocb); - return (ndlp->nlp_state); + return ndlp->nlp_state; } /* This routine is envoked when we rcv a PRLO request from a nport @@ -1203,7 +1215,7 @@ lpfc_rcv_prlo_prli_issue(struct lpfc_hba * phba, cmdiocb = (struct lpfc_iocbq *) arg; lpfc_els_rsp_acc(phba, ELS_CMD_ACC, cmdiocb, ndlp, NULL, 0); - return (ndlp->nlp_state); + return ndlp->nlp_state; } static uint32_t @@ -1220,9 +1232,10 @@ lpfc_cmpl_prli_prli_issue(struct lpfc_hba * phba, irsp = &rspiocb->iocb; if (irsp->ulpStatus) { + ndlp->nlp_prev_state = NLP_STE_PRLI_ISSUE; ndlp->nlp_state = NLP_STE_UNMAPPED_NODE; lpfc_nlp_list(phba, ndlp, NLP_UNMAPPED_LIST); - return (ndlp->nlp_state); + return ndlp->nlp_state; } /* Check out PRLI rsp */ @@ -1238,9 +1251,10 @@ lpfc_cmpl_prli_prli_issue(struct lpfc_hba * phba, ndlp->nlp_fcp_info |= NLP_FCP_2_DEVICE; } + ndlp->nlp_prev_state = NLP_STE_PRLI_ISSUE; ndlp->nlp_state = NLP_STE_MAPPED_NODE; lpfc_nlp_list(phba, ndlp, NLP_MAPPED_LIST); - return (ndlp->nlp_state); + return ndlp->nlp_state; } /*! lpfc_device_rm_prli_issue @@ -1268,7 +1282,7 @@ lpfc_device_rm_prli_issue(struct lpfc_hba * phba, lpfc_els_abort(phba, ndlp, 1); lpfc_nlp_list(phba, ndlp, NLP_NO_LIST); - return (NLP_STE_FREED_NODE); + return NLP_STE_FREED_NODE; } @@ -1295,12 +1309,13 @@ lpfc_device_recov_prli_issue(struct lpfc_hba * phba, /* software abort outstanding PRLI */ lpfc_els_abort(phba, ndlp, 1); + ndlp->nlp_prev_state = NLP_STE_PRLI_ISSUE; ndlp->nlp_state = NLP_STE_NPR_NODE; lpfc_nlp_list(phba, ndlp, NLP_NPR_LIST); spin_lock_irq(phba->host->host_lock); ndlp->nlp_flag &= ~NLP_NPR_2B_DISC; spin_unlock_irq(phba->host->host_lock); - return (ndlp->nlp_state); + return ndlp->nlp_state; } static uint32_t @@ -1312,7 +1327,7 @@ lpfc_rcv_plogi_unmap_node(struct lpfc_hba * phba, cmdiocb = (struct lpfc_iocbq *) arg; lpfc_rcv_plogi(phba, ndlp, cmdiocb); - return (ndlp->nlp_state); + return ndlp->nlp_state; } static uint32_t @@ -1325,7 +1340,7 @@ lpfc_rcv_prli_unmap_node(struct lpfc_hba * phba, lpfc_rcv_prli(phba, ndlp, cmdiocb); lpfc_els_rsp_prli_acc(phba, cmdiocb, ndlp); - return (ndlp->nlp_state); + return ndlp->nlp_state; } static uint32_t @@ -1337,7 +1352,7 @@ lpfc_rcv_logo_unmap_node(struct lpfc_hba * phba, cmdiocb = (struct lpfc_iocbq *) arg; lpfc_rcv_logo(phba, ndlp, cmdiocb); - return (ndlp->nlp_state); + return ndlp->nlp_state; } static uint32_t @@ -1349,7 +1364,7 @@ lpfc_rcv_padisc_unmap_node(struct lpfc_hba * phba, cmdiocb = (struct lpfc_iocbq *) arg; lpfc_rcv_padisc(phba, ndlp, cmdiocb); - return (ndlp->nlp_state); + return ndlp->nlp_state; } static uint32_t @@ -1360,21 +1375,21 @@ lpfc_rcv_prlo_unmap_node(struct lpfc_hba * phba, cmdiocb = (struct lpfc_iocbq *) arg; - /* Treat like rcv logo */ - lpfc_rcv_logo(phba, ndlp, cmdiocb); - return (ndlp->nlp_state); + lpfc_els_rsp_acc(phba, ELS_CMD_ACC, cmdiocb, ndlp, NULL, 0); + return ndlp->nlp_state; } static uint32_t lpfc_device_recov_unmap_node(struct lpfc_hba * phba, struct lpfc_nodelist * ndlp, void *arg, uint32_t evt) { + ndlp->nlp_prev_state = NLP_STE_UNMAPPED_NODE; ndlp->nlp_state = NLP_STE_NPR_NODE; lpfc_nlp_list(phba, ndlp, NLP_NPR_LIST); ndlp->nlp_flag &= ~NLP_NPR_2B_DISC; lpfc_disc_set_adisc(phba, ndlp); - return (ndlp->nlp_state); + return ndlp->nlp_state; } static uint32_t @@ -1386,7 +1401,7 @@ lpfc_rcv_plogi_mapped_node(struct lpfc_hba * phba, cmdiocb = (struct lpfc_iocbq *) arg; lpfc_rcv_plogi(phba, ndlp, cmdiocb); - return (ndlp->nlp_state); + return ndlp->nlp_state; } static uint32_t @@ -1398,7 +1413,7 @@ lpfc_rcv_prli_mapped_node(struct lpfc_hba * phba, cmdiocb = (struct lpfc_iocbq *) arg; lpfc_els_rsp_prli_acc(phba, cmdiocb, ndlp); - return (ndlp->nlp_state); + return ndlp->nlp_state; } static uint32_t @@ -1410,7 +1425,7 @@ lpfc_rcv_logo_mapped_node(struct lpfc_hba * phba, cmdiocb = (struct lpfc_iocbq *) arg; lpfc_rcv_logo(phba, ndlp, cmdiocb); - return (ndlp->nlp_state); + return ndlp->nlp_state; } static uint32_t @@ -1423,7 +1438,7 @@ lpfc_rcv_padisc_mapped_node(struct lpfc_hba * phba, cmdiocb = (struct lpfc_iocbq *) arg; lpfc_rcv_padisc(phba, ndlp, cmdiocb); - return (ndlp->nlp_state); + return ndlp->nlp_state; } static uint32_t @@ -1442,7 +1457,7 @@ lpfc_rcv_prlo_mapped_node(struct lpfc_hba * phba, /* Treat like rcv logo */ lpfc_rcv_logo(phba, ndlp, cmdiocb); - return (ndlp->nlp_state); + return ndlp->nlp_state; } static uint32_t @@ -1450,13 +1465,14 @@ lpfc_device_recov_mapped_node(struct lpfc_hba * phba, struct lpfc_nodelist * ndlp, void *arg, uint32_t evt) { + ndlp->nlp_prev_state = NLP_STE_MAPPED_NODE; ndlp->nlp_state = NLP_STE_NPR_NODE; lpfc_nlp_list(phba, ndlp, NLP_NPR_LIST); spin_lock_irq(phba->host->host_lock); ndlp->nlp_flag &= ~NLP_NPR_2B_DISC; spin_unlock_irq(phba->host->host_lock); lpfc_disc_set_adisc(phba, ndlp); - return (ndlp->nlp_state); + return ndlp->nlp_state; } static uint32_t @@ -1470,23 +1486,25 @@ lpfc_rcv_plogi_npr_node(struct lpfc_hba * phba, /* Ignore PLOGI if we have an outstanding LOGO */ if (ndlp->nlp_flag & NLP_LOGO_SND) { - return (ndlp->nlp_state); + return ndlp->nlp_state; } if (lpfc_rcv_plogi(phba, ndlp, cmdiocb)) { spin_lock_irq(phba->host->host_lock); - ndlp->nlp_flag &= ~(NLP_NPR_ADISC | NLP_NPR_2B_DISC); + ndlp->nlp_flag &= ~NLP_NPR_ADISC; spin_unlock_irq(phba->host->host_lock); - return (ndlp->nlp_state); + return ndlp->nlp_state; } /* send PLOGI immediately, move to PLOGI issue state */ if (!(ndlp->nlp_flag & NLP_DELAY_TMO)) { - ndlp->nlp_state = NLP_STE_PLOGI_ISSUE; - lpfc_nlp_list(phba, ndlp, NLP_PLOGI_LIST); - lpfc_issue_els_plogi(phba, ndlp, 0); + ndlp->nlp_prev_state = NLP_STE_NPR_NODE; + ndlp->nlp_state = NLP_STE_PLOGI_ISSUE; + lpfc_nlp_list(phba, ndlp, NLP_PLOGI_LIST); + lpfc_issue_els_plogi(phba, ndlp->nlp_DID, 0); } - return (ndlp->nlp_state); + + return ndlp->nlp_state; } static uint32_t @@ -1506,16 +1524,22 @@ lpfc_rcv_prli_npr_node(struct lpfc_hba * phba, if (!(ndlp->nlp_flag & NLP_DELAY_TMO)) { if (ndlp->nlp_flag & NLP_NPR_ADISC) { + spin_lock_irq(phba->host->host_lock); + ndlp->nlp_flag &= ~NLP_NPR_ADISC; + spin_unlock_irq(phba->host->host_lock); + ndlp->nlp_prev_state = NLP_STE_NPR_NODE; ndlp->nlp_state = NLP_STE_ADISC_ISSUE; lpfc_nlp_list(phba, ndlp, NLP_ADISC_LIST); lpfc_issue_els_adisc(phba, ndlp, 0); } else { + ndlp->nlp_prev_state = NLP_STE_NPR_NODE; ndlp->nlp_state = NLP_STE_PLOGI_ISSUE; lpfc_nlp_list(phba, ndlp, NLP_PLOGI_LIST); - lpfc_issue_els_plogi(phba, ndlp, 0); + lpfc_issue_els_plogi(phba, ndlp->nlp_DID, 0); } + } - return (ndlp->nlp_state); + return ndlp->nlp_state; } static uint32_t @@ -1528,7 +1552,7 @@ lpfc_rcv_logo_npr_node(struct lpfc_hba * phba, cmdiocb = (struct lpfc_iocbq *) arg; lpfc_rcv_logo(phba, ndlp, cmdiocb); - return (ndlp->nlp_state); + return ndlp->nlp_state; } static uint32_t @@ -1544,16 +1568,18 @@ lpfc_rcv_padisc_npr_node(struct lpfc_hba * phba, if (!(ndlp->nlp_flag & NLP_DELAY_TMO)) { if (ndlp->nlp_flag & NLP_NPR_ADISC) { + ndlp->nlp_prev_state = NLP_STE_NPR_NODE; ndlp->nlp_state = NLP_STE_ADISC_ISSUE; lpfc_nlp_list(phba, ndlp, NLP_ADISC_LIST); lpfc_issue_els_adisc(phba, ndlp, 0); } else { + ndlp->nlp_prev_state = NLP_STE_NPR_NODE; ndlp->nlp_state = NLP_STE_PLOGI_ISSUE; lpfc_nlp_list(phba, ndlp, NLP_PLOGI_LIST); - lpfc_issue_els_plogi(phba, ndlp, 0); + lpfc_issue_els_plogi(phba, ndlp->nlp_DID, 0); } } - return (ndlp->nlp_state); + return ndlp->nlp_state; } static uint32_t @@ -1565,25 +1591,47 @@ lpfc_rcv_prlo_npr_node(struct lpfc_hba * phba, cmdiocb = (struct lpfc_iocbq *) arg; + spin_lock_irq(phba->host->host_lock); + ndlp->nlp_flag |= NLP_LOGO_ACC; + spin_unlock_irq(phba->host->host_lock); + lpfc_els_rsp_acc(phba, ELS_CMD_ACC, cmdiocb, ndlp, NULL, 0); - if (ndlp->nlp_flag & NLP_DELAY_TMO) { - if (ndlp->nlp_last_elscmd == (unsigned long)ELS_CMD_PLOGI) { - return (ndlp->nlp_state); - } else { - spin_lock_irq(phba->host->host_lock); - ndlp->nlp_flag &= ~NLP_DELAY_TMO; - spin_unlock_irq(phba->host->host_lock); - del_timer_sync(&ndlp->nlp_delayfunc); - if (!list_empty(&ndlp->els_retry_evt.evt_listp)) - list_del_init(&ndlp->els_retry_evt.evt_listp); - } + if (!(ndlp->nlp_flag & NLP_DELAY_TMO)) { + mod_timer(&ndlp->nlp_delayfunc, jiffies + HZ * 1); + spin_lock_irq(phba->host->host_lock); + ndlp->nlp_flag |= NLP_DELAY_TMO; + ndlp->nlp_flag &= ~NLP_NPR_ADISC; + spin_unlock_irq(phba->host->host_lock); + ndlp->nlp_last_elscmd = ELS_CMD_PLOGI; + } else { + spin_lock_irq(phba->host->host_lock); + ndlp->nlp_flag &= ~NLP_NPR_ADISC; + spin_unlock_irq(phba->host->host_lock); } + return ndlp->nlp_state; +} - ndlp->nlp_state = NLP_STE_PLOGI_ISSUE; - lpfc_nlp_list(phba, ndlp, NLP_PLOGI_LIST); - lpfc_issue_els_plogi(phba, ndlp, 0); - return (ndlp->nlp_state); +static uint32_t +lpfc_cmpl_plogi_npr_node(struct lpfc_hba * phba, + struct lpfc_nodelist * ndlp, void *arg, uint32_t evt) +{ + struct lpfc_iocbq *cmdiocb, *rspiocb; + + cmdiocb = (struct lpfc_iocbq *) arg; + rspiocb = cmdiocb->context_un.rsp_iocb; + return ndlp->nlp_state; +} + +static uint32_t +lpfc_cmpl_prli_npr_node(struct lpfc_hba * phba, + struct lpfc_nodelist * ndlp, void *arg, uint32_t evt) +{ + struct lpfc_iocbq *cmdiocb, *rspiocb; + + cmdiocb = (struct lpfc_iocbq *) arg; + rspiocb = cmdiocb->context_un.rsp_iocb; + return ndlp->nlp_state; } static uint32_t @@ -1592,7 +1640,19 @@ lpfc_cmpl_logo_npr_node(struct lpfc_hba * phba, { lpfc_unreg_rpi(phba, ndlp); /* This routine does nothing, just return the current state */ - return (ndlp->nlp_state); + return ndlp->nlp_state; +} + +static uint32_t +lpfc_cmpl_adisc_npr_node(struct lpfc_hba * phba, + struct lpfc_nodelist * ndlp, void *arg, + uint32_t evt) +{ + struct lpfc_iocbq *cmdiocb, *rspiocb; + + cmdiocb = (struct lpfc_iocbq *) arg; + rspiocb = cmdiocb->context_un.rsp_iocb; + return ndlp->nlp_state; } static uint32_t @@ -1606,9 +1666,10 @@ lpfc_cmpl_reglogin_npr_node(struct lpfc_hba * phba, pmb = (LPFC_MBOXQ_t *) arg; mb = &pmb->mb; - ndlp->nlp_rpi = mb->un.varWords[0]; + if (!mb->mbxStatus) + ndlp->nlp_rpi = mb->un.varWords[0]; - return (ndlp->nlp_state); + return ndlp->nlp_state; } static uint32_t @@ -1617,7 +1678,7 @@ lpfc_device_rm_npr_node(struct lpfc_hba * phba, uint32_t evt) { lpfc_nlp_list(phba, ndlp, NLP_NO_LIST); - return (NLP_STE_FREED_NODE); + return NLP_STE_FREED_NODE; } static uint32_t @@ -1628,7 +1689,10 @@ lpfc_device_recov_npr_node(struct lpfc_hba * phba, spin_lock_irq(phba->host->host_lock); ndlp->nlp_flag &= ~NLP_NPR_2B_DISC; spin_unlock_irq(phba->host->host_lock); - return (ndlp->nlp_state); + if (ndlp->nlp_flag & NLP_DELAY_TMO) { + lpfc_cancel_retry_delay_tmo(phba, ndlp); + } + return ndlp->nlp_state; } @@ -1707,7 +1771,7 @@ static uint32_t (*lpfc_disc_action[NLP_STE_MAX_STATE * NLP_EVT_MAX_EVENT]) lpfc_rcv_plogi_plogi_issue, /* RCV_PLOGI PLOGI_ISSUE */ lpfc_rcv_els_plogi_issue, /* RCV_PRLI */ - lpfc_rcv_els_plogi_issue, /* RCV_LOGO */ + lpfc_rcv_logo_plogi_issue, /* RCV_LOGO */ lpfc_rcv_els_plogi_issue, /* RCV_ADISC */ lpfc_rcv_els_plogi_issue, /* RCV_PDISC */ lpfc_rcv_els_plogi_issue, /* RCV_PRLO */ @@ -1795,10 +1859,10 @@ static uint32_t (*lpfc_disc_action[NLP_STE_MAX_STATE * NLP_EVT_MAX_EVENT]) lpfc_rcv_padisc_npr_node, /* RCV_ADISC */ lpfc_rcv_padisc_npr_node, /* RCV_PDISC */ lpfc_rcv_prlo_npr_node, /* RCV_PRLO */ - lpfc_disc_noop, /* CMPL_PLOGI */ - lpfc_disc_noop, /* CMPL_PRLI */ + lpfc_cmpl_plogi_npr_node, /* CMPL_PLOGI */ + lpfc_cmpl_prli_npr_node, /* CMPL_PRLI */ lpfc_cmpl_logo_npr_node, /* CMPL_LOGO */ - lpfc_disc_noop, /* CMPL_ADISC */ + lpfc_cmpl_adisc_npr_node, /* CMPL_ADISC */ lpfc_cmpl_reglogin_npr_node, /* CMPL_REG_LOGIN */ lpfc_device_rm_npr_node, /* DEVICE_RM */ lpfc_device_recov_npr_node, /* DEVICE_RECOVERY */ @@ -1844,10 +1908,9 @@ lpfc_disc_state_machine(struct lpfc_hba * phba, ndlp->nlp_flag &= ~NLP_DELAY_REMOVE; spin_unlock_irq(phba->host->host_lock); lpfc_nlp_remove(phba, ndlp); - return (NLP_STE_FREED_NODE); + return NLP_STE_FREED_NODE; } if (rc == NLP_STE_FREED_NODE) - return (NLP_STE_FREED_NODE); - ndlp->nlp_state = rc; - return (rc); + return NLP_STE_FREED_NODE; + return rc; } |