1
0
Fork 0
mirror of git://git.code.sf.net/p/zsh/code synced 2024-05-31 20:36:03 +02:00

41724: update ethtool completion for new options

This commit is contained in:
Oliver Kiddle 2017-09-15 20:50:08 +02:00
parent 8e9fe082be
commit b0c12e3771
2 changed files with 275 additions and 160 deletions

View File

@ -1,3 +1,8 @@
2017-09-18 Oliver Kiddle <opk@zsh.org>
* 41724: Completion/Linux/Command/_ethtool: update
completion for new options
2017-09-15 Oliver Kiddle <opk@zsh.org>
* 41711: Completion/Unix/Command/_dconf: new dconf completion

View File

@ -1,164 +1,274 @@
#compdef ethtool
local -a expl cmds
local curcontext="$curcontext"
local -a state line expl cmds
local -A opt_args
if [[ $CURRENT -ge 4 ]]; then
case $words[CURRENT-1] in
rx|tx)
[[ $words[2] = '-G' ]] && _message -e n 'number of ring entries' || _wanted -x onoff expl 'enabled' compadd off on
;;
autoneg|adaptive-rx|adaptive-tx|raw|hex|sg|tso|ufo|gso)
_wanted -x onoff expl 'enabled' compadd off on
;;
rx-usecs|rx-frames|rx-usecs-irq|rx-frames-irq|tx-usecs|tx-frames|tx-usecs-irq|tx-frames-irq|stats-block-usecs|pkt-rate-low|rx-usecs-low|rx-frames-low|tx-usecs-low|tx-frames-low|pkt-rate-high|rx-usecs-high|rx-frames-high|tx-usecs-high|tx-frames-high|sample-interval|rx-mini|rx-jumbo|offset|length|magic|value|phyad|msglvl)
_message -e n 'number'
;;
speed)
_wanted -x speed expl 'speed' compadd 10 100 1000
;;
duplex)
_wanted -x duplex expl 'duplex mode' compadd half full
;;
port)
_wanted -x port expl 'device port' compadd tp aui bnc mii
;;
advertise)
_values 'hexidecimal value (or a combination of the following)' \
'0x001[10 half]' \
'0x002[10 full]' \
'0x004[100 half]' \
'0x008[100 full]' \
'0x010[1000 half(not supported by IEEE standards)]' \
'0x020[1000 full]' \
'0x8000[2500 full(not supported by IEEE standards)]' \
'0x800[10000 full]' \
'0x03F[auto]'
;;
xcvr)
_wanted -x xcvr expl 'transceiver type' compadd internal external
;;
wol)
_values -s '' 'Wake-on-LAN options' \
'(d)p[wake on phy activity]' \
'(d)u[wake on unicast messages]' \
'(d)m[wake on multicast messages]' \
'(d)b[wake on broadcast messages]' \
'(d)a[wake on ARP]' \
'(d)g[wake on MagicPacket(tm)]' \
'(d)s[enable SecureOn(tm) password for MagicPacket(tm)]' \
'(p u m b a g s)d[disable (wake on nothing)]'
;;
sopass)
_message -e secureon 'password - 6 bytes in ethernet MAC hex format (xx:yy:zz:aa:bb:cc)'
;;
file)
_wanted files expl 'raw register dump files' _files
;;
*)
case $words[2] in
-A|--pause)
_values -S ' ' -w 'pause options' \
'autoneg[specify if pause autonegotiation is enabled]' \
'rx[specify if RX pause is enabled]' \
'tx[specify if TX pause is enabled]'
;;
-C|--coalesce)
_values -S ' ' -w 'coalescing settings' \
'adaptive-rx' 'adaptive-tx' \
'rx-usecs' 'rx-frames' 'rx-usecs-irq' 'rx-frames-irq' \
'tx-usecs' 'tx-frames' 'tx-usecs-irq' 'tx-frames-irq' \
'stats-block-usecs' \
'pkt-rate-low' \
'rx-usecs-low' 'rx-frames-low' \
'tx-usecs-low' 'tx-frames-low' \
'pkt-rate-high' \
'rx-usecs-high' 'rx-frames-high' \
'tx-usecs-high' 'tx-frames-high' \
'sample-interval'
;;
-G|--set-ring)
_values -S ' ' -w 'ring parameters' \
'rx[change number of ring entries for the RX ring]' \
'rx-mini[change number of ring entries for the RX Mini ring]' \
'rx-jumbo[change number of ring entries for the RX Jumbo ring]' \
'tx[change number of ring entries for the TX ring]'
;;
-d|--register-dump)
_values -S ' ' -w 'register dump options' \
'hex[dump hex register data]' \
'raw[dump raw register data]' \
'file[use contents from file rather than device]'
;;
-e|--eeprom-dump)
_values -S ' ' -w 'EEPROM dump options' \
'raw[dump raw EEPROM data]' \
'offset[dump certain portions of the EEPROM]' \
'length[dump certain portions of the EEPROM]'
;;
-E|--change-eeprom)
_values -S ' ' -w 'EEPROM values' \
'magic[device-specific key]' \
'offset[select byte]' \
'value[new value]'
;;
-K|--offload)
_values -S ' ' -w 'offload options' \
'rx[specify if RX checksumming is enabled]' \
'tx[specify if TX checksumming is enabled]' \
'sg[specify if scatter-gather is enabled]' \
'tso[specify if TCP segmentation offload is enabled]' \
'ufo[specify if UDP segmentation offload is enabled]' \
'gso[specify if generic segmentation offload is enabled]'
;;
-p|--identify)
[[ $CURRENT -eq 4 ]] && _message -e length 'seconds'
;;
-t|--test)
_values -S ' ' -w 'selftest option' \
'(online)offline:perform full set of tests possibly causing normal operation interruption (default)]' \
'(offline)online:perform limited set of tests do not interrupting normal adapter operation]'
;;
-s|--change)
_values -S ' ' -w 'change setting' \
'speed[set speed in Mb/s]' \
'duplex[set full or half duplex mode]' \
'port[select device port]' \
'autoneg[specify if autonegotiation is enabled]' \
'advertise[set the speed and duplex advertised by autonegotiation]' \
'phyad[PHY address]' \
'xcvr[select transceiver type]' \
'wol[set Wake-on-LAN options]' \
'sopass[set the SecureOn(tm) password]' \
'msglvl[set the driver message level]'
;;
esac
;;
esac
_arguments -C \
"1:interface:_net_interfaces" \
'*: :->args' \
+ '(cmds)' \
'(1)'{-h,--help}'[display help information]' \
'(1)--version[display version information]' \
{-s,--change}'[allow changing some or all settings of the specified ethernet device]' \
{-a,--show-pause}'[query the specified ethernet device for pause parameter information]' \
{-A,--pause}'[change the pause parameters of the specified ethernet device]' \
{-c,--show-coalesce}'[query the specified ethernet device for coalescing information]' \
{-C,--coalesce}'[change the coalescing settings of the specified ethernet device]' \
{-g,--show-ring}'[query the specified ethernet device for RX/TX ring parameter information]' \
{-G,--set-ring}'[change the RX/TX ring parameters of the specified ethernet device]' \
{-k,--show-features,--show-offload}'[query the specified ethernet device for offload information]' \
{-K,--features,--offload}'[change the offload parameters of the specified ethernet device]' \
{-i,--driver}'[query the specified ethernet device for associated driver information]' \
{-d,--register-dump}'[retrieve and prints a register dump for the specified ethernet device]' \
{-e,--eeprom-dump}'[retrieve and prints an EEPROM dump for the specified ethernet device]' \
{-E,--change-eeprom}'[change EEPROM byte for the specified ethernet device]' \
{-r,--negotiate}'[restart auto-negotiation on the specified ethernet device]' \
{-p,--identify}'[initiate adapter-specific action intended to identify the adapter by sight]' \
{-t,--test}'[execute adapter selftest on the specified ethernet device]' \
{-S,--statistics}'[query specified ethernet device for NIC- and driver-specific statistics]' \
'--phy-statistics[show phy statistics]' \
{-n,--show-nfc,-u,--show-ntuple}'[retrieve receive network flow classification options or rules]' \
{-N,--config-nfc,-U,--config-ntuple}'[configure receive network flow classification options or rules]' \
{-T,--show-time-stamping}"[show device's time stamping capabilities]" \
{-x,--show-rxfh-indir,--show-rxfh}'[show Rx flow hash indirection table and/or RSS hash key]' \
{-X,--set-rxfh-indir,--rxfh}'[set Rx flow hash indirection table and/or RSS hash key]' \
{-f,--flash}'[flash firmware image from the specified file]' \
{-P,--show-permaddr}'[show permanent hardware address]' \
{-w,--get-dump}'[get dump flag, data]' \
{-W,--set-dump}'[set device dump flag]' \
{-l,--show-channels}'[query channels]' \
{-L,--set-channels}'[set channels]' \
'--show-priv-flags[query private flags]' \
'--set-priv-flags[set private flags]' \
{-m,--dump-module-eeprom,--module-info}'[show module EEPROM information]' \
'--show-eee[show EEE settings]' \
'--set-eee[set EEE settings]' \
'--set-phy-tunable[set PHY tunable]' \
'--get-phy-tunable[get PHY tunable]' && return
if [[ -n $state ]]; then
case $words[CURRENT-1] in
rx|tx)
if (( $+opt_args[cmds--G] + $+opt_args[cmds---set-ring] )); then
_message -e numbers 'number of ring entries'
elif (( $+opt_args[cmds--L] + $+opt_args[cmds---set-channels] )); then
_message -e numbers 'number of channels'
else
_wanted onoff expl 'enabled' compadd off on
fi
;;
autoneg|adaptive-[rt]x|raw|hex|sg|tso|ufo|gso|lro|eee|tx-lpi|downshift)
_wanted onoff expl 'enabled' compadd off on
;;
rx-usecs|rx-frames|rx-usecs-irq|rx-frames-irq|tx-usecs|tx-frames) ;&
tx-usecs-irq|tx-frames-irq|stats-block-usecs|pkt-rate-low|rx-usecs-low) ;&
rx-frames-low|tx-usecs-low|tx-frames-low|pkt-rate-high|rx-usecs-high) ;&
rx-frames-high|tx-usecs-high|tx-frames-high|sample-interval|rx-mini) ;&
rx-jumbo|offset|length|magic|value|phyad|proto|tos|tclass|l4proto|src-port) ;&
dst-port|spi|l4data|vlan-etype|vlan|user-def|action|vf|queue|loc|delete) ;&
other|combined|tx-timer|count)
_message -e numbers 'number'
;;
speed)
_wanted -x speed expl 'speed' compadd 10 100 1000
;;
duplex)
_wanted duplex expl 'duplex mode' compadd half full
;;
port)
_wanted port expl 'device port' compadd tp aui bnc mii fibre
;;
advertise)
_values 'hexadecimal value (or a combination of the following)' \
'0x001[10 half]' \
'0x002[10 full]' \
'0x004[100 half]' \
'0x008[100 full]' \
'0x010[1000 half(not supported by IEEE standards)]' \
'0x020[1000 full]' \
'0x8000[2500 full(not supported by IEEE standards)]' \
'0x800[10000 full]' \
'0x03F[auto]'
;;
xcvr)
_wanted xcvr expl 'transceiver type' compadd internal external
;;
wol)
_values -s '' 'Wake-on-LAN option' \
'(d)p[wake on phy activity]' \
'(d)u[wake on unicast messages]' \
'(d)m[wake on multicast messages]' \
'(d)b[wake on broadcast messages]' \
'(d)a[wake on ARP]' \
'(d)g[wake on MagicPacket(tm)]' \
'(d)s[enable SecureOn(tm) password for MagicPacket(tm)]' \
'(p u m b a g s)d[disable (wake on nothing)]'
;;
sopass)
_message -e secureon 'password - 6 bytes in ethernet MAC hex format (xx:yy:zz:aa:bb:cc)'
;;
data|file)
_wanted files expl 'file' _files
;;
rx-flow-hash)
_wanted flow-types expl 'flow type' compadd {tcp,udp,ah,esp,sctp}{4,6}
;;
rule)
_message -e ids 'rule id'
;;
flow-type)
_wanted flow-types expl 'flow type' compadd ether {tcp,udp,ah,esp,sctp}{4,6}
;;
src|src-ip|dst|dst-ip|dst-mac)
_message -e addresses address
;;
m)
_message -e masks mask
;;
hkey)
_message -e keys expl 'hash key'
;;
hfunc)
_message -e functions expl 'hash function'
;;
*)
case $words[2] in
-A|--pause)
_values -S ' ' -w 'pause parameter' \
'autoneg[specify if pause autonegotiation is enabled]' \
'rx[specify if RX pause is enabled]' \
'tx[specify if TX pause is enabled]'
;;
-C|--coalesce)
_wanted settings expl 'coalescing setting' compadd -F line -M 'r:|-=* r:|=*' - \
adaptive-{r,t}x {r,t}x-{usecs,frames}{,-irq,-high,-low} \
stats-block-usecs pkt-rate-{low,high} sample-interval
;;
-G|--set-ring)
_values -S ' ' -w 'ring parameter' \
'rx[change number of ring entries for the RX ring]' \
'rx-mini[change number of ring entries for the RX Mini ring]' \
'rx-jumbo[change number of ring entries for the RX Jumbo ring]' \
'tx[change number of ring entries for the TX ring]'
;;
-d|--register-dump)
_values -S ' ' -w 'option' \
'hex[dump hex register data]' \
'raw[dump raw register data]' \
'file[use contents from file rather than device]'
;;
-e|--eeprom-dump)
_values -S ' ' -w 'option' \
'raw[dump raw EEPROM data]' \
'offset' 'length'
;;
-E|--change-eeprom)
_values -S ' ' -w 'option' \
'magic[device-specific key]' \
'offset' 'length'
'value[new value]'
;;
-K|--features|--offload)
if (( CURRENT % 2 )); then
_wanted values expl enable compadd on off
else
_wanted features expl feature compadd -F line - \
${${${${(f)"$(_call_program features $words[1] -k $line[1])"}%%:*}#$'\t'}[2,-1]} \
rx tx sg tso ufo gso gro rxvlan txvlan ntuple rxhash
fi
;;
-p|--identify)
(( CURRENT = 4 )) && _message -e length 'duration (seconds)'
;;
-t|--test)
_values -S ' ' -w 'test mode' \
'(online)offline:perform full set of tests possibly causing normal operation interruption (default)]' \
'(offline)online:perform limited set of tests without interrupting normal adapter operation]' \
'external_lb[perform full set of tests plus external-loopback test]'
;;
-s|--change)
if (( ! $words[(I)msglvl] )); then
_values -S ' ' -w 'generic option' \
'speed[set speed in Mb/s]' \
'duplex[set full or half duplex mode]' \
'port[select device port]' \
'autoneg[specify if autonegotiation is enabled]' \
'advertise[set the speed and duplex advertised by autonegotiation]' \
'phyad[PHY address]' \
'xcvr[select transceiver type]' \
'wol[set Wake-on-LAN options]' \
'sopass[set the SecureOn(tm) password]' \
'msglvl[set the driver message level]'
elif (( (CURRENT - $words[(I)msglvl]) % 2 )); then
[[ -prefix [^0-9]## ]] || _message -e numbers number
_wanted flags expl 'message type flag' compadd drv probe link timer \
if{down,up} rx_{err,status} tx_{err,queued,done} intr pktdata hw wol
else
_wanted onoff expl 'enabled' compadd off on
fi
;;
-n|-u|--show-nfc|--show-ntuple)
_wanted options expl option compadd -F line - rx-flow-hash rule
;;
-N|-U|--config-nfc|--config-ntuple)
if [[ $words[CURRENT-2] = rx-flow-hash ]]; then
_values -S ' ' 'rx packet hash' \
'm[layer 2 destination address]' \
'v[VLAN tag]' \
't[layer 3 protocol field]' \
's[IP source address]' \
'd[IP destination address]' \
'f[bytes 0 and 1 of the Layer 4 header]' \
'n[bytes 2 and 3 of the Layer 4 header]' \
'r[discard all packets of this flow type]'
else
_wanted options expl option compadd -F line - rx-flow-hash flow-type \
delete src dst proto src-ip dst-ip tos m tclass l4proto src-port \
dst-port spi l4data vlan-etype vlan user-def dst-mac action vf \
queue loc
fi
;;
-X|--set-rxfh-indir|--rxfh)
_values -S ' ' -w 'option' \
'(weight default)equal' \
'(equal default)weight' \
'(equal weight)default' \
hkey hfunc
;;
-f|--flash)
if (( CURRENT = 4 )); then
_files
else
_message -e regions region
fi
;;
-w|--get-dump)
_wanted options expl option compadd data
;;
-L|--set-channels)
_wanted options expl option compadd -F line - rx tx other combined
;;
--set-priv-flags)
if (( CURRENT % 2 )); then
_wanted values expl enable compadd on off
else
_message -e flags 'private flag'
fi
;;
-m|--dump-module-eeprom|--module-info)
_wanted options expl option compadd -F line - raw hex offset length
;;
--set-eee)
_wanted behaviours expl behaviour compadd -F line - eee advertise tx-lpi tx-timer
;;
--set-phy-tunable)
_wanted options expl tunable compadd -F line - downshift count
;;
--get-phy-tunable)
_wanted options expl tunable compadd downshift
;;
esac
;;
esac
fi
cmds=(-h -a -A -c -C -g -G -i -d -e -E -k -K -p -r -S -t -s
--help --show-pause --pause --show-coalesce --coalesce --show-ring
--set-ring --driver --register-dump --eeprom-dump --change-eeprom
--show-offload --offload --identify --negotiate --statistics --test --change)
_arguments \
"($cmds)1:interface:_net_interfaces" \
"($cmds 1)"{-h,--help}'[shows a short help message]' \
"($cmds)"{-a,--show-pause}'[queries the specified ethernet device for pause parameter information]' \
"($cmds)"{-A,--pause}'[change the pause parameters of the specified ethernet device]' \
"($cmds)"{-c,--show-coalesce}'[queries the specified ethernet device for coalescing information]' \
"($cmds)"{-C,--coalesce}'[change the coalescing settings of the specified ethernet device]' \
"($cmds)"{-g,--show-ring}'[queries the specified ethernet device for RX/TX ring parameter information]' \
"($cmds)"{-G,--set-ring}'[change the RX/TX ring parameters of the specified ethernet device]' \
"($cmds)"{-i,--driver}'[queries the specified ethernet device for associated driver information]' \
"($cmds)"{-d,--register-dump}'[retrieves and prints a register dump for the specified ethernet device]' \
"($cmds)"{-e,--eeprom-dump}'[retrieves and prints an EEPROM dump for the specified ethernet device]' \
"($cmds)"{-E,--change-eeprom}'[changes EEPROM byte for the specified ethernet device]' \
"($cmds)"{-k,--show-offload}'[queries the specified ethernet device for offload information]' \
"($cmds)"{-K,--offload}'[change the offload parameters of the specified ethernet device]' \
"($cmds)"{-p,--identify}'[initiates adapter-specific action intended to identify the adapter by sight]' \
"($cmds)"{-r,--negotiate}'[restarts auto-negotiation on the specified ethernet device]' \
"($cmds)"{-S,--statistics}'[queries the specified ethernet device for NIC- and driver-specific statistics]' \
"($cmds)"{-t,--test}'[executes adapter selftest on the specified ethernet device]' \
"($cmds)"{-s,--change}'[allows changing some or all settings of the specified ethernet device]' \
'*:' && ret=0