blob: 14ccf28d120ca8ac0b700171a7b0260127a31772 [file] [log] [blame]
b.liue9582032025-04-17 19:18:16 +08001From: Felix Fietkau <nbd@nbd.name>
2Date: Sun, 13 Sep 2020 08:27:24 +0200
3Subject: [PATCH] net: ethernet: mtk_eth_soc: set PPE flow hash as skb hash
4 if present
5
6This improves GRO performance
7
8Signed-off-by: Felix Fietkau <nbd@nbd.name>
9---
10
11--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c
12+++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
13@@ -19,6 +19,7 @@
14 #include <linux/interrupt.h>
15 #include <linux/pinctrl/devinfo.h>
16 #include <linux/phylink.h>
17+#include <linux/jhash.h>
18 #include <net/dsa.h>
19
20 #include "mtk_eth_soc.h"
21@@ -1278,6 +1279,7 @@ static int mtk_poll_rx(struct napi_struc
22 struct net_device *netdev;
23 unsigned int pktlen;
24 dma_addr_t dma_addr;
25+ u32 hash;
26 int mac;
27
28 ring = mtk_get_rx_ring(eth);
29@@ -1350,6 +1352,12 @@ static int mtk_poll_rx(struct napi_struc
30 skb->protocol = eth_type_trans(skb, netdev);
31 bytes += pktlen;
32
33+ hash = trxd.rxd4 & GENMASK(13, 0);
34+ if (hash != GENMASK(13, 0)) {
35+ hash = jhash_1word(hash, 0);
36+ skb_set_hash(skb, hash, PKT_HASH_TYPE_L4);
37+ }
38+
39 if (netdev->features & NETIF_F_HW_VLAN_CTAG_RX &&
40 (trxd.rxd2 & RX_DMA_VTAG))
41 __vlan_hwaccel_put_tag(skb, htons(ETH_P_8021Q),