From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from out4-smtp.messagingengine.com (out4-smtp.messagingengine.com [66.111.4.28]) by dpdk.org (Postfix) with ESMTP id 2B40323B for ; Tue, 21 Nov 2017 14:23:21 +0100 (CET) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id D52DC20CA7; Tue, 21 Nov 2017 08:23:20 -0500 (EST) Received: from frontend2 ([10.202.2.161]) by compute1.internal (MEProxy); Tue, 21 Nov 2017 08:23:20 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fridaylinux.org; h=cc:date:from:in-reply-to:message-id:references:subject:to :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; bh=q4HtniHkcr45Py9cL QbNyBi3YcAJeEYrxQ5NEfIc/L8=; b=j2otixjDepmf96XxeQBhIKyp9AMYT5y1e IhUGRSLn+VSmM2zTREVFHMO8txKxg5vK6SQBmdyOOSRVtzk7Dyg0c6af7YbNRRzC ZHm5dAbMh/aq++n2NoQq1QDuSSYCD4RsfgIHq45bHjZokfTZyb0xxGsTfyS0lwQB dpNnZf6aGJvhrqjc3sldhypExij6lgBnqPGIYEqF3Xyh9TWoHq3fI6MYC/7smnOi fuTt6SE0tXvLSiMlYWApmKDDBaMF5bmyOGt6SWgrmY6J52L5RN9mYVpv3ttkYJIy 009NLvyzFVV2cES6nduOZZtKeWzXD9AcPhdqJTionfxPOtK6QH8zA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:date:from:in-reply-to:message-id :references:subject:to:x-me-sender:x-me-sender:x-sasl-enc; s= fm1; bh=q4HtniHkcr45Py9cLQbNyBi3YcAJeEYrxQ5NEfIc/L8=; b=U8yEODfH doG1ram5F0f8f3+Y9CXzY7yoc4GVPt67lcD9iI57JsPUmhdCl0Y9ON8qr+xi87Ah 5GpdY+W6Ga4j12b8+L6mioqtITvvttGuy7bFoUeTJu5NZ2JqJBb0OW4gOy25TAFM qHBOSiuS2Ir4GJHifH+Tu355/gr233TlFbTQ3ZBpuB9FhI25mqTyFh+/Kg+4q9/E gp2t/2++YZ7IpE4Q6bJ1iszU6QLUmORe0QXLoxT4A/rm1eLE++ExVoSteSgVYYdb 4HwMVxpJPWAUViAr77xNcwgB+9R22B36lRkFODkgoRD5E6Sitnqyh7LD/BS5Jl9j SICwi9a7XDzJEw== X-ME-Sender: Received: from localhost.localdomain (unknown [180.158.62.0]) by mail.messagingengine.com (Postfix) with ESMTPA id D3552243B9; Tue, 21 Nov 2017 08:23:18 -0500 (EST) From: Yuanhan Liu To: Ajit Khaparde Cc: dpdk stable Date: Tue, 21 Nov 2017 21:16:42 +0800 Message-Id: <1511270333-31002-60-git-send-email-yliu@fridaylinux.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1511270333-31002-1-git-send-email-yliu@fridaylinux.org> References: <1511270333-31002-1-git-send-email-yliu@fridaylinux.org> Subject: [dpdk-stable] patch 'net/bnxt: fix Rx handling and buffer allocation logic' has been queued to stable release 17.08.1 X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 21 Nov 2017 13:23:21 -0000 Hi, FYI, your patch has been queued to stable release 17.08.1 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 11/24/17. So please shout if anyone has objections. Thanks. --yliu --- >>From ee754a2f84951da46c4a484a7f11751847172a76 Mon Sep 17 00:00:00 2001 From: Ajit Khaparde Date: Thu, 28 Sep 2017 16:43:27 -0500 Subject: [PATCH] net/bnxt: fix Rx handling and buffer allocation logic [ upstream commit d9dd0b29ed315cff166b96cea278d0bcf489cd47 ] Even when rx buffer allocation fails, we are wrongly updating the producer index. This patch fixes that. Also in case of a buffer allocation failure, reattempt buffer allocation before the rx handler exits. Fixes: 2eb53b134aae ("net/bnxt: add initial Rx code") Signed-off-by: Ajit Khaparde --- drivers/net/bnxt/bnxt_rxr.c | 32 +++++++++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) diff --git a/drivers/net/bnxt/bnxt_rxr.c b/drivers/net/bnxt/bnxt_rxr.c index bee67d3..bf9f78a 100644 --- a/drivers/net/bnxt/bnxt_rxr.c +++ b/drivers/net/bnxt/bnxt_rxr.c @@ -391,7 +391,7 @@ static int bnxt_rx_pkt(struct rte_mbuf **rx_pkt, rte_prefetch0(mbuf); if (mbuf == NULL) - return -ENOMEM; + return -EBUSY; mbuf->nb_segs = 1; mbuf->next = NULL; @@ -448,13 +448,14 @@ static int bnxt_rx_pkt(struct rte_mbuf **rx_pkt, if (bnxt_alloc_rx_data(rxq, rxr, prod)) { RTE_LOG(ERR, PMD, "mbuf alloc failed with prod=0x%x\n", prod); rc = -ENOMEM; + goto rx; } rxr->rx_prod = prod; /* * All MBUFs are allocated with the same size under DPDK, * no optimization for rx_copy_thresh */ - +rx: *rx_pkt = mbuf; next_rx: @@ -476,6 +477,7 @@ uint16_t bnxt_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, struct rx_pkt_cmpl *rxcmp; uint16_t prod = rxr->rx_prod; uint16_t ag_prod = rxr->ag_prod; + int rc = 0; /* Handle RX burst request */ while (1) { @@ -491,7 +493,7 @@ 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)) + if (likely(!rc) || rc == -ENOMEM) nb_rx_pkts++; if (rc == -EBUSY) /* partial completion */ break; @@ -514,6 +516,30 @@ uint16_t bnxt_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, B_RX_DB(rxr->rx_doorbell, rxr->rx_prod); /* Ring the AGG ring DB */ B_RX_DB(rxr->ag_doorbell, rxr->ag_prod); + + /* Attempt to alloc Rx buf in case of a previous allocation failure. */ + if (rc == -ENOMEM) { + int i; + + for (i = prod; i <= nb_rx_pkts; + i = RING_NEXT(rxr->rx_ring_struct, i)) { + struct bnxt_sw_rx_bd *rx_buf = &rxr->rx_buf_ring[i]; + + /* Buffer already allocated for this index. */ + if (rx_buf->mbuf != NULL) + continue; + + /* This slot is empty. Alloc buffer for Rx */ + if (!bnxt_alloc_rx_data(rxq, rxr, i)) { + rxr->rx_prod = i; + B_RX_DB(rxr->rx_doorbell, rxr->rx_prod); + } else { + RTE_LOG(ERR, PMD, "Alloc mbuf failed\n"); + break; + } + } + } + return nb_rx_pkts; } -- 2.7.4