1 From 3d49ee2127c26fd2c77944fd2e3168c057f99439 Mon Sep 17 00:00:00 2001
2 From: Matthias Schiffer <mschiffer@universe-factory.net>
3 Date: Tue, 18 Jun 2024 09:17:13 +0200
4 Subject: [PATCH 2/2] net: dsa: mt7530: add support for bridge port isolation
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
9 Remove a pair of ports from the port matrix when both ports have the
12 Signed-off-by: Matthias Schiffer <mschiffer@universe-factory.net>
13 Reviewed-by: Wojciech Drewek <wojciech.drewek@intel.com>
14 Reviewed-by: Arınç ÜNAL <arinc.unal@arinc9.com>
15 Tested-by: Arınç ÜNAL <arinc.unal@arinc9.com>
16 Signed-off-by: David S. Miller <davem@davemloft.net>
18 drivers/net/dsa/mt7530.c | 18 ++++++++++++++++--
19 drivers/net/dsa/mt7530.h | 1 +
20 2 files changed, 17 insertions(+), 2 deletions(-)
22 --- a/drivers/net/dsa/mt7530.c
23 +++ b/drivers/net/dsa/mt7530.c
24 @@ -1311,6 +1311,7 @@ static void mt7530_update_port_member(st
25 struct dsa_port *cpu_dp = dp->cpu_dp;
26 u32 port_bitmap = BIT(cpu_dp->index);
30 dsa_switch_for_each_user_port(other_dp, priv->ds) {
31 other_port = other_dp->index;
32 @@ -1327,7 +1328,9 @@ static void mt7530_update_port_member(st
33 if (!dsa_port_offloads_bridge_dev(other_dp, bridge_dev))
37 + isolated = p->isolated && other_p->isolated;
39 + if (join && !isolated) {
40 other_p->pm |= PCR_MATRIX(BIT(port));
41 port_bitmap |= BIT(other_port);
43 @@ -1354,7 +1357,7 @@ mt7530_port_pre_bridge_flags(struct dsa_
44 struct netlink_ext_ack *extack)
46 if (flags.mask & ~(BR_LEARNING | BR_FLOOD | BR_MCAST_FLOOD |
48 + BR_BCAST_FLOOD | BR_ISOLATED))
52 @@ -1383,6 +1386,17 @@ mt7530_port_bridge_flags(struct dsa_swit
53 mt7530_rmw(priv, MT753X_MFC, BC_FFP(BIT(port)),
54 flags.val & BR_BCAST_FLOOD ? BC_FFP(BIT(port)) : 0);
56 + if (flags.mask & BR_ISOLATED) {
57 + struct dsa_port *dp = dsa_to_port(ds, port);
58 + struct net_device *bridge_dev = dsa_port_bridge_dev_get(dp);
60 + priv->ports[port].isolated = !!(flags.val & BR_ISOLATED);
62 + mutex_lock(&priv->reg_mutex);
63 + mt7530_update_port_member(priv, port, bridge_dev, true);
64 + mutex_unlock(&priv->reg_mutex);
70 --- a/drivers/net/dsa/mt7530.h
71 +++ b/drivers/net/dsa/mt7530.h
72 @@ -721,6 +721,7 @@ struct mt7530_fdb {
79 struct phylink_pcs *sgmii_pcs;