mirror of
https://git.proxmox.com/git/mirror_iproute2
synced 2025-08-08 08:49:00 +00:00
devlink: Add helper functions for name and value separately
Add a new helper functions which outputs only values (without name label) for different types: boolean, uint, uint64, string and binary. In addition add a helper function which prints only the name label. Signed-off-by: Aya Levin <ayal@mellanox.com> Reviewed-by: Moshe Shemesh <moshe@mellanox.com> Acked-by: Jiri Pirko <jiri@mellanox.com> Signed-off-by: David Ahern <dsahern@gmail.com>
This commit is contained in:
parent
8257e6c49c
commit
844a61764c
@ -1661,6 +1661,71 @@ static void pr_out_u64(struct dl *dl, const char *name, uint64_t val)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void pr_out_bool_value(struct dl *dl, bool value)
|
||||||
|
{
|
||||||
|
if (dl->json_output)
|
||||||
|
jsonw_bool(dl->jw, value);
|
||||||
|
else
|
||||||
|
pr_out(" %s", value ? "true" : "false");
|
||||||
|
}
|
||||||
|
|
||||||
|
static void pr_out_uint_value(struct dl *dl, unsigned int value)
|
||||||
|
{
|
||||||
|
if (dl->json_output)
|
||||||
|
jsonw_uint(dl->jw, value);
|
||||||
|
else
|
||||||
|
pr_out(" %u", value);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void pr_out_uint64_value(struct dl *dl, uint64_t value)
|
||||||
|
{
|
||||||
|
if (dl->json_output)
|
||||||
|
jsonw_u64(dl->jw, value);
|
||||||
|
else
|
||||||
|
pr_out(" %lu", value);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void pr_out_binary_value(struct dl *dl, uint8_t *data, uint32_t len)
|
||||||
|
{
|
||||||
|
int i = 1;
|
||||||
|
|
||||||
|
if (dl->json_output)
|
||||||
|
jsonw_start_array(dl->jw);
|
||||||
|
else
|
||||||
|
pr_out("\n");
|
||||||
|
|
||||||
|
while (i < len) {
|
||||||
|
if (dl->json_output) {
|
||||||
|
jsonw_printf(dl->jw, "%d", data[i]);
|
||||||
|
} else {
|
||||||
|
pr_out(" %02x", data[i]);
|
||||||
|
if (!(i % 16))
|
||||||
|
pr_out("\n");
|
||||||
|
}
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
if (dl->json_output)
|
||||||
|
jsonw_end_array(dl->jw);
|
||||||
|
else if ((i - 1) % 16)
|
||||||
|
pr_out("\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
static void pr_out_str_value(struct dl *dl, const char *value)
|
||||||
|
{
|
||||||
|
if (dl->json_output)
|
||||||
|
jsonw_string(dl->jw, value);
|
||||||
|
else
|
||||||
|
pr_out(" %s", value);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void pr_out_name(struct dl *dl, const char *name)
|
||||||
|
{
|
||||||
|
if (dl->json_output)
|
||||||
|
jsonw_name(dl->jw, name);
|
||||||
|
else
|
||||||
|
pr_out(" %s:", name);
|
||||||
|
}
|
||||||
|
|
||||||
static void pr_out_region_chunk_start(struct dl *dl, uint64_t addr)
|
static void pr_out_region_chunk_start(struct dl *dl, uint64_t addr)
|
||||||
{
|
{
|
||||||
if (dl->json_output) {
|
if (dl->json_output) {
|
||||||
|
Loading…
Reference in New Issue
Block a user