Skip to contentSkip to conversation

net: bcmgenet: convert RX path to page_pool

PATCH Applied Nicolai Buchwitz 3 participants 3 messages Jun 10 – Jun 11

Subsystems (4)
lore
Share & tools
lore

Nicolai Buchwitz

author maintainer
#0 lore raw

PATCH v2 1/1 net: bcmgenet: convert RX path to page_pool

Replace the per-packet __netdev_alloc_skb() + dma_map_single() in the RX path with page_pool. SKBs are built from pool pages via napi_build_skb() with skb_mark_for_recycle() so the network stack returns pages to the pool, and DMA mapping happens once per page instead of once per packet.

Reject HW-reported lengths smaller than the RSB so a runt cannot underflow the SKB build path.

Drop the now-unused priv->rx_buf_len field and the rx_dma_failed soft MIB counter (nothing increments it after the conversion). This removes the "rx_dma_failed" entry from ethtool -S, which is a user-visible change for monitoring tools that key on stat names.

---
Changes since v1 (all from Simon Horman / sashiko's review):
- Tighten the runt length check to len < GENET_RSB_PAD.
- Drop the unused rx_page_offset field from struct enet_cb (it was an artifact from the XDP series, where it will hold XDP_PACKET_HEADROOM).
- Mention the rx_dma_failed removal in the commit message as a user-visible ethtool -S change.

v1: https://lore.kernel.org/netdev/[email protected]/

This is the page_pool conversion patch from my bcmgenet XDP series [1], pulled out as a standalone submission. The XDP series has had several review rounds, and page_pool is the part that has taken the most discussion. Getting it in on its own should hopefully make the rest of the XDP work easier to review later, and it is also the API new RX paths are expected to use anyway.

Tested on a Raspberry Pi CM4 (BCM2711, 1 Gbps). Ran the benchmarks at the default 1.5 GHz and again with the CPU pinned to 600 MHz to push the RX path harder. No regressions either way.

[1] https://lore.kernel.org/netdev/[email protected]/

 drivers/net/ethernet/broadcom/Kconfig         |   1 +
 .../net/ethernet/broadcom/genet/bcmgenet.c    | 220 +++++++++++-------
 .../net/ethernet/broadcom/genet/bcmgenet.h    |   5 +-
 3 files changed, 141 insertions(+), 85 deletions(-)
drivers/net/ethernet/broadcom/Kconfig +1 -0
index 4287edc7ddd6..f0bac0dd1439 100644
@@ -78,6 +78,7 @@ config BCMGENET
 	select BCM7XXX_PHY
 	select MDIO_BCM_UNIMAC
 	select DIMLIB
+	select PAGE_POOL
 	select BROADCOM_PHY if ARCH_BCM2835
 	help
 	  This driver supports the built-in Ethernet MACs found in the
drivers/net/ethernet/broadcom/genet/bcmgenet.c +137 -83

367 lines not on this page · raw message

drivers/net/ethernet/broadcom/genet/bcmgenet.h +3 -2
index 9e4110c7fdf6..22a958ba9902 100644
@@ -15,6 +15,7 @@
 #include <linux/phy.h>
 #include <linux/dim.h>
 #include <linux/ethtool.h>
+#include <net/page_pool/helpers.h>
 
 #include "../unimac.h"
 
@@ -149,7 +150,6 @@ struct bcmgenet_mib_counters {
 	u32	rbuf_err_cnt;
 	u32	mdf_err_cnt;
 	u32	alloc_rx_buff_failed;
-	u32	rx_dma_failed;
 	u32	tx_dma_failed;
 	u32	tx_realloc_tsb;
 	u32	tx_realloc_tsb_failed;
@@ -469,6 +469,7 @@ struct bcmgenet_rx_stats64 {
 
 struct enet_cb {
 	struct sk_buff      *skb;
+	struct page         *rx_page;
 	void __iomem *bd_addr;
 	DEFINE_DMA_UNMAP_ADDR(dma_addr);
 	DEFINE_DMA_UNMAP_LEN(dma_len);
@@ -575,6 +576,7 @@ struct bcmgenet_rx_ring {
 	struct bcmgenet_net_dim dim;
 	u32		rx_max_coalesced_frames;
 	u32		rx_coalesce_usecs;
+	struct page_pool *page_pool;
 	struct bcmgenet_priv *priv;
 };
 
@@ -609,7 +611,6 @@ struct bcmgenet_priv {
 	void __iomem *rx_bds;
 	struct enet_cb *rx_cbs;
 	unsigned int num_rx_bds;
-	unsigned int rx_buf_len;
 	struct bcmgenet_rxnfc_rule rxnfc_rules[MAX_NUM_OF_FS_RULES];
 	struct list_head rxnfc_list;
 
Signature · 1 line
2.53.0
Reviewed-by Tested-by on v2 1/1
#1 lore raw
Quoted 9 lines · Nicolai Buchwitz

Replace the per-packet __netdev_alloc_skb() + dma_map_single() in the RX path with page_pool. SKBs are built from pool pages via napi_build_skb() with skb_mark_for_recycle() so the network stack returns pages to the pool, and DMA mapping happens once per page instead of once per packet.

Reject HW-reported lengths smaller than the RSB so a runt cannot underflow the SKB build path.

Quoted 6 lines

Drop the now-unused priv->rx_buf_len field and the rx_dma_failed soft MIB counter (nothing increments it after the conversion). This removes the "rx_dma_failed" entry from ethtool -S, which is a user-visible change for monitoring tools that key on stat names.

#2 lore raw
In reply to Nicolai Buchwitz
This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:

Hello:

This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:

Quoted 10 lines · On Wed, 10 Jun 2026 13:48:35 +0200 you wrote:

Replace the per-packet __netdev_alloc_skb() + dma_map_single() in the RX path with page_pool. SKBs are built from pool pages via napi_build_skb() with skb_mark_for_recycle() so the network stack returns pages to the pool, and DMA mapping happens once per page instead of once per packet.

Reject HW-reported lengths smaller than the RSB so a runt cannot underflow the SKB build path.

[...]

Here is the summary with links:
- [net-next,v2] net: bcmgenet: convert RX path to page_pool

    https://git.kernel.org/netdev/net-next/c/7bc054c2d4ed

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html