How to use RTL8156 USB ethernet adapter(2.5Gbase) with correct driver

I am looking for a way to use the RTL8156 USB ethernet adapter with the correct driver on OpenWrt on PC hardware (x86/64)
This device is recognized as an ethernet device just by plugging it in, but the cdc_ncm driver is selected, and has problems such as low throughput.

root@OpenWrt:~# lsusb
Bus 002 Device 002: ID 0bda:8156 Realtek USB 10/100/1G/2.5G LAN

I installed "kmod-usb-net-rtl8152" and related packages in my OpenWrt 22.03 environment and found that other Linux systems such as ArchLinux could solve this situation by installing the r8152 package,
I ran the command echo 1 > /sys/bus/usb/devices/2-1/bConfigurationValue based on the following post (A huge thank you to bmork and the users of the forum).

As a result, the r8152 driver detected the device, but an error "r8152 2-1:1.0: Unknown version 0x7410" is printed.
(I suspect this is because the current driver supports the series up to RTL8153 and not the newer RTL8156 devices.)

So I tried a snapshot build of kernel 5.15.114 and tried the same thing, and was able to confirm that the r8152 driver recognizes this adapter, but it outputs logs like this, and although communication is possible I encountered some problems, such as not linking up at 2.5GbaseT.
(I tried to force a link speed change with ethtool just to be sure, but could not change it from 1000base-T)

[    8.368490] usb 2-1: reset SuperSpeed USB device number 2 using xhci_hcd
[    8.411750] r8152 2-1:1.0: ram code speedup mode fail
[    8.412077] r8152 2-1:1.0: load rtl8156b-2 v2 04/27/23 successfully
[    8.458695] r8152 2-1:1.0 (unnamed net_device) (uninitialized): netif_napi_add() called with weight 256
[    8.459761] r8152 2-1:1.0 eth4: v1.12.13

Any advice on how to use 2.5G/full speed with this RTL8156 device?
I don't have the ability to modify the source code, but I think I can check the logs of the device if needed or create an image using the Build system from another PC.

Any help will be appreciated. Thank you.

I finally looked at this when I got one of these adapters myself, and this was the best I could come up with:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/drivers/net/usb/r8152.c?id=ec51fbd1b8a2bca2948dede99c14ec63dc57ff6b

But that's in Linux 6.3 and later, and I don't think it's stable material. OpenWrt would probably accept a backport, but you'd need to bring in lots of other changes between 6.1 and 6.3

The other alternative is simply waiting for OpenWrt to have a newer kernel.

But you don't have to wait for the unrelated "Unknown version 0x7410" problem. That was solved with
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/drivers/net/usb/r8152.c?id=195aae321c829dd1945900d75561e6aa79cce208
which is in Linux v5.13 and later. So it's already in OpenWrt. You just need the latest snapshot or 23.05 release :slight_smile:

And with that in place, the manual bConfiguration workaround should work fine.

2 Likes

Thanks for the clarifying answer!
I just tried new snapshot build on another device (x86/64) and the RTL8156 device linked at 2500/Full.

I'll check with the original machine at a later date, but it looks like using the newer build will solve the problem.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.