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

net: ps3_gelic_net: Use napi_alloc_skb() and napi_gro_receive()

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>
Reviewed-by: Simon Horman <horms@kernel.org>
Reviewed-by: Eric Dumazet <edumazet@google.com>
Link: https://patch.msgid.link/20251130194155.1950980-1-fuchsfl@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Florian Fuchs and committed by
Jakub Kicinski
d8e08149 3101f3e1

+10 -5
+10 -5
drivers/net/ethernet/toshiba/ps3_gelic_net.c
··· 364 364 * gelic_descr_prepare_rx - reinitializes a rx descriptor 365 365 * @card: card structure 366 366 * @descr: descriptor to re-init 367 + * @napi_mode: is it running in napi poll 367 368 * 368 369 * return 0 on success, <0 on failure 369 370 * ··· 375 374 * must be a multiple of GELIC_NET_RXBUF_ALIGN. 376 375 */ 377 376 static int gelic_descr_prepare_rx(struct gelic_card *card, 378 - struct gelic_descr *descr) 377 + struct gelic_descr *descr, 378 + bool napi_mode) 379 379 { 380 380 static const unsigned int rx_skb_size = 381 381 ALIGN(GELIC_NET_MAX_FRAME, GELIC_NET_RXBUF_ALIGN) + ··· 394 392 descr->hw_regs.payload.dev_addr = 0; 395 393 descr->hw_regs.payload.size = 0; 396 394 397 - descr->skb = netdev_alloc_skb(*card->netdev, rx_skb_size); 395 + if (napi_mode) 396 + descr->skb = napi_alloc_skb(&card->napi, rx_skb_size); 397 + else 398 + descr->skb = netdev_alloc_skb(*card->netdev, rx_skb_size); 398 399 if (!descr->skb) { 399 400 descr->hw_regs.payload.dev_addr = 0; /* tell DMAC don't touch memory */ 400 401 return -ENOMEM; ··· 469 464 470 465 do { 471 466 if (!descr->skb) { 472 - ret = gelic_descr_prepare_rx(card, descr); 467 + ret = gelic_descr_prepare_rx(card, descr, false); 473 468 if (ret) 474 469 goto rewind; 475 470 } ··· 969 964 netdev->stats.rx_bytes += skb->len; 970 965 971 966 /* pass skb up to stack */ 972 - netif_receive_skb(skb); 967 + napi_gro_receive(&card->napi, skb); 973 968 } 974 969 975 970 /** ··· 1074 1069 /* 1075 1070 * this call can fail, propagate the error 1076 1071 */ 1077 - prepare_rx_ret = gelic_descr_prepare_rx(card, descr); 1072 + prepare_rx_ret = gelic_descr_prepare_rx(card, descr, true); 1078 1073 if (prepare_rx_ret) 1079 1074 return prepare_rx_ret; 1080 1075