From d5102d37b313a1266d4f956cb2c59555e364472f Mon Sep 17 00:00:00 2001 From: Changpeng Liu Date: Wed, 30 Jun 2021 21:02:10 +0800 Subject: [PATCH] nvmf/vfio-user: process NVMe response cdw0 correctly The NVMf library will set cdw0 based on specific command, so we use it directly in vfio-user, otherwise, some NVMe commands such as AER can't work. Fix issue #2016. Change-Id: Ie1a80a92c0856b61822ee51ce5d8faaaf1d463de Signed-off-by: Changpeng Liu Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/8556 Reviewed-by: Ziye Yang Reviewed-by: Jim Harris Reviewed-by: Ben Walker Tested-by: SPDK CI Jenkins Community-CI: Mellanox Build Bot --- lib/nvmf/vfio_user.c | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/lib/nvmf/vfio_user.c b/lib/nvmf/vfio_user.c index 729479d79..e449795e6 100644 --- a/lib/nvmf/vfio_user.c +++ b/lib/nvmf/vfio_user.c @@ -579,7 +579,7 @@ handle_cmd_req(struct nvmf_vfio_user_ctrlr *ctrlr, struct spdk_nvme_cmd *cmd, * @ctrlr: the vfio-user controller * @cmd: the NVMe command for which the completion is posted * @cq: the completion queue - * @cdw0: cdw0 as reported by NVMf (only for SPDK_NVME_OPC_GET/SET_FEATURES) + * @cdw0: cdw0 as reported by NVMf * @sc: the NVMe CQE status code * @sct: the NVMe CQE status code type */ @@ -617,20 +617,11 @@ post_completion(struct nvmf_vfio_user_ctrlr *ctrlr, struct spdk_nvme_cmd *cmd, ctrlr_id(ctrlr), qid, cmd->cid, sc, ctrlr->qp[qid]->sq.head, cq->tail); - if (qid == 0) { - switch (cmd->opc) { - case SPDK_NVME_OPC_SET_FEATURES: - case SPDK_NVME_OPC_GET_FEATURES: - cpl->cdw0 = cdw0; - break; - } - } - - assert(ctrlr->qp[qid] != NULL); cpl->sqhd = ctrlr->qp[qid]->sq.head; cpl->cid = cmd->cid; + cpl->cdw0 = cdw0; cpl->status.dnr = 0x0; cpl->status.m = 0x0; cpl->status.sct = sct;