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 F1AC1A2E1B for ; Tue, 3 Sep 2019 04:21:03 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id E5CD51EB36; Tue, 3 Sep 2019 04:19:33 +0200 (CEST) Received: from rnd-relay.smtp.broadcom.com (rnd-relay.smtp.broadcom.com [192.19.229.170]) by dpdk.org (Postfix) with ESMTP id 64E5A2B94 for ; Tue, 3 Sep 2019 04:19:09 +0200 (CEST) Received: from nis-sj1-27.broadcom.com (nis-sj1-27.lvn.broadcom.net [10.75.144.136]) by rnd-relay.smtp.broadcom.com (Postfix) with ESMTP id CC31B30C1FE; Mon, 2 Sep 2019 19:19:01 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.10.3 rnd-relay.smtp.broadcom.com CC31B30C1FE DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=broadcom.com; s=dkimrelay; t=1567477141; bh=T4katix4EVgL+HcU+T6Bkj1hOuGec0vgZhDulyx9JL4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=funBSWyb8H0Ptx+AXbp8KGtAgOkgIG7xOcvJazEgK7kioWDGRQFun4FB6em6aMoRH H7J/3kKRSSocAdvlKbYllBWB3aXIj9amZDqMvjcohZ4KxWBhX1DL8ym2wcU4iRCo1P t1J7ve/wOQfKflmcCfBkwySGqlaG63lhi8UTBrHk= Received: from localhost.localdomain (unknown [10.230.30.225]) by nis-sj1-27.broadcom.com (Postfix) with ESMTP id D68A6AC078A; Mon, 2 Sep 2019 19:19:07 -0700 (PDT) From: Ajit Khaparde To: dev@dpdk.org Cc: ferruh.yigit@intel.com, Rahul Gupta , Venkat Duvvuru , Kalesh Anakkur Purayil Date: Mon, 2 Sep 2019 19:18:54 -0700 Message-Id: <20190903021901.25895-11-ajit.khaparde@broadcom.com> X-Mailer: git-send-email 2.20.1 (Apple Git-117) In-Reply-To: <20190903021901.25895-1-ajit.khaparde@broadcom.com> References: <20190903021901.25895-1-ajit.khaparde@broadcom.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH 10/17] net/bnxt: properly handle ring cleanup in case of error 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: Rahul Gupta Initialize all rings to INVALID_HW_RING_ID. This can be used to determine the rings to free if allocation fails. Signed-off-by: Rahul Gupta Reviewed-by: Venkat Duvvuru Reviewed-by: Kalesh Anakkur Purayil Reviewed-by: Ajit Khaparde Signed-off-by: Ajit Khaparde --- drivers/net/bnxt/bnxt_ring.c | 37 ++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/drivers/net/bnxt/bnxt_ring.c b/drivers/net/bnxt/bnxt_ring.c index 119a6919f..f6e81d308 100644 --- a/drivers/net/bnxt/bnxt_ring.c +++ b/drivers/net/bnxt/bnxt_ring.c @@ -637,6 +637,42 @@ int bnxt_alloc_hwrm_rx_ring(struct bnxt *bp, int queue_index) return rc; } +/* Initialise all rings to -1, its used to free rings later if allocation + * of few rings fails. + */ +static void bnxt_init_all_rings(struct bnxt *bp) +{ + unsigned int i = 0; + struct bnxt_rx_queue *rxq; + struct bnxt_ring *cp_ring; + struct bnxt_ring *ring; + struct bnxt_rx_ring_info *rxr; + struct bnxt_tx_queue *txq; + + for (i = 0; i < bp->rx_cp_nr_rings; i++) { + rxq = bp->rx_queues[i]; + /* Rx-compl */ + cp_ring = rxq->cp_ring->cp_ring_struct; + cp_ring->fw_ring_id = INVALID_HW_RING_ID; + /* Rx-Reg */ + rxr = rxq->rx_ring; + ring = rxr->rx_ring_struct; + ring->fw_ring_id = INVALID_HW_RING_ID; + /* Rx-AGG */ + ring = rxr->ag_ring_struct; + ring->fw_ring_id = INVALID_HW_RING_ID; + } + for (i = 0; i < bp->tx_cp_nr_rings; i++) { + txq = bp->tx_queues[i]; + /* Tx cmpl */ + cp_ring = txq->cp_ring->cp_ring_struct; + cp_ring->fw_ring_id = INVALID_HW_RING_ID; + /*Tx Ring */ + ring = txq->tx_ring->tx_ring_struct; + ring->fw_ring_id = INVALID_HW_RING_ID; + } +} + /* ring_grp usage: * [0] = default completion ring * [1 -> +rx_cp_nr_rings] = rx_cp, rx rings @@ -650,6 +686,7 @@ int bnxt_alloc_hwrm_rings(struct bnxt *bp) int rc = 0; bnxt_init_dflt_coal(&coal); + bnxt_init_all_rings(bp); for (i = 0; i < bp->rx_cp_nr_rings; i++) { struct bnxt_rx_queue *rxq = bp->rx_queues[i]; -- 2.20.1 (Apple Git-117)