Thread (22 messages) flat view 22 messages, 5 authors, 2025-07-07

Re: [PATCH 3/3] net: renesas: rswitch: add modifiable ageing time

From: Geert Uytterhoeven <geert@linux-m68k.org>
Date: 2025-07-07 12:50:23
Also in: linux-renesas-soc, lkml

Hi Michael,

On Fri, 4 Jul 2025 at 07:52, Michael Dege [off-list ref] wrote:
This commit allows the setting of the MAC table aging in the R-Car S4
Rswitch using the SWITCHDEV_ATTR_ID_BRIDGE_AGEING_TIME attribute.

Signed-off-by: Michael Dege <redacted>
Thanks for your patch!
quoted hunk ↗ jump to hunk
--- a/drivers/net/ethernet/renesas/rswitch.h
+++ b/drivers/net/ethernet/renesas/rswitch.h
@@ -849,6 +849,7 @@ enum rswitch_gwca_mode {
 #define FWMACAGC_MACDESOG      BIT(29)

 #define RSW_AGEING_TIME                300
+#define RSW_MAX_AGEING_TIME    65535
This is not needed (see below).
quoted hunk ↗ jump to hunk
 /* TOP */
 #define TPEMIMC7(queue)                (TPEMIMC70 + (queue) * 4)
diff --git a/drivers/net/ethernet/renesas/rswitch_l2.c b/drivers/net/ethernet/renesas/rswitch_l2.c
index 242beb1f15c089585f5fe5019f626df8824b971a..c8a8a60a20e70f7ce421280ed35c0c4afe1ed039 100644
--- a/drivers/net/ethernet/renesas/rswitch_l2.c
+++ b/drivers/net/ethernet/renesas/rswitch_l2.c
@@ -196,6 +196,30 @@ static int rswitch_netdevice_event(struct notifier_block *nb,
        return NOTIFY_OK;
 }

+static int rswitch_update_ageing_time(struct net_device *ndev, clock_t time)
+{
+       struct rswitch_device *rdev = netdev_priv(ndev);
+       u32 reg_val, time_val;
+
+       if (!is_rdev(ndev))
+               return -ENODEV;
+
+       /* Although brctl accepts the ageing time parameter in seconds, the value
+        * passed to the driver is multiplied by 100. We need it in seconds.
+        */
+       time_val = (u32)time / 100;
switchdev_attr.u.ageing_time is clock_t, which is long, so no cast is
needed before doing the division.  Actually the cast may truncate very
large values on 64-bit.
However, dropping the cast means time_val should be changed to clock_t.
+
+       if (time_val > RSW_MAX_AGEING_TIME)
if (!FIELD_FIT(FWMACAGC_MACAGT, time_val))
+               return -EINVAL;
+
+       rdev = netdev_priv(ndev);
+       reg_val = FIELD_PREP(FWMACAGC_MACAGT, time_val);
+       reg_val |= FWMACAGC_MACAGE | FWMACAGC_MACAGSL;
+       iowrite32(reg_val, rdev->priv->addr + FWMACAGC);
+
+       return 0;
+}
+
 static int rswitch_port_attr_set(struct net_device *ndev, const void *ctx,
                                 const struct switchdev_attr *attr,
                                 struct netlink_ext_ack *extack)
Gr{oetje,eeting}s,

                        Geert


--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help