Message ID | 20220809131730.2677759-1-jiri@resnulli.us (mailing list archive) |
---|---|
State | Accepted |
Commit | 700a8991f05e6e37889101196a531cf82777bdf7 |
Delegated to: | David Ahern |
Headers | show |
Series | [iproute2-next] devlink: expose nested devlink for a line card object | expand |
Context | Check | Description |
---|---|---|
netdev/tree_selection | success | Not a local patch |
On Tue, Aug 09, 2022 at 03:17:30PM +0200, Jiri Pirko wrote: > From: Jiri Pirko <jiri@nvidia.com> > > If line card object contains a nested devlink, expose it. > > Example: > > $ devlink lc show pci/0000:01:00.0 lc 1 > pci/0000:01:00.0: > lc 1 state active type 16x100G nested_devlink auxiliary/mlxsw_core.lc.0 > supported_types: > 16x100G > $ devlink dev show auxiliary/mlxsw_core.lc.0 > auxiliary/mlxsw_core.lc.0 > > Signed-off-by: Jiri Pirko <jiri@nvidia.com> Reviewed-by: Ido Schimmel <idosch@nvidia.com>
Hello: This patch was applied to iproute2/iproute2-next.git (main) by David Ahern <dsahern@kernel.org>: On Tue, 9 Aug 2022 15:17:30 +0200 you wrote: > From: Jiri Pirko <jiri@nvidia.com> > > If line card object contains a nested devlink, expose it. > > Example: > > $ devlink lc show pci/0000:01:00.0 lc 1 > pci/0000:01:00.0: > lc 1 state active type 16x100G nested_devlink auxiliary/mlxsw_core.lc.0 > supported_types: > 16x100G > $ devlink dev show auxiliary/mlxsw_core.lc.0 > auxiliary/mlxsw_core.lc.0 > > [...] Here is the summary with links: - [iproute2-next] devlink: expose nested devlink for a line card object https://git.kernel.org/pub/scm/network/iproute2/iproute2-next.git/commit/?id=700a8991f05e You are awesome, thank you!
diff --git a/devlink/devlink.c b/devlink/devlink.c index 21f26246f91b..1ccb669c423b 100644 --- a/devlink/devlink.c +++ b/devlink/devlink.c @@ -703,6 +703,7 @@ static const enum mnl_attr_data_type devlink_policy[DEVLINK_ATTR_MAX + 1] = { [DEVLINK_ATTR_LINECARD_STATE] = MNL_TYPE_U8, [DEVLINK_ATTR_LINECARD_TYPE] = MNL_TYPE_STRING, [DEVLINK_ATTR_LINECARD_SUPPORTED_TYPES] = MNL_TYPE_NESTED, + [DEVLINK_ATTR_NESTED_DEVLINK] = MNL_TYPE_NESTED, [DEVLINK_ATTR_SELFTESTS] = MNL_TYPE_NESTED, }; @@ -2423,6 +2424,25 @@ static bool should_arr_last_handle_end(struct dl *dl, const char *bus_name, !cmp_arr_last_handle(dl, bus_name, dev_name); } +static void pr_out_nested_handle(struct nlattr *nla_nested_dl) +{ + struct nlattr *tb[DEVLINK_ATTR_MAX + 1] = {}; + char buf[64]; + int err; + + err = mnl_attr_parse_nested(nla_nested_dl, attr_cb, tb); + if (err != MNL_CB_OK) + return; + + if (!tb[DEVLINK_ATTR_BUS_NAME] || + !tb[DEVLINK_ATTR_DEV_NAME]) + return; + + sprintf(buf, "%s/%s", mnl_attr_get_str(tb[DEVLINK_ATTR_BUS_NAME]), + mnl_attr_get_str(tb[DEVLINK_ATTR_DEV_NAME])); + print_string(PRINT_ANY, "nested_devlink", " nested_devlink %s", buf); +} + static void __pr_out_handle_start(struct dl *dl, struct nlattr **tb, bool content, bool array) { @@ -5278,6 +5298,9 @@ static void pr_out_linecard(struct dl *dl, struct nlattr **tb) if (tb[DEVLINK_ATTR_LINECARD_TYPE]) print_string(PRINT_ANY, "type", " type %s", mnl_attr_get_str(tb[DEVLINK_ATTR_LINECARD_TYPE])); + if (tb[DEVLINK_ATTR_NESTED_DEVLINK]) + pr_out_nested_handle(tb[DEVLINK_ATTR_NESTED_DEVLINK]); + pr_out_linecard_supported_types(dl, tb); pr_out_handle_end(dl); }