net: devlink: track netdev with devlink_port assigned
authorJiri Pirko <jiri@nvidia.com>
Wed, 2 Nov 2022 16:02:03 +0000 (17:02 +0100)
committerJakub Kicinski <kuba@kernel.org>
Fri, 4 Nov 2022 03:48:33 +0000 (20:48 -0700)
commit02a68a47eadedf95748facfca6ced31fb0181d52
treeec9516721ac6b31f4d0c9ece1dfa6fbf5f709c6c
parentd41c9dbd12745cfc1cb2946cd99016d83c2c5364
net: devlink: track netdev with devlink_port assigned

Currently, ethernet drivers are using devlink_port_type_eth_set() and
devlink_port_type_clear() to set devlink port type and link to related
netdev.

Instead of calling them directly, let the driver use
SET_NETDEV_DEVLINK_PORT macro to assign devlink_port pointer and let
devlink to track it. Note the devlink port pointer is static during
the time netdevice is registered.

In devlink code, use per-namespace netdev notifier to track
the netdevices with devlink_port assigned and change the internal
devlink_port type and related type pointer accordingly.

Signed-off-by: Jiri Pirko <jiri@nvidia.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
include/linux/netdevice.h
net/core/dev.c
net/core/devlink.c