3

How to get Link speed of USB Ethernet?

$ sudo ethtool enp0s20u2c2
Settings for enp0s20u2c2:
    Current message level: 0x00000007 (7)
                           drv probe link
    Link detected: yes

$ sudo mii-tool enp0s20u2c2
SIOCGMIIPHY on 'enp0s20u2c2' failed: Operation not supported

$ ifconfig
enp0s20u2c2: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
    inet 10.0.0.6  netmask 255.0.0.0  broadcast 10.255.255.255
    inet6 fe80::f6f2:6dff:fe18:fb0b  prefixlen 64  scopeid 0x20<link>
    ether f4:f2:6d:18:fb:0b  txqueuelen 1000  (Ethernet)
    RX packets 91635  bytes 108661674 (103.6 MiB)
    RX errors 0  dropped 0  overruns 0  frame 0
    TX packets 82066  bytes 20398670 (19.4 MiB)
    TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

enp3s0: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
    ether 8c:89:a5:0e:da:e2  txqueuelen 1000  (Ethernet)
    RX packets 274813965  bytes 281606620432 (262.2 GiB)
    RX errors 2  dropped 0  overruns 0  frame 2
    TX packets 307772449  bytes 202115845888 (188.2 GiB)
    TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
    device interrupt 18

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
    inet 127.0.0.1  netmask 255.0.0.0
    inet6 ::1  prefixlen 128  scopeid 0x10<host>
    loop  txqueuelen 1  (Local Loopback)
    RX packets 4778773  bytes 1711054659 (1.5 GiB)
    RX errors 0  dropped 0  overruns 0  frame 0
    TX packets 4778773  bytes 1711054659 (1.5 GiB)
    TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

wlp4s0: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
    ether 70:18:8b:82:51:79  txqueuelen 1000  (Ethernet)
    RX packets 171104  bytes 101660534 (96.9 MiB)
    RX errors 0  dropped 0  overruns 0  frame 0
    TX packets 140287  bytes 59377507 (56.6 MiB)
    TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

Related dmesg

[1281750.433715] usb 3-2: new high-speed USB device number 24 using xhci_hcd
[1281751.213885] cdc_ether 3-2:2.0 eth0: register 'cdc_ether' at usb-0000:00:14.0-2, CDC Ethernet Device, f4:f2:6d:18:fb:0b
[1281751.213910] usbcore: registered new interface driver cdc_ether
[1281751.348703] cdc_ether 3-2:2.0 enp0s20u2c2: renamed from eth0
[1281751.705115] IPv6: ADDRCONF(NETDEV_UP): enp0s20u2c2: link is not ready
[1281751.705235] cdc_ether 3-2:2.0 enp0s20u2c2: kevent 12 may have been dropped
[1281751.705241] cdc_ether 3-2:2.0 enp0s20u2c2: kevent 12 may have been dropped
[1281751.706719] cdc_ether 3-2:2.0 enp0s20u2c2: kevent 12 may have been dropped
[1281751.706925] cdc_ether 3-2:2.0 enp0s20u2c2: kevent 12 may have been dropped
[1281751.706934] cdc_ether 3-2:2.0 enp0s20u2c2: kevent 12 may have been dropped
[1281761.835095] cdc_ether 3-2:2.0 enp0s20u2c2: kevent 12 may have been dropped
[1281761.835106] cdc_ether 3-2:2.0 enp0s20u2c2: kevent 12 may have been dropped
[1281761.960577] cdc_ether 3-2:2.0 enp0s20u2c2: kevent 12 may have been dropped
[1281761.960593] cdc_ether 3-2:2.0 enp0s20u2c2: kevent 12 may have been dropped

I'm using 64-bit archlinux.

Kokizzu
  • 9,699

1 Answers1

1

I would compile ethtool from source and recompile cdc_ether and usbnet against your kernel.

From David Brownell (author of cdc_ether)

http://www.linux-usb.org/usbnet/

Ethtool

With ethtool version 1.5 or later, and recent enough version of the usbnet driver, you can get additional information from the driver. Different devices may have different information available; for example, link availability is not always known. Linux defines some standard interpretations for the "message level" bits, which are not widely used ... but this framework uses them for all its devices, letting you mask which messages will be seen. (Many messages won't be available unless debugging is enabled.)

sh# ethtool usb0
Settings for usb0:
    Current message level: 0x00000001 (1)
sh# ethtool -i usb0
driver: usbnet
version: 17-Jul-2002
firmware-version: Prolific PL-2301/PL-2302
bus-info: usb-00:02.0-1.2
sh#
sh# ethtool usb1
Settings for usb1:
    Current message level: 0x00000001 (1)
    Link detected: no
sh# ethtool -i usb1
driver: usbnet
version: 17-Jul-2002
firmware-version: NetChip TurboCONNECT
bus-info: usb-00:02.0-1.4
sh#

You might want to use stable bus-info values to figure out what network address to assign to a given link, if your routing configuration needs that. You can use ip link set usbN name newname or similar tools. (NOTE: the nameif tool is unfortunately not going to help here, since it assumes that that Ethernet addresses solve this problem. For dynamically assigned Ethernet addresses, that can't work; using "bus-info" is the appropriate solution.)

See also https://hewlettpackard.github.io/wireless-tools/HOTPLUG.txt about handling such hotplug issues, mostly with Debian and wireless.)

f3xy
  • 111