net/bnxt: refactor mbuf pointer reset
authorLance Richardson <lance.richardson@broadcom.com>
Tue, 2 Mar 2021 15:16:08 +0000 (10:16 -0500)
committerAjit Khaparde <ajit.khaparde@broadcom.com>
Fri, 12 Mar 2021 06:13:27 +0000 (07:13 +0100)
Remove code for setting consumed mbuf pointers to NULL from the
vector receive functions as a minor performance optimization.

Signed-off-by: Lance Richardson <lance.richardson@broadcom.com>
Reviewed-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
Reviewed-by: Somnath Kotur <somnath.kotur@broadcom.com>
drivers/net/bnxt/bnxt_rxq.c
drivers/net/bnxt/bnxt_rxtx_vec_neon.c
drivers/net/bnxt/bnxt_rxtx_vec_sse.c

index 53a9b52..2b0d3d4 100644 (file)
@@ -213,6 +213,16 @@ void bnxt_rx_queue_release_mbufs(struct bnxt_rx_queue *rxq)
 
        sw_ring = rxq->rx_ring->rx_buf_ring;
        if (sw_ring) {
+#if defined(RTE_ARCH_X86) || defined(RTE_ARCH_ARM64)
+               /*
+                * The vector receive burst function does not set used
+                * mbuf pointers to NULL, do that here to simplify
+                * cleanup logic.
+                */
+               for (i = 0; i < rxq->rxrearm_nb; i++)
+                       sw_ring[rxq->rxrearm_start + i] = NULL;
+               rxq->rxrearm_nb = 0;
+#endif
                for (i = 0;
                     i < rxq->rx_ring->rx_ring_struct->ring_size; i++) {
                        if (sw_ring[i]) {
index b0981da..3d54d9d 100644 (file)
@@ -274,22 +274,8 @@ bnxt_recv_pkts_vec(void *rx_queue, struct rte_mbuf **rx_pkts,
                num_valid = (sizeof(uint64_t) / sizeof(uint16_t)) -
                                (__builtin_clzl(valid & desc_valid_mask) / 16);
 
-               switch (num_valid) {
-               case 4:
-                       rxr->rx_buf_ring[mbcons + 3] = NULL;
-                       /* FALLTHROUGH */
-               case 3:
-                       rxr->rx_buf_ring[mbcons + 2] = NULL;
-                       /* FALLTHROUGH */
-               case 2:
-                       rxr->rx_buf_ring[mbcons + 1] = NULL;
-                       /* FALLTHROUGH */
-               case 1:
-                       rxr->rx_buf_ring[mbcons + 0] = NULL;
+               if (num_valid == 0)
                        break;
-               case 0:
-                       goto out;
-               }
 
                descs_to_mbufs(rxcmp, rxcmp1, mb_init, &rx_pkts[nb_rx_pkts],
                               rxr);
@@ -299,7 +285,6 @@ bnxt_recv_pkts_vec(void *rx_queue, struct rte_mbuf **rx_pkts,
                        break;
        }
 
-out:
        if (nb_rx_pkts) {
                rxr->rx_raw_prod = RING_ADV(rxr->rx_raw_prod, nb_rx_pkts);
 
index 7ae6f5c..7a58434 100644 (file)
@@ -256,22 +256,8 @@ bnxt_recv_pkts_vec(void *rx_queue, struct rte_mbuf **rx_pkts,
                valid = _mm_cvtsi128_si64(_mm_packs_epi32(info3_v, info3_v));
                num_valid = __builtin_popcountll(valid & desc_valid_mask);
 
-               switch (num_valid) {
-               case 4:
-                       rxr->rx_buf_ring[mbcons + 3] = NULL;
-                       /* FALLTHROUGH */
-               case 3:
-                       rxr->rx_buf_ring[mbcons + 2] = NULL;
-                       /* FALLTHROUGH */
-               case 2:
-                       rxr->rx_buf_ring[mbcons + 1] = NULL;
-                       /* FALLTHROUGH */
-               case 1:
-                       rxr->rx_buf_ring[mbcons + 0] = NULL;
+               if (num_valid == 0)
                        break;
-               case 0:
-                       goto out;
-               }
 
                descs_to_mbufs(rxcmp, rxcmp1, mbuf_init, &rx_pkts[nb_rx_pkts],
                               rxr);
@@ -281,7 +267,6 @@ bnxt_recv_pkts_vec(void *rx_queue, struct rte_mbuf **rx_pkts,
                        break;
        }
 
-out:
        if (nb_rx_pkts) {
                rxr->rx_raw_prod = RING_ADV(rxr->rx_raw_prod, nb_rx_pkts);