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