Skip to content

Commit 0589a1e

Browse files
Michael Chandavem330
authored andcommitted
bnxt_en: Support up to 8 TX rings per MSIX
For each mqprio TC, we allocate a set of TX rings to map to the new hardware CoS queue. Expand the tx_ring pointer in struct bnxt_napi to an array of 8 to support up to 8 TX rings, one for each TC. Only array entry 0 is used at this time. The rest of the array entries will be used in later patches. 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 877edb3 commit 0589a1e

File tree

3 files changed

+55
-39
lines changed

3 files changed

+55
-39
lines changed

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

Lines changed: 44 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -758,9 +758,13 @@ static void __bnxt_tx_int(struct bnxt *bp, struct bnxt_tx_ring_info *txr,
758758

759759
static void bnxt_tx_int(struct bnxt *bp, struct bnxt_napi *bnapi, int budget)
760760
{
761-
struct bnxt_tx_ring_info *txr = bnapi->tx_ring;
761+
struct bnxt_tx_ring_info *txr;
762+
int i;
762763

763-
__bnxt_tx_int(bp, txr, budget);
764+
bnxt_for_each_napi_tx(i, bnapi, txr) {
765+
if (txr->tx_hw_cons != txr->tx_cons)
766+
__bnxt_tx_int(bp, txr, budget);
767+
}
764768
bnapi->events &= ~BNXT_TX_CMP_EVENT;
765769
}
766770

@@ -2596,15 +2600,13 @@ static int __bnxt_poll_work(struct bnxt *bp, struct bnxt_cp_ring_info *cpr,
25962600
{
25972601
struct bnxt_napi *bnapi = cpr->bnapi;
25982602
u32 raw_cons = cpr->cp_raw_cons;
2599-
struct bnxt_tx_ring_info *txr;
26002603
u32 cons;
26012604
int rx_pkts = 0;
26022605
u8 event = 0;
26032606
struct tx_cmp *txcmp;
26042607

26052608
cpr->has_more_work = 0;
26062609
cpr->had_work_done = 1;
2607-
txr = bnapi->tx_ring;
26082610
while (1) {
26092611
int rc;
26102612

@@ -2620,8 +2622,10 @@ static int __bnxt_poll_work(struct bnxt *bp, struct bnxt_cp_ring_info *cpr,
26202622
dma_rmb();
26212623
if (TX_CMP_TYPE(txcmp) == CMP_TYPE_TX_L2_CMP) {
26222624
u32 opaque = txcmp->tx_cmp_opaque;
2625+
struct bnxt_tx_ring_info *txr;
26232626
u16 tx_freed;
26242627

2628+
txr = bnapi->tx_ring[TX_OPAQUE_RING(opaque)];
26252629
event |= BNXT_TX_CMP_EVENT;
26262630
txr->tx_hw_cons = TX_OPAQUE_PROD(bp, opaque);
26272631
tx_freed = (txr->tx_hw_cons - txr->tx_cons) &
@@ -2671,7 +2675,7 @@ static int __bnxt_poll_work(struct bnxt *bp, struct bnxt_cp_ring_info *cpr,
26712675
xdp_do_flush();
26722676

26732677
if (event & BNXT_TX_EVENT) {
2674-
struct bnxt_tx_ring_info *txr = bnapi->tx_ring;
2678+
struct bnxt_tx_ring_info *txr = bnapi->tx_ring[0];
26752679
u16 prod = txr->tx_prod;
26762680

26772681
/* Sync BD data before updating doorbell */
@@ -3657,7 +3661,7 @@ static int bnxt_alloc_cp_rings(struct bnxt *bp)
36573661

36583662
static void bnxt_init_ring_struct(struct bnxt *bp)
36593663
{
3660-
int i;
3664+
int i, j;
36613665

36623666
for (i = 0; i < bp->cp_nr_rings; i++) {
36633667
struct bnxt_napi *bnapi = bp->bnapi[i];
@@ -3702,18 +3706,16 @@ static void bnxt_init_ring_struct(struct bnxt *bp)
37023706
rmem->vmem = (void **)&rxr->rx_agg_ring;
37033707

37043708
skip_rx:
3705-
txr = bnapi->tx_ring;
3706-
if (!txr)
3707-
continue;
3708-
3709-
ring = &txr->tx_ring_struct;
3710-
rmem = &ring->ring_mem;
3711-
rmem->nr_pages = bp->tx_nr_pages;
3712-
rmem->page_size = HW_RXBD_RING_SIZE;
3713-
rmem->pg_arr = (void **)txr->tx_desc_ring;
3714-
rmem->dma_arr = txr->tx_desc_mapping;
3715-
rmem->vmem_size = SW_TXBD_RING_SIZE * bp->tx_nr_pages;
3716-
rmem->vmem = (void **)&txr->tx_buf_ring;
3709+
bnxt_for_each_napi_tx(j, bnapi, txr) {
3710+
ring = &txr->tx_ring_struct;
3711+
rmem = &ring->ring_mem;
3712+
rmem->nr_pages = bp->tx_nr_pages;
3713+
rmem->page_size = HW_TXBD_RING_SIZE;
3714+
rmem->pg_arr = (void **)txr->tx_desc_ring;
3715+
rmem->dma_arr = txr->tx_desc_mapping;
3716+
rmem->vmem_size = SW_TXBD_RING_SIZE * bp->tx_nr_pages;
3717+
rmem->vmem = (void **)&txr->tx_buf_ring;
3718+
}
37173719
}
37183720
}
37193721

@@ -4512,7 +4514,7 @@ static int bnxt_alloc_stats(struct bnxt *bp)
45124514

45134515
static void bnxt_clear_ring_indices(struct bnxt *bp)
45144516
{
4515-
int i;
4517+
int i, j;
45164518

45174519
if (!bp->bnapi)
45184520
return;
@@ -4529,8 +4531,7 @@ static void bnxt_clear_ring_indices(struct bnxt *bp)
45294531
cpr = &bnapi->cp_ring;
45304532
cpr->cp_raw_cons = 0;
45314533

4532-
txr = bnapi->tx_ring;
4533-
if (txr) {
4534+
bnxt_for_each_napi_tx(j, bnapi, txr) {
45344535
txr->tx_prod = 0;
45354536
txr->tx_cons = 0;
45364537
txr->tx_hw_cons = 0;
@@ -4703,7 +4704,7 @@ static int bnxt_alloc_mem(struct bnxt *bp, bool irq_re_init)
47034704
else
47044705
txr->tx_cpr = &bp->bnapi[i]->cp_ring;
47054706
txr->bnapi = bp->bnapi[j];
4706-
bp->bnapi[j]->tx_ring = txr;
4707+
bp->bnapi[j]->tx_ring[0] = txr;
47074708
bp->tx_ring_map[i] = bp->tx_nr_rings_xdp + i;
47084709
if (i >= bp->tx_nr_rings_xdp) {
47094710
txr->txq_index = i - bp->tx_nr_rings_xdp;
@@ -6910,10 +6911,21 @@ static int
69106911
bnxt_hwrm_set_tx_coal(struct bnxt *bp, struct bnxt_napi *bnapi,
69116912
struct hwrm_ring_cmpl_ring_cfg_aggint_params_input *req)
69126913
{
6913-
u16 ring_id = bnxt_cp_ring_for_tx(bp, bnapi->tx_ring);
6914+
struct bnxt_tx_ring_info *txr;
6915+
int i, rc;
69146916

6915-
req->ring_id = cpu_to_le16(ring_id);
6916-
return hwrm_req_send(bp, req);
6917+
bnxt_for_each_napi_tx(i, bnapi, txr) {
6918+
u16 ring_id;
6919+
6920+
ring_id = bnxt_cp_ring_for_tx(bp, txr);
6921+
req->ring_id = cpu_to_le16(ring_id);
6922+
rc = hwrm_req_send(bp, req);
6923+
if (rc)
6924+
return rc;
6925+
if (!(bp->flags & BNXT_FLAG_CHIP_P5))
6926+
return 0;
6927+
}
6928+
return 0;
69176929
}
69186930

69196931
int bnxt_hwrm_set_coal(struct bnxt *bp)
@@ -6950,7 +6962,7 @@ int bnxt_hwrm_set_coal(struct bnxt *bp)
69506962
if (!(bp->flags & BNXT_FLAG_CHIP_P5))
69516963
continue;
69526964

6953-
if (bnapi->rx_ring && bnapi->tx_ring) {
6965+
if (bnapi->rx_ring && bnapi->tx_ring[0]) {
69546966
rc = bnxt_hwrm_set_tx_coal(bp, bnapi, req_tx);
69556967
if (rc)
69566968
break;
@@ -11575,15 +11587,13 @@ static int bnxt_dbg_hwrm_ring_info_get(struct bnxt *bp, u8 ring_type,
1157511587

1157611588
static void bnxt_dump_tx_sw_state(struct bnxt_napi *bnapi)
1157711589
{
11578-
struct bnxt_tx_ring_info *txr = bnapi->tx_ring;
11579-
int i = bnapi->index;
11580-
11581-
if (!txr)
11582-
return;
11590+
struct bnxt_tx_ring_info *txr;
11591+
int i = bnapi->index, j;
1158311592

11584-
netdev_info(bnapi->bp->dev, "[%d]: tx{fw_ring: %d prod: %x cons: %x}\n",
11585-
i, txr->tx_ring_struct.fw_ring_id, txr->tx_prod,
11586-
txr->tx_cons);
11593+
bnxt_for_each_napi_tx(j, bnapi, txr)
11594+
netdev_info(bnapi->bp->dev, "[%d.%d]: tx{fw_ring: %d prod: %x cons: %x}\n",
11595+
i, j, txr->tx_ring_struct.fw_ring_id, txr->tx_prod,
11596+
txr->tx_cons);
1158711597
}
1158811598

1158911599
static void bnxt_dump_rx_sw_state(struct bnxt_napi *bnapi)

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

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1046,14 +1046,22 @@ struct bnxt_cp_ring_info {
10461046
struct bnxt_cp_ring_info *cp_ring_arr;
10471047
};
10481048

1049+
#define BNXT_MAX_QUEUE 8
1050+
#define BNXT_MAX_TXR_PER_NAPI BNXT_MAX_QUEUE
1051+
1052+
#define bnxt_for_each_napi_tx(iter, bnapi, txr) \
1053+
for (iter = 0, txr = (bnapi)->tx_ring[0]; txr; \
1054+
txr = (iter < BNXT_MAX_TXR_PER_NAPI - 1) ? \
1055+
(bnapi)->tx_ring[++iter] : NULL)
1056+
10491057
struct bnxt_napi {
10501058
struct napi_struct napi;
10511059
struct bnxt *bp;
10521060

10531061
int index;
10541062
struct bnxt_cp_ring_info cp_ring;
10551063
struct bnxt_rx_ring_info *rx_ring;
1056-
struct bnxt_tx_ring_info *tx_ring;
1064+
struct bnxt_tx_ring_info *tx_ring[BNXT_MAX_TXR_PER_NAPI];
10571065

10581066
void (*tx_int)(struct bnxt *, struct bnxt_napi *,
10591067
int budget);
@@ -1391,8 +1399,6 @@ struct bnxt_link_info {
13911399
(PORT_PHY_CFG_REQ_FLAGS_FEC_CLAUSE74_DISABLE | \
13921400
BNXT_FEC_RS_OFF(link_info))
13931401

1394-
#define BNXT_MAX_QUEUE 8
1395-
13961402
struct bnxt_queue_info {
13971403
u8 queue_id;
13981404
u8 queue_profile;

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ static void __bnxt_xmit_xdp_redirect(struct bnxt *bp,
127127

128128
void bnxt_tx_int_xdp(struct bnxt *bp, struct bnxt_napi *bnapi, int budget)
129129
{
130-
struct bnxt_tx_ring_info *txr = bnapi->tx_ring;
130+
struct bnxt_tx_ring_info *txr = bnapi->tx_ring[0];
131131
struct bnxt_rx_ring_info *rxr = bnapi->rx_ring;
132132
u16 tx_hw_cons = txr->tx_hw_cons;
133133
bool rx_doorbell_needed = false;
@@ -249,7 +249,7 @@ bool bnxt_rx_xdp(struct bnxt *bp, struct bnxt_rx_ring_info *rxr, u16 cons,
249249
pdev = bp->pdev;
250250
offset = bp->rx_offset;
251251

252-
txr = rxr->bnapi->tx_ring;
252+
txr = rxr->bnapi->tx_ring[0];
253253
/* BNXT_RX_PAGE_MODE(bp) when XDP enabled */
254254
orig_data = xdp.data;
255255

0 commit comments

Comments
 (0)