Merge tag 'drm-next-2020-08-12' of git://anongit.freedesktop.org/drm/drm
[platform/kernel/linux-starfive.git] / drivers / staging / rtl8188eu / include / wifi.h
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 #define WLAN_IEEE_OUI_LEN       3
11 #define WLAN_CRC_LEN            4
12 #define WLAN_BSSID_LEN          6
13 #define WLAN_BSS_TS_LEN         8
14 #define WLAN_HDR_A3_LEN         24
15 #define WLAN_HDR_A4_LEN         30
16 #define WLAN_HDR_A3_QOS_LEN     26
17 #define WLAN_HDR_A4_QOS_LEN     32
18 #define WLAN_DATA_MAXLEN        2312
19
20 #define WLAN_A3_PN_OFFSET       24
21 #define WLAN_A4_PN_OFFSET       30
22
23 #define WLAN_MIN_ETHFRM_LEN     60
24 #define WLAN_MAX_ETHFRM_LEN     1514
25
26 #define P80211CAPTURE_VERSION   0x80211001
27
28 /*  This value is tested by WiFi 11n Test Plan 5.2.3. */
29 /*  This test verifies the WLAN NIC can update the NAV through sending
30  *  the CTS with large duration.
31  */
32 #define WiFiNavUpperUs                          30000   /*  30 ms */
33
34 enum WIFI_FRAME_TYPE {
35         WIFI_MGT_TYPE  =        (0),
36         WIFI_CTRL_TYPE =        (BIT(2)),
37         WIFI_DATA_TYPE =        (BIT(3)),
38         WIFI_QOS_DATA_TYPE      = (BIT(7) | BIT(3)),    /*  QoS Data */
39 };
40
41 enum WIFI_FRAME_SUBTYPE {
42         /*  below is for mgt frame */
43         WIFI_ASSOCREQ       = (0 | WIFI_MGT_TYPE),
44         WIFI_ASSOCRSP       = (BIT(4) | WIFI_MGT_TYPE),
45         WIFI_REASSOCREQ     = (BIT(5) | WIFI_MGT_TYPE),
46         WIFI_REASSOCRSP     = (BIT(5) | BIT(4) | WIFI_MGT_TYPE),
47         WIFI_PROBEREQ       = (BIT(6) | WIFI_MGT_TYPE),
48         WIFI_PROBERSP       = (BIT(6) | BIT(4) | WIFI_MGT_TYPE),
49         WIFI_BEACON         = (BIT(7) | WIFI_MGT_TYPE),
50         WIFI_ATIM           = (BIT(7) | BIT(4) | WIFI_MGT_TYPE),
51         WIFI_DISASSOC       = (BIT(7) | BIT(5) | WIFI_MGT_TYPE),
52         WIFI_AUTH           = (BIT(7) | BIT(5) | BIT(4) | WIFI_MGT_TYPE),
53         WIFI_DEAUTH         = (BIT(7) | BIT(6) | WIFI_MGT_TYPE),
54         WIFI_ACTION         = (BIT(7) | BIT(6) | BIT(4) | WIFI_MGT_TYPE),
55
56         /*  below is for control frame */
57         WIFI_PSPOLL         = (BIT(7) | BIT(5) | WIFI_CTRL_TYPE),
58         WIFI_RTS            = (BIT(7) | BIT(5) | BIT(4) | WIFI_CTRL_TYPE),
59         WIFI_CTS            = (BIT(7) | BIT(6) | WIFI_CTRL_TYPE),
60         WIFI_ACK            = (BIT(7) | BIT(6) | BIT(4) | WIFI_CTRL_TYPE),
61         WIFI_CFEND          = (BIT(7) | BIT(6) | BIT(5) | WIFI_CTRL_TYPE),
62         WIFI_CFEND_CFACK    = (BIT(7) | BIT(6) | BIT(5) | BIT(4) |
63         WIFI_CTRL_TYPE),
64
65         /*  below is for data frame */
66         WIFI_DATA           = (0 | WIFI_DATA_TYPE),
67         WIFI_DATA_CFACK     = (BIT(4) | WIFI_DATA_TYPE),
68         WIFI_DATA_CFPOLL    = (BIT(5) | WIFI_DATA_TYPE),
69         WIFI_DATA_CFACKPOLL = (BIT(5) | BIT(4) | WIFI_DATA_TYPE),
70         WIFI_DATA_NULL      = (BIT(6) | WIFI_DATA_TYPE),
71         WIFI_CF_ACK         = (BIT(6) | BIT(4) | WIFI_DATA_TYPE),
72         WIFI_CF_POLL        = (BIT(6) | BIT(5) | WIFI_DATA_TYPE),
73         WIFI_CF_ACKPOLL     = (BIT(6) | BIT(5) | BIT(4) | WIFI_DATA_TYPE),
74         WIFI_QOS_DATA_NULL      = (BIT(6) | WIFI_QOS_DATA_TYPE),
75 };
76
77 enum WIFI_REASON_CODE   {
78         _RSON_RESERVED_                 = 0,
79         _RSON_UNSPECIFIED_              = 1,
80         _RSON_AUTH_NO_LONGER_VALID_     = 2,
81         _RSON_DEAUTH_STA_LEAVING_       = 3,
82         _RSON_INACTIVITY_               = 4,
83         _RSON_UNABLE_HANDLE_            = 5,
84         _RSON_CLS2_                     = 6,
85         _RSON_CLS3_                     = 7,
86         _RSON_DISAOC_STA_LEAVING_       = 8,
87         _RSON_ASOC_NOT_AUTH_            = 9,
88
89         /*  WPA reason */
90         _RSON_INVALID_IE_               = 13,
91         _RSON_MIC_FAILURE_              = 14,
92         _RSON_4WAY_HNDSHK_TIMEOUT_      = 15,
93         _RSON_GROUP_KEY_UPDATE_TIMEOUT_ = 16,
94         _RSON_DIFF_IE_                  = 17,
95         _RSON_MLTCST_CIPHER_NOT_VALID_  = 18,
96         _RSON_UNICST_CIPHER_NOT_VALID_  = 19,
97         _RSON_AKMP_NOT_VALID_           = 20,
98         _RSON_UNSUPPORT_RSNE_VER_       = 21,
99         _RSON_INVALID_RSNE_CAP_         = 22,
100         _RSON_IEEE_802DOT1X_AUTH_FAIL_  = 23,
101
102         /* belowing are Realtek definition */
103         _RSON_PMK_NOT_AVAILABLE_        = 24,
104         _RSON_TDLS_TEAR_TOOFAR_         = 25,
105         _RSON_TDLS_TEAR_UN_RSN_         = 26,
106 };
107
108 enum WIFI_STATUS_CODE {
109         _STATS_SUCCESSFUL_              = 0,
110         _STATS_FAILURE_                 = 1,
111         _STATS_CAP_FAIL_                = 10,
112         _STATS_NO_ASOC_                 = 11,
113         _STATS_OTHER_                   = 12,
114         _STATS_NO_SUPP_ALG_             = 13,
115         _STATS_OUT_OF_AUTH_SEQ_         = 14,
116         _STATS_CHALLENGE_FAIL_          = 15,
117         _STATS_AUTH_TIMEOUT_            = 16,
118         _STATS_UNABLE_HANDLE_STA_       = 17,
119         _STATS_RATE_FAIL_               = 18,
120 };
121
122 enum WIFI_REG_DOMAIN {
123         DOMAIN_FCC      = 1,
124         DOMAIN_IC       = 2,
125         DOMAIN_ETSI     = 3,
126         DOMAIN_SPA      = 4,
127         DOMAIN_FRANCE   = 5,
128         DOMAIN_MKK      = 6,
129         DOMAIN_ISRAEL   = 7,
130         DOMAIN_MKK1     = 8,
131         DOMAIN_MKK2     = 9,
132         DOMAIN_MKK3     = 10,
133         DOMAIN_MAX
134 };
135
136 #define _TO_DS_         BIT(8)
137 #define _FROM_DS_       BIT(9)
138 #define _MORE_FRAG_     BIT(10)
139 #define _RETRY_         BIT(11)
140 #define _PWRMGT_        BIT(12)
141 #define _MORE_DATA_     BIT(13)
142 #define _PRIVACY_       BIT(14)
143 #define _ORDER_         BIT(15)
144
145 #define SetToDs(pbuf)   \
146         *(__le16 *)(pbuf) |= cpu_to_le16(_TO_DS_)
147
148 #define GetToDs(pbuf)   (((*(__le16 *)(pbuf)) & cpu_to_le16(_TO_DS_)) != 0)
149
150 #define ClearToDs(pbuf) \
151         *(__le16 *)(pbuf) &= (~cpu_to_le16(_TO_DS_))
152
153 #define SetFrDs(pbuf)   \
154         *(__le16 *)(pbuf) |= cpu_to_le16(_FROM_DS_)
155
156 #define GetFrDs(pbuf)   (((*(__le16 *)(pbuf)) & cpu_to_le16(_FROM_DS_)) != 0)
157
158 #define ClearFrDs(pbuf) \
159         *(__le16 *)(pbuf) &= (~cpu_to_le16(_FROM_DS_))
160
161 #define get_tofr_ds(pframe)     ((GetToDs(pframe) << 1) | GetFrDs(pframe))
162
163 #define SetMFrag(pbuf)  \
164         *(__le16 *)(pbuf) |= cpu_to_le16(_MORE_FRAG_)
165
166 #define GetMFrag(pbuf)  (((*(__le16 *)(pbuf)) & cpu_to_le16(_MORE_FRAG_)) != 0)
167
168 #define ClearMFrag(pbuf)        \
169         *(__le16 *)(pbuf) &= (~cpu_to_le16(_MORE_FRAG_))
170
171 #define SetRetry(pbuf)  \
172         *(__le16 *)(pbuf) |= cpu_to_le16(_RETRY_)
173
174 #define GetRetry(pbuf)  (((*(__le16 *)(pbuf)) & cpu_to_le16(_RETRY_)) != 0)
175
176 #define ClearRetry(pbuf)        \
177         *(__le16 *)(pbuf) &= (~cpu_to_le16(_RETRY_))
178
179 #define SetPwrMgt(pbuf) \
180         *(__le16 *)(pbuf) |= cpu_to_le16(_PWRMGT_)
181
182 #define GetPwrMgt(pbuf) (((*(__le16 *)(pbuf)) & cpu_to_le16(_PWRMGT_)) != 0)
183
184 #define ClearPwrMgt(pbuf)       \
185         *(__le16 *)(pbuf) &= (~cpu_to_le16(_PWRMGT_))
186
187 #define SetMData(pbuf)  \
188         *(__le16 *)(pbuf) |= cpu_to_le16(_MORE_DATA_)
189
190 #define GetMData(pbuf)  (((*(__le16 *)(pbuf)) & cpu_to_le16(_MORE_DATA_)) != 0)
191
192 #define ClearMData(pbuf)        \
193         *(__le16 *)(pbuf) &= (~cpu_to_le16(_MORE_DATA_))
194
195 #define SetPrivacy(pbuf)        \
196         *(__le16 *)(pbuf) |= cpu_to_le16(_PRIVACY_)
197
198 #define GetPrivacy(pbuf)                                        \
199         (((*(__le16 *)(pbuf)) & cpu_to_le16(_PRIVACY_)) != 0)
200
201 #define GetOrder(pbuf)                                  \
202         (((*(__le16 *)(pbuf)) & cpu_to_le16(_ORDER_)) != 0)
203
204 #define GetFrameType(pbuf)                              \
205         (le16_to_cpu(*(__le16 *)(pbuf)) & (BIT(3) | BIT(2)))
206
207 #define GetFrameSubType(pbuf)   (le16_to_cpu(*(__le16 *)(pbuf)) & (BIT(7) |\
208          BIT(6) | BIT(5) | BIT(4) | BIT(3) | BIT(2)))
209
210 #define SetFrameSubType(pbuf, type) \
211         do {    \
212                 *(__le16 *)(pbuf) &= cpu_to_le16(~(BIT(7) | BIT(6) |    \
213                  BIT(5) | BIT(4) | BIT(3) | BIT(2))); \
214                 *(__le16 *)(pbuf) |= cpu_to_le16(type); \
215         } while (0)
216
217 #define GetSequence(pbuf)                       \
218         (le16_to_cpu(*(__le16 *)((size_t)(pbuf) + 22)) >> 4)
219
220 #define GetFragNum(pbuf)                        \
221         (le16_to_cpu(*(__le16 *)((size_t)(pbuf) + 22)) & 0x0f)
222
223 #define SetSeqNum(pbuf, num) \
224         do {    \
225                 *(__le16 *)((size_t)(pbuf) + 22) = \
226                         ((*(__le16 *)((size_t)(pbuf) + 22)) & cpu_to_le16((unsigned short)0x000f)) | \
227                         cpu_to_le16((unsigned short)(0xfff0 & (num << 4))); \
228         } while (0)
229
230 #define SetDuration(pbuf, dur) \
231         *(__le16 *)((size_t)(pbuf) + 2) = cpu_to_le16(0xffff & (dur))
232
233 #define SetPriority(pbuf, tid)  \
234         *(__le16 *)(pbuf) |= cpu_to_le16(tid & 0xf)
235
236 #define GetPriority(pbuf)       ((le16_to_cpu(*(__le16 *)(pbuf))) & 0xf)
237
238 #define SetEOSP(pbuf, eosp)     \
239                 *(__le16 *)(pbuf) |= cpu_to_le16((eosp & 1) << 4)
240
241 #define SetAckpolicy(pbuf, ack) \
242         *(__le16 *)(pbuf) |= cpu_to_le16((ack & 3) << 5)
243
244 #define GetAckpolicy(pbuf) (((le16_to_cpu(*(__le16 *)pbuf)) >> 5) & 0x3)
245
246 #define GetAMsdu(pbuf) (((le16_to_cpu(*(__le16 *)pbuf)) >> 7) & 0x1)
247
248 #define GetAid(pbuf)    (le16_to_cpu(*(__le16 *)((size_t)(pbuf) + 2)) & 0x3fff)
249
250 #define GetAddr1Ptr(pbuf)       ((unsigned char *)((size_t)(pbuf) + 4))
251
252 #define GetAddr2Ptr(pbuf)       ((unsigned char *)((size_t)(pbuf) + 10))
253
254 #define GetAddr3Ptr(pbuf)       ((unsigned char *)((size_t)(pbuf) + 16))
255
256 #define GetAddr4Ptr(pbuf)       ((unsigned char *)((size_t)(pbuf) + 24))
257
258 static inline unsigned char *get_da(unsigned char *pframe)
259 {
260         unsigned char   *da;
261         unsigned int to_fr_ds = (GetToDs(pframe) << 1) | GetFrDs(pframe);
262
263         switch (to_fr_ds) {
264         case 0x00:      /*  ToDs=0, FromDs=0 */
265                 da = GetAddr1Ptr(pframe);
266                 break;
267         case 0x01:      /*  ToDs=0, FromDs=1 */
268                 da = GetAddr1Ptr(pframe);
269                 break;
270         case 0x02:      /*  ToDs=1, FromDs=0 */
271                 da = GetAddr3Ptr(pframe);
272                 break;
273         default:        /*  ToDs=1, FromDs=1 */
274                 da = GetAddr3Ptr(pframe);
275                 break;
276         }
277         return da;
278 }
279
280 static inline unsigned char *get_sa(unsigned char *pframe)
281 {
282         unsigned char   *sa;
283         unsigned int    to_fr_ds = (GetToDs(pframe) << 1) | GetFrDs(pframe);
284
285         switch (to_fr_ds) {
286         case 0x00:      /*  ToDs=0, FromDs=0 */
287                 sa = GetAddr2Ptr(pframe);
288                 break;
289         case 0x01:      /*  ToDs=0, FromDs=1 */
290                 sa = GetAddr3Ptr(pframe);
291                 break;
292         case 0x02:      /*  ToDs=1, FromDs=0 */
293                 sa = GetAddr2Ptr(pframe);
294                 break;
295         default:        /*  ToDs=1, FromDs=1 */
296                 sa = GetAddr4Ptr(pframe);
297                 break;
298         }
299         return sa;
300 }
301
302 static inline unsigned char *get_hdr_bssid(unsigned char *pframe)
303 {
304         unsigned char   *sa;
305         unsigned int    to_fr_ds = (GetToDs(pframe) << 1) | GetFrDs(pframe);
306
307         switch (to_fr_ds) {
308         case 0x00:      /*  ToDs=0, FromDs=0 */
309                 sa = GetAddr3Ptr(pframe);
310                 break;
311         case 0x01:      /*  ToDs=0, FromDs=1 */
312                 sa = GetAddr2Ptr(pframe);
313                 break;
314         case 0x02:      /*  ToDs=1, FromDs=0 */
315                 sa = GetAddr1Ptr(pframe);
316                 break;
317         case 0x03:      /*  ToDs=1, FromDs=1 */
318                 sa = GetAddr1Ptr(pframe);
319                 break;
320         default:
321                 sa = NULL; /*  */
322                 break;
323         }
324         return sa;
325 }
326
327 static inline int IsFrameTypeCtrl(unsigned char *pframe)
328 {
329         if (WIFI_CTRL_TYPE == GetFrameType(pframe))
330                 return true;
331         else
332                 return false;
333 }
334 /*-----------------------------------------------------------------------------
335                         Below is for the security related definition
336 ------------------------------------------------------------------------------*/
337 #define _RESERVED_FRAME_TYPE_           0
338 #define _SKB_FRAME_TYPE_                2
339 #define _PRE_ALLOCMEM_                  1
340 #define _PRE_ALLOCHDR_                  3
341 #define _PRE_ALLOCLLCHDR_               4
342 #define _PRE_ALLOCICVHDR_               5
343 #define _PRE_ALLOCMICHDR_               6
344
345 #define _SIFSTIME_                              \
346         ((priv->pmib->dot11BssType.net_work_type & WIRELESS_11A) ? 16 : 10)
347 #define _ACKCTSLNG_             14      /* 14 bytes long, including crclng */
348 #define _CRCLNG_                4
349
350 #define _ASOCREQ_IE_OFFSET_     4       /*  excluding wlan_hdr */
351 #define _ASOCRSP_IE_OFFSET_     6
352 #define _REASOCREQ_IE_OFFSET_   10
353 #define _REASOCRSP_IE_OFFSET_   6
354 #define _PROBEREQ_IE_OFFSET_    0
355 #define _PROBERSP_IE_OFFSET_    12
356 #define _AUTH_IE_OFFSET_        6
357 #define _DEAUTH_IE_OFFSET_      0
358 #define _BEACON_IE_OFFSET_      12
359 #define _PUBLIC_ACTION_IE_OFFSET_       8
360
361 #define _FIXED_IE_LENGTH_       _BEACON_IE_OFFSET_
362
363 #define _SSID_IE_               0
364 #define _SUPPORTEDRATES_IE_     1
365 #define _DSSET_IE_              3
366 #define _TIM_IE_                5
367 #define _IBSS_PARA_IE_          6
368 #define _COUNTRY_IE_            7
369 #define _CHLGETXT_IE_           16
370 #define _SUPPORTED_CH_IE_       36
371 #define _CH_SWTICH_ANNOUNCE_    37      /* Secondary Channel Offset */
372 #define _RSN_IE_2_              48
373 #define _SSN_IE_1_              221
374 #define _ERPINFO_IE_            42
375 #define _EXT_SUPPORTEDRATES_IE_ 50
376
377 #define _HT_CAPABILITY_IE_      45
378 #define _FTIE_                  55
379 #define _TIMEOUT_ITVL_IE_       56
380 #define _SRC_IE_                59
381 #define _HT_EXTRA_INFO_IE_      61
382 #define _HT_ADD_INFO_IE_        61 /* _HT_EXTRA_INFO_IE_ */
383 #define _WAPI_IE_               68
384
385 #define EID_BSSCoexistence      72 /*  20/40 BSS Coexistence */
386 #define EID_BSSIntolerantChlReport      73
387 #define _RIC_Descriptor_IE_     75
388
389 #define _LINK_ID_IE_            101
390 #define _CH_SWITCH_TIMING_      104
391 #define _PTI_BUFFER_STATUS_     106
392 #define _EXT_CAP_IE_            127
393 #define _VENDOR_SPECIFIC_IE_    221
394
395 #define _RESERVED47_            47
396
397 /* ---------------------------------------------------------------------------
398                                         Below is the fixed elements...
399 -----------------------------------------------------------------------------*/
400 #define _AUTH_ALGM_NUM_         2
401 #define _AUTH_SEQ_NUM_          2
402 #define _BEACON_ITERVAL_        2
403 #define _CAPABILITY_            2
404 #define _CURRENT_APADDR_        6
405 #define _LISTEN_INTERVAL_       2
406 #define _RSON_CODE_             2
407 #define _ASOC_ID_               2
408 #define _STATUS_CODE_           2
409 #define _TIMESTAMP_             8
410
411 #define AUTH_ODD_TO             0
412 #define AUTH_EVEN_TO            1
413
414 #define WLAN_ETHCONV_ENCAP      1
415 #define WLAN_ETHCONV_RFC1042    2
416 #define WLAN_ETHCONV_8021h      3
417
418 #define cap_ESS         BIT(0)
419 #define cap_IBSS        BIT(1)
420 #define cap_CFPollable  BIT(2)
421 #define cap_CFRequest   BIT(3)
422 #define cap_Privacy     BIT(4)
423 #define cap_ShortPremble BIT(5)
424 #define cap_PBCC        BIT(6)
425 #define cap_ChAgility   BIT(7)
426 #define cap_SpecMgmt    BIT(8)
427 #define cap_QoSi        BIT(9)
428 #define cap_ShortSlot   BIT(10)
429
430 /*-----------------------------------------------------------------------------
431                                 Below is the definition for 802.11i / 802.1x
432 ------------------------------------------------------------------------------*/
433 #define _IEEE8021X_MGT_                 1       /*  WPA */
434 #define _IEEE8021X_PSK_                 2       /*  WPA with pre-shared key */
435
436 /*
437  * #define _NO_PRIVACY_                 0
438  * #define _WEP_40_PRIVACY_             1
439  * #define _TKIP_PRIVACY_               2
440  * #define _WRAP_PRIVACY_               3
441  * #define _CCMP_PRIVACY_               4
442  * #define _WEP_104_PRIVACY_            5
443  * #define _WEP_WPA_MIXED_PRIVACY_ 6    WEP + WPA
444  */
445
446 /*-----------------------------------------------------------------------------
447                                 Below is the definition for WMM
448 ------------------------------------------------------------------------------*/
449 #define _WMM_IE_Length_                         7  /*  for WMM STA */
450 #define _WMM_Para_Element_Length_               24
451
452 /*-----------------------------------------------------------------------------
453                                 Below is the definition for 802.11n
454 ------------------------------------------------------------------------------*/
455
456 /**
457  * struct rtw_ieee80211_ht_cap - HT additional information
458  *
459  * This structure refers to "HT information element" as
460  * described in 802.11n draft section 7.3.2.53
461  */
462 struct ieee80211_ht_addt_info {
463         unsigned char   control_chan;
464         unsigned char   ht_param;
465         unsigned short  operation_mode;
466         unsigned short  stbc_param;
467         unsigned char   basic_set[16];
468 } __packed;
469
470 struct HT_info_element {
471         unsigned char   primary_channel;
472         unsigned char   infos[5];
473         unsigned char   MCS_rate[16];
474 } __packed;
475
476 struct AC_param {
477         unsigned char           ACI_AIFSN;
478         unsigned char           CW;
479         __le16  TXOP_limit;
480 } __packed;
481
482 struct WMM_para_element {
483         unsigned char           QoS_info;
484         unsigned char           reserved;
485         struct AC_param ac_param[4];
486 } __packed;
487
488 struct ADDBA_request {
489         unsigned char   dialog_token;
490         __le16          BA_para_set;
491         unsigned short  BA_timeout_value;
492         unsigned short  BA_starting_seqctrl;
493 } __packed;
494
495 enum ht_cap_ampdu_factor {
496         MAX_AMPDU_FACTOR_8K     = 0,
497         MAX_AMPDU_FACTOR_16K    = 1,
498         MAX_AMPDU_FACTOR_32K    = 2,
499         MAX_AMPDU_FACTOR_64K    = 3,
500 };
501
502 #define OP_MODE_PURE                    0
503 #define OP_MODE_MAY_BE_LEGACY_STAS      1
504 #define OP_MODE_20MHZ_HT_STA_ASSOCED    2
505 #define OP_MODE_MIXED                   3
506
507 #define HT_INFO_HT_PARAM_SECONDARY_CHNL_OFF_MASK        ((u8)BIT(0) | BIT(1))
508 #define HT_INFO_HT_PARAM_SECONDARY_CHNL_ABOVE           ((u8)BIT(0))
509 #define HT_INFO_HT_PARAM_SECONDARY_CHNL_BELOW           ((u8)BIT(0) | BIT(1))
510 #define HT_INFO_HT_PARAM_REC_TRANS_CHNL_WIDTH           ((u8)BIT(2))
511 #define HT_INFO_HT_PARAM_RIFS_MODE                      ((u8)BIT(3))
512 #define HT_INFO_HT_PARAM_CTRL_ACCESS_ONLY               ((u8)BIT(4))
513 #define HT_INFO_HT_PARAM_SRV_INTERVAL_GRANULARITY       ((u8)BIT(5))
514
515 #define HT_INFO_OPERATION_MODE_OP_MODE_MASK     \
516                 ((u16)(0x0001 | 0x0002))
517 #define HT_INFO_OPERATION_MODE_OP_MODE_OFFSET           0
518 #define HT_INFO_OPERATION_MODE_NON_GF_DEVS_PRESENT      ((u8)BIT(2))
519 #define HT_INFO_OPERATION_MODE_TRANSMIT_BURST_LIMIT     ((u8)BIT(3))
520 #define HT_INFO_OPERATION_MODE_NON_HT_STA_PRESENT       ((u8)BIT(4))
521
522 #define HT_INFO_STBC_PARAM_DUAL_BEACON          ((u16)BIT(6))
523 #define HT_INFO_STBC_PARAM_DUAL_STBC_PROTECT    ((u16)BIT(7))
524 #define HT_INFO_STBC_PARAM_SECONDARY_BC         ((u16)BIT(8))
525 #define HT_INFO_STBC_PARAM_LSIG_TXOP_PROTECT_ALLOWED    ((u16)BIT(9))
526 #define HT_INFO_STBC_PARAM_PCO_ACTIVE           ((u16)BIT(10))
527 #define HT_INFO_STBC_PARAM_PCO_PHASE            ((u16)BIT(11))
528
529 /*      ===============WPS Section=============== */
530 /*      For WPSv1.0 */
531 #define WPSOUI                                  0x0050f204
532 /*      WPS attribute ID */
533 #define WPS_ATTR_VER1                           0x104A
534 #define WPS_ATTR_SIMPLE_CONF_STATE              0x1044
535 #define WPS_ATTR_RESP_TYPE                      0x103B
536 #define WPS_ATTR_UUID_E                         0x1047
537 #define WPS_ATTR_MANUFACTURER                   0x1021
538 #define WPS_ATTR_MODEL_NAME                     0x1023
539 #define WPS_ATTR_MODEL_NUMBER                   0x1024
540 #define WPS_ATTR_SERIAL_NUMBER                  0x1042
541 #define WPS_ATTR_PRIMARY_DEV_TYPE               0x1054
542 #define WPS_ATTR_SEC_DEV_TYPE_LIST              0x1055
543 #define WPS_ATTR_DEVICE_NAME                    0x1011
544 #define WPS_ATTR_CONF_METHOD                    0x1008
545 #define WPS_ATTR_RF_BANDS                       0x103C
546 #define WPS_ATTR_DEVICE_PWID                    0x1012
547 #define WPS_ATTR_REQUEST_TYPE                   0x103A
548 #define WPS_ATTR_ASSOCIATION_STATE              0x1002
549 #define WPS_ATTR_CONFIG_ERROR                   0x1009
550 #define WPS_ATTR_VENDOR_EXT                     0x1049
551 #define WPS_ATTR_SELECTED_REGISTRAR             0x1041
552
553 /*      Value of WPS Request Type Attribute */
554 #define WPS_REQ_TYPE_ENROLLEE_INFO_ONLY         0x00
555 #define WPS_REQ_TYPE_ENROLLEE_OPEN_8021X        0x01
556 #define WPS_REQ_TYPE_REGISTRAR                  0x02
557 #define WPS_REQ_TYPE_WLAN_MANAGER_REGISTRAR     0x03
558
559 /*      Value of WPS Response Type Attribute */
560 #define WPS_RESPONSE_TYPE_INFO_ONLY     0x00
561 #define WPS_RESPONSE_TYPE_8021X         0x01
562 #define WPS_RESPONSE_TYPE_REGISTRAR     0x02
563 #define WPS_RESPONSE_TYPE_AP            0x03
564
565 /*      Value of WPS WiFi Simple Configuration State Attribute */
566 #define WPS_WSC_STATE_NOT_CONFIG        0x01
567 #define WPS_WSC_STATE_CONFIG            0x02
568
569 /*      Value of WPS Version Attribute */
570 #define WPS_VERSION_1                   0x10
571
572 /*      Value of WPS Configuration Method Attribute */
573 #define WPS_CONFIG_METHOD_FLASH         0x0001
574 #define WPS_CONFIG_METHOD_ETHERNET      0x0002
575 #define WPS_CONFIG_METHOD_LABEL         0x0004
576 #define WPS_CONFIG_METHOD_DISPLAY       0x0008
577 #define WPS_CONFIG_METHOD_E_NFC         0x0010
578 #define WPS_CONFIG_METHOD_I_NFC         0x0020
579 #define WPS_CONFIG_METHOD_NFC           0x0040
580 #define WPS_CONFIG_METHOD_PBC           0x0080
581 #define WPS_CONFIG_METHOD_KEYPAD        0x0100
582 #define WPS_CONFIG_METHOD_VPBC          0x0280
583 #define WPS_CONFIG_METHOD_PPBC          0x0480
584 #define WPS_CONFIG_METHOD_VDISPLAY      0x2008
585 #define WPS_CONFIG_METHOD_PDISPLAY      0x4008
586
587 /*      Value of Category ID of WPS Primary Device Type Attribute */
588 #define WPS_PDT_CID_DISPLAYS            0x0007
589 #define WPS_PDT_CID_MULIT_MEDIA         0x0008
590 #define WPS_PDT_CID_RTK_WIDI            WPS_PDT_CID_MULIT_MEDIA
591
592 /*      Value of Sub Category ID of WPS Primary Device Type Attribute */
593 #define WPS_PDT_SCID_MEDIA_SERVER       0x0005
594 #define WPS_PDT_SCID_RTK_DMP            WPS_PDT_SCID_MEDIA_SERVER
595
596 /*      Value of Device Password ID */
597 #define WPS_DPID_P                      0x0000
598 #define WPS_DPID_USER_SPEC              0x0001
599 #define WPS_DPID_MACHINE_SPEC           0x0002
600 #define WPS_DPID_REKEY                  0x0003
601 #define WPS_DPID_PBC                    0x0004
602 #define WPS_DPID_REGISTRAR_SPEC         0x0005
603
604 /*      Value of WPS RF Bands Attribute */
605 #define WPS_RF_BANDS_2_4_GHZ            0x01
606 #define WPS_RF_BANDS_5_GHZ              0x02
607
608 /*      Value of WPS Association State Attribute */
609 #define WPS_ASSOC_STATE_NOT_ASSOCIATED          0x00
610 #define WPS_ASSOC_STATE_CONNECTION_SUCCESS      0x01
611 #define WPS_ASSOC_STATE_CONFIGURATION_FAILURE   0x02
612 #define WPS_ASSOC_STATE_ASSOCIATION_FAILURE     0x03
613 #define WPS_ASSOC_STATE_IP_FAILURE              0x04
614
615 /*      WPS Configuration Method */
616 #define WPS_CM_NONE                     0x0000
617 #define WPS_CM_LABEL                    0x0004
618 #define WPS_CM_DISPLYA                  0x0008
619 #define WPS_CM_EXTERNAL_NFC_TOKEN       0x0010
620 #define WPS_CM_INTEGRATED_NFC_TOKEN     0x0020
621 #define WPS_CM_NFC_INTERFACE            0x0040
622 #define WPS_CM_PUSH_BUTTON              0x0080
623 #define WPS_CM_KEYPAD                   0x0100
624 #define WPS_CM_SW_PUHS_BUTTON           0x0280
625 #define WPS_CM_HW_PUHS_BUTTON           0x0480
626 #define WPS_CM_SW_DISPLAY_P             0x2008
627 #define WPS_CM_LCD_DISPLAY_P            0x4008
628
629 #define IP_MCAST_MAC(mac)                               \
630         ((mac[0] == 0x01) && (mac[1] == 0x00) && (mac[2] == 0x5e))
631 #define ICMPV6_MCAST_MAC(mac)                           \
632         ((mac[0] == 0x33) && (mac[1] == 0x33) && (mac[2] != 0xff))
633
634 #endif /*  _WIFI_H_ */