Skip to content

Commit fea8335

Browse files
ffainellidavem330
authored andcommitted
net: dsa: b53: Fix default VLAN ID
We were not consistent in how the default VID of a given port was defined, b53_br_leave() would make sure the VLAN ID would be either 0/1 depending on the switch generation, but b53_configure_vlan(), which is the default configuration would unconditionally set it to 1. The correct value is 1 for 5325/5365 series and 0 otherwise. To avoid repeating that mistake ever again, introduce a helper function: b53_default_pvid() to factor that out. Fixes: 967dd82 ("net: dsa: b53: Add support for Broadcom RoboSwitch") Signed-off-by: Florian Fainelli <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent d5be7f6 commit fea8335

File tree

1 file changed

+16
-13
lines changed

1 file changed

+16
-13
lines changed

drivers/net/dsa/b53/b53_common.c

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -632,15 +632,25 @@ static void b53_enable_mib(struct b53_device *dev)
632632
b53_write8(dev, B53_MGMT_PAGE, B53_GLOBAL_CONFIG, gc);
633633
}
634634

635+
static u16 b53_default_pvid(struct b53_device *dev)
636+
{
637+
if (is5325(dev) || is5365(dev))
638+
return 1;
639+
else
640+
return 0;
641+
}
642+
635643
int b53_configure_vlan(struct dsa_switch *ds)
636644
{
637645
struct b53_device *dev = ds->priv;
638646
struct b53_vlan vl = { 0 };
639-
int i;
647+
int i, def_vid;
648+
649+
def_vid = b53_default_pvid(dev);
640650

641651
/* clear all vlan entries */
642652
if (is5325(dev) || is5365(dev)) {
643-
for (i = 1; i < dev->num_vlans; i++)
653+
for (i = def_vid; i < dev->num_vlans; i++)
644654
b53_set_vlan_entry(dev, i, &vl);
645655
} else {
646656
b53_do_vlan_op(dev, VTA_CMD_CLEAR);
@@ -650,7 +660,7 @@ int b53_configure_vlan(struct dsa_switch *ds)
650660

651661
b53_for_each_port(dev, i)
652662
b53_write16(dev, B53_VLAN_PAGE,
653-
B53_VLAN_PORT_DEF_TAG(i), 1);
663+
B53_VLAN_PORT_DEF_TAG(i), def_vid);
654664

655665
if (!is5325(dev) && !is5365(dev))
656666
b53_set_jumbo(dev, dev->enable_jumbo, false);
@@ -1326,12 +1336,8 @@ int b53_vlan_del(struct dsa_switch *ds, int port,
13261336

13271337
vl->members &= ~BIT(port);
13281338

1329-
if (pvid == vid) {
1330-
if (is5325(dev) || is5365(dev))
1331-
pvid = 1;
1332-
else
1333-
pvid = 0;
1334-
}
1339+
if (pvid == vid)
1340+
pvid = b53_default_pvid(dev);
13351341

13361342
if (untagged && !dsa_is_cpu_port(ds, port))
13371343
vl->untag &= ~(BIT(port));
@@ -1644,10 +1650,7 @@ void b53_br_leave(struct dsa_switch *ds, int port, struct net_device *br)
16441650
b53_write16(dev, B53_PVLAN_PAGE, B53_PVLAN_PORT_MASK(port), pvlan);
16451651
dev->ports[port].vlan_ctl_mask = pvlan;
16461652

1647-
if (is5325(dev) || is5365(dev))
1648-
pvid = 1;
1649-
else
1650-
pvid = 0;
1653+
pvid = b53_default_pvid(dev);
16511654

16521655
/* Make this port join all VLANs without VLAN entries */
16531656
if (is58xx(dev)) {

0 commit comments

Comments
 (0)