kernel: bump 5.10 to 5.10.124
[openwrt/openwrt.git] / target / linux / generic / backport-5.10 / 610-v5.13-40-net-ethernet-mtk_eth_soc-use-napi_consume_skb.patch
1 From c30c4a82739090a2de4a4e3f245355ea4fb3ec14 Mon Sep 17 00:00:00 2001
2 From: Felix Fietkau <nbd@nbd.name>
3 Date: Thu, 22 Apr 2021 22:20:57 -0700
4 Subject: [PATCH] net: ethernet: mtk_eth_soc: use napi_consume_skb
5
6 Should improve performance, since it can use bulk free
7
8 Signed-off-by: Felix Fietkau <nbd@nbd.name>
9 Signed-off-by: Ilya Lipnitskiy <ilya.lipnitskiy@gmail.com>
10 Signed-off-by: David S. Miller <davem@davemloft.net>
11 ---
12 drivers/net/ethernet/mediatek/mtk_eth_soc.c | 19 ++++++++++++-------
13 1 file changed, 12 insertions(+), 7 deletions(-)
14
15 --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c
16 +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
17 @@ -890,7 +890,8 @@ static int txd_to_idx(struct mtk_tx_ring
18 return ((void *)dma - (void *)ring->dma) / sizeof(*dma);
19 }
20
21 -static void mtk_tx_unmap(struct mtk_eth *eth, struct mtk_tx_buf *tx_buf)
22 +static void mtk_tx_unmap(struct mtk_eth *eth, struct mtk_tx_buf *tx_buf,
23 + bool napi)
24 {
25 if (MTK_HAS_CAPS(eth->soc->caps, MTK_QDMA)) {
26 if (tx_buf->flags & MTK_TX_FLAGS_SINGLE0) {
27 @@ -922,8 +923,12 @@ static void mtk_tx_unmap(struct mtk_eth
28
29 tx_buf->flags = 0;
30 if (tx_buf->skb &&
31 - (tx_buf->skb != (struct sk_buff *)MTK_DMA_DUMMY_DESC))
32 - dev_kfree_skb_any(tx_buf->skb);
33 + (tx_buf->skb != (struct sk_buff *)MTK_DMA_DUMMY_DESC)) {
34 + if (napi)
35 + napi_consume_skb(tx_buf->skb, napi);
36 + else
37 + dev_kfree_skb_any(tx_buf->skb);
38 + }
39 tx_buf->skb = NULL;
40 }
41
42 @@ -1101,7 +1106,7 @@ err_dma:
43 tx_buf = mtk_desc_to_tx_buf(ring, itxd);
44
45 /* unmap dma */
46 - mtk_tx_unmap(eth, tx_buf);
47 + mtk_tx_unmap(eth, tx_buf, false);
48
49 itxd->txd3 = TX_DMA_LS0 | TX_DMA_OWNER_CPU;
50 if (!MTK_HAS_CAPS(eth->soc->caps, MTK_QDMA))
51 @@ -1423,7 +1428,7 @@ static int mtk_poll_tx_qdma(struct mtk_e
52 done[mac]++;
53 budget--;
54 }
55 - mtk_tx_unmap(eth, tx_buf);
56 + mtk_tx_unmap(eth, tx_buf, true);
57
58 ring->last_free = desc;
59 atomic_inc(&ring->free_count);
60 @@ -1460,7 +1465,7 @@ static int mtk_poll_tx_pdma(struct mtk_e
61 budget--;
62 }
63
64 - mtk_tx_unmap(eth, tx_buf);
65 + mtk_tx_unmap(eth, tx_buf, true);
66
67 desc = &ring->dma[cpu];
68 ring->last_free = desc;
69 @@ -1662,7 +1667,7 @@ static void mtk_tx_clean(struct mtk_eth
70
71 if (ring->buf) {
72 for (i = 0; i < MTK_DMA_SIZE; i++)
73 - mtk_tx_unmap(eth, &ring->buf[i]);
74 + mtk_tx_unmap(eth, &ring->buf[i], false);
75 kfree(ring->buf);
76 ring->buf = NULL;
77 }