Commit 04c32001 authored by Justin Tee's avatar Justin Tee Committed by Martin K. Petersen
Browse files

scsi: lpfc: Set Establish Image Pair service parameter only for Target Functions



Previously, Establish Image Pair was set in all PRLI_ACC responses
regardless if the received PRLI was from an initiator or target function.
Specific target vendors that can operate in both initiator and target mode,
may view the PRLI_ACC with Establish Image Pair set as an invalid service
parameter when operating in initiator only mode.  This causes discovery
issues later when the target switches on its target mode function.

Revise logic that determines an rport's role as an initiator or target and
set the Establish Image Pair service parameter bit only if the Target
Function bit is set.

Signed-off-by: default avatarJustin Tee <justin.tee@broadcom.com>
Link: https://lore.kernel.org/r/20230712180522.112722-7-justintee8345@gmail.com


Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
parent 90cec07f
Loading
Loading
Loading
Loading
+15 −1
Original line number Diff line number Diff line
@@ -6165,11 +6165,25 @@ lpfc_els_rsp_prli_acc(struct lpfc_vport *vport, struct lpfc_iocbq *oldiocb,
			npr->TaskRetryIdReq = 1;
		}
		npr->acceptRspCode = PRLI_REQ_EXECUTED;

		/* Set image pair for complementary pairs only. */
		if (ndlp->nlp_type & NLP_FCP_TARGET)
			npr->estabImagePair = 1;
		else
			npr->estabImagePair = 0;
		npr->readXferRdyDis = 1;
		npr->ConfmComplAllowed = 1;
		npr->prliType = PRLI_FCP_TYPE;
		npr->initiatorFunc = 1;

		/* Xmit PRLI ACC response tag <ulpIoTag> */
		lpfc_printf_vlog(vport, KERN_INFO,
				 LOG_ELS | LOG_NODE | LOG_DISCOVERY,
				 "6014 FCP issue PRLI ACC imgpair %d "
				 "retry %d task %d\n",
				 npr->estabImagePair,
				 npr->Retry, npr->TaskRetryIdReq);

	} else if (prli_fc4_req == PRLI_NVME_TYPE) {
		/* Respond with an NVME PRLI Type */
		npr_nvme = (struct lpfc_nvme_prli *) pcmd;
+2 −0
Original line number Diff line number Diff line
@@ -764,6 +764,8 @@ typedef struct _PRLI { /* Structure is in Big Endian format */
#define PRLI_PREDEF_CONFIG    0x5
#define PRLI_PARTIAL_SUCCESS  0x6
#define PRLI_INVALID_PAGE_CNT 0x7
#define PRLI_INV_SRV_PARM     0x8

	uint8_t word0Reserved3;	/* FC Parm Word 0, bit 0:7 */

	uint32_t origProcAssoc;	/* FC Parm Word 1, bit 0:31 */
+25 −14
Original line number Diff line number Diff line
@@ -2148,6 +2148,7 @@ lpfc_cmpl_prli_prli_issue(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
	struct lpfc_nvme_prli *nvpr;
	void *temp_ptr;
	u32 ulp_status;
	bool acc_imode_sps = false;

	cmdiocb = (struct lpfc_iocbq *) arg;
	rspiocb = cmdiocb->rsp_iocb;
@@ -2182,12 +2183,22 @@ lpfc_cmpl_prli_prli_issue(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
		goto out_err;
	}

	if (npr && (npr->acceptRspCode == PRLI_REQ_EXECUTED) &&
	    (npr->prliType == PRLI_FCP_TYPE)) {
		lpfc_printf_vlog(vport, KERN_INFO, LOG_NVME_DISC,
				 "6028 FCP NPR PRLI Cmpl Init %d Target %d\n",
				 npr->initiatorFunc,
				 npr->targetFunc);
	if (npr && npr->prliType == PRLI_FCP_TYPE) {
		lpfc_printf_vlog(vport, KERN_INFO,
				 LOG_ELS | LOG_NODE | LOG_DISCOVERY,
				 "6028 FCP NPR PRLI Cmpl Init %d Target %d "
				 "EIP %d AccCode x%x\n",
				 npr->initiatorFunc, npr->targetFunc,
				 npr->estabImagePair, npr->acceptRspCode);

		if (npr->acceptRspCode == PRLI_INV_SRV_PARM) {
			/* Strict initiators don't establish an image pair. */
			if (npr->initiatorFunc && !npr->targetFunc &&
			    !npr->estabImagePair)
				acc_imode_sps = true;
		}

		if (npr->acceptRspCode == PRLI_REQ_EXECUTED || acc_imode_sps) {
			if (npr->initiatorFunc)
				ndlp->nlp_type |= NLP_FCP_INITIATOR;
			if (npr->targetFunc) {
@@ -2197,7 +2208,7 @@ lpfc_cmpl_prli_prli_issue(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
			}
			if (npr->Retry)
				ndlp->nlp_fcp_info |= NLP_FCP_2_DEVICE;

		}
	} else if (nvpr &&
		   (bf_get_be32(prli_acc_rsp_code, nvpr) ==
		    PRLI_REQ_EXECUTED) &&