[openwrt/openwrt] ath79: ag71xx: reuse skbuff_head with napi skb api

LEDE Commits lede-commits at lists.infradead.org
Mon Jul 4 08:18:58 PDT 2022


ansuel pushed a commit to openwrt/openwrt.git, branch master:
https://git.openwrt.org/265f402fbdd8444835b43954bf27a83bc9369b91

commit 265f402fbdd8444835b43954bf27a83bc9369b91
Author: Sieng Piaw Liew <liew.s.piaw at gmail.com>
AuthorDate: Wed Jun 15 12:17:24 2022 +0800

    ath79: ag71xx: reuse skbuff_head with napi skb api
    
    napi_build_skb() reuses NAPI skbuff_head cache in order to save some
    cycles on freeing/allocating skbuff_heads on every new Rx or completed
    Tx.
    Use napi_consume_skb() to feed the cache with skbuff_heads of completed
    Tx so it's never empty.
    
    Signed-off-by: Sieng Piaw Liew <liew.s.piaw at gmail.com>
    [ fixed commit title ]
    Signed-off-by: Christian Marangi <ansuelsmth at gmail.com>
---
 .../ath79/files/drivers/net/ethernet/atheros/ag71xx/ag71xx_main.c   | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/target/linux/ath79/files/drivers/net/ethernet/atheros/ag71xx/ag71xx_main.c b/target/linux/ath79/files/drivers/net/ethernet/atheros/ag71xx/ag71xx_main.c
index 2fc18d5979..d6e8dd20c8 100644
--- a/target/linux/ath79/files/drivers/net/ethernet/atheros/ag71xx/ag71xx_main.c
+++ b/target/linux/ath79/files/drivers/net/ethernet/atheros/ag71xx/ag71xx_main.c
@@ -1278,7 +1278,7 @@ static int ag71xx_tx_packets(struct ag71xx *ag, bool flush)
 		if (!skb)
 			continue;
 
-		dev_kfree_skb_any(skb);
+		napi_consume_skb(skb, !flush);
 		ring->buf[i].skb = NULL;
 
 		bytes_compl += ring->buf[i].len;
@@ -1352,7 +1352,11 @@ static int ag71xx_rx_packets(struct ag71xx *ag, int limit)
 		dev->stats.rx_packets++;
 		dev->stats.rx_bytes += pktlen;
 
+#if LINUX_VERSION_CODE < KERNEL_VERSION(5,12,0)
 		skb = build_skb(ring->buf[i].rx_buf, ag71xx_buffer_size(ag));
+#else
+		skb = napi_build_skb(ring->buf[i].rx_buf, ag71xx_buffer_size(ag));
+#endif
 		if (!skb) {
 			skb_free_frag(ring->buf[i].rx_buf);
 			goto next;




More information about the lede-commits mailing list