netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* understanding switchdev notifications
@ 2024-08-08  0:48 Chris Packham
  2024-08-14  6:54 ` Tobias Waldekranz
  0 siblings, 1 reply; 4+ messages in thread
From: Chris Packham @ 2024-08-08  0:48 UTC (permalink / raw)
  To: netdev, linux-kernel@vger.kernel.org

Hi,

I'm trying to get to grips with how the switchdev notifications are 
supposed to be used when developing a switchdev driver.

I have been reading through 
https://www.kernel.org/doc/html/latest/networking/switchdev.html which 
covers a few things but doesn't go into detail around the notifiers that 
one needs to implement for a new switchdev driver (which is probably 
very dependent on what the hardware is capable of).

Specifically right now I'm looking at having a switch port join a vlan 
aware bridge. I have a configuration something like this

     ip link add br0 type bridge vlan_filtering 1
     ip link set sw1p5 master br0
     ip link set sw1p1 master br0
     bridge vlan add vid 2 dev br0 self
     ip link add link br0 br0.2 type vlan id 2
     ip addr add dev br0.2 192.168.2.1/24
     bridge vlan add vid 2 dev lan5 pvid untagged
     bridge vlan add vid 2 dev lan1
     ip link set sw1p5 up
     ip link set sw1p1 up
     ip link set br0 up
     ip link set br0.2 up

Then I'm testing by sending a ping to a nonexistent host on the 
192.168.2.0/24 subnet and looking at the traffic with tcpdump on another 
device connected to sw1p5.

I'm a bit confused about how I should be calling 
switchdev_bridge_port_offload(). It takes two netdevs (brport_dev and 
dev) but as far as I've been able to see all the callers end up passing 
the same netdev for both of these (some create a driver specific brport 
but this still ends up with brport->dev and dev being the same object).

I've figured out that I need to set tx_fwd_offload=true so that the 
bridge software only sends one packet to the hardware. That makes sense 
as a way of saying the my hardware can take care of sending the packet 
out the right ports.

I do have a problem that what I get from the bridge has a vlan tag 
inserted (which makes sense in sw when the packet goes from br0.2 to 
br0). But I don't actually need it as the hardware will insert a tag for 
me if the port is setup for egress tagging. I can shuffle the Ethernet 
header up but I was wondering if there was a way of telling the bridge 
not to insert the tag?

Finally I'm confused about the atomic_nb/atomic_nb parameters. Some 
drivers just pass NULL and others pass the same notifier blocks that 
they've already registered with 
register_switchdev_notifier()/register_switchdev_notifier(). If 
notifiers are registered why does switchdev_bridge_port_offload() take 
them as parameters?

Thanks,
Chris



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-08-15  7:02 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-08-08  0:48 understanding switchdev notifications Chris Packham
2024-08-14  6:54 ` Tobias Waldekranz
2024-08-14 22:18   ` Chris Packham
2024-08-15  7:02     ` Tobias Waldekranz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).