mirror of
https://github.com/openwrt/openwrt.git
synced 2025-01-26 06:09:37 +00:00
kernel: improve skb hash on the mtk ethernet driver
The PPE only provides a 14 bit hash, however many uses of the skb hash expect the hash to use the full 32 bit range. Use jhash to extend the hash to the full size Signed-off-by: Felix Fietkau <nbd@nbd.name>
This commit is contained in:
parent
fca0eb2d92
commit
6244b0b6c9
@ -18,15 +18,7 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
|
||||
|
||||
#include "mtk_eth_soc.h"
|
||||
|
||||
@@ -1246,6 +1247,7 @@ static int mtk_poll_rx(struct napi_struc
|
||||
unsigned int pktlen;
|
||||
dma_addr_t dma_addr;
|
||||
int mac;
|
||||
+ u16 hash;
|
||||
|
||||
ring = mtk_get_rx_ring(eth);
|
||||
if (unlikely(!ring))
|
||||
@@ -1259,13 +1261,12 @@ static int mtk_poll_rx(struct napi_struc
|
||||
@@ -1259,13 +1260,12 @@ static int mtk_poll_rx(struct napi_struc
|
||||
break;
|
||||
|
||||
/* find out which mac the packet come from. values start at 1 */
|
||||
@ -45,7 +37,7 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
|
||||
|
||||
if (unlikely(mac < 0 || mac >= MTK_MAC_COUNT ||
|
||||
!eth->netdev[mac]))
|
||||
@@ -2247,6 +2248,9 @@ static void mtk_gdm_config(struct mtk_et
|
||||
@@ -2247,6 +2247,9 @@ static void mtk_gdm_config(struct mtk_et
|
||||
|
||||
val |= config;
|
||||
|
||||
|
@ -10,13 +10,31 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
|
||||
|
||||
--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c
|
||||
+++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
|
||||
@@ -1316,6 +1316,10 @@ static int mtk_poll_rx(struct napi_struc
|
||||
@@ -19,6 +19,7 @@
|
||||
#include <linux/interrupt.h>
|
||||
#include <linux/pinctrl/devinfo.h>
|
||||
#include <linux/phylink.h>
|
||||
+#include <linux/jhash.h>
|
||||
#include <net/dsa.h>
|
||||
|
||||
#include "mtk_eth_soc.h"
|
||||
@@ -1246,6 +1247,7 @@ static int mtk_poll_rx(struct napi_struc
|
||||
struct net_device *netdev;
|
||||
unsigned int pktlen;
|
||||
dma_addr_t dma_addr;
|
||||
+ u32 hash;
|
||||
int mac;
|
||||
|
||||
ring = mtk_get_rx_ring(eth);
|
||||
@@ -1315,6 +1317,12 @@ static int mtk_poll_rx(struct napi_struc
|
||||
skb->protocol = eth_type_trans(skb, netdev);
|
||||
bytes += pktlen;
|
||||
|
||||
+ hash = trxd.rxd4 & GENMASK(13, 0);
|
||||
+ if (hash != GENMASK(13, 0))
|
||||
+ if (hash != GENMASK(13, 0)) {
|
||||
+ hash = jhash_1word(hash, 0);
|
||||
+ skb_set_hash(skb, hash, PKT_HASH_TYPE_L4);
|
||||
+ }
|
||||
+
|
||||
if (netdev->features & NETIF_F_HW_VLAN_CTAG_RX &&
|
||||
(trxd.rxd2 & RX_DMA_VTAG))
|
||||
|
@ -24,7 +24,7 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
|
||||
+mtk_eth-y := mtk_eth_soc.o mtk_sgmii.o mtk_eth_path.o mtk_ppe.o
|
||||
--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c
|
||||
+++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
|
||||
@@ -2277,12 +2277,17 @@ static int mtk_open(struct net_device *d
|
||||
@@ -2280,12 +2280,17 @@ static int mtk_open(struct net_device *d
|
||||
|
||||
/* we run 2 netdevs on the same dma ring so we only bring it up once */
|
||||
if (!refcount_read(ð->dma_refcnt)) {
|
||||
@ -44,7 +44,7 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
|
||||
|
||||
napi_enable(ð->tx_napi);
|
||||
napi_enable(ð->rx_napi);
|
||||
@@ -2352,6 +2357,9 @@ static int mtk_stop(struct net_device *d
|
||||
@@ -2355,6 +2360,9 @@ static int mtk_stop(struct net_device *d
|
||||
|
||||
mtk_dma_free(eth);
|
||||
|
||||
@ -54,7 +54,7 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -3141,6 +3149,13 @@ static int mtk_probe(struct platform_dev
|
||||
@@ -3144,6 +3152,13 @@ static int mtk_probe(struct platform_dev
|
||||
goto err_free_dev;
|
||||
}
|
||||
|
||||
@ -68,7 +68,7 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
|
||||
for (i = 0; i < MTK_MAX_DEVS; i++) {
|
||||
if (!eth->netdev[i])
|
||||
continue;
|
||||
@@ -3215,6 +3230,7 @@ static const struct mtk_soc_data mt7621_
|
||||
@@ -3218,6 +3233,7 @@ static const struct mtk_soc_data mt7621_
|
||||
.hw_features = MTK_HW_FEATURES,
|
||||
.required_clks = MT7621_CLKS_BITMAP,
|
||||
.required_pctl = false,
|
||||
@ -76,7 +76,7 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
|
||||
};
|
||||
|
||||
static const struct mtk_soc_data mt7622_data = {
|
||||
@@ -3223,6 +3239,7 @@ static const struct mtk_soc_data mt7622_
|
||||
@@ -3226,6 +3242,7 @@ static const struct mtk_soc_data mt7622_
|
||||
.hw_features = MTK_HW_FEATURES,
|
||||
.required_clks = MT7622_CLKS_BITMAP,
|
||||
.required_pctl = false,
|
||||
|
@ -20,16 +20,16 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
|
||||
+mtk_eth-y := mtk_eth_soc.o mtk_sgmii.o mtk_eth_path.o mtk_ppe.o mtk_ppe_debugfs.o mtk_offload.o
|
||||
--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c
|
||||
+++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
|
||||
@@ -19,6 +19,8 @@
|
||||
#include <linux/interrupt.h>
|
||||
@@ -20,6 +20,8 @@
|
||||
#include <linux/pinctrl/devinfo.h>
|
||||
#include <linux/phylink.h>
|
||||
#include <linux/jhash.h>
|
||||
+#include <linux/netfilter.h>
|
||||
+#include <net/netfilter/nf_flow_table.h>
|
||||
#include <net/dsa.h>
|
||||
|
||||
#include "mtk_eth_soc.h"
|
||||
@@ -1324,8 +1326,12 @@ static int mtk_poll_rx(struct napi_struc
|
||||
@@ -1327,8 +1329,12 @@ static int mtk_poll_rx(struct napi_struc
|
||||
(trxd.rxd2 & RX_DMA_VTAG))
|
||||
__vlan_hwaccel_put_tag(skb, htons(ETH_P_8021Q),
|
||||
RX_DMA_VID(trxd.rxd3));
|
||||
@ -44,7 +44,7 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
|
||||
|
||||
skip_rx:
|
||||
ring->data[idx] = new_data;
|
||||
@@ -2858,6 +2864,25 @@ static int mtk_set_rxnfc(struct net_devi
|
||||
@@ -2861,6 +2867,25 @@ static int mtk_set_rxnfc(struct net_devi
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -70,7 +70,7 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
|
||||
static const struct ethtool_ops mtk_ethtool_ops = {
|
||||
.get_link_ksettings = mtk_get_link_ksettings,
|
||||
.set_link_ksettings = mtk_set_link_ksettings,
|
||||
@@ -2889,6 +2914,7 @@ static const struct net_device_ops mtk_n
|
||||
@@ -2892,6 +2917,7 @@ static const struct net_device_ops mtk_n
|
||||
#ifdef CONFIG_NET_POLL_CONTROLLER
|
||||
.ndo_poll_controller = mtk_poll_controller,
|
||||
#endif
|
||||
@ -78,7 +78,7 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
|
||||
};
|
||||
|
||||
static int mtk_add_mac(struct mtk_eth *eth, struct device_node *np)
|
||||
@@ -3154,6 +3180,10 @@ static int mtk_probe(struct platform_dev
|
||||
@@ -3157,6 +3183,10 @@ static int mtk_probe(struct platform_dev
|
||||
eth->base + MTK_ETH_PPE_BASE, 2);
|
||||
if (err)
|
||||
goto err_free_dev;
|
||||
|
@ -37,7 +37,7 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
|
||||
#include <linux/mfd/syscon.h>
|
||||
#include <linux/regmap.h>
|
||||
#include <linux/clk.h>
|
||||
@@ -2482,6 +2483,13 @@ static int mtk_hw_init(struct mtk_eth *e
|
||||
@@ -2485,6 +2486,13 @@ static int mtk_hw_init(struct mtk_eth *e
|
||||
if (ret)
|
||||
goto err_disable_pm;
|
||||
|
||||
@ -51,7 +51,7 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
|
||||
if (MTK_HAS_CAPS(eth->soc->caps, MTK_SOC_MT7628)) {
|
||||
ret = device_reset(eth->dev);
|
||||
if (ret) {
|
||||
@@ -3080,6 +3088,16 @@ static int mtk_probe(struct platform_dev
|
||||
@@ -3083,6 +3091,16 @@ static int mtk_probe(struct platform_dev
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user