Skip to content

Commit 02a5416

Browse files
mugunthanvnmdavem330
authored andcommitted
drivers: net: cpsw: discard dual emac default vlan configuration
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: d9ba8f9 (driver: net: ethernet: cpsw: dual emac interface implementation) Cc: <[email protected]> # v3.9+ Reported-by: Felipe Balbi <[email protected]> Signed-off-by: Mugunthan V N <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent b6663ad commit 02a5416

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

drivers/net/ethernet/ti/cpsw.c

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1683,6 +1683,19 @@ static int cpsw_ndo_vlan_rx_add_vid(struct net_device *ndev,
16831683
if (vid == priv->data.default_vlan)
16841684
return 0;
16851685

1686+
if (priv->data.dual_emac) {
1687+
/* In dual EMAC, reserved VLAN id should not be used for
1688+
* creating VLAN interfaces as this can break the dual
1689+
* EMAC port separation
1690+
*/
1691+
int i;
1692+
1693+
for (i = 0; i < priv->data.slaves; i++) {
1694+
if (vid == priv->slaves[i].port_vlan)
1695+
return -EINVAL;
1696+
}
1697+
}
1698+
16861699
dev_info(priv->dev, "Adding vlanid %d to vlan filter\n", vid);
16871700
return cpsw_add_vlan_ale_entry(priv, vid);
16881701
}
@@ -1696,6 +1709,15 @@ static int cpsw_ndo_vlan_rx_kill_vid(struct net_device *ndev,
16961709
if (vid == priv->data.default_vlan)
16971710
return 0;
16981711

1712+
if (priv->data.dual_emac) {
1713+
int i;
1714+
1715+
for (i = 0; i < priv->data.slaves; i++) {
1716+
if (vid == priv->slaves[i].port_vlan)
1717+
return -EINVAL;
1718+
}
1719+
}
1720+
16991721
dev_info(priv->dev, "removing vlanid %d from vlan filter\n", vid);
17001722
ret = cpsw_ale_del_vlan(priv->ale, vid, 0);
17011723
if (ret != 0)

0 commit comments

Comments
 (0)