Commit fea83353 authored by Florian Fainelli's avatar Florian Fainelli Committed by David S. Miller

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: 967dd82f ("net: dsa: b53: Add support for Broadcom RoboSwitch")
Signed-off-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent d5be7f63
...@@ -632,15 +632,25 @@ static void b53_enable_mib(struct b53_device *dev) ...@@ -632,15 +632,25 @@ static void b53_enable_mib(struct b53_device *dev)
b53_write8(dev, B53_MGMT_PAGE, B53_GLOBAL_CONFIG, gc); b53_write8(dev, B53_MGMT_PAGE, B53_GLOBAL_CONFIG, gc);
} }
static u16 b53_default_pvid(struct b53_device *dev)
{
if (is5325(dev) || is5365(dev))
return 1;
else
return 0;
}
int b53_configure_vlan(struct dsa_switch *ds) int b53_configure_vlan(struct dsa_switch *ds)
{ {
struct b53_device *dev = ds->priv; struct b53_device *dev = ds->priv;
struct b53_vlan vl = { 0 }; struct b53_vlan vl = { 0 };
int i; int i, def_vid;
def_vid = b53_default_pvid(dev);
/* clear all vlan entries */ /* clear all vlan entries */
if (is5325(dev) || is5365(dev)) { if (is5325(dev) || is5365(dev)) {
for (i = 1; i < dev->num_vlans; i++) for (i = def_vid; i < dev->num_vlans; i++)
b53_set_vlan_entry(dev, i, &vl); b53_set_vlan_entry(dev, i, &vl);
} else { } else {
b53_do_vlan_op(dev, VTA_CMD_CLEAR); b53_do_vlan_op(dev, VTA_CMD_CLEAR);
...@@ -650,7 +660,7 @@ int b53_configure_vlan(struct dsa_switch *ds) ...@@ -650,7 +660,7 @@ int b53_configure_vlan(struct dsa_switch *ds)
b53_for_each_port(dev, i) b53_for_each_port(dev, i)
b53_write16(dev, B53_VLAN_PAGE, b53_write16(dev, B53_VLAN_PAGE,
B53_VLAN_PORT_DEF_TAG(i), 1); B53_VLAN_PORT_DEF_TAG(i), def_vid);
if (!is5325(dev) && !is5365(dev)) if (!is5325(dev) && !is5365(dev))
b53_set_jumbo(dev, dev->enable_jumbo, false); b53_set_jumbo(dev, dev->enable_jumbo, false);
...@@ -1326,12 +1336,8 @@ int b53_vlan_del(struct dsa_switch *ds, int port, ...@@ -1326,12 +1336,8 @@ int b53_vlan_del(struct dsa_switch *ds, int port,
vl->members &= ~BIT(port); vl->members &= ~BIT(port);
if (pvid == vid) { if (pvid == vid)
if (is5325(dev) || is5365(dev)) pvid = b53_default_pvid(dev);
pvid = 1;
else
pvid = 0;
}
if (untagged && !dsa_is_cpu_port(ds, port)) if (untagged && !dsa_is_cpu_port(ds, port))
vl->untag &= ~(BIT(port)); vl->untag &= ~(BIT(port));
...@@ -1644,10 +1650,7 @@ void b53_br_leave(struct dsa_switch *ds, int port, struct net_device *br) ...@@ -1644,10 +1650,7 @@ void b53_br_leave(struct dsa_switch *ds, int port, struct net_device *br)
b53_write16(dev, B53_PVLAN_PAGE, B53_PVLAN_PORT_MASK(port), pvlan); b53_write16(dev, B53_PVLAN_PAGE, B53_PVLAN_PORT_MASK(port), pvlan);
dev->ports[port].vlan_ctl_mask = pvlan; dev->ports[port].vlan_ctl_mask = pvlan;
if (is5325(dev) || is5365(dev)) pvid = b53_default_pvid(dev);
pvid = 1;
else
pvid = 0;
/* Make this port join all VLANs without VLAN entries */ /* Make this port join all VLANs without VLAN entries */
if (is58xx(dev)) { if (is58xx(dev)) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment