Qualcomm Wlan Country Code

Country code defined in ISO-3166 alpha2 (two-character format) is commonly used to abbreviate country names in the world.

一、Country Code

Country Code information can be given to driver from:

  1. DefaultCountryTable field in WCNSS_qcom_wlan_nv.bin - read during driver initialization
  2. gStaCountryCode parameter in WCNSS_qcom_cfg.ini – read during driver initialization to replace default country code in WCNSS_qcom_wlan_nv.bin
  3. Country IE from AP defined by 802.11d – information given by AP
  4. “iw reg set” command – set from userspace application over cfg80211 interface
  5. Private IOCTL with “COUNTRY” command – set from userspace app

gCountryCodePriority
gCountryCodePriority is a flag that can be defined in WCNSS_qcom_cfg.ini
to decide the preferred priority of Country Code information between userspace commands
(either over cfg80211 interface or wext interface) and 802.11d; the value can be 1 or 0.

1 – Country Code information from userspace commands takes priority
Overall priority would be userspace commands > 802.11d > gStaCountryCode in WCNSS_qcom_cfg.ini >
DefaultCountryTable in WCNSS_qcom_wlan_nv.bin

0 – Country Code information from 802.11d takes priority
Overall priority would be 802.11d > userspace commands > gStaCountryCode in WCNSS_qcom_cfg.ini >
DefaultCountryTable in WCNSS_qcom_wlan_nv.bin

二、Country Code Configuration

1. WCNSS_qcom_wlan_nv.bin
Country code is saved in CountryCode attribute of DefaultCountryTable field and considered as default country code of the device

<DefaultCountryTable>
	<RegulatoryDomain Map="0:FCC,1:ETSI,2:JAPAN,3:WORLD,4:N_AMER_EXC_FCC,5:APAC,6:KOREA,7:HI_5GHZ,8:NO_5GHZ">3</RegulatoryDomain>
	<CountryCode>
		<Value>48</Value> // 48=0x30=0<Value>48</Value> // 48=0x30=0<Value>73</Value> // 73=0x49=‘I’ for indoor
	</CountryCode>
</DefaultCountryTable>
or
<defaultCountryTable>
	<regDomain>0</regDomain>
	<countryCode>
		<countryCode_value Index="0">67</countryCode_value>
		<countryCode_value Index="1">78</countryCode_value>
		<countryCode_value Index="2">73</countryCode_value>
	</countryCode>
</defaultCountryTable>
// 67 = 0x43 = ‘C’
// 78 = 0x4E = ‘N’
// 73 = 0x49 = ‘I’ for indoor

## Third character is optional and valid characters can be ‘O' for outdoor, 'I' for Indoor, or ' ' (space)

2. WCNSS_qcom_cfg.ini
gStaCountryCode = 000

If gStaCountryCode parameter in WCNSS_qcom_cfg.ini is configured and not the same as “000”, the country code set in gStaCountryCode parameter will replace the default country code in WCNSS_qcom_wlan_nv.bin during driver initialization

3. Country Code from Country IE from AP Defined by 802.11d
As defined by 802.11d, AP would bring Country Information Element with country code, channel and power limit information

g11dSupportEnabled is the flag in WCNSS_qcom_cfg.ini to enable 802.11d support in WCN driver.
If the value is set to 1 (enable), driver will internally trigger scan request with passive scan during driver initialization to look for country
information; default value is 1

gEnableBypass11d flag in WCNSS_qcom_cfg.ini can be set to bypass triggering driver internal 802.11d passive scan during initialization.
With the value set to 1, WCN driver would do active scan based on the allowable regulatory channels
without doing passive scan. It can improve the initial scan time; default value is 1

4. Country Code from NL80211 Command
iw set reg <CountryCode> is the command to test NL80211 interface setting country code information

5. IW Tool ( iwpriv/iwlist )
For iwpriv/iwlist, they are open-souce tools known as wirelesss tool.
How to get it ? ====> Please see link: https://blog.csdn.net/Ciellee/article/details/88046465

三、User Space Command

here are some command for usre space to set or get Country Code

iw reg set 			//such as "iw reg set CN" 
iw reg get 			//will get current country code and channel info. /kernel/net/wireless/db.txt
iwpriv wlan0 getChannelList 		//this command will print all of the channel you support now;
wpa_cli -i wlan0 driver COUNTRY CN 	//change to CN

四、ISO 3166

ISO 3166 is the International Standard for country codes and codes for their subdivisions.
Example:
在这里插入图片描述
See the links below for details:
https://baike.baidu.com/item/ISO 3166-1/5269555?fr=aladdin

五、Other cfg80211’s algorithm

more detail,Please see link:
https://wireless.wiki.kernel.org/en/developers/Regulatory/processing_rules#Country_definition

Article from [80-Y0476-2 Rev. J]

猜你喜欢

转载自blog.csdn.net/Ciellee/article/details/88046387