1 /* SPDX-License-Identifier: GPL-2.0 */
2 /******************************************************************************
3 *
4 * Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved.
5 *
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 { \
269 *(unsigned short *)(pbuf) &= cpu_to_le16(~(BIT(3) | BIT(2))); \
270 *(unsigned short *)(pbuf) |= cpu_to_le16(type); \
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
IS_MCAST(unsigned char * da)350 static inline int IS_MCAST(unsigned char *da)
351 {
352 if ((*da) & 0x01)
353 return true;
354 else
355 return false;
356 }
357
get_ra(unsigned char * pframe)358 static inline unsigned char * get_ra(unsigned char *pframe)
359 {
360 unsigned char *ra;
361 ra = GetAddr1Ptr(pframe);
362 return ra;
363 }
get_ta(unsigned char * pframe)364 static inline unsigned char * get_ta(unsigned char *pframe)
365 {
366 unsigned char *ta;
367 ta = GetAddr2Ptr(pframe);
368 return ta;
369 }
370
get_da(unsigned char * pframe)371 static inline unsigned char * get_da(unsigned char *pframe)
372 {
373 unsigned char *da;
374 unsigned int to_fr_ds = (GetToDs(pframe) << 1) | GetFrDs(pframe);
375
376 switch (to_fr_ds) {
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;
389 }
390
391 return da;
392 }
393
394
get_sa(unsigned char * pframe)395 static inline unsigned char * get_sa(unsigned char *pframe)
396 {
397 unsigned char *sa;
398 unsigned int to_fr_ds = (GetToDs(pframe) << 1) | GetFrDs(pframe);
399
400 switch (to_fr_ds) {
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;
413 }
414
415 return sa;
416 }
417
get_hdr_bssid(unsigned char * pframe)418 static inline unsigned char * get_hdr_bssid(unsigned char *pframe)
419 {
420 unsigned char *sa = NULL;
421 unsigned int to_fr_ds = (GetToDs(pframe) << 1) | GetFrDs(pframe);
422
423 switch (to_fr_ds) {
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;
436 }
437
438 return sa;
439 }
440
441
IsFrameTypeCtrl(unsigned char * pframe)442 static inline int IsFrameTypeCtrl(unsigned char *pframe)
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 /**
661 * struct rtw_ieee80211_ht_cap - HT capabilities
662 *
663 * This structure refers to "HT capabilities element" as
664 * described in 802.11n draft section 7.3.2.52
665 */
666
667 struct rtw_ieee80211_ht_cap {
668 __le16 cap_info;
669 unsigned char ampdu_params_info;
670 unsigned char supp_mcs_set[16];
671 __le16 extended_ht_cap_info;
672 __le16 tx_BF_cap_info;
673 unsigned char antenna_selection_info;
674 } __attribute__ ((packed));
675
676 /**
677 * struct rtw_ieee80211_ht_cap - HT additional information
678 *
679 * This structure refers to "HT information element" as
680 * described in 802.11n draft section 7.3.2.53
681 */
682 struct ieee80211_ht_addt_info {
683 unsigned char control_chan;
684 unsigned char ht_param;
685 __le16 operation_mode;
686 __le16 stbc_param;
687 unsigned char basic_set[16];
688 } __attribute__ ((packed));
689
690
691 struct HT_caps_element {
692 union {
693 struct {
694 __le16 HT_caps_info;
695 unsigned char AMPDU_para;
696 unsigned char MCS_rate[16];
697 __le16 HT_ext_caps;
698 __le16 Beamforming_caps;
699 unsigned char ASEL_caps;
700 } HT_cap_element;
701 unsigned char HT_cap[26];
702 } u;
703 } __attribute__ ((packed));
704
705 struct HT_info_element {
706 unsigned char primary_channel;
707 unsigned char infos[5];
708 unsigned char MCS_rate[16];
709 } __attribute__ ((packed));
710
711 struct AC_param {
712 unsigned char ACI_AIFSN;
713 unsigned char CW;
714 __le16 TXOP_limit;
715 } __attribute__ ((packed));
716
717 struct WMM_para_element {
718 unsigned char QoS_info;
719 unsigned char reserved;
720 struct AC_param ac_param[4];
721 } __attribute__ ((packed));
722
723 struct ADDBA_request {
724 unsigned char dialog_token;
725 __le16 BA_para_set;
726 __le16 BA_timeout_value;
727 __le16 BA_starting_seqctrl;
728 } __attribute__ ((packed));
729
730 enum HT_CAP_AMPDU_FACTOR {
731 MAX_AMPDU_FACTOR_8K = 0,
732 MAX_AMPDU_FACTOR_16K = 1,
733 MAX_AMPDU_FACTOR_32K = 2,
734 MAX_AMPDU_FACTOR_64K = 3,
735 };
736
737 /* 802.11n HT capabilities masks */
738 #define IEEE80211_HT_CAP_LDPC_CODING 0x0001
739 #define IEEE80211_HT_CAP_SUP_WIDTH 0x0002
740 #define IEEE80211_HT_CAP_SM_PS 0x000C
741 #define IEEE80211_HT_CAP_GRN_FLD 0x0010
742 #define IEEE80211_HT_CAP_SGI_20 0x0020
743 #define IEEE80211_HT_CAP_SGI_40 0x0040
744 #define IEEE80211_HT_CAP_TX_STBC 0x0080
745 #define IEEE80211_HT_CAP_RX_STBC_1R 0x0100
746 #define IEEE80211_HT_CAP_RX_STBC_2R 0x0200
747 #define IEEE80211_HT_CAP_RX_STBC_3R 0x0300
748 #define IEEE80211_HT_CAP_DELAY_BA 0x0400
749 #define IEEE80211_HT_CAP_MAX_AMSDU 0x0800
750 #define IEEE80211_HT_CAP_DSSSCCK40 0x1000
751 /* 802.11n HT capability AMPDU settings */
752 #define IEEE80211_HT_CAP_AMPDU_FACTOR 0x03
753 #define IEEE80211_HT_CAP_AMPDU_DENSITY 0x1C
754 /* 802.11n HT capability MSC set */
755 #define IEEE80211_SUPP_MCS_SET_UEQM 4
756 #define IEEE80211_HT_CAP_MAX_STREAMS 4
757 #define IEEE80211_SUPP_MCS_SET_LEN 10
758 /* maximum streams the spec allows */
759 #define IEEE80211_HT_CAP_MCS_TX_DEFINED 0x01
760 #define IEEE80211_HT_CAP_MCS_TX_RX_DIFF 0x02
761 #define IEEE80211_HT_CAP_MCS_TX_STREAMS 0x0C
762 #define IEEE80211_HT_CAP_MCS_TX_UEQM 0x10
763 /* 802.11n HT capability TXBF capability */
764 #define IEEE80211_HT_CAP_TXBF_RX_NDP 0x00000008
765 #define IEEE80211_HT_CAP_TXBF_TX_NDP 0x00000010
766 #define IEEE80211_HT_CAP_TXBF_EXPLICIT_COMP_STEERING_CAP 0x00000400
767
768 /* 802.11n HT IE masks */
769 #define IEEE80211_HT_IE_CHA_SEC_OFFSET 0x03
770 #define IEEE80211_HT_IE_CHA_SEC_NONE 0x00
771 #define IEEE80211_HT_IE_CHA_SEC_ABOVE 0x01
772 #define IEEE80211_HT_IE_CHA_SEC_BELOW 0x03
773 #define IEEE80211_HT_IE_CHA_WIDTH 0x04
774 #define IEEE80211_HT_IE_HT_PROTECTION 0x0003
775 #define IEEE80211_HT_IE_NON_GF_STA_PRSNT 0x0004
776 #define IEEE80211_HT_IE_NON_HT_STA_PRSNT 0x0010
777
778 /* block-ack parameters */
779 #define IEEE80211_ADDBA_PARAM_POLICY_MASK 0x0002
780 #define IEEE80211_ADDBA_PARAM_TID_MASK 0x003C
781 #define RTW_IEEE80211_ADDBA_PARAM_BUF_SIZE_MASK 0xFFC0
782 #define IEEE80211_DELBA_PARAM_TID_MASK 0xF000
783 #define IEEE80211_DELBA_PARAM_INITIATOR_MASK 0x0800
784
785 /*
786 * A-PMDU buffer sizes
787 * According to IEEE802.11n spec size varies from 8K to 64K (in powers of 2)
788 */
789 #define IEEE80211_MIN_AMPDU_BUF 0x8
790
791
792 /* Spatial Multiplexing Power Save Modes */
793 #define WLAN_HT_CAP_SM_PS_STATIC 0
794 #define WLAN_HT_CAP_SM_PS_DYNAMIC 1
795 #define WLAN_HT_CAP_SM_PS_INVALID 2
796 #define WLAN_HT_CAP_SM_PS_DISABLED 3
797
798
799 #define OP_MODE_PURE 0
800 #define OP_MODE_MAY_BE_LEGACY_STAS 1
801 #define OP_MODE_20MHZ_HT_STA_ASSOCED 2
802 #define OP_MODE_MIXED 3
803
804 #define HT_INFO_HT_PARAM_SECONDARY_CHNL_OFF_MASK ((u8) BIT(0) | BIT(1))
805 #define HT_INFO_HT_PARAM_SECONDARY_CHNL_ABOVE ((u8) BIT(0))
806 #define HT_INFO_HT_PARAM_SECONDARY_CHNL_BELOW ((u8) BIT(0) | BIT(1))
807 #define HT_INFO_HT_PARAM_REC_TRANS_CHNL_WIDTH ((u8) BIT(2))
808 #define HT_INFO_HT_PARAM_RIFS_MODE ((u8) BIT(3))
809 #define HT_INFO_HT_PARAM_CTRL_ACCESS_ONLY ((u8) BIT(4))
810 #define HT_INFO_HT_PARAM_SRV_INTERVAL_GRANULARITY ((u8) BIT(5))
811
812 #define HT_INFO_OPERATION_MODE_OP_MODE_MASK \
813 ((u16) (0x0001 | 0x0002))
814 #define HT_INFO_OPERATION_MODE_OP_MODE_OFFSET 0
815 #define HT_INFO_OPERATION_MODE_NON_GF_DEVS_PRESENT ((u8) BIT(2))
816 #define HT_INFO_OPERATION_MODE_TRANSMIT_BURST_LIMIT ((u8) BIT(3))
817 #define HT_INFO_OPERATION_MODE_NON_HT_STA_PRESENT ((u8) BIT(4))
818
819 #define HT_INFO_STBC_PARAM_DUAL_BEACON ((u16) BIT(6))
820 #define HT_INFO_STBC_PARAM_DUAL_STBC_PROTECT ((u16) BIT(7))
821 #define HT_INFO_STBC_PARAM_SECONDARY_BCN ((u16) BIT(8))
822 #define HT_INFO_STBC_PARAM_LSIG_TXOP_PROTECT_ALLOWED ((u16) BIT(9))
823 #define HT_INFO_STBC_PARAM_PCO_ACTIVE ((u16) BIT(10))
824 #define HT_INFO_STBC_PARAM_PCO_PHASE ((u16) BIT(11))
825
826
827
828 /* endif */
829
830 /* ===============WPS Section =============== */
831 /* For WPSv1.0 */
832 #define WPSOUI 0x0050f204
833 /* WPS attribute ID */
834 #define WPS_ATTR_VER1 0x104A
835 #define WPS_ATTR_SIMPLE_CONF_STATE 0x1044
836 #define WPS_ATTR_RESP_TYPE 0x103B
837 #define WPS_ATTR_UUID_E 0x1047
838 #define WPS_ATTR_MANUFACTURER 0x1021
839 #define WPS_ATTR_MODEL_NAME 0x1023
840 #define WPS_ATTR_MODEL_NUMBER 0x1024
841 #define WPS_ATTR_SERIAL_NUMBER 0x1042
842 #define WPS_ATTR_PRIMARY_DEV_TYPE 0x1054
843 #define WPS_ATTR_SEC_DEV_TYPE_LIST 0x1055
844 #define WPS_ATTR_DEVICE_NAME 0x1011
845 #define WPS_ATTR_CONF_METHOD 0x1008
846 #define WPS_ATTR_RF_BANDS 0x103C
847 #define WPS_ATTR_DEVICE_PWID 0x1012
848 #define WPS_ATTR_REQUEST_TYPE 0x103A
849 #define WPS_ATTR_ASSOCIATION_STATE 0x1002
850 #define WPS_ATTR_CONFIG_ERROR 0x1009
851 #define WPS_ATTR_VENDOR_EXT 0x1049
852 #define WPS_ATTR_SELECTED_REGISTRAR 0x1041
853
854 /* Value of WPS attribute "WPS_ATTR_DEVICE_NAME */
855 #define WPS_MAX_DEVICE_NAME_LEN 32
856
857 /* Value of WPS Request Type Attribute */
858 #define WPS_REQ_TYPE_ENROLLEE_INFO_ONLY 0x00
859 #define WPS_REQ_TYPE_ENROLLEE_OPEN_8021X 0x01
860 #define WPS_REQ_TYPE_REGISTRAR 0x02
861 #define WPS_REQ_TYPE_WLAN_MANAGER_REGISTRAR 0x03
862
863 /* Value of WPS Response Type Attribute */
864 #define WPS_RESPONSE_TYPE_INFO_ONLY 0x00
865 #define WPS_RESPONSE_TYPE_8021X 0x01
866 #define WPS_RESPONSE_TYPE_REGISTRAR 0x02
867 #define WPS_RESPONSE_TYPE_AP 0x03
868
869 /* Value of WPS WiFi Simple Configuration State Attribute */
870 #define WPS_WSC_STATE_NOT_CONFIG 0x01
871 #define WPS_WSC_STATE_CONFIG 0x02
872
873 /* Value of WPS Version Attribute */
874 #define WPS_VERSION_1 0x10
875
876 /* Value of WPS Configuration Method Attribute */
877 #define WPS_CONFIG_METHOD_FLASH 0x0001
878 #define WPS_CONFIG_METHOD_ETHERNET 0x0002
879 #define WPS_CONFIG_METHOD_LABEL 0x0004
880 #define WPS_CONFIG_METHOD_DISPLAY 0x0008
881 #define WPS_CONFIG_METHOD_E_NFC 0x0010
882 #define WPS_CONFIG_METHOD_I_NFC 0x0020
883 #define WPS_CONFIG_METHOD_NFC 0x0040
884 #define WPS_CONFIG_METHOD_PBC 0x0080
885 #define WPS_CONFIG_METHOD_KEYPAD 0x0100
886 #define WPS_CONFIG_METHOD_VPBC 0x0280
887 #define WPS_CONFIG_METHOD_PPBC 0x0480
888 #define WPS_CONFIG_METHOD_VDISPLAY 0x2008
889 #define WPS_CONFIG_METHOD_PDISPLAY 0x4008
890
891 /* Value of Category ID of WPS Primary Device Type Attribute */
892 #define WPS_PDT_CID_DISPLAYS 0x0007
893 #define WPS_PDT_CID_MULIT_MEDIA 0x0008
894 #define WPS_PDT_CID_RTK_WIDI WPS_PDT_CID_MULIT_MEDIA
895
896 /* Value of Sub Category ID of WPS Primary Device Type Attribute */
897 #define WPS_PDT_SCID_MEDIA_SERVER 0x0005
898 #define WPS_PDT_SCID_RTK_DMP WPS_PDT_SCID_MEDIA_SERVER
899
900 /* Value of Device Password ID */
901 #define WPS_DPID_PIN 0x0000
902 #define WPS_DPID_USER_SPEC 0x0001
903 #define WPS_DPID_MACHINE_SPEC 0x0002
904 #define WPS_DPID_REKEY 0x0003
905 #define WPS_DPID_PBC 0x0004
906 #define WPS_DPID_REGISTRAR_SPEC 0x0005
907
908 /* Value of WPS RF Bands Attribute */
909 #define WPS_RF_BANDS_2_4_GHZ 0x01
910 #define WPS_RF_BANDS_5_GHZ 0x02
911
912 /* Value of WPS Association State Attribute */
913 #define WPS_ASSOC_STATE_NOT_ASSOCIATED 0x00
914 #define WPS_ASSOC_STATE_CONNECTION_SUCCESS 0x01
915 #define WPS_ASSOC_STATE_CONFIGURATION_FAILURE 0x02
916 #define WPS_ASSOC_STATE_ASSOCIATION_FAILURE 0x03
917 #define WPS_ASSOC_STATE_IP_FAILURE 0x04
918
919 /* =====================P2P Section ===================== */
920 /* For P2P */
921 #define P2POUI 0x506F9A09
922
923 /* P2P Attribute ID */
924 #define P2P_ATTR_STATUS 0x00
925 #define P2P_ATTR_MINOR_REASON_CODE 0x01
926 #define P2P_ATTR_CAPABILITY 0x02
927 #define P2P_ATTR_DEVICE_ID 0x03
928 #define P2P_ATTR_GO_INTENT 0x04
929 #define P2P_ATTR_CONF_TIMEOUT 0x05
930 #define P2P_ATTR_LISTEN_CH 0x06
931 #define P2P_ATTR_GROUP_BSSID 0x07
932 #define P2P_ATTR_EX_LISTEN_TIMING 0x08
933 #define P2P_ATTR_INTENTED_IF_ADDR 0x09
934 #define P2P_ATTR_MANAGEABILITY 0x0A
935 #define P2P_ATTR_CH_LIST 0x0B
936 #define P2P_ATTR_NOA 0x0C
937 #define P2P_ATTR_DEVICE_INFO 0x0D
938 #define P2P_ATTR_GROUP_INFO 0x0E
939 #define P2P_ATTR_GROUP_ID 0x0F
940 #define P2P_ATTR_INTERFACE 0x10
941 #define P2P_ATTR_OPERATING_CH 0x11
942 #define P2P_ATTR_INVITATION_FLAGS 0x12
943
944 /* Value of Status Attribute */
945 #define P2P_STATUS_SUCCESS 0x00
946 #define P2P_STATUS_FAIL_INFO_UNAVAILABLE 0x01
947 #define P2P_STATUS_FAIL_INCOMPATIBLE_PARAM 0x02
948 #define P2P_STATUS_FAIL_LIMIT_REACHED 0x03
949 #define P2P_STATUS_FAIL_INVALID_PARAM 0x04
950 #define P2P_STATUS_FAIL_REQUEST_UNABLE 0x05
951 #define P2P_STATUS_FAIL_PREVOUS_PROTO_ERR 0x06
952 #define P2P_STATUS_FAIL_NO_COMMON_CH 0x07
953 #define P2P_STATUS_FAIL_UNKNOWN_P2PGROUP 0x08
954 #define P2P_STATUS_FAIL_BOTH_GOINTENT_15 0x09
955 #define P2P_STATUS_FAIL_INCOMPATIBLE_PROVSION 0x0A
956 #define P2P_STATUS_FAIL_USER_REJECT 0x0B
957
958 /* Value of Invitation Flags Attribute */
959 #define P2P_INVITATION_FLAGS_PERSISTENT BIT(0)
960
961 #define DMP_P2P_DEVCAP_SUPPORT (P2P_DEVCAP_SERVICE_DISCOVERY | \
962 P2P_DEVCAP_CLIENT_DISCOVERABILITY | \
963 P2P_DEVCAP_CONCURRENT_OPERATION | \
964 P2P_DEVCAP_INVITATION_PROC)
965
966 #define DMP_P2P_GRPCAP_SUPPORT (P2P_GRPCAP_INTRABSS)
967
968 /* Value of Device Capability Bitmap */
969 #define P2P_DEVCAP_SERVICE_DISCOVERY BIT(0)
970 #define P2P_DEVCAP_CLIENT_DISCOVERABILITY BIT(1)
971 #define P2P_DEVCAP_CONCURRENT_OPERATION BIT(2)
972 #define P2P_DEVCAP_INFRA_MANAGED BIT(3)
973 #define P2P_DEVCAP_DEVICE_LIMIT BIT(4)
974 #define P2P_DEVCAP_INVITATION_PROC BIT(5)
975
976 /* Value of Group Capability Bitmap */
977 #define P2P_GRPCAP_GO BIT(0)
978 #define P2P_GRPCAP_PERSISTENT_GROUP BIT(1)
979 #define P2P_GRPCAP_GROUP_LIMIT BIT(2)
980 #define P2P_GRPCAP_INTRABSS BIT(3)
981 #define P2P_GRPCAP_CROSS_CONN BIT(4)
982 #define P2P_GRPCAP_PERSISTENT_RECONN BIT(5)
983 #define P2P_GRPCAP_GROUP_FORMATION BIT(6)
984
985 /* P2P Public Action Frame (Management Frame) */
986 #define P2P_PUB_ACTION_ACTION 0x09
987
988 /* P2P Public Action Frame Type */
989 #define P2P_GO_NEGO_REQ 0
990 #define P2P_GO_NEGO_RESP 1
991 #define P2P_GO_NEGO_CONF 2
992 #define P2P_INVIT_REQ 3
993 #define P2P_INVIT_RESP 4
994 #define P2P_DEVDISC_REQ 5
995 #define P2P_DEVDISC_RESP 6
996 #define P2P_PROVISION_DISC_REQ 7
997 #define P2P_PROVISION_DISC_RESP 8
998
999 /* P2P Action Frame Type */
1000 #define P2P_NOTICE_OF_ABSENCE 0
1001 #define P2P_PRESENCE_REQUEST 1
1002 #define P2P_PRESENCE_RESPONSE 2
1003 #define P2P_GO_DISC_REQUEST 3
1004
1005
1006 #define P2P_MAX_PERSISTENT_GROUP_NUM 10
1007
1008 #define P2P_PROVISIONING_SCAN_CNT 3
1009
1010 #define P2P_WILDCARD_SSID_LEN 7
1011
1012 #define P2P_FINDPHASE_EX_NONE 0 /* default value, used when: (1)p2p disabed or (2)p2p enabled but only do 1 scan phase */
1013 #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 */
1014 #define P2P_FINDPHASE_EX_SOCIAL_FIRST (P2P_FINDPHASE_EX_FULL+1)
1015 #define P2P_FINDPHASE_EX_MAX 4
1016 #define P2P_FINDPHASE_EX_SOCIAL_LAST P2P_FINDPHASE_EX_MAX
1017
1018 #define P2P_PROVISION_TIMEOUT 5000 /* 5 seconds timeout for sending the provision discovery request */
1019 #define P2P_CONCURRENT_PROVISION_TIMEOUT 3000 /* 3 seconds timeout for sending the provision discovery request under concurrent mode */
1020 #define P2P_GO_NEGO_TIMEOUT 5000 /* 5 seconds timeout for receiving the group negotation response */
1021 #define P2P_CONCURRENT_GO_NEGO_TIMEOUT 3000 /* 3 seconds timeout for sending the negotiation request under concurrent mode */
1022 #define P2P_TX_PRESCAN_TIMEOUT 100 /* 100ms */
1023 #define P2P_INVITE_TIMEOUT 5000 /* 5 seconds timeout for sending the invitation request */
1024 #define P2P_CONCURRENT_INVITE_TIMEOUT 3000 /* 3 seconds timeout for sending the invitation request under concurrent mode */
1025 #define P2P_RESET_SCAN_CH 25000 /* 25 seconds timeout to reset the scan channel (based on channel plan) */
1026 #define P2P_MAX_INTENT 15
1027
1028 #define P2P_MAX_NOA_NUM 2
1029
1030 /* WPS Configuration Method */
1031 #define WPS_CM_NONE 0x0000
1032 #define WPS_CM_LABEL 0x0004
1033 #define WPS_CM_DISPLYA 0x0008
1034 #define WPS_CM_EXTERNAL_NFC_TOKEN 0x0010
1035 #define WPS_CM_INTEGRATED_NFC_TOKEN 0x0020
1036 #define WPS_CM_NFC_INTERFACE 0x0040
1037 #define WPS_CM_PUSH_BUTTON 0x0080
1038 #define WPS_CM_KEYPAD 0x0100
1039 #define WPS_CM_SW_PUHS_BUTTON 0x0280
1040 #define WPS_CM_HW_PUHS_BUTTON 0x0480
1041 #define WPS_CM_SW_DISPLAY_PIN 0x2008
1042 #define WPS_CM_LCD_DISPLAY_PIN 0x4008
1043
1044 enum P2P_ROLE {
1045 P2P_ROLE_DISABLE = 0,
1046 P2P_ROLE_DEVICE = 1,
1047 P2P_ROLE_CLIENT = 2,
1048 P2P_ROLE_GO = 3
1049 };
1050
1051 enum P2P_STATE {
1052 P2P_STATE_NONE = 0, /* P2P disable */
1053 P2P_STATE_IDLE = 1, /* P2P had enabled and do nothing */
1054 P2P_STATE_LISTEN = 2, /* In pure listen state */
1055 P2P_STATE_SCAN = 3, /* In scan phase */
1056 P2P_STATE_FIND_PHASE_LISTEN = 4, /* In the listen state of find phase */
1057 P2P_STATE_FIND_PHASE_SEARCH = 5, /* In the search state of find phase */
1058 P2P_STATE_TX_PROVISION_DIS_REQ = 6, /* In P2P provisioning discovery */
1059 P2P_STATE_RX_PROVISION_DIS_RSP = 7,
1060 P2P_STATE_RX_PROVISION_DIS_REQ = 8,
1061 P2P_STATE_GONEGO_ING = 9, /* Doing the group owner negotiation handshake */
1062 P2P_STATE_GONEGO_OK = 10, /* finish the group negotiation handshake with success */
1063 P2P_STATE_GONEGO_FAIL = 11, /* finish the group negotiation handshake with failure */
1064 P2P_STATE_RECV_INVITE_REQ_MATCH = 12, /* receiving the P2P Invitation request and match with the profile. */
1065 P2P_STATE_PROVISIONING_ING = 13, /* Doing the P2P WPS */
1066 P2P_STATE_PROVISIONING_DONE = 14, /* Finish the P2P WPS */
1067 P2P_STATE_TX_INVITE_REQ = 15, /* Transmit the P2P Invitation request */
1068 P2P_STATE_RX_INVITE_RESP_OK = 16, /* Receiving the P2P Invitation response */
1069 P2P_STATE_RECV_INVITE_REQ_DISMATCH = 17, /* receiving the P2P Invitation request and mismatch with the profile. */
1070 P2P_STATE_RECV_INVITE_REQ_GO = 18, /* receiving the P2P Invitation request and this wifi is GO. */
1071 P2P_STATE_RECV_INVITE_REQ_JOIN = 19, /* receiving the P2P Invitation request to join an existing P2P Group. */
1072 P2P_STATE_RX_INVITE_RESP_FAIL = 20, /* recveing the P2P Invitation response with failure */
1073 P2P_STATE_RX_INFOR_NOREADY = 21, /* receiving p2p negotiation response with information is not available */
1074 P2P_STATE_TX_INFOR_NOREADY = 22, /* sending p2p negotiation response with information is not available */
1075 };
1076
1077 enum P2P_WPSINFO {
1078 P2P_NO_WPSINFO = 0,
1079 P2P_GOT_WPSINFO_PEER_DISPLAY_PIN = 1,
1080 P2P_GOT_WPSINFO_SELF_DISPLAY_PIN = 2,
1081 P2P_GOT_WPSINFO_PBC = 3,
1082 };
1083
1084 #define P2P_PRIVATE_IOCTL_SET_LEN 64
1085
1086 enum P2P_PROTO_WK_ID {
1087 P2P_FIND_PHASE_WK = 0,
1088 P2P_RESTORE_STATE_WK = 1,
1089 P2P_PRE_TX_PROVDISC_PROCESS_WK = 2,
1090 P2P_PRE_TX_NEGOREQ_PROCESS_WK = 3,
1091 P2P_PRE_TX_INVITEREQ_PROCESS_WK = 4,
1092 P2P_AP_P2P_CH_SWITCH_PROCESS_WK = 5,
1093 P2P_RO_CH_WK = 6,
1094 };
1095
1096 /* =====================WFD Section ===================== */
1097 /* For Wi-Fi Display */
1098 #define WFD_ATTR_DEVICE_INFO 0x00
1099 #define WFD_ATTR_ASSOC_BSSID 0x01
1100 #define WFD_ATTR_COUPLED_SINK_INFO 0x06
1101 #define WFD_ATTR_LOCAL_IP_ADDR 0x08
1102 #define WFD_ATTR_SESSION_INFO 0x09
1103 #define WFD_ATTR_ALTER_MAC 0x0a
1104
1105 /* For WFD Device Information Attribute */
1106 #define WFD_DEVINFO_SOURCE 0x0000
1107 #define WFD_DEVINFO_PSINK 0x0001
1108 #define WFD_DEVINFO_SSINK 0x0002
1109 #define WFD_DEVINFO_DUAL 0x0003
1110
1111 #define WFD_DEVINFO_SESSION_AVAIL 0x0010
1112 #define WFD_DEVINFO_WSD 0x0040
1113 #define WFD_DEVINFO_PC_TDLS 0x0080
1114 #define WFD_DEVINFO_HDCP_SUPPORT 0x0100
1115
1116 #define IP_MCAST_MAC(mac) ((mac[0] == 0x01) && (mac[1] == 0x00) && (mac[2] == 0x5e))
1117 #define ICMPV6_MCAST_MAC(mac) ((mac[0] == 0x33) && (mac[1] == 0x33) && (mac[2] != 0xff))
1118
1119 /* Regulatroy Domain */
1120 struct regd_pair_mapping {
1121 u16 reg_dmnenum;
1122 u16 reg_2ghz_ctl;
1123 };
1124
1125 struct rtw_regulatory {
1126 char alpha2[2];
1127 u16 country_code;
1128 u16 max_power_level;
1129 u32 tp_scale;
1130 u16 current_rd;
1131 u16 current_rd_ext;
1132 int16_t power_limit;
1133 struct regd_pair_mapping *regpair;
1134 };
1135
1136 #endif /* _WIFI_H_ */
1137