Skip to content

Commit 12aad64

Browse files
KanjiMonsterjfvogel
authored andcommitted
net: dsa: b53: prevent standalone from trying to forward to other ports
[ Upstream commit 4227ea91e2657f7965e34313448e9d0a2b67712e ] When bridged ports and standalone ports share a VLAN, e.g. via VLAN uppers, or untagged traffic with a vlan unaware bridge, the ASIC will still try to forward traffic to known FDB entries on standalone ports. But since the port VLAN masks prevent forwarding to bridged ports, this traffic will be dropped. This e.g. can be observed in the bridge_vlan_unaware ping tests, where this breaks pinging with learning on. Work around this by enabling the simplified EAP mode on switches supporting it for standalone ports, which causes the ASIC to redirect traffic of unknown source MAC addresses to the CPU port. Since standalone ports do not learn, there are no known source MAC addresses, so effectively this redirects all incoming traffic to the CPU port. Fixes: ff39c2d ("net: dsa: b53: Add bridge support") Signed-off-by: Jonas Gorski <[email protected]> Reviewed-by: Florian Fainelli <[email protected]> Reviewed-by: Vladimir Oltean <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Paolo Abeni <[email protected]> Signed-off-by: Sasha Levin <[email protected]> (cherry picked from commit 225e29465aa78f6b68ae8d3848cdd879a958c969) Signed-off-by: Jack Vogel <[email protected]>
1 parent 4310e94 commit 12aad64

File tree

2 files changed

+47
-0
lines changed

2 files changed

+47
-0
lines changed

drivers/net/dsa/b53/b53_common.c

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,26 @@ static void b53_get_vlan_entry(struct b53_device *dev, u16 vid,
326326
}
327327
}
328328

329+
static void b53_set_eap_mode(struct b53_device *dev, int port, int mode)
330+
{
331+
u64 eap_conf;
332+
333+
if (is5325(dev) || is5365(dev) || dev->chip_id == BCM5389_DEVICE_ID)
334+
return;
335+
336+
b53_read64(dev, B53_EAP_PAGE, B53_PORT_EAP_CONF(port), &eap_conf);
337+
338+
if (is63xx(dev)) {
339+
eap_conf &= ~EAP_MODE_MASK_63XX;
340+
eap_conf |= (u64)mode << EAP_MODE_SHIFT_63XX;
341+
} else {
342+
eap_conf &= ~EAP_MODE_MASK;
343+
eap_conf |= (u64)mode << EAP_MODE_SHIFT;
344+
}
345+
346+
b53_write64(dev, B53_EAP_PAGE, B53_PORT_EAP_CONF(port), eap_conf);
347+
}
348+
329349
static void b53_set_forwarding(struct b53_device *dev, int enable)
330350
{
331351
u8 mgmt;
@@ -586,6 +606,13 @@ int b53_setup_port(struct dsa_switch *ds, int port)
586606
b53_port_set_mcast_flood(dev, port, true);
587607
b53_port_set_learning(dev, port, false);
588608

609+
/* Force all traffic to go to the CPU port to prevent the ASIC from
610+
* trying to forward to bridged ports on matching FDB entries, then
611+
* dropping frames because it isn't allowed to forward there.
612+
*/
613+
if (dsa_is_user_port(ds, port))
614+
b53_set_eap_mode(dev, port, EAP_MODE_SIMPLIFIED);
615+
589616
return 0;
590617
}
591618
EXPORT_SYMBOL(b53_setup_port);
@@ -2043,6 +2070,9 @@ int b53_br_join(struct dsa_switch *ds, int port, struct dsa_bridge bridge,
20432070
pvlan |= BIT(i);
20442071
}
20452072

2073+
/* Disable redirection of unknown SA to the CPU port */
2074+
b53_set_eap_mode(dev, port, EAP_MODE_BASIC);
2075+
20462076
/* Configure the local port VLAN control membership to include
20472077
* remote ports and update the local port bitmask
20482078
*/
@@ -2078,6 +2108,9 @@ void b53_br_leave(struct dsa_switch *ds, int port, struct dsa_bridge bridge)
20782108
pvlan &= ~BIT(i);
20792109
}
20802110

2111+
/* Enable redirection of unknown SA to the CPU port */
2112+
b53_set_eap_mode(dev, port, EAP_MODE_SIMPLIFIED);
2113+
20812114
b53_write16(dev, B53_PVLAN_PAGE, B53_PVLAN_PORT_MASK(port), pvlan);
20822115
dev->ports[port].vlan_ctl_mask = pvlan;
20832116

drivers/net/dsa/b53/b53_regs.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@
5050
/* Jumbo Frame Registers */
5151
#define B53_JUMBO_PAGE 0x40
5252

53+
/* EAP Registers */
54+
#define B53_EAP_PAGE 0x42
55+
5356
/* EEE Control Registers Page */
5457
#define B53_EEE_PAGE 0x92
5558

@@ -480,6 +483,17 @@
480483
#define JMS_MIN_SIZE 1518
481484
#define JMS_MAX_SIZE 9724
482485

486+
/*************************************************************************
487+
* EAP Page Registers
488+
*************************************************************************/
489+
#define B53_PORT_EAP_CONF(i) (0x20 + 8 * (i))
490+
#define EAP_MODE_SHIFT 51
491+
#define EAP_MODE_SHIFT_63XX 50
492+
#define EAP_MODE_MASK (0x3ull << EAP_MODE_SHIFT)
493+
#define EAP_MODE_MASK_63XX (0x3ull << EAP_MODE_SHIFT_63XX)
494+
#define EAP_MODE_BASIC 0
495+
#define EAP_MODE_SIMPLIFIED 3
496+
483497
/*************************************************************************
484498
* EEE Configuration Page Registers
485499
*************************************************************************/

0 commit comments

Comments
 (0)