Re: [PATCH iproute2-next V4] devlink: add support for port params get/set

2021-02-11 Thread Oleksandr Mazur
On 2/9/21 3:31 AM, Oleksandr Mazur wrote:
> Add implementation for the port parameters
> getting/setting.
> Add bash completion for port param.
> Add man description for port param.
> 
> Signed-off-by: Oleksandr Mazur 
> ---

> applied to iproute2-next.

> In the future, please add example commands - get/set/show, and the show
> commands should have examples for normal and json.

Thanks;
And yes - sorry; i missed it when uploaded the 4-th patch version (was present 
in V3)...

Re: [PATCH iproute2-next V4] devlink: add support for port params get/set

2021-02-11 Thread David Ahern
On 2/9/21 3:31 AM, Oleksandr Mazur wrote:
> Add implementation for the port parameters
> getting/setting.
> Add bash completion for port param.
> Add man description for port param.
> 
> Signed-off-by: Oleksandr Mazur 
> ---

applied to iproute2-next.

In the future, please add example commands - get/set/show, and the show
commands should have examples for normal and json.


Re: [PATCH iproute2-next V4] devlink: add support for port params get/set

2021-02-11 Thread patchwork-bot+netdevbpf
Hello:

This patch was applied to iproute2/iproute2-next.git (refs/heads/main):

On Tue,  9 Feb 2021 12:31:51 +0200 you wrote:
> Add implementation for the port parameters
> getting/setting.
> Add bash completion for port param.
> Add man description for port param.
> 
> Signed-off-by: Oleksandr Mazur 
> 
> [...]

Here is the summary with links:
  - [iproute2-next,V4] devlink: add support for port params get/set

https://git.kernel.org/pub/scm/network/iproute2/iproute2-next.git/commit/?id=c946f5d3e414

You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html




[PATCH iproute2-next V4] devlink: add support for port params get/set

2021-02-09 Thread Oleksandr Mazur
Add implementation for the port parameters
getting/setting.
Add bash completion for port param.
Add man description for port param.

Signed-off-by: Oleksandr Mazur 
---
V4:
1) Rebase on top of master;
2) Add missed space in after else-if-clause bracket;
V3:
1) Add usage example;
2) Remove stray newline in code;
V2:
1) Add bash completion for port param;
2) Add man decsription / examples for port param;

 bash-completion/devlink |  55 
 devlink/devlink.c   | 274 +++-
 man/man8/devlink-port.8 |  65 ++
 3 files changed, 388 insertions(+), 6 deletions(-)

diff --git a/bash-completion/devlink b/bash-completion/devlink
index 7395b504..361be9fe 100644
--- a/bash-completion/devlink
+++ b/bash-completion/devlink
@@ -319,6 +319,57 @@ _devlink_port_split()
 esac
 }
 
+# Completion for devlink port param set
+_devlink_port_param_set()
+{
+case $cword in
+7)
+COMPREPLY=( $( compgen -W "value" -- "$cur" ) )
+return
+;;
+8)
+# String argument
+return
+;;
+9)
+COMPREPLY=( $( compgen -W "cmode" -- "$cur" ) )
+return
+;;
+10)
+COMPREPLY=( $( compgen -W "runtime driverinit permanent" -- \
+"$cur" ) )
+return
+;;
+esac
+}
+
+# Completion for devlink port param
+_devlink_port_param()
+{
+case "$cword" in
+3)
+COMPREPLY=( $( compgen -W "show set" -- "$cur" ) )
+return
+;;
+4)
+_devlink_direct_complete "port"
+return
+;;
+5)
+COMPREPLY=( $( compgen -W "name" -- "$cur" ) )
+return
+;;
+6)
+_devlink_direct_complete "param_name"
+return
+;;
+esac
+
+if [[ "${words[3]}" == "set" ]]; then
+_devlink_port_param_set
+fi
+}
+
 # Completion for devlink port
 _devlink_port()
 {
@@ -331,6 +382,10 @@ _devlink_port()
 _devlink_port_split
 return
 ;;
+param)
+_devlink_port_param
+return
+;;
 show|unsplit)
 if [[ $cword -eq 3 ]]; then
 _devlink_direct_complete "port"
diff --git a/devlink/devlink.c b/devlink/devlink.c
index 10398f77..c6e85ff9 100644
--- a/devlink/devlink.c
+++ b/devlink/devlink.c
@@ -2808,7 +2808,8 @@ static void pr_out_param_value(struct dl *dl, const char 
*nla_name,
}
 }
 
-static void pr_out_param(struct dl *dl, struct nlattr **tb, bool array)
+static void pr_out_param(struct dl *dl, struct nlattr **tb, bool array,
+bool is_port_param)
 {
struct nlattr *nla_param[DEVLINK_ATTR_MAX + 1] = {};
struct nlattr *param_value_attr;
@@ -2825,9 +2826,15 @@ static void pr_out_param(struct dl *dl, struct nlattr 
**tb, bool array)
return;
 
if (array)
-   pr_out_handle_start_arr(dl, tb);
+   if (is_port_param)
+   pr_out_port_handle_start_arr(dl, tb, false);
+   else
+   pr_out_handle_start_arr(dl, tb);
else
-   __pr_out_handle_start(dl, tb, true, false);
+   if (is_port_param)
+   pr_out_port_handle_start(dl, tb, false);
+   else
+   __pr_out_handle_start(dl, tb, true, false);
 
nla_type = mnl_attr_get_u8(nla_param[DEVLINK_ATTR_PARAM_TYPE]);
 
@@ -2847,7 +2854,10 @@ static void pr_out_param(struct dl *dl, struct nlattr 
**tb, bool array)
pr_out_entry_end(dl);
}
pr_out_array_end(dl);
-   pr_out_handle_end(dl);
+   if (is_port_param)
+   pr_out_port_handle_end(dl);
+   else
+   pr_out_handle_end(dl);
 }
 
 static int cmd_dev_param_show_cb(const struct nlmsghdr *nlh, void *data)
@@ -2860,7 +2870,7 @@ static int cmd_dev_param_show_cb(const struct nlmsghdr 
*nlh, void *data)
if (!tb[DEVLINK_ATTR_BUS_NAME] || !tb[DEVLINK_ATTR_DEV_NAME] ||
!tb[DEVLINK_ATTR_PARAM])
return MNL_CB_ERROR;
-   pr_out_param(dl, tb, true);
+   pr_out_param(dl, tb, true, false);
return MNL_CB_OK;
 }
 
@@ -3058,6 +3068,21 @@ err_param_value_parse:
return err;
 }
 
+static int cmd_port_param_show_cb(const struct nlmsghdr *nlh, void *data)
+{
+   struct genlmsghdr *genl = mnl_nlmsg_get_payload(nlh);
+   struct nlattr *tb[DEVLINK_ATTR_MAX + 1] = {};
+   struct dl *dl = data;
+
+   mnl_attr_parse(nlh, sizeof(*genl), attr_cb, tb);
+   if (!tb[DEVLINK_ATTR_BUS_NAME] || !tb[DEVLINK_ATTR_DEV_NAME] ||
+   !tb[DEVLINK_ATTR_PORT_INDEX] || !tb[DEVLINK_ATTR_PARAM])
+   return MNL_CB_ERROR;
+
+   pr_out_param(dl, tb, true, true);
+   return MNL_CB_OK;
+}
+
 static int