Subject: Re: [PATCH net-next 1/3] selftests: mlxsw: Add ethtool_lib.sh

From: Ido Schimmel <[email-masked]>
Date: Mon, 10 Jun 2019 17:31:57 +0300

On Mon, Jun 10, 2019 at 03:59:14PM +0200, Andrew Lunn wrote:
> > +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, are you suggestion to split speeds_get() into
supported_speeds_get() and advertised_speeds_get() and use each where
appropriate? Note that not all the tests are testing with autoneg on.