All of lore.kernel.org
 help / color / mirror / Atom feed
From: Lance Richardson <h.lance.richardson@gmail.com>
To: Ajit Khaparde <ajit.khaparde@broadcom.com>,
	Somnath Kotur <somnath.kotur@broadcom.com>
Cc: dev@dpdk.org, Lance Richardson <lance.richardson@broadcom.com>,
	stable@dpdk.org
Subject: [dpdk-dev] [PATCH] net/bnxt: fix fallback mbuf allocation logic
Date: Wed, 16 Dec 2020 10:06:18 -0500	[thread overview]
Message-ID: <20201216150618.1829951-1-lance604@gmail.com> (raw)

From: Lance Richardson <lance.richardson@broadcom.com>

Fixes for fallback mbuf allocation logic.
   - Preserve raw (unmasked) producer index.
   - Iterate over all processed descriptors (representor and
     non-representor) when checking allocation status.
   - Invoke fallback allocation logic when an allocation
     failure has occurred for any received packet, not
     just the last.

Fixes: 6dc83230b43b ("net/bnxt: support port representor data path")
Fixes: d9dd0b29ed31 ("net/bnxt: fix Rx handling and buffer allocation logic")
Fixes: 8b8dc3f783ff ("net/bnxt: modify ring index logic")
Cc: stable@dpdk.org
Signed-off-by: Lance Richardson <lance.richardson@broadcom.com>
---
 drivers/net/bnxt/bnxt_rxr.c | 28 +++++++++++++++++-----------
 1 file changed, 17 insertions(+), 11 deletions(-)

diff --git a/drivers/net/bnxt/bnxt_rxr.c b/drivers/net/bnxt/bnxt_rxr.c
index ffdeeecc3a..288b403bf0 100644
--- a/drivers/net/bnxt/bnxt_rxr.c
+++ b/drivers/net/bnxt/bnxt_rxr.c
@@ -839,6 +839,7 @@ uint16_t bnxt_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
 	uint16_t rx_raw_prod = rxr->rx_raw_prod;
 	uint16_t ag_raw_prod = rxr->ag_raw_prod;
 	uint32_t raw_cons = cpr->cp_raw_cons;
+	bool alloc_failed = false;
 	uint32_t cons;
 	int nb_rx_pkts = 0;
 	int nb_rep_rx_pkts = 0;
@@ -885,12 +886,16 @@ uint16_t bnxt_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
 		/* TODO: Avoid magic numbers... */
 		if ((CMP_TYPE(rxcmp) & 0x30) == 0x10) {
 			rc = bnxt_rx_pkt(&rx_pkts[nb_rx_pkts], rxq, &raw_cons);
-			if (likely(!rc) || rc == -ENOMEM)
+			if (!rc)
 				nb_rx_pkts++;
-			if (rc == -EBUSY)	/* partial completion */
+			else if (rc == -EBUSY)	/* partial completion */
 				break;
-			if (rc == -ENODEV)	/* completion for representor */
+			else if (rc == -ENODEV)	/* completion for representor */
 				nb_rep_rx_pkts++;
+			else if (rc == -ENOMEM) {
+				nb_rx_pkts++;
+				alloc_failed = true;
+			}
 		} else if (!BNXT_NUM_ASYNC_CPR(rxq->bp)) {
 			evt =
 			bnxt_event_hwrm_resp_handler(rxq->bp,
@@ -929,23 +934,24 @@ uint16_t bnxt_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
 		bnxt_db_write(&rxr->ag_db, rxr->ag_raw_prod);
 
 	/* Attempt to alloc Rx buf in case of a previous allocation failure. */
-	if (rc == -ENOMEM) {
-		int i = RING_NEXT(rx_raw_prod);
-		int cnt = nb_rx_pkts;
+	if (alloc_failed) {
+		uint16_t cnt;
 
-		for (; nb_rx_pkts; i = RING_NEXT(i), cnt--) {
+		rx_raw_prod = RING_NEXT(rx_raw_prod);
+		for (cnt = 0; cnt < nb_rx_pkts + nb_rep_rx_pkts; cnt++) {
 			struct rte_mbuf **rx_buf;
-			uint16_t rx_raw_prod = RING_IDX(rxr->rx_ring_struct, i);
+			uint16_t ndx;
 
-			rx_buf = &rxr->rx_buf_ring[rx_raw_prod];
+			ndx = RING_IDX(rxr->rx_ring_struct, rx_raw_prod + cnt);
+			rx_buf = &rxr->rx_buf_ring[ndx];
 
 			/* Buffer already allocated for this index. */
 			if (*rx_buf != NULL && *rx_buf != &rxq->fake_mbuf)
 				continue;
 
 			/* This slot is empty. Alloc buffer for Rx */
-			if (!bnxt_alloc_rx_data(rxq, rxr, i)) {
-				rxr->rx_raw_prod = i;
+			if (!bnxt_alloc_rx_data(rxq, rxr, rx_raw_prod + cnt)) {
+				rxr->rx_raw_prod = rx_raw_prod + cnt;
 				bnxt_db_write(&rxr->rx_db, rxr->rx_raw_prod);
 			} else {
 				PMD_DRV_LOG(ERR, "Alloc  mbuf failed\n");
-- 
2.25.1


             reply	other threads:[~2020-12-16 15:06 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-16 15:06 Lance Richardson [this message]
2020-12-17 23:57 ` [dpdk-dev] [PATCH] net/bnxt: fix fallback mbuf allocation logic Ajit Khaparde

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20201216150618.1829951-1-lance604@gmail.com \
    --to=h.lance.richardson@gmail.com \
    --cc=ajit.khaparde@broadcom.com \
    --cc=dev@dpdk.org \
    --cc=lance.richardson@broadcom.com \
    --cc=somnath.kotur@broadcom.com \
    --cc=stable@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.