Blame SOURCES/0017-scsi-scsi-qla2xxx-Add-First-Burst-support-for-FC-NVM.patch

3d7c23
From 55ebc45d7e6818b6759f7a3d7ea28099043d3020 Mon Sep 17 00:00:00 2001
3d7c23
From: Himanshu Madhani <hmadhani@redhat.com>
3d7c23
Date: Thu, 1 Aug 2019 15:54:37 -0400
3d7c23
Subject: [PATCH 017/124] [scsi] scsi: qla2xxx: Add First Burst support for
3d7c23
 FC-NVMe devices
3d7c23
3d7c23
Message-id: <20190801155618.12650-18-hmadhani@redhat.com>
3d7c23
Patchwork-id: 267821
3d7c23
O-Subject: [RHEL 7.8 e-stor PATCH 017/118] scsi: qla2xxx: Add First Burst support for FC-NVMe devices
3d7c23
Bugzilla: 1729270
3d7c23
RH-Acked-by: Jarod Wilson <jarod@redhat.com>
3d7c23
RH-Acked-by: Tony Camuso <tcamuso@redhat.com>
3d7c23
3d7c23
From: Darren Trapp <darren.trapp@cavium.com>
3d7c23
3d7c23
Bugzilla 1729270
3d7c23
3d7c23
Add Support for First Burst for FC-NVMe protocol. This feature requires
3d7c23
First Burst support in the firmware.
3d7c23
3d7c23
Signed-off-by: Darren Trapp <darren.trapp@cavium.com>
3d7c23
Signed-off-by: Himanshu Madhani <hmadhani@marvell.com>
3d7c23
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3d7c23
(cherry picked from commit 03aaa89fe46feccccf29e137131400f309431e64)
3d7c23
Signed-off-by: Himanshu Madhani <hmadhani@redhat.com>
3d7c23
Signed-off-by: Jan Stancek <jstancek@redhat.com>
3d7c23
---
3d7c23
 drivers/scsi/qla2xxx/qla_def.h  |  4 ++++
3d7c23
 drivers/scsi/qla2xxx/qla_init.c |  6 ++++++
3d7c23
 drivers/scsi/qla2xxx/qla_iocb.c |  5 ++++-
3d7c23
 drivers/scsi/qla2xxx/qla_isr.c  |  9 +++++++++
3d7c23
 drivers/scsi/qla2xxx/qla_mbx.c  |  5 +++--
3d7c23
 drivers/scsi/qla2xxx/qla_nvme.c | 17 ++++++++++++-----
3d7c23
 drivers/scsi/qla2xxx/qla_nvme.h |  2 +-
3d7c23
 7 files changed, 39 insertions(+), 9 deletions(-)
3d7c23
3d7c23
diff --git a/drivers/scsi/qla2xxx/qla_def.h b/drivers/scsi/qla2xxx/qla_def.h
3d7c23
index 5e580b4c6ae2..bcb7ad530240 100644
3d7c23
--- a/drivers/scsi/qla2xxx/qla_def.h
3d7c23
+++ b/drivers/scsi/qla2xxx/qla_def.h
3d7c23
@@ -2377,7 +2377,9 @@ typedef struct fc_port {
3d7c23
 #define NVME_PRLI_SP_INITIATOR  BIT_5
3d7c23
 #define NVME_PRLI_SP_TARGET     BIT_4
3d7c23
 #define NVME_PRLI_SP_DISCOVERY  BIT_3
3d7c23
+#define NVME_PRLI_SP_FIRST_BURST	BIT_0
3d7c23
 	uint8_t nvme_flag;
3d7c23
+	uint32_t nvme_first_burst_size;
3d7c23
 #define NVME_FLAG_REGISTERED 4
3d7c23
 #define NVME_FLAG_DELETING 2
3d7c23
 #define NVME_FLAG_RESETTING 1
3d7c23
@@ -3973,6 +3975,7 @@ struct qla_hw_data {
3d7c23
 	uint16_t	fw_subminor_version;
3d7c23
 	uint16_t	fw_attributes;
3d7c23
 	uint16_t	fw_attributes_h;
3d7c23
+#define FW_ATTR_H_NVME_FBURST 	BIT_1
3d7c23
 #define FW_ATTR_H_NVME		BIT_10
3d7c23
 #define FW_ATTR_H_NVME_UPDATED  BIT_14
3d7c23
 
3d7c23
@@ -4267,6 +4270,7 @@ typedef struct scsi_qla_host {
3d7c23
 		uint32_t	qpairs_req_created:1;
3d7c23
 		uint32_t	qpairs_rsp_created:1;
3d7c23
 		uint32_t	nvme_enabled:1;
3d7c23
+		uint32_t        nvme_first_burst:1;
3d7c23
 	} flags;
3d7c23
 
3d7c23
 	atomic_t	loop_state;
3d7c23
diff --git a/drivers/scsi/qla2xxx/qla_init.c b/drivers/scsi/qla2xxx/qla_init.c
3d7c23
index 90eeff414931..3a79abe8e658 100644
3d7c23
--- a/drivers/scsi/qla2xxx/qla_init.c
3d7c23
+++ b/drivers/scsi/qla2xxx/qla_init.c
3d7c23
@@ -1831,6 +1831,12 @@ qla24xx_handle_prli_done_event(struct scsi_qla_host *vha, struct event_arg *ea)
3d7c23
 
3d7c23
 		ea->fcport->chip_reset = vha->hw->base_qpair->chip_reset;
3d7c23
 		ea->fcport->logout_on_delete = 1;
3d7c23
+		ea->fcport->nvme_prli_service_param = ea->iop[0];
3d7c23
+		if (ea->iop[0] & NVME_PRLI_SP_FIRST_BURST)
3d7c23
+			ea->fcport->nvme_first_burst_size =
3d7c23
+			    (ea->iop[1] & 0xffff) * 512;
3d7c23
+		else
3d7c23
+			ea->fcport->nvme_first_burst_size = 0;
3d7c23
 		qla24xx_post_gpdb_work(vha, ea->fcport, 0);
3d7c23
 		break;
3d7c23
 	default:
3d7c23
diff --git a/drivers/scsi/qla2xxx/qla_iocb.c b/drivers/scsi/qla2xxx/qla_iocb.c
3d7c23
index 348d9d3bf590..1acdd4cea6a3 100644
3d7c23
--- a/drivers/scsi/qla2xxx/qla_iocb.c
3d7c23
+++ b/drivers/scsi/qla2xxx/qla_iocb.c
3d7c23
@@ -2461,8 +2461,11 @@ qla24xx_prli_iocb(srb_t *sp, struct logio_entry_24xx *logio)
3d7c23
 
3d7c23
 	logio->entry_type = LOGINOUT_PORT_IOCB_TYPE;
3d7c23
 	logio->control_flags = cpu_to_le16(LCF_COMMAND_PRLI);
3d7c23
-	if (lio->u.logio.flags & SRB_LOGIN_NVME_PRLI)
3d7c23
+	if (lio->u.logio.flags & SRB_LOGIN_NVME_PRLI) {
3d7c23
 		logio->control_flags |= LCF_NVME_PRLI;
3d7c23
+		if (sp->vha->flags.nvme_first_burst)
3d7c23
+			logio->io_parameter[0] = NVME_PRLI_SP_FIRST_BURST;
3d7c23
+	}
3d7c23
 
3d7c23
 	logio->nport_handle = cpu_to_le16(sp->fcport->loop_id);
3d7c23
 	logio->port_id[0] = sp->fcport->d_id.b.al_pa;
3d7c23
diff --git a/drivers/scsi/qla2xxx/qla_isr.c b/drivers/scsi/qla2xxx/qla_isr.c
3d7c23
index 8e5467ee957d..da7428a6efb8 100644
3d7c23
--- a/drivers/scsi/qla2xxx/qla_isr.c
3d7c23
+++ b/drivers/scsi/qla2xxx/qla_isr.c
3d7c23
@@ -1714,6 +1714,15 @@ qla24xx_logio_entry(scsi_qla_host_t *vha, struct req_que *req,
3d7c23
 
3d7c23
 		vha->hw->exch_starvation = 0;
3d7c23
 		data[0] = MBS_COMMAND_COMPLETE;
3d7c23
+
3d7c23
+		if (sp->type == SRB_PRLI_CMD) {
3d7c23
+			lio->u.logio.iop[0] =
3d7c23
+			    le32_to_cpu(logio->io_parameter[0]);
3d7c23
+			lio->u.logio.iop[1] =
3d7c23
+			    le32_to_cpu(logio->io_parameter[1]);
3d7c23
+			goto logio_done;
3d7c23
+		}
3d7c23
+
3d7c23
 		if (sp->type != SRB_LOGIN_CMD)
3d7c23
 			goto logio_done;
3d7c23
 
3d7c23
diff --git a/drivers/scsi/qla2xxx/qla_mbx.c b/drivers/scsi/qla2xxx/qla_mbx.c
3d7c23
index 17fde50ac8d1..731fa37603d5 100644
3d7c23
--- a/drivers/scsi/qla2xxx/qla_mbx.c
3d7c23
+++ b/drivers/scsi/qla2xxx/qla_mbx.c
3d7c23
@@ -1114,6 +1114,9 @@ qla2x00_get_fw_version(scsi_qla_host_t *vha)
3d7c23
 		if ((ha->fw_attributes_h &
3d7c23
 		    (FW_ATTR_H_NVME | FW_ATTR_H_NVME_UPDATED)) &&
3d7c23
 			ql2xnvmeenable) {
3d7c23
+			if (ha->fw_attributes_h & FW_ATTR_H_NVME_FBURST)
3d7c23
+				vha->flags.nvme_first_burst = 1;
3d7c23
+
3d7c23
 			vha->flags.nvme_enabled = 1;
3d7c23
 			ql_log(ql_log_info, vha, 0xd302,
3d7c23
 			    "%s: FC-NVMe is Enabled (0x%x)\n",
3d7c23
@@ -6269,8 +6272,6 @@ int __qla24xx_parse_gpdb(struct scsi_qla_host *vha, fc_port_t *fcport,
3d7c23
 	fcport->d_id.b.rsvd_1 = 0;
3d7c23
 
3d7c23
 	if (fcport->fc4f_nvme) {
3d7c23
-		fcport->nvme_prli_service_param =
3d7c23
-		    pd->prli_nvme_svc_param_word_3;
3d7c23
 		fcport->port_type = FCT_NVME;
3d7c23
 	} else {
3d7c23
 		/* If not target must be initiator or unknown type. */
3d7c23
diff --git a/drivers/scsi/qla2xxx/qla_nvme.c b/drivers/scsi/qla2xxx/qla_nvme.c
3d7c23
index 417e1d6263da..9c31d01ddd30 100644
3d7c23
--- a/drivers/scsi/qla2xxx/qla_nvme.c
3d7c23
+++ b/drivers/scsi/qla2xxx/qla_nvme.c
3d7c23
@@ -369,17 +369,24 @@ static inline int qla2x00_start_nvme_mq(srb_t *sp)
3d7c23
 
3d7c23
 	/* No data transfer how do we check buffer len == 0?? */
3d7c23
 	if (fd->io_dir == NVMEFC_FCP_READ) {
3d7c23
-		cmd_pkt->control_flags =
3d7c23
-		    cpu_to_le16(CF_READ_DATA | CF_NVME_ENABLE);
3d7c23
+		cmd_pkt->control_flags = CF_READ_DATA;
3d7c23
 		vha->qla_stats.input_bytes += fd->payload_length;
3d7c23
 		vha->qla_stats.input_requests++;
3d7c23
 	} else if (fd->io_dir == NVMEFC_FCP_WRITE) {
3d7c23
-		cmd_pkt->control_flags =
3d7c23
-		    cpu_to_le16(CF_WRITE_DATA | CF_NVME_ENABLE);
3d7c23
+		cmd_pkt->control_flags = CF_WRITE_DATA;
3d7c23
+		if ((vha->flags.nvme_first_burst) &&
3d7c23
+		    (sp->fcport->nvme_prli_service_param &
3d7c23
+			NVME_PRLI_SP_FIRST_BURST)) {
3d7c23
+			if ((fd->payload_length <=
3d7c23
+			    sp->fcport->nvme_first_burst_size) ||
3d7c23
+				(sp->fcport->nvme_first_burst_size == 0))
3d7c23
+				cmd_pkt->control_flags |=
3d7c23
+				    CF_NVME_FIRST_BURST_ENABLE;
3d7c23
+		}
3d7c23
 		vha->qla_stats.output_bytes += fd->payload_length;
3d7c23
 		vha->qla_stats.output_requests++;
3d7c23
 	} else if (fd->io_dir == 0) {
3d7c23
-		cmd_pkt->control_flags = cpu_to_le16(CF_NVME_ENABLE);
3d7c23
+		cmd_pkt->control_flags = 0;
3d7c23
 	}
3d7c23
 
3d7c23
 	/* Set NPORT-ID */
3d7c23
diff --git a/drivers/scsi/qla2xxx/qla_nvme.h b/drivers/scsi/qla2xxx/qla_nvme.h
3d7c23
index 4941d107fb1c..da8dad5ad693 100644
3d7c23
--- a/drivers/scsi/qla2xxx/qla_nvme.h
3d7c23
+++ b/drivers/scsi/qla2xxx/qla_nvme.h
3d7c23
@@ -57,7 +57,7 @@ struct cmd_nvme {
3d7c23
 	uint64_t rsvd;
3d7c23
 
3d7c23
 	uint16_t control_flags;         /* Control Flags */
3d7c23
-#define CF_NVME_ENABLE                  BIT_9
3d7c23
+#define CF_NVME_FIRST_BURST_ENABLE	BIT_11
3d7c23
 #define CF_DIF_SEG_DESCR_ENABLE         BIT_3
3d7c23
 #define CF_DATA_SEG_DESCR_ENABLE        BIT_2
3d7c23
 #define CF_READ_DATA                    BIT_1
3d7c23
-- 
3d7c23
2.13.6
3d7c23