net: dsa: mt7530: fix handling of BPDUs on MT7530 switch
authorArınç ÜNAL <arinc.unal@arinc9.com>
Sat, 17 Jun 2023 06:26:46 +0000 (09:26 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 28 Jun 2023 09:12:31 +0000 (11:12 +0200)
[ Upstream commit d7c66073559386b836bded7cdc8b66ee5c049129 ]

BPDUs are link-local frames, therefore they must be trapped to the CPU
port. Currently, the MT7530 switch treats BPDUs as regular multicast
frames, therefore flooding them to user ports. To fix this, set BPDUs to be
trapped to the CPU port. Group this on mt7530_setup() and
mt7531_setup_common() into mt753x_trap_frames() and call that.

Fixes: b8f126a8d543 ("net-next: dsa: add dsa support for Mediatek MT7530 switch")
Signed-off-by: Arınç ÜNAL <arinc.unal@arinc9.com>
Reviewed-by: Vladimir Oltean <olteanv@gmail.com>
Reviewed-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/net/dsa/mt7530.c

index 886dc7d..ec43edc 100644 (file)
@@ -998,6 +998,14 @@ unlock_exit:
        mutex_unlock(&priv->reg_mutex);
 }
 
+static void
+mt753x_trap_frames(struct mt7530_priv *priv)
+{
+       /* Trap BPDUs to the CPU port(s) */
+       mt7530_rmw(priv, MT753X_BPC, MT753X_BPDU_PORT_FW_MASK,
+                  MT753X_BPDU_CPU_ONLY);
+}
+
 static int
 mt753x_cpu_port_enable(struct dsa_switch *ds, int port)
 {
@@ -2219,6 +2227,8 @@ mt7530_setup(struct dsa_switch *ds)
 
        priv->p6_interface = PHY_INTERFACE_MODE_NA;
 
+       mt753x_trap_frames(priv);
+
        /* Enable and reset MIB counters */
        mt7530_mib_reset(ds);
 
@@ -2325,8 +2335,8 @@ mt7531_setup_common(struct dsa_switch *ds)
                           BIT(cpu_dp->index));
                break;
        }
-       mt7530_rmw(priv, MT753X_BPC, MT753X_BPDU_PORT_FW_MASK,
-                  MT753X_BPDU_CPU_ONLY);
+
+       mt753x_trap_frames(priv);
 
        /* Enable and reset MIB counters */
        mt7530_mib_reset(ds);