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