1 /*
2  * Copyright (c) 2008-2009 Atheros Communications Inc.
3  *
4  * Permission to use, copy, modify, and/or distribute this software for any
5  * purpose with or without fee is hereby granted, provided that the above
6  * copyright notice and this permission notice appear in all copies.
7  *
8  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15  */
16 
17 #ifndef REGD_H
18 #define REGD_H
19 
20 #include <linux/nl80211.h>
21 #include <net/cfg80211.h>
22 
23 #include "ath.h"
24 
25 enum ctl_group {
26 	CTL_FCC = 0x10,
27 	CTL_MKK = 0x40,
28 	CTL_ETSI = 0x30,
29 };
30 
31 #define SD_NO_CTL               0xE0
32 #define NO_CTL                  0xff
33 #define CTL_11A                 0
34 #define CTL_11B                 1
35 #define CTL_11G                 2
36 #define CTL_2GHT20              5
37 #define CTL_5GHT20              6
38 #define CTL_2GHT40              7
39 #define CTL_5GHT40              8
40 
41 #define CTRY_DEBUG 0x1ff
42 #define CTRY_DEFAULT 0
43 
44 #define COUNTRY_ERD_FLAG        0x8000
45 #define WORLDWIDE_ROAMING_FLAG  0x4000
46 
47 #define MULTI_DOMAIN_MASK 0xFF00
48 
49 #define WORLD_SKU_MASK          0x00F0
50 #define WORLD_SKU_PREFIX        0x0060
51 
52 #define CHANNEL_HALF_BW         10
53 #define CHANNEL_QUARTER_BW      5
54 
55 struct country_code_to_enum_rd {
56 	u16 countryCode;
57 	u16 regDmnEnum;
58 	const char *isoName;
59 };
60 
61 enum CountryCode {
62 	CTRY_ALBANIA = 8,
63 	CTRY_ALGERIA = 12,
64 	CTRY_ARGENTINA = 32,
65 	CTRY_ARMENIA = 51,
66 	CTRY_ARUBA = 533,
67 	CTRY_AUSTRALIA = 36,
68 	CTRY_AUSTRIA = 40,
69 	CTRY_AZERBAIJAN = 31,
70 	CTRY_BAHAMAS = 44,
71 	CTRY_BAHRAIN = 48,
72 	CTRY_BANGLADESH = 50,
73 	CTRY_BARBADOS = 52,
74 	CTRY_BELARUS = 112,
75 	CTRY_BELGIUM = 56,
76 	CTRY_BELIZE = 84,
77 	CTRY_BERMUDA = 60,
78 	CTRY_BOLIVIA = 68,
79 	CTRY_BOSNIA_HERZ = 70,
80 	CTRY_BRAZIL = 76,
81 	CTRY_BRUNEI_DARUSSALAM = 96,
82 	CTRY_BULGARIA = 100,
83 	CTRY_CAMBODIA = 116,
84 	CTRY_CANADA = 124,
85 	CTRY_CHILE = 152,
86 	CTRY_CHINA = 156,
87 	CTRY_COLOMBIA = 170,
88 	CTRY_COSTA_RICA = 188,
89 	CTRY_CROATIA = 191,
90 	CTRY_CYPRUS = 196,
91 	CTRY_CZECH = 203,
92 	CTRY_DENMARK = 208,
93 	CTRY_DOMINICAN_REPUBLIC = 214,
94 	CTRY_ECUADOR = 218,
95 	CTRY_EGYPT = 818,
96 	CTRY_EL_SALVADOR = 222,
97 	CTRY_ESTONIA = 233,
98 	CTRY_FAEROE_ISLANDS = 234,
99 	CTRY_FINLAND = 246,
100 	CTRY_FRANCE = 250,
101 	CTRY_GEORGIA = 268,
102 	CTRY_GERMANY = 276,
103 	CTRY_GREECE = 300,
104 	CTRY_GREENLAND = 304,
105 	CTRY_GRENADA = 308,
106 	CTRY_GUAM = 316,
107 	CTRY_GUATEMALA = 320,
108 	CTRY_HAITI = 332,
109 	CTRY_HONDURAS = 340,
110 	CTRY_HONG_KONG = 344,
111 	CTRY_HUNGARY = 348,
112 	CTRY_ICELAND = 352,
113 	CTRY_INDIA = 356,
114 	CTRY_INDONESIA = 360,
115 	CTRY_IRAN = 364,
116 	CTRY_IRAQ = 368,
117 	CTRY_IRELAND = 372,
118 	CTRY_ISRAEL = 376,
119 	CTRY_ITALY = 380,
120 	CTRY_JAMAICA = 388,
121 	CTRY_JAPAN = 392,
122 	CTRY_JORDAN = 400,
123 	CTRY_KAZAKHSTAN = 398,
124 	CTRY_KENYA = 404,
125 	CTRY_KOREA_NORTH = 408,
126 	CTRY_KOREA_ROC = 410,
127 	CTRY_KOREA_ROC2 = 411,
128 	CTRY_KOREA_ROC3 = 412,
129 	CTRY_KUWAIT = 414,
130 	CTRY_LATVIA = 428,
131 	CTRY_LEBANON = 422,
132 	CTRY_LIBYA = 434,
133 	CTRY_LIECHTENSTEIN = 438,
134 	CTRY_LITHUANIA = 440,
135 	CTRY_LUXEMBOURG = 442,
136 	CTRY_MACAU = 446,
137 	CTRY_MACEDONIA = 807,
138 	CTRY_MALAYSIA = 458,
139 	CTRY_MALTA = 470,
140 	CTRY_MAURITIUS = 480,
141 	CTRY_MEXICO = 484,
142 	CTRY_MONACO = 492,
143 	CTRY_MONTENEGRO = 499,
144 	CTRY_MOROCCO = 504,
145 	CTRY_NEPAL = 524,
146 	CTRY_NETHERLANDS = 528,
147 	CTRY_NETHERLANDS_ANTILLES = 530,
148 	CTRY_NEW_ZEALAND = 554,
149 	CTRY_NICARAGUA = 558,
150 	CTRY_NORWAY = 578,
151 	CTRY_OMAN = 512,
152 	CTRY_PAKISTAN = 586,
153 	CTRY_PANAMA = 591,
154 	CTRY_PAPUA_NEW_GUINEA = 598,
155 	CTRY_PARAGUAY = 600,
156 	CTRY_PERU = 604,
157 	CTRY_PHILIPPINES = 608,
158 	CTRY_POLAND = 616,
159 	CTRY_PORTUGAL = 620,
160 	CTRY_PUERTO_RICO = 630,
161 	CTRY_QATAR = 634,
162 	CTRY_ROMANIA = 642,
163 	CTRY_RUSSIA = 643,
164 	CTRY_SAUDI_ARABIA = 682,
165 	CTRY_SERBIA = 688,
166 	CTRY_SERBIA_MONTENEGRO = 891,
167 	CTRY_SINGAPORE = 702,
168 	CTRY_SLOVAKIA = 703,
169 	CTRY_SLOVENIA = 705,
170 	CTRY_SOUTH_AFRICA = 710,
171 	CTRY_SPAIN = 724,
172 	CTRY_SRI_LANKA = 144,
173 	CTRY_SWEDEN = 752,
174 	CTRY_SWITZERLAND = 756,
175 	CTRY_SYRIA = 760,
176 	CTRY_TAIWAN = 158,
177 	CTRY_TANZANIA = 834,
178 	CTRY_THAILAND = 764,
179 	CTRY_TRINIDAD_Y_TOBAGO = 780,
180 	CTRY_TUNISIA = 788,
181 	CTRY_TURKEY = 792,
182 	CTRY_UAE = 784,
183 	CTRY_UGANDA = 800,
184 	CTRY_UKRAINE = 804,
185 	CTRY_UNITED_KINGDOM = 826,
186 	CTRY_UNITED_STATES = 840,
187 	CTRY_UNITED_STATES2 = 841,
188 	CTRY_UNITED_STATES_FCC49 = 842,
189 	CTRY_UNITED_STATES3 = 843,
190 	CTRY_URUGUAY = 858,
191 	CTRY_UZBEKISTAN = 860,
192 	CTRY_VENEZUELA = 862,
193 	CTRY_VIET_NAM = 704,
194 	CTRY_YEMEN = 887,
195 	CTRY_ZIMBABWE = 716,
196 	CTRY_JAPAN1 = 393,
197 	CTRY_JAPAN2 = 394,
198 	CTRY_JAPAN3 = 395,
199 	CTRY_JAPAN4 = 396,
200 	CTRY_JAPAN5 = 397,
201 	CTRY_JAPAN6 = 4006,
202 	CTRY_JAPAN7 = 4007,
203 	CTRY_JAPAN8 = 4008,
204 	CTRY_JAPAN9 = 4009,
205 	CTRY_JAPAN10 = 4010,
206 	CTRY_JAPAN11 = 4011,
207 	CTRY_JAPAN12 = 4012,
208 	CTRY_JAPAN13 = 4013,
209 	CTRY_JAPAN14 = 4014,
210 	CTRY_JAPAN15 = 4015,
211 	CTRY_JAPAN16 = 4016,
212 	CTRY_JAPAN17 = 4017,
213 	CTRY_JAPAN18 = 4018,
214 	CTRY_JAPAN19 = 4019,
215 	CTRY_JAPAN20 = 4020,
216 	CTRY_JAPAN21 = 4021,
217 	CTRY_JAPAN22 = 4022,
218 	CTRY_JAPAN23 = 4023,
219 	CTRY_JAPAN24 = 4024,
220 	CTRY_JAPAN25 = 4025,
221 	CTRY_JAPAN26 = 4026,
222 	CTRY_JAPAN27 = 4027,
223 	CTRY_JAPAN28 = 4028,
224 	CTRY_JAPAN29 = 4029,
225 	CTRY_JAPAN30 = 4030,
226 	CTRY_JAPAN31 = 4031,
227 	CTRY_JAPAN32 = 4032,
228 	CTRY_JAPAN33 = 4033,
229 	CTRY_JAPAN34 = 4034,
230 	CTRY_JAPAN35 = 4035,
231 	CTRY_JAPAN36 = 4036,
232 	CTRY_JAPAN37 = 4037,
233 	CTRY_JAPAN38 = 4038,
234 	CTRY_JAPAN39 = 4039,
235 	CTRY_JAPAN40 = 4040,
236 	CTRY_JAPAN41 = 4041,
237 	CTRY_JAPAN42 = 4042,
238 	CTRY_JAPAN43 = 4043,
239 	CTRY_JAPAN44 = 4044,
240 	CTRY_JAPAN45 = 4045,
241 	CTRY_JAPAN46 = 4046,
242 	CTRY_JAPAN47 = 4047,
243 	CTRY_JAPAN48 = 4048,
244 	CTRY_JAPAN49 = 4049,
245 	CTRY_JAPAN50 = 4050,
246 	CTRY_JAPAN51 = 4051,
247 	CTRY_JAPAN52 = 4052,
248 	CTRY_JAPAN53 = 4053,
249 	CTRY_JAPAN54 = 4054,
250 	CTRY_JAPAN55 = 4055,
251 	CTRY_JAPAN56 = 4056,
252 	CTRY_JAPAN57 = 4057,
253 	CTRY_JAPAN58 = 4058,
254 	CTRY_JAPAN59 = 4059,
255 	CTRY_AUSTRALIA2 = 5000,
256 	CTRY_CANADA2 = 5001,
257 	CTRY_BELGIUM2 = 5002
258 };
259 
260 bool ath_is_world_regd(struct ath_regulatory *reg);
261 bool ath_is_49ghz_allowed(u16 redomain);
262 u16 ath_regd_find_country_by_name(char *alpha2);
263 int ath_regd_init(struct ath_regulatory *reg, struct wiphy *wiphy,
264 		  void (*reg_notifier)(struct wiphy *wiphy,
265 				       struct regulatory_request *request));
266 u32 ath_regd_get_band_ctl(struct ath_regulatory *reg,
267 			  enum nl80211_band band);
268 void ath_reg_notifier_apply(struct wiphy *wiphy,
269 			    struct regulatory_request *request,
270 			    struct ath_regulatory *reg);
271 
272 #endif
273