Skip to content

Commit

Permalink
devlink: expose components
Browse files Browse the repository at this point in the history
Signed-off-by: Jiri Pirko <jiri@nvidia.com>
  • Loading branch information
Jiri Pirko committed Aug 18, 2022
1 parent a946824 commit e1d3640
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions devlink/devlink.c
Expand Up @@ -3651,6 +3651,49 @@ static void pr_out_versions_single(struct dl *dl, const struct nlmsghdr *nlh,
pr_out_object_end(dl);
}

static void pr_out_versions_flash_components(struct dl *dl, const struct nlmsghdr *nlh)
{
struct nlattr *version;
bool array_started = false;

mnl_attr_for_each(version, nlh, sizeof(struct genlmsghdr)) {
struct nlattr *tb[DEVLINK_ATTR_MAX + 1] = {};
uint8_t ver_is_component;
const char *ver_name;
int err;

err = mnl_attr_parse_nested(version, attr_cb, tb);
if (err != MNL_CB_OK)
continue;

if (!tb[DEVLINK_ATTR_INFO_VERSION_NAME] ||
!tb[DEVLINK_ATTR_INFO_VERSION_VALUE] ||
!tb[DEVLINK_ATTR_INFO_VERSION_IS_COMPONENT])
continue;

ver_is_component = mnl_attr_get_u8(tb[DEVLINK_ATTR_INFO_VERSION_IS_COMPONENT]);
if (!ver_is_component)
continue;

if (!array_started) {
pr_out_array_start(dl, "flash_components");
array_started = true;
}

ver_name = mnl_attr_get_str(tb[DEVLINK_ATTR_INFO_VERSION_NAME]);

check_indent_newline(dl);

print_string(PRINT_ANY, NULL, "%s", ver_name);

if (!dl->json_output)
__pr_out_newline();
}

if (array_started)
pr_out_array_end(dl);
}

static void pr_out_info(struct dl *dl, const struct nlmsghdr *nlh,
struct nlattr **tb, bool has_versions)
{
Expand Down Expand Up @@ -3697,6 +3740,7 @@ static void pr_out_info(struct dl *dl, const struct nlmsghdr *nlh,
DEVLINK_ATTR_INFO_VERSION_RUNNING);
pr_out_versions_single(dl, nlh, "stored",
DEVLINK_ATTR_INFO_VERSION_STORED);
pr_out_versions_flash_components(dl, nlh);

pr_out_object_end(dl);
}
Expand Down

0 comments on commit e1d3640

Please sign in to comment.