Commit 87b89b50 authored by Mugunthan V N's avatar Mugunthan V N Committed by Luis Henriques

drivers: net: cpsw: discard dual emac default vlan configuration

commit 02a54164 upstream.

In Dual EMAC, the default VLANs are used to segregate Rx packets between
the ports, so adding the same default VLAN to the switch will affect the
normal packet transfers. So returning error on addition of dual EMAC
default VLANs.

Even if EMAC 0 default port VLAN is added to EMAC 1, it will lead to
break dual EMAC port separations.

Fixes: d9ba8f9e (driver: net: ethernet: cpsw: dual emac interface implementation)
Reported-by: default avatarFelipe Balbi <balbi@ti.com>
Signed-off-by: default avatarMugunthan V N <mugunthanvnm@ti.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
Signed-off-by: default avatarLuis Henriques <luis.henriques@canonical.com>
parent cb923e23
...@@ -1631,6 +1631,19 @@ static int cpsw_ndo_vlan_rx_add_vid(struct net_device *ndev, ...@@ -1631,6 +1631,19 @@ static int cpsw_ndo_vlan_rx_add_vid(struct net_device *ndev,
if (vid == priv->data.default_vlan) if (vid == priv->data.default_vlan)
return 0; return 0;
if (priv->data.dual_emac) {
/* In dual EMAC, reserved VLAN id should not be used for
* creating VLAN interfaces as this can break the dual
* EMAC port separation
*/
int i;
for (i = 0; i < priv->data.slaves; i++) {
if (vid == priv->slaves[i].port_vlan)
return -EINVAL;
}
}
dev_info(priv->dev, "Adding vlanid %d to vlan filter\n", vid); dev_info(priv->dev, "Adding vlanid %d to vlan filter\n", vid);
return cpsw_add_vlan_ale_entry(priv, vid); return cpsw_add_vlan_ale_entry(priv, vid);
} }
...@@ -1644,6 +1657,15 @@ static int cpsw_ndo_vlan_rx_kill_vid(struct net_device *ndev, ...@@ -1644,6 +1657,15 @@ static int cpsw_ndo_vlan_rx_kill_vid(struct net_device *ndev,
if (vid == priv->data.default_vlan) if (vid == priv->data.default_vlan)
return 0; return 0;
if (priv->data.dual_emac) {
int i;
for (i = 0; i < priv->data.slaves; i++) {
if (vid == priv->slaves[i].port_vlan)
return -EINVAL;
}
}
dev_info(priv->dev, "removing vlanid %d from vlan filter\n", vid); dev_info(priv->dev, "removing vlanid %d from vlan filter\n", vid);
ret = cpsw_ale_del_vlan(priv->ale, vid, 0); ret = cpsw_ale_del_vlan(priv->ale, vid, 0);
if (ret != 0) if (ret != 0)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment