summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorRahul Gupta <rahul.gupta@broadcom.com>2019-10-02 16:25:52 -0700
committerFerruh Yigit <ferruh.yigit@intel.com>2019-10-08 12:14:31 +0200
commit4cfbb0da7c3d8abd8172727dcf8139c059c8dfd0 (patch)
treeb958e35295dfecaef80e3f921cdfb091cd1fb9e1 /drivers
parent40724480038911ecc3b1c7a2b5a57ecc3e793ffd (diff)
downloaddpdk-4cfbb0da7c3d8abd8172727dcf8139c059c8dfd0.zip
dpdk-4cfbb0da7c3d8abd8172727dcf8139c059c8dfd0.tar.gz
dpdk-4cfbb0da7c3d8abd8172727dcf8139c059c8dfd0.tar.xz
net/bnxt: handle ring cleanup in case of error
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 <rahul.gupta@broadcom.com> Signed-off-by: Ajit Khaparde <ajit.khaparde@broadcom.com> Reviewed-by: Venkat Duvvuru <venkatkumar.duvvuru@broadcom.com> Reviewed-by: Kalesh AP <kalesh-anakkur.purayil@broadcom.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/net/bnxt/bnxt_ring.c37
1 files changed, 37 insertions, 0 deletions
diff --git a/drivers/net/bnxt/bnxt_ring.c b/drivers/net/bnxt/bnxt_ring.c
index eeb4e91..e650906 100644
--- a/drivers/net/bnxt/bnxt_ring.c
+++ b/drivers/net/bnxt/bnxt_ring.c
@@ -583,6 +583,42 @@ err_out:
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];