aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/lpfc/lpfc_nportdisc.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/scsi/lpfc/lpfc_nportdisc.c')
-rw-r--r--drivers/scsi/lpfc/lpfc_nportdisc.c307
1 files changed, 128 insertions, 179 deletions
diff --git a/drivers/scsi/lpfc/lpfc_nportdisc.c b/drivers/scsi/lpfc/lpfc_nportdisc.c
index 0c7e731dc45a..b309841e3846 100644
--- a/drivers/scsi/lpfc/lpfc_nportdisc.c
+++ b/drivers/scsi/lpfc/lpfc_nportdisc.c
@@ -1,7 +1,7 @@
1/******************************************************************* 1/*******************************************************************
2 * This file is part of the Emulex Linux Device Driver for * 2 * This file is part of the Emulex Linux Device Driver for *
3 * Fibre Channel Host Bus Adapters. * 3 * Fibre Channel Host Bus Adapters. *
4 * Copyright (C) 2004-2006 Emulex. All rights reserved. * 4 * Copyright (C) 2004-2007 Emulex. All rights reserved. *
5 * EMULEX and SLI are trademarks of Emulex. * 5 * EMULEX and SLI are trademarks of Emulex. *
6 * www.emulex.com * 6 * www.emulex.com *
7 * Portions Copyright (C) 2004-2005 Christoph Hellwig * 7 * Portions Copyright (C) 2004-2005 Christoph Hellwig *
@@ -168,14 +168,13 @@ lpfc_check_elscmpl_iocb(struct lpfc_hba * phba,
168 * routine effectively results in a "software abort". 168 * routine effectively results in a "software abort".
169 */ 169 */
170int 170int
171lpfc_els_abort(struct lpfc_hba * phba, struct lpfc_nodelist * ndlp, 171lpfc_els_abort(struct lpfc_hba * phba, struct lpfc_nodelist * ndlp)
172 int send_abts)
173{ 172{
173 LIST_HEAD(completions);
174 struct lpfc_sli *psli; 174 struct lpfc_sli *psli;
175 struct lpfc_sli_ring *pring; 175 struct lpfc_sli_ring *pring;
176 struct lpfc_iocbq *iocb, *next_iocb; 176 struct lpfc_iocbq *iocb, *next_iocb;
177 IOCB_t *icmd; 177 IOCB_t *cmd;
178 int found = 0;
179 178
180 /* Abort outstanding I/O on NPort <nlp_DID> */ 179 /* Abort outstanding I/O on NPort <nlp_DID> */
181 lpfc_printf_log(phba, KERN_INFO, LOG_DISCOVERY, 180 lpfc_printf_log(phba, KERN_INFO, LOG_DISCOVERY,
@@ -188,75 +187,39 @@ lpfc_els_abort(struct lpfc_hba * phba, struct lpfc_nodelist * ndlp,
188 pring = &psli->ring[LPFC_ELS_RING]; 187 pring = &psli->ring[LPFC_ELS_RING];
189 188
190 /* First check the txq */ 189 /* First check the txq */
191 do { 190 spin_lock_irq(phba->host->host_lock);
192 found = 0; 191 list_for_each_entry_safe(iocb, next_iocb, &pring->txq, list) {
193 spin_lock_irq(phba->host->host_lock); 192 /* Check to see if iocb matches the nport we are looking
194 list_for_each_entry_safe(iocb, next_iocb, &pring->txq, list) { 193 for */
195 /* Check to see if iocb matches the nport we are looking 194 if (lpfc_check_sli_ndlp(phba, pring, iocb, ndlp)) {
196 for */ 195 /* It matches, so deque and call compl with an
197 if ((lpfc_check_sli_ndlp(phba, pring, iocb, ndlp))) { 196 error */
198 found = 1; 197 list_move_tail(&iocb->list, &completions);
199 /* It matches, so deque and call compl with an 198 pring->txq_cnt--;
200 error */
201 list_del(&iocb->list);
202 pring->txq_cnt--;
203 if (iocb->iocb_cmpl) {
204 icmd = &iocb->iocb;
205 icmd->ulpStatus = IOSTAT_LOCAL_REJECT;
206 icmd->un.ulpWord[4] = IOERR_SLI_ABORTED;
207 spin_unlock_irq(phba->host->host_lock);
208 (iocb->iocb_cmpl) (phba, iocb, iocb);
209 spin_lock_irq(phba->host->host_lock);
210 } else
211 lpfc_sli_release_iocbq(phba, iocb);
212 break;
213 }
214 } 199 }
215 spin_unlock_irq(phba->host->host_lock); 200 }
216 } while (found);
217 201
218 /* Everything on txcmplq will be returned by firmware
219 * with a no rpi / linkdown / abort error. For ring 0,
220 * ELS discovery, we want to get rid of it right here.
221 */
222 /* Next check the txcmplq */ 202 /* Next check the txcmplq */
223 do { 203 list_for_each_entry_safe(iocb, next_iocb, &pring->txcmplq, list) {
224 found = 0; 204 /* Check to see if iocb matches the nport we are looking
225 spin_lock_irq(phba->host->host_lock); 205 for */
226 list_for_each_entry_safe(iocb, next_iocb, &pring->txcmplq, 206 if (lpfc_check_sli_ndlp(phba, pring, iocb, ndlp))
227 list) { 207 lpfc_sli_issue_abort_iotag(phba, pring, iocb);
228 /* Check to see if iocb matches the nport we are looking 208 }
229 for */ 209 spin_unlock_irq(phba->host->host_lock);
230 if ((lpfc_check_sli_ndlp (phba, pring, iocb, ndlp))) { 210
231 found = 1; 211 while (!list_empty(&completions)) {
232 /* It matches, so deque and call compl with an 212 iocb = list_get_first(&completions, struct lpfc_iocbq, list);
233 error */ 213 cmd = &iocb->iocb;
234 list_del(&iocb->list); 214 list_del(&iocb->list);
235 pring->txcmplq_cnt--; 215
236 216 if (iocb->iocb_cmpl) {
237 icmd = &iocb->iocb; 217 cmd->ulpStatus = IOSTAT_LOCAL_REJECT;
238 /* If the driver is completing an ELS 218 cmd->un.ulpWord[4] = IOERR_SLI_ABORTED;
239 * command early, flush it out of the firmware. 219 (iocb->iocb_cmpl) (phba, iocb, iocb);
240 */ 220 } else
241 if (send_abts && 221 lpfc_sli_release_iocbq(phba, iocb);
242 (icmd->ulpCommand == CMD_ELS_REQUEST64_CR) && 222 }
243 (icmd->un.elsreq64.bdl.ulpIoTag32)) {
244 lpfc_sli_issue_abort_iotag32(phba,
245 pring, iocb);
246 }
247 if (iocb->iocb_cmpl) {
248 icmd->ulpStatus = IOSTAT_LOCAL_REJECT;
249 icmd->un.ulpWord[4] = IOERR_SLI_ABORTED;
250 spin_unlock_irq(phba->host->host_lock);
251 (iocb->iocb_cmpl) (phba, iocb, iocb);
252 spin_lock_irq(phba->host->host_lock);
253 } else
254 lpfc_sli_release_iocbq(phba, iocb);
255 break;
256 }
257 }
258 spin_unlock_irq(phba->host->host_lock);
259 } while(found);
260 223
261 /* If we are delaying issuing an ELS command, cancel it */ 224 /* If we are delaying issuing an ELS command, cancel it */
262 if (ndlp->nlp_flag & NLP_DELAY_TMO) 225 if (ndlp->nlp_flag & NLP_DELAY_TMO)
@@ -390,7 +353,10 @@ lpfc_rcv_plogi(struct lpfc_hba * phba,
390 * queue this mbox command to be processed later. 353 * queue this mbox command to be processed later.
391 */ 354 */
392 mbox->mbox_cmpl = lpfc_mbx_cmpl_reg_login; 355 mbox->mbox_cmpl = lpfc_mbx_cmpl_reg_login;
393 mbox->context2 = ndlp; 356 /*
357 * mbox->context2 = lpfc_nlp_get(ndlp) deferred until mailbox
358 * command issued in lpfc_cmpl_els_acc().
359 */
394 ndlp->nlp_flag |= (NLP_ACC_REGLOGIN | NLP_RCV_PLOGI); 360 ndlp->nlp_flag |= (NLP_ACC_REGLOGIN | NLP_RCV_PLOGI);
395 361
396 /* 362 /*
@@ -404,7 +370,7 @@ lpfc_rcv_plogi(struct lpfc_hba * phba,
404 */ 370 */
405 if (ndlp->nlp_state == NLP_STE_PLOGI_ISSUE) { 371 if (ndlp->nlp_state == NLP_STE_PLOGI_ISSUE) {
406 /* software abort outstanding PLOGI */ 372 /* software abort outstanding PLOGI */
407 lpfc_els_abort(phba, ndlp, 1); 373 lpfc_els_abort(phba, ndlp);
408 } 374 }
409 375
410 lpfc_els_rsp_acc(phba, ELS_CMD_PLOGI, cmdiocb, ndlp, mbox, 0); 376 lpfc_els_rsp_acc(phba, ELS_CMD_PLOGI, cmdiocb, ndlp, mbox, 0);
@@ -471,8 +437,7 @@ lpfc_rcv_padisc(struct lpfc_hba * phba,
471 spin_unlock_irq(phba->host->host_lock); 437 spin_unlock_irq(phba->host->host_lock);
472 ndlp->nlp_last_elscmd = ELS_CMD_PLOGI; 438 ndlp->nlp_last_elscmd = ELS_CMD_PLOGI;
473 ndlp->nlp_prev_state = ndlp->nlp_state; 439 ndlp->nlp_prev_state = ndlp->nlp_state;
474 ndlp->nlp_state = NLP_STE_NPR_NODE; 440 lpfc_nlp_set_state(phba, ndlp, NLP_STE_NPR_NODE);
475 lpfc_nlp_list(phba, ndlp, NLP_NPR_LIST);
476 return 0; 441 return 0;
477} 442}
478 443
@@ -502,12 +467,10 @@ lpfc_rcv_logo(struct lpfc_hba * phba,
502 467
503 ndlp->nlp_last_elscmd = ELS_CMD_PLOGI; 468 ndlp->nlp_last_elscmd = ELS_CMD_PLOGI;
504 ndlp->nlp_prev_state = ndlp->nlp_state; 469 ndlp->nlp_prev_state = ndlp->nlp_state;
505 ndlp->nlp_state = NLP_STE_NPR_NODE; 470 lpfc_nlp_set_state(phba, ndlp, NLP_STE_NPR_NODE);
506 lpfc_nlp_list(phba, ndlp, NLP_NPR_LIST);
507 } else { 471 } else {
508 ndlp->nlp_prev_state = ndlp->nlp_state; 472 ndlp->nlp_prev_state = ndlp->nlp_state;
509 ndlp->nlp_state = NLP_STE_UNUSED_NODE; 473 lpfc_nlp_set_state(phba, ndlp, NLP_STE_UNUSED_NODE);
510 lpfc_nlp_list(phba, ndlp, NLP_UNUSED_LIST);
511 } 474 }
512 475
513 spin_lock_irq(phba->host->host_lock); 476 spin_lock_irq(phba->host->host_lock);
@@ -601,11 +564,10 @@ lpfc_rcv_plogi_unused_node(struct lpfc_hba * phba,
601 564
602 if (lpfc_rcv_plogi(phba, ndlp, cmdiocb)) { 565 if (lpfc_rcv_plogi(phba, ndlp, cmdiocb)) {
603 ndlp->nlp_prev_state = NLP_STE_UNUSED_NODE; 566 ndlp->nlp_prev_state = NLP_STE_UNUSED_NODE;
604 ndlp->nlp_state = NLP_STE_UNUSED_NODE; 567 lpfc_nlp_set_state(phba, ndlp, NLP_STE_UNUSED_NODE);
605 lpfc_nlp_list(phba, ndlp, NLP_UNUSED_LIST);
606 return ndlp->nlp_state; 568 return ndlp->nlp_state;
607 } 569 }
608 lpfc_nlp_list(phba, ndlp, NLP_NO_LIST); 570 lpfc_drop_node(phba, ndlp);
609 return NLP_STE_FREED_NODE; 571 return NLP_STE_FREED_NODE;
610} 572}
611 573
@@ -614,7 +576,7 @@ lpfc_rcv_els_unused_node(struct lpfc_hba * phba,
614 struct lpfc_nodelist * ndlp, void *arg, uint32_t evt) 576 struct lpfc_nodelist * ndlp, void *arg, uint32_t evt)
615{ 577{
616 lpfc_issue_els_logo(phba, ndlp, 0); 578 lpfc_issue_els_logo(phba, ndlp, 0);
617 lpfc_nlp_list(phba, ndlp, NLP_UNUSED_LIST); 579 lpfc_nlp_set_state(phba, ndlp, NLP_STE_UNUSED_NODE);
618 return ndlp->nlp_state; 580 return ndlp->nlp_state;
619} 581}
620 582
@@ -630,7 +592,7 @@ lpfc_rcv_logo_unused_node(struct lpfc_hba * phba,
630 ndlp->nlp_flag |= NLP_LOGO_ACC; 592 ndlp->nlp_flag |= NLP_LOGO_ACC;
631 spin_unlock_irq(phba->host->host_lock); 593 spin_unlock_irq(phba->host->host_lock);
632 lpfc_els_rsp_acc(phba, ELS_CMD_ACC, cmdiocb, ndlp, NULL, 0); 594 lpfc_els_rsp_acc(phba, ELS_CMD_ACC, cmdiocb, ndlp, NULL, 0);
633 lpfc_nlp_list(phba, ndlp, NLP_UNUSED_LIST); 595 lpfc_nlp_set_state(phba, ndlp, NLP_STE_UNUSED_NODE);
634 596
635 return ndlp->nlp_state; 597 return ndlp->nlp_state;
636} 598}
@@ -639,7 +601,7 @@ static uint32_t
639lpfc_cmpl_logo_unused_node(struct lpfc_hba * phba, 601lpfc_cmpl_logo_unused_node(struct lpfc_hba * phba,
640 struct lpfc_nodelist * ndlp, void *arg, uint32_t evt) 602 struct lpfc_nodelist * ndlp, void *arg, uint32_t evt)
641{ 603{
642 lpfc_nlp_list(phba, ndlp, NLP_NO_LIST); 604 lpfc_drop_node(phba, ndlp);
643 return NLP_STE_FREED_NODE; 605 return NLP_STE_FREED_NODE;
644} 606}
645 607
@@ -647,7 +609,7 @@ static uint32_t
647lpfc_device_rm_unused_node(struct lpfc_hba * phba, 609lpfc_device_rm_unused_node(struct lpfc_hba * phba,
648 struct lpfc_nodelist * ndlp, void *arg, uint32_t evt) 610 struct lpfc_nodelist * ndlp, void *arg, uint32_t evt)
649{ 611{
650 lpfc_nlp_list(phba, ndlp, NLP_NO_LIST); 612 lpfc_drop_node(phba, ndlp);
651 return NLP_STE_FREED_NODE; 613 return NLP_STE_FREED_NODE;
652} 614}
653 615
@@ -697,7 +659,7 @@ lpfc_rcv_logo_plogi_issue(struct lpfc_hba * phba,
697 cmdiocb = (struct lpfc_iocbq *) arg; 659 cmdiocb = (struct lpfc_iocbq *) arg;
698 660
699 /* software abort outstanding PLOGI */ 661 /* software abort outstanding PLOGI */
700 lpfc_els_abort(phba, ndlp, 1); 662 lpfc_els_abort(phba, ndlp);
701 663
702 lpfc_rcv_logo(phba, ndlp, cmdiocb, ELS_CMD_LOGO); 664 lpfc_rcv_logo(phba, ndlp, cmdiocb, ELS_CMD_LOGO);
703 return ndlp->nlp_state; 665 return ndlp->nlp_state;
@@ -712,7 +674,7 @@ lpfc_rcv_els_plogi_issue(struct lpfc_hba * phba,
712 cmdiocb = (struct lpfc_iocbq *) arg; 674 cmdiocb = (struct lpfc_iocbq *) arg;
713 675
714 /* software abort outstanding PLOGI */ 676 /* software abort outstanding PLOGI */
715 lpfc_els_abort(phba, ndlp, 1); 677 lpfc_els_abort(phba, ndlp);
716 678
717 if (evt == NLP_EVT_RCV_LOGO) { 679 if (evt == NLP_EVT_RCV_LOGO) {
718 lpfc_els_rsp_acc(phba, ELS_CMD_ACC, cmdiocb, ndlp, NULL, 0); 680 lpfc_els_rsp_acc(phba, ELS_CMD_ACC, cmdiocb, ndlp, NULL, 0);
@@ -727,8 +689,7 @@ lpfc_rcv_els_plogi_issue(struct lpfc_hba * phba,
727 spin_unlock_irq(phba->host->host_lock); 689 spin_unlock_irq(phba->host->host_lock);
728 ndlp->nlp_last_elscmd = ELS_CMD_PLOGI; 690 ndlp->nlp_last_elscmd = ELS_CMD_PLOGI;
729 ndlp->nlp_prev_state = NLP_STE_PLOGI_ISSUE; 691 ndlp->nlp_prev_state = NLP_STE_PLOGI_ISSUE;
730 ndlp->nlp_state = NLP_STE_NPR_NODE; 692 lpfc_nlp_set_state(phba, ndlp, NLP_STE_NPR_NODE);
731 lpfc_nlp_list(phba, ndlp, NLP_NPR_LIST);
732 693
733 return ndlp->nlp_state; 694 return ndlp->nlp_state;
734} 695}
@@ -803,32 +764,26 @@ lpfc_cmpl_plogi_plogi_issue(struct lpfc_hba * phba,
803 goto out; 764 goto out;
804 765
805 lpfc_unreg_rpi(phba, ndlp); 766 lpfc_unreg_rpi(phba, ndlp);
806 if (lpfc_reg_login 767 if (lpfc_reg_login(phba, irsp->un.elsreq64.remoteID, (uint8_t *) sp,
807 (phba, irsp->un.elsreq64.remoteID, 768 mbox, 0) == 0) {
808 (uint8_t *) sp, mbox, 0) == 0) {
809 switch (ndlp->nlp_DID) { 769 switch (ndlp->nlp_DID) {
810 case NameServer_DID: 770 case NameServer_DID:
811 mbox->mbox_cmpl = 771 mbox->mbox_cmpl = lpfc_mbx_cmpl_ns_reg_login;
812 lpfc_mbx_cmpl_ns_reg_login;
813 break; 772 break;
814 case FDMI_DID: 773 case FDMI_DID:
815 mbox->mbox_cmpl = 774 mbox->mbox_cmpl = lpfc_mbx_cmpl_fdmi_reg_login;
816 lpfc_mbx_cmpl_fdmi_reg_login;
817 break; 775 break;
818 default: 776 default:
819 mbox->mbox_cmpl = 777 mbox->mbox_cmpl = lpfc_mbx_cmpl_reg_login;
820 lpfc_mbx_cmpl_reg_login;
821 } 778 }
822 mbox->context2 = ndlp; 779 mbox->context2 = lpfc_nlp_get(ndlp);
823 if (lpfc_sli_issue_mbox(phba, mbox, 780 if (lpfc_sli_issue_mbox(phba, mbox,
824 (MBX_NOWAIT | MBX_STOP_IOCB)) 781 (MBX_NOWAIT | MBX_STOP_IOCB))
825 != MBX_NOT_FINISHED) { 782 != MBX_NOT_FINISHED) {
826 ndlp->nlp_state = 783 lpfc_nlp_set_state(phba, ndlp, NLP_STE_REG_LOGIN_ISSUE);
827 NLP_STE_REG_LOGIN_ISSUE;
828 lpfc_nlp_list(phba, ndlp,
829 NLP_REGLOGIN_LIST);
830 return ndlp->nlp_state; 784 return ndlp->nlp_state;
831 } 785 }
786 lpfc_nlp_put(ndlp);
832 mp = (struct lpfc_dmabuf *)mbox->context1; 787 mp = (struct lpfc_dmabuf *)mbox->context1;
833 lpfc_mbuf_free(phba, mp->virt, mp->phys); 788 lpfc_mbuf_free(phba, mp->virt, mp->phys);
834 kfree(mp); 789 kfree(mp);
@@ -841,7 +796,7 @@ lpfc_cmpl_plogi_plogi_issue(struct lpfc_hba * phba,
841 out: 796 out:
842 /* Free this node since the driver cannot login or has the wrong 797 /* Free this node since the driver cannot login or has the wrong
843 sparm */ 798 sparm */
844 lpfc_nlp_list(phba, ndlp, NLP_NO_LIST); 799 lpfc_drop_node(phba, ndlp);
845 return NLP_STE_FREED_NODE; 800 return NLP_STE_FREED_NODE;
846} 801}
847 802
@@ -855,9 +810,9 @@ lpfc_device_rm_plogi_issue(struct lpfc_hba * phba,
855 } 810 }
856 else { 811 else {
857 /* software abort outstanding PLOGI */ 812 /* software abort outstanding PLOGI */
858 lpfc_els_abort(phba, ndlp, 1); 813 lpfc_els_abort(phba, ndlp);
859 814
860 lpfc_nlp_list(phba, ndlp, NLP_NO_LIST); 815 lpfc_drop_node(phba, ndlp);
861 return NLP_STE_FREED_NODE; 816 return NLP_STE_FREED_NODE;
862 } 817 }
863} 818}
@@ -868,11 +823,10 @@ lpfc_device_recov_plogi_issue(struct lpfc_hba * phba,
868 uint32_t evt) 823 uint32_t evt)
869{ 824{
870 /* software abort outstanding PLOGI */ 825 /* software abort outstanding PLOGI */
871 lpfc_els_abort(phba, ndlp, 1); 826 lpfc_els_abort(phba, ndlp);
872 827
873 ndlp->nlp_prev_state = NLP_STE_PLOGI_ISSUE; 828 ndlp->nlp_prev_state = NLP_STE_PLOGI_ISSUE;
874 ndlp->nlp_state = NLP_STE_NPR_NODE; 829 lpfc_nlp_set_state(phba, ndlp, NLP_STE_NPR_NODE);
875 lpfc_nlp_list(phba, ndlp, NLP_NPR_LIST);
876 spin_lock_irq(phba->host->host_lock); 830 spin_lock_irq(phba->host->host_lock);
877 ndlp->nlp_flag &= ~(NLP_NODEV_REMOVE | NLP_NPR_2B_DISC); 831 ndlp->nlp_flag &= ~(NLP_NODEV_REMOVE | NLP_NPR_2B_DISC);
878 spin_unlock_irq(phba->host->host_lock); 832 spin_unlock_irq(phba->host->host_lock);
@@ -888,7 +842,7 @@ lpfc_rcv_plogi_adisc_issue(struct lpfc_hba * phba,
888 struct lpfc_iocbq *cmdiocb; 842 struct lpfc_iocbq *cmdiocb;
889 843
890 /* software abort outstanding ADISC */ 844 /* software abort outstanding ADISC */
891 lpfc_els_abort(phba, ndlp, 1); 845 lpfc_els_abort(phba, ndlp);
892 846
893 cmdiocb = (struct lpfc_iocbq *) arg; 847 cmdiocb = (struct lpfc_iocbq *) arg;
894 848
@@ -896,8 +850,7 @@ lpfc_rcv_plogi_adisc_issue(struct lpfc_hba * phba,
896 return ndlp->nlp_state; 850 return ndlp->nlp_state;
897 } 851 }
898 ndlp->nlp_prev_state = NLP_STE_ADISC_ISSUE; 852 ndlp->nlp_prev_state = NLP_STE_ADISC_ISSUE;
899 ndlp->nlp_state = NLP_STE_PLOGI_ISSUE; 853 lpfc_nlp_set_state(phba, ndlp, NLP_STE_PLOGI_ISSUE);
900 lpfc_nlp_list(phba, ndlp, NLP_PLOGI_LIST);
901 lpfc_issue_els_plogi(phba, ndlp->nlp_DID, 0); 854 lpfc_issue_els_plogi(phba, ndlp->nlp_DID, 0);
902 855
903 return ndlp->nlp_state; 856 return ndlp->nlp_state;
@@ -926,7 +879,7 @@ lpfc_rcv_logo_adisc_issue(struct lpfc_hba * phba,
926 cmdiocb = (struct lpfc_iocbq *) arg; 879 cmdiocb = (struct lpfc_iocbq *) arg;
927 880
928 /* software abort outstanding ADISC */ 881 /* software abort outstanding ADISC */
929 lpfc_els_abort(phba, ndlp, 0); 882 lpfc_els_abort(phba, ndlp);
930 883
931 lpfc_rcv_logo(phba, ndlp, cmdiocb, ELS_CMD_LOGO); 884 lpfc_rcv_logo(phba, ndlp, cmdiocb, ELS_CMD_LOGO);
932 return ndlp->nlp_state; 885 return ndlp->nlp_state;
@@ -987,20 +940,17 @@ lpfc_cmpl_adisc_adisc_issue(struct lpfc_hba * phba,
987 memset(&ndlp->nlp_portname, 0, sizeof (struct lpfc_name)); 940 memset(&ndlp->nlp_portname, 0, sizeof (struct lpfc_name));
988 941
989 ndlp->nlp_prev_state = NLP_STE_ADISC_ISSUE; 942 ndlp->nlp_prev_state = NLP_STE_ADISC_ISSUE;
990 ndlp->nlp_state = NLP_STE_NPR_NODE; 943 lpfc_nlp_set_state(phba, ndlp, NLP_STE_NPR_NODE);
991 lpfc_nlp_list(phba, ndlp, NLP_NPR_LIST);
992 lpfc_unreg_rpi(phba, ndlp); 944 lpfc_unreg_rpi(phba, ndlp);
993 return ndlp->nlp_state; 945 return ndlp->nlp_state;
994 } 946 }
995 947
996 if (ndlp->nlp_type & NLP_FCP_TARGET) { 948 if (ndlp->nlp_type & NLP_FCP_TARGET) {
997 ndlp->nlp_prev_state = NLP_STE_ADISC_ISSUE; 949 ndlp->nlp_prev_state = NLP_STE_ADISC_ISSUE;
998 ndlp->nlp_state = NLP_STE_MAPPED_NODE; 950 lpfc_nlp_set_state(phba, ndlp, NLP_STE_MAPPED_NODE);
999 lpfc_nlp_list(phba, ndlp, NLP_MAPPED_LIST);
1000 } else { 951 } else {
1001 ndlp->nlp_prev_state = NLP_STE_ADISC_ISSUE; 952 ndlp->nlp_prev_state = NLP_STE_ADISC_ISSUE;
1002 ndlp->nlp_state = NLP_STE_UNMAPPED_NODE; 953 lpfc_nlp_set_state(phba, ndlp, NLP_STE_UNMAPPED_NODE);
1003 lpfc_nlp_list(phba, ndlp, NLP_UNMAPPED_LIST);
1004 } 954 }
1005 return ndlp->nlp_state; 955 return ndlp->nlp_state;
1006} 956}
@@ -1016,9 +966,9 @@ lpfc_device_rm_adisc_issue(struct lpfc_hba * phba,
1016 } 966 }
1017 else { 967 else {
1018 /* software abort outstanding ADISC */ 968 /* software abort outstanding ADISC */
1019 lpfc_els_abort(phba, ndlp, 1); 969 lpfc_els_abort(phba, ndlp);
1020 970
1021 lpfc_nlp_list(phba, ndlp, NLP_NO_LIST); 971 lpfc_drop_node(phba, ndlp);
1022 return NLP_STE_FREED_NODE; 972 return NLP_STE_FREED_NODE;
1023 } 973 }
1024} 974}
@@ -1029,11 +979,10 @@ lpfc_device_recov_adisc_issue(struct lpfc_hba * phba,
1029 uint32_t evt) 979 uint32_t evt)
1030{ 980{
1031 /* software abort outstanding ADISC */ 981 /* software abort outstanding ADISC */
1032 lpfc_els_abort(phba, ndlp, 1); 982 lpfc_els_abort(phba, ndlp);
1033 983
1034 ndlp->nlp_prev_state = NLP_STE_ADISC_ISSUE; 984 ndlp->nlp_prev_state = NLP_STE_ADISC_ISSUE;
1035 ndlp->nlp_state = NLP_STE_NPR_NODE; 985 lpfc_nlp_set_state(phba, ndlp, NLP_STE_NPR_NODE);
1036 lpfc_nlp_list(phba, ndlp, NLP_NPR_LIST);
1037 spin_lock_irq(phba->host->host_lock); 986 spin_lock_irq(phba->host->host_lock);
1038 ndlp->nlp_flag &= ~(NLP_NODEV_REMOVE | NLP_NPR_2B_DISC); 987 ndlp->nlp_flag &= ~(NLP_NODEV_REMOVE | NLP_NPR_2B_DISC);
1039 ndlp->nlp_flag |= NLP_NPR_ADISC; 988 ndlp->nlp_flag |= NLP_NPR_ADISC;
@@ -1074,9 +1023,36 @@ lpfc_rcv_logo_reglogin_issue(struct lpfc_hba * phba,
1074 uint32_t evt) 1023 uint32_t evt)
1075{ 1024{
1076 struct lpfc_iocbq *cmdiocb; 1025 struct lpfc_iocbq *cmdiocb;
1026 LPFC_MBOXQ_t *mb;
1027 LPFC_MBOXQ_t *nextmb;
1028 struct lpfc_dmabuf *mp;
1077 1029
1078 cmdiocb = (struct lpfc_iocbq *) arg; 1030 cmdiocb = (struct lpfc_iocbq *) arg;
1079 1031
1032 /* cleanup any ndlp on mbox q waiting for reglogin cmpl */
1033 if ((mb = phba->sli.mbox_active)) {
1034 if ((mb->mb.mbxCommand == MBX_REG_LOGIN64) &&
1035 (ndlp == (struct lpfc_nodelist *) mb->context2)) {
1036 mb->context2 = NULL;
1037 mb->mbox_cmpl = lpfc_sli_def_mbox_cmpl;
1038 }
1039 }
1040
1041 spin_lock_irq(phba->host->host_lock);
1042 list_for_each_entry_safe(mb, nextmb, &phba->sli.mboxq, list) {
1043 if ((mb->mb.mbxCommand == MBX_REG_LOGIN64) &&
1044 (ndlp == (struct lpfc_nodelist *) mb->context2)) {
1045 mp = (struct lpfc_dmabuf *) (mb->context1);
1046 if (mp) {
1047 lpfc_mbuf_free(phba, mp->virt, mp->phys);
1048 kfree(mp);
1049 }
1050 list_del(&mb->list);
1051 mempool_free(mb, phba->mbox_mem_pool);
1052 }
1053 }
1054 spin_unlock_irq(phba->host->host_lock);
1055
1080 lpfc_rcv_logo(phba, ndlp, cmdiocb, ELS_CMD_LOGO); 1056 lpfc_rcv_logo(phba, ndlp, cmdiocb, ELS_CMD_LOGO);
1081 return ndlp->nlp_state; 1057 return ndlp->nlp_state;
1082} 1058}
@@ -1133,8 +1109,7 @@ lpfc_cmpl_reglogin_reglogin_issue(struct lpfc_hba * phba,
1133 */ 1109 */
1134 if (mb->mbxStatus == MBXERR_RPI_FULL) { 1110 if (mb->mbxStatus == MBXERR_RPI_FULL) {
1135 ndlp->nlp_prev_state = NLP_STE_UNUSED_NODE; 1111 ndlp->nlp_prev_state = NLP_STE_UNUSED_NODE;
1136 ndlp->nlp_state = NLP_STE_UNUSED_NODE; 1112 lpfc_nlp_set_state(phba, ndlp, NLP_STE_UNUSED_NODE);
1137 lpfc_nlp_list(phba, ndlp, NLP_UNUSED_LIST);
1138 return ndlp->nlp_state; 1113 return ndlp->nlp_state;
1139 } 1114 }
1140 1115
@@ -1147,8 +1122,7 @@ lpfc_cmpl_reglogin_reglogin_issue(struct lpfc_hba * phba,
1147 1122
1148 lpfc_issue_els_logo(phba, ndlp, 0); 1123 lpfc_issue_els_logo(phba, ndlp, 0);
1149 ndlp->nlp_prev_state = NLP_STE_REG_LOGIN_ISSUE; 1124 ndlp->nlp_prev_state = NLP_STE_REG_LOGIN_ISSUE;
1150 ndlp->nlp_state = NLP_STE_NPR_NODE; 1125 lpfc_nlp_set_state(phba, ndlp, NLP_STE_NPR_NODE);
1151 lpfc_nlp_list(phba, ndlp, NLP_NPR_LIST);
1152 return ndlp->nlp_state; 1126 return ndlp->nlp_state;
1153 } 1127 }
1154 1128
@@ -1157,13 +1131,11 @@ lpfc_cmpl_reglogin_reglogin_issue(struct lpfc_hba * phba,
1157 /* Only if we are not a fabric nport do we issue PRLI */ 1131 /* Only if we are not a fabric nport do we issue PRLI */
1158 if (!(ndlp->nlp_type & NLP_FABRIC)) { 1132 if (!(ndlp->nlp_type & NLP_FABRIC)) {
1159 ndlp->nlp_prev_state = NLP_STE_REG_LOGIN_ISSUE; 1133 ndlp->nlp_prev_state = NLP_STE_REG_LOGIN_ISSUE;
1160 ndlp->nlp_state = NLP_STE_PRLI_ISSUE; 1134 lpfc_nlp_set_state(phba, ndlp, NLP_STE_PRLI_ISSUE);
1161 lpfc_nlp_list(phba, ndlp, NLP_PRLI_LIST);
1162 lpfc_issue_els_prli(phba, ndlp, 0); 1135 lpfc_issue_els_prli(phba, ndlp, 0);
1163 } else { 1136 } else {
1164 ndlp->nlp_prev_state = NLP_STE_REG_LOGIN_ISSUE; 1137 ndlp->nlp_prev_state = NLP_STE_REG_LOGIN_ISSUE;
1165 ndlp->nlp_state = NLP_STE_UNMAPPED_NODE; 1138 lpfc_nlp_set_state(phba, ndlp, NLP_STE_UNMAPPED_NODE);
1166 lpfc_nlp_list(phba, ndlp, NLP_UNMAPPED_LIST);
1167 } 1139 }
1168 return ndlp->nlp_state; 1140 return ndlp->nlp_state;
1169} 1141}
@@ -1178,7 +1150,7 @@ lpfc_device_rm_reglogin_issue(struct lpfc_hba * phba,
1178 return ndlp->nlp_state; 1150 return ndlp->nlp_state;
1179 } 1151 }
1180 else { 1152 else {
1181 lpfc_nlp_list(phba, ndlp, NLP_NO_LIST); 1153 lpfc_drop_node(phba, ndlp);
1182 return NLP_STE_FREED_NODE; 1154 return NLP_STE_FREED_NODE;
1183 } 1155 }
1184} 1156}
@@ -1189,8 +1161,7 @@ lpfc_device_recov_reglogin_issue(struct lpfc_hba * phba,
1189 uint32_t evt) 1161 uint32_t evt)
1190{ 1162{
1191 ndlp->nlp_prev_state = NLP_STE_REG_LOGIN_ISSUE; 1163 ndlp->nlp_prev_state = NLP_STE_REG_LOGIN_ISSUE;
1192 ndlp->nlp_state = NLP_STE_NPR_NODE; 1164 lpfc_nlp_set_state(phba, ndlp, NLP_STE_NPR_NODE);
1193 lpfc_nlp_list(phba, ndlp, NLP_NPR_LIST);
1194 spin_lock_irq(phba->host->host_lock); 1165 spin_lock_irq(phba->host->host_lock);
1195 ndlp->nlp_flag &= ~(NLP_NODEV_REMOVE | NLP_NPR_2B_DISC); 1166 ndlp->nlp_flag &= ~(NLP_NODEV_REMOVE | NLP_NPR_2B_DISC);
1196 spin_unlock_irq(phba->host->host_lock); 1167 spin_unlock_irq(phba->host->host_lock);
@@ -1230,7 +1201,7 @@ lpfc_rcv_logo_prli_issue(struct lpfc_hba * phba,
1230 cmdiocb = (struct lpfc_iocbq *) arg; 1201 cmdiocb = (struct lpfc_iocbq *) arg;
1231 1202
1232 /* Software abort outstanding PRLI before sending acc */ 1203 /* Software abort outstanding PRLI before sending acc */
1233 lpfc_els_abort(phba, ndlp, 1); 1204 lpfc_els_abort(phba, ndlp);
1234 1205
1235 lpfc_rcv_logo(phba, ndlp, cmdiocb, ELS_CMD_LOGO); 1206 lpfc_rcv_logo(phba, ndlp, cmdiocb, ELS_CMD_LOGO);
1236 return ndlp->nlp_state; 1207 return ndlp->nlp_state;
@@ -1279,8 +1250,7 @@ lpfc_cmpl_prli_prli_issue(struct lpfc_hba * phba,
1279 irsp = &rspiocb->iocb; 1250 irsp = &rspiocb->iocb;
1280 if (irsp->ulpStatus) { 1251 if (irsp->ulpStatus) {
1281 ndlp->nlp_prev_state = NLP_STE_PRLI_ISSUE; 1252 ndlp->nlp_prev_state = NLP_STE_PRLI_ISSUE;
1282 ndlp->nlp_state = NLP_STE_UNMAPPED_NODE; 1253 lpfc_nlp_set_state(phba, ndlp, NLP_STE_UNMAPPED_NODE);
1283 lpfc_nlp_list(phba, ndlp, NLP_UNMAPPED_LIST);
1284 return ndlp->nlp_state; 1254 return ndlp->nlp_state;
1285 } 1255 }
1286 1256
@@ -1298,8 +1268,7 @@ lpfc_cmpl_prli_prli_issue(struct lpfc_hba * phba,
1298 } 1268 }
1299 1269
1300 ndlp->nlp_prev_state = NLP_STE_PRLI_ISSUE; 1270 ndlp->nlp_prev_state = NLP_STE_PRLI_ISSUE;
1301 ndlp->nlp_state = NLP_STE_MAPPED_NODE; 1271 lpfc_nlp_set_state(phba, ndlp, NLP_STE_MAPPED_NODE);
1302 lpfc_nlp_list(phba, ndlp, NLP_MAPPED_LIST);
1303 return ndlp->nlp_state; 1272 return ndlp->nlp_state;
1304} 1273}
1305 1274
@@ -1330,9 +1299,9 @@ lpfc_device_rm_prli_issue(struct lpfc_hba * phba,
1330 } 1299 }
1331 else { 1300 else {
1332 /* software abort outstanding PLOGI */ 1301 /* software abort outstanding PLOGI */
1333 lpfc_els_abort(phba, ndlp, 1); 1302 lpfc_els_abort(phba, ndlp);
1334 1303
1335 lpfc_nlp_list(phba, ndlp, NLP_NO_LIST); 1304 lpfc_drop_node(phba, ndlp);
1336 return NLP_STE_FREED_NODE; 1305 return NLP_STE_FREED_NODE;
1337 } 1306 }
1338} 1307}
@@ -1359,11 +1328,10 @@ lpfc_device_recov_prli_issue(struct lpfc_hba * phba,
1359 struct lpfc_nodelist * ndlp, void *arg, uint32_t evt) 1328 struct lpfc_nodelist * ndlp, void *arg, uint32_t evt)
1360{ 1329{
1361 /* software abort outstanding PRLI */ 1330 /* software abort outstanding PRLI */
1362 lpfc_els_abort(phba, ndlp, 1); 1331 lpfc_els_abort(phba, ndlp);
1363 1332
1364 ndlp->nlp_prev_state = NLP_STE_PRLI_ISSUE; 1333 ndlp->nlp_prev_state = NLP_STE_PRLI_ISSUE;
1365 ndlp->nlp_state = NLP_STE_NPR_NODE; 1334 lpfc_nlp_set_state(phba, ndlp, NLP_STE_NPR_NODE);
1366 lpfc_nlp_list(phba, ndlp, NLP_NPR_LIST);
1367 spin_lock_irq(phba->host->host_lock); 1335 spin_lock_irq(phba->host->host_lock);
1368 ndlp->nlp_flag &= ~(NLP_NODEV_REMOVE | NLP_NPR_2B_DISC); 1336 ndlp->nlp_flag &= ~(NLP_NODEV_REMOVE | NLP_NPR_2B_DISC);
1369 spin_unlock_irq(phba->host->host_lock); 1337 spin_unlock_irq(phba->host->host_lock);
@@ -1436,8 +1404,7 @@ lpfc_device_recov_unmap_node(struct lpfc_hba * phba,
1436 struct lpfc_nodelist * ndlp, void *arg, uint32_t evt) 1404 struct lpfc_nodelist * ndlp, void *arg, uint32_t evt)
1437{ 1405{
1438 ndlp->nlp_prev_state = NLP_STE_UNMAPPED_NODE; 1406 ndlp->nlp_prev_state = NLP_STE_UNMAPPED_NODE;
1439 ndlp->nlp_state = NLP_STE_NPR_NODE; 1407 lpfc_nlp_set_state(phba, ndlp, NLP_STE_NPR_NODE);
1440 lpfc_nlp_list(phba, ndlp, NLP_NPR_LIST);
1441 ndlp->nlp_flag &= ~(NLP_NODEV_REMOVE | NLP_NPR_2B_DISC); 1408 ndlp->nlp_flag &= ~(NLP_NODEV_REMOVE | NLP_NPR_2B_DISC);
1442 lpfc_disc_set_adisc(phba, ndlp); 1409 lpfc_disc_set_adisc(phba, ndlp);
1443 1410
@@ -1518,8 +1485,7 @@ lpfc_device_recov_mapped_node(struct lpfc_hba * phba,
1518 uint32_t evt) 1485 uint32_t evt)
1519{ 1486{
1520 ndlp->nlp_prev_state = NLP_STE_MAPPED_NODE; 1487 ndlp->nlp_prev_state = NLP_STE_MAPPED_NODE;
1521 ndlp->nlp_state = NLP_STE_NPR_NODE; 1488 lpfc_nlp_set_state(phba, ndlp, NLP_STE_NPR_NODE);
1522 lpfc_nlp_list(phba, ndlp, NLP_NPR_LIST);
1523 spin_lock_irq(phba->host->host_lock); 1489 spin_lock_irq(phba->host->host_lock);
1524 ndlp->nlp_flag &= ~(NLP_NODEV_REMOVE | NLP_NPR_2B_DISC); 1490 ndlp->nlp_flag &= ~(NLP_NODEV_REMOVE | NLP_NPR_2B_DISC);
1525 spin_unlock_irq(phba->host->host_lock); 1491 spin_unlock_irq(phba->host->host_lock);
@@ -1551,8 +1517,7 @@ lpfc_rcv_plogi_npr_node(struct lpfc_hba * phba,
1551 /* send PLOGI immediately, move to PLOGI issue state */ 1517 /* send PLOGI immediately, move to PLOGI issue state */
1552 if (!(ndlp->nlp_flag & NLP_DELAY_TMO)) { 1518 if (!(ndlp->nlp_flag & NLP_DELAY_TMO)) {
1553 ndlp->nlp_prev_state = NLP_STE_NPR_NODE; 1519 ndlp->nlp_prev_state = NLP_STE_NPR_NODE;
1554 ndlp->nlp_state = NLP_STE_PLOGI_ISSUE; 1520 lpfc_nlp_set_state(phba, ndlp, NLP_STE_PLOGI_ISSUE);
1555 lpfc_nlp_list(phba, ndlp, NLP_PLOGI_LIST);
1556 lpfc_issue_els_plogi(phba, ndlp->nlp_DID, 0); 1521 lpfc_issue_els_plogi(phba, ndlp->nlp_DID, 0);
1557 } 1522 }
1558 1523
@@ -1580,16 +1545,13 @@ lpfc_rcv_prli_npr_node(struct lpfc_hba * phba,
1580 ndlp->nlp_flag &= ~NLP_NPR_ADISC; 1545 ndlp->nlp_flag &= ~NLP_NPR_ADISC;
1581 spin_unlock_irq(phba->host->host_lock); 1546 spin_unlock_irq(phba->host->host_lock);
1582 ndlp->nlp_prev_state = NLP_STE_NPR_NODE; 1547 ndlp->nlp_prev_state = NLP_STE_NPR_NODE;
1583 ndlp->nlp_state = NLP_STE_ADISC_ISSUE; 1548 lpfc_nlp_set_state(phba, ndlp, NLP_STE_ADISC_ISSUE);
1584 lpfc_nlp_list(phba, ndlp, NLP_ADISC_LIST);
1585 lpfc_issue_els_adisc(phba, ndlp, 0); 1549 lpfc_issue_els_adisc(phba, ndlp, 0);
1586 } else { 1550 } else {
1587 ndlp->nlp_prev_state = NLP_STE_NPR_NODE; 1551 ndlp->nlp_prev_state = NLP_STE_NPR_NODE;
1588 ndlp->nlp_state = NLP_STE_PLOGI_ISSUE; 1552 lpfc_nlp_set_state(phba, ndlp, NLP_STE_PLOGI_ISSUE);
1589 lpfc_nlp_list(phba, ndlp, NLP_PLOGI_LIST);
1590 lpfc_issue_els_plogi(phba, ndlp->nlp_DID, 0); 1553 lpfc_issue_els_plogi(phba, ndlp->nlp_DID, 0);
1591 } 1554 }
1592
1593 } 1555 }
1594 return ndlp->nlp_state; 1556 return ndlp->nlp_state;
1595} 1557}
@@ -1627,13 +1589,11 @@ lpfc_rcv_padisc_npr_node(struct lpfc_hba * phba,
1627 !(ndlp->nlp_flag & NLP_NPR_2B_DISC)){ 1589 !(ndlp->nlp_flag & NLP_NPR_2B_DISC)){
1628 if (ndlp->nlp_flag & NLP_NPR_ADISC) { 1590 if (ndlp->nlp_flag & NLP_NPR_ADISC) {
1629 ndlp->nlp_prev_state = NLP_STE_NPR_NODE; 1591 ndlp->nlp_prev_state = NLP_STE_NPR_NODE;
1630 ndlp->nlp_state = NLP_STE_ADISC_ISSUE; 1592 lpfc_nlp_set_state(phba, ndlp, NLP_STE_ADISC_ISSUE);
1631 lpfc_nlp_list(phba, ndlp, NLP_ADISC_LIST);
1632 lpfc_issue_els_adisc(phba, ndlp, 0); 1593 lpfc_issue_els_adisc(phba, ndlp, 0);
1633 } else { 1594 } else {
1634 ndlp->nlp_prev_state = NLP_STE_NPR_NODE; 1595 ndlp->nlp_prev_state = NLP_STE_NPR_NODE;
1635 ndlp->nlp_state = NLP_STE_PLOGI_ISSUE; 1596 lpfc_nlp_set_state(phba, ndlp, NLP_STE_PLOGI_ISSUE);
1636 lpfc_nlp_list(phba, ndlp, NLP_PLOGI_LIST);
1637 lpfc_issue_els_plogi(phba, ndlp->nlp_DID, 0); 1597 lpfc_issue_els_plogi(phba, ndlp->nlp_DID, 0);
1638 } 1598 }
1639 } 1599 }
@@ -1682,7 +1642,7 @@ lpfc_cmpl_plogi_npr_node(struct lpfc_hba * phba,
1682 1642
1683 irsp = &rspiocb->iocb; 1643 irsp = &rspiocb->iocb;
1684 if (irsp->ulpStatus) { 1644 if (irsp->ulpStatus) {
1685 lpfc_nlp_list(phba, ndlp, NLP_NO_LIST); 1645 lpfc_drop_node(phba, ndlp);
1686 return NLP_STE_FREED_NODE; 1646 return NLP_STE_FREED_NODE;
1687 } 1647 }
1688 return ndlp->nlp_state; 1648 return ndlp->nlp_state;
@@ -1700,7 +1660,7 @@ lpfc_cmpl_prli_npr_node(struct lpfc_hba * phba,
1700 1660
1701 irsp = &rspiocb->iocb; 1661 irsp = &rspiocb->iocb;
1702 if (irsp->ulpStatus && (ndlp->nlp_flag & NLP_NODEV_REMOVE)) { 1662 if (irsp->ulpStatus && (ndlp->nlp_flag & NLP_NODEV_REMOVE)) {
1703 lpfc_nlp_list(phba, ndlp, NLP_NO_LIST); 1663 lpfc_drop_node(phba, ndlp);
1704 return NLP_STE_FREED_NODE; 1664 return NLP_STE_FREED_NODE;
1705 } 1665 }
1706 return ndlp->nlp_state; 1666 return ndlp->nlp_state;
@@ -1728,7 +1688,7 @@ lpfc_cmpl_adisc_npr_node(struct lpfc_hba * phba,
1728 1688
1729 irsp = &rspiocb->iocb; 1689 irsp = &rspiocb->iocb;
1730 if (irsp->ulpStatus && (ndlp->nlp_flag & NLP_NODEV_REMOVE)) { 1690 if (irsp->ulpStatus && (ndlp->nlp_flag & NLP_NODEV_REMOVE)) {
1731 lpfc_nlp_list(phba, ndlp, NLP_NO_LIST); 1691 lpfc_drop_node(phba, ndlp);
1732 return NLP_STE_FREED_NODE; 1692 return NLP_STE_FREED_NODE;
1733 } 1693 }
1734 return ndlp->nlp_state; 1694 return ndlp->nlp_state;
@@ -1749,7 +1709,7 @@ lpfc_cmpl_reglogin_npr_node(struct lpfc_hba * phba,
1749 ndlp->nlp_rpi = mb->un.varWords[0]; 1709 ndlp->nlp_rpi = mb->un.varWords[0];
1750 else { 1710 else {
1751 if (ndlp->nlp_flag & NLP_NODEV_REMOVE) { 1711 if (ndlp->nlp_flag & NLP_NODEV_REMOVE) {
1752 lpfc_nlp_list(phba, ndlp, NLP_NO_LIST); 1712 lpfc_drop_node(phba, ndlp);
1753 return NLP_STE_FREED_NODE; 1713 return NLP_STE_FREED_NODE;
1754 } 1714 }
1755 } 1715 }
@@ -1765,7 +1725,7 @@ lpfc_device_rm_npr_node(struct lpfc_hba * phba,
1765 ndlp->nlp_flag |= NLP_NODEV_REMOVE; 1725 ndlp->nlp_flag |= NLP_NODEV_REMOVE;
1766 return ndlp->nlp_state; 1726 return ndlp->nlp_state;
1767 } 1727 }
1768 lpfc_nlp_list(phba, ndlp, NLP_NO_LIST); 1728 lpfc_drop_node(phba, ndlp);
1769 return NLP_STE_FREED_NODE; 1729 return NLP_STE_FREED_NODE;
1770} 1730}
1771 1731
@@ -1964,7 +1924,7 @@ lpfc_disc_state_machine(struct lpfc_hba * phba,
1964 uint32_t(*func) (struct lpfc_hba *, struct lpfc_nodelist *, void *, 1924 uint32_t(*func) (struct lpfc_hba *, struct lpfc_nodelist *, void *,
1965 uint32_t); 1925 uint32_t);
1966 1926
1967 ndlp->nlp_disc_refcnt++; 1927 lpfc_nlp_get(ndlp);
1968 cur_state = ndlp->nlp_state; 1928 cur_state = ndlp->nlp_state;
1969 1929
1970 /* DSM in event <evt> on NPort <nlp_DID> in state <cur_state> */ 1930 /* DSM in event <evt> on NPort <nlp_DID> in state <cur_state> */
@@ -1987,18 +1947,7 @@ lpfc_disc_state_machine(struct lpfc_hba * phba,
1987 phba->brd_no, 1947 phba->brd_no,
1988 rc, ndlp->nlp_DID, ndlp->nlp_flag); 1948 rc, ndlp->nlp_DID, ndlp->nlp_flag);
1989 1949
1990 ndlp->nlp_disc_refcnt--; 1950 lpfc_nlp_put(ndlp);
1991 1951
1992 /* Check to see if ndlp removal is deferred */
1993 if ((ndlp->nlp_disc_refcnt == 0)
1994 && (ndlp->nlp_flag & NLP_DELAY_REMOVE)) {
1995 spin_lock_irq(phba->host->host_lock);
1996 ndlp->nlp_flag &= ~NLP_DELAY_REMOVE;
1997 spin_unlock_irq(phba->host->host_lock);
1998 lpfc_nlp_remove(phba, ndlp);
1999 return NLP_STE_FREED_NODE;
2000 }
2001 if (rc == NLP_STE_FREED_NODE)
2002 return NLP_STE_FREED_NODE;
2003 return rc; 1952 return rc;
2004} 1953}