From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 2C755A053B; Thu, 6 Feb 2020 17:17:33 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 630861C1F8; Thu, 6 Feb 2020 17:16:36 +0100 (CET) Received: from relay.smtp.broadcom.com (relay.smtp.broadcom.com [192.19.232.149]) by dpdk.org (Postfix) with ESMTP id D4AA11C1CC for ; Thu, 6 Feb 2020 17:16:30 +0100 (CET) Received: from dhcp-10-123-153-22.dhcp.broadcom.net (bgccx-dev-host-lnx2.bec.broadcom.net [10.123.153.22]) by relay.smtp.broadcom.com (Postfix) with ESMTP id 385101BDA23; Thu, 6 Feb 2020 08:16:29 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.10.3 relay.smtp.broadcom.com 385101BDA23 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=broadcom.com; s=dkimrelay; t=1581005790; bh=k+7KR2yeLVcY58ci1KWYwHvY6PwcuNX46DPTTWD2JKU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=X3m+PhSo8XREr87pubHC3ma8o+sSFLgEqw8OuVYnIDBaQ/DRCUB2Asapc6wzcorKQ S1i1k3wKB6OvbLATTO/F2iwSzCe8HhaZY8rksfZMHFkp9o7xdi10N2DCHEdVn8EkU4 F33lETf3dlkshQn+CsG1RTAaEk8T88XO6egtRLaQ= From: Kalesh A P To: dev@dpdk.org Cc: ferruh.yigit@intel.com, ajit.khaparde@broadcom.com Date: Thu, 6 Feb 2020 22:03:14 +0530 Message-Id: <20200206163314.12755-8-kalesh-anakkur.purayil@broadcom.com> X-Mailer: git-send-email 2.10.1 In-Reply-To: <20200206163314.12755-1-kalesh-anakkur.purayil@broadcom.com> References: <20200206163314.12755-1-kalesh-anakkur.purayil@broadcom.com> Subject: [dpdk-dev] [PATCH 7/7] net/bnxt: fix buffer allocation reattempt logic X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" From: Santoshkumar Karanappa Rastapur 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 Reviewed-by: Somnath Kotur --- drivers/net/bnxt/bnxt_rxr.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) 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. */ -- 2.10.1