From f49b1724ba9f0d097d18e5a40eea8f70a2ccf7e8 Mon Sep 17 00:00:00 2001 From: John Levon Date: Wed, 2 Mar 2022 11:08:09 +0000 Subject: [PATCH] nvmf/vfio-user: move io_q_exists() As a general utility function, move it up with the others. Signed-off-by: John Levon Change-Id: I32881c01afd9819c889730d7c09163c95fbb827e Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/11790 Tested-by: SPDK CI Jenkins Community-CI: Broadcom CI Community-CI: Mellanox Build Bot Reviewed-by: Changpeng Liu Reviewed-by: Thanos Makatos Reviewed-by: Ben Walker --- lib/nvmf/vfio_user.c | 52 ++++++++++++++++++++++---------------------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/lib/nvmf/vfio_user.c b/lib/nvmf/vfio_user.c index 19c28f810..aaecdf8b6 100644 --- a/lib/nvmf/vfio_user.c +++ b/lib/nvmf/vfio_user.c @@ -497,6 +497,32 @@ cq_is_full(struct nvmf_vfio_user_cq *cq) return qindex == *cq_dbl_headp(cq); } +static bool +io_q_exists(struct nvmf_vfio_user_ctrlr *vu_ctrlr, const uint16_t qid, const bool is_cq) +{ + assert(vu_ctrlr != NULL); + + if (qid == 0 || qid >= NVMF_VFIO_USER_MAX_QPAIRS_PER_CTRLR) { + return false; + } + + if (is_cq) { + if (vu_ctrlr->cqs[qid] == NULL) { + return false; + } + + return (vu_ctrlr->cqs[qid]->cq_state != VFIO_USER_CQ_DELETED && + vu_ctrlr->cqs[qid]->cq_state != VFIO_USER_CQ_UNUSED); + } + + if (vu_ctrlr->sqs[qid] == NULL) { + return false; + } + + return (vu_ctrlr->sqs[qid]->sq_state != VFIO_USER_SQ_DELETED && + vu_ctrlr->sqs[qid]->sq_state != VFIO_USER_SQ_UNUSED); +} + static inline size_t vfio_user_migr_data_len(void) { @@ -1215,32 +1241,6 @@ post_completion(struct nvmf_vfio_user_ctrlr *ctrlr, struct nvmf_vfio_user_cq *cq return 0; } -static bool -io_q_exists(struct nvmf_vfio_user_ctrlr *vu_ctrlr, const uint16_t qid, const bool is_cq) -{ - assert(vu_ctrlr != NULL); - - if (qid == 0 || qid >= NVMF_VFIO_USER_MAX_QPAIRS_PER_CTRLR) { - return false; - } - - if (is_cq) { - if (vu_ctrlr->cqs[qid] == NULL) { - return false; - } - - return (vu_ctrlr->cqs[qid]->cq_state != VFIO_USER_CQ_DELETED && - vu_ctrlr->cqs[qid]->cq_state != VFIO_USER_CQ_UNUSED); - } - - if (vu_ctrlr->sqs[qid] == NULL) { - return false; - } - - return (vu_ctrlr->sqs[qid]->sq_state != VFIO_USER_SQ_DELETED && - vu_ctrlr->sqs[qid]->sq_state != VFIO_USER_SQ_UNUSED); -} - static void free_sq_reqs(struct nvmf_vfio_user_sq *sq) {