Skip to content

Commit

Permalink
bnxt_en: Refactor TX ring free logic
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Michael Chan authored and Jakub Kicinski committed Feb 15, 2025
1 parent 6b6bf60 commit c8a0f76
Showing 1 changed file with 19 additions and 14 deletions.
33 changes: 19 additions & 14 deletions drivers/net/ethernet/broadcom/bnxt/bnxt.c
Original file line number Diff line number Diff line change
Expand Up @@ -7368,6 +7368,23 @@ static int hwrm_ring_free_send_msg(struct bnxt *bp,
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)
Expand Down Expand Up @@ -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++) {
Expand Down

0 comments on commit c8a0f76

Please sign in to comment.