Hi Michael, On Fri, 4 Jul 2025 at 07:52, Michael Dege <michael.dege@xxxxxxxxxxx> 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 <michael.dege@xxxxxxxxxxx> Thanks for your patch! > --- 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). > > /* 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@xxxxxxxxxxxxxx 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