Skip to content

Commit 259a706

Browse files
CHKDSK88kuba-moo
authored andcommitted
net: dsa: vsc73xx: start treating the BR_LEARNING flag
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]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 6dfaaa2 commit 259a706

File tree

1 file changed

+35
-6
lines changed

1 file changed

+35
-6
lines changed

drivers/net/dsa/vitesse-vsc73xx-core.c

Lines changed: 35 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1622,6 +1622,31 @@ static int vsc73xx_tag_8021q_vlan_del(struct dsa_switch *ds, int port, u16 vid)
16221622
return vsc73xx_update_vlan_table(vsc, port, vid, false);
16231623
}
16241624

1625+
static int vsc73xx_port_pre_bridge_flags(struct dsa_switch *ds, int port,
1626+
struct switchdev_brport_flags flags,
1627+
struct netlink_ext_ack *extack)
1628+
{
1629+
if (flags.mask & ~BR_LEARNING)
1630+
return -EINVAL;
1631+
1632+
return 0;
1633+
}
1634+
1635+
static int vsc73xx_port_bridge_flags(struct dsa_switch *ds, int port,
1636+
struct switchdev_brport_flags flags,
1637+
struct netlink_ext_ack *extack)
1638+
{
1639+
if (flags.mask & BR_LEARNING) {
1640+
u32 val = flags.val & BR_LEARNING ? BIT(port) : 0;
1641+
struct vsc73xx *vsc = ds->priv;
1642+
1643+
return vsc73xx_update_bits(vsc, VSC73XX_BLOCK_ANALYZER, 0,
1644+
VSC73XX_LEARNMASK, BIT(port), val);
1645+
}
1646+
1647+
return 0;
1648+
}
1649+
16251650
static void vsc73xx_refresh_fwd_map(struct dsa_switch *ds, int port, u8 state)
16261651
{
16271652
struct dsa_port *other_dp, *dp = dsa_to_port(ds, port);
@@ -1682,19 +1707,21 @@ static void vsc73xx_refresh_fwd_map(struct dsa_switch *ds, int port, u8 state)
16821707
static void vsc73xx_port_stp_state_set(struct dsa_switch *ds, int port,
16831708
u8 state)
16841709
{
1710+
struct dsa_port *dp = dsa_to_port(ds, port);
16851711
struct vsc73xx *vsc = ds->priv;
1686-
u32 val;
1712+
u32 val = 0;
1713+
1714+
if (state == BR_STATE_LEARNING || state == BR_STATE_FORWARDING)
1715+
val = dp->learning ? BIT(port) : 0;
1716+
1717+
vsc73xx_update_bits(vsc, VSC73XX_BLOCK_ANALYZER, 0,
1718+
VSC73XX_LEARNMASK, BIT(port), val);
16871719

16881720
val = (state == BR_STATE_BLOCKING || state == BR_STATE_DISABLED) ?
16891721
0 : BIT(port);
16901722
vsc73xx_update_bits(vsc, VSC73XX_BLOCK_ANALYZER, 0,
16911723
VSC73XX_RECVMASK, BIT(port), val);
16921724

1693-
val = (state == BR_STATE_LEARNING || state == BR_STATE_FORWARDING) ?
1694-
BIT(port) : 0;
1695-
vsc73xx_update_bits(vsc, VSC73XX_BLOCK_ANALYZER, 0,
1696-
VSC73XX_LEARNMASK, BIT(port), val);
1697-
16981725
/* CPU Port should always forward packets when user ports are forwarding
16991726
* so let's configure it from other ports only.
17001727
*/
@@ -1719,6 +1746,8 @@ static const struct dsa_switch_ops vsc73xx_ds_ops = {
17191746
.get_sset_count = vsc73xx_get_sset_count,
17201747
.port_enable = vsc73xx_port_enable,
17211748
.port_disable = vsc73xx_port_disable,
1749+
.port_pre_bridge_flags = vsc73xx_port_pre_bridge_flags,
1750+
.port_bridge_flags = vsc73xx_port_bridge_flags,
17221751
.port_bridge_join = dsa_tag_8021q_bridge_join,
17231752
.port_bridge_leave = dsa_tag_8021q_bridge_leave,
17241753
.port_change_mtu = vsc73xx_change_mtu,

0 commit comments

Comments
 (0)