2a8def39b8ccc91f8b5acc13a6fcd8fcec971b8c
[openwrt/staging/blogic.git] /
1 From 2c32a3d3c233b855943677609fe388f82b1f0975 Mon Sep 17 00:00:00 2001
2 From: Florian Fainelli <f.fainelli@gmail.com>
3 Date: Tue, 8 Jun 2021 14:22:04 -0700
4 Subject: [PATCH] net: dsa: b53: Do not force CPU to be always tagged
5
6 Commit ca8931948344 ("net: dsa: b53: Keep CPU port as tagged in all
7 VLANs") forced the CPU port to be always tagged in any VLAN membership.
8 This was necessary back then because we did not support Broadcom tags
9 for all configurations so the only way to differentiate tagged and
10 untagged traffic while DSA_TAG_PROTO_NONE was used was to force the CPU
11 port into being always tagged.
12
13 With most configurations enabling Broadcom tags, especially after
14 8fab459e69ab ("net: dsa: b53: Enable Broadcom tags for 531x5/539x
15 families") we do not need to apply this unconditional force tagging of
16 the CPU port in all VLANs.
17
18 A helper function is introduced to faciliate the encapsulation of the
19 specific condition requiring the CPU port to be tagged in all VLANs and
20 the dsa_switch_ops::untag_bridge_pvid boolean is moved to when
21 dsa_switch_ops::setup is called when we have already determined the
22 tagging protocol we will be using.
23
24 Reported-by: Matthew Hagan <mnhagan88@gmail.com>
25 Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
26 Reviewed-by: Vladimir Oltean <olteanv@gmail.com>
27 Tested-by: Matthew Hagan <mnhagan88@gmail.com>
28 Signed-off-by: David S. Miller <davem@davemloft.net>
29 ---
30 drivers/net/dsa/b53/b53_common.c | 17 ++++++++++++++---
31 1 file changed, 14 insertions(+), 3 deletions(-)
32
33 --- a/drivers/net/dsa/b53/b53_common.c
34 +++ b/drivers/net/dsa/b53/b53_common.c
35 @@ -1049,6 +1049,11 @@ static int b53_setup(struct dsa_switch *
36 unsigned int port;
37 int ret;
38
39 + /* Request bridge PVID untagged when DSA_TAG_PROTO_NONE is set
40 + * which forces the CPU port to be tagged in all VLANs.
41 + */
42 + ds->untag_bridge_pvid = dev->tag_protocol == DSA_TAG_PROTO_NONE;
43 +
44 ret = b53_reset_switch(dev);
45 if (ret) {
46 dev_err(ds->dev, "failed to reset switch\n");
47 @@ -1423,6 +1428,13 @@ int b53_vlan_prepare(struct dsa_switch *
48 return 0;
49 }
50 EXPORT_SYMBOL(b53_vlan_prepare);
51 +
52 +static bool b53_vlan_port_needs_forced_tagged(struct dsa_switch *ds, int port)
53 +{
54 + struct b53_device *dev = ds->priv;
55 +
56 + return dev->tag_protocol == DSA_TAG_PROTO_NONE && dsa_is_cpu_port(ds, port);
57 +}
58
59 void b53_vlan_add(struct dsa_switch *ds, int port,
60 const struct switchdev_obj_port_vlan *vlan)
61 @@ -1442,7 +1454,7 @@ void b53_vlan_add(struct dsa_switch *ds,
62 untagged = true;
63
64 vl->members |= BIT(port);
65 - if (untagged && !dsa_is_cpu_port(ds, port))
66 + if (untagged && !b53_vlan_port_needs_forced_tagged(ds, port))
67 vl->untag |= BIT(port);
68 else
69 vl->untag &= ~BIT(port);
70 @@ -1480,7 +1492,7 @@ int b53_vlan_del(struct dsa_switch *ds,
71 if (pvid == vid)
72 pvid = b53_default_pvid(dev);
73
74 - if (untagged && !dsa_is_cpu_port(ds, port))
75 + if (untagged && !b53_vlan_port_needs_forced_tagged(ds, port))
76 vl->untag &= ~(BIT(port));
77
78 b53_set_vlan_entry(dev, vid, vl);
79 @@ -2644,7 +2656,6 @@ struct b53_device *b53_switch_alloc(stru
80 dev->ops = ops;
81 ds->ops = &b53_switch_ops;
82 ds->configure_vlan_while_not_filtering = true;
83 - ds->untag_bridge_pvid = true;
84 dev->vlan_enabled = ds->configure_vlan_while_not_filtering;
85 /* Let DSA handle the case were multiple bridges span the same switch
86 * device and different VLAN awareness settings are requested, which