ieee80211.h 73 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451
  1. /*
  2. * Merged with mainline ieee80211.h in Aug 2004. Original ieee802_11
  3. * remains copyright by the original authors
  4. *
  5. * Portions of the merged code are based on Host AP (software wireless
  6. * LAN access point) driver for Intersil Prism2/2.5/3.
  7. *
  8. * Copyright (c) 2001-2002, SSH Communications Security Corp and Jouni Malinen
  9. * <jkmaline@cc.hut.fi>
  10. * Copyright (c) 2002-2003, Jouni Malinen <jkmaline@cc.hut.fi>
  11. *
  12. * Adaption to a generic IEEE 802.11 stack by James Ketrenos
  13. * <jketreno@linux.intel.com>
  14. * Copyright (c) 2004, Intel Corporation
  15. *
  16. * Modified for Realtek's wi-fi cards by Andrea Merello
  17. * <andrea.merello@gmail.com>
  18. *
  19. * This program is free software; you can redistribute it and/or modify
  20. * it under the terms of the GNU General Public License version 2 as
  21. * published by the Free Software Foundation. See README and COPYING for
  22. * more details.
  23. */
  24. #ifndef IEEE80211_H
  25. #define IEEE80211_H
  26. #include <linux/if_ether.h> /* ETH_ALEN */
  27. #include <linux/kernel.h>
  28. #include <linux/module.h>
  29. #include <linux/jiffies.h>
  30. #include <linux/timer.h>
  31. #include <linux/sched.h>
  32. #include <linux/semaphore.h>
  33. #include <linux/interrupt.h>
  34. #include <linux/delay.h>
  35. #include <linux/wireless.h>
  36. #include <linux/ieee80211.h>
  37. #include "rtl819x_HT.h"
  38. #include "rtl819x_BA.h"
  39. #include "rtl819x_TS.h"
  40. #ifndef IW_MODE_MONITOR
  41. #define IW_MODE_MONITOR 6
  42. #endif
  43. #ifndef IWEVCUSTOM
  44. #define IWEVCUSTOM 0x8c02
  45. #endif
  46. #define KEY_TYPE_NA 0x0
  47. #define KEY_TYPE_WEP40 0x1
  48. #define KEY_TYPE_TKIP 0x2
  49. #define KEY_TYPE_CCMP 0x4
  50. #define KEY_TYPE_WEP104 0x5
  51. /* added for rtl819x tx procedure */
  52. #define MAX_QUEUE_SIZE 0x10
  53. //
  54. // 8190 queue mapping
  55. //
  56. #define BK_QUEUE 0
  57. #define BE_QUEUE 1
  58. #define VI_QUEUE 2
  59. #define VO_QUEUE 3
  60. #define HCCA_QUEUE 4
  61. #define TXCMD_QUEUE 5
  62. #define MGNT_QUEUE 6
  63. #define HIGH_QUEUE 7
  64. #define BEACON_QUEUE 8
  65. #define LOW_QUEUE BE_QUEUE
  66. #define NORMAL_QUEUE MGNT_QUEUE
  67. //added by amy for ps
  68. #define SWRF_TIMEOUT 50
  69. //added by amy for LEAP related
  70. #define IE_CISCO_FLAG_POSITION 0x08 // Flag byte: byte 8, numbered from 0.
  71. #define SUPPORT_CKIP_MIC 0x08 // bit3
  72. #define SUPPORT_CKIP_PK 0x10 // bit4
  73. /* defined for skb cb field */
  74. /* At most 28 byte */
  75. typedef struct cb_desc {
  76. /* Tx Desc Related flags (8-9) */
  77. u8 bLastIniPkt:1;
  78. u8 bCmdOrInit:1;
  79. u8 bFirstSeg:1;
  80. u8 bLastSeg:1;
  81. u8 bEncrypt:1;
  82. u8 bTxDisableRateFallBack:1;
  83. u8 bTxUseDriverAssingedRate:1;
  84. u8 bHwSec:1; //indicate whether use Hw security. WB
  85. u8 reserved1;
  86. /* Tx Firmware Relaged flags (10-11)*/
  87. u8 bCTSEnable:1;
  88. u8 bRTSEnable:1;
  89. u8 bUseShortGI:1;
  90. u8 bUseShortPreamble:1;
  91. u8 bTxEnableFwCalcDur:1;
  92. u8 bAMPDUEnable:1;
  93. u8 bRTSSTBC:1;
  94. u8 RTSSC:1;
  95. u8 bRTSBW:1;
  96. u8 bPacketBW:1;
  97. u8 bRTSUseShortPreamble:1;
  98. u8 bRTSUseShortGI:1;
  99. u8 bMulticast:1;
  100. u8 bBroadcast:1;
  101. //u8 reserved2:2;
  102. u8 drv_agg_enable:1;
  103. u8 reserved2:1;
  104. /* Tx Desc related element(12-19) */
  105. u8 rata_index;
  106. u8 queue_index;
  107. //u8 reserved3;
  108. //u8 reserved4;
  109. u16 txbuf_size;
  110. //u8 reserved5;
  111. u8 RATRIndex;
  112. u8 reserved6;
  113. u8 reserved7;
  114. u8 reserved8;
  115. /* Tx firmware related element(20-27) */
  116. u8 data_rate;
  117. u8 rts_rate;
  118. u8 ampdu_factor;
  119. u8 ampdu_density;
  120. //u8 reserved9;
  121. //u8 reserved10;
  122. //u8 reserved11;
  123. u8 DrvAggrNum;
  124. u16 pkt_size;
  125. u8 reserved12;
  126. }cb_desc, *pcb_desc;
  127. /*--------------------------Define -------------------------------------------*/
  128. #define MGN_1M 0x02
  129. #define MGN_2M 0x04
  130. #define MGN_5_5M 0x0b
  131. #define MGN_11M 0x16
  132. #define MGN_6M 0x0c
  133. #define MGN_9M 0x12
  134. #define MGN_12M 0x18
  135. #define MGN_18M 0x24
  136. #define MGN_24M 0x30
  137. #define MGN_36M 0x48
  138. #define MGN_48M 0x60
  139. #define MGN_54M 0x6c
  140. #define MGN_MCS0 0x80
  141. #define MGN_MCS1 0x81
  142. #define MGN_MCS2 0x82
  143. #define MGN_MCS3 0x83
  144. #define MGN_MCS4 0x84
  145. #define MGN_MCS5 0x85
  146. #define MGN_MCS6 0x86
  147. #define MGN_MCS7 0x87
  148. #define MGN_MCS8 0x88
  149. #define MGN_MCS9 0x89
  150. #define MGN_MCS10 0x8a
  151. #define MGN_MCS11 0x8b
  152. #define MGN_MCS12 0x8c
  153. #define MGN_MCS13 0x8d
  154. #define MGN_MCS14 0x8e
  155. #define MGN_MCS15 0x8f
  156. #define aSifsTime ((priv->ieee80211->current_network.mode == IEEE_A || \
  157. priv->ieee80211->current_network.mode == IEEE_N_24G || \
  158. priv->ieee80211->current_network.mode == IEEE_N_5G) ? \
  159. 16 : 10)
  160. #define MGMT_QUEUE_NUM 5
  161. #define IEEE_CMD_SET_WPA_PARAM 1
  162. #define IEEE_CMD_SET_WPA_IE 2
  163. #define IEEE_CMD_SET_ENCRYPTION 3
  164. #define IEEE_CMD_MLME 4
  165. #define IEEE_PARAM_WPA_ENABLED 1
  166. #define IEEE_PARAM_TKIP_COUNTERMEASURES 2
  167. #define IEEE_PARAM_DROP_UNENCRYPTED 3
  168. #define IEEE_PARAM_PRIVACY_INVOKED 4
  169. #define IEEE_PARAM_AUTH_ALGS 5
  170. #define IEEE_PARAM_IEEE_802_1X 6
  171. //It should consistent with the driver_XXX.c
  172. // David, 2006.9.26
  173. #define IEEE_PARAM_WPAX_SELECT 7
  174. //Added for notify the encryption type selection
  175. // David, 2006.9.26
  176. #define IEEE_PROTO_WPA 1
  177. #define IEEE_PROTO_RSN 2
  178. //Added for notify the encryption type selection
  179. // David, 2006.9.26
  180. #define IEEE_WPAX_USEGROUP 0
  181. #define IEEE_WPAX_WEP40 1
  182. #define IEEE_WPAX_TKIP 2
  183. #define IEEE_WPAX_WRAP 3
  184. #define IEEE_WPAX_CCMP 4
  185. #define IEEE_WPAX_WEP104 5
  186. #define IEEE_KEY_MGMT_IEEE8021X 1
  187. #define IEEE_KEY_MGMT_PSK 2
  188. #define IEEE_MLME_STA_DEAUTH 1
  189. #define IEEE_MLME_STA_DISASSOC 2
  190. #define IEEE_CRYPT_ERR_UNKNOWN_ALG 2
  191. #define IEEE_CRYPT_ERR_UNKNOWN_ADDR 3
  192. #define IEEE_CRYPT_ERR_CRYPT_INIT_FAILED 4
  193. #define IEEE_CRYPT_ERR_KEY_SET_FAILED 5
  194. #define IEEE_CRYPT_ERR_TX_KEY_SET_FAILED 6
  195. #define IEEE_CRYPT_ERR_CARD_CONF_FAILED 7
  196. #define IEEE_CRYPT_ALG_NAME_LEN 16
  197. #define MAX_IE_LEN 0xff
  198. // added for kernel conflict
  199. #define ieee80211_crypt_deinit_entries ieee80211_crypt_deinit_entries_rsl
  200. #define ieee80211_crypt_deinit_handler ieee80211_crypt_deinit_handler_rsl
  201. #define ieee80211_crypt_delayed_deinit ieee80211_crypt_delayed_deinit_rsl
  202. #define ieee80211_register_crypto_ops ieee80211_register_crypto_ops_rsl
  203. #define ieee80211_unregister_crypto_ops ieee80211_unregister_crypto_ops_rsl
  204. #define ieee80211_get_crypto_ops ieee80211_get_crypto_ops_rsl
  205. #define ieee80211_ccmp_null ieee80211_ccmp_null_rsl
  206. #define ieee80211_tkip_null ieee80211_tkip_null_rsl
  207. #define ieee80211_wep_null ieee80211_wep_null_rsl
  208. #define free_ieee80211 free_ieee80211_rsl
  209. #define alloc_ieee80211 alloc_ieee80211_rsl
  210. #define ieee80211_rx ieee80211_rx_rsl
  211. #define ieee80211_rx_mgt ieee80211_rx_mgt_rsl
  212. #define ieee80211_get_beacon ieee80211_get_beacon_rsl
  213. #define ieee80211_wake_queue ieee80211_wake_queue_rsl
  214. #define ieee80211_stop_queue ieee80211_stop_queue_rsl
  215. #define ieee80211_reset_queue ieee80211_reset_queue_rsl
  216. #define ieee80211_softmac_stop_protocol ieee80211_softmac_stop_protocol_rsl
  217. #define ieee80211_softmac_start_protocol ieee80211_softmac_start_protocol_rsl
  218. #define ieee80211_is_shortslot ieee80211_is_shortslot_rsl
  219. #define ieee80211_is_54g ieee80211_is_54g_rsl
  220. #define ieee80211_wpa_supplicant_ioctl ieee80211_wpa_supplicant_ioctl_rsl
  221. #define ieee80211_ps_tx_ack ieee80211_ps_tx_ack_rsl
  222. #define ieee80211_softmac_xmit ieee80211_softmac_xmit_rsl
  223. #define ieee80211_stop_send_beacons ieee80211_stop_send_beacons_rsl
  224. #define notify_wx_assoc_event notify_wx_assoc_event_rsl
  225. #define SendDisassociation SendDisassociation_rsl
  226. #define ieee80211_disassociate ieee80211_disassociate_rsl
  227. #define ieee80211_start_send_beacons ieee80211_start_send_beacons_rsl
  228. #define ieee80211_stop_scan ieee80211_stop_scan_rsl
  229. #define ieee80211_send_probe_requests ieee80211_send_probe_requests_rsl
  230. #define ieee80211_softmac_scan_syncro ieee80211_softmac_scan_syncro_rsl
  231. #define ieee80211_start_scan_syncro ieee80211_start_scan_syncro_rsl
  232. #define ieee80211_wx_get_essid ieee80211_wx_get_essid_rsl
  233. #define ieee80211_wx_set_essid ieee80211_wx_set_essid_rsl
  234. #define ieee80211_wx_set_rate ieee80211_wx_set_rate_rsl
  235. #define ieee80211_wx_get_rate ieee80211_wx_get_rate_rsl
  236. #define ieee80211_wx_set_wap ieee80211_wx_set_wap_rsl
  237. #define ieee80211_wx_get_wap ieee80211_wx_get_wap_rsl
  238. #define ieee80211_wx_set_mode ieee80211_wx_set_mode_rsl
  239. #define ieee80211_wx_get_mode ieee80211_wx_get_mode_rsl
  240. #define ieee80211_wx_set_scan ieee80211_wx_set_scan_rsl
  241. #define ieee80211_wx_get_freq ieee80211_wx_get_freq_rsl
  242. #define ieee80211_wx_set_freq ieee80211_wx_set_freq_rsl
  243. #define ieee80211_wx_set_rawtx ieee80211_wx_set_rawtx_rsl
  244. #define ieee80211_wx_get_name ieee80211_wx_get_name_rsl
  245. #define ieee80211_wx_set_power ieee80211_wx_set_power_rsl
  246. #define ieee80211_wx_get_power ieee80211_wx_get_power_rsl
  247. #define ieee80211_wlan_frequencies ieee80211_wlan_frequencies_rsl
  248. #define ieee80211_wx_set_rts ieee80211_wx_set_rts_rsl
  249. #define ieee80211_wx_get_rts ieee80211_wx_get_rts_rsl
  250. #define ieee80211_txb_free ieee80211_txb_free_rsl
  251. #define ieee80211_wx_set_gen_ie ieee80211_wx_set_gen_ie_rsl
  252. #define ieee80211_wx_get_scan ieee80211_wx_get_scan_rsl
  253. #define ieee80211_wx_set_encode ieee80211_wx_set_encode_rsl
  254. #define ieee80211_wx_get_encode ieee80211_wx_get_encode_rsl
  255. #define ieee80211_wx_set_mlme ieee80211_wx_set_mlme_rsl
  256. #define ieee80211_wx_set_auth ieee80211_wx_set_auth_rsl
  257. #define ieee80211_wx_set_encode_ext ieee80211_wx_set_encode_ext_rsl
  258. #define ieee80211_wx_get_encode_ext ieee80211_wx_get_encode_ext_rsl
  259. typedef struct ieee_param {
  260. u32 cmd;
  261. u8 sta_addr[ETH_ALEN];
  262. union {
  263. struct {
  264. u8 name;
  265. u32 value;
  266. } wpa_param;
  267. struct {
  268. u32 len;
  269. u8 reserved[32];
  270. u8 data[0];
  271. } wpa_ie;
  272. struct{
  273. int command;
  274. int reason_code;
  275. } mlme;
  276. struct {
  277. u8 alg[IEEE_CRYPT_ALG_NAME_LEN];
  278. u8 set_tx;
  279. u32 err;
  280. u8 idx;
  281. u8 seq[8]; /* sequence counter (set: RX, get: TX) */
  282. u16 key_len;
  283. u8 key[0];
  284. } crypt;
  285. } u;
  286. }ieee_param;
  287. // linux under 2.6.9 release may not support it, so modify it for common use
  288. #define MSECS(t) msecs_to_jiffies(t)
  289. #define msleep_interruptible_rsl msleep_interruptible
  290. #define IEEE80211_DATA_LEN 2304
  291. /* Maximum size for the MA-UNITDATA primitive, 802.11 standard section
  292. 6.2.1.1.2.
  293. The figure in section 7.1.2 suggests a body size of up to 2312
  294. bytes is allowed, which is a bit confusing, I suspect this
  295. represents the 2304 bytes of real data, plus a possible 8 bytes of
  296. WEP IV and ICV. (this interpretation suggested by Ramiro Barreiro) */
  297. #define IEEE80211_1ADDR_LEN 10
  298. #define IEEE80211_2ADDR_LEN 16
  299. #define IEEE80211_3ADDR_LEN 24
  300. #define IEEE80211_4ADDR_LEN 30
  301. #define IEEE80211_FCS_LEN 4
  302. #define IEEE80211_HLEN (IEEE80211_4ADDR_LEN)
  303. #define IEEE80211_FRAME_LEN (IEEE80211_DATA_LEN + IEEE80211_HLEN)
  304. #define IEEE80211_MGMT_HDR_LEN 24
  305. #define IEEE80211_DATA_HDR3_LEN 24
  306. #define IEEE80211_DATA_HDR4_LEN 30
  307. #define MIN_FRAG_THRESHOLD 256U
  308. #define MAX_FRAG_THRESHOLD 2346U
  309. /* Frame control field constants */
  310. #define IEEE80211_FCTL_VERS 0x0003
  311. #define IEEE80211_FCTL_FTYPE 0x000c
  312. #define IEEE80211_FCTL_STYPE 0x00f0
  313. #define IEEE80211_FCTL_FRAMETYPE 0x00fc
  314. #define IEEE80211_FCTL_TODS 0x0100
  315. #define IEEE80211_FCTL_FROMDS 0x0200
  316. #define IEEE80211_FCTL_DSTODS 0x0300 //added by david
  317. #define IEEE80211_FCTL_MOREFRAGS 0x0400
  318. #define IEEE80211_FCTL_RETRY 0x0800
  319. #define IEEE80211_FCTL_PM 0x1000
  320. #define IEEE80211_FCTL_MOREDATA 0x2000
  321. #define IEEE80211_FCTL_WEP 0x4000
  322. #define IEEE80211_FCTL_ORDER 0x8000
  323. #define IEEE80211_FTYPE_MGMT 0x0000
  324. #define IEEE80211_FTYPE_CTL 0x0004
  325. #define IEEE80211_FTYPE_DATA 0x0008
  326. /* management */
  327. #define IEEE80211_STYPE_ASSOC_REQ 0x0000
  328. #define IEEE80211_STYPE_ASSOC_RESP 0x0010
  329. #define IEEE80211_STYPE_REASSOC_REQ 0x0020
  330. #define IEEE80211_STYPE_REASSOC_RESP 0x0030
  331. #define IEEE80211_STYPE_PROBE_REQ 0x0040
  332. #define IEEE80211_STYPE_PROBE_RESP 0x0050
  333. #define IEEE80211_STYPE_BEACON 0x0080
  334. #define IEEE80211_STYPE_ATIM 0x0090
  335. #define IEEE80211_STYPE_DISASSOC 0x00A0
  336. #define IEEE80211_STYPE_AUTH 0x00B0
  337. #define IEEE80211_STYPE_DEAUTH 0x00C0
  338. #define IEEE80211_STYPE_MANAGE_ACT 0x00D0
  339. /* control */
  340. #define IEEE80211_STYPE_PSPOLL 0x00A0
  341. #define IEEE80211_STYPE_RTS 0x00B0
  342. #define IEEE80211_STYPE_CTS 0x00C0
  343. #define IEEE80211_STYPE_ACK 0x00D0
  344. #define IEEE80211_STYPE_CFEND 0x00E0
  345. #define IEEE80211_STYPE_CFENDACK 0x00F0
  346. #define IEEE80211_STYPE_BLOCKACK 0x0094
  347. /* data */
  348. #define IEEE80211_STYPE_DATA 0x0000
  349. #define IEEE80211_STYPE_DATA_CFACK 0x0010
  350. #define IEEE80211_STYPE_DATA_CFPOLL 0x0020
  351. #define IEEE80211_STYPE_DATA_CFACKPOLL 0x0030
  352. #define IEEE80211_STYPE_NULLFUNC 0x0040
  353. #define IEEE80211_STYPE_CFACK 0x0050
  354. #define IEEE80211_STYPE_CFPOLL 0x0060
  355. #define IEEE80211_STYPE_CFACKPOLL 0x0070
  356. #define IEEE80211_STYPE_QOS_DATA 0x0080 //added for WMM 2006/8/2
  357. #define IEEE80211_STYPE_QOS_NULL 0x00C0
  358. #define IEEE80211_SCTL_FRAG 0x000F
  359. #define IEEE80211_SCTL_SEQ 0xFFF0
  360. /* QOS control */
  361. #define IEEE80211_QCTL_TID 0x000F
  362. #define FC_QOS_BIT BIT(7)
  363. #define IsDataFrame(pdu) ( ((pdu[0] & 0x0C)==0x08) ? true : false )
  364. #define IsLegacyDataFrame(pdu) (IsDataFrame(pdu) && (!(pdu[0]&FC_QOS_BIT)) )
  365. //added by wb. Is this right?
  366. #define IsQoSDataFrame(pframe) ((*(u16 *)pframe&(IEEE80211_STYPE_QOS_DATA|IEEE80211_FTYPE_DATA)) == (IEEE80211_STYPE_QOS_DATA|IEEE80211_FTYPE_DATA))
  367. #define Frame_Order(pframe) (*(u16 *)pframe&IEEE80211_FCTL_ORDER)
  368. #define SN_LESS(a, b) (((a-b)&0x800)!=0)
  369. #define SN_EQUAL(a, b) (a == b)
  370. #define MAX_DEV_ADDR_SIZE 8
  371. typedef enum _ACT_CATEGORY{
  372. ACT_CAT_QOS = 1,
  373. ACT_CAT_DLS = 2,
  374. ACT_CAT_BA = 3,
  375. ACT_CAT_HT = 7,
  376. ACT_CAT_WMM = 17,
  377. } ACT_CATEGORY, *PACT_CATEGORY;
  378. typedef enum _TS_ACTION{
  379. ACT_ADDTSREQ = 0,
  380. ACT_ADDTSRSP = 1,
  381. ACT_DELTS = 2,
  382. ACT_SCHEDULE = 3,
  383. } TS_ACTION, *PTS_ACTION;
  384. typedef enum _BA_ACTION{
  385. ACT_ADDBAREQ = 0,
  386. ACT_ADDBARSP = 1,
  387. ACT_DELBA = 2,
  388. } BA_ACTION, *PBA_ACTION;
  389. typedef enum _InitialGainOpType{
  390. IG_Backup=0,
  391. IG_Restore,
  392. IG_Max
  393. }InitialGainOpType;
  394. /* debug macros */
  395. #define CONFIG_IEEE80211_DEBUG
  396. #ifdef CONFIG_IEEE80211_DEBUG
  397. extern u32 ieee80211_debug_level;
  398. #define IEEE80211_DEBUG(level, fmt, args...) \
  399. do { if (ieee80211_debug_level & (level)) \
  400. printk(KERN_DEBUG "ieee80211: " fmt, ## args); } while (0)
  401. //wb added to debug out data buf
  402. //if you want print DATA buffer related BA, please set ieee80211_debug_level to DATA|BA
  403. #define IEEE80211_DEBUG_DATA(level, data, datalen) \
  404. do{ if ((ieee80211_debug_level & (level)) == (level)) \
  405. { \
  406. int i; \
  407. u8 *pdata = (u8 *) data; \
  408. printk(KERN_DEBUG "ieee80211: %s()\n", __func__); \
  409. for(i=0; i<(int)(datalen); i++) \
  410. { \
  411. printk("%2x ", pdata[i]); \
  412. if ((i+1)%16 == 0) printk("\n"); \
  413. } \
  414. printk("\n"); \
  415. } \
  416. } while (0)
  417. #else
  418. #define IEEE80211_DEBUG(level, fmt, args...) do {} while (0)
  419. #define IEEE80211_DEBUG_DATA(level, data, datalen) do {} while(0)
  420. #endif /* CONFIG_IEEE80211_DEBUG */
  421. /* debug macros not dependent on CONFIG_IEEE80211_DEBUG */
  422. /*
  423. * To use the debug system;
  424. *
  425. * If you are defining a new debug classification, simply add it to the #define
  426. * list here in the form of:
  427. *
  428. * #define IEEE80211_DL_xxxx VALUE
  429. *
  430. * shifting value to the left one bit from the previous entry. xxxx should be
  431. * the name of the classification (for example, WEP)
  432. *
  433. * You then need to either add a IEEE80211_xxxx_DEBUG() macro definition for your
  434. * classification, or use IEEE80211_DEBUG(IEEE80211_DL_xxxx, ...) whenever you want
  435. * to send output to that classification.
  436. *
  437. * To add your debug level to the list of levels seen when you perform
  438. *
  439. * % cat /proc/net/ipw/debug_level
  440. *
  441. * you simply need to add your entry to the ipw_debug_levels array.
  442. *
  443. * If you do not see debug_level in /proc/net/ipw then you do not have
  444. * CONFIG_IEEE80211_DEBUG defined in your kernel configuration
  445. *
  446. */
  447. #define IEEE80211_DL_INFO (1<<0)
  448. #define IEEE80211_DL_WX (1<<1)
  449. #define IEEE80211_DL_SCAN (1<<2)
  450. #define IEEE80211_DL_STATE (1<<3)
  451. #define IEEE80211_DL_MGMT (1<<4)
  452. #define IEEE80211_DL_FRAG (1<<5)
  453. #define IEEE80211_DL_EAP (1<<6)
  454. #define IEEE80211_DL_DROP (1<<7)
  455. #define IEEE80211_DL_TX (1<<8)
  456. #define IEEE80211_DL_RX (1<<9)
  457. #define IEEE80211_DL_HT (1<<10) //HT
  458. #define IEEE80211_DL_BA (1<<11) //ba
  459. #define IEEE80211_DL_TS (1<<12) //TS
  460. #define IEEE80211_DL_QOS (1<<13)
  461. #define IEEE80211_DL_REORDER (1<<14)
  462. #define IEEE80211_DL_IOT (1<<15)
  463. #define IEEE80211_DL_IPS (1<<16)
  464. #define IEEE80211_DL_TRACE (1<<29) //trace function, need to user net_ratelimit() together in order not to print too much to the screen
  465. #define IEEE80211_DL_DATA (1<<30) //use this flag to control whether print data buf out.
  466. #define IEEE80211_DL_ERR (1<<31) //always open
  467. #define IEEE80211_ERROR(f, a...) printk(KERN_ERR "ieee80211: " f, ## a)
  468. #define IEEE80211_WARNING(f, a...) printk(KERN_WARNING "ieee80211: " f, ## a)
  469. #define IEEE80211_DEBUG_INFO(f, a...) IEEE80211_DEBUG(IEEE80211_DL_INFO, f, ## a)
  470. #define IEEE80211_DEBUG_WX(f, a...) IEEE80211_DEBUG(IEEE80211_DL_WX, f, ## a)
  471. #define IEEE80211_DEBUG_SCAN(f, a...) IEEE80211_DEBUG(IEEE80211_DL_SCAN, f, ## a)
  472. #define IEEE80211_DEBUG_STATE(f, a...) IEEE80211_DEBUG(IEEE80211_DL_STATE, f, ## a)
  473. #define IEEE80211_DEBUG_MGMT(f, a...) IEEE80211_DEBUG(IEEE80211_DL_MGMT, f, ## a)
  474. #define IEEE80211_DEBUG_FRAG(f, a...) IEEE80211_DEBUG(IEEE80211_DL_FRAG, f, ## a)
  475. #define IEEE80211_DEBUG_EAP(f, a...) IEEE80211_DEBUG(IEEE80211_DL_EAP, f, ## a)
  476. #define IEEE80211_DEBUG_DROP(f, a...) IEEE80211_DEBUG(IEEE80211_DL_DROP, f, ## a)
  477. #define IEEE80211_DEBUG_TX(f, a...) IEEE80211_DEBUG(IEEE80211_DL_TX, f, ## a)
  478. #define IEEE80211_DEBUG_RX(f, a...) IEEE80211_DEBUG(IEEE80211_DL_RX, f, ## a)
  479. #define IEEE80211_DEBUG_QOS(f, a...) IEEE80211_DEBUG(IEEE80211_DL_QOS, f, ## a)
  480. #include <linux/if_arp.h> /* ARPHRD_ETHER */
  481. #ifndef WIRELESS_SPY
  482. #define WIRELESS_SPY // enable iwspy support
  483. #endif
  484. #include <net/iw_handler.h> // new driver API
  485. #ifndef ETH_P_PAE
  486. #define ETH_P_PAE 0x888E /* Port Access Entity (IEEE 802.1X) */
  487. #endif /* ETH_P_PAE */
  488. #define ETH_P_PREAUTH 0x88C7 /* IEEE 802.11i pre-authentication */
  489. #ifndef ETH_P_80211_RAW
  490. #define ETH_P_80211_RAW (ETH_P_ECONET + 1)
  491. #endif
  492. /* IEEE 802.11 defines */
  493. #define P80211_OUI_LEN 3
  494. struct ieee80211_snap_hdr {
  495. u8 dsap; /* always 0xAA */
  496. u8 ssap; /* always 0xAA */
  497. u8 ctrl; /* always 0x03 */
  498. u8 oui[P80211_OUI_LEN]; /* organizational universal id */
  499. } __packed;
  500. #define SNAP_SIZE sizeof(struct ieee80211_snap_hdr)
  501. #define WLAN_FC_GET_VERS(fc) ((fc) & IEEE80211_FCTL_VERS)
  502. #define WLAN_FC_GET_TYPE(fc) ((fc) & IEEE80211_FCTL_FTYPE)
  503. #define WLAN_FC_GET_STYPE(fc) ((fc) & IEEE80211_FCTL_STYPE)
  504. #define WLAN_FC_GET_FRAMETYPE(fc) ((fc) & IEEE80211_FCTL_FRAMETYPE)
  505. #define WLAN_GET_SEQ_FRAG(seq) ((seq) & IEEE80211_SCTL_FRAG)
  506. #define WLAN_GET_SEQ_SEQ(seq) (((seq) & IEEE80211_SCTL_SEQ) >> 4)
  507. #define WLAN_CAPABILITY_BSS (1<<0)
  508. #define WLAN_CAPABILITY_IBSS (1<<1)
  509. #define WLAN_CAPABILITY_CF_POLLABLE (1<<2)
  510. #define WLAN_CAPABILITY_CF_POLL_REQUEST (1<<3)
  511. #define WLAN_CAPABILITY_PRIVACY (1<<4)
  512. #define WLAN_CAPABILITY_SHORT_PREAMBLE (1<<5)
  513. #define WLAN_CAPABILITY_PBCC (1<<6)
  514. #define WLAN_CAPABILITY_CHANNEL_AGILITY (1<<7)
  515. #define WLAN_CAPABILITY_SPECTRUM_MGMT (1<<8)
  516. #define WLAN_CAPABILITY_QOS (1<<9)
  517. #define WLAN_CAPABILITY_SHORT_SLOT (1<<10)
  518. #define WLAN_CAPABILITY_DSSS_OFDM (1<<13)
  519. /* 802.11g ERP information element */
  520. #define WLAN_ERP_NON_ERP_PRESENT (1<<0)
  521. #define WLAN_ERP_USE_PROTECTION (1<<1)
  522. #define WLAN_ERP_BARKER_PREAMBLE (1<<2)
  523. #define IEEE80211_STATMASK_SIGNAL (1<<0)
  524. #define IEEE80211_STATMASK_RSSI (1<<1)
  525. #define IEEE80211_STATMASK_NOISE (1<<2)
  526. #define IEEE80211_STATMASK_RATE (1<<3)
  527. #define IEEE80211_STATMASK_WEMASK 0x7
  528. #define IEEE80211_CCK_MODULATION (1<<0)
  529. #define IEEE80211_OFDM_MODULATION (1<<1)
  530. #define IEEE80211_24GHZ_BAND (1<<0)
  531. #define IEEE80211_52GHZ_BAND (1<<1)
  532. #define IEEE80211_CCK_RATE_LEN 4
  533. #define IEEE80211_CCK_RATE_1MB 0x02
  534. #define IEEE80211_CCK_RATE_2MB 0x04
  535. #define IEEE80211_CCK_RATE_5MB 0x0B
  536. #define IEEE80211_CCK_RATE_11MB 0x16
  537. #define IEEE80211_OFDM_RATE_LEN 8
  538. #define IEEE80211_OFDM_RATE_6MB 0x0C
  539. #define IEEE80211_OFDM_RATE_9MB 0x12
  540. #define IEEE80211_OFDM_RATE_12MB 0x18
  541. #define IEEE80211_OFDM_RATE_18MB 0x24
  542. #define IEEE80211_OFDM_RATE_24MB 0x30
  543. #define IEEE80211_OFDM_RATE_36MB 0x48
  544. #define IEEE80211_OFDM_RATE_48MB 0x60
  545. #define IEEE80211_OFDM_RATE_54MB 0x6C
  546. #define IEEE80211_BASIC_RATE_MASK 0x80
  547. #define IEEE80211_CCK_RATE_1MB_MASK (1<<0)
  548. #define IEEE80211_CCK_RATE_2MB_MASK (1<<1)
  549. #define IEEE80211_CCK_RATE_5MB_MASK (1<<2)
  550. #define IEEE80211_CCK_RATE_11MB_MASK (1<<3)
  551. #define IEEE80211_OFDM_RATE_6MB_MASK (1<<4)
  552. #define IEEE80211_OFDM_RATE_9MB_MASK (1<<5)
  553. #define IEEE80211_OFDM_RATE_12MB_MASK (1<<6)
  554. #define IEEE80211_OFDM_RATE_18MB_MASK (1<<7)
  555. #define IEEE80211_OFDM_RATE_24MB_MASK (1<<8)
  556. #define IEEE80211_OFDM_RATE_36MB_MASK (1<<9)
  557. #define IEEE80211_OFDM_RATE_48MB_MASK (1<<10)
  558. #define IEEE80211_OFDM_RATE_54MB_MASK (1<<11)
  559. #define IEEE80211_CCK_RATES_MASK 0x0000000F
  560. #define IEEE80211_CCK_BASIC_RATES_MASK (IEEE80211_CCK_RATE_1MB_MASK | \
  561. IEEE80211_CCK_RATE_2MB_MASK)
  562. #define IEEE80211_CCK_DEFAULT_RATES_MASK (IEEE80211_CCK_BASIC_RATES_MASK | \
  563. IEEE80211_CCK_RATE_5MB_MASK | \
  564. IEEE80211_CCK_RATE_11MB_MASK)
  565. #define IEEE80211_OFDM_RATES_MASK 0x00000FF0
  566. #define IEEE80211_OFDM_BASIC_RATES_MASK (IEEE80211_OFDM_RATE_6MB_MASK | \
  567. IEEE80211_OFDM_RATE_12MB_MASK | \
  568. IEEE80211_OFDM_RATE_24MB_MASK)
  569. #define IEEE80211_OFDM_DEFAULT_RATES_MASK (IEEE80211_OFDM_BASIC_RATES_MASK | \
  570. IEEE80211_OFDM_RATE_9MB_MASK | \
  571. IEEE80211_OFDM_RATE_18MB_MASK | \
  572. IEEE80211_OFDM_RATE_36MB_MASK | \
  573. IEEE80211_OFDM_RATE_48MB_MASK | \
  574. IEEE80211_OFDM_RATE_54MB_MASK)
  575. #define IEEE80211_DEFAULT_RATES_MASK (IEEE80211_OFDM_DEFAULT_RATES_MASK | \
  576. IEEE80211_CCK_DEFAULT_RATES_MASK)
  577. #define IEEE80211_NUM_OFDM_RATES 8
  578. #define IEEE80211_NUM_CCK_RATES 4
  579. #define IEEE80211_OFDM_SHIFT_MASK_A 4
  580. /* this is stolen and modified from the madwifi driver*/
  581. #define IEEE80211_FC0_TYPE_MASK 0x0c
  582. #define IEEE80211_FC0_TYPE_DATA 0x08
  583. #define IEEE80211_FC0_SUBTYPE_MASK 0xB0
  584. #define IEEE80211_FC0_SUBTYPE_QOS 0x80
  585. #define IEEE80211_QOS_HAS_SEQ(fc) \
  586. (((fc) & (IEEE80211_FC0_TYPE_MASK | IEEE80211_FC0_SUBTYPE_MASK)) == \
  587. (IEEE80211_FC0_TYPE_DATA | IEEE80211_FC0_SUBTYPE_QOS))
  588. /* this is stolen from ipw2200 driver */
  589. #define IEEE_IBSS_MAC_HASH_SIZE 31
  590. struct ieee_ibss_seq {
  591. u8 mac[ETH_ALEN];
  592. u16 seq_num[17];
  593. u16 frag_num[17];
  594. unsigned long packet_time[17];
  595. struct list_head list;
  596. };
  597. /* NOTE: This data is for statistical purposes; not all hardware provides this
  598. * information for frames received. Not setting these will not cause
  599. * any adverse affects. */
  600. struct ieee80211_rx_stats {
  601. u32 mac_time[2];
  602. s8 rssi;
  603. u8 signal;
  604. u8 noise;
  605. u16 rate; /* in 100 kbps */
  606. u8 received_channel;
  607. u8 control;
  608. u8 mask;
  609. u8 freq;
  610. u16 len;
  611. u64 tsf;
  612. u32 beacon_time;
  613. u8 nic_type;
  614. u16 Length;
  615. // u8 DataRate; // In 0.5 Mbps
  616. u8 SignalQuality; // in 0-100 index.
  617. s32 RecvSignalPower; // Real power in dBm for this packet, no beautification and aggregation.
  618. s8 RxPower; // in dBm Translate from PWdB
  619. u8 SignalStrength; // in 0-100 index.
  620. u16 bHwError:1;
  621. u16 bCRC:1;
  622. u16 bICV:1;
  623. u16 bShortPreamble:1;
  624. u16 Antenna:1; //for rtl8185
  625. u16 Decrypted:1; //for rtl8185, rtl8187
  626. u16 Wakeup:1; //for rtl8185
  627. u16 Reserved0:1; //for rtl8185
  628. u8 AGC;
  629. u32 TimeStampLow;
  630. u32 TimeStampHigh;
  631. bool bShift;
  632. bool bIsQosData; // Added by Annie, 2005-12-22.
  633. u8 UserPriority;
  634. //1!!!!!!!!!!!!!!!!!!!!!!!!!!!
  635. //1Attention Please!!!<11n or 8190 specific code should be put below this line>
  636. //1!!!!!!!!!!!!!!!!!!!!!!!!!!!
  637. u8 RxDrvInfoSize;
  638. u8 RxBufShift;
  639. bool bIsAMPDU;
  640. bool bFirstMPDU;
  641. bool bContainHTC;
  642. bool RxIs40MHzPacket;
  643. u32 RxPWDBAll;
  644. u8 RxMIMOSignalStrength[4]; // in 0~100 index
  645. s8 RxMIMOSignalQuality[2];
  646. bool bPacketMatchBSSID;
  647. bool bIsCCK;
  648. bool bPacketToSelf;
  649. //added by amy
  650. u8 *virtual_address;
  651. u16 packetlength; // Total packet length: Must equal to sum of all FragLength
  652. u16 fraglength; // FragLength should equal to PacketLength in non-fragment case
  653. u16 fragoffset; // Data offset for this fragment
  654. u16 ntotalfrag;
  655. bool bisrxaggrsubframe;
  656. bool bPacketBeacon; //cosa add for rssi
  657. bool bToSelfBA; //cosa add for rssi
  658. char cck_adc_pwdb[4]; //cosa add for rx path selection
  659. u16 Seq_Num;
  660. };
  661. /* IEEE 802.11 requires that STA supports concurrent reception of at least
  662. * three fragmented frames. This define can be increased to support more
  663. * concurrent frames, but it should be noted that each entry can consume about
  664. * 2 kB of RAM and increasing cache size will slow down frame reassembly. */
  665. #define IEEE80211_FRAG_CACHE_LEN 4
  666. struct ieee80211_frag_entry {
  667. unsigned long first_frag_time;
  668. unsigned int seq;
  669. unsigned int last_frag;
  670. struct sk_buff *skb;
  671. u8 src_addr[ETH_ALEN];
  672. u8 dst_addr[ETH_ALEN];
  673. };
  674. struct ieee80211_stats {
  675. unsigned int tx_unicast_frames;
  676. unsigned int tx_multicast_frames;
  677. unsigned int tx_fragments;
  678. unsigned int tx_unicast_octets;
  679. unsigned int tx_multicast_octets;
  680. unsigned int tx_deferred_transmissions;
  681. unsigned int tx_single_retry_frames;
  682. unsigned int tx_multiple_retry_frames;
  683. unsigned int tx_retry_limit_exceeded;
  684. unsigned int tx_discards;
  685. unsigned int rx_unicast_frames;
  686. unsigned int rx_multicast_frames;
  687. unsigned int rx_fragments;
  688. unsigned int rx_unicast_octets;
  689. unsigned int rx_multicast_octets;
  690. unsigned int rx_fcs_errors;
  691. unsigned int rx_discards_no_buffer;
  692. unsigned int tx_discards_wrong_sa;
  693. unsigned int rx_discards_undecryptable;
  694. unsigned int rx_message_in_msg_fragments;
  695. unsigned int rx_message_in_bad_msg_fragments;
  696. };
  697. struct ieee80211_device;
  698. #include "ieee80211_crypt.h"
  699. #define SEC_KEY_1 (1<<0)
  700. #define SEC_KEY_2 (1<<1)
  701. #define SEC_KEY_3 (1<<2)
  702. #define SEC_KEY_4 (1<<3)
  703. #define SEC_ACTIVE_KEY (1<<4)
  704. #define SEC_AUTH_MODE (1<<5)
  705. #define SEC_UNICAST_GROUP (1<<6)
  706. #define SEC_LEVEL (1<<7)
  707. #define SEC_ENABLED (1<<8)
  708. #define SEC_ENCRYPT (1<<9)
  709. #define SEC_LEVEL_0 0 /* None */
  710. #define SEC_LEVEL_1 1 /* WEP 40 and 104 bit */
  711. #define SEC_LEVEL_2 2 /* Level 1 + TKIP */
  712. #define SEC_LEVEL_2_CKIP 3 /* Level 1 + CKIP */
  713. #define SEC_LEVEL_3 4 /* Level 2 + CCMP */
  714. #define SEC_ALG_NONE 0
  715. #define SEC_ALG_WEP 1
  716. #define SEC_ALG_TKIP 2
  717. #define SEC_ALG_CCMP 3
  718. #define WEP_KEYS 4
  719. #define WEP_KEY_LEN 13
  720. #define SCM_KEY_LEN 32
  721. #define SCM_TEMPORAL_KEY_LENGTH 16
  722. struct ieee80211_security {
  723. u16 active_key:2,
  724. enabled:1,
  725. auth_algo:4,
  726. unicast_uses_group:1,
  727. encrypt:1;
  728. u8 auth_mode;
  729. u8 key_sizes[WEP_KEYS];
  730. u8 keys[WEP_KEYS][SCM_KEY_LEN];
  731. u8 level;
  732. u16 flags;
  733. } __packed;
  734. /*
  735. 802.11 data frame from AP
  736. ,-------------------------------------------------------------------.
  737. Bytes | 2 | 2 | 6 | 6 | 6 | 2 | 0..2312 | 4 |
  738. |------|------|---------|---------|---------|------|---------|------|
  739. Desc. | ctrl | dura | DA/RA | TA | SA | Sequ | frame | fcs |
  740. | | tion | (BSSID) | | | ence | data | |
  741. `-------------------------------------------------------------------'
  742. Total: 28-2340 bytes
  743. */
  744. /* Management Frame Information Element Types */
  745. enum ieee80211_mfie {
  746. MFIE_TYPE_SSID = 0,
  747. MFIE_TYPE_RATES = 1,
  748. MFIE_TYPE_FH_SET = 2,
  749. MFIE_TYPE_DS_SET = 3,
  750. MFIE_TYPE_CF_SET = 4,
  751. MFIE_TYPE_TIM = 5,
  752. MFIE_TYPE_IBSS_SET = 6,
  753. MFIE_TYPE_COUNTRY = 7,
  754. MFIE_TYPE_HOP_PARAMS = 8,
  755. MFIE_TYPE_HOP_TABLE = 9,
  756. MFIE_TYPE_REQUEST = 10,
  757. MFIE_TYPE_CHALLENGE = 16,
  758. MFIE_TYPE_POWER_CONSTRAINT = 32,
  759. MFIE_TYPE_POWER_CAPABILITY = 33,
  760. MFIE_TYPE_TPC_REQUEST = 34,
  761. MFIE_TYPE_TPC_REPORT = 35,
  762. MFIE_TYPE_SUPP_CHANNELS = 36,
  763. MFIE_TYPE_CSA = 37,
  764. MFIE_TYPE_MEASURE_REQUEST = 38,
  765. MFIE_TYPE_MEASURE_REPORT = 39,
  766. MFIE_TYPE_QUIET = 40,
  767. MFIE_TYPE_IBSS_DFS = 41,
  768. MFIE_TYPE_ERP = 42,
  769. MFIE_TYPE_RSN = 48,
  770. MFIE_TYPE_RATES_EX = 50,
  771. MFIE_TYPE_HT_CAP= 45,
  772. MFIE_TYPE_HT_INFO= 61,
  773. MFIE_TYPE_AIRONET=133,
  774. MFIE_TYPE_GENERIC = 221,
  775. MFIE_TYPE_QOS_PARAMETER = 222,
  776. };
  777. /* Minimal header; can be used for passing 802.11 frames with sufficient
  778. * information to determine what type of underlying data type is actually
  779. * stored in the data. */
  780. struct rtl_80211_hdr {
  781. __le16 frame_ctl;
  782. __le16 duration_id;
  783. u8 payload[0];
  784. } __packed;
  785. struct rtl_80211_hdr_1addr {
  786. __le16 frame_ctl;
  787. __le16 duration_id;
  788. u8 addr1[ETH_ALEN];
  789. u8 payload[0];
  790. } __packed;
  791. struct rtl_80211_hdr_2addr {
  792. __le16 frame_ctl;
  793. __le16 duration_id;
  794. u8 addr1[ETH_ALEN];
  795. u8 addr2[ETH_ALEN];
  796. u8 payload[0];
  797. } __packed;
  798. struct rtl_80211_hdr_3addr {
  799. __le16 frame_ctl;
  800. __le16 duration_id;
  801. u8 addr1[ETH_ALEN];
  802. u8 addr2[ETH_ALEN];
  803. u8 addr3[ETH_ALEN];
  804. __le16 seq_ctl;
  805. u8 payload[0];
  806. } __packed;
  807. struct rtl_80211_hdr_4addr {
  808. __le16 frame_ctl;
  809. __le16 duration_id;
  810. u8 addr1[ETH_ALEN];
  811. u8 addr2[ETH_ALEN];
  812. u8 addr3[ETH_ALEN];
  813. __le16 seq_ctl;
  814. u8 addr4[ETH_ALEN];
  815. u8 payload[0];
  816. } __packed;
  817. struct rtl_80211_hdr_3addrqos {
  818. __le16 frame_ctl;
  819. __le16 duration_id;
  820. u8 addr1[ETH_ALEN];
  821. u8 addr2[ETH_ALEN];
  822. u8 addr3[ETH_ALEN];
  823. __le16 seq_ctl;
  824. u8 payload[0];
  825. __le16 qos_ctl;
  826. } __packed;
  827. struct rtl_80211_hdr_4addrqos {
  828. __le16 frame_ctl;
  829. __le16 duration_id;
  830. u8 addr1[ETH_ALEN];
  831. u8 addr2[ETH_ALEN];
  832. u8 addr3[ETH_ALEN];
  833. __le16 seq_ctl;
  834. u8 addr4[ETH_ALEN];
  835. u8 payload[0];
  836. __le16 qos_ctl;
  837. } __packed;
  838. struct ieee80211_info_element {
  839. u8 id;
  840. u8 len;
  841. u8 data[0];
  842. } __packed;
  843. struct ieee80211_authentication {
  844. struct rtl_80211_hdr_3addr header;
  845. __le16 algorithm;
  846. __le16 transaction;
  847. __le16 status;
  848. /*challenge*/
  849. struct ieee80211_info_element info_element[0];
  850. } __packed;
  851. struct ieee80211_disassoc {
  852. struct rtl_80211_hdr_3addr header;
  853. __le16 reason;
  854. } __packed;
  855. struct ieee80211_probe_request {
  856. struct rtl_80211_hdr_3addr header;
  857. /* SSID, supported rates */
  858. struct ieee80211_info_element info_element[0];
  859. } __packed;
  860. struct ieee80211_probe_response {
  861. struct rtl_80211_hdr_3addr header;
  862. __le32 time_stamp[2];
  863. __le16 beacon_interval;
  864. __le16 capability;
  865. /* SSID, supported rates, FH params, DS params,
  866. * CF params, IBSS params, TIM (if beacon), RSN */
  867. struct ieee80211_info_element info_element[0];
  868. } __packed;
  869. /* Alias beacon for probe_response */
  870. #define ieee80211_beacon ieee80211_probe_response
  871. struct ieee80211_assoc_request_frame {
  872. struct rtl_80211_hdr_3addr header;
  873. __le16 capability;
  874. __le16 listen_interval;
  875. /* SSID, supported rates, RSN */
  876. struct ieee80211_info_element info_element[0];
  877. } __packed;
  878. struct ieee80211_reassoc_request_frame {
  879. struct rtl_80211_hdr_3addr header;
  880. __le16 capability;
  881. __le16 listen_interval;
  882. u8 current_ap[ETH_ALEN];
  883. /* SSID, supported rates, RSN */
  884. struct ieee80211_info_element info_element[0];
  885. } __packed;
  886. struct ieee80211_assoc_response_frame {
  887. struct rtl_80211_hdr_3addr header;
  888. __le16 capability;
  889. __le16 status;
  890. __le16 aid;
  891. struct ieee80211_info_element info_element[0]; /* supported rates */
  892. } __packed;
  893. struct ieee80211_txb {
  894. u8 nr_frags;
  895. u8 encrypted;
  896. u8 queue_index;
  897. u8 rts_included;
  898. u16 reserved;
  899. __le16 frag_size;
  900. __le16 payload_size;
  901. struct sk_buff *fragments[0];
  902. };
  903. #define MAX_TX_AGG_COUNT 16
  904. struct ieee80211_drv_agg_txb {
  905. u8 nr_drv_agg_frames;
  906. struct sk_buff *tx_agg_frames[MAX_TX_AGG_COUNT];
  907. } __packed;
  908. #define MAX_SUBFRAME_COUNT 64
  909. struct ieee80211_rxb {
  910. u8 nr_subframes;
  911. struct sk_buff *subframes[MAX_SUBFRAME_COUNT];
  912. u8 dst[ETH_ALEN];
  913. u8 src[ETH_ALEN];
  914. } __packed;
  915. typedef union _frameqos {
  916. u16 shortdata;
  917. u8 chardata[2];
  918. struct {
  919. u16 tid:4;
  920. u16 eosp:1;
  921. u16 ack_policy:2;
  922. u16 reserved:1;
  923. u16 txop:8;
  924. }field;
  925. } frameqos, *pframeqos;
  926. /* SWEEP TABLE ENTRIES NUMBER*/
  927. #define MAX_SWEEP_TAB_ENTRIES 42
  928. #define MAX_SWEEP_TAB_ENTRIES_PER_PACKET 7
  929. /* MAX_RATES_LENGTH needs to be 12. The spec says 8, and many APs
  930. * only use 8, and then use extended rates for the remaining supported
  931. * rates. Other APs, however, stick all of their supported rates on the
  932. * main rates information element... */
  933. #define MAX_RATES_LENGTH ((u8)12)
  934. #define MAX_RATES_EX_LENGTH ((u8)16)
  935. #define MAX_NETWORK_COUNT 128
  936. #define MAX_CHANNEL_NUMBER 161
  937. #define IEEE80211_SOFTMAC_SCAN_TIME 100
  938. //(HZ / 2)
  939. #define IEEE80211_SOFTMAC_ASSOC_RETRY_TIME (HZ * 2)
  940. #define CRC_LENGTH 4U
  941. #define MAX_WPA_IE_LEN 64
  942. #define NETWORK_EMPTY_ESSID (1<<0)
  943. #define NETWORK_HAS_OFDM (1<<1)
  944. #define NETWORK_HAS_CCK (1<<2)
  945. /* QoS structure */
  946. #define NETWORK_HAS_QOS_PARAMETERS (1<<3)
  947. #define NETWORK_HAS_QOS_INFORMATION (1<<4)
  948. #define NETWORK_HAS_QOS_MASK (NETWORK_HAS_QOS_PARAMETERS | \
  949. NETWORK_HAS_QOS_INFORMATION)
  950. /* 802.11h */
  951. #define NETWORK_HAS_POWER_CONSTRAINT (1<<5)
  952. #define NETWORK_HAS_CSA (1<<6)
  953. #define NETWORK_HAS_QUIET (1<<7)
  954. #define NETWORK_HAS_IBSS_DFS (1<<8)
  955. #define NETWORK_HAS_TPC_REPORT (1<<9)
  956. #define NETWORK_HAS_ERP_VALUE (1<<10)
  957. #define QOS_QUEUE_NUM 4
  958. #define QOS_OUI_LEN 3
  959. #define QOS_OUI_TYPE 2
  960. #define QOS_ELEMENT_ID 221
  961. #define QOS_OUI_INFO_SUB_TYPE 0
  962. #define QOS_OUI_PARAM_SUB_TYPE 1
  963. #define QOS_VERSION_1 1
  964. #define QOS_AIFSN_MIN_VALUE 2
  965. struct ieee80211_qos_information_element {
  966. u8 elementID;
  967. u8 length;
  968. u8 qui[QOS_OUI_LEN];
  969. u8 qui_type;
  970. u8 qui_subtype;
  971. u8 version;
  972. u8 ac_info;
  973. } __packed;
  974. struct ieee80211_qos_ac_parameter {
  975. u8 aci_aifsn;
  976. u8 ecw_min_max;
  977. __le16 tx_op_limit;
  978. } __packed;
  979. struct ieee80211_qos_parameter_info {
  980. struct ieee80211_qos_information_element info_element;
  981. u8 reserved;
  982. struct ieee80211_qos_ac_parameter ac_params_record[QOS_QUEUE_NUM];
  983. } __packed;
  984. struct ieee80211_qos_parameters {
  985. __le16 cw_min[QOS_QUEUE_NUM];
  986. __le16 cw_max[QOS_QUEUE_NUM];
  987. u8 aifs[QOS_QUEUE_NUM];
  988. u8 flag[QOS_QUEUE_NUM];
  989. __le16 tx_op_limit[QOS_QUEUE_NUM];
  990. } __packed;
  991. struct ieee80211_qos_data {
  992. struct ieee80211_qos_parameters parameters;
  993. int active;
  994. int supported;
  995. u8 param_count;
  996. u8 old_param_count;
  997. };
  998. struct ieee80211_tim_parameters {
  999. u8 tim_count;
  1000. u8 tim_period;
  1001. } __packed;
  1002. //#else
  1003. struct ieee80211_wmm_ts_info {
  1004. u8 ac_dir_tid;
  1005. u8 ac_up_psb;
  1006. u8 reserved;
  1007. } __packed;
  1008. struct ieee80211_wmm_tspec_elem {
  1009. struct ieee80211_wmm_ts_info ts_info;
  1010. u16 norm_msdu_size;
  1011. u16 max_msdu_size;
  1012. u32 min_serv_inter;
  1013. u32 max_serv_inter;
  1014. u32 inact_inter;
  1015. u32 suspen_inter;
  1016. u32 serv_start_time;
  1017. u32 min_data_rate;
  1018. u32 mean_data_rate;
  1019. u32 peak_data_rate;
  1020. u32 max_burst_size;
  1021. u32 delay_bound;
  1022. u32 min_phy_rate;
  1023. u16 surp_band_allow;
  1024. u16 medium_time;
  1025. } __packed;
  1026. enum eap_type {
  1027. EAP_PACKET = 0,
  1028. EAPOL_START,
  1029. EAPOL_LOGOFF,
  1030. EAPOL_KEY,
  1031. EAPOL_ENCAP_ASF_ALERT
  1032. };
  1033. static const char *eap_types[] = {
  1034. [EAP_PACKET] = "EAP-Packet",
  1035. [EAPOL_START] = "EAPOL-Start",
  1036. [EAPOL_LOGOFF] = "EAPOL-Logoff",
  1037. [EAPOL_KEY] = "EAPOL-Key",
  1038. [EAPOL_ENCAP_ASF_ALERT] = "EAPOL-Encap-ASF-Alert"
  1039. };
  1040. static inline const char *eap_get_type(int type)
  1041. {
  1042. return ((u32)type >= ARRAY_SIZE(eap_types)) ? "Unknown" : eap_types[type];
  1043. }
  1044. //added by amy for reorder
  1045. static inline u8 Frame_QoSTID(u8 *buf)
  1046. {
  1047. struct rtl_80211_hdr_3addr *hdr;
  1048. u16 fc;
  1049. hdr = (struct rtl_80211_hdr_3addr *)buf;
  1050. fc = le16_to_cpu(hdr->frame_ctl);
  1051. return (u8)((frameqos *)(buf + (((fc & IEEE80211_FCTL_TODS)&&(fc & IEEE80211_FCTL_FROMDS))? 30 : 24)))->field.tid;
  1052. }
  1053. //added by amy for reorder
  1054. struct eapol {
  1055. u8 snap[6];
  1056. u16 ethertype;
  1057. u8 version;
  1058. u8 type;
  1059. u16 length;
  1060. } __packed;
  1061. struct ieee80211_softmac_stats{
  1062. unsigned int rx_ass_ok;
  1063. unsigned int rx_ass_err;
  1064. unsigned int rx_probe_rq;
  1065. unsigned int tx_probe_rs;
  1066. unsigned int tx_beacons;
  1067. unsigned int rx_auth_rq;
  1068. unsigned int rx_auth_rs_ok;
  1069. unsigned int rx_auth_rs_err;
  1070. unsigned int tx_auth_rq;
  1071. unsigned int no_auth_rs;
  1072. unsigned int no_ass_rs;
  1073. unsigned int tx_ass_rq;
  1074. unsigned int rx_ass_rq;
  1075. unsigned int tx_probe_rq;
  1076. unsigned int reassoc;
  1077. unsigned int swtxstop;
  1078. unsigned int swtxawake;
  1079. unsigned char CurrentShowTxate;
  1080. unsigned char last_packet_rate;
  1081. unsigned int txretrycount;
  1082. };
  1083. #define BEACON_PROBE_SSID_ID_POSITION 12
  1084. struct ieee80211_info_element_hdr {
  1085. u8 id;
  1086. u8 len;
  1087. } __packed;
  1088. /*
  1089. * These are the data types that can make up management packets
  1090. *
  1091. u16 auth_algorithm;
  1092. u16 auth_sequence;
  1093. u16 beacon_interval;
  1094. u16 capability;
  1095. u8 current_ap[ETH_ALEN];
  1096. u16 listen_interval;
  1097. struct {
  1098. u16 association_id:14, reserved:2;
  1099. } __packed;
  1100. u32 time_stamp[2];
  1101. u16 reason;
  1102. u16 status;
  1103. */
  1104. #define IEEE80211_DEFAULT_TX_ESSID "Penguin"
  1105. #define IEEE80211_DEFAULT_BASIC_RATE 2 //1Mbps
  1106. enum {WMM_all_frame, WMM_two_frame, WMM_four_frame, WMM_six_frame};
  1107. #define MAX_SP_Len (WMM_all_frame << 4)
  1108. #define IEEE80211_QOS_TID 0x0f
  1109. #define QOS_CTL_NOTCONTAIN_ACK (0x01 << 5)
  1110. #define IEEE80211_DTIM_MBCAST 4
  1111. #define IEEE80211_DTIM_UCAST 2
  1112. #define IEEE80211_DTIM_VALID 1
  1113. #define IEEE80211_DTIM_INVALID 0
  1114. #define IEEE80211_PS_DISABLED 0
  1115. #define IEEE80211_PS_UNICAST IEEE80211_DTIM_UCAST
  1116. #define IEEE80211_PS_MBCAST IEEE80211_DTIM_MBCAST
  1117. //added by David for QoS 2006/6/30
  1118. //#define WMM_Hang_8187
  1119. #ifdef WMM_Hang_8187
  1120. #undef WMM_Hang_8187
  1121. #endif
  1122. #define WME_AC_BK 0x00
  1123. #define WME_AC_BE 0x01
  1124. #define WME_AC_VI 0x02
  1125. #define WME_AC_VO 0x03
  1126. #define WME_ACI_MASK 0x03
  1127. #define WME_AIFSN_MASK 0x03
  1128. #define WME_AC_PRAM_LEN 16
  1129. #define MAX_RECEIVE_BUFFER_SIZE 9100
  1130. //UP Mapping to AC, using in MgntQuery_SequenceNumber() and maybe for DSCP
  1131. //#define UP2AC(up) ((up<3) ? ((up==0)?1:0) : (up>>1))
  1132. #define UP2AC(up) ( \
  1133. ((up) < 1) ? WME_AC_BE : \
  1134. ((up) < 3) ? WME_AC_BK : \
  1135. ((up) < 4) ? WME_AC_BE : \
  1136. ((up) < 6) ? WME_AC_VI : \
  1137. WME_AC_VO)
  1138. //AC Mapping to UP, using in Tx part for selecting the corresponding TX queue
  1139. #define AC2UP(_ac) ( \
  1140. ((_ac) == WME_AC_VO) ? 6 : \
  1141. ((_ac) == WME_AC_VI) ? 5 : \
  1142. ((_ac) == WME_AC_BK) ? 1 : \
  1143. 0)
  1144. #define ETHER_ADDR_LEN 6 /* length of an Ethernet address */
  1145. #define ETHERNET_HEADER_SIZE 14 /* length of two Ethernet address plus ether type*/
  1146. struct ether_header {
  1147. u8 ether_dhost[ETHER_ADDR_LEN];
  1148. u8 ether_shost[ETHER_ADDR_LEN];
  1149. u16 ether_type;
  1150. } __packed;
  1151. #ifndef ETHERTYPE_PAE
  1152. #define ETHERTYPE_PAE 0x888e /* EAPOL PAE/802.1x */
  1153. #endif
  1154. #ifndef ETHERTYPE_IP
  1155. #define ETHERTYPE_IP 0x0800 /* IP protocol */
  1156. #endif
  1157. typedef enum _erp_t{
  1158. ERP_NonERPpresent = 0x01,
  1159. ERP_UseProtection = 0x02,
  1160. ERP_BarkerPreambleMode = 0x04,
  1161. } erp_t;
  1162. struct ieee80211_network {
  1163. /* These entries are used to identify a unique network */
  1164. u8 bssid[ETH_ALEN];
  1165. u8 channel;
  1166. /* Ensure null-terminated for any debug msgs */
  1167. u8 ssid[IW_ESSID_MAX_SIZE + 1];
  1168. u8 ssid_len;
  1169. struct ieee80211_qos_data qos_data;
  1170. //added by amy for LEAP
  1171. bool bWithAironetIE;
  1172. bool bCkipSupported;
  1173. bool bCcxRmEnable;
  1174. u16 CcxRmState[2];
  1175. // CCXv4 S59, MBSSID.
  1176. bool bMBssidValid;
  1177. u8 MBssidMask;
  1178. u8 MBssid[6];
  1179. // CCX 2 S38, WLAN Device Version Number element. Annie, 2006-08-20.
  1180. bool bWithCcxVerNum;
  1181. u8 BssCcxVerNumber;
  1182. /* These are network statistics */
  1183. struct ieee80211_rx_stats stats;
  1184. u16 capability;
  1185. u8 rates[MAX_RATES_LENGTH];
  1186. u8 rates_len;
  1187. u8 rates_ex[MAX_RATES_EX_LENGTH];
  1188. u8 rates_ex_len;
  1189. unsigned long last_scanned;
  1190. u8 mode;
  1191. u32 flags;
  1192. u32 last_associate;
  1193. u32 time_stamp[2];
  1194. u16 beacon_interval;
  1195. u16 listen_interval;
  1196. u16 atim_window;
  1197. u8 erp_value;
  1198. u8 wpa_ie[MAX_WPA_IE_LEN];
  1199. size_t wpa_ie_len;
  1200. u8 rsn_ie[MAX_WPA_IE_LEN];
  1201. size_t rsn_ie_len;
  1202. struct ieee80211_tim_parameters tim;
  1203. u8 dtim_period;
  1204. u8 dtim_data;
  1205. u32 last_dtim_sta_time[2];
  1206. //appeded for QoS
  1207. u8 wmm_info;
  1208. struct ieee80211_wmm_ac_param wmm_param[4];
  1209. u8 QoS_Enable;
  1210. #ifdef THOMAS_TURBO
  1211. u8 Turbo_Enable;//enable turbo mode, added by thomas
  1212. #endif
  1213. u16 CountryIeLen;
  1214. u8 CountryIeBuf[MAX_IE_LEN];
  1215. // HT Related, by amy, 2008.04.29
  1216. BSS_HT bssht;
  1217. // Add to handle broadcom AP management frame CCK rate.
  1218. bool broadcom_cap_exist;
  1219. bool ralink_cap_exist;
  1220. bool atheros_cap_exist;
  1221. bool cisco_cap_exist;
  1222. bool unknown_cap_exist;
  1223. // u8 berp_info;
  1224. bool berp_info_valid;
  1225. bool buseprotection;
  1226. //put at the end of the structure.
  1227. struct list_head list;
  1228. };
  1229. enum ieee80211_state {
  1230. /* the card is not linked at all */
  1231. IEEE80211_NOLINK = 0,
  1232. /* IEEE80211_ASSOCIATING* are for BSS client mode
  1233. * the driver shall not perform RX filtering unless
  1234. * the state is LINKED.
  1235. * The driver shall just check for the state LINKED and
  1236. * defaults to NOLINK for ALL the other states (including
  1237. * LINKED_SCANNING)
  1238. */
  1239. /* the association procedure will start (wq scheduling)*/
  1240. IEEE80211_ASSOCIATING,
  1241. IEEE80211_ASSOCIATING_RETRY,
  1242. /* the association procedure is sending AUTH request*/
  1243. IEEE80211_ASSOCIATING_AUTHENTICATING,
  1244. /* the association procedure has successfully authentcated
  1245. * and is sending association request
  1246. */
  1247. IEEE80211_ASSOCIATING_AUTHENTICATED,
  1248. /* the link is ok. the card associated to a BSS or linked
  1249. * to a ibss cell or acting as an AP and creating the bss
  1250. */
  1251. IEEE80211_LINKED,
  1252. /* same as LINKED, but the driver shall apply RX filter
  1253. * rules as we are in NO_LINK mode. As the card is still
  1254. * logically linked, but it is doing a syncro site survey
  1255. * then it will be back to LINKED state.
  1256. */
  1257. IEEE80211_LINKED_SCANNING,
  1258. };
  1259. #define DEFAULT_MAX_SCAN_AGE (15 * HZ)
  1260. #define DEFAULT_FTS 2346
  1261. #define CFG_IEEE80211_RESERVE_FCS (1<<0)
  1262. #define CFG_IEEE80211_COMPUTE_FCS (1<<1)
  1263. #define CFG_IEEE80211_RTS (1<<2)
  1264. #define IEEE80211_24GHZ_MIN_CHANNEL 1
  1265. #define IEEE80211_24GHZ_MAX_CHANNEL 14
  1266. #define IEEE80211_24GHZ_CHANNELS (IEEE80211_24GHZ_MAX_CHANNEL - \
  1267. IEEE80211_24GHZ_MIN_CHANNEL + 1)
  1268. #define IEEE80211_52GHZ_MIN_CHANNEL 34
  1269. #define IEEE80211_52GHZ_MAX_CHANNEL 165
  1270. #define IEEE80211_52GHZ_CHANNELS (IEEE80211_52GHZ_MAX_CHANNEL - \
  1271. IEEE80211_52GHZ_MIN_CHANNEL + 1)
  1272. typedef struct tx_pending_t{
  1273. int frag;
  1274. struct ieee80211_txb *txb;
  1275. }tx_pending_t;
  1276. typedef struct _bandwidth_autoswitch {
  1277. long threshold_20Mhzto40Mhz;
  1278. long threshold_40Mhzto20Mhz;
  1279. bool bforced_tx20Mhz;
  1280. bool bautoswitch_enable;
  1281. } bandwidth_autoswitch, *pbandwidth_autoswitch;
  1282. //added by amy for order
  1283. #define REORDER_WIN_SIZE 128
  1284. #define REORDER_ENTRY_NUM 128
  1285. typedef struct _RX_REORDER_ENTRY {
  1286. struct list_head List;
  1287. u16 SeqNum;
  1288. struct ieee80211_rxb *prxb;
  1289. } RX_REORDER_ENTRY, *PRX_REORDER_ENTRY;
  1290. //added by amy for order
  1291. typedef enum _Fsync_State{
  1292. Default_Fsync,
  1293. HW_Fsync,
  1294. SW_Fsync
  1295. }Fsync_State;
  1296. // Power save mode configured.
  1297. typedef enum _RT_PS_MODE
  1298. {
  1299. eActive, // Active/Continuous access.
  1300. eMaxPs, // Max power save mode.
  1301. eFastPs // Fast power save mode.
  1302. }RT_PS_MODE;
  1303. typedef enum _IPS_CALLBACK_FUNCION
  1304. {
  1305. IPS_CALLBACK_NONE = 0,
  1306. IPS_CALLBACK_MGNT_LINK_REQUEST = 1,
  1307. IPS_CALLBACK_JOIN_REQUEST = 2,
  1308. }IPS_CALLBACK_FUNCION;
  1309. typedef enum _RT_JOIN_ACTION{
  1310. RT_JOIN_INFRA = 1,
  1311. RT_JOIN_IBSS = 2,
  1312. RT_START_IBSS = 3,
  1313. RT_NO_ACTION = 4,
  1314. }RT_JOIN_ACTION;
  1315. typedef struct _IbssParms{
  1316. u16 atimWin;
  1317. }IbssParms, *PIbssParms;
  1318. #define MAX_NUM_RATES 264 // Max num of support rates element: 8, Max num of ext. support rate: 255. 061122, by rcnjko.
  1319. // RF state.
  1320. typedef enum _RT_RF_POWER_STATE {
  1321. eRfOn,
  1322. eRfSleep,
  1323. eRfOff
  1324. }RT_RF_POWER_STATE;
  1325. typedef struct _RT_POWER_SAVE_CONTROL {
  1326. //
  1327. // Inactive Power Save(IPS) : Disable RF when disconnected
  1328. //
  1329. bool bInactivePs;
  1330. bool bIPSModeBackup;
  1331. bool bSwRfProcessing;
  1332. RT_RF_POWER_STATE eInactivePowerState;
  1333. struct work_struct InactivePsWorkItem;
  1334. struct timer_list InactivePsTimer;
  1335. // Return point for join action
  1336. IPS_CALLBACK_FUNCION ReturnPoint;
  1337. // Recored Parameters for rescheduled JoinRequest
  1338. bool bTmpBssDesc;
  1339. RT_JOIN_ACTION tmpJoinAction;
  1340. struct ieee80211_network tmpBssDesc;
  1341. // Recored Parameters for rescheduled MgntLinkRequest
  1342. bool bTmpScanOnly;
  1343. bool bTmpActiveScan;
  1344. bool bTmpFilterHiddenAP;
  1345. bool bTmpUpdateParms;
  1346. u8 tmpSsidBuf[33];
  1347. OCTET_STRING tmpSsid2Scan;
  1348. bool bTmpSsid2Scan;
  1349. u8 tmpNetworkType;
  1350. u8 tmpChannelNumber;
  1351. u16 tmpBcnPeriod;
  1352. u8 tmpDtimPeriod;
  1353. u16 tmpmCap;
  1354. OCTET_STRING tmpSuppRateSet;
  1355. u8 tmpSuppRateBuf[MAX_NUM_RATES];
  1356. bool bTmpSuppRate;
  1357. IbssParms tmpIbpm;
  1358. bool bTmpIbpm;
  1359. //
  1360. // Leisre Poswer Save : Disable RF if connected but traffic is not busy
  1361. //
  1362. bool bLeisurePs;
  1363. } RT_POWER_SAVE_CONTROL, *PRT_POWER_SAVE_CONTROL;
  1364. typedef u32 RT_RF_CHANGE_SOURCE;
  1365. #define RF_CHANGE_BY_SW BIT(31)
  1366. #define RF_CHANGE_BY_HW BIT(30)
  1367. #define RF_CHANGE_BY_PS BIT(29)
  1368. #define RF_CHANGE_BY_IPS BIT(28)
  1369. #define RF_CHANGE_BY_INIT 0 // Do not change the RFOff reason. Defined by Bruce, 2008-01-17.
  1370. typedef enum
  1371. {
  1372. COUNTRY_CODE_FCC = 0,
  1373. COUNTRY_CODE_IC = 1,
  1374. COUNTRY_CODE_ETSI = 2,
  1375. COUNTRY_CODE_SPAIN = 3,
  1376. COUNTRY_CODE_FRANCE = 4,
  1377. COUNTRY_CODE_MKK = 5,
  1378. COUNTRY_CODE_MKK1 = 6,
  1379. COUNTRY_CODE_ISRAEL = 7,
  1380. COUNTRY_CODE_TELEC,
  1381. COUNTRY_CODE_MIC,
  1382. COUNTRY_CODE_GLOBAL_DOMAIN
  1383. }country_code_type_t;
  1384. #define RT_MAX_LD_SLOT_NUM 10
  1385. typedef struct _RT_LINK_DETECT_T{
  1386. u32 NumRecvBcnInPeriod;
  1387. u32 NumRecvDataInPeriod;
  1388. u32 RxBcnNum[RT_MAX_LD_SLOT_NUM]; // number of Rx beacon / CheckForHang_period to determine link status
  1389. u32 RxDataNum[RT_MAX_LD_SLOT_NUM]; // number of Rx data / CheckForHang_period to determine link status
  1390. u16 SlotNum; // number of CheckForHang period to determine link status
  1391. u16 SlotIndex;
  1392. u32 NumTxOkInPeriod;
  1393. u32 NumRxOkInPeriod;
  1394. bool bBusyTraffic;
  1395. }RT_LINK_DETECT_T, *PRT_LINK_DETECT_T;
  1396. struct ieee80211_device {
  1397. struct net_device *dev;
  1398. struct ieee80211_security sec;
  1399. //hw security related
  1400. // u8 hwsec_support; //support?
  1401. u8 hwsec_active; //hw security active.
  1402. bool is_silent_reset;
  1403. bool ieee_up;
  1404. //added by amy
  1405. bool bSupportRemoteWakeUp;
  1406. RT_PS_MODE dot11PowerSaveMode; // Power save mode configured.
  1407. bool actscanning;
  1408. bool beinretry;
  1409. RT_RF_POWER_STATE eRFPowerState;
  1410. RT_RF_CHANGE_SOURCE RfOffReason;
  1411. bool is_set_key;
  1412. //11n spec related I wonder if These info structure need to be moved out of ieee80211_device
  1413. //11n HT below
  1414. PRT_HIGH_THROUGHPUT pHTInfo;
  1415. //struct timer_list SwBwTimer;
  1416. // spinlock_t chnlop_spinlock;
  1417. spinlock_t bw_spinlock;
  1418. spinlock_t reorder_spinlock;
  1419. // for HT operation rate set. we use this one for HT data rate to separate different descriptors
  1420. //the way fill this is the same as in the IE
  1421. u8 Regdot11HTOperationalRateSet[16]; //use RATR format
  1422. u8 dot11HTOperationalRateSet[16]; //use RATR format
  1423. u8 RegHTSuppRateSet[16];
  1424. u8 HTCurrentOperaRate;
  1425. u8 HTHighestOperaRate;
  1426. //wb added for rate operation mode to firmware
  1427. u8 bTxDisableRateFallBack;
  1428. u8 bTxUseDriverAssingedRate;
  1429. atomic_t atm_chnlop;
  1430. atomic_t atm_swbw;
  1431. // u8 HTHighestOperaRate;
  1432. // u8 HTCurrentOperaRate;
  1433. // 802.11e and WMM Traffic Stream Info (TX)
  1434. struct list_head Tx_TS_Admit_List;
  1435. struct list_head Tx_TS_Pending_List;
  1436. struct list_head Tx_TS_Unused_List;
  1437. TX_TS_RECORD TxTsRecord[TOTAL_TS_NUM];
  1438. // 802.11e and WMM Traffic Stream Info (RX)
  1439. struct list_head Rx_TS_Admit_List;
  1440. struct list_head Rx_TS_Pending_List;
  1441. struct list_head Rx_TS_Unused_List;
  1442. RX_TS_RECORD RxTsRecord[TOTAL_TS_NUM];
  1443. //#ifdef TO_DO_LIST
  1444. RX_REORDER_ENTRY RxReorderEntry[128];
  1445. struct list_head RxReorder_Unused_List;
  1446. //#endif
  1447. // Qos related. Added by Annie, 2005-11-01.
  1448. // PSTA_QOS pStaQos;
  1449. u8 ForcedPriority; // Force per-packet priority 1~7. (default: 0, not to force it.)
  1450. /* Bookkeeping structures */
  1451. struct net_device_stats stats;
  1452. struct ieee80211_stats ieee_stats;
  1453. struct ieee80211_softmac_stats softmac_stats;
  1454. /* Probe / Beacon management */
  1455. struct list_head network_free_list;
  1456. struct list_head network_list;
  1457. struct ieee80211_network *networks;
  1458. int scans;
  1459. int scan_age;
  1460. int iw_mode; /* operating mode (IW_MODE_*) */
  1461. struct iw_spy_data spy_data;
  1462. spinlock_t lock;
  1463. spinlock_t wpax_suitlist_lock;
  1464. int tx_headroom; /* Set to size of any additional room needed at front
  1465. * of allocated Tx SKBs */
  1466. u32 config;
  1467. /* WEP and other encryption related settings at the device level */
  1468. int open_wep; /* Set to 1 to allow unencrypted frames */
  1469. int auth_mode;
  1470. int reset_on_keychange; /* Set to 1 if the HW needs to be reset on
  1471. * WEP key changes */
  1472. /* If the host performs {en,de}cryption, then set to 1 */
  1473. int host_encrypt;
  1474. int host_encrypt_msdu;
  1475. int host_decrypt;
  1476. /* host performs multicast decryption */
  1477. int host_mc_decrypt;
  1478. /* host should strip IV and ICV from protected frames */
  1479. /* meaningful only when hardware decryption is being used */
  1480. int host_strip_iv_icv;
  1481. int host_open_frag;
  1482. int host_build_iv;
  1483. int ieee802_1x; /* is IEEE 802.1X used */
  1484. /* WPA data */
  1485. bool bHalfWirelessN24GMode;
  1486. int wpa_enabled;
  1487. int drop_unencrypted;
  1488. int tkip_countermeasures;
  1489. int privacy_invoked;
  1490. size_t wpa_ie_len;
  1491. u8 *wpa_ie;
  1492. u8 ap_mac_addr[6];
  1493. u16 pairwise_key_type;
  1494. u16 group_key_type;
  1495. struct list_head crypt_deinit_list;
  1496. struct ieee80211_crypt_data *crypt[WEP_KEYS];
  1497. int tx_keyidx; /* default TX key index (crypt[tx_keyidx]) */
  1498. struct timer_list crypt_deinit_timer;
  1499. int crypt_quiesced;
  1500. int bcrx_sta_key; /* use individual keys to override default keys even
  1501. * with RX of broad/multicast frames */
  1502. /* Fragmentation structures */
  1503. // each streaming contain a entry
  1504. struct ieee80211_frag_entry frag_cache[17][IEEE80211_FRAG_CACHE_LEN];
  1505. unsigned int frag_next_idx[17];
  1506. u16 fts; /* Fragmentation Threshold */
  1507. #define DEFAULT_RTS_THRESHOLD 2346U
  1508. #define MIN_RTS_THRESHOLD 1
  1509. #define MAX_RTS_THRESHOLD 2346U
  1510. u16 rts; /* RTS threshold */
  1511. /* Association info */
  1512. u8 bssid[ETH_ALEN];
  1513. /* This stores infos for the current network.
  1514. * Either the network we are associated in INFRASTRUCTURE
  1515. * or the network that we are creating in MASTER mode.
  1516. * ad-hoc is a mixture ;-).
  1517. * Note that in infrastructure mode, even when not associated,
  1518. * fields bssid and essid may be valid (if wpa_set and essid_set
  1519. * are true) as thy carry the value set by the user via iwconfig
  1520. */
  1521. struct ieee80211_network current_network;
  1522. enum ieee80211_state state;
  1523. int short_slot;
  1524. int reg_mode;
  1525. int mode; /* A, B, G */
  1526. int modulation; /* CCK, OFDM */
  1527. int freq_band; /* 2.4Ghz, 5.2Ghz, Mixed */
  1528. int abg_true; /* ABG flag */
  1529. /* used for forcing the ibss workqueue to terminate
  1530. * without wait for the syncro scan to terminate
  1531. */
  1532. short sync_scan_hurryup;
  1533. int perfect_rssi;
  1534. int worst_rssi;
  1535. u16 prev_seq_ctl; /* used to drop duplicate frames */
  1536. /* map of allowed channels. 0 is dummy */
  1537. // FIXME: remember to default to a basic channel plan depending of the PHY type
  1538. void *pDot11dInfo;
  1539. bool bGlobalDomain;
  1540. int rate; /* current rate */
  1541. int basic_rate;
  1542. //FIXME: pleace callback, see if redundant with softmac_features
  1543. short active_scan;
  1544. /* this contains flags for selectively enable softmac support */
  1545. u16 softmac_features;
  1546. /* if the sequence control field is not filled by HW */
  1547. u16 seq_ctrl[5];
  1548. /* association procedure transaction sequence number */
  1549. u16 associate_seq;
  1550. /* AID for RTXed association responses */
  1551. u16 assoc_id;
  1552. /* power save mode related*/
  1553. short ps;
  1554. short sta_sleep;
  1555. int ps_timeout;
  1556. int ps_period;
  1557. struct tasklet_struct ps_task;
  1558. u32 ps_th;
  1559. u32 ps_tl;
  1560. short raw_tx;
  1561. /* used if IEEE_SOFTMAC_TX_QUEUE is set */
  1562. short queue_stop;
  1563. short scanning;
  1564. short proto_started;
  1565. struct semaphore wx_sem;
  1566. struct semaphore scan_sem;
  1567. spinlock_t mgmt_tx_lock;
  1568. spinlock_t beacon_lock;
  1569. short beacon_txing;
  1570. short wap_set;
  1571. short ssid_set;
  1572. u8 wpax_type_set; //{added by David, 2006.9.28}
  1573. u32 wpax_type_notify; //{added by David, 2006.9.26}
  1574. /* QoS related flag */
  1575. char init_wmmparam_flag;
  1576. /* set on initialization */
  1577. u8 qos_support;
  1578. /* for discarding duplicated packets in IBSS */
  1579. struct list_head ibss_mac_hash[IEEE_IBSS_MAC_HASH_SIZE];
  1580. /* for discarding duplicated packets in BSS */
  1581. u16 last_rxseq_num[17]; /* rx seq previous per-tid */
  1582. u16 last_rxfrag_num[17];/* tx frag previous per-tid */
  1583. unsigned long last_packet_time[17];
  1584. /* for PS mode */
  1585. unsigned long last_rx_ps_time;
  1586. /* used if IEEE_SOFTMAC_SINGLE_QUEUE is set */
  1587. struct sk_buff *mgmt_queue_ring[MGMT_QUEUE_NUM];
  1588. int mgmt_queue_head;
  1589. int mgmt_queue_tail;
  1590. //{ added for rtl819x
  1591. #define IEEE80211_QUEUE_LIMIT 128
  1592. u8 AsocRetryCount;
  1593. unsigned int hw_header;
  1594. struct sk_buff_head skb_waitQ[MAX_QUEUE_SIZE];
  1595. struct sk_buff_head skb_aggQ[MAX_QUEUE_SIZE];
  1596. struct sk_buff_head skb_drv_aggQ[MAX_QUEUE_SIZE];
  1597. u32 sta_edca_param[4];
  1598. bool aggregation;
  1599. // Enable/Disable Rx immediate BA capability.
  1600. bool enable_rx_imm_BA;
  1601. bool bibsscoordinator;
  1602. //+by amy for DM ,080515
  1603. //Dynamic Tx power for near/far range enable/Disable , by amy , 2008-05-15
  1604. bool bdynamic_txpower_enable;
  1605. bool bCTSToSelfEnable;
  1606. u8 CTSToSelfTH;
  1607. u32 fsync_time_interval;
  1608. u32 fsync_rate_bitmap;
  1609. u8 fsync_rssi_threshold;
  1610. bool bfsync_enable;
  1611. u8 fsync_multiple_timeinterval; // FsyncMultipleTimeInterval * FsyncTimeInterval
  1612. u32 fsync_firstdiff_ratethreshold; // low threshold
  1613. u32 fsync_seconddiff_ratethreshold; // decrease threshold
  1614. Fsync_State fsync_state;
  1615. bool bis_any_nonbepkts;
  1616. //20Mhz 40Mhz AutoSwitch Threshold
  1617. bandwidth_autoswitch bandwidth_auto_switch;
  1618. //for txpower tracking
  1619. bool FwRWRF;
  1620. //added by amy for AP roaming
  1621. RT_LINK_DETECT_T LinkDetectInfo;
  1622. //added by amy for ps
  1623. RT_POWER_SAVE_CONTROL PowerSaveControl;
  1624. //}
  1625. /* used if IEEE_SOFTMAC_TX_QUEUE is set */
  1626. struct tx_pending_t tx_pending;
  1627. /* used if IEEE_SOFTMAC_ASSOCIATE is set */
  1628. struct timer_list associate_timer;
  1629. /* used if IEEE_SOFTMAC_BEACONS is set */
  1630. struct timer_list beacon_timer;
  1631. struct work_struct associate_complete_wq;
  1632. struct work_struct associate_procedure_wq;
  1633. struct delayed_work softmac_scan_wq;
  1634. struct delayed_work associate_retry_wq;
  1635. struct delayed_work start_ibss_wq;
  1636. struct work_struct wx_sync_scan_wq;
  1637. struct workqueue_struct *wq;
  1638. // Qos related. Added by Annie, 2005-11-01.
  1639. //STA_QOS StaQos;
  1640. //u32 STA_EDCA_PARAM[4];
  1641. //CHANNEL_ACCESS_SETTING ChannelAccessSetting;
  1642. /* Callback functions */
  1643. void (*set_security)(struct net_device *dev,
  1644. struct ieee80211_security *sec);
  1645. /* Used to TX data frame by using txb structs.
  1646. * this is not used if in the softmac_features
  1647. * is set the flag IEEE_SOFTMAC_TX_QUEUE
  1648. */
  1649. int (*hard_start_xmit)(struct ieee80211_txb *txb,
  1650. struct net_device *dev);
  1651. int (*reset_port)(struct net_device *dev);
  1652. int (*is_queue_full) (struct net_device *dev, int pri);
  1653. int (*handle_management) (struct net_device *dev,
  1654. struct ieee80211_network *network, u16 type);
  1655. int (*is_qos_active) (struct net_device *dev, struct sk_buff *skb);
  1656. /* Softmac-generated frames (management) are TXed via this
  1657. * callback if the flag IEEE_SOFTMAC_SINGLE_QUEUE is
  1658. * not set. As some cards may have different HW queues that
  1659. * one might want to use for data and management frames
  1660. * the option to have two callbacks might be useful.
  1661. * This function can't sleep.
  1662. */
  1663. int (*softmac_hard_start_xmit)(struct sk_buff *skb,
  1664. struct net_device *dev);
  1665. /* used instead of hard_start_xmit (not softmac_hard_start_xmit)
  1666. * if the IEEE_SOFTMAC_TX_QUEUE feature is used to TX data
  1667. * frames. I the option IEEE_SOFTMAC_SINGLE_QUEUE is also set
  1668. * then also management frames are sent via this callback.
  1669. * This function can't sleep.
  1670. */
  1671. void (*softmac_data_hard_start_xmit)(struct sk_buff *skb,
  1672. struct net_device *dev, int rate);
  1673. /* stops the HW queue for DATA frames. Useful to avoid
  1674. * waste time to TX data frame when we are reassociating
  1675. * This function can sleep.
  1676. */
  1677. void (*data_hard_stop)(struct net_device *dev);
  1678. /* OK this is complementar to data_poll_hard_stop */
  1679. void (*data_hard_resume)(struct net_device *dev);
  1680. /* ask to the driver to retune the radio .
  1681. * This function can sleep. the driver should ensure
  1682. * the radio has been swithced before return.
  1683. */
  1684. void (*set_chan)(struct net_device *dev, short ch);
  1685. /* These are not used if the ieee stack takes care of
  1686. * scanning (IEEE_SOFTMAC_SCAN feature set).
  1687. * In this case only the set_chan is used.
  1688. *
  1689. * The syncro version is similar to the start_scan but
  1690. * does not return until all channels has been scanned.
  1691. * this is called in user context and should sleep,
  1692. * it is called in a work_queue when swithcing to ad-hoc mode
  1693. * or in behalf of iwlist scan when the card is associated
  1694. * and root user ask for a scan.
  1695. * the function stop_scan should stop both the syncro and
  1696. * background scanning and can sleep.
  1697. * The function start_scan should initiate the background
  1698. * scanning and can't sleep.
  1699. */
  1700. void (*scan_syncro)(struct net_device *dev);
  1701. void (*start_scan)(struct net_device *dev);
  1702. void (*stop_scan)(struct net_device *dev);
  1703. /* indicate the driver that the link state is changed
  1704. * for example it may indicate the card is associated now.
  1705. * Driver might be interested in this to apply RX filter
  1706. * rules or simply light the LINK led
  1707. */
  1708. void (*link_change)(struct net_device *dev);
  1709. /* these two function indicates to the HW when to start
  1710. * and stop to send beacons. This is used when the
  1711. * IEEE_SOFTMAC_BEACONS is not set. For now the
  1712. * stop_send_bacons is NOT guaranteed to be called only
  1713. * after start_send_beacons.
  1714. */
  1715. void (*start_send_beacons) (struct net_device *dev,u16 tx_rate);
  1716. void (*stop_send_beacons) (struct net_device *dev);
  1717. /* power save mode related */
  1718. void (*sta_wake_up) (struct net_device *dev);
  1719. void (*ps_request_tx_ack) (struct net_device *dev);
  1720. void (*enter_sleep_state) (struct net_device *dev, u32 th, u32 tl);
  1721. short (*ps_is_queue_empty) (struct net_device *dev);
  1722. int (*handle_beacon) (struct net_device *dev, struct ieee80211_beacon *beacon, struct ieee80211_network *network);
  1723. int (*handle_assoc_response) (struct net_device *dev, struct ieee80211_assoc_response_frame *resp, struct ieee80211_network *network);
  1724. /* check whether Tx hw resource available */
  1725. short (*check_nic_enough_desc)(struct net_device *dev, int queue_index);
  1726. //added by wb for HT related
  1727. // void (*SwChnlByTimerHandler)(struct net_device *dev, int channel);
  1728. void (*SetBWModeHandler)(struct net_device *dev, HT_CHANNEL_WIDTH Bandwidth, HT_EXTCHNL_OFFSET Offset);
  1729. // void (*UpdateHalRATRTableHandler)(struct net_device* dev, u8* pMcsRate);
  1730. bool (*GetNmodeSupportBySecCfg)(struct net_device *dev);
  1731. void (*SetWirelessMode)(struct net_device *dev, u8 wireless_mode);
  1732. bool (*GetHalfNmodeSupportByAPsHandler)(struct net_device *dev);
  1733. void (*InitialGainHandler)(struct net_device *dev, u8 Operation);
  1734. /* This must be the last item so that it points to the data
  1735. * allocated beyond this structure by alloc_ieee80211 */
  1736. u8 priv[0];
  1737. };
  1738. #define IEEE_A (1<<0)
  1739. #define IEEE_B (1<<1)
  1740. #define IEEE_G (1<<2)
  1741. #define IEEE_N_24G (1<<4)
  1742. #define IEEE_N_5G (1<<5)
  1743. #define IEEE_MODE_MASK (IEEE_A|IEEE_B|IEEE_G)
  1744. /* Generate a 802.11 header */
  1745. /* Uses the channel change callback directly
  1746. * instead of [start/stop] scan callbacks
  1747. */
  1748. #define IEEE_SOFTMAC_SCAN (1<<2)
  1749. /* Perform authentication and association handshake */
  1750. #define IEEE_SOFTMAC_ASSOCIATE (1<<3)
  1751. /* Generate probe requests */
  1752. #define IEEE_SOFTMAC_PROBERQ (1<<4)
  1753. /* Generate respones to probe requests */
  1754. #define IEEE_SOFTMAC_PROBERS (1<<5)
  1755. /* The ieee802.11 stack will manages the netif queue
  1756. * wake/stop for the driver, taking care of 802.11
  1757. * fragmentation. See softmac.c for details. */
  1758. #define IEEE_SOFTMAC_TX_QUEUE (1<<7)
  1759. /* Uses only the softmac_data_hard_start_xmit
  1760. * even for TX management frames.
  1761. */
  1762. #define IEEE_SOFTMAC_SINGLE_QUEUE (1<<8)
  1763. /* Generate beacons. The stack will enqueue beacons
  1764. * to the card
  1765. */
  1766. #define IEEE_SOFTMAC_BEACONS (1<<6)
  1767. static inline void *ieee80211_priv(struct net_device *dev)
  1768. {
  1769. return ((struct ieee80211_device *)netdev_priv(dev))->priv;
  1770. }
  1771. static inline int ieee80211_is_empty_essid(const char *essid, int essid_len)
  1772. {
  1773. /* Single white space is for Linksys APs */
  1774. if (essid_len == 1 && essid[0] == ' ')
  1775. return 1;
  1776. /* Otherwise, if the entire essid is 0, we assume it is hidden */
  1777. while (essid_len) {
  1778. essid_len--;
  1779. if (essid[essid_len] != '\0')
  1780. return 0;
  1781. }
  1782. return 1;
  1783. }
  1784. static inline int ieee80211_is_valid_mode(struct ieee80211_device *ieee, int mode)
  1785. {
  1786. /*
  1787. * It is possible for both access points and our device to support
  1788. * combinations of modes, so as long as there is one valid combination
  1789. * of ap/device supported modes, then return success
  1790. *
  1791. */
  1792. if ((mode & IEEE_A) &&
  1793. (ieee->modulation & IEEE80211_OFDM_MODULATION) &&
  1794. (ieee->freq_band & IEEE80211_52GHZ_BAND))
  1795. return 1;
  1796. if ((mode & IEEE_G) &&
  1797. (ieee->modulation & IEEE80211_OFDM_MODULATION) &&
  1798. (ieee->freq_band & IEEE80211_24GHZ_BAND))
  1799. return 1;
  1800. if ((mode & IEEE_B) &&
  1801. (ieee->modulation & IEEE80211_CCK_MODULATION) &&
  1802. (ieee->freq_band & IEEE80211_24GHZ_BAND))
  1803. return 1;
  1804. return 0;
  1805. }
  1806. static inline int ieee80211_get_hdrlen(u16 fc)
  1807. {
  1808. int hdrlen = IEEE80211_3ADDR_LEN;
  1809. switch (WLAN_FC_GET_TYPE(fc)) {
  1810. case IEEE80211_FTYPE_DATA:
  1811. if ((fc & IEEE80211_FCTL_FROMDS) && (fc & IEEE80211_FCTL_TODS))
  1812. hdrlen = IEEE80211_4ADDR_LEN; /* Addr4 */
  1813. if(IEEE80211_QOS_HAS_SEQ(fc))
  1814. hdrlen += 2; /* QOS ctrl*/
  1815. break;
  1816. case IEEE80211_FTYPE_CTL:
  1817. switch (WLAN_FC_GET_STYPE(fc)) {
  1818. case IEEE80211_STYPE_CTS:
  1819. case IEEE80211_STYPE_ACK:
  1820. hdrlen = IEEE80211_1ADDR_LEN;
  1821. break;
  1822. default:
  1823. hdrlen = IEEE80211_2ADDR_LEN;
  1824. break;
  1825. }
  1826. break;
  1827. }
  1828. return hdrlen;
  1829. }
  1830. static inline u8 *ieee80211_get_payload(struct rtl_80211_hdr *hdr)
  1831. {
  1832. switch (ieee80211_get_hdrlen(le16_to_cpu(hdr->frame_ctl))) {
  1833. case IEEE80211_1ADDR_LEN:
  1834. return ((struct rtl_80211_hdr_1addr *)hdr)->payload;
  1835. case IEEE80211_2ADDR_LEN:
  1836. return ((struct rtl_80211_hdr_2addr *)hdr)->payload;
  1837. case IEEE80211_3ADDR_LEN:
  1838. return ((struct rtl_80211_hdr_3addr *)hdr)->payload;
  1839. case IEEE80211_4ADDR_LEN:
  1840. return ((struct rtl_80211_hdr_4addr *)hdr)->payload;
  1841. }
  1842. return NULL;
  1843. }
  1844. static inline int ieee80211_is_ofdm_rate(u8 rate)
  1845. {
  1846. switch (rate & ~IEEE80211_BASIC_RATE_MASK) {
  1847. case IEEE80211_OFDM_RATE_6MB:
  1848. case IEEE80211_OFDM_RATE_9MB:
  1849. case IEEE80211_OFDM_RATE_12MB:
  1850. case IEEE80211_OFDM_RATE_18MB:
  1851. case IEEE80211_OFDM_RATE_24MB:
  1852. case IEEE80211_OFDM_RATE_36MB:
  1853. case IEEE80211_OFDM_RATE_48MB:
  1854. case IEEE80211_OFDM_RATE_54MB:
  1855. return 1;
  1856. }
  1857. return 0;
  1858. }
  1859. static inline int ieee80211_is_cck_rate(u8 rate)
  1860. {
  1861. switch (rate & ~IEEE80211_BASIC_RATE_MASK) {
  1862. case IEEE80211_CCK_RATE_1MB:
  1863. case IEEE80211_CCK_RATE_2MB:
  1864. case IEEE80211_CCK_RATE_5MB:
  1865. case IEEE80211_CCK_RATE_11MB:
  1866. return 1;
  1867. }
  1868. return 0;
  1869. }
  1870. /* ieee80211.c */
  1871. void free_ieee80211(struct net_device *dev);
  1872. struct net_device *alloc_ieee80211(int sizeof_priv);
  1873. int ieee80211_set_encryption(struct ieee80211_device *ieee);
  1874. /* ieee80211_tx.c */
  1875. int ieee80211_encrypt_fragment(struct ieee80211_device *ieee,
  1876. struct sk_buff *frag, int hdr_len);
  1877. int ieee80211_xmit(struct sk_buff *skb, struct net_device *dev);
  1878. void ieee80211_txb_free(struct ieee80211_txb *);
  1879. /* ieee80211_rx.c */
  1880. int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb,
  1881. struct ieee80211_rx_stats *rx_stats);
  1882. void ieee80211_rx_mgt(struct ieee80211_device *ieee,
  1883. struct rtl_80211_hdr_4addr *header,
  1884. struct ieee80211_rx_stats *stats);
  1885. /* ieee80211_wx.c */
  1886. int ieee80211_wx_get_scan(struct ieee80211_device *ieee,
  1887. struct iw_request_info *info,
  1888. union iwreq_data *wrqu, char *key);
  1889. int ieee80211_wx_set_encode(struct ieee80211_device *ieee,
  1890. struct iw_request_info *info,
  1891. union iwreq_data *wrqu, char *key);
  1892. int ieee80211_wx_get_encode(struct ieee80211_device *ieee,
  1893. struct iw_request_info *info,
  1894. union iwreq_data *wrqu, char *key);
  1895. int ieee80211_wx_get_encode_ext(struct ieee80211_device *ieee,
  1896. struct iw_request_info *info,
  1897. union iwreq_data *wrqu, char *extra);
  1898. int ieee80211_wx_set_encode_ext(struct ieee80211_device *ieee,
  1899. struct iw_request_info *info,
  1900. union iwreq_data *wrqu, char *extra);
  1901. int ieee80211_wx_set_auth(struct ieee80211_device *ieee,
  1902. struct iw_request_info *info,
  1903. struct iw_param *data, char *extra);
  1904. int ieee80211_wx_set_mlme(struct ieee80211_device *ieee,
  1905. struct iw_request_info *info,
  1906. union iwreq_data *wrqu, char *extra);
  1907. int ieee80211_wx_set_gen_ie(struct ieee80211_device *ieee, u8 *ie, size_t len);
  1908. /* ieee80211_softmac.c */
  1909. short ieee80211_is_54g(const struct ieee80211_network *net);
  1910. short ieee80211_is_shortslot(const struct ieee80211_network *net);
  1911. int ieee80211_rx_frame_softmac(struct ieee80211_device *ieee,
  1912. struct sk_buff *skb,
  1913. struct ieee80211_rx_stats *rx_stats,
  1914. u16 type, u16 stype);
  1915. void ieee80211_softmac_new_net(struct ieee80211_device *ieee,
  1916. struct ieee80211_network *net);
  1917. void SendDisassociation(struct ieee80211_device *ieee, u8 *asSta, u8 asRsn);
  1918. void ieee80211_softmac_xmit(struct ieee80211_txb *txb,
  1919. struct ieee80211_device *ieee);
  1920. void ieee80211_stop_send_beacons(struct ieee80211_device *ieee);
  1921. void notify_wx_assoc_event(struct ieee80211_device *ieee);
  1922. void ieee80211_softmac_check_all_nets(struct ieee80211_device *ieee);
  1923. void ieee80211_start_bss(struct ieee80211_device *ieee);
  1924. void ieee80211_start_master_bss(struct ieee80211_device *ieee);
  1925. void ieee80211_start_ibss(struct ieee80211_device *ieee);
  1926. void ieee80211_softmac_init(struct ieee80211_device *ieee);
  1927. void ieee80211_softmac_free(struct ieee80211_device *ieee);
  1928. void ieee80211_associate_abort(struct ieee80211_device *ieee);
  1929. void ieee80211_disassociate(struct ieee80211_device *ieee);
  1930. void ieee80211_stop_scan(struct ieee80211_device *ieee);
  1931. void ieee80211_start_scan_syncro(struct ieee80211_device *ieee);
  1932. void ieee80211_check_all_nets(struct ieee80211_device *ieee);
  1933. void ieee80211_start_protocol(struct ieee80211_device *ieee);
  1934. void ieee80211_stop_protocol(struct ieee80211_device *ieee);
  1935. void ieee80211_softmac_start_protocol(struct ieee80211_device *ieee);
  1936. void ieee80211_softmac_stop_protocol(struct ieee80211_device *ieee);
  1937. void ieee80211_reset_queue(struct ieee80211_device *ieee);
  1938. void ieee80211_wake_queue(struct ieee80211_device *ieee);
  1939. void ieee80211_stop_queue(struct ieee80211_device *ieee);
  1940. struct sk_buff *ieee80211_get_beacon(struct ieee80211_device *ieee);
  1941. void ieee80211_start_send_beacons(struct ieee80211_device *ieee);
  1942. void ieee80211_stop_send_beacons(struct ieee80211_device *ieee);
  1943. int ieee80211_wpa_supplicant_ioctl(struct ieee80211_device *ieee,
  1944. struct iw_point *p);
  1945. void notify_wx_assoc_event(struct ieee80211_device *ieee);
  1946. void ieee80211_ps_tx_ack(struct ieee80211_device *ieee, short success);
  1947. void softmac_mgmt_xmit(struct sk_buff *skb, struct ieee80211_device *ieee);
  1948. /* ieee80211_crypt_ccmp&tkip&wep.c */
  1949. void ieee80211_tkip_null(void);
  1950. void ieee80211_wep_null(void);
  1951. void ieee80211_ccmp_null(void);
  1952. int ieee80211_crypto_init(void);
  1953. void ieee80211_crypto_deinit(void);
  1954. int ieee80211_crypto_tkip_init(void);
  1955. void ieee80211_crypto_tkip_exit(void);
  1956. int ieee80211_crypto_ccmp_init(void);
  1957. void ieee80211_crypto_ccmp_exit(void);
  1958. int ieee80211_crypto_wep_init(void);
  1959. void ieee80211_crypto_wep_exit(void);
  1960. /* ieee80211_softmac_wx.c */
  1961. int ieee80211_wx_get_wap(struct ieee80211_device *ieee,
  1962. struct iw_request_info *info,
  1963. union iwreq_data *wrqu, char *ext);
  1964. int ieee80211_wx_set_wap(struct ieee80211_device *ieee,
  1965. struct iw_request_info *info,
  1966. union iwreq_data *awrq,
  1967. char *extra);
  1968. int ieee80211_wx_get_essid(struct ieee80211_device *ieee,
  1969. struct iw_request_info *a,
  1970. union iwreq_data *wrqu, char *b);
  1971. int ieee80211_wx_set_rate(struct ieee80211_device *ieee,
  1972. struct iw_request_info *info,
  1973. union iwreq_data *wrqu, char *extra);
  1974. int ieee80211_wx_get_rate(struct ieee80211_device *ieee,
  1975. struct iw_request_info *info,
  1976. union iwreq_data *wrqu, char *extra);
  1977. int ieee80211_wx_set_mode(struct ieee80211_device *ieee,
  1978. struct iw_request_info *a,
  1979. union iwreq_data *wrqu, char *b);
  1980. int ieee80211_wx_set_scan(struct ieee80211_device *ieee,
  1981. struct iw_request_info *a,
  1982. union iwreq_data *wrqu, char *b);
  1983. int ieee80211_wx_set_essid(struct ieee80211_device *ieee,
  1984. struct iw_request_info *a,
  1985. union iwreq_data *wrqu, char *extra);
  1986. int ieee80211_wx_get_mode(struct ieee80211_device *ieee,
  1987. struct iw_request_info *a,
  1988. union iwreq_data *wrqu, char *b);
  1989. int ieee80211_wx_set_freq(struct ieee80211_device *ieee,
  1990. struct iw_request_info *a,
  1991. union iwreq_data *wrqu, char *b);
  1992. int ieee80211_wx_get_freq(struct ieee80211_device *ieee,
  1993. struct iw_request_info *a,
  1994. union iwreq_data *wrqu, char *b);
  1995. /* ieee80211_module.c */
  1996. int ieee80211_debug_init(void);
  1997. void ieee80211_debug_exit(void);
  1998. //extern void ieee80211_wx_sync_scan_wq(struct ieee80211_device *ieee);
  1999. void ieee80211_wx_sync_scan_wq(struct work_struct *work);
  2000. int ieee80211_wx_set_rawtx(struct ieee80211_device *ieee,
  2001. struct iw_request_info *info,
  2002. union iwreq_data *wrqu, char *extra);
  2003. int ieee80211_wx_get_name(struct ieee80211_device *ieee,
  2004. struct iw_request_info *info,
  2005. union iwreq_data *wrqu, char *extra);
  2006. int ieee80211_wx_set_power(struct ieee80211_device *ieee,
  2007. struct iw_request_info *info,
  2008. union iwreq_data *wrqu, char *extra);
  2009. int ieee80211_wx_get_power(struct ieee80211_device *ieee,
  2010. struct iw_request_info *info,
  2011. union iwreq_data *wrqu, char *extra);
  2012. int ieee80211_wx_set_rts(struct ieee80211_device *ieee,
  2013. struct iw_request_info *info,
  2014. union iwreq_data *wrqu, char *extra);
  2015. int ieee80211_wx_get_rts(struct ieee80211_device *ieee,
  2016. struct iw_request_info *info,
  2017. union iwreq_data *wrqu, char *extra);
  2018. //HT
  2019. #define MAX_RECEIVE_BUFFER_SIZE 9100 //
  2020. void HTDebugHTCapability(u8 *CapIE, u8 *TitleString);
  2021. void HTDebugHTInfo(u8 *InfoIE, u8 *TitleString);
  2022. void HTSetConnectBwMode(struct ieee80211_device *ieee,
  2023. HT_CHANNEL_WIDTH Bandwidth, HT_EXTCHNL_OFFSET Offset);
  2024. void HTUpdateDefaultSetting(struct ieee80211_device *ieee);
  2025. void HTConstructCapabilityElement(struct ieee80211_device *ieee, u8 *posHTCap,
  2026. u8 *len, u8 isEncrypt);
  2027. void HTConstructInfoElement(struct ieee80211_device *ieee, u8 *posHTInfo,
  2028. u8 *len, u8 isEncrypt);
  2029. void HTConstructRT2RTAggElement(struct ieee80211_device *ieee, u8 *posRT2RTAgg,
  2030. u8 *len);
  2031. void HTOnAssocRsp(struct ieee80211_device *ieee);
  2032. void HTInitializeHTInfo(struct ieee80211_device *ieee);
  2033. void HTInitializeBssDesc(PBSS_HT pBssHT);
  2034. void HTResetSelfAndSavePeerSetting(struct ieee80211_device *ieee,
  2035. struct ieee80211_network *pNetwork);
  2036. void HTUpdateSelfAndPeerSetting(struct ieee80211_device *ieee,
  2037. struct ieee80211_network *pNetwork);
  2038. u8 HTGetHighestMCSRate(struct ieee80211_device *ieee,
  2039. u8 *pMCSRateSet, u8 *pMCSFilter);
  2040. extern u8 MCS_FILTER_ALL[];
  2041. extern u16 MCS_DATA_RATE[2][2][77] ;
  2042. u8 HTCCheck(struct ieee80211_device *ieee, u8 *pFrame);
  2043. //extern void HTSetConnectBwModeCallback(unsigned long data);
  2044. void HTResetIOTSetting(PRT_HIGH_THROUGHPUT pHTInfo);
  2045. bool IsHTHalfNmodeAPs(struct ieee80211_device *ieee);
  2046. u16 HTHalfMcsToDataRate(struct ieee80211_device *ieee, u8 nMcsRate);
  2047. u16 HTMcsToDataRate(struct ieee80211_device *ieee, u8 nMcsRate);
  2048. u16 TxCountToDataRate(struct ieee80211_device *ieee, u8 nDataRate);
  2049. //function in BAPROC.c
  2050. int ieee80211_rx_ADDBAReq(struct ieee80211_device *ieee, struct sk_buff *skb);
  2051. int ieee80211_rx_ADDBARsp(struct ieee80211_device *ieee, struct sk_buff *skb);
  2052. int ieee80211_rx_DELBA(struct ieee80211_device *ieee, struct sk_buff *skb);
  2053. void TsInitAddBA(struct ieee80211_device *ieee, PTX_TS_RECORD pTS,
  2054. u8 Policy, u8 bOverwritePending);
  2055. void TsInitDelBA(struct ieee80211_device *ieee,
  2056. PTS_COMMON_INFO pTsCommonInfo, TR_SELECT TxRxSelect);
  2057. void BaSetupTimeOut(unsigned long data);
  2058. void TxBaInactTimeout(unsigned long data);
  2059. void RxBaInactTimeout(unsigned long data);
  2060. void ResetBaEntry(PBA_RECORD pBA);
  2061. //function in TS.c
  2062. bool GetTs(
  2063. struct ieee80211_device *ieee,
  2064. PTS_COMMON_INFO *ppTS,
  2065. u8 *Addr,
  2066. u8 TID,
  2067. TR_SELECT TxRxSelect, //Rx:1, Tx:0
  2068. bool bAddNewTs
  2069. );
  2070. void TSInitialize(struct ieee80211_device *ieee);
  2071. void TsStartAddBaProcess(struct ieee80211_device *ieee, PTX_TS_RECORD pTxTS);
  2072. void RemovePeerTS(struct ieee80211_device *ieee, u8 *Addr);
  2073. void RemoveAllTS(struct ieee80211_device *ieee);
  2074. void ieee80211_softmac_scan_syncro(struct ieee80211_device *ieee);
  2075. extern const long ieee80211_wlan_frequencies[];
  2076. static inline void ieee80211_increment_scans(struct ieee80211_device *ieee)
  2077. {
  2078. ieee->scans++;
  2079. }
  2080. static inline int ieee80211_get_scans(struct ieee80211_device *ieee)
  2081. {
  2082. return ieee->scans;
  2083. }
  2084. static inline const char *escape_essid(const char *essid, u8 essid_len) {
  2085. static char escaped[IW_ESSID_MAX_SIZE * 2 + 1];
  2086. if (ieee80211_is_empty_essid(essid, essid_len)) {
  2087. memcpy(escaped, "<hidden>", sizeof("<hidden>"));
  2088. return escaped;
  2089. }
  2090. snprintf(escaped, sizeof(escaped), "%*pEn", essid_len, essid);
  2091. return escaped;
  2092. }
  2093. /* For the function is more related to hardware setting, it's better to use the
  2094. * ieee handler to refer to it.
  2095. */
  2096. short check_nic_enough_desc(struct net_device *dev, int queue_index);
  2097. int ieee80211_data_xmit(struct sk_buff *skb, struct net_device *dev);
  2098. int ieee80211_parse_info_param(struct ieee80211_device *ieee,
  2099. struct ieee80211_info_element *info_element,
  2100. u16 length,
  2101. struct ieee80211_network *network,
  2102. struct ieee80211_rx_stats *stats);
  2103. void ieee80211_indicate_packets(struct ieee80211_device *ieee,
  2104. struct ieee80211_rxb **prxbIndicateArray,
  2105. u8 index);
  2106. #define RT_ASOC_RETRY_LIMIT 5
  2107. #endif /* IEEE80211_H */