Skip to content

Commit 2324c78

Browse files
Furong XuPaolo Abeni
authored andcommitted
net: stmmac: Set page_pool_params.max_len to a precise size
DMA engine will always write no more than dma_buf_sz bytes of a received frame into a page buffer, the remaining spaces are unused or used by CPU exclusively. Setting page_pool_params.max_len to almost the full size of page(s) helps nothing more, but wastes more CPU cycles on cache maintenance. For a standard MTU of 1500, then dma_buf_sz is assigned to 1536, and this patch brings ~16.9% driver performance improvement in a TCP RX throughput test with iPerf tool on a single isolated Cortex-A65 CPU core, from 2.43 Gbits/sec increased to 2.84 Gbits/sec. Signed-off-by: Furong Xu <0x1207@gmail.com> Reviewed-by: Alexander Lobakin <aleksander.lobakin@intel.com> Reviewed-by: Yanteng Si <si.yanteng@linux.dev> Signed-off-by: Paolo Abeni <pabeni@redhat.com>
1 parent df542f6 commit 2324c78

File tree

2 files changed

+1
-2
lines changed

2 files changed

+1
-2
lines changed

drivers/net/ethernet/stmicro/stmmac/stmmac_main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2059,7 +2059,7 @@ static int __alloc_dma_rx_desc_resources(struct stmmac_priv *priv,
20592059
pp_params.dev = priv->device;
20602060
pp_params.dma_dir = xdp_prog ? DMA_BIDIRECTIONAL : DMA_FROM_DEVICE;
20612061
pp_params.offset = stmmac_rx_offset(priv);
2062-
pp_params.max_len = STMMAC_MAX_RX_BUF_SIZE(num_pages);
2062+
pp_params.max_len = dma_conf->dma_buf_sz;
20632063

20642064
rx_q->page_pool = page_pool_create(&pp_params);
20652065
if (IS_ERR(rx_q->page_pool)) {

drivers/net/ethernet/stmicro/stmmac/stmmac_xdp.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
#ifndef _STMMAC_XDP_H_
55
#define _STMMAC_XDP_H_
66

7-
#define STMMAC_MAX_RX_BUF_SIZE(num) (((num) * PAGE_SIZE) - XDP_PACKET_HEADROOM)
87
#define STMMAC_RX_DMA_ATTR (DMA_ATTR_SKIP_CPU_SYNC | DMA_ATTR_WEAK_ORDERING)
98

109
int stmmac_xdp_setup_pool(struct stmmac_priv *priv, struct xsk_buff_pool *pool,

0 commit comments

Comments
 (0)