Realtek RTL8157 5 GbE adapters with 10 Gb USB interface - Wavlink, WisdPi

Notice: Page may contain affiliate links for which we may earn a small commission through services like Amazon Affiliates or Skimlinks.

WhiteNoise

Member
Jan 20, 2024
53
12
8
Even though I promised myself to not buy another nic, especially another USB one, yesterday I bought another one.

While I was making the last minute, before tariff, purchases on Aliexpress, I noticed this super cheap https://www.aliexpress.us/item/3256808357803191.html

I have seen the complains in this thread, however, I am not 100% sure Realtek is to blame. In the past, I have had issue with some devices and some ports rated USB 10gb (Usb 3 Gen 2x1) and 20gb(Usb 3 Gen 2x2).
 

Tinkerer

Member
Sep 5, 2020
92
28
18
Don't think this was mentioned before, but to those who are having stability issues on Linux with Realtek USB-C adapters, try this:

Code:
echo disable > /sys/class/net/enp1s0f0u1/rtl_adv/sg_en
replace the enp1s0f0u1 with whatever name your USB network adapter has. You can check with ip l for instance.

I have tested it with iperf3 bidirectionally for about 5 minutes and it has been stable. That's really something considering it used to crash within seconds even on simple ping replies.
 

dza

New Member
Sep 10, 2023
3
0
1
Here's my notes for my adapter Club3D CAC-2530 5Gbps with R8157 similar to WisdPi, WAVLINK, etc.

You need the latest realtek r8152 driver (2.19.2)

I also recommend you install the 50-usb-realtek-net.rules into /usr/lib/udev/rules.d/50-usb-realtek-net.rules
Bash:
# This is used to change the default configuration of Realtek USB ethernet adapters

ACTION!="add", GOTO="usb_realtek_net_end"
SUBSYSTEM!="usb", GOTO="usb_realtek_net_end"
ENV{DEVTYPE}!="usb_device", GOTO="usb_realtek_net_end"

# Modify this to change the default value
ENV{REALTEK_MODE1}="1"
ENV{REALTEK_MODE2}="3"

# Realtek
ATTR{idVendor}=="0bda", ATTR{idProduct}=="815[2,3,5,6,7]", ATTR{bConfigurationValue}!="$env{REALTEK_MODE1}", ATTR{bConfigurationValue}="$env{REALTEK_MODE1}"
ATTR{idVendor}=="0bda", ATTR{idProduct}=="8053", ATTR{bcdDevice}=="e???", ATTR{bConfigurationValue}!="$env{REALTEK_MODE2}", ATTR{bConfigurationValue}="$env{REALTEK_MODE2}"

# Samsung
ATTR{idVendor}=="04e8", ATTR{idProduct}=="a101", ATTR{bConfigurationValue}!="$env{REALTEK_MODE1}", ATTR{bConfigurationValue}="$env{REALTEK_MODE1}"

# Lenovo
ATTR{idVendor}=="17ef", ATTR{idProduct}=="304f", ATTR{bConfigurationValue}!="$env{REALTEK_MODE1}", ATTR{bConfigurationValue}="$env{REALTEK_MODE1}"
ATTR{idVendor}=="17ef", ATTR{idProduct}=="3052", ATTR{bConfigurationValue}!="$env{REALTEK_MODE1}", ATTR{bConfigurationValue}="$env{REALTEK_MODE1}"
ATTR{idVendor}=="17ef", ATTR{idProduct}=="3054", ATTR{bConfigurationValue}!="$env{REALTEK_MODE1}", ATTR{bConfigurationValue}="$env{REALTEK_MODE1}"
ATTR{idVendor}=="17ef", ATTR{idProduct}=="3057", ATTR{bConfigurationValue}!="$env{REALTEK_MODE1}", ATTR{bConfigurationValue}="$env{REALTEK_MODE1}"
ATTR{idVendor}=="17ef", ATTR{idProduct}=="3062", ATTR{bConfigurationValue}!="$env{REALTEK_MODE1}", ATTR{bConfigurationValue}="$env{REALTEK_MODE1}"
ATTR{idVendor}=="17ef", ATTR{idProduct}=="3069", ATTR{bConfigurationValue}!="$env{REALTEK_MODE1}", ATTR{bConfigurationValue}="$env{REALTEK_MODE1}"
ATTR{idVendor}=="17ef", ATTR{idProduct}=="3082", ATTR{bConfigurationValue}!="$env{REALTEK_MODE1}", ATTR{bConfigurationValue}="$env{REALTEK_MODE1}"
ATTR{idVendor}=="17ef", ATTR{idProduct}=="3098", ATTR{bConfigurationValue}!="$env{REALTEK_MODE1}", ATTR{bConfigurationValue}="$env{REALTEK_MODE1}"
ATTR{idVendor}=="17ef", ATTR{idProduct}=="7205", ATTR{bConfigurationValue}!="$env{REALTEK_MODE1}", ATTR{bConfigurationValue}="$env{REALTEK_MODE1}"
ATTR{idVendor}=="17ef", ATTR{idProduct}=="720a", ATTR{bConfigurationValue}!="$env{REALTEK_MODE1}", ATTR{bConfigurationValue}="$env{REALTEK_MODE1}"
ATTR{idVendor}=="17ef", ATTR{idProduct}=="720b", ATTR{bConfigurationValue}!="$env{REALTEK_MODE1}", ATTR{bConfigurationValue}="$env{REALTEK_MODE1}"
ATTR{idVendor}=="17ef", ATTR{idProduct}=="720c", ATTR{bConfigurationValue}!="$env{REALTEK_MODE1}", ATTR{bConfigurationValue}="$env{REALTEK_MODE1}"
ATTR{idVendor}=="17ef", ATTR{idProduct}=="7214", ATTR{bConfigurationValue}!="$env{REALTEK_MODE1}", ATTR{bConfigurationValue}="$env{REALTEK_MODE1}"
ATTR{idVendor}=="17ef", ATTR{idProduct}=="721e", ATTR{bConfigurationValue}!="$env{REALTEK_MODE1}", ATTR{bConfigurationValue}="$env{REALTEK_MODE1}"
ATTR{idVendor}=="17ef", ATTR{idProduct}=="8153", ATTR{bConfigurationValue}!="$env{REALTEK_MODE1}", ATTR{bConfigurationValue}="$env{REALTEK_MODE1}"
ATTR{idVendor}=="17ef", ATTR{idProduct}=="a359", ATTR{bConfigurationValue}!="$env{REALTEK_MODE1}", ATTR{bConfigurationValue}="$env{REALTEK_MODE1}"
ATTR{idVendor}=="17ef", ATTR{idProduct}=="a387", ATTR{bConfigurationValue}!="$env{REALTEK_MODE1}", ATTR{bConfigurationValue}="$env{REALTEK_MODE1}"

# TP-LINK
ATTR{idVendor}=="2357", ATTR{idProduct}=="0601", ATTR{bConfigurationValue}!="$env{REALTEK_MODE1}", ATTR{bConfigurationValue}="$env{REALTEK_MODE1}"

# Nvidia
ATTR{idVendor}=="0955", ATTR{idProduct}=="09ff", ATTR{bConfigurationValue}!="$env{REALTEK_MODE1}", ATTR{bConfigurationValue}="$env{REALTEK_MODE1}"

# LINKSYS
ATTR{idVendor}=="13b1", ATTR{idProduct}=="0041", ATTR{bConfigurationValue}!="$env{REALTEK_MODE1}", ATTR{bConfigurationValue}="$env{REALTEK_MODE1}"

LABEL="usb_realtek_net_end"
The bConfigurationMode should be 1 to work with the r8152 driver, so if yours for whatever reason has entered a different mode remember this, you can set it back by locating the bus, port in lsusb --tree and using this path in the sysfs dir, example: echo "1" | sudo tee /sys/bus/usb/devices/2-4/bConfigurationValue (here the bus is 002, the port is 004)

The difference between the latest in-kernel (6.14, 6.15) r8157 driver and the Realtek one is that the current kernel does not define 5Gbps only 2.5 https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/tree/drivers/net/usb/r8152.c#n1200

You will find 5000 defined in the realtek driver.

Once your realtek driver r8152 v2.19.2 is built, installed you can simply modprobe r8152, you can verify it is your version by comparing modinfo r8152 before and after installing it.

After that your ethtool query sudo ethtool enp15s0u4 should show:

Code:
$ sudo ethtool enp15s0u4
Settings for enp15s0u4:
        Supported ports: [ MII ]
        Supported link modes:   10baseT/Half 10baseT/Full
                                100baseT/Half 100baseT/Full
                                1000baseT/Full
                                2500baseT/Full
                                5000baseT/Full
        Supported pause frame use: No
        Supports auto-negotiation: Yes
        Supported FEC modes: Not reported
        Advertised link modes:  10baseT/Half 10baseT/Full
                                100baseT/Half 100baseT/Full
                                1000baseT/Full
                                2500baseT/Full
                                5000baseT/Full
        Advertised pause frame use: No
        Advertised auto-negotiation: Yes
        Advertised FEC modes: Not reported
        Link partner advertised link modes:  10baseT/Half 10baseT/Full
                                             100baseT/Half 100baseT/Full
                                             1000baseT/Full
                                             2500baseT/Full
                                             5000baseT/Full
        Link partner advertised pause frame use: No
        Link partner advertised auto-negotiation: Yes
        Link partner advertised FEC modes: Not reported
        Speed: 5000Mb/s
        Duplex: Full
        Auto-negotiation: on
        Port: MII
        PHYAD: 32
        Transceiver: internal
        Supports Wake-on: pumbg
        Wake-on: d
        Current message level: 0x00007fff (32767)
                               drv probe link timer ifdown ifup rx_err tx_err tx_queued intr tx_done rx_status pktdata hw wol
        Link detected: yes
I couldn't find anything about the Club3D CAC-2530 anywhere, but I figured it must work somehow.. Finally got it working by building their own driver.. It was very confusing that it was already in-kernel I thought it was the same version, but I couldn't see any commits around 2024-11 when Realtek last updated it on their page.

suspend/sleep NOTE: I found that the r8152 driver did not suspend properly, locks on resume if enabled. You can do a simple service to fix this.

INI:
# /etc/systemd/system/r8152-fix.service

[Unit]
Description=Disable r8152 before sleep
Before=sleep.target
StopWhenUnneeded=yes

[Service]
Type=oneshot
RemainAfterExit=yes

ExecStart=/usr/sbin/modprobe -r r8152
ExecStop=/usr/sbin/modprobe r8152

[Install]
WantedBy=sleep.target
Bash:
sudo systemctl daemon-reload
sudo systemctl enable r8152-fix
 
Last edited:

jerrythea

Member
Sep 12, 2022
41
17
8
Just as a very important caveat:

I got the above Linux drivers built and working on a Proxmox VE 8 cluster, and everything worked well, except for a huge issue:

If you host an NFS share on a system with one of the USB network adapters, the Linux kernel will get wedged, and eventually hang, and then crash.

I tested this for a few weeks, and confirmed it is the driver iteself, and not the Kernel.

The exact same configuration using 2.5 GBs USB realtek has been rock solid for multiple years.

I was also able to confirm that the more mature AQ drivers were equally rock solid for 10 GBs over Thunderbolt 3/4.

Until I see a mainline kernel with the following code in the source tree, I would not rely on these 5 GBs USB Realtek for use with Linux:
Code:
# grep -i rtl8157 r8152.[ch]
static int rtl8157_runtime_enable(struct r8152 *tp, bool enable)
static int rtl8157_enable(struct r8152 *tp)
static int rtl8157_change_mtu(struct r8152 *tp)
static int rtl8157_up(struct r8152 *tp)
        ret = rtl8157_change_mtu(tp);
static int rtl8157_down(struct r8152 *tp)
static void rtl8157_unload(struct r8152 *tp)
                ops->enable             = rtl8157_enable;
                ops->up                 = rtl8157_up;
                ops->down               = rtl8157_down;
                ops->unload             = rtl8157_unload;
                ops->autosuspend_en     = rtl8157_runtime_enable;
                ops->change_mtu         = rtl8157_change_mtu;
On Windows and macOS these USB dongles are pretty stable as well, but these are not server platforms designed to be running 24x7x365