From 8586a1b3cc799d3061dbf4169d68a4393566cfa9 Mon Sep 17 00:00:00 2001 From: Changpeng Liu Date: Sun, 7 Feb 2021 22:25:07 +0800 Subject: [PATCH] nvmf/vfio-user: unpack add_qp() function add_qp() function is only called when creating NVMe SQ/CQ, so unpack it into the caller to make the code more clear. Change-Id: Id5cc1152b1684df980909b2f7d73ed2788c0efb2 Signed-off-by: Changpeng Liu Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/6308 Community-CI: Broadcom CI Community-CI: Mellanox Build Bot Tested-by: SPDK CI Jenkins Reviewed-by: Ben Walker Reviewed-by: Jim Harris --- lib/nvmf/vfio_user.c | 43 ++++++++++--------------------------------- 1 file changed, 10 insertions(+), 33 deletions(-) diff --git a/lib/nvmf/vfio_user.c b/lib/nvmf/vfio_user.c index 25d081ef8..92807edb8 100644 --- a/lib/nvmf/vfio_user.c +++ b/lib/nvmf/vfio_user.c @@ -779,36 +779,6 @@ out: return err; } -static int -add_qp(struct nvmf_vfio_user_ctrlr *ctrlr, struct spdk_nvmf_transport *transport, - const uint16_t qsize, const uint16_t qid) -{ - int err; - struct nvmf_vfio_user_transport *vu_transport; - - SPDK_DEBUGLOG(nvmf_vfio, "%s: request add QP%d\n", - ctrlr_id(ctrlr), qid); - - err = init_qp(ctrlr, transport, qsize, qid); - if (err != 0) { - return err; - } - - vu_transport = SPDK_CONTAINEROF(transport, struct nvmf_vfio_user_transport, - transport); - - /* - * After we've returned from the nvmf_vfio_user_poll_group_poll thread, once - * nvmf_vfio_user_accept executes it will pick up this QP and will eventually - * call nvmf_vfio_user_poll_group_add. The rest of the opertion needed to - * complete the addition of the queue will be continued at the - * completion callback. - */ - TAILQ_INSERT_TAIL(&vu_transport->new_qps, ctrlr->qp[qid], link); - - return 0; -} - /* * Creates a completion or sumbission I/O queue. Returns 0 on success, -errno * on error. @@ -913,14 +883,21 @@ handle_create_io_q(struct nvmf_vfio_user_ctrlr *ctrlr, (unsigned long long)io_q.addr); if (is_cq) { - err = add_qp(ctrlr, ctrlr->qp[0]->qpair.transport, io_q.size, - cmd->cdw10_bits.create_io_q.qid); + err = init_qp(ctrlr, ctrlr->qp[0]->qpair.transport, io_q.size, + cmd->cdw10_bits.create_io_q.qid); if (err != 0) { sc = SPDK_NVME_SC_INTERNAL_DEVICE_ERROR; goto out; } + /* + * After we've returned from the nvmf_vfio_user_poll_group_poll thread, once + * nvmf_vfio_user_accept executes it will pick up this QP and will eventually + * call nvmf_vfio_user_poll_group_add. The rest of the opertion needed to + * complete the addition of the queue will be continued at the + * completion callback. + */ + TAILQ_INSERT_TAIL(&ctrlr->transport->new_qps, ctrlr->qp[cmd->cdw10_bits.create_io_q.qid], link); } - insert_queue(ctrlr, &io_q, is_cq, cmd->cdw10_bits.create_io_q.qid); out: