Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

bnxt: fill data page pool with frags if PAGE_SIZE > BNXT_RX_PAGE_SIZE

The data page pool always fills the HW rx ring with pages. On arm64 with
64K pages, this will waste _at least_ 32K of memory per entry in the rx
ring.

Fix by fragmenting the pages if PAGE_SIZE > BNXT_RX_PAGE_SIZE. This
makes the data page pool the same as the header pool.

Tested with iperf3 with a small (64 entries) rx ring to encourage buffer
circulation.

Fixes: cd1fafe7da1f ("eth: bnxt: add support rx side device memory TCP")
Reviewed-by: Michael Chan <michael.chan@broadcom.com>
Signed-off-by: David Wei <dw@davidwei.uk>
Link: https://patch.msgid.link/20250812182907.1540755-1-dw@davidwei.uk
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

David Wei and committed by
Jakub Kicinski
39f8fcda b2cafefa

+9 -3
+9 -3
drivers/net/ethernet/broadcom/bnxt/bnxt.c
··· 926 926 927 927 static netmem_ref __bnxt_alloc_rx_netmem(struct bnxt *bp, dma_addr_t *mapping, 928 928 struct bnxt_rx_ring_info *rxr, 929 + unsigned int *offset, 929 930 gfp_t gfp) 930 931 { 931 932 netmem_ref netmem; 932 933 933 - netmem = page_pool_alloc_netmems(rxr->page_pool, gfp); 934 + if (PAGE_SIZE > BNXT_RX_PAGE_SIZE) { 935 + netmem = page_pool_alloc_frag_netmem(rxr->page_pool, offset, BNXT_RX_PAGE_SIZE, gfp); 936 + } else { 937 + netmem = page_pool_alloc_netmems(rxr->page_pool, gfp); 938 + *offset = 0; 939 + } 934 940 if (!netmem) 935 941 return 0; 936 942 937 - *mapping = page_pool_get_dma_addr_netmem(netmem); 943 + *mapping = page_pool_get_dma_addr_netmem(netmem) + *offset; 938 944 return netmem; 939 945 } 940 946 ··· 1035 1029 dma_addr_t mapping; 1036 1030 netmem_ref netmem; 1037 1031 1038 - netmem = __bnxt_alloc_rx_netmem(bp, &mapping, rxr, gfp); 1032 + netmem = __bnxt_alloc_rx_netmem(bp, &mapping, rxr, &offset, gfp); 1039 1033 if (!netmem) 1040 1034 return -ENOMEM; 1041 1035