Loading...
1#ifndef _WIFI_H_
2#define _WIFI_H_
3
4#include "rtl871x_byteorder.h"
5#include <linux/compiler.h>
6
7#ifdef BIT
8#undef BIT
9#endif
10#define BIT(x) (1 << (x))
11
12#define WLAN_ETHHDR_LEN 14
13#define WLAN_ETHADDR_LEN 6
14#define WLAN_IEEE_OUI_LEN 3
15#define WLAN_ADDR_LEN 6
16#define WLAN_CRC_LEN 4
17#define WLAN_BSSID_LEN 6
18#define WLAN_BSS_TS_LEN 8
19#define WLAN_HDR_A3_LEN 24
20#define WLAN_HDR_A4_LEN 30
21#define WLAN_HDR_A3_QOS_LEN 26
22#define WLAN_HDR_A4_QOS_LEN 32
23#define WLAN_SSID_MAXLEN 32
24#define WLAN_DATA_MAXLEN 2312
25
26#define WLAN_A3_PN_OFFSET 24
27#define WLAN_A4_PN_OFFSET 30
28
29#define WLAN_MIN_ETHFRM_LEN 60
30#define WLAN_MAX_ETHFRM_LEN 1514
31#define WLAN_ETHHDR_LEN 14
32
33#define P80211CAPTURE_VERSION 0x80211001
34
35enum WIFI_FRAME_TYPE {
36 WIFI_MGT_TYPE = (0),
37 WIFI_CTRL_TYPE = (BIT(2)),
38 WIFI_DATA_TYPE = (BIT(3)),
39 WIFI_QOS_DATA_TYPE = (BIT(7)|BIT(3)), /*!< QoS Data */
40};
41
42enum WIFI_FRAME_SUBTYPE {
43 /* below is for mgt frame */
44 WIFI_ASSOCREQ = (0 | WIFI_MGT_TYPE),
45 WIFI_ASSOCRSP = (BIT(4) | WIFI_MGT_TYPE),
46 WIFI_REASSOCREQ = (BIT(5) | WIFI_MGT_TYPE),
47 WIFI_REASSOCRSP = (BIT(5) | BIT(4) | WIFI_MGT_TYPE),
48 WIFI_PROBEREQ = (BIT(6) | WIFI_MGT_TYPE),
49 WIFI_PROBERSP = (BIT(6) | BIT(4) | WIFI_MGT_TYPE),
50 WIFI_BEACON = (BIT(7) | WIFI_MGT_TYPE),
51 WIFI_ATIM = (BIT(7) | BIT(4) | WIFI_MGT_TYPE),
52 WIFI_DISASSOC = (BIT(7) | BIT(5) | WIFI_MGT_TYPE),
53 WIFI_AUTH = (BIT(7) | BIT(5) | BIT(4) | WIFI_MGT_TYPE),
54 WIFI_DEAUTH = (BIT(7) | BIT(6) | WIFI_MGT_TYPE),
55 WIFI_ACTION = (BIT(7) | BIT(6) | BIT(4) | WIFI_MGT_TYPE),
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) | WIFI_CTRL_TYPE),
63 /* below is for data frame */
64 WIFI_DATA = (0 | WIFI_DATA_TYPE),
65 WIFI_DATA_CFACK = (BIT(4) | WIFI_DATA_TYPE),
66 WIFI_DATA_CFPOLL = (BIT(5) | WIFI_DATA_TYPE),
67 WIFI_DATA_CFACKPOLL = (BIT(5) | BIT(4) | WIFI_DATA_TYPE),
68 WIFI_DATA_NULL = (BIT(6) | WIFI_DATA_TYPE),
69 WIFI_CF_ACK = (BIT(6) | BIT(4) | WIFI_DATA_TYPE),
70 WIFI_CF_POLL = (BIT(6) | BIT(5) | WIFI_DATA_TYPE),
71 WIFI_CF_ACKPOLL = (BIT(6) | BIT(5) | BIT(4) | WIFI_DATA_TYPE),
72};
73
74enum WIFI_REASON_CODE {
75 _RSON_RESERVED_ = 0,
76 _RSON_UNSPECIFIED_ = 1,
77 _RSON_AUTH_NO_LONGER_VALID_ = 2,
78 _RSON_DEAUTH_STA_LEAVING_ = 3,
79 _RSON_INACTIVITY_ = 4,
80 _RSON_UNABLE_HANDLE_ = 5,
81 _RSON_CLS2_ = 6,
82 _RSON_CLS3_ = 7,
83 _RSON_DISAOC_STA_LEAVING_ = 8,
84 _RSON_ASOC_NOT_AUTH_ = 9,
85 /* WPA reason */
86 _RSON_INVALID_IE_ = 13,
87 _RSON_MIC_FAILURE_ = 14,
88 _RSON_4WAY_HNDSHK_TIMEOUT_ = 15,
89 _RSON_GROUP_KEY_UPDATE_TIMEOUT_ = 16,
90 _RSON_DIFF_IE_ = 17,
91 _RSON_MLTCST_CIPHER_NOT_VALID_ = 18,
92 _RSON_UNICST_CIPHER_NOT_VALID_ = 19,
93 _RSON_AKMP_NOT_VALID_ = 20,
94 _RSON_UNSUPPORT_RSNE_VER_ = 21,
95 _RSON_INVALID_RSNE_CAP_ = 22,
96 _RSON_IEEE_802DOT1X_AUTH_FAIL_ = 23,
97 /* below are Realtek definitions */
98 _RSON_PMK_NOT_AVAILABLE_ = 24,
99};
100
101enum WIFI_STATUS_CODE {
102 _STATS_SUCCESSFUL_ = 0,
103 _STATS_FAILURE_ = 1,
104 _STATS_CAP_FAIL_ = 10,
105 _STATS_NO_ASOC_ = 11,
106 _STATS_OTHER_ = 12,
107 _STATS_NO_SUPP_ALG_ = 13,
108 _STATS_OUT_OF_AUTH_SEQ_ = 14,
109 _STATS_CHALLENGE_FAIL_ = 15,
110 _STATS_AUTH_TIMEOUT_ = 16,
111 _STATS_UNABLE_HANDLE_STA_ = 17,
112 _STATS_RATE_FAIL_ = 18,
113};
114
115enum WIFI_REG_DOMAIN {
116 DOMAIN_FCC = 1,
117 DOMAIN_IC = 2,
118 DOMAIN_ETSI = 3,
119 DOMAIN_SPAIN = 4,
120 DOMAIN_FRANCE = 5,
121 DOMAIN_MKK = 6,
122 DOMAIN_ISRAEL = 7,
123 DOMAIN_MKK1 = 8,
124 DOMAIN_MKK2 = 9,
125 DOMAIN_MKK3 = 10,
126 DOMAIN_MAX
127};
128
129#define _TO_DS_ BIT(8)
130#define _FROM_DS_ BIT(9)
131#define _MORE_FRAG_ BIT(10)
132#define _RETRY_ BIT(11)
133#define _PWRMGT_ BIT(12)
134#define _MORE_DATA_ BIT(13)
135#define _PRIVACY_ BIT(14)
136#define _ORDER_ BIT(15)
137
138#define SetToDs(pbuf) \
139 do { \
140 *(unsigned short *)(pbuf) |= cpu_to_le16(_TO_DS_); \
141 } while (0)
142
143#define GetToDs(pbuf) (((*(unsigned short *)(pbuf)) & \
144 le16_to_cpu(_TO_DS_)) != 0)
145
146#define ClearToDs(pbuf) \
147 do { \
148 *(unsigned short *)(pbuf) &= (~cpu_to_le16(_TO_DS_)); \
149 } while (0)
150
151#define SetFrDs(pbuf) \
152 do { \
153 *(unsigned short *)(pbuf) |= cpu_to_le16(_FROM_DS_); \
154 } while (0)
155
156#define GetFrDs(pbuf) (((*(unsigned short *)(pbuf)) & \
157 le16_to_cpu(_FROM_DS_)) != 0)
158
159#define ClearFrDs(pbuf) \
160 do { \
161 *(unsigned short *)(pbuf) &= (~cpu_to_le16(_FROM_DS_)); \
162 } while (0)
163
164#define get_tofr_ds(pframe) ((GetToDs(pframe) << 1) | GetFrDs(pframe))
165
166
167#define SetMFrag(pbuf) \
168 do { \
169 *(unsigned short *)(pbuf) |= cpu_to_le16(_MORE_FRAG_); \
170 } while (0)
171
172#define GetMFrag(pbuf) (((*(unsigned short *)(pbuf)) & \
173 le16_to_cpu(_MORE_FRAG_)) != 0)
174
175#define ClearMFrag(pbuf) \
176 do { \
177 *(unsigned short *)(pbuf) &= (~cpu_to_le16(_MORE_FRAG_)); \
178 } while (0)
179
180#define SetRetry(pbuf) \
181 do { \
182 *(unsigned short *)(pbuf) |= cpu_to_le16(_RETRY_); \
183 } while (0)
184
185#define GetRetry(pbuf) (((*(unsigned short *)(pbuf)) & \
186 le16_to_cpu(_RETRY_)) != 0)
187
188#define ClearRetry(pbuf) \
189 do { \
190 *(unsigned short *)(pbuf) &= (~cpu_to_le16(_RETRY_)); \
191 } while (0)
192
193#define SetPwrMgt(pbuf) \
194 do { \
195 *(unsigned short *)(pbuf) |= cpu_to_le16(_PWRMGT_); \
196 } while (0)
197
198#define GetPwrMgt(pbuf) (((*(unsigned short *)(pbuf)) & \
199 le16_to_cpu(_PWRMGT_)) != 0)
200
201#define ClearPwrMgt(pbuf) \
202 do { \
203 *(unsigned short *)(pbuf) &= (~cpu_to_le16(_PWRMGT_)); \
204 } while (0)
205
206#define SetMData(pbuf) \
207 do { \
208 *(unsigned short *)(pbuf) |= cpu_to_le16(_MORE_DATA_); \
209 } while (0)
210
211#define GetMData(pbuf) (((*(unsigned short *)(pbuf)) & \
212 le16_to_cpu(_MORE_DATA_)) != 0)
213
214#define ClearMData(pbuf) \
215 do { \
216 *(unsigned short *)(pbuf) &= (~cpu_to_le16(_MORE_DATA_)); \
217 } while (0)
218
219#define SetPrivacy(pbuf) \
220 do { \
221 *(unsigned short *)(pbuf) |= cpu_to_le16(_PRIVACY_); \
222 } while (0)
223
224#define GetPrivacy(pbuf) (((*(unsigned short *)(pbuf)) & \
225 le16_to_cpu(_PRIVACY_)) != 0)
226
227#define ClearPrivacy(pbuf) \
228 do { \
229 *(unsigned short *)(pbuf) &= (~cpu_to_le16(_PRIVACY_)); \
230 } while (0)
231
232
233#define GetOrder(pbuf) (((*(unsigned short *)(pbuf)) & \
234 le16_to_cpu(_ORDER_)) != 0)
235
236#define GetFrameType(pbuf) (le16_to_cpu(*(unsigned short *)(pbuf)) & \
237 (BIT(3) | BIT(2)))
238
239#define SetFrameType(pbuf, type) \
240 do { \
241 *(unsigned short *)(pbuf) &= __constant_cpu_to_le16(~(BIT(3) | \
242 BIT(2))); \
243 *(unsigned short *)(pbuf) |= __constant_cpu_to_le16(type); \
244 } while (0)
245
246#define GetFrameSubType(pbuf) (cpu_to_le16(*(unsigned short *)(pbuf)) & \
247 (BIT(7) | BIT(6) | BIT(5) | BIT(4) | BIT(3) | \
248 BIT(2)))
249
250#define SetFrameSubType(pbuf, type) \
251 do { \
252 *(unsigned short *)(pbuf) &= cpu_to_le16(~(BIT(7) | BIT(6) | \
253 BIT(5) | BIT(4) | BIT(3) | BIT(2))); \
254 *(unsigned short *)(pbuf) |= cpu_to_le16(type); \
255 } while (0)
256
257#define GetSequence(pbuf) (cpu_to_le16(*(unsigned short *)\
258 ((addr_t)(pbuf) + 22)) >> 4)
259
260#define GetFragNum(pbuf) (cpu_to_le16(*(unsigned short *)((addr_t)\
261 (pbuf) + 22)) & 0x0f)
262
263#define GetTupleCache(pbuf) (cpu_to_le16(*(unsigned short *)\
264 ((addr_t)(pbuf) + 22)))
265
266#define SetFragNum(pbuf, num) \
267 do { \
268 *(unsigned short *)((addr_t)(pbuf) + 22) = \
269 ((*(unsigned short *)((addr_t)(pbuf) + 22)) & \
270 le16_to_cpu(~(0x000f))) | \
271 cpu_to_le16(0x0f & (num)); \
272 } while (0)
273
274#define SetSeqNum(pbuf, num) \
275 do { \
276 *(unsigned short *)((addr_t)(pbuf) + 22) = \
277 ((*(unsigned short *)((addr_t)(pbuf) + 22)) & \
278 le16_to_cpu((unsigned short)0x000f)) | \
279 le16_to_cpu((unsigned short)(0xfff0 & (num << 4))); \
280 } while (0)
281
282#define SetDuration(pbuf, dur) \
283 do { \
284 *(unsigned short *)((addr_t)(pbuf) + 2) |= \
285 cpu_to_le16(0xffff & (dur)); \
286 } while (0)
287
288#define SetPriority(pbuf, tid) \
289 do { \
290 *(unsigned short *)(pbuf) |= cpu_to_le16(tid & 0xf); \
291 } while (0)
292
293#define GetPriority(pbuf) ((le16_to_cpu(*(unsigned short *)(pbuf))) & 0xf)
294
295#define SetAckpolicy(pbuf, ack) \
296 do { \
297 *(unsigned short *)(pbuf) |= cpu_to_le16((ack & 3) << 5); \
298 } while (0)
299
300#define GetAckpolicy(pbuf) (((le16_to_cpu(*(unsigned short *)pbuf)) >> 5) & 0x3)
301
302#define GetAMsdu(pbuf) (((le16_to_cpu(*(unsigned short *)pbuf)) >> 7) & 0x1)
303
304#define SetAMsdu(pbuf, amsdu) \
305 do { \
306 *(unsigned short *)(pbuf) |= cpu_to_le16((amsdu & 1) << 7); \
307 } while (0)
308
309#define GetAid(pbuf) (cpu_to_le16(*(unsigned short *)((addr_t)(pbuf) + 2)) \
310 & 0x3fff)
311
312#define GetTid(pbuf) (cpu_to_le16(*(unsigned short *)((addr_t)(pbuf) + \
313 (((GetToDs(pbuf) << 1)|GetFrDs(pbuf)) == 3 ? \
314 30 : 24))) & 0x000f)
315
316#define GetAddr1Ptr(pbuf) ((unsigned char *)((addr_t)(pbuf) + 4))
317
318#define GetAddr2Ptr(pbuf) ((unsigned char *)((addr_t)(pbuf) + 10))
319
320#define GetAddr3Ptr(pbuf) ((unsigned char *)((addr_t)(pbuf) + 16))
321
322#define GetAddr4Ptr(pbuf) ((unsigned char *)((addr_t)(pbuf) + 24))
323
324
325
326static inline int IS_MCAST(unsigned char *da)
327{
328 if ((*da) & 0x01)
329 return true;
330 else
331 return false;
332}
333
334
335static inline unsigned char *get_da(unsigned char *pframe)
336{
337 unsigned char *da;
338 unsigned int to_fr_ds = (GetToDs(pframe) << 1) | GetFrDs(pframe);
339
340 switch (to_fr_ds) {
341 case 0x00: /* ToDs=0, FromDs=0 */
342 da = GetAddr1Ptr(pframe);
343 break;
344 case 0x01: /* ToDs=0, FromDs=1 */
345 da = GetAddr1Ptr(pframe);
346 break;
347 case 0x02: /* ToDs=1, FromDs=0 */
348 da = GetAddr3Ptr(pframe);
349 break;
350 default: /* ToDs=1, FromDs=1 */
351 da = GetAddr3Ptr(pframe);
352 break;
353 }
354 return da;
355}
356
357
358static inline unsigned char *get_sa(unsigned char *pframe)
359{
360 unsigned char *sa;
361 unsigned int to_fr_ds = (GetToDs(pframe) << 1) | GetFrDs(pframe);
362
363 switch (to_fr_ds) {
364 case 0x00: /* ToDs=0, FromDs=0 */
365 sa = GetAddr2Ptr(pframe);
366 break;
367 case 0x01: /* ToDs=0, FromDs=1 */
368 sa = GetAddr3Ptr(pframe);
369 break;
370 case 0x02: /* ToDs=1, FromDs=0 */
371 sa = GetAddr2Ptr(pframe);
372 break;
373 default: /* ToDs=1, FromDs=1 */
374 sa = GetAddr4Ptr(pframe);
375 break;
376 }
377
378 return sa;
379}
380
381static inline unsigned char *get_hdr_bssid(unsigned char *pframe)
382{
383 unsigned char *sa;
384 unsigned int to_fr_ds = (GetToDs(pframe) << 1) | GetFrDs(pframe);
385
386 switch (to_fr_ds) {
387 case 0x00: /* ToDs=0, FromDs=0 */
388 sa = GetAddr3Ptr(pframe);
389 break;
390 case 0x01: /* ToDs=0, FromDs=1 */
391 sa = GetAddr2Ptr(pframe);
392 break;
393 case 0x02: /* ToDs=1, FromDs=0 */
394 sa = GetAddr1Ptr(pframe);
395 break;
396 default: /* ToDs=1, FromDs=1 */
397 sa = NULL;
398 break;
399 }
400 return sa;
401}
402
403
404
405/*-----------------------------------------------------------------------------
406 Below is for the security related definition
407------------------------------------------------------------------------------*/
408#define _RESERVED_FRAME_TYPE_ 0
409#define _SKB_FRAME_TYPE_ 2
410#define _PRE_ALLOCMEM_ 1
411#define _PRE_ALLOCHDR_ 3
412#define _PRE_ALLOCLLCHDR_ 4
413#define _PRE_ALLOCICVHDR_ 5
414#define _PRE_ALLOCMICHDR_ 6
415
416#define _SIFSTIME_ ((priv->pmib->BssType.net_work_type & \
417 WIRELESS_11A) ? 16 : 10)
418#define _ACKCTSLNG_ 14 /*14 bytes long, including crclng */
419#define _CRCLNG_ 4
420
421#define _ASOCREQ_IE_OFFSET_ 4 /* excluding wlan_hdr */
422#define _ASOCRSP_IE_OFFSET_ 6
423#define _REASOCREQ_IE_OFFSET_ 10
424#define _REASOCRSP_IE_OFFSET_ 6
425#define _PROBEREQ_IE_OFFSET_ 0
426#define _PROBERSP_IE_OFFSET_ 12
427#define _AUTH_IE_OFFSET_ 6
428#define _DEAUTH_IE_OFFSET_ 0
429#define _BEACON_IE_OFFSET_ 12
430
431#define _FIXED_IE_LENGTH_ _BEACON_IE_OFFSET_
432
433#define _SSID_IE_ 0
434#define _SUPPORTEDRATES_IE_ 1
435#define _DSSET_IE_ 3
436#define _TIM_IE_ 5
437#define _IBSS_PARA_IE_ 6
438#define _CHLGETXT_IE_ 16
439#define _RSN_IE_2_ 48`
440#define _SSN_IE_1_ 221
441#define _ERPINFO_IE_ 42
442#define _EXT_SUPPORTEDRATES_IE_ 50
443
444#define _HT_CAPABILITY_IE_ 45
445#define _HT_EXTRA_INFO_IE_ 61
446#define _HT_ADD_INFO_IE_ 61 /* _HT_EXTRA_INFO_IE_ */
447
448#define _VENDOR_SPECIFIC_IE_ 221
449
450#define _RESERVED47_ 47
451
452
453/* ---------------------------------------------------------------------------
454 Below is the fixed elements...
455-----------------------------------------------------------------------------*/
456#define _AUTH_ALGM_NUM_ 2
457#define _AUTH_SEQ_NUM_ 2
458#define _BEACON_ITERVAL_ 2
459#define _CAPABILITY_ 2
460#define _CURRENT_APADDR_ 6
461#define _LISTEN_INTERVAL_ 2
462#define _RSON_CODE_ 2
463#define _ASOC_ID_ 2
464#define _STATUS_CODE_ 2
465#define _TIMESTAMP_ 8
466
467#define AUTH_ODD_TO 0
468#define AUTH_EVEN_TO 1
469
470#define WLAN_ETHCONV_ENCAP 1
471#define WLAN_ETHCONV_RFC1042 2
472#define WLAN_ETHCONV_8021h 3
473
474#define cap_ESS BIT(0)
475#define cap_IBSS BIT(1)
476#define cap_CFPollable BIT(2)
477#define cap_CFRequest BIT(3)
478#define cap_Privacy BIT(4)
479#define cap_ShortPremble BIT(5)
480
481/*-----------------------------------------------------------------------------
482 Below is the definition for 802.11i / 802.1x
483------------------------------------------------------------------------------*/
484#define _IEEE8021X_MGT_ 1 /*WPA */
485#define _IEEE8021X_PSK_ 2 /* WPA with pre-shared key */
486
487/*-----------------------------------------------------------------------------
488 Below is the definition for WMM
489------------------------------------------------------------------------------*/
490#define _WMM_IE_Length_ 7 /* for WMM STA */
491#define _WMM_Para_Element_Length_ 24
492
493
494/*-----------------------------------------------------------------------------
495 Below is the definition for 802.11n
496------------------------------------------------------------------------------*/
497
498/* block-ack parameters */
499#define IEEE80211_ADDBA_PARAM_POLICY_MASK 0x0002
500#define IEEE80211_ADDBA_PARAM_TID_MASK 0x003C
501#define IEEE80211_ADDBA_PARAM_BUF_SIZE_MASK 0xFFA0
502#define IEEE80211_DELBA_PARAM_TID_MASK 0xF000
503#define IEEE80211_DELBA_PARAM_INITIATOR_MASK 0x0800
504
505#define SetOrderBit(pbuf) \
506 do { \
507 *(unsigned short *)(pbuf) |= cpu_to_le16(_ORDER_); \
508 } while (0)
509
510#define GetOrderBit(pbuf) (((*(unsigned short *)(pbuf)) & \
511 le16_to_cpu(_ORDER_)) != 0)
512
513
514/**
515 * struct ieee80211_bar - HT Block Ack Request
516 *
517 * This structure refers to "HT BlockAckReq" as
518 * described in 802.11n draft section 7.2.1.7.1
519 */
520struct ieee80211_bar {
521 unsigned short frame_control;
522 unsigned short duration;
523 unsigned char ra[6];
524 unsigned char ta[6];
525 unsigned short control;
526 unsigned short start_seq_num;
527} __packed;
528
529/* 802.11 BAR control masks */
530#define IEEE80211_BAR_CTRL_ACK_POLICY_NORMAL 0x0000
531#define IEEE80211_BAR_CTRL_CBMTID_COMPRESSED_BA 0x0004
532
533
534 /**
535 * struct ieee80211_ht_cap - HT capabilities
536 *
537 * This structure refers to "HT capabilities element" as
538 * described in 802.11n draft section 7.3.2.52
539 */
540
541struct ieee80211_ht_cap {
542 unsigned short cap_info;
543 unsigned char ampdu_params_info;
544 unsigned char supp_mcs_set[16];
545 unsigned short extended_ht_cap_info;
546 unsigned int tx_BF_cap_info;
547 unsigned char antenna_selection_info;
548} __packed;
549
550/**
551 * struct ieee80211_ht_cap - HT additional information
552 *
553 * This structure refers to "HT information element" as
554 * described in 802.11n draft section 7.3.2.53
555 */
556struct ieee80211_ht_addt_info {
557 unsigned char control_chan;
558 unsigned char ht_param;
559 unsigned short operation_mode;
560 unsigned short stbc_param;
561 unsigned char basic_set[16];
562} __packed;
563
564/* 802.11n HT capabilities masks */
565#define IEEE80211_HT_CAP_SUP_WIDTH 0x0002
566#define IEEE80211_HT_CAP_SM_PS 0x000C
567#define IEEE80211_HT_CAP_GRN_FLD 0x0010
568#define IEEE80211_HT_CAP_SGI_20 0x0020
569#define IEEE80211_HT_CAP_SGI_40 0x0040
570#define IEEE80211_HT_CAP_TX_STBC 0x0080
571#define IEEE80211_HT_CAP_DELAY_BA 0x0400
572#define IEEE80211_HT_CAP_MAX_AMSDU 0x0800
573#define IEEE80211_HT_CAP_DSSSCCK40 0x1000
574/* 802.11n HT capability AMPDU settings */
575#define IEEE80211_HT_CAP_AMPDU_FACTOR 0x03
576#define IEEE80211_HT_CAP_AMPDU_DENSITY 0x1C
577/* 802.11n HT capability MSC set */
578#define IEEE80211_SUPP_MCS_SET_UEQM 4
579#define IEEE80211_HT_CAP_MAX_STREAMS 4
580#define IEEE80211_SUPP_MCS_SET_LEN 10
581/* maximum streams the spec allows */
582#define IEEE80211_HT_CAP_MCS_TX_DEFINED 0x01
583#define IEEE80211_HT_CAP_MCS_TX_RX_DIFF 0x02
584#define IEEE80211_HT_CAP_MCS_TX_STREAMS 0x0C
585#define IEEE80211_HT_CAP_MCS_TX_UEQM 0x10
586/* 802.11n HT IE masks */
587#define IEEE80211_HT_IE_CHA_SEC_OFFSET 0x03
588#define IEEE80211_HT_IE_CHA_SEC_NONE 0x00
589#define IEEE80211_HT_IE_CHA_SEC_ABOVE 0x01
590#define IEEE80211_HT_IE_CHA_SEC_BELOW 0x03
591#define IEEE80211_HT_IE_CHA_WIDTH 0x04
592#define IEEE80211_HT_IE_HT_PROTECTION 0x0003
593#define IEEE80211_HT_IE_NON_GF_STA_PRSNT 0x0004
594#define IEEE80211_HT_IE_NON_HT_STA_PRSNT 0x0010
595
596/* block-ack parameters */
597#define IEEE80211_ADDBA_PARAM_POLICY_MASK 0x0002
598#define IEEE80211_ADDBA_PARAM_TID_MASK 0x003C
599#define IEEE80211_ADDBA_PARAM_BUF_SIZE_MASK 0xFFA0
600#define IEEE80211_DELBA_PARAM_TID_MASK 0xF000
601#define IEEE80211_DELBA_PARAM_INITIATOR_MASK 0x0800
602
603/*
604 * A-PMDU buffer sizes
605 * According to IEEE802.11n spec size varies from 8K to 64K (in powers of 2)
606 */
607#define IEEE80211_MIN_AMPDU_BUF 0x8
608#define IEEE80211_MAX_AMPDU_BUF 0x40
609
610
611/* Spatial Multiplexing Power Save Modes */
612#define WLAN_HT_CAP_SM_PS_STATIC 0
613#define WLAN_HT_CAP_SM_PS_DYNAMIC 1
614#define WLAN_HT_CAP_SM_PS_INVALID 2
615#define WLAN_HT_CAP_SM_PS_DISABLED 3
616
617#endif /* _WIFI_H_ */
618
1/******************************************************************************
2 *
3 * Copyright(c) 2007 - 2010 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 * Modifications for inclusion into the Linux staging tree are
19 * Copyright(c) 2010 Larry Finger. All rights reserved.
20 *
21 * Contact information:
22 * WLAN FAE <wlanfae@realtek.com>
23 * Larry Finger <Larry.Finger@lwfinger.net>
24 *
25 ******************************************************************************/
26#ifndef _WIFI_H_
27#define _WIFI_H_
28
29#include <linux/compiler.h>
30
31#ifdef BIT
32#undef BIT
33#endif
34#define BIT(x) (1 << (x))
35
36#define WLAN_ETHHDR_LEN 14
37#define WLAN_ETHADDR_LEN 6
38#define WLAN_IEEE_OUI_LEN 3
39#define WLAN_ADDR_LEN 6
40#define WLAN_CRC_LEN 4
41#define WLAN_BSSID_LEN 6
42#define WLAN_BSS_TS_LEN 8
43#define WLAN_HDR_A3_LEN 24
44#define WLAN_HDR_A4_LEN 30
45#define WLAN_HDR_A3_QOS_LEN 26
46#define WLAN_HDR_A4_QOS_LEN 32
47#define WLAN_SSID_MAXLEN 32
48#define WLAN_DATA_MAXLEN 2312
49
50#define WLAN_A3_PN_OFFSET 24
51#define WLAN_A4_PN_OFFSET 30
52
53#define WLAN_MIN_ETHFRM_LEN 60
54#define WLAN_MAX_ETHFRM_LEN 1514
55#define WLAN_ETHHDR_LEN 14
56
57#define P80211CAPTURE_VERSION 0x80211001
58
59enum 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
66enum 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 /* below is for control frame */
81 WIFI_PSPOLL = (BIT(7) | BIT(5) | WIFI_CTRL_TYPE),
82 WIFI_RTS = (BIT(7) | BIT(5) | BIT(4) | WIFI_CTRL_TYPE),
83 WIFI_CTS = (BIT(7) | BIT(6) | WIFI_CTRL_TYPE),
84 WIFI_ACK = (BIT(7) | BIT(6) | BIT(4) | WIFI_CTRL_TYPE),
85 WIFI_CFEND = (BIT(7) | BIT(6) | BIT(5) | WIFI_CTRL_TYPE),
86 WIFI_CFEND_CFACK = (BIT(7) | BIT(6) | BIT(5) | BIT(4) | WIFI_CTRL_TYPE),
87 /* below is for data frame */
88 WIFI_DATA = (0 | WIFI_DATA_TYPE),
89 WIFI_DATA_CFACK = (BIT(4) | WIFI_DATA_TYPE),
90 WIFI_DATA_CFPOLL = (BIT(5) | WIFI_DATA_TYPE),
91 WIFI_DATA_CFACKPOLL = (BIT(5) | BIT(4) | WIFI_DATA_TYPE),
92 WIFI_DATA_NULL = (BIT(6) | WIFI_DATA_TYPE),
93 WIFI_CF_ACK = (BIT(6) | BIT(4) | WIFI_DATA_TYPE),
94 WIFI_CF_POLL = (BIT(6) | BIT(5) | WIFI_DATA_TYPE),
95 WIFI_CF_ACKPOLL = (BIT(6) | BIT(5) | BIT(4) | WIFI_DATA_TYPE),
96};
97
98enum WIFI_REASON_CODE {
99 _RSON_RESERVED_ = 0,
100 _RSON_UNSPECIFIED_ = 1,
101 _RSON_AUTH_NO_LONGER_VALID_ = 2,
102 _RSON_DEAUTH_STA_LEAVING_ = 3,
103 _RSON_INACTIVITY_ = 4,
104 _RSON_UNABLE_HANDLE_ = 5,
105 _RSON_CLS2_ = 6,
106 _RSON_CLS3_ = 7,
107 _RSON_DISAOC_STA_LEAVING_ = 8,
108 _RSON_ASOC_NOT_AUTH_ = 9,
109 /* WPA reason */
110 _RSON_INVALID_IE_ = 13,
111 _RSON_MIC_FAILURE_ = 14,
112 _RSON_4WAY_HNDSHK_TIMEOUT_ = 15,
113 _RSON_GROUP_KEY_UPDATE_TIMEOUT_ = 16,
114 _RSON_DIFF_IE_ = 17,
115 _RSON_MLTCST_CIPHER_NOT_VALID_ = 18,
116 _RSON_UNICST_CIPHER_NOT_VALID_ = 19,
117 _RSON_AKMP_NOT_VALID_ = 20,
118 _RSON_UNSUPPORT_RSNE_VER_ = 21,
119 _RSON_INVALID_RSNE_CAP_ = 22,
120 _RSON_IEEE_802DOT1X_AUTH_FAIL_ = 23,
121 /* below are Realtek definitions */
122 _RSON_PMK_NOT_AVAILABLE_ = 24,
123};
124
125enum WIFI_STATUS_CODE {
126 _STATS_SUCCESSFUL_ = 0,
127 _STATS_FAILURE_ = 1,
128 _STATS_CAP_FAIL_ = 10,
129 _STATS_NO_ASOC_ = 11,
130 _STATS_OTHER_ = 12,
131 _STATS_NO_SUPP_ALG_ = 13,
132 _STATS_OUT_OF_AUTH_SEQ_ = 14,
133 _STATS_CHALLENGE_FAIL_ = 15,
134 _STATS_AUTH_TIMEOUT_ = 16,
135 _STATS_UNABLE_HANDLE_STA_ = 17,
136 _STATS_RATE_FAIL_ = 18,
137};
138
139enum WIFI_REG_DOMAIN {
140 DOMAIN_FCC = 1,
141 DOMAIN_IC = 2,
142 DOMAIN_ETSI = 3,
143 DOMAIN_SPAIN = 4,
144 DOMAIN_FRANCE = 5,
145 DOMAIN_MKK = 6,
146 DOMAIN_ISRAEL = 7,
147 DOMAIN_MKK1 = 8,
148 DOMAIN_MKK2 = 9,
149 DOMAIN_MKK3 = 10,
150 DOMAIN_MAX
151};
152
153#define _TO_DS_ BIT(8)
154#define _FROM_DS_ BIT(9)
155#define _MORE_FRAG_ BIT(10)
156#define _RETRY_ BIT(11)
157#define _PWRMGT_ BIT(12)
158#define _MORE_DATA_ BIT(13)
159#define _PRIVACY_ BIT(14)
160#define _ORDER_ BIT(15)
161
162#define SetToDs(pbuf) \
163 do { \
164 *(unsigned short *)(pbuf) |= cpu_to_le16(_TO_DS_); \
165 } while (0)
166
167#define GetToDs(pbuf) (((*(unsigned short *)(pbuf)) & \
168 le16_to_cpu(_TO_DS_)) != 0)
169
170#define ClearToDs(pbuf) \
171 do { \
172 *(unsigned short *)(pbuf) &= (~cpu_to_le16(_TO_DS_)); \
173 } while (0)
174
175#define SetFrDs(pbuf) \
176 do { \
177 *(unsigned short *)(pbuf) |= cpu_to_le16(_FROM_DS_); \
178 } while (0)
179
180#define GetFrDs(pbuf) (((*(unsigned short *)(pbuf)) & \
181 le16_to_cpu(_FROM_DS_)) != 0)
182
183#define ClearFrDs(pbuf) \
184 do { \
185 *(unsigned short *)(pbuf) &= (~cpu_to_le16(_FROM_DS_)); \
186 } while (0)
187
188#define get_tofr_ds(pframe) ((GetToDs(pframe) << 1) | GetFrDs(pframe))
189
190
191#define SetMFrag(pbuf) \
192 do { \
193 *(unsigned short *)(pbuf) |= cpu_to_le16(_MORE_FRAG_); \
194 } while (0)
195
196#define GetMFrag(pbuf) (((*(unsigned short *)(pbuf)) & \
197 le16_to_cpu(_MORE_FRAG_)) != 0)
198
199#define ClearMFrag(pbuf) \
200 do { \
201 *(unsigned short *)(pbuf) &= (~cpu_to_le16(_MORE_FRAG_)); \
202 } while (0)
203
204#define SetRetry(pbuf) \
205 do { \
206 *(unsigned short *)(pbuf) |= cpu_to_le16(_RETRY_); \
207 } while (0)
208
209#define GetRetry(pbuf) (((*(unsigned short *)(pbuf)) & \
210 le16_to_cpu(_RETRY_)) != 0)
211
212#define ClearRetry(pbuf) \
213 do { \
214 *(unsigned short *)(pbuf) &= (~cpu_to_le16(_RETRY_)); \
215 } while (0)
216
217#define SetPwrMgt(pbuf) \
218 do { \
219 *(unsigned short *)(pbuf) |= cpu_to_le16(_PWRMGT_); \
220 } while (0)
221
222#define GetPwrMgt(pbuf) (((*(unsigned short *)(pbuf)) & \
223 le16_to_cpu(_PWRMGT_)) != 0)
224
225#define ClearPwrMgt(pbuf) \
226 do { \
227 *(unsigned short *)(pbuf) &= (~cpu_to_le16(_PWRMGT_)); \
228 } while (0)
229
230#define SetMData(pbuf) \
231 do { \
232 *(unsigned short *)(pbuf) |= cpu_to_le16(_MORE_DATA_); \
233 } while (0)
234
235#define GetMData(pbuf) (((*(unsigned short *)(pbuf)) & \
236 le16_to_cpu(_MORE_DATA_)) != 0)
237
238#define ClearMData(pbuf) \
239 do { \
240 *(unsigned short *)(pbuf) &= (~cpu_to_le16(_MORE_DATA_)); \
241 } while (0)
242
243#define SetPrivacy(pbuf) \
244 do { \
245 *(unsigned short *)(pbuf) |= cpu_to_le16(_PRIVACY_); \
246 } while (0)
247
248#define GetPrivacy(pbuf) (((*(unsigned short *)(pbuf)) & \
249 le16_to_cpu(_PRIVACY_)) != 0)
250
251#define ClearPrivacy(pbuf) \
252 do { \
253 *(unsigned short *)(pbuf) &= (~cpu_to_le16(_PRIVACY_)); \
254 } while (0)
255
256
257#define GetOrder(pbuf) (((*(unsigned short *)(pbuf)) & \
258 le16_to_cpu(_ORDER_)) != 0)
259
260#define GetFrameType(pbuf) (le16_to_cpu(*(unsigned short *)(pbuf)) & \
261 (BIT(3) | BIT(2)))
262
263#define SetFrameType(pbuf, type) \
264 do { \
265 *(unsigned short *)(pbuf) &= __constant_cpu_to_le16(~(BIT(3) | \
266 BIT(2))); \
267 *(unsigned short *)(pbuf) |= __constant_cpu_to_le16(type); \
268 } while (0)
269
270#define GetFrameSubType(pbuf) (cpu_to_le16(*(unsigned short *)(pbuf)) & \
271 (BIT(7) | BIT(6) | BIT(5) | BIT(4) | BIT(3) | \
272 BIT(2)))
273
274#define SetFrameSubType(pbuf, type) \
275 do { \
276 *(unsigned short *)(pbuf) &= cpu_to_le16(~(BIT(7) | BIT(6) | \
277 BIT(5) | BIT(4) | BIT(3) | BIT(2))); \
278 *(unsigned short *)(pbuf) |= cpu_to_le16(type); \
279 } while (0)
280
281#define GetSequence(pbuf) (cpu_to_le16(*(unsigned short *)\
282 ((addr_t)(pbuf) + 22)) >> 4)
283
284#define GetFragNum(pbuf) (cpu_to_le16(*(unsigned short *)((addr_t)\
285 (pbuf) + 22)) & 0x0f)
286
287#define GetTupleCache(pbuf) (cpu_to_le16(*(unsigned short *)\
288 ((addr_t)(pbuf) + 22)))
289
290#define SetFragNum(pbuf, num) \
291 do { \
292 *(unsigned short *)((addr_t)(pbuf) + 22) = \
293 ((*(unsigned short *)((addr_t)(pbuf) + 22)) & \
294 le16_to_cpu(~(0x000f))) | \
295 cpu_to_le16(0x0f & (num)); \
296 } while (0)
297
298#define SetSeqNum(pbuf, num) \
299 do { \
300 *(unsigned short *)((addr_t)(pbuf) + 22) = \
301 ((*(unsigned short *)((addr_t)(pbuf) + 22)) & \
302 le16_to_cpu((unsigned short)0x000f)) | \
303 le16_to_cpu((unsigned short)(0xfff0 & (num << 4))); \
304 } while (0)
305
306#define SetDuration(pbuf, dur) \
307 do { \
308 *(unsigned short *)((addr_t)(pbuf) + 2) |= \
309 cpu_to_le16(0xffff & (dur)); \
310 } while (0)
311
312#define SetPriority(pbuf, tid) \
313 do { \
314 *(unsigned short *)(pbuf) |= cpu_to_le16(tid & 0xf); \
315 } while (0)
316
317#define GetPriority(pbuf) ((le16_to_cpu(*(unsigned short *)(pbuf))) & 0xf)
318
319#define SetAckpolicy(pbuf, ack) \
320 do { \
321 *(unsigned short *)(pbuf) |= cpu_to_le16((ack & 3) << 5); \
322 } while (0)
323
324#define GetAckpolicy(pbuf) (((le16_to_cpu(*(unsigned short *)pbuf)) >> 5) & 0x3)
325
326#define GetAMsdu(pbuf) (((le16_to_cpu(*(unsigned short *)pbuf)) >> 7) & 0x1)
327
328#define SetAMsdu(pbuf, amsdu) \
329 do { \
330 *(unsigned short *)(pbuf) |= cpu_to_le16((amsdu & 1) << 7); \
331 } while (0)
332
333#define GetAid(pbuf) (cpu_to_le16(*(unsigned short *)((addr_t)(pbuf) + 2)) \
334 & 0x3fff)
335
336#define GetTid(pbuf) (cpu_to_le16(*(unsigned short *)((addr_t)(pbuf) + \
337 (((GetToDs(pbuf) << 1)|GetFrDs(pbuf)) == 3 ? \
338 30 : 24))) & 0x000f)
339
340#define GetAddr1Ptr(pbuf) ((unsigned char *)((addr_t)(pbuf) + 4))
341
342#define GetAddr2Ptr(pbuf) ((unsigned char *)((addr_t)(pbuf) + 10))
343
344#define GetAddr3Ptr(pbuf) ((unsigned char *)((addr_t)(pbuf) + 16))
345
346#define GetAddr4Ptr(pbuf) ((unsigned char *)((addr_t)(pbuf) + 24))
347
348
349
350static inline int IS_MCAST(unsigned char *da)
351{
352 if ((*da) & 0x01)
353 return true;
354 else
355 return false;
356}
357
358
359static inline unsigned char *get_da(unsigned char *pframe)
360{
361 unsigned char *da;
362 unsigned int to_fr_ds = (GetToDs(pframe) << 1) | GetFrDs(pframe);
363
364 switch (to_fr_ds) {
365 case 0x00: /* ToDs=0, FromDs=0 */
366 da = GetAddr1Ptr(pframe);
367 break;
368 case 0x01: /* ToDs=0, FromDs=1 */
369 da = GetAddr1Ptr(pframe);
370 break;
371 case 0x02: /* ToDs=1, FromDs=0 */
372 da = GetAddr3Ptr(pframe);
373 break;
374 default: /* ToDs=1, FromDs=1 */
375 da = GetAddr3Ptr(pframe);
376 break;
377 }
378 return da;
379}
380
381
382static inline unsigned char *get_sa(unsigned char *pframe)
383{
384 unsigned char *sa;
385 unsigned int to_fr_ds = (GetToDs(pframe) << 1) | GetFrDs(pframe);
386
387 switch (to_fr_ds) {
388 case 0x00: /* ToDs=0, FromDs=0 */
389 sa = GetAddr2Ptr(pframe);
390 break;
391 case 0x01: /* ToDs=0, FromDs=1 */
392 sa = GetAddr3Ptr(pframe);
393 break;
394 case 0x02: /* ToDs=1, FromDs=0 */
395 sa = GetAddr2Ptr(pframe);
396 break;
397 default: /* ToDs=1, FromDs=1 */
398 sa = GetAddr4Ptr(pframe);
399 break;
400 }
401
402 return sa;
403}
404
405static inline unsigned char *get_hdr_bssid(unsigned char *pframe)
406{
407 unsigned char *sa;
408 unsigned int to_fr_ds = (GetToDs(pframe) << 1) | GetFrDs(pframe);
409
410 switch (to_fr_ds) {
411 case 0x00: /* ToDs=0, FromDs=0 */
412 sa = GetAddr3Ptr(pframe);
413 break;
414 case 0x01: /* ToDs=0, FromDs=1 */
415 sa = GetAddr2Ptr(pframe);
416 break;
417 case 0x02: /* ToDs=1, FromDs=0 */
418 sa = GetAddr1Ptr(pframe);
419 break;
420 default: /* ToDs=1, FromDs=1 */
421 sa = NULL;
422 break;
423 }
424 return sa;
425}
426
427
428
429/*-----------------------------------------------------------------------------
430 Below is for the security related definition
431------------------------------------------------------------------------------*/
432#define _RESERVED_FRAME_TYPE_ 0
433#define _SKB_FRAME_TYPE_ 2
434#define _PRE_ALLOCMEM_ 1
435#define _PRE_ALLOCHDR_ 3
436#define _PRE_ALLOCLLCHDR_ 4
437#define _PRE_ALLOCICVHDR_ 5
438#define _PRE_ALLOCMICHDR_ 6
439
440#define _SIFSTIME_ ((priv->pmib->BssType.net_work_type & \
441 WIRELESS_11A) ? 16 : 10)
442#define _ACKCTSLNG_ 14 /*14 bytes long, including crclng */
443#define _CRCLNG_ 4
444
445#define _ASOCREQ_IE_OFFSET_ 4 /* excluding wlan_hdr */
446#define _ASOCRSP_IE_OFFSET_ 6
447#define _REASOCREQ_IE_OFFSET_ 10
448#define _REASOCRSP_IE_OFFSET_ 6
449#define _PROBEREQ_IE_OFFSET_ 0
450#define _PROBERSP_IE_OFFSET_ 12
451#define _AUTH_IE_OFFSET_ 6
452#define _DEAUTH_IE_OFFSET_ 0
453#define _BEACON_IE_OFFSET_ 12
454
455#define _FIXED_IE_LENGTH_ _BEACON_IE_OFFSET_
456
457#define _SSID_IE_ 0
458#define _SUPPORTEDRATES_IE_ 1
459#define _DSSET_IE_ 3
460#define _TIM_IE_ 5
461#define _IBSS_PARA_IE_ 6
462#define _CHLGETXT_IE_ 16
463#define _RSN_IE_2_ 48`
464#define _SSN_IE_1_ 221
465#define _ERPINFO_IE_ 42
466#define _EXT_SUPPORTEDRATES_IE_ 50
467
468#define _HT_CAPABILITY_IE_ 45
469#define _HT_EXTRA_INFO_IE_ 61
470#define _HT_ADD_INFO_IE_ 61 /* _HT_EXTRA_INFO_IE_ */
471
472#define _VENDOR_SPECIFIC_IE_ 221
473
474#define _RESERVED47_ 47
475
476
477/* ---------------------------------------------------------------------------
478 Below is the fixed elements...
479-----------------------------------------------------------------------------*/
480#define _AUTH_ALGM_NUM_ 2
481#define _AUTH_SEQ_NUM_ 2
482#define _BEACON_ITERVAL_ 2
483#define _CAPABILITY_ 2
484#define _CURRENT_APADDR_ 6
485#define _LISTEN_INTERVAL_ 2
486#define _RSON_CODE_ 2
487#define _ASOC_ID_ 2
488#define _STATUS_CODE_ 2
489#define _TIMESTAMP_ 8
490
491#define AUTH_ODD_TO 0
492#define AUTH_EVEN_TO 1
493
494#define WLAN_ETHCONV_ENCAP 1
495#define WLAN_ETHCONV_RFC1042 2
496#define WLAN_ETHCONV_8021h 3
497
498#define cap_ESS BIT(0)
499#define cap_IBSS BIT(1)
500#define cap_CFPollable BIT(2)
501#define cap_CFRequest BIT(3)
502#define cap_Privacy BIT(4)
503#define cap_ShortPremble BIT(5)
504
505/*-----------------------------------------------------------------------------
506 Below is the definition for 802.11i / 802.1x
507------------------------------------------------------------------------------*/
508#define _IEEE8021X_MGT_ 1 /*WPA */
509#define _IEEE8021X_PSK_ 2 /* WPA with pre-shared key */
510
511/*-----------------------------------------------------------------------------
512 Below is the definition for WMM
513------------------------------------------------------------------------------*/
514#define _WMM_IE_Length_ 7 /* for WMM STA */
515#define _WMM_Para_Element_Length_ 24
516
517
518/*-----------------------------------------------------------------------------
519 Below is the definition for 802.11n
520------------------------------------------------------------------------------*/
521
522/* block-ack parameters */
523#define IEEE80211_ADDBA_PARAM_POLICY_MASK 0x0002
524#define IEEE80211_ADDBA_PARAM_TID_MASK 0x003C
525#define IEEE80211_ADDBA_PARAM_BUF_SIZE_MASK 0xFFA0
526#define IEEE80211_DELBA_PARAM_TID_MASK 0xF000
527#define IEEE80211_DELBA_PARAM_INITIATOR_MASK 0x0800
528
529#define SetOrderBit(pbuf) \
530 do { \
531 *(unsigned short *)(pbuf) |= cpu_to_le16(_ORDER_); \
532 } while (0)
533
534#define GetOrderBit(pbuf) (((*(unsigned short *)(pbuf)) & \
535 le16_to_cpu(_ORDER_)) != 0)
536
537
538/**
539 * struct ieee80211_bar - HT Block Ack Request
540 *
541 * This structure refers to "HT BlockAckReq" as
542 * described in 802.11n draft section 7.2.1.7.1
543 */
544struct ieee80211_bar {
545 unsigned short frame_control;
546 unsigned short duration;
547 unsigned char ra[6];
548 unsigned char ta[6];
549 unsigned short control;
550 unsigned short start_seq_num;
551} __packed;
552
553/* 802.11 BAR control masks */
554#define IEEE80211_BAR_CTRL_ACK_POLICY_NORMAL 0x0000
555#define IEEE80211_BAR_CTRL_CBMTID_COMPRESSED_BA 0x0004
556
557
558 /**
559 * struct ieee80211_ht_cap - HT capabilities
560 *
561 * This structure refers to "HT capabilities element" as
562 * described in 802.11n draft section 7.3.2.52
563 */
564
565struct ieee80211_ht_cap {
566 unsigned short cap_info;
567 unsigned char ampdu_params_info;
568 unsigned char supp_mcs_set[16];
569 unsigned short extended_ht_cap_info;
570 unsigned int tx_BF_cap_info;
571 unsigned char antenna_selection_info;
572} __packed;
573
574/**
575 * struct ieee80211_ht_cap - HT additional information
576 *
577 * This structure refers to "HT information element" as
578 * described in 802.11n draft section 7.3.2.53
579 */
580struct ieee80211_ht_addt_info {
581 unsigned char control_chan;
582 unsigned char ht_param;
583 unsigned short operation_mode;
584 unsigned short stbc_param;
585 unsigned char basic_set[16];
586} __packed;
587
588/* 802.11n HT capabilities masks */
589#define IEEE80211_HT_CAP_SUP_WIDTH 0x0002
590#define IEEE80211_HT_CAP_SM_PS 0x000C
591#define IEEE80211_HT_CAP_GRN_FLD 0x0010
592#define IEEE80211_HT_CAP_SGI_20 0x0020
593#define IEEE80211_HT_CAP_SGI_40 0x0040
594#define IEEE80211_HT_CAP_TX_STBC 0x0080
595#define IEEE80211_HT_CAP_DELAY_BA 0x0400
596#define IEEE80211_HT_CAP_MAX_AMSDU 0x0800
597#define IEEE80211_HT_CAP_DSSSCCK40 0x1000
598/* 802.11n HT capability AMPDU settings */
599#define IEEE80211_HT_CAP_AMPDU_FACTOR 0x03
600#define IEEE80211_HT_CAP_AMPDU_DENSITY 0x1C
601/* 802.11n HT capability MSC set */
602#define IEEE80211_SUPP_MCS_SET_UEQM 4
603#define IEEE80211_HT_CAP_MAX_STREAMS 4
604#define IEEE80211_SUPP_MCS_SET_LEN 10
605/* maximum streams the spec allows */
606#define IEEE80211_HT_CAP_MCS_TX_DEFINED 0x01
607#define IEEE80211_HT_CAP_MCS_TX_RX_DIFF 0x02
608#define IEEE80211_HT_CAP_MCS_TX_STREAMS 0x0C
609#define IEEE80211_HT_CAP_MCS_TX_UEQM 0x10
610/* 802.11n HT IE masks */
611#define IEEE80211_HT_IE_CHA_SEC_OFFSET 0x03
612#define IEEE80211_HT_IE_CHA_SEC_NONE 0x00
613#define IEEE80211_HT_IE_CHA_SEC_ABOVE 0x01
614#define IEEE80211_HT_IE_CHA_SEC_BELOW 0x03
615#define IEEE80211_HT_IE_CHA_WIDTH 0x04
616#define IEEE80211_HT_IE_HT_PROTECTION 0x0003
617#define IEEE80211_HT_IE_NON_GF_STA_PRSNT 0x0004
618#define IEEE80211_HT_IE_NON_HT_STA_PRSNT 0x0010
619
620/* block-ack parameters */
621#define IEEE80211_ADDBA_PARAM_POLICY_MASK 0x0002
622#define IEEE80211_ADDBA_PARAM_TID_MASK 0x003C
623#define IEEE80211_ADDBA_PARAM_BUF_SIZE_MASK 0xFFA0
624#define IEEE80211_DELBA_PARAM_TID_MASK 0xF000
625#define IEEE80211_DELBA_PARAM_INITIATOR_MASK 0x0800
626
627/*
628 * A-PMDU buffer sizes
629 * According to IEEE802.11n spec size varies from 8K to 64K (in powers of 2)
630 */
631#define IEEE80211_MIN_AMPDU_BUF 0x8
632#define IEEE80211_MAX_AMPDU_BUF 0x40
633
634
635/* Spatial Multiplexing Power Save Modes */
636#define WLAN_HT_CAP_SM_PS_STATIC 0
637#define WLAN_HT_CAP_SM_PS_DYNAMIC 1
638#define WLAN_HT_CAP_SM_PS_INVALID 2
639#define WLAN_HT_CAP_SM_PS_DISABLED 3
640
641#endif /* _WIFI_H_ */
642