[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <YDO0LvSf0/sa7dmq@lunn.ch>
Date: Mon, 22 Feb 2021 14:39:58 +0100
From: Andrew Lunn <andrew@...n.ch>
To: Eric Dumazet <eric.dumazet@...il.com>
Cc: Danielle Ratson <danieller@...dia.com>, netdev@...r.kernel.org,
davem@...emloft.net, kuba@...nel.org, jiri@...dia.com,
f.fainelli@...il.com, mkubecek@...e.cz, mlxsw@...dia.com,
idosch@...dia.com
Subject: Re: [PATCH net-next v4 3/8] ethtool: Get link mode in use instead of
speed and duplex parameters
> > 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
Powered by blists - more mailing lists