net: dsa: sja1105: Clear VLAN filtering offload netdev feature
authorVladimir Oltean <olteanv@gmail.com>
Sun, 25 Aug 2019 19:46:30 +0000 (22:46 +0300)
committerDavid S. Miller <davem@davemloft.net>
Wed, 28 Aug 2019 03:46:26 +0000 (20:46 -0700)
The switch barely supports traffic I/O, and it does that by repurposing
VLANs when there is no bridge that is taking control of them.

Letting DSA declare this netdev feature as supported (see
dsa_slave_create) would mean that VLAN sub-interfaces created on sja1105
switch ports will be hardware offloaded. That means that
net/8021q/vlan_core.c would install the VLAN into the filter tables of
the switch, potentially interfering with the tag_8021q VLANs.

We need to prevent that from happening and not let the 8021q core
offload VLANs to the switch hardware tables. In vlan_filtering=0 modes
of operation, the switch ports can pass through VLAN-tagged frames with
no problem.

Suggested-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: Vladimir Oltean <olteanv@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/dsa/sja1105/sja1105_main.c

index df976b259e43d24dc226d1e347c6338412868fe6..d8cff0107ec425d42c3bd4cc2fb44b602acb988e 100644 (file)
@@ -1728,6 +1728,21 @@ static void sja1105_teardown(struct dsa_switch *ds)
        sja1105_static_config_free(&priv->static_config);
 }
 
+static int sja1105_port_enable(struct dsa_switch *ds, int port,
+                              struct phy_device *phy)
+{
+       struct net_device *slave;
+
+       if (!dsa_is_user_port(ds, port))
+               return 0;
+
+       slave = ds->ports[port].slave;
+
+       slave->features &= ~NETIF_F_HW_VLAN_CTAG_FILTER;
+
+       return 0;
+}
+
 static int sja1105_mgmt_xmit(struct dsa_switch *ds, int port, int slot,
                             struct sk_buff *skb, bool takets)
 {
@@ -2049,6 +2064,7 @@ static const struct dsa_switch_ops sja1105_switch_ops = {
        .get_ethtool_stats      = sja1105_get_ethtool_stats,
        .get_sset_count         = sja1105_get_sset_count,
        .get_ts_info            = sja1105_get_ts_info,
+       .port_enable            = sja1105_port_enable,
        .port_fdb_dump          = sja1105_fdb_dump,
        .port_fdb_add           = sja1105_fdb_add,
        .port_fdb_del           = sja1105_fdb_del,