diff options
author | Jiri Pirko <jiri@nvidia.com> | 2022-07-16 13:24:51 +0200 |
---|---|---|
committer | David Ahern <dsahern@kernel.org> | 2022-07-21 09:19:40 -0600 |
commit | 4cb0bec3744ac4f8d21de0e769f170e4059c6b9e (patch) | |
tree | 642ff9f38a607c195f980b48849549e4ad516cc8 /bash-completion/devlink | |
parent | 63394af8b1ccd57a38fa22dffee97b2c560c335f (diff) | |
download | iproute2-4cb0bec3744ac4f8d21de0e769f170e4059c6b9e.tar.gz |
devlink: add support for linecard show and type set
Introduce a new object "lc" to add devlink support for line cards with
two commands:
show - to get the info about the line card state, list of supported
types as reported by kernel/driver.
set - to set/clear the line card type.
Example:
$ devlink lc
pci/0000:01:00.0:
lc 1 state unprovisioned
supported_types:
16x100G
lc 2 state unprovisioned
supported_types:
16x100G
lc 3 state unprovisioned
supported_types:
16x100G
lc 4 state unprovisioned
supported_types:
16x100G
lc 5 state unprovisioned
supported_types:
16x100G
lc 6 state unprovisioned
supported_types:
16x100G
lc 7 state unprovisioned
supported_types:
16x100G
lc 8 state unprovisioned
supported_types:
16x100G
To provision the slot #8:
$ devlink lc set pci/0000:01:00.0 lc 8 type 16x100G
$ devlink lc show pci/0000:01:00.0 lc 8
pci/0000:01:00.0:
lc 8 state active type 16x100G
supported_types:
16x100G
To uprovision the slot #8:
$ devlink lc set pci/0000:01:00.0 lc 8 notype
Signed-off-by: Jiri Pirko <jiri@nvidia.com>
Reviewed-by: Ido Schimmel <idosch@nvidia.com>
Signed-off-by: David Ahern <dsahern@kernel.org>
Diffstat (limited to 'bash-completion/devlink')
-rw-r--r-- | bash-completion/devlink | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/bash-completion/devlink b/bash-completion/devlink index 361be9fe..757e03b7 100644 --- a/bash-completion/devlink +++ b/bash-completion/devlink @@ -43,6 +43,19 @@ _devlink_direct_complete() | jq '.port as $ports | $ports | keys[] as $key | ($ports[$key].netdev // $key)') ;; + lc) + dev=${words[3]} + value=$(devlink -j lc show 2>/dev/null \ + | jq ".lc[\"$dev\"]" \ + | jq '. as $lcs | $lcs | keys[] as $key |($lcs[$key].lc)' \ + 2>/dev/null) + ;; + lc_type) + dev=${words[3]} + lc=${words[5]} + value=$(devlink lc show $dev lc $lc -j 2>/dev/null \ + | jq '.[][][]["supported_types"][]') + ;; region) value=$(devlink -j region show 2>/dev/null \ | jq '.regions' | jq 'keys[]') @@ -395,6 +408,62 @@ _devlink_port() esac } +# Completion for devlink lc set +_devlink_lc_set() +{ + case "$cword" in + 3) + _devlink_direct_complete "dev" + return + ;; + 4) + COMPREPLY=( $( compgen -W "lc" -- "$cur" ) ) + ;; + 5) + _devlink_direct_complete "lc" + ;; + 6) + COMPREPLY=( $( compgen -W "type notype" -- "$cur" ) ) + return + ;; + 7) + if [[ "$prev" == "type" ]]; then + _devlink_direct_complete "lc_type" + fi + esac +} + +# Completion for devlink lc show +_devlink_lc_show() +{ + case $cword in + 3) + _devlink_direct_complete "dev" + ;; + 4) + COMPREPLY=( $( compgen -W "lc" -- "$cur" ) ) + ;; + 5) + _devlink_direct_complete "lc" + ;; + esac +} + +# Completion for devlink lc +_devlink_lc() +{ + case $command in + set) + _devlink_lc_set + return + ;; + show) + _devlink_lc_show + return + ;; + esac +} + # Completion for devlink dpipe _devlink_dpipe() { @@ -988,6 +1057,7 @@ _devlink() local object=${words[1]} local command=${words[2]} local pprev=${words[cword - 2]} + local prev=${words[cword - 1]} if [[ $objects =~ $object ]]; then if [[ $cword -eq 2 ]]; then |