From: Felix Fietkau Date: Fri, 18 Dec 2020 16:10:04 +0000 (+0100) Subject: kernel: improve skb hash on the mtk ethernet driver X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=6244b0b6c942a6257c612622a5761f05277025e9;p=openwrt%2Fstaging%2Frobimarko.git 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 --- diff --git a/target/linux/generic/pending-5.4/770-13-net-ethernet-mtk_eth_soc-fix-parsing-packets-in-GDM.patch b/target/linux/generic/pending-5.4/770-13-net-ethernet-mtk_eth_soc-fix-parsing-packets-in-GDM.patch index 9ef675dcd1..16993b9d80 100644 --- a/target/linux/generic/pending-5.4/770-13-net-ethernet-mtk_eth_soc-fix-parsing-packets-in-GDM.patch +++ b/target/linux/generic/pending-5.4/770-13-net-ethernet-mtk_eth_soc-fix-parsing-packets-in-GDM.patch @@ -18,15 +18,7 @@ Signed-off-by: Felix Fietkau #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 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; diff --git a/target/linux/generic/pending-5.4/770-14-net-ethernet-mtk_eth_soc-set-PPE-flow-hash-as-skb-ha.patch b/target/linux/generic/pending-5.4/770-14-net-ethernet-mtk_eth_soc-set-PPE-flow-hash-as-skb-ha.patch index 60ac12c013..68ae19ec6e 100644 --- a/target/linux/generic/pending-5.4/770-14-net-ethernet-mtk_eth_soc-set-PPE-flow-hash-as-skb-ha.patch +++ b/target/linux/generic/pending-5.4/770-14-net-ethernet-mtk_eth_soc-set-PPE-flow-hash-as-skb-ha.patch @@ -10,13 +10,31 @@ Signed-off-by: Felix Fietkau --- 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 + #include + #include ++#include + #include + + #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)) diff --git a/target/linux/generic/pending-5.4/770-15-net-ethernet-mediatek-mtk_eth_soc-add-support-for-in.patch b/target/linux/generic/pending-5.4/770-15-net-ethernet-mediatek-mtk_eth_soc-add-support-for-in.patch index 6d729c0f08..d679e30bea 100644 --- a/target/linux/generic/pending-5.4/770-15-net-ethernet-mediatek-mtk_eth_soc-add-support-for-in.patch +++ b/target/linux/generic/pending-5.4/770-15-net-ethernet-mediatek-mtk_eth_soc-add-support-for-in.patch @@ -24,7 +24,7 @@ Signed-off-by: Felix Fietkau +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 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 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 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 }; 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, diff --git a/target/linux/generic/pending-5.4/770-16-net-ethernet-mediatek-mtk_eth_soc-add-flow-offloadin.patch b/target/linux/generic/pending-5.4/770-16-net-ethernet-mediatek-mtk_eth_soc-add-flow-offloadin.patch index 810eeda75c..f63ed28998 100644 --- a/target/linux/generic/pending-5.4/770-16-net-ethernet-mediatek-mtk_eth_soc-add-flow-offloadin.patch +++ b/target/linux/generic/pending-5.4/770-16-net-ethernet-mediatek-mtk_eth_soc-add-flow-offloadin.patch @@ -20,16 +20,16 @@ Signed-off-by: Felix Fietkau +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 +@@ -20,6 +20,8 @@ #include #include + #include +#include +#include #include #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 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 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 }; 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; diff --git a/target/linux/mediatek/patches-5.4/1011-net-ethernet-mtk_eth_soc-add-support-for-coherent-DM.patch b/target/linux/mediatek/patches-5.4/1011-net-ethernet-mtk_eth_soc-add-support-for-coherent-DM.patch index 18ddd0863e..efb30f2e50 100644 --- a/target/linux/mediatek/patches-5.4/1011-net-ethernet-mtk_eth_soc-add-support-for-coherent-DM.patch +++ b/target/linux/mediatek/patches-5.4/1011-net-ethernet-mtk_eth_soc-add-support-for-coherent-DM.patch @@ -37,7 +37,7 @@ Signed-off-by: Felix Fietkau #include #include #include -@@ -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 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 } }