Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge branch 'net-dsa-learning-fixes-for-b53-bcm_sf2'

Florian Fainelli says:

====================
net: dsa: Learning fixes for b53/bcm_sf2

This patch series contains a couple of fixes for the b53/bcm_sf2 drivers
with respect to configuring learning.

The first patch is wiring-up the necessary dsa_switch_ops operations in
order to support the offloading of bridge flags.

The second patch corrects the switch driver's default learning behavior
which was unfortunately wrong from day one.

This is submitted against "net" because this is technically a bug fix
since ports should not have had learning enabled by default but given
this is dependent upon Vladimir's recent br_flags series, there is no
Fixes tag provided.

I will be providing targeted stable backports that look a bit
different.

Changes in v2:

- added first patch
- updated second patch to include BR_LEARNING check in br_flags_pre as
a support bridge flag to offload
====================

Link: https://lore.kernel.org/r/20210222223010.2907234-1-f.fainelli@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

+43 -23
+30 -9
drivers/net/dsa/b53/b53_common.c
··· 543 543 b53_write16(dev, B53_CTRL_PAGE, B53_IPMC_FLOOD_MASK, mc); 544 544 } 545 545 546 + static void b53_port_set_learning(struct b53_device *dev, int port, 547 + bool learning) 548 + { 549 + u16 reg; 550 + 551 + b53_read16(dev, B53_CTRL_PAGE, B53_DIS_LEARNING, &reg); 552 + if (learning) 553 + reg &= ~BIT(port); 554 + else 555 + reg |= BIT(port); 556 + b53_write16(dev, B53_CTRL_PAGE, B53_DIS_LEARNING, reg); 557 + } 558 + 546 559 int b53_enable_port(struct dsa_switch *ds, int port, struct phy_device *phy) 547 560 { 548 561 struct b53_device *dev = ds->priv; ··· 570 557 571 558 b53_port_set_ucast_flood(dev, port, true); 572 559 b53_port_set_mcast_flood(dev, port, true); 560 + b53_port_set_learning(dev, port, false); 573 561 574 562 if (dev->ops->irq_enable) 575 563 ret = dev->ops->irq_enable(dev, port); ··· 705 691 706 692 b53_port_set_ucast_flood(dev, port, true); 707 693 b53_port_set_mcast_flood(dev, port, true); 694 + b53_port_set_learning(dev, port, false); 708 695 } 709 696 710 697 static void b53_enable_mib(struct b53_device *dev) ··· 1968 1953 } 1969 1954 EXPORT_SYMBOL(b53_br_fast_age); 1970 1955 1971 - static int b53_br_flags_pre(struct dsa_switch *ds, int port, 1972 - struct switchdev_brport_flags flags, 1973 - struct netlink_ext_ack *extack) 1956 + int b53_br_flags_pre(struct dsa_switch *ds, int port, 1957 + struct switchdev_brport_flags flags, 1958 + struct netlink_ext_ack *extack) 1974 1959 { 1975 - if (flags.mask & ~(BR_FLOOD | BR_MCAST_FLOOD)) 1960 + if (flags.mask & ~(BR_FLOOD | BR_MCAST_FLOOD | BR_LEARNING)) 1976 1961 return -EINVAL; 1977 1962 1978 1963 return 0; 1979 1964 } 1965 + EXPORT_SYMBOL(b53_br_flags_pre); 1980 1966 1981 - static int b53_br_flags(struct dsa_switch *ds, int port, 1982 - struct switchdev_brport_flags flags, 1983 - struct netlink_ext_ack *extack) 1967 + int b53_br_flags(struct dsa_switch *ds, int port, 1968 + struct switchdev_brport_flags flags, 1969 + struct netlink_ext_ack *extack) 1984 1970 { 1985 1971 if (flags.mask & BR_FLOOD) 1986 1972 b53_port_set_ucast_flood(ds->priv, port, ··· 1989 1973 if (flags.mask & BR_MCAST_FLOOD) 1990 1974 b53_port_set_mcast_flood(ds->priv, port, 1991 1975 !!(flags.val & BR_MCAST_FLOOD)); 1976 + if (flags.mask & BR_LEARNING) 1977 + b53_port_set_learning(ds->priv, port, 1978 + !!(flags.val & BR_LEARNING)); 1992 1979 1993 1980 return 0; 1994 1981 } 1982 + EXPORT_SYMBOL(b53_br_flags); 1995 1983 1996 - static int b53_set_mrouter(struct dsa_switch *ds, int port, bool mrouter, 1997 - struct netlink_ext_ack *extack) 1984 + int b53_set_mrouter(struct dsa_switch *ds, int port, bool mrouter, 1985 + struct netlink_ext_ack *extack) 1998 1986 { 1999 1987 b53_port_set_mcast_flood(ds->priv, port, mrouter); 2000 1988 2001 1989 return 0; 2002 1990 } 1991 + EXPORT_SYMBOL(b53_set_mrouter); 2003 1992 2004 1993 static bool b53_possible_cpu_port(struct dsa_switch *ds, int port) 2005 1994 {
+8
drivers/net/dsa/b53/b53_priv.h
··· 326 326 void b53_br_leave(struct dsa_switch *ds, int port, struct net_device *bridge); 327 327 void b53_br_set_stp_state(struct dsa_switch *ds, int port, u8 state); 328 328 void b53_br_fast_age(struct dsa_switch *ds, int port); 329 + int b53_br_flags_pre(struct dsa_switch *ds, int port, 330 + struct switchdev_brport_flags flags, 331 + struct netlink_ext_ack *extack); 332 + int b53_br_flags(struct dsa_switch *ds, int port, 333 + struct switchdev_brport_flags flags, 334 + struct netlink_ext_ack *extack); 335 + int b53_set_mrouter(struct dsa_switch *ds, int port, bool mrouter, 336 + struct netlink_ext_ack *extack); 329 337 int b53_setup_devlink_resources(struct dsa_switch *ds); 330 338 void b53_port_event(struct dsa_switch *ds, int port); 331 339 void b53_phylink_validate(struct dsa_switch *ds, int port,
+1
drivers/net/dsa/b53/b53_regs.h
··· 115 115 #define B53_UC_FLOOD_MASK 0x32 116 116 #define B53_MC_FLOOD_MASK 0x34 117 117 #define B53_IPMC_FLOOD_MASK 0x36 118 + #define B53_DIS_LEARNING 0x3c 118 119 119 120 /* 120 121 * Override Ports 0-7 State on devices with xMII interfaces (8 bit)
+4 -14
drivers/net/dsa/bcm_sf2.c
··· 223 223 reg &= ~P_TXQ_PSM_VDD(port); 224 224 core_writel(priv, reg, CORE_MEM_PSM_VDD_CTRL); 225 225 226 - /* Enable learning */ 227 - reg = core_readl(priv, CORE_DIS_LEARN); 228 - reg &= ~BIT(port); 229 - core_writel(priv, reg, CORE_DIS_LEARN); 230 - 231 226 /* Enable Broadcom tags for that port if requested */ 232 - if (priv->brcm_tag_mask & BIT(port)) { 227 + if (priv->brcm_tag_mask & BIT(port)) 233 228 b53_brcm_hdr_setup(ds, port); 234 - 235 - /* Disable learning on ASP port */ 236 - if (port == 7) { 237 - reg = core_readl(priv, CORE_DIS_LEARN); 238 - reg |= BIT(port); 239 - core_writel(priv, reg, CORE_DIS_LEARN); 240 - } 241 - } 242 229 243 230 /* Configure Traffic Class to QoS mapping, allow each priority to map 244 231 * to a different queue number ··· 1104 1117 .set_mac_eee = b53_set_mac_eee, 1105 1118 .port_bridge_join = b53_br_join, 1106 1119 .port_bridge_leave = b53_br_leave, 1120 + .port_pre_bridge_flags = b53_br_flags_pre, 1121 + .port_bridge_flags = b53_br_flags, 1107 1122 .port_stp_state_set = b53_br_set_stp_state, 1123 + .port_set_mrouter = b53_set_mrouter, 1108 1124 .port_fast_age = b53_br_fast_age, 1109 1125 .port_vlan_filtering = b53_vlan_filtering, 1110 1126 .port_vlan_add = b53_vlan_add,