Commit | Line | Data |
---|---|---|
58391efd | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
554c0a3a HG |
2 | /****************************************************************************** |
3 | * | |
4 | * Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved. | |
5 | * | |
554c0a3a HG |
6 | ******************************************************************************/ |
7 | #ifndef _WIFI_H_ | |
8 | #define _WIFI_H_ | |
9 | ||
10 | ||
11 | #ifdef BIT | |
12 | /* error "BIT define occurred earlier elsewhere!\n" */ | |
13 | #undef BIT | |
14 | #endif | |
15 | #define BIT(x) (1 << (x)) | |
16 | ||
17 | ||
18 | #define WLAN_ETHHDR_LEN 14 | |
19 | #define WLAN_ETHADDR_LEN 6 | |
20 | #define WLAN_IEEE_OUI_LEN 3 | |
21 | #define WLAN_ADDR_LEN 6 | |
22 | #define WLAN_CRC_LEN 4 | |
23 | #define WLAN_BSSID_LEN 6 | |
24 | #define WLAN_BSS_TS_LEN 8 | |
25 | #define WLAN_HDR_A3_LEN 24 | |
26 | #define WLAN_HDR_A4_LEN 30 | |
27 | #define WLAN_HDR_A3_QOS_LEN 26 | |
28 | #define WLAN_HDR_A4_QOS_LEN 32 | |
29 | #define WLAN_SSID_MAXLEN 32 | |
30 | #define WLAN_DATA_MAXLEN 2312 | |
31 | ||
32 | #define WLAN_A3_PN_OFFSET 24 | |
33 | #define WLAN_A4_PN_OFFSET 30 | |
34 | ||
35 | #define WLAN_MIN_ETHFRM_LEN 60 | |
36 | #define WLAN_MAX_ETHFRM_LEN 1514 | |
37 | #define WLAN_ETHHDR_LEN 14 | |
38 | #define WLAN_WMM_LEN 24 | |
39 | ||
40 | #define P80211CAPTURE_VERSION 0x80211001 | |
41 | ||
42 | /* This value is tested by WiFi 11n Test Plan 5.2.3. */ | |
43 | /* This test verifies the WLAN NIC can update the NAV through sending the CTS with large duration. */ | |
44 | #define WiFiNavUpperUs 30000 /* 30 ms */ | |
45 | ||
46 | enum WIFI_FRAME_TYPE { | |
47 | WIFI_MGT_TYPE = (0), | |
48 | WIFI_CTRL_TYPE = (BIT(2)), | |
49 | WIFI_DATA_TYPE = (BIT(3)), | |
50 | WIFI_QOS_DATA_TYPE = (BIT(7)|BIT(3)), /* QoS Data */ | |
51 | }; | |
52 | ||
53 | enum WIFI_FRAME_SUBTYPE { | |
54 | ||
55 | /* below is for mgt frame */ | |
56 | WIFI_ASSOCREQ = (0 | WIFI_MGT_TYPE), | |
57 | WIFI_ASSOCRSP = (BIT(4) | WIFI_MGT_TYPE), | |
58 | WIFI_REASSOCREQ = (BIT(5) | WIFI_MGT_TYPE), | |
59 | WIFI_REASSOCRSP = (BIT(5) | BIT(4) | WIFI_MGT_TYPE), | |
60 | WIFI_PROBEREQ = (BIT(6) | WIFI_MGT_TYPE), | |
61 | WIFI_PROBERSP = (BIT(6) | BIT(4) | WIFI_MGT_TYPE), | |
62 | WIFI_BEACON = (BIT(7) | WIFI_MGT_TYPE), | |
63 | WIFI_ATIM = (BIT(7) | BIT(4) | WIFI_MGT_TYPE), | |
64 | WIFI_DISASSOC = (BIT(7) | BIT(5) | WIFI_MGT_TYPE), | |
65 | WIFI_AUTH = (BIT(7) | BIT(5) | BIT(4) | WIFI_MGT_TYPE), | |
66 | WIFI_DEAUTH = (BIT(7) | BIT(6) | WIFI_MGT_TYPE), | |
67 | WIFI_ACTION = (BIT(7) | BIT(6) | BIT(4) | WIFI_MGT_TYPE), | |
68 | WIFI_ACTION_NOACK = (BIT(7) | BIT(6) | BIT(5) | WIFI_MGT_TYPE), | |
69 | ||
70 | /* below is for control frame */ | |
71 | WIFI_NDPA = (BIT(6) | BIT(4) | WIFI_CTRL_TYPE), | |
72 | WIFI_PSPOLL = (BIT(7) | BIT(5) | WIFI_CTRL_TYPE), | |
73 | WIFI_RTS = (BIT(7) | BIT(5) | BIT(4) | WIFI_CTRL_TYPE), | |
74 | WIFI_CTS = (BIT(7) | BIT(6) | WIFI_CTRL_TYPE), | |
75 | WIFI_ACK = (BIT(7) | BIT(6) | BIT(4) | WIFI_CTRL_TYPE), | |
76 | WIFI_CFEND = (BIT(7) | BIT(6) | BIT(5) | WIFI_CTRL_TYPE), | |
77 | WIFI_CFEND_CFACK = (BIT(7) | BIT(6) | BIT(5) | BIT(4) | WIFI_CTRL_TYPE), | |
78 | ||
79 | /* below is for data frame */ | |
80 | WIFI_DATA = (0 | WIFI_DATA_TYPE), | |
81 | WIFI_DATA_CFACK = (BIT(4) | WIFI_DATA_TYPE), | |
82 | WIFI_DATA_CFPOLL = (BIT(5) | WIFI_DATA_TYPE), | |
83 | WIFI_DATA_CFACKPOLL = (BIT(5) | BIT(4) | WIFI_DATA_TYPE), | |
84 | WIFI_DATA_NULL = (BIT(6) | WIFI_DATA_TYPE), | |
85 | WIFI_CF_ACK = (BIT(6) | BIT(4) | WIFI_DATA_TYPE), | |
86 | WIFI_CF_POLL = (BIT(6) | BIT(5) | WIFI_DATA_TYPE), | |
87 | WIFI_CF_ACKPOLL = (BIT(6) | BIT(5) | BIT(4) | WIFI_DATA_TYPE), | |
88 | WIFI_QOS_DATA_NULL = (BIT(6) | WIFI_QOS_DATA_TYPE), | |
89 | }; | |
90 | ||
91 | enum WIFI_REASON_CODE { | |
92 | _RSON_RESERVED_ = 0, | |
93 | _RSON_UNSPECIFIED_ = 1, | |
94 | _RSON_AUTH_NO_LONGER_VALID_ = 2, | |
95 | _RSON_DEAUTH_STA_LEAVING_ = 3, | |
96 | _RSON_INACTIVITY_ = 4, | |
97 | _RSON_UNABLE_HANDLE_ = 5, | |
98 | _RSON_CLS2_ = 6, | |
99 | _RSON_CLS3_ = 7, | |
100 | _RSON_DISAOC_STA_LEAVING_ = 8, | |
101 | _RSON_ASOC_NOT_AUTH_ = 9, | |
102 | ||
103 | /* WPA reason */ | |
104 | _RSON_INVALID_IE_ = 13, | |
105 | _RSON_MIC_FAILURE_ = 14, | |
106 | _RSON_4WAY_HNDSHK_TIMEOUT_ = 15, | |
107 | _RSON_GROUP_KEY_UPDATE_TIMEOUT_ = 16, | |
108 | _RSON_DIFF_IE_ = 17, | |
109 | _RSON_MLTCST_CIPHER_NOT_VALID_ = 18, | |
110 | _RSON_UNICST_CIPHER_NOT_VALID_ = 19, | |
111 | _RSON_AKMP_NOT_VALID_ = 20, | |
112 | _RSON_UNSUPPORT_RSNE_VER_ = 21, | |
113 | _RSON_INVALID_RSNE_CAP_ = 22, | |
114 | _RSON_IEEE_802DOT1X_AUTH_FAIL_ = 23, | |
115 | ||
116 | /* belowing are Realtek definition */ | |
117 | _RSON_PMK_NOT_AVAILABLE_ = 24, | |
118 | _RSON_TDLS_TEAR_TOOFAR_ = 25, | |
119 | _RSON_TDLS_TEAR_UN_RSN_ = 26, | |
120 | }; | |
121 | ||
122 | /* Reason codes (IEEE 802.11-2007, 7.3.1.7, Table 7-22) */ | |
123 | /* IEEE 802.11h */ | |
124 | #define WLAN_REASON_PWR_CAPABILITY_NOT_VALID 10 | |
125 | #define WLAN_REASON_SUPPORTED_CHANNEL_NOT_VALID 11 | |
126 | ||
127 | enum WIFI_STATUS_CODE { | |
128 | _STATS_SUCCESSFUL_ = 0, | |
129 | _STATS_FAILURE_ = 1, | |
130 | _STATS_CAP_FAIL_ = 10, | |
131 | _STATS_NO_ASOC_ = 11, | |
132 | _STATS_OTHER_ = 12, | |
133 | _STATS_NO_SUPP_ALG_ = 13, | |
134 | _STATS_OUT_OF_AUTH_SEQ_ = 14, | |
135 | _STATS_CHALLENGE_FAIL_ = 15, | |
136 | _STATS_AUTH_TIMEOUT_ = 16, | |
137 | _STATS_UNABLE_HANDLE_STA_ = 17, | |
138 | _STATS_RATE_FAIL_ = 18, | |
139 | }; | |
140 | ||
141 | /* Status codes (IEEE 802.11-2007, 7.3.1.9, Table 7-23) */ | |
142 | /* entended */ | |
143 | /* IEEE 802.11b */ | |
144 | #define WLAN_STATUS_ASSOC_DENIED_NOSHORT 19 | |
145 | #define WLAN_STATUS_ASSOC_DENIED_NOPBCC 20 | |
146 | #define WLAN_STATUS_ASSOC_DENIED_NOAGILITY 21 | |
147 | /* IEEE 802.11h */ | |
148 | #define WLAN_STATUS_SPEC_MGMT_REQUIRED 22 | |
149 | #define WLAN_STATUS_PWR_CAPABILITY_NOT_VALID 23 | |
150 | #define WLAN_STATUS_SUPPORTED_CHANNEL_NOT_VALID 24 | |
151 | /* IEEE 802.11g */ | |
152 | #define WLAN_STATUS_ASSOC_DENIED_NO_SHORT_SLOT_TIME 25 | |
153 | #define WLAN_STATUS_ASSOC_DENIED_NO_ER_PBCC 26 | |
154 | #define WLAN_STATUS_ASSOC_DENIED_NO_DSSS_OFDM 27 | |
155 | /* IEEE 802.11w */ | |
156 | #define WLAN_STATUS_ASSOC_REJECTED_TEMPORARILY 30 | |
157 | #define WLAN_STATUS_ROBUST_MGMT_FRAME_POLICY_VIOLATION 31 | |
158 | /* IEEE 802.11i */ | |
159 | #define WLAN_STATUS_INVALID_IE 40 | |
160 | #define WLAN_STATUS_GROUP_CIPHER_NOT_VALID 41 | |
161 | #define WLAN_STATUS_PAIRWISE_CIPHER_NOT_VALID 42 | |
162 | #define WLAN_STATUS_AKMP_NOT_VALID 43 | |
163 | #define WLAN_STATUS_UNSUPPORTED_RSN_IE_VERSION 44 | |
164 | #define WLAN_STATUS_INVALID_RSN_IE_CAPAB 45 | |
165 | #define WLAN_STATUS_CIPHER_REJECTED_PER_POLICY 46 | |
166 | #define WLAN_STATUS_TS_NOT_CREATED 47 | |
167 | #define WLAN_STATUS_DIRECT_LINK_NOT_ALLOWED 48 | |
168 | #define WLAN_STATUS_DEST_STA_NOT_PRESENT 49 | |
169 | #define WLAN_STATUS_DEST_STA_NOT_QOS_STA 50 | |
170 | #define WLAN_STATUS_ASSOC_DENIED_LISTEN_INT_TOO_LARGE 51 | |
171 | /* IEEE 802.11r */ | |
172 | #define WLAN_STATUS_INVALID_FT_ACTION_FRAME_COUNT 52 | |
173 | #define WLAN_STATUS_INVALID_PMKID 53 | |
174 | #define WLAN_STATUS_INVALID_MDIE 54 | |
175 | #define WLAN_STATUS_INVALID_FTIE 55 | |
176 | ||
177 | ||
178 | enum WIFI_REG_DOMAIN { | |
179 | DOMAIN_FCC = 1, | |
180 | DOMAIN_IC = 2, | |
181 | DOMAIN_ETSI = 3, | |
182 | DOMAIN_SPAIN = 4, | |
183 | DOMAIN_FRANCE = 5, | |
184 | DOMAIN_MKK = 6, | |
185 | DOMAIN_ISRAEL = 7, | |
186 | DOMAIN_MKK1 = 8, | |
187 | DOMAIN_MKK2 = 9, | |
188 | DOMAIN_MKK3 = 10, | |
189 | DOMAIN_MAX | |
190 | }; | |
191 | ||
192 | #define _TO_DS_ BIT(8) | |
193 | #define _FROM_DS_ BIT(9) | |
194 | #define _MORE_FRAG_ BIT(10) | |
195 | #define _RETRY_ BIT(11) | |
196 | #define _PWRMGT_ BIT(12) | |
197 | #define _MORE_DATA_ BIT(13) | |
198 | #define _PRIVACY_ BIT(14) | |
199 | #define _ORDER_ BIT(15) | |
200 | ||
201 | #define SetToDs(pbuf) \ | |
202 | *(__le16 *)(pbuf) |= cpu_to_le16(_TO_DS_) | |
203 | ||
204 | #define GetToDs(pbuf) (((*(__le16 *)(pbuf)) & cpu_to_le16(_TO_DS_)) != 0) | |
205 | ||
206 | #define ClearToDs(pbuf) \ | |
207 | *(__le16 *)(pbuf) &= (~cpu_to_le16(_TO_DS_)) | |
208 | ||
209 | #define SetFrDs(pbuf) \ | |
210 | *(__le16 *)(pbuf) |= cpu_to_le16(_FROM_DS_) | |
211 | ||
212 | #define GetFrDs(pbuf) (((*(__le16 *)(pbuf)) & cpu_to_le16(_FROM_DS_)) != 0) | |
213 | ||
214 | #define ClearFrDs(pbuf) \ | |
215 | *(__le16 *)(pbuf) &= (~cpu_to_le16(_FROM_DS_)) | |
216 | ||
217 | #define get_tofr_ds(pframe) ((GetToDs(pframe) << 1) | GetFrDs(pframe)) | |
218 | ||
219 | #define SetMFrag(pbuf) \ | |
220 | *(__le16 *)(pbuf) |= cpu_to_le16(_MORE_FRAG_) | |
221 | ||
222 | #define GetMFrag(pbuf) (((*(__le16 *)(pbuf)) & cpu_to_le16(_MORE_FRAG_)) != 0) | |
223 | ||
224 | #define ClearMFrag(pbuf) \ | |
225 | *(__le16 *)(pbuf) &= (~cpu_to_le16(_MORE_FRAG_)) | |
226 | ||
227 | #define SetRetry(pbuf) \ | |
228 | *(__le16 *)(pbuf) |= cpu_to_le16(_RETRY_) | |
229 | ||
230 | #define GetRetry(pbuf) (((*(__le16 *)(pbuf)) & cpu_to_le16(_RETRY_)) != 0) | |
231 | ||
232 | #define ClearRetry(pbuf) \ | |
233 | *(__le16 *)(pbuf) &= (~cpu_to_le16(_RETRY_)) | |
234 | ||
235 | #define SetPwrMgt(pbuf) \ | |
236 | *(__le16 *)(pbuf) |= cpu_to_le16(_PWRMGT_) | |
237 | ||
238 | #define GetPwrMgt(pbuf) (((*(__le16 *)(pbuf)) & cpu_to_le16(_PWRMGT_)) != 0) | |
239 | ||
240 | #define ClearPwrMgt(pbuf) \ | |
241 | *(__le16 *)(pbuf) &= (~cpu_to_le16(_PWRMGT_)) | |
242 | ||
243 | #define SetMData(pbuf) \ | |
244 | *(__le16 *)(pbuf) |= cpu_to_le16(_MORE_DATA_) | |
245 | ||
246 | #define GetMData(pbuf) (((*(__le16 *)(pbuf)) & cpu_to_le16(_MORE_DATA_)) != 0) | |
247 | ||
248 | #define ClearMData(pbuf) \ | |
249 | *(__le16 *)(pbuf) &= (~cpu_to_le16(_MORE_DATA_)) | |
250 | ||
251 | #define SetPrivacy(pbuf) \ | |
252 | *(__le16 *)(pbuf) |= cpu_to_le16(_PRIVACY_) | |
253 | ||
254 | #define GetPrivacy(pbuf) \ | |
255 | (((*(__le16 *)(pbuf)) & cpu_to_le16(_PRIVACY_)) != 0) | |
256 | ||
257 | #define ClearPrivacy(pbuf) \ | |
258 | *(__le16 *)(pbuf) &= (~cpu_to_le16(_PRIVACY_)) | |
259 | ||
260 | ||
261 | #define GetOrder(pbuf) \ | |
262 | (((*(__le16 *)(pbuf)) & cpu_to_le16(_ORDER_)) != 0) | |
263 | ||
264 | #define GetFrameType(pbuf) \ | |
265 | (le16_to_cpu(*(__le16 *)(pbuf)) & (BIT(3) | BIT(2))) | |
266 | ||
267 | #define SetFrameType(pbuf, type) \ | |
268 | do { \ | |
403fa6de SS |
269 | *(unsigned short *)(pbuf) &= cpu_to_le16(~(BIT(3) | BIT(2))); \ |
270 | *(unsigned short *)(pbuf) |= cpu_to_le16(type); \ | |
554c0a3a HG |
271 | } while (0) |
272 | ||
273 | #define GetFrameSubType(pbuf) (le16_to_cpu(*(__le16 *)(pbuf)) & (BIT(7) |\ | |
274 | BIT(6) | BIT(5) | BIT(4) | BIT(3) | BIT(2))) | |
275 | ||
276 | #define SetFrameSubType(pbuf, type) \ | |
277 | do { \ | |
278 | *(__le16 *)(pbuf) &= cpu_to_le16(~(BIT(7) | BIT(6) | \ | |
279 | BIT(5) | BIT(4) | BIT(3) | BIT(2))); \ | |
280 | *(__le16 *)(pbuf) |= cpu_to_le16(type); \ | |
281 | } while (0) | |
282 | ||
283 | #define GetSequence(pbuf) \ | |
284 | (le16_to_cpu(*(__le16 *)((size_t)(pbuf) + 22)) >> 4) | |
285 | ||
286 | #define GetFragNum(pbuf) \ | |
287 | (le16_to_cpu(*(__le16 *)((size_t)(pbuf) + 22)) & 0x0f) | |
288 | ||
289 | #define GetTupleCache(pbuf) \ | |
290 | (cpu_to_le16(*(unsigned short *)((size_t)(pbuf) + 22))) | |
291 | ||
292 | #define SetFragNum(pbuf, num) \ | |
293 | do { \ | |
294 | *(unsigned short *)((size_t)(pbuf) + 22) = \ | |
295 | ((*(unsigned short *)((size_t)(pbuf) + 22)) & \ | |
296 | le16_to_cpu(~(0x000f))) | \ | |
297 | cpu_to_le16(0x0f & (num)); \ | |
298 | } while (0) | |
299 | ||
300 | #define SetSeqNum(pbuf, num) \ | |
301 | do { \ | |
302 | *(__le16 *)((size_t)(pbuf) + 22) = \ | |
303 | ((*(__le16 *)((size_t)(pbuf) + 22)) & cpu_to_le16((unsigned short)0x000f)) | \ | |
304 | cpu_to_le16((unsigned short)(0xfff0 & (num << 4))); \ | |
305 | } while (0) | |
306 | ||
307 | #define SetDuration(pbuf, dur) \ | |
308 | *(__le16 *)((size_t)(pbuf) + 2) = cpu_to_le16(0xffff & (dur)) | |
309 | ||
310 | ||
311 | #define SetPriority(pbuf, tid) \ | |
312 | *(__le16 *)(pbuf) |= cpu_to_le16(tid & 0xf) | |
313 | ||
314 | #define GetPriority(pbuf) ((le16_to_cpu(*(__le16 *)(pbuf))) & 0xf) | |
315 | ||
316 | #define SetEOSP(pbuf, eosp) \ | |
317 | *(__le16 *)(pbuf) |= cpu_to_le16((eosp & 1) << 4) | |
318 | ||
319 | #define SetAckpolicy(pbuf, ack) \ | |
320 | *(__le16 *)(pbuf) |= cpu_to_le16((ack & 3) << 5) | |
321 | ||
322 | #define GetAckpolicy(pbuf) (((le16_to_cpu(*(__le16 *)pbuf)) >> 5) & 0x3) | |
323 | ||
324 | #define GetAMsdu(pbuf) (((le16_to_cpu(*(__le16 *)pbuf)) >> 7) & 0x1) | |
325 | ||
326 | #define SetAMsdu(pbuf, amsdu) \ | |
327 | *(__le16 *)(pbuf) |= cpu_to_le16((amsdu & 1) << 7) | |
328 | ||
329 | #define GetAid(pbuf) (le16_to_cpu(*(__le16 *)((size_t)(pbuf) + 2)) & 0x3fff) | |
330 | ||
331 | #define GetTid(pbuf) (le16_to_cpu(*(__le16 *)((size_t)(pbuf) + \ | |
332 | (((GetToDs(pbuf)<<1) | GetFrDs(pbuf)) == 3 ? \ | |
333 | 30 : 24))) & 0x000f) | |
334 | ||
335 | #define GetAddr1Ptr(pbuf) ((unsigned char *)((size_t)(pbuf) + 4)) | |
336 | ||
337 | #define GetAddr2Ptr(pbuf) ((unsigned char *)((size_t)(pbuf) + 10)) | |
338 | ||
339 | #define GetAddr3Ptr(pbuf) ((unsigned char *)((size_t)(pbuf) + 16)) | |
340 | ||
341 | #define GetAddr4Ptr(pbuf) ((unsigned char *)((size_t)(pbuf) + 24)) | |
342 | ||
343 | #define MacAddr_isBcst(addr) \ | |
344 | (\ | |
345 | ((addr[0] == 0xff) && (addr[1] == 0xff) && \ | |
346 | (addr[2] == 0xff) && (addr[3] == 0xff) && \ | |
347 | (addr[4] == 0xff) && (addr[5] == 0xff)) ? true : false \ | |
348 | ) | |
349 | ||
4a397521 | 350 | static inline int IS_MCAST(unsigned char *da) |
554c0a3a HG |
351 | { |
352 | if ((*da) & 0x01) | |
353 | return true; | |
354 | else | |
355 | return false; | |
356 | } | |
357 | ||
4a397521 | 358 | static inline unsigned char * get_ra(unsigned char *pframe) |
554c0a3a HG |
359 | { |
360 | unsigned char *ra; | |
361 | ra = GetAddr1Ptr(pframe); | |
362 | return ra; | |
363 | } | |
4a397521 | 364 | static inline unsigned char * get_ta(unsigned char *pframe) |
554c0a3a HG |
365 | { |
366 | unsigned char *ta; | |
367 | ta = GetAddr2Ptr(pframe); | |
368 | return ta; | |
369 | } | |
370 | ||
4a397521 | 371 | static inline unsigned char * get_da(unsigned char *pframe) |
554c0a3a HG |
372 | { |
373 | unsigned char *da; | |
374 | unsigned int to_fr_ds = (GetToDs(pframe) << 1) | GetFrDs(pframe); | |
375 | ||
376 | switch (to_fr_ds) { | |
9c0867e0 VN |
377 | case 0x00: /* ToDs = 0, FromDs = 0 */ |
378 | da = GetAddr1Ptr(pframe); | |
379 | break; | |
380 | case 0x01: /* ToDs = 0, FromDs = 1 */ | |
381 | da = GetAddr1Ptr(pframe); | |
382 | break; | |
383 | case 0x02: /* ToDs = 1, FromDs = 0 */ | |
384 | da = GetAddr3Ptr(pframe); | |
385 | break; | |
386 | default: /* ToDs = 1, FromDs = 1 */ | |
387 | da = GetAddr3Ptr(pframe); | |
388 | break; | |
554c0a3a HG |
389 | } |
390 | ||
391 | return da; | |
392 | } | |
393 | ||
394 | ||
4a397521 | 395 | static inline unsigned char * get_sa(unsigned char *pframe) |
554c0a3a HG |
396 | { |
397 | unsigned char *sa; | |
398 | unsigned int to_fr_ds = (GetToDs(pframe) << 1) | GetFrDs(pframe); | |
399 | ||
400 | switch (to_fr_ds) { | |
9c0867e0 VN |
401 | case 0x00: /* ToDs = 0, FromDs = 0 */ |
402 | sa = GetAddr2Ptr(pframe); | |
403 | break; | |
404 | case 0x01: /* ToDs = 0, FromDs = 1 */ | |
405 | sa = GetAddr3Ptr(pframe); | |
406 | break; | |
407 | case 0x02: /* ToDs = 1, FromDs = 0 */ | |
408 | sa = GetAddr2Ptr(pframe); | |
409 | break; | |
410 | default: /* ToDs = 1, FromDs = 1 */ | |
411 | sa = GetAddr4Ptr(pframe); | |
412 | break; | |
554c0a3a HG |
413 | } |
414 | ||
415 | return sa; | |
416 | } | |
417 | ||
4a397521 | 418 | static inline unsigned char * get_hdr_bssid(unsigned char *pframe) |
554c0a3a HG |
419 | { |
420 | unsigned char *sa = NULL; | |
421 | unsigned int to_fr_ds = (GetToDs(pframe) << 1) | GetFrDs(pframe); | |
422 | ||
423 | switch (to_fr_ds) { | |
9c0867e0 VN |
424 | case 0x00: /* ToDs = 0, FromDs = 0 */ |
425 | sa = GetAddr3Ptr(pframe); | |
426 | break; | |
427 | case 0x01: /* ToDs = 0, FromDs = 1 */ | |
428 | sa = GetAddr2Ptr(pframe); | |
429 | break; | |
430 | case 0x02: /* ToDs = 1, FromDs = 0 */ | |
431 | sa = GetAddr1Ptr(pframe); | |
432 | break; | |
433 | case 0x03: /* ToDs = 1, FromDs = 1 */ | |
434 | sa = GetAddr1Ptr(pframe); | |
435 | break; | |
554c0a3a HG |
436 | } |
437 | ||
438 | return sa; | |
439 | } | |
440 | ||
441 | ||
4a397521 | 442 | static inline int IsFrameTypeCtrl(unsigned char *pframe) |
554c0a3a HG |
443 | { |
444 | if (WIFI_CTRL_TYPE == GetFrameType(pframe)) | |
445 | return true; | |
446 | else | |
447 | return false; | |
448 | } | |
449 | /*----------------------------------------------------------------------------- | |
450 | Below is for the security related definition | |
451 | ------------------------------------------------------------------------------*/ | |
452 | #define _RESERVED_FRAME_TYPE_ 0 | |
453 | #define _SKB_FRAME_TYPE_ 2 | |
454 | #define _PRE_ALLOCMEM_ 1 | |
455 | #define _PRE_ALLOCHDR_ 3 | |
456 | #define _PRE_ALLOCLLCHDR_ 4 | |
457 | #define _PRE_ALLOCICVHDR_ 5 | |
458 | #define _PRE_ALLOCMICHDR_ 6 | |
459 | ||
460 | #define _SIFSTIME_ ((priv->pmib->dot11BssType.net_work_type&WIRELESS_11A)?16:10) | |
461 | #define _ACKCTSLNG_ 14 /* 14 bytes long, including crclng */ | |
462 | #define _CRCLNG_ 4 | |
463 | ||
464 | #define _ASOCREQ_IE_OFFSET_ 4 /* excluding wlan_hdr */ | |
465 | #define _ASOCRSP_IE_OFFSET_ 6 | |
466 | #define _REASOCREQ_IE_OFFSET_ 10 | |
467 | #define _REASOCRSP_IE_OFFSET_ 6 | |
468 | #define _PROBEREQ_IE_OFFSET_ 0 | |
469 | #define _PROBERSP_IE_OFFSET_ 12 | |
470 | #define _AUTH_IE_OFFSET_ 6 | |
471 | #define _DEAUTH_IE_OFFSET_ 0 | |
472 | #define _BEACON_IE_OFFSET_ 12 | |
473 | #define _PUBLIC_ACTION_IE_OFFSET_ 8 | |
474 | ||
475 | #define _FIXED_IE_LENGTH_ _BEACON_IE_OFFSET_ | |
476 | ||
477 | #define _SSID_IE_ 0 | |
478 | #define _SUPPORTEDRATES_IE_ 1 | |
479 | #define _DSSET_IE_ 3 | |
480 | #define _TIM_IE_ 5 | |
481 | #define _IBSS_PARA_IE_ 6 | |
482 | #define _COUNTRY_IE_ 7 | |
483 | #define _CHLGETXT_IE_ 16 | |
484 | #define _SUPPORTED_CH_IE_ 36 | |
485 | #define _CH_SWTICH_ANNOUNCE_ 37 /* Secondary Channel Offset */ | |
486 | #define _RSN_IE_2_ 48 | |
487 | #define _SSN_IE_1_ 221 | |
488 | #define _ERPINFO_IE_ 42 | |
489 | #define _EXT_SUPPORTEDRATES_IE_ 50 | |
490 | ||
491 | #define _HT_CAPABILITY_IE_ 45 | |
492 | #define _FTIE_ 55 | |
493 | #define _TIMEOUT_ITVL_IE_ 56 | |
494 | #define _SRC_IE_ 59 | |
495 | #define _HT_EXTRA_INFO_IE_ 61 | |
496 | #define _HT_ADD_INFO_IE_ 61 /* _HT_EXTRA_INFO_IE_ */ | |
497 | #define _WAPI_IE_ 68 | |
498 | ||
499 | #define _RIC_Descriptor_IE_ 75 | |
500 | #define _MME_IE_ 76 /* 802.11w Management MIC element */ | |
501 | #define _LINK_ID_IE_ 101 | |
502 | #define _CH_SWITCH_TIMING_ 104 | |
503 | #define _PTI_BUFFER_STATUS_ 106 | |
504 | #define _EXT_CAP_IE_ 127 | |
505 | #define _VENDOR_SPECIFIC_IE_ 221 | |
506 | ||
507 | #define _RESERVED47_ 47 | |
508 | ||
509 | enum ELEMENT_ID { | |
510 | EID_SsId = 0, /* service set identifier (0:32) */ | |
511 | EID_SupRates = 1, /* supported rates (1:8) */ | |
512 | EID_FHParms = 2, /* FH parameter set (5) */ | |
513 | EID_DSParms = 3, /* DS parameter set (1) */ | |
514 | EID_CFParms = 4, /* CF parameter set (6) */ | |
515 | EID_Tim = 5, /* Traffic Information Map (4:254) */ | |
516 | EID_IbssParms = 6, /* IBSS parameter set (2) */ | |
517 | EID_Country = 7, /* */ | |
518 | ||
519 | /* Form 7.3.2: Information elements in 802.11E/D13.0, page 46. */ | |
520 | EID_QBSSLoad = 11, | |
521 | EID_EDCAParms = 12, | |
522 | EID_TSpec = 13, | |
523 | EID_TClass = 14, | |
524 | EID_Schedule = 15, | |
525 | /* */ | |
526 | ||
527 | EID_Ctext = 16, /* challenge text*/ | |
528 | EID_POWER_CONSTRAINT = 32, /* Power Constraint*/ | |
529 | ||
530 | /* vivi for WIFITest, 802.11h AP, 20100427 */ | |
531 | /* 2010/12/26 MH The definition we can declare always!! */ | |
532 | EID_PowerCap = 33, | |
533 | EID_SupportedChannels = 36, | |
534 | EID_ChlSwitchAnnounce = 37, | |
535 | ||
536 | EID_MeasureRequest = 38, /* Measurement Request */ | |
537 | EID_MeasureReport = 39, /* Measurement Report */ | |
538 | ||
539 | EID_ERPInfo = 42, | |
540 | ||
541 | /* Form 7.3.2: Information elements in 802.11E/D13.0, page 46. */ | |
542 | EID_TSDelay = 43, | |
543 | EID_TCLASProc = 44, | |
544 | EID_HTCapability = 45, | |
545 | EID_QoSCap = 46, | |
546 | /* */ | |
547 | ||
548 | EID_WPA2 = 48, | |
549 | EID_ExtSupRates = 50, | |
550 | ||
551 | EID_FTIE = 55, /* Defined in 802.11r */ | |
552 | EID_Timeout = 56, /* Defined in 802.11r */ | |
553 | ||
554 | EID_SupRegulatory = 59, /* Supported Requlatory Classes 802.11y */ | |
555 | EID_HTInfo = 61, | |
556 | EID_SecondaryChnlOffset = 62, | |
557 | ||
558 | EID_BSSCoexistence = 72, /* 20/40 BSS Coexistence */ | |
559 | EID_BSSIntolerantChlReport = 73, | |
560 | EID_OBSS = 74, /* Overlapping BSS Scan Parameters */ | |
561 | ||
562 | EID_LinkIdentifier = 101, /* Defined in 802.11z */ | |
563 | EID_WakeupSchedule = 102, /* Defined in 802.11z */ | |
564 | EID_ChnlSwitchTimeing = 104, /* Defined in 802.11z */ | |
565 | EID_PTIControl = 105, /* Defined in 802.11z */ | |
566 | EID_PUBufferStatus = 106, /* Defined in 802.11z */ | |
567 | ||
568 | EID_EXTCapability = 127, /* Extended Capabilities */ | |
569 | /* From S19:Aironet IE and S21:AP IP address IE in CCX v1.13, p16 and p18. */ | |
570 | EID_Aironet = 133, /* 0x85: Aironet Element for Cisco CCX */ | |
571 | EID_CiscoIP = 149, /* 0x95: IP Address IE for Cisco CCX */ | |
572 | ||
573 | EID_CellPwr = 150, /* 0x96: Cell Power Limit IE. Ref. 0x96. */ | |
574 | ||
575 | EID_CCKM = 156, | |
576 | ||
577 | EID_Vendor = 221, /* 0xDD: Vendor Specific */ | |
578 | ||
579 | EID_WAPI = 68, | |
580 | EID_VHTCapability = 191, /* Based on 802.11ac D2.0 */ | |
581 | EID_VHTOperation = 192, /* Based on 802.11ac D2.0 */ | |
582 | EID_OpModeNotification = 199, /* Based on 802.11ac D3.0 */ | |
583 | }; | |
584 | ||
585 | /* --------------------------------------------------------------------------- | |
586 | Below is the fixed elements... | |
587 | -----------------------------------------------------------------------------*/ | |
588 | #define _AUTH_ALGM_NUM_ 2 | |
589 | #define _AUTH_SEQ_NUM_ 2 | |
590 | #define _BEACON_ITERVAL_ 2 | |
591 | #define _CAPABILITY_ 2 | |
592 | #define _CURRENT_APADDR_ 6 | |
593 | #define _LISTEN_INTERVAL_ 2 | |
594 | #define _RSON_CODE_ 2 | |
595 | #define _ASOC_ID_ 2 | |
596 | #define _STATUS_CODE_ 2 | |
597 | #define _TIMESTAMP_ 8 | |
598 | ||
599 | #define AUTH_ODD_TO 0 | |
600 | #define AUTH_EVEN_TO 1 | |
601 | ||
602 | #define WLAN_ETHCONV_ENCAP 1 | |
603 | #define WLAN_ETHCONV_RFC1042 2 | |
604 | #define WLAN_ETHCONV_8021h 3 | |
605 | ||
606 | #define cap_ESS BIT(0) | |
607 | #define cap_IBSS BIT(1) | |
608 | #define cap_CFPollable BIT(2) | |
609 | #define cap_CFRequest BIT(3) | |
610 | #define cap_Privacy BIT(4) | |
611 | #define cap_ShortPremble BIT(5) | |
612 | #define cap_PBCC BIT(6) | |
613 | #define cap_ChAgility BIT(7) | |
614 | #define cap_SpecMgmt BIT(8) | |
615 | #define cap_QoS BIT(9) | |
616 | #define cap_ShortSlot BIT(10) | |
617 | ||
618 | /*----------------------------------------------------------------------------- | |
619 | Below is the definition for 802.11i / 802.1x | |
620 | ------------------------------------------------------------------------------*/ | |
621 | #define _IEEE8021X_MGT_ 1 /* WPA */ | |
622 | #define _IEEE8021X_PSK_ 2 /* WPA with pre-shared key */ | |
623 | ||
624 | #define _MME_IE_LENGTH_ 18 | |
625 | /*----------------------------------------------------------------------------- | |
626 | Below is the definition for WMM | |
627 | ------------------------------------------------------------------------------*/ | |
628 | #define _WMM_IE_Length_ 7 /* for WMM STA */ | |
629 | #define _WMM_Para_Element_Length_ 24 | |
630 | ||
631 | ||
632 | /*----------------------------------------------------------------------------- | |
633 | Below is the definition for 802.11n | |
634 | ------------------------------------------------------------------------------*/ | |
635 | ||
636 | #define SetOrderBit(pbuf) \ | |
637 | do { \ | |
638 | *(unsigned short *)(pbuf) |= cpu_to_le16(_ORDER_); \ | |
639 | } while (0) | |
640 | ||
641 | #define GetOrderBit(pbuf) (((*(unsigned short *)(pbuf)) & cpu_to_le16(_ORDER_)) != 0) | |
642 | ||
643 | #define ACT_CAT_VENDOR 0x7F/* 127 */ | |
644 | ||
645 | /** | |
646 | * struct rtw_ieee80211_bar - HT Block Ack Request | |
647 | * | |
648 | * This structure refers to "HT BlockAckReq" as | |
649 | * described in 802.11n draft section 7.2.1.7.1 | |
650 | */ | |
651 | struct rtw_ieee80211_bar { | |
652 | __le16 frame_control; | |
653 | __le16 duration; | |
654 | unsigned char ra[6]; | |
655 | unsigned char ta[6]; | |
656 | __le16 control; | |
657 | __le16 start_seq_num; | |
658 | } __attribute__((packed)); | |
659 | ||
660 | /* 802.11 BAR control masks */ | |
661 | #define IEEE80211_BAR_CTRL_ACK_POLICY_NORMAL 0x0000 | |
662 | #define IEEE80211_BAR_CTRL_CBMTID_COMPRESSED_BA 0x0004 | |
663 | ||
664 | ||
665 | /** | |
666 | * struct rtw_ieee80211_ht_cap - HT capabilities | |
667 | * | |
668 | * This structure refers to "HT capabilities element" as | |
669 | * described in 802.11n draft section 7.3.2.52 | |
670 | */ | |
671 | ||
672 | struct rtw_ieee80211_ht_cap { | |
673 | __le16 cap_info; | |
674 | unsigned char ampdu_params_info; | |
675 | unsigned char supp_mcs_set[16]; | |
676 | __le16 extended_ht_cap_info; | |
677 | __le16 tx_BF_cap_info; | |
678 | unsigned char antenna_selection_info; | |
679 | } __attribute__ ((packed)); | |
680 | ||
681 | /** | |
682 | * struct rtw_ieee80211_ht_cap - HT additional information | |
683 | * | |
684 | * This structure refers to "HT information element" as | |
685 | * described in 802.11n draft section 7.3.2.53 | |
686 | */ | |
687 | struct ieee80211_ht_addt_info { | |
688 | unsigned char control_chan; | |
689 | unsigned char ht_param; | |
690 | __le16 operation_mode; | |
691 | __le16 stbc_param; | |
692 | unsigned char basic_set[16]; | |
693 | } __attribute__ ((packed)); | |
694 | ||
695 | ||
696 | struct HT_caps_element | |
697 | { | |
698 | union | |
699 | { | |
700 | struct | |
701 | { | |
702 | __le16 HT_caps_info; | |
703 | unsigned char AMPDU_para; | |
704 | unsigned char MCS_rate[16]; | |
705 | __le16 HT_ext_caps; | |
706 | __le16 Beamforming_caps; | |
707 | unsigned char ASEL_caps; | |
708 | } HT_cap_element; | |
709 | unsigned char HT_cap[26]; | |
c77761d6 | 710 | } u; |
554c0a3a HG |
711 | } __attribute__ ((packed)); |
712 | ||
713 | struct HT_info_element | |
714 | { | |
715 | unsigned char primary_channel; | |
716 | unsigned char infos[5]; | |
717 | unsigned char MCS_rate[16]; | |
718 | } __attribute__ ((packed)); | |
719 | ||
720 | struct AC_param | |
721 | { | |
722 | unsigned char ACI_AIFSN; | |
723 | unsigned char CW; | |
724 | __le16 TXOP_limit; | |
725 | } __attribute__ ((packed)); | |
726 | ||
727 | struct WMM_para_element | |
728 | { | |
729 | unsigned char QoS_info; | |
730 | unsigned char reserved; | |
731 | struct AC_param ac_param[4]; | |
732 | } __attribute__ ((packed)); | |
733 | ||
734 | struct ADDBA_request | |
735 | { | |
736 | unsigned char dialog_token; | |
737 | __le16 BA_para_set; | |
738 | __le16 BA_timeout_value; | |
739 | __le16 BA_starting_seqctrl; | |
740 | } __attribute__ ((packed)); | |
741 | ||
742 | enum HT_CAP_AMPDU_FACTOR { | |
743 | MAX_AMPDU_FACTOR_8K = 0, | |
744 | MAX_AMPDU_FACTOR_16K = 1, | |
745 | MAX_AMPDU_FACTOR_32K = 2, | |
746 | MAX_AMPDU_FACTOR_64K = 3, | |
747 | }; | |
748 | ||
749 | /* 802.11n HT capabilities masks */ | |
750 | #define IEEE80211_HT_CAP_LDPC_CODING 0x0001 | |
751 | #define IEEE80211_HT_CAP_SUP_WIDTH 0x0002 | |
752 | #define IEEE80211_HT_CAP_SM_PS 0x000C | |
753 | #define IEEE80211_HT_CAP_GRN_FLD 0x0010 | |
754 | #define IEEE80211_HT_CAP_SGI_20 0x0020 | |
755 | #define IEEE80211_HT_CAP_SGI_40 0x0040 | |
756 | #define IEEE80211_HT_CAP_TX_STBC 0x0080 | |
757 | #define IEEE80211_HT_CAP_RX_STBC_1R 0x0100 | |
758 | #define IEEE80211_HT_CAP_RX_STBC_2R 0x0200 | |
759 | #define IEEE80211_HT_CAP_RX_STBC_3R 0x0300 | |
760 | #define IEEE80211_HT_CAP_DELAY_BA 0x0400 | |
761 | #define IEEE80211_HT_CAP_MAX_AMSDU 0x0800 | |
762 | #define IEEE80211_HT_CAP_DSSSCCK40 0x1000 | |
763 | /* 802.11n HT capability AMPDU settings */ | |
764 | #define IEEE80211_HT_CAP_AMPDU_FACTOR 0x03 | |
765 | #define IEEE80211_HT_CAP_AMPDU_DENSITY 0x1C | |
766 | /* 802.11n HT capability MSC set */ | |
767 | #define IEEE80211_SUPP_MCS_SET_UEQM 4 | |
768 | #define IEEE80211_HT_CAP_MAX_STREAMS 4 | |
769 | #define IEEE80211_SUPP_MCS_SET_LEN 10 | |
770 | /* maximum streams the spec allows */ | |
771 | #define IEEE80211_HT_CAP_MCS_TX_DEFINED 0x01 | |
772 | #define IEEE80211_HT_CAP_MCS_TX_RX_DIFF 0x02 | |
773 | #define IEEE80211_HT_CAP_MCS_TX_STREAMS 0x0C | |
774 | #define IEEE80211_HT_CAP_MCS_TX_UEQM 0x10 | |
775 | /* 802.11n HT capability TXBF capability */ | |
776 | #define IEEE80211_HT_CAP_TXBF_RX_NDP 0x00000008 | |
777 | #define IEEE80211_HT_CAP_TXBF_TX_NDP 0x00000010 | |
778 | #define IEEE80211_HT_CAP_TXBF_EXPLICIT_COMP_STEERING_CAP 0x00000400 | |
779 | ||
780 | /* 802.11n HT IE masks */ | |
781 | #define IEEE80211_HT_IE_CHA_SEC_OFFSET 0x03 | |
782 | #define IEEE80211_HT_IE_CHA_SEC_NONE 0x00 | |
783 | #define IEEE80211_HT_IE_CHA_SEC_ABOVE 0x01 | |
784 | #define IEEE80211_HT_IE_CHA_SEC_BELOW 0x03 | |
785 | #define IEEE80211_HT_IE_CHA_WIDTH 0x04 | |
786 | #define IEEE80211_HT_IE_HT_PROTECTION 0x0003 | |
787 | #define IEEE80211_HT_IE_NON_GF_STA_PRSNT 0x0004 | |
788 | #define IEEE80211_HT_IE_NON_HT_STA_PRSNT 0x0010 | |
789 | ||
790 | /* block-ack parameters */ | |
791 | #define IEEE80211_ADDBA_PARAM_POLICY_MASK 0x0002 | |
792 | #define IEEE80211_ADDBA_PARAM_TID_MASK 0x003C | |
793 | #define RTW_IEEE80211_ADDBA_PARAM_BUF_SIZE_MASK 0xFFC0 | |
794 | #define IEEE80211_DELBA_PARAM_TID_MASK 0xF000 | |
795 | #define IEEE80211_DELBA_PARAM_INITIATOR_MASK 0x0800 | |
796 | ||
797 | /* | |
798 | * A-PMDU buffer sizes | |
799 | * According to IEEE802.11n spec size varies from 8K to 64K (in powers of 2) | |
800 | */ | |
801 | #define IEEE80211_MIN_AMPDU_BUF 0x8 | |
554c0a3a HG |
802 | |
803 | ||
804 | /* Spatial Multiplexing Power Save Modes */ | |
805 | #define WLAN_HT_CAP_SM_PS_STATIC 0 | |
806 | #define WLAN_HT_CAP_SM_PS_DYNAMIC 1 | |
807 | #define WLAN_HT_CAP_SM_PS_INVALID 2 | |
808 | #define WLAN_HT_CAP_SM_PS_DISABLED 3 | |
809 | ||
810 | ||
811 | #define OP_MODE_PURE 0 | |
812 | #define OP_MODE_MAY_BE_LEGACY_STAS 1 | |
813 | #define OP_MODE_20MHZ_HT_STA_ASSOCED 2 | |
814 | #define OP_MODE_MIXED 3 | |
815 | ||
816 | #define HT_INFO_HT_PARAM_SECONDARY_CHNL_OFF_MASK ((u8) BIT(0) | BIT(1)) | |
817 | #define HT_INFO_HT_PARAM_SECONDARY_CHNL_ABOVE ((u8) BIT(0)) | |
818 | #define HT_INFO_HT_PARAM_SECONDARY_CHNL_BELOW ((u8) BIT(0) | BIT(1)) | |
819 | #define HT_INFO_HT_PARAM_REC_TRANS_CHNL_WIDTH ((u8) BIT(2)) | |
820 | #define HT_INFO_HT_PARAM_RIFS_MODE ((u8) BIT(3)) | |
821 | #define HT_INFO_HT_PARAM_CTRL_ACCESS_ONLY ((u8) BIT(4)) | |
822 | #define HT_INFO_HT_PARAM_SRV_INTERVAL_GRANULARITY ((u8) BIT(5)) | |
823 | ||
824 | #define HT_INFO_OPERATION_MODE_OP_MODE_MASK \ | |
825 | ((u16) (0x0001 | 0x0002)) | |
826 | #define HT_INFO_OPERATION_MODE_OP_MODE_OFFSET 0 | |
827 | #define HT_INFO_OPERATION_MODE_NON_GF_DEVS_PRESENT ((u8) BIT(2)) | |
828 | #define HT_INFO_OPERATION_MODE_TRANSMIT_BURST_LIMIT ((u8) BIT(3)) | |
829 | #define HT_INFO_OPERATION_MODE_NON_HT_STA_PRESENT ((u8) BIT(4)) | |
830 | ||
831 | #define HT_INFO_STBC_PARAM_DUAL_BEACON ((u16) BIT(6)) | |
832 | #define HT_INFO_STBC_PARAM_DUAL_STBC_PROTECT ((u16) BIT(7)) | |
833 | #define HT_INFO_STBC_PARAM_SECONDARY_BCN ((u16) BIT(8)) | |
834 | #define HT_INFO_STBC_PARAM_LSIG_TXOP_PROTECT_ALLOWED ((u16) BIT(9)) | |
835 | #define HT_INFO_STBC_PARAM_PCO_ACTIVE ((u16) BIT(10)) | |
836 | #define HT_INFO_STBC_PARAM_PCO_PHASE ((u16) BIT(11)) | |
837 | ||
838 | ||
839 | ||
840 | /* endif */ | |
841 | ||
842 | /* ===============WPS Section =============== */ | |
843 | /* For WPSv1.0 */ | |
844 | #define WPSOUI 0x0050f204 | |
845 | /* WPS attribute ID */ | |
846 | #define WPS_ATTR_VER1 0x104A | |
847 | #define WPS_ATTR_SIMPLE_CONF_STATE 0x1044 | |
848 | #define WPS_ATTR_RESP_TYPE 0x103B | |
849 | #define WPS_ATTR_UUID_E 0x1047 | |
850 | #define WPS_ATTR_MANUFACTURER 0x1021 | |
851 | #define WPS_ATTR_MODEL_NAME 0x1023 | |
852 | #define WPS_ATTR_MODEL_NUMBER 0x1024 | |
853 | #define WPS_ATTR_SERIAL_NUMBER 0x1042 | |
854 | #define WPS_ATTR_PRIMARY_DEV_TYPE 0x1054 | |
855 | #define WPS_ATTR_SEC_DEV_TYPE_LIST 0x1055 | |
856 | #define WPS_ATTR_DEVICE_NAME 0x1011 | |
857 | #define WPS_ATTR_CONF_METHOD 0x1008 | |
858 | #define WPS_ATTR_RF_BANDS 0x103C | |
859 | #define WPS_ATTR_DEVICE_PWID 0x1012 | |
860 | #define WPS_ATTR_REQUEST_TYPE 0x103A | |
861 | #define WPS_ATTR_ASSOCIATION_STATE 0x1002 | |
862 | #define WPS_ATTR_CONFIG_ERROR 0x1009 | |
863 | #define WPS_ATTR_VENDOR_EXT 0x1049 | |
864 | #define WPS_ATTR_SELECTED_REGISTRAR 0x1041 | |
865 | ||
866 | /* Value of WPS attribute "WPS_ATTR_DEVICE_NAME */ | |
867 | #define WPS_MAX_DEVICE_NAME_LEN 32 | |
868 | ||
869 | /* Value of WPS Request Type Attribute */ | |
870 | #define WPS_REQ_TYPE_ENROLLEE_INFO_ONLY 0x00 | |
871 | #define WPS_REQ_TYPE_ENROLLEE_OPEN_8021X 0x01 | |
872 | #define WPS_REQ_TYPE_REGISTRAR 0x02 | |
873 | #define WPS_REQ_TYPE_WLAN_MANAGER_REGISTRAR 0x03 | |
874 | ||
875 | /* Value of WPS Response Type Attribute */ | |
876 | #define WPS_RESPONSE_TYPE_INFO_ONLY 0x00 | |
877 | #define WPS_RESPONSE_TYPE_8021X 0x01 | |
878 | #define WPS_RESPONSE_TYPE_REGISTRAR 0x02 | |
879 | #define WPS_RESPONSE_TYPE_AP 0x03 | |
880 | ||
881 | /* Value of WPS WiFi Simple Configuration State Attribute */ | |
882 | #define WPS_WSC_STATE_NOT_CONFIG 0x01 | |
883 | #define WPS_WSC_STATE_CONFIG 0x02 | |
884 | ||
885 | /* Value of WPS Version Attribute */ | |
886 | #define WPS_VERSION_1 0x10 | |
887 | ||
888 | /* Value of WPS Configuration Method Attribute */ | |
889 | #define WPS_CONFIG_METHOD_FLASH 0x0001 | |
890 | #define WPS_CONFIG_METHOD_ETHERNET 0x0002 | |
891 | #define WPS_CONFIG_METHOD_LABEL 0x0004 | |
892 | #define WPS_CONFIG_METHOD_DISPLAY 0x0008 | |
893 | #define WPS_CONFIG_METHOD_E_NFC 0x0010 | |
894 | #define WPS_CONFIG_METHOD_I_NFC 0x0020 | |
895 | #define WPS_CONFIG_METHOD_NFC 0x0040 | |
896 | #define WPS_CONFIG_METHOD_PBC 0x0080 | |
897 | #define WPS_CONFIG_METHOD_KEYPAD 0x0100 | |
898 | #define WPS_CONFIG_METHOD_VPBC 0x0280 | |
899 | #define WPS_CONFIG_METHOD_PPBC 0x0480 | |
900 | #define WPS_CONFIG_METHOD_VDISPLAY 0x2008 | |
901 | #define WPS_CONFIG_METHOD_PDISPLAY 0x4008 | |
902 | ||
903 | /* Value of Category ID of WPS Primary Device Type Attribute */ | |
904 | #define WPS_PDT_CID_DISPLAYS 0x0007 | |
905 | #define WPS_PDT_CID_MULIT_MEDIA 0x0008 | |
906 | #define WPS_PDT_CID_RTK_WIDI WPS_PDT_CID_MULIT_MEDIA | |
907 | ||
908 | /* Value of Sub Category ID of WPS Primary Device Type Attribute */ | |
909 | #define WPS_PDT_SCID_MEDIA_SERVER 0x0005 | |
910 | #define WPS_PDT_SCID_RTK_DMP WPS_PDT_SCID_MEDIA_SERVER | |
911 | ||
912 | /* Value of Device Password ID */ | |
913 | #define WPS_DPID_PIN 0x0000 | |
914 | #define WPS_DPID_USER_SPEC 0x0001 | |
915 | #define WPS_DPID_MACHINE_SPEC 0x0002 | |
916 | #define WPS_DPID_REKEY 0x0003 | |
917 | #define WPS_DPID_PBC 0x0004 | |
918 | #define WPS_DPID_REGISTRAR_SPEC 0x0005 | |
919 | ||
920 | /* Value of WPS RF Bands Attribute */ | |
921 | #define WPS_RF_BANDS_2_4_GHZ 0x01 | |
922 | #define WPS_RF_BANDS_5_GHZ 0x02 | |
923 | ||
924 | /* Value of WPS Association State Attribute */ | |
925 | #define WPS_ASSOC_STATE_NOT_ASSOCIATED 0x00 | |
926 | #define WPS_ASSOC_STATE_CONNECTION_SUCCESS 0x01 | |
927 | #define WPS_ASSOC_STATE_CONFIGURATION_FAILURE 0x02 | |
928 | #define WPS_ASSOC_STATE_ASSOCIATION_FAILURE 0x03 | |
929 | #define WPS_ASSOC_STATE_IP_FAILURE 0x04 | |
930 | ||
931 | /* =====================P2P Section ===================== */ | |
932 | /* For P2P */ | |
933 | #define P2POUI 0x506F9A09 | |
934 | ||
935 | /* P2P Attribute ID */ | |
936 | #define P2P_ATTR_STATUS 0x00 | |
937 | #define P2P_ATTR_MINOR_REASON_CODE 0x01 | |
938 | #define P2P_ATTR_CAPABILITY 0x02 | |
939 | #define P2P_ATTR_DEVICE_ID 0x03 | |
940 | #define P2P_ATTR_GO_INTENT 0x04 | |
941 | #define P2P_ATTR_CONF_TIMEOUT 0x05 | |
942 | #define P2P_ATTR_LISTEN_CH 0x06 | |
943 | #define P2P_ATTR_GROUP_BSSID 0x07 | |
944 | #define P2P_ATTR_EX_LISTEN_TIMING 0x08 | |
945 | #define P2P_ATTR_INTENTED_IF_ADDR 0x09 | |
946 | #define P2P_ATTR_MANAGEABILITY 0x0A | |
947 | #define P2P_ATTR_CH_LIST 0x0B | |
948 | #define P2P_ATTR_NOA 0x0C | |
949 | #define P2P_ATTR_DEVICE_INFO 0x0D | |
950 | #define P2P_ATTR_GROUP_INFO 0x0E | |
951 | #define P2P_ATTR_GROUP_ID 0x0F | |
952 | #define P2P_ATTR_INTERFACE 0x10 | |
953 | #define P2P_ATTR_OPERATING_CH 0x11 | |
954 | #define P2P_ATTR_INVITATION_FLAGS 0x12 | |
955 | ||
956 | /* Value of Status Attribute */ | |
957 | #define P2P_STATUS_SUCCESS 0x00 | |
958 | #define P2P_STATUS_FAIL_INFO_UNAVAILABLE 0x01 | |
959 | #define P2P_STATUS_FAIL_INCOMPATIBLE_PARAM 0x02 | |
960 | #define P2P_STATUS_FAIL_LIMIT_REACHED 0x03 | |
961 | #define P2P_STATUS_FAIL_INVALID_PARAM 0x04 | |
962 | #define P2P_STATUS_FAIL_REQUEST_UNABLE 0x05 | |
963 | #define P2P_STATUS_FAIL_PREVOUS_PROTO_ERR 0x06 | |
964 | #define P2P_STATUS_FAIL_NO_COMMON_CH 0x07 | |
965 | #define P2P_STATUS_FAIL_UNKNOWN_P2PGROUP 0x08 | |
966 | #define P2P_STATUS_FAIL_BOTH_GOINTENT_15 0x09 | |
967 | #define P2P_STATUS_FAIL_INCOMPATIBLE_PROVSION 0x0A | |
968 | #define P2P_STATUS_FAIL_USER_REJECT 0x0B | |
969 | ||
fb2bb23d | 970 | /* Value of Invitation Flags Attribute */ |
554c0a3a HG |
971 | #define P2P_INVITATION_FLAGS_PERSISTENT BIT(0) |
972 | ||
973 | #define DMP_P2P_DEVCAP_SUPPORT (P2P_DEVCAP_SERVICE_DISCOVERY | \ | |
974 | P2P_DEVCAP_CLIENT_DISCOVERABILITY | \ | |
975 | P2P_DEVCAP_CONCURRENT_OPERATION | \ | |
976 | P2P_DEVCAP_INVITATION_PROC) | |
977 | ||
978 | #define DMP_P2P_GRPCAP_SUPPORT (P2P_GRPCAP_INTRABSS) | |
979 | ||
980 | /* Value of Device Capability Bitmap */ | |
981 | #define P2P_DEVCAP_SERVICE_DISCOVERY BIT(0) | |
982 | #define P2P_DEVCAP_CLIENT_DISCOVERABILITY BIT(1) | |
983 | #define P2P_DEVCAP_CONCURRENT_OPERATION BIT(2) | |
984 | #define P2P_DEVCAP_INFRA_MANAGED BIT(3) | |
985 | #define P2P_DEVCAP_DEVICE_LIMIT BIT(4) | |
986 | #define P2P_DEVCAP_INVITATION_PROC BIT(5) | |
987 | ||
988 | /* Value of Group Capability Bitmap */ | |
989 | #define P2P_GRPCAP_GO BIT(0) | |
990 | #define P2P_GRPCAP_PERSISTENT_GROUP BIT(1) | |
991 | #define P2P_GRPCAP_GROUP_LIMIT BIT(2) | |
992 | #define P2P_GRPCAP_INTRABSS BIT(3) | |
993 | #define P2P_GRPCAP_CROSS_CONN BIT(4) | |
994 | #define P2P_GRPCAP_PERSISTENT_RECONN BIT(5) | |
995 | #define P2P_GRPCAP_GROUP_FORMATION BIT(6) | |
996 | ||
997 | /* P2P Public Action Frame (Management Frame) */ | |
998 | #define P2P_PUB_ACTION_ACTION 0x09 | |
999 | ||
1000 | /* P2P Public Action Frame Type */ | |
1001 | #define P2P_GO_NEGO_REQ 0 | |
1002 | #define P2P_GO_NEGO_RESP 1 | |
1003 | #define P2P_GO_NEGO_CONF 2 | |
1004 | #define P2P_INVIT_REQ 3 | |
1005 | #define P2P_INVIT_RESP 4 | |
1006 | #define P2P_DEVDISC_REQ 5 | |
1007 | #define P2P_DEVDISC_RESP 6 | |
1008 | #define P2P_PROVISION_DISC_REQ 7 | |
1009 | #define P2P_PROVISION_DISC_RESP 8 | |
1010 | ||
1011 | /* P2P Action Frame Type */ | |
1012 | #define P2P_NOTICE_OF_ABSENCE 0 | |
1013 | #define P2P_PRESENCE_REQUEST 1 | |
1014 | #define P2P_PRESENCE_RESPONSE 2 | |
1015 | #define P2P_GO_DISC_REQUEST 3 | |
1016 | ||
1017 | ||
1018 | #define P2P_MAX_PERSISTENT_GROUP_NUM 10 | |
1019 | ||
1020 | #define P2P_PROVISIONING_SCAN_CNT 3 | |
1021 | ||
1022 | #define P2P_WILDCARD_SSID_LEN 7 | |
1023 | ||
1024 | #define P2P_FINDPHASE_EX_NONE 0 /* default value, used when: (1)p2p disabed or (2)p2p enabled but only do 1 scan phase */ | |
1025 | #define P2P_FINDPHASE_EX_FULL 1 /* used when p2p enabled and want to do 1 scan phase and P2P_FINDPHASE_EX_MAX-1 find phase */ | |
1026 | #define P2P_FINDPHASE_EX_SOCIAL_FIRST (P2P_FINDPHASE_EX_FULL+1) | |
1027 | #define P2P_FINDPHASE_EX_MAX 4 | |
1028 | #define P2P_FINDPHASE_EX_SOCIAL_LAST P2P_FINDPHASE_EX_MAX | |
1029 | ||
1030 | #define P2P_PROVISION_TIMEOUT 5000 /* 5 seconds timeout for sending the provision discovery request */ | |
1031 | #define P2P_CONCURRENT_PROVISION_TIMEOUT 3000 /* 3 seconds timeout for sending the provision discovery request under concurrent mode */ | |
1032 | #define P2P_GO_NEGO_TIMEOUT 5000 /* 5 seconds timeout for receiving the group negotation response */ | |
1033 | #define P2P_CONCURRENT_GO_NEGO_TIMEOUT 3000 /* 3 seconds timeout for sending the negotiation request under concurrent mode */ | |
1034 | #define P2P_TX_PRESCAN_TIMEOUT 100 /* 100ms */ | |
1035 | #define P2P_INVITE_TIMEOUT 5000 /* 5 seconds timeout for sending the invitation request */ | |
1036 | #define P2P_CONCURRENT_INVITE_TIMEOUT 3000 /* 3 seconds timeout for sending the invitation request under concurrent mode */ | |
1037 | #define P2P_RESET_SCAN_CH 25000 /* 25 seconds timeout to reset the scan channel (based on channel plan) */ | |
1038 | #define P2P_MAX_INTENT 15 | |
1039 | ||
1040 | #define P2P_MAX_NOA_NUM 2 | |
1041 | ||
1042 | /* WPS Configuration Method */ | |
1043 | #define WPS_CM_NONE 0x0000 | |
1044 | #define WPS_CM_LABEL 0x0004 | |
1045 | #define WPS_CM_DISPLYA 0x0008 | |
1046 | #define WPS_CM_EXTERNAL_NFC_TOKEN 0x0010 | |
1047 | #define WPS_CM_INTEGRATED_NFC_TOKEN 0x0020 | |
1048 | #define WPS_CM_NFC_INTERFACE 0x0040 | |
1049 | #define WPS_CM_PUSH_BUTTON 0x0080 | |
1050 | #define WPS_CM_KEYPAD 0x0100 | |
1051 | #define WPS_CM_SW_PUHS_BUTTON 0x0280 | |
1052 | #define WPS_CM_HW_PUHS_BUTTON 0x0480 | |
1053 | #define WPS_CM_SW_DISPLAY_PIN 0x2008 | |
1054 | #define WPS_CM_LCD_DISPLAY_PIN 0x4008 | |
1055 | ||
1056 | enum P2P_ROLE { | |
1057 | P2P_ROLE_DISABLE = 0, | |
1058 | P2P_ROLE_DEVICE = 1, | |
1059 | P2P_ROLE_CLIENT = 2, | |
1060 | P2P_ROLE_GO = 3 | |
1061 | }; | |
1062 | ||
1063 | enum P2P_STATE { | |
1064 | P2P_STATE_NONE = 0, /* P2P disable */ | |
1065 | P2P_STATE_IDLE = 1, /* P2P had enabled and do nothing */ | |
1066 | P2P_STATE_LISTEN = 2, /* In pure listen state */ | |
1067 | P2P_STATE_SCAN = 3, /* In scan phase */ | |
1068 | P2P_STATE_FIND_PHASE_LISTEN = 4, /* In the listen state of find phase */ | |
1069 | P2P_STATE_FIND_PHASE_SEARCH = 5, /* In the search state of find phase */ | |
1070 | P2P_STATE_TX_PROVISION_DIS_REQ = 6, /* In P2P provisioning discovery */ | |
1071 | P2P_STATE_RX_PROVISION_DIS_RSP = 7, | |
1072 | P2P_STATE_RX_PROVISION_DIS_REQ = 8, | |
3fe9ff48 VN |
1073 | P2P_STATE_GONEGO_ING = 9, /* Doing the group owner negotiation handshake */ |
1074 | P2P_STATE_GONEGO_OK = 10, /* finish the group negotiation handshake with success */ | |
1075 | P2P_STATE_GONEGO_FAIL = 11, /* finish the group negotiation handshake with failure */ | |
fb2bb23d | 1076 | P2P_STATE_RECV_INVITE_REQ_MATCH = 12, /* receiving the P2P Invitation request and match with the profile. */ |
554c0a3a HG |
1077 | P2P_STATE_PROVISIONING_ING = 13, /* Doing the P2P WPS */ |
1078 | P2P_STATE_PROVISIONING_DONE = 14, /* Finish the P2P WPS */ | |
1079 | P2P_STATE_TX_INVITE_REQ = 15, /* Transmit the P2P Invitation request */ | |
1080 | P2P_STATE_RX_INVITE_RESP_OK = 16, /* Receiving the P2P Invitation response */ | |
fb2bb23d CIK |
1081 | P2P_STATE_RECV_INVITE_REQ_DISMATCH = 17, /* receiving the P2P Invitation request and mismatch with the profile. */ |
1082 | P2P_STATE_RECV_INVITE_REQ_GO = 18, /* receiving the P2P Invitation request and this wifi is GO. */ | |
1083 | P2P_STATE_RECV_INVITE_REQ_JOIN = 19, /* receiving the P2P Invitation request to join an existing P2P Group. */ | |
1084 | P2P_STATE_RX_INVITE_RESP_FAIL = 20, /* recveing the P2P Invitation response with failure */ | |
3fe9ff48 VN |
1085 | P2P_STATE_RX_INFOR_NOREADY = 21, /* receiving p2p negotiation response with information is not available */ |
1086 | P2P_STATE_TX_INFOR_NOREADY = 22, /* sending p2p negotiation response with information is not available */ | |
554c0a3a HG |
1087 | }; |
1088 | ||
1089 | enum P2P_WPSINFO { | |
1090 | P2P_NO_WPSINFO = 0, | |
1091 | P2P_GOT_WPSINFO_PEER_DISPLAY_PIN = 1, | |
1092 | P2P_GOT_WPSINFO_SELF_DISPLAY_PIN = 2, | |
1093 | P2P_GOT_WPSINFO_PBC = 3, | |
1094 | }; | |
1095 | ||
1096 | #define P2P_PRIVATE_IOCTL_SET_LEN 64 | |
1097 | ||
1098 | enum P2P_PROTO_WK_ID | |
1099 | { | |
1100 | P2P_FIND_PHASE_WK = 0, | |
1101 | P2P_RESTORE_STATE_WK = 1, | |
1102 | P2P_PRE_TX_PROVDISC_PROCESS_WK = 2, | |
1103 | P2P_PRE_TX_NEGOREQ_PROCESS_WK = 3, | |
1104 | P2P_PRE_TX_INVITEREQ_PROCESS_WK = 4, | |
c77761d6 | 1105 | P2P_AP_P2P_CH_SWITCH_PROCESS_WK = 5, |
554c0a3a HG |
1106 | P2P_RO_CH_WK = 6, |
1107 | }; | |
1108 | ||
1109 | /* =====================WFD Section ===================== */ | |
1110 | /* For Wi-Fi Display */ | |
1111 | #define WFD_ATTR_DEVICE_INFO 0x00 | |
1112 | #define WFD_ATTR_ASSOC_BSSID 0x01 | |
1113 | #define WFD_ATTR_COUPLED_SINK_INFO 0x06 | |
1114 | #define WFD_ATTR_LOCAL_IP_ADDR 0x08 | |
1115 | #define WFD_ATTR_SESSION_INFO 0x09 | |
1116 | #define WFD_ATTR_ALTER_MAC 0x0a | |
1117 | ||
1118 | /* For WFD Device Information Attribute */ | |
1119 | #define WFD_DEVINFO_SOURCE 0x0000 | |
1120 | #define WFD_DEVINFO_PSINK 0x0001 | |
1121 | #define WFD_DEVINFO_SSINK 0x0002 | |
1122 | #define WFD_DEVINFO_DUAL 0x0003 | |
1123 | ||
1124 | #define WFD_DEVINFO_SESSION_AVAIL 0x0010 | |
1125 | #define WFD_DEVINFO_WSD 0x0040 | |
1126 | #define WFD_DEVINFO_PC_TDLS 0x0080 | |
1127 | #define WFD_DEVINFO_HDCP_SUPPORT 0x0100 | |
1128 | ||
c77761d6 LS |
1129 | #define IP_MCAST_MAC(mac) ((mac[0] == 0x01) && (mac[1] == 0x00) && (mac[2] == 0x5e)) |
1130 | #define ICMPV6_MCAST_MAC(mac) ((mac[0] == 0x33) && (mac[1] == 0x33) && (mac[2] != 0xff)) | |
554c0a3a HG |
1131 | |
1132 | /* Regulatroy Domain */ | |
1133 | struct regd_pair_mapping { | |
1134 | u16 reg_dmnenum; | |
1135 | u16 reg_2ghz_ctl; | |
1136 | }; | |
1137 | ||
1138 | struct rtw_regulatory { | |
1139 | char alpha2[2]; | |
1140 | u16 country_code; | |
1141 | u16 max_power_level; | |
1142 | u32 tp_scale; | |
1143 | u16 current_rd; | |
1144 | u16 current_rd_ext; | |
1145 | int16_t power_limit; | |
1146 | struct regd_pair_mapping *regpair; | |
1147 | }; | |
1148 | ||
1149 | #endif /* _WIFI_H_ */ |