Posts Tagged ‘mii-tool’

Using ethtool to determine Ethernet link speed, not mii-tool

Thursday, February 3rd, 2011

mii-tool is a deprecated tool for checking the link speed of an Ethernet port.

Unfortunately, mii-tool is still distributed by default in the most recent Linux distributions like Ubuntu 10.10 as part of the net-tool package, while ethtool is not!

The main problem is that mii-tool is so old, it doesn’t even support Gigabit Ethernet.

Here is an example on a GigE port:

bash# /sbin/mii-tool
eth0: negotiated 100baseTx-FD, link ok
bash#
bash# /sbin/mii-tool -v
eth0: negotiated 100baseTx-FD, link ok
  product info: vendor 00:aa:00, model 57 rev 0
  basic mode:   autonegotiation enabled
  basic status: autonegotiation complete, link ok
  capabilities: 100baseTx-FD 100baseTx-HD 10baseT-FD 10baseT-HD
  advertising:  100baseTx-FD 100baseTx-HD 10baseT-FD 10baseT-HD flow-control
  link partner: 100baseTx-FD 100baseTx-HD 10baseT-FD 10baseT-HD
bash#

The ports are reported at 100 Mbps by mii-tool.

And ethtool finds the correct speed: 1000 Mbps:

bash# /sbin/ethtool eth0
Settings for eth0:
        Supported ports: [ TP ]
        Supported link modes:   10baseT/Half 10baseT/Full
                                100baseT/Half 100baseT/Full
                                1000baseT/Full
        Supports auto-negotiation: Yes
        Advertised link modes:  10baseT/Half 10baseT/Full
                                100baseT/Half 100baseT/Full
                                1000baseT/Full
        Advertised auto-negotiation: Yes
        Speed: 1000Mb/s
        Duplex: Full
        Port: Twisted Pair
        PHYAD: 1
        Transceiver: internal
        Auto-negotiation: on
        Supports Wake-on: umbg
        Wake-on: g
        Current message level: 0x00000003 (3)
        Link detected: yes
bash#

Looking closer at the manpage of mii-tool, it dates back to 2004, and doesn’t list 1000 as a supported media:

MII-TOOL(8) MII-TOOL(8)

NAME
mii-tool – view, manipulate media-independent interface status

SYNOPSIS
mii-tool [-v, --verbose] [-V, --version] [-R, --reset] [-r, --restart] [-w, --watch] [-l, --log] [-A, --advertise=media,...] [-F, --force=media] [interface ...]

DESCRIPTION
This utility checks or sets the status of a network interface’s Media Independent Interface (MII) unit. Most fast ethernet adapters use an MII to autonegotiate link speed and duplex setting.

Most intelligent ne
capabilities. Some
force the MII to operate in one mode, instead of autonegotiating. The -A and -F options are mutually exclusive.

The default short output reports the negotiated link speed and link status for each interface. If an interface or interfaces are not specified on the command line, then mii-tool will check any available interfaces from eth0 through eth7.

OPTIONS
-v, –verbose
Display more detailed MII status information. If used twice, also display raw MII register contents.

-V, –version
Display program version information.

-R, –reset
Reset the MII to its default configuration.

-r, –restart
Restart autonegotiation.

-w, –watch
Watch interface(s) and report changes in link status. The MII interfaces are polled at one second intervals.

-l, –log
Used with -w, records link status changes in the system log instead of printing on standard output.

-F media, –force=media
Disable autonegotiation, and force the MII to either 100baseTx-FD, 100baseTx-HD, 10baseT-FD, or 10baseT-HD operation.

-A media,…, –advertise=media,…
Enable and restart autonegotiation, and advertise only the specified media technologies. Multiple technologies should be separated by commas. Valid media are 100baseT4, 100baseTx-FD, 100baseTx-HD, 10baseT-FD, and 10baseT-HD.

DIAGNOSTICS
SIOCGMIIPHY on ‘eth?’ failed: Invalid argument
If the interface is not running (up), kernel will refuse to report its link state.

SIOCGMIIPHY on ‘eth?’ failed: Operation not permitted
Most kernels restrict access to root.

SIOCGMIIPHY on ‘eth?’ failed: No such device
This error is shown, if the kernel does not know about the named device.

SIOCGMIIPHY on ‘eth?’ failed: Operation not supported
The interface in question does not support MII queries. Most likely, it does not have MII transceivers, at all.

AUTHORS
David Hinds – dhinds@pcmcia.sourceforge.org
Donald Becker – becker@scyld.com
Bernd Eckenfels – ecki@debian.org

net-tools 2004/03/28 23:30:00 MII-TOOL(8)

Yet mii-tool is still available on some very recent Linux distro like the latest Ubuntu 10.10, while you have to manually install ethtool.

bash# apt-cache search ethtool
ethtool - display or change Ethernet device settings
ifplugd - configuration daemon for ethernet devices
bash#
bash# apt-get install ethtool
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
  dbconfig-common php5-gd libmcrypt4 libt1-5 libgd2-xpm php5-mcrypt wwwconfig-common javascript-common libjs-mootools
Use 'apt-get autoremove' to remove them.
The following NEW packages will be installed:
  ethtool
0 upgraded, 1 newly installed, 0 to remove and 70 not upgraded.
Need to get 76.4kB of archives.
After this operation, 279kB of additional disk space will be used.
Get:1 http://us.archive.ubuntu.com/ubuntu/ maverick/main ethtool amd64 1:2.6.34-2 [76.4kB]
Fetched 76.4kB in 1s (58.0kB/s)
Selecting previously deselected package ethtool.
(Reading database ... 64086 files and directories currently installed.)
Unpacking ethtool (from .../ethtool_1%3a2.6.34-2_amd64.deb) ...
Processing triggers for man-db ...
Setting up ethtool (1:2.6.34-2) ...
bash#

ethtool has also many more interesting options compared to mii-tool:

bash# ethtool -h
ethtool version 2.6.34
Usage:
ethtool DEVNAME Display standard information about device
        ethtool -s|--change DEVNAME     Change generic options
                [ speed %d ]
                [ duplex half|full ]
                [ port tp|aui|bnc|mii|fibre ]
                [ autoneg on|off ]
                [ advertise %x ]
                [ phyad %d ]
                [ xcvr internal|external ]
                [ wol p|u|m|b|a|g|s|d... ]
                [ sopass %x:%x:%x:%x:%x:%x ]
                [ msglvl %d ]
        ethtool -a|--show-pause DEVNAME Show pause options
        ethtool -A|--pause DEVNAME      Set pause options
                [ autoneg on|off ]
                [ rx on|off ]
                [ tx on|off ]
        ethtool -c|--show-coalesce DEVNAME      Show coalesce options
        ethtool -C|--coalesce DEVNAME   Set coalesce options
                [adaptive-rx on|off]
                [adaptive-tx on|off]
                [rx-usecs N]
                [rx-frames N]
                [rx-usecs-irq N]
                [rx-frames-irq N]
                [tx-usecs N]
                [tx-frames N]
                [tx-usecs-irq N]
                [tx-frames-irq N]
                [stats-block-usecs N]
                [pkt-rate-low N]
                [rx-usecs-low N]
                [rx-frames-low N]
                [tx-usecs-low N]
                [tx-frames-low N]
                [pkt-rate-high N]
                [rx-usecs-high N]
                [rx-frames-high N]
                [tx-usecs-high N]
                [tx-frames-high N]
                [sample-interval N]
        ethtool -g|--show-ring DEVNAME  Query RX/TX ring parameters
        ethtool -G|--set-ring DEVNAME   Set RX/TX ring parameters
                [ rx N ]
                [ rx-mini N ]
                [ rx-jumbo N ]
                [ tx N ]
        ethtool -k|--show-offload DEVNAME       Get protocol offload information
        ethtool -K|--offload DEVNAME    Set protocol offload
                [ rx on|off ]
                [ tx on|off ]
                [ sg on|off ]
                [ tso on|off ]
                [ ufo on|off ]
                [ gso on|off ]
                [ gro on|off ]
                [ lro on|off ]
                [ ntuple on|off ]
                [ rxhash on|off ]
        ethtool -i|--driver DEVNAME     Show driver information
        ethtool -d|--register-dump DEVNAME      Do a register dump
                [ raw on|off ]
                [ file FILENAME ]
        ethtool -e|--eeprom-dump DEVNAME        Do a EEPROM dump
                [ raw on|off ]
                [ offset N ]
                [ length N ]
        ethtool -E|--change-eeprom DEVNAME      Change bytes in device EEPROM
                [ magic N ]
                [ offset N ]
                [ length N ]
                [ value N ]
        ethtool -r|--negotiate DEVNAME  Restart N-WAY negotation
        ethtool -p|--identify DEVNAME   Show visible port identification (e.g. blinking)
               [ TIME-IN-SECONDS ]
        ethtool -t|--test DEVNAME       Execute adapter self test
               [ online | offline ]
        ethtool -S|--statistics DEVNAME Show adapter statistics
        ethtool -n|--show-nfc DEVNAME   Show Rx network flow classificationoptions
                [ rx-flow-hash tcp4|udp4|ah4|sctp4|tcp6|udp6|ah6|sctp6 ]
        ethtool -f|--flash DEVNAME      FILENAME Flash firmware image from the specified file to a region on the device
               [ REGION-NUMBER-TO-FLASH ]
        ethtool -N|--config-nfc DEVNAME Configure Rx network flow classification options
                [ rx-flow-hash tcp4|udp4|ah4|sctp4|tcp6|udp6|ah6|sctp6 m|v|t|s|d|f|n|r... ]
        ethtool -U|--config-ntuple DEVNAME      Configure Rx ntuple filters and actions
               [ fl
        ethtool -u|--show-ntuple DEVNAME        Get Rx ntuple filters and actions

        ethtool -h|--help               Show this help
bash#

And its manpage:

ETHTOOL(8)

NAME
ethtool - Display or change ethernet card settings

SYNOPSIS
ethtool ethX

ethtool -h|--help

ethtool -a|--show-pause ethX

ethtool -A|--pause ethX [autoneg on|off] [rx on|off] [tx on|off]

ethtool -c|--show-coalesce ethX

ethtool -C|--coales
usecs-low N] [tx-frames-low N] [pkt-rate-high N] [rx-usecs-high N] [rx-frames-high N] [tx-usecs-high N] [tx-frames-high N] [sample-interval N]

ethtool -g|--show-ring ethX

ethtool -G|--set-ring ethX [rx N] [rx-mini N] [rx-jumbo N] [tx N]

ethtool -i|--driver ethX

ethtool -d|--register-dump ethX [raw on|off] [hex on|off] [file name]

ethtool -e|--eeprom-dump ethX [raw on|off] [offset N] [length N]

ethtool -E|--change-eeprom ethX [magic N] [offset N] [length N] [value N]

ethtool -k|--show-offload ethX

ethtool -K|--offload ethX [rx on|off] [tx on|off] [sg on|off] [tso on|off] [ufo on|off] [gso on|off] [gro on|off] [lro on|off] [rxhash on|off]

ethtool -p|--identify ethX [N]

ethtool -r|--negotiate ethX

ethtool -S|--statistics ethX

ethtool -t|--test ethX [offline|online]

ethtool -s ethX speed N [duplex half|full] [port tp|aui|bnc|mii] [autoneg on|off] [advertise N] [phyad N] [xcvr internal|external] [wol p|u|m|b|a|g|s|d...] [sopass xx:yy:zz:aa:bb:cc] [msglvl N]

ethtool -n ethX [rx-flow-hash tcp4|udp4|ah4|sctp4|tcp6|udp6|ah6|sctp6]

ethtool -N ethX [rx-flow-hash tcp4|udp4|ah4|sctp4|tcp6|udp6|ah6|sctp6 m|v|t|s|d|f|n|r...]

ethtool -f|--flash ethX FILE [N]

ethtool -u|--show-ntuple ethX

ethtool -U|--config-
[action queue or drop]

DESCRIPTION
ethtool is used for querying settings of an ethernet device and changing them.

ethX is the name of the ethernet device on which ethtool should operate.

OPTIONS
ethtool with a single argument specifying the device name prints current settings of the specified device.

-h --help
Shows a short help message.

-a --show-pause
Queries the specified ethernet device for pause parameter information.

-A --pause
Changes the pause parameters of the specified ethernet device.

autoneg on|off
Specifies whether pause autonegotiation should be enabled.

rx on|off
Specifies whether RX pause should be enabled.

tx on|off
Specifies whether TX pause should be enabled.

-c --show-coalesce
Queries the specified ethernet device for coalescing information.

-C --coalesce
Changes the coalescing settings of the specified ethernet device.

-g --show-ring
Queries the specified ethernet device for rx/tx ring parameter information.

-G --set-ring
Changes the rx/tx ring parameters of the specified ethernet device.

rx N Changes the number of ring entries for the Rx ring.

rx-mini N
Changes the number of ring entries for the Rx Mini ring.

rx-jumbo N
Changes the number of ring entries for the Rx Jumbo ring.

tx N Changes the number of ring entries for the Tx ring.

-i --driver
Queries the specified ethernet device for associated driver information.

-d --register-dump
Retrieves and
tents of previous raw register dump, rather than reading from the device.

-e --eeprom-dump

-E --change-eeprom
If value is s
of the EEPROM. Because of the persistent nature of writing to the EEPROM, a device-specific magic key must be specified to prevent the accidental writing to the EEPROM.

-k --show-offload
Queries the specified ethernet device for offload information.

-K --offload
Changes the offload parameters of the specified ethernet device.

rx on|off
Specifies whether RX checksumming should be enabled.

tx on|off
Specifies whether TX checksumming should be enabled.

sg on|off
Specifies whether scatter-gather should be enabled.

tso on|off
Specifies whether TCP segmentation offload should be enabled.

ufo on|off
Specifies whether UDP fragmentation offload should be enabled

gso on|off
Specifies whether generic segmentation offload should be enabled

gro on|off
Specifies whether generic receive offload should be enabled

lro on|off
Specifies whether large receive offload should be enabled

rxhash on|off
Specifies whether receive hashing offload should be enabled

-p --identify
Initiates adapter-specific action intended to enable an operator to easily identify the adapter by sight. Typically this involves blinking one or more LEDs on the specific ethernet port.

N Length of time to perform phys-id, in seconds.

-r --negotiate
Restarts auto-negotiation on the specified ethernet device, if auto-negotiation is enabled.

-S --statistics
Queries the specified ethernet device for NIC- and driver-specific statistics.

-t --test
Executes adapter selftest on the specified ethernet device. Possible test modes are:

offline|online
defines test type: offline (default) means to perform full set of tests possibly causing normal operation interruption during the tests, online means to perform limited set of tests do not interrupting normal adapter operation.

-s --change
Allows changing some or all settings of the specified ethernet device. All following options only apply if -s was specified.

speed N
Set speed in Mb/s. ethtool with just the device name as an argument will show you the supported device speeds.

duplex half|full
Sets full or half duplex mode.

port tp|aui|bnc|mii
Selects device port.

autoneg on|off
Specifies whether autonegotiation should be enabled. Autonegotiation is enabled by deafult, but in some network devices may have trouble with it, so you can disable it if really necessary.

advertise N
Sets the speed and duplex advertised by autonegotiation. The argument is a hexidecimal value using one or a combination of the following values:
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)
0x1000 10000 Full
0x03F Auto

phyad N
PHY address.

xcvr internal|external
Selects transceiver type. Currently only internal and external can be specified, in the future further types might be added.

wol p|u|m|b|a|g|s|d...
Sets Wake-on-LAN options. Not all devices support this. The argument to this option is a string of characters specifying which options to enable.
p Wake on phy activity
u Wake on unicast messages
m Wake on multicast messages
b Wake on broadcast messages
a Wake on ARP
g Wake on MagicPacket(tm)
s Enable SecureOn(tm) password for MagicPacket(tm)
d Disable (wake on nothing). This option clears all previous options.

sopass xx:yy:zz:aa:bb:cc
Sets the SecureOn(tm) password. The argument to this option must be 6 bytes in ethernet MAC hex format (xx:yy:zz:aa:bb:cc).

msglvl N
Sets the driver message level. Meanings differ per driver.

-n --show-nfc
Retrieves the receive network flow classification configurations.

rx-flow-hash tcp4|udp4|ah4|sctp4|tcp6|udp6|ah6|sctp6
Retrieves the hash options for the specified network traffic type.
tcp4 TCP over IPv4
udp4 UDP over IPv4
ah4 IPSEC AH/ESP over IPv4
sctp4 SCTP over IPv4
tcp6 TCP over IPv6
udp6 UDP over IPv6
ah6 IPSEC AH/ESP over IPv6
sctp6 SCTP over IPv6

-N --config-nfc
Configures the receive network flow classification.

rx-flow-hash tcp4|udp4|ah4|sctp4|tcp6|udp6|ah6|sctp6 m|v|t|s|d|f|n|r...
Configures the hash options for the specified network traffic type.
m Hash on the Layer 2 destination address of the rx packet.
v Hash on the VLAN tag of the rx packet.
t Hash on the Layer 3 protocol field of the rx packet.
s Hash on the IP source address of the rx packet.
d Hash on the IP destination address of the rx packet.
f Hash on bytes 0 and 1 of the Layer 4 header of the rx packet.
n Hash on bytes 2 and 3 of the Layer 4 header of the rx packet.
r Discard all packets of this flow type. When this option is set, all other options are ignored.

-f --flash FILE
Flash firmware image from the specified file to a region on the adapter. By default this will flash all the regions on the adapter.

N A number to identify flash region where the image should be flashed. Default region is 0 which denotes all regions in the flash.

-u --show-ntuple
Get Rx ntuple filters and actions, then display them to the user.

-U --config-ntuple
Configure Rx ntuple filters and actions

flow-type tcp4|udp4|sctp4
tcp4 TCP over IPv4
udp4 UDP over IPv4
sctp4 SCTP over IPv4

src-ip addr
Includes the source IP address, specified in hex.

src-ip-mask mask
Specify a mask for the source IP address, specified in hex.

dst-ip addr
Includes the destination IP address, specified in hex.

dst-ip-mask mask
Specify a mask for the destination IP address, specified in hex.

src-port port
Includes the source port, specified in decimal.

src-port-mask mask
Specify a mask for the source port, specified in hex.

dst-port port
Includes the destination port, specified in decimal.

dst-port-mask mask
Specify a mask for the destination port, specified in hex.

vlan VLAN-tag
Includes the VLAN tag, specified in hex.

vlan-mask mask
Specify a mask for the VLAN tag, specified in hex.

user-def data
Includes 64-bits of user-specific data, specified in hex.

user-def-mask mask
Specify a mask for the user-specific data, specified in hex.

action N
Specifies either the Rx queue to send packets to, or to drop the matched flow.
-1 Drop the matched flow
0 or higher Rx queue to route the flow

BUGS
Not supported (in part or whole) on all ethernet drivers.

AUTHOR
ethtool was written by David Miller.

Modifications by Jeff Garzik, Tim Hockin, Jakub Jelinek, Andre Majorel, Eli Kupermann, Scott Feldman, Andi Kleen.

AVAILABILITY
ethtool is available over the Web on the SourceForge site at http://sourceforge.net/projects/gkernel/

Ethtool version 6 July 2007

Hey Ubuntu, why not remove mii-tool as it's misleading?

If it's there for compatibility reasons, why not also ship your releases with ethtool too?

And also someone should update the mii-tool manpage to specify it's deprecated and replaced by ethtool.

It's so weird I found an old mii-tool manpage from 2000 and it does state mii-tool is obsoleted and refers to ethtool, citing it in the SEE ALSO section of the manpage:

MII-TOOL(8) MII-TOOL(8)

NAME
mii-tool - view, manipulate media-independent interface status

SYNOPSIS
mii-tool [-v, --verbose] [-V, --version] [-R, --reset] [-r, --restart] [-w, --watch] [-l, --log] [-A, --advertise=media,...] [-F, --force=media] [interface ...]

NOTE
This program is obsolete. Valid media are only 100baseT4, 100baseTx-FD,100baseTx-HD, 10baseT-FD and 10baseT-HD ethernet cards. For replacement check ethtool.

DESCRIPTION
This utility checks or sets the status of a network interfaceĆ¢s Media Independent Interface (MII) unit. Most fast ethernet adapters use an MII to autonegotiate link speed and
duplex setting.

Most intelligent network devices use an autonegotiation protocol to communicate what media technologies they support, and then select the fastest mutually supported media technol-
ogy. The -A or --advertise options can be used to tell the MII to only advertise a subset of its capabilities. Some passive devices, such as single-speed hubs, are unable to
autonegotiate. To handle such devices, the MII protocol also allows for establishing a link by simply detecting either a 10baseT or 100baseT link beat. The -F or --force options
can be used to force the MII to operate in one mode, instead of autonegotiating. The -A and -F options are mutually exclusive.

The default short output reports the negotiated link speed and link status for each interface. If an interface or interfaces are not specified on the command line, then mii-tool
will check any available interfaces from eth0 through eth7.

OPTIONS
-v, --verbose
Display more detailed MII status information. If used twice, also display raw MII register contents.

-V, --version
Display program version information.

-R, --reset
Reset the MII to its default configuration.

-r, --restart
Restart autonegotiation.

-w, --watch
Watch interface(s) and report changes in link status. The MII interfaces are polled at one second intervals.

-l, --log
Used with -w, records link status changes in the system log instead of printing on standard output.

-F media, --force=media
Disable autonegotiation, and force the MII to either 100baseTx-FD, 100baseTx-HD, 10baseT-FD, or 10baseT-HD operation.

-A media,..., --advertise=media,...
Enable and restart autonegotiation, and advertise only the specified media technologies. Multiple technologies should be separated by commas. Valid media are 100baseT4,
100baseTx-FD, 100baseTx-HD, 10baseT-FD, and 10baseT-HD.

SEE ALSO
ethtool(8)

AUTHORS
David Hinds - dhinds@pcmcia.sourceforge.org
Donald Becker - becker@scyld.com

net-tools 2000/04/25 22:58:19 MII-TOOL(8)

The 2000 version of the manpage explicitly mentions:
"This program is obsolete. For replacement check ethtool." in the NOTE section, and the SEE ALSO section refers to ethtool.

However the 2004 version doesn't have any of these mentions (see above).

Why was it removed in 2004?