Skip to content

Commit 2c32a3d

Browse files
ffainellidavem330
authored andcommitted
net: dsa: b53: Do not force CPU to be always tagged
Commit ca89319 ("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 8fab459 ("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: Matthew Hagan <[email protected]> Signed-off-by: Florian Fainelli <[email protected]> Reviewed-by: Vladimir Oltean <[email protected]> Tested-by: Matthew Hagan <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 2aa8eca commit 2c32a3d

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

drivers/net/dsa/b53/b53_common.c

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1084,6 +1084,11 @@ static int b53_setup(struct dsa_switch *ds)
10841084
unsigned int port;
10851085
int ret;
10861086

1087+
/* Request bridge PVID untagged when DSA_TAG_PROTO_NONE is set
1088+
* which forces the CPU port to be tagged in all VLANs.
1089+
*/
1090+
ds->untag_bridge_pvid = dev->tag_protocol == DSA_TAG_PROTO_NONE;
1091+
10871092
ret = b53_reset_switch(dev);
10881093
if (ret) {
10891094
dev_err(ds->dev, "failed to reset switch\n");
@@ -1455,6 +1460,13 @@ static int b53_vlan_prepare(struct dsa_switch *ds, int port,
14551460
return 0;
14561461
}
14571462

1463+
static bool b53_vlan_port_needs_forced_tagged(struct dsa_switch *ds, int port)
1464+
{
1465+
struct b53_device *dev = ds->priv;
1466+
1467+
return dev->tag_protocol == DSA_TAG_PROTO_NONE && dsa_is_cpu_port(ds, port);
1468+
}
1469+
14581470
int b53_vlan_add(struct dsa_switch *ds, int port,
14591471
const struct switchdev_obj_port_vlan *vlan,
14601472
struct netlink_ext_ack *extack)
@@ -1477,7 +1489,7 @@ int b53_vlan_add(struct dsa_switch *ds, int port,
14771489
untagged = true;
14781490

14791491
vl->members |= BIT(port);
1480-
if (untagged && !dsa_is_cpu_port(ds, port))
1492+
if (untagged && !b53_vlan_port_needs_forced_tagged(ds, port))
14811493
vl->untag |= BIT(port);
14821494
else
14831495
vl->untag &= ~BIT(port);
@@ -1514,7 +1526,7 @@ int b53_vlan_del(struct dsa_switch *ds, int port,
15141526
if (pvid == vlan->vid)
15151527
pvid = b53_default_pvid(dev);
15161528

1517-
if (untagged && !dsa_is_cpu_port(ds, port))
1529+
if (untagged && !b53_vlan_port_needs_forced_tagged(ds, port))
15181530
vl->untag &= ~(BIT(port));
15191531

15201532
b53_set_vlan_entry(dev, vlan->vid, vl);
@@ -2660,7 +2672,6 @@ struct b53_device *b53_switch_alloc(struct device *base,
26602672
dev->priv = priv;
26612673
dev->ops = ops;
26622674
ds->ops = &b53_switch_ops;
2663-
ds->untag_bridge_pvid = true;
26642675
dev->vlan_enabled = true;
26652676
/* Let DSA handle the case were multiple bridges span the same switch
26662677
* device and different VLAN awareness settings are requested, which

0 commit comments

Comments
 (0)