Skip to content

Commit d8833c6

Browse files
KanjiMonsterSasha Levin
authored andcommitted
net: dsa: b53: fix clearing PVID of a port
[ Upstream commit f480851 ] Currently the PVID of ports are only set when adding/updating VLANs with PVID set or removing VLANs, but not when clearing the PVID flag of a VLAN. E.g. the following flow $ ip link add br0 type bridge vlan_filtering 1 $ ip link set sw1p1 master bridge $ bridge vlan add dev sw1p1 vid 10 pvid untagged $ bridge vlan add dev sw1p1 vid 10 untagged Would keep the PVID set as 10, despite the flag being cleared. Fix this by checking if we need to unset the PVID on vlan updates. Fixes: a2482d2 ("net: dsa: b53: Plug in VLAN support") Signed-off-by: Jonas Gorski <jonas.gorski@gmail.com> Tested-by: Florian Fainelli <florian.fainelli@broadcom.com> Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com> Link: https://patch.msgid.link/20250429201710.330937-4-jonas.gorski@gmail.com Signed-off-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent a8fdba2 commit d8833c6

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

drivers/net/dsa/b53/b53_common.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1538,12 +1538,21 @@ int b53_vlan_add(struct dsa_switch *ds, int port,
15381538
bool untagged = vlan->flags & BRIDGE_VLAN_INFO_UNTAGGED;
15391539
bool pvid = vlan->flags & BRIDGE_VLAN_INFO_PVID;
15401540
struct b53_vlan *vl;
1541+
u16 old_pvid, new_pvid;
15411542
int err;
15421543

15431544
err = b53_vlan_prepare(ds, port, vlan);
15441545
if (err)
15451546
return err;
15461547

1548+
b53_read16(dev, B53_VLAN_PAGE, B53_VLAN_PORT_DEF_TAG(port), &old_pvid);
1549+
if (pvid)
1550+
new_pvid = vlan->vid;
1551+
else if (!pvid && vlan->vid == old_pvid)
1552+
new_pvid = b53_default_pvid(dev);
1553+
else
1554+
new_pvid = old_pvid;
1555+
15471556
vl = &dev->vlans[vlan->vid];
15481557

15491558
b53_get_vlan_entry(dev, vlan->vid, vl);
@@ -1563,9 +1572,9 @@ int b53_vlan_add(struct dsa_switch *ds, int port,
15631572
b53_set_vlan_entry(dev, vlan->vid, vl);
15641573
b53_fast_age_vlan(dev, vlan->vid);
15651574

1566-
if (pvid && !dsa_is_cpu_port(ds, port)) {
1575+
if (!dsa_is_cpu_port(ds, port) && new_pvid != old_pvid) {
15671576
b53_write16(dev, B53_VLAN_PAGE, B53_VLAN_PORT_DEF_TAG(port),
1568-
vlan->vid);
1577+
new_pvid);
15691578
b53_fast_age_vlan(dev, vlan->vid);
15701579
}
15711580

0 commit comments

Comments
 (0)