All of lore.kernel.org
 help / color / mirror / Atom feed
From: James Smart <jsmart2021@gmail.com>
To: linux-scsi@vger.kernel.org
Cc: jsmart2021@gmail.com, Dick Kennedy <dick.kennedy@broadcom.com>,
	James Smart <james.smart@broadcom.com>
Subject: [PATCH v2 07/20] lpfc: Fix handling of FCP and NVME FC4 types in Pt2Pt topology
Date: Fri,  4 Aug 2017 17:47:18 -0700	[thread overview]
Message-ID: <20170805004731.1335-8-jsmart2021@gmail.com> (raw)
In-Reply-To: <20170805004731.1335-1-jsmart2021@gmail.com>

From: Dick Kennedy <dick.kennedy@broadcom.com>

After link bounce in a NVME Pt2Pt config, the driver managed to
map the same nport twice, resulting in multiple device nodes for the
same namespace.

In Pt2Pt, the driver must send PRLI's for both (scsi) FCP and NVME
rather than using fabric aids. The driver was inconsistent on handling
various PRLI completions, especially rejects, which had reject codes
cross the different protocol PRLI completions.

Fixed to perform the following:
if nvmet mode (fc port can only be a nvme target) - rejects all
unsolicitly FCP PRLI's. Never issues a FCP PRLI.

The multiple protocol PRLI's are sent simultaneously. However, driver
will now only state transition after both PRLI's are complete. New
flags were added to aid tracking the responses from the different PRLI's.

Signed-off-by: Dick Kennedy <dick.kennedy@broadcom.com>
Signed-off-by: James Smart <james.smart@broadcom.com>
---
 drivers/scsi/lpfc/lpfc_disc.h      |  1 +
 drivers/scsi/lpfc/lpfc_els.c       | 30 ++++++++++++++++++++++++++++++
 drivers/scsi/lpfc/lpfc_nportdisc.c |  9 +++++++++
 3 files changed, 40 insertions(+)

diff --git a/drivers/scsi/lpfc/lpfc_disc.h b/drivers/scsi/lpfc/lpfc_disc.h
index 094c97b9e5f7..f9a566eaef04 100644
--- a/drivers/scsi/lpfc/lpfc_disc.h
+++ b/drivers/scsi/lpfc/lpfc_disc.h
@@ -159,6 +159,7 @@ struct lpfc_node_rrq {
 #define NLP_RNID_SND       0x00000400	/* sent RNID request for this entry */
 #define NLP_ELS_SND_MASK   0x000007e0	/* sent ELS request for this entry */
 #define NLP_NVMET_RECOV    0x00001000   /* NVMET auditing node for recovery. */
+#define NLP_FCP_PRLI_RJT   0x00002000   /* Rport does not support FCP PRLI. */
 #define NLP_DEFER_RM       0x00010000	/* Remove this ndlp if no longer used */
 #define NLP_DELAY_TMO      0x00020000	/* delay timeout is running for node */
 #define NLP_NPR_2B_DISC    0x00040000	/* node is included in num_disc_nodes */
diff --git a/drivers/scsi/lpfc/lpfc_els.c b/drivers/scsi/lpfc/lpfc_els.c
index 9e9aa8bb7001..6962e22087c8 100644
--- a/drivers/scsi/lpfc/lpfc_els.c
+++ b/drivers/scsi/lpfc/lpfc_els.c
@@ -1966,6 +1966,7 @@ int
 lpfc_issue_els_plogi(struct lpfc_vport *vport, uint32_t did, uint8_t retry)
 {
 	struct lpfc_hba  *phba = vport->phba;
+	struct Scsi_Host *shost;
 	struct serv_parm *sp;
 	struct lpfc_nodelist *ndlp;
 	struct lpfc_iocbq *elsiocb;
@@ -1984,6 +1985,11 @@ lpfc_issue_els_plogi(struct lpfc_vport *vport, uint32_t did, uint8_t retry)
 	if (!elsiocb)
 		return 1;
 
+	shost = lpfc_shost_from_vport(vport);
+	spin_lock_irq(shost->host_lock);
+	ndlp->nlp_flag &= ~NLP_FCP_PRLI_RJT;
+	spin_unlock_irq(shost->host_lock);
+
 	pcmd = (uint8_t *) (((struct lpfc_dmabuf *) elsiocb->context2)->virt);
 
 	/* For PLOGI request, remainder of payload is service parameters */
@@ -3442,6 +3448,23 @@ lpfc_els_retry(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,
 				goto out_retry;
 			}
 			break;
+		case LSRJT_CMD_UNSUPPORTED:
+			/* lpfc nvmet returns this type of LS_RJT when it
+			 * receives an FCP PRLI because lpfc nvmet only
+			 * support NVME.  ELS request is terminated for FCP4
+			 * on this rport.
+			 */
+			if (stat.un.b.lsRjtRsnCodeExp ==
+			    LSEXP_REQ_UNSUPPORTED) {
+				if (cmd == ELS_CMD_PRLI) {
+					spin_lock_irq(shost->host_lock);
+					ndlp->nlp_flag |= NLP_FCP_PRLI_RJT;
+					spin_unlock_irq(shost->host_lock);
+					retry = 0;
+					goto out_retry;
+				}
+			}
+			break;
 		}
 		break;
 
@@ -8013,6 +8036,13 @@ lpfc_els_unsol_buffer(struct lpfc_hba *phba, struct lpfc_sli_ring *pring,
 			rjt_exp = LSEXP_NOTHING_MORE;
 			break;
 		}
+
+		/* NVMET accepts NVME PRLI only.  Reject FCP PRLI */
+		if (cmd == ELS_CMD_PRLI && phba->nvmet_support) {
+			rjt_err = LSRJT_CMD_UNSUPPORTED;
+			rjt_exp = LSEXP_REQ_UNSUPPORTED;
+			break;
+		}
 		lpfc_disc_state_machine(vport, ndlp, elsiocb, NLP_EVT_RCV_PRLI);
 		break;
 	case ELS_CMD_LIRR:
diff --git a/drivers/scsi/lpfc/lpfc_nportdisc.c b/drivers/scsi/lpfc/lpfc_nportdisc.c
index a4488d6339c1..f3ad7cac355d 100644
--- a/drivers/scsi/lpfc/lpfc_nportdisc.c
+++ b/drivers/scsi/lpfc/lpfc_nportdisc.c
@@ -1895,6 +1895,15 @@ lpfc_cmpl_prli_prli_issue(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
 			goto out;
 		}
 
+		/* When the rport rejected the FCP PRLI as unsupported.
+		 * This should only happen in Pt2Pt so an NVME PRLI
+		 * should be outstanding still.
+		 */
+		if (npr && ndlp->nlp_flag & NLP_FCP_PRLI_RJT) {
+			ndlp->nlp_fc4_type &= ~NLP_FC4_FCP;
+			goto out_err;
+		}
+
 		/* The LS Req had some error.  Don't let this be a
 		 * target.
 		 */
-- 
2.13.1

  parent reply	other threads:[~2017-08-05  0:47 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-05  0:47 [PATCH v2 00/20] lpfc updates for 11.4.0.3 James Smart
2017-08-05  0:47 ` [PATCH v2 01/20] lpfc: Fix plogi collision that causes illegal state transition James Smart
2017-08-07  7:49   ` Johannes Thumshirn
2017-08-05  0:47 ` [PATCH v2 02/20] lpfc: Fix loop mode target discovery James Smart
2017-08-07  7:55   ` Johannes Thumshirn
2017-08-05  0:47 ` [PATCH v2 03/20] lpfc: Fix rediscovery on switch blade pull James Smart
2017-08-07  7:56   ` Johannes Thumshirn
2017-08-05  0:47 ` [PATCH v2 04/20] lpfc: Fix oops when NVME Target is discovered in a nonNVME environment James Smart
2017-08-07  8:00   ` Johannes Thumshirn
2017-08-07 20:34     ` James Smart
2017-08-05  0:47 ` [PATCH v2 05/20] lpfc: convert info messages to standard messages James Smart
2017-08-07  8:00   ` Johannes Thumshirn
2017-08-05  0:47 ` [PATCH v2 06/20] lpfc: Correct return error codes to align with nvme_fc transport James Smart
2017-08-07  8:07   ` Johannes Thumshirn
2017-08-05  0:47 ` James Smart [this message]
2017-08-07  8:18   ` [PATCH v2 07/20] lpfc: Fix handling of FCP and NVME FC4 types in Pt2Pt topology Johannes Thumshirn
2017-08-05  0:47 ` [PATCH v2 08/20] lpfc: Fix duplicate NVME rport entries and namespaces James Smart
2017-08-07  8:33   ` Johannes Thumshirn
2017-08-05  0:47 ` [PATCH v2 09/20] lpfc: Fix crash in lpfc nvmet when fc port is reset James Smart
2017-08-07  8:34   ` Johannes Thumshirn
2017-08-05  0:47 ` [PATCH v2 10/20] lpfc: Fix NVME PRLI handling during RSCN James Smart
2017-08-07  8:35   ` Johannes Thumshirn
2017-08-05  0:47 ` [PATCH v2 11/20] lpfc: Correct issues with FAWWN and FDISCs James Smart
2017-08-05  0:47 ` [PATCH v2 12/20] lpfc: Limit amount of work processed in IRQ James Smart
2017-08-07  8:43   ` Johannes Thumshirn
2017-08-07 20:50     ` James Smart
2017-08-05  0:47 ` [PATCH v2 13/20] lpfc: Fix MRQ > 1 context list handling James Smart
2017-08-07  9:02   ` Johannes Thumshirn
2017-08-05  0:47 ` [PATCH v2 14/20] lpfc: Fix relative offset error on large nvmet target ios James Smart
2017-08-07  9:02   ` Johannes Thumshirn
2017-08-05  0:47 ` [PATCH v2 15/20] lpfc: Fix nvme target failure after 2nd adapter reset James Smart
2017-08-07  9:05   ` Johannes Thumshirn
2017-08-05  0:47 ` [PATCH v2 16/20] lpfc: Fix bad sgl reposting " James Smart
2017-08-07  9:06   ` Johannes Thumshirn
2017-08-05  0:47 ` [PATCH v2 17/20] lpfc: remove console log clutter James Smart
2017-08-07  9:06   ` Johannes Thumshirn
2017-08-05  0:47 ` [PATCH v2 18/20] lpfc: Add Buffer to Buffer credit recovery support James Smart
2017-08-07  9:08   ` Johannes Thumshirn
2017-08-05  0:47 ` [PATCH v2 19/20] scsi: lpfc: fix "integer constant too large" error on 32bit archs James Smart
2017-08-07  9:09   ` Johannes Thumshirn
2017-08-05  0:47 ` [PATCH v2 20/20] lpfc: lpfc version bump 11.4.0.3 James Smart
2017-08-07  9:08   ` Johannes Thumshirn

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=20170805004731.1335-8-jsmart2021@gmail.com \
    --to=jsmart2021@gmail.com \
    --cc=dick.kennedy@broadcom.com \
    --cc=james.smart@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.