Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Project: Add 8821/11au rtw88 in-kernel driver. Need testers... #133

Open
morrownr opened this issue Apr 30, 2024 · 197 comments
Open

Project: Add 8821/11au rtw88 in-kernel driver. Need testers... #133

morrownr opened this issue Apr 30, 2024 · 197 comments

Comments

@morrownr
Copy link
Owner

morrownr commented Apr 30, 2024

Greetings to anyone that reads this message.

This Issue is where we coordinate and take bug report for the new 8821a in-kernel driver.

An effort is underway to add support for the rtl8821/11au chipset to the rtw88 in-kernel driver series. The driver is available for testing at the following repo:

https://github.com/lwfinger/rtw88

Remember to first remove the out-of-kernel driver in this repo or whatever repo you may have installed. You can run the following to remove it if using this repo:

$ sudo sh remove-driver.sh

It is important to follow the instructions in the README at the repo with the new test driver. You may not be familiar with rtw88 in the kernel but even if you are, there are some necessary mods that you need to know about. The rtw88 that has this new driver is more advanced than the rtw88 in stable kernels as it follows wireless-next and is used to work on and develop new drivers.

We welcome you to test and report on this new driver. Your testing will help us get this new driver in the Linux kernel sooner and in better shape. We do have specific needs. The most immediate need is to find users that have adapters that have bluetooth support (rtl8821au chip). The current developers only have adapters that have rtl8811au chips so we need help. We also need testers with old laptps that have the rtl8821ae chip.

If you are aware of anyone who is familiar with mac80211 drivers, please invite them as more eyes on the code is a good thing. Your ideas are most welcome. We can do this.

@morrownr

Status report:

  • Managed mode (client) appears to be in really good shape. No outstanding issues.

  • Monitor mode appears to be in good shape but Active Monitor mode is not supported yet.

  • AP mode is in good shape but AP Mode DFS channels are not supported (this common on usb wifi adapters). This is an issue that needs to be investigated but should not slow down the upstreaming of this driver.

  • P2P mode is in good shape.

  • IBSS mode has not been tested yet. Please test and report.

Overall: the driver appears to be in good shape. Please test and report your results.

@lwfinger
Copy link

lwfinger commented May 5, 2024

I get a maximum of 130 Mbps transmit and 93 RX with iperf3. LibreSpeed gets 119 down and 113 up.

@lwfinger
Copy link

lwfinger commented May 6, 2024

The master branch now contains all of dubhater's changes for the RTW8821AU and RTW8812AU, and the driver works. I have not removed any of the other branches until the code is checked a bit more, but please test everything. The speeds are still on the low side, but that will come.

@morrownr
Copy link
Owner Author

morrownr commented May 6, 2024

@lwfinger

The master branch now contains all of dubhater's changes for the RTW8821AU and RTW8812AU, and the driver works.

Thanks. I'll start testing and adding additional vid/pids for rtw8812au.

@dubhater

As you ready for rtw8812au to be tested or just rtw8821au?

@morrownr
Copy link
Owner Author

morrownr commented May 6, 2024

Initital testing of rtw88 master:

$ iperf3 -c 192.168.1.1
Connecting to host 192.168.1.1, port 5201
[  5] local 192.168.1.172 port 57430 connected to 192.168.1.1 port 5201
[ ID] Interval           Transfer     Bitrate         Retr  Cwnd
[  5]   0.00-1.00   sec  28.6 MBytes   240 Mbits/sec    0    526 KBytes       
[  5]   1.00-2.00   sec  25.4 MBytes   213 Mbits/sec    0    526 KBytes       
[  5]   2.00-3.00   sec  25.5 MBytes   214 Mbits/sec    0    526 KBytes       
[  5]   3.00-4.00   sec  25.5 MBytes   214 Mbits/sec    0    551 KBytes       
[  5]   4.00-5.00   sec  25.7 MBytes   216 Mbits/sec    0    551 KBytes       
[  5]   5.00-6.00   sec  25.7 MBytes   216 Mbits/sec    0    551 KBytes       
[  5]   6.00-7.00   sec  26.5 MBytes   222 Mbits/sec    0    577 KBytes       
[  5]   7.00-8.00   sec  24.2 MBytes   203 Mbits/sec    0    577 KBytes       
[  5]   8.00-9.00   sec  25.5 MBytes   214 Mbits/sec    0    577 KBytes       
[  5]   9.00-10.00  sec  25.6 MBytes   215 Mbits/sec    0    577 KBytes       
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval           Transfer     Bitrate         Retr
[  5]   0.00-10.00  sec   258 MBytes   217 Mbits/sec    0             sender
[  5]   0.00-10.01  sec   256 MBytes   214 Mbits/sec                  receiver

iperf Done.

I ran iperf3 several times with my primary testing setup. Speed looks really good. Around 220 Mbps is about as fast as this chip can go if the out-of-kernel results over the last few years are good. The test above is on a DFS channel where there is no congestion. dmesg is clean. I'm impressed so far.

Monitor mode frame injection test:

$ sudo aireplay-ng --test wlx00c0caac47c7
[sudo] password for morrow:         
13:40:39  Trying broadcast probe requests...
13:40:39  Injection is working!
13:40:41  Found 12 APs

13:40:41  Trying directed probe requests...
13:40:41  C6:BE:59:93:4F:3B - channel: 44 - ''
13:40:43  Ping (min/avg/max): 2.473ms/9.155ms/17.771ms Power: -81.38
13:40:43  21/30:  70%

13:40:43  10:33:BF:60:FA:3B - channel: 44 - 'CoxWiFi'
13:40:43  Ping (min/avg/max): 1.548ms/5.636ms/8.924ms Power: -39.00
13:40:43  29/30:  96%

13:40:43  08:A7:C0:14:81:DA - channel: 44 - 'Wade Wifi'
13:40:47  Ping (min/avg/max): 10.801ms/17.700ms/27.914ms Power: -76.69
13:40:47  13/30:  43%

13:40:47  08:A7:C0:14:81:DF - channel: 44 - ''
13:40:51  Ping (min/avg/max): 14.111ms/22.023ms/39.249ms Power: -76.83
13:40:51  12/30:  40%

13:40:51  CC:BE:59:93:4F:3B - channel: 44 - 'SKHutch5'
13:40:52  Ping (min/avg/max): 2.017ms/6.207ms/20.025ms Power: -80.83
13:40:52  24/30:  80%

13:40:52  08:A7:C0:14:81:DD - channel: 44 - ''
13:40:57  Ping (min/avg/max): 10.314ms/21.516ms/31.877ms Power: -77.00
13:40:57  10/30:  33%

13:40:57  C2:BE:59:93:4F:3B - channel: 44 - ''
13:40:59  Ping (min/avg/max): 7.544ms/18.691ms/34.159ms Power: -79.70
13:40:59  20/30:  66%

13:40:59  10:33:BF:60:FA:3A - channel: 44 - ''
13:41:00  Ping (min/avg/max): 3.128ms/9.390ms/16.078ms Power: -38.93
13:41:00  28/30:  93%

13:41:00  10:33:BF:60:FA:3E - channel: 44 - ''
13:41:00  Ping (min/avg/max): 1.213ms/8.218ms/20.971ms Power: -38.80
13:41:00  30/30: 100%

13:41:00  08:A7:C0:14:81:DC - channel: 44 - 'CoxWiFi'
13:41:04  Ping (min/avg/max): 6.712ms/18.391ms/26.479ms Power: -77.00
13:41:04   9/30:  30%

13:41:04  08:A7:C0:14:81:DB - channel: 44 - ''
13:41:09  Ping (min/avg/max): 12.830ms/20.560ms/26.364ms Power: -77.00
13:41:09   9/30:  30%

13:41:09  10:33:BF:60:FA:3C - channel: 44 - ''
13:41:09  Ping (min/avg/max): 2.109ms/8.086ms/23.178ms Power: -38.93
13:41:09  28/30:  93%

Going in and out of monitor mode works well and things look like they should. The injection test above showed very good results. So far monitor mode looks good.

I will do more detailed test on managed and monitor mode as able this week and I plan to test AP mode and
P2P-client. So far, this driver looks good.

I plan to rework the first message in this thread to provide instructions to those who can test/report as most will not be used to the instructions for getting this driver going,

I am still looking for someone with a rtl8821au based adapter and someone with an old laptop with a rtl8821ce chip in it so we can test bluetooth.

@morrownr

Repository owner deleted a comment from dubhater May 6, 2024
Repository owner deleted a comment from dubhater May 6, 2024
Repository owner deleted a comment from dubhater May 6, 2024
Repository owner deleted a comment from lwfinger May 6, 2024
Repository owner deleted a comment from dubhater May 6, 2024
Repository owner deleted a comment from lwfinger May 6, 2024
Repository owner deleted a comment from dubhater May 6, 2024
Repository owner deleted a comment from lwfinger May 6, 2024
Repository owner deleted a comment from lwfinger May 6, 2024
@dubhater
Copy link

dubhater commented May 6, 2024

@morrownr rtw_8812au is not ready yet.

I can see some RTL8821AE on Aliexpress, both M.2 and mini PCIe.

Repository owner deleted a comment from dubhater May 6, 2024
@morrownr
Copy link
Owner Author

morrownr commented May 6, 2024

@dubhater

I can see some RTL8821AE on Aliexpress, both M.2 and mini PCIe.

Give me a chance to round up some testers that already have the chips. We can always go get one if we have to do so. This repo gets over 100 hits per day so there are a lot of users of this chip. I just need to work on getting them in here now that we have something for them to test. I'll work it.

I'm impressed with this driver so far. We'll find problems but so far it is working well. My opinion after a few years of supporting out-of-kernel drivers for both the rtl8821au and rtl8821cu is that the au is simply a more reliable chip that causes users far fewer problems.

@morrownr

@gmsanchez
Copy link

@morrownr

I have a TP-Link Archer T2U PLUS [RTL8821AU]. I removed this kernel module using $ sudo sh remove-driver.sh and installed rtw88 using the provided readme on Kubuntu 24.04

So far everything is working good. I am willing to help, but I don't have a lot of experience in this field. Are there any instructions to run the required tests? Just let me know.

@morrownr
Copy link
Owner Author

morrownr commented May 8, 2024

Hi @gmsanchez

Thanks for testing.

Are there any instructions to run the required tests?

Do you have any experience using any modes in addition to managed (client) mode?

Please document your distro and version here and post the results of the following:

$ uname -r
$ gcc --version

Do you know of a way to test your speed? If so, do it.

Post the results of:

$ sudo dmesg | grep rtw

Since you have an adapter with the version of the chip that has bluetooth support, can you verify that bluetooth is working correctly?

Post the results of:

$ lsusb

If your adapter has an LED, does it blink?

Lastly, just use it. See if anything goes wrong over the next few days. Keep us posted.

You may also get questions from @dubhater and @lwfinger .

@morrownr

@gmsanchez
Copy link

gmsanchez commented May 8, 2024

Do you know of a way to test your speed? If so, do it.

I don't know how to test my speed.

Since you have an adapter with the version of the chip that has bluetooth support, can you verify that bluetooth is working correctly?

I don't have any bluetooth device on my system.

If your adapter has an LED, does it blink?

I'll move the adapter to the front and check the LED status.

In the meantime, the requested output of the commands is below:

$ uname -r
6.8.0-31-generic
$ gcc --version
gcc (Ubuntu 13.2.0-23ubuntu4) 13.2.0
Copyright (C) 2023 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
$ sudo dmesg | grep rtw
[    3.848959] rtw_core: loading out-of-tree module taints kernel.
[    3.848966] rtw_core: module verification failed: signature and/or required key missing - tainting kernel
[    3.874055] rtw_8821au 3-1:1.0: Firmware version 42.4.0, H2C version 0
[    3.915832] usbcore: registered new interface driver rtw_8821au
[    3.919055] rtw_8821au 3-1:1.0 wlx6c5ab0d0395d: renamed from wlan0
[    6.110598] rtw_8821au 3-1:1.0: MAC has not been powered on yet
$ lsusb
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub
Bus 001 Device 003: ID 05e3:0606 Genesys Logic, Inc. USB 2.0 Hub / D-Link DUB-H4 USB 2.0 Hub
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub
Bus 002 Device 003: ID 046d:c31c Logitech, Inc. Keyboard K120
Bus 002 Device 004: ID 046d:c077 Logitech, Inc. Mouse
Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 003 Device 002: ID 2357:0120 TP-Link Archer T2U PLUS [RTL8821AU]
Bus 003 Device 003: ID 046d:08e4 Logitech, Inc. C505e HD Webcam
Bus 004 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub

@morrownr
Copy link
Owner Author

morrownr commented May 8, 2024

@dubhater

rtw88 master - rtw_8821au

I am seeing the below during compilation. This is with Debian 12 and kernels 6.1 LTS and 6.6 LTS plus gcc 12.2. This not fatal but...

  CC [M]  /home/morrow/src/rtw88/rtw8821a.o
  CC [M]  /home/morrow/src/rtw88/rtw8821a_table.o
In file included from /usr/src/linux-headers-6.1.0-21-common/include/linux/kernel.h:26,
                 from /usr/src/linux-headers-6.1.0-21-common/arch/x86/include/asm/percpu.h:27,
                 from /usr/src/linux-headers-6.1.0-21-common/arch/x86/include/asm/current.h:6,
                 from /usr/src/linux-headers-6.1.0-21-common/include/linux/sched.h:12,
                 from /usr/src/linux-headers-6.1.0-21-common/include/linux/delay.h:23,
                 from /usr/src/linux-headers-6.1.0-21-common/include/linux/usb.h:15,
                 from /home/morrow/src/rtw88/rtw8821a.c:5:
/home/morrow/src/rtw88/rtw8821a.c: In function ‘rtw8821a_tx_power_training’:
/usr/src/linux-headers-6.1.0-21-common/include/linux/minmax.h:20:35: warning: comparison of distinct pointer types lacks a cast
   20 |         (!!(sizeof((typeof(x) *)1 == (typeof(y) *)1)))
      |                                   ^~
/usr/src/linux-headers-6.1.0-21-common/include/linux/minmax.h:26:18: note: in expansion of macro ‘__typecheck’
   26 |                 (__typecheck(x, y) && __no_side_effects(x, y))
      |                  ^~~~~~~~~~~
/usr/src/linux-headers-6.1.0-21-common/include/linux/minmax.h:36:31: note: in expansion of macro ‘__safe_cmp’
   36 |         __builtin_choose_expr(__safe_cmp(x, y), \
      |                               ^~~~~~~~~~
/usr/src/linux-headers-6.1.0-21-common/include/linux/minmax.h:52:25: note: in expansion of macro ‘__careful_cmp’
   52 | #define max(x, y)       __careful_cmp(x, y, >)
      |                         ^~~~~~~~~~~~~
/home/morrow/src/rtw88/rtw8821a.c:2481:31: note: in expansion of macro ‘max’
 2481 |                 write_data |= max(power_level, 2) << (i * 8);
      |                               ^~~

@lwfinger
Copy link

lwfinger commented May 8, 2024

The problem is that the code used max(a,b), whereas it should have been max_t(u32,a,b). It now compiles cleanly on openSUSE Tumbleweed and Debian 12.

@morrownr
Copy link
Owner Author

morrownr commented May 9, 2024

@gmsanchez

I don't know how to test my speed.

You can give the following site a try for basic speed testing:

https://testmy.net/

Most of us use iperf3 on our local lans for speed testing. Do you have a RasPi on your local lan or a wifi router that runs OpenWRT?

I don't have any bluetooth device on my system.

It looked like you might have a version of the chipset that includes bluetooth support so I was looking to see if the bluetooth in your adapter was working. Maybe you have a chip that is wifi only.

[ 6.110598] rtw_8821au 3-1:1.0: MAC has not been powered on yet

Let me think out loud here for a moment. I am trying to sort out why the above line is needed. What is it doing for us?

Thanks for the info and we'll be waiting for additional reports.

@morrownr

@morrownr
Copy link
Owner Author

morrownr commented May 9, 2024

@lwfinger

The problem is that the code used max(a,b), whereas it should have been max_t(u32,a,b). It now compiles cleanly on openSUSE Tumbleweed and Debian 12.

Awesome! Clean compile here.

FYI: I'll be moving to AP mode testing soon. So far, managed and monitor modes look really good but my AP mode testing will take me to another distro and ARM64.

@morrownr
Copy link
Owner Author

morrownr commented May 9, 2024

@dubhater @lwfinger

Here is a very minor nitpick:

Screenshot from 2024-05-09 14-58-12

When I run iperf3, I am seeing drop (in the statistics box) increase regularly. With other wireless devices I am more used to it not increasing or occasionally incrementing but not as regularly as I am seeing here. Do we have a buffer set slightly smaller than it needs to be?

Like I said, nitpick. I am having a difficult time finding any problems with managed and monitor modes.

I am off to test AP mode.

@morrownr

@lwfinger
Copy link

Do you see any WARNINGS in your logs like this "WARNING: CPU: 3 PID: 36 at net/mac80211/rx.c"? Your CPU and PID will be different. That may be the source of your drops.

I have a patch to silence the WARNINGS, but the drops are not fixed as the packets are malformed.

What is the utility that produced the screenshot? I am not familiar with anything like it.

@5kft
Copy link
Contributor

5kft commented May 10, 2024

@morrownr I'm using a Debian-based custom arm64/armhf distribution, and as such I can't build the rtw88 driver via @lwfinger's process (I didn't bother to try to address this further). Instead, I simply removed the original mainline (6.9-rc7) rtw88 driver source and replaced it completely with @lwfinger's version from his github.

Now, when building this new version of rtw88 I am getting errors relating to the PCI driver module support or something (see errors below). My kernel configuration does not enable CONFIG_PCI, just in case this might be related. I haven't debugged the new in-kernel rtw88 build process any further. I'm pointing this out just in case there is an oversight in this new rtw88 code for non-CONFIG_PCI and/or ARM builds (or something).

As a comparison, the mainline 6.9-rc7 rtw88 driver builds completely fine - without any errors - so there does appear to be a regression in this new version of the driver source.

In my kernel config I am only enabling the the 8821CU module, so it is kind of odd that the build is erroring out for driver sources that aren't even enabled:

CONFIG_RTW88=m
CONFIG_RTW88_CORE=m
CONFIG_RTW88_USB=m
CONFIG_RTW88_8821C=m
# CONFIG_RTW88_8822BS is not set
# CONFIG_RTW88_8822BU is not set
# CONFIG_RTW88_8822CS is not set
# CONFIG_RTW88_8822CU is not set
# CONFIG_RTW88_8723DS is not set
# CONFIG_RTW88_8723DU is not set
# CONFIG_RTW88_8821CS is not set
CONFIG_RTW88_8821CU=m
# CONFIG_RTW88_DEBUG is not set
# CONFIG_RTW88_DEBUGFS is not set

Build errors:

drivers/net/wireless/realtek/rtw88/rtw8822be.c:27:1: warning: data definition has no type or storage class
   27 | module_pci_driver(rtw_8822be_driver);
      | ^~~~~~~~~~~~~~~~~
drivers/net/wireless/realtek/rtw88/rtw8822be.c:27:1: error: type defaults to ‘int’ in declaration of ‘module_pci_driver’ [-Werror=implicit-int]
drivers/net/wireless/realtek/rtw88/rtw8822be.c:27:1: warning: parameter names (without types) in function declaration
drivers/net/wireless/realtek/rtw88/rtw8822be.c:19:26: warning: ‘rtw_8822be_driver’ defined but not used [-Wunused-variable]
   19 | static struct pci_driver rtw_8822be_driver = {
      |                          ^~~~~~~~~~~~~~~~~
cc1: some warnings being treated as errors
make[7]: *** [scripts/Makefile.build:244: drivers/net/wireless/realtek/rtw88/rtw8822be.o] Error 1
make[7]: *** Waiting for unfinished jobs....
drivers/net/wireless/realtek/rtw88/rtw8822ce.c:31:1: warning: data definition has no type or storage class
   31 | module_pci_driver(rtw_8822ce_driver);
      | ^~~~~~~~~~~~~~~~~
drivers/net/wireless/realtek/rtw88/rtw8822ce.c:31:1: error: type defaults to ‘int’ in declaration of ‘module_pci_driver’ [-Werror=implicit-int]
drivers/net/wireless/realtek/rtw88/rtw8822ce.c:31:1: warning: parameter names (without types) in function declaration
drivers/net/wireless/realtek/rtw88/rtw8822ce.c:23:26: warning: ‘rtw_8822ce_driver’ defined but not used [-Wunused-variable]
   23 | static struct pci_driver rtw_8822ce_driver = {
      |                          ^~~~~~~~~~~~~~~~~
cc1: some warnings being treated as errors
make[7]: *** [scripts/Makefile.build:244: drivers/net/wireless/realtek/rtw88/rtw8822ce.o] Error 1
make[6]: *** [scripts/Makefile.build:485: drivers/net/wireless/realtek/rtw88] Error 2
make[5]: *** [scripts/Makefile.build:485: drivers/net/wireless/realtek] Error 2
make[4]: *** [scripts/Makefile.build:485: drivers/net/wireless] Error 2
make[3]: *** [scripts/Makefile.build:485: drivers/net] Error 2
make[2]: *** [scripts/Makefile.build:485: drivers] Error 2

@morrownr
Copy link
Owner Author

To: @kimocoder and others

Are you offering to donate a device? I'm missing RTL8812BU/RTL8822BU.

Let me add something to @dubhater 's request: He can also make good use of adapters with mt7921au, mt7612u, mt7610u and mt7601u chips. Alfa makes the AXM, ACM and ACHM which would cover the mt7921au, mt7612u and mt7610u respectively. Certainly any donated adapters do not have to be Alfa but Alfa does make good adapters. I was planning to donate funds or adapters with the listed chips to @dubhater once some of the current work has gone upstream and things have settled down. If I ship, it is a long way from my place to @dubhater 's place we live a half a world apart so if anyone in Europe has adapters with the 6 listed chips and you are willing to donate them to @dubhater , it would be a very good thing.

@dubhater

I've had a 88x2bu repo up for several years. Almost all product that has shipped with those chips has been the rtl8812bu chip. The adapters with the 8822bu are limited to USB2 as noted on Realtek's website. I'm sure it has to do with the bluetooth/USB3 interference issue as noted by an Intel White Paper from about 12 years ago. Who would want a 8822bu when the 8812bu is a LOT faster?

@dubhater
Copy link

@5kft It's possible I copied the wrong thing from the official driver. Does it look more normal with this?

diff --git a/drivers/net/wireless/realtek/rtw88/rtw8821a.c b/drivers/net/wireless/realtek/rtw88/rtw8821a.c
index e2cb323f4fd2..2d738c3f8c75 100644
--- a/drivers/net/wireless/realtek/rtw88/rtw8821a.c
+++ b/drivers/net/wireless/realtek/rtw88/rtw8821a.c
@@ -1683,7 +1683,7 @@ static void rtw8821a_query_phy_status(struct rtw_dev *rtwdev, u8 *phy_status,
 		}
 	} else { /* OFDM rate */
 		for (i = RF_PATH_A; i < rtwdev->hal.rf_path_num; i++) {
-			val = phy_sts->gain_trsw[i];
+			val = phy_sts->pwdb_all >> 1;
 			pkt_stat->rx_power[i] = (val & 0x7F) - 110;
 			rssi = rtw_phy_rf_power_2_rssi(&pkt_stat->rx_power[i], 1);
 			dm_info->rssi[i] = rssi;

@5kft
Copy link
Contributor

5kft commented Jul 27, 2024

Thanks @dubhater, unfortunately however, that change has no impact, it still reports 0 dBm:

Connected to xx:xx:xx:xx:xx:xx (on wlan0)
        SSID: xxxxxx
        freq: 5640
        RX: 248460 bytes (1280 packets)
        TX: 55545 bytes (220 packets)
        signal: 0 dBm
        rx bitrate: 390.0 MBit/s VHT-MCS 9 80MHz VHT-NSS 1
        tx bitrate: 433.3 MBit/s VHT-MCS 9 80MHz short GI VHT-NSS 1

        bss flags:      short-slot-time
        dtim period:    2
        beacon int:     100

I just rebuilt and re-tested using @morrownr's 8821au driver, and it consistently shows -36/-37 dBm:

iw wlan0 link output w/@morrownr 8821au driver:

Connected to xx:xx:xx:xx:xx:xx (on wlan0)
        SSID: xxxxxx
        freq: 5640
        signal: -37 dBm
        tx bitrate: 434.0 MBit/s

iwconfig output w/@morrownr's driver (yes, everyone else, I know it's deprecated, yada, yada):

wlan0     IEEE 802.11  ESSID:"xxxxxx"
          Mode:Managed  Frequency:5.64 GHz  Access Point: xx:xx:xx:xx:xx:xx
          Bit Rate=434 Mb/s   Tx-Power=13 dBm
          Retry short limit:7   RTS thr:off   Fragment thr:off
          Power Management:on
          Link Quality=70/70  Signal level=-37 dBm
          Rx invalid nwid:0  Rx invalid crypt:0  Rx invalid frag:0
          Tx excessive retries:0  Invalid misc:0   Missed beacon:0

(FWIW, I don't recall ever seeing 0 dBm reported from the @morrownr driver)

@dubhater
Copy link

In that case, the hardware really is seeing 0 dbm. Both drivers adjust the RX gain every two seconds in order to minimise RX errors, but they don't calculate it exactly the same way, so they end up with slightly different values. I guess that's why the signal strength is different.

@dubhater
Copy link

dubhater commented Aug 9, 2024

@5kft Can you retest the speed with and without aggregation, please? Like you did with the RTL8811CU.

@5kft
Copy link
Contributor

5kft commented Aug 10, 2024

@5kft Can you retest the speed with and without aggregation, please? Like you did with the RTL8811CU.

Hi @dubhater , absolutely - here you go: Both tests run via iperf3 -w 512K -P 4 -i 10 -R:

Test with RX aggregation disabled (i.e., addition of the "return" statement at the beginning of rtw8821au_rx_aggregation; results are consistent over several runs):

[ ID] Interval           Transfer     Bitrate         Retr  Cwnd
[  5]   0.00-10.00  sec  2.26 MBytes  1.90 Mbits/sec
[  7]   0.00-10.00  sec  2.25 MBytes  1.88 Mbits/sec
[  9]   0.00-10.00  sec  2.30 MBytes  1.93 Mbits/sec
[ 11]   0.00-10.00  sec  29.5 MBytes  24.8 Mbits/sec
[SUM]   0.00-10.00  sec  36.3 MBytes  30.5 Mbits/sec

Default current top-of-tree code with RX aggregation enabled:

[ ID] Interval           Transfer     Bitrate         Retr  Cwnd
[  5]   0.00-10.00  sec  15.1 MBytes  12.7 Mbits/sec
[  7]   0.00-10.00  sec  15.3 MBytes  12.8 Mbits/sec
[  9]   0.00-10.00  sec  16.4 MBytes  13.7 Mbits/sec
[ 11]   0.00-10.00  sec   221 MBytes   185 Mbits/sec
[SUM]   0.00-10.00  sec   268 MBytes   224 Mbits/sec

@5kft
Copy link
Contributor

5kft commented Aug 10, 2024

@dubhater Just a side note, with this adapter the reported signal strength is still behaving oddly for this driver. In running the requested tests above, I ran a few iw wlan0 link commands in quick succession (i.e., perhaps each a second apart), and the reported signal strength value jumped from 0 dBm to -54 dBm back to 0 dBm... Just wanted to let you know.

root@test2:~# iw wlan0 link
Connected to xx:xx:xx:xx:xx:xx (on wlan0)
        SSID: xxxxxxx
        freq: 5500
        RX: 42593794 bytes (29721 packets)
        TX: 1242425 bytes (12782 packets)
        signal: 0 dBm
        rx bitrate: 351.0 MBit/s VHT-MCS 8 80MHz VHT-NSS 1
        tx bitrate: 433.3 MBit/s VHT-MCS 9 80MHz short GI VHT-NSS 1

        bss flags:      short-slot-time
        dtim period:    2
        beacon int:     100
root@test2:~# iw wlan0 link
Connected to xx:xx:xx:xx:xx:xx (on wlan0)
        SSID: xxxxxxx
        freq: 5500
        RX: 42608930 bytes (29797 packets)
        TX: 1243685 bytes (12788 packets)
        signal: -54 dBm
        rx bitrate: 351.0 MBit/s VHT-MCS 8 80MHz VHT-NSS 1
        tx bitrate: 433.3 MBit/s VHT-MCS 9 80MHz short GI VHT-NSS 1

        bss flags:      short-slot-time
        dtim period:    2
        beacon int:     100
root@test2:~# iw wlan0 link
Connected to xx:xx:xx:xx:xx:xx (on wlan0)
        SSID: xxxxxxx
        freq: 5500
        RX: 42617211 bytes (29838 packets)
        TX: 1245075 bytes (12795 packets)
        signal: 0 dBm
        rx bitrate: 351.0 MBit/s VHT-MCS 8 80MHz VHT-NSS 1
        tx bitrate: 433.3 MBit/s VHT-MCS 9 80MHz short GI VHT-NSS 1

        bss flags:      short-slot-time
        dtim period:    2
        beacon int:     100
root@test2:~#

Except for this interesting -54 dBm case, it almost always reports 0 dBm, however. For these tests, the AP is actually in another room, through two walls.

@dubhater
Copy link

Thank you for testing again.

That signal strength is weird. If you want, you can check what the hardware is reporting:

diff --git a/drivers/net/wireless/realtek/rtw88/rtw8821a.c b/drivers/net/wireless/realtek/rtw88/rtw8821a.c
index d1bb3c03c473..18fa7939372e 100644
--- a/drivers/net/wireless/realtek/rtw88/rtw8821a.c
+++ b/drivers/net/wireless/realtek/rtw88/rtw8821a.c
@@ -1629,6 +1629,7 @@ static void rtw8821a_query_phy_status(struct rtw_dev *rtwdev, u8 *phy_status,
 	} else { /* OFDM rate */
 		for (i = RF_PATH_A; i < rtwdev->hal.rf_path_num; i++) {
 			val = phy_sts->gain_trsw[i];
+			pr_err("gain_trsw[%d] = 0x%02x pwdb_all = 0x%02x\n", i, phy_sts->gain_trsw[i], phy_sts->pwdb_all);
 			pkt_stat->rx_power[i] = (val & 0x7F) - 110;
 			rssi = rtw_phy_rf_power_2_rssi(&pkt_stat->rx_power[i], 1);
 			dm_info->rssi[i] = rssi;

It will print one line for each received packet (two if you use RTL8812AU).

@5kft
Copy link
Contributor

5kft commented Aug 10, 2024

That signal strength is weird. If you want, you can check what the hardware is reporting:

Hi @dubhater, I captured a few seconds of reporting and hid it within a dropdown so as to not spam this issues thread:

Expand this to see a capture of what the hardware is reporting for the signal strength
[  620.042250] gain_trsw[0] = 0x38 pwdb_all = 0x6c
[  620.144746] gain_trsw[0] = 0x38 pwdb_all = 0x68
[  620.247625] gain_trsw[0] = 0x38 pwdb_all = 0x6a
[  620.349509] gain_trsw[0] = 0x38 pwdb_all = 0x6c
[  620.451875] gain_trsw[0] = 0x38 pwdb_all = 0x6e
[  620.554247] gain_trsw[0] = 0x38 pwdb_all = 0x6d
[  620.656628] gain_trsw[0] = 0x38 pwdb_all = 0x6d
[  620.759134] gain_trsw[0] = 0x38 pwdb_all = 0x6d
[  620.861500] gain_trsw[0] = 0x38 pwdb_all = 0x70
[  620.962368] gain_trsw[0] = 0x38 pwdb_all = 0x6a
[  620.963972] gain_trsw[0] = 0x38 pwdb_all = 0x70
[  621.066261] gain_trsw[0] = 0x38 pwdb_all = 0x6f
[  621.168777] gain_trsw[0] = 0x38 pwdb_all = 0x6c
[  621.271113] gain_trsw[0] = 0x38 pwdb_all = 0x6d
[  621.373537] gain_trsw[0] = 0x38 pwdb_all = 0x6f
[  621.465611] gain_trsw[0] = 0x38 pwdb_all = 0x6d
[  621.475858] gain_trsw[0] = 0x38 pwdb_all = 0x6a
[  621.578895] gain_trsw[0] = 0x38 pwdb_all = 0x6f
[  621.680762] gain_trsw[0] = 0x38 pwdb_all = 0x6c
[  621.783126] gain_trsw[0] = 0x38 pwdb_all = 0x6f
[  621.885485] gain_trsw[0] = 0x38 pwdb_all = 0x70
[  621.987941] gain_trsw[0] = 0x38 pwdb_all = 0x70
[  622.090356] gain_trsw[0] = 0x38 pwdb_all = 0x6d
[  622.191268] gain_trsw[0] = 0x38 pwdb_all = 0x6c
[  622.192747] gain_trsw[0] = 0x38 pwdb_all = 0x6e
[  622.295107] gain_trsw[0] = 0x38 pwdb_all = 0x6c
[  622.397514] gain_trsw[0] = 0x38 pwdb_all = 0x6e
[  622.500007] gain_trsw[0] = 0x38 pwdb_all = 0x6e
[  622.602372] gain_trsw[0] = 0x38 pwdb_all = 0x6a
[  622.705128] gain_trsw[0] = 0x38 pwdb_all = 0x70
[  622.807261] gain_trsw[0] = 0x38 pwdb_all = 0x6c
[  622.909502] gain_trsw[0] = 0x38 pwdb_all = 0x6d
[  623.012096] gain_trsw[0] = 0x38 pwdb_all = 0x6c
[  623.114502] gain_trsw[0] = 0x38 pwdb_all = 0x6b
[  623.216872] gain_trsw[0] = 0x38 pwdb_all = 0x70
[  623.319123] gain_trsw[0] = 0x38 pwdb_all = 0x6b
[  623.421638] gain_trsw[0] = 0x38 pwdb_all = 0x6b
[  623.524627] gain_trsw[0] = 0x38 pwdb_all = 0x70
[  623.545608] gain_trsw[0] = 0x38 pwdb_all = 0x6d
[  623.626492] gain_trsw[0] = 0x38 pwdb_all = 0x6f
[  623.728880] gain_trsw[0] = 0x38 pwdb_all = 0x6e
[  623.831122] gain_trsw[0] = 0x38 pwdb_all = 0x6d
[  623.906982] gain_trsw[0] = 0x40 pwdb_all = 0x83
[  623.910987] gain_trsw[0] = 0x40 pwdb_all = 0x83
[  623.913876] gain_trsw[0] = 0x40 pwdb_all = 0x83
[  623.917012] gain_trsw[0] = 0x40 pwdb_all = 0x83
[  623.920601] gain_trsw[0] = 0x40 pwdb_all = 0x83
[  623.927362] gain_trsw[0] = 0x40 pwdb_all = 0x83
[  623.931013] gain_trsw[0] = 0x40 pwdb_all = 0x83
[  623.934001] gain_trsw[0] = 0x38 pwdb_all = 0x6d
[  623.934387] gain_trsw[0] = 0x40 pwdb_all = 0x83
[  623.940456] gain_trsw[0] = 0x40 pwdb_all = 0x83
[  623.943955] gain_trsw[0] = 0x40 pwdb_all = 0x83
[  623.947623] gain_trsw[0] = 0x40 pwdb_all = 0x83
[  623.950544] gain_trsw[0] = 0x40 pwdb_all = 0x83
[  623.954438] gain_trsw[0] = 0x40 pwdb_all = 0x83
[  623.957357] gain_trsw[0] = 0x40 pwdb_all = 0x83
[  624.036002] gain_trsw[0] = 0x38 pwdb_all = 0x70
[  624.138475] gain_trsw[0] = 0x38 pwdb_all = 0x6e
[  624.240829] gain_trsw[0] = 0x38 pwdb_all = 0x6c
[  624.343834] gain_trsw[0] = 0x38 pwdb_all = 0x6f
[  624.445576] gain_trsw[0] = 0x38 pwdb_all = 0x6d
[  624.548087] gain_trsw[0] = 0x38 pwdb_all = 0x70
[  624.648949] gain_trsw[0] = 0x38 pwdb_all = 0x6b
[  624.650445] gain_trsw[0] = 0x38 pwdb_all = 0x6d
[  624.752837] gain_trsw[0] = 0x38 pwdb_all = 0x6e
[  624.855199] gain_trsw[0] = 0x38 pwdb_all = 0x6d
[  624.957584] gain_trsw[0] = 0x38 pwdb_all = 0x6a
[  625.060075] gain_trsw[0] = 0x38 pwdb_all = 0x6b
[  625.162460] gain_trsw[0] = 0x38 pwdb_all = 0x6b
[  625.264823] gain_trsw[0] = 0x38 pwdb_all = 0x6b
[  625.367211] gain_trsw[0] = 0x38 pwdb_all = 0x6a
[  625.469701] gain_trsw[0] = 0x38 pwdb_all = 0x6b
[  625.572087] gain_trsw[0] = 0x38 pwdb_all = 0x6b
[  625.625699] gain_trsw[0] = 0x38 pwdb_all = 0x6d
[  625.674447] gain_trsw[0] = 0x38 pwdb_all = 0x6e
[  625.776960] gain_trsw[0] = 0x38 pwdb_all = 0x70
[  625.879324] gain_trsw[0] = 0x38 pwdb_all = 0x6c
[  625.981702] gain_trsw[0] = 0x38 pwdb_all = 0x6e
[  626.084084] gain_trsw[0] = 0x38 pwdb_all = 0x6f
[  626.186483] gain_trsw[0] = 0x38 pwdb_all = 0x6e
[  626.288994] gain_trsw[0] = 0x38 pwdb_all = 0x6a
[  626.391354] gain_trsw[0] = 0x38 pwdb_all = 0x70
[  626.493768] gain_trsw[0] = 0x38 pwdb_all = 0x6f
[  626.596484] gain_trsw[0] = 0x38 pwdb_all = 0x6d
[  626.668624] gain_trsw[0] = 0x38 pwdb_all = 0x67
[  626.698654] gain_trsw[0] = 0x38 pwdb_all = 0x6f
[  626.775354] gain_trsw[0] = 0x38 pwdb_all = 0x6f
[  626.800981] gain_trsw[0] = 0x38 pwdb_all = 0x6e
[  626.903377] gain_trsw[0] = 0x38 pwdb_all = 0x6a
[  626.985364] gain_trsw[0] = 0x38 pwdb_all = 0x6a
[  627.005733] gain_trsw[0] = 0x38 pwdb_all = 0x6d
[  627.047106] gain_trsw[0] = 0x40 pwdb_all = 0x83
[  627.049984] gain_trsw[0] = 0x40 pwdb_all = 0x83
[  627.054854] gain_trsw[0] = 0x40 pwdb_all = 0x83
[  627.060864] gain_trsw[0] = 0x40 pwdb_all = 0x83
[  627.064101] gain_trsw[0] = 0x40 pwdb_all = 0x83
[  627.069109] gain_trsw[0] = 0x40 pwdb_all = 0x83
[  627.073351] gain_trsw[0] = 0x40 pwdb_all = 0x83
[  627.076758] gain_trsw[0] = 0x40 pwdb_all = 0x83
[  627.079858] gain_trsw[0] = 0x40 pwdb_all = 0x83
[  627.082364] gain_trsw[0] = 0x40 pwdb_all = 0x83
[  627.087982] gain_trsw[0] = 0x40 pwdb_all = 0x83
[  627.091229] gain_trsw[0] = 0x40 pwdb_all = 0x83
[  627.094979] gain_trsw[0] = 0x40 pwdb_all = 0x83
[  627.098981] gain_trsw[0] = 0x40 pwdb_all = 0x83
[  627.102227] gain_trsw[0] = 0x40 pwdb_all = 0x83
[  627.107587] gain_trsw[0] = 0x40 pwdb_all = 0x83
[  627.108724] gain_trsw[0] = 0x38 pwdb_all = 0x6b

pwdb_all seems to bounce between the upper 0x60s and 0x70, and peaks sometimes at 0x83 (?). gain_trsw stays between 0x38 and 0x40.

@dubhater
Copy link

That looks normal. 0x38 should result in -54, and 0x40 in -46. Can you follow the code and find out where it goes wrong? The "destination" is rx_status->signal (maybe also rx_status->chain_signal) in rtw_rx_fill_rx_status() in rx.c.

@5kft
Copy link
Contributor

5kft commented Aug 10, 2024

I took a quick look and rtw_rx_fill_rx_status is not in "sync" with rtw8821a_query_phy_status - when pkt_stat->signal_power is set, then the fill is correct - but the fill will return a signal value of zero when the phy query isn't performed;

[   37.287992] rtw_rx_fill_rx_status: rx_status->signal=-54
[   37.288507] rtw8821a_query_phy_status: pkt_stat->signal_power=-54
[   37.288513] rtw_rx_fill_rx_status: rx_status->signal=-54
[   37.390806] rtw8821a_query_phy_status: pkt_stat->signal_power=-54
[   37.390835] rtw_rx_fill_rx_status: rx_status->signal=-54
[   37.493196] rtw8821a_query_phy_status: pkt_stat->signal_power=-54
[   37.493220] rtw_rx_fill_rx_status: rx_status->signal=-54
[   37.595676] rtw8821a_query_phy_status: pkt_stat->signal_power=-54
[   37.595710] rtw_rx_fill_rx_status: rx_status->signal=-54
[   37.698080] rtw8821a_query_phy_status: pkt_stat->signal_power=-54
[   37.698114] rtw_rx_fill_rx_status: rx_status->signal=-54
[   37.800470] rtw8821a_query_phy_status: pkt_stat->signal_power=-54
[   37.800507] rtw_rx_fill_rx_status: rx_status->signal=-54
[   37.902951] rtw8821a_query_phy_status: pkt_stat->signal_power=-54
[   37.902986] rtw_rx_fill_rx_status: rx_status->signal=-54
[   38.005265] rtw8821a_query_phy_status: pkt_stat->signal_power=-54
[   38.005296] rtw_rx_fill_rx_status: rx_status->signal=-54
[   38.037262] rtw_rx_fill_rx_status: rx_status->signal=0
[   38.041374] rtw_rx_fill_rx_status: rx_status->signal=0
[   38.050195] rtw_rx_fill_rx_status: rx_status->signal=0
[   38.107697] rtw8821a_query_phy_status: pkt_stat->signal_power=-54
[   38.107739] rtw_rx_fill_rx_status: rx_status->signal=-54
[   38.210124] rtw8821a_query_phy_status: pkt_stat->signal_power=-54
[   38.210157] rtw_rx_fill_rx_status: rx_status->signal=-54
[   38.284895] rtw_rx_fill_rx_status: rx_status->signal=0
[   38.312507] rtw8821a_query_phy_status: pkt_stat->signal_power=-54
[   38.312519] rtw_rx_fill_rx_status: rx_status->signal=-54
[   38.414755] rtw8821a_query_phy_status: pkt_stat->signal_power=-54
[   38.414767] rtw_rx_fill_rx_status: rx_status->signal=-54
[   38.516503] rtw_rx_fill_rx_status: rx_status->signal=0
[   38.517427] rtw8821a_query_phy_status: pkt_stat->signal_power=-54
[   38.517443] rtw_rx_fill_rx_status: rx_status->signal=-54
[   38.574145] rtw_rx_fill_rx_status: rx_status->signal=0
[   38.593261] rtw_rx_fill_rx_status: rx_status->signal=0
[   38.619754] rtw8821a_query_phy_status: pkt_stat->signal_power=-54
[   38.619772] rtw_rx_fill_rx_status: rx_status->signal=-54
[   38.629379] rtw_rx_fill_rx_status: rx_status->signal=0
[   38.651378] rtw_rx_fill_rx_status: rx_status->signal=0
[   38.722000] rtw8821a_query_phy_status: pkt_stat->signal_power=-54
[   38.722007] rtw_rx_fill_rx_status: rx_status->signal=-54
[   38.739496] rtw_rx_fill_rx_status: rx_status->signal=0
[   38.791004] rtw_rx_fill_rx_status: rx_status->signal=0
[   38.808123] rtw_rx_fill_rx_status: rx_status->signal=0
[   38.824505] rtw8821a_query_phy_status: pkt_stat->signal_power=-54
[   38.824518] rtw_rx_fill_rx_status: rx_status->signal=-54
[   38.852873] rtw_rx_fill_rx_status: rx_status->signal=0
[   38.885177] rtw_rx_fill_rx_status: rx_status->signal=0
[   38.926905] rtw8821a_query_phy_status: pkt_stat->signal_power=-54
[   38.926939] rtw_rx_fill_rx_status: rx_status->signal=-54
[   38.930138] rtw_rx_fill_rx_status: rx_status->signal=0
[   38.982125] rtw_rx_fill_rx_status: rx_status->signal=0
[   38.986417] rtw_rx_fill_rx_status: rx_status->signal=0
[   38.999629] rtw_rx_fill_rx_status: rx_status->signal=0
[   39.003895] rtw8821a_query_phy_status: pkt_stat->signal_power=-44
[   39.003917] rtw_rx_fill_rx_status: rx_status->signal=-44
[   39.007788] rtw8821a_query_phy_status: pkt_stat->signal_power=-44
[   39.007806] rtw_rx_fill_rx_status: rx_status->signal=-44
[   39.012690] rtw8821a_query_phy_status: pkt_stat->signal_power=-44
[   39.012714] rtw_rx_fill_rx_status: rx_status->signal=-44

@dubhater
Copy link

dubhater commented Aug 10, 2024

That explains it. Now to find out why some frames don't have the PHY status. This is controlled by BIT_APP_PHYSTS in REG_RCR. As far as I can tell it's never cleared.

Is it the same with rtw8811a_fw.bin?

diff --git a/drivers/net/wireless/realtek/rtw88/rtw8821a.c b/drivers/net/wireless/realtek/rtw88/rtw8821a.c
index f69e60a06719..41fd7d82cb67 100644
--- a/drivers/net/wireless/realtek/rtw88/rtw8821a.c
+++ b/drivers/net/wireless/realtek/rtw88/rtw8821a.c
@@ -3974,7 +3974,7 @@ static const struct rtw_reg_domain coex_info_hw_regs_8821a[] = {
 const struct rtw_chip_info rtw8821a_hw_spec = {
 	.ops = &rtw8821a_ops,
 	.id = RTW_CHIP_TYPE_8821A,
-	.fw_name = "rtw88/rtw8821a_fw.bin",
+	.fw_name = "rtw88/rtw8811a_fw.bin",
 	.wlan_cpu = RTW_WCPU_11N,
 	.tx_pkt_desc_sz = 40,
 	.tx_buf_desc_sz = 16,

@5kft
Copy link
Contributor

5kft commented Aug 10, 2024

Is it the same with rtw8811a_fw.bin?

I'd be happy to try this, but I can't find rtw8811a_fw.bin anywhere. It's not in lwfinger/rtw88/firmware/, nor in the latest Debian firmware-realtek_20240709-1_all.deb package, and Google returns zero results when searching for this file... (I'm running Debian Bookworm...) Hope I'm not missing something obvious here...

@dubhater
Copy link

I'm not sure what happened to it. You can still find it here: https://github.com/lwfinger/rtw88/blob/8821au_8812au/rtw8811a_fw.bin

@a5a5aa555oo
Copy link

@dubhater

I checked commit history in one year, it looks like rtw8811a_fw.bin is never in the master branch.
You said rtw8811a_fw.bin is needed by RTL8811AU, should I add it into master branch? or you will add by yourself?

@a5a5aa555oo
Copy link

Note that my adapter shows as this (via lsusb):

Bus 004 Device 002: ID 0bda:0811 Realtek Semiconductor Corp. Realtek 8812AU/8821AU 802.11ac WLAN Adapter [USB Wireless Dual-Band Adapter 2.4/5Ghz]

I think we should inform the author of hwdata to correct it, your adapter has a RTL8811AU chip actually.
https://github.com/vcrhonek/hwdata/blob/master/usb.ids#L14015

@5kft
Copy link
Contributor

5kft commented Aug 11, 2024

@dubhater The "zero signal strength" problem actually occurs when signal strength is queried while wireless traffic is taking place. The same problem happens with the rtw8811a_fw.bin firmware as well - there is no change in behavior between the two firmwares.

I found that if I connect to the board via serial console (i.e., not via ssh over Wi-Fi), and then run iw wlan0 link, then the signal strength for the adapter is always correctly reported (i.e., non-zero). However, when Wi-Fi traffic is being sent over the adapter, then the signal strength is mostly reported as zero (sometimes it is correct, as noted above). I verified this by running a long iperf session over Wi-Fi while querying signal strength via the serial console.

If I ssh into the board via Wi-Fi and do the query, it is almost always reported as zero because Wi-Fi traffic is being transferred for the ssh session.

@morrownr
Copy link
Owner Author

I think we should inform the author of hwdata to correct it, your adapter has a RTL8811AU chip actually.

That is a good idea but there are likely several ID descriptions that need correcting. I authored the vid/pid files for the rtw_8812au and rtw8821/11au in Larry's rtw88 so I know they are accurate. Are you volunteering to handle this?

Here is the history in case you haven't been watching this for the last 10+ years: Realtek's original, and for a few versions, vendor driver was a combined driver for the rtl8812au, rtl8821au and rtl8811au chips. Then about 5 or so years ago, they released separate drivers which has led to a lot of confusion in the years since. The bug reports that I get these days are mostly ones when I have to send users to the other driver. This is confusion that needs to go away. Getting the drivers in mainline will help we still need the ID wordage to be accurate.

@dubhater
Copy link

@a5a5aa555oo rtw8821a_fw.bin has worked fine so far, so we don't need rtw8811a_fw.bin.

I opened a pull request to correct the description of 0bda:1a2b. It was rejected because that repository is not the right place for it. They directed me to http://www.linux-usb.org/usb-ids.html. I'm still waiting to hear back. The current list of IDs is from July, so there is hope.

@a5a5aa555oo
Copy link

@dubhater

I read the guideline and found it hard to correct them but im trying it with 0bda:1a2b and 0bda:2005~

@a5a5aa555oo
Copy link

a5a5aa555oo commented Aug 11, 2024

I submitted some change requests to that site, but I don't know if they will accept them. :(

https://usb-ids.gowdy.us/read/UD/0bda/2005
https://usb-ids.gowdy.us/read/UD/0bda/1a2b
https://usb-ids.gowdy.us/read/UD/0bda/0811

That is a good idea but there are likely several ID descriptions that need correcting. I authored the vid/pid files for the rtw_8812au and rtw8821/11au in Larry's rtw88 so I know they are accurate. Are you volunteering to handle this?

Here is the history in case you haven't been watching this for the last 10+ years: Realtek's original, and for a few versions, vendor driver was a combined driver for the rtl8812au, rtl8821au and rtl8811au chips. Then about 5 or so years ago, they released separate drivers which has led to a lot of confusion in the years since. The bug reports that I get these days are mostly ones when I have to send users to the other driver. This is confusion that needs to go away. Getting the drivers in mainline will help we still need the ID wordage to be accurate.

@morrownr
it looks like pretty hard to correct them, all we can do are just submitting the changes, and then wait, wait and wait...

@5kft
Copy link
Contributor

5kft commented Aug 11, 2024

@dubhater Regarding the signal strength issue, what do you think about the following fix for the 8821a (see diff below)? My thinking is this:

For the 8821a, most packets aren't reporting a PHY status even though BIT_APP_PHYSTS is set in REG_RCR. (E.g., I don't see this signal strength issue with my 8821cu adapter, so it appears PHY status reporting is working for that adapter.)

rtw_rx_fill_rx_status copies pkt_stat->signal_power to rx-status->signal regardless of the status of the packet. So, for the 8821a, why not simply cache the last signal strength value returned from a valid PHY status, and return this value when there is no PHY status present in the packet?

The fact that the signal value is always copied in rx.c regardless makes this logic actually pretty reasonable. Thoughts?

index 7031ca176..5e3b62ac4 100644
--- a/drivers/net/wireless/realtek/rtw88/rtw8821a.c
+++ b/drivers/net/wireless/realtek/rtw88/rtw8821a.c
@@ -1708,6 +1708,7 @@ static void rtw8821a_query_rx_desc(struct rtw_dev *rtwdev, u8 *rx_desc,
        u32 desc_sz = rtwdev->chip->rx_pkt_desc_sz;
        struct ieee80211_hdr *hdr;
        u8 *phy_status = NULL;
+       static s32 prev_signal_power = 0;

        memset(pkt_stat, 0, sizeof(*pkt_stat));

@@ -1738,6 +1739,9 @@ static void rtw8821a_query_rx_desc(struct rtw_dev *rtwdev, u8 *rx_desc,
        if (pkt_stat->phy_status) {
                phy_status = rx_desc + desc_sz + pkt_stat->shift;
                rtw8821a_query_phy_status(rtwdev, phy_status, pkt_stat);
+               prev_signal_power = pkt_stat->signal_power;
+       } else {
+               pkt_stat->signal_power = prev_signal_power;
        }

        rtw_rx_fill_rx_status(rtwdev, pkt_stat, hdr, rx_status, phy_status);

@dubhater
Copy link

@5kft That's what I was thinking too, but only if the missing PHY status is normal, if it's like that with the official driver too. I haven't checked yet.

(Also prev_signal_power has to go in a struct, rtw_dev, rtw_phy, something like that. Otherwise if you have two devices using this driver at the same time the signal strength will be incorrect.)

@5kft
Copy link
Contributor

5kft commented Aug 11, 2024

@dubhater Totally makes sense.

@dubhater
Copy link

@5kft It's the same with the official driver. Fortunately, not knowing the signal strength for some frames is very normal, not just for Realtek chips. mac80211 already supports this:

diff --git a/drivers/net/wireless/realtek/rtw88/rx.c b/drivers/net/wireless/realtek/rtw88/rx.c
index 66f9419588cf..4f9fce3f79b1 100644
--- a/drivers/net/wireless/realtek/rtw88/rx.c
+++ b/drivers/net/wireless/realtek/rtw88/rx.c
@@ -235,10 +235,14 @@ void rtw_rx_fill_rx_status(struct rtw_dev *rtwdev,
 	else
 		rx_status->bw = RATE_INFO_BW_20;
 
-	rx_status->signal = pkt_stat->signal_power;
-	for (path = 0; path < rtwdev->hal.rf_path_num; path++) {
-		rx_status->chains |= BIT(path);
-		rx_status->chain_signal[path] = pkt_stat->rx_power[path];
+	if (pkt_stat->phy_status) {
+		rx_status->signal = pkt_stat->signal_power;
+		for (path = 0; path < rtwdev->hal.rf_path_num; path++) {
+			rx_status->chains |= BIT(path);
+			rx_status->chain_signal[path] = pkt_stat->rx_power[path];
+		}
+	} else {
+		rx_status->flag |= RX_FLAG_NO_SIGNAL_VAL;
 	}
 
 	rtw_rx_addr_match(rtwdev, pkt_stat, hdr);

@5kft
Copy link
Contributor

5kft commented Aug 12, 2024

Fortunately, not knowing the signal strength for some frames is very normal, not just for Realtek chips. mac80211 already supports this

@dubhater This is perfect - very nice! I can confirm that this change works like a charm. Thank you!

@tukkek
Copy link

tukkek commented Aug 17, 2024

Hi fellas, I wrote my experiences with the rtw88 driver here: lwfinger/rtw88#231

I wasn't sure what would be helpful or not so I pretty much just put everything I could think of there. I won't subscribe to this issue here since it's pretty active (and I doubt I'd be of any help either) but I'll try to keep an eye for replies on the linked issue. Cheers!

@realskyquest
Copy link

realskyquest commented Aug 19, 2024

Hello, I have tried using https://github.com/morrownr/8821au-20210708 , I have found this in https://forums.linuxmint.com/viewtopic.php?t=376909

It works great, but i'm not sure about how good it works and my wifi speed is not great, so can't really do a wifi test speed with over 50 mbps.

neofetch

OS: Linux Mint 22 x86_64 
HOST: OptiPlex 790 01
Kernel: 6.8.0-40-generic
DE: Cinnamon 6.2.9

lsusb

Bus 002 Device 006: ID 0846:9052 NetGear, Inc. A6100 AC600 DB Wireless Adapter [Realtek RTL8811AU]

I have read tukkek post, it seems kinda lacking on os and other information, so I did not get any usefull information, also read several other ubuntu forums and linux forums, this was the most legit looking driver, althought it has some recent updates a less than year ago, I'm concerned a bit.

If you have any more questions, I will answer them.

EDIT: I did basic wifi speed test, I'm not that experienced to do other tests like mode switch or etc

@realskyquest
Copy link

New update on my driver issues, I randomly got a warning report that told me that there was a driver for my NetGear usb wifi adapter, so i'm switching to that. I swear that driver appeared randomly.

Screenshot from 2024-08-20 23-26-01

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests