* [PATCH net-next] net: bgmac: use the NAPI skb cache
@ 2026-10-10 7:06 Rosen Penev
0 siblings, 0 replies; only message in thread
From: Rosen Penev @ 2026-10-10 7:06 UTC (permalink / raw)
To: netdev
Cc: Rafał Miłecki, Broadcom internal kernel review list,
Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, open list
Allocate RX skb heads with napi_build_skb() and free completed TX skbs
with napi_consume_skb(). Both run from the NAPI poll, so the heads are
recycled through the per-CPU NAPI cache and freed in bulk instead of
going through the slab allocator for every packet. The recycled heads
are usually still in the cache, which matters on the small cores bgmac
is found on.
On an Asus RT-N16 (BCM4716, 74Kc at 480 MHz, single TCP stream unless
noted, iperf3 median of 3, A/B in the same boot, two rounds each):
before after (Mbit/s)
local rx / tx 242 / 210 251 / 213
routed down 154 156
routed, 4 streams 69 / 83 71 / 85
Routed upload and software flow offload were unchanged within noise.
Assisted-by: LLM
Signed-off-by: Rosen Penev <rosenp@gmail.com>
---
drivers/net/ethernet/broadcom/bgmac.c | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/drivers/net/ethernet/broadcom/bgmac.c b/drivers/net/ethernet/broadcom/bgmac.c
index f40fde1d6bce..df2f0a87cbfd 100644
--- a/drivers/net/ethernet/broadcom/bgmac.c
+++ b/drivers/net/ethernet/broadcom/bgmac.c
@@ -229,7 +229,8 @@ static netdev_tx_t bgmac_dma_tx_add(struct bgmac *bgmac,
}
/* Free transmitted packets */
-static void bgmac_dma_tx_free(struct bgmac *bgmac, struct bgmac_dma_ring *ring)
+static void bgmac_dma_tx_free(struct bgmac *bgmac, struct bgmac_dma_ring *ring,
+ int budget)
{
struct device *dma_dev = bgmac->dma_dev;
int empty_slot;
@@ -269,7 +270,7 @@ static void bgmac_dma_tx_free(struct bgmac *bgmac, struct bgmac_dma_ring *ring)
pkts_compl++;
/* Free memory! :) */
- dev_kfree_skb(slot->skb);
+ napi_consume_skb(slot->skb, budget);
slot->skb = NULL;
}
@@ -465,9 +466,9 @@ static int bgmac_dma_rx_read(struct bgmac *bgmac, struct bgmac_dma_ring *ring,
/* Omit CRC. */
len -= ETH_FCS_LEN;
- skb = build_skb(buf, BGMAC_RX_ALLOC_SIZE);
+ skb = napi_build_skb(buf, BGMAC_RX_ALLOC_SIZE);
if (unlikely(!skb)) {
- netdev_err(bgmac->net_dev, "build_skb failed\n");
+ netdev_err(bgmac->net_dev, "napi_build_skb failed\n");
put_page(virt_to_head_page(buf));
bgmac->net_dev->stats.rx_errors++;
break;
@@ -1157,7 +1158,7 @@ static int bgmac_poll(struct napi_struct *napi, int weight)
/* Ack */
bgmac_write(bgmac, BGMAC_INT_STATUS, ~0);
- bgmac_dma_tx_free(bgmac, &bgmac->tx_ring[0]);
+ bgmac_dma_tx_free(bgmac, &bgmac->tx_ring[0], weight);
handled += bgmac_dma_rx_read(bgmac, &bgmac->rx_ring[0], weight);
/* Poll again if more events arrived in the meantime */
--
2.56.0
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2026-10-10 7:06 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-10 7:06 [PATCH net-next] net: bgmac: use the NAPI skb cache Rosen Penev
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®