wifi.h 17 KB

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