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.

[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 PayPal or cryptocurrencies, become a Patron on Patreon, or buy review samples

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.
60 Comments
oldest
newest
tkaiser
tkaiser
2 months 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
2 months 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
domih
2 months 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
domih
2 months 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
domih
2 months 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
domih
2 months ago

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

domih
domih
2 months 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
domih
2 months 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
domih
2 months 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
domih
2 months 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: [email protected]:~/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)}, [email protected]:~/Downloads$ diff r8152-master/50-usb-realtek-net.rules r8152-2.15.0/50-usb-realtek-net.rules… Read more »

tkaiser
tkaiser
2 months ago

> the CPUs should not be the bottleneck.

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

Willy
2 months 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
2 months 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
2 months 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
domih
2 months ago

[email protected]:~$ 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
2 months 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
2 months 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
2 months 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
2 months 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
2 months 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
2 months ago

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

Tim
Tim
2 months 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
Olexii
2 months ago

Can try on one machine through virtual systems but to connect networks in adapters among themselves by a patchcord.and keep trying. Maybe the arm driver is weak.
Try loop.

Theguyuk
Theguyuk
2 months ago

Searching for issues with the usb ethernet chipset you have, shows it is popular for problems and driver issues. Seems you bought a world of pain.

domih
domih
2 months ago

Yep!

Willy
2 months ago

Please note that this large an rx-usecs is only going to increase losses at best, as it tries to deliver IRQs no more than every 250ms, i.e. it can fill the rx ring and deliver the IRQ once completely filled. I think that instead it would be useful to try with lower values (like 30 which can cause up to 33k irq/s and will trigger after no more than 108 packets in ring at 2.5 GbE). It’s also common for many chips not to use accurate timings, so another test you can make is to use “rx-frames 1” to try… Read more »

domih
domih
2 months ago

Great. Is there a good documentation somewhere describing the meaning of these TX and RX parameters? I can play with these, but I need to know what I’m doing/testing. TIA!

Willy
2 months ago

I guess it’s in “man ethtool”, but the names look pretty natural to me: everything suffixed with “usecs” indicates a delay, others are counts.

domih
domih
2 months ago

With: [email protected]:~$ sudo ethtool -i enx00e04c680184 driver: cdc_ncm version: 5.13.0-30-generic firmware-version: CDC NCM expansion-rom-version: bus-info: usb-0000:08:00.3-1 supports-statistics: yes supports-test: no supports-eeprom-access: no supports-register-dump: no supports-priv-flags: no [email protected]:~$ sudo ethtool -c enx00e04c680184 Coalesce parameters for enx00e04c680184: Cannot get device coalesce settings: Operation not supported [email protected]:~$ sudo ethtool -C enx00e04c680184 rx-usecs 250000 Cannot get device coalesce settings: Operation not supported [email protected]:~$ sudo ethtool -g enx00e04c680184 Ring parameters for enx00e04c680184: Cannot get device ring settings: Operation not supported [email protected]:~$ sudo ethtool -G enx00e04c680184 rx 1000 Cannot get device ring settings: Operation not supported So I guess I’ll have to try it with the… Read more »

tkaiser
tkaiser
1 month ago

What does this new RTL8156B dongle report when querying it for bcdDevice?

Vladislav
1 month ago

Friendly reminder to provide the details on the new RTL8156B dongle report.

tkaiser
tkaiser
1 month ago

Thank you! That’s at least a third variant after ‘30.00’ (RTL8156) and ‘31.00’ (RTL8156B).

tkaiser
tkaiser
1 month ago

Ok, it starts to make sense (at least from a Linux perspective):

RTL81XX: don’t buy, doesn’t work
RTL81XXB: barely working
RTL81XXBG: barely working but good enough

tkaiser
tkaiser
1 month ago

Hmm… strange since what remains then? AMD Ryzen means USB3/XHCI host controller being part of the CPU or some AMD chipset? Same controller in both laptops?

If that’s the case the only remaining difference could be unstable powering triggering issues with the RTL8156B but not with the different/new RTL8156BG dongle?

Andrew Welham
Andrew Welham
1 month ago

repost ( may have forgot to submit) Good to see it was not just me with these issues. I have multiple usb3 – 2.5GB dongles with R8156b chips. Running on Ubuntu Jammy and win 11. Terrible issues with performance and old drivers limiting ubuntu to 2500 / half. Using ethtool to force the speeds (or at least advertised speeds) was throwing errors. I even had the interface going off line overnight, (I think I fixed it by disabling power savings, still testing, I have read the driver crashes if told to sleep). I was also seeing huge fluctuations in performance… Read more »

Willy
1 month ago

Interesting. This option sounds very much like “workaround for known but undisclosed chip bug” :-/

MrRobot
MrRobot
22 days ago

Hi, Andrew, Thanks a lot for your findings!

I was able to compile the r8152.c driver on Linux Kernel 5.15 thanks to you.

static int rtl8152_get_coalesce(struct net_device *netdev,
struct ethtool_coalesce *coalesce,
struct kernel_ethtool_coalesce *kernel_coal,
  struct netlink_ext_ack *extack)

static int rtl8152_set_coalesce(struct net_device *netdev,
struct ethtool_coalesce *coalesce,
struct kernel_ethtool_coalesce *kernel_coal,
  struct netlink_ext_ack *extack)

I came out with the following little script:

sudo apt install lshw -y
sudo cp rtl8156b-2.fw /usr/lib/firmware/rtl_nic/rtl8156b-2.fw
make clean
make all
make install
modprobe r8152
sudo cp 50-usb-realtek-net.rules /etc/udev/rules.d/50-usb-realtek-net.rules
sudo depmod -a
sudo update-initramfs -u
sudo rm -rf /usr/lib/modules/$(uname -r)/kernel/drivers/net/usb/cdc_ncm.ko

It now works great, with full duplex and all!

tkaiser
tkaiser
24 days ago

> With the USB protocol analyzer sniffer in between, the issue does not occur.

Reminds me of the situation at a former customer over a decade ago. Their ‘network department’ was never able to reproduce issues when they put their Ethernet sniffer in between. Turned out the thing was pretty old and only capable of Fast Ethernet. 🙂

Vladislav
1 month ago

Another post where I see that RTL81xxBG is showing quietly and fixing performance issues.
I saw the same chipset in review for DIEWU network card ASM1812 + RTL8125BG chipsets…

Eugen
Eugen
26 days ago

Thanks Jean-Luc! The brand new Ubuntu 22.04 has the same problem, and the 50-usb-realtek-net.rules trick worked for me. Kernel already is at 5.15 however, so no need to upgrade that.

MrRobot
MrRobot
25 days ago

Hi all, I’ve just purchased 4 units of Alxum 2.5 Gigabit Ethernet Adapter, 2.5 Gigabit Network Adapter with RTL8156B (https://amzn.to/3k8SwKD), at one go/in the same purchase. Something funny (crazy?) is happening: I got two RaspberryPi Model 4B, 8GB The first one Installed with the Beta 64bits version available on the “legacy” download link here: https://downloads.raspberrypi.org/raspios_arm64/images/ I am using that version: 2021-10-30-raspios-bullseye-arm64-lite.img The kernel version of that one is 5.10 On the second one I’ve installed the official 64 bits version after it got released few weeks/months ago, and installed it with the RaspberryPi Imager The kernel version is 5.15 And guess what ?… Read more »

tkaiser
tkaiser
24 days ago

The r8152 driver is the preferred one and if you want to debug why some install chooses this driver and the other another one, probably udevadm is of help: https://unix.stackexchange.com/a/607935

Module blacklisting might be the other source of different driver ‘choices’ so if you’re not administrating the RPi yourself check /etc/modprobe.d/ and ‘grep blacklist /proc/cmdline’

MrRobot
MrRobot
21 days ago

For your information, I also ordered the ASUS USB-C2500 2.5G Ethernet USB Adapter, and plugged it on my RPi 4B with the latest official 64 bit RaspiOS, and Kernel 5.15. The bcdDevice version is even higher: 31.05. $ usb-devices T: Bus=02 Lev=01 Prnt=01 Port=01 Cnt=01 Dev#= 2 Spd=5000 MxCh= 0 D: Ver= 3.20 Cls=00(>ifc ) Sub=00 Prot=00 MxPS= 9 #Cfgs= 3 P: Vendor=0b05 ProdID=1976 Rev=31.05 S: Manufacturer=Realtek S: Product=USB 10/100/1G/2.5G LAN S: SerialNumber=5013000001 C: #Ifs= 2 Cfg#= 2 Atr=a0 MxPwr=256mA I: If#=0x0 Alt= 0 #EPs= 1 Cls=02(commc) Sub=0d Prot=00 Driver=(none) I: If#=0x1 Alt= 0 #EPs= 0 Cls=0a(data ) Sub=00 Prot=01 Driver=(none) 1234567891011 $ usb-devices T: Bus=02 Lev=01 Prnt=01 Port=01 Cnt=01 Dev#= 2 Spd=5000 MxCh=… Read more »

Advertisement