devlink: expose nested devlink for a line card object
Subsystems (2)
PATCH 1/1 devlink: expose nested devlink for a line card object
From: Jiri Pirko <[email protected]>
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.0Signed-off-by Jiri Pirko <[email protected]>
--- devlink/devlink.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+)
devlink/devlink.c +23 -0
@@ -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); }
Signature · 1 line
2.35.3
Quoted 14 lines · Jiri Pirko
From: Jiri Pirko <[email protected]>
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
Quoted 1 line
Signed-off-by Jiri Pirko <[email protected]>
Reviewed-by Ido Schimmel <[email protected]>
This patch was applied to iproute2/iproute2-next.git (main) by David Ahern <[email protected]>:
Hello:
This patch was applied to iproute2/iproute2-next.git (main) by David Ahern <[email protected]>:
Quoted 14 lines · On Tue, 9 Aug 2022 15:17:30 +0200 you wrote:
From: Jiri Pirko <[email protected]>
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
Quoted 1 line
[...]
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!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html