#compdef ethtool
local -a cmds
if [[ $CURRENT -ge 4 ]]; then
case $words[CURRENT-1]; in
rx|tx)
if [[ $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)
if [[ $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
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
Copyright 2K16 - 2K18 Indonesian Hacker Rulez