bnxt_en: Refactor TX ring free logic
authorMichael Chan <michael.chan@broadcom.com>
Thu, 13 Feb 2025 01:12:37 +0000 (17:12 -0800)
committerJakub Kicinski <kuba@kernel.org>
Sat, 15 Feb 2025 03:50:23 +0000 (19:50 -0800)
Add a new bnxt_hwrm_tx_ring_free() function to handle freeing a HW
transmit ring.  The new function will also be used in the next patch
to free the TX ring in queue_stop.

Reviewed-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
Signed-off-by: Michael Chan <michael.chan@broadcom.com>
Link: https://patch.msgid.link/20250213011240.1640031-10-michael.chan@broadcom.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/broadcom/bnxt/bnxt.c

index 04980718c2871048921885949d9a41c87090647b..2d0d9ac8e2c44214443d060a16471e746a1bad01 100644 (file)
@@ -7368,6 +7368,23 @@ exit:
        return 0;
 }
 
+static void bnxt_hwrm_tx_ring_free(struct bnxt *bp,
+                                  struct bnxt_tx_ring_info *txr,
+                                  bool close_path)
+{
+       struct bnxt_ring_struct *ring = &txr->tx_ring_struct;
+       u32 cmpl_ring_id;
+
+       if (ring->fw_ring_id == INVALID_HW_RING_ID)
+               return;
+
+       cmpl_ring_id = close_path ? bnxt_cp_ring_for_tx(bp, txr) :
+                      INVALID_HW_RING_ID;
+       hwrm_ring_free_send_msg(bp, ring, RING_FREE_REQ_RING_TYPE_TX,
+                               cmpl_ring_id);
+       ring->fw_ring_id = INVALID_HW_RING_ID;
+}
+
 static void bnxt_hwrm_rx_ring_free(struct bnxt *bp,
                                   struct bnxt_rx_ring_info *rxr,
                                   bool close_path)
@@ -7447,20 +7464,8 @@ static void bnxt_hwrm_ring_free(struct bnxt *bp, bool close_path)
        if (!bp->bnapi)
                return;
 
-       for (i = 0; i < bp->tx_nr_rings; i++) {
-               struct bnxt_tx_ring_info *txr = &bp->tx_ring[i];
-               struct bnxt_ring_struct *ring = &txr->tx_ring_struct;
-
-               if (ring->fw_ring_id != INVALID_HW_RING_ID) {
-                       u32 cmpl_ring_id = bnxt_cp_ring_for_tx(bp, txr);
-
-                       hwrm_ring_free_send_msg(bp, ring,
-                                               RING_FREE_REQ_RING_TYPE_TX,
-                                               close_path ? cmpl_ring_id :
-                                               INVALID_HW_RING_ID);
-                       ring->fw_ring_id = INVALID_HW_RING_ID;
-               }
-       }
+       for (i = 0; i < bp->tx_nr_rings; i++)
+               bnxt_hwrm_tx_ring_free(bp, &bp->tx_ring[i], close_path);
 
        bnxt_cancel_dim(bp);
        for (i = 0; i < bp->rx_nr_rings; i++) {