diff mbox series

net/bnxt: don't set mbuf pointers to null in vector PMD

Message ID 20210302151608.537865-1-lance.richardson@broadcom.com (mailing list archive)
State Accepted
Delegated to: Ajit Khaparde
Headers show
Series net/bnxt: don't set mbuf pointers to null in vector PMD | expand

Checks

Context Check Description
ci/intel-Testing success Testing PASS
ci/Intel-compilation success Compilation OK
ci/iol-testing success Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/travis-robot success travis build: passed
ci/checkpatch success coding style OK

Commit Message

Lance Richardson March 2, 2021, 3:16 p.m. UTC
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 Kumar Khaparde <ajit.khaparde@broadcom.com>
Reviewed-by: Somnath Kotur <somnath.kotur@broadcom.com>
---
 drivers/net/bnxt/bnxt_rxq.c           | 10 ++++++++++
 drivers/net/bnxt/bnxt_rxtx_vec_neon.c | 17 +----------------
 drivers/net/bnxt/bnxt_rxtx_vec_sse.c  | 17 +----------------
 3 files changed, 12 insertions(+), 32 deletions(-)

Comments

Ajit Khaparde March 11, 2021, 11:57 p.m. UTC | #1
On Tue, Mar 2, 2021 at 7:16 AM Lance Richardson
<lance.richardson@broadcom.com> wrote:
>
> 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 Kumar Khaparde <ajit.khaparde@broadcom.com>
> Reviewed-by: Somnath Kotur <somnath.kotur@broadcom.com>

Patch applied to dpdk-next-net-brcm. Thanks
Shortened/modified the commit headline to
"modify mbuf pointer assignment"

> ---
>  drivers/net/bnxt/bnxt_rxq.c           | 10 ++++++++++
>  drivers/net/bnxt/bnxt_rxtx_vec_neon.c | 17 +----------------
>  drivers/net/bnxt/bnxt_rxtx_vec_sse.c  | 17 +----------------
>  3 files changed, 12 insertions(+), 32 deletions(-)
>
> diff --git a/drivers/net/bnxt/bnxt_rxq.c b/drivers/net/bnxt/bnxt_rxq.c
> index f46b10c1c5..d345c37c8d 100644
> --- a/drivers/net/bnxt/bnxt_rxq.c
> +++ b/drivers/net/bnxt/bnxt_rxq.c
> @@ -212,6 +212,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]) {
> diff --git a/drivers/net/bnxt/bnxt_rxtx_vec_neon.c b/drivers/net/bnxt/bnxt_rxtx_vec_neon.c
> index b0981da0f4..3d54d9d59d 100644
> --- a/drivers/net/bnxt/bnxt_rxtx_vec_neon.c
> +++ b/drivers/net/bnxt/bnxt_rxtx_vec_neon.c
> @@ -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);
>
> diff --git a/drivers/net/bnxt/bnxt_rxtx_vec_sse.c b/drivers/net/bnxt/bnxt_rxtx_vec_sse.c
> index 7ae6f5c098..7a58434ce9 100644
> --- a/drivers/net/bnxt/bnxt_rxtx_vec_sse.c
> +++ b/drivers/net/bnxt/bnxt_rxtx_vec_sse.c
> @@ -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);
>
> --
> 2.25.1
>
diff mbox series

Patch

diff --git a/drivers/net/bnxt/bnxt_rxq.c b/drivers/net/bnxt/bnxt_rxq.c
index f46b10c1c5..d345c37c8d 100644
--- a/drivers/net/bnxt/bnxt_rxq.c
+++ b/drivers/net/bnxt/bnxt_rxq.c
@@ -212,6 +212,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]) {
diff --git a/drivers/net/bnxt/bnxt_rxtx_vec_neon.c b/drivers/net/bnxt/bnxt_rxtx_vec_neon.c
index b0981da0f4..3d54d9d59d 100644
--- a/drivers/net/bnxt/bnxt_rxtx_vec_neon.c
+++ b/drivers/net/bnxt/bnxt_rxtx_vec_neon.c
@@ -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);
 
diff --git a/drivers/net/bnxt/bnxt_rxtx_vec_sse.c b/drivers/net/bnxt/bnxt_rxtx_vec_sse.c
index 7ae6f5c098..7a58434ce9 100644
--- a/drivers/net/bnxt/bnxt_rxtx_vec_sse.c
+++ b/drivers/net/bnxt/bnxt_rxtx_vec_sse.c
@@ -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);