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, become a Patron on Patreon, or purchase goods on Amazon or Aliexpress

Radxa Orion O6 Armv9 mini-ITX motherboard
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.
74 Comments
oldest
newest
Boardcon CM3588 Rockchip RK3588 System-on-Module designed for AI and IoT applications