ieee80211.h 62 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172
  1. /******************************************************************************
  2. *
  3. * Copyright(c) 2007 - 2017 Realtek Corporation.
  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. *****************************************************************************/
  15. #ifndef __IEEE80211_H
  16. #define __IEEE80211_H
  17. #ifndef CONFIG_RTL8711FW
  18. #if defined PLATFORM_OS_XP
  19. #include <ntstrsafe.h>
  20. #endif
  21. #else
  22. #endif
  23. #define MGMT_QUEUE_NUM 5
  24. #define ETH_ALEN 6
  25. #define ETH_TYPE_LEN 2
  26. #define PAYLOAD_TYPE_LEN 1
  27. #define NET80211_TU_TO_US 1024 /* unit:us */
  28. #define DEFAULT_BCN_INTERVAL 100 /* 100 ms */
  29. #ifdef CONFIG_AP_MODE
  30. #define RTL_IOCTL_HOSTAPD (SIOCIWFIRSTPRIV + 28)
  31. /* RTL871X_IOCTL_HOSTAPD ioctl() cmd: */
  32. enum {
  33. RTL871X_HOSTAPD_FLUSH = 1,
  34. RTL871X_HOSTAPD_ADD_STA = 2,
  35. RTL871X_HOSTAPD_REMOVE_STA = 3,
  36. RTL871X_HOSTAPD_GET_INFO_STA = 4,
  37. /* REMOVED: PRISM2_HOSTAPD_RESET_TXEXC_STA = 5, */
  38. RTL871X_HOSTAPD_GET_WPAIE_STA = 5,
  39. RTL871X_SET_ENCRYPTION = 6,
  40. RTL871X_GET_ENCRYPTION = 7,
  41. RTL871X_HOSTAPD_SET_FLAGS_STA = 8,
  42. RTL871X_HOSTAPD_GET_RID = 9,
  43. RTL871X_HOSTAPD_SET_RID = 10,
  44. RTL871X_HOSTAPD_SET_ASSOC_AP_ADDR = 11,
  45. RTL871X_HOSTAPD_SET_GENERIC_ELEMENT = 12,
  46. RTL871X_HOSTAPD_MLME = 13,
  47. RTL871X_HOSTAPD_SCAN_REQ = 14,
  48. RTL871X_HOSTAPD_STA_CLEAR_STATS = 15,
  49. RTL871X_HOSTAPD_SET_BEACON = 16,
  50. RTL871X_HOSTAPD_SET_WPS_BEACON = 17,
  51. RTL871X_HOSTAPD_SET_WPS_PROBE_RESP = 18,
  52. RTL871X_HOSTAPD_SET_WPS_ASSOC_RESP = 19,
  53. RTL871X_HOSTAPD_SET_HIDDEN_SSID = 20,
  54. RTL871X_HOSTAPD_SET_MACADDR_ACL = 21,
  55. RTL871X_HOSTAPD_ACL_ADD_STA = 22,
  56. RTL871X_HOSTAPD_ACL_REMOVE_STA = 23,
  57. };
  58. /* STA flags */
  59. #define WLAN_STA_AUTH BIT(0)
  60. #define WLAN_STA_ASSOC BIT(1)
  61. #define WLAN_STA_PS BIT(2)
  62. #define WLAN_STA_TIM BIT(3)
  63. #define WLAN_STA_PERM BIT(4)
  64. #define WLAN_STA_AUTHORIZED BIT(5)
  65. #define WLAN_STA_PENDING_POLL BIT(6) /* pending activity poll not ACKed */
  66. #define WLAN_STA_SHORT_PREAMBLE BIT(7)
  67. #define WLAN_STA_PREAUTH BIT(8)
  68. #define WLAN_STA_WME BIT(9)
  69. #define WLAN_STA_MFP BIT(10)
  70. #define WLAN_STA_HT BIT(11)
  71. #define WLAN_STA_WPS BIT(12)
  72. #define WLAN_STA_MAYBE_WPS BIT(13)
  73. #define WLAN_STA_VHT BIT(14)
  74. #define WLAN_STA_NONERP BIT(31)
  75. #endif
  76. #define IEEE_CMD_SET_WPA_PARAM 1
  77. #define IEEE_CMD_SET_WPA_IE 2
  78. #define IEEE_CMD_SET_ENCRYPTION 3
  79. #define IEEE_CMD_MLME 4
  80. #define IEEE_PARAM_WPA_ENABLED 1
  81. #define IEEE_PARAM_TKIP_COUNTERMEASURES 2
  82. #define IEEE_PARAM_DROP_UNENCRYPTED 3
  83. #define IEEE_PARAM_PRIVACY_INVOKED 4
  84. #define IEEE_PARAM_AUTH_ALGS 5
  85. #define IEEE_PARAM_IEEE_802_1X 6
  86. #define IEEE_PARAM_WPAX_SELECT 7
  87. #define AUTH_ALG_OPEN_SYSTEM 0x1
  88. #define AUTH_ALG_SHARED_KEY 0x2
  89. #define AUTH_ALG_LEAP 0x00000004
  90. #define IEEE_MLME_STA_DEAUTH 1
  91. #define IEEE_MLME_STA_DISASSOC 2
  92. #define IEEE_CRYPT_ERR_UNKNOWN_ALG 2
  93. #define IEEE_CRYPT_ERR_UNKNOWN_ADDR 3
  94. #define IEEE_CRYPT_ERR_CRYPT_INIT_FAILED 4
  95. #define IEEE_CRYPT_ERR_KEY_SET_FAILED 5
  96. #define IEEE_CRYPT_ERR_TX_KEY_SET_FAILED 6
  97. #define IEEE_CRYPT_ERR_CARD_CONF_FAILED 7
  98. #define IEEE_CRYPT_ALG_NAME_LEN 16
  99. #define WPA_CIPHER_NONE BIT(0)
  100. #define WPA_CIPHER_WEP40 BIT(1)
  101. #define WPA_CIPHER_WEP104 BIT(2)
  102. #define WPA_CIPHER_TKIP BIT(3)
  103. #define WPA_CIPHER_CCMP BIT(4)
  104. #define WPA_SELECTOR_LEN 4
  105. extern u8 RTW_WPA_OUI_TYPE[] ;
  106. extern u16 RTW_WPA_VERSION ;
  107. extern u8 WPA_AUTH_KEY_MGMT_NONE[];
  108. extern u8 WPA_AUTH_KEY_MGMT_UNSPEC_802_1X[];
  109. extern u8 WPA_AUTH_KEY_MGMT_PSK_OVER_802_1X[];
  110. extern u8 WPA_CIPHER_SUITE_NONE[];
  111. extern u8 WPA_CIPHER_SUITE_WEP40[];
  112. extern u8 WPA_CIPHER_SUITE_TKIP[];
  113. extern u8 WPA_CIPHER_SUITE_WRAP[];
  114. extern u8 WPA_CIPHER_SUITE_CCMP[];
  115. extern u8 WPA_CIPHER_SUITE_WEP104[];
  116. #define RSN_HEADER_LEN 4
  117. #define RSN_SELECTOR_LEN 4
  118. extern u16 RSN_VERSION_BSD;
  119. extern u8 RSN_AUTH_KEY_MGMT_UNSPEC_802_1X[];
  120. extern u8 RSN_AUTH_KEY_MGMT_PSK_OVER_802_1X[];
  121. extern u8 RSN_CIPHER_SUITE_NONE[];
  122. extern u8 RSN_CIPHER_SUITE_WEP40[];
  123. extern u8 RSN_CIPHER_SUITE_TKIP[];
  124. extern u8 RSN_CIPHER_SUITE_WRAP[];
  125. extern u8 RSN_CIPHER_SUITE_CCMP[];
  126. extern u8 RSN_CIPHER_SUITE_WEP104[];
  127. /* IEEE 802.11i */
  128. #define PMKID_LEN 16
  129. #define PMK_LEN 32
  130. #define PMK_LEN_SUITE_B_192 48
  131. #define PMK_LEN_MAX 48
  132. #define WPA_REPLAY_COUNTER_LEN 8
  133. #define WPA_NONCE_LEN 32
  134. #define WPA_KEY_RSC_LEN 8
  135. #define WPA_GMK_LEN 32
  136. #define WPA_GTK_MAX_LEN 32
  137. /* IEEE 802.11, 8.5.2 EAPOL-Key frames */
  138. #define WPA_KEY_INFO_TYPE_MASK ((u16) (BIT(0) | BIT(1) | BIT(2)))
  139. #define WPA_KEY_INFO_TYPE_AKM_DEFINED 0
  140. #define WPA_KEY_INFO_TYPE_HMAC_MD5_RC4 BIT(0)
  141. #define WPA_KEY_INFO_TYPE_HMAC_SHA1_AES BIT(1)
  142. #define WPA_KEY_INFO_TYPE_AES_128_CMAC 3
  143. #define WPA_KEY_INFO_KEY_TYPE BIT(3) /* 1 = Pairwise, 0 = Group key */
  144. /* bit4..5 is used in WPA, but is reserved in IEEE 802.11i/RSN */
  145. #define WPA_KEY_INFO_KEY_INDEX_MASK (BIT(4) | BIT(5))
  146. #define WPA_KEY_INFO_KEY_INDEX_SHIFT 4
  147. #define WPA_KEY_INFO_INSTALL BIT(6) /* pairwise */
  148. #define WPA_KEY_INFO_TXRX BIT(6) /* group */
  149. #define WPA_KEY_INFO_ACK BIT(7)
  150. #define WPA_KEY_INFO_MIC BIT(8)
  151. #define WPA_KEY_INFO_SECURE BIT(9)
  152. #define WPA_KEY_INFO_ERROR BIT(10)
  153. #define WPA_KEY_INFO_REQUEST BIT(11)
  154. #define WPA_KEY_INFO_ENCR_KEY_DATA BIT(12) /* IEEE 802.11i/RSN only */
  155. #define WPA_KEY_INFO_SMK_MESSAGE BIT(13)
  156. struct ieee802_1x_hdr {
  157. u8 version;
  158. u8 type;
  159. u16 length;
  160. /* followed by length octets of data */
  161. };
  162. struct wpa_eapol_key {
  163. u8 type;
  164. /* Note: key_info, key_length, and key_data_length are unaligned */
  165. u8 key_info[2]; /* big endian */
  166. u8 key_length[2]; /* big endian */
  167. u8 replay_counter[WPA_REPLAY_COUNTER_LEN];
  168. u8 key_nonce[WPA_NONCE_LEN];
  169. u8 key_iv[16];
  170. u8 key_rsc[WPA_KEY_RSC_LEN];
  171. u8 key_id[8]; /* Reserved in IEEE 802.11i/RSN */
  172. u8 key_mic[16];
  173. u8 key_data_length[2]; /* big endian */
  174. /* followed by key_data_length bytes of key_data */
  175. };
  176. typedef enum _RATEID_IDX_ {
  177. RATEID_IDX_BGN_40M_2SS = 0,
  178. RATEID_IDX_BGN_40M_1SS = 1,
  179. RATEID_IDX_BGN_20M_2SS_BN = 2,
  180. RATEID_IDX_BGN_20M_1SS_BN = 3,
  181. RATEID_IDX_GN_N2SS = 4,
  182. RATEID_IDX_GN_N1SS = 5,
  183. RATEID_IDX_BG = 6,
  184. RATEID_IDX_G = 7,
  185. RATEID_IDX_B = 8,
  186. RATEID_IDX_VHT_2SS = 9,
  187. RATEID_IDX_VHT_1SS = 10,
  188. RATEID_IDX_MIX1 = 11,
  189. RATEID_IDX_MIX2 = 12,
  190. RATEID_IDX_VHT_3SS = 13,
  191. RATEID_IDX_BGN_3SS = 14,
  192. } RATEID_IDX, *PRATEID_IDX;
  193. typedef enum _RATR_TABLE_MODE {
  194. RATR_INX_WIRELESS_NGB = 0, /* BGN 40 Mhz 2SS 1SS */
  195. RATR_INX_WIRELESS_NG = 1, /* GN or N */
  196. RATR_INX_WIRELESS_NB = 2, /* BGN 20 Mhz 2SS 1SS or BN */
  197. RATR_INX_WIRELESS_N = 3,
  198. RATR_INX_WIRELESS_GB = 4,
  199. RATR_INX_WIRELESS_G = 5,
  200. RATR_INX_WIRELESS_B = 6,
  201. RATR_INX_WIRELESS_MC = 7,
  202. RATR_INX_WIRELESS_AC_N = 8,
  203. } RATR_TABLE_MODE, *PRATR_TABLE_MODE;
  204. enum NETWORK_TYPE {
  205. WIRELESS_INVALID = 0,
  206. /* Sub-Element */
  207. WIRELESS_11B = BIT(0), /* tx: cck only , rx: cck only, hw: cck */
  208. WIRELESS_11G = BIT(1), /* tx: ofdm only, rx: ofdm & cck, hw: cck & ofdm */
  209. WIRELESS_11A = BIT(2), /* tx: ofdm only, rx: ofdm only, hw: ofdm only */
  210. WIRELESS_11_24N = BIT(3), /* tx: MCS only, rx: MCS & cck, hw: MCS & cck */
  211. WIRELESS_11_5N = BIT(4), /* tx: MCS only, rx: MCS & ofdm, hw: ofdm only */
  212. WIRELESS_AUTO = BIT(5),
  213. WIRELESS_11AC = BIT(6),
  214. /* Combination */
  215. /* Type for current wireless mode */
  216. WIRELESS_11BG = (WIRELESS_11B | WIRELESS_11G), /* tx: cck & ofdm, rx: cck & ofdm & MCS, hw: cck & ofdm */
  217. WIRELESS_11G_24N = (WIRELESS_11G | WIRELESS_11_24N), /* tx: ofdm & MCS, rx: ofdm & cck & MCS, hw: cck & ofdm */
  218. WIRELESS_11A_5N = (WIRELESS_11A | WIRELESS_11_5N), /* tx: ofdm & MCS, rx: ofdm & MCS, hw: ofdm only */
  219. WIRELESS_11B_24N = (WIRELESS_11B | WIRELESS_11_24N), /* tx: ofdm & cck & MCS, rx: ofdm & cck & MCS, hw: ofdm & cck */
  220. WIRELESS_11BG_24N = (WIRELESS_11B | WIRELESS_11G | WIRELESS_11_24N), /* tx: ofdm & cck & MCS, rx: ofdm & cck & MCS, hw: ofdm & cck */
  221. WIRELESS_11_24AC = (WIRELESS_11B | WIRELESS_11G | WIRELESS_11AC),
  222. WIRELESS_11_5AC = (WIRELESS_11A | WIRELESS_11AC),
  223. /* Type for registry default wireless mode */
  224. WIRELESS_11AGN = (WIRELESS_11A | WIRELESS_11G | WIRELESS_11_24N | WIRELESS_11_5N), /* tx: ofdm & MCS, rx: ofdm & MCS, hw: ofdm only */
  225. WIRELESS_11ABGN = (WIRELESS_11A | WIRELESS_11B | WIRELESS_11G | WIRELESS_11_24N | WIRELESS_11_5N),
  226. WIRELESS_MODE_24G = (WIRELESS_11B | WIRELESS_11G | WIRELESS_11_24N),
  227. WIRELESS_MODE_5G = (WIRELESS_11A | WIRELESS_11_5N | WIRELESS_11AC),
  228. WIRELESS_MODE_MAX = (WIRELESS_11A | WIRELESS_11B | WIRELESS_11G | WIRELESS_11_24N | WIRELESS_11_5N | WIRELESS_11AC),
  229. };
  230. #define SUPPORTED_24G_NETTYPE_MSK WIRELESS_MODE_24G
  231. #define SUPPORTED_5G_NETTYPE_MSK WIRELESS_MODE_5G
  232. #define IsLegacyOnly(NetType) ((NetType) == ((NetType) & (WIRELESS_11BG | WIRELESS_11A)))
  233. #define IsSupported24G(NetType) ((NetType) & SUPPORTED_24G_NETTYPE_MSK ? _TRUE : _FALSE)
  234. #define is_supported_5g(NetType) ((NetType) & SUPPORTED_5G_NETTYPE_MSK ? _TRUE : _FALSE)
  235. #define IsEnableHWCCK(NetType) IsSupported24G(NetType)
  236. #define IsEnableHWOFDM(NetType) ((NetType) & (WIRELESS_11G | WIRELESS_11_24N | SUPPORTED_5G_NETTYPE_MSK) ? _TRUE : _FALSE)
  237. #define IsSupportedRxCCK(NetType) IsEnableHWCCK(NetType)
  238. #define IsSupportedRxOFDM(NetType) IsEnableHWOFDM(NetType)
  239. #define IsSupportedRxHT(NetType) IsEnableHWOFDM(NetType)
  240. #define IsSupportedTxCCK(NetType) ((NetType) & (WIRELESS_11B) ? _TRUE : _FALSE)
  241. #define IsSupportedTxOFDM(NetType) ((NetType) & (WIRELESS_11G | WIRELESS_11A) ? _TRUE : _FALSE)
  242. #define is_supported_ht(NetType) ((NetType) & (WIRELESS_11_24N | WIRELESS_11_5N) ? _TRUE : _FALSE)
  243. #define is_supported_vht(NetType) ((NetType) & (WIRELESS_11AC) ? _TRUE : _FALSE)
  244. typedef struct ieee_param {
  245. u32 cmd;
  246. u8 sta_addr[ETH_ALEN];
  247. union {
  248. struct {
  249. u8 name;
  250. u32 value;
  251. } wpa_param;
  252. struct {
  253. u32 len;
  254. u8 reserved[32];
  255. u8 data[0];
  256. } wpa_ie;
  257. struct {
  258. int command;
  259. int reason_code;
  260. } mlme;
  261. struct {
  262. u8 alg[IEEE_CRYPT_ALG_NAME_LEN];
  263. u8 set_tx;
  264. u32 err;
  265. u8 idx;
  266. u8 seq[8]; /* sequence counter (set: RX, get: TX) */
  267. u16 key_len;
  268. u8 key[0];
  269. } crypt;
  270. #ifdef CONFIG_AP_MODE
  271. struct {
  272. u16 aid;
  273. u16 capability;
  274. int flags;
  275. u8 tx_supp_rates[16];
  276. struct rtw_ieee80211_ht_cap ht_cap;
  277. } add_sta;
  278. struct {
  279. u8 reserved[2];/* for set max_num_sta */
  280. u8 buf[0];
  281. } bcn_ie;
  282. #endif
  283. } u;
  284. } ieee_param;
  285. #ifdef CONFIG_AP_MODE
  286. typedef struct ieee_param_ex {
  287. u32 cmd;
  288. u8 sta_addr[ETH_ALEN];
  289. u8 data[0];
  290. } ieee_param_ex;
  291. struct sta_data {
  292. u16 aid;
  293. u16 capability;
  294. int flags;
  295. u32 sta_set;
  296. u8 tx_supp_rates[16];
  297. u32 tx_supp_rates_len;
  298. struct rtw_ieee80211_ht_cap ht_cap;
  299. u64 rx_pkts;
  300. u64 rx_bytes;
  301. u64 rx_drops;
  302. u64 tx_pkts;
  303. u64 tx_bytes;
  304. u64 tx_drops;
  305. };
  306. #endif
  307. #if WIRELESS_EXT < 17
  308. #define IW_QUAL_QUAL_INVALID 0x10
  309. #define IW_QUAL_LEVEL_INVALID 0x20
  310. #define IW_QUAL_NOISE_INVALID 0x40
  311. #define IW_QUAL_QUAL_UPDATED 0x1
  312. #define IW_QUAL_LEVEL_UPDATED 0x2
  313. #define IW_QUAL_NOISE_UPDATED 0x4
  314. #endif
  315. #define IEEE80211_DATA_LEN 2304
  316. /* Maximum size for the MA-UNITDATA primitive, 802.11 standard section
  317. 6.2.1.1.2.
  318. The figure in section 7.1.2 suggests a body size of up to 2312
  319. bytes is allowed, which is a bit confusing, I suspect this
  320. represents the 2304 bytes of real data, plus a possible 8 bytes of
  321. WEP IV and ICV. (this interpretation suggested by Ramiro Barreiro) */
  322. #define IEEE80211_HLEN 30
  323. #define IEEE80211_FRAME_LEN (IEEE80211_DATA_LEN + IEEE80211_HLEN)
  324. /* this is stolen from ipw2200 driver */
  325. #define IEEE_IBSS_MAC_HASH_SIZE 31
  326. struct ieee_ibss_seq {
  327. u8 mac[ETH_ALEN];
  328. u16 seq_num;
  329. u16 frag_num;
  330. unsigned long packet_time;
  331. _list list;
  332. };
  333. #if defined(PLATFORM_LINUX) || defined(CONFIG_RTL8711FW) || defined(PLATFORM_FREEBSD)
  334. struct rtw_ieee80211_hdr {
  335. u16 frame_ctl;
  336. u16 duration_id;
  337. u8 addr1[ETH_ALEN];
  338. u8 addr2[ETH_ALEN];
  339. u8 addr3[ETH_ALEN];
  340. u16 seq_ctl;
  341. u8 addr4[ETH_ALEN];
  342. } __attribute__((packed));
  343. struct rtw_ieee80211_hdr_3addr {
  344. u16 frame_ctl;
  345. u16 duration_id;
  346. u8 addr1[ETH_ALEN];
  347. u8 addr2[ETH_ALEN];
  348. u8 addr3[ETH_ALEN];
  349. u16 seq_ctl;
  350. } __attribute__((packed));
  351. struct rtw_ieee80211_hdr_qos {
  352. u16 frame_ctl;
  353. u16 duration_id;
  354. u8 addr1[ETH_ALEN];
  355. u8 addr2[ETH_ALEN];
  356. u8 addr3[ETH_ALEN];
  357. u16 seq_ctl;
  358. u8 addr4[ETH_ALEN];
  359. u16 qc;
  360. } __attribute__((packed));
  361. struct rtw_ieee80211_hdr_3addr_qos {
  362. u16 frame_ctl;
  363. u16 duration_id;
  364. u8 addr1[ETH_ALEN];
  365. u8 addr2[ETH_ALEN];
  366. u8 addr3[ETH_ALEN];
  367. u16 seq_ctl;
  368. u16 qc;
  369. } __attribute__((packed));
  370. struct eapol {
  371. u8 snap[6];
  372. u16 ethertype;
  373. u8 version;
  374. u8 type;
  375. u16 length;
  376. } __attribute__((packed));
  377. struct rtw_ieee80211s_hdr {
  378. u8 flags;
  379. u8 ttl;
  380. u32 seqnum;
  381. u8 eaddr1[ETH_ALEN];
  382. u8 eaddr2[ETH_ALEN];
  383. } __attribute__((packed));
  384. /**
  385. * struct rtw_ieee80211_rann_ie
  386. *
  387. * This structure refers to "Root Announcement information element"
  388. */
  389. struct rtw_ieee80211_rann_ie {
  390. u8 rann_flags;
  391. u8 rann_hopcount;
  392. u8 rann_ttl;
  393. u8 rann_addr[ETH_ALEN];
  394. u32 rann_seq;
  395. u32 rann_interval;
  396. u32 rann_metric;
  397. } __attribute__((packed));
  398. #endif
  399. #ifdef PLATFORM_WINDOWS
  400. #pragma pack(1)
  401. struct rtw_ieee80211_hdr {
  402. u16 frame_ctl;
  403. u16 duration_id;
  404. u8 addr1[ETH_ALEN];
  405. u8 addr2[ETH_ALEN];
  406. u8 addr3[ETH_ALEN];
  407. u16 seq_ctl;
  408. u8 addr4[ETH_ALEN];
  409. };
  410. struct rtw_ieee80211_hdr_3addr {
  411. u16 frame_ctl;
  412. u16 duration_id;
  413. u8 addr1[ETH_ALEN];
  414. u8 addr2[ETH_ALEN];
  415. u8 addr3[ETH_ALEN];
  416. u16 seq_ctl;
  417. };
  418. struct rtw_ieee80211_hdr_qos {
  419. struct rtw_ieee80211_hdr wlan_hdr;
  420. u16 qc;
  421. };
  422. struct rtw_ieee80211_hdr_3addr_qos {
  423. struct rtw_ieee80211_hdr_3addr wlan_hdr;
  424. u16 qc;
  425. };
  426. struct eapol {
  427. u8 snap[6];
  428. u16 ethertype;
  429. u8 version;
  430. u8 type;
  431. u16 length;
  432. };
  433. #pragma pack()
  434. #endif
  435. enum eap_type {
  436. EAP_PACKET = 0,
  437. EAPOL_START,
  438. EAPOL_LOGOFF,
  439. EAPOL_KEY,
  440. EAPOL_ENCAP_ASF_ALERT
  441. };
  442. #define IEEE80211_3ADDR_LEN 24
  443. #define IEEE80211_4ADDR_LEN 30
  444. #define IEEE80211_FCS_LEN 4
  445. #define MIN_FRAG_THRESHOLD 256U
  446. #define MAX_FRAG_THRESHOLD 2346U
  447. /* Frame control field constants */
  448. #define RTW_IEEE80211_FCTL_VERS 0x0003
  449. #define RTW_IEEE80211_FCTL_FTYPE 0x000c
  450. #define RTW_IEEE80211_FCTL_STYPE 0x00f0
  451. #define RTW_IEEE80211_FCTL_TODS 0x0100
  452. #define RTW_IEEE80211_FCTL_FROMDS 0x0200
  453. #define RTW_IEEE80211_FCTL_MOREFRAGS 0x0400
  454. #define RTW_IEEE80211_FCTL_RETRY 0x0800
  455. #define RTW_IEEE80211_FCTL_PM 0x1000
  456. #define RTW_IEEE80211_FCTL_MOREDATA 0x2000
  457. #define RTW_IEEE80211_FCTL_PROTECTED 0x4000
  458. #define RTW_IEEE80211_FCTL_ORDER 0x8000
  459. #define RTW_IEEE80211_FCTL_CTL_EXT 0x0f00
  460. #define RTW_IEEE80211_FTYPE_MGMT 0x0000
  461. #define RTW_IEEE80211_FTYPE_CTL 0x0004
  462. #define RTW_IEEE80211_FTYPE_DATA 0x0008
  463. #define RTW_IEEE80211_FTYPE_EXT 0x000c
  464. /* management */
  465. #define RTW_IEEE80211_STYPE_ASSOC_REQ 0x0000
  466. #define RTW_IEEE80211_STYPE_ASSOC_RESP 0x0010
  467. #define RTW_IEEE80211_STYPE_REASSOC_REQ 0x0020
  468. #define RTW_IEEE80211_STYPE_REASSOC_RESP 0x0030
  469. #define RTW_IEEE80211_STYPE_PROBE_REQ 0x0040
  470. #define RTW_IEEE80211_STYPE_PROBE_RESP 0x0050
  471. #define RTW_IEEE80211_STYPE_BEACON 0x0080
  472. #define RTW_IEEE80211_STYPE_ATIM 0x0090
  473. #define RTW_IEEE80211_STYPE_DISASSOC 0x00A0
  474. #define RTW_IEEE80211_STYPE_AUTH 0x00B0
  475. #define RTW_IEEE80211_STYPE_DEAUTH 0x00C0
  476. #define RTW_IEEE80211_STYPE_ACTION 0x00D0
  477. /* control */
  478. #define RTW_IEEE80211_STYPE_CTL_EXT 0x0060
  479. #define RTW_IEEE80211_STYPE_BACK_REQ 0x0080
  480. #define RTW_IEEE80211_STYPE_BACK 0x0090
  481. #define RTW_IEEE80211_STYPE_PSPOLL 0x00A0
  482. #define RTW_IEEE80211_STYPE_RTS 0x00B0
  483. #define RTW_IEEE80211_STYPE_CTS 0x00C0
  484. #define RTW_IEEE80211_STYPE_ACK 0x00D0
  485. #define RTW_IEEE80211_STYPE_CFEND 0x00E0
  486. #define RTW_IEEE80211_STYPE_CFENDACK 0x00F0
  487. /* data */
  488. #define RTW_IEEE80211_STYPE_DATA 0x0000
  489. #define RTW_IEEE80211_STYPE_DATA_CFACK 0x0010
  490. #define RTW_IEEE80211_STYPE_DATA_CFPOLL 0x0020
  491. #define RTW_IEEE80211_STYPE_DATA_CFACKPOLL 0x0030
  492. #define RTW_IEEE80211_STYPE_NULLFUNC 0x0040
  493. #define RTW_IEEE80211_STYPE_CFACK 0x0050
  494. #define RTW_IEEE80211_STYPE_CFPOLL 0x0060
  495. #define RTW_IEEE80211_STYPE_CFACKPOLL 0x0070
  496. #define RTW_IEEE80211_STYPE_QOS_DATA 0x0080
  497. #define RTW_IEEE80211_STYPE_QOS_DATA_CFACK 0x0090
  498. #define RTW_IEEE80211_STYPE_QOS_DATA_CFPOLL 0x00A0
  499. #define RTW_IEEE80211_STYPE_QOS_DATA_CFACKPOLL 0x00B0
  500. #define RTW_IEEE80211_STYPE_QOS_NULLFUNC 0x00C0
  501. #define RTW_IEEE80211_STYPE_QOS_CFACK 0x00D0
  502. #define RTW_IEEE80211_STYPE_QOS_CFPOLL 0x00E0
  503. #define RTW_IEEE80211_STYPE_QOS_CFACKPOLL 0x00F0
  504. /* sequence control field */
  505. #define RTW_IEEE80211_SCTL_FRAG 0x000F
  506. #define RTW_IEEE80211_SCTL_SEQ 0xFFF0
  507. #define RTW_ERP_INFO_NON_ERP_PRESENT BIT(0)
  508. #define RTW_ERP_INFO_USE_PROTECTION BIT(1)
  509. #define RTW_ERP_INFO_BARKER_PREAMBLE_MODE BIT(2)
  510. /* QoS,QOS */
  511. #define NORMAL_ACK 0
  512. #define NO_ACK 1
  513. #define NON_EXPLICIT_ACK 2
  514. #define BLOCK_ACK 3
  515. #ifndef ETH_P_PAE
  516. #define ETH_P_PAE 0x888E /* Port Access Entity (IEEE 802.1X) */
  517. #endif /* ETH_P_PAE */
  518. #define ETH_P_PREAUTH 0x88C7 /* IEEE 802.11i pre-authentication */
  519. #define ETH_P_ECONET 0x0018
  520. #ifndef ETH_P_80211_RAW
  521. #define ETH_P_80211_RAW (ETH_P_ECONET + 1)
  522. #endif
  523. /* IEEE 802.11 defines */
  524. #define P80211_OUI_LEN 3
  525. #if defined(PLATFORM_LINUX) || defined(CONFIG_RTL8711FW) || defined(PLATFORM_FREEBSD)
  526. struct ieee80211_snap_hdr {
  527. u8 dsap; /* always 0xAA */
  528. u8 ssap; /* always 0xAA */
  529. u8 ctrl; /* always 0x03 */
  530. u8 oui[P80211_OUI_LEN]; /* organizational universal id */
  531. } __attribute__((packed));
  532. #endif
  533. #ifdef PLATFORM_WINDOWS
  534. #pragma pack(1)
  535. struct ieee80211_snap_hdr {
  536. u8 dsap; /* always 0xAA */
  537. u8 ssap; /* always 0xAA */
  538. u8 ctrl; /* always 0x03 */
  539. u8 oui[P80211_OUI_LEN]; /* organizational universal id */
  540. };
  541. #pragma pack()
  542. #endif
  543. #define SNAP_SIZE sizeof(struct ieee80211_snap_hdr)
  544. #define WLAN_FC_GET_TYPE(fc) ((fc) & RTW_IEEE80211_FCTL_FTYPE)
  545. #define WLAN_FC_GET_STYPE(fc) ((fc) & RTW_IEEE80211_FCTL_STYPE)
  546. #define WLAN_QC_GET_TID(qc) ((qc) & 0x0f)
  547. #define WLAN_GET_SEQ_FRAG(seq) ((seq) & RTW_IEEE80211_SCTL_FRAG)
  548. #define WLAN_GET_SEQ_SEQ(seq) ((seq) & RTW_IEEE80211_SCTL_SEQ)
  549. /* Authentication algorithms */
  550. #define WLAN_AUTH_OPEN 0
  551. #define WLAN_AUTH_SHARED_KEY 1
  552. #define WLAN_AUTH_CHALLENGE_LEN 128
  553. #define WLAN_CAPABILITY_BSS (1<<0)
  554. #define WLAN_CAPABILITY_IBSS (1<<1)
  555. #define WLAN_CAPABILITY_CF_POLLABLE (1<<2)
  556. #define WLAN_CAPABILITY_CF_POLL_REQUEST (1<<3)
  557. #define WLAN_CAPABILITY_PRIVACY (1<<4)
  558. #define WLAN_CAPABILITY_SHORT_PREAMBLE (1<<5)
  559. #define WLAN_CAPABILITY_PBCC (1<<6)
  560. #define WLAN_CAPABILITY_CHANNEL_AGILITY (1<<7)
  561. #define WLAN_CAPABILITY_SHORT_SLOT (1<<10)
  562. /* Status codes */
  563. #define WLAN_STATUS_SUCCESS 0
  564. #define WLAN_STATUS_UNSPECIFIED_FAILURE 1
  565. #define WLAN_STATUS_CAPS_UNSUPPORTED 10
  566. #define WLAN_STATUS_REASSOC_NO_ASSOC 11
  567. #define WLAN_STATUS_ASSOC_DENIED_UNSPEC 12
  568. #define WLAN_STATUS_NOT_SUPPORTED_AUTH_ALG 13
  569. #define WLAN_STATUS_UNKNOWN_AUTH_TRANSACTION 14
  570. #define WLAN_STATUS_CHALLENGE_FAIL 15
  571. #define WLAN_STATUS_AUTH_TIMEOUT 16
  572. #define WLAN_STATUS_AP_UNABLE_TO_HANDLE_NEW_STA 17
  573. #define WLAN_STATUS_ASSOC_DENIED_RATES 18
  574. /* 802.11b */
  575. #define WLAN_STATUS_ASSOC_DENIED_NOSHORT 19
  576. #define WLAN_STATUS_ASSOC_DENIED_NOPBCC 20
  577. #define WLAN_STATUS_ASSOC_DENIED_NOAGILITY 21
  578. /* Reason codes */
  579. #define WLAN_REASON_UNSPECIFIED 1
  580. #define WLAN_REASON_PREV_AUTH_NOT_VALID 2
  581. #define WLAN_REASON_DEAUTH_LEAVING 3
  582. #define WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY 4
  583. #define WLAN_REASON_DISASSOC_AP_BUSY 5
  584. #define WLAN_REASON_CLASS2_FRAME_FROM_NONAUTH_STA 6
  585. #define WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA 7
  586. #define WLAN_REASON_DISASSOC_STA_HAS_LEFT 8
  587. #define WLAN_REASON_STA_REQ_ASSOC_WITHOUT_AUTH 9
  588. #define WLAN_REASON_MESH_PEER_CANCELED 52
  589. #define WLAN_REASON_MESH_MAX_PEERS 53
  590. #define WLAN_REASON_MESH_CONFIG 54
  591. #define WLAN_REASON_MESH_CLOSE 55
  592. #define WLAN_REASON_MESH_MAX_RETRIES 56
  593. #define WLAN_REASON_MESH_CONFIRM_TIMEOUT 57
  594. #define WLAN_REASON_MESH_INVALID_GTK 58
  595. #define WLAN_REASON_MESH_INCONSISTENT_PARAM 59
  596. #define WLAN_REASON_MESH_INVALID_SECURITY 60
  597. #define WLAN_REASON_MESH_PATH_NOPROXY 61
  598. #define WLAN_REASON_MESH_PATH_NOFORWARD 62
  599. #define WLAN_REASON_MESH_PATH_DEST_UNREACHABLE 63
  600. #define WLAN_REASON_MAC_EXISTS_IN_MBSS 64
  601. #define WLAN_REASON_MESH_CHAN_REGULATORY 65
  602. #define WLAN_REASON_MESH_CHAN 66
  603. #define WLAN_REASON_SA_QUERY_TIMEOUT 65532
  604. #define WLAN_REASON_ACTIVE_ROAM 65533
  605. #define WLAN_REASON_JOIN_WRONG_CHANNEL 65534
  606. #define WLAN_REASON_EXPIRATION_CHK 65535
  607. #define WLAN_REASON_IS_PRIVATE(reason) ( \
  608. reason == WLAN_REASON_EXPIRATION_CHK \
  609. || reason == WLAN_REASON_JOIN_WRONG_CHANNEL \
  610. || reason == WLAN_REASON_ACTIVE_ROAM \
  611. || reason == WLAN_REASON_SA_QUERY_TIMEOUT \
  612. )
  613. /* Information Element IDs */
  614. #define WLAN_EID_SSID 0
  615. #define WLAN_EID_SUPP_RATES 1
  616. #define WLAN_EID_FH_PARAMS 2
  617. #define WLAN_EID_DS_PARAMS 3
  618. #define WLAN_EID_CF_PARAMS 4
  619. #define WLAN_EID_TIM 5
  620. #define WLAN_EID_IBSS_PARAMS 6
  621. #define WLAN_EID_CHALLENGE 16
  622. /* EIDs defined by IEEE 802.11h - START */
  623. #define WLAN_EID_PWR_CONSTRAINT 32
  624. #define WLAN_EID_PWR_CAPABILITY 33
  625. #define WLAN_EID_TPC_REQUEST 34
  626. #define WLAN_EID_TPC_REPORT 35
  627. #define WLAN_EID_SUPPORTED_CHANNELS 36
  628. #define WLAN_EID_CHANNEL_SWITCH 37
  629. #define WLAN_EID_MEASURE_REQUEST 38
  630. #define WLAN_EID_MEASURE_REPORT 39
  631. #define WLAN_EID_QUITE 40
  632. #define WLAN_EID_IBSS_DFS 41
  633. /* EIDs defined by IEEE 802.11h - END */
  634. #define WLAN_EID_ERP_INFO 42
  635. #define WLAN_EID_HT_CAP 45
  636. #define WLAN_EID_RSN 48
  637. #define WLAN_EID_EXT_SUPP_RATES 50
  638. #define WLAN_EID_MOBILITY_DOMAIN 54
  639. #define WLAN_EID_FAST_BSS_TRANSITION 55
  640. #define WLAN_EID_TIMEOUT_INTERVAL 56
  641. #define WLAN_EID_RIC_DATA 57
  642. #define WLAN_EID_HT_OPERATION 61
  643. #define WLAN_EID_SECONDARY_CHANNEL_OFFSET 62
  644. #define WLAN_EID_20_40_BSS_COEXISTENCE 72
  645. #define WLAN_EID_20_40_BSS_INTOLERANT 73
  646. #define WLAN_EID_OVERLAPPING_BSS_SCAN_PARAMS 74
  647. #define WLAN_EID_MMIE 76
  648. #define WLAN_EID_MESH_CONFIG 113
  649. #define WLAN_EID_MESH_ID 114
  650. #define WLAN_EID_MPM 117
  651. #define WLAN_EID_RANN 126
  652. #define WLAN_EID_PREQ 130
  653. #define WLAN_EID_PREP 131
  654. #define WLAN_EID_PERR 132
  655. #define WLAN_EID_AMPE 139
  656. #define WLAN_EID_MIC 140
  657. #define WLAN_EID_VENDOR_SPECIFIC 221
  658. #define WLAN_EID_GENERIC (WLAN_EID_VENDOR_SPECIFIC)
  659. #define WLAN_EID_VHT_CAPABILITY 191
  660. #define WLAN_EID_VHT_OPERATION 192
  661. #define WLAN_EID_VHT_OP_MODE_NOTIFY 199
  662. #define IEEE80211_MGMT_HDR_LEN 24
  663. #define IEEE80211_DATA_HDR3_LEN 24
  664. #define IEEE80211_DATA_HDR4_LEN 30
  665. #define IEEE80211_STATMASK_SIGNAL (1<<0)
  666. #define IEEE80211_STATMASK_RSSI (1<<1)
  667. #define IEEE80211_STATMASK_NOISE (1<<2)
  668. #define IEEE80211_STATMASK_RATE (1<<3)
  669. #define IEEE80211_STATMASK_WEMASK 0x7
  670. #define IEEE80211_CCK_MODULATION (1<<0)
  671. #define IEEE80211_OFDM_MODULATION (1<<1)
  672. #define IEEE80211_24GHZ_BAND (1<<0)
  673. #define IEEE80211_52GHZ_BAND (1<<1)
  674. #define IEEE80211_CCK_RATE_LEN 4
  675. #define IEEE80211_NUM_OFDM_RATESLEN 8
  676. #define IEEE80211_CCK_RATE_1MB 0x02
  677. #define IEEE80211_CCK_RATE_2MB 0x04
  678. #define IEEE80211_CCK_RATE_5MB 0x0B
  679. #define IEEE80211_CCK_RATE_11MB 0x16
  680. #define IEEE80211_OFDM_RATE_LEN 8
  681. #define IEEE80211_OFDM_RATE_6MB 0x0C
  682. #define IEEE80211_OFDM_RATE_9MB 0x12
  683. #define IEEE80211_OFDM_RATE_12MB 0x18
  684. #define IEEE80211_OFDM_RATE_18MB 0x24
  685. #define IEEE80211_OFDM_RATE_24MB 0x30
  686. #define IEEE80211_OFDM_RATE_36MB 0x48
  687. #define IEEE80211_OFDM_RATE_48MB 0x60
  688. #define IEEE80211_OFDM_RATE_54MB 0x6C
  689. #define IEEE80211_PBCC_RATE_22MB 0x2c
  690. #define IEEE80211_PBCC_RATE_33MB 0x42
  691. #define IEEE80211_BASIC_RATE_MASK 0x80
  692. #define IEEE80211_CCK_RATE_1MB_MASK (1<<0)
  693. #define IEEE80211_CCK_RATE_2MB_MASK (1<<1)
  694. #define IEEE80211_CCK_RATE_5MB_MASK (1<<2)
  695. #define IEEE80211_CCK_RATE_11MB_MASK (1<<3)
  696. #define IEEE80211_OFDM_RATE_6MB_MASK (1<<4)
  697. #define IEEE80211_OFDM_RATE_9MB_MASK (1<<5)
  698. #define IEEE80211_OFDM_RATE_12MB_MASK (1<<6)
  699. #define IEEE80211_OFDM_RATE_18MB_MASK (1<<7)
  700. #define IEEE80211_OFDM_RATE_24MB_MASK (1<<8)
  701. #define IEEE80211_OFDM_RATE_36MB_MASK (1<<9)
  702. #define IEEE80211_OFDM_RATE_48MB_MASK (1<<10)
  703. #define IEEE80211_OFDM_RATE_54MB_MASK (1<<11)
  704. #define IEEE80211_CCK_RATES_MASK 0x0000000F
  705. #define IEEE80211_CCK_BASIC_RATES_MASK (IEEE80211_CCK_RATE_1MB_MASK | \
  706. IEEE80211_CCK_RATE_2MB_MASK)
  707. #define IEEE80211_CCK_DEFAULT_RATES_MASK (IEEE80211_CCK_BASIC_RATES_MASK | \
  708. IEEE80211_CCK_RATE_5MB_MASK | \
  709. IEEE80211_CCK_RATE_11MB_MASK)
  710. #define IEEE80211_OFDM_RATES_MASK 0x00000FF0
  711. #define IEEE80211_OFDM_BASIC_RATES_MASK (IEEE80211_OFDM_RATE_6MB_MASK | \
  712. IEEE80211_OFDM_RATE_12MB_MASK | \
  713. IEEE80211_OFDM_RATE_24MB_MASK)
  714. #define IEEE80211_OFDM_DEFAULT_RATES_MASK (IEEE80211_OFDM_BASIC_RATES_MASK | \
  715. IEEE80211_OFDM_RATE_9MB_MASK | \
  716. IEEE80211_OFDM_RATE_18MB_MASK | \
  717. IEEE80211_OFDM_RATE_36MB_MASK | \
  718. IEEE80211_OFDM_RATE_48MB_MASK | \
  719. IEEE80211_OFDM_RATE_54MB_MASK)
  720. #define IEEE80211_DEFAULT_RATES_MASK (IEEE80211_OFDM_DEFAULT_RATES_MASK | \
  721. IEEE80211_CCK_DEFAULT_RATES_MASK)
  722. #define IEEE80211_NUM_OFDM_RATES 8
  723. #define IEEE80211_NUM_CCK_RATES 4
  724. #define IEEE80211_OFDM_SHIFT_MASK_A 4
  725. enum MGN_RATE {
  726. MGN_1M = 0x02,
  727. MGN_2M = 0x04,
  728. MGN_5_5M = 0x0B,
  729. MGN_6M = 0x0C,
  730. MGN_9M = 0x12,
  731. MGN_11M = 0x16,
  732. MGN_12M = 0x18,
  733. MGN_18M = 0x24,
  734. MGN_24M = 0x30,
  735. MGN_36M = 0x48,
  736. MGN_48M = 0x60,
  737. MGN_54M = 0x6C,
  738. MGN_MCS32 = 0x7F,
  739. MGN_MCS0,
  740. MGN_MCS1,
  741. MGN_MCS2,
  742. MGN_MCS3,
  743. MGN_MCS4,
  744. MGN_MCS5,
  745. MGN_MCS6,
  746. MGN_MCS7,
  747. MGN_MCS8,
  748. MGN_MCS9,
  749. MGN_MCS10,
  750. MGN_MCS11,
  751. MGN_MCS12,
  752. MGN_MCS13,
  753. MGN_MCS14,
  754. MGN_MCS15,
  755. MGN_MCS16,
  756. MGN_MCS17,
  757. MGN_MCS18,
  758. MGN_MCS19,
  759. MGN_MCS20,
  760. MGN_MCS21,
  761. MGN_MCS22,
  762. MGN_MCS23,
  763. MGN_MCS24,
  764. MGN_MCS25,
  765. MGN_MCS26,
  766. MGN_MCS27,
  767. MGN_MCS28,
  768. MGN_MCS29,
  769. MGN_MCS30,
  770. MGN_MCS31,
  771. MGN_VHT1SS_MCS0,
  772. MGN_VHT1SS_MCS1,
  773. MGN_VHT1SS_MCS2,
  774. MGN_VHT1SS_MCS3,
  775. MGN_VHT1SS_MCS4,
  776. MGN_VHT1SS_MCS5,
  777. MGN_VHT1SS_MCS6,
  778. MGN_VHT1SS_MCS7,
  779. MGN_VHT1SS_MCS8,
  780. MGN_VHT1SS_MCS9,
  781. MGN_VHT2SS_MCS0,
  782. MGN_VHT2SS_MCS1,
  783. MGN_VHT2SS_MCS2,
  784. MGN_VHT2SS_MCS3,
  785. MGN_VHT2SS_MCS4,
  786. MGN_VHT2SS_MCS5,
  787. MGN_VHT2SS_MCS6,
  788. MGN_VHT2SS_MCS7,
  789. MGN_VHT2SS_MCS8,
  790. MGN_VHT2SS_MCS9,
  791. MGN_VHT3SS_MCS0,
  792. MGN_VHT3SS_MCS1,
  793. MGN_VHT3SS_MCS2,
  794. MGN_VHT3SS_MCS3,
  795. MGN_VHT3SS_MCS4,
  796. MGN_VHT3SS_MCS5,
  797. MGN_VHT3SS_MCS6,
  798. MGN_VHT3SS_MCS7,
  799. MGN_VHT3SS_MCS8,
  800. MGN_VHT3SS_MCS9,
  801. MGN_VHT4SS_MCS0,
  802. MGN_VHT4SS_MCS1,
  803. MGN_VHT4SS_MCS2,
  804. MGN_VHT4SS_MCS3,
  805. MGN_VHT4SS_MCS4,
  806. MGN_VHT4SS_MCS5,
  807. MGN_VHT4SS_MCS6,
  808. MGN_VHT4SS_MCS7,
  809. MGN_VHT4SS_MCS8,
  810. MGN_VHT4SS_MCS9,
  811. MGN_UNKNOWN
  812. };
  813. #define IS_HT_RATE(_rate) ((_rate) >= MGN_MCS0 && (_rate) <= MGN_MCS31)
  814. #define IS_VHT_RATE(_rate) ((_rate) >= MGN_VHT1SS_MCS0 && (_rate) <= MGN_VHT4SS_MCS9)
  815. #define IS_CCK_RATE(_rate) ((_rate) == MGN_1M || (_rate) == MGN_2M || (_rate) == MGN_5_5M || (_rate) == MGN_11M)
  816. #define IS_OFDM_RATE(_rate) ((_rate) >= MGN_6M && (_rate) <= MGN_54M && (_rate) != MGN_11M)
  817. #define IS_HT1SS_RATE(_rate) ((_rate) >= MGN_MCS0 && (_rate) <= MGN_MCS7)
  818. #define IS_HT2SS_RATE(_rate) ((_rate) >= MGN_MCS8 && (_rate) <= MGN_MCS15)
  819. #define IS_HT3SS_RATE(_rate) ((_rate) >= MGN_MCS16 && (_rate) <= MGN_MCS23)
  820. #define IS_HT4SS_RATE(_rate) ((_rate) >= MGN_MCS24 && (_rate) <= MGN_MCS31)
  821. #define IS_VHT1SS_RATE(_rate) ((_rate) >= MGN_VHT1SS_MCS0 && (_rate) <= MGN_VHT1SS_MCS9)
  822. #define IS_VHT2SS_RATE(_rate) ((_rate) >= MGN_VHT2SS_MCS0 && (_rate) <= MGN_VHT2SS_MCS9)
  823. #define IS_VHT3SS_RATE(_rate) ((_rate) >= MGN_VHT3SS_MCS0 && (_rate) <= MGN_VHT3SS_MCS9)
  824. #define IS_VHT4SS_RATE(_rate) ((_rate) >= MGN_VHT4SS_MCS0 && (_rate) <= MGN_VHT4SS_MCS9)
  825. #define IS_1T_RATE(_rate) (IS_CCK_RATE((_rate)) || IS_OFDM_RATE((_rate)) || IS_HT1SS_RATE((_rate)) || IS_VHT1SS_RATE((_rate)))
  826. #define IS_2T_RATE(_rate) (IS_HT2SS_RATE((_rate)) || IS_VHT2SS_RATE((_rate)))
  827. #define IS_3T_RATE(_rate) (IS_HT3SS_RATE((_rate)) || IS_VHT3SS_RATE((_rate)))
  828. #define IS_4T_RATE(_rate) (IS_HT4SS_RATE((_rate)) || IS_VHT4SS_RATE((_rate)))
  829. #define MGN_RATE_STR(_rate) \
  830. (_rate == MGN_1M) ? "CCK_1M" : \
  831. (_rate == MGN_2M) ? "CCK_2M" : \
  832. (_rate == MGN_5_5M) ? "CCK_5.5M" : \
  833. (_rate == MGN_11M) ? "CCK_11M" : \
  834. (_rate == MGN_6M) ? "OFDM_6M" : \
  835. (_rate == MGN_9M) ? "OFDM_9M" : \
  836. (_rate == MGN_12M) ? "OFDM_12M" : \
  837. (_rate == MGN_18M) ? "OFDM_18M" : \
  838. (_rate == MGN_24M) ? "OFDM_24M" : \
  839. (_rate == MGN_36M) ? "OFDM_36M" : \
  840. (_rate == MGN_48M) ? "OFDM_48M" : \
  841. (_rate == MGN_54M) ? "OFDM_54M" : \
  842. (_rate == MGN_MCS32) ? "MCS32" : \
  843. (_rate == MGN_MCS0) ? "MCS0" : \
  844. (_rate == MGN_MCS1) ? "MCS1" : \
  845. (_rate == MGN_MCS2) ? "MCS2" : \
  846. (_rate == MGN_MCS3) ? "MCS3" : \
  847. (_rate == MGN_MCS4) ? "MCS4" : \
  848. (_rate == MGN_MCS5) ? "MCS5" : \
  849. (_rate == MGN_MCS6) ? "MCS6" : \
  850. (_rate == MGN_MCS7) ? "MCS7" : \
  851. (_rate == MGN_MCS8) ? "MCS8" : \
  852. (_rate == MGN_MCS9) ? "MCS9" : \
  853. (_rate == MGN_MCS10) ? "MCS10" : \
  854. (_rate == MGN_MCS11) ? "MCS11" : \
  855. (_rate == MGN_MCS12) ? "MCS12" : \
  856. (_rate == MGN_MCS13) ? "MCS13" : \
  857. (_rate == MGN_MCS14) ? "MCS14" : \
  858. (_rate == MGN_MCS15) ? "MCS15" : \
  859. (_rate == MGN_MCS16) ? "MCS16" : \
  860. (_rate == MGN_MCS17) ? "MCS17" : \
  861. (_rate == MGN_MCS18) ? "MCS18" : \
  862. (_rate == MGN_MCS19) ? "MCS19" : \
  863. (_rate == MGN_MCS20) ? "MCS20" : \
  864. (_rate == MGN_MCS21) ? "MCS21" : \
  865. (_rate == MGN_MCS22) ? "MCS22" : \
  866. (_rate == MGN_MCS23) ? "MCS23" : \
  867. (_rate == MGN_MCS24) ? "MCS24" : \
  868. (_rate == MGN_MCS25) ? "MCS25" : \
  869. (_rate == MGN_MCS26) ? "MCS26" : \
  870. (_rate == MGN_MCS27) ? "MCS27" : \
  871. (_rate == MGN_MCS28) ? "MCS28" : \
  872. (_rate == MGN_MCS29) ? "MCS29" : \
  873. (_rate == MGN_MCS30) ? "MCS30" : \
  874. (_rate == MGN_MCS31) ? "MCS31" : \
  875. (_rate == MGN_VHT1SS_MCS0) ? "VHT1SMCS0" : \
  876. (_rate == MGN_VHT1SS_MCS1) ? "VHT1SMCS1" : \
  877. (_rate == MGN_VHT1SS_MCS2) ? "VHT1SMCS2" : \
  878. (_rate == MGN_VHT1SS_MCS3) ? "VHT1SMCS3" : \
  879. (_rate == MGN_VHT1SS_MCS4) ? "VHT1SMCS4" : \
  880. (_rate == MGN_VHT1SS_MCS5) ? "VHT1SMCS5" : \
  881. (_rate == MGN_VHT1SS_MCS6) ? "VHT1SMCS6" : \
  882. (_rate == MGN_VHT1SS_MCS7) ? "VHT1SMCS7" : \
  883. (_rate == MGN_VHT1SS_MCS8) ? "VHT1SMCS8" : \
  884. (_rate == MGN_VHT1SS_MCS9) ? "VHT1SMCS9" : \
  885. (_rate == MGN_VHT2SS_MCS0) ? "VHT2SMCS0" : \
  886. (_rate == MGN_VHT2SS_MCS1) ? "VHT2SMCS1" : \
  887. (_rate == MGN_VHT2SS_MCS2) ? "VHT2SMCS2" : \
  888. (_rate == MGN_VHT2SS_MCS3) ? "VHT2SMCS3" : \
  889. (_rate == MGN_VHT2SS_MCS4) ? "VHT2SMCS4" : \
  890. (_rate == MGN_VHT2SS_MCS5) ? "VHT2SMCS5" : \
  891. (_rate == MGN_VHT2SS_MCS6) ? "VHT2SMCS6" : \
  892. (_rate == MGN_VHT2SS_MCS7) ? "VHT2SMCS7" : \
  893. (_rate == MGN_VHT2SS_MCS8) ? "VHT2SMCS8" : \
  894. (_rate == MGN_VHT2SS_MCS9) ? "VHT2SMCS9" : \
  895. (_rate == MGN_VHT3SS_MCS0) ? "VHT3SMCS0" : \
  896. (_rate == MGN_VHT3SS_MCS1) ? "VHT3SMCS1" : \
  897. (_rate == MGN_VHT3SS_MCS2) ? "VHT3SMCS2" : \
  898. (_rate == MGN_VHT3SS_MCS3) ? "VHT3SMCS3" : \
  899. (_rate == MGN_VHT3SS_MCS4) ? "VHT3SMCS4" : \
  900. (_rate == MGN_VHT3SS_MCS5) ? "VHT3SMCS5" : \
  901. (_rate == MGN_VHT3SS_MCS6) ? "VHT3SMCS6" : \
  902. (_rate == MGN_VHT3SS_MCS7) ? "VHT3SMCS7" : \
  903. (_rate == MGN_VHT3SS_MCS8) ? "VHT3SMCS8" : \
  904. (_rate == MGN_VHT3SS_MCS9) ? "VHT3SMCS9" : \
  905. (_rate == MGN_VHT4SS_MCS0) ? "VHT4SMCS0" : \
  906. (_rate == MGN_VHT4SS_MCS1) ? "VHT4SMCS1" : \
  907. (_rate == MGN_VHT4SS_MCS2) ? "VHT4SMCS2" : \
  908. (_rate == MGN_VHT4SS_MCS3) ? "VHT4SMCS3" : \
  909. (_rate == MGN_VHT4SS_MCS4) ? "VHT4SMCS4" : \
  910. (_rate == MGN_VHT4SS_MCS5) ? "VHT4SMCS5" : \
  911. (_rate == MGN_VHT4SS_MCS6) ? "VHT4SMCS6" : \
  912. (_rate == MGN_VHT4SS_MCS7) ? "VHT4SMCS7" : \
  913. (_rate == MGN_VHT4SS_MCS8) ? "VHT4SMCS8" : \
  914. (_rate == MGN_VHT4SS_MCS9) ? "VHT4SMCS9" : "UNKNOWN"
  915. typedef enum _RATE_SECTION {
  916. CCK = 0,
  917. OFDM = 1,
  918. HT_MCS0_MCS7 = 2,
  919. HT_MCS8_MCS15 = 3,
  920. HT_MCS16_MCS23 = 4,
  921. HT_MCS24_MCS31 = 5,
  922. HT_1SS = HT_MCS0_MCS7,
  923. HT_2SS = HT_MCS8_MCS15,
  924. HT_3SS = HT_MCS16_MCS23,
  925. HT_4SS = HT_MCS24_MCS31,
  926. VHT_1SSMCS0_1SSMCS9 = 6,
  927. VHT_2SSMCS0_2SSMCS9 = 7,
  928. VHT_3SSMCS0_3SSMCS9 = 8,
  929. VHT_4SSMCS0_4SSMCS9 = 9,
  930. VHT_1SS = VHT_1SSMCS0_1SSMCS9,
  931. VHT_2SS = VHT_2SSMCS0_2SSMCS9,
  932. VHT_3SS = VHT_3SSMCS0_3SSMCS9,
  933. VHT_4SS = VHT_4SSMCS0_4SSMCS9,
  934. RATE_SECTION_NUM,
  935. } RATE_SECTION;
  936. const char *rate_section_str(u8 section);
  937. #define IS_CCK_RATE_SECTION(section) ((section) == CCK)
  938. #define IS_OFDM_RATE_SECTION(section) ((section) == OFDM)
  939. #define IS_HT_RATE_SECTION(section) ((section) >= HT_1SS && (section) <= HT_4SS)
  940. #define IS_VHT_RATE_SECTION(section) ((section) >= VHT_1SS && (section) <= VHT_4SS)
  941. #define IS_1T_RATE_SECTION(section) ((section) == CCK || (section) == OFDM || (section) == HT_1SS || (section) == VHT_1SS)
  942. #define IS_2T_RATE_SECTION(section) ((section) == HT_2SS || (section) == VHT_2SS)
  943. #define IS_3T_RATE_SECTION(section) ((section) == HT_3SS || (section) == VHT_3SS)
  944. #define IS_4T_RATE_SECTION(section) ((section) == HT_4SS || (section) == VHT_4SS)
  945. extern u8 mgn_rates_cck[];
  946. extern u8 mgn_rates_ofdm[];
  947. extern u8 mgn_rates_mcs0_7[];
  948. extern u8 mgn_rates_mcs8_15[];
  949. extern u8 mgn_rates_mcs16_23[];
  950. extern u8 mgn_rates_mcs24_31[];
  951. extern u8 mgn_rates_vht1ss[];
  952. extern u8 mgn_rates_vht2ss[];
  953. extern u8 mgn_rates_vht3ss[];
  954. extern u8 mgn_rates_vht4ss[];
  955. struct rate_section_ent {
  956. u8 tx_num; /* value of RF_TX_NUM */
  957. u8 rate_num;
  958. u8 *rates;
  959. };
  960. extern struct rate_section_ent rates_by_sections[];
  961. #define rate_section_to_tx_num(section) (rates_by_sections[(section)].tx_num)
  962. #define rate_section_rate_num(section) (rates_by_sections[(section)].rate_num)
  963. /* NOTE: This data is for statistical purposes; not all hardware provides this
  964. * information for frames received. Not setting these will not cause
  965. * any adverse affects. */
  966. struct ieee80211_rx_stats {
  967. /* u32 mac_time[2]; */
  968. s8 rssi;
  969. u8 signal;
  970. u8 noise;
  971. u8 received_channel;
  972. u16 rate; /* in 100 kbps */
  973. /* u8 control; */
  974. u8 mask;
  975. u8 freq;
  976. u16 len;
  977. };
  978. /* IEEE 802.11 requires that STA supports concurrent reception of at least
  979. * three fragmented frames. This define can be increased to support more
  980. * concurrent frames, but it should be noted that each entry can consume about
  981. * 2 kB of RAM and increasing cache size will slow down frame reassembly. */
  982. #define IEEE80211_FRAG_CACHE_LEN 4
  983. struct ieee80211_frag_entry {
  984. u32 first_frag_time;
  985. uint seq;
  986. uint last_frag;
  987. uint qos; /* jackson */
  988. uint tid; /* jackson */
  989. struct sk_buff *skb;
  990. u8 src_addr[ETH_ALEN];
  991. u8 dst_addr[ETH_ALEN];
  992. };
  993. #ifndef PLATFORM_FREEBSD /* Baron BSD has already defined */
  994. struct ieee80211_stats {
  995. uint tx_unicast_frames;
  996. uint tx_multicast_frames;
  997. uint tx_fragments;
  998. uint tx_unicast_octets;
  999. uint tx_multicast_octets;
  1000. uint tx_deferred_transmissions;
  1001. uint tx_single_retry_frames;
  1002. uint tx_multiple_retry_frames;
  1003. uint tx_retry_limit_exceeded;
  1004. uint tx_discards;
  1005. uint rx_unicast_frames;
  1006. uint rx_multicast_frames;
  1007. uint rx_fragments;
  1008. uint rx_unicast_octets;
  1009. uint rx_multicast_octets;
  1010. uint rx_fcs_errors;
  1011. uint rx_discards_no_buffer;
  1012. uint tx_discards_wrong_sa;
  1013. uint rx_discards_undecryptable;
  1014. uint rx_message_in_msg_fragments;
  1015. uint rx_message_in_bad_msg_fragments;
  1016. };
  1017. #endif /* PLATFORM_FREEBSD */
  1018. struct ieee80211_softmac_stats {
  1019. uint rx_ass_ok;
  1020. uint rx_ass_err;
  1021. uint rx_probe_rq;
  1022. uint tx_probe_rs;
  1023. uint tx_beacons;
  1024. uint rx_auth_rq;
  1025. uint rx_auth_rs_ok;
  1026. uint rx_auth_rs_err;
  1027. uint tx_auth_rq;
  1028. uint no_auth_rs;
  1029. uint no_ass_rs;
  1030. uint tx_ass_rq;
  1031. uint rx_ass_rq;
  1032. uint tx_probe_rq;
  1033. uint reassoc;
  1034. uint swtxstop;
  1035. uint swtxawake;
  1036. };
  1037. #define SEC_KEY_1 (1<<0)
  1038. #define SEC_KEY_2 (1<<1)
  1039. #define SEC_KEY_3 (1<<2)
  1040. #define SEC_KEY_4 (1<<3)
  1041. #define SEC_ACTIVE_KEY (1<<4)
  1042. #define SEC_AUTH_MODE (1<<5)
  1043. #define SEC_UNICAST_GROUP (1<<6)
  1044. #define SEC_LEVEL (1<<7)
  1045. #define SEC_ENABLED (1<<8)
  1046. #define SEC_LEVEL_0 0 /* None */
  1047. #define SEC_LEVEL_1 1 /* WEP 40 and 104 bit */
  1048. #define SEC_LEVEL_2 2 /* Level 1 + TKIP */
  1049. #define SEC_LEVEL_2_CKIP 3 /* Level 1 + CKIP */
  1050. #define SEC_LEVEL_3 4 /* Level 2 + CCMP */
  1051. #define WEP_KEYS 4
  1052. #define WEP_KEY_LEN 13
  1053. #define BIP_MAX_KEYID 5
  1054. #define BIP_AAD_SIZE 20
  1055. #if defined(PLATFORM_LINUX) || defined(CONFIG_RTL8711FW)
  1056. struct ieee80211_security {
  1057. u16 active_key:2,
  1058. enabled:1,
  1059. auth_mode:2,
  1060. auth_algo:4,
  1061. unicast_uses_group:1;
  1062. u8 key_sizes[WEP_KEYS];
  1063. u8 keys[WEP_KEYS][WEP_KEY_LEN];
  1064. u8 level;
  1065. u16 flags;
  1066. } __attribute__((packed));
  1067. #endif
  1068. #ifdef PLATFORM_WINDOWS
  1069. #pragma pack(1)
  1070. struct ieee80211_security {
  1071. u16 active_key:2,
  1072. enabled:1,
  1073. auth_mode:2,
  1074. auth_algo:4,
  1075. unicast_uses_group:1;
  1076. u8 key_sizes[WEP_KEYS];
  1077. u8 keys[WEP_KEYS][WEP_KEY_LEN];
  1078. u8 level;
  1079. u16 flags;
  1080. } ;
  1081. #pragma pack()
  1082. #endif
  1083. /*
  1084. 802.11 data frame from AP
  1085. ,-------------------------------------------------------------------.
  1086. Bytes | 2 | 2 | 6 | 6 | 6 | 2 | 0..2312 | 4 |
  1087. |------|------|---------|---------|---------|------|---------|------|
  1088. Desc. | ctrl | dura | DA/RA | TA | SA | Sequ | frame | fcs |
  1089. | | tion | (BSSID) | | | ence | data | |
  1090. `-------------------------------------------------------------------'
  1091. Total: 28-2340 bytes
  1092. */
  1093. struct ieee80211_header_data {
  1094. u16 frame_ctl;
  1095. u16 duration_id;
  1096. u8 addr1[6];
  1097. u8 addr2[6];
  1098. u8 addr3[6];
  1099. u16 seq_ctrl;
  1100. };
  1101. #define BEACON_PROBE_SSID_ID_POSITION 12
  1102. /* Management Frame Information Element Types */
  1103. #define MFIE_TYPE_SSID 0
  1104. #define MFIE_TYPE_RATES 1
  1105. #define MFIE_TYPE_FH_SET 2
  1106. #define MFIE_TYPE_DS_SET 3
  1107. #define MFIE_TYPE_CF_SET 4
  1108. #define MFIE_TYPE_TIM 5
  1109. #define MFIE_TYPE_IBSS_SET 6
  1110. #define MFIE_TYPE_CHALLENGE 16
  1111. #define MFIE_TYPE_ERP 42
  1112. #define MFIE_TYPE_RSN 48
  1113. #define MFIE_TYPE_RATES_EX 50
  1114. #define MFIE_TYPE_GENERIC 221
  1115. #if defined(PLATFORM_LINUX) || defined(CONFIG_RTL8711FW)
  1116. struct ieee80211_info_element_hdr {
  1117. u8 id;
  1118. u8 len;
  1119. } __attribute__((packed));
  1120. struct ieee80211_info_element {
  1121. u8 id;
  1122. u8 len;
  1123. u8 data[0];
  1124. } __attribute__((packed));
  1125. #endif
  1126. #ifdef PLATFORM_WINDOWS
  1127. #pragma pack(1)
  1128. struct ieee80211_info_element_hdr {
  1129. u8 id;
  1130. u8 len;
  1131. } ;
  1132. struct ieee80211_info_element {
  1133. u8 id;
  1134. u8 len;
  1135. u8 data[0];
  1136. } ;
  1137. #pragma pack()
  1138. #endif
  1139. /*
  1140. * These are the data types that can make up management packets
  1141. *
  1142. u16 auth_algorithm;
  1143. u16 auth_sequence;
  1144. u16 beacon_interval;
  1145. u16 capability;
  1146. u8 current_ap[ETH_ALEN];
  1147. u16 listen_interval;
  1148. struct {
  1149. u16 association_id:14, reserved:2;
  1150. } __attribute__ ((packed));
  1151. u32 time_stamp[2];
  1152. u16 reason;
  1153. u16 status;
  1154. */
  1155. #define IEEE80211_DEFAULT_TX_ESSID "Penguin"
  1156. #define IEEE80211_DEFAULT_BASIC_RATE 10
  1157. #if defined(PLATFORM_LINUX) || defined(CONFIG_RTL8711FW)
  1158. struct ieee80211_authentication {
  1159. struct ieee80211_header_data header;
  1160. u16 algorithm;
  1161. u16 transaction;
  1162. u16 status;
  1163. /* struct ieee80211_info_element_hdr info_element; */
  1164. } __attribute__((packed));
  1165. struct ieee80211_probe_response {
  1166. struct ieee80211_header_data header;
  1167. u32 time_stamp[2];
  1168. u16 beacon_interval;
  1169. u16 capability;
  1170. struct ieee80211_info_element info_element;
  1171. } __attribute__((packed));
  1172. struct ieee80211_probe_request {
  1173. struct ieee80211_header_data header;
  1174. /*struct ieee80211_info_element info_element;*/
  1175. } __attribute__((packed));
  1176. struct ieee80211_assoc_request_frame {
  1177. struct rtw_ieee80211_hdr_3addr header;
  1178. u16 capability;
  1179. u16 listen_interval;
  1180. /* u8 current_ap[ETH_ALEN]; */
  1181. struct ieee80211_info_element_hdr info_element;
  1182. } __attribute__((packed));
  1183. struct ieee80211_assoc_response_frame {
  1184. struct rtw_ieee80211_hdr_3addr header;
  1185. u16 capability;
  1186. u16 status;
  1187. u16 aid;
  1188. /* struct ieee80211_info_element info_element; supported rates */
  1189. } __attribute__((packed));
  1190. #endif
  1191. #ifdef PLATFORM_WINDOWS
  1192. #pragma pack(1)
  1193. struct ieee80211_authentication {
  1194. struct ieee80211_header_data header;
  1195. u16 algorithm;
  1196. u16 transaction;
  1197. u16 status;
  1198. /* struct ieee80211_info_element_hdr info_element; */
  1199. } ;
  1200. struct ieee80211_probe_response {
  1201. struct ieee80211_header_data header;
  1202. u32 time_stamp[2];
  1203. u16 beacon_interval;
  1204. u16 capability;
  1205. struct ieee80211_info_element info_element;
  1206. } ;
  1207. struct ieee80211_probe_request {
  1208. struct ieee80211_header_data header;
  1209. /*struct ieee80211_info_element info_element;*/
  1210. } ;
  1211. struct ieee80211_assoc_request_frame {
  1212. struct rtw_ieee80211_hdr_3addr header;
  1213. u16 capability;
  1214. u16 listen_interval;
  1215. /* u8 current_ap[ETH_ALEN]; */
  1216. struct ieee80211_info_element_hdr info_element;
  1217. } ;
  1218. struct ieee80211_assoc_response_frame {
  1219. struct rtw_ieee80211_hdr_3addr header;
  1220. u16 capability;
  1221. u16 status;
  1222. u16 aid;
  1223. /* struct ieee80211_info_element info_element; supported rates */
  1224. };
  1225. #pragma pack()
  1226. #endif
  1227. struct ieee80211_txb {
  1228. u8 nr_frags;
  1229. u8 encrypted;
  1230. u16 reserved;
  1231. u16 frag_size;
  1232. u16 payload_size;
  1233. struct sk_buff *fragments[0];
  1234. };
  1235. /* SWEEP TABLE ENTRIES NUMBER*/
  1236. #define MAX_SWEEP_TAB_ENTRIES 42
  1237. #define MAX_SWEEP_TAB_ENTRIES_PER_PACKET 7
  1238. /* MAX_RATES_LENGTH needs to be 12. The spec says 8, and many APs
  1239. * only use 8, and then use extended rates for the remaining supported
  1240. * rates. Other APs, however, stick all of their supported rates on the
  1241. * main rates information element... */
  1242. #define MAX_RATES_LENGTH ((u8)12)
  1243. #define MAX_RATES_EX_LENGTH ((u8)16)
  1244. #define MAX_NETWORK_COUNT 128
  1245. #define IEEE80211_SOFTMAC_SCAN_TIME 400
  1246. /* (HZ / 2) */
  1247. #define IEEE80211_SOFTMAC_ASSOC_RETRY_TIME (HZ * 2)
  1248. #define CRC_LENGTH 4U
  1249. #define MAX_WPA_IE_LEN (256)
  1250. #define MAX_WPS_IE_LEN (512)
  1251. #define MAX_P2P_IE_LEN (256)
  1252. #define MAX_WFD_IE_LEN (128)
  1253. #define NETWORK_EMPTY_ESSID (1<<0)
  1254. #define NETWORK_HAS_OFDM (1<<1)
  1255. #define NETWORK_HAS_CCK (1<<2)
  1256. #define IEEE80211_DTIM_MBCAST 4
  1257. #define IEEE80211_DTIM_UCAST 2
  1258. #define IEEE80211_DTIM_VALID 1
  1259. #define IEEE80211_DTIM_INVALID 0
  1260. #define IEEE80211_PS_DISABLED 0
  1261. #define IEEE80211_PS_UNICAST IEEE80211_DTIM_UCAST
  1262. #define IEEE80211_PS_MBCAST IEEE80211_DTIM_MBCAST
  1263. #define IW_ESSID_MAX_SIZE 32
  1264. #if 0
  1265. struct ieee80211_network {
  1266. /* These entries are used to identify a unique network */
  1267. u8 bssid[ETH_ALEN];
  1268. u8 channel;
  1269. /* Ensure null-terminated for any debug msgs */
  1270. u8 ssid[IW_ESSID_MAX_SIZE + 1];
  1271. u8 ssid_len;
  1272. u8 rssi; /* relative signal strength */
  1273. u8 sq; /* signal quality */
  1274. /* These are network statistics */
  1275. /* struct ieee80211_rx_stats stats; */
  1276. u16 capability;
  1277. u16 aid;
  1278. u8 rates[MAX_RATES_LENGTH];
  1279. u8 rates_len;
  1280. u8 rates_ex[MAX_RATES_EX_LENGTH];
  1281. u8 rates_ex_len;
  1282. u8 edca_parmsets[18];
  1283. u8 mode;
  1284. u8 flags;
  1285. u8 time_stamp[8];
  1286. u16 beacon_interval;
  1287. u16 listen_interval;
  1288. u16 atim_window;
  1289. u8 wpa_ie[MAX_WPA_IE_LEN];
  1290. size_t wpa_ie_len;
  1291. u8 rsn_ie[MAX_WPA_IE_LEN];
  1292. size_t rsn_ie_len;
  1293. u8 country[6];
  1294. u8 dtim_period;
  1295. u8 dtim_data;
  1296. u8 power_constraint;
  1297. u8 qosinfo;
  1298. u8 qbssload[5];
  1299. u8 network_type;
  1300. int join_res;
  1301. unsigned long last_scanned;
  1302. };
  1303. #endif
  1304. /*
  1305. join_res:
  1306. -1: authentication fail
  1307. -2: association fail
  1308. > 0: TID
  1309. */
  1310. #ifndef PLATFORM_FREEBSD /* Baron BSD has already defined */
  1311. enum ieee80211_state {
  1312. /* the card is not linked at all */
  1313. IEEE80211_NOLINK = 0,
  1314. /* IEEE80211_ASSOCIATING* are for BSS client mode
  1315. * the driver shall not perform RX filtering unless
  1316. * the state is LINKED.
  1317. * The driver shall just check for the state LINKED and
  1318. * defaults to NOLINK for ALL the other states (including
  1319. * LINKED_SCANNING)
  1320. */
  1321. /* the association procedure will start (wq scheduling)*/
  1322. IEEE80211_ASSOCIATING,
  1323. IEEE80211_ASSOCIATING_RETRY,
  1324. /* the association procedure is sending AUTH request*/
  1325. IEEE80211_ASSOCIATING_AUTHENTICATING,
  1326. /* the association procedure has successfully authentcated
  1327. * and is sending association request
  1328. */
  1329. IEEE80211_ASSOCIATING_AUTHENTICATED,
  1330. /* the link is ok. the card associated to a BSS or linked
  1331. * to a ibss cell or acting as an AP and creating the bss
  1332. */
  1333. IEEE80211_LINKED,
  1334. /* same as LINKED, but the driver shall apply RX filter
  1335. * rules as we are in NO_LINK mode. As the card is still
  1336. * logically linked, but it is doing a syncro site survey
  1337. * then it will be back to LINKED state.
  1338. */
  1339. IEEE80211_LINKED_SCANNING,
  1340. };
  1341. #endif /* PLATFORM_FREEBSD */
  1342. #define DEFAULT_MAX_SCAN_AGE (15 * HZ)
  1343. #define DEFAULT_FTS 2346
  1344. #define MAC_FMT "%02x:%02x:%02x:%02x:%02x:%02x"
  1345. #define MAC_ARG(x) ((u8 *)(x))[0], ((u8 *)(x))[1], ((u8 *)(x))[2], ((u8 *)(x))[3], ((u8 *)(x))[4], ((u8 *)(x))[5]
  1346. #define MAC_SFMT "%02hhx:%02hhx:%02hhx:%02hhx:%02hhx:%02hhx"
  1347. #define MAC_SARG(x) ((u8*)(x)),((u8*)(x)) + 1,((u8*)(x)) + 2,((u8*)(x)) + 3,((u8*)(x)) + 4,((u8*)(x)) + 5
  1348. #define IP_FMT "%d.%d.%d.%d"
  1349. #define IP_ARG(x) ((u8 *)(x))[0], ((u8 *)(x))[1], ((u8 *)(x))[2], ((u8 *)(x))[3]
  1350. #define PORT_FMT "%u"
  1351. #define PORT_ARG(x) ntohs(*((u16 *)(x)))
  1352. #ifdef PLATFORM_FREEBSD /* Baron change func to macro */
  1353. #define is_multicast_mac_addr(Addr) ((((Addr[0]) & 0x01) == 0x01) && ((Addr[0]) != 0xff))
  1354. #define is_broadcast_mac_addr(Addr) ((((Addr[0]) & 0xff) == 0xff) && (((Addr[1]) & 0xff) == 0xff) && \
  1355. (((Addr[2]) & 0xff) == 0xff) && (((Addr[3]) & 0xff) == 0xff) && (((Addr[4]) & 0xff) == 0xff) && \
  1356. (((Addr[5]) & 0xff) == 0xff))
  1357. #else
  1358. extern __inline int is_multicast_mac_addr(const u8 *addr)
  1359. {
  1360. return (addr[0] != 0xff) && (0x01 & addr[0]);
  1361. }
  1362. extern __inline int is_broadcast_mac_addr(const u8 *addr)
  1363. {
  1364. return ((addr[0] == 0xff) && (addr[1] == 0xff) && (addr[2] == 0xff) && \
  1365. (addr[3] == 0xff) && (addr[4] == 0xff) && (addr[5] == 0xff));
  1366. }
  1367. extern __inline int is_zero_mac_addr(const u8 *addr)
  1368. {
  1369. return ((addr[0] == 0x00) && (addr[1] == 0x00) && (addr[2] == 0x00) && \
  1370. (addr[3] == 0x00) && (addr[4] == 0x00) && (addr[5] == 0x00));
  1371. }
  1372. #endif /* PLATFORM_FREEBSD */
  1373. #define CFG_IEEE80211_RESERVE_FCS (1<<0)
  1374. #define CFG_IEEE80211_COMPUTE_FCS (1<<1)
  1375. typedef struct tx_pending_t {
  1376. int frag;
  1377. struct ieee80211_txb *txb;
  1378. } tx_pending_t;
  1379. #define TID_NUM 16
  1380. #define IEEE_A (1<<0)
  1381. #define IEEE_B (1<<1)
  1382. #define IEEE_G (1<<2)
  1383. #define IEEE_MODE_MASK (IEEE_A | IEEE_B | IEEE_G)
  1384. /* Baron move to ieee80211.c */
  1385. int ieee80211_is_empty_essid(const char *essid, int essid_len);
  1386. int ieee80211_get_hdrlen(u16 fc);
  1387. #if 0
  1388. /* Action frame categories (IEEE 802.11-2007, 7.3.1.11, Table 7-24) */
  1389. #define WLAN_ACTION_SPECTRUM_MGMT 0
  1390. #define WLAN_ACTION_QOS 1
  1391. #define WLAN_ACTION_DLS 2
  1392. #define WLAN_ACTION_BLOCK_ACK 3
  1393. #define WLAN_ACTION_RADIO_MEASUREMENT 5
  1394. #define WLAN_ACTION_FT 6
  1395. #define WLAN_ACTION_SA_QUERY 8
  1396. #define WLAN_ACTION_WMM 17
  1397. #endif
  1398. /* Action category code */
  1399. enum rtw_ieee80211_category {
  1400. RTW_WLAN_CATEGORY_SPECTRUM_MGMT = 0,
  1401. RTW_WLAN_CATEGORY_QOS = 1,
  1402. RTW_WLAN_CATEGORY_DLS = 2,
  1403. RTW_WLAN_CATEGORY_BACK = 3,
  1404. RTW_WLAN_CATEGORY_PUBLIC = 4, /* IEEE 802.11 public action frames */
  1405. RTW_WLAN_CATEGORY_RADIO_MEAS = 5,
  1406. RTW_WLAN_CATEGORY_FT = 6,
  1407. RTW_WLAN_CATEGORY_HT = 7,
  1408. RTW_WLAN_CATEGORY_SA_QUERY = 8,
  1409. RTW_WLAN_CATEGORY_WNM = 10,
  1410. RTW_WLAN_CATEGORY_UNPROTECTED_WNM = 11, /* add for CONFIG_IEEE80211W, none 11w also can use */
  1411. RTW_WLAN_CATEGORY_TDLS = 12,
  1412. RTW_WLAN_CATEGORY_MESH = 13,
  1413. RTW_WLAN_CATEGORY_MULTIHOP = 14,
  1414. RTW_WLAN_CATEGORY_SELF_PROTECTED = 15,
  1415. RTW_WLAN_CATEGORY_WMM = 17,
  1416. RTW_WLAN_CATEGORY_VHT = 21,
  1417. RTW_WLAN_CATEGORY_P2P = 0x7f,/* P2P action frames */
  1418. };
  1419. #define CATEGORY_IS_GROUP_PRIVACY(cat) \
  1420. (cat == RTW_WLAN_CATEGORY_MESH || cat == RTW_WLAN_CATEGORY_MULTIHOP)
  1421. #define CATEGORY_IS_NON_ROBUST(cat) \
  1422. (cat == RTW_WLAN_CATEGORY_PUBLIC \
  1423. || cat == RTW_WLAN_CATEGORY_HT \
  1424. || cat == RTW_WLAN_CATEGORY_UNPROTECTED_WNM \
  1425. || cat == RTW_WLAN_CATEGORY_SELF_PROTECTED \
  1426. || cat == RTW_WLAN_CATEGORY_VHT \
  1427. || cat == RTW_WLAN_CATEGORY_P2P)
  1428. #define CATEGORY_IS_ROBUST(cat) !CATEGORY_IS_NON_ROBUST(cat)
  1429. /* SPECTRUM_MGMT action code */
  1430. enum rtw_ieee80211_spectrum_mgmt_actioncode {
  1431. RTW_WLAN_ACTION_SPCT_MSR_REQ = 0,
  1432. RTW_WLAN_ACTION_SPCT_MSR_RPRT = 1,
  1433. RTW_WLAN_ACTION_SPCT_TPC_REQ = 2,
  1434. RTW_WLAN_ACTION_SPCT_TPC_RPRT = 3,
  1435. RTW_WLAN_ACTION_SPCT_CHL_SWITCH = 4,
  1436. RTW_WLAN_ACTION_SPCT_EXT_CHL_SWITCH = 5,
  1437. };
  1438. /* SELF_PROTECTED action code */
  1439. enum rtw_ieee80211_self_protected_actioncode {
  1440. RTW_ACT_SELF_PROTECTED_RSVD = 0,
  1441. RTW_ACT_SELF_PROTECTED_MESH_OPEN = 1,
  1442. RTW_ACT_SELF_PROTECTED_MESH_CONF = 2,
  1443. RTW_ACT_SELF_PROTECTED_MESH_CLOSE = 3,
  1444. RTW_ACT_SELF_PROTECTED_MESH_GK_INFORM = 4,
  1445. RTW_ACT_SELF_PROTECTED_MESH_GK_ACK = 5,
  1446. RTW_ACT_SELF_PROTECTED_NUM,
  1447. };
  1448. /* MESH action code */
  1449. enum rtw_ieee80211_mesh_actioncode {
  1450. RTW_ACT_MESH_LINK_METRIC_REPORT,
  1451. RTW_ACT_MESH_HWMP_PATH_SELECTION,
  1452. RTW_ACT_MESH_GATE_ANNOUNCEMENT,
  1453. RTW_ACT_MESH_CONGESTION_CONTROL_NOTIFICATION,
  1454. RTW_ACT_MESH_MCCA_SETUP_REQUEST,
  1455. RTW_ACT_MESH_MCCA_SETUP_REPLY,
  1456. RTW_ACT_MESH_MCCA_ADVERTISEMENT_REQUEST,
  1457. RTW_ACT_MESH_MCCA_ADVERTISEMENT,
  1458. RTW_ACT_MESH_MCCA_TEARDOWN,
  1459. RTW_ACT_MESH_TBTT_ADJUSTMENT_REQUEST,
  1460. RTW_ACT_MESH_TBTT_ADJUSTMENT_RESPONSE,
  1461. };
  1462. enum _PUBLIC_ACTION {
  1463. ACT_PUBLIC_BSSCOEXIST = 0, /* 20/40 BSS Coexistence */
  1464. ACT_PUBLIC_DSE_ENABLE = 1,
  1465. ACT_PUBLIC_DSE_DEENABLE = 2,
  1466. ACT_PUBLIC_DSE_REG_LOCATION = 3,
  1467. ACT_PUBLIC_EXT_CHL_SWITCH = 4,
  1468. ACT_PUBLIC_DSE_MSR_REQ = 5,
  1469. ACT_PUBLIC_DSE_MSR_RPRT = 6,
  1470. ACT_PUBLIC_MP = 7, /* Measurement Pilot */
  1471. ACT_PUBLIC_DSE_PWR_CONSTRAINT = 8,
  1472. ACT_PUBLIC_VENDOR = 9, /* for WIFI_DIRECT */
  1473. ACT_PUBLIC_GAS_INITIAL_REQ = 10,
  1474. ACT_PUBLIC_GAS_INITIAL_RSP = 11,
  1475. ACT_PUBLIC_GAS_COMEBACK_REQ = 12,
  1476. ACT_PUBLIC_GAS_COMEBACK_RSP = 13,
  1477. ACT_PUBLIC_TDLS_DISCOVERY_RSP = 14,
  1478. ACT_PUBLIC_LOCATION_TRACK = 15,
  1479. ACT_PUBLIC_MAX
  1480. };
  1481. #ifdef CONFIG_TDLS
  1482. enum TDLS_ACTION_FIELD {
  1483. TDLS_SETUP_REQUEST = 0,
  1484. TDLS_SETUP_RESPONSE = 1,
  1485. TDLS_SETUP_CONFIRM = 2,
  1486. TDLS_TEARDOWN = 3,
  1487. TDLS_PEER_TRAFFIC_INDICATION = 4,
  1488. TDLS_CHANNEL_SWITCH_REQUEST = 5,
  1489. TDLS_CHANNEL_SWITCH_RESPONSE = 6,
  1490. TDLS_PEER_PSM_REQUEST = 7,
  1491. TDLS_PEER_PSM_RESPONSE = 8,
  1492. TDLS_PEER_TRAFFIC_RESPONSE = 9,
  1493. TDLS_DISCOVERY_REQUEST = 10,
  1494. TDLS_DISCOVERY_RESPONSE = 14, /* it's used in public action frame */
  1495. };
  1496. #define TUNNELED_PROBE_REQ 15
  1497. #define TUNNELED_PROBE_RSP 16
  1498. #endif /* CONFIG_TDLS */
  1499. /* BACK action code */
  1500. enum rtw_ieee80211_back_actioncode {
  1501. RTW_WLAN_ACTION_ADDBA_REQ = 0,
  1502. RTW_WLAN_ACTION_ADDBA_RESP = 1,
  1503. RTW_WLAN_ACTION_DELBA = 2,
  1504. };
  1505. /* HT features action code */
  1506. enum rtw_ieee80211_ht_actioncode {
  1507. RTW_WLAN_ACTION_HT_NOTI_CHNL_WIDTH = 0,
  1508. RTW_WLAN_ACTION_HT_SM_PS = 1,
  1509. RTW_WLAN_ACTION_HT_PSMP = 2,
  1510. RTW_WLAN_ACTION_HT_SET_PCO_PHASE = 3,
  1511. RTW_WLAN_ACTION_HT_CSI = 4,
  1512. RTW_WLAN_ACTION_HT_NON_COMPRESS_BEAMFORMING = 5,
  1513. RTW_WLAN_ACTION_HT_COMPRESS_BEAMFORMING = 6,
  1514. RTW_WLAN_ACTION_HT_ASEL_FEEDBACK = 7,
  1515. };
  1516. /* BACK (block-ack) parties */
  1517. enum rtw_ieee80211_back_parties {
  1518. RTW_WLAN_BACK_RECIPIENT = 0,
  1519. RTW_WLAN_BACK_INITIATOR = 1,
  1520. RTW_WLAN_BACK_TIMER = 2,
  1521. };
  1522. /*20/40 BSS Coexistence element */
  1523. #define RTW_WLAN_20_40_BSS_COEX_INFO_REQ BIT(0)
  1524. #define RTW_WLAN_20_40_BSS_COEX_40MHZ_INTOL BIT(1)
  1525. #define RTW_WLAN_20_40_BSS_COEX_20MHZ_WIDTH_REQ BIT(2)
  1526. #define RTW_WLAN_20_40_BSS_COEX_OBSS_EXEMPT_REQ BIT(3)
  1527. #define RTW_WLAN_20_40_BSS_COEX_OBSS_EXEMPT_GRNT BIT(4)
  1528. /* VHT features action code */
  1529. enum rtw_ieee80211_vht_actioncode {
  1530. RTW_WLAN_ACTION_VHT_COMPRESSED_BEAMFORMING = 0,
  1531. RTW_WLAN_ACTION_VHT_GROUPID_MANAGEMENT = 1,
  1532. RTW_WLAN_ACTION_VHT_OPMODE_NOTIFICATION = 2,
  1533. };
  1534. /*IEEE 802.11r action code*/
  1535. #ifdef CONFIG_RTW_80211R
  1536. enum rtw_ieee80211_ft_actioncode {
  1537. RTW_WLAN_ACTION_FT_RESV,
  1538. RTW_WLAN_ACTION_FT_REQ,
  1539. RTW_WLAN_ACTION_FT_RSP,
  1540. RTW_WLAN_ACTION_FT_CONF,
  1541. RTW_WLAN_ACTION_FT_ACK,
  1542. RTW_WLAN_ACTION_FT_MAX,
  1543. };
  1544. #endif
  1545. #ifdef CONFIG_RTW_WNM
  1546. enum rtw_ieee80211_wnm_actioncode {
  1547. RTW_WLAN_ACTION_WNM_BTM_QUERY = 6,
  1548. RTW_WLAN_ACTION_WNM_BTM_REQ = 7,
  1549. RTW_WLAN_ACTION_WNM_BTM_RSP = 8,
  1550. };
  1551. #endif
  1552. #define OUI_MICROSOFT 0x0050f2 /* Microsoft (also used in Wi-Fi specs)
  1553. * 00:50:F2 */
  1554. #ifndef PLATFORM_FREEBSD /* Baron BSD has defined */
  1555. #define WME_OUI_TYPE 2
  1556. #endif /* PLATFORM_FREEBSD */
  1557. #define WME_OUI_SUBTYPE_INFORMATION_ELEMENT 0
  1558. #define WME_OUI_SUBTYPE_PARAMETER_ELEMENT 1
  1559. #define WME_OUI_SUBTYPE_TSPEC_ELEMENT 2
  1560. #define WME_VERSION 1
  1561. #define WME_ACTION_CODE_SETUP_REQUEST 0
  1562. #define WME_ACTION_CODE_SETUP_RESPONSE 1
  1563. #define WME_ACTION_CODE_TEARDOWN 2
  1564. #define WME_SETUP_RESPONSE_STATUS_ADMISSION_ACCEPTED 0
  1565. #define WME_SETUP_RESPONSE_STATUS_INVALID_PARAMETERS 1
  1566. #define WME_SETUP_RESPONSE_STATUS_REFUSED 3
  1567. #define WME_TSPEC_DIRECTION_UPLINK 0
  1568. #define WME_TSPEC_DIRECTION_DOWNLINK 1
  1569. #define WME_TSPEC_DIRECTION_BI_DIRECTIONAL 3
  1570. #define OUI_BROADCOM 0x00904c /* Broadcom (Epigram) */
  1571. #define VENDOR_HT_CAPAB_OUI_TYPE 0x33 /* 00-90-4c:0x33 */
  1572. enum rtw_ieee80211_rann_flags {
  1573. RTW_RANN_FLAG_IS_GATE = 1 << 0,
  1574. };
  1575. /**
  1576. * enum rtw_ieee80211_preq_flags - mesh PREQ element flags
  1577. *
  1578. * @RTW_IEEE80211_PREQ_IS_GATE_FLAG: Gate Announcement subfield
  1579. * @RTW_IEEE80211_PREQ_PROACTIVE_PREP_FLAG: proactive PREP subfield
  1580. */
  1581. enum rtw_ieee80211_preq_flags {
  1582. RTW_IEEE80211_PREQ_IS_GATE_FLAG = 1 << 0,
  1583. RTW_IEEE80211_PREQ_PROACTIVE_PREP_FLAG = 1 << 2,
  1584. };
  1585. /**
  1586. * enum rtw_ieee80211_preq_target_flags - mesh PREQ element per target flags
  1587. *
  1588. * @RTW_IEEE80211_PREQ_TO_FLAG: target only subfield
  1589. * @RTW_IEEE80211_PREQ_USN_FLAG: unknown target HWMP sequence number subfield
  1590. */
  1591. enum rtw_ieee80211_preq_target_flags {
  1592. RTW_IEEE80211_PREQ_TO_FLAG = 1<<0,
  1593. RTW_IEEE80211_PREQ_USN_FLAG = 1<<2,
  1594. };
  1595. /**
  1596. * enum rtw_ieee80211_root_mode_identifier - root mesh STA mode identifier
  1597. *
  1598. * These attribute are used by dot11MeshHWMPRootMode to set root mesh STA mode
  1599. *
  1600. * @RTW_IEEE80211_ROOTMODE_NO_ROOT: the mesh STA is not a root mesh STA (default)
  1601. * @RTW_IEEE80211_ROOTMODE_ROOT: the mesh STA is a root mesh STA if greater than
  1602. * this value
  1603. * @RTW_IEEE80211_PROACTIVE_PREQ_NO_PREP: the mesh STA is a root mesh STA supports
  1604. * the proactive PREQ with proactive PREP subfield set to 0
  1605. * @RTW_IEEE80211_PROACTIVE_PREQ_WITH_PREP: the mesh STA is a root mesh STA
  1606. * supports the proactive PREQ with proactive PREP subfield set to 1
  1607. * @RTW_IEEE80211_PROACTIVE_RANN: the mesh STA is a root mesh STA supports
  1608. * the proactive RANN
  1609. */
  1610. enum rtw_ieee80211_root_mode_identifier {
  1611. RTW_IEEE80211_ROOTMODE_NO_ROOT = 0,
  1612. RTW_IEEE80211_ROOTMODE_ROOT = 1,
  1613. RTW_IEEE80211_PROACTIVE_PREQ_NO_PREP = 2,
  1614. RTW_IEEE80211_PROACTIVE_PREQ_WITH_PREP = 3,
  1615. RTW_IEEE80211_PROACTIVE_RANN = 4,
  1616. };
  1617. /**
  1618. * enum rtw_ieee80211_channel_flags - channel flags
  1619. *
  1620. * Channel flags set by the regulatory control code.
  1621. *
  1622. * @RTW_IEEE80211_CHAN_DISABLED: This channel is disabled.
  1623. * @RTW_IEEE80211_CHAN_PASSIVE_SCAN: Only passive scanning is permitted
  1624. * on this channel.
  1625. * @RTW_IEEE80211_CHAN_NO_IBSS: IBSS is not allowed on this channel.
  1626. * @RTW_IEEE80211_CHAN_RADAR: Radar detection is required on this channel.
  1627. * @RTW_IEEE80211_CHAN_NO_HT40PLUS: extension channel above this channel
  1628. * is not permitted.
  1629. * @RTW_IEEE80211_CHAN_NO_HT40MINUS: extension channel below this channel
  1630. * is not permitted.
  1631. */
  1632. enum rtw_ieee80211_channel_flags {
  1633. RTW_IEEE80211_CHAN_DISABLED = 1 << 0,
  1634. RTW_IEEE80211_CHAN_PASSIVE_SCAN = 1 << 1,
  1635. RTW_IEEE80211_CHAN_NO_IBSS = 1 << 2,
  1636. RTW_IEEE80211_CHAN_RADAR = 1 << 3,
  1637. RTW_IEEE80211_CHAN_NO_HT40PLUS = 1 << 4,
  1638. RTW_IEEE80211_CHAN_NO_HT40MINUS = 1 << 5,
  1639. };
  1640. #define RTW_IEEE80211_CHAN_NO_HT40 \
  1641. (RTW_IEEE80211_CHAN_NO_HT40PLUS | RTW_IEEE80211_CHAN_NO_HT40MINUS)
  1642. /* Represent channel details, subset of ieee80211_channel */
  1643. struct rtw_ieee80211_channel {
  1644. /* enum ieee80211_band band; */
  1645. /* u16 center_freq; */
  1646. u16 hw_value;
  1647. u32 flags;
  1648. /* int max_antenna_gain; */
  1649. /* int max_power; */
  1650. /* int max_reg_power; */
  1651. /* bool beacon_found; */
  1652. /* u32 orig_flags; */
  1653. /* int orig_mag; */
  1654. /* int orig_mpwr; */
  1655. };
  1656. #define CHAN_FMT \
  1657. /*"band:%d, "*/ \
  1658. /*"center_freq:%u, "*/ \
  1659. "hw_value:%u, " \
  1660. "flags:0x%08x" \
  1661. /*"max_antenna_gain:%d\n"*/ \
  1662. /*"max_power:%d\n"*/ \
  1663. /*"max_reg_power:%d\n"*/ \
  1664. /*"beacon_found:%u\n"*/ \
  1665. /*"orig_flags:0x%08x\n"*/ \
  1666. /*"orig_mag:%d\n"*/ \
  1667. /*"orig_mpwr:%d\n"*/
  1668. #define CHAN_ARG(channel) \
  1669. /*(channel)->band*/ \
  1670. /*, (channel)->center_freq*/ \
  1671. (channel)->hw_value \
  1672. , (channel)->flags \
  1673. /*, (channel)->max_antenna_gain*/ \
  1674. /*, (channel)->max_power*/ \
  1675. /*, (channel)->max_reg_power*/ \
  1676. /*, (channel)->beacon_found*/ \
  1677. /*, (channel)->orig_flags*/ \
  1678. /*, (channel)->orig_mag*/ \
  1679. /*, (channel)->orig_mpwr*/ \
  1680. /* Parsed Information Elements */
  1681. struct rtw_ieee802_11_elems {
  1682. u8 *ssid;
  1683. u8 ssid_len;
  1684. u8 *supp_rates;
  1685. u8 supp_rates_len;
  1686. u8 *fh_params;
  1687. u8 fh_params_len;
  1688. u8 *ds_params;
  1689. u8 ds_params_len;
  1690. u8 *cf_params;
  1691. u8 cf_params_len;
  1692. u8 *tim;
  1693. u8 tim_len;
  1694. u8 *ibss_params;
  1695. u8 ibss_params_len;
  1696. u8 *challenge;
  1697. u8 challenge_len;
  1698. u8 *erp_info;
  1699. u8 erp_info_len;
  1700. u8 *ext_supp_rates;
  1701. u8 ext_supp_rates_len;
  1702. u8 *wpa_ie;
  1703. u8 wpa_ie_len;
  1704. u8 *rsn_ie;
  1705. u8 rsn_ie_len;
  1706. u8 *wme;
  1707. u8 wme_len;
  1708. u8 *wme_tspec;
  1709. u8 wme_tspec_len;
  1710. u8 *wps_ie;
  1711. u8 wps_ie_len;
  1712. u8 *power_cap;
  1713. u8 power_cap_len;
  1714. u8 *supp_channels;
  1715. u8 supp_channels_len;
  1716. u8 *mdie;
  1717. u8 mdie_len;
  1718. u8 *ftie;
  1719. u8 ftie_len;
  1720. u8 *timeout_int;
  1721. u8 timeout_int_len;
  1722. u8 *ht_capabilities;
  1723. u8 ht_capabilities_len;
  1724. u8 *ht_operation;
  1725. u8 ht_operation_len;
  1726. u8 *vendor_ht_cap;
  1727. u8 vendor_ht_cap_len;
  1728. u8 *vht_capabilities;
  1729. u8 vht_capabilities_len;
  1730. u8 *vht_operation;
  1731. u8 vht_operation_len;
  1732. u8 *vht_op_mode_notify;
  1733. u8 vht_op_mode_notify_len;
  1734. u8 *rm_en_cap;
  1735. u8 rm_en_cap_len;
  1736. #ifdef CONFIG_RTW_MESH
  1737. u8 *preq;
  1738. u8 preq_len;
  1739. u8 *prep;
  1740. u8 prep_len;
  1741. u8 *perr;
  1742. u8 perr_len;
  1743. u8 *rann;
  1744. u8 rann_len;
  1745. #endif
  1746. };
  1747. typedef enum { ParseOK = 0, ParseUnknown = 1, ParseFailed = -1 } ParseRes;
  1748. ParseRes rtw_ieee802_11_parse_elems(u8 *start, uint len,
  1749. struct rtw_ieee802_11_elems *elems,
  1750. int show_errors);
  1751. u8 *rtw_set_fixed_ie(unsigned char *pbuf, unsigned int len, unsigned char *source, unsigned int *frlen);
  1752. u8 *rtw_set_ie(u8 *pbuf, sint index, uint len, const u8 *source, uint *frlen);
  1753. enum secondary_ch_offset {
  1754. SCN = 0, /* no secondary channel */
  1755. SCA = 1, /* secondary channel above */
  1756. SCB = 3, /* secondary channel below */
  1757. };
  1758. u8 secondary_ch_offset_to_hal_ch_offset(u8 ch_offset);
  1759. u8 hal_ch_offset_to_secondary_ch_offset(u8 ch_offset);
  1760. u8 *rtw_set_ie_ch_switch(u8 *buf, u32 *buf_len, u8 ch_switch_mode, u8 new_ch, u8 ch_switch_cnt);
  1761. u8 *rtw_set_ie_secondary_ch_offset(u8 *buf, u32 *buf_len, u8 secondary_ch_offset);
  1762. u8 *rtw_set_ie_mesh_ch_switch_parm(u8 *buf, u32 *buf_len, u8 ttl, u8 flags, u16 reason, u16 precedence);
  1763. u8 *rtw_get_ie(const u8 *pbuf, sint index, sint *len, sint limit);
  1764. int rtw_remove_ie_g_rate(u8 *ie, uint *ie_len, uint offset, u8 eid);
  1765. u8 *rtw_get_ie_ex(const u8 *in_ie, uint in_len, u8 eid, const u8 *oui, u8 oui_len, u8 *ie, uint *ielen);
  1766. int rtw_ies_remove_ie(u8 *ies, uint *ies_len, uint offset, u8 eid, u8 *oui, u8 oui_len);
  1767. void rtw_set_supported_rate(u8 *SupportedRates, uint mode) ;
  1768. #define GET_RSN_CAP_MFP_OPTION(cap) LE_BITS_TO_2BYTE(((u8 *)(cap)), 6, 2)
  1769. #define MFP_NO 0
  1770. #define MFP_INVALID 1
  1771. #define MFP_OPTIONAL 2
  1772. #define MFP_REQUIRED 3
  1773. struct rsne_info {
  1774. u8 *gcs;
  1775. u16 pcs_cnt;
  1776. u8 *pcs_list;
  1777. u16 akm_cnt;
  1778. u8 *akm_list;
  1779. u8 *cap;
  1780. u16 pmkid_cnt;
  1781. u8 *pmkid_list;
  1782. u8 *gmcs;
  1783. u8 err;
  1784. };
  1785. int rtw_rsne_info_parse(const u8 *ie, uint ie_len, struct rsne_info *info);
  1786. unsigned char *rtw_get_wpa_ie(unsigned char *pie, int *wpa_ie_len, int limit);
  1787. unsigned char *rtw_get_wpa2_ie(unsigned char *pie, int *rsn_ie_len, int limit);
  1788. int rtw_get_wpa_cipher_suite(u8 *s);
  1789. int rtw_get_wpa2_cipher_suite(u8 *s);
  1790. int rtw_get_wapi_ie(u8 *in_ie, uint in_len, u8 *wapi_ie, u16 *wapi_len);
  1791. int rtw_parse_wpa_ie(u8 *wpa_ie, int wpa_ie_len, int *group_cipher, int *pairwise_cipher, int *is_8021x);
  1792. int rtw_parse_wpa2_ie(u8 *wpa_ie, int wpa_ie_len, int *group_cipher, int *pairwise_cipher, int *is_8021x, u8 *mfp_opt);
  1793. int rtw_get_sec_ie(u8 *in_ie, uint in_len, u8 *rsn_ie, u16 *rsn_len, u8 *wpa_ie, u16 *wpa_len);
  1794. u8 rtw_is_wps_ie(u8 *ie_ptr, uint *wps_ielen);
  1795. u8 *rtw_get_wps_ie_from_scan_queue(u8 *in_ie, uint in_len, u8 *wps_ie, uint *wps_ielen, enum bss_type frame_type);
  1796. u8 *rtw_get_wps_ie(const u8 *in_ie, uint in_len, u8 *wps_ie, uint *wps_ielen);
  1797. u8 *rtw_get_wps_attr(u8 *wps_ie, uint wps_ielen, u16 target_attr_id , u8 *buf_attr, u32 *len_attr);
  1798. u8 *rtw_get_wps_attr_content(u8 *wps_ie, uint wps_ielen, u16 target_attr_id , u8 *buf_content, uint *len_content);
  1799. /**
  1800. * for_each_ie - iterate over continuous IEs
  1801. * @ie:
  1802. * @buf:
  1803. * @buf_len:
  1804. */
  1805. #define for_each_ie(ie, buf, buf_len) \
  1806. for (ie = (void *)buf; (((u8 *)ie) - ((u8 *)buf) + 1) < buf_len; ie = (void *)(((u8 *)ie) + *(((u8 *)ie)+1) + 2))
  1807. void dump_ies(void *sel, const u8 *buf, u32 buf_len);
  1808. #ifdef CONFIG_80211N_HT
  1809. #define HT_SC_OFFSET_MAX 4
  1810. extern const char *const _ht_sc_offset_str[];
  1811. #define ht_sc_offset_str(sc) (((sc) >= HT_SC_OFFSET_MAX) ? _ht_sc_offset_str[2] : _ht_sc_offset_str[(sc)])
  1812. void dump_ht_cap_ie_content(void *sel, const u8 *buf, u32 buf_len);
  1813. #endif
  1814. void dump_wps_ie(void *sel, const u8 *ie, u32 ie_len);
  1815. void rtw_ies_get_chbw(u8 *ies, int ies_len, u8 *ch, u8 *bw, u8 *offset, u8 ht, u8 vht);
  1816. void rtw_bss_get_chbw(WLAN_BSSID_EX *bss, u8 *ch, u8 *bw, u8 *offset, u8 ht, u8 vht);
  1817. bool rtw_is_chbw_grouped(u8 ch_a, u8 bw_a, u8 offset_a
  1818. , u8 ch_b, u8 bw_b, u8 offset_b);
  1819. void rtw_sync_chbw(u8 *req_ch, u8 *req_bw, u8 *req_offset
  1820. , u8 *g_ch, u8 *g_bw, u8 *g_offset);
  1821. u32 rtw_get_p2p_merged_ies_len(u8 *in_ie, u32 in_len);
  1822. int rtw_p2p_merge_ies(u8 *in_ie, u32 in_len, u8 *merge_ie);
  1823. void dump_p2p_ie(void *sel, const u8 *ie, u32 ie_len);
  1824. u8 *rtw_get_p2p_ie(const u8 *in_ie, int in_len, u8 *p2p_ie, uint *p2p_ielen);
  1825. u8 *rtw_get_p2p_attr(u8 *p2p_ie, uint p2p_ielen, u8 target_attr_id, u8 *buf_attr, u32 *len_attr);
  1826. u8 *rtw_get_p2p_attr_content(u8 *p2p_ie, uint p2p_ielen, u8 target_attr_id, u8 *buf_content, uint *len_content);
  1827. u32 rtw_set_p2p_attr_content(u8 *pbuf, u8 attr_id, u16 attr_len, u8 *pdata_attr);
  1828. uint rtw_del_p2p_ie(u8 *ies, uint ies_len_ori, const char *msg);
  1829. uint rtw_del_p2p_attr(u8 *ie, uint ielen_ori, u8 attr_id);
  1830. u8 *rtw_bss_ex_get_p2p_ie(WLAN_BSSID_EX *bss_ex, u8 *p2p_ie, uint *p2p_ielen);
  1831. void rtw_bss_ex_del_p2p_ie(WLAN_BSSID_EX *bss_ex);
  1832. void rtw_bss_ex_del_p2p_attr(WLAN_BSSID_EX *bss_ex, u8 attr_id);
  1833. void dump_wfd_ie(void *sel, const u8 *ie, u32 ie_len);
  1834. u8 *rtw_get_wfd_ie(const u8 *in_ie, int in_len, u8 *wfd_ie, uint *wfd_ielen);
  1835. u8 *rtw_get_wfd_attr(u8 *wfd_ie, uint wfd_ielen, u8 target_attr_id, u8 *buf_attr, u32 *len_attr);
  1836. u8 *rtw_get_wfd_attr_content(u8 *wfd_ie, uint wfd_ielen, u8 target_attr_id, u8 *buf_content, uint *len_content);
  1837. uint rtw_del_wfd_ie(u8 *ies, uint ies_len_ori, const char *msg);
  1838. uint rtw_del_wfd_attr(u8 *ie, uint ielen_ori, u8 attr_id);
  1839. u8 *rtw_bss_ex_get_wfd_ie(WLAN_BSSID_EX *bss_ex, u8 *wfd_ie, uint *wfd_ielen);
  1840. void rtw_bss_ex_del_wfd_ie(WLAN_BSSID_EX *bss_ex);
  1841. void rtw_bss_ex_del_wfd_attr(WLAN_BSSID_EX *bss_ex, u8 attr_id);
  1842. uint rtw_get_rateset_len(u8 *rateset);
  1843. struct registry_priv;
  1844. int rtw_generate_ie(struct registry_priv *pregistrypriv);
  1845. int rtw_get_bit_value_from_ieee_value(u8 val);
  1846. uint rtw_is_cckrates_included(u8 *rate);
  1847. uint rtw_is_cckratesonly_included(u8 *rate);
  1848. uint rtw_get_cckrate_size(u8 *rate,u32 rate_length);
  1849. int rtw_check_network_type(unsigned char *rate, int ratelen, int channel);
  1850. void rtw_get_bcn_info(struct wlan_network *pnetwork);
  1851. u8 rtw_check_invalid_mac_address(u8 *mac_addr, u8 check_local_bit);
  1852. void rtw_macaddr_cfg(u8 *out, const u8 *hw_mac_addr);
  1853. u16 rtw_mcs_rate(u8 rf_type, u8 bw_40MHz, u8 short_GI, unsigned char *MCS_rate);
  1854. u8 rtw_ht_mcsset_to_nss(u8 *supp_mcs_set);
  1855. u32 rtw_ht_mcs_set_to_bitmap(u8 *mcs_set, u8 nss);
  1856. int rtw_action_frame_parse(const u8 *frame, u32 frame_len, u8 *category, u8 *action);
  1857. const char *action_public_str(u8 action);
  1858. u8 key_2char2num(u8 hch, u8 lch);
  1859. u8 str_2char2num(u8 hch, u8 lch);
  1860. void macstr2num(u8 *dst, u8 *src);
  1861. u8 convert_ip_addr(u8 hch, u8 mch, u8 lch);
  1862. int wifirate2_ratetbl_inx(unsigned char rate);
  1863. #endif /* IEEE80211_H */