From: Felix Fietkau Date: Thu, 10 Nov 2022 21:24:54 +0000 (+0100) Subject: kernel: more fixes for mtk_eth_soc performance optimization X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=04b8ad60fd92b375cf661a56afb853344c95ca99;p=openwrt%2Fstaging%2Fnbd.git kernel: more fixes for mtk_eth_soc performance optimization - fix features sync between netdevs - fix crash in dsa_switch_rcv Fixes: ceb1451c10c1 ("kernel: add mediatek soc ethernet performance improvements") Signed-off-by: Felix Fietkau --- diff --git a/target/linux/generic/pending-5.15/732-08-net-dsa-add-support-for-DSA-rx-offloading-via-metada.patch b/target/linux/generic/pending-5.15/732-08-net-dsa-add-support-for-DSA-rx-offloading-via-metada.patch index 7fe7e5c07d..f6799f2949 100644 --- a/target/linux/generic/pending-5.15/732-08-net-dsa-add-support-for-DSA-rx-offloading-via-metada.patch +++ b/target/linux/generic/pending-5.15/732-08-net-dsa-add-support-for-DSA-rx-offloading-via-metada.patch @@ -45,7 +45,7 @@ Signed-off-by: Felix Fietkau struct dsa_port *cpu_dp = dev->dsa_ptr; struct sk_buff *nskb = NULL; struct dsa_slave_priv *p; -@@ -238,7 +240,21 @@ static int dsa_switch_rcv(struct sk_buff +@@ -238,7 +240,22 @@ static int dsa_switch_rcv(struct sk_buff if (!skb) return 0; @@ -53,14 +53,15 @@ Signed-off-by: Felix Fietkau + if (md_dst && md_dst->type == METADATA_HW_PORT_MUX) { + unsigned int port = md_dst->u.port_info.port_id; + -+ dsa_default_offload_fwd_mark(skb); + skb_dst_set(skb, NULL); + if (!skb_has_extensions(skb)) + skb->slow_gro = 0; + + skb->dev = dsa_master_find_slave(dev, 0, port); -+ if (skb->dev) ++ if (likely(skb->dev)) { ++ dsa_default_offload_fwd_mark(skb); + nskb = skb; ++ } + } else { + nskb = cpu_dp->rcv(skb, dev); + } diff --git a/target/linux/generic/pending-5.15/732-09-net-ethernet-mtk_eth_soc-fix-VLAN-rx-hardware-accele.patch b/target/linux/generic/pending-5.15/732-09-net-ethernet-mtk_eth_soc-fix-VLAN-rx-hardware-accele.patch index a065ea8257..8a20202131 100644 --- a/target/linux/generic/pending-5.15/732-09-net-ethernet-mtk_eth_soc-fix-VLAN-rx-hardware-accele.patch +++ b/target/linux/generic/pending-5.15/732-09-net-ethernet-mtk_eth_soc-fix-VLAN-rx-hardware-accele.patch @@ -52,39 +52,43 @@ Signed-off-by: Felix Fietkau } skb_record_rx_queue(skb, 0); -@@ -2793,15 +2800,25 @@ static netdev_features_t mtk_fix_feature +@@ -2793,15 +2800,30 @@ static netdev_features_t mtk_fix_feature static int mtk_set_features(struct net_device *dev, netdev_features_t features) { - int err = 0; -- -- if (!((dev->features ^ features) & NETIF_F_LRO)) -- return 0; + struct mtk_mac *mac = netdev_priv(dev); + struct mtk_eth *eth = mac->hw; + netdev_features_t diff = dev->features ^ features; + int i; ++ ++ if ((diff & NETIF_F_LRO) && !(features & NETIF_F_LRO)) ++ mtk_hwlro_netdev_disable(dev); + +- if (!((dev->features ^ features) & NETIF_F_LRO)) ++ /* Set RX VLAN offloading */ ++ if (!(diff & NETIF_F_HW_VLAN_CTAG_RX)) + return 0; - if (!(features & NETIF_F_LRO)) -+ if ((diff & NETIF_F_LRO) && !(features & NETIF_F_LRO)) - mtk_hwlro_netdev_disable(dev); +- mtk_hwlro_netdev_disable(dev); ++ mtk_w32(eth, !!(features & NETIF_F_HW_VLAN_CTAG_RX), ++ MTK_CDMP_EG_CTRL); - return err; -+ /* Set RX VLAN offloading */ -+ if (diff & NETIF_F_HW_VLAN_CTAG_RX) -+ mtk_w32(eth, !!(features & NETIF_F_HW_VLAN_CTAG_RX), -+ MTK_CDMP_EG_CTRL); -+ + /* sync features with other MAC */ -+ for (i = 0; i < MTK_MAC_COUNT; i++) -+ if (eth->netdev[i] && eth->netdev[i] != dev) -+ eth->netdev[i]->features = features; ++ for (i = 0; i < MTK_MAC_COUNT; i++) { ++ if (!eth->netdev[i] || eth->netdev[i] == dev) ++ continue; ++ eth->netdev[i]->features &= ~NETIF_F_HW_VLAN_CTAG_RX; ++ eth->netdev[i]->features |= features & NETIF_F_HW_VLAN_CTAG_RX; ++ } + + return 0; } /* wait for DMA to finish whatever it is doing before we start using it again */ -@@ -3083,11 +3100,45 @@ found: +@@ -3083,11 +3105,45 @@ found: return NOTIFY_DONE; } @@ -131,7 +135,7 @@ Signed-off-by: Felix Fietkau err = phylink_of_phy_connect(mac->phylink, mac->of_node, 0); if (err) { -@@ -3417,6 +3468,10 @@ static int mtk_hw_init(struct mtk_eth *e +@@ -3417,6 +3473,10 @@ static int mtk_hw_init(struct mtk_eth *e */ val = mtk_r32(eth, MTK_CDMQ_IG_CTRL); mtk_w32(eth, val | MTK_CDMQ_STAG_EN, MTK_CDMQ_IG_CTRL); @@ -142,7 +146,7 @@ Signed-off-by: Felix Fietkau /* Enable RX VLan Offloading */ mtk_w32(eth, 1, MTK_CDMP_EG_CTRL); -@@ -3634,6 +3689,12 @@ static int mtk_free_dev(struct mtk_eth * +@@ -3634,6 +3694,12 @@ static int mtk_free_dev(struct mtk_eth * free_netdev(eth->netdev[i]); } diff --git a/target/linux/ramips/patches-5.15/700-net-ethernet-mediatek-support-net-labels.patch b/target/linux/ramips/patches-5.15/700-net-ethernet-mediatek-support-net-labels.patch index 74e8f999ab..c447793eae 100644 --- a/target/linux/ramips/patches-5.15/700-net-ethernet-mediatek-support-net-labels.patch +++ b/target/linux/ramips/patches-5.15/700-net-ethernet-mediatek-support-net-labels.patch @@ -14,7 +14,7 @@ Signed-off-by: René van Dorst --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c -@@ -3918,6 +3918,7 @@ static const struct net_device_ops mtk_n +@@ -4021,6 +4021,7 @@ static const struct net_device_ops mtk_n static int mtk_add_mac(struct mtk_eth *eth, struct device_node *np) { @@ -22,7 +22,7 @@ Signed-off-by: René van Dorst const __be32 *_id = of_get_property(np, "reg", NULL); phy_interface_t phy_mode; struct phylink *phylink; -@@ -4046,6 +4047,9 @@ static int mtk_add_mac(struct mtk_eth *e +@@ -4149,6 +4150,9 @@ static int mtk_add_mac(struct mtk_eth *e register_netdevice_notifier(&mac->device_notifier); }