xref: /OK3568_Linux_fs/external/rkwifibt/drivers/rtl8188fu/core/rtw_chplan.c (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1 /******************************************************************************
2  *
3  * Copyright(c) 2007 - 2018 Realtek Corporation.
4  *
5  * This program is free software; you can redistribute it and/or modify it
6  * under the terms of version 2 of the GNU General Public License as
7  * published by the Free Software Foundation.
8  *
9  * This program is distributed in the hope that it will be useful, but WITHOUT
10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12  * more details.
13  *
14  *****************************************************************************/
15 #define _RTW_CHPLAN_C_
16 
17 #include <drv_types.h>
18 
19 #define RTW_DOMAIN_MAP_VER		"51"
20 #define RTW_DOMAIN_MAP_M_VER	"f"
21 #define RTW_COUNTRY_MAP_VER		"26"
22 
23 enum rtw_rd_2g {
24 	RTW_RD_2G_WORLD = 0,	/* Worldwide 13 */
25 	RTW_RD_2G_ETSI1 = 1,	/* Europe */
26 	RTW_RD_2G_FCC1 = 2,		/* US */
27 	RTW_RD_2G_MKK1 = 3,		/* Japan */
28 	RTW_RD_2G_ETSI2 = 4,	/* France */
29 	RTW_RD_2G_GLOBAL = 5,	/* 2G Global (include Ch14) */
30 	RTW_RD_2G_MKK2 = 6,		/* Japan */
31 	RTW_RD_2G_FCC2 = 7,		/* US */
32 	RTW_RD_2G_NULL = 8,
33 	RTW_RD_2G_IC1 = 9,		/* Canada */
34 	RTW_RD_2G_WORLD1 = 10,	/* Worldwide 11 */
35 	RTW_RD_2G_KCC1 = 11,	/* Korea */
36 	RTW_RD_2G_IC2 = 12,		/* Canada */
37 
38 	RTW_RD_2G_MAX,
39 };
40 
41 enum rtw_rd_5g {
42 	RTW_RD_5G_NULL = 0,		/*	*/
43 	RTW_RD_5G_ETSI1 = 1,	/* Europe */
44 	RTW_RD_5G_ETSI2 = 2,	/* Australia, New Zealand */
45 	RTW_RD_5G_ETSI3 = 3,	/* Russia (w/o Ch136, Ch140) */
46 	RTW_RD_5G_FCC1 = 4,		/* US */
47 	RTW_RD_5G_FCC2 = 5,		/* FCC w/o DFS Channels */
48 	RTW_RD_5G_FCC3 = 6,		/* Bolivia, Chile, El Salvador, Venezuela */
49 	RTW_RD_5G_FCC4 = 7,		/* Venezuela (w/o Ch165) */
50 	RTW_RD_5G_FCC5 = 8,		/* China */
51 	RTW_RD_5G_FCC6 = 9,		/*	*/
52 	RTW_RD_5G_FCC7 = 10,	/* US, Canada (w/o Weather radar) (w/o Ch120~Ch128) */
53 	RTW_RD_5G_IC1 = 11,		/* US Canada (w/o Weather radar) */
54 	RTW_RD_5G_KCC1 = 12,	/* Korea */
55 	RTW_RD_5G_MKK1 = 13,	/* Japan */
56 	RTW_RD_5G_MKK2 = 14,	/* Japan (W52, W53) */
57 	RTW_RD_5G_MKK3 = 15,	/* Japan (W56) */
58 	RTW_RD_5G_NCC1 = 16,	/* Taiwan, (w/o Weather radar) (w/o Ch52, Ch120~Ch128) */
59 	RTW_RD_5G_NCC2 = 17,	/* Taiwan, Band2, Band4 */
60 	RTW_RD_5G_NCC3 = 18,	/* Taiwan w/o DFS, Band4 only */
61 	RTW_RD_5G_ETSI4 = 19,	/* Europe w/o DFS, Band1 only */
62 	RTW_RD_5G_ETSI5 = 20,	/* Australia, New Zealand (w/o Weather radar) (w/o Ch120~Ch128) */
63 	RTW_RD_5G_FCC8 = 21,	/* Latin America */
64 	RTW_RD_5G_ETSI6 = 22,	/* Israel, Bahrain, Egypt, India, China, Malaysia */
65 	RTW_RD_5G_ETSI7 = 23,	/* China */
66 	RTW_RD_5G_ETSI8 = 24,	/* Jordan */
67 	RTW_RD_5G_ETSI9 = 25,	/* Lebanon */
68 	RTW_RD_5G_ETSI10 = 26,	/* Qatar */
69 	RTW_RD_5G_ETSI11 = 27,	/* Russia */
70 	RTW_RD_5G_NCC4 = 28,	/* Taiwan (w/o Weather radar) (w/o Ch120~Ch128) */
71 	RTW_RD_5G_ETSI12 = 29,	/* Indonesia */
72 	RTW_RD_5G_FCC9 = 30,	/* FCC (w/o Weather radar) (w/o Ch120~Ch128) */
73 	RTW_RD_5G_ETSI13 = 31,	/* ETSI (w/o Weather radar) (w/o Ch120~Ch128) */
74 	RTW_RD_5G_FCC10 = 32,	/* Argentina (w/o Weather radar) (w/o Ch120~Ch128, Ch165) */
75 	RTW_RD_5G_MKK4 = 33,	/* Japan */
76 	RTW_RD_5G_ETSI14 = 34,	/* Russia */
77 	RTW_RD_5G_FCC11 = 35,	/* US (include Ch144) */
78 	RTW_RD_5G_ETSI15 = 36,	/* Malaysia */
79 	RTW_RD_5G_MKK5 = 37,	/* Japan */
80 	RTW_RD_5G_ETSI16 = 38,	/* Europe */
81 	RTW_RD_5G_ETSI17 = 39,	/* Europe */
82 	RTW_RD_5G_FCC12 = 40,	/* FCC */
83 	RTW_RD_5G_FCC13 = 41,	/* FCC */
84 	RTW_RD_5G_FCC14 = 42,	/* FCC w/o Weather radar (w/o Ch120~Ch128) */
85 	RTW_RD_5G_FCC15 = 43,	/* FCC w/o Band3 */
86 	RTW_RD_5G_FCC16 = 44,	/* FCC w/o Band3 */
87 	RTW_RD_5G_ETSI18 = 45,	/* ETSI w/o DFS Band2&3 */
88 	RTW_RD_5G_ETSI19 = 46,	/* Europe */
89 	RTW_RD_5G_FCC17 = 47,	/* FCC (w/o Weather radar) (w/o Ch120~Ch128) */
90 	RTW_RD_5G_ETSI20 = 48,	/* Europe */
91 	RTW_RD_5G_IC2 = 49,		/* Canada (w/o Weather radar) (w/o Ch120~Ch128, include Ch144) */
92 	RTW_RD_5G_ETSI21 = 50,	/* Australia, New Zealand (w/o Weather radar) (w/o Ch120~Ch128) */
93 	RTW_RD_5G_FCC18 = 51,	/*  */
94 	RTW_RD_5G_WORLD = 52,	/* 5G Worldwide (include Ch144) Band2&3 w/i DFS */
95 	RTW_RD_5G_CHILE1 = 53,	/* Chile */
96 	RTW_RD_5G_ACMA1 = 54,	/* Australia, New Zealand (w/o Weather radar) (w/o Ch120~Ch128) */
97 	RTW_RD_5G_WORLD1 = 55,	/* 5G Worldwide Band1&2 */
98 	RTW_RD_5G_CHILE2 = 56,	/* Chile (Band2,Band3) */
99 	RTW_RD_5G_KCC2 = 57,	/* Korea (New standard) */
100 	RTW_RD_5G_KCC3 = 58,	/* Korea (2018 Dec 05 New standard, include ch144) */
101 	RTW_RD_5G_MKK6 = 59,	/* Japan */
102 	RTW_RD_5G_MKK7 = 60,	/* Japan */
103 	RTW_RD_5G_MKK8 = 61,	/* Japan */
104 	RTW_RD_5G_MEX1 = 62,	/* Mexico */
105 	RTW_RD_5G_ETSI22 = 63,	/* Europe */
106 	RTW_RD_5G_MKK9 = 64,	/* Japan */
107 	RTW_RD_5G_FCC19 = 65,	/* FCC */
108 	RTW_RD_5G_FCC20 = 66,	/* FCC w/o Band3 */
109 	RTW_RD_5G_FCC21 = 67,	/* FCC */
110 	RTW_RD_5G_ETSI23 = 68,	/* Indonesia */
111 	RTW_RD_5G_ETSI24 = 69,	/* Indonesia */
112 	RTW_RD_5G_ETSI25 = 70,	/* China */
113 	RTW_RD_5G_MKK10 = 71,	/* Japan */
114 	RTW_RD_5G_ETSI26 = 72,	/* Singapore */
115 	RTW_RD_5G_MKK11 = 73,	/* Japan */
116 	RTW_RD_5G_ETSI27 = 74,	/*  */
117 	RTW_RD_5G_ETSI28 = 75,	/* Russia */
118 
119 	RTW_RD_5G_MAX,
120 };
121 
122 struct ch_list_t {
123 	u8 *len_ch_attr;
124 };
125 
126 #define CLA_2G_12_14_PASSIVE	BIT0
127 
128 #define CLA_5G_B1_PASSIVE		BIT0
129 #define CLA_5G_B2_PASSIVE		BIT1
130 #define CLA_5G_B3_PASSIVE		BIT2
131 #define CLA_5G_B4_PASSIVE		BIT3
132 #define CLA_5G_B2_DFS			BIT4
133 #define CLA_5G_B3_DFS			BIT5
134 #define CLA_5G_B4_DFS			BIT6
135 
136 #define CH_LIST_ENT(_len, arg...) \
137 	{.len_ch_attr = (u8[_len + 2]) {_len, ##arg}, }
138 
139 #define CH_LIST_LEN(_ch_list) (_ch_list.len_ch_attr[0])
140 #define CH_LIST_CH(_ch_list, _i) (_ch_list.len_ch_attr[_i + 1])
141 #define CH_LIST_ATTRIB(_ch_list) (_ch_list.len_ch_attr[CH_LIST_LEN(_ch_list) + 1])
142 
143 struct chplan_ent_t {
144 	u8 rd_2g;
145 #if CONFIG_IEEE80211_BAND_5GHZ
146 	u8 rd_5g;
147 #endif
148 	u8 regd; /* value of REGULATION_TXPWR_LMT */
149 };
150 
151 #if CONFIG_IEEE80211_BAND_5GHZ
152 #define CHPLAN_ENT(i2g, i5g, regd) {i2g, i5g, regd}
153 #else
154 #define CHPLAN_ENT(i2g, i5g, regd) {i2g, regd}
155 #endif
156 
157 #define CHPLAN_ENT_NOT_DEFINED CHPLAN_ENT(RTW_RD_2G_NULL, RTW_RD_5G_NULL, TXPWR_LMT_WW)
158 
159 static const struct ch_list_t RTW_ChannelPlan2G[] = {
160 	/* 0, RTW_RD_2G_WORLD */	CH_LIST_ENT(13, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, CLA_2G_12_14_PASSIVE),
161 	/* 1, RTW_RD_2G_ETSI1 */		CH_LIST_ENT(13, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 0),
162 	/* 2, RTW_RD_2G_FCC1 */		CH_LIST_ENT(11, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 0),
163 	/* 3, RTW_RD_2G_MKK1 */		CH_LIST_ENT(14, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 0),
164 	/* 4, RTW_RD_2G_ETSI2 */		CH_LIST_ENT(4, 10, 11, 12, 13, 0),
165 	/* 5, RTW_RD_2G_GLOBAL */	CH_LIST_ENT(14, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, CLA_2G_12_14_PASSIVE),
166 	/* 6, RTW_RD_2G_MKK2 */		CH_LIST_ENT(13, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 0),
167 	/* 7, RTW_RD_2G_FCC2 */		CH_LIST_ENT(13, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 0),
168 	/* 8, RTW_RD_2G_NULL */		CH_LIST_ENT(0, 0),
169 	/* 9, RTW_RD_2G_IC1 */		CH_LIST_ENT(13, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 0),
170 	/* 10, RTW_RD_2G_WORLD1 */	CH_LIST_ENT(11, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 0),
171 	/* 11, RTW_RD_2G_KCC1 */	CH_LIST_ENT(13, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 0),
172 	/* 12, RTW_RD_2G_IC2 */		CH_LIST_ENT(11, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 0),
173 };
174 
175 #if CONFIG_IEEE80211_BAND_5GHZ
176 static const struct ch_list_t RTW_ChannelPlan5G[] = {
177 	/* 0, RTW_RD_5G_NULL */		CH_LIST_ENT(0, 0),
178 	/* 1, RTW_RD_5G_ETSI1 */		CH_LIST_ENT(19, 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140, CLA_5G_B2_DFS | CLA_5G_B3_DFS),
179 	/* 2, RTW_RD_5G_ETSI2 */		CH_LIST_ENT(24, 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140, 149, 153, 157, 161, 165, CLA_5G_B2_DFS | CLA_5G_B3_DFS),
180 	/* 3, RTW_RD_5G_ETSI3 */		CH_LIST_ENT(22, 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 120, 124, 128, 132, 149, 153, 157, 161, 165, CLA_5G_B2_DFS | CLA_5G_B3_DFS),
181 	/* 4, RTW_RD_5G_FCC1 */		CH_LIST_ENT(24, 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140, 149, 153, 157, 161, 165, CLA_5G_B2_DFS | CLA_5G_B3_DFS),
182 	/* 5, RTW_RD_5G_FCC2 */		CH_LIST_ENT(9, 36, 40, 44, 48, 149, 153, 157, 161, 165, 0),
183 	/* 6, RTW_RD_5G_FCC3 */		CH_LIST_ENT(13, 36, 40, 44, 48, 52, 56, 60, 64, 149, 153, 157, 161, 165, CLA_5G_B2_DFS),
184 	/* 7, RTW_RD_5G_FCC4 */		CH_LIST_ENT(12, 36, 40, 44, 48, 52, 56, 60, 64, 149, 153, 157, 161, CLA_5G_B2_DFS),
185 	/* 8, RTW_RD_5G_FCC5 */		CH_LIST_ENT(5, 149, 153, 157, 161, 165, 0),
186 	/* 9, RTW_RD_5G_FCC6 */		CH_LIST_ENT(8, 36, 40, 44, 48, 52, 56, 60, 64, CLA_5G_B2_DFS),
187 	/* 10, RTW_RD_5G_FCC7 */	CH_LIST_ENT(21, 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 132, 136, 140, 149, 153, 157, 161, 165, CLA_5G_B2_DFS | CLA_5G_B3_DFS),
188 	/* 11, RTW_RD_5G_IC1 */		CH_LIST_ENT(21, 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 132, 136, 140, 149, 153, 157, 161, 165, CLA_5G_B2_DFS | CLA_5G_B3_DFS),
189 	/* 12, RTW_RD_5G_KCC1 */	CH_LIST_ENT(19, 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 120, 124, 149, 153, 157, 161, CLA_5G_B2_DFS | CLA_5G_B3_DFS),
190 	/* 13, RTW_RD_5G_MKK1 */	CH_LIST_ENT(19, 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140, CLA_5G_B2_DFS | CLA_5G_B3_DFS),
191 	/* 14, RTW_RD_5G_MKK2 */	CH_LIST_ENT(8, 36, 40, 44, 48, 52, 56, 60, 64, CLA_5G_B2_DFS),
192 	/* 15, RTW_RD_5G_MKK3 */	CH_LIST_ENT(11, 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140, CLA_5G_B3_DFS),
193 	/* 16, RTW_RD_5G_NCC1 */	CH_LIST_ENT(16, 56, 60, 64, 100, 104, 108, 112, 116, 132, 136, 140, 149, 153, 157, 161, 165, CLA_5G_B2_DFS | CLA_5G_B3_DFS),
194 	/* 17, RTW_RD_5G_NCC2 */	CH_LIST_ENT(8, 56, 60, 64, 149, 153, 157, 161, 165, CLA_5G_B2_DFS),
195 	/* 18, RTW_RD_5G_NCC3 */	CH_LIST_ENT(5, 149, 153, 157, 161, 165, 0),
196 	/* 19, RTW_RD_5G_ETSI4 */	CH_LIST_ENT(4, 36, 40, 44, 48, 0),
197 	/* 20, RTW_RD_5G_ETSI5 */	CH_LIST_ENT(21, 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 132, 136, 140, 149, 153, 157, 161, 165, CLA_5G_B2_DFS | CLA_5G_B3_DFS),
198 	/* 21, RTW_RD_5G_FCC8 */	CH_LIST_ENT(4, 149, 153, 157, 161, 0),
199 	/* 22, RTW_RD_5G_ETSI6 */	CH_LIST_ENT(8, 36, 40, 44, 48, 52, 56, 60, 64, CLA_5G_B2_DFS),
200 	/* 23, RTW_RD_5G_ETSI7 */	CH_LIST_ENT(13, 36, 40, 44, 48, 52, 56, 60, 64, 149, 153, 157, 161, 165, CLA_5G_B2_DFS),
201 	/* 24, RTW_RD_5G_ETSI8 */	CH_LIST_ENT(9, 36, 40, 44, 48, 149, 153, 157, 161, 165, 0),
202 	/* 25, RTW_RD_5G_ETSI9 */	CH_LIST_ENT(11, 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140, 0),
203 	/* 26, RTW_RD_5G_ETSI10 */	CH_LIST_ENT(5, 149, 153, 157, 161, 165, 0),
204 	/* 27, RTW_RD_5G_ETSI11 */	CH_LIST_ENT(16, 36, 40, 44, 48, 52, 56, 60, 64, 132, 136, 140, 149, 153, 157, 161, 165, CLA_5G_B2_DFS | CLA_5G_B3_DFS),
205 	/* 28, RTW_RD_5G_NCC4 */	CH_LIST_ENT(17, 52, 56, 60, 64, 100, 104, 108, 112, 116, 132, 136, 140, 149, 153, 157, 161, 165, CLA_5G_B2_DFS | CLA_5G_B3_DFS),
206 	/* 29, RTW_RD_5G_ETSI12 */	CH_LIST_ENT(4, 149, 153, 157, 161, 0),
207 	/* 30, RTW_RD_5G_FCC9 */	CH_LIST_ENT(21, 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 132, 136, 140, 149, 153, 157, 161, 165, CLA_5G_B2_DFS | CLA_5G_B3_DFS),
208 	/* 31, RTW_RD_5G_ETSI13 */	CH_LIST_ENT(16, 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 132, 136, 140, CLA_5G_B2_DFS | CLA_5G_B3_DFS),
209 	/* 32, RTW_RD_5G_FCC10 */	CH_LIST_ENT(20, 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 132, 136, 140, 149, 153, 157, 161, CLA_5G_B2_DFS | CLA_5G_B3_DFS),
210 	/* 33, RTW_RD_5G_MKK4 */	CH_LIST_ENT(4, 36, 40, 44, 48, 0),
211 	/* 34, RTW_RD_5G_ETSI14 */	CH_LIST_ENT(11, 36, 40, 44, 48, 52, 56, 60, 64, 132, 136, 140, CLA_5G_B2_DFS | CLA_5G_B3_DFS),
212 	/* 35, RTW_RD_5G_FCC11 */	CH_LIST_ENT(25, 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140, 144, 149, 153, 157, 161, 165, CLA_5G_B2_DFS | CLA_5G_B3_DFS),
213 	/* 36, RTW_RD_5G_ETSI15 */	CH_LIST_ENT(21, 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 120, 124, 128, 149, 153, 157, 161, 165, CLA_5G_B2_DFS | CLA_5G_B3_DFS),
214 	/* 37, RTW_RD_5G_MKK5 */	CH_LIST_ENT(24, 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140, 149, 153, 157, 161, 165, CLA_5G_B2_PASSIVE | CLA_5G_B3_PASSIVE | CLA_5G_B4_PASSIVE),
215 	/* 38, RTW_RD_5G_ETSI16 */	CH_LIST_ENT(24, 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140, 149, 153, 157, 161, 165, CLA_5G_B2_PASSIVE | CLA_5G_B3_PASSIVE | CLA_5G_B4_PASSIVE),
216 	/* 39, RTW_RD_5G_ETSI17 */	CH_LIST_ENT(24, 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140, 149, 153, 157, 161, 165, CLA_5G_B2_PASSIVE | CLA_5G_B3_PASSIVE),
217 	/* 40, RTW_RD_5G_FCC12 */	CH_LIST_ENT(24, 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140, 149, 153, 157, 161, 165, CLA_5G_B2_PASSIVE | CLA_5G_B3_PASSIVE),
218 	/* 41, RTW_RD_5G_FCC13 */	CH_LIST_ENT(24, 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140, 149, 153, 157, 161, 165, CLA_5G_B1_PASSIVE | CLA_5G_B2_PASSIVE | CLA_5G_B3_PASSIVE),
219 	/* 42, RTW_RD_5G_FCC14 */	CH_LIST_ENT(21, 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 132, 136, 140, 149, 153, 157, 161, 165, CLA_5G_B2_PASSIVE | CLA_5G_B3_PASSIVE),
220 	/* 43, RTW_RD_5G_FCC15 */	CH_LIST_ENT(13, 36, 40, 44, 48, 52, 56, 60, 64, 149, 153, 157, 161, 165, CLA_5G_B2_PASSIVE),
221 	/* 44, RTW_RD_5G_FCC16 */	CH_LIST_ENT(13, 36, 40, 44, 48, 52, 56, 60, 64, 149, 153, 157, 161, 165, CLA_5G_B1_PASSIVE | CLA_5G_B2_PASSIVE),
222 	/* 45, RTW_RD_5G_ETSI18 */	CH_LIST_ENT(9, 36, 40, 44, 48, 149, 153, 157, 161, 165, CLA_5G_B1_PASSIVE | CLA_5G_B4_PASSIVE),
223 	/* 46, RTW_RD_5G_ETSI19 */	CH_LIST_ENT(24, 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140, 149, 153, 157, 161, 165, CLA_5G_B1_PASSIVE | CLA_5G_B2_PASSIVE | CLA_5G_B3_PASSIVE | CLA_5G_B4_PASSIVE),
224 	/* 47, RTW_RD_5G_FCC17 */	CH_LIST_ENT(16, 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 132, 136, 140, CLA_5G_B2_DFS | CLA_5G_B3_DFS),
225 	/* 48, RTW_RD_5G_ETSI20 */	CH_LIST_ENT(9, 52, 56, 60, 64, 149, 153, 157, 161, 165, CLA_5G_B2_DFS),
226 	/* 49, RTW_RD_5G_IC2 */		CH_LIST_ENT(22, 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 132, 136, 140, 144, 149, 153, 157, 161, 165, CLA_5G_B2_DFS | CLA_5G_B3_DFS),
227 	/* 50, RTW_RD_5G_ETSI21 */	CH_LIST_ENT(13, 100, 104, 108, 112, 116, 132, 136, 140, 149, 153, 157, 161, 165, CLA_5G_B3_DFS),
228 	/* 51, RTW_RD_5G_FCC18 */	CH_LIST_ENT(8, 100, 104, 108, 112, 116, 132, 136, 140, CLA_5G_B3_DFS),
229 	/* 52, RTW_RD_5G_WORLD */	CH_LIST_ENT(25, 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140, 144, 149, 153, 157, 161, 165, CLA_5G_B1_PASSIVE | CLA_5G_B2_PASSIVE | CLA_5G_B2_DFS | CLA_5G_B3_PASSIVE | CLA_5G_B3_DFS | CLA_5G_B4_PASSIVE),
230 	/* 53, RTW_RD_5G_CHILE1 */	CH_LIST_ENT(25, 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140, 144, 149, 153, 157, 161, 165, CLA_5G_B2_DFS | CLA_5G_B3_DFS),
231 	/* 54, RTW_RD_5G_ACMA1 */	CH_LIST_ENT(21, 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 132, 136, 140, 149, 153, 157, 161, 165, CLA_5G_B2_DFS | CLA_5G_B3_DFS),
232 	/* 55, RTW_RD_5G_WORLD1 */	CH_LIST_ENT(8, 36, 40, 44, 48, 52, 56, 60, 64, CLA_5G_B1_PASSIVE | CLA_5G_B2_PASSIVE),
233 	/* 56, RTW_RD_5G_CHILE2 */	CH_LIST_ENT(16, 52, 56, 60, 64, 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140, 144, CLA_5G_B2_DFS | CLA_5G_B3_DFS),
234 	/* 57, RTW_RD_5G_KCC2 */	CH_LIST_ENT(24, 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140, 149, 153, 157, 161, 165, CLA_5G_B2_DFS | CLA_5G_B3_DFS),
235 	/* 58, RTW_RD_5G_KCC3 */	CH_LIST_ENT(25, 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140, 144, 149, 153, 157, 161, 165, CLA_5G_B2_DFS | CLA_5G_B3_DFS),
236 	/* 59, RTW_RD_5G_MKK6 */	CH_LIST_ENT(21, 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 120, 124, 128, 149, 153, 157, 161, 165, CLA_5G_B1_PASSIVE | CLA_5G_B2_DFS | CLA_5G_B3_DFS | CLA_5G_B4_DFS),
237 	/* 60, RTW_RD_5G_MKK7 */	CH_LIST_ENT(21, 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 132, 136, 140, 149, 153, 157, 161, 165, CLA_5G_B1_PASSIVE | CLA_5G_B2_DFS | CLA_5G_B3_DFS),
238 	/* 61, RTW_RD_5G_MKK8 */	CH_LIST_ENT(24, 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140, 149, 153, 157, 161, 165, CLA_5G_B2_DFS | CLA_5G_B3_DFS),
239 	/* 62, RTW_RD_5G_MEX1 */	CH_LIST_ENT(21, 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 132, 136, 140, 149, 153, 157, 161, 165, CLA_5G_B2_DFS | CLA_5G_B3_DFS),
240 	/* 63, RTW_RD_5G_ETSI22 */	CH_LIST_ENT(24, 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140, 149, 153, 157, 161, 165, CLA_5G_B1_PASSIVE | CLA_5G_B2_DFS | CLA_5G_B3_DFS | CLA_5G_B4_PASSIVE),
241 	/* 64, RTW_RD_5G_MKK9 */	CH_LIST_ENT(23, 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 120, 124, 128, 136, 140, 149, 153, 157, 161, 165, CLA_5G_B1_PASSIVE | CLA_5G_B2_PASSIVE | CLA_5G_B3_PASSIVE | CLA_5G_B4_PASSIVE),
242 	/* 65, RTW_RD_5G_FCC19 */	CH_LIST_ENT(21, 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 132, 136, 140, 149, 153, 157, 161, 165, CLA_5G_B1_PASSIVE | CLA_5G_B2_PASSIVE | CLA_5G_B3_PASSIVE | CLA_5G_B4_PASSIVE),
243 	/* 66, RTW_RD_5G_FCC20 */	CH_LIST_ENT(13, 36, 40, 44, 48, 52, 56, 60, 64, 149, 153, 157, 161, 165, CLA_5G_B1_PASSIVE | CLA_5G_B2_PASSIVE | CLA_5G_B4_PASSIVE),
244 	/* 67, RTW_RD_5G_FCC21 */	CH_LIST_ENT(23, 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 120, 124, 128, 136, 140, 149, 153, 157, 161, 165, CLA_5G_B1_PASSIVE | CLA_5G_B2_PASSIVE | CLA_5G_B3_PASSIVE | CLA_5G_B4_PASSIVE),
245 	/* 68, RTW_RD_5G_ETSI23 */	CH_LIST_ENT(12, 36, 40, 44, 48, 52, 56, 60, 64, 149, 153, 157, 161, CLA_5G_B2_DFS),
246 	/* 69, RTW_RD_5G_ETSI24 */	CH_LIST_ENT(12, 36, 40, 44, 48, 52, 56, 60, 64, 149, 153, 157, 161, CLA_5G_B2_PASSIVE),
247 	/* 70, RTW_RD_5G_ETSI25 */	CH_LIST_ENT(13, 36, 40, 44, 48, 52, 56, 60, 64, 149, 153, 157, 161, 165, CLA_5G_B2_PASSIVE),
248 	/* 71, RTW_RD_5G_MKK10 */	CH_LIST_ENT(19, 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140, CLA_5G_B2_PASSIVE | CLA_5G_B3_PASSIVE),
249 	/* 72, RTW_RD_5G_ETSI26 */	CH_LIST_ENT(19, 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140, CLA_5G_B2_PASSIVE | CLA_5G_B3_PASSIVE),
250 	/* 73, RTW_RD_5G_MKK11 */	CH_LIST_ENT(20, 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140, 144, CLA_5G_B2_DFS | CLA_5G_B3_DFS),
251 	/* 74, RTW_RD_5G_ETSI27 */	CH_LIST_ENT(17, 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 120, 124, 128, 132, CLA_5G_B2_DFS | CLA_5G_B3_DFS),
252 	/* 75, RTW_RD_5G_ETSI28 */	CH_LIST_ENT(17, 36, 40, 44, 48, 52, 56, 60, 64, 132, 136, 140, 144, 149, 153, 157, 161, 165, CLA_5G_B2_DFS | CLA_5G_B3_DFS),
253 };
254 #endif /* CONFIG_IEEE80211_BAND_5GHZ */
255 
256 static const struct chplan_ent_t RTW_ChannelPlanMap[] = {
257 	/* 0x00 */	CHPLAN_ENT(RTW_RD_2G_ETSI1,		RTW_RD_5G_ETSI27,	TXPWR_LMT_ETSI),
258 	/* 0x01 */	CHPLAN_ENT(RTW_RD_2G_ETSI1,		RTW_RD_5G_ETSI28,	TXPWR_LMT_ETSI),
259 	/* 0x02 */	CHPLAN_ENT(RTW_RD_2G_WORLD1,	RTW_RD_5G_ETSI7,	TXPWR_LMT_ETSI),
260 	/* 0x03 */	CHPLAN_ENT_NOT_DEFINED,
261 	/* 0x04 */	CHPLAN_ENT_NOT_DEFINED,
262 	/* 0x05 */	CHPLAN_ENT_NOT_DEFINED,
263 	/* 0x06 */	CHPLAN_ENT_NOT_DEFINED,
264 	/* 0x07 */	CHPLAN_ENT_NOT_DEFINED,
265 	/* 0x08 */	CHPLAN_ENT_NOT_DEFINED,
266 	/* 0x09 */	CHPLAN_ENT_NOT_DEFINED,
267 	/* 0x0A */	CHPLAN_ENT_NOT_DEFINED,
268 	/* 0x0B */	CHPLAN_ENT_NOT_DEFINED,
269 	/* 0x0C */	CHPLAN_ENT_NOT_DEFINED,
270 	/* 0x0D */	CHPLAN_ENT_NOT_DEFINED,
271 	/* 0x0E */	CHPLAN_ENT_NOT_DEFINED,
272 	/* 0x0F */	CHPLAN_ENT_NOT_DEFINED,
273 	/* 0x10 */	CHPLAN_ENT_NOT_DEFINED,
274 	/* 0x11 */	CHPLAN_ENT_NOT_DEFINED,
275 	/* 0x12 */	CHPLAN_ENT_NOT_DEFINED,
276 	/* 0x13 */	CHPLAN_ENT_NOT_DEFINED,
277 	/* 0x14 */	CHPLAN_ENT_NOT_DEFINED,
278 	/* 0x15 */	CHPLAN_ENT_NOT_DEFINED,
279 	/* 0x16 */	CHPLAN_ENT_NOT_DEFINED,
280 	/* 0x17 */	CHPLAN_ENT_NOT_DEFINED,
281 	/* 0x18 */	CHPLAN_ENT_NOT_DEFINED,
282 	/* 0x19 */	CHPLAN_ENT_NOT_DEFINED,
283 	/* 0x1A */	CHPLAN_ENT_NOT_DEFINED,
284 	/* 0x1B */	CHPLAN_ENT_NOT_DEFINED,
285 	/* 0x1C */	CHPLAN_ENT_NOT_DEFINED,
286 	/* 0x1D */	CHPLAN_ENT_NOT_DEFINED,
287 	/* 0x1E */	CHPLAN_ENT_NOT_DEFINED,
288 	/* 0x1F */	CHPLAN_ENT_NOT_DEFINED,
289 	/* 0x20 */	CHPLAN_ENT(RTW_RD_2G_WORLD,		RTW_RD_5G_NULL,		TXPWR_LMT_WW),
290 	/* 0x21 */	CHPLAN_ENT(RTW_RD_2G_ETSI1,		RTW_RD_5G_NULL,		TXPWR_LMT_ETSI),
291 	/* 0x22 */	CHPLAN_ENT(RTW_RD_2G_FCC1,		RTW_RD_5G_NULL,		TXPWR_LMT_FCC),
292 	/* 0x23 */	CHPLAN_ENT(RTW_RD_2G_MKK1,		RTW_RD_5G_NULL,		TXPWR_LMT_MKK),
293 	/* 0x24 */	CHPLAN_ENT(RTW_RD_2G_ETSI2,		RTW_RD_5G_NULL,		TXPWR_LMT_ETSI),
294 	/* 0x25 */	CHPLAN_ENT(RTW_RD_2G_FCC1,		RTW_RD_5G_FCC1,		TXPWR_LMT_FCC),
295 	/* 0x26 */	CHPLAN_ENT(RTW_RD_2G_WORLD,		RTW_RD_5G_ETSI1,	TXPWR_LMT_ETSI),
296 	/* 0x27 */	CHPLAN_ENT(RTW_RD_2G_MKK1,		RTW_RD_5G_MKK1,		TXPWR_LMT_MKK),
297 	/* 0x28 */	CHPLAN_ENT(RTW_RD_2G_WORLD,		RTW_RD_5G_KCC1,		TXPWR_LMT_KCC),
298 	/* 0x29 */	CHPLAN_ENT(RTW_RD_2G_WORLD,		RTW_RD_5G_FCC2,		TXPWR_LMT_FCC),
299 	/* 0x2A */	CHPLAN_ENT(RTW_RD_2G_FCC2,		RTW_RD_5G_NULL,		TXPWR_LMT_FCC),
300 	/* 0x2B */	CHPLAN_ENT(RTW_RD_2G_IC1,		RTW_RD_5G_IC2,		TXPWR_LMT_IC),
301 	/* 0x2C */	CHPLAN_ENT(RTW_RD_2G_MKK2,		RTW_RD_5G_NULL,		TXPWR_LMT_MKK),
302 	/* 0x2D */	CHPLAN_ENT(RTW_RD_2G_WORLD,		RTW_RD_5G_CHILE1,	TXPWR_LMT_CHILE),
303 	/* 0x2E */	CHPLAN_ENT(RTW_RD_2G_WORLD1,	RTW_RD_5G_WORLD1,	TXPWR_LMT_WW),
304 	/* 0x2F */	CHPLAN_ENT(RTW_RD_2G_WORLD,		RTW_RD_5G_CHILE2,	TXPWR_LMT_CHILE),
305 	/* 0x30 */	CHPLAN_ENT(RTW_RD_2G_WORLD,		RTW_RD_5G_FCC3,		TXPWR_LMT_FCC),
306 	/* 0x31 */	CHPLAN_ENT(RTW_RD_2G_WORLD,		RTW_RD_5G_FCC4,		TXPWR_LMT_FCC),
307 	/* 0x32 */	CHPLAN_ENT(RTW_RD_2G_WORLD,		RTW_RD_5G_FCC5,		TXPWR_LMT_FCC),
308 	/* 0x33 */	CHPLAN_ENT(RTW_RD_2G_WORLD,		RTW_RD_5G_FCC6,		TXPWR_LMT_FCC),
309 	/* 0x34 */	CHPLAN_ENT(RTW_RD_2G_FCC1,		RTW_RD_5G_FCC7,		TXPWR_LMT_FCC),
310 	/* 0x35 */	CHPLAN_ENT(RTW_RD_2G_WORLD,		RTW_RD_5G_ETSI2,	TXPWR_LMT_ETSI),
311 	/* 0x36 */	CHPLAN_ENT(RTW_RD_2G_WORLD,		RTW_RD_5G_ETSI3,	TXPWR_LMT_ETSI),
312 	/* 0x37 */	CHPLAN_ENT(RTW_RD_2G_MKK1,		RTW_RD_5G_MKK2,		TXPWR_LMT_MKK),
313 	/* 0x38 */	CHPLAN_ENT(RTW_RD_2G_MKK1,		RTW_RD_5G_MKK3,		TXPWR_LMT_MKK),
314 	/* 0x39 */	CHPLAN_ENT(RTW_RD_2G_FCC1,		RTW_RD_5G_NCC1,		TXPWR_LMT_FCC),
315 	/* 0x3A */	CHPLAN_ENT(RTW_RD_2G_ETSI1,		RTW_RD_5G_ETSI1,	TXPWR_LMT_ETSI),
316 	/* 0x3B */	CHPLAN_ENT(RTW_RD_2G_ETSI1,		RTW_RD_5G_ACMA1,	TXPWR_LMT_ACMA),
317 	/* 0x3C */	CHPLAN_ENT(RTW_RD_2G_ETSI1,		RTW_RD_5G_ETSI6,	TXPWR_LMT_ETSI),
318 	/* 0x3D */	CHPLAN_ENT(RTW_RD_2G_ETSI1,		RTW_RD_5G_ETSI12,	TXPWR_LMT_ETSI),
319 	/* 0x3E */	CHPLAN_ENT(RTW_RD_2G_KCC1,		RTW_RD_5G_KCC2,		TXPWR_LMT_KCC),
320 	/* 0x3F */	CHPLAN_ENT(RTW_RD_2G_FCC1,		RTW_RD_5G_FCC11,	TXPWR_LMT_FCC),
321 	/* 0x40 */	CHPLAN_ENT(RTW_RD_2G_FCC1,		RTW_RD_5G_NCC2,		TXPWR_LMT_FCC),
322 	/* 0x41 */	CHPLAN_ENT(RTW_RD_2G_GLOBAL,	RTW_RD_5G_NULL,		TXPWR_LMT_WW),
323 	/* 0x42 */	CHPLAN_ENT(RTW_RD_2G_ETSI1,		RTW_RD_5G_ETSI4,	TXPWR_LMT_ETSI),
324 	/* 0x43 */	CHPLAN_ENT(RTW_RD_2G_FCC1,		RTW_RD_5G_FCC2,		TXPWR_LMT_FCC),
325 	/* 0x44 */	CHPLAN_ENT(RTW_RD_2G_FCC1,		RTW_RD_5G_NCC3,		TXPWR_LMT_FCC),
326 	/* 0x45 */	CHPLAN_ENT(RTW_RD_2G_WORLD,		RTW_RD_5G_ACMA1,	TXPWR_LMT_ACMA),
327 	/* 0x46 */	CHPLAN_ENT(RTW_RD_2G_FCC1,		RTW_RD_5G_FCC8,		TXPWR_LMT_FCC),
328 	/* 0x47 */	CHPLAN_ENT(RTW_RD_2G_WORLD,		RTW_RD_5G_ETSI6,	TXPWR_LMT_ETSI),
329 	/* 0x48 */	CHPLAN_ENT(RTW_RD_2G_WORLD,		RTW_RD_5G_ETSI7,	TXPWR_LMT_ETSI),
330 	/* 0x49 */	CHPLAN_ENT(RTW_RD_2G_WORLD,		RTW_RD_5G_ETSI8,	TXPWR_LMT_ETSI),
331 	/* 0x4A */	CHPLAN_ENT(RTW_RD_2G_IC2,		RTW_RD_5G_IC2,		TXPWR_LMT_IC),
332 	/* 0x4B */	CHPLAN_ENT(RTW_RD_2G_KCC1,		RTW_RD_5G_KCC3,		TXPWR_LMT_KCC),
333 	/* 0x4C */	CHPLAN_ENT(RTW_RD_2G_FCC1,		RTW_RD_5G_FCC15,	TXPWR_LMT_FCC),
334 	/* 0x4D */	CHPLAN_ENT(RTW_RD_2G_FCC2,		RTW_RD_5G_MEX1,		TXPWR_LMT_MEXICO),
335 	/* 0x4E */	CHPLAN_ENT(RTW_RD_2G_ETSI1,		RTW_RD_5G_ETSI22,	TXPWR_LMT_ETSI),
336 	/* 0x4F */	CHPLAN_ENT(RTW_RD_2G_NULL,		RTW_RD_5G_MKK9,		TXPWR_LMT_MKK),
337 	/* 0x50 */	CHPLAN_ENT(RTW_RD_2G_WORLD,		RTW_RD_5G_ETSI9,	TXPWR_LMT_ETSI),
338 	/* 0x51 */	CHPLAN_ENT(RTW_RD_2G_WORLD,		RTW_RD_5G_ETSI10,	TXPWR_LMT_ETSI),
339 	/* 0x52 */	CHPLAN_ENT(RTW_RD_2G_WORLD,		RTW_RD_5G_ETSI11,	TXPWR_LMT_ETSI),
340 	/* 0x53 */	CHPLAN_ENT(RTW_RD_2G_FCC1,		RTW_RD_5G_NCC4,		TXPWR_LMT_FCC),
341 	/* 0x54 */	CHPLAN_ENT(RTW_RD_2G_WORLD,		RTW_RD_5G_ETSI12,	TXPWR_LMT_ETSI),
342 	/* 0x55 */	CHPLAN_ENT(RTW_RD_2G_FCC1,		RTW_RD_5G_FCC9,		TXPWR_LMT_FCC),
343 	/* 0x56 */	CHPLAN_ENT(RTW_RD_2G_WORLD,		RTW_RD_5G_ETSI13,	TXPWR_LMT_ETSI),
344 	/* 0x57 */	CHPLAN_ENT(RTW_RD_2G_FCC1,		RTW_RD_5G_FCC10,	TXPWR_LMT_FCC),
345 	/* 0x58 */	CHPLAN_ENT(RTW_RD_2G_MKK2,		RTW_RD_5G_MKK4,		TXPWR_LMT_MKK),
346 	/* 0x59 */	CHPLAN_ENT(RTW_RD_2G_WORLD,		RTW_RD_5G_ETSI14,	TXPWR_LMT_ETSI),
347 	/* 0x5A */	CHPLAN_ENT(RTW_RD_2G_NULL,		RTW_RD_5G_FCC19,	TXPWR_LMT_FCC),
348 	/* 0x5B */	CHPLAN_ENT(RTW_RD_2G_NULL,		RTW_RD_5G_FCC20,	TXPWR_LMT_FCC),
349 	/* 0x5C */	CHPLAN_ENT(RTW_RD_2G_NULL,		RTW_RD_5G_FCC21,	TXPWR_LMT_FCC),
350 	/* 0x5D */	CHPLAN_ENT(RTW_RD_2G_ETSI1,		RTW_RD_5G_ETSI23,	TXPWR_LMT_ETSI),
351 	/* 0x5E */	CHPLAN_ENT(RTW_RD_2G_ETSI1,		RTW_RD_5G_ETSI2,	TXPWR_LMT_ETSI),
352 	/* 0x5F */	CHPLAN_ENT(RTW_RD_2G_MKK2,		RTW_RD_5G_MKK10,	TXPWR_LMT_MKK),
353 	/* 0x60 */	CHPLAN_ENT(RTW_RD_2G_FCC1,		RTW_RD_5G_FCC5,		TXPWR_LMT_FCC),
354 	/* 0x61 */	CHPLAN_ENT(RTW_RD_2G_FCC2,		RTW_RD_5G_FCC7,		TXPWR_LMT_FCC),
355 	/* 0x62 */	CHPLAN_ENT(RTW_RD_2G_FCC2,		RTW_RD_5G_FCC1,		TXPWR_LMT_FCC),
356 	/* 0x63 */	CHPLAN_ENT(RTW_RD_2G_WORLD,		RTW_RD_5G_ETSI15,	TXPWR_LMT_ETSI),
357 	/* 0x64 */	CHPLAN_ENT(RTW_RD_2G_MKK2,		RTW_RD_5G_MKK5,		TXPWR_LMT_MKK),
358 	/* 0x65 */	CHPLAN_ENT(RTW_RD_2G_ETSI1,		RTW_RD_5G_ETSI16,	TXPWR_LMT_ETSI),
359 	/* 0x66 */	CHPLAN_ENT(RTW_RD_2G_FCC1,		RTW_RD_5G_FCC14,	TXPWR_LMT_FCC),
360 	/* 0x67 */	CHPLAN_ENT(RTW_RD_2G_FCC1,		RTW_RD_5G_FCC12,	TXPWR_LMT_FCC),
361 	/* 0x68 */	CHPLAN_ENT(RTW_RD_2G_FCC2,		RTW_RD_5G_FCC14,	TXPWR_LMT_FCC),
362 	/* 0x69 */	CHPLAN_ENT(RTW_RD_2G_FCC2,		RTW_RD_5G_FCC12,	TXPWR_LMT_FCC),
363 	/* 0x6A */	CHPLAN_ENT(RTW_RD_2G_ETSI1,		RTW_RD_5G_ETSI17,	TXPWR_LMT_ETSI),
364 	/* 0x6B */	CHPLAN_ENT(RTW_RD_2G_WORLD,		RTW_RD_5G_FCC16,	TXPWR_LMT_FCC),
365 	/* 0x6C */	CHPLAN_ENT(RTW_RD_2G_WORLD,		RTW_RD_5G_FCC13,	TXPWR_LMT_FCC),
366 	/* 0x6D */	CHPLAN_ENT(RTW_RD_2G_FCC2,		RTW_RD_5G_FCC15,	TXPWR_LMT_FCC),
367 	/* 0x6E */	CHPLAN_ENT(RTW_RD_2G_WORLD,		RTW_RD_5G_FCC12,	TXPWR_LMT_FCC),
368 	/* 0x6F */	CHPLAN_ENT(RTW_RD_2G_NULL,		RTW_RD_5G_ETSI8,	TXPWR_LMT_ETSI),
369 	/* 0x70 */	CHPLAN_ENT(RTW_RD_2G_NULL,		RTW_RD_5G_ETSI18,	TXPWR_LMT_ETSI),
370 	/* 0x71 */	CHPLAN_ENT(RTW_RD_2G_NULL,		RTW_RD_5G_ETSI17,	TXPWR_LMT_ETSI),
371 	/* 0x72 */	CHPLAN_ENT(RTW_RD_2G_NULL,		RTW_RD_5G_ETSI19,	TXPWR_LMT_ETSI),
372 	/* 0x73 */	CHPLAN_ENT(RTW_RD_2G_WORLD,		RTW_RD_5G_FCC7,		TXPWR_LMT_FCC),
373 	/* 0x74 */	CHPLAN_ENT(RTW_RD_2G_FCC2,		RTW_RD_5G_FCC17,	TXPWR_LMT_FCC),
374 	/* 0x75 */	CHPLAN_ENT(RTW_RD_2G_WORLD,		RTW_RD_5G_ETSI20,	TXPWR_LMT_ETSI),
375 	/* 0x76 */	CHPLAN_ENT(RTW_RD_2G_FCC2,		RTW_RD_5G_FCC11,	TXPWR_LMT_FCC),
376 	/* 0x77 */	CHPLAN_ENT(RTW_RD_2G_WORLD,		RTW_RD_5G_ETSI21,	TXPWR_LMT_ETSI),
377 	/* 0x78 */	CHPLAN_ENT(RTW_RD_2G_FCC1,		RTW_RD_5G_FCC18,	TXPWR_LMT_FCC),
378 	/* 0x79 */	CHPLAN_ENT(RTW_RD_2G_MKK2,		RTW_RD_5G_MKK1,		TXPWR_LMT_MKK),
379 	/* 0x7A */	CHPLAN_ENT(RTW_RD_2G_ETSI1,		RTW_RD_5G_ETSI25, 	TXPWR_LMT_ETSI),
380 	/* 0x7B */	CHPLAN_ENT(RTW_RD_2G_ETSI1,		RTW_RD_5G_ETSI24,	TXPWR_LMT_ETSI),
381 	/* 0x7C */	CHPLAN_ENT(RTW_RD_2G_ETSI1,		RTW_RD_5G_ETSI26,	TXPWR_LMT_ETSI),
382 	/* 0x7D */	CHPLAN_ENT(RTW_RD_2G_MKK1,		RTW_RD_5G_MKK11,	TXPWR_LMT_MKK),
383 	/* 0x7E */	CHPLAN_ENT(RTW_RD_2G_MKK2,		RTW_RD_5G_MKK11,	TXPWR_LMT_MKK),
384 	/* 0x7F */	CHPLAN_ENT(RTW_RD_2G_WORLD,		RTW_RD_5G_FCC1,		TXPWR_LMT_FCC),		/* Realtek Define */
385 };
386 
387 const int RTW_ChannelPlanMap_size = sizeof(RTW_ChannelPlanMap) / sizeof(RTW_ChannelPlanMap[0]);
388 
rtw_chplan_get_default_regd(u8 id)389 u8 rtw_chplan_get_default_regd(u8 id)
390 {
391 	return RTW_ChannelPlanMap[id].regd;
392 }
393 
rtw_chplan_is_empty(u8 id)394 bool rtw_chplan_is_empty(u8 id)
395 {
396 	const struct chplan_ent_t *chplan_map = &RTW_ChannelPlanMap[id];
397 
398 	if (chplan_map->rd_2g == RTW_RD_2G_NULL
399 		#if CONFIG_IEEE80211_BAND_5GHZ
400 		&& chplan_map->rd_5g == RTW_RD_5G_NULL
401 		#endif
402 	)
403 		return _TRUE;
404 
405 	return _FALSE;
406 }
407 
rtw_is_channel_plan_valid(u8 id)408 bool rtw_is_channel_plan_valid(u8 id)
409 {
410 	return id < RTW_ChannelPlanMap_size && !rtw_chplan_is_empty(id);
411 }
412 
rtw_regsty_is_excl_chs(struct registry_priv * regsty,u8 ch)413 bool rtw_regsty_is_excl_chs(struct registry_priv *regsty, u8 ch)
414 {
415 	int i;
416 
417 	for (i = 0; i < MAX_CHANNEL_NUM; i++) {
418 		if (regsty->excl_chs[i] == 0)
419 			break;
420 		if (regsty->excl_chs[i] == ch)
421 			return _TRUE;
422 	}
423 	return _FALSE;
424 }
425 
init_channel_set(_adapter * padapter,u8 ChannelPlan,RT_CHANNEL_INFO * channel_set)426 u8 init_channel_set(_adapter *padapter, u8 ChannelPlan, RT_CHANNEL_INFO *channel_set)
427 {
428 	struct rf_ctl_t *rfctl = adapter_to_rfctl(padapter);
429 	struct registry_priv *regsty = adapter_to_regsty(padapter);
430 	u8 index, chanset_size = 0;
431 	u8 b5GBand = _FALSE, b2_4GBand = _FALSE;
432 	u8 rd_2g = 0, rd_5g = 0;
433 	u8 ch, attrib;
434 #ifdef CONFIG_DFS_MASTER
435 	int i;
436 #endif
437 
438 	if (!rtw_is_channel_plan_valid(ChannelPlan)) {
439 		RTW_ERR("ChannelPlan ID 0x%02X error !!!!!\n", ChannelPlan);
440 		return chanset_size;
441 	}
442 
443 	_rtw_memset(channel_set, 0, sizeof(RT_CHANNEL_INFO) * MAX_CHANNEL_NUM);
444 
445 	if (IsSupported24G(regsty->wireless_mode) && hal_chk_band_cap(padapter, BAND_CAP_2G))
446 		b2_4GBand = _TRUE;
447 
448 	if (is_supported_5g(regsty->wireless_mode) && hal_chk_band_cap(padapter, BAND_CAP_5G))
449 		b5GBand = _TRUE;
450 
451 	if (b2_4GBand == _FALSE && b5GBand == _FALSE) {
452 		RTW_WARN("HW band_cap has no intersection with SW wireless_mode setting\n");
453 		return chanset_size;
454 	}
455 
456 	if (b2_4GBand) {
457 		rd_2g = RTW_ChannelPlanMap[ChannelPlan].rd_2g;
458 		attrib = CH_LIST_ATTRIB(RTW_ChannelPlan2G[rd_2g]);
459 
460 		for (index = 0; index < CH_LIST_LEN(RTW_ChannelPlan2G[rd_2g]); index++) {
461 			ch = CH_LIST_CH(RTW_ChannelPlan2G[rd_2g], index);
462 			if (rtw_regsty_is_excl_chs(regsty, ch) == _TRUE)
463 				continue;
464 
465 			if (chanset_size >= MAX_CHANNEL_NUM) {
466 				RTW_WARN("chset size can't exceed MAX_CHANNEL_NUM(%u)\n", MAX_CHANNEL_NUM);
467 				break;
468 			}
469 
470 			channel_set[chanset_size].ChannelNum = ch;
471 
472 			if (ch >= 12 && ch <= 14 && (attrib & CLA_2G_12_14_PASSIVE))
473 				channel_set[chanset_size].ScanType = SCAN_PASSIVE;
474 			else
475 				channel_set[chanset_size].ScanType = SCAN_ACTIVE;
476 
477 			if (channel_set[chanset_size].ScanType == SCAN_PASSIVE) {
478 				if (rfctl->country_ent || ch <= 11)
479 					RTW_INFO("ch%u is PASSIVE\n", ch);
480 			}
481 
482 			chanset_size++;
483 		}
484 	}
485 
486 #if CONFIG_IEEE80211_BAND_5GHZ
487 	if (b5GBand) {
488 		bool dfs;
489 
490 		rd_5g = RTW_ChannelPlanMap[ChannelPlan].rd_5g;
491 		attrib = CH_LIST_ATTRIB(RTW_ChannelPlan5G[rd_5g]);
492 
493 		for (index = 0; index < CH_LIST_LEN(RTW_ChannelPlan5G[rd_5g]); index++) {
494 			ch = CH_LIST_CH(RTW_ChannelPlan5G[rd_5g], index);
495 			if (rtw_regsty_is_excl_chs(regsty, ch) == _TRUE)
496 				continue;
497 			dfs = (rtw_is_5g_band2(ch) && (attrib & CLA_5G_B2_DFS))
498 				|| (rtw_is_5g_band3(ch) && (attrib & CLA_5G_B3_DFS))
499 				|| (rtw_is_5g_band4(ch) && (attrib & CLA_5G_B4_DFS));
500 			#if !CONFIG_DFS
501 			if (dfs)
502 				continue;
503 			#endif
504 
505 			if (chanset_size >= MAX_CHANNEL_NUM) {
506 				RTW_WARN("chset size can't exceed MAX_CHANNEL_NUM(%u)\n", MAX_CHANNEL_NUM);
507 				break;
508 			}
509 
510 			channel_set[chanset_size].ChannelNum = ch;
511 
512 			if ((rtw_is_5g_band1(ch) && (attrib & CLA_5G_B1_PASSIVE)) /* band1 passive */
513 				|| (rtw_is_5g_band2(ch) && (attrib & CLA_5G_B2_PASSIVE)) /* band2 passive */
514 				|| (rtw_is_5g_band3(ch) && (attrib & CLA_5G_B3_PASSIVE)) /* band3 passive */
515 				|| (rtw_is_5g_band4(ch) && (attrib & CLA_5G_B4_PASSIVE)) /* band4 passive */
516 			)
517 				channel_set[chanset_size].ScanType = SCAN_PASSIVE;
518 			else
519 				channel_set[chanset_size].ScanType = SCAN_ACTIVE;
520 
521 			channel_set[chanset_size].dfs = dfs;
522 
523 			if (channel_set[chanset_size].ScanType == SCAN_PASSIVE) {
524 				if (rfctl->country_ent || channel_set[chanset_size].dfs)
525 					RTW_INFO("ch%u is PASSIVE%s\n", ch, dfs ? " DFS" : "");
526 			}
527 
528 			chanset_size++;
529 		}
530 	}
531 
532 	#ifdef CONFIG_DFS_MASTER
533 	for (i = 0; i < chanset_size; i++)
534 		channel_set[i].non_ocp_end_time = rtw_get_current_time();
535 	#endif
536 #endif /* CONFIG_IEEE80211_BAND_5GHZ */
537 
538 	if (chanset_size)
539 		RTW_INFO(FUNC_ADPT_FMT" ChannelPlan ID:0x%02x, ch num:%d\n"
540 			, FUNC_ADPT_ARG(padapter), ChannelPlan, chanset_size);
541 	else
542 		RTW_WARN(FUNC_ADPT_FMT" ChannelPlan ID:0x%02x, final chset has no channel\n"
543 			, FUNC_ADPT_ARG(padapter), ChannelPlan);
544 
545 	return chanset_size;
546 }
547 
rtw_chset_is_dfs_range(struct _RT_CHANNEL_INFO * chset,u32 hi,u32 lo)548 bool rtw_chset_is_dfs_range(struct _RT_CHANNEL_INFO *chset, u32 hi, u32 lo)
549 {
550 	u8 hi_ch = rtw_freq2ch(hi);
551 	u8 lo_ch = rtw_freq2ch(lo);
552 	int i;
553 
554 	for (i = 0; i < MAX_CHANNEL_NUM && chset[i].ChannelNum != 0; i++){
555 		if (!chset[i].dfs)
556 			continue;
557 		if (hi_ch > chset[i].ChannelNum && lo_ch < chset[i].ChannelNum)
558 			return 1;
559 	}
560 
561 	return 0;
562 }
563 
rtw_chset_is_dfs_ch(struct _RT_CHANNEL_INFO * chset,u8 ch)564 bool rtw_chset_is_dfs_ch(struct _RT_CHANNEL_INFO *chset, u8 ch)
565 {
566 	int i;
567 
568 	for (i = 0; i < MAX_CHANNEL_NUM && chset[i].ChannelNum != 0; i++){
569 		if (chset[i].ChannelNum == ch)
570 			return chset[i].dfs;
571 	}
572 
573 	return 0;
574 }
575 
rtw_chset_is_dfs_chbw(struct _RT_CHANNEL_INFO * chset,u8 ch,u8 bw,u8 offset)576 bool rtw_chset_is_dfs_chbw(struct _RT_CHANNEL_INFO *chset, u8 ch, u8 bw, u8 offset)
577 {
578 	u32 hi, lo;
579 
580 	if (!rtw_chbw_to_freq_range(ch, bw, offset, &hi, &lo))
581 		return 0;
582 
583 	return rtw_chset_is_dfs_range(chset, hi, lo);
584 }
585 
rtw_process_beacon_hint(_adapter * adapter,WLAN_BSSID_EX * bss)586 void rtw_process_beacon_hint(_adapter *adapter, WLAN_BSSID_EX *bss)
587 {
588 #ifndef RTW_CHPLAN_BEACON_HINT_NON_WORLD_WIDE
589 #define RTW_CHPLAN_BEACON_HINT_NON_WORLD_WIDE 0
590 #endif
591 
592 #ifndef RTW_CHPLAN_BEACON_HINT_ON_2G_CH_1_11
593 #define RTW_CHPLAN_BEACON_HINT_ON_2G_CH_1_11 0
594 #endif
595 
596 #ifndef RTW_CHPLAN_BEACON_HINT_ON_DFS_CH
597 #define RTW_CHPLAN_BEACON_HINT_ON_DFS_CH 0
598 #endif
599 
600 	struct rf_ctl_t *rfctl = adapter_to_rfctl(adapter);
601 	RT_CHANNEL_INFO *chset = rfctl->channel_set;
602 	u8 ch = bss->Configuration.DSConfig;
603 	int chset_idx = rtw_chset_search_ch(chset, ch);
604 
605 	if (chset_idx < 0)
606 		return;
607 
608 	if (chset[chset_idx].ScanType == SCAN_PASSIVE
609 		&& (RTW_CHPLAN_BEACON_HINT_NON_WORLD_WIDE || !rfctl->country_ent)
610 		&& (RTW_CHPLAN_BEACON_HINT_ON_2G_CH_1_11 || !(ch <= 11))
611 		&& (RTW_CHPLAN_BEACON_HINT_ON_DFS_CH || !chset[chset_idx].dfs)
612 	) {
613 		RTW_INFO("%s: change ch:%d to active\n", __func__, ch);
614 		chset[chset_idx].ScanType = SCAN_ACTIVE;
615 		init_op_class_ch_bmp(adapter, chset, rfctl->cur_spt_op_class_ch_bmp);
616 	}
617 }
618 
619 #ifdef CONFIG_80211AC_VHT
620 #define COUNTRY_CHPLAN_ASSIGN_EN_11AC(_val) , .en_11ac = (_val)
621 #else
622 #define COUNTRY_CHPLAN_ASSIGN_EN_11AC(_val)
623 #endif
624 
625 #if RTW_DEF_MODULE_REGULATORY_CERT
626 #define COUNTRY_CHPLAN_ASSIGN_DEF_MODULE_FLAGS(_val) , .def_module_flags = (_val)
627 #else
628 #define COUNTRY_CHPLAN_ASSIGN_DEF_MODULE_FLAGS(_val)
629 #endif
630 
631 /* has def_module_flags specified, used by common map and HAL dfference map */
632 #define COUNTRY_CHPLAN_ENT(_alpha2, _chplan, _en_11ac, _def_module_flags) \
633 	{.alpha2 = (_alpha2), .chplan = (_chplan) \
634 		COUNTRY_CHPLAN_ASSIGN_EN_11AC(_en_11ac) \
635 		COUNTRY_CHPLAN_ASSIGN_DEF_MODULE_FLAGS(_def_module_flags) \
636 	}
637 
638 #ifdef CONFIG_CUSTOMIZED_COUNTRY_CHPLAN_MAP
639 
640 #include "../platform/custom_country_chplan.h"
641 
642 #elif RTW_DEF_MODULE_REGULATORY_CERT
643 
644 /* leave def_module_flags empty, def_module_flags check is done on country_chplan_map */
645 #if (RTW_DEF_MODULE_REGULATORY_CERT & RTW_MODULE_RTL8821AE_HMC_M2) /* 2013 certify */
646 static const struct country_chplan RTL8821AE_HMC_M2_country_chplan_exc_map[] = {
647 	COUNTRY_CHPLAN_ENT("CA", 0x34, 1, 0), /* Canada */
648 	COUNTRY_CHPLAN_ENT("CL", 0x30, 1, 0), /* Chile */
649 	COUNTRY_CHPLAN_ENT("CN", 0x51, 1, 0), /* China */
650 	COUNTRY_CHPLAN_ENT("CO", 0x34, 1, 0), /* Colombia */
651 	COUNTRY_CHPLAN_ENT("CR", 0x34, 1, 0), /* Costa Rica */
652 	COUNTRY_CHPLAN_ENT("DO", 0x34, 1, 0), /* Dominican Republic */
653 	COUNTRY_CHPLAN_ENT("EC", 0x34, 1, 0), /* Ecuador */
654 	COUNTRY_CHPLAN_ENT("GT", 0x34, 1, 0), /* Guatemala */
655 	COUNTRY_CHPLAN_ENT("ID", 0x3D, 0, 0), /* Indonesia */
656 	COUNTRY_CHPLAN_ENT("KR", 0x28, 1, 0), /* South Korea */
657 	COUNTRY_CHPLAN_ENT("MX", 0x34, 1, 0), /* Mexico */
658 	COUNTRY_CHPLAN_ENT("MY", 0x47, 1, 0), /* Malaysia */
659 	COUNTRY_CHPLAN_ENT("NI", 0x34, 1, 0), /* Nicaragua */
660 	COUNTRY_CHPLAN_ENT("PA", 0x34, 1, 0), /* Panama */
661 	COUNTRY_CHPLAN_ENT("PE", 0x34, 1, 0), /* Peru */
662 	COUNTRY_CHPLAN_ENT("PR", 0x34, 1, 0), /* Puerto Rico */
663 	COUNTRY_CHPLAN_ENT("PY", 0x34, 1, 0), /* Paraguay */
664 	COUNTRY_CHPLAN_ENT("TW", 0x39, 1, 0), /* Taiwan */
665 	COUNTRY_CHPLAN_ENT("UA", 0x36, 0, 0), /* Ukraine */
666 	COUNTRY_CHPLAN_ENT("US", 0x34, 1, 0), /* United States of America (USA) */
667 };
668 #endif
669 
670 #if (RTW_DEF_MODULE_REGULATORY_CERT & RTW_MODULE_RTL8821AU) /* 2014 certify */
671 static const struct country_chplan RTL8821AU_country_chplan_exc_map[] = {
672 	COUNTRY_CHPLAN_ENT("CA", 0x34, 1, 0), /* Canada */
673 	COUNTRY_CHPLAN_ENT("ID", 0x3D, 0, 0), /* Indonesia */
674 	COUNTRY_CHPLAN_ENT("KR", 0x28, 1, 0), /* South Korea */
675 	COUNTRY_CHPLAN_ENT("RU", 0x59, 0, 0), /* Russia(fac/gost), Kaliningrad */
676 	COUNTRY_CHPLAN_ENT("TW", 0x39, 1, 0), /* Taiwan */
677 	COUNTRY_CHPLAN_ENT("UA", 0x36, 0, 0), /* Ukraine */
678 	COUNTRY_CHPLAN_ENT("US", 0x34, 1, 0), /* United States of America (USA) */
679 };
680 #endif
681 
682 #if (RTW_DEF_MODULE_REGULATORY_CERT & RTW_MODULE_RTL8812AENF_NGFF) /* 2014 certify */
683 static const struct country_chplan RTL8812AENF_NGFF_country_chplan_exc_map[] = {
684 	COUNTRY_CHPLAN_ENT("TW", 0x39, 1, 0), /* Taiwan */
685 	COUNTRY_CHPLAN_ENT("US", 0x34, 1, 0), /* United States of America (USA) */
686 };
687 #endif
688 
689 #if (RTW_DEF_MODULE_REGULATORY_CERT & RTW_MODULE_RTL8812AEBT_HMC) /* 2013 certify */
690 static const struct country_chplan RTL8812AEBT_HMC_country_chplan_exc_map[] = {
691 	COUNTRY_CHPLAN_ENT("CA", 0x34, 1, 0), /* Canada */
692 	COUNTRY_CHPLAN_ENT("KR", 0x28, 1, 0), /* South Korea */
693 	COUNTRY_CHPLAN_ENT("RU", 0x59, 0, 0), /* Russia(fac/gost), Kaliningrad */
694 	COUNTRY_CHPLAN_ENT("TW", 0x39, 1, 0), /* Taiwan */
695 	COUNTRY_CHPLAN_ENT("UA", 0x36, 0, 0), /* Ukraine */
696 	COUNTRY_CHPLAN_ENT("US", 0x34, 1, 0), /* United States of America (USA) */
697 };
698 #endif
699 
700 #if (RTW_DEF_MODULE_REGULATORY_CERT & RTW_MODULE_RTL8188EE_HMC_M2) /* 2012 certify */
701 static const struct country_chplan RTL8188EE_HMC_M2_country_chplan_exc_map[] = {
702 	COUNTRY_CHPLAN_ENT("AW", 0x34, 1, 0), /* Aruba */
703 	COUNTRY_CHPLAN_ENT("BB", 0x34, 1, 0), /* Barbados */
704 	COUNTRY_CHPLAN_ENT("CA", 0x20, 1, 0), /* Canada */
705 	COUNTRY_CHPLAN_ENT("CO", 0x34, 1, 0), /* Colombia */
706 	COUNTRY_CHPLAN_ENT("CR", 0x34, 1, 0), /* Costa Rica */
707 	COUNTRY_CHPLAN_ENT("DO", 0x34, 1, 0), /* Dominican Republic */
708 	COUNTRY_CHPLAN_ENT("EC", 0x34, 1, 0), /* Ecuador */
709 	COUNTRY_CHPLAN_ENT("GT", 0x34, 1, 0), /* Guatemala */
710 	COUNTRY_CHPLAN_ENT("HT", 0x34, 1, 0), /* Haiti */
711 	COUNTRY_CHPLAN_ENT("KR", 0x28, 1, 0), /* South Korea */
712 	COUNTRY_CHPLAN_ENT("MX", 0x34, 1, 0), /* Mexico */
713 	COUNTRY_CHPLAN_ENT("NI", 0x34, 1, 0), /* Nicaragua */
714 	COUNTRY_CHPLAN_ENT("PA", 0x34, 1, 0), /* Panama */
715 	COUNTRY_CHPLAN_ENT("PE", 0x34, 1, 0), /* Peru */
716 	COUNTRY_CHPLAN_ENT("PR", 0x34, 1, 0), /* Puerto Rico */
717 	COUNTRY_CHPLAN_ENT("PY", 0x34, 1, 0), /* Paraguay */
718 	COUNTRY_CHPLAN_ENT("SC", 0x34, 1, 0), /* Seychelles */
719 	COUNTRY_CHPLAN_ENT("TW", 0x39, 1, 0), /* Taiwan */
720 	COUNTRY_CHPLAN_ENT("US", 0x34, 1, 0), /* United States of America (USA) */
721 	COUNTRY_CHPLAN_ENT("VC", 0x34, 1, 0), /* Saint Vincent and the Grenadines */
722 };
723 #endif
724 
725 #if (RTW_DEF_MODULE_REGULATORY_CERT & RTW_MODULE_RTL8723BE_HMC_M2) /* 2013 certify */
726 static const struct country_chplan RTL8723BE_HMC_M2_country_chplan_exc_map[] = {
727 	COUNTRY_CHPLAN_ENT("AW", 0x34, 1, 0), /* Aruba */
728 	COUNTRY_CHPLAN_ENT("BS", 0x34, 1, 0), /* Bahamas */
729 	COUNTRY_CHPLAN_ENT("CA", 0x20, 1, 0), /* Canada */
730 	COUNTRY_CHPLAN_ENT("CO", 0x34, 1, 0), /* Colombia */
731 	COUNTRY_CHPLAN_ENT("CR", 0x34, 1, 0), /* Costa Rica */
732 	COUNTRY_CHPLAN_ENT("DO", 0x34, 1, 0), /* Dominican Republic */
733 	COUNTRY_CHPLAN_ENT("EC", 0x34, 1, 0), /* Ecuador */
734 	COUNTRY_CHPLAN_ENT("GT", 0x34, 1, 0), /* Guatemala */
735 	COUNTRY_CHPLAN_ENT("KR", 0x28, 1, 0), /* South Korea */
736 	COUNTRY_CHPLAN_ENT("MX", 0x34, 1, 0), /* Mexico */
737 	COUNTRY_CHPLAN_ENT("NI", 0x34, 1, 0), /* Nicaragua */
738 	COUNTRY_CHPLAN_ENT("PA", 0x34, 1, 0), /* Panama */
739 	COUNTRY_CHPLAN_ENT("PE", 0x34, 1, 0), /* Peru */
740 	COUNTRY_CHPLAN_ENT("PR", 0x34, 1, 0), /* Puerto Rico */
741 	COUNTRY_CHPLAN_ENT("PY", 0x34, 1, 0), /* Paraguay */
742 	COUNTRY_CHPLAN_ENT("TW", 0x39, 1, 0), /* Taiwan */
743 	COUNTRY_CHPLAN_ENT("US", 0x34, 1, 0), /* United States of America (USA) */
744 };
745 #endif
746 
747 #if (RTW_DEF_MODULE_REGULATORY_CERT & RTW_MODULE_RTL8723BS_NGFF1216) /* 2014 certify */
748 static const struct country_chplan RTL8723BS_NGFF1216_country_chplan_exc_map[] = {
749 	COUNTRY_CHPLAN_ENT("BB", 0x34, 1, 0), /* Barbados */
750 	COUNTRY_CHPLAN_ENT("CA", 0x20, 1, 0), /* Canada */
751 	COUNTRY_CHPLAN_ENT("CO", 0x34, 1, 0), /* Colombia */
752 	COUNTRY_CHPLAN_ENT("CR", 0x34, 1, 0), /* Costa Rica */
753 	COUNTRY_CHPLAN_ENT("DO", 0x34, 1, 0), /* Dominican Republic */
754 	COUNTRY_CHPLAN_ENT("EC", 0x34, 1, 0), /* Ecuador */
755 	COUNTRY_CHPLAN_ENT("GT", 0x34, 1, 0), /* Guatemala */
756 	COUNTRY_CHPLAN_ENT("HT", 0x34, 1, 0), /* Haiti */
757 	COUNTRY_CHPLAN_ENT("KR", 0x28, 1, 0), /* South Korea */
758 	COUNTRY_CHPLAN_ENT("MX", 0x34, 1, 0), /* Mexico */
759 	COUNTRY_CHPLAN_ENT("NI", 0x34, 1, 0), /* Nicaragua */
760 	COUNTRY_CHPLAN_ENT("PA", 0x34, 1, 0), /* Panama */
761 	COUNTRY_CHPLAN_ENT("PE", 0x34, 1, 0), /* Peru */
762 	COUNTRY_CHPLAN_ENT("PR", 0x34, 1, 0), /* Puerto Rico */
763 	COUNTRY_CHPLAN_ENT("PY", 0x34, 1, 0), /* Paraguay */
764 	COUNTRY_CHPLAN_ENT("TW", 0x39, 1, 0), /* Taiwan */
765 	COUNTRY_CHPLAN_ENT("US", 0x34, 1, 0), /* United States of America (USA) */
766 };
767 #endif
768 
769 #if (RTW_DEF_MODULE_REGULATORY_CERT & RTW_MODULE_RTL8192EEBT_HMC_M2) /* 2013 certify */
770 static const struct country_chplan RTL8192EEBT_HMC_M2_country_chplan_exc_map[] = {
771 	COUNTRY_CHPLAN_ENT("AW", 0x34, 1, 0), /* Aruba */
772 	COUNTRY_CHPLAN_ENT("CA", 0x20, 1, 0), /* Canada */
773 	COUNTRY_CHPLAN_ENT("CO", 0x34, 1, 0), /* Colombia */
774 	COUNTRY_CHPLAN_ENT("CR", 0x34, 1, 0), /* Costa Rica */
775 	COUNTRY_CHPLAN_ENT("DO", 0x34, 1, 0), /* Dominican Republic */
776 	COUNTRY_CHPLAN_ENT("EC", 0x34, 1, 0), /* Ecuador */
777 	COUNTRY_CHPLAN_ENT("GT", 0x34, 1, 0), /* Guatemala */
778 	COUNTRY_CHPLAN_ENT("KR", 0x28, 1, 0), /* South Korea */
779 	COUNTRY_CHPLAN_ENT("MX", 0x34, 1, 0), /* Mexico */
780 	COUNTRY_CHPLAN_ENT("NI", 0x34, 1, 0), /* Nicaragua */
781 	COUNTRY_CHPLAN_ENT("PA", 0x34, 1, 0), /* Panama */
782 	COUNTRY_CHPLAN_ENT("PE", 0x34, 1, 0), /* Peru */
783 	COUNTRY_CHPLAN_ENT("PR", 0x34, 1, 0), /* Puerto Rico */
784 	COUNTRY_CHPLAN_ENT("PY", 0x34, 1, 0), /* Paraguay */
785 	COUNTRY_CHPLAN_ENT("SC", 0x34, 1, 0), /* Seychelles */
786 	COUNTRY_CHPLAN_ENT("ST", 0x34, 1, 0), /* Sao Tome and Principe */
787 	COUNTRY_CHPLAN_ENT("TW", 0x39, 1, 0), /* Taiwan */
788 	COUNTRY_CHPLAN_ENT("US", 0x34, 1, 0), /* United States of America (USA) */
789 };
790 #endif
791 
792 #if (RTW_DEF_MODULE_REGULATORY_CERT & RTW_MODULE_RTL8723DE_NGFF1630) /* 2016 certify */
793 static const struct country_chplan RTL8723DE_NGFF1630_country_chplan_exc_map[] = {
794 	COUNTRY_CHPLAN_ENT("CA", 0x2A, 1, 0), /* Canada */
795 	COUNTRY_CHPLAN_ENT("KR", 0x28, 1, 0), /* South Korea */
796 	COUNTRY_CHPLAN_ENT("MX", 0x34, 1, 0), /* Mexico */
797 };
798 #endif
799 
800 #if (RTW_DEF_MODULE_REGULATORY_CERT & RTW_MODULE_RTL8822BE) /* 2016 certify */
801 static const struct country_chplan RTL8822BE_country_chplan_exc_map[] = {
802 	COUNTRY_CHPLAN_ENT("ID", 0x3D, 0, 0), /* Indonesia */
803 	COUNTRY_CHPLAN_ENT("KR", 0x28, 1, 0), /* South Korea */
804 };
805 #endif
806 
807 #if (RTW_DEF_MODULE_REGULATORY_CERT & RTW_MODULE_RTL8821CE) /* 2016 certify */
808 static const struct country_chplan RTL8821CE_country_chplan_exc_map[] = {
809 	COUNTRY_CHPLAN_ENT("ID", 0x3D, 0, 0), /* Indonesia */
810 	COUNTRY_CHPLAN_ENT("KR", 0x28, 1, 0), /* South Korea */
811 };
812 #endif
813 
814 #if (RTW_DEF_MODULE_REGULATORY_CERT & RTW_MODULE_RTL8822CE) /* 2018 certify */
815 static const struct country_chplan RTL8822CE_country_chplan_exc_map[] = {
816 };
817 #endif
818 
819 /**
820  * rtw_def_module_get_chplan_from_country -
821  * @country_code: string of country code
822  * @return:
823  * Return NULL for case referring to common map
824  */
rtw_def_module_get_chplan_from_country(const char * country_code)825 static const struct country_chplan *rtw_def_module_get_chplan_from_country(const char *country_code)
826 {
827 	const struct country_chplan *ent = NULL;
828 	const struct country_chplan *hal_map = NULL;
829 	u16 hal_map_sz = 0;
830 	int i;
831 
832 	/* TODO: runtime selection for multi driver */
833 #if (RTW_DEF_MODULE_REGULATORY_CERT == RTW_MODULE_RTL8821AE_HMC_M2)
834 	hal_map = RTL8821AE_HMC_M2_country_chplan_exc_map;
835 	hal_map_sz = sizeof(RTL8821AE_HMC_M2_country_chplan_exc_map) / sizeof(struct country_chplan);
836 #elif (RTW_DEF_MODULE_REGULATORY_CERT == RTW_MODULE_RTL8821AU)
837 	hal_map = RTL8821AU_country_chplan_exc_map;
838 	hal_map_sz = sizeof(RTL8821AU_country_chplan_exc_map) / sizeof(struct country_chplan);
839 #elif (RTW_DEF_MODULE_REGULATORY_CERT == RTW_MODULE_RTL8812AENF_NGFF)
840 	hal_map = RTL8812AENF_NGFF_country_chplan_exc_map;
841 	hal_map_sz = sizeof(RTL8812AENF_NGFF_country_chplan_exc_map) / sizeof(struct country_chplan);
842 #elif (RTW_DEF_MODULE_REGULATORY_CERT == RTW_MODULE_RTL8812AEBT_HMC)
843 	hal_map = RTL8812AEBT_HMC_country_chplan_exc_map;
844 	hal_map_sz = sizeof(RTL8812AEBT_HMC_country_chplan_exc_map) / sizeof(struct country_chplan);
845 #elif (RTW_DEF_MODULE_REGULATORY_CERT == RTW_MODULE_RTL8188EE_HMC_M2)
846 	hal_map = RTL8188EE_HMC_M2_country_chplan_exc_map;
847 	hal_map_sz = sizeof(RTL8188EE_HMC_M2_country_chplan_exc_map) / sizeof(struct country_chplan);
848 #elif (RTW_DEF_MODULE_REGULATORY_CERT == RTW_MODULE_RTL8723BE_HMC_M2)
849 	hal_map = RTL8723BE_HMC_M2_country_chplan_exc_map;
850 	hal_map_sz = sizeof(RTL8723BE_HMC_M2_country_chplan_exc_map) / sizeof(struct country_chplan);
851 #elif (RTW_DEF_MODULE_REGULATORY_CERT == RTW_MODULE_RTL8723BS_NGFF1216)
852 	hal_map = RTL8723BS_NGFF1216_country_chplan_exc_map;
853 	hal_map_sz = sizeof(RTL8723BS_NGFF1216_country_chplan_exc_map) / sizeof(struct country_chplan);
854 #elif (RTW_DEF_MODULE_REGULATORY_CERT == RTW_MODULE_RTL8192EEBT_HMC_M2)
855 	hal_map = RTL8192EEBT_HMC_M2_country_chplan_exc_map;
856 	hal_map_sz = sizeof(RTL8192EEBT_HMC_M2_country_chplan_exc_map) / sizeof(struct country_chplan);
857 #elif (RTW_DEF_MODULE_REGULATORY_CERT == RTW_MODULE_RTL8723DE_NGFF1630)
858 	hal_map = RTL8723DE_NGFF1630_country_chplan_exc_map;
859 	hal_map_sz = sizeof(RTL8723DE_NGFF1630_country_chplan_exc_map) / sizeof(struct country_chplan);
860 #elif (RTW_DEF_MODULE_REGULATORY_CERT == RTW_MODULE_RTL8822BE)
861 	hal_map = RTL8822BE_country_chplan_exc_map;
862 	hal_map_sz = sizeof(RTL8822BE_country_chplan_exc_map) / sizeof(struct country_chplan);
863 #elif (RTW_DEF_MODULE_REGULATORY_CERT == RTW_MODULE_RTL8821CE)
864 	hal_map = RTL8821CE_country_chplan_exc_map;
865 	hal_map_sz = sizeof(RTL8821CE_country_chplan_exc_map) / sizeof(struct country_chplan);
866 #elif (RTW_DEF_MODULE_REGULATORY_CERT == RTW_MODULE_RTL8822CE)
867 	hal_map = RTL8822CE_country_chplan_exc_map;
868 	hal_map_sz = sizeof(RTL8822CE_country_chplan_exc_map) / sizeof(struct country_chplan);
869 #endif
870 
871 	if (hal_map == NULL || hal_map_sz == 0)
872 		goto exit;
873 
874 	for (i = 0; i < hal_map_sz; i++) {
875 		if (strncmp(country_code, hal_map[i].alpha2, 2) == 0) {
876 			ent = &hal_map[i];
877 			break;
878 		}
879 	}
880 
881 exit:
882 	return ent;
883 }
884 #endif /* CONFIG_CUSTOMIZED_COUNTRY_CHPLAN_MAP or RTW_DEF_MODULE_REGULATORY_CERT */
885 
886 static const struct country_chplan country_chplan_map[] = {
887 	COUNTRY_CHPLAN_ENT("AD", 0x26, 1, 0x000), /* Andorra */
888 	COUNTRY_CHPLAN_ENT("AE", 0x35, 1, 0xFFB), /* United Arab Emirates */
889 	COUNTRY_CHPLAN_ENT("AF", 0x42, 1, 0x000), /* Afghanistan */
890 	COUNTRY_CHPLAN_ENT("AG", 0x76, 1, 0x000), /* Antigua & Barbuda */
891 	COUNTRY_CHPLAN_ENT("AI", 0x26, 1, 0x000), /* Anguilla(UK) */
892 	COUNTRY_CHPLAN_ENT("AL", 0x26, 1, 0xFF1), /* Albania */
893 	COUNTRY_CHPLAN_ENT("AM", 0x26, 1, 0xEB0), /* Armenia */
894 	COUNTRY_CHPLAN_ENT("AN", 0x76, 1, 0xFF1), /* Netherlands Antilles */
895 	COUNTRY_CHPLAN_ENT("AO", 0x47, 1, 0xEE0), /* Angola */
896 	COUNTRY_CHPLAN_ENT("AQ", 0x26, 1, 0x000), /* Antarctica */
897 	COUNTRY_CHPLAN_ENT("AR", 0x61, 1, 0xFF3), /* Argentina */
898 	COUNTRY_CHPLAN_ENT("AS", 0x76, 1, 0x000), /* American Samoa */
899 	COUNTRY_CHPLAN_ENT("AT", 0x26, 1, 0xFFB), /* Austria */
900 	COUNTRY_CHPLAN_ENT("AU", 0x45, 1, 0xFFB), /* Australia */
901 	COUNTRY_CHPLAN_ENT("AW", 0x76, 1, 0x8B0), /* Aruba */
902 	COUNTRY_CHPLAN_ENT("AZ", 0x26, 1, 0xFF1), /* Azerbaijan */
903 	COUNTRY_CHPLAN_ENT("BA", 0x26, 1, 0xFF1), /* Bosnia & Herzegovina */
904 	COUNTRY_CHPLAN_ENT("BB", 0x76, 1, 0xE50), /* Barbados */
905 	COUNTRY_CHPLAN_ENT("BD", 0x26, 1, 0xFF1), /* Bangladesh */
906 	COUNTRY_CHPLAN_ENT("BE", 0x26, 1, 0xFFB), /* Belgium */
907 	COUNTRY_CHPLAN_ENT("BF", 0x26, 1, 0xEB0), /* Burkina Faso */
908 	COUNTRY_CHPLAN_ENT("BG", 0x26, 1, 0xFF1), /* Bulgaria */
909 	COUNTRY_CHPLAN_ENT("BH", 0x48, 1, 0xFF1), /* Bahrain */
910 	COUNTRY_CHPLAN_ENT("BI", 0x26, 1, 0xEB0), /* Burundi */
911 	COUNTRY_CHPLAN_ENT("BJ", 0x26, 1, 0xEB0), /* Benin */
912 	COUNTRY_CHPLAN_ENT("BM", 0x76, 1, 0xE00), /* Bermuda (UK) */
913 	COUNTRY_CHPLAN_ENT("BN", 0x47, 1, 0xE10), /* Brunei */
914 	COUNTRY_CHPLAN_ENT("BO", 0x73, 1, 0xFF1), /* Bolivia */
915 	COUNTRY_CHPLAN_ENT("BR", 0x62, 1, 0xFF1), /* Brazil */
916 	COUNTRY_CHPLAN_ENT("BS", 0x76, 1, 0xE20), /* Bahamas */
917 	COUNTRY_CHPLAN_ENT("BT", 0x26, 1, 0x000), /* Bhutan */
918 	COUNTRY_CHPLAN_ENT("BV", 0x26, 1, 0x000), /* Bouvet Island (Norway) */
919 	COUNTRY_CHPLAN_ENT("BW", 0x35, 1, 0xEF1), /* Botswana */
920 	COUNTRY_CHPLAN_ENT("BY", 0x26, 1, 0xFF1), /* Belarus */
921 	COUNTRY_CHPLAN_ENT("BZ", 0x76, 1, 0x000), /* Belize */
922 	COUNTRY_CHPLAN_ENT("CA", 0x2B, 1, 0xFFB), /* Canada */
923 	COUNTRY_CHPLAN_ENT("CC", 0x26, 1, 0x000), /* Cocos (Keeling) Islands (Australia) */
924 	COUNTRY_CHPLAN_ENT("CD", 0x26, 1, 0xEB0), /* Congo, Republic of the */
925 	COUNTRY_CHPLAN_ENT("CF", 0x26, 1, 0xEB0), /* Central African Republic */
926 	COUNTRY_CHPLAN_ENT("CG", 0x26, 1, 0xEB0), /* Congo, Democratic Republic of the. Zaire */
927 	COUNTRY_CHPLAN_ENT("CH", 0x26, 1, 0xFFB), /* Switzerland */
928 	COUNTRY_CHPLAN_ENT("CI", 0x42, 1, 0xFF1), /* Cote d'Ivoire */
929 	COUNTRY_CHPLAN_ENT("CK", 0x26, 1, 0x000), /* Cook Islands */
930 	COUNTRY_CHPLAN_ENT("CL", 0x2D, 1, 0xFF1), /* Chile */
931 	COUNTRY_CHPLAN_ENT("CM", 0x26, 1, 0xEB0), /* Cameroon */
932 	COUNTRY_CHPLAN_ENT("CN", 0x48, 1, 0xFFB), /* China */
933 	COUNTRY_CHPLAN_ENT("CO", 0x76, 1, 0xFF1), /* Colombia */
934 	COUNTRY_CHPLAN_ENT("CR", 0x76, 1, 0xFF1), /* Costa Rica */
935 	COUNTRY_CHPLAN_ENT("CV", 0x26, 1, 0xEB0), /* Cape Verde */
936 	COUNTRY_CHPLAN_ENT("CX", 0x45, 1, 0x000), /* Christmas Island (Australia) */
937 	COUNTRY_CHPLAN_ENT("CY", 0x26, 1, 0xFFB), /* Cyprus */
938 	COUNTRY_CHPLAN_ENT("CZ", 0x26, 1, 0xFFB), /* Czech Republic */
939 	COUNTRY_CHPLAN_ENT("DE", 0x26, 1, 0xFFB), /* Germany */
940 	COUNTRY_CHPLAN_ENT("DJ", 0x26, 1, 0xE80), /* Djibouti */
941 	COUNTRY_CHPLAN_ENT("DK", 0x26, 1, 0xFFB), /* Denmark */
942 	COUNTRY_CHPLAN_ENT("DM", 0x76, 1, 0x000), /* Dominica */
943 	COUNTRY_CHPLAN_ENT("DO", 0x76, 1, 0xFF1), /* Dominican Republic */
944 	COUNTRY_CHPLAN_ENT("DZ", 0x26, 1, 0xFF1), /* Algeria */
945 	COUNTRY_CHPLAN_ENT("EC", 0x76, 1, 0xFF1), /* Ecuador */
946 	COUNTRY_CHPLAN_ENT("EE", 0x26, 1, 0xFFB), /* Estonia */
947 	COUNTRY_CHPLAN_ENT("EG", 0x47, 1, 0xFF1), /* Egypt */
948 	COUNTRY_CHPLAN_ENT("EH", 0x47, 1, 0xE80), /* Western Sahara */
949 	COUNTRY_CHPLAN_ENT("ER", 0x26, 1, 0x000), /* Eritrea */
950 	COUNTRY_CHPLAN_ENT("ES", 0x26, 1, 0xFFB), /* Spain, Canary Islands, Ceuta, Melilla */
951 	COUNTRY_CHPLAN_ENT("ET", 0x26, 1, 0xCB0), /* Ethiopia */
952 	COUNTRY_CHPLAN_ENT("FI", 0x26, 1, 0xFFB), /* Finland */
953 	COUNTRY_CHPLAN_ENT("FJ", 0x76, 1, 0xE00), /* Fiji */
954 	COUNTRY_CHPLAN_ENT("FK", 0x26, 1, 0x000), /* Falkland Islands (Islas Malvinas) (UK) */
955 	COUNTRY_CHPLAN_ENT("FM", 0x76, 1, 0x000), /* Micronesia, Federated States of (USA) */
956 	COUNTRY_CHPLAN_ENT("FO", 0x26, 1, 0x000), /* Faroe Islands (Denmark) */
957 	COUNTRY_CHPLAN_ENT("FR", 0x26, 1, 0xFFB), /* France */
958 	COUNTRY_CHPLAN_ENT("GA", 0x26, 1, 0xEB0), /* Gabon */
959 	COUNTRY_CHPLAN_ENT("GB", 0x26, 1, 0xFFB), /* Great Britain (United Kingdom; England) */
960 	COUNTRY_CHPLAN_ENT("GD", 0x76, 1, 0x0B0), /* Grenada */
961 	COUNTRY_CHPLAN_ENT("GE", 0x26, 1, 0xE00), /* Georgia */
962 	COUNTRY_CHPLAN_ENT("GF", 0x26, 1, 0x080), /* French Guiana */
963 	COUNTRY_CHPLAN_ENT("GG", 0x26, 1, 0x000), /* Guernsey (UK) */
964 	COUNTRY_CHPLAN_ENT("GH", 0x26, 1, 0xFF1), /* Ghana */
965 	COUNTRY_CHPLAN_ENT("GI", 0x26, 1, 0xE00), /* Gibraltar (UK) */
966 	COUNTRY_CHPLAN_ENT("GL", 0x26, 1, 0xE00), /* Greenland (Denmark) */
967 	COUNTRY_CHPLAN_ENT("GM", 0x26, 1, 0xEB0), /* Gambia */
968 	COUNTRY_CHPLAN_ENT("GN", 0x26, 1, 0xE10), /* Guinea */
969 	COUNTRY_CHPLAN_ENT("GP", 0x26, 1, 0xE00), /* Guadeloupe (France) */
970 	COUNTRY_CHPLAN_ENT("GQ", 0x26, 1, 0xEB0), /* Equatorial Guinea */
971 	COUNTRY_CHPLAN_ENT("GR", 0x26, 1, 0xFFB), /* Greece */
972 	COUNTRY_CHPLAN_ENT("GS", 0x26, 1, 0x000), /* South Georgia and the Sandwich Islands (UK) */
973 	COUNTRY_CHPLAN_ENT("GT", 0x61, 1, 0xFF1), /* Guatemala */
974 	COUNTRY_CHPLAN_ENT("GU", 0x76, 1, 0xE00), /* Guam (USA) */
975 	COUNTRY_CHPLAN_ENT("GW", 0x26, 1, 0xEB0), /* Guinea-Bissau */
976 	COUNTRY_CHPLAN_ENT("GY", 0x44, 1, 0x000), /* Guyana */
977 	COUNTRY_CHPLAN_ENT("HK", 0x35, 1, 0xFFB), /* Hong Kong */
978 	COUNTRY_CHPLAN_ENT("HM", 0x45, 1, 0x000), /* Heard and McDonald Islands (Australia) */
979 	COUNTRY_CHPLAN_ENT("HN", 0x32, 1, 0xFF1), /* Honduras */
980 	COUNTRY_CHPLAN_ENT("HR", 0x26, 1, 0xFF9), /* Croatia */
981 	COUNTRY_CHPLAN_ENT("HT", 0x76, 1, 0xE50), /* Haiti */
982 	COUNTRY_CHPLAN_ENT("HU", 0x26, 1, 0xFFB), /* Hungary */
983 	COUNTRY_CHPLAN_ENT("ID", 0x5D, 1, 0x7F3), /* Indonesia */
984 	COUNTRY_CHPLAN_ENT("IE", 0x26, 1, 0xFFB), /* Ireland */
985 	COUNTRY_CHPLAN_ENT("IL", 0x47, 1, 0xFF1), /* Israel */
986 	COUNTRY_CHPLAN_ENT("IM", 0x26, 1, 0x000), /* Isle of Man (UK) */
987 	COUNTRY_CHPLAN_ENT("IN", 0x48, 1, 0xFF1), /* India */
988 	COUNTRY_CHPLAN_ENT("IO", 0x26, 1, 0x000), /* British Indian Ocean Territory (UK) */
989 	COUNTRY_CHPLAN_ENT("IQ", 0x26, 1, 0x000), /* Iraq */
990 	COUNTRY_CHPLAN_ENT("IR", 0x26, 0, 0x000), /* Iran */
991 	COUNTRY_CHPLAN_ENT("IS", 0x26, 1, 0xFFB), /* Iceland */
992 	COUNTRY_CHPLAN_ENT("IT", 0x26, 1, 0xFFB), /* Italy */
993 	COUNTRY_CHPLAN_ENT("JE", 0x26, 1, 0x000), /* Jersey (UK) */
994 	COUNTRY_CHPLAN_ENT("JM", 0x32, 1, 0xFF1), /* Jamaica */
995 	COUNTRY_CHPLAN_ENT("JO", 0x49, 1, 0xFFB), /* Jordan */
996 	COUNTRY_CHPLAN_ENT("JP", 0x27, 1, 0xFFF), /* Japan- Telec */
997 	COUNTRY_CHPLAN_ENT("KE", 0x47, 1, 0xFF9), /* Kenya */
998 	COUNTRY_CHPLAN_ENT("KG", 0x26, 1, 0xFF1), /* Kyrgyzstan */
999 	COUNTRY_CHPLAN_ENT("KH", 0x26, 1, 0xFF1), /* Cambodia */
1000 	COUNTRY_CHPLAN_ENT("KI", 0x26, 1, 0x000), /* Kiribati */
1001 	COUNTRY_CHPLAN_ENT("KM", 0x26, 1, 0x800), /* Comoros */
1002 	COUNTRY_CHPLAN_ENT("KN", 0x76, 1, 0x000), /* Saint Kitts and Nevis */
1003 	COUNTRY_CHPLAN_ENT("KR", 0x4B, 1, 0xFFB), /* South Korea */
1004 	COUNTRY_CHPLAN_ENT("KW", 0x26, 1, 0xFFB), /* Kuwait */
1005 	COUNTRY_CHPLAN_ENT("KY", 0x76, 1, 0x000), /* Cayman Islands (UK) */
1006 	COUNTRY_CHPLAN_ENT("KZ", 0x26, 1, 0xF00), /* Kazakhstan */
1007 	COUNTRY_CHPLAN_ENT("LA", 0x26, 1, 0x000), /* Laos */
1008 	COUNTRY_CHPLAN_ENT("LB", 0x26, 1, 0xFF1), /* Lebanon */
1009 	COUNTRY_CHPLAN_ENT("LC", 0x76, 1, 0x000), /* Saint Lucia */
1010 	COUNTRY_CHPLAN_ENT("LI", 0x26, 1, 0xFFB), /* Liechtenstein */
1011 	COUNTRY_CHPLAN_ENT("LK", 0x26, 1, 0xFF1), /* Sri Lanka */
1012 	COUNTRY_CHPLAN_ENT("LR", 0x26, 1, 0xEB0), /* Liberia */
1013 	COUNTRY_CHPLAN_ENT("LS", 0x26, 1, 0xFF1), /* Lesotho */
1014 	COUNTRY_CHPLAN_ENT("LT", 0x26, 1, 0xFFB), /* Lithuania */
1015 	COUNTRY_CHPLAN_ENT("LU", 0x26, 1, 0xFFB), /* Luxembourg */
1016 	COUNTRY_CHPLAN_ENT("LV", 0x26, 1, 0xFFB), /* Latvia */
1017 	COUNTRY_CHPLAN_ENT("LY", 0x26, 1, 0x000), /* Libya */
1018 	COUNTRY_CHPLAN_ENT("MA", 0x47, 1, 0xFF1), /* Morocco */
1019 	COUNTRY_CHPLAN_ENT("MC", 0x26, 1, 0xFFB), /* Monaco */
1020 	COUNTRY_CHPLAN_ENT("MD", 0x26, 1, 0xFF1), /* Moldova */
1021 	COUNTRY_CHPLAN_ENT("ME", 0x26, 1, 0xFF1), /* Montenegro */
1022 	COUNTRY_CHPLAN_ENT("MF", 0x76, 1, 0x000), /* Saint Martin */
1023 	COUNTRY_CHPLAN_ENT("MG", 0x26, 1, 0xE20), /* Madagascar */
1024 	COUNTRY_CHPLAN_ENT("MH", 0x76, 1, 0x000), /* Marshall Islands (USA) */
1025 	COUNTRY_CHPLAN_ENT("MK", 0x26, 1, 0xFF1), /* Republic of Macedonia (FYROM) */
1026 	COUNTRY_CHPLAN_ENT("ML", 0x26, 1, 0xEB0), /* Mali */
1027 	COUNTRY_CHPLAN_ENT("MM", 0x26, 1, 0x000), /* Burma (Myanmar) */
1028 	COUNTRY_CHPLAN_ENT("MN", 0x26, 1, 0x000), /* Mongolia */
1029 	COUNTRY_CHPLAN_ENT("MO", 0x35, 1, 0xE00), /* Macau */
1030 	COUNTRY_CHPLAN_ENT("MP", 0x76, 1, 0x000), /* Northern Mariana Islands (USA) */
1031 	COUNTRY_CHPLAN_ENT("MQ", 0x26, 1, 0xE40), /* Martinique (France) */
1032 	COUNTRY_CHPLAN_ENT("MR", 0x26, 1, 0xEA0), /* Mauritania */
1033 	COUNTRY_CHPLAN_ENT("MS", 0x26, 1, 0x000), /* Montserrat (UK) */
1034 	COUNTRY_CHPLAN_ENT("MT", 0x26, 1, 0xFFB), /* Malta */
1035 	COUNTRY_CHPLAN_ENT("MU", 0x26, 1, 0xEB0), /* Mauritius */
1036 	COUNTRY_CHPLAN_ENT("MV", 0x47, 1, 0x000), /* Maldives */
1037 	COUNTRY_CHPLAN_ENT("MW", 0x26, 1, 0xEB0), /* Malawi */
1038 	COUNTRY_CHPLAN_ENT("MX", 0x4D, 1, 0xFF1), /* Mexico */
1039 	COUNTRY_CHPLAN_ENT("MY", 0x63, 1, 0xFF1), /* Malaysia */
1040 	COUNTRY_CHPLAN_ENT("MZ", 0x26, 1, 0xFF1), /* Mozambique */
1041 	COUNTRY_CHPLAN_ENT("NA", 0x26, 1, 0xF00), /* Namibia */
1042 	COUNTRY_CHPLAN_ENT("NC", 0x26, 1, 0x000), /* New Caledonia */
1043 	COUNTRY_CHPLAN_ENT("NE", 0x26, 1, 0xEB0), /* Niger */
1044 	COUNTRY_CHPLAN_ENT("NF", 0x45, 1, 0x000), /* Norfolk Island (Australia) */
1045 	COUNTRY_CHPLAN_ENT("NG", 0x75, 1, 0xFF9), /* Nigeria */
1046 	COUNTRY_CHPLAN_ENT("NI", 0x76, 1, 0xFF1), /* Nicaragua */
1047 	COUNTRY_CHPLAN_ENT("NL", 0x26, 1, 0xFFB), /* Netherlands */
1048 	COUNTRY_CHPLAN_ENT("NO", 0x26, 1, 0xFFB), /* Norway */
1049 	COUNTRY_CHPLAN_ENT("NP", 0x48, 1, 0xEF0), /* Nepal */
1050 	COUNTRY_CHPLAN_ENT("NR", 0x26, 1, 0x000), /* Nauru */
1051 	COUNTRY_CHPLAN_ENT("NU", 0x45, 1, 0x000), /* Niue */
1052 	COUNTRY_CHPLAN_ENT("NZ", 0x45, 1, 0xFFB), /* New Zealand */
1053 	COUNTRY_CHPLAN_ENT("OM", 0x26, 1, 0xFF9), /* Oman */
1054 	COUNTRY_CHPLAN_ENT("PA", 0x76, 1, 0xFF1), /* Panama */
1055 	COUNTRY_CHPLAN_ENT("PE", 0x76, 1, 0xFF1), /* Peru */
1056 	COUNTRY_CHPLAN_ENT("PF", 0x26, 1, 0x000), /* French Polynesia (France) */
1057 	COUNTRY_CHPLAN_ENT("PG", 0x35, 1, 0xFF1), /* Papua New Guinea */
1058 	COUNTRY_CHPLAN_ENT("PH", 0x35, 1, 0xFF1), /* Philippines */
1059 	COUNTRY_CHPLAN_ENT("PK", 0x51, 1, 0xFF1), /* Pakistan */
1060 	COUNTRY_CHPLAN_ENT("PL", 0x26, 1, 0xFFB), /* Poland */
1061 	COUNTRY_CHPLAN_ENT("PM", 0x26, 1, 0x000), /* Saint Pierre and Miquelon (France) */
1062 	COUNTRY_CHPLAN_ENT("PR", 0x76, 1, 0xFF1), /* Puerto Rico */
1063 	COUNTRY_CHPLAN_ENT("PT", 0x26, 1, 0xFFB), /* Portugal */
1064 	COUNTRY_CHPLAN_ENT("PW", 0x76, 1, 0x000), /* Palau */
1065 	COUNTRY_CHPLAN_ENT("PY", 0x76, 1, 0xFF1), /* Paraguay */
1066 	COUNTRY_CHPLAN_ENT("QA", 0x35, 1, 0xFF9), /* Qatar */
1067 	COUNTRY_CHPLAN_ENT("RE", 0x26, 1, 0x000), /* Reunion (France) */
1068 	COUNTRY_CHPLAN_ENT("RO", 0x26, 1, 0xFF1), /* Romania */
1069 	COUNTRY_CHPLAN_ENT("RS", 0x26, 1, 0xFF1), /* Serbia, Kosovo */
1070 	COUNTRY_CHPLAN_ENT("RU", 0x59, 1, 0xFFB), /* Russia(fac/gost), Kaliningrad */
1071 	COUNTRY_CHPLAN_ENT("RW", 0x26, 1, 0x0B0), /* Rwanda */
1072 	COUNTRY_CHPLAN_ENT("SA", 0x35, 1, 0xFFB), /* Saudi Arabia */
1073 	COUNTRY_CHPLAN_ENT("SB", 0x26, 1, 0x000), /* Solomon Islands */
1074 	COUNTRY_CHPLAN_ENT("SC", 0x76, 1, 0xE90), /* Seychelles */
1075 	COUNTRY_CHPLAN_ENT("SE", 0x26, 1, 0xFFB), /* Sweden */
1076 	COUNTRY_CHPLAN_ENT("SG", 0x35, 1, 0xFFB), /* Singapore */
1077 	COUNTRY_CHPLAN_ENT("SH", 0x26, 1, 0x000), /* Saint Helena (UK) */
1078 	COUNTRY_CHPLAN_ENT("SI", 0x26, 1, 0xFFB), /* Slovenia */
1079 	COUNTRY_CHPLAN_ENT("SJ", 0x26, 1, 0x000), /* Svalbard (Norway) */
1080 	COUNTRY_CHPLAN_ENT("SK", 0x26, 1, 0xFFB), /* Slovakia */
1081 	COUNTRY_CHPLAN_ENT("SL", 0x26, 1, 0xEB0), /* Sierra Leone */
1082 	COUNTRY_CHPLAN_ENT("SM", 0x26, 1, 0x000), /* San Marino */
1083 	COUNTRY_CHPLAN_ENT("SN", 0x26, 1, 0xFF1), /* Senegal */
1084 	COUNTRY_CHPLAN_ENT("SO", 0x26, 1, 0x000), /* Somalia */
1085 	COUNTRY_CHPLAN_ENT("SR", 0x74, 1, 0x000), /* Suriname */
1086 	COUNTRY_CHPLAN_ENT("ST", 0x76, 1, 0xE80), /* Sao Tome and Principe */
1087 	COUNTRY_CHPLAN_ENT("SV", 0x30, 1, 0xFF1), /* El Salvador */
1088 	COUNTRY_CHPLAN_ENT("SX", 0x76, 1, 0x000), /* Sint Marteen */
1089 	COUNTRY_CHPLAN_ENT("SZ", 0x26, 1, 0x820), /* Swaziland */
1090 	COUNTRY_CHPLAN_ENT("TC", 0x26, 1, 0x000), /* Turks and Caicos Islands (UK) */
1091 	COUNTRY_CHPLAN_ENT("TD", 0x26, 1, 0xEB0), /* Chad */
1092 	COUNTRY_CHPLAN_ENT("TF", 0x26, 1, 0xE80), /* French Southern and Antarctic Lands (FR Southern Territories) */
1093 	COUNTRY_CHPLAN_ENT("TG", 0x26, 1, 0xEB0), /* Togo */
1094 	COUNTRY_CHPLAN_ENT("TH", 0x35, 1, 0xFF1), /* Thailand */
1095 	COUNTRY_CHPLAN_ENT("TJ", 0x26, 1, 0xE40), /* Tajikistan */
1096 	COUNTRY_CHPLAN_ENT("TK", 0x45, 1, 0x000), /* Tokelau */
1097 	COUNTRY_CHPLAN_ENT("TM", 0x26, 1, 0x000), /* Turkmenistan */
1098 	COUNTRY_CHPLAN_ENT("TN", 0x47, 1, 0xFF1), /* Tunisia */
1099 	COUNTRY_CHPLAN_ENT("TO", 0x26, 1, 0x000), /* Tonga */
1100 	COUNTRY_CHPLAN_ENT("TR", 0x26, 1, 0xFF1), /* Turkey, Northern Cyprus */
1101 	COUNTRY_CHPLAN_ENT("TT", 0x76, 1, 0x3F1), /* Trinidad & Tobago */
1102 	COUNTRY_CHPLAN_ENT("TV", 0x21, 0, 0x000), /* Tuvalu */
1103 	COUNTRY_CHPLAN_ENT("TW", 0x76, 1, 0xFFF), /* Taiwan */
1104 	COUNTRY_CHPLAN_ENT("TZ", 0x26, 1, 0xEF0), /* Tanzania */
1105 	COUNTRY_CHPLAN_ENT("UA", 0x35, 1, 0xFFB), /* Ukraine */
1106 	COUNTRY_CHPLAN_ENT("UG", 0x26, 1, 0xEF1), /* Uganda */
1107 	COUNTRY_CHPLAN_ENT("US", 0x76, 1, 0xFFF), /* United States of America (USA) */
1108 	COUNTRY_CHPLAN_ENT("UY", 0x30, 1, 0xFF1), /* Uruguay */
1109 	COUNTRY_CHPLAN_ENT("UZ", 0x47, 1, 0xEF0), /* Uzbekistan */
1110 	COUNTRY_CHPLAN_ENT("VA", 0x26, 1, 0x000), /* Holy See (Vatican City) */
1111 	COUNTRY_CHPLAN_ENT("VC", 0x76, 1, 0x010), /* Saint Vincent and the Grenadines */
1112 	COUNTRY_CHPLAN_ENT("VE", 0x30, 1, 0xFF1), /* Venezuela */
1113 	COUNTRY_CHPLAN_ENT("VG", 0x76, 1, 0x000), /* British Virgin Islands (UK) */
1114 	COUNTRY_CHPLAN_ENT("VI", 0x76, 1, 0x000), /* United States Virgin Islands (USA) */
1115 	COUNTRY_CHPLAN_ENT("VN", 0x35, 1, 0xFF1), /* Vietnam */
1116 	COUNTRY_CHPLAN_ENT("VU", 0x26, 1, 0x000), /* Vanuatu */
1117 	COUNTRY_CHPLAN_ENT("WF", 0x26, 1, 0x000), /* Wallis and Futuna (France) */
1118 	COUNTRY_CHPLAN_ENT("WS", 0x76, 1, 0x000), /* Samoa */
1119 	COUNTRY_CHPLAN_ENT("YE", 0x26, 1, 0x040), /* Yemen */
1120 	COUNTRY_CHPLAN_ENT("YT", 0x26, 1, 0xE80), /* Mayotte (France) */
1121 	COUNTRY_CHPLAN_ENT("ZA", 0x35, 1, 0xFF1), /* South Africa */
1122 	COUNTRY_CHPLAN_ENT("ZM", 0x26, 1, 0xEB0), /* Zambia */
1123 	COUNTRY_CHPLAN_ENT("ZW", 0x26, 1, 0xFF1), /* Zimbabwe */
1124 };
1125 
1126 /*
1127 * rtw_get_chplan_from_country -
1128 * @country_code: string of country code
1129 *
1130 * Return pointer of struct country_chplan entry or NULL when unsupported country_code is given
1131 */
rtw_get_chplan_from_country(const char * country_code)1132 const struct country_chplan *rtw_get_chplan_from_country(const char *country_code)
1133 {
1134 #if RTW_DEF_MODULE_REGULATORY_CERT
1135 	const struct country_chplan *exc_ent = NULL;
1136 #endif
1137 	const struct country_chplan *ent = NULL;
1138 	const struct country_chplan *map = NULL;
1139 	u16 map_sz = 0;
1140 	char code[2];
1141 	int i;
1142 
1143 	code[0] = alpha_to_upper(country_code[0]);
1144 	code[1] = alpha_to_upper(country_code[1]);
1145 
1146 #ifdef CONFIG_CUSTOMIZED_COUNTRY_CHPLAN_MAP
1147 	map = CUSTOMIZED_country_chplan_map;
1148 	map_sz = sizeof(CUSTOMIZED_country_chplan_map) / sizeof(struct country_chplan);
1149 #else
1150 	#if RTW_DEF_MODULE_REGULATORY_CERT
1151 	exc_ent = rtw_def_module_get_chplan_from_country(code);
1152 	#endif
1153 	map = country_chplan_map;
1154 	map_sz = sizeof(country_chplan_map) / sizeof(struct country_chplan);
1155 #endif
1156 
1157 	for (i = 0; i < map_sz; i++) {
1158 		if (strncmp(code, map[i].alpha2, 2) == 0) {
1159 			ent = &map[i];
1160 			break;
1161 		}
1162 	}
1163 
1164 	#if RTW_DEF_MODULE_REGULATORY_CERT
1165 	if (!ent || !(COUNTRY_CHPLAN_DEF_MODULE_FALGS(ent) & RTW_DEF_MODULE_REGULATORY_CERT))
1166 		exc_ent = ent = NULL;
1167 	if (exc_ent)
1168 		ent = exc_ent;
1169 	#endif
1170 
1171 	return ent;
1172 }
1173 
dump_country_chplan(void * sel,const struct country_chplan * ent)1174 void dump_country_chplan(void *sel, const struct country_chplan *ent)
1175 {
1176 	RTW_PRINT_SEL(sel, "\"%c%c\", 0x%02X%s\n"
1177 		, ent->alpha2[0], ent->alpha2[1], ent->chplan
1178 		, COUNTRY_CHPLAN_EN_11AC(ent) ? " ac" : ""
1179 	);
1180 }
1181 
dump_country_chplan_map(void * sel)1182 void dump_country_chplan_map(void *sel)
1183 {
1184 	const struct country_chplan *ent;
1185 	u8 code[2];
1186 
1187 #if RTW_DEF_MODULE_REGULATORY_CERT
1188 	RTW_PRINT_SEL(sel, "RTW_DEF_MODULE_REGULATORY_CERT:0x%x\n", RTW_DEF_MODULE_REGULATORY_CERT);
1189 #endif
1190 #ifdef CONFIG_CUSTOMIZED_COUNTRY_CHPLAN_MAP
1191 	RTW_PRINT_SEL(sel, "CONFIG_CUSTOMIZED_COUNTRY_CHPLAN_MAP\n");
1192 #endif
1193 
1194 	for (code[0] = 'A'; code[0] <= 'Z'; code[0]++) {
1195 		for (code[1] = 'A'; code[1] <= 'Z'; code[1]++) {
1196 			ent = rtw_get_chplan_from_country(code);
1197 			if (!ent)
1198 				continue;
1199 
1200 			dump_country_chplan(sel, ent);
1201 		}
1202 	}
1203 }
1204 
dump_chplan_id_list(void * sel)1205 void dump_chplan_id_list(void *sel)
1206 {
1207 	u8 first = 1;
1208 	int i;
1209 
1210 	for (i = 0; i < RTW_ChannelPlanMap_size; i++) {
1211 		if (!rtw_is_channel_plan_valid(i))
1212 			continue;
1213 
1214 		if (first) {
1215 			RTW_PRINT_SEL(sel, "0x%02X ", i);
1216 			first = 0;
1217 		} else
1218 			_RTW_PRINT_SEL(sel, "0x%02X ", i);
1219 	}
1220 }
1221 
dump_chplan_test(void * sel)1222 void dump_chplan_test(void *sel)
1223 {
1224 	int i, j;
1225 
1226 	/* check invalid channel */
1227 	for (i = 0; i < RTW_RD_2G_MAX; i++) {
1228 		for (j = 0; j < CH_LIST_LEN(RTW_ChannelPlan2G[i]); j++) {
1229 			if (rtw_ch2freq(CH_LIST_CH(RTW_ChannelPlan2G[i], j)) == 0)
1230 				RTW_PRINT_SEL(sel, "invalid ch:%u at (%d,%d)\n", CH_LIST_CH(RTW_ChannelPlan2G[i], j), i, j);
1231 		}
1232 	}
1233 
1234 #if CONFIG_IEEE80211_BAND_5GHZ
1235 	for (i = 0; i < RTW_RD_5G_MAX; i++) {
1236 		for (j = 0; j < CH_LIST_LEN(RTW_ChannelPlan5G[i]); j++) {
1237 			if (rtw_ch2freq(CH_LIST_CH(RTW_ChannelPlan5G[i], j)) == 0)
1238 				RTW_PRINT_SEL(sel, "invalid ch:%u at (%d,%d)\n", CH_LIST_CH(RTW_ChannelPlan5G[i], j), i, j);
1239 		}
1240 	}
1241 #endif
1242 }
1243 
dump_chplan_ver(void * sel)1244 void dump_chplan_ver(void *sel)
1245 {
1246 	RTW_PRINT_SEL(sel, "%s%s-%s\n", RTW_DOMAIN_MAP_VER, RTW_DOMAIN_MAP_M_VER, RTW_COUNTRY_MAP_VER);
1247 }
1248