Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

devlink: Add port-level resource registration infrastructure

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>
Link: https://patch.msgid.link/20260407194107.148063-3-tariqt@nvidia.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Or Har-Toov and committed by
Jakub Kicinski
6f38acfe 7be3163c

+53
+8
include/net/devlink.h
··· 129 129 struct devlink_port { 130 130 struct list_head list; 131 131 struct list_head region_list; 132 + struct list_head resource_list; 132 133 struct devlink *devlink; 133 134 const struct devlink_port_ops *ops; 134 135 unsigned int index; ··· 1892 1891 int devl_resource_size_get(struct devlink *devlink, 1893 1892 u64 resource_id, 1894 1893 u64 *p_resource_size); 1894 + int 1895 + devl_port_resource_register(struct devlink_port *devlink_port, 1896 + const char *resource_name, 1897 + u64 resource_size, u64 resource_id, 1898 + u64 parent_resource_id, 1899 + const struct devlink_resource_size_params *params); 1900 + void devl_port_resources_unregister(struct devlink_port *devlink_port); 1895 1901 int devl_dpipe_table_resource_set(struct devlink *devlink, 1896 1902 const char *table_name, u64 resource_id, 1897 1903 u64 resource_units);
+2
net/devlink/port.c
··· 1025 1025 return; 1026 1026 devlink_port->devlink = devlink; 1027 1027 INIT_LIST_HEAD(&devlink_port->region_list); 1028 + INIT_LIST_HEAD(&devlink_port->resource_list); 1028 1029 devlink_port->initialized = true; 1029 1030 } 1030 1031 EXPORT_SYMBOL_GPL(devlink_port_init); ··· 1043 1042 void devlink_port_fini(struct devlink_port *devlink_port) 1044 1043 { 1045 1044 WARN_ON(!list_empty(&devlink_port->region_list)); 1045 + WARN_ON(!list_empty(&devlink_port->resource_list)); 1046 1046 } 1047 1047 EXPORT_SYMBOL_GPL(devlink_port_fini); 1048 1048
+43
net/devlink/resource.c
··· 532 532 resource->occ_get_priv = NULL; 533 533 } 534 534 EXPORT_SYMBOL_GPL(devl_resource_occ_get_unregister); 535 + 536 + /** 537 + * devl_port_resource_register - devlink port resource register 538 + * 539 + * @devlink_port: devlink port 540 + * @resource_name: resource's name 541 + * @resource_size: resource's size 542 + * @resource_id: resource's id 543 + * @parent_resource_id: resource's parent id 544 + * @params: size parameters 545 + * 546 + * Generic resources should reuse the same names across drivers. 547 + * Please see the generic resources list at: 548 + * Documentation/networking/devlink/devlink-resource.rst 549 + * 550 + * Return: 0 on success, negative error code otherwise. 551 + */ 552 + int 553 + devl_port_resource_register(struct devlink_port *devlink_port, 554 + const char *resource_name, 555 + u64 resource_size, u64 resource_id, 556 + u64 parent_resource_id, 557 + const struct devlink_resource_size_params *params) 558 + { 559 + return __devl_resource_register(devlink_port->devlink, 560 + &devlink_port->resource_list, 561 + resource_name, resource_size, 562 + resource_id, parent_resource_id, 563 + params); 564 + } 565 + EXPORT_SYMBOL_GPL(devl_port_resource_register); 566 + 567 + /** 568 + * devl_port_resources_unregister - unregister all devlink port resources 569 + * 570 + * @devlink_port: devlink port 571 + */ 572 + void devl_port_resources_unregister(struct devlink_port *devlink_port) 573 + { 574 + __devl_resources_unregister(devlink_port->devlink, 575 + &devlink_port->resource_list); 576 + } 577 + EXPORT_SYMBOL_GPL(devl_port_resources_unregister);