scsi: qla2xxx: Handle NVME status iocb correctly

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.

Link: https://lore.kernel.org/r/20200226224022.24518-17-hmadhani@marvell.com
Signed-off-by: Himanshu Madhani <hmadhani@marvell.com>
Signed-off-by: Arun Easi <aeasi@marvell.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
This commit is contained in:
Arun Easi 2020-02-26 14:40:20 -08:00 committed by Martin K. Petersen
parent 3e4615a292
commit 3d582b3499

View File

@ -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,