lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Thu, 18 Feb 2021 11:20:37 +0100
From:   Oliver Neukum <oneukum@...e.com>
To:     netdev@...r.kernel.org, grundler@...omium.org, andrew@...n.ch,
        davem@...emloft.org, hayeswang@...ltek.com, kuba@...nel.org
Cc:     Oliver Neukum <oneukum@...e.com>, Roland Dreier <roland@...nel.org>
Subject: [PATCHv3 2/3] usbnet: add method for reporting speed without MDIO

The old method for reporting network speed upwards
assumed that a device uses MDIO and uses the generic phy
functions based on that.
Add a a primitive internal version not making the assumption
reporting back directly what the status operations record.

v2: rebased on upstream
v3: changed names and made clear which units are used

Signed-off-by: Oliver Neukum <oneukum@...e.com>
Tested-by: Roland Dreier <roland@...nel.org>
---
 drivers/net/usb/usbnet.c   | 11 +++++++----
 include/linux/usb/usbnet.h |  6 ++++--
 2 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/drivers/net/usb/usbnet.c b/drivers/net/usb/usbnet.c
index f3e5ad9befd0..368428a4290b 100644
--- a/drivers/net/usb/usbnet.c
+++ b/drivers/net/usb/usbnet.c
@@ -971,10 +971,10 @@ int usbnet_get_link_ksettings_internal(struct net_device *net,
 	 * For wireless stuff it is not true.
 	 * We assume that rxspeed matters more.
 	 */
-	if (dev->rxspeed != SPEED_UNKNOWN)
-		cmd->base.speed = dev->rxspeed / 1000000;
-	else if (dev->txspeed != SPEED_UNKNOWN)
-		cmd->base.speed = dev->txspeed / 1000000;
+	if (dev->rx_speed != SPEED_UNSET)
+		cmd->base.speed = dev->rx_speed / 1000000;
+	else if (dev->tx_speed != SPEED_UNSET)
+		cmd->base.speed = dev->tx_speed / 1000000;
 	else
 		cmd->base.speed = SPEED_UNKNOWN;
 
@@ -1685,6 +1685,9 @@ usbnet_probe (struct usb_interface *udev, const struct usb_device_id *prod)
 	dev->intf = udev;
 	dev->driver_info = info;
 	dev->driver_name = name;
+	/* cannot use 0, as simplex devices may exist */
+	dev->rx_speed = SPEED_UNSET; /* unknown or handled by MII */
+	dev->tx_speed = SPEED_UNSET; 
 
 	net->tstats = netdev_alloc_pcpu_stats(struct pcpu_sw_netstats);
 	if (!net->tstats)
diff --git a/include/linux/usb/usbnet.h b/include/linux/usb/usbnet.h
index 132c1b5e14bb..7f445c1e0003 100644
--- a/include/linux/usb/usbnet.h
+++ b/include/linux/usb/usbnet.h
@@ -53,6 +53,10 @@ struct usbnet {
 	u32			hard_mtu;	/* count any extra framing */
 	size_t			rx_urb_size;	/* size for rx urbs */
 	struct mii_if_info	mii;
+	/* These are bits per second unlike what ethernet uses */
+	long			rx_speed;	/* if MII is not used */
+	long			tx_speed;	/* if MII is not used */
+#		define SPEED_UNSET	-1
 
 	/* various kinds of pending driver work */
 	struct sk_buff_head	rxq;
@@ -81,8 +85,6 @@ struct usbnet {
 #		define EVENT_LINK_CHANGE	11
 #		define EVENT_SET_RX_MODE	12
 #		define EVENT_NO_IP_ALIGN	13
-	u32			rx_speed;	/* in bps - NOT Mbps */
-	u32			tx_speed;	/* in bps - NOT Mbps */
 };
 
 static inline struct usb_driver *driver_of(struct usb_interface *intf)
-- 
2.26.2

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ