aad129b897113f4d8abc2eed929bed019835cb81
[openwrt/staging/ldir.git] / target / linux / generic / backport-5.10 / 610-v5.13-50-net-ethernet-mtk_eth_soc-set-PPE-flow-hash-as-skb-ha.patch
1 From fa817272c37ef78e25dc14e4760ac78a7043a18a Mon Sep 17 00:00:00 2001
2 From: Felix Fietkau <nbd@nbd.name>
3 Date: Thu, 22 Apr 2021 22:21:07 -0700
4 Subject: [PATCH] net: ethernet: mtk_eth_soc: set PPE flow hash as skb hash if
5 present
6
7 This improves GRO performance
8
9 Signed-off-by: Felix Fietkau <nbd@nbd.name>
10 [Ilya: Use MTK_RXD4_FOE_ENTRY instead of GENMASK(13, 0)]
11 Signed-off-by: Ilya Lipnitskiy <ilya.lipnitskiy@gmail.com>
12 Signed-off-by: David S. Miller <davem@davemloft.net>
13 ---
14 drivers/net/ethernet/mediatek/mtk_eth_soc.c | 8 ++++++++
15 1 file changed, 8 insertions(+)
16
17 --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c
18 +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
19 @@ -19,6 +19,7 @@
20 #include <linux/interrupt.h>
21 #include <linux/pinctrl/devinfo.h>
22 #include <linux/phylink.h>
23 +#include <linux/jhash.h>
24 #include <net/dsa.h>
25
26 #include "mtk_eth_soc.h"
27 @@ -1283,6 +1284,7 @@ static int mtk_poll_rx(struct napi_struc
28 struct net_device *netdev;
29 unsigned int pktlen;
30 dma_addr_t dma_addr;
31 + u32 hash;
32 int mac;
33
34 ring = mtk_get_rx_ring(eth);
35 @@ -1355,6 +1357,12 @@ static int mtk_poll_rx(struct napi_struc
36 skb->protocol = eth_type_trans(skb, netdev);
37 bytes += pktlen;
38
39 + hash = trxd.rxd4 & MTK_RXD4_FOE_ENTRY;
40 + if (hash != MTK_RXD4_FOE_ENTRY) {
41 + hash = jhash_1word(hash, 0);
42 + skb_set_hash(skb, hash, PKT_HASH_TYPE_L4);
43 + }
44 +
45 if (netdev->features & NETIF_F_HW_VLAN_CTAG_RX &&
46 (trxd.rxd2 & RX_DMA_VTAG))
47 __vlan_hwaccel_put_tag(skb, htons(ETH_P_8021Q),