netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andrew Lunn <andrew@lunn.ch>
To: Eric Dumazet <eric.dumazet@gmail.com>
Cc: Danielle Ratson <danieller@nvidia.com>,
	netdev@vger.kernel.org, davem@davemloft.net, kuba@kernel.org,
	jiri@nvidia.com, f.fainelli@gmail.com, mkubecek@suse.cz,
	mlxsw@nvidia.com, idosch@nvidia.com
Subject: Re: [PATCH net-next v4 3/8] ethtool: Get link mode in use instead of speed and duplex parameters
Date: Mon, 22 Feb 2021 14:39:58 +0100	[thread overview]
Message-ID: <YDO0LvSf0/sa7dmq@lunn.ch> (raw)
In-Reply-To: <672f3968-fb26-3af5-de23-219ea9411765@gmail.com>

> > Currently, when user space queries the link's parameters, as speed and
> > duplex, each parameter is passed from the driver to ethtool.
> > 
> > Instead, get the link mode bit in use, and derive each of the parameters
> > from it in ethtool.

> > +	err = dev->ethtool_ops->get_link_ksettings(dev, link_ksettings);
> > +	if (err)
> > +		return err;
> 
> If a driver like drivers/net/tun.c does a complete
> 
> memcpy(cmd, &tun->link_ksettings, sizeof(*cmd)); 
> 
> then the link_ksettings->link_mode is overwritten with possible
> garbage data.
> 
> > +
> > +	if (link_ksettings->link_mode != -1) {
> > +		link_info = &link_mode_params[link_ksettings->link_mode];
> > +		link_ksettings->base.speed = link_info->speed;
> > +		link_ksettings->lanes = link_info->lanes;
> > +		link_ksettings->base.duplex = link_info->duplex;
> > +	}

Sorry, i missed the first posting of this.

What about downshift? A 1G PHY detects that it cannot establish a link
using four pairs at 1G. So it downshifts to 100Mbps using 2 pairs. The
PHY will report a speed of SPEED_100, despite the mode being
1000Base-T. This is not part of 802.3 clause 22, but a number of PHYs
have vendor registers which report the actual speed, and drivers are
reading this actual speed and returning it.

I really think you need to only use the link_mode derived speed when
speed is SPEED_UNKNOWN, duplex is DUPLEX_UNKNOWN.

	Andrew

  parent reply	other threads:[~2021-02-22 13:44 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-02 18:06 [PATCH net-next v4 0/8] Support setting lanes via ethtool Danielle Ratson
2021-02-02 18:06 ` [PATCH net-next v4 1/8] ethtool: Validate master slave configuration before rtnl_lock() Danielle Ratson
2021-02-02 18:06 ` [PATCH net-next v4 2/8] ethtool: Extend link modes settings uAPI with lanes Danielle Ratson
2021-02-02 18:06 ` [PATCH net-next v4 3/8] ethtool: Get link mode in use instead of speed and duplex parameters Danielle Ratson
2021-02-22  9:41   ` Eric Dumazet
2021-02-22 13:11     ` Danielle Ratson
2021-02-22 13:39     ` Andrew Lunn [this message]
2021-02-02 18:06 ` [PATCH net-next v4 4/8] ethtool: Expose the number of lanes in use Danielle Ratson
2021-02-02 18:06 ` [PATCH net-next v4 5/8] mlxsw: ethtool: Remove max lanes filtering Danielle Ratson
2021-02-02 18:06 ` [PATCH net-next v4 6/8] mlxsw: ethtool: Add support for setting lanes when autoneg is off Danielle Ratson
2021-02-02 18:06 ` [PATCH net-next v4 7/8] mlxsw: ethtool: Pass link mode in use to ethtool Danielle Ratson
2021-02-02 18:06 ` [PATCH net-next v4 8/8] net: selftests: Add lanes setting test Danielle Ratson
2021-02-02 19:54 ` [PATCH net-next v4 0/8] Support setting lanes via ethtool Edwin Peer
2021-02-04  4:00 ` patchwork-bot+netdevbpf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YDO0LvSf0/sa7dmq@lunn.ch \
    --to=andrew@lunn.ch \
    --cc=danieller@nvidia.com \
    --cc=davem@davemloft.net \
    --cc=eric.dumazet@gmail.com \
    --cc=f.fainelli@gmail.com \
    --cc=idosch@nvidia.com \
    --cc=jiri@nvidia.com \
    --cc=kuba@kernel.org \
    --cc=mkubecek@suse.cz \
    --cc=mlxsw@nvidia.com \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).