[PATCH 0/3] net: renesas: rswitch: R-Car S4 add HW offloading for layer 2 switching

Michael Dege posted 3 patches 3 months ago
There is a newer version of this series
drivers/net/ethernet/renesas/Makefile              |   1 +
drivers/net/ethernet/renesas/rswitch.h             |  43 ++-
drivers/net/ethernet/renesas/rswitch_l2.c          | 344 +++++++++++++++++++++
drivers/net/ethernet/renesas/rswitch_l2.h          |  15 +
.../ethernet/renesas/{rswitch.c => rswitch_main.c} |  88 +++++-
5 files changed, 485 insertions(+), 6 deletions(-)
[PATCH 0/3] net: renesas: rswitch: R-Car S4 add HW offloading for layer 2 switching
Posted by Michael Dege 3 months ago
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 the L2 driver extension in a separate file. The HW offloading
is automatically configured when a port is added to the bridge device.

Ussage example:
ip link add name br type bridge
ip link set dev tsn0 master br
ip link set dev tsn1 master br
ip link set dev br 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.

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

Usage example:
brctl setageing br 300

Thanks,

Michael

Signed-off-by: Michael Dege <michael.dege@renesas.com>
Signed-off-by: Nikita Yushchenko <nikita.yoush@cogentembedded.com>
---
Michael Dege (3):
      net: renesas: rswitch: rename rswitch.c to rswitch_main.c
      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          | 344 +++++++++++++++++++++
 drivers/net/ethernet/renesas/rswitch_l2.h          |  15 +
 .../ethernet/renesas/{rswitch.c => rswitch_main.c} |  88 +++++-
 5 files changed, 485 insertions(+), 6 deletions(-)
---
base-commit: 19272b37aa4f83ca52bdf9c16d5d81bdd1354494
change-id: 20250616-add_l2_switching-345117105d0d

Best regards,
-- 
Michael Dege <michael.dege@renesas.com>
Re: [PATCH 0/3] net: renesas: rswitch: R-Car S4 add HW offloading for layer 2 switching
Posted by Andrew Lunn 3 months ago
On Fri, Jul 04, 2025 at 07:51:14AM +0200, Michael Dege 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)
> 
> 2. Add the L2 driver extension in a separate file. The HW offloading
> is automatically configured when a port is added to the bridge device.
> 
> Ussage example:
> ip link add name br type bridge
> ip link set dev tsn0 master br
> ip link set dev tsn1 master br
> ip link set dev br up
> ip link set dev tsn0 up
> ip link set dev tsn1 up

Looking at the code, it is not clear to me what would happen with:

ip link add name br0 type bridge
ip link set dev tsn0 master br0
ip link set dev br0 up
ip link set dev tsn0 up
ip link add name br1 type bridge
ip link set dev tsn1 master br1
ip link set dev br1 up
ip link set dev tsn1 up

   Andrew
Re: [PATCH 0/3] net: renesas: rswitch: R-Car S4 add HW offloading for layer 2 switching
Posted by Nikita Yushchenko 3 months ago
> Looking at the code, it is not clear to me what would happen with:
> 
> ip link add name br0 type bridge
> ip link set dev tsn0 master br0
> ip link set dev br0 up
> ip link set dev tsn0 up
> ip link add name br1 type bridge
> ip link set dev tsn1 master br1
> ip link set dev br1 up
> ip link set dev tsn1 up

Per design, it shall enable hardware forwarding when two ports are in the same brdev.
Re: [PATCH 0/3] net: renesas: rswitch: R-Car S4 add HW offloading for layer 2 switching
Posted by Andrew Lunn 3 months ago
On Fri, Jul 04, 2025 at 11:05:14AM +0200, Nikita Yushchenko wrote:
> > Looking at the code, it is not clear to me what would happen with:
> > 
> > ip link add name br0 type bridge
> > ip link set dev tsn0 master br0
> > ip link set dev br0 up
> > ip link set dev tsn0 up
> > ip link add name br1 type bridge
> > ip link set dev tsn1 master br1
> > ip link set dev br1 up
> > ip link set dev tsn1 up
> 
> Per design, it shall enable hardware forwarding when two ports are in the same brdev.

So in this case, the hardware offload has been reserved by br0, but is
in fact never used, since there is only one port in the bridge. If i
was to then do

ip link set dev tsn2 master br1
ip link set dev tsn2 up

br1 would not be offloaded, but done in software.

	Andrew
Re: [PATCH 0/3] net: renesas: rswitch: R-Car S4 add HW offloading for layer 2 switching
Posted by Nikita Yushchenko 3 months ago

04.07.2025 19:53, Andrew Lunn wrote:
> On Fri, Jul 04, 2025 at 11:05:14AM +0200, Nikita Yushchenko wrote:
>>> Looking at the code, it is not clear to me what would happen with:
>>>
>>> ip link add name br0 type bridge
>>> ip link set dev tsn0 master br0
>>> ip link set dev br0 up
>>> ip link set dev tsn0 up
>>> ip link add name br1 type bridge
>>> ip link set dev tsn1 master br1
>>> ip link set dev br1 up
>>> ip link set dev tsn1 up
>>
>> Per design, it shall enable hardware forwarding when two ports are in the same brdev.
> 
> So in this case, the hardware offload has been reserved by br0, but is
> in fact never used, since there is only one port in the bridge. If i
> was to then do
> 
> ip link set dev tsn2 master br1
> ip link set dev tsn2 up
> 
> br1 would not be offloaded, but done in software.

rswitch_update_offload_brdev() calculates which brdev to offload, and it only considers brdev having at 
least two rswitch ports. So in this case br1 shall get offloaded.

Nikita
Re: [PATCH 0/3] net: renesas: rswitch: R-Car S4 add HW offloading for layer 2 switching
Posted by Andrew Lunn 3 months ago
On Fri, Jul 04, 2025 at 07:51:14AM +0200, Michael Dege 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)
> 
> 2. Add the L2 driver extension in a separate file. The HW offloading
> is automatically configured when a port is added to the bridge device.
> 
> Ussage example:
> ip link add name br type bridge
> ip link set dev tsn0 master br
> ip link set dev tsn1 master br
> ip link set dev br up
> ip link set dev tsn0 up
> ip link set dev tsn1 up

It is not wrong, but it is normal for an interface to have a number of
some sort. So br0.

> 
> Layer 2 traffic is now fowarded by HW from port TSN0 to port TSN1.
> 
> 3. Provides the functionality to set the MAC table ageing time in the
> Rswitch.
> 
> Usage example:
> brctl setageing br 300

brctl is deprecated. iproute2 has a method to do this, which would be
a better reference to give.

  Andrew