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 58E57A0541; Thu, 6 Feb 2020 19:45:36 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 15A701C219; Thu, 6 Feb 2020 19:44:50 +0100 (CET) Received: from rnd-relay.smtp.broadcom.com (rnd-relay.smtp.broadcom.com [192.19.229.170]) by dpdk.org (Postfix) with ESMTP id 4156E1C1CA; Thu, 6 Feb 2020 19:44:39 +0100 (CET) Received: from mail-irv-17.broadcom.com (mail-irv-17.lvn.broadcom.net [10.75.242.48]) by rnd-relay.smtp.broadcom.com (Postfix) with ESMTP id A220D30C0AD; Thu, 6 Feb 2020 10:37:16 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.10.3 rnd-relay.smtp.broadcom.com A220D30C0AD DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=broadcom.com; s=dkimrelay; t=1581014236; bh=ZobIk0uDWNz1ktyFVA7oNdSr0MrbXMlEQSQDP2UYFsA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fL35G2zw0bxiiQhr7UgDwpr7chh95rS2NqyqvpACs0e1TdFiqMSxY2AFK5mWeyQYt 8KAUFvpxeJnPvkbcowH8iOnm/nRCoEkWbkZsfHyiwr8I1bqR1tL9U0xItgFaCm77Qz z0bsz8sEk1dgbo7lFOUGuprB9+zkYEf+n+7rVC+k= Received: from C02VPB22HTD6.wifi.broadcom.net (c02vpb22htd6.wifi.broadcom.net [10.69.74.102]) by mail-irv-17.broadcom.com (Postfix) with ESMTP id 75E0514008D; Thu, 6 Feb 2020 10:44:36 -0800 (PST) From: Ajit Khaparde To: dev@dpdk.org Cc: ferruh.yigit@intel.com, Santoshkumar Karanappa Rastapur , stable@dpdk.org, Somnath Kotur Date: Thu, 6 Feb 2020 10:44:32 -0800 Message-Id: <20200206184432.34360-8-ajit.khaparde@broadcom.com> X-Mailer: git-send-email 2.21.1 (Apple Git-122.3) In-Reply-To: <20200206184432.34360-1-ajit.khaparde@broadcom.com> References: <20200206163314.12755-1-kalesh-anakkur.purayil@broadcom.com> <20200206184432.34360-1-ajit.khaparde@broadcom.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH v2 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 1f47db97b..bef9720f5 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.21.1 (Apple Git-122.3)