Commit 8586a1b3 authored by Changpeng Liu's avatar Changpeng Liu Committed by Tomasz Zawadzki
Browse files

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: default avatarChangpeng Liu <changpeng.liu@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/6308


Community-CI: Broadcom CI
Community-CI: Mellanox Build Bot
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarBen Walker <benjamin.walker@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
parent a7ab74b1
Loading
Loading
Loading
Loading
+10 −33
Original line number Diff line number Diff line
@@ -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,
		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: