Skip to content

netdevsim: implement proper device model

Jiri Pirko netdev 3 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v4 Latest16 patches 4 repliesIn review
  2. v216 patches 11 repliesSuperseded
  3. v115 patches 6 repliesSuperseded

Patches in v4 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/16netdevsim: move device registration on bus to be done earlier in initdrivers/net/netdevsim/netdev.c+13 -130 replies
2/16netdevsim: create devlink instance per netdevsim instancedrivers/net/netdevsim/devlink.c drivers/net/netdevsim/fib.c drivers/net/netdevsim/netdev.c +1 more+124 -2020 replies
3/16netdevsim: rename devlink.c to dev.c to contain per-dev(asic) itemsdrivers/net/netdevsim/Makefile drivers/net/netdevsim/dev.c drivers/net/netdevsim/netdev.c +1 more+56 -590 replies
4/16netdevsim: put netdevsim bus code into separate filedrivers/net/netdevsim/Makefile drivers/net/netdevsim/bus.c drivers/net/netdevsim/netdev.c +1 more+38 -130 replies
5/16netdevsim: move device registration and related code to bus.cdrivers/net/netdevsim/bus.c drivers/net/netdevsim/dev.c drivers/net/netdevsim/netdev.c +1 more+207 -1630 replies
6/16netdevsim: add stub netdevsim driver implementationdrivers/net/netdevsim/bus.c+20 -11 reply
7/16netdevsim: use ida for bus device idsdrivers/net/netdevsim/bus.c+10 -30 replies
8/16netdevsim: add bus attributes to add new and delete devicesdrivers/net/netdevsim/bus.c drivers/net/netdevsim/netdev.c drivers/net/netdevsim/netdevsim.h+99 -40 replies
9/16netdevsim: rename dev_init/exit() functions and make them independent on nsdrivers/net/netdevsim/dev.c drivers/net/netdevsim/netdev.c drivers/net/netdevsim/netdevsim.h+30 -280 replies
10/16netdevsim: merge sdev into devdrivers/net/netdevsim/Makefile drivers/net/netdevsim/bpf.c drivers/net/netdevsim/dev.c +3 more+120 -1190 replies
11/16netdevsim: generate random switch id instead of using dev iddrivers/net/netdevsim/dev.c drivers/net/netdevsim/netdev.c drivers/net/netdevsim/netdevsim.h+5 -20 replies
12/16netdevsim: change debugfs tree topologydrivers/net/netdevsim/dev.c drivers/net/netdevsim/netdev.c drivers/net/netdevsim/netdevsim.h +2 more+15 -170 replies
13/16netdevsim: implement dev probe/remove skeleton with port initializationdrivers/net/netdevsim/bus.c drivers/net/netdevsim/dev.c drivers/net/netdevsim/netdev.c +1 more+160 -300 replies
14/16netdevsim: extend device attrs to support port addition and deletiondrivers/net/netdevsim/bus.c drivers/net/netdevsim/dev.c drivers/net/netdevsim/netdevsim.h+92 -40 replies
15/16netdevsim: move netdev creation/destruction to dev probedrivers/net/netdevsim/bpf.c drivers/net/netdevsim/bus.c drivers/net/netdevsim/dev.c +5 more+238 -1970 replies
16/16netdevsim: implement ndo_get_devlink_portdrivers/net/netdevsim/netdev.c+8 -00 replies

Reviews trailers per patch

None of the 16 patches has a Reviewed-by or Acked-by of their own; the series has one for all of them.

PatchJakub Kicinski
SeriesA-b
1/16
2/16
3/16
4/16
5/16
6/16
7/16
8/16
9/16
10/16
11/16
12/16
13/16
14/16
15/16
16/16

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v4 thread

Cover letter [patch net-next v4 00/16] netdevsim: implement proper device model

From: Jiri Pirko <[email protected]>

Currently the model of netdevsim is a bit odd in multiple ways.
1) devlink instance is not in any way related with actual netdevsim netdevices. Instead, it is created per-namespace.
2) multi-port netdevsim device is done using "link" attribute.
3) netdevsim bus is there only to have something to bind the netdev to, it really does not act as a bus.
4) netdevsim instances are created by "ip link add" which is great for soft devices with no hw backend. The rtnl core allocates netdev and calls into driver holding rtnl mutex. For hw-backed devices, this flow is wrong as it breaks order in which things are done.

This patchset adjust netdevsim to fix all above.

In order to support proper devlink and devlink port instances and to be able to emulate real devices, there is need to implement bus probe and instantiate everything from there. User can specify device id and port count to be instantianted. For example:

$ echo "10 4" > /sys/bus/netdevsim/new_device

Then devlink shows this:

$ devlink dev
netdevsim/netdevsim10
$ devlink port
netdevsim/netdevsim10/0: type eth netdev eni0np1 flavour physical
netdevsim/netdevsim10/1: type eth netdev eni0np2 flavour physical
netdevsim/netdevsim10/2: type eth netdev eni0np3 flavour physical
netdevsim/netdevsim10/3: type eth netdev eni0np4 flavour physical

There is possible to add and delete ports using their indexes during netdevsim device lifetime like this:

# echo "43" > /sys/bus/netdevsim/devices/netdevsim10/new_port
# echo "0" > /sys/bus/netdevsim/devices/netdevsim10/del_port

Then devlink shows this:

$ devlink port
netdevsim/netdevsim10/1: type eth netdev eni10np2 flavour physical
netdevsim/netdevsim10/2: type eth netdev eni10np3 flavour physical
netdevsim/netdevsim10/3: type eth netdev eni10np4 flavour physical
netdevsim/netdevsim10/43: type eth netdev eni10np44 flavour physical

Debugfs topology is also adjusted a bit. The rest stays the same as before.

Udev bits are merged un systemd upstream git:
https://github.com/systemd/systemd/commit/eaa9d507d85509c8bf727356e3884ec54b0fc646

See individual patches for changelog.

Jiri Pirko (16):
netdevsim: move device registration on bus to be done earlier in init
netdevsim: create devlink instance per netdevsim instance
netdevsim: rename devlink.c to dev.c to contain per-dev(asic) items
netdevsim: put netdevsim bus code into separate file
netdevsim: move device registration and related code to bus.c
netdevsim: add stub netdevsim driver implementation
netdevsim: use ida for bus device ids
netdevsim: add bus attributes to add new and delete devices
netdevsim: rename dev_init/exit() functions and make them independent
on ns
netdevsim: merge sdev into dev
netdevsim: generate random switch id instead of using dev id
netdevsim: change debugfs tree topology
netdevsim: implement dev probe/remove skeleton with port
initialization
netdevsim: extend device attrs to support port addition and deletion
netdevsim: move netdev creation/destruction to dev probe
netdevsim: implement ndo_get_devlink_port

 drivers/net/netdevsim/Makefile              |   2 +-
 drivers/net/netdevsim/bpf.c                 |  92 ++--
 drivers/net/netdevsim/bus.c                 | 341 +++++++++++++++
 drivers/net/netdevsim/dev.c                 | 447 ++++++++++++++++++++
 drivers/net/netdevsim/devlink.c             | 295 -------------
 drivers/net/netdevsim/fib.c                 | 102 ++---
 drivers/net/netdevsim/ipsec.c               |   3 +-
 drivers/net/netdevsim/netdev.c              | 396 +++++------------
 drivers/net/netdevsim/netdevsim.h           | 130 +++---
 tools/testing/selftests/bpf/test_offload.py | 227 ++++++----
 tools/testing/selftests/net/rtnetlink.sh    |  11 +-
 11 files changed, 1213 insertions(+), 833 deletions(-)
 create mode 100644 drivers/net/netdevsim/bus.c
 create mode 100644 drivers/net/netdevsim/dev.c
 delete mode 100644 drivers/net/netdevsim/devlink.c
Signature · 1 line
2.17.2