net/sfc: support Rx free threshold
authorAndrew Rybchenko <arybchenko@solarflare.com>
Thu, 15 Dec 2016 12:51:07 +0000 (12:51 +0000)
committerFerruh Yigit <ferruh.yigit@intel.com>
Tue, 17 Jan 2017 18:40:50 +0000 (19:40 +0100)
Rx free threshold defines minimum number of free Rx descriptors
when Rx ring refill should be done.

Signed-off-by: Andrew Rybchenko <arybchenko@solarflare.com>
Reviewed-by: Andrew Lee <alee@solarflare.com>
Reviewed-by: Robert Stonehouse <rstonehouse@solarflare.com>
drivers/net/sfc/sfc_ethdev.c
drivers/net/sfc/sfc_rx.c
drivers/net/sfc/sfc_rx.h

index 97e82c1..226ff16 100644 (file)
@@ -837,6 +837,7 @@ sfc_rx_queue_info_get(struct rte_eth_dev *dev, uint16_t rx_queue_id,
        SFC_ASSERT(rxq != NULL);
 
        qinfo->mp = rxq->refill_mb_pool;
+       qinfo->conf.rx_free_thresh = rxq->refill_threshold;
        qinfo->conf.rx_drop_en = 1;
        qinfo->nb_desc = rxq_info->entries;
 
index be8fa23..278d583 100644 (file)
@@ -87,6 +87,10 @@ sfc_rx_qrefill(struct sfc_rxq *rxq)
 
        free_space = EFX_RXQ_LIMIT(rxq->ptr_mask + 1) -
                (added - rxq->completed);
+
+       if (free_space < rxq->refill_threshold)
+               return;
+
        bulks = free_space / RTE_DIM(objs);
 
        id = added & rxq->ptr_mask;
@@ -410,9 +414,10 @@ sfc_rx_qstop(struct sfc_adapter *sa, unsigned int sw_index)
 }
 
 static int
-sfc_rx_qcheck_conf(struct sfc_adapter *sa,
+sfc_rx_qcheck_conf(struct sfc_adapter *sa, uint16_t nb_rx_desc,
                   const struct rte_eth_rxconf *rx_conf)
 {
+       const uint16_t rx_free_thresh_max = EFX_RXQ_LIMIT(nb_rx_desc);
        int rc = 0;
 
        if (rx_conf->rx_thresh.pthresh != 0 ||
@@ -423,8 +428,10 @@ sfc_rx_qcheck_conf(struct sfc_adapter *sa,
                rc = EINVAL;
        }
 
-       if (rx_conf->rx_free_thresh != 0) {
-               sfc_err(sa, "RxQ free threshold is not supported");
+       if (rx_conf->rx_free_thresh > rx_free_thresh_max) {
+               sfc_err(sa,
+                       "RxQ free threshold too large: %u vs maximum %u",
+                       rx_conf->rx_free_thresh, rx_free_thresh_max);
                rc = EINVAL;
        }
 
@@ -555,7 +562,7 @@ sfc_rx_qinit(struct sfc_adapter *sa, unsigned int sw_index,
        struct sfc_evq *evq;
        struct sfc_rxq *rxq;
 
-       rc = sfc_rx_qcheck_conf(sa, rx_conf);
+       rc = sfc_rx_qcheck_conf(sa, nb_rx_desc, rx_conf);
        if (rc != 0)
                goto fail_bad_conf;
 
@@ -615,6 +622,7 @@ sfc_rx_qinit(struct sfc_adapter *sa, unsigned int sw_index,
        evq->rxq = rxq;
        rxq->evq = evq;
        rxq->ptr_mask = rxq_info->entries - 1;
+       rxq->refill_threshold = rx_conf->rx_free_thresh;
        rxq->refill_mb_pool = mb_pool;
        rxq->buf_size = buf_size;
        rxq->hw_index = sw_index;
index e4385b9..69318ab 100644 (file)
@@ -87,6 +87,7 @@ struct sfc_rxq {
        /* Used on refill */
        unsigned int            added;
        unsigned int            pushed;
+       unsigned int            refill_threshold;
        uint8_t                 port_id;
        uint16_t                buf_size;
        struct rte_mempool      *refill_mb_pool;