xref: /titanic_52/usr/src/uts/common/io/arn/arn_regd.h (revision dd1de3740722a4b99a74005255effebbd20a6d70)
1 /*
2  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
3  * Use is subject to license terms.
4  */
5 
6 /*
7  * Copyright (c) 2008 Atheros Communications Inc.
8  *
9  * Permission to use, copy, modify, and/or distribute this software for any
10  * purpose with or without fee is hereby granted, provided that the above
11  * copyright notice and this permission notice appear in all copies.
12  *
13  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
14  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
15  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
16  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
17  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
18  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
19  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
20  */
21 
22 #ifndef	_ARN_REGD_H
23 #define	_ARN_REGD_H
24 
25 #ifdef __cplusplus
26 extern "C" {
27 #endif
28 
29 #include "arn_ath9k.h"
30 
31 #define	BMLEN 2
32 #define	BMZERO {(uint64_t)0, (uint64_t)0}
33 
34 #define	BM(_fa, _fb, _fc, _fd, _fe, _ff, _fg, _fh, _fi, _fj, _fk, _fl) \
35 	{((((_fa >= 0) && (_fa < 64)) ? \
36 		(((uint64_t)1) << _fa) : (uint64_t)0) | \
37 	(((_fb >= 0) && (_fb < 64)) ? \
38 		(((uint64_t)1) << _fb) : (uint64_t)0) | \
39 	(((_fc >= 0) && (_fc < 64)) ? \
40 		(((uint64_t)1) << _fc) : (uint64_t)0) | \
41 	(((_fd >= 0) && (_fd < 64)) ? \
42 		(((uint64_t)1) << _fd) : (uint64_t)0) | \
43 	(((_fe >= 0) && (_fe < 64)) ? \
44 		(((uint64_t)1) << _fe) : (uint64_t)0) | \
45 	(((_ff >= 0) && (_ff < 64)) ? \
46 		(((uint64_t)1) << _ff) : (uint64_t)0) | \
47 	(((_fg >= 0) && (_fg < 64)) ? \
48 		(((uint64_t)1) << _fg) : (uint64_t)0) | \
49 	(((_fh >= 0) && (_fh < 64)) ? \
50 		(((uint64_t)1) << _fh) : (uint64_t)0) | \
51 	(((_fi >= 0) && (_fi < 64)) ? \
52 		(((uint64_t)1) << _fi) : (uint64_t)0) | \
53 	(((_fj >= 0) && (_fj < 64)) ? \
54 		(((uint64_t)1) << _fj) : (uint64_t)0) | \
55 	(((_fk >= 0) && (_fk < 64)) ? \
56 		(((uint64_t)1) << _fk) : (uint64_t)0) | \
57 	(((_fl >= 0) && (_fl < 64)) ? \
58 		(((uint64_t)1) << _fl) : (uint64_t)0) | \
59 	((((_fa > 63) && (_fa < 128)) ? \
60 		(((uint64_t)1) << (_fa - 64)) : (uint64_t)0) | \
61 	(((_fb > 63) && (_fb < 128)) ? \
62 		(((uint64_t)1) << (_fb - 64)) : (uint64_t)0) | \
63 	(((_fc > 63) && (_fc < 128)) ? \
64 		(((uint64_t)1) << (_fc - 64)) : (uint64_t)0) | \
65 	(((_fd > 63) && (_fd < 128)) ? \
66 		(((uint64_t)1) << (_fd - 64)) : (uint64_t)0) | \
67 	(((_fe > 63) && (_fe < 128)) ? \
68 		(((uint64_t)1) << (_fe - 64)) : (uint64_t)0) | \
69 	(((_ff > 63) && (_ff < 128)) ? \
70 		(((uint64_t)1) << (_ff - 64)) : (uint64_t)0) | \
71 	(((_fg > 63) && (_fg < 128)) ? \
72 		(((uint64_t)1) << (_fg - 64)) : (uint64_t)0) | \
73 	(((_fh > 63) && (_fh < 128)) ? \
74 		(((uint64_t)1) << (_fh - 64)) : (uint64_t)0) | \
75 	(((_fi > 63) && (_fi < 128)) ? \
76 		(((uint64_t)1) << (_fi - 64)) : (uint64_t)0) | \
77 	(((_fj > 63) && (_fj < 128)) ? \
78 		(((uint64_t)1) << (_fj - 64)) : (uint64_t)0) | \
79 	(((_fk > 63) && (_fk < 128)) ? \
80 		(((uint64_t)1) << (_fk - 64)) : (uint64_t)0) | \
81 	(((_fl > 63) && (_fl < 128)) ? \
82 		(((uint64_t)1) << (_fl - 64)) : (uint64_t)0)))}
83 
84 #define	DEF_REGDMN		FCC1_FCCA
85 #define	DEF_DMN_5		FCC1
86 #define	DEF_DMN_2		FCCA
87 #define	COUNTRY_ERD_FLAG	0x8000
88 #define	WORLDWIDE_ROAMING_FLAG	0x4000
89 #define	SUPER_DOMAIN_MASK	0x0fff
90 #define	COUNTRY_CODE_MASK	0x3fff
91 #define	CF_INTERFERENCE		(CHANNEL_CW_INT | CHANNEL_RADAR_INT)
92 #define	CHANNEL_14		(2484)
93 #define	IS_11G_CH14(_ch, _cf) \
94 	(((_ch) == CHANNEL_14) && ((_cf) == CHANNEL_G))
95 
96 #define	NO_PSCAN	0x0ULL
97 #define	PSCAN_FCC	0x0000000000000001ULL
98 #define	PSCAN_FCC_T	0x0000000000000002ULL
99 #define	PSCAN_ETSI 	0x0000000000000004ULL
100 #define	PSCAN_MKK1	0x0000000000000008ULL
101 #define	PSCAN_MKK2	0x0000000000000010ULL
102 #define	PSCAN_MKKA	0x0000000000000020ULL
103 #define	PSCAN_MKKA_G	0x0000000000000040ULL
104 #define	PSCAN_ETSIA	0x0000000000000080ULL
105 #define	PSCAN_ETSIB	0x0000000000000100ULL
106 #define	PSCAN_ETSIC	0x0000000000000200ULL
107 #define	PSCAN_WWR	0x0000000000000400ULL
108 #define	PSCAN_MKKA1	0x0000000000000800ULL
109 #define	PSCAN_MKKA1_G	0x0000000000001000ULL
110 #define	PSCAN_MKKA2	0x0000000000002000ULL
111 #define	PSCAN_MKKA2_G	0x0000000000004000ULL
112 #define	PSCAN_MKK3	0x0000000000008000ULL
113 #define	PSCAN_DEFER	0x7FFFFFFFFFFFFFFFULL
114 #define	IS_ECM_CHAN	0x8000000000000000ULL
115 
116 #define	isWwrSKU(_ah) \
117 	(((ath9k_regd_get_eepromRD((_ah)) & WORLD_SKU_MASK) == \
118 	    WORLD_SKU_PREFIX) || \
119 	    (ath9k_regd_get_eepromRD(_ah) == WORLD))
120 
121 #define	isWwrSKU_NoMidband(_ah) \
122 	((ath9k_regd_get_eepromRD((_ah)) == WOR3_WORLD) || \
123 	(ath9k_regd_get_eepromRD(_ah) == WOR4_WORLD) || \
124 	(ath9k_regd_get_eepromRD(_ah) == WOR5_ETSIC))
125 
126 #define	isUNII1OddChan(ch) \
127 	((ch == 5170) || (ch == 5190) || (ch == 5210) || (ch == 5230))
128 
129 #define	IS_HT40_MODE(_mode)					\
130 	(((_mode == ATH9K_MODE_11NA_HT40PLUS	||		\
131 	_mode == ATH9K_MODE_11NG_HT40PLUS	||		\
132 	_mode == ATH9K_MODE_11NA_HT40MINUS	||		\
133 	_mode == ATH9K_MODE_11NG_HT40MINUS) ? B_TRUE : B_FALSE))
134 
135 #define	CHAN_FLAGS	(CHANNEL_ALL|CHANNEL_HALF|CHANNEL_QUARTER)
136 
137 #define	swap(_a, _b, _size) {		\
138 	uint8_t *s = _b;		\
139 	int i = _size;			\
140 	do {				\
141 		uint8_t tmp = *_a;	\
142 		*_a++ = *s;		\
143 		*s++ = tmp;		\
144 	} while (--i);			\
145 	_a -= _size;			\
146 }
147 
148 
149 #define	HALF_MAXCHANBW		10
150 
151 #define	MULTI_DOMAIN_MASK	0xFF00
152 
153 #define	WORLD_SKU_MASK		0x00F0
154 #define	WORLD_SKU_PREFIX	0x0060
155 
156 #define	CHANNEL_HALF_BW		10
157 #define	CHANNEL_QUARTER_BW	5
158 
159 typedef int ath_hal_cmp_t(const void *, const void *);
160 
161 struct reg_dmn_pair_mapping {
162 	uint16_t regDmnEnum;
163 	uint16_t regDmn5GHz;
164 	uint16_t regDmn2GHz;
165 	uint32_t flags5GHz;
166 	uint32_t flags2GHz;
167 	uint64_t pscanMask;
168 	uint16_t singleCC;
169 };
170 
171 struct ccmap {
172 	char isoName[3];
173 	uint16_t countryCode;
174 };
175 
176 struct country_code_to_enum_rd {
177 	uint16_t countryCode;
178 	uint16_t regDmnEnum;
179 	const char *isoName;
180 	const char *name;
181 	boolean_t allow11g;
182 	boolean_t allow11aTurbo;
183 	boolean_t allow11gTurbo;
184 	boolean_t allow11ng20;
185 	boolean_t allow11ng40;
186 	boolean_t allow11na20;
187 	boolean_t allow11na40;
188 	uint16_t outdoorChanStart;
189 };
190 
191 struct RegDmnFreqBand {
192 	uint16_t lowChannel;
193 	uint16_t highChannel;
194 	uint8_t powerDfs;
195 	uint8_t antennaMax;
196 	uint8_t channelBW;
197 	uint8_t channelSep;
198 	uint64_t useDfs;
199 	uint64_t usePassScan;
200 	uint8_t regClassId;
201 };
202 
203 struct regDomain {
204 	uint16_t regDmnEnum;
205 	uint8_t conformanceTestLimit;
206 	uint64_t dfsMask;
207 	uint64_t pscan;
208 	uint32_t flags;
209 	uint64_t chan11a[BMLEN];
210 	uint64_t chan11a_turbo[BMLEN];
211 	uint64_t chan11a_dyn_turbo[BMLEN];
212 	uint64_t chan11b[BMLEN];
213 	uint64_t chan11g[BMLEN];
214 	uint64_t chan11g_turbo[BMLEN];
215 };
216 
217 struct cmode {
218 	uint32_t mode;
219 	uint32_t flags;
220 };
221 
222 #define	YES	B_TRUE
223 #define	NO	B_FALSE
224 
225 struct japan_bandcheck {
226 	uint16_t freqbandbit;
227 	uint32_t eepromflagtocheck;
228 };
229 
230 struct common_mode_power {
231 	uint16_t lchan;
232 	uint16_t hchan;
233 	uint8_t pwrlvl;
234 };
235 
236 enum CountryCode {
237 	CTRY_ALBANIA = 8,
238 	CTRY_ALGERIA = 12,
239 	CTRY_ARGENTINA = 32,
240 	CTRY_ARMENIA = 51,
241 	CTRY_AUSTRALIA = 36,
242 	CTRY_AUSTRIA = 40,
243 	CTRY_AZERBAIJAN = 31,
244 	CTRY_BAHRAIN = 48,
245 	CTRY_BELARUS = 112,
246 	CTRY_BELGIUM = 56,
247 	CTRY_BELIZE = 84,
248 	CTRY_BOLIVIA = 68,
249 	CTRY_BOSNIA_HERZ = 70,
250 	CTRY_BRAZIL = 76,
251 	CTRY_BRUNEI_DARUSSALAM = 96,
252 	CTRY_BULGARIA = 100,
253 	CTRY_CANADA = 124,
254 	CTRY_CHILE = 152,
255 	CTRY_CHINA = 156,
256 	CTRY_COLOMBIA = 170,
257 	CTRY_COSTA_RICA = 188,
258 	CTRY_CROATIA = 191,
259 	CTRY_CYPRUS = 196,
260 	CTRY_CZECH = 203,
261 	CTRY_DENMARK = 208,
262 	CTRY_DOMINICAN_REPUBLIC = 214,
263 	CTRY_ECUADOR = 218,
264 	CTRY_EGYPT = 818,
265 	CTRY_EL_SALVADOR = 222,
266 	CTRY_ESTONIA = 233,
267 	CTRY_FAEROE_ISLANDS = 234,
268 	CTRY_FINLAND = 246,
269 	CTRY_FRANCE = 250,
270 	CTRY_GEORGIA = 268,
271 	CTRY_GERMANY = 276,
272 	CTRY_GREECE = 300,
273 	CTRY_GUATEMALA = 320,
274 	CTRY_HONDURAS = 340,
275 	CTRY_HONG_KONG = 344,
276 	CTRY_HUNGARY = 348,
277 	CTRY_ICELAND = 352,
278 	CTRY_INDIA = 356,
279 	CTRY_INDONESIA = 360,
280 	CTRY_IRAN = 364,
281 	CTRY_IRAQ = 368,
282 	CTRY_IRELAND = 372,
283 	CTRY_ISRAEL = 376,
284 	CTRY_ITALY = 380,
285 	CTRY_JAMAICA = 388,
286 	CTRY_JAPAN = 392,
287 	CTRY_JORDAN = 400,
288 	CTRY_KAZAKHSTAN = 398,
289 	CTRY_KENYA = 404,
290 	CTRY_KOREA_NORTH = 408,
291 	CTRY_KOREA_ROC = 410,
292 	CTRY_KOREA_ROC2 = 411,
293 	CTRY_KOREA_ROC3 = 412,
294 	CTRY_KUWAIT = 414,
295 	CTRY_LATVIA = 428,
296 	CTRY_LEBANON = 422,
297 	CTRY_LIBYA = 434,
298 	CTRY_LIECHTENSTEIN = 438,
299 	CTRY_LITHUANIA = 440,
300 	CTRY_LUXEMBOURG = 442,
301 	CTRY_MACAU = 446,
302 	CTRY_MACEDONIA = 807,
303 	CTRY_MALAYSIA = 458,
304 	CTRY_MALTA = 470,
305 	CTRY_MEXICO = 484,
306 	CTRY_MONACO = 492,
307 	CTRY_MOROCCO = 504,
308 	CTRY_NEPAL = 524,
309 	CTRY_NETHERLANDS = 528,
310 	CTRY_NETHERLANDS_ANTILLES = 530,
311 	CTRY_NEW_ZEALAND = 554,
312 	CTRY_NICARAGUA = 558,
313 	CTRY_NORWAY = 578,
314 	CTRY_OMAN = 512,
315 	CTRY_PAKISTAN = 586,
316 	CTRY_PANAMA = 591,
317 	CTRY_PAPUA_NEW_GUINEA = 598,
318 	CTRY_PARAGUAY = 600,
319 	CTRY_PERU = 604,
320 	CTRY_PHILIPPINES = 608,
321 	CTRY_POLAND = 616,
322 	CTRY_PORTUGAL = 620,
323 	CTRY_PUERTO_RICO = 630,
324 	CTRY_QATAR = 634,
325 	CTRY_ROMANIA = 642,
326 	CTRY_RUSSIA = 643,
327 	CTRY_SAUDI_ARABIA = 682,
328 	CTRY_SERBIA_MONTENEGRO = 891,
329 	CTRY_SINGAPORE = 702,
330 	CTRY_SLOVAKIA = 703,
331 	CTRY_SLOVENIA = 705,
332 	CTRY_SOUTH_AFRICA = 710,
333 	CTRY_SPAIN = 724,
334 	CTRY_SRI_LANKA = 144,
335 	CTRY_SWEDEN = 752,
336 	CTRY_SWITZERLAND = 756,
337 	CTRY_SYRIA = 760,
338 	CTRY_TAIWAN = 158,
339 	CTRY_THAILAND = 764,
340 	CTRY_TRINIDAD_Y_TOBAGO = 780,
341 	CTRY_TUNISIA = 788,
342 	CTRY_TURKEY = 792,
343 	CTRY_UAE = 784,
344 	CTRY_UKRAINE = 804,
345 	CTRY_UNITED_KINGDOM = 826,
346 	CTRY_UNITED_STATES = 840,
347 	CTRY_UNITED_STATES_FCC49 = 842,
348 	CTRY_URUGUAY = 858,
349 	CTRY_UZBEKISTAN = 860,
350 	CTRY_VENEZUELA = 862,
351 	CTRY_VIET_NAM = 704,
352 	CTRY_YEMEN = 887,
353 	CTRY_ZIMBABWE = 716,
354 	CTRY_JAPAN1 = 393,
355 	CTRY_JAPAN2 = 394,
356 	CTRY_JAPAN3 = 395,
357 	CTRY_JAPAN4 = 396,
358 	CTRY_JAPAN5 = 397,
359 	CTRY_JAPAN6 = 4006,
360 	CTRY_JAPAN7 = 4007,
361 	CTRY_JAPAN8 = 4008,
362 	CTRY_JAPAN9 = 4009,
363 	CTRY_JAPAN10 = 4010,
364 	CTRY_JAPAN11 = 4011,
365 	CTRY_JAPAN12 = 4012,
366 	CTRY_JAPAN13 = 4013,
367 	CTRY_JAPAN14 = 4014,
368 	CTRY_JAPAN15 = 4015,
369 	CTRY_JAPAN16 = 4016,
370 	CTRY_JAPAN17 = 4017,
371 	CTRY_JAPAN18 = 4018,
372 	CTRY_JAPAN19 = 4019,
373 	CTRY_JAPAN20 = 4020,
374 	CTRY_JAPAN21 = 4021,
375 	CTRY_JAPAN22 = 4022,
376 	CTRY_JAPAN23 = 4023,
377 	CTRY_JAPAN24 = 4024,
378 	CTRY_JAPAN25 = 4025,
379 	CTRY_JAPAN26 = 4026,
380 	CTRY_JAPAN27 = 4027,
381 	CTRY_JAPAN28 = 4028,
382 	CTRY_JAPAN29 = 4029,
383 	CTRY_JAPAN30 = 4030,
384 	CTRY_JAPAN31 = 4031,
385 	CTRY_JAPAN32 = 4032,
386 	CTRY_JAPAN33 = 4033,
387 	CTRY_JAPAN34 = 4034,
388 	CTRY_JAPAN35 = 4035,
389 	CTRY_JAPAN36 = 4036,
390 	CTRY_JAPAN37 = 4037,
391 	CTRY_JAPAN38 = 4038,
392 	CTRY_JAPAN39 = 4039,
393 	CTRY_JAPAN40 = 4040,
394 	CTRY_JAPAN41 = 4041,
395 	CTRY_JAPAN42 = 4042,
396 	CTRY_JAPAN43 = 4043,
397 	CTRY_JAPAN44 = 4044,
398 	CTRY_JAPAN45 = 4045,
399 	CTRY_JAPAN46 = 4046,
400 	CTRY_JAPAN47 = 4047,
401 	CTRY_JAPAN48 = 4048,
402 	CTRY_JAPAN49 = 4049,
403 	CTRY_JAPAN50 = 4050,
404 	CTRY_JAPAN51 = 4051,
405 	CTRY_JAPAN52 = 4052,
406 	CTRY_JAPAN53 = 4053,
407 	CTRY_JAPAN54 = 4054,
408 	CTRY_JAPAN55 = 4055,
409 	CTRY_JAPAN56 = 4056,
410 	CTRY_JAPAN57 = 4057,
411 	CTRY_JAPAN58 = 4058,
412 	CTRY_JAPAN59 = 4059,
413 	CTRY_AUSTRALIA2 = 5000,
414 	CTRY_CANADA2 = 5001,
415 	CTRY_BELGIUM2 = 5002
416 };
417 
418 void ath9k_regd_get_current_country(struct ath_hal *ah,
419 				    struct ath9k_country_entry *ctry);
420 
421 #ifdef __cplusplus
422 }
423 #endif
424 
425 #endif /* _ARN_REGD_H */
426