Prepare to support more options for number of Rx descriptors.

libefx-based datapath is updated just for completeness to
make code more readable and less error-prone.

Signed-off-by: Andrew Rybchenko <arybche...@solarflare.com>
Reviewed-by: Andy Moreton <amore...@solarflare.com>
---
 drivers/net/sfc/sfc_dp_rx.h   | 2 ++
 drivers/net/sfc/sfc_ef10_rx.c | 5 +++--
 drivers/net/sfc/sfc_rx.c      | 5 +++--
 drivers/net/sfc/sfc_rx.h      | 1 +
 4 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/drivers/net/sfc/sfc_dp_rx.h b/drivers/net/sfc/sfc_dp_rx.h
index d2e3106..029ebaf 100644
--- a/drivers/net/sfc/sfc_dp_rx.h
+++ b/drivers/net/sfc/sfc_dp_rx.h
@@ -60,6 +60,8 @@ struct sfc_dp_rxq {
 struct sfc_dp_rx_qcreate_info {
        /** Memory pool to allocate Rx buffer from */
        struct rte_mempool      *refill_mb_pool;
+       /** Maximum number of pushed Rx descriptors in the queue */
+       unsigned int            max_fill_level;
        /** Minimum number of unused Rx descriptors to do refill */
        unsigned int            refill_threshold;
        /**
diff --git a/drivers/net/sfc/sfc_ef10_rx.c b/drivers/net/sfc/sfc_ef10_rx.c
index 192cfb4..ad84629 100644
--- a/drivers/net/sfc/sfc_ef10_rx.c
+++ b/drivers/net/sfc/sfc_ef10_rx.c
@@ -93,6 +93,7 @@ struct sfc_ef10_rxq {
        /* Used on refill */
        uint16_t                        buf_size;
        unsigned int                    added;
+       unsigned int                    max_fill_level;
        unsigned int                    refill_threshold;
        struct rte_mempool              *refill_mb_pool;
        efx_qword_t                     *rxq_hw_ring;
@@ -141,8 +142,7 @@ sfc_ef10_rx_qrefill(struct sfc_ef10_rxq *rxq)
        void *objs[SFC_RX_REFILL_BULK];
        unsigned int added = rxq->added;
 
-       free_space = SFC_EF10_RXQ_LIMIT(ptr_mask + 1) -
-               (added - rxq->completed);
+       free_space = rxq->max_fill_level - (added - rxq->completed);
 
        if (free_space < rxq->refill_threshold)
                return;
@@ -705,6 +705,7 @@ sfc_ef10_rx_qcreate(uint16_t port_id, uint16_t queue_id,
                rxq->flags |= SFC_EF10_RXQ_RSS_HASH;
        rxq->ptr_mask = info->rxq_entries - 1;
        rxq->evq_hw_ring = info->evq_hw_ring;
+       rxq->max_fill_level = info->max_fill_level;
        rxq->refill_threshold = info->refill_threshold;
        rxq->rearm_data =
                sfc_ef10_mk_mbuf_rearm_data(port_id, info->prefix_size);
diff --git a/drivers/net/sfc/sfc_rx.c b/drivers/net/sfc/sfc_rx.c
index f9da984..387f855 100644
--- a/drivers/net/sfc/sfc_rx.c
+++ b/drivers/net/sfc/sfc_rx.c
@@ -88,8 +88,7 @@ sfc_efx_rx_qrefill(struct sfc_efx_rxq *rxq)
        struct rte_mbuf *m;
        uint16_t port_id = rxq->dp.dpq.port_id;
 
-       free_space = EFX_RXQ_LIMIT(rxq->ptr_mask + 1) -
-               (added - rxq->completed);
+       free_space = rxq->max_fill_level - (added - rxq->completed);
 
        if (free_space < rxq->refill_threshold)
                return;
@@ -459,6 +458,7 @@ sfc_efx_rx_qcreate(uint16_t port_id, uint16_t queue_id,
        rxq->ptr_mask = info->rxq_entries - 1;
        rxq->batch_max = info->batch_max;
        rxq->prefix_size = info->prefix_size;
+       rxq->max_fill_level = info->max_fill_level;
        rxq->refill_threshold = info->refill_threshold;
        rxq->buf_size = info->buf_size;
        rxq->refill_mb_pool = info->refill_mb_pool;
@@ -998,6 +998,7 @@ sfc_rx_qinit(struct sfc_adapter *sa, unsigned int sw_index,
 
        memset(&info, 0, sizeof(info));
        info.refill_mb_pool = rxq->refill_mb_pool;
+       info.max_fill_level = rxq_max_fill_level;
        info.refill_threshold = rxq->refill_threshold;
        info.buf_size = buf_size;
        info.batch_max = encp->enc_rx_batch_max;
diff --git a/drivers/net/sfc/sfc_rx.h b/drivers/net/sfc/sfc_rx.h
index ff72718..956cb3f 100644
--- a/drivers/net/sfc/sfc_rx.h
+++ b/drivers/net/sfc/sfc_rx.h
@@ -121,6 +121,7 @@ struct sfc_efx_rxq {
        /* Used on refill */
        unsigned int                    added;
        unsigned int                    pushed;
+       unsigned int                    max_fill_level;
        unsigned int                    refill_threshold;
        uint16_t                        buf_size;
        struct rte_mempool              *refill_mb_pool;
-- 
2.7.4

Reply via email to