net/sfc: avoid dummy writes to Rx queue state structure
authorAndrew Rybchenko <arybchenko@solarflare.com>
Wed, 3 Oct 2018 09:03:51 +0000 (10:03 +0100)
committerFerruh Yigit <ferruh.yigit@intel.com>
Thu, 11 Oct 2018 16:53:49 +0000 (18:53 +0200)
If there is no packets to be processed, it does not make sense
to write the same values back to Rx queue structure.

Signed-off-by: Andrew Rybchenko <arybchenko@solarflare.com>
Reviewed-by: Ivan Malov <ivan.malov@oktetlabs.ru>
drivers/net/sfc/sfc_ef10_rx.c

index 8d0e69c..0986102 100644 (file)
@@ -191,14 +191,18 @@ sfc_ef10_rx_prepared(struct sfc_ef10_rxq *rxq, struct rte_mbuf **rx_pkts,
                     uint16_t nb_pkts)
 {
        uint16_t n_rx_pkts = RTE_MIN(nb_pkts, rxq->prepared);
-       unsigned int completed = rxq->completed;
-       unsigned int i;
 
-       rxq->prepared -= n_rx_pkts;
-       rxq->completed = completed + n_rx_pkts;
+       if (n_rx_pkts != 0) {
+               unsigned int completed = rxq->completed;
 
-       for (i = 0; i < n_rx_pkts; ++i, ++completed)
-               rx_pkts[i] = rxq->sw_ring[completed & rxq->ptr_mask].mbuf;
+               rxq->prepared -= n_rx_pkts;
+               rxq->completed = completed + n_rx_pkts;
+
+               do {
+                       *rx_pkts++ =
+                               rxq->sw_ring[completed++ & rxq->ptr_mask].mbuf;
+               } while (completed != rxq->completed);
+       }
 
        return n_rx_pkts;
 }