devlink: add support for linecard show and type set
Subsystems (2)
PATCH v3 1/1 devlink: add support for linecard show and type set
From: Jiri Pirko <[email protected]>
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:
16x100GTo 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:
16x100GTo uprovision the slot #8:
$ devlink lc set pci/0000:01:00.0 lc 8 notype
---v2->v3:
- fixed completion of instance without line cards
- fixed couple issues in man pagev1->v2:
- added missing bash completion bits
--- bash-completion/devlink | 70 ++++++++++++++ devlink/devlink.c | 210 +++++++++++++++++++++++++++++++++++++++- man/man8/devlink-lc.8 | 101 +++++++++++++++++++ 3 files changed, 378 insertions(+), 3 deletions(-) create mode 100644 man/man8/devlink-lc.8
bash-completion/devlink +70 -0
@@ -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
devlink/devlink.c +207 -3
312 lines not on this page · raw message
man/man8/devlink-lc.8 new file +101 -0
101 lines not on this page · raw message
Signature · 1 line
2.35.3
Quoted 8 lines · Jiri Pirko
From: Jiri Pirko <[email protected]>
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.
[...]
Quoted 1 line
Signed-off-by Jiri Pirko <[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 9 lines · On Sat, 16 Jul 2022 13:24:51 +0200 you wrote:
From: Jiri Pirko <[email protected]>
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.[...]
Here is the summary with links:
- [iproute2-next,v3] devlink: add support for linecard show and type set
https://git.kernel.org/pub/scm/network/iproute2/iproute2-next.git/commit/?id=4cb0bec3744a
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html