df891d68ab4fe4502ba6831261e657601adfea41
[openwrt/staging/blogic.git] /
1 From 64a81b24487f0d2fba0f033029eec2abc7d82cee Mon Sep 17 00:00:00 2001
2 From: Florian Fainelli <f.fainelli@gmail.com>
3 Date: Mon, 21 Jun 2021 15:10:55 -0700
4 Subject: [PATCH] net: dsa: b53: Create default VLAN entry explicitly
5
6 In case CONFIG_VLAN_8021Q is not set, there will be no call down to the
7 b53 driver to ensure that the default PVID VLAN entry will be configured
8 with the appropriate untagged attribute towards the CPU port. We were
9 implicitly relying on dsa_slave_vlan_rx_add_vid() to do that for us,
10 instead make it explicit.
11
12 Reported-by: Vladimir Oltean <olteanv@gmail.com>
13 Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
14 Reviewed-by: Vladimir Oltean <olteanv@gmail.com>
15 Signed-off-by: David S. Miller <davem@davemloft.net>
16 ---
17 drivers/net/dsa/b53/b53_common.c | 27 +++++++++++++++++++--------
18 1 file changed, 19 insertions(+), 8 deletions(-)
19
20 --- a/drivers/net/dsa/b53/b53_common.c
21 +++ b/drivers/net/dsa/b53/b53_common.c
22 @@ -693,6 +693,13 @@ static u16 b53_default_pvid(struct b53_d
23 return 0;
24 }
25
26 +static bool b53_vlan_port_needs_forced_tagged(struct dsa_switch *ds, int port)
27 +{
28 + struct b53_device *dev = ds->priv;
29 +
30 + return dev->tag_protocol == DSA_TAG_PROTO_NONE && dsa_is_cpu_port(ds, port);
31 +}
32 +
33 int b53_configure_vlan(struct dsa_switch *ds)
34 {
35 struct b53_device *dev = ds->priv;
36 @@ -713,9 +720,20 @@ int b53_configure_vlan(struct dsa_switch
37
38 b53_enable_vlan(dev, -1, dev->vlan_enabled, ds->vlan_filtering);
39
40 - b53_for_each_port(dev, i)
41 + /* Create an untagged VLAN entry for the default PVID in case
42 + * CONFIG_VLAN_8021Q is disabled and there are no calls to
43 + * dsa_slave_vlan_rx_add_vid() to create the default VLAN
44 + * entry. Do this only when the tagging protocol is not
45 + * DSA_TAG_PROTO_NONE
46 + */
47 + b53_for_each_port(dev, i) {
48 + v = &dev->vlans[def_vid];
49 + v->members |= BIT(i);
50 + if (!b53_vlan_port_needs_forced_tagged(ds, i))
51 + v->untag = v->members;
52 b53_write16(dev, B53_VLAN_PAGE,
53 B53_VLAN_PORT_DEF_TAG(i), def_vid);
54 + }
55
56 /* Upon initial call we have not set-up any VLANs, but upon
57 * system resume, we need to restore all VLAN entries.
58 @@ -1429,13 +1447,6 @@ int b53_vlan_prepare(struct dsa_switch *
59 }
60 EXPORT_SYMBOL(b53_vlan_prepare);
61
62 -static bool b53_vlan_port_needs_forced_tagged(struct dsa_switch *ds, int port)
63 -{
64 - struct b53_device *dev = ds->priv;
65 -
66 - return dev->tag_protocol == DSA_TAG_PROTO_NONE && dsa_is_cpu_port(ds, port);
67 -}
68 -
69 void b53_vlan_add(struct dsa_switch *ds, int port,
70 const struct switchdev_obj_port_vlan *vlan)
71 {