History

devlink: support default values for param-get and param-set

Support querying and resetting to default param values. Introduce two new devlink netlink attrs: DEVLINK_ATTR_PARAM_VALUE_DEFAULT and DEVLINK_ATTR_PARAM_RESET_DEFAULT. The former is used to contain an optional parameter value inside of the param_value nested attribute. The latter is used in param-set requests from userspace to indicate that the driver should reset the param to its default value. To implement this, two new functions are added to the devlink driver api: devlink_param::get_default() and devlink_param::reset_default(). These callbacks allow drivers to implement default param actions for runtime and permanent cmodes. For driverinit params, the core latches the last value set by a driver via devl_param_driverinit_value_set(), and uses that as the default value for a param. Because default parameter values are optional, it would be impossible to discern whether or not a param of type bool has default value of false or not provided if the default value is encoded using a netlink flag type. For this reason, when a DEVLINK_PARAM_TYPE_BOOL has an associated default value, the default value is encoded using a u8 type.

Daniel Zahka committed 11 months ago

Commit 2a367001 parent 17a42aa6 files · +160 −14Browse files

Showing the changes to include/uapi (1 of 6 files). Show all

Unified · Split

include/uapi/linux/devlink.h+3−0
@@ -639,6 +639,9 @@ enum devlink_attr { · 638 unmodified lines
639 639
640 DEVLINK_ATTR_HEALTH_REPORTER_BURST_PERIOD, /* u64 */640 DEVLINK_ATTR_HEALTH_REPORTER_BURST_PERIOD, /* u64 */
641 641
642 DEVLINK_ATTR_PARAM_VALUE_DEFAULT, /* dynamic */
643 DEVLINK_ATTR_PARAM_RESET_DEFAULT, /* flag */
644
642 /* Add new attributes above here, update the spec in645 /* Add new attributes above here, update the spec in
643 * Documentation/netlink/specs/devlink.yaml and re-generate646 * Documentation/netlink/specs/devlink.yaml and re-generate
644 * net/devlink/netlink_gen.c.647 * net/devlink/netlink_gen.c.