drivers/net/ethernet/renesas/rswitch_l2.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
A change of the port state of one port, caused the state of another
port to change. This behvior was unintended.
Signed-off-by: Michael Dege <michael.dege@renesas.com>
---
A change of the port state of one port, caused the state of another
port to change. This behvior was unintended.
Fixes: b7502b1043de86967ff341819d05e09a8dbe8b2b ("net: renesas: rswitch: add offloading for L2 switching")
---
drivers/net/ethernet/renesas/rswitch_l2.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/renesas/rswitch_l2.c b/drivers/net/ethernet/renesas/rswitch_l2.c
index 4a69ec77d69c..dcf726793bdc 100644
--- a/drivers/net/ethernet/renesas/rswitch_l2.c
+++ b/drivers/net/ethernet/renesas/rswitch_l2.c
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: GPL-2.0
/* Renesas Ethernet Switch device driver
*
- * Copyright (C) 2025 Renesas Electronics Corporation
+ * Copyright (C) 2025 - 2026 Renesas Electronics Corporation
*/
#include <linux/err.h>
@@ -88,7 +88,8 @@ static void rswitch_update_l2_hw_forwarding(struct rswitch_private *priv)
rdev->forwarding_requested &&
!rdev->forwarding_offloaded) {
rswitch_change_l2_hw_offloading(rdev, true, false);
- } else if (rdev->forwarding_offloaded) {
+ } else if (rdev->forwarding_offloaded &&
+ !rdev->forwarding_requested) {
rswitch_change_l2_hw_offloading(rdev, false, false);
}
}
---
base-commit: f14faaf3a1fb3b9e4cf2e56269711fb85fba9458
change-id: 20260205-fix-offloading-statemachine-1d301630a08d
Best regards,
--
Michael Dege <michael.dege@renesas.com>
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
WBR,
Nikita Yushchenko,
System Software Engineer @ Cogent Embedded
05.02.2026 08:47, Nikita Yushchenko wrote:
> 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.
May be even better to add
bool new_forwarding_offloaded = rdev_for_l2_offload(rdev) && rdev->forwarding_requested;
at the beginning of the loop body, and use this flag over the loop - it will make the code shorter and
cleaner.
© 2016 - 2026 Red Hat, Inc.