You are not logged in.

#1 2022-09-01 17:38:15

ilytryic64
Member
Registered: 2022-08-23
Posts: 6

[Solved] Can't set correct regulatory domain for wifi (Mediatek MT7922

$ lspci -k
02:00.0 Network controller: MEDIATEK Corp. MT7922 802.11ax PCI Express Wireless Network Adapter
	Subsystem: Lenovo Device e0c6
	Kernel driver in use: mt7921e
	Kernel modules: mt7921e

These are the settings without any configuration:

$ iw reg get
global
country DE: DFS-ETSI
	(2400 - 2483 @ 40), (N/A, 20), (N/A)
	(5150 - 5250 @ 80), (N/A, 23), (N/A), NO-OUTDOOR, AUTO-BW
	(5250 - 5350 @ 80), (N/A, 20), (0 ms), NO-OUTDOOR, DFS, AUTO-BW
	(5470 - 5725 @ 160), (N/A, 26), (0 ms), DFS
	(5725 - 5875 @ 80), (N/A, 13), (N/A)
	(5945 - 6425 @ 160), (N/A, 23), (N/A), NO-OUTDOOR
	(57000 - 66000 @ 2160), (N/A, 40), (N/A)

This does not change when uncommenting

WIRELESS_REGDOM="CH"

in /etc/conf.d/wireless-regdom and reboot or when setting via

options cfg80211 ieee80211_regdom=CH

in modprobe and reboot.

But when doing

# iw reg set CH

it changes to

$ iw reg get
global
country 98: DFS-ETSI
	(2400 - 2483 @ 40), (N/A, 20), (N/A)
	(5150 - 5250 @ 100), (N/A, 23), (N/A), NO-OUTDOOR, AUTO-BW
	(5250 - 5350 @ 100), (N/A, 20), (0 ms), NO-OUTDOOR, DFS, AUTO-BW
	(5470 - 5725 @ 160), (N/A, 26), (0 ms), DFS
	(5725 - 5875 @ 80), (N/A, 13), (N/A)
	(57000 - 66000 @ 2160), (N/A, 40), (N/A)

with no possibilty to change it back or to anything else after that.

The card is supported by the driver and I don't understand what the issue is here, have not faced this on any of my older devices. What could be the issue here? Is this some setting in the Mediatek hardware that can't be changed via software?

Last edited by ilytryic64 (2022-09-06 12:50:51)

Offline

#2 2022-09-01 19:53:51

seth
Member
Registered: 2012-09-03
Posts: 31,978

Offline

#3 2022-09-02 07:31:47

ilytryic64
Member
Registered: 2022-08-23
Posts: 6

Re: [Solved] Can't set correct regulatory domain for wifi (Mediatek MT7922

Yes, I have installed wireless-regdb and uncommented the line I want as stated above. Yes, I followed that wiki section as I have done with my older pcs. I use iwd so can't set anything via wpa_supplicant.

The db is being loaded:

# dmesg | grep -i cfg80211
[   11.543259] cfg80211: Loading compiled-in X.509 certificates for regulatory database
[   11.543474] cfg80211: Loaded X.509 cert 'sforshee: 00b28ddf47aef9cea7'

The module doesn't show anything special:

# dmesg | grep -i mt7921e
[   11.865042] mt7921e 0000:02:00.0: enabling device (0000 -> 0002)
[   11.888033] mt7921e 0000:02:00.0: ASIC revision: 79220010
[   11.970451] mt7921e 0000:02:00.0: HW/SW Version: 0x8a108a10, Build Time: 20220523103345a
[   11.987017] mt7921e 0000:02:00.0: WM Firmware Version: ____000000, Build Time: 20220523103447

Offline

#4 2022-09-02 12:39:30

seth
Member
Registered: 2012-09-03
Posts: 31,978

Re: [Solved] Can't set correct regulatory domain for wifi (Mediatek MT7922

I use iwd so can't set anything via wpa_supplicant.

You could try, though.

Also don't filter the dmesg and/or "dmesg -w" before you set the reg domain and see whether this triggers any sort of response (and notably errors)
Can you switch to US or CN?

Offline

#5 2022-09-06 12:50:20

ilytryic64
Member
Registered: 2022-08-23
Posts: 6

Re: [Solved] Can't set correct regulatory domain for wifi (Mediatek MT7922

So I think it's my home router sending this regulatory domain info to my laptop. When I disconnect the wifi and run

iw reg get

it shows "CH" which is what I want. The only weird thing is that my old laptop and my pc are on the same wifi and they do not receive anything from the router and are set to "CH" even when connected. I have no idea why that is (maybe something with the network card/driver), but I guess the issue is "solved" since the regdom is being correctly set when disconnected or connected to another wifi. Thanks for your help seth.

I still would like it if I could override the router regdom with my own, but I'm not sure if or how this is possible.

Last edited by ilytryic64 (2022-09-06 12:52:27)

Offline

#6 2022-09-06 13:23:56

seth
Member
Registered: 2012-09-03
Posts: 31,978

Re: [Solved] Can't set correct regulatory domain for wifi (Mediatek MT7922

Can you set the reg domain when not connected?
What happens when you then connect?
How do you connect? Only iwd or iwd as NM backend?
What if you connect manually w/ wpa_supplicant?

https://bugs.launchpad.net/netplan/+bug … omments/26
The AP probably yells its regdomain into the world (=> check the scan results) and your network config tool might pick it up from there to ensure compliance before it tries to associate to not get rejected for the mismatch.

If you control the AP, you might be able to impact the regdomain there.

Offline

#7 2022-09-06 19:41:12

jprestwo
Member
Registered: 2022-01-06
Posts: 22

Re: [Solved] Can't set correct regulatory domain for wifi (Mediatek MT7922

Marked as solved, but FWIW this sounds simply like a limitation (or feature) of using wifi on Linux. The kernel sets the regulatory domain based on beacons/probes and so setting it from userspace is only going to work temporarily, if at all. And bonus, if no AP's around you advertise a country IE you are stuck without a domain being set entirely which restricts frequencies such as 6Ghz...

Offline

#8 2022-09-06 19:53:46

seth
Member
Registered: 2012-09-03
Posts: 31,978

Re: [Solved] Can't set correct regulatory domain for wifi (Mediatek MT7922

It is *highly* unlikely that the kernel is setting anything here, but the network managing service (and in particular iwd) does.
(In contrast to wpa_supplicant which at least allows to override the regdomain)

Offline

#9 2022-09-06 22:49:42

jprestwo
Member
Registered: 2022-01-06
Posts: 22

Re: [Solved] Can't set correct regulatory domain for wifi (Mediatek MT7922

seth wrote:

It is *highly* unlikely that the kernel is setting anything here, but the network managing service (and in particular iwd) does.
(In contrast to wpa_supplicant which at least allows to override the regdomain)

Well, wpa_supplicant can set it (and in turn NM via wpa_supplicant), but IWD does not touch the regdom. Based on the fact that 'iw reg set CH' results in the CC being '98' I'd say its highly likely the kernel *is* changing it. '98' is a special intersection country code defined by the kernel, meaning multiple country codes were detected, either via beacons/probes or maybe by setting it explicitly. If I were to guess, the intersection between DE and CH.

Last edited by jprestwo (2022-09-06 22:55:37)

Offline

#10 2022-09-07 07:02:52

seth
Member
Registered: 2012-09-03
Posts: 31,978

Re: [Solved] Can't set correct regulatory domain for wifi (Mediatek MT7922

It's actually somewhat documented
https://wireless.wiki.kernel.org/en/dev … sing_rules

The Linux kernel wireless subsystem always enables the dot11MultiDomainCapabilityEnabled flag. Therefore, STA devices in the Linux kernel try to follow country information received in AP beacons.

Enabling users to enhance regulatory
Users can enhance regulatory settings by further restricting devices by picking a regulatory domain. This will enable users to help compliance further. Currently regulatory rules for certain countries (“US” and “JP”) do not allow users to select their regulatory domain though so blindly trusting a user is not something that can be allowed if you are in certain regulatory domain. If a user picks a regulatory domain channels will be restricted further on a device if the device has its own regulatory domain already listed.

Though my impression would be that outside "certain countries" the user provided domain would still override the beacon hint.
I'll test that somewhat later (all APs in range do not hint their regdomain)

Offline

#11 2022-09-07 23:10:54

jprestwo
Member
Registered: 2022-01-06
Posts: 22

Re: [Solved] Can't set correct regulatory domain for wifi (Mediatek MT7922

Whether its beacons, cellular, or 'iw reg set' is all hints to the kernel, and it can choose to use them or not. There is an explicit API (CMD_SET_REG) to set the regdom, but this is not used anymore and was only used by CRDA (the API requires a lot more than an alpha2 CC, i.e. parsing the regdb).

The way wpa_supplicant/iw does it is via CMD_REQ_SET_REG which is just a user hint to the kernel. This may actually set it, or it may not. I've currently got two systems, one of which sets it fine while the other completely refuses. Not that my two data points mean much, but the kernel code is quite obvious that any attempt to set it is merely a hint.

If you really want to dig in:
https://git.kernel.org/pub/scm/linux/ke … 11.c#n7754

Seth,
I have a feeling for *most* systems you are correct and explicitly setting the regdom will work. All I'm saying is its far from a guarantee and ultimately left up to the kernel in the end.

Offline

#12 2022-09-08 11:39:21

ilytryic64
Member
Registered: 2022-08-23
Posts: 6

Re: [Solved] Can't set correct regulatory domain for wifi (Mediatek MT7922

Can you set the reg domain when not connected?
What happens when you then connect?
How do you connect? Only iwd or iwd as NM backend?
What if you connect manually w/ wpa_supplicant?

Yes, when not connected I can set it to anything.
Then when I connect (to my home network) whatever it was set to previously gets overridden with DE like in my original post.
I use just iwd (as a systemd service) and initially connected via iwctl.
So I tried with wpa_supplicant and set country=CH in my config file, but still it's the same issue and the regdom gets set to DE when connecting.

How can I find out if my AP is sending out this regdom?

Offline

#13 2022-09-08 12:22:28

seth
Member
Registered: 2012-09-03
Posts: 31,978

Re: [Solved] Can't set correct regulatory domain for wifi (Mediatek MT7922

Shows up in the scan results

sudo iw dev wlwhatever scan

Offline

Board footer

Powered by FluxBB