devlink: Add support for 64bit parameters
Subsystems (2)
PATCH 1/1 devlink: Add support for 64bit parameters
Kernel commit c0ef144695910 ("devlink: Add support for u64 parameters") added support for 64bit devlink parameters, add the support for them also into devlink utility userspace counterpart.
--- devlink/devlink.c | 78 +++++++++++++++++++++++++++++++++++------------ 1 file changed, 59 insertions(+), 19 deletions(-)
devlink/devlink.c +59 -19
@@ -3419,7 +3419,7 @@ static int cmd_dev_eswitch(struct dl *dl)struct param_val_conv {const char *name;const char *vstr; -uint32_t vuint; +uint64_t vuint; }; static bool param_val_conv_exists(const struct param_val_conv *param_val_conv,
@@ -3437,7 +3437,7 @@ static bool param_val_conv_exists(const struct param_val_conv *param_val_conv,static int param_val_conv_uint_get (const struct param_val_conv *param_val_conv,uint32_t len,const char *name,const char *vstr, -uint32_t *vuint) +uint64_t *vuint) {uint32_t i;
@@ -3453,7 +3453,7 @@ param_val_conv_uint_get(const struct param_val_conv *param_val_conv,static int param_val_conv_str_get (const struct param_val_conv *param_val_conv, -uint32_t len,const char *name,uint32_t vuint, +uint32_t len,const char *name,uint64_t vuint,const char **vstr) {uint32_t i;
@@ -3670,6 +3670,7 @@ struct param_ctx {uint8_t vu8;uint16_t vu16;uint32_t vu32; +uint64_t vu64;const char *vstr;bool vbool; } value;
@@ -3730,6 +3731,9 @@ static int cmd_dev_param_set_cb(const struct nlmsghdr *nlh, void *data)case MNL_TYPE_U32 : ctx->value.vu32 =mnl_attr_get_u32 (val_attr);break ; +case MNL_TYPE_U64 : + ctx->value.vu64 =mnl_attr_get_u64 (val_attr); +break ;case MNL_TYPE_STRING : ctx->value.vstr =mnl_attr_get_str (val_attr);break ;
@@ -3749,7 +3753,8 @@ static int cmd_dev_param_set(struct dl *dl)struct param_ctx ctx = {};struct nlmsghdr *nlh;bool conv_exists; -uint32_t val_u32 =0 ; +uint64_t val_u64 =0 ; +uint32_t val_u32;uint16_t val_u16;uint8_t val_u8;bool val_bool;
@@ -3791,8 +3796,8 @@ static int cmd_dev_param_set(struct dl *dl)PARAM_VAL_CONV_LEN , dl->opts.param_name, dl->opts.param_value, - &val_u32); - val_u8 = val_u32; + &val_u64); + val_u8 = val_u64; }else { err =get_u8 (&val_u8, dl->opts.param_value,10 ); }
@@ -3808,8 +3813,8 @@ static int cmd_dev_param_set(struct dl *dl)PARAM_VAL_CONV_LEN , dl->opts.param_name, dl->opts.param_value, - &val_u32); - val_u16 = val_u32; + &val_u64); + val_u16 = val_u64; }else { err =get_u16 (&val_u16, dl->opts.param_value,10 ); }
@@ -3820,20 +3825,37 @@ static int cmd_dev_param_set(struct dl *dl)mnl_attr_put_u16 (nlh,DEVLINK_ATTR_PARAM_VALUE_DATA , val_u16);break ;case MNL_TYPE_U32 : -if (conv_exists) +if (conv_exists) { err =param_val_conv_uint_get (param_val_conv,PARAM_VAL_CONV_LEN , dl->opts.param_name, dl->opts.param_value, - &val_u32); -else + &val_u64); + val_u32 = val_u64; + }else { err =get_u32 (&val_u32, dl->opts.param_value,10 ); + }if (err) goto err_param_value_parse;if (val_u32 == ctx.value.vu32)return 0 ;mnl_attr_put_u32 (nlh,DEVLINK_ATTR_PARAM_VALUE_DATA , val_u32);break ; +case MNL_TYPE_U64 : +if (conv_exists) + err =param_val_conv_uint_get (param_val_conv, +PARAM_VAL_CONV_LEN , + dl->opts.param_name, + dl->opts.param_value, + &val_u64); +else + err =get_u64 ((__u64 *)&val_u64, dl->opts.param_value,10 ); +if (err) + goto err_param_value_parse; +if (val_u64 == ctx.value.vu64) +return 0 ; +mnl_attr_put_u64 (nlh,DEVLINK_ATTR_PARAM_VALUE_DATA , val_u64); +break ;case MNL_TYPE_FLAG : err =strtobool (dl->opts.param_value, &val_bool);if (err)
@@ -5325,7 +5347,8 @@ static int cmd_port_param_set(struct dl *dl)struct param_ctx ctx = {};struct nlmsghdr *nlh;bool conv_exists; -uint32_t val_u32 =0 ; +uint64_t val_u64 =0 ; +uint32_t val_u32;uint16_t val_u16;uint8_t val_u8;bool val_bool;
@@ -5363,8 +5386,8 @@ static int cmd_port_param_set(struct dl *dl)PARAM_VAL_CONV_LEN , dl->opts.param_name, dl->opts.param_value, - &val_u32); - val_u8 = val_u32; + &val_u64); + val_u8 = val_u64; }else { err =get_u8 (&val_u8, dl->opts.param_value,10 ); }
@@ -5380,8 +5403,8 @@ static int cmd_port_param_set(struct dl *dl)PARAM_VAL_CONV_LEN , dl->opts.param_name, dl->opts.param_value, - &val_u32); - val_u16 = val_u32; + &val_u64); + val_u16 = val_u64; }else { err =get_u16 (&val_u16, dl->opts.param_value,10 ); }
@@ -5392,20 +5415,37 @@ static int cmd_port_param_set(struct dl *dl)mnl_attr_put_u16 (nlh,DEVLINK_ATTR_PARAM_VALUE_DATA , val_u16);break ;case MNL_TYPE_U32 : -if (conv_exists) +if (conv_exists) { err =param_val_conv_uint_get (param_val_conv,PARAM_VAL_CONV_LEN , dl->opts.param_name, dl->opts.param_value, - &val_u32); -else + &val_u64); + val_u32 = val_u64; + }else { err =get_u32 (&val_u32, dl->opts.param_value,10 ); + }if (err) goto err_param_value_parse;if (val_u32 == ctx.value.vu32)return 0 ;mnl_attr_put_u32 (nlh,DEVLINK_ATTR_PARAM_VALUE_DATA , val_u32);break ; +case MNL_TYPE_U64 : +if (conv_exists) + err =param_val_conv_uint_get (param_val_conv, +PARAM_VAL_CONV_LEN , + dl->opts.param_name, + dl->opts.param_value, + &val_u64); +else + err =get_u64 ((__u64 *)&val_u64, dl->opts.param_value,10 ); +if (err) + goto err_param_value_parse; +if (val_u64 == ctx.value.vu64) +return 0 ; +mnl_attr_put_u64 (nlh,DEVLINK_ATTR_PARAM_VALUE_DATA , val_u64); +break ;case MNL_TYPE_FLAG : err =strtobool (dl->opts.param_value, &val_bool);if (err)
Signature · 1 line
2.51.0
Quoted 7 lines · Ivan Vecera
Kernel commit
c0ef144695910("devlink: Add support for u64 parameters") added support for 64bit devlink parameters, add the support for them also into devlink utility userspace counterpart.Cc Jiri Pirko <[email protected]>Signed-off-by Ivan Vecera <[email protected]>---
Tested on Microchip EDS2 development board...
Prior patch:
root@eds2:~# devlink dev param set i2c/1-0070 name clock_id value 1234 cmode driverinit Value type not supported root@eds2:~#
After patch:
root@eds2:~# devlink dev param set i2c/1-0070 name clock_id value 1234 cmode driverinit root@eds2:~#
Ivan
Quoted 18 lines · Ivan Vecera
Quoted 7 lines · Ivan Vecera
Kernel commit
c0ef144695910("devlink: Add support for u64 parameters") added support for 64bit devlink parameters, add the support for them also into devlink utility userspace counterpart.Cc Jiri Pirko <[email protected]>Signed-off-by Ivan Vecera <[email protected]>---
Tested on Microchip EDS2 development board...
Prior patch:
root@eds2:~# devlink dev param set i2c/1-0070 name clock_id value 1234 cmode driverinit Value type not supported root@eds2:~#
Quoted 8 lines
After patch:
root@eds2:~# devlink dev param set i2c/1-0070 name clock_id value 1234 cmode driverinit root@eds2:~#Ivan
Added the testing to the commit message and applied to iproute2-next
Quoted 6 lines · Thu, Oct 30, 2025 at 08:42:00PM +0100, [email protected] wrote:
Kernel commit
c0ef144695910("devlink: Add support for u64 parameters") added support for 64bit devlink parameters, add the support for them also into devlink utility userspace counterpart.Cc Jiri Pirko <[email protected]>Signed-off-by Ivan Vecera <[email protected]>