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 57C93A2F18 for ; Thu, 3 Oct 2019 01:27:40 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 3D2111BFD1; Thu, 3 Oct 2019 01:26:32 +0200 (CEST) Received: from rnd-relay.smtp.broadcom.com (unknown [192.19.229.170]) by dpdk.org (Postfix) with ESMTP id 841EC1BF8F for ; Thu, 3 Oct 2019 01:26:10 +0200 (CEST) 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 BF2FD30C251; Wed, 2 Oct 2019 16:24:56 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.10.3 rnd-relay.smtp.broadcom.com BF2FD30C251 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=broadcom.com; s=dkimrelay; t=1570058696; bh=Z3XzofpLTHmrGIOhzvysdqrj5s4DqHrK32ssmSmwlaE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=g+B7tKM/padChNOrExax66y+lQ72ZJ6p/WDdDTmSHrOA/uCokKrQFLS/JDqfZJJQy zgXxZKPZTW4ih0rqq/VnDZWT4HMOMNW5rQjn60cfaBzkqYw7q9yFn4IaQ2KZfU9175 BOzHfgCo6JZ9cSXoi41J3lKYJO9x9mIBFRX7iCi4= Received: from localhost.localdomain (unknown [10.230.30.225]) by mail-irv-17.broadcom.com (Postfix) with ESMTP id C45B914008B; Wed, 2 Oct 2019 16:26:08 -0700 (PDT) From: Ajit Khaparde To: dev@dpdk.org Cc: ferruh.yigit@intel.com, Rahul Gupta , Venkat Duvvuru , Kalesh Anakkur Purayil Date: Wed, 2 Oct 2019 16:25:52 -0700 Message-Id: <20191002232601.22715-12-ajit.khaparde@broadcom.com> X-Mailer: git-send-email 2.20.1 (Apple Git-117) In-Reply-To: <20191002232601.22715-1-ajit.khaparde@broadcom.com> References: <20191002232601.22715-1-ajit.khaparde@broadcom.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH v2 11/20] 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 68a690de5a..a3e5a68714 100644 --- a/drivers/net/bnxt/bnxt_ring.c +++ b/drivers/net/bnxt/bnxt_ring.c @@ -583,6 +583,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 @@ -596,6 +632,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)