Skip to contentSkip to conversation

scsi: qla2xxx: Fix P2P mode

PATCH In review Anastasia Kovaleva 2 participants 5 messages Apr 15, 2021 – Apr 22, 2021

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

cover scsi: qla2xxx: Fix P2P mode

Hi Greg and Sasha,

QLogic FC adapters don’t work in P2P mode on the latest stable 5.4 (at least QLE2692, and QLE2694, QLE2742 are affected).

We’ve tested and bisected from 5.4 up to 5.4.112 and figured out the following:

1. From 5.4 to 5.4.5 inclusively direct mode doesn’t work at all.

Stable commit a82545b62e07 ("scsi: qla2xxx: Change discovery state before PLOGI") fixes the issue in 5.4.6

2. From 5.4.6 to 5.4.68 inclusively direct mode works but FC link cannot be recovered after issue_lip and all presented LUNs are lost

Not working issue_lip is an outcome of a82545b62e07 applied to stable without the upstream commit 65e920093805 ("scsi: qla2xxx: Fix device connect issues in P2P configuration.").

3. From 5.4.69 up till now (5.4.112) direct mode doesn’t work again

The issue was introduced by stable commit 74924e407bf7 ("scsi: qla2xxx:
Retry PLOGI on FC-NVMe PRLI failure").

Upstream commit 84ed362ac40c ("scsi: qla2xxx: Dual FCP-NVMe target port support") fixes the issue.

So, in order to fix both P2P issues we need to apply upstream commits 65e920093805 and 84ed362ac40c.

However, stable commits 0b84591fdd5e ("scsi: qla2xxx: Fix stuck login session using prli_pend_timer") introduced in 5.4.19 and 74924e407bf7 ("scsi: qla2xxx:
Retry PLOGI on FC-NVMe PRLI failure") in 5.4.69 were applied in the wrong order, upstream and chronological-wise with regards to required upstream fixes, and cherry-picking of the fixes is not possible without a merge conflict.

The series provides merge conflict resolution and resolves both P2P discovery and issue_lip issue. It has been tested over Linux stable 5.4.112 and Ubuntu 20.04 kernel 5.4.0-71.79 (that's based off stable 5.4.101).

Please apply at your earliest convenience to 5.4 stable.

thanks,
Anastasia

Arun Easi (1):
scsi: qla2xxx: Fix device connect issues in P2P configuration

Michael Hernandez (1):
scsi: qla2xxx: Dual FCP-NVMe target port support

 drivers/scsi/qla2xxx/qla_def.h    | 26 +++++++++++-
 drivers/scsi/qla2xxx/qla_fw.h     |  2 +
 drivers/scsi/qla2xxx/qla_gbl.h    |  1 +
 drivers/scsi/qla2xxx/qla_gs.c     | 42 +++++++++++--------
 drivers/scsi/qla2xxx/qla_init.c   | 70 +++++++++++++++++++------------
 drivers/scsi/qla2xxx/qla_inline.h | 12 ++++++
 drivers/scsi/qla2xxx/qla_iocb.c   |  5 +--
 drivers/scsi/qla2xxx/qla_mbx.c    | 11 ++---
 drivers/scsi/qla2xxx/qla_os.c     | 17 ++++----
 9 files changed, 124 insertions(+), 62 deletions(-)
Signature · 1 line
2.30.2
#1 lore raw

PATCH 1/2 scsi: qla2xxx: Dual FCP-NVMe target port support

From: Michael Hernandez <[email protected]>

[ Upstream commit 84ed362ac40ca44dbbbebf767301463aa72bc797 ]

Some storage arrays advertise FCP LUNs and NVMe namespaces behind the same WWN. The driver now offers a user option by way of NVRAM parameter to allow users to choose, on a per port basis, the kind of FC-4 type they would like to prioritize for login.

[yadro: restored patch order between the upstream commit, 983f127603fac6 and 8aaac2d7da873a]
---
 drivers/scsi/qla2xxx/qla_def.h    | 26 ++++++++++++-
 drivers/scsi/qla2xxx/qla_fw.h     |  2 +
 drivers/scsi/qla2xxx/qla_gs.c     | 42 ++++++++++++---------
 drivers/scsi/qla2xxx/qla_init.c   | 61 ++++++++++++++++++-------------
 drivers/scsi/qla2xxx/qla_inline.h | 12 ++++++
 drivers/scsi/qla2xxx/qla_mbx.c    | 11 +++---
 drivers/scsi/qla2xxx/qla_os.c     | 17 ++++-----
 7 files changed, 112 insertions(+), 59 deletions(-)
drivers/scsi/qla2xxx/qla_def.h +24 -2
index c57b95a20688..d4c16ae92a2a 100644
@@ -2281,7 +2281,7 @@ typedef struct {
 	uint8_t fabric_port_name[WWN_SIZE];
 	uint16_t fp_speed;
 	uint8_t fc4_type;
-	uint8_t fc4f_nvme;	/* nvme fc4 feature bits */
+	uint8_t fc4_features;
 } sw_info_t;
 
 /* FCP-4 types */
@@ -2452,7 +2452,7 @@ typedef struct fc_port {
 	u32 supported_classes;
 
 	uint8_t fc4_type;
-	uint8_t	fc4f_nvme;
+	uint8_t fc4_features;
 	uint8_t scan_state;
 
 	unsigned long last_queue_full;
@@ -2483,6 +2483,9 @@ typedef struct fc_port {
 	u16 n2n_chip_reset;
 } fc_port_t;
 
+#define FC4_PRIORITY_NVME	0
+#define FC4_PRIORITY_FCP	1
+
 #define QLA_FCPORT_SCAN		1
 #define QLA_FCPORT_FOUND	2
 
@@ -4298,6 +4301,8 @@ struct qla_hw_data {
 	atomic_t        nvme_active_aen_cnt;
 	uint16_t        nvme_last_rptd_aen;             /* Last recorded aen count */
 
+	uint8_t fc4_type_priority;
+
 	atomic_t zio_threshold;
 	uint16_t last_zio_threshold;
 
@@ -4823,6 +4828,23 @@ struct sff_8247_a0 {
 	 ha->current_topology == ISP_CFG_N || \
 	 !ha->current_topology)
 
+#define NVME_TYPE(fcport) \
+	(fcport->fc4_type & FS_FC4TYPE_NVME) \
+
+#define FCP_TYPE(fcport) \
+	(fcport->fc4_type & FS_FC4TYPE_FCP) \
+
+#define NVME_ONLY_TARGET(fcport) \
+	(NVME_TYPE(fcport) && !FCP_TYPE(fcport))  \
+
+#define NVME_FCP_TARGET(fcport) \
+	(FCP_TYPE(fcport) && NVME_TYPE(fcport)) \
+
+#define NVME_TARGET(ha, fcport) \
+	((NVME_FCP_TARGET(fcport) && \
+	(ha->fc4_type_priority == FC4_PRIORITY_NVME)) || \
+	NVME_ONLY_TARGET(fcport)) \
+
 #define PRLI_PHASE(_cls) \
 	((_cls == DSC_LS_PRLI_PEND) || (_cls == DSC_LS_PRLI_COMP))
 
drivers/scsi/qla2xxx/qla_fw.h +2 -0
index dc2366a29665..9dc09c117416 100644
@@ -2105,4 +2105,6 @@ struct qla_fcp_prio_cfg {
 #define FA_FLASH_LAYOUT_ADDR_83	(0x3F1000/4)
 #define FA_FLASH_LAYOUT_ADDR_28	(0x11000/4)
 
+#define NVRAM_DUAL_FCP_NVME_FLAG_OFFSET	0x196
+
 #endif
drivers/scsi/qla2xxx/qla_gs.c +25 -17

83 lines not on this page · raw message

drivers/scsi/qla2xxx/qla_init.c +35 -26

147 lines not on this page · raw message

drivers/scsi/qla2xxx/qla_inline.h +12 -0
index 6dfde42d799b..af91e567a38d 100644
@@ -312,3 +312,15 @@ qla_83xx_start_iocbs(struct qla_qpair *qpair)
 
 	WRT_REG_DWORD(req->req_q_in, req->ring_index);
 }
+
+static inline int
+qla2xxx_get_fc4_priority(struct scsi_qla_host *vha)
+{
+	uint32_t data;
+
+	data =
+	    ((uint8_t *)vha->hw->nvram)[NVRAM_DUAL_FCP_NVME_FLAG_OFFSET];
+
+
+	return ((data >> 6) & BIT_0);
+}
drivers/scsi/qla2xxx/qla_mbx.c +6 -5
index c1631e42d35d..098388a12feb 100644
@@ -1924,7 +1924,7 @@ qla2x00_get_port_database(scsi_qla_host_t *vha, fc_port_t *fcport, uint8_t opt)
 		pd24 = (struct port_database_24xx *) pd;
 
 		/* Check for logged in state. */
-		if (fcport->fc4f_nvme) {
+		if (NVME_TARGET(ha, fcport)) {
 			current_login_state = pd24->current_login_state >> 4;
 			last_login_state = pd24->last_login_state >> 4;
 		} else {
@@ -3891,8 +3891,9 @@ qla24xx_report_id_acquisition(scsi_qla_host_t *vha,
 				fcport->scan_state = QLA_FCPORT_FOUND;
 				fcport->n2n_flag = 1;
 				fcport->keep_nport_handle = 1;
+				fcport->fc4_type = FS_FC4TYPE_FCP;
 				if (vha->flags.nvme_enabled)
-					fcport->fc4f_nvme = 1;
+					fcport->fc4_type |= FS_FC4TYPE_NVME;
 
 				switch (fcport->disc_state) {
 				case DSC_DELETED:
@@ -6350,7 +6351,7 @@ int __qla24xx_parse_gpdb(struct scsi_qla_host *vha, fc_port_t *fcport,
 	uint64_t zero = 0;
 	u8 current_login_state, last_login_state;
 
-	if (fcport->fc4f_nvme) {
+	if (NVME_TARGET(vha->hw, fcport)) {
 		current_login_state = pd->current_login_state >> 4;
 		last_login_state = pd->last_login_state >> 4;
 	} else {
@@ -6385,8 +6386,8 @@ int __qla24xx_parse_gpdb(struct scsi_qla_host *vha, fc_port_t *fcport,
 	fcport->d_id.b.al_pa = pd->port_id[2];
 	fcport->d_id.b.rsvd_1 = 0;
 
-	if (fcport->fc4f_nvme) {
-		fcport->port_type = 0;
+	if (NVME_TARGET(vha->hw, fcport)) {
+		fcport->port_type = FCT_NVME;
 		if ((pd->prli_svc_param_word_3[0] & BIT_5) == 0)
 			fcport->port_type |= FCT_NVME_INITIATOR;
 		if ((pd->prli_svc_param_word_3[0] & BIT_4) == 0)
drivers/scsi/qla2xxx/qla_os.c +8 -9
index 67b1e74fcd1e..899dfb445710 100644
@@ -5055,19 +5055,17 @@ void qla24xx_create_new_sess(struct scsi_qla_host *vha, struct qla_work_evt *e)
 			fcport->d_id = e->u.new_sess.id;
 			fcport->flags |= FCF_FABRIC_DEVICE;
 			fcport->fw_login_state = DSC_LS_PLOGI_PEND;
-			if (e->u.new_sess.fc4_type == FS_FC4TYPE_FCP)
-				fcport->fc4_type = FC4_TYPE_FCP_SCSI;
-
-			if (e->u.new_sess.fc4_type == FS_FC4TYPE_NVME) {
-				fcport->fc4_type = FC4_TYPE_OTHER;
-				fcport->fc4f_nvme = FC4_TYPE_NVME;
-			}
 
 			memcpy(fcport->port_name, e->u.new_sess.port_name,
 			    WWN_SIZE);
 
-			if (e->u.new_sess.fc4_type & FS_FCP_IS_N2N)
+			fcport->fc4_type = e->u.new_sess.fc4_type;
+			if (e->u.new_sess.fc4_type & FS_FCP_IS_N2N) {
+				fcport->fc4_type = FS_FC4TYPE_FCP;
 				fcport->n2n_flag = 1;
+				if (vha->flags.nvme_enabled)
+					fcport->fc4_type |= FS_FC4TYPE_NVME;
+			}
 
 		} else {
 			ql_dbg(ql_dbg_disc, vha, 0xffff,
@@ -5171,7 +5169,8 @@ void qla24xx_create_new_sess(struct scsi_qla_host *vha, struct qla_work_evt *e)
 				fcport->flags &= ~FCF_FABRIC_DEVICE;
 				fcport->keep_nport_handle = 1;
 				if (vha->flags.nvme_enabled) {
-					fcport->fc4f_nvme = 1;
+					fcport->fc4_type =
+					    (FS_FC4TYPE_NVME | FS_FC4TYPE_FCP);
 					fcport->n2n_flag = 1;
 				}
 				fcport->fw_login_state = 0;
Signature · 1 line
2.30.2
#2 lore raw

PATCH 2/2 scsi: qla2xxx: Fix device connect issues in P2P configuration

In reply to Anastasia Kovaleva

From: Arun Easi <[email protected]>

[ Upstream commit 65e9200938052ce90f24421bb057e1be1d6147c7 ]

P2P needs to take the alternate plogi route.

---
 drivers/scsi/qla2xxx/qla_gbl.h  | 1 +
 drivers/scsi/qla2xxx/qla_init.c | 9 +++++++++
 drivers/scsi/qla2xxx/qla_iocb.c | 5 ++---
 3 files changed, 12 insertions(+), 3 deletions(-)
drivers/scsi/qla2xxx/qla_gbl.h +1 -0
index d11416dcee4e..5b163ad85c34 100644
@@ -917,4 +917,5 @@ int qla2x00_set_data_rate(scsi_qla_host_t *vha, uint16_t mode);
 
 /* nvme.c */
 void qla_nvme_unregister_remote_port(struct fc_port *fcport);
+void qla_handle_els_plogi_done(scsi_qla_host_t *vha, struct event_arg *ea);
 #endif /* _QLA_GBL_H */
drivers/scsi/qla2xxx/qla_init.c +9 -0
index bdc46e6c3de8..6d5953c529cd 100644
@@ -1756,6 +1756,15 @@ void qla24xx_handle_relogin_event(scsi_qla_host_t *vha,
 	qla24xx_fcport_handle_login(vha, fcport);
 }
 
+void qla_handle_els_plogi_done(scsi_qla_host_t *vha,
+				      struct event_arg *ea)
+{
+	ql_dbg(ql_dbg_disc, vha, 0x2118,
+	    "%s %d %8phC post PRLI\n",
+	    __func__, __LINE__, ea->fcport->port_name);
+	qla24xx_post_prli_work(vha, ea->fcport);
+}
+
 /*
  * RSCN(s) came in for this fcport, but the RSCN(s) was not able
  * to be consumed by the fcport
drivers/scsi/qla2xxx/qla_iocb.c +2 -3
index aed4ce66e6cf..53ccbd6b71ed 100644
@@ -2769,9 +2769,8 @@ static void qla2x00_els_dcmd2_sp_done(srb_t *sp, int res)
 		case CS_COMPLETE:
 			memset(&ea, 0, sizeof(ea));
 			ea.fcport = fcport;
-			ea.data[0] = MBS_COMMAND_COMPLETE;
-			ea.sp = sp;
-			qla24xx_handle_plogi_done_event(vha, &ea);
+			ea.rc = res;
+			qla_handle_els_plogi_done(vha, &ea);
 			break;
 
 		case CS_IOCB_ERROR:
Signature · 1 line
2.30.2
maintainer
#3 lore raw
In reply to Anastasia Kovaleva
Quoted 22 lines · Anastasia Kovaleva

Hi Greg and Sasha,

QLogic FC adapters don’t work in P2P mode on the latest stable 5.4 (at least QLE2692, and QLE2694, QLE2742 are affected).

We’ve tested and bisected from 5.4 up to 5.4.112 and figured out the following:

1. From 5.4 to 5.4.5 inclusively direct mode doesn’t work at all.

Stable commit a82545b62e07 ("scsi: qla2xxx: Change discovery state before PLOGI") fixes the issue in 5.4.6

2. From 5.4.6 to 5.4.68 inclusively direct mode works but FC link cannot be recovered after issue_lip and all presented LUNs are lost

Not working issue_lip is an outcome of a82545b62e07 applied to stable without the upstream commit 65e920093805 ("scsi: qla2xxx: Fix device connect issues in P2P configuration.").

3. From 5.4.69 up till now (5.4.112) direct mode doesn’t work again

Quoted 8 lines

The issue was introduced by stable commit 74924e407bf7 ("scsi: qla2xxx:
Retry PLOGI on FC-NVMe PRLI failure").

Upstream commit 84ed362ac40c ("scsi: qla2xxx: Dual FCP-NVMe target port support") fixes the issue.

So, in order to fix both P2P issues we need to apply upstream commits 65e920093805 and 84ed362ac40c.

That's a great analysis, thank you.

Quoted 5 lines

However, stable commits 0b84591fdd5e ("scsi: qla2xxx: Fix stuck login session using prli_pend_timer") introduced in 5.4.19 and 74924e407bf7 ("scsi: qla2xxx:
Retry PLOGI on FC-NVMe PRLI failure") in 5.4.69 were applied in the wrong order, upstream and chronological-wise with regards to required upstream fixes, and cherry-picking of the fixes is not possible without a merge conflict.

Right, in particular: 74924e407bf7 ("scsi: qla2xxx: Retry PLOGI on FC-NVMe PRLI failure") was modified to work around missing 84ed362ac40c ("scsi: qla2xxx: Dual FCP-NVMe target port support"), which is where the rest of the conflicts are coming from.

Quoted 5 lines

The series provides merge conflict resolution and resolves both P2P discovery and issue_lip issue. It has been tested over Linux stable 5.4.112 and Ubuntu 20.04 kernel 5.4.0-71.79 (that's based off stable 5.4.101).

Please apply at your earliest convenience to 5.4 stable.

So instead of applying even more modified patches that'll create similar issue in the future, I backed up 0b84591fdd5e and 74924e407bf7, and applied the 4 commits you've pointed out in the "correct" order. I also grabbed 27258a577144 ("scsi: qla2xxx: Add a shadow variable to hold disc_state history of fcport") for completeness.

Thanks for diagnosing this issue! Please let me know if something is still broken.

Signature · 2 lines
Thanks,
Sasha
#4 lore raw
Quoted 2 lines

Thanks for diagnosing this issue! Please let me know if something is still broken.

Hi Sasha,

I've tested P2P mode on v5.4.114, the P2P login issue is resolved.

Thanks a lot!
Anastasia