From d318c6464c91b4423ed756f4e53dda3908450931 Mon Sep 17 00:00:00 2001 From: Andrew Boyer Date: Mon, 18 Jan 2021 12:35:03 -0800 Subject: [PATCH] net/ionic: inline queue space function This is a hot-path function. Remove ionic_q_has_space() while here. Signed-off-by: Andrew Boyer --- drivers/net/ionic/ionic_dev.c | 21 +-------------------- drivers/net/ionic/ionic_dev.h | 15 +++++++++++++-- 2 files changed, 14 insertions(+), 22 deletions(-) diff --git a/drivers/net/ionic/ionic_dev.c b/drivers/net/ionic/ionic_dev.c index a0a70644c3..aba1713fbc 100644 --- a/drivers/net/ionic/ionic_dev.c +++ b/drivers/net/ionic/ionic_dev.c @@ -476,25 +476,6 @@ ionic_q_post(struct ionic_queue *q, bool ring_doorbell, desc_cb cb, ionic_q_flush(q); } -uint32_t -ionic_q_space_avail(struct ionic_queue *q) -{ - uint32_t avail = q->tail_idx; - - if (q->head_idx >= avail) - avail += q->num_descs - q->head_idx - 1; - else - avail -= q->head_idx + 1; - - return avail; -} - -bool -ionic_q_has_space(struct ionic_queue *q, uint32_t want) -{ - return ionic_q_space_avail(q) >= want; -} - void ionic_q_service(struct ionic_queue *q, uint32_t cq_desc_index, uint32_t stop_index, void *service_cb_arg) @@ -563,7 +544,7 @@ ionic_adminq_post(struct ionic_lif *lif, struct ionic_admin_ctx *ctx) rte_spinlock_lock(&lif->adminq_lock); - if (!ionic_q_has_space(adminq, 1)) { + if (ionic_q_space_avail(adminq) < 1) { err = -ENOSPC; goto err_out; } diff --git a/drivers/net/ionic/ionic_dev.h b/drivers/net/ionic/ionic_dev.h index afaddb719f..ef63ff7abd 100644 --- a/drivers/net/ionic/ionic_dev.h +++ b/drivers/net/ionic/ionic_dev.h @@ -256,11 +256,22 @@ void ionic_q_map(struct ionic_queue *q, void *base, rte_iova_t base_pa); void ionic_q_sg_map(struct ionic_queue *q, void *base, rte_iova_t base_pa); void ionic_q_post(struct ionic_queue *q, bool ring_doorbell, desc_cb cb, void *cb_arg); -uint32_t ionic_q_space_avail(struct ionic_queue *q); -bool ionic_q_has_space(struct ionic_queue *q, uint32_t want); void ionic_q_service(struct ionic_queue *q, uint32_t cq_desc_index, uint32_t stop_index, void *service_cb_arg); +static inline uint32_t +ionic_q_space_avail(struct ionic_queue *q) +{ + uint32_t avail = q->tail_idx; + + if (q->head_idx >= avail) + avail += q->num_descs - q->head_idx - 1; + else + avail -= q->head_idx + 1; + + return avail; +} + static inline void ionic_q_flush(struct ionic_queue *q) { -- 2.20.1