Skip to content

Commit 7845b8d

Browse files
Michael Chandavem330
authored andcommitted
bnxt_en: Add completion ring pointer in TX and RX ring structures
From the TX or RX ring structure, we need to find the corresponding completion ring during initialization. On P5 chips, we use the MSIX/napi entry to locate the completion ring because there is only one RX/TX ring per MSIX. To allow multiple TX rings for each MSIX, we need to add a direct pointer from the TX ring and RX ring structures. This also simplifies the existing logic. Reviewed-by: Andy Gospodarek <andrew.gospodarek@broadcom.com> Signed-off-by: Michael Chan <michael.chan@broadcom.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent d1eec61 commit 7845b8d

File tree

3 files changed

+19
-25
lines changed

3 files changed

+19
-25
lines changed

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

Lines changed: 16 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -3584,11 +3584,11 @@ static int bnxt_alloc_cp_sub_ring(struct bnxt *bp,
35843584
static int bnxt_alloc_cp_rings(struct bnxt *bp)
35853585
{
35863586
bool sh = !!(bp->flags & BNXT_FLAG_SHARED_RINGS);
3587-
int i, rc, ulp_base_vec, ulp_msix;
3587+
int i, j, rc, ulp_base_vec, ulp_msix;
35883588

35893589
ulp_msix = bnxt_get_ulp_msix_num(bp);
35903590
ulp_base_vec = bnxt_get_ulp_msix_base(bp);
3591-
for (i = 0; i < bp->cp_nr_rings; i++) {
3591+
for (i = 0, j = 0; i < bp->cp_nr_rings; i++) {
35923592
struct bnxt_napi *bnapi = bp->bnapi[i];
35933593
struct bnxt_cp_ring_info *cpr, *cpr2;
35943594
struct bnxt_ring_struct *ring;
@@ -3626,6 +3626,7 @@ static int bnxt_alloc_cp_rings(struct bnxt *bp)
36263626
if (rc)
36273627
return rc;
36283628
cpr2->bnapi = bnapi;
3629+
bp->rx_ring[i].rx_cpr = cpr2;
36293630
}
36303631
if ((sh && i < bp->tx_nr_rings) ||
36313632
(!sh && i >= bp->rx_nr_rings)) {
@@ -3634,6 +3635,7 @@ static int bnxt_alloc_cp_rings(struct bnxt *bp)
36343635
if (rc)
36353636
return rc;
36363637
cpr2->bnapi = bnapi;
3638+
bp->tx_ring[j++].tx_cpr = cpr2;
36373639
}
36383640
}
36393641
return 0;
@@ -4654,6 +4656,8 @@ static int bnxt_alloc_mem(struct bnxt *bp, bool irq_re_init)
46544656
BNXT_RMEM_RING_PTE_FLAG;
46554657
rxr->rx_agg_ring_struct.ring_mem.flags =
46564658
BNXT_RMEM_RING_PTE_FLAG;
4659+
} else {
4660+
rxr->rx_cpr = &bp->bnapi[i]->cp_ring;
46574661
}
46584662
rxr->bnapi = bp->bnapi[i];
46594663
bp->bnapi[i]->rx_ring = &bp->rx_ring[i];
@@ -4682,6 +4686,8 @@ static int bnxt_alloc_mem(struct bnxt *bp, bool irq_re_init)
46824686
if (bp->flags & BNXT_FLAG_CHIP_P5)
46834687
txr->tx_ring_struct.ring_mem.flags =
46844688
BNXT_RMEM_RING_PTE_FLAG;
4689+
else
4690+
txr->tx_cpr = &bp->bnapi[i]->cp_ring;
46854691
txr->bnapi = bp->bnapi[j];
46864692
bp->bnapi[j]->tx_ring = txr;
46874693
bp->tx_ring_map[i] = bp->tx_nr_rings_xdp + i;
@@ -5242,28 +5248,18 @@ static u16 bnxt_cp_ring_from_grp(struct bnxt *bp, struct bnxt_ring_struct *ring)
52425248

52435249
static u16 bnxt_cp_ring_for_rx(struct bnxt *bp, struct bnxt_rx_ring_info *rxr)
52445250
{
5245-
if (bp->flags & BNXT_FLAG_CHIP_P5) {
5246-
struct bnxt_napi *bnapi = rxr->bnapi;
5247-
struct bnxt_cp_ring_info *cpr;
5248-
5249-
cpr = &bnapi->cp_ring.cp_ring_arr[BNXT_RX_HDL];
5250-
return cpr->cp_ring_struct.fw_ring_id;
5251-
} else {
5251+
if (bp->flags & BNXT_FLAG_CHIP_P5)
5252+
return rxr->rx_cpr->cp_ring_struct.fw_ring_id;
5253+
else
52525254
return bnxt_cp_ring_from_grp(bp, &rxr->rx_ring_struct);
5253-
}
52545255
}
52555256

52565257
static u16 bnxt_cp_ring_for_tx(struct bnxt *bp, struct bnxt_tx_ring_info *txr)
52575258
{
5258-
if (bp->flags & BNXT_FLAG_CHIP_P5) {
5259-
struct bnxt_napi *bnapi = txr->bnapi;
5260-
struct bnxt_cp_ring_info *cpr;
5261-
5262-
cpr = &bnapi->cp_ring.cp_ring_arr[BNXT_TX_HDL];
5263-
return cpr->cp_ring_struct.fw_ring_id;
5264-
} else {
5259+
if (bp->flags & BNXT_FLAG_CHIP_P5)
5260+
return txr->tx_cpr->cp_ring_struct.fw_ring_id;
5261+
else
52655262
return bnxt_cp_ring_from_grp(bp, &txr->tx_ring_struct);
5266-
}
52675263
}
52685264

52695265
static int bnxt_alloc_rss_indir_tbl(struct bnxt *bp)
@@ -6022,12 +6018,10 @@ static int bnxt_hwrm_ring_alloc(struct bnxt *bp)
60226018
u32 map_idx;
60236019

60246020
if (bp->flags & BNXT_FLAG_CHIP_P5) {
6021+
struct bnxt_cp_ring_info *cpr2 = txr->tx_cpr;
60256022
struct bnxt_napi *bnapi = txr->bnapi;
6026-
struct bnxt_cp_ring_info *cpr, *cpr2;
60276023
u32 type2 = HWRM_RING_ALLOC_CMPL;
60286024

6029-
cpr = &bnapi->cp_ring;
6030-
cpr2 = &cpr->cp_ring_arr[BNXT_TX_HDL];
60316025
ring = &cpr2->cp_ring_struct;
60326026
ring->handle = BNXT_TX_HDL;
60336027
map_idx = bnapi->index;
@@ -6062,11 +6056,9 @@ static int bnxt_hwrm_ring_alloc(struct bnxt *bp)
60626056
bnxt_db_write(bp, &rxr->rx_db, rxr->rx_prod);
60636057
bp->grp_info[map_idx].rx_fw_ring_id = ring->fw_ring_id;
60646058
if (bp->flags & BNXT_FLAG_CHIP_P5) {
6065-
struct bnxt_cp_ring_info *cpr = &bnapi->cp_ring;
6059+
struct bnxt_cp_ring_info *cpr2 = rxr->rx_cpr;
60666060
u32 type2 = HWRM_RING_ALLOC_CMPL;
6067-
struct bnxt_cp_ring_info *cpr2;
60686061

6069-
cpr2 = &cpr->cp_ring_arr[BNXT_RX_HDL];
60706062
ring = &cpr2->cp_ring_struct;
60716063
ring->handle = BNXT_RX_HDL;
60726064
rc = hwrm_ring_alloc_send_msg(bp, ring, type2, map_idx);

drivers/net/ethernet/broadcom/bnxt/bnxt.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -806,6 +806,7 @@ struct bnxt_db_info {
806806

807807
struct bnxt_tx_ring_info {
808808
struct bnxt_napi *bnapi;
809+
struct bnxt_cp_ring_info *tx_cpr;
809810
u16 tx_prod;
810811
u16 tx_cons;
811812
u16 tx_hw_cons;
@@ -916,6 +917,7 @@ struct bnxt_tpa_idx_map {
916917

917918
struct bnxt_rx_ring_info {
918919
struct bnxt_napi *bnapi;
920+
struct bnxt_cp_ring_info *rx_cpr;
919921
u16 rx_prod;
920922
u16 rx_agg_prod;
921923
u16 rx_sw_agg_prod;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3941,7 +3941,7 @@ static int bnxt_run_loopback(struct bnxt *bp)
39413941

39423942
cpr = &rxr->bnapi->cp_ring;
39433943
if (bp->flags & BNXT_FLAG_CHIP_P5)
3944-
cpr = &cpr->cp_ring_arr[BNXT_RX_HDL];
3944+
cpr = rxr->rx_cpr;
39453945
pkt_size = min(bp->dev->mtu + ETH_HLEN, bp->rx_copy_thresh);
39463946
skb = netdev_alloc_skb(bp->dev, pkt_size);
39473947
if (!skb)

0 commit comments

Comments
 (0)