Skip to content

Commit 4b81329

Browse files
KanjiMonsterSasha Levin
authored andcommitted
net: dsa: b53: do not program vlans when vlan filtering is off
[ Upstream commit f089652 ] Documentation/networking/switchdev.rst says: - with VLAN filtering turned off: the bridge is strictly VLAN unaware and its data path will process all Ethernet frames as if they are VLAN-untagged. The bridge VLAN database can still be modified, but the modifications should have no effect while VLAN filtering is turned off. This breaks if we immediately apply the VLAN configuration, so skip writing it when vlan_filtering is off. Fixes: 0ee2af4 ("net: dsa: set configure_vlan_while_not_filtering to true by default") 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-9-jonas.gorski@gmail.com Signed-off-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent ea749a8 commit 4b81329

File tree

1 file changed

+28
-20
lines changed

1 file changed

+28
-20
lines changed

drivers/net/dsa/b53/b53_common.c

Lines changed: 28 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1548,6 +1548,9 @@ int b53_vlan_add(struct dsa_switch *ds, int port,
15481548
if (vlan->vid == 0)
15491549
return 0;
15501550

1551+
if (!ds->vlan_filtering)
1552+
return 0;
1553+
15511554
b53_read16(dev, B53_VLAN_PAGE, B53_VLAN_PORT_DEF_TAG(port), &old_pvid);
15521555
if (pvid)
15531556
new_pvid = vlan->vid;
@@ -1593,6 +1596,9 @@ int b53_vlan_del(struct dsa_switch *ds, int port,
15931596
if (vlan->vid == 0)
15941597
return 0;
15951598

1599+
if (!ds->vlan_filtering)
1600+
return 0;
1601+
15961602
b53_read16(dev, B53_VLAN_PAGE, B53_VLAN_PORT_DEF_TAG(port), &pvid);
15971603

15981604
vl = &dev->vlans[vlan->vid];
@@ -1953,18 +1959,20 @@ int b53_br_join(struct dsa_switch *ds, int port, struct dsa_bridge bridge,
19531959
pvid = b53_default_pvid(dev);
19541960
vl = &dev->vlans[pvid];
19551961

1956-
/* Make this port leave the all VLANs join since we will have proper
1957-
* VLAN entries from now on
1958-
*/
1959-
if (is58xx(dev)) {
1960-
b53_read16(dev, B53_VLAN_PAGE, B53_JOIN_ALL_VLAN_EN, &reg);
1961-
reg &= ~BIT(port);
1962-
if ((reg & BIT(cpu_port)) == BIT(cpu_port))
1963-
reg &= ~BIT(cpu_port);
1964-
b53_write16(dev, B53_VLAN_PAGE, B53_JOIN_ALL_VLAN_EN, reg);
1965-
}
1966-
19671962
if (ds->vlan_filtering) {
1963+
/* Make this port leave the all VLANs join since we will have
1964+
* proper VLAN entries from now on
1965+
*/
1966+
if (is58xx(dev)) {
1967+
b53_read16(dev, B53_VLAN_PAGE, B53_JOIN_ALL_VLAN_EN,
1968+
&reg);
1969+
reg &= ~BIT(port);
1970+
if ((reg & BIT(cpu_port)) == BIT(cpu_port))
1971+
reg &= ~BIT(cpu_port);
1972+
b53_write16(dev, B53_VLAN_PAGE, B53_JOIN_ALL_VLAN_EN,
1973+
reg);
1974+
}
1975+
19681976
b53_get_vlan_entry(dev, pvid, vl);
19691977
vl->members &= ~BIT(port);
19701978
if (vl->members == BIT(cpu_port))
@@ -2031,16 +2039,16 @@ void b53_br_leave(struct dsa_switch *ds, int port, struct dsa_bridge bridge)
20312039
pvid = b53_default_pvid(dev);
20322040
vl = &dev->vlans[pvid];
20332041

2034-
/* Make this port join all VLANs without VLAN entries */
2035-
if (is58xx(dev)) {
2036-
b53_read16(dev, B53_VLAN_PAGE, B53_JOIN_ALL_VLAN_EN, &reg);
2037-
reg |= BIT(port);
2038-
if (!(reg & BIT(cpu_port)))
2039-
reg |= BIT(cpu_port);
2040-
b53_write16(dev, B53_VLAN_PAGE, B53_JOIN_ALL_VLAN_EN, reg);
2041-
}
2042-
20432042
if (ds->vlan_filtering) {
2043+
/* Make this port join all VLANs without VLAN entries */
2044+
if (is58xx(dev)) {
2045+
b53_read16(dev, B53_VLAN_PAGE, B53_JOIN_ALL_VLAN_EN, &reg);
2046+
reg |= BIT(port);
2047+
if (!(reg & BIT(cpu_port)))
2048+
reg |= BIT(cpu_port);
2049+
b53_write16(dev, B53_VLAN_PAGE, B53_JOIN_ALL_VLAN_EN, reg);
2050+
}
2051+
20442052
b53_get_vlan_entry(dev, pvid, vl);
20452053
vl->members |= BIT(port) | BIT(cpu_port);
20462054
vl->untag |= BIT(port) | BIT(cpu_port);

0 commit comments

Comments
 (0)