From: Tariq Toukan <tariqt@nvidia.com>
To: Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Andrew Lunn <andrew+netdev@lunn.ch>,
"David S. Miller" <davem@davemloft.net>
Cc: Donald Hunter <donald.hunter@gmail.com>,
Jiri Pirko <jiri@resnulli.us>, Jonathan Corbet <corbet@lwn.net>,
Saeed Mahameed <saeedm@nvidia.com>,
"Leon Romanovsky" <leon@kernel.org>,
Tariq Toukan <tariqt@nvidia.com>, Mark Bloch <mbloch@nvidia.com>,
Shuah Khan <shuah@kernel.org>, <netdev@vger.kernel.org>,
<linux-kernel@vger.kernel.org>, <linux-doc@vger.kernel.org>,
<linux-rdma@vger.kernel.org>, <linux-kselftest@vger.kernel.org>,
Gal Pressman <gal@nvidia.com>,
Dragos Tatulea <dtatulea@nvidia.com>,
Shay Drory <shayd@nvidia.com>, Jiri Pirko <jiri@nvidia.com>,
Moshe Shemesh <moshe@nvidia.com>,
Or Har-Toov <ohartoov@nvidia.com>
Subject: [PATCH net-next V3 05/10] devlink: Add port-level resource registration infrastructure
Date: Fri, 27 Feb 2026 00:19:11 +0200 [thread overview]
Message-ID: <20260226221916.1800227-6-tariqt@nvidia.com> (raw)
In-Reply-To: <20260226221916.1800227-1-tariqt@nvidia.com>
From: Or Har-Toov <ohartoov@nvidia.com>
The current devlink resource infrastructure supports only device-level
resources. Some hardware resources are associated with specific ports
rather than the entire device, and today we have no way to show resource
per-port.
Add support for registering resources at the port level.
Signed-off-by: Or Har-Toov <ohartoov@nvidia.com>
Reviewed-by: Shay Drori <shayd@nvidia.com>
Reviewed-by: Moshe Shemesh <moshe@nvidia.com>
Reviewed-by: Jiri Pirko <jiri@nvidia.com>
Signed-off-by: Tariq Toukan <tariqt@nvidia.com>
---
include/net/devlink.h | 8 ++++++++
net/devlink/port.c | 3 +++
net/devlink/resource.c | 43 ++++++++++++++++++++++++++++++++++++++++++
3 files changed, 54 insertions(+)
diff --git a/include/net/devlink.h b/include/net/devlink.h
index 48e1ad067836..1ba12ab51e66 100644
--- a/include/net/devlink.h
+++ b/include/net/devlink.h
@@ -129,6 +129,7 @@ struct devlink_rate {
struct devlink_port {
struct list_head list;
struct list_head region_list;
+ struct list_head resource_list;
struct devlink *devlink;
const struct devlink_port_ops *ops;
unsigned int index;
@@ -1881,6 +1882,13 @@ void devlink_resources_unregister(struct devlink *devlink);
int devl_resource_size_get(struct devlink *devlink,
u64 resource_id,
u64 *p_resource_size);
+int
+devl_port_resource_register(struct devlink_port *devlink_port,
+ const char *resource_name,
+ u64 resource_size, u64 resource_id,
+ u64 parent_resource_id,
+ const struct devlink_resource_size_params *params);
+void devl_port_resources_unregister(struct devlink_port *devlink_port);
int devl_dpipe_table_resource_set(struct devlink *devlink,
const char *table_name, u64 resource_id,
u64 resource_units);
diff --git a/net/devlink/port.c b/net/devlink/port.c
index 93d8a25bb920..10d0d88894a3 100644
--- a/net/devlink/port.c
+++ b/net/devlink/port.c
@@ -1024,6 +1024,7 @@ void devlink_port_init(struct devlink *devlink,
return;
devlink_port->devlink = devlink;
INIT_LIST_HEAD(&devlink_port->region_list);
+ INIT_LIST_HEAD(&devlink_port->resource_list);
devlink_port->initialized = true;
}
EXPORT_SYMBOL_GPL(devlink_port_init);
@@ -1041,6 +1042,7 @@ EXPORT_SYMBOL_GPL(devlink_port_init);
void devlink_port_fini(struct devlink_port *devlink_port)
{
WARN_ON(!list_empty(&devlink_port->region_list));
+ WARN_ON(!list_empty(&devlink_port->resource_list));
}
EXPORT_SYMBOL_GPL(devlink_port_fini);
@@ -1135,6 +1137,7 @@ void devl_port_unregister(struct devlink_port *devlink_port)
devlink_port_notify(devlink_port, DEVLINK_CMD_PORT_DEL);
xa_erase(&devlink_port->devlink->ports, devlink_port->index);
WARN_ON(!list_empty(&devlink_port->reporter_list));
+ devlink_port_fini(devlink_port);
devlink_port->registered = false;
}
EXPORT_SYMBOL_GPL(devl_port_unregister);
diff --git a/net/devlink/resource.c b/net/devlink/resource.c
index 10043ad26dfd..71f00e580f59 100644
--- a/net/devlink/resource.c
+++ b/net/devlink/resource.c
@@ -613,3 +613,46 @@ void devl_resource_occ_get_unregister(struct devlink *devlink,
resource->occ_get_priv = NULL;
}
EXPORT_SYMBOL_GPL(devl_resource_occ_get_unregister);
+
+/**
+ * devl_port_resource_register - devlink port resource register
+ *
+ * @devlink_port: devlink port
+ * @resource_name: resource's name
+ * @resource_size: resource's size
+ * @resource_id: resource's id
+ * @parent_resource_id: resource's parent id
+ * @params: size parameters
+ *
+ * Generic resources should reuse the same names across drivers.
+ * Please see the generic resources list at:
+ * Documentation/networking/devlink/devlink-resource.rst
+ *
+ * Return: 0 on success, negative error code otherwise.
+ */
+int
+devl_port_resource_register(struct devlink_port *devlink_port,
+ const char *resource_name,
+ u64 resource_size, u64 resource_id,
+ u64 parent_resource_id,
+ const struct devlink_resource_size_params *params)
+{
+ return __devl_resource_register(devlink_port->devlink,
+ &devlink_port->resource_list,
+ resource_name, resource_size,
+ resource_id, parent_resource_id,
+ params);
+}
+EXPORT_SYMBOL_GPL(devl_port_resource_register);
+
+/**
+ * devl_port_resources_unregister - unregister all devlink port resources
+ *
+ * @devlink_port: devlink port
+ */
+void devl_port_resources_unregister(struct devlink_port *devlink_port)
+{
+ __devl_resources_unregister(devlink_port->devlink,
+ &devlink_port->resource_list);
+}
+EXPORT_SYMBOL_GPL(devl_port_resources_unregister);
--
2.44.0
next prev parent reply other threads:[~2026-02-26 22:20 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-26 22:19 [PATCH net-next V3 00/10] devlink: add per-port resource support Tariq Toukan
2026-02-26 22:19 ` [PATCH net-next V3 01/10] devlink: Add dump support for device-level resources Tariq Toukan
2026-02-26 22:19 ` [PATCH net-next V3 02/10] selftest: netdevsim: Add resource dump test Tariq Toukan
2026-02-26 22:19 ` [PATCH net-next V3 03/10] devlink: Add dump to resource documentation Tariq Toukan
2026-02-26 22:19 ` [PATCH net-next V3 04/10] devlink: Refactor resource functions to be generic Tariq Toukan
2026-02-26 22:19 ` Tariq Toukan [this message]
2026-02-26 22:19 ` [PATCH net-next V3 06/10] devlink: Add port resource netlink command Tariq Toukan
2026-02-26 22:19 ` [PATCH net-next V3 07/10] net/mlx5: Register SF resource on PF port representor Tariq Toukan
2026-02-26 22:19 ` [PATCH net-next V3 08/10] netdevsim: Add devlink port resource registration Tariq Toukan
2026-02-26 22:19 ` [PATCH net-next V3 09/10] selftest: netdevsim: Add devlink port resource test Tariq Toukan
2026-02-26 22:19 ` [PATCH net-next V3 10/10] devlink: Document port-level resources Tariq Toukan
2026-03-03 3:14 ` Jakub Kicinski
2026-03-04 10:06 ` Jiri Pirko
2026-03-03 3:26 ` [PATCH net-next V3 00/10] devlink: add per-port resource support Jakub Kicinski
2026-03-04 10:05 ` Jiri Pirko
2026-03-04 10:34 ` Jiri Pirko
2026-03-04 18:15 ` Jakub Kicinski
2026-03-05 7:56 ` Jiri Pirko
2026-03-05 14:37 ` Jakub Kicinski
2026-03-06 12:13 ` Jiri Pirko
2026-03-06 20:03 ` Jakub Kicinski
2026-03-08 16:03 ` Or Har-Toov
2026-03-09 20:33 ` Jakub Kicinski
2026-03-11 18:24 ` Or Har-Toov
2026-03-11 21:51 ` Jakub Kicinski
2026-03-12 8:34 ` Jiri Pirko
2026-03-12 14:19 ` Jakub Kicinski
2026-03-12 14:29 ` Jiri Pirko
2026-03-12 14:36 ` Jakub Kicinski
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260226221916.1800227-6-tariqt@nvidia.com \
--to=tariqt@nvidia.com \
--cc=andrew+netdev@lunn.ch \
--cc=corbet@lwn.net \
--cc=davem@davemloft.net \
--cc=donald.hunter@gmail.com \
--cc=dtatulea@nvidia.com \
--cc=edumazet@google.com \
--cc=gal@nvidia.com \
--cc=jiri@nvidia.com \
--cc=jiri@resnulli.us \
--cc=kuba@kernel.org \
--cc=leon@kernel.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=linux-rdma@vger.kernel.org \
--cc=mbloch@nvidia.com \
--cc=moshe@nvidia.com \
--cc=netdev@vger.kernel.org \
--cc=ohartoov@nvidia.com \
--cc=pabeni@redhat.com \
--cc=saeedm@nvidia.com \
--cc=shayd@nvidia.com \
--cc=shuah@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox