From 4216f7fff5ac5cc9f972c52c5b8d01042231cfe9 Mon Sep 17 00:00:00 2001 From: Changpeng Liu Date: Thu, 29 Jul 2021 23:13:54 +0800 Subject: [PATCH] nvmf/vfio-user: fix shared CQ usage case Multiple IO Submission Queue can share one Completion Queue, and we use field 'cqid' to save it in Submission Queue, so when posting completion response, we need to get the Submission Queue's CQID first, then post the completion queue based on CQID. Also rename vfio-user internal variables with 'vu_' prefix in this function. Change-Id: Ib73b91a86740d105b5fb5c73127484ebfb6b55ef Signed-off-by: Changpeng Liu Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/8969 Community-CI: Broadcom CI Community-CI: Mellanox Build Bot Tested-by: SPDK CI Jenkins Reviewed-by: Aleksey Marchuk Reviewed-by: Thanos Makatos Reviewed-by: Jim Harris --- lib/nvmf/vfio_user.c | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/lib/nvmf/vfio_user.c b/lib/nvmf/vfio_user.c index bb131b1b2..e8824f96d 100644 --- a/lib/nvmf/vfio_user.c +++ b/lib/nvmf/vfio_user.c @@ -1265,20 +1265,25 @@ consume_admin_cmd(struct nvmf_vfio_user_ctrlr *ctrlr, struct spdk_nvme_cmd *cmd) } static int -handle_cmd_rsp(struct nvmf_vfio_user_req *req, void *cb_arg) +handle_cmd_rsp(struct nvmf_vfio_user_req *vu_req, void *cb_arg) { - struct nvmf_vfio_user_qpair *qpair = cb_arg; + struct nvmf_vfio_user_qpair *vu_qpair = cb_arg; + struct nvmf_vfio_user_ctrlr *vu_ctrlr = vu_qpair->ctrlr; + uint16_t sqid, cqid; - assert(qpair != NULL); - assert(req != NULL); + assert(vu_qpair != NULL); + assert(vu_req != NULL); + assert(vu_ctrlr != NULL); - vfu_unmap_sg(qpair->ctrlr->endpoint->vfu_ctx, req->sg, req->iov, req->iovcnt); + vfu_unmap_sg(vu_ctrlr->endpoint->vfu_ctx, vu_req->sg, vu_req->iov, vu_req->iovcnt); + sqid = vu_qpair->qpair.qid; + cqid = vu_ctrlr->qp[sqid]->sq.cqid; - return post_completion(qpair->ctrlr, &req->req.cmd->nvme_cmd, - &qpair->ctrlr->qp[req->req.qpair->qid]->cq, - req->req.rsp->nvme_cpl.cdw0, - req->req.rsp->nvme_cpl.status.sc, - req->req.rsp->nvme_cpl.status.sct); + return post_completion(vu_ctrlr, &vu_req->req.cmd->nvme_cmd, + &vu_ctrlr->qp[cqid]->cq, + vu_req->req.rsp->nvme_cpl.cdw0, + vu_req->req.rsp->nvme_cpl.status.sc, + vu_req->req.rsp->nvme_cpl.status.sct); } static int