Thread (14 messages) 14 messages, 5 authors, 2021-02-22

Re: [PATCH net-next v4 3/8] ethtool: Get link mode in use instead of speed and duplex parameters

flat view

From: Andrew Lunn <andrew@lunn.ch>
Date: 2021-02-22 13:44:46

quoted
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.
quoted
+	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.
quoted
+
+	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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help