netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] net: dsa: mv88e6xxx: use distinct FIDs for each bridge
@ 2023-07-24 10:10 Daniel Mack
  2023-07-25 15:55 ` Simon Horman
  2023-07-25 17:03 ` Vladimir Oltean
  0 siblings, 2 replies; 3+ messages in thread
From: Daniel Mack @ 2023-07-24 10:10 UTC (permalink / raw)
  To: netdev; +Cc: andrew, f.fainelli, olteanv, Daniel Mack

Allow setups with overlapping VLAN IDs in different bridges by settting
the FID of all bridge ports to the index of the bridge.

Read the FID back when detecting overlaps.

Signed-off-by: Daniel Mack <daniel.mack@holoplot.com>
---
 drivers/net/dsa/mv88e6xxx/chip.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/drivers/net/dsa/mv88e6xxx/chip.c b/drivers/net/dsa/mv88e6xxx/chip.c
index c7d51a539451..dff271981c69 100644
--- a/drivers/net/dsa/mv88e6xxx/chip.c
+++ b/drivers/net/dsa/mv88e6xxx/chip.c
@@ -2028,6 +2028,7 @@ static int mv88e6xxx_port_check_hw_vlan(struct dsa_switch *ds, int port,
 	struct mv88e6xxx_chip *chip = ds->priv;
 	struct mv88e6xxx_vtu_entry vlan;
 	int err;
+	u16 fid;
 
 	/* DSA and CPU ports have to be members of multiple vlans */
 	if (dsa_port_is_dsa(dp) || dsa_port_is_cpu(dp))
@@ -2037,11 +2038,16 @@ static int mv88e6xxx_port_check_hw_vlan(struct dsa_switch *ds, int port,
 	if (err)
 		return err;
 
+	err = mv88e6xxx_port_get_fid(chip, port, &fid);
+	if (err)
+		return err;
+
 	if (!vlan.valid)
 		return 0;
 
 	dsa_switch_for_each_user_port(other_dp, ds) {
 		struct net_device *other_br;
+		u16 other_fid;
 
 		if (vlan.member[other_dp->index] ==
 		    MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER)
@@ -2054,6 +2060,10 @@ static int mv88e6xxx_port_check_hw_vlan(struct dsa_switch *ds, int port,
 		if (!other_br)
 			continue;
 
+		err = mv88e6xxx_port_get_fid(chip, other_dp->index, &other_fid);
+		if (err == 0 && fid != other_fid)
+			continue;
+
 		dev_err(ds->dev, "p%d: hw VLAN %d already used by port %d in %s\n",
 			port, vlan.vid, other_dp->index, netdev_name(other_br));
 		return -EOPNOTSUPP;
@@ -2948,6 +2958,11 @@ static int mv88e6xxx_port_bridge_join(struct dsa_switch *ds, int port,
 		*tx_fwd_offload = true;
 	}
 
+	/* Set the port's FID to the bridge index so bridges can have
+	 * overlapping VLANs.
+	 */
+	err = mv88e6xxx_port_set_fid(chip, port, bridge.num);
+
 unlock:
 	mv88e6xxx_reg_unlock(chip);
 
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-07-25 17:03 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-07-24 10:10 [PATCH] net: dsa: mv88e6xxx: use distinct FIDs for each bridge Daniel Mack
2023-07-25 15:55 ` Simon Horman
2023-07-25 17:03 ` Vladimir Oltean

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).