Blame SOURCES/0137-scsi-scsi-qla2xxx-Dual-FCP-NVMe-target-port-support.patch

3c6e85
From f705e9236b22df5bc170d449f4100368f7e5915d Mon Sep 17 00:00:00 2001
3c6e85
From: Himanshu Madhani <hmadhani@redhat.com>
3c6e85
Date: Thu, 21 Nov 2019 16:36:47 -0500
3c6e85
Subject: [PATCH 137/155] [scsi] scsi: qla2xxx: Dual FCP-NVMe target port
3c6e85
 support
3c6e85
3c6e85
Message-id: <20191121163701.43688-13-hmadhani@redhat.com>
3c6e85
Patchwork-id: 287851
3c6e85
O-Subject: [RHLE 7.8 e-stor PATCH v3 12/26] scsi: qla2xxx: Dual FCP-NVMe target port support
3c6e85
Bugzilla: 1731581
3c6e85
RH-Acked-by: Jarod Wilson <jarod@redhat.com>
3c6e85
RH-Acked-by: Ewan Milne <emilne@redhat.com>
3c6e85
RH-Acked-by: Tony Camuso <tcamuso@redhat.com>
3c6e85
3c6e85
From: Michael Hernandez <mhernandez@marvell.com>
3c6e85
3c6e85
Bugzilla 1731581
3c6e85
3c6e85
Some storage arrays advertise FCP LUNs and NVMe namespaces behind the same
3c6e85
WWN.  The driver now offers a user option by way of NVRAM parameter to
3c6e85
allow users to choose, on a per port basis, the kind of FC-4 type they
3c6e85
would like to prioritize for login.
3c6e85
3c6e85
Link: https://lore.kernel.org/r/20190912180918.6436-9-hmadhani@marvell.com
3c6e85
Signed-off-by: Michael Hernandez <mhernandez@marvell.com>
3c6e85
Signed-off-by: Himanshu Madhani <hmadhani@marvell.com>
3c6e85
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3c6e85
(cherry picked from commit 84ed362ac40ca44dbbbebf767301463aa72bc797)
3c6e85
Signed-off-by: Himanshu Madhani <hmadhani@redhat.com>
3c6e85
Signed-off-by: Jan Stancek <jstancek@redhat.com>
3c6e85
---
3c6e85
 drivers/scsi/qla2xxx/qla_def.h    | 26 ++++++++++++++--
3c6e85
 drivers/scsi/qla2xxx/qla_fw.h     |  2 ++
3c6e85
 drivers/scsi/qla2xxx/qla_gs.c     | 42 ++++++++++++++-----------
3c6e85
 drivers/scsi/qla2xxx/qla_init.c   | 64 ++++++++++++++++++++++-----------------
3c6e85
 drivers/scsi/qla2xxx/qla_inline.h | 12 ++++++++
3c6e85
 drivers/scsi/qla2xxx/qla_mbx.c    | 11 ++++---
3c6e85
 drivers/scsi/qla2xxx/qla_os.c     | 17 +++++------
3c6e85
 7 files changed, 114 insertions(+), 60 deletions(-)
3c6e85
3c6e85
Index: src/drivers/scsi/qla2xxx/qla_def.h
3c6e85
===================================================================
3c6e85
--- src.orig/drivers/scsi/qla2xxx/qla_def.h	2019-12-20 19:04:14.604251603 +0100
3c6e85
+++ src/drivers/scsi/qla2xxx/qla_def.h	2019-12-20 19:04:41.787008568 +0100
3c6e85
@@ -2244,7 +2244,7 @@
3c6e85
 	uint8_t fabric_port_name[WWN_SIZE];
3c6e85
 	uint16_t fp_speed;
3c6e85
 	uint8_t fc4_type;
3c6e85
-	uint8_t fc4f_nvme;	/* nvme fc4 feature bits */
3c6e85
+	uint8_t fc4_features;
3c6e85
 } sw_info_t;
3c6e85
 
3c6e85
 /* FCP-4 types */
3c6e85
@@ -2425,7 +2425,7 @@
3c6e85
 	u32 supported_classes;
3c6e85
 
3c6e85
 	uint8_t fc4_type;
3c6e85
-	uint8_t	fc4f_nvme;
3c6e85
+	uint8_t fc4_features;
3c6e85
 	uint8_t scan_state;
3c6e85
 
3c6e85
 	unsigned long last_queue_full;
3c6e85
@@ -2456,6 +2456,9 @@
3c6e85
 	u16 n2n_chip_reset;
3c6e85
 } fc_port_t;
3c6e85
 
3c6e85
+#define FC4_PRIORITY_NVME	0
3c6e85
+#define FC4_PRIORITY_FCP	1
3c6e85
+
3c6e85
 #define QLA_FCPORT_SCAN		1
3c6e85
 #define QLA_FCPORT_FOUND	2
3c6e85
 
3c6e85
@@ -4269,6 +4272,8 @@
3c6e85
 	atomic_t        nvme_active_aen_cnt;
3c6e85
 	uint16_t        nvme_last_rptd_aen;             /* Last recorded aen count */
3c6e85
 
3c6e85
+	uint8_t fc4_type_priority;
3c6e85
+
3c6e85
 	atomic_t zio_threshold;
3c6e85
 	uint16_t last_zio_threshold;
3c6e85
 #define DEFAULT_ZIO_THRESHOLD 5
3c6e85
@@ -4787,6 +4792,23 @@
3c6e85
 	 ha->current_topology == ISP_CFG_N || \
3c6e85
 	 !ha->current_topology)
3c6e85
 
3c6e85
+#define NVME_TYPE(fcport) \
3c6e85
+	(fcport->fc4_type & FS_FC4TYPE_NVME) \
3c6e85
+
3c6e85
+#define FCP_TYPE(fcport) \
3c6e85
+	(fcport->fc4_type & FS_FC4TYPE_FCP) \
3c6e85
+
3c6e85
+#define NVME_ONLY_TARGET(fcport) \
3c6e85
+	(NVME_TYPE(fcport) && !FCP_TYPE(fcport))  \
3c6e85
+
3c6e85
+#define NVME_FCP_TARGET(fcport) \
3c6e85
+	(FCP_TYPE(fcport) && NVME_TYPE(fcport)) \
3c6e85
+
3c6e85
+#define NVME_TARGET(ha, fcport) \
3c6e85
+	((NVME_FCP_TARGET(fcport) && \
3c6e85
+	(ha->fc4_type_priority == FC4_PRIORITY_NVME)) || \
3c6e85
+	NVME_ONLY_TARGET(fcport)) \
3c6e85
+
3c6e85
 #include "qla_target.h"
3c6e85
 #include "qla_gbl.h"
3c6e85
 #include "qla_dbg.h"
3c6e85
Index: src/drivers/scsi/qla2xxx/qla_fw.h
3c6e85
===================================================================
3c6e85
--- src.orig/drivers/scsi/qla2xxx/qla_fw.h	2019-12-20 19:04:14.604251603 +0100
3c6e85
+++ src/drivers/scsi/qla2xxx/qla_fw.h	2019-12-20 19:04:41.787008568 +0100
3c6e85
@@ -2106,4 +2106,6 @@
3c6e85
 #define FA_FLASH_LAYOUT_ADDR_83	(0x3F1000/4)
3c6e85
 #define FA_FLASH_LAYOUT_ADDR_28	(0x11000/4)
3c6e85
 
3c6e85
+#define NVRAM_DUAL_FCP_NVME_FLAG_OFFSET	0x196
3c6e85
+
3c6e85
 #endif
3c6e85
Index: src/drivers/scsi/qla2xxx/qla_gs.c
3c6e85
===================================================================
3c6e85
--- src.orig/drivers/scsi/qla2xxx/qla_gs.c	2019-12-20 19:04:14.605251594 +0100
3c6e85
+++ src/drivers/scsi/qla2xxx/qla_gs.c	2019-12-20 19:04:41.788008559 +0100
3c6e85
@@ -256,7 +256,7 @@
3c6e85
 		    WWN_SIZE);
3c6e85
 
3c6e85
 		fcport->fc4_type = (ct_rsp->rsp.ga_nxt.fc4_types[2] & BIT_0) ?
3c6e85
-		    FC4_TYPE_FCP_SCSI : FC4_TYPE_OTHER;
3c6e85
+		    FS_FC4TYPE_FCP : FC4_TYPE_OTHER;
3c6e85
 
3c6e85
 		if (ct_rsp->rsp.ga_nxt.port_type != NS_N_PORT_TYPE &&
3c6e85
 		    ct_rsp->rsp.ga_nxt.port_type != NS_NL_PORT_TYPE)
3c6e85
@@ -2917,7 +2917,7 @@
3c6e85
 	struct ct_sns_req	*ct_req;
3c6e85
 	struct ct_sns_rsp	*ct_rsp;
3c6e85
 	struct qla_hw_data *ha = vha->hw;
3c6e85
-	uint8_t fcp_scsi_features = 0;
3c6e85
+	uint8_t fcp_scsi_features = 0, nvme_features = 0;
3c6e85
 	struct ct_arg arg;
3c6e85
 
3c6e85
 	for (i = 0; i < ha->max_fibre_devices; i++) {
3c6e85
@@ -2965,14 +2965,19 @@
3c6e85
 			   ct_rsp->rsp.gff_id.fc4_features[GFF_FCP_SCSI_OFFSET];
3c6e85
 			fcp_scsi_features &= 0x0f;
3c6e85
 
3c6e85
-			if (fcp_scsi_features)
3c6e85
-				list[i].fc4_type = FC4_TYPE_FCP_SCSI;
3c6e85
-			else
3c6e85
-				list[i].fc4_type = FC4_TYPE_OTHER;
3c6e85
+			if (fcp_scsi_features) {
3c6e85
+				list[i].fc4_type = FS_FC4TYPE_FCP;
3c6e85
+				list[i].fc4_features = fcp_scsi_features;
3c6e85
+			}
3c6e85
 
3c6e85
-			list[i].fc4f_nvme =
3c6e85
+			nvme_features =
3c6e85
 			    ct_rsp->rsp.gff_id.fc4_features[GFF_NVME_OFFSET];
3c6e85
-			list[i].fc4f_nvme &= 0xf;
3c6e85
+			nvme_features &= 0xf;
3c6e85
+
3c6e85
+			if (nvme_features) {
3c6e85
+				list[i].fc4_type |= FS_FC4TYPE_NVME;
3c6e85
+				list[i].fc4_features = nvme_features;
3c6e85
+			}
3c6e85
 		}
3c6e85
 
3c6e85
 		/* Last device exit. */
3c6e85
@@ -3488,6 +3493,8 @@
3c6e85
 	fc_port_t *fcport = sp->fcport;
3c6e85
 	struct ct_sns_rsp *ct_rsp;
3c6e85
 	struct event_arg ea;
3c6e85
+	uint8_t fc4_scsi_feat;
3c6e85
+	uint8_t fc4_nvme_feat;
3c6e85
 
3c6e85
 	ql_dbg(ql_dbg_disc, vha, 0x2133,
3c6e85
 	       "Async done-%s res %x ID %x. %8phC\n",
3c6e85
@@ -3495,24 +3502,25 @@
3c6e85
 
3c6e85
 	fcport->flags &= ~FCF_ASYNC_SENT;
3c6e85
 	ct_rsp = &fcport->ct_desc.ct_sns->p.rsp;
3c6e85
+	fc4_scsi_feat = ct_rsp->rsp.gff_id.fc4_features[GFF_FCP_SCSI_OFFSET];
3c6e85
+	fc4_nvme_feat = ct_rsp->rsp.gff_id.fc4_features[GFF_NVME_OFFSET];
3c6e85
+
3c6e85
 	/*
3c6e85
 	 * FC-GS-7, 5.2.3.12 FC-4 Features - format
3c6e85
 	 * The format of the FC-4 Features object, as defined by the FC-4,
3c6e85
 	 * Shall be an array of 4-bit values, one for each type code value
3c6e85
 	 */
3c6e85
 	if (!res) {
3c6e85
-		if (ct_rsp->rsp.gff_id.fc4_features[GFF_FCP_SCSI_OFFSET] & 0xf) {
3c6e85
+		if (fc4_scsi_feat & 0xf) {
3c6e85
 			/* w1 b00:03 */
3c6e85
-			fcport->fc4_type =
3c6e85
-			    ct_rsp->rsp.gff_id.fc4_features[GFF_FCP_SCSI_OFFSET];
3c6e85
-			fcport->fc4_type &= 0xf;
3c6e85
-	       }
3c6e85
+			fcport->fc4_type = FS_FC4TYPE_FCP;
3c6e85
+			fcport->fc4_features = fc4_scsi_feat & 0xf;
3c6e85
+		}
3c6e85
 
3c6e85
-		if (ct_rsp->rsp.gff_id.fc4_features[GFF_NVME_OFFSET] & 0xf) {
3c6e85
+		if (fc4_nvme_feat & 0xf) {
3c6e85
 			/* w5 [00:03]/28h */
3c6e85
-			fcport->fc4f_nvme =
3c6e85
-			    ct_rsp->rsp.gff_id.fc4_features[GFF_NVME_OFFSET];
3c6e85
-			fcport->fc4f_nvme &= 0xf;
3c6e85
+			fcport->fc4_type |= FS_FC4TYPE_NVME;
3c6e85
+			fcport->fc4_features = fc4_nvme_feat & 0xf;
3c6e85
 		}
3c6e85
 	}
3c6e85
 
3c6e85
Index: src/drivers/scsi/qla2xxx/qla_init.c
3c6e85
===================================================================
3c6e85
--- src.orig/drivers/scsi/qla2xxx/qla_init.c	2019-12-20 19:04:14.610251550 +0100
3c6e85
+++ src/drivers/scsi/qla2xxx/qla_init.c	2019-12-20 19:04:41.789008550 +0100
3c6e85
@@ -334,7 +334,7 @@
3c6e85
 	else
3c6e85
 		lio->u.logio.flags |= SRB_LOGIN_COND_PLOGI;
3c6e85
 
3c6e85
-	if (fcport->fc4f_nvme)
3c6e85
+	if (NVME_TARGET(vha->hw, fcport))
3c6e85
 		lio->u.logio.flags |= SRB_LOGIN_SKIP_PRLI;
3c6e85
 
3c6e85
 	ql_dbg(ql_dbg_disc, vha, 0x2072,
3c6e85
@@ -737,19 +737,17 @@
3c6e85
 
3c6e85
 		loop_id = le16_to_cpu(e->nport_handle);
3c6e85
 		loop_id = (loop_id & 0x7fff);
3c6e85
-		if  (fcport->fc4f_nvme)
3c6e85
+		if (NVME_TARGET(vha->hw, fcport))
3c6e85
 			current_login_state = e->current_login_state >> 4;
3c6e85
 		else
3c6e85
 			current_login_state = e->current_login_state & 0xf;
3c6e85
 
3c6e85
-
3c6e85
 		ql_dbg(ql_dbg_disc, vha, 0x20e2,
3c6e85
-		    "%s found %8phC CLS [%x|%x] nvme %d ID[%02x%02x%02x|%02x%02x%02x] lid[%d|%d]\n",
3c6e85
+		    "%s found %8phC CLS [%x|%x] fc4_type %d ID[%06x|%06x] lid[%d|%d]\n",
3c6e85
 		    __func__, fcport->port_name,
3c6e85
 		    e->current_login_state, fcport->fw_login_state,
3c6e85
-		    fcport->fc4f_nvme, id.b.domain, id.b.area, id.b.al_pa,
3c6e85
-		    fcport->d_id.b.domain, fcport->d_id.b.area,
3c6e85
-		    fcport->d_id.b.al_pa, loop_id, fcport->loop_id);
3c6e85
+		    fcport->fc4_type, id.b24, fcport->d_id.b24,
3c6e85
+		    loop_id, fcport->loop_id);
3c6e85
 
3c6e85
 		switch (fcport->disc_state) {
3c6e85
 		case DSC_DELETE_PEND:
3c6e85
@@ -1245,13 +1243,13 @@
3c6e85
 	sp->done = qla2x00_async_prli_sp_done;
3c6e85
 	lio->u.logio.flags = 0;
3c6e85
 
3c6e85
-	if  (fcport->fc4f_nvme)
3c6e85
+	if (NVME_TARGET(vha->hw, fcport))
3c6e85
 		lio->u.logio.flags |= SRB_LOGIN_NVME_PRLI;
3c6e85
 
3c6e85
 	ql_dbg(ql_dbg_disc, vha, 0x211b,
3c6e85
 	    "Async-prli - %8phC hdl=%x, loopid=%x portid=%06x retries=%d %s.\n",
3c6e85
 	    fcport->port_name, sp->handle, fcport->loop_id, fcport->d_id.b24,
3c6e85
-	    fcport->login_retry, fcport->fc4f_nvme ? "nvme" : "fc");
3c6e85
+	    fcport->login_retry, NVME_TARGET(vha->hw, fcport) ? "nvme" : "fc");
3c6e85
 
3c6e85
 	rval = qla2x00_start_sp(sp);
3c6e85
 	if (rval != QLA_SUCCESS) {
3c6e85
@@ -1402,14 +1400,14 @@
3c6e85
 	fcport->flags &= ~FCF_ASYNC_SENT;
3c6e85
 
3c6e85
 	ql_dbg(ql_dbg_disc, vha, 0x20d2,
3c6e85
-	    "%s %8phC DS %d LS %d nvme %x rc %d\n", __func__, fcport->port_name,
3c6e85
-	    fcport->disc_state, pd->current_login_state, fcport->fc4f_nvme,
3c6e85
-	    ea->rc);
3c6e85
+	    "%s %8phC DS %d LS %d fc4_type %x rc %d\n", __func__,
3c6e85
+	    fcport->port_name, fcport->disc_state, pd->current_login_state,
3c6e85
+	    fcport->fc4_type, ea->rc);
3c6e85
 
3c6e85
 	if (fcport->disc_state == DSC_DELETE_PEND)
3c6e85
 		return;
3c6e85
 
3c6e85
-	if (fcport->fc4f_nvme)
3c6e85
+	if (NVME_TARGET(vha->hw, fcport))
3c6e85
 		ls = pd->current_login_state >> 4;
3c6e85
 	else
3c6e85
 		ls = pd->current_login_state & 0xf;
3c6e85
@@ -1598,7 +1596,8 @@
3c6e85
 				ql_dbg(ql_dbg_disc, vha, 0x2118,
3c6e85
 				    "%s %d %8phC post %s PRLI\n",
3c6e85
 				    __func__, __LINE__, fcport->port_name,
3c6e85
-				    fcport->fc4f_nvme ? "NVME" : "FC");
3c6e85
+				    NVME_TARGET(vha->hw, fcport) ? "NVME" :
3c6e85
+				    "FC");
3c6e85
 				qla24xx_post_prli_work(vha, fcport);
3c6e85
 			}
3c6e85
 			break;
3c6e85
@@ -1941,13 +1940,22 @@
3c6e85
 			break;
3c6e85
 		}
3c6e85
 
3c6e85
-		if (ea->fcport->fc4f_nvme) {
3c6e85
+		/*
3c6e85
+		 * Retry PRLI with other FC-4 type if failure occurred on dual
3c6e85
+		 * FCP/NVMe port
3c6e85
+		 */
3c6e85
+		if (NVME_FCP_TARGET(ea->fcport)) {
3c6e85
+			if (vha->hw->fc4_type_priority == FC4_PRIORITY_NVME)
3c6e85
+				ea->fcport->fc4_type &= ~FS_FC4TYPE_NVME;
3c6e85
+			else
3c6e85
+				ea->fcport->fc4_type &= ~FS_FC4TYPE_FCP;
3c6e85
 			ql_dbg(ql_dbg_disc, vha, 0x2118,
3c6e85
-				"%s %d %8phC post fc4 prli\n",
3c6e85
-				__func__, __LINE__, ea->fcport->port_name);
3c6e85
-			ea->fcport->fc4f_nvme = 0;
3c6e85
+				"%s %d %8phC post %s prli\n",
3c6e85
+				__func__, __LINE__, ea->fcport->port_name,
3c6e85
+				(ea->fcport->fc4_type & FS_FC4TYPE_NVME) ?
3c6e85
+				"NVMe" : "FCP");
3c6e85
 			qla24xx_post_prli_work(vha, ea->fcport);
3c6e85
-			return;
3c6e85
+			break;
3c6e85
 		}
3c6e85
 
3c6e85
 		/* at this point both PRLI NVME & PRLI FCP failed */
3c6e85
@@ -2030,7 +2038,7 @@
3c6e85
 		 * force a relogin attempt via implicit LOGO, PLOGI, and PRLI
3c6e85
 		 * requests.
3c6e85
 		 */
3c6e85
-		if (ea->fcport->fc4f_nvme) {
3c6e85
+		if (NVME_TARGET(vha->hw, ea->fcport)) {
3c6e85
 			ql_dbg(ql_dbg_disc, vha, 0x2117,
3c6e85
 				"%s %d %8phC post prli\n",
3c6e85
 				__func__, __LINE__, ea->fcport->port_name);
3c6e85
@@ -5486,7 +5494,7 @@
3c6e85
 
3c6e85
 	qla2x00_iidma_fcport(vha, fcport);
3c6e85
 
3c6e85
-	if (fcport->fc4f_nvme) {
3c6e85
+	if (NVME_TARGET(vha->hw, fcport)) {
3c6e85
 		qla_nvme_register_remote(vha, fcport);
3c6e85
 		fcport->disc_state = DSC_LOGIN_COMPLETE;
3c6e85
 		qla2x00_set_fcport_state(fcport, FCS_ONLINE);
3c6e85
@@ -5814,11 +5822,8 @@
3c6e85
 				new_fcport->fc4_type = swl[swl_idx].fc4_type;
3c6e85
 
3c6e85
 				new_fcport->nvme_flag = 0;
3c6e85
-				new_fcport->fc4f_nvme = 0;
3c6e85
 				if (vha->flags.nvme_enabled &&
3c6e85
-				    swl[swl_idx].fc4f_nvme) {
3c6e85
-					new_fcport->fc4f_nvme =
3c6e85
-					    swl[swl_idx].fc4f_nvme;
3c6e85
+				    swl[swl_idx].fc4_type & FS_FC4TYPE_NVME) {
3c6e85
 					ql_log(ql_log_info, vha, 0x2131,
3c6e85
 					    "FOUND: NVME port %8phC as FC Type 28h\n",
3c6e85
 					    new_fcport->port_name);
3c6e85
@@ -5874,7 +5879,7 @@
3c6e85
 
3c6e85
 		/* Bypass ports whose FCP-4 type is not FCP_SCSI */
3c6e85
 		if (ql2xgffidenable &&
3c6e85
-		    (new_fcport->fc4_type != FC4_TYPE_FCP_SCSI &&
3c6e85
+		    (!(new_fcport->fc4_type & FS_FC4TYPE_FCP) &&
3c6e85
 		    new_fcport->fc4_type != FC4_TYPE_UNKNOWN))
3c6e85
 			continue;
3c6e85
 
3c6e85
@@ -5943,7 +5948,7 @@
3c6e85
 			break;
3c6e85
 		}
3c6e85
 
3c6e85
-		if (fcport->fc4f_nvme) {
3c6e85
+		if (NVME_TARGET(vha->hw, fcport)) {
3c6e85
 			if (fcport->disc_state == DSC_DELETE_PEND) {
3c6e85
 				fcport->disc_state = DSC_GNL;
3c6e85
 				vha->fcport_count--;
3c6e85
@@ -8613,6 +8618,11 @@
3c6e85
 	/* N2N: driver will initiate Login instead of FW */
3c6e85
 	icb->firmware_options_3 |= BIT_8;
3c6e85
 
3c6e85
+	/* Determine NVMe/FCP priority for target ports */
3c6e85
+	ha->fc4_type_priority = qla2xxx_get_fc4_priority(vha);
3c6e85
+	ql_log(ql_log_info, vha, 0xffff, "FC4 priority set to %s\n",
3c6e85
+	    ha->fc4_type_priority & BIT_0 ? "FCP" : "NVMe");
3c6e85
+
3c6e85
 	if (rval) {
3c6e85
 		ql_log(ql_log_warn, vha, 0x0076,
3c6e85
 		    "NVRAM configuration failed.\n");
3c6e85
Index: src/drivers/scsi/qla2xxx/qla_inline.h
3c6e85
===================================================================
3c6e85
--- src.orig/drivers/scsi/qla2xxx/qla_inline.h	2019-12-20 19:04:14.610251550 +0100
3c6e85
+++ src/drivers/scsi/qla2xxx/qla_inline.h	2019-12-20 19:04:41.789008550 +0100
3c6e85
@@ -320,3 +320,15 @@
3c6e85
 
3c6e85
 	WRT_REG_DWORD(req->req_q_in, req->ring_index);
3c6e85
 }
3c6e85
+
3c6e85
+static inline int
3c6e85
+qla2xxx_get_fc4_priority(struct scsi_qla_host *vha)
3c6e85
+{
3c6e85
+	uint32_t data;
3c6e85
+
3c6e85
+	data =
3c6e85
+	    ((uint8_t *)vha->hw->nvram)[NVRAM_DUAL_FCP_NVME_FLAG_OFFSET];
3c6e85
+
3c6e85
+
3c6e85
+	return ((data >> 6) & BIT_0);
3c6e85
+}
3c6e85
Index: src/drivers/scsi/qla2xxx/qla_mbx.c
3c6e85
===================================================================
3c6e85
--- src.orig/drivers/scsi/qla2xxx/qla_mbx.c	2019-12-20 19:04:14.611251541 +0100
3c6e85
+++ src/drivers/scsi/qla2xxx/qla_mbx.c	2019-12-20 19:07:11.648678207 +0100
3c6e85
@@ -1930,7 +1930,7 @@
3c6e85
 		pd24 = (struct port_database_24xx *) pd;
3c6e85
 
3c6e85
 		/* Check for logged in state. */
3c6e85
-		if (fcport->fc4f_nvme) {
3c6e85
+		if (NVME_TARGET(ha, fcport)) {
3c6e85
 			current_login_state = pd24->current_login_state >> 4;
3c6e85
 			last_login_state = pd24->last_login_state >> 4;
3c6e85
 		} else {
3c6e85
@@ -3897,8 +3897,9 @@
3c6e85
 				fcport->scan_state = QLA_FCPORT_FOUND;
3c6e85
 				fcport->n2n_flag = 1;
3c6e85
 				fcport->keep_nport_handle = 1;
3c6e85
+				fcport->fc4_type = FS_FC4TYPE_FCP;
3c6e85
 				if (vha->flags.nvme_enabled)
3c6e85
-					fcport->fc4f_nvme = 1;
3c6e85
+					fcport->fc4_type |= FS_FC4TYPE_NVME;
3c6e85
 
3c6e85
 				switch (fcport->disc_state) {
3c6e85
 				case DSC_DELETED:
3c6e85
@@ -6362,7 +6363,7 @@
3c6e85
 	uint64_t zero = 0;
3c6e85
 	u8 current_login_state, last_login_state;
3c6e85
 
3c6e85
-	if (fcport->fc4f_nvme) {
3c6e85
+	if (NVME_TARGET(vha->hw, fcport)) {
3c6e85
 		current_login_state = pd->current_login_state >> 4;
3c6e85
 		last_login_state = pd->last_login_state >> 4;
3c6e85
 	} else {
3c6e85
@@ -6397,7 +6398,7 @@
3c6e85
 	fcport->d_id.b.al_pa = pd->port_id[2];
3c6e85
 	fcport->d_id.b.rsvd_1 = 0;
3c6e85
 
3c6e85
-	if (fcport->fc4f_nvme) {
3c6e85
+	if (NVME_TARGET(vha->hw, fcport)) {
3c6e85
 		fcport->port_type = FCT_NVME;
3c6e85
 	} else {
3c6e85
 		/* If not target must be initiator or unknown type. */
3c6e85
Index: src/drivers/scsi/qla2xxx/qla_os.c
3c6e85
===================================================================
3c6e85
--- src.orig/drivers/scsi/qla2xxx/qla_os.c	2019-12-20 19:04:14.613251523 +0100
3c6e85
+++ src/drivers/scsi/qla2xxx/qla_os.c	2019-12-20 19:04:41.791008533 +0100
3c6e85
@@ -5125,19 +5125,17 @@
3c6e85
 			fcport->d_id = e->u.new_sess.id;
3c6e85
 			fcport->flags |= FCF_FABRIC_DEVICE;
3c6e85
 			fcport->fw_login_state = DSC_LS_PLOGI_PEND;
3c6e85
-			if (e->u.new_sess.fc4_type == FS_FC4TYPE_FCP)
3c6e85
-				fcport->fc4_type = FC4_TYPE_FCP_SCSI;
3c6e85
-
3c6e85
-			if (e->u.new_sess.fc4_type == FS_FC4TYPE_NVME) {
3c6e85
-				fcport->fc4_type = FC4_TYPE_OTHER;
3c6e85
-				fcport->fc4f_nvme = FC4_TYPE_NVME;
3c6e85
-			}
3c6e85
 
3c6e85
 			memcpy(fcport->port_name, e->u.new_sess.port_name,
3c6e85
 			    WWN_SIZE);
3c6e85
 
3c6e85
-			if (e->u.new_sess.fc4_type & FS_FCP_IS_N2N)
3c6e85
+			fcport->fc4_type = e->u.new_sess.fc4_type;
3c6e85
+			if (e->u.new_sess.fc4_type & FS_FCP_IS_N2N) {
3c6e85
+				fcport->fc4_type = FS_FC4TYPE_FCP;
3c6e85
 				fcport->n2n_flag = 1;
3c6e85
+				if (vha->flags.nvme_enabled)
3c6e85
+					fcport->fc4_type |= FS_FC4TYPE_NVME;
3c6e85
+			}
3c6e85
 
3c6e85
 		} else {
3c6e85
 			ql_dbg(ql_dbg_disc, vha, 0xffff,
3c6e85
@@ -5239,7 +5237,8 @@
3c6e85
 				fcport->flags &= ~FCF_FABRIC_DEVICE;
3c6e85
 				fcport->keep_nport_handle = 1;
3c6e85
 				if (vha->flags.nvme_enabled) {
3c6e85
-					fcport->fc4f_nvme = 1;
3c6e85
+					fcport->fc4_type =
3c6e85
+					    (FS_FC4TYPE_NVME | FS_FC4TYPE_FCP);
3c6e85
 					fcport->n2n_flag = 1;
3c6e85
 				}
3c6e85
 				fcport->fw_login_state = 0;