wifi.h 43 KB

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