Skip to contentSkip to conversation

net: renesas: rswitch: R-Car S4 add HW offloading for layer 2 switching

PATCH Applied Michael Dege 5 participants 10 messages Sep 1, 2025 – Oct 16, 2025

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

v5 cover net: renesas: rswitch: R-Car S4 add HW offloading for layer 2 switching

Hello!

The current R-Car S4 rswitch driver only supports port based fowarding. This patch set adds HW offloading for L2 switching/bridgeing. The driver hooks into switchdev.

1. Rename the base driver file to keep the driver name (rswitch.ko)

2. Add setting of default MAC ageing time in hardware.

3. Add the L2 driver extension in a separate file. The HW offloading is automatically configured when a port is added to the bridge device.

Usage example:
ip link add name br0 type bridge
ip link set dev tsn0 master br0
ip link set dev tsn1 master br0
ip link set dev br0 up
ip link set dev tsn0 up
ip link set dev tsn1 up

Layer 2 traffic is now fowarded by HW from port TSN0 to port TSN1.

4. Provides the functionality to set the MAC table ageing time in the Rswitch.

Usage example:
ip link change dev br0 type bridge ageing 100

Changes in v5:
- Updated commit messeges [3/4] and [4/4] using iperative mood.
- Fixed incorrect id_len setting in rswitch_get_port_parent_id()
- Removed duplicate initialization of *rdev in
rswitch_update_ageing_time()
- Link to v4: https://lore.kernel.org/r/[email protected]

Changes in v4:
- Added target tree to subject prefix.
- refactored rswitch_update_l2_hw_learning() and rswitch_update_l2_hw_forwarding() to remove duplicate code.
- In function rswitch_update_offload_brdev() removed unused force_update_l2_offload parameter.
- Link to v3: https://lore.kernel.org/r/[email protected]

Changes in v3:
- Split void rswitch_update_l2_offload(struct rswitch_private *priv)
into two functions to reduce the complexity.
- In rswitch_switchdev_blocking_event() returning -EOPNOTSUPP directly
for unsupported events intead of calling function which returned
-EOPNOTSUPP.
- Retuning result from rswitch_reg_wait() directly instead of using
local variable at end of function.
- Restructured rswitch_update_offload_brdev() to fix smatch
false-positive report.
- Fixed reviewed-by tags in [1/4]
- Fixed oder of signed-off-by tags in [2/4]
- Removed magic number in [2/4]
- Link to v2: https://lore.kernel.org/r/[email protected]

Changes in v2:
- Pulled default ageing setting into separate patch.
- Changed logging priority from info to dbg.
- Updated usage examples.
- Fixed passing of ageing parameter. Parameter is already in seconds
no need to convert. Parameter checking improved.
- Updated commit message of [3/4] to point out that the switch hardware
only supports the offloading of one bridge device.
- Link to v1: https://lore.kernel.org/r/[email protected]

Thanks,

Michael

---
To: Niklas Söderlund <[email protected]>
To: Paul Barker <[email protected]>
To: Yoshihiro Shimoda <[email protected]>
To: Andrew Lunn <[email protected]>
To: David S. Miller <[email protected]>
To: Eric Dumazet <[email protected]>
To: Jakub Kicinski <[email protected]>
To: Paolo Abeni <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]

---
Michael Dege (4):
net: renesas: rswitch: rename rswitch.c to rswitch_main.c
net: renesas: rswitch: configure default ageing time
net: renesas: rswitch: add offloading for L2 switching
net: renesas: rswitch: add modifiable ageing time

 drivers/net/ethernet/renesas/Makefile              |   1 +
 drivers/net/ethernet/renesas/rswitch.h             |  43 ++-
 drivers/net/ethernet/renesas/rswitch_l2.c          | 316 +++++++++++++++++++++
 drivers/net/ethernet/renesas/rswitch_l2.h          |  15 +
 .../ethernet/renesas/{rswitch.c => rswitch_main.c} |  86 +++++-
 5 files changed, 455 insertions(+), 6 deletions(-)

---
base-commit: 19272b37aa4f83ca52bdf9c16d5d81bdd1354494
change-id: 20250616-add_l2_switching-345117105d0d

Best regards,

Signature · 1 line
Michael Dege <[email protected]>
#1 lore raw

PATCH v5 1/4 net: renesas: rswitch: rename rswitch.c to rswitch_main.c

Adding new functionality to the driver. Therefore splitting into multiple c files to keep them manageable. New functionality will be added to separate files.

---
 drivers/net/ethernet/renesas/Makefile                      | 1 +
 drivers/net/ethernet/renesas/{rswitch.c => rswitch_main.c} | 0
 2 files changed, 1 insertion(+)
drivers/net/ethernet/renesas/Makefile +1 -0
index f65fc76f8b4df8dd9f24af836b6dc0772965366f..6222298bb5582b7091cf8de76acb83ac7dd39c11 100644
@@ -8,6 +8,7 @@ obj-$(CONFIG_SH_ETH) += sh_eth.o
 ravb-objs := ravb_main.o ravb_ptp.o
 obj-$(CONFIG_RAVB) += ravb.o
 
+rswitch-objs := rswitch_main.o
 obj-$(CONFIG_RENESAS_ETHER_SWITCH) += rswitch.o
 
 obj-$(CONFIG_RENESAS_GEN4_PTP) += rcar_gen4_ptp.o
drivers/net/ethernet/renesas/rswitch_main.c renamed from drivers/net/ethernet/renesas/rswitch.c +0 -0
similarity index 100%
rename from drivers/net/ethernet/renesas/rswitch.c
rename to drivers/net/ethernet/renesas/rswitch_main.c
Signature · 1 line
2.50.1
#2 lore raw

PATCH v5 2/4 net: renesas: rswitch: configure default ageing time

In reply to Michael Dege

Enable MAC ageing by setting up the timer and setting the ageging time to the default of 300s.

---
 drivers/net/ethernet/renesas/rswitch.h      | 14 +++++++++++++-
 drivers/net/ethernet/renesas/rswitch_main.c | 11 ++++++++++-
 2 files changed, 23 insertions(+), 2 deletions(-)
drivers/net/ethernet/renesas/rswitch.h +13 -1
index 532192cbca4b520e06a7e35653929d8364f1ccb2..131034d5d992eb59fd2299fa25de3a65285d29ad 100644
@@ -1,7 +1,7 @@
 /* SPDX-License-Identifier: GPL-2.0 */
 /* Renesas Ethernet Switch device driver
  *
- * Copyright (C) 2022 Renesas Electronics Corporation
+ * Copyright (C) 2022-2025 Renesas Electronics Corporation
  */
 
 #ifndef __RSWITCH_H__
@@ -826,6 +826,18 @@ enum rswitch_gwca_mode {
 
 #define FWPBFCSDC(j, i)         (FWPBFCSDC00 + (i) * 0x10 + (j) * 0x04)
 
+#define FWMACAGUSPC_MACAGUSP	GENMASK(9, 0)
+#define FWMACAGC_MACAGT		GENMASK(15, 0)
+#define FWMACAGC_MACAGE		BIT(16)
+#define FWMACAGC_MACAGSL	BIT(17)
+#define FWMACAGC_MACAGPM	BIT(18)
+#define FWMACAGC_MACDES		BIT(24)
+#define FWMACAGC_MACAGOG	BIT(28)
+#define FWMACAGC_MACDESOG	BIT(29)
+
+#define RSW_AGEING_CLK_PER_US	0x140
+#define RSW_AGEING_TIME		300
+
 /* TOP */
 #define TPEMIMC7(queue)		(TPEMIMC70 + (queue) * 4)
 
drivers/net/ethernet/renesas/rswitch_main.c +10 -1
index aba772e14555d30891dc74a5a123121dad77e92b..99019ad9de224eaf1c4128bd29609b24d1a6f263 100644
@@ -1,7 +1,7 @@
 // SPDX-License-Identifier: GPL-2.0
 /* Renesas Ethernet Switch device driver
  *
- * Copyright (C) 2022 Renesas Electronics Corporation
+ * Copyright (C) 2022-2025 Renesas Electronics Corporation
  */
 
 #include <linux/clk.h>
@@ -113,6 +113,7 @@ static void rswitch_fwd_init(struct rswitch_private *priv)
 {
 	u32 all_ports_mask = GENMASK(RSWITCH_NUM_AGENTS - 1, 0);
 	unsigned int i;
+	u32 reg_val;
 
 	/* Start with empty configuration */
 	for (i = 0; i < RSWITCH_NUM_AGENTS; i++) {
@@ -128,6 +129,14 @@ static void rswitch_fwd_init(struct rswitch_private *priv)
 		iowrite32(0, priv->addr + FWPBFC(i));
 	}
 
+	/* Configure MAC table aging */
+	rswitch_modify(priv->addr, FWMACAGUSPC, FWMACAGUSPC_MACAGUSP,
+		       FIELD_PREP(FWMACAGUSPC_MACAGUSP, RSW_AGEING_CLK_PER_US));
+
+	reg_val = FIELD_PREP(FWMACAGC_MACAGT, RSW_AGEING_TIME);
+	reg_val |= FWMACAGC_MACAGE | FWMACAGC_MACAGSL;
+	iowrite32(reg_val, priv->addr + FWMACAGC);
+
 	/* For enabled ETHA ports, setup port based forwarding */
 	rswitch_for_each_enabled_port(priv, i) {
 		/* Port based forwarding from port i to GWCA port */
Signature · 1 line
2.50.1
#3 lore raw

PATCH v5 3/4 net: renesas: rswitch: add offloading for L2 switching

In reply to Michael Dege

Add hardware offloading for L2 switching on R-Car S4.

On S4 brdev is limited to one per-device (not per port). Reasoning is that hw L2 forwarding support lacks any sort of source port based filtering, which makes it unusable to offload more than one bridge device. Either you allow hardware to forward destination MAC to a port, or you have to send it to CPU. You can't make it forward only if src and dst ports are in the same brdev.

---
 drivers/net/ethernet/renesas/Makefile       |   2 +-
 drivers/net/ethernet/renesas/rswitch.h      |  29 ++-
 drivers/net/ethernet/renesas/rswitch_l2.c   | 296 ++++++++++++++++++++++++++++
 drivers/net/ethernet/renesas/rswitch_l2.h   |  15 ++
 drivers/net/ethernet/renesas/rswitch_main.c |  75 ++++++-
 5 files changed, 412 insertions(+), 5 deletions(-)
drivers/net/ethernet/renesas/Makefile +1 -1
index 6222298bb5582b7091cf8de76acb83ac7dd39c11..d63e0c61bb68a9993d388967aea9e1d50f6a95be 100644
@@ -8,7 +8,7 @@ obj-$(CONFIG_SH_ETH) += sh_eth.o
 ravb-objs := ravb_main.o ravb_ptp.o
 obj-$(CONFIG_RAVB) += ravb.o
 
-rswitch-objs := rswitch_main.o
+rswitch-objs := rswitch_main.o rswitch_l2.o
 obj-$(CONFIG_RENESAS_ETHER_SWITCH) += rswitch.o
 
 obj-$(CONFIG_RENESAS_GEN4_PTP) += rcar_gen4_ptp.o
drivers/net/ethernet/renesas/rswitch.h +28 -1
index 131034d5d992eb59fd2299fa25de3a65285d29ad..a1d4a877e5bd4d3186544649695ddcebb7975032 100644
@@ -8,12 +8,18 @@
 #define __RSWITCH_H__
 
 #include <linux/platform_device.h>
+#include <linux/phy.h>
+
 #include "rcar_gen4_ptp.h"
 
 #define RSWITCH_MAX_NUM_QUEUES	128
 
 #define RSWITCH_NUM_AGENTS	5
 #define RSWITCH_NUM_PORTS	3
+
+#define rswitch_for_all_ports(_priv, _rdev)			\
+	list_for_each_entry(_rdev, &_priv->port_list, list)
+
 #define rswitch_for_each_enabled_port(priv, i)		\
 	for (i = 0; i < RSWITCH_NUM_PORTS; i++)		\
 		if (priv->rdev[i]->disabled)		\
@@ -809,7 +815,8 @@ enum rswitch_gwca_mode {
 #define FWPC0_IP4EA		BIT(10)
 #define FWPC0_IPDSA		BIT(12)
 #define FWPC0_IPHLA		BIT(18)
-#define FWPC0_MACSDA		BIT(20)
+#define FWPC0_MACDSA		BIT(20)
+#define FWPC0_MACSSA		BIT(23)
 #define FWPC0_MACHLA		BIT(26)
 #define FWPC0_MACHMA		BIT(27)
 #define FWPC0_VLANSA		BIT(28)
@@ -820,12 +827,18 @@ enum rswitch_gwca_mode {
 
 #define FWPC2(i)		(FWPC20 + (i) * 0x10)
 #define FWCP2_LTWFW		GENMASK(16 + (RSWITCH_NUM_AGENTS - 1), 16)
+#define FWCP2_LTWFW_MASK	GENMASK(16 + (RSWITCH_NUM_AGENTS - 1), 16)
 
 #define FWPBFC(i)		(FWPBFC0 + (i) * 0x10)
 #define FWPBFC_PBDV		GENMASK(RSWITCH_NUM_AGENTS - 1, 0)
 
 #define FWPBFCSDC(j, i)         (FWPBFCSDC00 + (i) * 0x10 + (j) * 0x04)
 
+#define FWMACHEC_MACHMUE_MASK	GENMASK(26, 16)
+
+#define FWMACTIM_MACTIOG	BIT(0)
+#define FWMACTIM_MACTR		BIT(1)
+
 #define FWMACAGUSPC_MACAGUSP	GENMASK(9, 0)
 #define FWMACAGC_MACAGT		GENMASK(15, 0)
 #define FWMACAGC_MACAGE		BIT(16)
@@ -1006,10 +1019,18 @@ struct rswitch_device {
 	DECLARE_BITMAP(ts_skb_used, TS_TAGS_PER_PORT);
 	bool disabled;
 
+	struct list_head list;
+
 	int port;
 	struct rswitch_etha *etha;
 	struct device_node *np_port;
 	struct phy *serdes;
+
+	struct net_device *brdev;	/* master bridge device */
+	unsigned int learning_requested : 1;
+	unsigned int learning_offloaded : 1;
+	unsigned int forwarding_requested : 1;
+	unsigned int forwarding_offloaded : 1;
 };
 
 struct rswitch_mfwd_mac_table_entry {
@@ -1034,11 +1055,17 @@ struct rswitch_private {
 	struct rswitch_etha etha[RSWITCH_NUM_PORTS];
 	struct rswitch_mfwd mfwd;
 
+	struct list_head port_list;
+
 	spinlock_t lock;	/* lock interrupt registers' control */
 	struct clk *clk;
 
 	bool etha_no_runtime_change;
 	bool gwca_halt;
+	struct net_device *offload_brdev;
 };
 
+bool is_rdev(const struct net_device *ndev);
+void rswitch_modify(void __iomem *addr, enum rswitch_reg reg, u32 clear, u32 set);
+
 #endif	/* #ifndef __RSWITCH_H__ */
drivers/net/ethernet/renesas/rswitch_l2.c new file +296 -0

296 lines not on this page · raw message

drivers/net/ethernet/renesas/rswitch_l2.h new file +15 -0
new file mode 100644
index 0000000000000000000000000000000000000000..57050ede8f31848cde5a497811a6ee1b60dedc65
@@ -0,0 +1,15 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/* Renesas Ethernet Switch device driver
+ *
+ * Copyright (C) 2025 Renesas Electronics Corporation
+ */
+
+#ifndef __RSWITCH_L2_H__
+#define __RSWITCH_L2_H__
+
+void rswitch_update_l2_offload(struct rswitch_private *priv);
+
+int rswitch_register_notifiers(void);
+void rswitch_unregister_notifiers(void);
+
+#endif	/* #ifndef __RSWITCH_L2_H__ */
drivers/net/ethernet/renesas/rswitch_main.c +72 -3

183 lines not on this page · raw message

Signature · 1 line
2.50.1
#4 lore raw

Re: [PATCH net-next v5 3/4] net: renesas: rswitch: add offloading for L2 switching

Le 01/09/2025 à 06:58, Michael Dege a écrit :

Quoted 11 lines

Add hardware offloading for L2 switching on R-Car S4.

On S4 brdev is limited to one per-device (not per port). Reasoning is that hw L2 forwarding support lacks any sort of source port based filtering, which makes it unusable to offload more than one bridge device. Either you allow hardware to forward destination MAC to a port, or you have to send it to CPU. You can't make it forward only if src and dst ports are in the same brdev.

...

Quoted 11 lines
(quoted diff) +2 -0
@@ -2153,6 +2210,8 @@ static int renesas_eth_sw_probe(struct platform_device *pdev)
  	if (!priv->gwca.queues)
  		return -ENOMEM;
 
+	INIT_LIST_HEAD(&priv->port_list);
+
  	pm_runtime_enable(&pdev->dev);
  	pm_runtime_get_sync(&pdev->dev);
 
@@ -2163,6 +2222,15 @@ static int renesas_eth_sw_probe(struct platform_device *pdev)
  		return ret;

Review static int renesas_eth_sw_probe(struct platform_device *pdev) · line 2232

Quoted 10 lines
(quoted diff) +8 -0
  	}
 
+	if (list_empty(&priv->port_list))
+		dev_warn(&pdev->dev, "could not initialize any ports\n");
+
+	ret = rswitch_register_notifiers();
+	if (ret) {
+		dev_err(&pdev->dev, "could not register notifiers\n");
+		return ret;
+	}

The error handling of the probe should be updated, as done in the remove function.

net-next is closed, so I'm just posting here

CJ

Review static void renesas_eth_sw_remove(struct platform_device *pdev) · line 2270

Quoted 13 lines
(quoted diff) +2 -0
+
  	device_set_wakeup_capable(&pdev->dev, 1);
 
  	return ret;
@@ -2196,6 +2264,7 @@ static void renesas_eth_sw_remove(struct platform_device *pdev)
  {
  	struct rswitch_private *priv = platform_get_drvdata(pdev);
 
+	rswitch_unregister_notifiers();
  	rswitch_deinit(priv);
 
  	pm_runtime_put(&pdev->dev);

The proposed fix would be:

drivers/net/ethernet/renesas/rswitch_main.c +11 -6
index 8d8acc2124b8..0f17c2e12cea 100644
@@ -2213,11 +2213,8 @@ static int renesas_eth_sw_probe(struct platform_device *pdev)
        pm_runtime_get_sync(&pdev->dev);
 
        ret = rswitch_init(priv);
-       if (ret < 0) {
-               pm_runtime_put(&pdev->dev);
-               pm_runtime_disable(&pdev->dev);
-               return ret;
-       }
+       if (ret < 0)
+               goto err_disable_pm_runtime;
 
        if (list_empty(&priv->port_list))
                dev_warn(&pdev->dev, "could not initialize any ports\n");
@@ -2225,11 +2222,19 @@ static int renesas_eth_sw_probe(struct platform_device *pdev)
        ret = rswitch_register_notifiers();
        if (ret) {
                dev_err(&pdev->dev, "could not register notifiers\n");
-               return ret;
+               goto err_deinit_rswitch;
        }
 
        device_set_wakeup_capable(&pdev->dev, 1);
 
+       return 0;
+
+err_deinit_rswitch:
+       rswitch_deinit(priv);
+err_disable_pm_runtime:
+       pm_runtime_put(&pdev->dev);
+       pm_runtime_disable(&pdev->dev);
+
        return ret;
 }
 
#5 lore raw

RE: [PATCH net-next v5 3/4] net: renesas: rswitch: add offloading for L2 switching

Quoted 52 lines

-----Original Message-----
From: Christophe JAILLET <[email protected]>
Sent: Monday, September 29, 2025 7:08 PM
To: Michael Dege <[email protected]>; Yoshihiro Shimoda <[email protected]>; niklas.soderlund <[email protected]>; Paul Barker <[email protected]>; Andrew Lunn <[email protected]>; David S. Miller <[email protected]>; Eric Dumazet <[email protected]>; Jakub Kicinski <[email protected]>; Paolo Abeni <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; Nikita Yushchenko <[email protected]>
Subject: Re: [PATCH net-next v5 3/4] net: renesas: rswitch: add offloading for L2 switching

Quoted 11 lines · Michael Dege

Add hardware offloading for L2 switching on R-Car S4.

On S4 brdev is limited to one per-device (not per port). Reasoning is that hw L2 forwarding support lacks any sort of source port based filtering, which makes it unusable to offload more than one bridge device. Either you allow hardware to forward destination MAC to a port, or you have to send it to CPU. You can't make it forward only if src and dst ports are in the same brdev.

...

Quoted 11 lines
(quoted diff) +2 -0
@@ -2153,6 +2210,8 @@ static int renesas_eth_sw_probe(struct platform_device *pdev)
    if (!priv->gwca.queues)
            return -ENOMEM;
 
+   INIT_LIST_HEAD(&priv->port_list);
+
    pm_runtime_enable(&pdev->dev);
    pm_runtime_get_sync(&pdev->dev);
 
@@ -2163,6 +2222,15 @@ static int renesas_eth_sw_probe(struct platform_device *pdev)
            return ret;

Review static int renesas_eth_sw_probe(struct platform_device *pdev) · line 2232

Quoted 10 lines
(quoted diff) +8 -0
    }
 
+   if (list_empty(&priv->port_list))
+           dev_warn(&pdev->dev, "could not initialize any ports\n");
+
+   ret = rswitch_register_notifiers();
+   if (ret) {
+           dev_err(&pdev->dev, "could not register notifiers\n");
+           return ret;
+   }

The error handling of the probe should be updated, as done in the remove function.

Quoted 4 lines

net-next is closed, so I'm just posting here

CJ

Hello Christophe,

Thank you for your comment. I will look at your proposal and add it to the next patch set.

Michael

Quoted 49 lines

drivers/net/ethernet/renesas/rswitch_main.c static void renesas_eth_sw_remove(struct platform_device *pdev) · line 2270

Quoted 13 lines
drivers/net/ethernet/renesas/rswitch_main.c +2 -0
+
    device_set_wakeup_capable(&pdev->dev, 1);
 
    return ret;
@@ -2196,6 +2264,7 @@ static void renesas_eth_sw_remove(struct platform_device *pdev)
  {
    struct rswitch_private *priv = platform_get_drvdata(pdev);
 
+   rswitch_unregister_notifiers();
    rswitch_deinit(priv);
 
    pm_runtime_put(&pdev->dev);

The proposed fix would be:

drivers/net/ethernet/renesas/rswitch_main.c +2 -5
index 8d8acc2124b8..0f17c2e12cea 100644
@@ -2213,11 +2213,8 @@ static int renesas_eth_sw_probe(struct platform_device *pdev)
         pm_runtime_get_sync(&pdev->dev);
 
         ret = rswitch_init(priv);
-       if (ret < 0) {
-               pm_runtime_put(&pdev->dev);
-               pm_runtime_disable(&pdev->dev);
-               return ret;
-       }
+       if (ret < 0)
+               goto err_disable_pm_runtime;
 
         if (list_empty(&priv->port_list))
                 dev_warn(&pdev->dev, "could not initialize any ports\n"); @@ -2225,11 +2222,19 @@

static int renesas_eth_sw_probe(struct platform_device *pdev)

         ret = rswitch_register_notifiers();
         if (ret) {
                 dev_err(&pdev->dev, "could not register notifiers\n");
drivers/net/ethernet/renesas/rswitch_main.c +1 -1
-               return ret;
+               goto err_deinit_rswitch;
         }
 
         device_set_wakeup_capable(&pdev->dev, 1);
 

drivers/net/ethernet/renesas/rswitch_main.c static int renesas_eth_sw_probe(struct platform_device *pdev) · line 2239

Quoted 10 lines
drivers/net/ethernet/renesas/rswitch_main.c +8 -0
+       return 0;
+
+err_deinit_rswitch:
+       rswitch_deinit(priv);
+err_disable_pm_runtime:
+       pm_runtime_put(&pdev->dev);
+       pm_runtime_disable(&pdev->dev);
+
         return ret;
  }

________________________________

Renesas Electronics Europe GmbH
Registered Office: Arcadiastrasse 10
DE-40472 Duesseldorf
Commercial Registry: Duesseldorf, HRB 3708
Managing Director: Carsten Jauch
VAT-No.: DE 14978647
Tax-ID-No: 105/5839/1793

Legal Disclaimer: This e-mail communication (and any attachment/s) is confidential and contains proprietary information, some or all of which may be legally privileged. It is intended solely for the use of the individual or entity to which it is addressed. Access to this email by anyone else is unauthorized. If you are not the intended recipient, any disclosure, copying, distribution or any action taken or omitted to be taken in reliance on it, is prohibited and may be unlawful.

#6 lore raw

Re: [External] : [PATCH net-next v5 3/4] net: renesas: rswitch: add offloading for L2 switching

In reply to Michael Dege

Hi Michael,

Quoted 13 lines · Michael Dege
drivers/net/ethernet/renesas/rswitch_l2.c new file +13 -0
+static void rswitch_update_offload_brdev(struct rswitch_private *priv)
+{
+	struct net_device *offload_brdev = NULL;
+	struct rswitch_device *rdev, *rdev2;
+
+	rswitch_for_all_ports(priv, rdev) {
+		if (!rdev->brdev)
+			continue;
+		rswitch_for_all_ports(priv, rdev2) {
+			if (rdev2 == rdev)
+				break;
+			if (rdev2->brdev == rdev->brdev) {
+				offload_brdev = rdev->brdev;

drivers/net/ethernet/renesas/rswitch_l2.c line 125

Quoted 10 lines
drivers/net/ethernet/renesas/rswitch_l2.c new file +10 -0
+				break;
+			}
+		}
+		if (offload_brdev)
+			break;
+	}
+
+	if (offload_brdev == priv->offload_brdev)
+		dev_dbg(&priv->pdev->dev,
+			"changing l2 offload from %s to %s\n",

condition does not match the actual intent
it seems, offload_brdev != priv->offload_brdev more suitable. I understand this code already has been merged in upstream 6.18.

drivers/net/ethernet/renesas/rswitch_l2.c line 138

Quoted 13 lines
drivers/net/ethernet/renesas/rswitch_l2.c new file +13 -0
+			netdev_name(priv->offload_brdev),
+			netdev_name(offload_brdev));
+	else if (offload_brdev)
+		dev_dbg(&priv->pdev->dev, "starting l2 offload for %s\n",
+			netdev_name(offload_brdev));
+	else if (!offload_brdev)
+		dev_dbg(&priv->pdev->dev, "stopping l2 offload for %s\n",
+			netdev_name(priv->offload_brdev));
+
+	priv->offload_brdev = offload_brdev;
+
+	rswitch_update_l2_offload(priv);
+}

Thanks,
Alok

#7 lore raw

PATCH v5 4/4 net: renesas: rswitch: add modifiable ageing time

In reply to Michael Dege

Allow the setting of the MAC table aging in the R-Car S4 Rswitch using the SWITCHDEV_ATTR_ID_BRIDGE_AGEING_TIME attribute.

---
 drivers/net/ethernet/renesas/rswitch_l2.c | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)
drivers/net/ethernet/renesas/rswitch_l2.c +20 -0
index 49a24464dbb0cf3f3219a0699fc4671ddd71ef03..4a69ec77d69c600530189f3f5e86da165022bc4e 100644
@@ -193,6 +193,24 @@ 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;
+
+	if (!is_rdev(ndev))
+		return -ENODEV;
+
+	if (!FIELD_FIT(FWMACAGC_MACAGT, time))
+		return -EINVAL;
+
+	reg_val = FIELD_PREP(FWMACAGC_MACAGT, time);
+	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)
@@ -200,6 +218,8 @@ static int rswitch_port_attr_set(struct net_device *ndev, const void *ctx,
 	switch (attr->id) {
 	case SWITCHDEV_ATTR_ID_PORT_STP_STATE:
 		return rswitch_port_update_stp_state(ndev, attr->u.stp_state);
+	case SWITCHDEV_ATTR_ID_BRIDGE_AGEING_TIME:
+		return rswitch_update_ageing_time(ndev, attr->u.ageing_time);
 	default:
 		return -EOPNOTSUPP;
 	}
Signature · 1 line
2.50.1
maintainer
#8 lore raw
In reply to Michael Dege
Quoted 19 lines · On Mon, 01 Sep 2025 06:58:04 +0200 Michael Dege wrote:

The current R-Car S4 rswitch driver only supports port based fowarding. This patch set adds HW offloading for L2 switching/bridgeing. The driver hooks into switchdev.

1. Rename the base driver file to keep the driver name (rswitch.ko)

2. Add setting of default MAC ageing time in hardware.

3. Add the L2 driver extension in a separate file. The HW offloading is automatically configured when a port is added to the bridge device.

Usage example:
ip link add name br0 type bridge
ip link set dev tsn0 master br0
ip link set dev tsn1 master br0
ip link set dev br0 up
ip link set dev tsn0 up
ip link set dev tsn1 up

Quoted 4 lines

Layer 2 traffic is now fowarded by HW from port TSN0 to port TSN1.

4. Provides the functionality to set the MAC table ageing time in the Rswitch.

Is anyone with bride offload expertise willing to provide a review here?

Jiri, Ivan, the switchdev MAINTAINERS entry only covers "core" switchdev which is rather fallow. Is it okay to extend it to driver review?

#9 lore raw
In reply to Michael Dege
This series was applied to netdev/net-next.git (main) by Paolo Abeni <[email protected]>:

Hello:

This series was applied to netdev/net-next.git (main) by Paolo Abeni <[email protected]>:

Quoted 9 lines · On Mon, 01 Sep 2025 06:58:04 +0200 you wrote:

Hello!

The current R-Car S4 rswitch driver only supports port based fowarding. This patch set adds HW offloading for L2 switching/bridgeing. The driver hooks into switchdev.

1. Rename the base driver file to keep the driver name (rswitch.ko)

[...]

Here is the summary with links:
- [net-next,v5,1/4] net: renesas: rswitch: rename rswitch.c to rswitch_main.c

    https://git.kernel.org/netdev/net-next/c/5ee21c004c0b
  - [net-next,v5,2/4] net: renesas: rswitch: configure default ageing time
    https://git.kernel.org/netdev/net-next/c/622303250c51
  - [net-next,v5,3/4] net: renesas: rswitch: add offloading for L2 switching
    https://git.kernel.org/netdev/net-next/c/b7502b1043de
  - [net-next,v5,4/4] net: renesas: rswitch: add modifiable ageing time
    https://git.kernel.org/netdev/net-next/c/92e913a3df3c

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html