All of lore.kernel.org
 help / color / mirror / Atom feed
From: James Smart <jsmart2021@gmail.com>
To: linux-scsi@vger.kernel.org
Cc: James Smart <jsmart2021@gmail.com>,
	Dick Kennedy <dick.kennedy@broadcom.com>
Subject: [PATCH v2 12/22] lpfc: Fix dropped FLOGI during pt2pt discovery recovery
Date: Mon,  1 Mar 2021 09:18:11 -0800	[thread overview]
Message-ID: <20210301171821.3427-13-jsmart2021@gmail.com> (raw)
In-Reply-To: <20210301171821.3427-1-jsmart2021@gmail.com>

When connected in pt2pt mode, there is a scenario where the remote port
significantly delays sending a response to our FLOGI, but acts on the
FLOGI it sent us and proceeds to PLOGI/PRLI.  The FLOGI ends up timing
out and kicks off recovery logic. End result is a lot of unnecessary
state changes and lots of discovery messages being logged.

Fix by terminating the FLOGI and noop'ing it's completion if we have
already accepted the remote ports FLOGI and are now processing PLOGI.

Co-developed-by: Dick Kennedy <dick.kennedy@broadcom.com>
Signed-off-by: Dick Kennedy <dick.kennedy@broadcom.com>
Signed-off-by: James Smart <jsmart2021@gmail.com>
---
 drivers/scsi/lpfc/lpfc.h           |  1 +
 drivers/scsi/lpfc/lpfc_crtn.h      |  2 ++
 drivers/scsi/lpfc/lpfc_els.c       | 10 ++++++++--
 drivers/scsi/lpfc/lpfc_nportdisc.c | 10 ++++++++++
 drivers/scsi/lpfc/lpfc_sli.c       |  2 +-
 5 files changed, 22 insertions(+), 3 deletions(-)

diff --git a/drivers/scsi/lpfc/lpfc.h b/drivers/scsi/lpfc/lpfc.h
index 6ba5fa08c47a..431c0d5376d9 100644
--- a/drivers/scsi/lpfc/lpfc.h
+++ b/drivers/scsi/lpfc/lpfc.h
@@ -782,6 +782,7 @@ struct lpfc_hba {
 #define HBA_NEEDS_CFG_PORT	0x2000000 /* SLI3 - needs a CONFIG_PORT mbox */
 #define HBA_HBEAT_INP		0x4000000 /* mbox HBEAT is in progress */
 #define HBA_HBEAT_TMO		0x8000000 /* HBEAT initiated after timeout */
+#define HBA_FLOGI_OUTSTANDING	0x10000000 /* FLOGI is outstanding */
 
 	uint32_t fcp_ring_in_use; /* When polling test if intr-hndlr active*/
 	struct lpfc_dmabuf slim2p;
diff --git a/drivers/scsi/lpfc/lpfc_crtn.h b/drivers/scsi/lpfc/lpfc_crtn.h
index a0aad4896a45..43820ab8a6e8 100644
--- a/drivers/scsi/lpfc/lpfc_crtn.h
+++ b/drivers/scsi/lpfc/lpfc_crtn.h
@@ -103,6 +103,8 @@ int lpfc_check_sli_ndlp(struct lpfc_hba *, struct lpfc_sli_ring *,
 struct lpfc_nodelist *lpfc_nlp_init(struct lpfc_vport *vport, uint32_t did);
 struct lpfc_nodelist *lpfc_nlp_get(struct lpfc_nodelist *);
 int  lpfc_nlp_put(struct lpfc_nodelist *);
+void lpfc_ignore_els_cmpl(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,
+			  struct lpfc_iocbq *rspiocb);
 int  lpfc_nlp_not_used(struct lpfc_nodelist *ndlp);
 struct lpfc_nodelist *lpfc_setup_disc_node(struct lpfc_vport *, uint32_t);
 void lpfc_disc_list_loopmap(struct lpfc_vport *);
diff --git a/drivers/scsi/lpfc/lpfc_els.c b/drivers/scsi/lpfc/lpfc_els.c
index 3bd1482af72f..0e92a0b61e77 100644
--- a/drivers/scsi/lpfc/lpfc_els.c
+++ b/drivers/scsi/lpfc/lpfc_els.c
@@ -1200,6 +1200,7 @@ lpfc_cmpl_els_flogi(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,
 		lpfc_issue_clear_la(phba, vport);
 	}
 out:
+	phba->hba_flag &= ~HBA_FLOGI_OUTSTANDING;
 	lpfc_els_free_iocb(phba, cmdiocb);
 	lpfc_nlp_put(ndlp);
 }
@@ -1354,7 +1355,7 @@ lpfc_issue_els_flogi(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
 		return 1;
 	}
 
-	phba->hba_flag |= HBA_FLOGI_ISSUED;
+	phba->hba_flag |= (HBA_FLOGI_ISSUED | HBA_FLOGI_OUTSTANDING);
 
 	/* Check for a deferred FLOGI ACC condition */
 	if (phba->defer_flogi_acc_flag) {
@@ -1425,9 +1426,14 @@ lpfc_els_abort_flogi(struct lpfc_hba *phba)
 		icmd = &iocb->iocb;
 		if (icmd->ulpCommand == CMD_ELS_REQUEST64_CR) {
 			ndlp = (struct lpfc_nodelist *)(iocb->context1);
-			if (ndlp && (ndlp->nlp_DID == Fabric_DID))
+			if (ndlp && ndlp->nlp_DID == Fabric_DID) {
+				if ((phba->pport->fc_flag & FC_PT2PT) &&
+				    !(phba->pport->fc_flag & FC_PT2PT_PLOGI))
+					iocb->fabric_iocb_cmpl =
+						lpfc_ignore_els_cmpl;
 				lpfc_sli_issue_abort_iotag(phba, pring, iocb,
 							   NULL);
+			}
 		}
 	}
 	/* Make sure HBA is alive */
diff --git a/drivers/scsi/lpfc/lpfc_nportdisc.c b/drivers/scsi/lpfc/lpfc_nportdisc.c
index 4918423960d6..57e4aef8a9a3 100644
--- a/drivers/scsi/lpfc/lpfc_nportdisc.c
+++ b/drivers/scsi/lpfc/lpfc_nportdisc.c
@@ -523,6 +523,16 @@ lpfc_rcv_plogi(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
 		/* rcv'ed PLOGI decides what our NPortId will be */
 		vport->fc_myDID = icmd->un.rcvels.parmRo;
 
+		/* If there is an outstanding FLOGI, abort it now.
+		 * The remote NPort is not going to ACC our FLOGI
+		 * if its already issuing a PLOGI for pt2pt mode.
+		 * This indicates our FLOGI was dropped; however, we
+		 * must have ACCed the remote NPorts FLOGI to us
+		 * to make it here.
+		 */
+		if (phba->hba_flag & HBA_FLOGI_OUTSTANDING)
+			lpfc_els_abort_flogi(phba);
+
 		ed_tov = be32_to_cpu(sp->cmn.e_d_tov);
 		if (sp->cmn.edtovResolution) {
 			/* E_D_TOV ticks are in nanoseconds */
diff --git a/drivers/scsi/lpfc/lpfc_sli.c b/drivers/scsi/lpfc/lpfc_sli.c
index 99307bb7b62c..56112c9fb6aa 100644
--- a/drivers/scsi/lpfc/lpfc_sli.c
+++ b/drivers/scsi/lpfc/lpfc_sli.c
@@ -11591,7 +11591,7 @@ lpfc_sli_abort_els_cmpl(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,
  * which are aborted. The function frees memory resources used for
  * the aborted ELS commands.
  **/
-static void
+void
 lpfc_ignore_els_cmpl(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,
 		     struct lpfc_iocbq *rspiocb)
 {
-- 
2.26.2


  parent reply	other threads:[~2021-03-01 17:27 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-01 17:17 [PATCH v2 00/22] lpfc: Update lpfc to revision 12.8.0.8 James Smart
2021-03-01 17:18 ` [PATCH v2 01/22] lpfc: Fix incorrect dbde assignment when building target abts wqe James Smart
2021-03-01 17:18 ` [PATCH v2 02/22] lpfc: Fix vport indices in lpfc_find_vport_by_vpid() James Smart
2021-03-01 17:18 ` [PATCH v2 03/22] lpfc: Fix reftag generation sizing errors James Smart
2021-03-01 17:18 ` [PATCH v2 04/22] lpfc: Fix stale node accesses on stale RRQ request James Smart
2021-03-01 17:18 ` [PATCH v2 05/22] lpfc: Fix FLOGI failure due to accessing a freed node James Smart
2021-03-01 17:18 ` [PATCH v2 06/22] lpfc: Fix lpfc_els_retry() possible null pointer dereference James Smart
2021-03-01 17:18 ` [PATCH v2 07/22] lpfc: Fix pt2pt connection does not recover after LOGO James Smart
2021-03-01 17:18 ` [PATCH v2 08/22] lpfc: Fix unnecessary null check in lpfc_release_scsi_buf James Smart
2021-03-01 17:18 ` [PATCH v2 09/22] lpfc: Fix null pointer dereference in lpfc_prep_els_iocb() James Smart
2021-03-01 17:18 ` [PATCH v2 10/22] lpfc: Fix use after free in lpfc_els_free_iocb James Smart
2021-03-01 17:18 ` [PATCH v2 11/22] lpfc: Fix status returned in lpfc_els_retry() error exit path James Smart
2021-03-01 17:18 ` James Smart [this message]
2021-03-01 17:18 ` [PATCH v2 13/22] lpfc: Fix PLOGI ACC to be transmit after REG_LOGIN James Smart
2021-03-01 17:18 ` [PATCH v2 14/22] lpfc: Fix ADISC handling that never frees nodes James Smart
2021-03-01 17:18 ` [PATCH v2 15/22] lpfc: Fix nodeinfo debugfs output James Smart
2021-03-01 17:18 ` [PATCH v2 16/22] lpfc: Fix pt2pt state transition causing rmmod hang James Smart
2021-03-01 17:18 ` [PATCH v2 17/22] lpfc: Fix crash caused by switch reboot James Smart
2021-03-01 17:18 ` [PATCH v2 18/22] lpfc: Change wording of invalid pci reset log message James Smart
2021-03-01 17:18 ` [PATCH v2 19/22] lpfc: Reduce LOG_TRACE_EVENT logging for vports James Smart
2021-03-01 17:18 ` [PATCH v2 20/22] lpfc: Correct function header comments related to ndlp reference counting James Smart
2021-03-01 17:18 ` [PATCH v2 21/22] lpfc: Update lpfc version to 12.8.0.8 James Smart
2021-03-01 17:18 ` [PATCH v2 22/22] lpfc: update copyrights for 12.8.0.7 and 12.8.0.8 changes James Smart
2021-03-04  3:44 ` [PATCH v2 00/22] lpfc: Update lpfc to revision 12.8.0.8 Martin K. Petersen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210301171821.3427-13-jsmart2021@gmail.com \
    --to=jsmart2021@gmail.com \
    --cc=dick.kennedy@broadcom.com \
    --cc=linux-scsi@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.