> +speeds_get()
> +{
> + local dev=$1; shift
> + local with_mode=$1; shift
> +
> + local speeds_str=$(ethtool "$dev" | \
> + # Snip everything before the link modes section.
> + sed -n '/Supported link modes:/,$p' | \
> + # Quit processing the rest at the start of the next section.
> + # When checking, skip the header of this section (hence the 2,).
> + sed -n '2,${/^[\t][^ \t]/q};p' | \
> + # Drop the section header of the current section.
> + cut -d':' -f2)
ethtool gives you two lists of link modes:
$ sudo ethtool eth17
Settings for eth17:
Supported ports: [ TP ]
Supported link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
1000baseT/Full
Supported pause frame use: No
Supports auto-negotiation: Yes
Supported FEC modes: Not reported
Advertised link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
1000baseT/Full
and if auto-neg has completed, there is potentially a third list, what
the peer is advertising.
Since this test is all about auto-neg, you should be using Advertised
link modes, not Supported link modes. There can be supported link
modes which you cannot advertise.
Andrew