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
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.
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>
17 drivers/net/dsa/b53/b53_common.c | 27 +++++++++++++++++++--------
18 1 file changed, 19 insertions(+), 8 deletions(-)
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
26 +static bool b53_vlan_port_needs_forced_tagged(struct dsa_switch *ds, int port)
28 + struct b53_device *dev = ds->priv;
30 + return dev->tag_protocol == DSA_TAG_PROTO_NONE && dsa_is_cpu_port(ds, port);
33 int b53_configure_vlan(struct dsa_switch *ds)
35 struct b53_device *dev = ds->priv;
36 @@ -713,9 +720,20 @@ int b53_configure_vlan(struct dsa_switch
38 b53_enable_vlan(dev, -1, dev->vlan_enabled, ds->vlan_filtering);
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
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);
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 *
60 EXPORT_SYMBOL(b53_vlan_prepare);
62 -static bool b53_vlan_port_needs_forced_tagged(struct dsa_switch *ds, int port)
64 - struct b53_device *dev = ds->priv;
66 - return dev->tag_protocol == DSA_TAG_PROTO_NONE && dsa_is_cpu_port(ds, port);
69 void b53_vlan_add(struct dsa_switch *ds, int port,
70 const struct switchdev_obj_port_vlan *vlan)