[PATCH net-next V2 0/7] devlink: add per-port resource support

Tariq Toukan posted 7 patches 1 day, 14 hours ago
Documentation/netlink/specs/devlink.yaml      |  23 ++
.../networking/devlink/devlink-resource.rst   |  36 +++
.../net/ethernet/mellanox/mlx5/core/devlink.h |   4 +
.../mellanox/mlx5/core/esw/devlink_port.c     |  37 +++
drivers/net/netdevsim/dev.c                   |  23 +-
drivers/net/netdevsim/netdevsim.h             |   4 +
include/net/devlink.h                         |   8 +
include/uapi/linux/devlink.h                  |   3 +
net/devlink/netlink.c                         |   2 +-
net/devlink/netlink_gen.c                     |  32 +-
net/devlink/netlink_gen.h                     |   6 +-
net/devlink/port.c                            |   3 +
net/devlink/resource.c                        | 281 ++++++++++++++----
.../drivers/net/netdevsim/devlink.sh          |  37 ++-
14 files changed, 441 insertions(+), 58 deletions(-)
[PATCH net-next V2 0/7] devlink: add per-port resource support
Posted by Tariq Toukan 1 day, 14 hours ago
Hi,

This series adds devlink per-port resource support.
See detailed description by Or below [1].

Regards,
Tariq

[1]
Currently, devlink resources are only available at the device level.
However, some resources are inherently per-port, such as the maximum
number of subfunctions (SFs) that can be created on a specific PF port.
This limitation prevents user space from obtaining accurate per-port
capacity information.
This series adds infrastructure for per-port resources in devlink core
and implements it in the mlx5 driver to expose the max_SFs resource on
PF devlink ports.

Patch #1 refactors resource functions to be generic
Patch #2 adds port-level resource registration functions
Patch #3 adds port resource netlink command
Patch #4 registers SF resource on PF port representor in mlx5
Patch #5 adds port resource registration to netdevsim for testing
Patch #6 adds selftest for devlink port resources
Patch #7 adds documentation for port-level resources

With this series (and upcoming userspace patches), users can query
per-port resources:

$ devlink port resource show pci/0000:03:00.0/196608
pci/0000:03:00.0/196608:
  name max_SFs size 20 unit entry

$ devlink port resource show
pci/0000:03:00.0/196608:
  name max_SFs size 20 unit entry
pci/0000:03:00.1/262144:
  name max_SFs size 20 unit entry

Userspace patches for iproute2:
https://github.com/ohartoov/iproute2/tree/port_resource

V2:
- Skip selftest on old userspace that doesn't have the devlink
  port resource command.
- Add link to the userspace patch.
- Rename internal helper functions to follow kernel __ prefix
  convention.
- Split first patch into three logical commits.
- Change names with "res" to "resource".
- Change netdevsim test resource to be generic and not with max_sfs.
- Change "max_sfs" to "max_SFs" in documentation file.
- V1 link: https://lore.kernel.org/all/20260203071033.1709445-1-tariqt@nvidia.com/

Or Har-Toov (7):
  devlink: Refactor resource functions to be generic
  devlink: Add port-level resource registration infrastructure
  devlink: Add port resource netlink command
  net/mlx5: Register SF resource on PF port representor
  netdevsim: Add devlink port resource registration
  selftest: netdevsim: Add devlink port resource test
  devlink: Document port-level resources

 Documentation/netlink/specs/devlink.yaml      |  23 ++
 .../networking/devlink/devlink-resource.rst   |  36 +++
 .../net/ethernet/mellanox/mlx5/core/devlink.h |   4 +
 .../mellanox/mlx5/core/esw/devlink_port.c     |  37 +++
 drivers/net/netdevsim/dev.c                   |  23 +-
 drivers/net/netdevsim/netdevsim.h             |   4 +
 include/net/devlink.h                         |   8 +
 include/uapi/linux/devlink.h                  |   3 +
 net/devlink/netlink.c                         |   2 +-
 net/devlink/netlink_gen.c                     |  32 +-
 net/devlink/netlink_gen.h                     |   6 +-
 net/devlink/port.c                            |   3 +
 net/devlink/resource.c                        | 281 ++++++++++++++----
 .../drivers/net/netdevsim/devlink.sh          |  37 ++-
 14 files changed, 441 insertions(+), 58 deletions(-)


base-commit: 021718d2cc1a2df2f53b06968fa89280199371bd
-- 
2.44.0
Re: [PATCH net-next V2 0/7] devlink: add per-port resource support
Posted by Jiri Pirko 19 hours ago
Thu, Feb 05, 2026 at 03:28:26PM +0100, tariqt@nvidia.com wrote:
>Hi,
>
>This series adds devlink per-port resource support.
>See detailed description by Or below [1].
>
>Regards,
>Tariq
>
>[1]
>Currently, devlink resources are only available at the device level.
>However, some resources are inherently per-port, such as the maximum
>number of subfunctions (SFs) that can be created on a specific PF port.
>This limitation prevents user space from obtaining accurate per-port
>capacity information.
>This series adds infrastructure for per-port resources in devlink core
>and implements it in the mlx5 driver to expose the max_SFs resource on
>PF devlink ports.
>
>Patch #1 refactors resource functions to be generic
>Patch #2 adds port-level resource registration functions
>Patch #3 adds port resource netlink command
>Patch #4 registers SF resource on PF port representor in mlx5
>Patch #5 adds port resource registration to netdevsim for testing
>Patch #6 adds selftest for devlink port resources
>Patch #7 adds documentation for port-level resources

Could you add dumpit op for the current devlink resource? I think that
was indented originally. Will help to see the whole code-picture :)

Thanks!
Re: [PATCH net-next V2 0/7] devlink: add per-port resource support
Posted by Jakub Kicinski 1 day, 4 hours ago
On Thu, 5 Feb 2026 16:28:26 +0200 Tariq Toukan wrote:
> Userspace patches for iproute2:
> https://github.com/ohartoov/iproute2/tree/port_resource

I pulled this but the test still doesn't pass:

# TEST: resource test                                                 [ OK ]
# TEST: port resource test                                            [FAIL]
# Unexpected resource name test_resource (expected max_sfs)
# TEST: dev_info test                                                 [ OK ]
# TEST: empty reporter test                                           [ OK ]

https://netdev-ctrl.bots.linux.dev/logs/vmksft/netdevsim/results/505601/9-devlink-sh/stdout
-- 
pw-bot: cr