Commit f1d5aa46638effd121eeccf5fbffc65c55df9403

Authored by Mugunthan V N
Committed by Greg Kroah-Hartman
1 parent ba31c58d46

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

commit 02a54164c52ed6eca3089a0d402170fbf34d6cf5 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: d9ba8f9e6298 (driver: net: ethernet: cpsw: dual emac interface implementation)
Reported-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Mugunthan V N <mugunthanvnm@ti.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Showing 1 changed file with 22 additions and 0 deletions Side-by-side Diff

drivers/net/ethernet/ti/cpsw.c
... ... @@ -1676,6 +1676,19 @@
1676 1676 if (vid == priv->data.default_vlan)
1677 1677 return 0;
1678 1678  
  1679 + if (priv->data.dual_emac) {
  1680 + /* In dual EMAC, reserved VLAN id should not be used for
  1681 + * creating VLAN interfaces as this can break the dual
  1682 + * EMAC port separation
  1683 + */
  1684 + int i;
  1685 +
  1686 + for (i = 0; i < priv->data.slaves; i++) {
  1687 + if (vid == priv->slaves[i].port_vlan)
  1688 + return -EINVAL;
  1689 + }
  1690 + }
  1691 +
1679 1692 dev_info(priv->dev, "Adding vlanid %d to vlan filter\n", vid);
1680 1693 return cpsw_add_vlan_ale_entry(priv, vid);
1681 1694 }
... ... @@ -1688,6 +1701,15 @@
1688 1701  
1689 1702 if (vid == priv->data.default_vlan)
1690 1703 return 0;
  1704 +
  1705 + if (priv->data.dual_emac) {
  1706 + int i;
  1707 +
  1708 + for (i = 0; i < priv->data.slaves; i++) {
  1709 + if (vid == priv->slaves[i].port_vlan)
  1710 + return -EINVAL;
  1711 + }
  1712 + }
1691 1713  
1692 1714 dev_info(priv->dev, "removing vlanid %d from vlan filter\n", vid);
1693 1715 ret = cpsw_ale_del_vlan(priv->ale, vid, 0);