Default init case
By default, when no country regulatory setting is defined, we use WW (World Wide safe setting, meaning we only transmit on bands which are allowed worldwide, with the TX power compatible with all countries regulations)
Setting country
1/ When operating in AP mode:
- we usually set country code (ex : country_code=JP) in hostapd.conf to define the country.
- this country definition will be advertised to all connected STA if ieee80211d=1 is set in hostpad.conf
- the country can also be set with "iw reg set" command
2/ When operating in STA mode
- country code can be set with "iw reg set" command or in wpa_supplicant.conf (ex : country=jp)
- once connected to the AP (with 80211d enabled), the STA will switch to the AP country setting (this behaviour can be disabled by adding country_ie_ignore=1 driver parameter)
Once country is set:
- we will only transmit on channels allowed for that country
- with country maximum TX power
- we might use DFS feature on channels declared as DFS channels for that specific country
TX power settings
1/ By default, using Linux regulatory settings (/lib/firmware/regulatory.db, generated from db.txt)
These settings define allowed channels, DFS flags and max TX power on a country basis
See section "Regulatory db" further.
2/ Linux regulatory settings can be overwritten by:
a. cntry_txpwr=0 and txpwrlimit_cfg=nxp/txpower.bin driver param (generated from txpower.conf (channel/MCS->txpower), see AN13009)
Same setting for all countries (static).
Using channels/flags from db.txt, and minimum TX power between db.txt and txpower.bin/rgpower.bin
b. cntry_txpwr=1 (look for nxp/txpower_XX.bin files (generated from txpower.conf (channel/MCS->txpower), see AN13009)
Need one txpower_XX.bin file for each country XX (dynamically loaded, for instance with iw reg set XX)
Using channels/flags from db.txt, and minimum TX power between db.txt and txpower_XX.bin
cntry_txpwr
txpwrlimit_cfg
TX power limit
Method
0
nxp/txpower.bin
nxp/txpower.bin (static)
V1
1
-
nxp/txpower_XX.bin (dynamic)
V1 cfg
We have default TX power tables, but customer can tune these TX power settings, based on their HW.
Please refer to "AN13009 Wi-Fi Tx Power Management in Linux"
Regulatory db
Source https://wireless.wiki.kernel.org/en/developers/Regulatory/wireless-regdb
Wifi regulatory setting (allow channels, etc) are defined in db.txt, then converted to regulatory.db (store in /lib/firmware)
We can get official db.txt from here, and build regulatory.db with below command
git clone git://git.kernel.org/pub/scm/linux/kernel/git/wens/wireless-regdb.git
make
Kernel regulatory.db integrity is checked by the Linux kernel.
Disabling REGDB signature check with the folllowing kernel config:
CONFIG_EXPERT=y
CONFIG_CFG80211_CERTIFICATION_ONUS=y
# CONFIG_CFG80211_REQUIRE_SIGNED_REGDB is not set
Rebuilding kernel and flashing
scp Image root@192.168.0.2:/run/media/mmcblk0p1/
iw reg command examples and other notes
root@imx8mqevk:~# iw reg get global country 00: DFS-UNSET (2402 - 2472 @ 40), (N/A, 20), (N/A) (2457 - 2482 @ 20), (N/A, 20), (N/A), AUTO-BW, PASSIVE-SCAN (2474 - 2494 @ 20), (N/A, 20), (N/A), NO-OFDM, PASSIVE-SCAN (5170 - 5250 @ 80), (N/A, 20), (N/A), AUTO-BW, PASSIVE-SCAN (5250 - 5330 @ 80), (N/A, 20), (0 ms), DFS, AUTO-BW, PASSIVE-SCAN (5490 - 5730 @ 160), (N/A, 20), (0 ms), DFS, PASSIVE-SCAN (5735 - 5835 @ 80), (N/A, 20), (N/A), PASSIVE-SCAN (57240 - 63720 @ 2160), (N/A, 0), (N/A) root@imx8mqevk:~# iw reg get global country FR: 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) (57000 - 66000 @ 2160), (N/A, 40), (N/A)
By default (if no country is set), we are using the world domain. this is the most restrictive.
Then you can set the country (using driver module parameter, wpa_supplicant.conf, etc) or get the country automatically provided by the access point (80211d). This will update the regulatory domain, meaning the allowed channels, etc.
You can check the country settings with "iw reg get" command.
The regulatory domain has priority, compared to the channel list you would set in the wpa_supplicant.conf.
查看全文