diederikdehaas / rtl8812AU

Realtek 8812AU USB WiFi driver
Other
475 stars 177 forks source link

Some channels are disabled regardless of the regulatory domain #35

Open ghost opened 8 years ago

ghost commented 8 years ago

I have my regulatory domain set to a country. This is what I get from iw reg get:

country <Country_code_here>: DFS-ETSI
    (2402 - 2482 @ 40), (N/A, 20), (N/A)
    (5170 - 5250 @ 80), (N/A, 17), (N/A), AUTO-BW
    (5250 - 5330 @ 80), (N/A, 24), (0 ms), DFS, AUTO-BW
    (5490 - 5710 @ 160), (N/A, 24), (0 ms), DFS
    (5735 - 5835 @ 80), (N/A, 30), (N/A)

For the same country, the matching record in db.txt from https://www.kernel.org/pub/software/network/wireless-regdb/ is shown below:

country <Country_code_here>: DFS-ETSI
    (2402 - 2482 @ 40), (20)
    (5170 - 5250 @ 80), (17), AUTO-BW
    (5250 - 5330 @ 80), (24), DFS, AUTO-BW
    (5490 - 5710 @ 160), (24), DFS
    (5735 - 5835 @ 80), (30)

However, when I run iw list, the output shows that some channels are disabled. Some channels have the flag "(no IR)", so those channels cannot be used, too.

        Frequencies:
            * 5170 MHz [34] (disabled)
            * 5180 MHz [36] (17.0 dBm)
            * 5190 MHz [38] (disabled)
            * 5200 MHz [40] (17.0 dBm)
            * 5210 MHz [42] (disabled)
            * 5220 MHz [44] (17.0 dBm)
            * 5230 MHz [46] (disabled)
            * 5240 MHz [48] (17.0 dBm)
            * 5260 MHz [52] (24.0 dBm) (no IR)
            * 5280 MHz [56] (24.0 dBm) (no IR)
            * 5300 MHz [60] (24.0 dBm) (no IR)
            * 5320 MHz [64] (24.0 dBm) (no IR)
            * 5500 MHz [100] (24.0 dBm) (no IR)
            * 5520 MHz [104] (24.0 dBm) (no IR)
            * 5540 MHz [108] (24.0 dBm) (no IR)
            * 5560 MHz [112] (24.0 dBm) (no IR)
            * 5580 MHz [116] (24.0 dBm) (no IR)
            * 5600 MHz [120] (24.0 dBm) (no IR)
            * 5620 MHz [124] (24.0 dBm) (no IR)
            * 5640 MHz [128] (24.0 dBm) (no IR)
            * 5660 MHz [132] (24.0 dBm) (no IR)
            * 5680 MHz [136] (24.0 dBm) (no IR)
            * 5700 MHz [140] (24.0 dBm) (no IR)
            * 5745 MHz [149] (30.0 dBm)
            * 5765 MHz [153] (30.0 dBm)
            * 5785 MHz [157] (30.0 dBm)
            * 5805 MHz [161] (30.0 dBm)
            * 5825 MHz [165] (30.0 dBm)
            * 5920 MHz [184] (disabled)
            * 5940 MHz [188] (disabled)
            * 5960 MHz [192] (disabled)
            * 5980 MHz [196] (disabled)
            * 6000 MHz [200] (disabled)
            * 6020 MHz [204] (disabled)
            * 6040 MHz [208] (disabled)
            * 6060 MHz [212] (disabled)
            * 6080 MHz [216] (disabled)

In addition, if I interpreted the regulatory domain regulation (records in db.txt) correctly, channels 12 and 13 in 2.4GHz should be available for use. However, this is what I get from iw list:

        Frequencies:
            * 2412 MHz [1] (20.0 dBm)
            * 2417 MHz [2] (20.0 dBm)
            * 2422 MHz [3] (20.0 dBm)
            * 2427 MHz [4] (20.0 dBm)
            * 2432 MHz [5] (20.0 dBm)
            * 2437 MHz [6] (20.0 dBm)
            * 2442 MHz [7] (20.0 dBm)
            * 2447 MHz [8] (20.0 dBm)
            * 2452 MHz [9] (20.0 dBm)
            * 2457 MHz [10] (20.0 dBm)
            * 2462 MHz [11] (20.0 dBm)
            * 2467 MHz [12] (disabled)
            * 2472 MHz [13] (disabled)
            * 2484 MHz [14] (disabled)

As a result, if the adapter attempts to use the disabled / no-IR channels (no matter in station mode or AP mode), the operation will fail. I have been able to reproduce this issue on version 4.3.22-beta and 4.3.21.

diederikdehaas commented 8 years ago

Kudos for the detailed analyses :+1:

I have my regulatory domain set to a country.

How/where can/should you do that?

This is what I get from iw reg get

Do you happen to know some good tutorials on the use of iw? I'm actually pretty clueless about it and the help info is quite daunting (to me) with loads of things in it that don't ring a bell and the man page seems to be pretty useless. I've been having some issues (maybe related to wpa_supplicant) and getting (and/or setting) the right info with the right tools (iw and ip) seems like something I should learn. Things work fine on my PC which uses a wired network connection, but the issues are on my laptop which has a wireless device and plugging in my rtl8812AU device doesn't make things easier :wink:

olivluca commented 8 years ago

I'm not sure that the driver reacts correctly to iw reg set, but it has an "iwpriv channel_plan" command (see include/rtw_mlme_ext.h and core/rtw_mlme_ext.c) though I'm not sure it does the "right" thing either.

olivluca commented 8 years ago

If you look at os_dep/linux/ioctl_linux.c you'll see that "iwpriv channel_plan" is implemented by rtw_wx_set_channel_plan which in turn calls rtw_set_chplan_cmd. This is in core/rtw_cmd.c and it checks that the parameter is valid by using the macro rtw_is_channel_plan_valid, defined in include/rtw_mlme_ext.h as #define rtw_is_channel_plan_valid(chplan) (chplan<RT_CHANNEL_DOMAIN_MAX || chplan == RT_CHANNEL_DOMAIN_REALTEK_DEFINE)

RT_CHANNEL_DOMAIN_MAX is defined in include/rtw_mlme_ext.h, where you can see the valid values for the "iwpriv channel_plan" parameter while the definitions of the various plans are in core/rtw_mlme_ext.c

I investigated because I see with iw list that various channels are disabled while they shouldn't in my regdomain (ES). Using the iwpriv I see some of them enabled (at least for x seconds, I suppose for DFS but I'm not an expert on wifi issues). BTW, I'm currently using your repository (the 4.3.14 branch, the 4.3.21 doesn't work with my adapter) but there should be no significant difference wrt regdomains to diederikdehaas' one

olivluca commented 8 years ago

Oh, and I investigated just because I couldn't see my access point, which had the channel set to auto and it selected one of the disabled one. I just set it manually and now I can connect, but I wonder why the driver doesn't allow me to use channels that are available here.

olivluca commented 8 years ago

@uminokoe yes, it is listed (0bda:881a) but somehow it fails during initialization and it enters in a loop, but I didn't investigate too much. I don't absolutely need to see all channels but it bothers me that it doesn't use all legally available channels. The change I see in 4.3.21 is that RT_CHANNEL_DOMAIN* is now RTW_CHPLAN* but the rest seems to be the same (just had a cursory glance).

olivluca commented 8 years ago

I commented out that line, iw list shows all channels up to 140 as available (52-140 with radar detection). Put the AP in auto mode, it selected channel 104 but the wifi stick cannot see it (and it is there: my mobile connects to it just fine). I tried channel 52 (also with radar detection) and it doesn't work either.

CableCatDK commented 7 years ago

I could not get 5Ghz to work. After reading this post I change the channel to 36, and it now works. Thanks.