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

net: dsa: b53: Do not force CPU to be always tagged

Commit ca893194 ("net: dsa: b53: Keep CPU port as tagged in all
VLANs") forced the CPU port to be always tagged in any VLAN membership.
This was necessary back then because we did not support Broadcom tags
for all configurations so the only way to differentiate tagged and
untagged traffic while DSA_TAG_PROTO_NONE was used was to force the CPU
port into being always tagged.

With most configurations enabling Broadcom tags, especially after
8fab459e ("net: dsa: b53: Enable Broadcom tags for 531x5/539x
families") we do not need to apply this unconditional force tagging of
the CPU port in all VLANs.

A helper function is introduced to faciliate the encapsulation of the
specific condition requiring the CPU port to be tagged in all VLANs and
the dsa_switch_ops::untag_bridge_pvid boolean is moved to when
dsa_switch_ops::setup is called when we have already determined the
tagging protocol we will be using.
Reported-by: default avatarMatthew Hagan <mnhagan88@gmail.com>
Signed-off-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
Reviewed-by: default avatarVladimir Oltean <olteanv@gmail.com>
Tested-by: default avatarMatthew Hagan <mnhagan88@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 2aa8eca6
...@@ -1084,6 +1084,11 @@ static int b53_setup(struct dsa_switch *ds) ...@@ -1084,6 +1084,11 @@ static int b53_setup(struct dsa_switch *ds)
unsigned int port; unsigned int port;
int ret; int ret;
/* Request bridge PVID untagged when DSA_TAG_PROTO_NONE is set
* which forces the CPU port to be tagged in all VLANs.
*/
ds->untag_bridge_pvid = dev->tag_protocol == DSA_TAG_PROTO_NONE;
ret = b53_reset_switch(dev); ret = b53_reset_switch(dev);
if (ret) { if (ret) {
dev_err(ds->dev, "failed to reset switch\n"); dev_err(ds->dev, "failed to reset switch\n");
...@@ -1455,6 +1460,13 @@ static int b53_vlan_prepare(struct dsa_switch *ds, int port, ...@@ -1455,6 +1460,13 @@ static int b53_vlan_prepare(struct dsa_switch *ds, int port,
return 0; return 0;
} }
static bool b53_vlan_port_needs_forced_tagged(struct dsa_switch *ds, int port)
{
struct b53_device *dev = ds->priv;
return dev->tag_protocol == DSA_TAG_PROTO_NONE && dsa_is_cpu_port(ds, port);
}
int b53_vlan_add(struct dsa_switch *ds, int port, int b53_vlan_add(struct dsa_switch *ds, int port,
const struct switchdev_obj_port_vlan *vlan, const struct switchdev_obj_port_vlan *vlan,
struct netlink_ext_ack *extack) struct netlink_ext_ack *extack)
...@@ -1477,7 +1489,7 @@ int b53_vlan_add(struct dsa_switch *ds, int port, ...@@ -1477,7 +1489,7 @@ int b53_vlan_add(struct dsa_switch *ds, int port,
untagged = true; untagged = true;
vl->members |= BIT(port); vl->members |= BIT(port);
if (untagged && !dsa_is_cpu_port(ds, port)) if (untagged && !b53_vlan_port_needs_forced_tagged(ds, port))
vl->untag |= BIT(port); vl->untag |= BIT(port);
else else
vl->untag &= ~BIT(port); vl->untag &= ~BIT(port);
...@@ -1514,7 +1526,7 @@ int b53_vlan_del(struct dsa_switch *ds, int port, ...@@ -1514,7 +1526,7 @@ int b53_vlan_del(struct dsa_switch *ds, int port,
if (pvid == vlan->vid) if (pvid == vlan->vid)
pvid = b53_default_pvid(dev); pvid = b53_default_pvid(dev);
if (untagged && !dsa_is_cpu_port(ds, port)) if (untagged && !b53_vlan_port_needs_forced_tagged(ds, port))
vl->untag &= ~(BIT(port)); vl->untag &= ~(BIT(port));
b53_set_vlan_entry(dev, vlan->vid, vl); b53_set_vlan_entry(dev, vlan->vid, vl);
...@@ -2660,7 +2672,6 @@ struct b53_device *b53_switch_alloc(struct device *base, ...@@ -2660,7 +2672,6 @@ struct b53_device *b53_switch_alloc(struct device *base,
dev->priv = priv; dev->priv = priv;
dev->ops = ops; dev->ops = ops;
ds->ops = &b53_switch_ops; ds->ops = &b53_switch_ops;
ds->untag_bridge_pvid = true;
dev->vlan_enabled = true; dev->vlan_enabled = true;
/* Let DSA handle the case were multiple bridges span the same switch /* Let DSA handle the case were multiple bridges span the same switch
* device and different VLAN awareness settings are requested, which * device and different VLAN awareness settings are requested, which
......
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