mirror of
https://github.com/torvalds/linux.git
synced 2025-12-07 20:06:24 +00:00
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>
This commit is contained in:
committed by
Jakub Kicinski
parent
3101f3e116
commit
d8e08149a5
@@ -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 @@ refill:
|
||||
/*
|
||||
* 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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user