All of lore.kernel.org
 help / color / mirror / Atom feed
From: Himanshu Madhani <hmadhani@marvell.com>
To: <James.Bottomley@HansenPartnership.com>, <martin.petersen@oracle.com>
Cc: <hmadhani@marvell.com>, <linux-scsi@vger.kernel.org>
Subject: [PATCH 16/18] qla2xxx: Handle NVME status iocb correctly
Date: Wed, 26 Feb 2020 14:40:20 -0800	[thread overview]
Message-ID: <20200226224022.24518-17-hmadhani@marvell.com> (raw)
In-Reply-To: <20200226224022.24518-1-hmadhani@marvell.com>

From: Arun Easi <aeasi@marvell.com>

Certain state flags bit combinations are not checked
and not handled correctly. Plus, do not log a normal
underrun situation, where there is no frame drop.

Signed-off-by: Arun Easi <aeasi@marvell.com>
Signed-off-by: Himanshu Madhani <hmadhani@marvell.com>
---
 drivers/scsi/qla2xxx/qla_isr.c | 47 +++++++++++++++++++++++++++++++++++-------
 1 file changed, 39 insertions(+), 8 deletions(-)

diff --git a/drivers/scsi/qla2xxx/qla_isr.c b/drivers/scsi/qla2xxx/qla_isr.c
index 0217a3456705..3699d3a29135 100644
--- a/drivers/scsi/qla2xxx/qla_isr.c
+++ b/drivers/scsi/qla2xxx/qla_isr.c
@@ -2064,6 +2064,7 @@ static void qla24xx_nvme_iocb_entry(scsi_qla_host_t *vha, struct req_que *req,
 	struct nvmefc_fcp_req *fd;
 	uint16_t        ret = QLA_SUCCESS;
 	uint16_t	comp_status = le16_to_cpu(sts->comp_status);
+	int		logit = 0;
 
 	iocb = &sp->u.iocb_cmd;
 	fcport = sp->fcport;
@@ -2074,6 +2075,12 @@ static void qla24xx_nvme_iocb_entry(scsi_qla_host_t *vha, struct req_que *req,
 	if (unlikely(iocb->u.nvme.aen_op))
 		atomic_dec(&sp->vha->hw->nvme_active_aen_cnt);
 
+	if (unlikely(comp_status != CS_COMPLETE))
+		logit = 1;
+
+	fd->transferred_length = fd->payload_length -
+	    le32_to_cpu(sts->residual_len);
+
 	/*
 	 * State flags: Bit 6 and 0.
 	 * If 0 is set, we don't care about 6.
@@ -2084,8 +2091,20 @@ static void qla24xx_nvme_iocb_entry(scsi_qla_host_t *vha, struct req_que *req,
 	 */
 	if (!(state_flags & (SF_FCP_RSP_DMA | SF_NVME_ERSP))) {
 		iocb->u.nvme.rsp_pyld_len = 0;
-	} else if ((state_flags & SF_FCP_RSP_DMA)) {
+	} else if ((state_flags & (SF_FCP_RSP_DMA | SF_NVME_ERSP)) ==
+			(SF_FCP_RSP_DMA | SF_NVME_ERSP)) {
+		/* Response already DMA'd to fd->rspaddr. */
 		iocb->u.nvme.rsp_pyld_len = le16_to_cpu(sts->nvme_rsp_pyld_len);
+	} else if ((state_flags & SF_FCP_RSP_DMA)) {
+		/*
+		 * Non-zero value in first 12 bytes of NVMe_RSP IU, treat this
+		 * as an error.
+		 */
+		iocb->u.nvme.rsp_pyld_len = 0;
+		fd->transferred_length = 0;
+		ql_dbg(ql_dbg_io, fcport->vha, 0x307a,
+			"Unexpected values in NVMe_RSP IU.\n");
+		logit = 1;
 	} else if (state_flags & SF_NVME_ERSP) {
 		uint32_t *inbuf, *outbuf;
 		uint16_t iter;
@@ -2108,16 +2127,28 @@ static void qla24xx_nvme_iocb_entry(scsi_qla_host_t *vha, struct req_que *req,
 		iter = iocb->u.nvme.rsp_pyld_len >> 2;
 		for (; iter; iter--)
 			*outbuf++ = swab32(*inbuf++);
-	} else { /* unhandled case */
-	    ql_log(ql_log_warn, fcport->vha, 0x503a,
-		"NVME-%s error. Unhandled state_flags of %x\n",
-		sp->name, state_flags);
 	}
 
-	fd->transferred_length = fd->payload_length -
-	    le32_to_cpu(sts->residual_len);
+	if (state_flags & SF_NVME_ERSP) {
+		struct nvme_fc_ersp_iu *rsp_iu = fd->rspaddr;
+		u32 tgt_xfer_len;
 
-	if (unlikely(comp_status != CS_COMPLETE))
+		tgt_xfer_len = be32_to_cpu(rsp_iu->xfrd_len);
+		if (fd->transferred_length != tgt_xfer_len) {
+			ql_dbg(ql_dbg_io, fcport->vha, 0x3079,
+				"Dropped frame(s) detected (sent/rcvd=%u/%u).\n",
+				tgt_xfer_len, fd->transferred_length);
+			logit = 1;
+		} else if (comp_status == CS_DATA_UNDERRUN) {
+			/*
+			 * Do not log if this is just an underflow and there
+			 * is no data loss.
+			 */
+			logit = 0;
+		}
+	}
+
+	if (unlikely(logit))
 		ql_log(ql_log_warn, fcport->vha, 0x5060,
 		   "NVME-%s ERR Handling - hdl=%x status(%x) tr_len:%x resid=%x  ox_id=%x\n",
 		   sp->name, sp->handle, comp_status,
-- 
2.12.0


  parent reply	other threads:[~2020-02-26 22:41 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-26 22:40 [PATCH 00/18] qla2xxx: fixes for the driver Himanshu Madhani
2020-02-26 22:40 ` [PATCH 01/18] qla2xxX: Add 16.0GT for PCI String Himanshu Madhani
2020-02-26 22:40 ` [PATCH 02/18] qla2xxx: Avoid setting firmware options twice in 24xx_update_fw_options Himanshu Madhani
2020-02-26 22:40 ` [PATCH 03/18] qla2xxx: Use FC generic update firmware options routine for ISP27xx Himanshu Madhani
2020-02-26 22:40 ` [PATCH 04/18] qla2xxx: Fix FCP-SCSI FC4 flag passing error Himanshu Madhani
2020-02-26 22:40 ` [PATCH 05/18] qla2xxx: Improved secure flash support messages Himanshu Madhani
2020-02-26 22:40 ` [PATCH 06/18] qla2xxx: Return appropriate failure through BSG Interface Himanshu Madhani
2020-02-26 22:40 ` [PATCH 07/18] qla2xxx: Use a dedicated interrupt handler for 'handshake-required' ISPs Himanshu Madhani
2020-02-26 22:40 ` [PATCH 08/18] qla2xxx: fix FW resource count values Himanshu Madhani
2020-02-26 22:40 ` [PATCH 09/18] qla2xxx: Update BPM enablement semantics Himanshu Madhani
2020-02-26 22:40 ` [PATCH 10/18] qla2xxx: add more FW debug information Himanshu Madhani
2020-02-26 22:40 ` [PATCH 11/18] qla2xxx: Force semaphore on flash validation failure Himanshu Madhani
2020-02-26 22:40 ` [PATCH 12/18] qla2xxx: Fix RDP respond data format Himanshu Madhani
2020-02-26 22:40 ` [PATCH 13/18] qla2xxx: Fix NPIV instantiation after FW dump Himanshu Madhani
2020-02-26 22:40 ` [PATCH 14/18] qla2xxx: Serialize fc_port alloc in N2N Himanshu Madhani
2020-02-26 22:40 ` [PATCH 15/18] qla2xxx: Remove restriction of FC T10-PI and FC-NVMe Himanshu Madhani
2020-02-26 22:40 ` Himanshu Madhani [this message]
2020-02-26 22:40 ` [PATCH 17/18] qla2xxx: Set Nport ID for N2N Himanshu Madhani
2020-02-26 22:40 ` [PATCH 18/18] qla2xxx: Update driver version to 10.01.00.25-k Himanshu Madhani
2020-02-29  1:33 ` [PATCH 00/18] qla2xxx: fixes for the driver Martin K. Petersen

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=20200226224022.24518-17-hmadhani@marvell.com \
    --to=hmadhani@marvell.com \
    --cc=James.Bottomley@HansenPartnership.com \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    /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.