[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20251030194200.1006201-1-ivecera@redhat.com>
Date: Thu, 30 Oct 2025 20:42:00 +0100
From: Ivan Vecera <ivecera@...hat.com>
To: netdev@...r.kernel.org
Cc: Stephen Hemminger <stephen@...workplumber.org>,
David Ahern <dsahern@...nel.org>,
Petr Oros <poros@...hat.com>,
Jiri Pirko <jiri@...nulli.us>
Subject: [PATCH iproute2-next] 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.
Cc: Jiri Pirko <jiri@...nulli.us>
Signed-off-by: Ivan Vecera <ivecera@...hat.com>
---
devlink/devlink.c | 78 +++++++++++++++++++++++++++++++++++------------
1 file changed, 59 insertions(+), 19 deletions(-)
diff --git a/devlink/devlink.c b/devlink/devlink.c
index f77b4449e8c5..efeb072a4637 100644
--- a/devlink/devlink.c
+++ b/devlink/devlink.c
@@ -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)
--
2.51.0
Powered by blists - more mailing lists