This patch series is a result of splitting a larger patch series [0],
where some parts was merged before.
The first patch implements port state configuration, which is required
for bridge functionality. STP frames are not forwarded at this moment.
BPDU frames are only forwarded from/to the PI/SI interface.
For more information, see chapter 2.7.1 (CPU Forwarding) in the
datasheet.
Patches 2, 7-9 and 11 provide a basic implementation of tag_8021q
functionality with QinQ support, without VLAN filtering in
the bridge and simple VLAN awareness in VLAN filtering mode.
Patches 3-6 came from Vladimir Oltean. They prepare for making
tag8021q more common. VSC73XX uses very similar tag recognition,
and some code from tag_sja1105 could be moved to tag_8021q for
common use.
Patch 10 is preparation for use tag_8021q bridge functions as generic
implementation of the 'ds->ops->port_bridge_*()'.
Patch 12 is required to avoid problem with learning on standalone ports.
[0] https://patchwork.kernel.org/project/netdevbpf/list/?series=841034&state=%2A&archive=both
Pawel Dembicki (8):
net: dsa: vsc73xx: add port_stp_state_set function
net: dsa: vsc73xx: Add vlan filtering
net: dsa: vsc73xx: introduce tag 8021q for vsc73xx
net: dsa: vsc73xx: Implement the tag_8021q VLAN operations
net: dsa: Define max num of bridges in tag8021q implementation
net: dsa: prepare 'dsa_tag_8021q_bridge_join' for standalone use
net: dsa: vsc73xx: Add bridge support
net: dsa: vsc73xx: start treating the BR_LEARNING flag
Vladimir Oltean (4):
net: dsa: tag_sja1105: absorb logic for not overwriting precise info
into dsa_8021q_rcv()
net: dsa: tag_sja1105: absorb entire sja1105_vlan_rcv() into
dsa_8021q_rcv()
net: dsa: tag_sja1105: prefer precise source port info on SJA1110 too
net: dsa: tag_sja1105: refactor skb->dev assignment to
dsa_tag_8021q_find_user()
drivers/net/dsa/Kconfig | 2 +-
drivers/net/dsa/sja1105/sja1105_main.c | 8 +-
drivers/net/dsa/vitesse-vsc73xx-core.c | 668 ++++++++++++++++++++++++-
drivers/net/dsa/vitesse-vsc73xx.h | 42 ++
include/linux/dsa/8021q.h | 8 +-
include/net/dsa.h | 2 +
net/dsa/Kconfig | 6 +
net/dsa/Makefile | 1 +
net/dsa/tag_8021q.c | 86 +++-
net/dsa/tag_8021q.h | 7 +-
net/dsa/tag_ocelot_8021q.c | 2 +-
net/dsa/tag_sja1105.c | 72 +--
net/dsa/tag_vsc73xx_8021q.c | 68 +++
13 files changed, 874 insertions(+), 98 deletions(-)
create mode 100644 net/dsa/tag_vsc73xx_8021q.c
--
2.34.1
This patch implements .port_pre_bridge_flags() and .port_bridge_flags(),
which are required for properly treating the BR_LEARNING flag. Also,
.port_stp_state_set() is tweaked and now disables learning for standalone
ports.
Disabling learning for standalone ports is required to avoid situations
where one port sees traffic originating from another, which could cause
packet drops.
Signed-off-by: Pawel Dembicki <[email protected]>
Acked-by: Linus Walleij <[email protected]>
Reviewed-by: Florian Fainelli <[email protected]>
Reviewed-by: Vladimir Oltean <[email protected]>
---
v1:
- resend only
---
Before patch series split:
https://patchwork.kernel.org/project/netdevbpf/list/?series=841034&state=%2A&archive=both
v8:
- resend only
v7:
- added 'Acked-by' and 'Reviewed-by' and improve commit message
v6:
- fix arranging local variables in reverse xmas tree order
v5:
- introduce patch
drivers/net/dsa/vitesse-vsc73xx-core.c | 41 ++++++++++++++++++++++----
1 file changed, 35 insertions(+), 6 deletions(-)
diff --git a/drivers/net/dsa/vitesse-vsc73xx-core.c b/drivers/net/dsa/vitesse-vsc73xx-core.c
index 7d5522e146f5..e15098a7b75b 100644
--- a/drivers/net/dsa/vitesse-vsc73xx-core.c
+++ b/drivers/net/dsa/vitesse-vsc73xx-core.c
@@ -1538,6 +1538,31 @@ static int vsc73xx_tag_8021q_vlan_del(struct dsa_switch *ds, int port, u16 vid)
return vsc73xx_update_vlan_table(vsc, port, vid, false);
}
+static int vsc73xx_port_pre_bridge_flags(struct dsa_switch *ds, int port,
+ struct switchdev_brport_flags flags,
+ struct netlink_ext_ack *extack)
+{
+ if (flags.mask & ~BR_LEARNING)
+ return -EINVAL;
+
+ return 0;
+}
+
+static int vsc73xx_port_bridge_flags(struct dsa_switch *ds, int port,
+ struct switchdev_brport_flags flags,
+ struct netlink_ext_ack *extack)
+{
+ if (flags.mask & BR_LEARNING) {
+ u32 val = flags.val & BR_LEARNING ? BIT(port) : 0;
+ struct vsc73xx *vsc = ds->priv;
+
+ return vsc73xx_update_bits(vsc, VSC73XX_BLOCK_ANALYZER, 0,
+ VSC73XX_LEARNMASK, BIT(port), val);
+ }
+
+ return 0;
+}
+
static int vsc73xx_port_setup(struct dsa_switch *ds, int port)
{
struct vsc73xx_portinfo *portinfo;
@@ -1616,19 +1641,21 @@ static void vsc73xx_refresh_fwd_map(struct dsa_switch *ds, int port, u8 state)
static void vsc73xx_port_stp_state_set(struct dsa_switch *ds, int port,
u8 state)
{
+ struct dsa_port *dp = dsa_to_port(ds, port);
struct vsc73xx *vsc = ds->priv;
- u32 val;
+ u32 val = 0;
+
+ if (state == BR_STATE_LEARNING || state == BR_STATE_FORWARDING)
+ val = dp->learning ? BIT(port) : 0;
+
+ vsc73xx_update_bits(vsc, VSC73XX_BLOCK_ANALYZER, 0,
+ VSC73XX_LEARNMASK, BIT(port), val);
val = (state == BR_STATE_BLOCKING || state == BR_STATE_DISABLED) ?
0 : BIT(port);
vsc73xx_update_bits(vsc, VSC73XX_BLOCK_ANALYZER, 0,
VSC73XX_RECVMASK, BIT(port), val);
- val = (state == BR_STATE_LEARNING || state == BR_STATE_FORWARDING) ?
- BIT(port) : 0;
- vsc73xx_update_bits(vsc, VSC73XX_BLOCK_ANALYZER, 0,
- VSC73XX_LEARNMASK, BIT(port), val);
-
/* CPU Port should always forward packets when user ports are forwarding
* so let's configure it from other ports only.
*/
@@ -1654,6 +1681,8 @@ static const struct dsa_switch_ops vsc73xx_ds_ops = {
.port_setup = vsc73xx_port_setup,
.port_enable = vsc73xx_port_enable,
.port_disable = vsc73xx_port_disable,
+ .port_pre_bridge_flags = vsc73xx_port_pre_bridge_flags,
+ .port_bridge_flags = vsc73xx_port_bridge_flags,
.port_bridge_join = dsa_tag_8021q_bridge_join,
.port_bridge_leave = dsa_tag_8021q_bridge_leave,
.port_change_mtu = vsc73xx_change_mtu,
--
2.34.1