lwfinger / rtw8852cu

GNU General Public License v2.0
26 stars 17 forks source link

slow speed / low power #15

Closed ntzb closed 3 months ago

ntzb commented 3 months ago

Hi, I tested the speed of this driver on both Ubuntu and Windows. in Windows I'm getting ~800 Mb/s, while on Ubuntu it's only ~330Mb/s (same distance from router). this seems to suggest it's not only me. anyone getting higher speeds on 160MHz WiFi 6, (in a reasonable distance from the AP)?

it could be a power issue, but there's no way to manually set the tx power (e.g. iw dev wlan0 set txpower fixed 2000): this https://github.com/lwfinger/rtw8852cu/blob/d256c2ae282b70f03629e36900da54905ab4187c/os_dep/linux/ioctl_cfg80211.c#L10623 links to this https://github.com/lwfinger/rtw8852cu/blob/d256c2ae282b70f03629e36900da54905ab4187c/os_dep/linux/ioctl_cfg80211.c#L4397 which does nothing (all code is #if 0, because it calls functions that start with iwm that probably belong to some prehistory iwmc3200wifi or similar)

and the power from iw dev wlan0 info always returns 12.00 dBm because it's hardcoded: https://github.com/lwfinger/rtw8852cu/blob/d256c2ae282b70f03629e36900da54905ab4187c/os_dep/linux/ioctl_cfg80211.c#L4445

there are some realtek repos that implemented tx control (https://github.com/aircrack-ng/rtl8812au/commit/fa35b99b425bc93ed712bd7c73e0701df0d46d3e#diff-f42b6f2928f2ff74d519a664378a6267da1fcde5b9c08d67e46d462b07d5671b, https://github.com/Mange/rtl8192eu-linux-driver/pull/136/files, https://github.com/morrownr/8814au/pull/7/files) but they refer to hal functions that do not exist in this driver, so it's impossible to add.

in general, it seems that many functions are missing, and implemented as empty shells, to only pass compilation without errors (like it was copied from other devices, e.g. rtw_hal_set_tx_power_level).

@lwfinger can you maybe ask for a newer driver?

pulller commented 3 months ago

My CF-972AX has max trans speed 40MB/s while I test by iperf in LAN. The operation system is Ubuntu 22.04. Max power is 12 dBm. It's too slower than tested in Windows system. The contry code is set "US" in makefile. I don't know whether it should set CONFIG_TXPWR_LIMIT to 'n'.

微信截图_20240616142936

ntzb commented 3 months ago

I already tried setting CONFIG_TXPWR_LIMIT (it needs other code modifications as well), it doesn't make a difference. regarding the 12dB, it's hardcoded and doesn't reflect the "real" current tx power (see my original post).

40MB/s is around 320 Mb/s, which is around what I got with my device (330), and what @lwfinger got with his. it's a driver problem (amongst others), and while this is the state of things, there is literally NO point in buying any of these devices to use in Linux (the bandwidth is 0.1x of what it should be - 3000Mb/s)

I'm open to ideas and to explorations, if anyone can think of a workaround or a fix to this driver

ntzb commented 3 months ago

I've found out that the device is configured as USB 2 (lsusb -t shows speed 480M). the variable that controls this is rtw_switch_usb_mode, and in order to change that I've followed this: https://askubuntu.com/a/1189615/1687468 with another reference here: https://github.com/morrownr/8814au/blob/main/8814au.conf it immediately solved the issue - the device was identified as USB 3.0 (5000M), and I'm getting 900Mbps.

a permanent "fix" is to modify this line to 1: https://github.com/lwfinger/rtw8852cu/blob/d256c2ae282b70f03629e36900da54905ab4187c/os_dep/linux/rtw_cfg.c#L387

@lwfinger since this driver is for devices with supported speed of 2.4Gbps, my suggestion is to make this change as mentioned.

@pulller FYI this should solve it for you

pulller commented 3 months ago

@ntzb @lwfinger I follow this article (https://deb.trendtechcn.com/advanced/usb3/). Doesn't need modify the file "rtw8852cu/os_dep/linux/rtw_cfg.c". This is my steps:

  1. Create a file named "rtl8852cu.conf" in /etc/modprobe.d/.The content is: options 8852cu rtw_switch_usb_mode=1
  2. reboot. Then it works at full speed.

image

By the way, I tried to modify the rtw_cfg.c, "int rtw_switch_usb_mode = 0;" to "int rtw_switch_usb_mode = 1;" It doen't work, and system can't recognize the driver.So, I think it DON'T need to change, the driver can adapt the usb3 and usb2 auto.

ntzb commented 3 months ago

@pulller those steps are exactly the same as outlined in the askubuntu answer I linked to. at the end of the day, setting it via the code, or via module .conf file is the same. the value is being initialized, and then, if passed as module param, can be overridden: https://github.com/lwfinger/rtw8852cu/blob/d256c2ae282b70f03629e36900da54905ab4187c/os_dep/linux/rtw_cfg.c#L575C1-L575C13

for platforms that do not have easy modprobe.d conf settings (e.g. openwrt), it is needed to set this in code. also there's no reason not to, since these adapters are bought for high speed usage, and are severely crippled by the default USB 2 flag, in the code.

I've no idea why this didn't work for you, but it did for me (and the code shows that it should)