nvmf/vfio-user: refactor out ctrlr_start()

Signed-off-by: John Levon <john.levon@nutanix.com>
Change-Id: I71563037c15ebe0b76cfa603deea7576bad5c73c
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/12836
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com>
Community-CI: Mellanox Build Bot
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Thanos Makatos <thanos.makatos@nutanix.com>
This commit is contained in:
John Levon 2022-05-05 23:19:44 +00:00 committed by Tomasz Zawadzki
parent 6066e62ee6
commit 554b3b3fe9

View File

@ -4744,6 +4744,43 @@ vfio_user_set_intr_mode(struct spdk_poller *poller, void *arg,
vfio_user_poll_group_rearm(ctrlr_to_poll_group(ctrlr));
}
/*
* In response to the nvmf_vfio_user_create_ctrlr() path, the admin queue is now
* set up and we can start operating on this controller.
*/
static void
start_ctrlr(struct nvmf_vfio_user_ctrlr *vu_ctrlr,
struct spdk_nvmf_ctrlr *ctrlr)
{
struct nvmf_vfio_user_endpoint *endpoint = vu_ctrlr->endpoint;
vu_ctrlr->ctrlr = ctrlr;
vu_ctrlr->cntlid = ctrlr->cntlid;
vu_ctrlr->thread = spdk_get_thread();
vu_ctrlr->state = VFIO_USER_CTRLR_RUNNING;
if (!in_interrupt_mode(endpoint->transport)) {
vu_ctrlr->vfu_ctx_poller = SPDK_POLLER_REGISTER(vfio_user_poll_vfu_ctx,
vu_ctrlr, 1000);
return;
}
vu_ctrlr->vfu_ctx_poller = SPDK_POLLER_REGISTER(vfio_user_poll_vfu_ctx,
vu_ctrlr, 0);
vu_ctrlr->intr_fd = vfu_get_poll_fd(vu_ctrlr->endpoint->vfu_ctx);
assert(vu_ctrlr->intr_fd != -1);
vu_ctrlr->intr = SPDK_INTERRUPT_REGISTER(vu_ctrlr->intr_fd,
vfio_user_ctrlr_intr, vu_ctrlr);
assert(vu_ctrlr->intr != NULL);
spdk_poller_register_interrupt(vu_ctrlr->vfu_ctx_poller,
vfio_user_set_intr_mode,
vu_ctrlr);
}
static int
handle_queue_connect_rsp(struct nvmf_vfio_user_req *req, void *cb_arg)
{
@ -4776,32 +4813,8 @@ handle_queue_connect_rsp(struct nvmf_vfio_user_req *req, void *cb_arg)
pthread_mutex_lock(&endpoint->lock);
if (nvmf_qpair_is_admin_queue(&sq->qpair)) {
vu_ctrlr->cntlid = sq->qpair.ctrlr->cntlid;
vu_ctrlr->thread = spdk_get_thread();
vu_ctrlr->ctrlr = sq->qpair.ctrlr;
vu_ctrlr->state = VFIO_USER_CTRLR_RUNNING;
admin_cq->thread = spdk_get_thread();
if (in_interrupt_mode(endpoint->transport)) {
vu_ctrlr->vfu_ctx_poller = SPDK_POLLER_REGISTER(vfio_user_poll_vfu_ctx,
vu_ctrlr, 0);
vu_ctrlr->intr_fd = vfu_get_poll_fd(vu_ctrlr->endpoint->vfu_ctx);
assert(vu_ctrlr->intr_fd != -1);
vu_ctrlr->intr = SPDK_INTERRUPT_REGISTER(vu_ctrlr->intr_fd,
vfio_user_ctrlr_intr, vu_ctrlr);
assert(vu_ctrlr->intr != NULL);
spdk_poller_register_interrupt(vu_ctrlr->vfu_ctx_poller,
vfio_user_set_intr_mode,
vu_ctrlr);
} else {
vu_ctrlr->vfu_ctx_poller = SPDK_POLLER_REGISTER(vfio_user_poll_vfu_ctx,
vu_ctrlr, 1000);
}
start_ctrlr(vu_ctrlr, sq->qpair.ctrlr);
} else {
/* For I/O queues this command was generated in response to an
* ADMIN I/O CREATE SUBMISSION QUEUE command which has not yet