net: dsa: set configure_vlan_while_not_filtering to true by default
authorVladimir Oltean <olteanv@gmail.com>
Fri, 15 Jan 2021 23:19:19 +0000 (01:19 +0200)
committerJakub Kicinski <kuba@kernel.org>
Sat, 16 Jan 2021 01:29:40 +0000 (17:29 -0800)
As explained in commit 54a0ed0df496 ("net: dsa: provide an option for
drivers to always receive bridge VLANs"), DSA has historically been
skipping VLAN switchdev operations when the bridge wasn't in
vlan_filtering mode, but the reason why it was doing that has never been
clear. So the configure_vlan_while_not_filtering option is there merely
to preserve functionality for existing drivers. It isn't some behavior
that drivers should opt into. Ideally, when all drivers leave this flag
set, we can delete the dsa_port_skip_vlan_configuration() function.

New drivers always seem to omit setting this flag, for some reason. So
let's reverse the logic: the DSA core sets it by default to true before
the .setup() callback, and legacy drivers can turn it off. This way, new
drivers get the new behavior by default, unless they explicitly set the
flag to false, which is more obvious during review.

Remove the assignment from drivers which were setting it to true, and
add the assignment to false for the drivers that didn't previously have
it. This way, it should be easier to see how many we have left.

The following drivers: lan9303, mv88e6060 were skipped from setting this
flag to false, because they didn't have any VLAN offload ops in the
first place.

The Broadcom Starfighter 2 driver calls the common b53_switch_alloc and
therefore also inherits the configure_vlan_while_not_filtering=true
behavior.

Also, print a message through netlink extack every time a VLAN has been
skipped. This is mildly annoying on purpose, so that (a) it is at least
clear that VLANs are being skipped - the legacy behavior in itself is
confusing, and the extack should be much more difficult to miss, unlike
kernel logs - and (b) people have one more incentive to convert to the
new behavior.

No behavior change except for the added prints is intended at this time.

$ ip link add br0 type bridge vlan_filtering 0
$ ip link set sw0p2 master br0
[   60.315148] br0: port 1(sw0p2) entered blocking state
[   60.320350] br0: port 1(sw0p2) entered disabled state
[   60.327839] device sw0p2 entered promiscuous mode
[   60.334905] br0: port 1(sw0p2) entered blocking state
[   60.340142] br0: port 1(sw0p2) entered forwarding state
Warning: dsa_core: skipping configuration of VLAN. # This was the pvid
$ bridge vlan add dev sw0p2 vid 100
Warning: dsa_core: skipping configuration of VLAN.

Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Reviewed-by: Kurt Kanzenbach <kurt@linutronix.de>
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Link: https://lore.kernel.org/r/20210115231919.43834-1-vladimir.oltean@nxp.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
15 files changed:
drivers/net/dsa/b53/b53_common.c
drivers/net/dsa/dsa_loop.c
drivers/net/dsa/hirschmann/hellcreek.c
drivers/net/dsa/lantiq_gswip.c
drivers/net/dsa/microchip/ksz8795.c
drivers/net/dsa/microchip/ksz9477.c
drivers/net/dsa/mt7530.c
drivers/net/dsa/mv88e6xxx/chip.c
drivers/net/dsa/ocelot/felix.c
drivers/net/dsa/qca/ar9331.c
drivers/net/dsa/qca8k.c
drivers/net/dsa/rtl8366rb.c
drivers/net/dsa/sja1105/sja1105_main.c
net/dsa/dsa2.c
net/dsa/slave.c

index 5d6d9f91d40af4e8ad014cea008108c1a22f94a3..a238ded354c22522bd10ed0b833cf7e6d7e15016 100644 (file)
@@ -2602,9 +2602,8 @@ struct b53_device *b53_switch_alloc(struct device *base,
        dev->priv = priv;
        dev->ops = ops;
        ds->ops = &b53_switch_ops;
-       ds->configure_vlan_while_not_filtering = true;
        ds->untag_bridge_pvid = true;
-       dev->vlan_enabled = ds->configure_vlan_while_not_filtering;
+       dev->vlan_enabled = true;
        mutex_init(&dev->reg_mutex);
        mutex_init(&dev->stats_mutex);
 
index be61ce93a3778a6da696c012dd1fa69938f0f829..5f69216376fe23260b285d3337cb24efe57f9412 100644 (file)
@@ -323,7 +323,6 @@ static int dsa_loop_drv_probe(struct mdio_device *mdiodev)
        ds->dev = &mdiodev->dev;
        ds->ops = &dsa_loop_driver;
        ds->priv = ps;
-       ds->configure_vlan_while_not_filtering = true;
        ps->bus = mdiodev->bus;
 
        dev_set_drvdata(&mdiodev->dev, ds);
index 205249504289dbff9d0a52b80f7eee831d80794f..9a1921e653e86fb2164bf9c98f7e17b0b16051b5 100644 (file)
@@ -1033,11 +1033,6 @@ static int hellcreek_setup(struct dsa_switch *ds)
        /* Configure PCP <-> TC mapping */
        hellcreek_setup_tc_identity_mapping(hellcreek);
 
-       /* Allow VLAN configurations while not filtering which is the default
-        * for new DSA drivers.
-        */
-       ds->configure_vlan_while_not_filtering = true;
-
        /* The VLAN awareness is a global switch setting. Therefore, mixed vlan
         * filtering setups are not supported.
         */
index 244729ee3bdbd5f13723f31113f282fd058de961..9fec97773a156ecd688cb7f068d028641e7ffed6 100644 (file)
@@ -827,6 +827,9 @@ static int gswip_setup(struct dsa_switch *ds)
        }
 
        gswip_port_enable(ds, cpu_port, NULL);
+
+       ds->configure_vlan_while_not_filtering = false;
+
        return 0;
 }
 
index d639f9476bd93329faaaec14806b0e5937362d2a..37a73421e2cc914f8304286a9deda84ada090ebd 100644 (file)
@@ -1094,6 +1094,8 @@ static int ksz8795_setup(struct dsa_switch *ds)
 
        ksz_init_mib_timer(dev);
 
+       ds->configure_vlan_while_not_filtering = false;
+
        return 0;
 }
 
index 71cf24f20252a7c16335edfd6460453601b9f44c..00e38c8e0d010d864b7f1ce55c1e4aa5502f5d48 100644 (file)
@@ -1381,6 +1381,8 @@ static int ksz9477_setup(struct dsa_switch *ds)
 
        ksz_init_mib_timer(dev);
 
+       ds->configure_vlan_while_not_filtering = false;
+
        return 0;
 }
 
index 199a135125b238ec3fafe04d01d432d9dc6d9aa1..d2196197d920a681c2f5dd5312a5da252c777fab 100644 (file)
@@ -1639,7 +1639,6 @@ mt7530_setup(struct dsa_switch *ds)
         * as two netdev instances.
         */
        dn = dsa_to_port(ds, MT7530_CPU_PORT)->master->dev.of_node->parent;
-       ds->configure_vlan_while_not_filtering = true;
        ds->mtu_enforcement_ingress = true;
 
        if (priv->id == ID_MT7530) {
@@ -1878,7 +1877,6 @@ mt7531_setup(struct dsa_switch *ds)
                           PVC_EG_TAG(MT7530_VLAN_EG_CONSISTENT));
        }
 
-       ds->configure_vlan_while_not_filtering = true;
        ds->mtu_enforcement_ingress = true;
 
        /* Flush the FDB table */
index 91286d7b12c75b0c065d2811021b16cbc5d0907a..2f976050a0d71d781c095aaaf683385107c36266 100644 (file)
@@ -2875,7 +2875,6 @@ static int mv88e6xxx_setup(struct dsa_switch *ds)
 
        chip->ds = ds;
        ds->slave_mii_bus = mv88e6xxx_default_mdio_bus(chip);
-       ds->configure_vlan_while_not_filtering = true;
 
        mv88e6xxx_reg_lock(chip);
 
index 768a74dc462afbd5e433974552a07b10b4bf1097..8492151f8133416d6ab7d4f6c60ae145d61d611c 100644 (file)
@@ -599,7 +599,6 @@ static int felix_setup(struct dsa_switch *ds)
                         ANA_PGID_PGID, PGID_UC);
 
        ds->mtu_enforcement_ingress = true;
-       ds->configure_vlan_while_not_filtering = true;
        ds->assisted_learning_on_cpu_port = true;
 
        return 0;
index 1e3706054ae1fc4f3a8e69b2414a0fc484aab558..ca2ad77b71f1c6177b8f342229177e04557288a9 100644 (file)
@@ -402,6 +402,8 @@ static int ar9331_sw_setup(struct dsa_switch *ds)
        if (ret)
                goto error;
 
+       ds->configure_vlan_while_not_filtering = false;
+
        return 0;
 error:
        dev_err_ratelimited(priv->dev, "%s: %i\n", __func__, ret);
index f54e8b6c86215ea7008f79e79c01db4d2233333c..6127823d6c2e440dd6b1c7167250ea97f4c92b71 100644 (file)
@@ -1431,7 +1431,6 @@ qca8k_sw_probe(struct mdio_device *mdiodev)
 
        priv->ds->dev = &mdiodev->dev;
        priv->ds->num_ports = QCA8K_NUM_PORTS;
-       priv->ds->configure_vlan_while_not_filtering = true;
        priv->ds->priv = priv;
        priv->ops = qca8k_switch_ops;
        priv->ds->ops = &priv->ops;
index 8969785687167e883cb1fe0b58f034655f04bea2..c6cc4938897cea0667ef4d6f4bf2b20f521c5446 100644 (file)
@@ -972,6 +972,8 @@ static int rtl8366rb_setup(struct dsa_switch *ds)
                return -ENODEV;
        }
 
+       ds->configure_vlan_while_not_filtering = false;
+
        return 0;
 }
 
index 050b1260f358b21971e93c8cf779b23969026053..282253543f3b8675913781c44b989484a873308b 100644 (file)
@@ -2901,8 +2901,6 @@ static int sja1105_setup(struct dsa_switch *ds)
 
        ds->mtu_enforcement_ingress = true;
 
-       ds->configure_vlan_while_not_filtering = true;
-
        rc = sja1105_devlink_setup(ds);
        if (rc < 0)
                return rc;
index 6f65ea0eef9f195929cd847ebdba10cf3e78b10f..f98eb521c2ec1580c469af22fa30b51416645b69 100644 (file)
@@ -511,6 +511,8 @@ static int dsa_switch_setup(struct dsa_switch *ds)
        if (err)
                goto unregister_devlink_ports;
 
+       ds->configure_vlan_while_not_filtering = true;
+
        err = ds->ops->setup(ds);
        if (err < 0)
                goto unregister_notifier;
index c5c81cba8259d14110ebd57e28eaf5db964913d0..f2fb433f3828480395b6c9e74f4ba208d3faf816 100644 (file)
@@ -326,7 +326,8 @@ dsa_slave_vlan_check_for_8021q_uppers(struct net_device *slave,
 }
 
 static int dsa_slave_vlan_add(struct net_device *dev,
-                             const struct switchdev_obj *obj)
+                             const struct switchdev_obj *obj,
+                             struct netlink_ext_ack *extack)
 {
        struct net_device *master = dsa_slave_to_master(dev);
        struct dsa_port *dp = dsa_slave_to_port(dev);
@@ -336,8 +337,10 @@ static int dsa_slave_vlan_add(struct net_device *dev,
        if (!dsa_port_offloads_netdev(dp, obj->orig_dev))
                return -EOPNOTSUPP;
 
-       if (dsa_port_skip_vlan_configuration(dp))
+       if (dsa_port_skip_vlan_configuration(dp)) {
+               NL_SET_ERR_MSG_MOD(extack, "skipping configuration of VLAN");
                return 0;
+       }
 
        vlan = *SWITCHDEV_OBJ_PORT_VLAN(obj);
 
@@ -389,7 +392,7 @@ static int dsa_slave_port_obj_add(struct net_device *dev,
                err = dsa_port_mdb_add(dp->cpu_dp, SWITCHDEV_OBJ_PORT_MDB(obj));
                break;
        case SWITCHDEV_OBJ_ID_PORT_VLAN:
-               err = dsa_slave_vlan_add(dev, obj);
+               err = dsa_slave_vlan_add(dev, obj, extack);
                break;
        default:
                err = -EOPNOTSUPP;