RE: [PATCH net] net: renesas: rswitch: fix forwarding offload statemachine

From: Michael Dege

Date: Thu Feb 05 2026 - 02:54:27 EST


Hello Nikita,

> -----Original Message-----
> From: Nikita Yushchenko <nikita.yoush@xxxxxxxxxxxxxxxxxx>
> Sent: Thursday, February 5, 2026 8:47 AM
> To: Michael Dege <michael.dege@xxxxxxxxxxx>; Yoshihiro Shimoda <yoshihiro.shimoda.uh@xxxxxxxxxxx>;
> Andrew Lunn <andrew+netdev@xxxxxxx>; David S. Miller <davem@xxxxxxxxxxxxx>; Eric Dumazet
> <edumazet@xxxxxxxxxx>; Jakub Kicinski <kuba@xxxxxxxxxx>; Paolo Abeni <pabeni@xxxxxxxxxx>
> Cc: netdev@xxxxxxxxxxxxxxx; linux-renesas-soc@xxxxxxxxxxxxxxx; linux-kernel@xxxxxxxxxxxxxxx
> Subject: Re: [PATCH net] net: renesas: rswitch: fix forwarding offload statemachine
>
> Hello Michael
>
> > - } else if (rdev->forwarding_offloaded) {
> > + } else if (rdev->forwarding_offloaded &&
> > + !rdev->forwarding_requested) {
> > rswitch_change_l2_hw_offloading(rdev, false, false);
> > }
>
> Although indeed the condition in the current code is not correct, I'm not sure comfortable with this
> fix.
>
> Full condition for a port to be a valid candidate for hardware forwarding is
>
> rdev_for_l2_offload() && rdev->forwarding_requested
>
> It is not obvious if at this point rdev_for_l2_offload() could get changed from the last call to
> rswitch_change_l2_hw_offloading(), so using only the partial condition at this point does not look
> good for me.
>
> I'd suggest to either change to something like
>
> if (rdev_for_l2_offload() && rdev->forwarding_requested && !rdev->forwarding_offloaded)
> rswitch_change_l2_hw_offloading(rdev, true, false); if (!(rdev_for_l2_offload() && rdev-
> >forwarding_requested) && rdev->forwarding_offloaded)
> rswitch_change_l2_hw_offloading(rdev, false, false);
>
> Or maybe just
>
> if (rdev_for_l2_offload() && rdev->forwarding_requested)
> rswitch_change_l2_hw_offloading(rdev, true, false); else
> rswitch_change_l2_hw_offloading(rdev, false, false);
>
> since rswitch_change_l2_hw_offloading() has internal check for the current state and returns early if
> the requested change is already applied.
>
> Nikita

Thank you for your comment.

Let me study and test your suggestion.

Best regards,

Michael