Skip to content

Commit 0fed290

Browse files
Michael Chankuba-moo
authored andcommitted
bnxt_en: Refactor completion ring allocation logic for P5_PLUS chips
Add a new bnxt_hwrm_cp_ring_alloc_p5() function to handle allocating one completion ring on P5_PLUS chips. This simplifies the existing code and will be useful later in the series. Reviewed-by: Ajit Khaparde <[email protected]> Reviewed-by: Michal Swiatkowski <[email protected]> Signed-off-by: Michael Chan <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent ebdf7fe commit 0fed290

File tree

1 file changed

+21
-23
lines changed
  • drivers/net/ethernet/broadcom/bnxt

1 file changed

+21
-23
lines changed

drivers/net/ethernet/broadcom/bnxt/bnxt.c

Lines changed: 21 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -7199,6 +7199,25 @@ static int bnxt_hwrm_rx_agg_ring_alloc(struct bnxt *bp,
71997199
return 0;
72007200
}
72017201

7202+
static int bnxt_hwrm_cp_ring_alloc_p5(struct bnxt *bp,
7203+
struct bnxt_cp_ring_info *cpr)
7204+
{
7205+
const u32 type = HWRM_RING_ALLOC_CMPL;
7206+
struct bnxt_napi *bnapi = cpr->bnapi;
7207+
struct bnxt_ring_struct *ring;
7208+
u32 map_idx = bnapi->index;
7209+
int rc;
7210+
7211+
ring = &cpr->cp_ring_struct;
7212+
ring->handle = BNXT_SET_NQ_HDL(cpr);
7213+
rc = hwrm_ring_alloc_send_msg(bp, ring, type, map_idx);
7214+
if (rc)
7215+
return rc;
7216+
bnxt_set_db(bp, &cpr->cp_db, type, map_idx, ring->fw_ring_id);
7217+
bnxt_db_cq(bp, &cpr->cp_db, cpr->cp_raw_cons);
7218+
return 0;
7219+
}
7220+
72027221
static int bnxt_hwrm_ring_alloc(struct bnxt *bp)
72037222
{
72047223
bool agg_rings = !!(bp->flags & BNXT_FLAG_AGG_RINGS);
@@ -7242,19 +7261,9 @@ static int bnxt_hwrm_ring_alloc(struct bnxt *bp)
72427261
u32 map_idx;
72437262

72447263
if (bp->flags & BNXT_FLAG_CHIP_P5_PLUS) {
7245-
struct bnxt_cp_ring_info *cpr2 = txr->tx_cpr;
7246-
struct bnxt_napi *bnapi = txr->bnapi;
7247-
u32 type2 = HWRM_RING_ALLOC_CMPL;
7248-
7249-
ring = &cpr2->cp_ring_struct;
7250-
ring->handle = BNXT_SET_NQ_HDL(cpr2);
7251-
map_idx = bnapi->index;
7252-
rc = hwrm_ring_alloc_send_msg(bp, ring, type2, map_idx);
7264+
rc = bnxt_hwrm_cp_ring_alloc_p5(bp, txr->tx_cpr);
72537265
if (rc)
72547266
goto err_out;
7255-
bnxt_set_db(bp, &cpr2->cp_db, type2, map_idx,
7256-
ring->fw_ring_id);
7257-
bnxt_db_cq(bp, &cpr2->cp_db, cpr2->cp_raw_cons);
72587267
}
72597268
ring = &txr->tx_ring_struct;
72607269
map_idx = i;
@@ -7274,20 +7283,9 @@ static int bnxt_hwrm_ring_alloc(struct bnxt *bp)
72747283
if (!agg_rings)
72757284
bnxt_db_write(bp, &rxr->rx_db, rxr->rx_prod);
72767285
if (bp->flags & BNXT_FLAG_CHIP_P5_PLUS) {
7277-
struct bnxt_cp_ring_info *cpr2 = rxr->rx_cpr;
7278-
struct bnxt_napi *bnapi = rxr->bnapi;
7279-
u32 type2 = HWRM_RING_ALLOC_CMPL;
7280-
struct bnxt_ring_struct *ring;
7281-
u32 map_idx = bnapi->index;
7282-
7283-
ring = &cpr2->cp_ring_struct;
7284-
ring->handle = BNXT_SET_NQ_HDL(cpr2);
7285-
rc = hwrm_ring_alloc_send_msg(bp, ring, type2, map_idx);
7286+
rc = bnxt_hwrm_cp_ring_alloc_p5(bp, rxr->rx_cpr);
72867287
if (rc)
72877288
goto err_out;
7288-
bnxt_set_db(bp, &cpr2->cp_db, type2, map_idx,
7289-
ring->fw_ring_id);
7290-
bnxt_db_cq(bp, &cpr2->cp_db, cpr2->cp_raw_cons);
72917289
}
72927290
}
72937291

0 commit comments

Comments
 (0)