* [PATCH net-next] net: ps3_gelic_net: Use napi_alloc_skb() and napi_gro_receive()
@ 2025-11-30 19:41 Florian Fuchs
2025-12-01 10:14 ` Simon Horman
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Florian Fuchs @ 2025-11-30 19:41 UTC (permalink / raw)
To: Geoff Levand, netdev, Jakub Kicinski
Cc: Andrew Lunn, David S . Miller, Eric Dumazet, Paolo Abeni,
Madhavan Srinivasan, Michael Ellerman, Nicholas Piggin,
Christophe Leroy, linuxppc-dev, linux-kernel, fuchsfl
Use the napi functions napi_alloc_skb() and napi_gro_receive() instead
of netdev_alloc_skb() and netif_receive_skb() for more efficient packet
receiving. The switch to napi aware functions increases the RX
throughput, reduces the occurrence of retransmissions and improves the
resilience against SKB allocation failures.
Signed-off-by: Florian Fuchs <fuchsfl@gmail.com>
---
Note: This change has been tested on real hardware Sony PS3 (CECHL04 PAL),
the patch was tested for many hours, with continuous system load, high
network transfer load and injected failslab errors.
In my tests, the RX throughput increased up to 100% and reduced the
occurrence of retransmissions drastically, with GRO enabled:
iperf3 before and after the commit, where PS3 (with this driver) is on
the receiving side:
Before: [ 5] 0.00-10.00 sec 551 MBytes 462 Mbits/sec receiver
After: [ 5] 0.00-10.00 sec 1.09 GBytes 939 Mbits/sec receiver
stats from the sending client to the PS3:
Before: [ 5] 0.00-10.00 sec 552 MBytes 463 Mbits/sec 3151 sender
After: [ 5] 0.00-10.00 sec 1.09 GBytes 940 Mbits/sec 37 sender
drivers/net/ethernet/toshiba/ps3_gelic_net.c | 15 ++++++++++-----
1 file changed, 10 insertions(+), 5 deletions(-)
diff --git a/drivers/net/ethernet/toshiba/ps3_gelic_net.c b/drivers/net/ethernet/toshiba/ps3_gelic_net.c
index 591866fc9055..d35d1f3c10a1 100644
--- a/drivers/net/ethernet/toshiba/ps3_gelic_net.c
+++ b/drivers/net/ethernet/toshiba/ps3_gelic_net.c
@@ -364,6 +364,7 @@ static int gelic_card_init_chain(struct gelic_card *card,
* gelic_descr_prepare_rx - reinitializes a rx descriptor
* @card: card structure
* @descr: descriptor to re-init
+ * @napi_mode: is it running in napi poll
*
* return 0 on success, <0 on failure
*
@@ -374,7 +375,8 @@ static int gelic_card_init_chain(struct gelic_card *card,
* must be a multiple of GELIC_NET_RXBUF_ALIGN.
*/
static int gelic_descr_prepare_rx(struct gelic_card *card,
- struct gelic_descr *descr)
+ struct gelic_descr *descr,
+ bool napi_mode)
{
static const unsigned int rx_skb_size =
ALIGN(GELIC_NET_MAX_FRAME, GELIC_NET_RXBUF_ALIGN) +
@@ -392,7 +394,10 @@ static int gelic_descr_prepare_rx(struct gelic_card *card,
descr->hw_regs.payload.dev_addr = 0;
descr->hw_regs.payload.size = 0;
- descr->skb = netdev_alloc_skb(*card->netdev, rx_skb_size);
+ if (napi_mode)
+ descr->skb = napi_alloc_skb(&card->napi, rx_skb_size);
+ else
+ descr->skb = netdev_alloc_skb(*card->netdev, rx_skb_size);
if (!descr->skb) {
descr->hw_regs.payload.dev_addr = 0; /* tell DMAC don't touch memory */
return -ENOMEM;
@@ -464,7 +469,7 @@ static int gelic_card_fill_rx_chain(struct gelic_card *card)
do {
if (!descr->skb) {
- ret = gelic_descr_prepare_rx(card, descr);
+ ret = gelic_descr_prepare_rx(card, descr, false);
if (ret)
goto rewind;
}
@@ -964,7 +969,7 @@ static void gelic_net_pass_skb_up(struct gelic_descr *descr,
netdev->stats.rx_bytes += skb->len;
/* pass skb up to stack */
- netif_receive_skb(skb);
+ napi_gro_receive(&card->napi, skb);
}
/**
@@ -1069,7 +1074,7 @@ static int gelic_card_decode_one_descr(struct gelic_card *card)
/*
* this call can fail, propagate the error
*/
- prepare_rx_ret = gelic_descr_prepare_rx(card, descr);
+ prepare_rx_ret = gelic_descr_prepare_rx(card, descr, true);
if (prepare_rx_ret)
return prepare_rx_ret;
base-commit: ff736a286116d462a4067ba258fa351bc0b4ed80
--
2.43.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH net-next] net: ps3_gelic_net: Use napi_alloc_skb() and napi_gro_receive()
2025-11-30 19:41 [PATCH net-next] net: ps3_gelic_net: Use napi_alloc_skb() and napi_gro_receive() Florian Fuchs
@ 2025-12-01 10:14 ` Simon Horman
2025-12-01 10:34 ` Eric Dumazet
2025-12-02 1:00 ` patchwork-bot+netdevbpf
2 siblings, 0 replies; 4+ messages in thread
From: Simon Horman @ 2025-12-01 10:14 UTC (permalink / raw)
To: Florian Fuchs
Cc: Geoff Levand, netdev, Jakub Kicinski, Andrew Lunn,
David S. Miller, Eric Dumazet, Paolo Abeni, Madhavan Srinivasan,
Michael Ellerman, Nicholas Piggin, Christophe Leroy, linuxppc-dev,
linux-kernel
On Sun, Nov 30, 2025 at 08:41:55PM +0100, Florian Fuchs wrote:
> Use the napi functions napi_alloc_skb() and napi_gro_receive() instead
> of netdev_alloc_skb() and netif_receive_skb() for more efficient packet
> receiving. The switch to napi aware functions increases the RX
> throughput, reduces the occurrence of retransmissions and improves the
> resilience against SKB allocation failures.
>
> Signed-off-by: Florian Fuchs <fuchsfl@gmail.com>
> ---
> Note: This change has been tested on real hardware Sony PS3 (CECHL04 PAL),
> the patch was tested for many hours, with continuous system load, high
> network transfer load and injected failslab errors.
>
> In my tests, the RX throughput increased up to 100% and reduced the
> occurrence of retransmissions drastically, with GRO enabled:
>
> iperf3 before and after the commit, where PS3 (with this driver) is on
> the receiving side:
> Before: [ 5] 0.00-10.00 sec 551 MBytes 462 Mbits/sec receiver
> After: [ 5] 0.00-10.00 sec 1.09 GBytes 939 Mbits/sec receiver
>
> stats from the sending client to the PS3:
> Before: [ 5] 0.00-10.00 sec 552 MBytes 463 Mbits/sec 3151 sender
> After: [ 5] 0.00-10.00 sec 1.09 GBytes 940 Mbits/sec 37 sender
Hi Florian,
Thanks for the rest results and confirming this has
been exercised on real HW.
Thinking out loud:
* I see that the napi_mode argument to gelic_descr_prepare_rx ensures
that napi_alloc_skb() is only called from softirq context.
* I see that the driver already calls napi_complete_done() in
it's poll callback, a pre-requisite for using napi_alloc_skb().
So as I understand things the use of the NAPI API by this patch is correct.
And this provides a nice example of the advantages of using this part
of the API.
Reviewed-by: Simon Horman <horms@kernel.org>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH net-next] net: ps3_gelic_net: Use napi_alloc_skb() and napi_gro_receive()
2025-11-30 19:41 [PATCH net-next] net: ps3_gelic_net: Use napi_alloc_skb() and napi_gro_receive() Florian Fuchs
2025-12-01 10:14 ` Simon Horman
@ 2025-12-01 10:34 ` Eric Dumazet
2025-12-02 1:00 ` patchwork-bot+netdevbpf
2 siblings, 0 replies; 4+ messages in thread
From: Eric Dumazet @ 2025-12-01 10:34 UTC (permalink / raw)
To: Florian Fuchs
Cc: Geoff Levand, netdev, Jakub Kicinski, Andrew Lunn,
David S . Miller, Paolo Abeni, Madhavan Srinivasan,
Michael Ellerman, Nicholas Piggin, Christophe Leroy, linuxppc-dev,
linux-kernel
On Sun, Nov 30, 2025 at 11:51 AM Florian Fuchs <fuchsfl@gmail.com> wrote:
>
> Use the napi functions napi_alloc_skb() and napi_gro_receive() instead
> of netdev_alloc_skb() and netif_receive_skb() for more efficient packet
> receiving. The switch to napi aware functions increases the RX
> throughput, reduces the occurrence of retransmissions and improves the
> resilience against SKB allocation failures.
>
> Signed-off-by: Florian Fuchs <fuchsfl@gmail.com>
> ---
> Note: This change has been tested on real hardware Sony PS3 (CECHL04 PAL),
> the patch was tested for many hours, with continuous system load, high
> network transfer load and injected failslab errors.
>
> In my tests, the RX throughput increased up to 100% and reduced the
> occurrence of retransmissions drastically, with GRO enabled:
>
> iperf3 before and after the commit, where PS3 (with this driver) is on
> the receiving side:
> Before: [ 5] 0.00-10.00 sec 551 MBytes 462 Mbits/sec receiver
> After: [ 5] 0.00-10.00 sec 1.09 GBytes 939 Mbits/sec receiver
>
> stats from the sending client to the PS3:
> Before: [ 5] 0.00-10.00 sec 552 MBytes 463 Mbits/sec 3151 sender
> After: [ 5] 0.00-10.00 sec 1.09 GBytes 940 Mbits/sec 37 sender
>
> drivers/net/ethernet/toshiba/ps3_gelic_net.c | 15 ++++++++++-----
> 1 file changed, 10 insertions(+), 5 deletions(-)
Patch looks fine to me. My PS3 died years ago, so I can not test it :)
Reviewed-by: Eric Dumazet <edumazet@google.com>
BTW, I think we can cleanup gelic_descr_prepare_rx() a bit :
diff --git a/drivers/net/ethernet/toshiba/ps3_gelic_net.c
b/drivers/net/ethernet/toshiba/ps3_gelic_net.c
index 5ee8e8980393c3491bf9cf91eb8e0dbb2df0f427..f4f34e9ed49c5b7fd1cf4ea3f5bfe7297e97ea23
100644
--- a/drivers/net/ethernet/toshiba/ps3_gelic_net.c
+++ b/drivers/net/ethernet/toshiba/ps3_gelic_net.c
@@ -392,10 +392,8 @@ static int gelic_descr_prepare_rx(struct gelic_card *card,
descr->hw_regs.payload.size = 0;
descr->skb = netdev_alloc_skb(*card->netdev, rx_skb_size);
- if (!descr->skb) {
- descr->hw_regs.payload.dev_addr = 0; /* tell DMAC
don't touch memory */
+ if (!descr->skb)
return -ENOMEM;
- }
offset = ((unsigned long)descr->skb->data) &
(GELIC_NET_RXBUF_ALIGN - 1);
@@ -404,13 +402,12 @@ static int gelic_descr_prepare_rx(struct gelic_card *card,
/* io-mmu-map the skb */
cpu_addr = dma_map_single(ctodev(card), descr->skb->data,
GELIC_NET_MAX_FRAME, DMA_FROM_DEVICE);
- descr->hw_regs.payload.dev_addr = cpu_to_be32(cpu_addr);
+
if (dma_mapping_error(ctodev(card), cpu_addr)) {
dev_kfree_skb_any(descr->skb);
descr->skb = NULL;
dev_info(ctodev(card),
"%s:Could not iommu-map rx buffer\n", __func__);
- gelic_descr_set_status(descr, GELIC_DESCR_DMA_NOT_IN_USE);
return -ENOMEM;
}
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH net-next] net: ps3_gelic_net: Use napi_alloc_skb() and napi_gro_receive()
2025-11-30 19:41 [PATCH net-next] net: ps3_gelic_net: Use napi_alloc_skb() and napi_gro_receive() Florian Fuchs
2025-12-01 10:14 ` Simon Horman
2025-12-01 10:34 ` Eric Dumazet
@ 2025-12-02 1:00 ` patchwork-bot+netdevbpf
2 siblings, 0 replies; 4+ messages in thread
From: patchwork-bot+netdevbpf @ 2025-12-02 1:00 UTC (permalink / raw)
To: Florian Fuchs
Cc: geoff, netdev, kuba, andrew+netdev, davem, edumazet, pabeni,
maddy, mpe, npiggin, chleroy, linuxppc-dev, linux-kernel
Hello:
This patch was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:
On Sun, 30 Nov 2025 20:41:55 +0100 you wrote:
> Use the napi functions napi_alloc_skb() and napi_gro_receive() instead
> of netdev_alloc_skb() and netif_receive_skb() for more efficient packet
> receiving. The switch to napi aware functions increases the RX
> throughput, reduces the occurrence of retransmissions and improves the
> resilience against SKB allocation failures.
>
> Signed-off-by: Florian Fuchs <fuchsfl@gmail.com>
>
> [...]
Here is the summary with links:
- [net-next] net: ps3_gelic_net: Use napi_alloc_skb() and napi_gro_receive()
https://git.kernel.org/netdev/net-next/c/d8e08149a5ed
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2025-12-02 1:03 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-30 19:41 [PATCH net-next] net: ps3_gelic_net: Use napi_alloc_skb() and napi_gro_receive() Florian Fuchs
2025-12-01 10:14 ` Simon Horman
2025-12-01 10:34 ` Eric Dumazet
2025-12-02 1:00 ` patchwork-bot+netdevbpf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).