Fixing performance issues with Realtek RTL8156B 2.5GbE USB dongle in Ubuntu

A few days ago, I reviewed a USB 3.0 to 2.5 Gbps Ethernet adapter based on Realtek RTL8156B chip in Ubuntu 20.04, and let’s say the reliability and performance were underwhelming. I got some recommendations like changing cables, the MTU size, etc…

Playing around with cables did no help, but one comment mentioned the cdc_ncm driver could be the issue, followed by another saying that updating to Linux kernel 5.14 should install the correct r8152 driver… So I just did that:


This upgraded Linux 5.13 (shipped with Ubuntu 20.04 + HWE) to Linux 5.14, but still no luck as the system kept using the cdc_ncm driver with a half-duplex link:


But then I thought I may have to use udev rules to prevent loading the cdc_ncm driver, and there’s indeed 50-usb-realtek-net.rules in r8152 driver to do just that. So I copied the file in /etc/udev/rules.d/ folder. Since I did not want to reboot, I unloaded the modules I did not need, and restart udev to try it out:


Let’s see…


Great! It’s now using r8152 driver and we’ve got a full-duplex connection.

Let’s go through all our tests again to compare the results.

iperf2

upload


download:


There’s an improvement to the download speed (was 600 Mbps with cdc_ncm driver), but still not quite close to 2.3 Gbps.

Let’s try full-duplex for fun:


That’s actually not too bad.

iperf3

upload:


download:


About the same as iperf2.

iperf3 did not have support for full-duplex for many years, but version 3.7 reintroduced the feature. So let’s give it a go:


Oops! What happened? There are some error messages in the kernel log as well.


I’m not the only one to have this problem, and that’s an open issue in r8156 driver’s Github repo. Here’s the answer from the developer for reference:

I suspect a problem on the ethernet adapter side, as there are many reports of it working with the DS918+. (Eg. design of power line, overheat, etc.)
https://github.com/bb-qq/r8152/wiki/Compatibility

Could you try another vendor? Also using a USB Hub with an external power supply might improve the situation.

At this point, the Ethernet did not work at all, and I had to unplug and reinsert the USB dongle. The second time “worked”.


There are still retransmissions on the Rx side which could help explain the lower speed.

SAMBA

From my laptop with the RTL8156B dongle, and SATA SSD to UP Xtreme i11 mini PC with a 2.5GbE port, and a MINIX USB-C dock with a 480GB SSD.

SAMBA r8152 driver laptop to mini PC

Around 930 Mbps with r8152 driver against 750 Mbps with cdc_ncm driver.

Now from the mini PC to the laptop (aka download)…

 

SAMBA r8152 driver mini PC to laptop

It’s slower as expected at 837 Mbps, but better than the under 500 Mbps I got with the cdc_ncm driver.

scp

laptop to mini PC:


mini PC to laptop:


It’s almost the same speed between download and upload with scp which is odd. The bottleneck here looks to be my SATA SSD:


Read is limited by around 145 MB/s, while write is around 140 MB/s.

The SSD used in MINIX NEO Storage Plus USB-C dock is quite faster with, last time I tested, 379MB/s for sequential reads, and 240+MB/s for sequential writes.

So let’s see the speed we can get throwing away the data to /dev/null

download to laptop:


upload from laptop:


So that’s more like it for the upload at least. I still have a problem with the download speed, but the performance was still greatly improved with the r8152 driver.

cdc_ncm vs r8152 drivers ubuntu
Left scale in Mbps

 

Testing with NanoPi R4S

While it’s much better, it’s not optimal. I have a NanoPi R4S router with two USB 3.0 ports, so I first tried it using the latest OpenWrt (FriendlyWrt) 21.02 image with Linux 5.15:


It’s really ugly with lots of retransmissions on both sides.


Looking at the kernel log, our RTL8156B USB dongle is using that CDC NCM driver again, just like in Ubuntu… There’s an r8152 driver too, but whatever module I remove in /etc/modules.d either the CDC NCM is loaded or the eth2 interface does not show up at all. So I’ve switched to the Ubuntu 20.04-based FriendlyCore OS, also featuring Linux 5.15, that will be closer to the setup on my laptop.

As one might have expected, the RTL8156B adapter uses the CDC NCM driver by default in Ubuntu:


eth1 is not showing up with ifconfig, so I just went ahead and change udev rules to use the r8152 driver…


It’s getting depressing. Let’s update the system first.


I followed all those steps since the FriendlyCore image relies on servers from China, which are very slow from where I have (just running apt update can take 15 minutes), so the update was possibly faster that way, although it still took a couple of hours! (See Changing Ubuntu Apt Mirror from the Command Line for details).

It did not help with the firmware issue. So instead I search for that rtl_nic/rtl8156b-2.fw file. It is in the firmware-realtek Debian package, or linux-firmware Ubuntu Impish package.

I downloaded the latter, extracted rtl8156b-2.fw and copied it to /etc/firmware/rtl_nic. It now works:


Somehow the interface is still not up, and adding it manually to /etc/network/interfaces.d, does not work.

Back to the Ubuntu laptop with rtl8156b-2.fw firmware

So instead, I went back to my laptop, and copied the firmware file to /lib/firmware/rtl_nic directory. The result was the same as in NanoPi R4S:


Let’s try iperf3 upload:


Same as before, so no regression. Now for the iperf3 download:


It’s getting better, although we are not there yet, and the retransmissions are through the roof. I’m really tired now… Let me know if you have other ideas.

Realtek RTL8156BG USB 3.0 to 2.5GbE dongle to the rescue.

[Update: Realtek sent me one of their USB 3.0 to 2.5GbE adapters and it does not have the same performance issue


]

Share this:

Support CNX Software! Donate via cryptocurrencies or become a Patron on Patreon

ROCK Pi 4C Plus
Subscribe
Notify of
guest
The comment form collects your name, email and content to allow us keep track of the comments placed on the website. Please read and accept our website Terms and Privacy Policy to post a comment.
71 Comments
oldest
newest
tkaiser
tkaiser
1 year ago

Have you already checked whether it can be related to overheating (thumb test, operating the thing open)? The RTL8156 dongles we use (Delock 65990) have a rather heavy metal enclosure allowing for good heat dissipation…

tkaiser
tkaiser
1 year ago

As for the horribly low SMB performance with Linux as client you should check whether you used gfvs and if that’s the case better switch to mount.cifs instead (might require installation of cifs-utils package).

domih
1 year ago

@Jean-Luc (1) reading this article and the previous one, I went back to testing rtl8156b on ARM (an Odroid N2+). The driver I use provides the expected max speed you can hope for: 2.35Gbits/sec in one direction and 2.05 Gbits/sec because the ARM CPU would probably need to run at 3Ghz to support 2.35Gbits/sec in reverse, meaning sending.) (2) To my dismay, with the driver I use plus the current ARM kernel on Odroid N2+ (4.9.277-121) hard disconnection is showing up its ugly head again (same thing using the Kernel driver too) in one direction 🙁 See https://forum.odroid.com/viewtopic.php?f=181&t=44027 for details.… Read more »

domih
1 year ago

@Jean-Luc

You may also want to try between the  UP Xtreme i11 and another PC. On my side, Odroid H2+ <–> an AMD r7-5700g go full speed high flying colors, no disconnection.

I’m now going to try Armbian images on the Odroid N2+, I think I remember Igor saying at the time that he took care of integrating and testing the Realtek drivers. I’ll try Armbian_20.05.1_Odroidn2_focal_current_5.6.15 and Armbian_21.08.9_Odroidn2_focal_current_5.10.81.

It could be that a full working Realtek driver started to appear with Kernel 5.6…

We’ll see.

domih
1 year ago

I tested Armbian on the Odroid N2+. It provides a tiny optimization in speed but I see the same pattern of hard disconnection. I posted my results on the Odroid forum whose link is in my first comment here.

domih
1 year ago

Oh, I thought you were testing with the RK3568 on the Radxa.

domih
1 year ago

a) What OS do you run on each host?
b) What does sudo ethtool -i <nic_name_in_ip_a> show?
c) After testing what does sudo ethtool -S <nic…> show?

In the meantime, may be I was lucky between my H2+ and 5700g with only 300-second sessions. I’m gonna run a 3600-second session just to be sure.

domih
1 year ago

The 1H session between a H2+ and a 5700g went fine full speed BUT and it’s a big one, both PC were unresponsive to console commands after the test. I had to reboot to get control back. So as of today, I’m no longer relying on these adapters, something is wrong with the current drivers and kernel. Two years ago, I ran 10H sessions with not a peep of an error. It’s a regression and clearly Realtek has not cleaned up its act.

domih
1 year ago

Yes, whatever the actual origin of the driver, they all refer to the 2.15 version from 04/15/21 on the Realtek web site. I diffed the r8152.c from the git project you referred to and from the download from the Realtek web site, it’s the same source code with just a few additions for ASUS and Trendnet branding.

domih
1 year ago

Mmm… Strike that. There are differences in compatibility.h plus usage of #ifdef ACPI_TYPE_BUFFER in r8152.c. So you may want to compare your testing between the version from the RealTek web site and the git project you referred to: domih@trx:~/Downloads$ diff r8152-master/r8152.c r8152-2.15.0/r8152.c 301,303d300 < #ifdef CR_TE < #undef CR_TE < #endif 794d790 < #define VENDOR_ID_ASUS         0x0b05 801d796 < #define VENDOR_ID_TRENDNET      0x20f4 1452d1446 < #ifdef ACPI_TYPE_BUFFER 1499d1492 < #endif 1509d1501 < #ifdef ACPI_TYPE_BUFFER 1521,1522d1512 < #endif < 20081d20070 <   netif_info(tp, probe, netdev, “chip rev %d\n”, tp->version); 20193,20195d20181 <   /* TRENDnet */ <   {REALTEK_USB_DEVICE(VENDOR_ID_TRENDNET, 0xe02b)}, <    20198,20200d20183 <    <   /* ASUS */ <   {REALTEK_USB_DEVICE(VENDOR_ID_ASUS, 0x1976)}, domih@trx:~/Downloads$ diff r8152-master/50-usb-realtek-net.rules r8152-2.15.0/50-usb-realtek-net.rules… Read more »

tkaiser
tkaiser
1 year ago

> the CPUs should not be the bottleneck.

But have you actually looked with atop in parallel while testing?

Willy
1 year ago

Just one general comment though that’s certainly not the cause of your current issue given the low rates involved, that’s a huge number of parasitic processes on your machine! The machine should be at exactly 0% CPU when the test does not run, and it should be dedicated to the test software **exclusively**. If you don’t want to kill these parasitic processes, just send them a kill -STOP before the tests, and a kill -CONT after (don’t forget to reduce your browser windows before kill -STOP as you won’t be able to move them). I’m personally used to seeing perf… Read more »

Willy
1 year ago

> the CPUs should not be the bottleneck

It could be if the driver is crappy or the rings are too small, resulting in lots of wakeups/sleeps or IRQs. It would be interesting to see “top” and check if you’re seeing ksoftirqd at 100% on one core, especially during the Rx tests. In this case it could be useful to enable RPS (/sys/class/net/eth1/queues/rx*/rps_cpus) to make other cores deal with the incoming traffic. Maybe the USB stack is busy enough on the receiving core.

tkaiser
tkaiser
1 year ago

> testing rtl8156b on ARM (an Odroid N2+)

Did Hardkernel replace the Genesys Logic GL3523 hub from the N2 on the N2+ or is it still the same thing?

domih
1 year ago

domih@n2pa:~$ lsusb Bus 002 Device 003: ID 152d:0578 JMicron Technology Corp. / JMicron USA Technology Corp. JMS567 SATA 6Gb/s bridge Bus 002 Device 002: ID 05e3:0620 Genesys Logic, Inc. USB3.1 Hub Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub Bus 001 Device 007: ID 0b95:6801 ASIX Electronics Corp. Bus 001 Device 006: ID 0b95:6801 ASIX Electronics Corp. USB2.1 Hub Bus 001 Device 005: ID 0b95:6808 ASIX Electronics Corp. Bus 001 Device 003: ID 1a40:0101 Terminus Technology Inc. Hub Bus 001 Device 002: ID 05e3:0610 Genesys Logic, Inc. 4-port hub Bus 001 Device 001: ID 1d6b:0002 Linux Foundation… Read more »

tkaiser
tkaiser
1 year ago

Thank you. So still ‘broken by design’ 🙁

I really wonder why they did not use the VL817 for N2+ (as they did on the C4. But even then everything behind an USB hub is sort of ‘broken by design’. Those Amlogic SoCs have USB3 and PCIe multiplexed so why not using a PCIe attached USB3 host controller like the VL805 instead to provide four USB3 ports?).

back2future
back2future
1 year ago

Is there a chance for testing RTL8156 related hardware with Windows 10/11 from https://realtek-download.com/realtek-usb-fe-gbe-2-5g-rtl8156-rtl8153-rtl8152b-gaming-ethernet-family-controller/ ?

dave
dave
1 year ago

That would indeed be good. It would rule out whether it is linux driver problems or if it has hardware/overheating issues.

tkaiser
tkaiser
1 year ago

Why either/or when it’s most probably about driver and hardware issues here? 🙂

Cheap hardware is involved, one of the most crappy receptacles ever designed (USB3-A with its extra tiny SuperSpeed pins) and an OS where a user has to waste hours of his life to get at least an idea which driver to try…

back2future
back2future
1 year ago

thats ‘normality’ for a big part of this world (?)
What’s the real difference between a 5Gbe for $75 and a 2.5Gbe for $15 if most around have cell phone and average global income per day is somewhere ~$25 (while that’s average (after tax) in Cuba or Venezuela for a whole month!)?
Honestly, taking that into account means we’re still talking about Win7 drivers compatibility (guess ~2billion computers globally: Win7 (end of support 01/2020), 2020 share 31%->~22% vs. WinXp ~25million globally, Win10 >60% global coverage of Windows systems)

back2future
back2future
1 year ago

(just adding to that: a starlink deposit can be £89.00 or >$500 or $99(CA) means ios or android OS )

Tim
Tim
1 year ago

I’m patiently waiting for starlink to become available at my current location.

I recently moved from where I had gigabit download to a rural location where no ISP is available. There is a microwave based ISP who told me they were adding a tower in the next two weeks which would allow me to receive 25/5 which I will indeed use if this tower appears.

It’s no starlink but when nothing is available it’s a life-saver.

Olexii