kernel: bump 5.4 to 5.4.92
[openwrt/openwrt.git] / target / linux / generic / pending-5.4 / 770-00-net-ethernet-mtk_eth_soc-use-napi_consume_skb.patch
1 From: Felix Fietkau <nbd@nbd.name>
2 Date: Mon, 8 Jun 2020 17:01:12 +0200
3 Subject: [PATCH] net: ethernet: mtk_eth_soc: use napi_consume_skb
4
5 Should improve performance, since it can use bulk free
6
7 Signed-off-by: Felix Fietkau <nbd@nbd.name>
8 ---
9
10 --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c
11 +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
12 @@ -853,7 +853,8 @@ static int txd_to_idx(struct mtk_tx_ring
13 return ((void *)dma - (void *)ring->dma) / sizeof(*dma);
14 }
15
16 -static void mtk_tx_unmap(struct mtk_eth *eth, struct mtk_tx_buf *tx_buf)
17 +static void mtk_tx_unmap(struct mtk_eth *eth, struct mtk_tx_buf *tx_buf,
18 + bool napi)
19 {
20 if (MTK_HAS_CAPS(eth->soc->caps, MTK_QDMA)) {
21 if (tx_buf->flags & MTK_TX_FLAGS_SINGLE0) {
22 @@ -885,8 +886,12 @@ static void mtk_tx_unmap(struct mtk_eth
23
24 tx_buf->flags = 0;
25 if (tx_buf->skb &&
26 - (tx_buf->skb != (struct sk_buff *)MTK_DMA_DUMMY_DESC))
27 - dev_kfree_skb_any(tx_buf->skb);
28 + (tx_buf->skb != (struct sk_buff *)MTK_DMA_DUMMY_DESC)) {
29 + if (napi)
30 + napi_consume_skb(tx_buf->skb, napi);
31 + else
32 + dev_kfree_skb_any(tx_buf->skb);
33 + }
34 tx_buf->skb = NULL;
35 }
36
37 @@ -1064,7 +1069,7 @@ err_dma:
38 tx_buf = mtk_desc_to_tx_buf(ring, itxd);
39
40 /* unmap dma */
41 - mtk_tx_unmap(eth, tx_buf);
42 + mtk_tx_unmap(eth, tx_buf, false);
43
44 itxd->txd3 = TX_DMA_LS0 | TX_DMA_OWNER_CPU;
45 if (!MTK_HAS_CAPS(eth->soc->caps, MTK_QDMA))
46 @@ -1382,7 +1387,7 @@ static int mtk_poll_tx_qdma(struct mtk_e
47 done[mac]++;
48 budget--;
49 }
50 - mtk_tx_unmap(eth, tx_buf);
51 + mtk_tx_unmap(eth, tx_buf, true);
52
53 ring->last_free = desc;
54 atomic_inc(&ring->free_count);
55 @@ -1419,7 +1424,7 @@ static int mtk_poll_tx_pdma(struct mtk_e
56 budget--;
57 }
58
59 - mtk_tx_unmap(eth, tx_buf);
60 + mtk_tx_unmap(eth, tx_buf, true);
61
62 desc = &ring->dma[cpu];
63 ring->last_free = desc;
64 @@ -1621,7 +1626,7 @@ static void mtk_tx_clean(struct mtk_eth
65
66 if (ring->buf) {
67 for (i = 0; i < MTK_DMA_SIZE; i++)
68 - mtk_tx_unmap(eth, &ring->buf[i]);
69 + mtk_tx_unmap(eth, &ring->buf[i], false);
70 kfree(ring->buf);
71 ring->buf = NULL;
72 }