kernel: more fixes for mtk_eth_soc performance optimization

- fix features sync between netdevs
- fix crash in dsa_switch_rcv

Fixes: ceb1451c10 ("kernel: add mediatek soc ethernet performance improvements")
Signed-off-by: Felix Fietkau <nbd@nbd.name>
This commit is contained in:
Felix Fietkau 2022-11-10 22:24:54 +01:00
parent 161b22d103
commit 04b8ad60fd
3 changed files with 27 additions and 22 deletions

View File

@ -45,7 +45,7 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
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 <nbd@nbd.name>
+ 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);
+ }

View File

@ -52,39 +52,43 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
}
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 <nbd@nbd.name>
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 <nbd@nbd.name>
/* 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]);
}

View File

@ -14,7 +14,7 @@ Signed-off-by: René van Dorst <opensource@vdorst.com>
--- 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 <opensource@vdorst.com>
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);
}