Skip to content

Commit bd649c5

Browse files
spikehkuba-moo
authored andcommitted
bnxt_en: handle tpa_info in queue API implementation
Commit 7ed816b ("eth: bnxt: use page pool for head frags") added a page pool for header frags, which may be distinct from the existing pool for the aggregation ring. Prior to this change, frags used in the TPA ring rx_tpa were allocated from system memory e.g. napi_alloc_frag() meaning their lifetimes were not associated with a page pool. They can be returned at any time and so the queue API did not alloc or free rx_tpa. But now frags come from a separate head_pool which may be different to page_pool. Without allocating and freeing rx_tpa, frags allocated from the old head_pool may be returned to a different new head_pool which causes a mismatch between the pp hold/release count. Fix this problem by properly freeing and allocating rx_tpa in the queue API implementation. Signed-off-by: David Wei <[email protected]> Reviewed-by: Michael Chan <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent bf1782d commit bd649c5

File tree

1 file changed

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

1 file changed

+23
-4
lines changed

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

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3710,7 +3710,7 @@ static void bnxt_free_rx_rings(struct bnxt *bp)
37103710
xdp_rxq_info_unreg(&rxr->xdp_rxq);
37113711

37123712
page_pool_destroy(rxr->page_pool);
3713-
if (rxr->page_pool != rxr->head_pool)
3713+
if (bnxt_separate_head_pool())
37143714
page_pool_destroy(rxr->head_pool);
37153715
rxr->page_pool = rxr->head_pool = NULL;
37163716

@@ -15388,25 +15388,37 @@ static int bnxt_queue_mem_alloc(struct net_device *dev, void *qmem, int idx)
1538815388
goto err_free_rx_agg_ring;
1538915389
}
1539015390

15391+
if (bp->flags & BNXT_FLAG_TPA) {
15392+
rc = bnxt_alloc_one_tpa_info(bp, clone);
15393+
if (rc)
15394+
goto err_free_tpa_info;
15395+
}
15396+
1539115397
bnxt_init_one_rx_ring_rxbd(bp, clone);
1539215398
bnxt_init_one_rx_agg_ring_rxbd(bp, clone);
1539315399

1539415400
bnxt_alloc_one_rx_ring_skb(bp, clone, idx);
1539515401
if (bp->flags & BNXT_FLAG_AGG_RINGS)
1539615402
bnxt_alloc_one_rx_ring_page(bp, clone, idx);
15403+
if (bp->flags & BNXT_FLAG_TPA)
15404+
bnxt_alloc_one_tpa_info_data(bp, clone);
1539715405

1539815406
return 0;
1539915407

15408+
err_free_tpa_info:
15409+
bnxt_free_one_tpa_info(bp, clone);
1540015410
err_free_rx_agg_ring:
1540115411
bnxt_free_ring(bp, &clone->rx_agg_ring_struct.ring_mem);
1540215412
err_free_rx_ring:
1540315413
bnxt_free_ring(bp, &clone->rx_ring_struct.ring_mem);
1540415414
err_rxq_info_unreg:
1540515415
xdp_rxq_info_unreg(&clone->xdp_rxq);
1540615416
err_page_pool_destroy:
15407-
clone->page_pool->p.napi = NULL;
1540815417
page_pool_destroy(clone->page_pool);
15418+
if (bnxt_separate_head_pool())
15419+
page_pool_destroy(clone->head_pool);
1540915420
clone->page_pool = NULL;
15421+
clone->head_pool = NULL;
1541015422
return rc;
1541115423
}
1541215424

@@ -15416,13 +15428,15 @@ static void bnxt_queue_mem_free(struct net_device *dev, void *qmem)
1541615428
struct bnxt *bp = netdev_priv(dev);
1541715429
struct bnxt_ring_struct *ring;
1541815430

15419-
bnxt_free_one_rx_ring(bp, rxr);
15420-
bnxt_free_one_rx_agg_ring(bp, rxr);
15431+
bnxt_free_one_rx_ring_skbs(bp, rxr);
1542115432

1542215433
xdp_rxq_info_unreg(&rxr->xdp_rxq);
1542315434

1542415435
page_pool_destroy(rxr->page_pool);
15436+
if (bnxt_separate_head_pool())
15437+
page_pool_destroy(rxr->head_pool);
1542515438
rxr->page_pool = NULL;
15439+
rxr->head_pool = NULL;
1542615440

1542715441
ring = &rxr->rx_ring_struct;
1542815442
bnxt_free_ring(bp, &ring->ring_mem);
@@ -15504,7 +15518,10 @@ static int bnxt_queue_start(struct net_device *dev, void *qmem, int idx)
1550415518
rxr->rx_agg_prod = clone->rx_agg_prod;
1550515519
rxr->rx_sw_agg_prod = clone->rx_sw_agg_prod;
1550615520
rxr->rx_next_cons = clone->rx_next_cons;
15521+
rxr->rx_tpa = clone->rx_tpa;
15522+
rxr->rx_tpa_idx_map = clone->rx_tpa_idx_map;
1550715523
rxr->page_pool = clone->page_pool;
15524+
rxr->head_pool = clone->head_pool;
1550815525
rxr->xdp_rxq = clone->xdp_rxq;
1550915526

1551015527
bnxt_copy_rx_ring(bp, rxr, clone);
@@ -15563,6 +15580,8 @@ static int bnxt_queue_stop(struct net_device *dev, void *qmem, int idx)
1556315580
bnxt_hwrm_rx_agg_ring_free(bp, rxr, false);
1556415581
rxr->rx_next_cons = 0;
1556515582
page_pool_disable_direct_recycling(rxr->page_pool);
15583+
if (bnxt_separate_head_pool())
15584+
page_pool_disable_direct_recycling(rxr->head_pool);
1556615585

1556715586
memcpy(qmem, rxr, sizeof(*rxr));
1556815587
bnxt_init_rx_ring_struct(bp, qmem);

0 commit comments

Comments
 (0)