[7/7] net/bnxt: fix buffer allocation reattempt logic

Message ID 20200206163314.12755-8-kalesh-anakkur.purayil@broadcom.com (mailing list archive)
State Superseded, archived
Headers
Series bnxt patchset with bug fixes |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/travis-robot warning Travis build: failed
ci/Intel-compilation fail apply issues

Commit Message

Kalesh A P Feb. 6, 2020, 4:33 p.m. UTC
From: Santoshkumar Karanappa Rastapur <santosh.rastapur@broadcom.com>

In case of a buffer allocation failure, we reattempt buffer allocation
before the rx handler exits. We were not attempting this when producer
index is greater than the number of buffers to allocate. Fixed it with
correct checks.

Fixes: d9dd0b29ed31 ("net/bnxt: fix Rx handling and buffer allocation logic")
Cc: stable@dpdk.org

Signed-off-by: Santoshkumar Karanappa Rastapur <santosh.rastapur@broadcom.com>
Reviewed-by: Somnath Kotur <somnath.kotur@broadcom.com>
---
 drivers/net/bnxt/bnxt_rxr.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
  

Patch

diff --git a/drivers/net/bnxt/bnxt_rxr.c b/drivers/net/bnxt/bnxt_rxr.c
index 1f47db9..bef9720 100644
--- a/drivers/net/bnxt/bnxt_rxr.c
+++ b/drivers/net/bnxt/bnxt_rxr.c
@@ -678,10 +678,11 @@  uint16_t bnxt_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
 
 	/* Attempt to alloc Rx buf in case of a previous allocation failure. */
 	if (rc == -ENOMEM) {
-		int i;
+		int i = RING_NEXT(rxr->rx_ring_struct, prod);
+		int cnt = nb_rx_pkts;
 
-		for (i = prod; i <= nb_rx_pkts;
-			i = RING_NEXT(rxr->rx_ring_struct, i)) {
+		for (; cnt;
+			i = RING_NEXT(rxr->rx_ring_struct, i), cnt--) {
 			struct bnxt_sw_rx_bd *rx_buf = &rxr->rx_buf_ring[i];
 
 			/* Buffer already allocated for this index. */