All of lore.kernel.org
 help / color / mirror / Atom feed
* [patch net-next v4 00/13] net: fix netdev to devlink_port linkage and expose to user
@ 2022-11-02 16:01 Jiri Pirko
  2022-11-02 16:01 ` [patch net-next v4 01/13] net: devlink: convert devlink port type-specific pointers to union Jiri Pirko
                   ` (13 more replies)
  0 siblings, 14 replies; 17+ messages in thread
From: Jiri Pirko @ 2022-11-02 16:01 UTC (permalink / raw)
  To: netdev; +Cc: davem, kuba, pabeni, edumazet, tariqt, moshe, saeedm, linux-rdma

From: Jiri Pirko <jiri@nvidia.com>

Currently, the info about linkage from netdev to the related
devlink_port instance is done using ndo_get_devlink_port().
This is not sufficient, as it is up to the driver to implement it and
some of them don't do that. Also it leads to a lot of unnecessary
boilerplate code in all the drivers.

Instead of that, introduce a possibility for driver to expose this
relationship by new SET_NETDEV_DEVLINK_PORT macro which stores it into
dev->devlink_port. It is ensured by the driver init/fini flows that
the devlink_port pointer does not change during the netdev lifetime.
Devlink port is always registered before netdev register and
unregistered after netdev unregister.

Benefit from this linkage setup and remove explicit calls from driver
to devlink_port_type_eth_set() and clear(). Many of the driver
didn't use it correctly anyway. Let the devlink.c to track associated
netdev events and adjust type and type pointer accordingly. Also
use this events to to keep track on ifname change and remove RTNL lock
taking from devlink_nl_port_fill().

Finally, remove the ndo_get_devlink_port() ndo which is no longer used
and expose devlink_port handle as a new netdev netlink attribute to the
user. That way, during the ifname->devlink_port lookup, userspace app
does not have to dump whole devlink port list and instead it can just
do a simple RTM_GETLINK query.

---
v3->v4:
- mostly cosmetics, see patches 5, 6 and 13 for changelogs
v2->v3:
- see patch 6 for a changelog
v1->v2:
- see patches 5 and 6 for changelogs

Jiri Pirko (13):
  net: devlink: convert devlink port type-specific pointers to union
  net: devlink: move port_type_warn_schedule() call to
    __devlink_port_type_set()
  net: devlink: move port_type_netdev_checks() call to
    __devlink_port_type_set()
  net: devlink: take RTNL in port_fill() function only if it is not held
  net: devlink: track netdev with devlink_port assigned
  net: make drivers to use SET_NETDEV_DEVLINK_PORT to set devlink_port
  net: devlink: remove netdev arg from devlink_port_type_eth_set()
  net: devlink: remove net namespace check from devlink_nl_port_fill()
  net: devlink: store copy netdevice ifindex and ifname to allow
    port_fill() without RTNL held
  net: devlink: add not cleared type warning to port unregister
  net: devlink: use devlink_port pointer instead of ndo_get_devlink_port
  net: remove unused ndo_get_devlink_port
  net: expose devlink port over rtnetlink

 drivers/net/ethernet/broadcom/bnxt/bnxt.c     |  14 +-
 .../freescale/dpaa2/dpaa2-eth-devlink.c       |  11 +-
 .../net/ethernet/freescale/dpaa2/dpaa2-eth.c  |   1 +
 .../ethernet/fungible/funeth/funeth_main.c    |  13 +-
 drivers/net/ethernet/intel/ice/ice_devlink.c  |  14 +-
 drivers/net/ethernet/intel/ice/ice_main.c     |  18 +-
 drivers/net/ethernet/intel/ice/ice_repr.c     |  12 +-
 .../marvell/prestera/prestera_devlink.c       |  17 --
 .../marvell/prestera/prestera_devlink.h       |   5 -
 .../ethernet/marvell/prestera/prestera_main.c |   5 +-
 .../net/ethernet/mellanox/mlx4/en_netdev.c    |   9 +-
 drivers/net/ethernet/mellanox/mlx4/main.c     |   2 +-
 .../ethernet/mellanox/mlx5/core/en/devlink.c  |  17 --
 .../ethernet/mellanox/mlx5/core/en/devlink.h  |   2 -
 .../net/ethernet/mellanox/mlx5/core/en_main.c |   4 +-
 .../net/ethernet/mellanox/mlx5/core/en_rep.c  |  44 +---
 drivers/net/ethernet/mellanox/mlxsw/core.c    |  20 +-
 drivers/net/ethernet/mellanox/mlxsw/core.h    |   7 +-
 drivers/net/ethernet/mellanox/mlxsw/minimal.c |  17 +-
 .../net/ethernet/mellanox/mlxsw/spectrum.c    |  16 +-
 drivers/net/ethernet/mscc/ocelot_net.c        |  11 +-
 drivers/net/ethernet/mscc/ocelot_vsc7514.c    |   9 -
 drivers/net/ethernet/netronome/nfp/nfp_app.h  |   2 -
 .../net/ethernet/netronome/nfp/nfp_devlink.c  |  23 +-
 .../ethernet/netronome/nfp/nfp_net_common.c   |   2 -
 .../net/ethernet/netronome/nfp/nfp_net_main.c |  11 +-
 .../net/ethernet/netronome/nfp/nfp_net_repr.c |   1 -
 drivers/net/ethernet/netronome/nfp/nfp_port.h |   2 -
 .../ethernet/pensando/ionic/ionic_devlink.c   |   2 +-
 drivers/net/ethernet/ti/am65-cpsw-nuss.c      |  14 +-
 drivers/net/netdevsim/dev.c                   |   2 -
 drivers/net/netdevsim/netdev.c                |  10 +-
 include/linux/netdevice.h                     |  24 ++-
 include/net/devlink.h                         |  32 ++-
 include/uapi/linux/if_link.h                  |   2 +
 net/core/dev.c                                |  14 +-
 net/core/devlink.c                            | 203 +++++++++++++-----
 net/core/net-sysfs.c                          |   4 +-
 net/core/rtnetlink.c                          |  39 ++++
 net/dsa/dsa2.c                                |   9 -
 net/dsa/slave.c                               |   9 +-
 net/ethtool/ioctl.c                           |  11 +-
 42 files changed, 293 insertions(+), 391 deletions(-)

-- 
2.37.3


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

end of thread, other threads:[~2022-11-07  7:41 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-02 16:01 [patch net-next v4 00/13] net: fix netdev to devlink_port linkage and expose to user Jiri Pirko
2022-11-02 16:01 ` [patch net-next v4 01/13] net: devlink: convert devlink port type-specific pointers to union Jiri Pirko
2022-11-02 16:02 ` [patch net-next v4 02/13] net: devlink: move port_type_warn_schedule() call to __devlink_port_type_set() Jiri Pirko
2022-11-02 16:02 ` [patch net-next v4 03/13] net: devlink: move port_type_netdev_checks() " Jiri Pirko
2022-11-02 16:02 ` [patch net-next v4 04/13] net: devlink: take RTNL in port_fill() function only if it is not held Jiri Pirko
2022-11-02 16:02 ` [patch net-next v4 05/13] net: devlink: track netdev with devlink_port assigned Jiri Pirko
2022-11-06  9:09   ` Ido Schimmel
2022-11-07  7:40     ` Jiri Pirko
2022-11-02 16:02 ` [patch net-next v4 06/13] net: make drivers to use SET_NETDEV_DEVLINK_PORT to set devlink_port Jiri Pirko
2022-11-02 16:02 ` [patch net-next v4 07/13] net: devlink: remove netdev arg from devlink_port_type_eth_set() Jiri Pirko
2022-11-02 16:02 ` [patch net-next v4 08/13] net: devlink: remove net namespace check from devlink_nl_port_fill() Jiri Pirko
2022-11-02 16:02 ` [patch net-next v4 09/13] net: devlink: store copy netdevice ifindex and ifname to allow port_fill() without RTNL held Jiri Pirko
2022-11-02 16:02 ` [patch net-next v4 10/13] net: devlink: add not cleared type warning to port unregister Jiri Pirko
2022-11-02 16:02 ` [patch net-next v4 11/13] net: devlink: use devlink_port pointer instead of ndo_get_devlink_port Jiri Pirko
2022-11-02 16:02 ` [patch net-next v4 12/13] net: remove unused ndo_get_devlink_port Jiri Pirko
2022-11-02 16:02 ` [patch net-next v4 13/13] net: expose devlink port over rtnetlink Jiri Pirko
2022-11-04  5:00 ` [patch net-next v4 00/13] net: fix netdev to devlink_port linkage and expose to user patchwork-bot+netdevbpf

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.