diff options
author | Florian Fainelli <f.fainelli@gmail.com> | 2016-08-26 15:18:32 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2016-08-26 16:15:48 -0400 |
commit | 48aea33a77ab8ec76245336ea08eeb3dda34f98a (patch) | |
tree | cb0e978ea91fe45c4835cf82aa9c17902434f8fc | |
parent | bde5d132c3fc50515e59119794945b0bda5a32bd (diff) |
net: dsa: b53: Add JOIN_ALL_VLAN support
In order to migrate the bcm_sf2 driver over to the b53 driver for most
VLAN/FDB/bridge operations, we need to add support for the "join all
VLANs" register and behavior which allows us to make a given port join
all VLANs and avoid setting specific VLAN entries when it is leaving the
bridge.
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.c | 30 | ||||
-rw-r--r-- | drivers/net/dsa/b53/b53_regs.h | 3 |
2 files changed, 29 insertions, 4 deletions
diff --git a/drivers/net/dsa/b53/b53_common.c b/drivers/net/dsa/b53/b53_common.c index ca13ee134562..1299104a87d4 100644 --- a/drivers/net/dsa/b53/b53_common.c +++ b/drivers/net/dsa/b53/b53_common.c | |||
@@ -1315,9 +1315,21 @@ static int b53_br_join(struct dsa_switch *ds, int port, | |||
1315 | struct net_device *bridge) | 1315 | struct net_device *bridge) |
1316 | { | 1316 | { |
1317 | struct b53_device *dev = ds_to_priv(ds); | 1317 | struct b53_device *dev = ds_to_priv(ds); |
1318 | s8 cpu_port = ds->dst->cpu_port; | ||
1318 | u16 pvlan, reg; | 1319 | u16 pvlan, reg; |
1319 | unsigned int i; | 1320 | unsigned int i; |
1320 | 1321 | ||
1322 | /* Make this port leave the all VLANs join since we will have proper | ||
1323 | * VLAN entries from now on | ||
1324 | */ | ||
1325 | if (is58xx(dev)) { | ||
1326 | b53_read16(dev, B53_VLAN_PAGE, B53_JOIN_ALL_VLAN_EN, ®); | ||
1327 | reg &= ~BIT(port); | ||
1328 | if ((reg & BIT(cpu_port)) == BIT(cpu_port)) | ||
1329 | reg &= ~BIT(cpu_port); | ||
1330 | b53_write16(dev, B53_VLAN_PAGE, B53_JOIN_ALL_VLAN_EN, reg); | ||
1331 | } | ||
1332 | |||
1321 | dev->ports[port].bridge_dev = bridge; | 1333 | dev->ports[port].bridge_dev = bridge; |
1322 | b53_read16(dev, B53_PVLAN_PAGE, B53_PVLAN_PORT_MASK(port), &pvlan); | 1334 | b53_read16(dev, B53_PVLAN_PAGE, B53_PVLAN_PORT_MASK(port), &pvlan); |
1323 | 1335 | ||
@@ -1350,6 +1362,7 @@ static void b53_br_leave(struct dsa_switch *ds, int port) | |||
1350 | struct b53_device *dev = ds_to_priv(ds); | 1362 | struct b53_device *dev = ds_to_priv(ds); |
1351 | struct net_device *bridge = dev->ports[port].bridge_dev; | 1363 | struct net_device *bridge = dev->ports[port].bridge_dev; |
1352 | struct b53_vlan *vl = &dev->vlans[0]; | 1364 | struct b53_vlan *vl = &dev->vlans[0]; |
1365 | s8 cpu_port = ds->dst->cpu_port; | ||
1353 | unsigned int i; | 1366 | unsigned int i; |
1354 | u16 pvlan, reg, pvid; | 1367 | u16 pvlan, reg, pvid; |
1355 | 1368 | ||
@@ -1379,10 +1392,19 @@ static void b53_br_leave(struct dsa_switch *ds, int port) | |||
1379 | else | 1392 | else |
1380 | pvid = 0; | 1393 | pvid = 0; |
1381 | 1394 | ||
1382 | b53_get_vlan_entry(dev, pvid, vl); | 1395 | /* Make this port join all VLANs without VLAN entries */ |
1383 | vl->members |= BIT(port) | BIT(dev->cpu_port); | 1396 | if (is58xx(dev)) { |
1384 | vl->untag |= BIT(port) | BIT(dev->cpu_port); | 1397 | b53_read16(dev, B53_VLAN_PAGE, B53_JOIN_ALL_VLAN_EN, ®); |
1385 | b53_set_vlan_entry(dev, pvid, vl); | 1398 | reg |= BIT(port); |
1399 | if (!(reg & BIT(cpu_port))) | ||
1400 | reg |= BIT(cpu_port); | ||
1401 | b53_write16(dev, B53_VLAN_PAGE, B53_JOIN_ALL_VLAN_EN, reg); | ||
1402 | } else { | ||
1403 | b53_get_vlan_entry(dev, pvid, vl); | ||
1404 | vl->members |= BIT(port) | BIT(dev->cpu_port); | ||
1405 | vl->untag |= BIT(port) | BIT(dev->cpu_port); | ||
1406 | b53_set_vlan_entry(dev, pvid, vl); | ||
1407 | } | ||
1386 | } | 1408 | } |
1387 | 1409 | ||
1388 | static void b53_br_set_stp_state(struct dsa_switch *ds, int port, | 1410 | static void b53_br_set_stp_state(struct dsa_switch *ds, int port, |
diff --git a/drivers/net/dsa/b53/b53_regs.h b/drivers/net/dsa/b53/b53_regs.h index a0b453ea34c9..dac0af4e2cd0 100644 --- a/drivers/net/dsa/b53/b53_regs.h +++ b/drivers/net/dsa/b53/b53_regs.h | |||
@@ -309,6 +309,9 @@ | |||
309 | /* Port VLAN mask (16 bit) IMP port is always 8, also on 5325 & co */ | 309 | /* Port VLAN mask (16 bit) IMP port is always 8, also on 5325 & co */ |
310 | #define B53_PVLAN_PORT_MASK(i) ((i) * 2) | 310 | #define B53_PVLAN_PORT_MASK(i) ((i) * 2) |
311 | 311 | ||
312 | /* Join all VLANs register (16 bit) */ | ||
313 | #define B53_JOIN_ALL_VLAN_EN 0x50 | ||
314 | |||
312 | /************************************************************************* | 315 | /************************************************************************* |
313 | * 802.1Q Page Registers | 316 | * 802.1Q Page Registers |
314 | *************************************************************************/ | 317 | *************************************************************************/ |