]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
net: dsa: b53: implement setting ageing time
authorJonas Gorski <jonas.gorski@gmail.com>
Sat, 10 May 2025 09:22:11 +0000 (11:22 +0200)
committerJakub Kicinski <kuba@kernel.org>
Tue, 13 May 2025 01:51:09 +0000 (18:51 -0700)
b53 supported switches support configuring ageing time between 1 and
1,048,575 seconds, so add an appropriate setter.

This allows b53 to pass the FDB learning test for both vlan aware and
vlan unaware bridges.

Signed-off-by: Jonas Gorski <jonas.gorski@gmail.com>
Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com>
Link: https://patch.msgid.link/20250510092211.276541-1-jonas.gorski@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/dsa/b53/b53_common.c
drivers/net/dsa/b53/b53_priv.h
drivers/net/dsa/b53/b53_regs.h
drivers/net/dsa/bcm_sf2.c

index 9eb39cfa5fb27596032880692083558639a254b2..2cff88bc7a1fa3461012290585c79fc62e949e7e 100644 (file)
@@ -21,6 +21,7 @@
 #include <linux/export.h>
 #include <linux/gpio.h>
 #include <linux/kernel.h>
+#include <linux/math.h>
 #include <linux/module.h>
 #include <linux/platform_data/b53.h>
 #include <linux/phy.h>
@@ -1175,6 +1176,10 @@ static int b53_setup(struct dsa_switch *ds)
         */
        ds->untag_vlan_aware_bridge_pvid = true;
 
+       /* Ageing time is set in seconds */
+       ds->ageing_time_min = 1 * 1000;
+       ds->ageing_time_max = AGE_TIME_MAX * 1000;
+
        ret = b53_reset_switch(dev);
        if (ret) {
                dev_err(ds->dev, "failed to reset switch\n");
@@ -2373,6 +2378,28 @@ static int b53_get_max_mtu(struct dsa_switch *ds, int port)
        return B53_MAX_MTU;
 }
 
+int b53_set_ageing_time(struct dsa_switch *ds, unsigned int msecs)
+{
+       struct b53_device *dev = ds->priv;
+       u32 atc;
+       int reg;
+
+       if (is63xx(dev))
+               reg = B53_AGING_TIME_CONTROL_63XX;
+       else
+               reg = B53_AGING_TIME_CONTROL;
+
+       atc = DIV_ROUND_CLOSEST(msecs, 1000);
+
+       if (!is5325(dev) && !is5365(dev))
+               atc |= AGE_CHANGE;
+
+       b53_write32(dev, B53_MGMT_PAGE, reg, atc);
+
+       return 0;
+}
+EXPORT_SYMBOL_GPL(b53_set_ageing_time);
+
 static const struct phylink_mac_ops b53_phylink_mac_ops = {
        .mac_select_pcs = b53_phylink_mac_select_pcs,
        .mac_config     = b53_phylink_mac_config,
@@ -2396,6 +2423,7 @@ static const struct dsa_switch_ops b53_switch_ops = {
        .port_disable           = b53_disable_port,
        .support_eee            = b53_support_eee,
        .set_mac_eee            = b53_set_mac_eee,
+       .set_ageing_time        = b53_set_ageing_time,
        .port_bridge_join       = b53_br_join,
        .port_bridge_leave      = b53_br_leave,
        .port_pre_bridge_flags  = b53_br_flags_pre,
index 2cf3e6a81e3785537ffff376468287e9f8563cdf..a5ef7071ba07b118f052c19dd3caf8f10b3114c9 100644 (file)
@@ -343,6 +343,7 @@ void b53_get_strings(struct dsa_switch *ds, int port, u32 stringset,
 void b53_get_ethtool_stats(struct dsa_switch *ds, int port, uint64_t *data);
 int b53_get_sset_count(struct dsa_switch *ds, int port, int sset);
 void b53_get_ethtool_phy_stats(struct dsa_switch *ds, int port, uint64_t *data);
+int b53_set_ageing_time(struct dsa_switch *ds, unsigned int msecs);
 int b53_br_join(struct dsa_switch *ds, int port, struct dsa_bridge bridge,
                bool *tx_fwd_offload, struct netlink_ext_ack *extack);
 void b53_br_leave(struct dsa_switch *ds, int port, struct dsa_bridge bridge);
index bfbcb66bef6626d84c49d5389ddf7ab1c4e3d36e..2f7ee0156952e0e5b431536c1dc3f40b2facc634 100644 (file)
 #define   BRCM_HDR_P5_EN               BIT(1) /* Enable tagging on port 5 */
 #define   BRCM_HDR_P7_EN               BIT(2) /* Enable tagging on port 7 */
 
+/* Aging Time control register (32 bit) */
+#define B53_AGING_TIME_CONTROL         0x06
+#define B53_AGING_TIME_CONTROL_63XX    0x08
+#define  AGE_CHANGE                    BIT(20)
+#define  AGE_TIME_MASK                 0x7ffff
+#define  AGE_TIME_MAX                  1048575
+
 /* Mirror capture control register (16 bit) */
 #define B53_MIR_CAP_CTL                        0x10
 #define  CAP_PORT_MASK                 0xf
index 454a8c7fd7eea5b247a0caf3d28f7412faef4851..960685596093b67235625b5741a5f7ceaaf719e6 100644 (file)
@@ -1235,6 +1235,7 @@ static const struct dsa_switch_ops bcm_sf2_ops = {
        .port_disable           = bcm_sf2_port_disable,
        .support_eee            = b53_support_eee,
        .set_mac_eee            = b53_set_mac_eee,
+       .set_ageing_time        = b53_set_ageing_time,
        .port_bridge_join       = b53_br_join,
        .port_bridge_leave      = b53_br_leave,
        .port_pre_bridge_flags  = b53_br_flags_pre,