wifi.h 40 KB

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