[PATCH net v2 4/4] net: dsa: motorcomm: Use VID 0 as the unaware PVID
From: David Yang
Date: Mon Nov 16 2026 - 11:02:57 EST
The hardware classifies untagged and priority-tagged frames to the
port's PVID before the VLAN table lookup, and the FDB lookup key equals
the classified VID (measured on YT9215S).
The driver assigned PVID 4095 to the VLAN-unaware ports, while switchdev
reports the bridge's FDB entries with VID 0. These entries were then
installed under FID 0 and could never be hit by the hardware lookups.
Dynamic entries learnt under VID 4095, if any, took effect instead.
Lift the restriction on VLAN 0. Keep VLAN 0 out of the generic VLAN
add/delete paths, otherwise 8021q's automatic VLAN 0 filtering would
leave a stray CPU port bit behind.
Use VLAN 0 as the PVID of the VLAN-unaware ports. Program the PVID when
a port joins a VLAN-unaware bridge since DSA does not necessarily call
.port_vlan_filtering().
The standalone default of 4095 stays, so mislearnt entries, if any,
would not pollute the bridge FDB.
Fixes: 186623f4aa72 ("net: dsa: yt921x: Add support for Motorcomm YT921x")
Signed-off-by: David Yang <mmyangfl@xxxxxxxxx>
---
drivers/net/dsa/motorcomm/chip.c | 44 +++++++++++++++++++-------------
1 file changed, 26 insertions(+), 18 deletions(-)
diff --git a/drivers/net/dsa/motorcomm/chip.c b/drivers/net/dsa/motorcomm/chip.c
index d84d863080ce..aa4d6a0c930c 100644
--- a/drivers/net/dsa/motorcomm/chip.c
+++ b/drivers/net/dsa/motorcomm/chip.c
@@ -79,7 +79,7 @@ static const struct yt921x_info yt921x_infos[] = {
{}
};
-#define YT921X_VID_UNWARE 4095
+#define YT921X_VID_STANDALONE 4095
struct yt921x_reg_mdio {
struct mii_bus *bus;
@@ -960,8 +960,10 @@ yt921x_vlan_filtering(struct yt921x_priv *priv, int port, bool vlan_filtering)
brport = dsa_port_to_bridge_port(dp);
- if (!brport || !vlan_filtering)
- pvid = YT921X_VID_UNWARE;
+ if (!brport)
+ pvid = YT921X_VID_STANDALONE;
+ else if (!vlan_filtering)
+ pvid = 0;
else
br_vlan_get_pvid(brport, &pvid);
res = yt921x_port_set_pvid(priv, port, pvid);
@@ -1029,8 +1031,7 @@ yt921x_pvid_clear(struct yt921x_priv *priv, int port)
vlan_filtering = dsa_port_is_vlan_filtering(dp);
- res = yt921x_port_set_pvid(priv, port,
- vlan_filtering ? 0 : YT921X_VID_UNWARE);
+ res = yt921x_port_set_pvid(priv, port, 0);
if (res)
return res;
@@ -1098,6 +1099,8 @@ yt921x_dsa_port_vlan_del(struct dsa_switch *ds, int port,
if (dsa_is_cpu_port(ds, port))
return 0;
+ if (!vid)
+ return 0;
mutex_lock(&priv->reg_lock);
do {
@@ -1135,6 +1138,11 @@ yt921x_dsa_port_vlan_add(struct dsa_switch *ds, int port,
*/
if (dsa_is_cpu_port(ds, port))
return 0;
+ /* VID 0 is the VLAN-unaware bridges' FDB domain; nothing to program,
+ * keep the entry at reset defaults
+ */
+ if (!vid)
+ return 0;
mutex_lock(&priv->reg_lock);
do {
@@ -1187,7 +1195,7 @@ static int yt921x_userport_standalone(struct yt921x_priv *priv, int port)
/* Unrelated since learning is off and all packets are trapped;
* set it anyway
*/
- res = yt921x_port_set_pvid(priv, port, YT921X_VID_UNWARE);
+ res = yt921x_port_set_pvid(priv, port, YT921X_VID_STANDALONE);
if (res)
return res;
@@ -1285,7 +1293,8 @@ static int yt921x_bridge_leave(struct yt921x_priv *priv, int port)
}
static int
-yt921x_bridge_join(struct yt921x_priv *priv, int port, u16 ports_mask)
+yt921x_bridge_join(struct yt921x_priv *priv, int port, u16 ports_mask,
+ bool vlan_filtering)
{
int res;
@@ -1297,6 +1306,14 @@ yt921x_bridge_join(struct yt921x_priv *priv, int port, u16 ports_mask)
if (res)
return res;
+ if (!vlan_filtering) {
+ /* DSA may shortcut .port_vlan_filtering(), leaving stale PVID
+ */
+ res = yt921x_port_set_pvid(priv, port, 0);
+ if (res)
+ return res;
+ }
+
return 0;
}
@@ -1427,7 +1444,8 @@ yt921x_dsa_port_bridge_join(struct dsa_switch *ds, int port,
mutex_lock(&priv->reg_lock);
pp->isolated = br_port_flag_is_set(brport_dev, BR_ISOLATED);
pp->hairpin = br_port_flag_is_set(brport_dev, BR_HAIRPIN_MODE);
- res = yt921x_bridge_join(priv, port, ports_mask);
+ res = yt921x_bridge_join(priv, port, ports_mask,
+ br_vlan_enabled(bridge.dev));
mutex_unlock(&priv->reg_lock);
return res;
@@ -2277,7 +2295,6 @@ static int yt921x_chip_setup_dsa(struct yt921x_priv *priv)
{
struct dsa_switch *ds = &priv->ds;
unsigned long cpu_ports_mask;
- u32 ctrls[2];
u32 ctrl;
int port;
int res;
@@ -2335,15 +2352,6 @@ static int yt921x_chip_setup_dsa(struct yt921x_priv *priv)
if (res)
return res;
- /* Tagged VID 0 should be treated as untagged, which confuses the
- * hardware a lot
- */
- ctrls[0] = YT921X_VLAN_CTRLa_LEARN_DIS | YT921X_VLAN_CTRLa_PORTS_M;
- ctrls[1] = 0;
- res = yt921x_reg64_write(priv, YT921X_VLANn_CTRL(0), ctrls);
- if (res)
- return res;
-
return 0;
}
--
2.53.0