Netdev List
 help / color / mirror / Atom feed
* [PATCH net] net: dsa: motorcomm: Read the port PVID instead of bridge's
@ 2026-11-19 22:09 David Yang
  2026-11-19 22:12 ` netdev-bot+sinfo
  0 siblings, 1 reply; 3+ messages in thread
From: David Yang @ 2026-11-19 22:09 UTC (permalink / raw)
  To: netdev
  Cc: David Yang, Andrew Lunn, Vladimir Oltean, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni

The driver passed the bridge master to br_vlan_get_pvid(), returning
the bridge's own PVID (VID 1 by default) instead of the configured
port's: deleting a vid that equalled the bridge's PVID wiped the port's
real hardware PVID, and a vlan_filtering toggle programmed that PVID
into every port.

Query the PVID from dsa_port_to_bridge_port() instead. Clear it when the
port has no PVID left, instead of comparing the deleted vid against the
bridge master's PVID, as the bridge unpublishes the PVID before the del
notification.

Fixes: 186623f4aa72 ("net: dsa: yt921x: Add support for Motorcomm YT921x")
Signed-off-by: David Yang <mmyangfl@gmail.com>
---
 drivers/net/dsa/motorcomm/chip.c | 26 +++++++++++++-------------
 1 file changed, 13 insertions(+), 13 deletions(-)

diff --git a/drivers/net/dsa/motorcomm/chip.c b/drivers/net/dsa/motorcomm/chip.c
index c753c746490a..b12bf32f8896 100644
--- a/drivers/net/dsa/motorcomm/chip.c
+++ b/drivers/net/dsa/motorcomm/chip.c
@@ -948,18 +948,18 @@ static int
 yt921x_vlan_filtering(struct yt921x_priv *priv, int port, bool vlan_filtering)
 {
 	struct dsa_port *dp = dsa_to_port(&priv->ds, port);
-	struct net_device *bdev;
+	struct net_device *brport;
 	u16 pvid;
 	u32 mask;
 	u32 ctrl;
 	int res;
 
-	bdev = dsa_port_bridge_dev_get(dp);
+	brport = dsa_port_to_bridge_port(dp);
 
-	if (!bdev || !vlan_filtering)
+	if (!brport || !vlan_filtering)
 		pvid = YT921X_VID_UNWARE;
 	else
-		br_vlan_get_pvid(bdev, &pvid);
+		br_vlan_get_pvid(brport, &pvid);
 	res = yt921x_port_set_pvid(priv, port, pvid);
 	if (res)
 		return res;
@@ -1098,16 +1098,16 @@ yt921x_dsa_port_vlan_del(struct dsa_switch *ds, int port,
 	mutex_lock(&priv->reg_lock);
 	do {
 		struct dsa_port *dp = dsa_to_port(ds, port);
-		struct net_device *bdev;
+		struct net_device *brport;
 
 		res = yt921x_vlan_del(priv, port, vid);
 		if (res)
 			break;
 
-		bdev = dsa_port_bridge_dev_get(dp);
-		if (bdev) {
-			br_vlan_get_pvid(bdev, &pvid);
-			if (pvid == vid)
+		brport = dsa_port_to_bridge_port(dp);
+		if (brport) {
+			br_vlan_get_pvid(brport, &pvid);
+			if (!pvid)
 				res = yt921x_pvid_clear(priv, port);
 		}
 	} while (0);
@@ -1135,19 +1135,19 @@ yt921x_dsa_port_vlan_add(struct dsa_switch *ds, int port,
 	mutex_lock(&priv->reg_lock);
 	do {
 		struct dsa_port *dp = dsa_to_port(ds, port);
-		struct net_device *bdev;
+		struct net_device *brport;
 
 		res = yt921x_vlan_add(priv, port, vid,
 				      vlan->flags & BRIDGE_VLAN_INFO_UNTAGGED);
 		if (res)
 			break;
 
-		bdev = dsa_port_bridge_dev_get(dp);
-		if (bdev) {
+		brport = dsa_port_to_bridge_port(dp);
+		if (brport) {
 			if (vlan->flags & BRIDGE_VLAN_INFO_PVID) {
 				res = yt921x_pvid_set(priv, port, vid);
 			} else {
-				br_vlan_get_pvid(bdev, &pvid);
+				br_vlan_get_pvid(brport, &pvid);
 				if (pvid == vid)
 					res = yt921x_pvid_clear(priv, port);
 			}
-- 
2.53.0


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

end of thread, other threads:[~2026-11-19 22:15 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-19 22:09 [PATCH net] net: dsa: motorcomm: Read the port PVID instead of bridge's David Yang
2026-11-19 22:12 ` netdev-bot+sinfo
2026-11-19 22:14   ` David Yang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox