Skip to content

Commit

Permalink
Merge branch 'Simplify-DSA-handling-of-VLAN-subinterface-offload'
Browse files Browse the repository at this point in the history
Vladimir Oltean says:

====================
Simplify DSA handling of VLAN subinterface offload

Depends on Vivien Didelot's patchset:
https://patchwork.ozlabs.org/project/netdev/list/?series=127197&state=*

This patchset removes a few strange-looking guards for -EOPNOTSUPP in
dsa_slave_vlan_rx_add_vid and dsa_slave_vlan_rx_kill_vid, making that
code path no longer possible.

It also disables the code path for the sja1105 driver, which does
support editing the VLAN table, but not hardware-accelerated VLAN
sub-interfaces, therefore the check in the DSA core would be wrong.
There was no better DSA callback to do this than .port_enable, i.e.
at ndo_open time.
====================

Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
David S. Miller committed Aug 28, 2019
2 parents 1ddc5d9 + e9bf969 commit 380702e
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 9 deletions.
16 changes: 16 additions & 0 deletions drivers/net/dsa/sja1105/sja1105_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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,
Expand Down
15 changes: 6 additions & 9 deletions net/dsa/slave.c
Original file line number Diff line number Diff line change
Expand Up @@ -1131,11 +1131,11 @@ static int dsa_slave_vlan_rx_add_vid(struct net_device *dev, __be16 proto,
}

ret = dsa_port_vid_add(dp, vid, 0);
if (ret && ret != -EOPNOTSUPP)
if (ret)
return ret;

ret = dsa_port_vid_add(dp->cpu_dp, vid, 0);
if (ret && ret != -EOPNOTSUPP)
if (ret)
return ret;

return 0;
Expand Down Expand Up @@ -1164,14 +1164,10 @@ static int dsa_slave_vlan_rx_kill_vid(struct net_device *dev, __be16 proto,
return -EBUSY;
}

ret = dsa_port_vid_del(dp, vid);
if (ret == -EOPNOTSUPP)
ret = 0;

/* Do not deprogram the CPU port as it may be shared with other user
* ports which can be members of this VLAN as well.
*/
return ret;
return dsa_port_vid_del(dp, vid);
}

static const struct ethtool_ops dsa_slave_ethtool_ops = {
Expand Down Expand Up @@ -1418,8 +1414,9 @@ int dsa_slave_create(struct dsa_port *port)
if (slave_dev == NULL)
return -ENOMEM;

slave_dev->features = master->vlan_features | NETIF_F_HW_TC |
NETIF_F_HW_VLAN_CTAG_FILTER;
slave_dev->features = master->vlan_features | NETIF_F_HW_TC;
if (ds->ops->port_vlan_add && ds->ops->port_vlan_del)
slave_dev->features |= NETIF_F_HW_VLAN_CTAG_FILTER;
slave_dev->hw_features |= NETIF_F_HW_TC;
slave_dev->ethtool_ops = &dsa_slave_ethtool_ops;
if (!IS_ERR_OR_NULL(port->mac))
Expand Down

0 comments on commit 380702e

Please sign in to comment.