Thread (14 messages) 14 messages, 2 authors, 2025-11-18

RE: [PATCH net-next v4 3/6] devlink: support default values for param-get and param-set

From: Loktionov, Aleksandr <hidden>
Date: 2025-11-18 07:27:08
Also in: linux-doc, linux-rdma

quoted hunk ↗ jump to hunk
-----Original Message-----
From: Daniel Zahka <daniel.zahka@gmail.com>
Sent: Tuesday, November 18, 2025 1:24 AM
To: Jiri Pirko <jiri@resnulli.us>; David S. Miller
[off-list ref]; Eric Dumazet [off-list ref]; Jakub
Kicinski [off-list ref]; Paolo Abeni [off-list ref]; Simon
Horman [off-list ref]; Jonathan Corbet [off-list ref]; Srujana
Challa [off-list ref]; Bharat Bhushan [off-list ref];
Herbert Xu [off-list ref]; Brett Creeley
[off-list ref]; Andrew Lunn [off-list ref]; Michael
Chan [off-list ref]; Pavan Chebbi
[off-list ref]; Nguyen, Anthony L
[off-list ref]; Kitszel, Przemyslaw
[off-list ref]; Goutham, Sunil Kovvuri
[off-list ref]; Linu Cherian [off-list ref]; Geetha
sowjanya [off-list ref]; Jerin Jacob [off-list ref];
hariprasad [off-list ref]; Subbaraya Sundeep
[off-list ref]; Tariq Toukan [off-list ref]; Saeed
Mahameed [off-list ref]; Leon Romanovsky [off-list ref]; Mark
Bloch [off-list ref]; Ido Schimmel [off-list ref]; Petr
Machata [off-list ref]; Manish Chopra [off-list ref];
Maxime Coquelin [off-list ref]; Alexandre Torgue
[off-list ref]; Siddharth Vadapalli <s-
vadapalli@ti.com>; Roger Quadros [off-list ref]; Loic Poulain
[off-list ref]; Sergey Ryazanov
[off-list ref]; Johannes Berg [off-list ref];
Vladimir Oltean [off-list ref]; Michal Swiatkowski
[off-list ref]; Loktionov, Aleksandr
[off-list ref]; Ertman, David M
[off-list ref]; Vlad Dumitrescu [off-list ref];
Russell King (Oracle) [off-list ref]; Alexander Sverdlin
[off-list ref]; Lorenzo Bianconi [off-list ref]
Cc: netdev@vger.kernel.org; linux-doc@vger.kernel.org; linux-
rdma@vger.kernel.org
Subject: [PATCH net-next v4 3/6] 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.

Signed-off-by: Daniel Zahka <daniel.zahka@gmail.com>
---
 Documentation/netlink/specs/devlink.yaml      |   9 ++
 .../networking/devlink/devlink-params.rst     |  10 ++
 include/net/devlink.h                         |  42 +++++++
 include/uapi/linux/devlink.h                  |   3 +
 net/devlink/netlink_gen.c                     |   5 +-
 net/devlink/param.c                           | 105 ++++++++++++++++-
-
 6 files changed, 160 insertions(+), 14 deletions(-)
diff --git a/Documentation/netlink/specs/devlink.yaml
b/Documentation/netlink/specs/devlink.yaml
index 426d5aa7d955..837112da6738 100644
--- a/Documentation/netlink/specs/devlink.yaml
+++ b/Documentation/netlink/specs/devlink.yaml
@@ -859,6 +859,14 @@ attribute-sets:
         name: health-reporter-burst-period
         type: u64
         doc: Time (in msec) for recoveries before starting the grace
period.
+
...
quoted hunk ↗ jump to hunk
diff --git a/include/uapi/linux/devlink.h
b/include/uapi/linux/devlink.h index 157f11d3fb72..e7d6b6d13470 100644
--- a/include/uapi/linux/devlink.h
+++ b/include/uapi/linux/devlink.h
@@ -639,6 +639,9 @@ enum devlink_attr {

 	DEVLINK_ATTR_HEALTH_REPORTER_BURST_PERIOD,	/* u64 */

+	DEVLINK_ATTR_PARAM_VALUE_DEFAULT,	/* dynamic */
+	DEVLINK_ATTR_PARAM_RESET_DEFAULT,	/* flag */
+
The patch introduces a new UAPI attribute DEVLINK_ATTR_PARAM_VALUE_DEFAULT but Documentation/netlink/specs/devlink.yaml only documents param-reset-default.
The spec should also describe the output attribute that appears in the nested param-value dump ("default" value), otherwise the generated tooling/specs are out of sync with UAPI and the committed generated C (netlink_gen.c).

I'm afraid you forgot to add a YAML entry for the nested attribute (e.g. under the param-value attribute set, typically alongside param-value-data and param-value-cmode), describing its type per param and the bool/u8 encoding rule covered in the commit message.
Am I right?

With the best regards
Alex
--
2.47.3
  
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help