aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFlorian Fainelli <f.fainelli@gmail.com>2016-11-15 18:58:15 -0500
committerDavid S. Miller <davem@davemloft.net>2016-11-16 23:25:29 -0500
commite47112d9d6009bf6b7438cedc0270316d6b0370d (patch)
tree6c27ac2fc19a99b149bf12391ce250f75c4eae99
parent955e16026d08a601d02b961d13b6db9d6c13c8c9 (diff)
net: dsa: b53: Fix VLAN usage and how we treat CPU port
We currently have a fundamental problem in how we treat the CPU port and its VLAN membership. As soon as a second VLAN is configured to be untagged, the CPU automatically becomes untagged for that VLAN as well, and yet, we don't gracefully make sure that the CPU becomes tagged in the other VLANs it could be a member of. This results in only one VLAN being effectively usable from the CPU's perspective. Instead of having some pretty complex logic which tries to maintain the CPU port's default VLAN and its untagged properties, just do something very simple which consists in neither altering the CPU port's PVID settings, nor its untagged settings: - whenever a VLAN is added, the CPU is automatically a member of this VLAN group, as a tagged member - PVID settings for downstream ports do not alter the CPU port's PVID since it now is part of all VLANs in the system This means that a typical example where e.g: LAN ports are in VLAN1, and WAN port is in VLAN2, now require having two VLAN interfaces for the host to properly terminate and send traffic from/to. Fixes: Fixes: a2482d2ce349 ("net: dsa: b53: Plug in VLAN support") Reported-by: Hartmut Knaack <knaack.h@gmx.de> Signed-off-by: Florian Fainelli <f.fainelli@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--drivers/net/dsa/b53/b53_common.c16
1 files changed, 4 insertions, 12 deletions
diff --git a/drivers/net/dsa/b53/b53_common.c b/drivers/net/dsa/b53/b53_common.c
index 7717b19dc806..947adda3397d 100644
--- a/drivers/net/dsa/b53/b53_common.c
+++ b/drivers/net/dsa/b53/b53_common.c
@@ -962,9 +962,10 @@ static void b53_vlan_add(struct dsa_switch *ds, int port,
962 962
963 vl->members |= BIT(port) | BIT(cpu_port); 963 vl->members |= BIT(port) | BIT(cpu_port);
964 if (untagged) 964 if (untagged)
965 vl->untag |= BIT(port) | BIT(cpu_port); 965 vl->untag |= BIT(port);
966 else 966 else
967 vl->untag &= ~(BIT(port) | BIT(cpu_port)); 967 vl->untag &= ~BIT(port);
968 vl->untag &= ~BIT(cpu_port);
968 969
969 b53_set_vlan_entry(dev, vid, vl); 970 b53_set_vlan_entry(dev, vid, vl);
970 b53_fast_age_vlan(dev, vid); 971 b53_fast_age_vlan(dev, vid);
@@ -973,8 +974,6 @@ static void b53_vlan_add(struct dsa_switch *ds, int port,
973 if (pvid) { 974 if (pvid) {
974 b53_write16(dev, B53_VLAN_PAGE, B53_VLAN_PORT_DEF_TAG(port), 975 b53_write16(dev, B53_VLAN_PAGE, B53_VLAN_PORT_DEF_TAG(port),
975 vlan->vid_end); 976 vlan->vid_end);
976 b53_write16(dev, B53_VLAN_PAGE, B53_VLAN_PORT_DEF_TAG(cpu_port),
977 vlan->vid_end);
978 b53_fast_age_vlan(dev, vid); 977 b53_fast_age_vlan(dev, vid);
979 } 978 }
980} 979}
@@ -984,7 +983,6 @@ static int b53_vlan_del(struct dsa_switch *ds, int port,
984{ 983{
985 struct b53_device *dev = ds->priv; 984 struct b53_device *dev = ds->priv;
986 bool untagged = vlan->flags & BRIDGE_VLAN_INFO_UNTAGGED; 985 bool untagged = vlan->flags & BRIDGE_VLAN_INFO_UNTAGGED;
987 unsigned int cpu_port = dev->cpu_port;
988 struct b53_vlan *vl; 986 struct b53_vlan *vl;
989 u16 vid; 987 u16 vid;
990 u16 pvid; 988 u16 pvid;
@@ -997,8 +995,6 @@ static int b53_vlan_del(struct dsa_switch *ds, int port,
997 b53_get_vlan_entry(dev, vid, vl); 995 b53_get_vlan_entry(dev, vid, vl);
998 996
999 vl->members &= ~BIT(port); 997 vl->members &= ~BIT(port);
1000 if ((vl->members & BIT(cpu_port)) == BIT(cpu_port))
1001 vl->members = 0;
1002 998
1003 if (pvid == vid) { 999 if (pvid == vid) {
1004 if (is5325(dev) || is5365(dev)) 1000 if (is5325(dev) || is5365(dev))
@@ -1007,18 +1003,14 @@ static int b53_vlan_del(struct dsa_switch *ds, int port,
1007 pvid = 0; 1003 pvid = 0;
1008 } 1004 }
1009 1005
1010 if (untagged) { 1006 if (untagged)
1011 vl->untag &= ~(BIT(port)); 1007 vl->untag &= ~(BIT(port));
1012 if ((vl->untag & BIT(cpu_port)) == BIT(cpu_port))
1013 vl->untag = 0;
1014 }
1015 1008
1016 b53_set_vlan_entry(dev, vid, vl); 1009 b53_set_vlan_entry(dev, vid, vl);
1017 b53_fast_age_vlan(dev, vid); 1010 b53_fast_age_vlan(dev, vid);
1018 } 1011 }
1019 1012
1020 b53_write16(dev, B53_VLAN_PAGE, B53_VLAN_PORT_DEF_TAG(port), pvid); 1013 b53_write16(dev, B53_VLAN_PAGE, B53_VLAN_PORT_DEF_TAG(port), pvid);
1021 b53_write16(dev, B53_VLAN_PAGE, B53_VLAN_PORT_DEF_TAG(cpu_port), pvid);
1022 b53_fast_age_vlan(dev, pvid); 1014 b53_fast_age_vlan(dev, pvid);
1023 1015
1024 return 0; 1016 return 0;