rtllib.h 82 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042
  1. /*
  2. * Merged with mainline rtllib.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 RTLLIB_H
  25. #define RTLLIB_H
  26. #include <linux/if_ether.h> /* ETH_ALEN */
  27. #include <linux/kernel.h> /* ARRAY_SIZE */
  28. #include <linux/module.h>
  29. #include <linux/interrupt.h>
  30. #include <linux/jiffies.h>
  31. #include <linux/timer.h>
  32. #include <linux/sched.h>
  33. #include <linux/semaphore.h>
  34. #include <linux/delay.h>
  35. #include <linux/wireless.h>
  36. #include "rtllib_debug.h"
  37. #include "rtl819x_HT.h"
  38. #include "rtl819x_BA.h"
  39. #include "rtl819x_TS.h"
  40. #include <linux/netdevice.h>
  41. #include <linux/if_arp.h> /* ARPHRD_ETHER */
  42. #include <net/lib80211.h>
  43. #define MAX_PRECMD_CNT 16
  44. #define MAX_RFDEPENDCMD_CNT 16
  45. #define MAX_POSTCMD_CNT 16
  46. #ifndef WIRELESS_SPY
  47. #define WIRELESS_SPY
  48. #endif
  49. #include <net/iw_handler.h>
  50. #ifndef IW_MODE_MONITOR
  51. #define IW_MODE_MONITOR 6
  52. #endif
  53. #ifndef IWEVCUSTOM
  54. #define IWEVCUSTOM 0x8c02
  55. #endif
  56. #ifndef IW_CUSTOM_MAX
  57. /* Max number of char in custom event - use multiple of them if needed */
  58. #define IW_CUSTOM_MAX 256 /* In bytes */
  59. #endif
  60. #ifndef container_of
  61. /**
  62. * container_of - cast a member of a structure out to the containing structure
  63. *
  64. * @ptr: the pointer to the member.
  65. * @type: the type of the container struct this is embedded in.
  66. * @member: the name of the member within the struct.
  67. *
  68. */
  69. #define container_of(ptr, type, member) ({ \
  70. const typeof(((type *)0)->member)*__mptr = (ptr); \
  71. (type *)((char *)__mptr - offsetof(type, member)); })
  72. #endif
  73. #define skb_tail_pointer_rsl(skb) skb_tail_pointer(skb)
  74. #define EXPORT_SYMBOL_RSL(x) EXPORT_SYMBOL(x)
  75. #define queue_delayed_work_rsl(x, y, z) queue_delayed_work(x, y, z)
  76. #define INIT_DELAYED_WORK_RSL(x, y, z) INIT_DELAYED_WORK(x, y)
  77. #define queue_work_rsl(x, y) queue_work(x, y)
  78. #define INIT_WORK_RSL(x, y, z) INIT_WORK(x, y)
  79. #define container_of_work_rsl(x, y, z) container_of(x, y, z)
  80. #define container_of_dwork_rsl(x, y, z) \
  81. container_of(container_of(x, struct delayed_work, work), y, z)
  82. #define iwe_stream_add_event_rsl(info, start, stop, iwe, len) \
  83. iwe_stream_add_event(info, start, stop, iwe, len)
  84. #define iwe_stream_add_point_rsl(info, start, stop, iwe, p) \
  85. iwe_stream_add_point(info, start, stop, iwe, p)
  86. #define usb_alloc_urb_rsl(x, y) usb_alloc_urb(x, y)
  87. #define usb_submit_urb_rsl(x, y) usb_submit_urb(x, y)
  88. static inline void *netdev_priv_rsl(struct net_device *dev)
  89. {
  90. return netdev_priv(dev);
  91. }
  92. #define KEY_TYPE_NA 0x0
  93. #define KEY_TYPE_WEP40 0x1
  94. #define KEY_TYPE_TKIP 0x2
  95. #define KEY_TYPE_CCMP 0x4
  96. #define KEY_TYPE_WEP104 0x5
  97. /* added for rtl819x tx procedure */
  98. #define MAX_QUEUE_SIZE 0x10
  99. #define BK_QUEUE 0
  100. #define BE_QUEUE 1
  101. #define VI_QUEUE 2
  102. #define VO_QUEUE 3
  103. #define HCCA_QUEUE 4
  104. #define TXCMD_QUEUE 5
  105. #define MGNT_QUEUE 6
  106. #define HIGH_QUEUE 7
  107. #define BEACON_QUEUE 8
  108. #define LOW_QUEUE BE_QUEUE
  109. #define NORMAL_QUEUE MGNT_QUEUE
  110. #ifndef IW_MODE_MESH
  111. #define IW_MODE_MESH 7
  112. #endif
  113. #define AMSDU_SUBHEADER_LEN 14
  114. #define SWRF_TIMEOUT 50
  115. #define IE_CISCO_FLAG_POSITION 0x08
  116. #define SUPPORT_CKIP_MIC 0x08
  117. #define SUPPORT_CKIP_PK 0x10
  118. #define RT_RF_OFF_LEVL_ASPM BIT0
  119. #define RT_RF_OFF_LEVL_CLK_REQ BIT1
  120. #define RT_RF_OFF_LEVL_PCI_D3 BIT2
  121. #define RT_RF_OFF_LEVL_HALT_NIC BIT3
  122. #define RT_RF_OFF_LEVL_FREE_FW BIT4
  123. #define RT_RF_OFF_LEVL_FW_32K BIT5
  124. #define RT_RF_PS_LEVEL_ALWAYS_ASPM BIT6
  125. #define RT_RF_LPS_DISALBE_2R BIT30
  126. #define RT_RF_LPS_LEVEL_ASPM BIT31
  127. #define RT_IN_PS_LEVEL(pPSC, _PS_FLAG) \
  128. ((pPSC->CurPsLevel & _PS_FLAG) ? true : false)
  129. #define RT_CLEAR_PS_LEVEL(pPSC, _PS_FLAG) \
  130. (pPSC->CurPsLevel &= (~(_PS_FLAG)))
  131. #define RT_SET_PS_LEVEL(pPSC, _PS_FLAG) (pPSC->CurPsLevel |= _PS_FLAG)
  132. /* defined for skb cb field */
  133. /* At most 28 byte */
  134. struct cb_desc {
  135. /* Tx Desc Related flags (8-9) */
  136. u8 bLastIniPkt:1;
  137. u8 bCmdOrInit:1;
  138. u8 bFirstSeg:1;
  139. u8 bLastSeg:1;
  140. u8 bEncrypt:1;
  141. u8 bTxDisableRateFallBack:1;
  142. u8 bTxUseDriverAssingedRate:1;
  143. u8 bHwSec:1;
  144. u8 nStuckCount;
  145. /* Tx Firmware Related flags (10-11)*/
  146. u8 bCTSEnable:1;
  147. u8 bRTSEnable:1;
  148. u8 bUseShortGI:1;
  149. u8 bUseShortPreamble:1;
  150. u8 bTxEnableFwCalcDur:1;
  151. u8 bAMPDUEnable:1;
  152. u8 bRTSSTBC:1;
  153. u8 RTSSC:1;
  154. u8 bRTSBW:1;
  155. u8 bPacketBW:1;
  156. u8 bRTSUseShortPreamble:1;
  157. u8 bRTSUseShortGI:1;
  158. u8 bMulticast:1;
  159. u8 bBroadcast:1;
  160. u8 drv_agg_enable:1;
  161. u8 reserved2:1;
  162. /* Tx Desc related element(12-19) */
  163. u8 rata_index;
  164. u8 queue_index;
  165. u16 txbuf_size;
  166. u8 RATRIndex;
  167. u8 bAMSDU:1;
  168. u8 bFromAggrQ:1;
  169. u8 reserved6:6;
  170. u8 macId;
  171. u8 priority;
  172. /* Tx firmware related element(20-27) */
  173. u8 data_rate;
  174. u8 rts_rate;
  175. u8 ampdu_factor;
  176. u8 ampdu_density;
  177. u8 DrvAggrNum;
  178. u8 bdhcp;
  179. u16 pkt_size;
  180. u8 bIsSpecialDataFrame;
  181. u8 bBTTxPacket;
  182. u8 bIsBTProbRsp;
  183. };
  184. enum sw_chnl_cmd_id {
  185. CmdID_End,
  186. CmdID_SetTxPowerLevel,
  187. CmdID_BBRegWrite10,
  188. CmdID_WritePortUlong,
  189. CmdID_WritePortUshort,
  190. CmdID_WritePortUchar,
  191. CmdID_RF_WriteReg,
  192. };
  193. struct sw_chnl_cmd {
  194. enum sw_chnl_cmd_id CmdID;
  195. u32 Para1;
  196. u32 Para2;
  197. u32 msDelay;
  198. } __packed;
  199. /*--------------------------Define -------------------------------------------*/
  200. #define MGN_1M 0x02
  201. #define MGN_2M 0x04
  202. #define MGN_5_5M 0x0b
  203. #define MGN_11M 0x16
  204. #define MGN_6M 0x0c
  205. #define MGN_9M 0x12
  206. #define MGN_12M 0x18
  207. #define MGN_18M 0x24
  208. #define MGN_24M 0x30
  209. #define MGN_36M 0x48
  210. #define MGN_48M 0x60
  211. #define MGN_54M 0x6c
  212. #define MGN_MCS0 0x80
  213. #define MGN_MCS1 0x81
  214. #define MGN_MCS2 0x82
  215. #define MGN_MCS3 0x83
  216. #define MGN_MCS4 0x84
  217. #define MGN_MCS5 0x85
  218. #define MGN_MCS6 0x86
  219. #define MGN_MCS7 0x87
  220. #define MGN_MCS8 0x88
  221. #define MGN_MCS9 0x89
  222. #define MGN_MCS10 0x8a
  223. #define MGN_MCS11 0x8b
  224. #define MGN_MCS12 0x8c
  225. #define MGN_MCS13 0x8d
  226. #define MGN_MCS14 0x8e
  227. #define MGN_MCS15 0x8f
  228. #define MGN_MCS0_SG 0x90
  229. #define MGN_MCS1_SG 0x91
  230. #define MGN_MCS2_SG 0x92
  231. #define MGN_MCS3_SG 0x93
  232. #define MGN_MCS4_SG 0x94
  233. #define MGN_MCS5_SG 0x95
  234. #define MGN_MCS6_SG 0x96
  235. #define MGN_MCS7_SG 0x97
  236. #define MGN_MCS8_SG 0x98
  237. #define MGN_MCS9_SG 0x99
  238. #define MGN_MCS10_SG 0x9a
  239. #define MGN_MCS11_SG 0x9b
  240. #define MGN_MCS12_SG 0x9c
  241. #define MGN_MCS13_SG 0x9d
  242. #define MGN_MCS14_SG 0x9e
  243. #define MGN_MCS15_SG 0x9f
  244. enum _ReasonCode {
  245. unspec_reason = 0x1,
  246. auth_not_valid = 0x2,
  247. deauth_lv_ss = 0x3,
  248. inactivity = 0x4,
  249. ap_overload = 0x5,
  250. class2_err = 0x6,
  251. class3_err = 0x7,
  252. disas_lv_ss = 0x8,
  253. asoc_not_auth = 0x9,
  254. mic_failure = 0xe,
  255. invalid_IE = 0x0d,
  256. four_way_tmout = 0x0f,
  257. two_way_tmout = 0x10,
  258. IE_dismatch = 0x11,
  259. invalid_Gcipher = 0x12,
  260. invalid_Pcipher = 0x13,
  261. invalid_AKMP = 0x14,
  262. unsup_RSNIEver = 0x15,
  263. invalid_RSNIE = 0x16,
  264. auth_802_1x_fail = 0x17,
  265. ciper_reject = 0x18,
  266. QoS_unspec = 0x20,
  267. QAP_bandwidth = 0x21,
  268. poor_condition = 0x22,
  269. no_facility = 0x23,
  270. req_declined = 0x25,
  271. invalid_param = 0x26,
  272. req_not_honored = 0x27,
  273. TS_not_created = 0x2F,
  274. DL_not_allowed = 0x30,
  275. dest_not_exist = 0x31,
  276. dest_not_QSTA = 0x32,
  277. };
  278. enum hal_def_variable {
  279. HAL_DEF_TPC_ENABLE,
  280. HAL_DEF_INIT_GAIN,
  281. HAL_DEF_PROT_IMP_MODE,
  282. HAL_DEF_HIGH_POWER_MECHANISM,
  283. HAL_DEF_RATE_ADAPTIVE_MECHANISM,
  284. HAL_DEF_ANTENNA_DIVERSITY_MECHANISM,
  285. HAL_DEF_LED,
  286. HAL_DEF_CW_MAX_MIN,
  287. HAL_DEF_WOWLAN,
  288. HAL_DEF_ENDPOINTS,
  289. HAL_DEF_MIN_TX_POWER_DBM,
  290. HAL_DEF_MAX_TX_POWER_DBM,
  291. HW_DEF_EFUSE_REPG_SECTION1_FLAG,
  292. HW_DEF_EFUSE_REPG_DATA,
  293. HW_DEF_GPIO,
  294. HAL_DEF_PCI_SUPPORT_ASPM,
  295. HAL_DEF_THERMAL_VALUE,
  296. HAL_DEF_USB_IN_TOKEN_REV,
  297. };
  298. enum hw_variables {
  299. HW_VAR_ETHER_ADDR,
  300. HW_VAR_MULTICAST_REG,
  301. HW_VAR_BASIC_RATE,
  302. HW_VAR_BSSID,
  303. HW_VAR_MEDIA_STATUS,
  304. HW_VAR_SECURITY_CONF,
  305. HW_VAR_BEACON_INTERVAL,
  306. HW_VAR_ATIM_WINDOW,
  307. HW_VAR_LISTEN_INTERVAL,
  308. HW_VAR_CS_COUNTER,
  309. HW_VAR_DEFAULTKEY0,
  310. HW_VAR_DEFAULTKEY1,
  311. HW_VAR_DEFAULTKEY2,
  312. HW_VAR_DEFAULTKEY3,
  313. HW_VAR_SIFS,
  314. HW_VAR_DIFS,
  315. HW_VAR_EIFS,
  316. HW_VAR_SLOT_TIME,
  317. HW_VAR_ACK_PREAMBLE,
  318. HW_VAR_CW_CONFIG,
  319. HW_VAR_CW_VALUES,
  320. HW_VAR_RATE_FALLBACK_CONTROL,
  321. HW_VAR_CONTENTION_WINDOW,
  322. HW_VAR_RETRY_COUNT,
  323. HW_VAR_TR_SWITCH,
  324. HW_VAR_COMMAND,
  325. HW_VAR_WPA_CONFIG,
  326. HW_VAR_AMPDU_MIN_SPACE,
  327. HW_VAR_SHORTGI_DENSITY,
  328. HW_VAR_AMPDU_FACTOR,
  329. HW_VAR_MCS_RATE_AVAILABLE,
  330. HW_VAR_AC_PARAM,
  331. HW_VAR_ACM_CTRL,
  332. HW_VAR_DIS_Req_Qsize,
  333. HW_VAR_CCX_CHNL_LOAD,
  334. HW_VAR_CCX_NOISE_HISTOGRAM,
  335. HW_VAR_CCX_CLM_NHM,
  336. HW_VAR_TxOPLimit,
  337. HW_VAR_TURBO_MODE,
  338. HW_VAR_RF_STATE,
  339. HW_VAR_RF_OFF_BY_HW,
  340. HW_VAR_BUS_SPEED,
  341. HW_VAR_SET_DEV_POWER,
  342. HW_VAR_RCR,
  343. HW_VAR_RATR_0,
  344. HW_VAR_RRSR,
  345. HW_VAR_CPU_RST,
  346. HW_VAR_CECHK_BSSID,
  347. HW_VAR_LBK_MODE,
  348. HW_VAR_AES_11N_FIX,
  349. HW_VAR_USB_RX_AGGR,
  350. HW_VAR_USER_CONTROL_TURBO_MODE,
  351. HW_VAR_RETRY_LIMIT,
  352. HW_VAR_INIT_TX_RATE,
  353. HW_VAR_TX_RATE_REG,
  354. HW_VAR_EFUSE_USAGE,
  355. HW_VAR_EFUSE_BYTES,
  356. HW_VAR_AUTOLOAD_STATUS,
  357. HW_VAR_RF_2R_DISABLE,
  358. HW_VAR_SET_RPWM,
  359. HW_VAR_H2C_FW_PWRMODE,
  360. HW_VAR_H2C_FW_JOINBSSRPT,
  361. HW_VAR_1X1_RECV_COMBINE,
  362. HW_VAR_STOP_SEND_BEACON,
  363. HW_VAR_TSF_TIMER,
  364. HW_VAR_IO_CMD,
  365. HW_VAR_RF_RECOVERY,
  366. HW_VAR_H2C_FW_UPDATE_GTK,
  367. HW_VAR_WF_MASK,
  368. HW_VAR_WF_CRC,
  369. HW_VAR_WF_IS_MAC_ADDR,
  370. HW_VAR_H2C_FW_OFFLOAD,
  371. HW_VAR_RESET_WFCRC,
  372. HW_VAR_HANDLE_FW_C2H,
  373. HW_VAR_DL_FW_RSVD_PAGE,
  374. HW_VAR_AID,
  375. HW_VAR_HW_SEQ_ENABLE,
  376. HW_VAR_CORRECT_TSF,
  377. HW_VAR_BCN_VALID,
  378. HW_VAR_FWLPS_RF_ON,
  379. HW_VAR_DUAL_TSF_RST,
  380. HW_VAR_SWITCH_EPHY_WoWLAN,
  381. HW_VAR_INT_MIGRATION,
  382. HW_VAR_INT_AC,
  383. HW_VAR_RF_TIMING,
  384. };
  385. enum rt_op_mode {
  386. RT_OP_MODE_AP,
  387. RT_OP_MODE_INFRASTRUCTURE,
  388. RT_OP_MODE_IBSS,
  389. RT_OP_MODE_NO_LINK,
  390. };
  391. #define aSifsTime \
  392. (((priv->rtllib->current_network.mode == IEEE_A) \
  393. || (priv->rtllib->current_network.mode == IEEE_N_24G) \
  394. || (priv->rtllib->current_network.mode == IEEE_N_5G)) ? 16 : 10)
  395. #define MGMT_QUEUE_NUM 5
  396. #define IEEE_CMD_SET_WPA_PARAM 1
  397. #define IEEE_CMD_SET_WPA_IE 2
  398. #define IEEE_CMD_SET_ENCRYPTION 3
  399. #define IEEE_CMD_MLME 4
  400. #define IEEE_PARAM_WPA_ENABLED 1
  401. #define IEEE_PARAM_TKIP_COUNTERMEASURES 2
  402. #define IEEE_PARAM_DROP_UNENCRYPTED 3
  403. #define IEEE_PARAM_PRIVACY_INVOKED 4
  404. #define IEEE_PARAM_AUTH_ALGS 5
  405. #define IEEE_PARAM_IEEE_802_1X 6
  406. #define IEEE_PARAM_WPAX_SELECT 7
  407. #define IEEE_PROTO_WPA 1
  408. #define IEEE_PROTO_RSN 2
  409. #define IEEE_WPAX_USEGROUP 0
  410. #define IEEE_WPAX_WEP40 1
  411. #define IEEE_WPAX_TKIP 2
  412. #define IEEE_WPAX_WRAP 3
  413. #define IEEE_WPAX_CCMP 4
  414. #define IEEE_WPAX_WEP104 5
  415. #define IEEE_KEY_MGMT_IEEE8021X 1
  416. #define IEEE_KEY_MGMT_PSK 2
  417. #define IEEE_MLME_STA_DEAUTH 1
  418. #define IEEE_MLME_STA_DISASSOC 2
  419. #define IEEE_CRYPT_ERR_UNKNOWN_ALG 2
  420. #define IEEE_CRYPT_ERR_UNKNOWN_ADDR 3
  421. #define IEEE_CRYPT_ERR_CRYPT_INIT_FAILED 4
  422. #define IEEE_CRYPT_ERR_KEY_SET_FAILED 5
  423. #define IEEE_CRYPT_ERR_TX_KEY_SET_FAILED 6
  424. #define IEEE_CRYPT_ERR_CARD_CONF_FAILED 7
  425. #define IEEE_CRYPT_ALG_NAME_LEN 16
  426. #define MAX_IE_LEN 0xff
  427. #define RT_ASSERT_RET(_Exp) do {} while (0)
  428. #define RT_ASSERT_RET_VALUE(_Exp, Ret) \
  429. do {} while (0)
  430. struct ieee_param {
  431. u32 cmd;
  432. u8 sta_addr[ETH_ALEN];
  433. union {
  434. struct {
  435. u8 name;
  436. u32 value;
  437. } wpa_param;
  438. struct {
  439. u32 len;
  440. u8 reserved[32];
  441. u8 data[0];
  442. } wpa_ie;
  443. struct {
  444. int command;
  445. int reason_code;
  446. } mlme;
  447. struct {
  448. u8 alg[IEEE_CRYPT_ALG_NAME_LEN];
  449. u8 set_tx;
  450. u32 err;
  451. u8 idx;
  452. u8 seq[8]; /* sequence counter (set: RX, get: TX) */
  453. u16 key_len;
  454. u8 key[0];
  455. } crypt;
  456. } u;
  457. };
  458. #if WIRELESS_EXT < 17
  459. #define IW_QUAL_QUAL_INVALID 0x10
  460. #define IW_QUAL_LEVEL_INVALID 0x20
  461. #define IW_QUAL_NOISE_INVALID 0x40
  462. #define IW_QUAL_QUAL_UPDATED 0x1
  463. #define IW_QUAL_LEVEL_UPDATED 0x2
  464. #define IW_QUAL_NOISE_UPDATED 0x4
  465. #endif
  466. #define MSECS(t) msecs_to_jiffies(t)
  467. #define msleep_interruptible_rsl msleep_interruptible
  468. #define RTLLIB_DATA_LEN 2304
  469. /* Maximum size for the MA-UNITDATA primitive, 802.11 standard section
  470. 6.2.1.1.2.
  471. The figure in section 7.1.2 suggests a body size of up to 2312
  472. bytes is allowed, which is a bit confusing, I suspect this
  473. represents the 2304 bytes of real data, plus a possible 8 bytes of
  474. WEP IV and ICV. (this interpretation suggested by Ramiro Barreiro) */
  475. #define RTLLIB_1ADDR_LEN 10
  476. #define RTLLIB_2ADDR_LEN 16
  477. #define RTLLIB_3ADDR_LEN 24
  478. #define RTLLIB_4ADDR_LEN 30
  479. #define RTLLIB_FCS_LEN 4
  480. #define RTLLIB_HLEN (RTLLIB_4ADDR_LEN)
  481. #define RTLLIB_FRAME_LEN (RTLLIB_DATA_LEN + RTLLIB_HLEN)
  482. #define RTLLIB_MGMT_HDR_LEN 24
  483. #define RTLLIB_DATA_HDR3_LEN 24
  484. #define RTLLIB_DATA_HDR4_LEN 30
  485. #define RTLLIB_SKBBUFFER_SIZE 2500
  486. #define MIN_FRAG_THRESHOLD 256U
  487. #define MAX_FRAG_THRESHOLD 2346U
  488. #define MAX_HT_DATA_FRAG_THRESHOLD 0x2000
  489. #define HT_AMSDU_SIZE_4K 3839
  490. #define HT_AMSDU_SIZE_8K 7935
  491. /* Frame control field constants */
  492. #define RTLLIB_FCTL_VERS 0x0003
  493. #define RTLLIB_FCTL_FTYPE 0x000c
  494. #define RTLLIB_FCTL_STYPE 0x00f0
  495. #define RTLLIB_FCTL_FRAMETYPE 0x00fc
  496. #define RTLLIB_FCTL_TODS 0x0100
  497. #define RTLLIB_FCTL_FROMDS 0x0200
  498. #define RTLLIB_FCTL_DSTODS 0x0300
  499. #define RTLLIB_FCTL_MOREFRAGS 0x0400
  500. #define RTLLIB_FCTL_RETRY 0x0800
  501. #define RTLLIB_FCTL_PM 0x1000
  502. #define RTLLIB_FCTL_MOREDATA 0x2000
  503. #define RTLLIB_FCTL_WEP 0x4000
  504. #define RTLLIB_FCTL_ORDER 0x8000
  505. #define RTLLIB_FTYPE_MGMT 0x0000
  506. #define RTLLIB_FTYPE_CTL 0x0004
  507. #define RTLLIB_FTYPE_DATA 0x0008
  508. /* management */
  509. #define RTLLIB_STYPE_ASSOC_REQ 0x0000
  510. #define RTLLIB_STYPE_ASSOC_RESP 0x0010
  511. #define RTLLIB_STYPE_REASSOC_REQ 0x0020
  512. #define RTLLIB_STYPE_REASSOC_RESP 0x0030
  513. #define RTLLIB_STYPE_PROBE_REQ 0x0040
  514. #define RTLLIB_STYPE_PROBE_RESP 0x0050
  515. #define RTLLIB_STYPE_BEACON 0x0080
  516. #define RTLLIB_STYPE_ATIM 0x0090
  517. #define RTLLIB_STYPE_DISASSOC 0x00A0
  518. #define RTLLIB_STYPE_AUTH 0x00B0
  519. #define RTLLIB_STYPE_DEAUTH 0x00C0
  520. #define RTLLIB_STYPE_MANAGE_ACT 0x00D0
  521. /* control */
  522. #define RTLLIB_STYPE_PSPOLL 0x00A0
  523. #define RTLLIB_STYPE_RTS 0x00B0
  524. #define RTLLIB_STYPE_CTS 0x00C0
  525. #define RTLLIB_STYPE_ACK 0x00D0
  526. #define RTLLIB_STYPE_CFEND 0x00E0
  527. #define RTLLIB_STYPE_CFENDACK 0x00F0
  528. #define RTLLIB_STYPE_BLOCKACK 0x0094
  529. /* data */
  530. #define RTLLIB_STYPE_DATA 0x0000
  531. #define RTLLIB_STYPE_DATA_CFACK 0x0010
  532. #define RTLLIB_STYPE_DATA_CFPOLL 0x0020
  533. #define RTLLIB_STYPE_DATA_CFACKPOLL 0x0030
  534. #define RTLLIB_STYPE_NULLFUNC 0x0040
  535. #define RTLLIB_STYPE_CFACK 0x0050
  536. #define RTLLIB_STYPE_CFPOLL 0x0060
  537. #define RTLLIB_STYPE_CFACKPOLL 0x0070
  538. #define RTLLIB_STYPE_QOS_DATA 0x0080
  539. #define RTLLIB_STYPE_QOS_NULL 0x00C0
  540. #define RTLLIB_SCTL_FRAG 0x000F
  541. #define RTLLIB_SCTL_SEQ 0xFFF0
  542. /* QOS control */
  543. #define RTLLIB_QCTL_TID 0x000F
  544. #define FC_QOS_BIT BIT7
  545. #define IsDataFrame(pdu) (((pdu[0] & 0x0C) == 0x08) ? true : false)
  546. #define IsLegacyDataFrame(pdu) (IsDataFrame(pdu) && (!(pdu[0]&FC_QOS_BIT)))
  547. #define IsQoSDataFrame(pframe) \
  548. ((*(u16 *)pframe&(RTLLIB_STYPE_QOS_DATA|RTLLIB_FTYPE_DATA)) == \
  549. (RTLLIB_STYPE_QOS_DATA|RTLLIB_FTYPE_DATA))
  550. #define Frame_Order(pframe) (*(u16 *)pframe&RTLLIB_FCTL_ORDER)
  551. #define SN_LESS(a, b) (((a-b)&0x800) != 0)
  552. #define SN_EQUAL(a, b) (a == b)
  553. #define MAX_DEV_ADDR_SIZE 8
  554. enum act_category {
  555. ACT_CAT_QOS = 1,
  556. ACT_CAT_DLS = 2,
  557. ACT_CAT_BA = 3,
  558. ACT_CAT_HT = 7,
  559. ACT_CAT_WMM = 17,
  560. };
  561. enum ts_action {
  562. ACT_ADDTSREQ = 0,
  563. ACT_ADDTSRSP = 1,
  564. ACT_DELTS = 2,
  565. ACT_SCHEDULE = 3,
  566. };
  567. enum ba_action {
  568. ACT_ADDBAREQ = 0,
  569. ACT_ADDBARSP = 1,
  570. ACT_DELBA = 2,
  571. };
  572. enum init_gain_op_type {
  573. IG_Backup = 0,
  574. IG_Restore,
  575. IG_Max
  576. };
  577. enum led_ctl_mode {
  578. LED_CTL_POWER_ON = 1,
  579. LED_CTL_LINK = 2,
  580. LED_CTL_NO_LINK = 3,
  581. LED_CTL_TX = 4,
  582. LED_CTL_RX = 5,
  583. LED_CTL_SITE_SURVEY = 6,
  584. LED_CTL_POWER_OFF = 7,
  585. LED_CTL_START_TO_LINK = 8,
  586. LED_CTL_START_WPS = 9,
  587. LED_CTL_STOP_WPS = 10,
  588. LED_CTL_START_WPS_BOTTON = 11,
  589. LED_CTL_STOP_WPS_FAIL = 12,
  590. LED_CTL_STOP_WPS_FAIL_OVERLAP = 13,
  591. };
  592. enum rt_rf_type_def {
  593. RF_1T2R = 0,
  594. RF_2T4R,
  595. RF_2T2R,
  596. RF_1T1R,
  597. RF_2T2R_GREEN,
  598. RF_819X_MAX_TYPE
  599. };
  600. enum wireless_mode {
  601. WIRELESS_MODE_UNKNOWN = 0x00,
  602. WIRELESS_MODE_A = 0x01,
  603. WIRELESS_MODE_B = 0x02,
  604. WIRELESS_MODE_G = 0x04,
  605. WIRELESS_MODE_AUTO = 0x08,
  606. WIRELESS_MODE_N_24G = 0x10,
  607. WIRELESS_MODE_N_5G = 0x20
  608. };
  609. enum wireless_network_type {
  610. WIRELESS_11B = 1,
  611. WIRELESS_11G = 2,
  612. WIRELESS_11A = 4,
  613. WIRELESS_11N = 8
  614. };
  615. #define OUI_SUBTYPE_WMM_INFO 0
  616. #define OUI_SUBTYPE_WMM_PARAM 1
  617. #define OUI_SUBTYPE_QOS_CAPABI 5
  618. /* debug macros */
  619. extern u32 rtllib_debug_level;
  620. #define RTLLIB_DEBUG(level, fmt, args...) \
  621. do { \
  622. if (rtllib_debug_level & (level)) \
  623. printk(KERN_DEBUG "rtllib: " fmt, ## args); \
  624. } while (0)
  625. #define RTLLIB_DEBUG_DATA(level, data, datalen) \
  626. do { \
  627. if ((rtllib_debug_level & (level)) == (level)) { \
  628. int i; \
  629. u8 *pdata = (u8 *)data; \
  630. printk(KERN_DEBUG "rtllib: %s()\n", __func__); \
  631. for (i = 0; i < (int)(datalen); i++) { \
  632. printk("%2.2x ", pdata[i]); \
  633. if ((i+1)%16 == 0) \
  634. printk("\n"); \
  635. } \
  636. printk("\n"); \
  637. } \
  638. } while (0)
  639. /*
  640. * To use the debug system;
  641. *
  642. * If you are defining a new debug classification, simply add it to the #define
  643. * list here in the form of:
  644. *
  645. * #define RTLLIB_DL_xxxx VALUE
  646. *
  647. * shifting value to the left one bit from the previous entry. xxxx should be
  648. * the name of the classification (for example, WEP)
  649. *
  650. * You then need to either add a RTLLIB_xxxx_DEBUG() macro definition for your
  651. * classification, or use RTLLIB_DEBUG(RTLLIB_DL_xxxx, ...) whenever you want
  652. * to send output to that classification.
  653. *
  654. * To add your debug level to the list of levels seen when you perform
  655. *
  656. * % cat /proc/net/ipw/debug_level
  657. *
  658. * you simply need to add your entry to the ipw_debug_levels array.
  659. *
  660. *
  661. */
  662. #define RTLLIB_DL_INFO (1<<0)
  663. #define RTLLIB_DL_WX (1<<1)
  664. #define RTLLIB_DL_SCAN (1<<2)
  665. #define RTLLIB_DL_STATE (1<<3)
  666. #define RTLLIB_DL_MGMT (1<<4)
  667. #define RTLLIB_DL_FRAG (1<<5)
  668. #define RTLLIB_DL_EAP (1<<6)
  669. #define RTLLIB_DL_DROP (1<<7)
  670. #define RTLLIB_DL_TX (1<<8)
  671. #define RTLLIB_DL_RX (1<<9)
  672. #define RTLLIB_DL_HT (1<<10)
  673. #define RTLLIB_DL_BA (1<<11)
  674. #define RTLLIB_DL_TS (1<<12)
  675. #define RTLLIB_DL_QOS (1<<13)
  676. #define RTLLIB_DL_REORDER (1<<14)
  677. #define RTLLIB_DL_IOT (1<<15)
  678. #define RTLLIB_DL_IPS (1<<16)
  679. #define RTLLIB_DL_TRACE (1<<29)
  680. #define RTLLIB_DL_DATA (1<<30)
  681. #define RTLLIB_DL_ERR (1<<31)
  682. #define RTLLIB_ERROR(f, a...) printk(KERN_ERR "rtllib: " f, ## a)
  683. #define RTLLIB_WARNING(f, a...) printk(KERN_WARNING "rtllib: " f, ## a)
  684. #define RTLLIB_DEBUG_INFO(f, a...) RTLLIB_DEBUG(RTLLIB_DL_INFO, f, ## a)
  685. #define RTLLIB_DEBUG_WX(f, a...) RTLLIB_DEBUG(RTLLIB_DL_WX, f, ## a)
  686. #define RTLLIB_DEBUG_SCAN(f, a...) RTLLIB_DEBUG(RTLLIB_DL_SCAN, f, ## a)
  687. #define RTLLIB_DEBUG_STATE(f, a...) RTLLIB_DEBUG(RTLLIB_DL_STATE, f, ## a)
  688. #define RTLLIB_DEBUG_MGMT(f, a...) RTLLIB_DEBUG(RTLLIB_DL_MGMT, f, ## a)
  689. #define RTLLIB_DEBUG_FRAG(f, a...) RTLLIB_DEBUG(RTLLIB_DL_FRAG, f, ## a)
  690. #define RTLLIB_DEBUG_EAP(f, a...) RTLLIB_DEBUG(RTLLIB_DL_EAP, f, ## a)
  691. #define RTLLIB_DEBUG_DROP(f, a...) RTLLIB_DEBUG(RTLLIB_DL_DROP, f, ## a)
  692. #define RTLLIB_DEBUG_TX(f, a...) RTLLIB_DEBUG(RTLLIB_DL_TX, f, ## a)
  693. #define RTLLIB_DEBUG_RX(f, a...) RTLLIB_DEBUG(RTLLIB_DL_RX, f, ## a)
  694. #define RTLLIB_DEBUG_QOS(f, a...) RTLLIB_DEBUG(RTLLIB_DL_QOS, f, ## a)
  695. /* Added by Annie, 2005-11-22. */
  696. #define MAX_STR_LEN 64
  697. /* I want to see ASCII 33 to 126 only. Otherwise, I print '?'. */
  698. #define PRINTABLE(_ch) (_ch > '!' && _ch < '~')
  699. #define RTLLIB_PRINT_STR(_Comp, _TitleString, _Ptr, _Len) \
  700. if ((_Comp) & level) { \
  701. int __i; \
  702. u8 struct buffer[MAX_STR_LEN]; \
  703. int length = (_Len < MAX_STR_LEN) ? _Len : (MAX_STR_LEN-1) ;\
  704. memset(struct buffer, 0, MAX_STR_LEN); \
  705. memcpy(struct buffer, (u8 *)_Ptr, length); \
  706. for (__i = 0; __i < MAX_STR_LEN; __i++) { \
  707. if (!PRINTABLE(struct buffer[__i])) \
  708. struct buffer[__i] = '?'; \
  709. } \
  710. struct buffer[length] = '\0'; \
  711. printk(KERN_INFO "Rtl819x: "); \
  712. printk(_TitleString); \
  713. printk(": %d, <%s>\n", _Len, struct buffer); \
  714. }
  715. #ifndef ETH_P_PAE
  716. #define ETH_P_PAE 0x888E /* Port Access Entity (IEEE 802.1X) */
  717. #define ETH_P_IP 0x0800 /* Internet Protocol packet */
  718. #define ETH_P_ARP 0x0806 /* Address Resolution packet */
  719. #endif /* ETH_P_PAE */
  720. #define ETH_P_PREAUTH 0x88C7 /* IEEE 802.11i pre-authentication */
  721. #ifndef ETH_P_80211_RAW
  722. #define ETH_P_80211_RAW (ETH_P_ECONET + 1)
  723. #endif
  724. /* IEEE 802.11 defines */
  725. #define P80211_OUI_LEN 3
  726. struct rtllib_snap_hdr {
  727. u8 dsap; /* always 0xAA */
  728. u8 ssap; /* always 0xAA */
  729. u8 ctrl; /* always 0x03 */
  730. u8 oui[P80211_OUI_LEN]; /* organizational universal id */
  731. } __packed;
  732. enum _REG_PREAMBLE_MODE {
  733. PREAMBLE_LONG = 1,
  734. PREAMBLE_AUTO = 2,
  735. PREAMBLE_SHORT = 3,
  736. };
  737. #define SNAP_SIZE sizeof(struct rtllib_snap_hdr)
  738. #define WLAN_FC_GET_VERS(fc) ((fc) & RTLLIB_FCTL_VERS)
  739. #define WLAN_FC_GET_TYPE(fc) ((fc) & RTLLIB_FCTL_FTYPE)
  740. #define WLAN_FC_GET_STYPE(fc) ((fc) & RTLLIB_FCTL_STYPE)
  741. #define WLAN_FC_MORE_DATA(fc) ((fc) & RTLLIB_FCTL_MOREDATA)
  742. #define WLAN_FC_GET_FRAMETYPE(fc) ((fc) & RTLLIB_FCTL_FRAMETYPE)
  743. #define WLAN_GET_SEQ_FRAG(seq) ((seq) & RTLLIB_SCTL_FRAG)
  744. #define WLAN_GET_SEQ_SEQ(seq) (((seq) & RTLLIB_SCTL_SEQ) >> 4)
  745. /* Authentication algorithms */
  746. #define WLAN_AUTH_OPEN 0
  747. #define WLAN_AUTH_SHARED_KEY 1
  748. #define WLAN_AUTH_LEAP 128
  749. #define WLAN_AUTH_CHALLENGE_LEN 128
  750. #define WLAN_CAPABILITY_ESS (1<<0)
  751. #define WLAN_CAPABILITY_IBSS (1<<1)
  752. #define WLAN_CAPABILITY_CF_POLLABLE (1<<2)
  753. #define WLAN_CAPABILITY_CF_POLL_REQUEST (1<<3)
  754. #define WLAN_CAPABILITY_PRIVACY (1<<4)
  755. #define WLAN_CAPABILITY_SHORT_PREAMBLE (1<<5)
  756. #define WLAN_CAPABILITY_PBCC (1<<6)
  757. #define WLAN_CAPABILITY_CHANNEL_AGILITY (1<<7)
  758. #define WLAN_CAPABILITY_SPECTRUM_MGMT (1<<8)
  759. #define WLAN_CAPABILITY_QOS (1<<9)
  760. #define WLAN_CAPABILITY_SHORT_SLOT_TIME (1<<10)
  761. #define WLAN_CAPABILITY_DSSS_OFDM (1<<13)
  762. /* 802.11g ERP information element */
  763. #define WLAN_ERP_NON_ERP_PRESENT (1<<0)
  764. #define WLAN_ERP_USE_PROTECTION (1<<1)
  765. #define WLAN_ERP_BARKER_PREAMBLE (1<<2)
  766. #define RTLLIB_STATMASK_SIGNAL (1<<0)
  767. #define RTLLIB_STATMASK_RSSI (1<<1)
  768. #define RTLLIB_STATMASK_NOISE (1<<2)
  769. #define RTLLIB_STATMASK_RATE (1<<3)
  770. #define RTLLIB_STATMASK_WEMASK 0x7
  771. #define RTLLIB_CCK_MODULATION (1<<0)
  772. #define RTLLIB_OFDM_MODULATION (1<<1)
  773. #define RTLLIB_24GHZ_BAND (1<<0)
  774. #define RTLLIB_52GHZ_BAND (1<<1)
  775. #define RTLLIB_CCK_RATE_LEN 4
  776. #define RTLLIB_CCK_RATE_1MB 0x02
  777. #define RTLLIB_CCK_RATE_2MB 0x04
  778. #define RTLLIB_CCK_RATE_5MB 0x0B
  779. #define RTLLIB_CCK_RATE_11MB 0x16
  780. #define RTLLIB_OFDM_RATE_LEN 8
  781. #define RTLLIB_OFDM_RATE_6MB 0x0C
  782. #define RTLLIB_OFDM_RATE_9MB 0x12
  783. #define RTLLIB_OFDM_RATE_12MB 0x18
  784. #define RTLLIB_OFDM_RATE_18MB 0x24
  785. #define RTLLIB_OFDM_RATE_24MB 0x30
  786. #define RTLLIB_OFDM_RATE_36MB 0x48
  787. #define RTLLIB_OFDM_RATE_48MB 0x60
  788. #define RTLLIB_OFDM_RATE_54MB 0x6C
  789. #define RTLLIB_BASIC_RATE_MASK 0x80
  790. #define RTLLIB_CCK_RATE_1MB_MASK (1<<0)
  791. #define RTLLIB_CCK_RATE_2MB_MASK (1<<1)
  792. #define RTLLIB_CCK_RATE_5MB_MASK (1<<2)
  793. #define RTLLIB_CCK_RATE_11MB_MASK (1<<3)
  794. #define RTLLIB_OFDM_RATE_6MB_MASK (1<<4)
  795. #define RTLLIB_OFDM_RATE_9MB_MASK (1<<5)
  796. #define RTLLIB_OFDM_RATE_12MB_MASK (1<<6)
  797. #define RTLLIB_OFDM_RATE_18MB_MASK (1<<7)
  798. #define RTLLIB_OFDM_RATE_24MB_MASK (1<<8)
  799. #define RTLLIB_OFDM_RATE_36MB_MASK (1<<9)
  800. #define RTLLIB_OFDM_RATE_48MB_MASK (1<<10)
  801. #define RTLLIB_OFDM_RATE_54MB_MASK (1<<11)
  802. #define RTLLIB_CCK_RATES_MASK 0x0000000F
  803. #define RTLLIB_CCK_BASIC_RATES_MASK (RTLLIB_CCK_RATE_1MB_MASK | \
  804. RTLLIB_CCK_RATE_2MB_MASK)
  805. #define RTLLIB_CCK_DEFAULT_RATES_MASK (RTLLIB_CCK_BASIC_RATES_MASK | \
  806. RTLLIB_CCK_RATE_5MB_MASK | \
  807. RTLLIB_CCK_RATE_11MB_MASK)
  808. #define RTLLIB_OFDM_RATES_MASK 0x00000FF0
  809. #define RTLLIB_OFDM_BASIC_RATES_MASK (RTLLIB_OFDM_RATE_6MB_MASK | \
  810. RTLLIB_OFDM_RATE_12MB_MASK | \
  811. RTLLIB_OFDM_RATE_24MB_MASK)
  812. #define RTLLIB_OFDM_DEFAULT_RATES_MASK (RTLLIB_OFDM_BASIC_RATES_MASK | \
  813. RTLLIB_OFDM_RATE_9MB_MASK | \
  814. RTLLIB_OFDM_RATE_18MB_MASK | \
  815. RTLLIB_OFDM_RATE_36MB_MASK | \
  816. RTLLIB_OFDM_RATE_48MB_MASK | \
  817. RTLLIB_OFDM_RATE_54MB_MASK)
  818. #define RTLLIB_DEFAULT_RATES_MASK (RTLLIB_OFDM_DEFAULT_RATES_MASK | \
  819. RTLLIB_CCK_DEFAULT_RATES_MASK)
  820. #define RTLLIB_NUM_OFDM_RATES 8
  821. #define RTLLIB_NUM_CCK_RATES 4
  822. #define RTLLIB_OFDM_SHIFT_MASK_A 4
  823. /* this is stolen and modified from the madwifi driver*/
  824. #define RTLLIB_FC0_TYPE_MASK 0x0c
  825. #define RTLLIB_FC0_TYPE_DATA 0x08
  826. #define RTLLIB_FC0_SUBTYPE_MASK 0xB0
  827. #define RTLLIB_FC0_SUBTYPE_QOS 0x80
  828. #define RTLLIB_QOS_HAS_SEQ(fc) \
  829. (((fc) & (RTLLIB_FC0_TYPE_MASK | RTLLIB_FC0_SUBTYPE_MASK)) == \
  830. (RTLLIB_FC0_TYPE_DATA | RTLLIB_FC0_SUBTYPE_QOS))
  831. /* this is stolen from ipw2200 driver */
  832. #define IEEE_IBSS_MAC_HASH_SIZE 31
  833. struct ieee_ibss_seq {
  834. u8 mac[ETH_ALEN];
  835. u16 seq_num[17];
  836. u16 frag_num[17];
  837. unsigned long packet_time[17];
  838. struct list_head list;
  839. };
  840. /* NOTE: This data is for statistical purposes; not all hardware provides this
  841. * information for frames received. Not setting these will not cause
  842. * any adverse affects. */
  843. struct rtllib_rx_stats {
  844. u64 mac_time;
  845. s8 rssi;
  846. u8 signal;
  847. u8 noise;
  848. u16 rate; /* in 100 kbps */
  849. u8 received_channel;
  850. u8 control;
  851. u8 mask;
  852. u8 freq;
  853. u16 len;
  854. u64 tsf;
  855. u32 beacon_time;
  856. u8 nic_type;
  857. u16 Length;
  858. u8 SignalQuality;
  859. s32 RecvSignalPower;
  860. s8 RxPower;
  861. u8 SignalStrength;
  862. u16 bHwError:1;
  863. u16 bCRC:1;
  864. u16 bICV:1;
  865. u16 bShortPreamble:1;
  866. u16 Antenna:1;
  867. u16 Decrypted:1;
  868. u16 Wakeup:1;
  869. u16 Reserved0:1;
  870. u8 AGC;
  871. u32 TimeStampLow;
  872. u32 TimeStampHigh;
  873. bool bShift;
  874. bool bIsQosData;
  875. u8 UserPriority;
  876. u8 RxDrvInfoSize;
  877. u8 RxBufShift;
  878. bool bIsAMPDU;
  879. bool bFirstMPDU;
  880. bool bContainHTC;
  881. bool RxIs40MHzPacket;
  882. u32 RxPWDBAll;
  883. u8 RxMIMOSignalStrength[4];
  884. s8 RxMIMOSignalQuality[2];
  885. bool bPacketMatchBSSID;
  886. bool bIsCCK;
  887. bool bPacketToSelf;
  888. u8 *virtual_address;
  889. u16 packetlength;
  890. u16 fraglength;
  891. u16 fragoffset;
  892. u16 ntotalfrag;
  893. bool bisrxaggrsubframe;
  894. bool bPacketBeacon;
  895. bool bToSelfBA;
  896. char cck_adc_pwdb[4];
  897. u16 Seq_Num;
  898. u8 nTotalAggPkt;
  899. };
  900. /* IEEE 802.11 requires that STA supports concurrent reception of at least
  901. * three fragmented frames. This define can be increased to support more
  902. * concurrent frames, but it should be noted that each entry can consume about
  903. * 2 kB of RAM and increasing cache size will slow down frame reassembly. */
  904. #define RTLLIB_FRAG_CACHE_LEN 4
  905. struct rtllib_frag_entry {
  906. unsigned long first_frag_time;
  907. unsigned int seq;
  908. unsigned int last_frag;
  909. struct sk_buff *skb;
  910. u8 src_addr[ETH_ALEN];
  911. u8 dst_addr[ETH_ALEN];
  912. };
  913. struct rtllib_stats {
  914. unsigned int tx_unicast_frames;
  915. unsigned int tx_multicast_frames;
  916. unsigned int tx_fragments;
  917. unsigned int tx_unicast_octets;
  918. unsigned int tx_multicast_octets;
  919. unsigned int tx_deferred_transmissions;
  920. unsigned int tx_single_retry_frames;
  921. unsigned int tx_multiple_retry_frames;
  922. unsigned int tx_retry_limit_exceeded;
  923. unsigned int tx_discards;
  924. unsigned int rx_unicast_frames;
  925. unsigned int rx_multicast_frames;
  926. unsigned int rx_fragments;
  927. unsigned int rx_unicast_octets;
  928. unsigned int rx_multicast_octets;
  929. unsigned int rx_fcs_errors;
  930. unsigned int rx_discards_no_buffer;
  931. unsigned int tx_discards_wrong_sa;
  932. unsigned int rx_discards_undecryptable;
  933. unsigned int rx_message_in_msg_fragments;
  934. unsigned int rx_message_in_bad_msg_fragments;
  935. };
  936. struct rtllib_device;
  937. #define SEC_KEY_1 (1<<0)
  938. #define SEC_KEY_2 (1<<1)
  939. #define SEC_KEY_3 (1<<2)
  940. #define SEC_KEY_4 (1<<3)
  941. #define SEC_ACTIVE_KEY (1<<4)
  942. #define SEC_AUTH_MODE (1<<5)
  943. #define SEC_UNICAST_GROUP (1<<6)
  944. #define SEC_LEVEL (1<<7)
  945. #define SEC_ENABLED (1<<8)
  946. #define SEC_ENCRYPT (1<<9)
  947. #define SEC_LEVEL_0 0 /* None */
  948. #define SEC_LEVEL_1 1 /* WEP 40 and 104 bit */
  949. #define SEC_LEVEL_2 2 /* Level 1 + TKIP */
  950. #define SEC_LEVEL_2_CKIP 3 /* Level 1 + CKIP */
  951. #define SEC_LEVEL_3 4 /* Level 2 + CCMP */
  952. #define SEC_ALG_NONE 0
  953. #define SEC_ALG_WEP 1
  954. #define SEC_ALG_TKIP 2
  955. #define SEC_ALG_CCMP 4
  956. #define WEP_KEY_LEN 13
  957. #define SCM_KEY_LEN 32
  958. #define SCM_TEMPORAL_KEY_LENGTH 16
  959. struct rtllib_security {
  960. u16 active_key:2,
  961. enabled:1,
  962. auth_mode:2,
  963. auth_algo:4,
  964. unicast_uses_group:1,
  965. encrypt:1;
  966. u8 key_sizes[NUM_WEP_KEYS];
  967. u8 keys[NUM_WEP_KEYS][SCM_KEY_LEN];
  968. u8 level;
  969. u16 flags;
  970. } __packed;
  971. /*
  972. 802.11 data frame from AP
  973. ,-------------------------------------------------------------------.
  974. Bytes | 2 | 2 | 6 | 6 | 6 | 2 | 0..2312 | 4 |
  975. |------|------|---------|---------|---------|------|---------|------|
  976. Desc. | ctrl | dura | DA/RA | TA | SA | Sequ | frame | fcs |
  977. | | tion | (BSSID) | | | ence | data | |
  978. `-------------------------------------------------------------------'
  979. Total: 28-2340 bytes
  980. */
  981. /* Management Frame Information Element Types */
  982. enum rtllib_mfie {
  983. MFIE_TYPE_SSID = 0,
  984. MFIE_TYPE_RATES = 1,
  985. MFIE_TYPE_FH_SET = 2,
  986. MFIE_TYPE_DS_SET = 3,
  987. MFIE_TYPE_CF_SET = 4,
  988. MFIE_TYPE_TIM = 5,
  989. MFIE_TYPE_IBSS_SET = 6,
  990. MFIE_TYPE_COUNTRY = 7,
  991. MFIE_TYPE_HOP_PARAMS = 8,
  992. MFIE_TYPE_HOP_TABLE = 9,
  993. MFIE_TYPE_REQUEST = 10,
  994. MFIE_TYPE_CHALLENGE = 16,
  995. MFIE_TYPE_POWER_CONSTRAINT = 32,
  996. MFIE_TYPE_POWER_CAPABILITY = 33,
  997. MFIE_TYPE_TPC_REQUEST = 34,
  998. MFIE_TYPE_TPC_REPORT = 35,
  999. MFIE_TYPE_SUPP_CHANNELS = 36,
  1000. MFIE_TYPE_CSA = 37,
  1001. MFIE_TYPE_MEASURE_REQUEST = 38,
  1002. MFIE_TYPE_MEASURE_REPORT = 39,
  1003. MFIE_TYPE_QUIET = 40,
  1004. MFIE_TYPE_IBSS_DFS = 41,
  1005. MFIE_TYPE_ERP = 42,
  1006. MFIE_TYPE_HT_CAP = 45,
  1007. MFIE_TYPE_RSN = 48,
  1008. MFIE_TYPE_RATES_EX = 50,
  1009. MFIE_TYPE_HT_INFO = 61,
  1010. MFIE_TYPE_AIRONET = 133,
  1011. MFIE_TYPE_GENERIC = 221,
  1012. MFIE_TYPE_QOS_PARAMETER = 222,
  1013. };
  1014. /* Minimal header; can be used for passing 802.11 frames with sufficient
  1015. * information to determine what type of underlying data type is actually
  1016. * stored in the data. */
  1017. struct rtllib_pspoll_hdr {
  1018. __le16 frame_ctl;
  1019. __le16 aid;
  1020. u8 bssid[ETH_ALEN];
  1021. u8 ta[ETH_ALEN];
  1022. } __packed;
  1023. struct rtllib_hdr {
  1024. __le16 frame_ctl;
  1025. __le16 duration_id;
  1026. u8 payload[0];
  1027. } __packed;
  1028. struct rtllib_hdr_1addr {
  1029. __le16 frame_ctl;
  1030. __le16 duration_id;
  1031. u8 addr1[ETH_ALEN];
  1032. u8 payload[0];
  1033. } __packed;
  1034. struct rtllib_hdr_2addr {
  1035. __le16 frame_ctl;
  1036. __le16 duration_id;
  1037. u8 addr1[ETH_ALEN];
  1038. u8 addr2[ETH_ALEN];
  1039. u8 payload[0];
  1040. } __packed;
  1041. struct rtllib_hdr_3addr {
  1042. __le16 frame_ctl;
  1043. __le16 duration_id;
  1044. u8 addr1[ETH_ALEN];
  1045. u8 addr2[ETH_ALEN];
  1046. u8 addr3[ETH_ALEN];
  1047. __le16 seq_ctl;
  1048. u8 payload[0];
  1049. } __packed;
  1050. struct rtllib_hdr_4addr {
  1051. __le16 frame_ctl;
  1052. __le16 duration_id;
  1053. u8 addr1[ETH_ALEN];
  1054. u8 addr2[ETH_ALEN];
  1055. u8 addr3[ETH_ALEN];
  1056. __le16 seq_ctl;
  1057. u8 addr4[ETH_ALEN];
  1058. u8 payload[0];
  1059. } __packed;
  1060. struct rtllib_hdr_3addrqos {
  1061. __le16 frame_ctl;
  1062. __le16 duration_id;
  1063. u8 addr1[ETH_ALEN];
  1064. u8 addr2[ETH_ALEN];
  1065. u8 addr3[ETH_ALEN];
  1066. __le16 seq_ctl;
  1067. __le16 qos_ctl;
  1068. u8 payload[0];
  1069. } __packed;
  1070. struct rtllib_hdr_4addrqos {
  1071. __le16 frame_ctl;
  1072. __le16 duration_id;
  1073. u8 addr1[ETH_ALEN];
  1074. u8 addr2[ETH_ALEN];
  1075. u8 addr3[ETH_ALEN];
  1076. __le16 seq_ctl;
  1077. u8 addr4[ETH_ALEN];
  1078. __le16 qos_ctl;
  1079. u8 payload[0];
  1080. } __packed;
  1081. struct rtllib_info_element {
  1082. u8 id;
  1083. u8 len;
  1084. u8 data[0];
  1085. } __packed;
  1086. struct rtllib_authentication {
  1087. struct rtllib_hdr_3addr header;
  1088. __le16 algorithm;
  1089. __le16 transaction;
  1090. __le16 status;
  1091. /*challenge*/
  1092. struct rtllib_info_element info_element[0];
  1093. } __packed;
  1094. struct rtllib_disauth {
  1095. struct rtllib_hdr_3addr header;
  1096. __le16 reason;
  1097. } __packed;
  1098. struct rtllib_disassoc {
  1099. struct rtllib_hdr_3addr header;
  1100. __le16 reason;
  1101. } __packed;
  1102. struct rtllib_probe_request {
  1103. struct rtllib_hdr_3addr header;
  1104. /* SSID, supported rates */
  1105. struct rtllib_info_element info_element[0];
  1106. } __packed;
  1107. struct rtllib_probe_response {
  1108. struct rtllib_hdr_3addr header;
  1109. u32 time_stamp[2];
  1110. __le16 beacon_interval;
  1111. __le16 capability;
  1112. /* SSID, supported rates, FH params, DS params,
  1113. * CF params, IBSS params, TIM (if beacon), RSN */
  1114. struct rtllib_info_element info_element[0];
  1115. } __packed;
  1116. /* Alias beacon for probe_response */
  1117. #define rtllib_beacon rtllib_probe_response
  1118. struct rtllib_assoc_request_frame {
  1119. struct rtllib_hdr_3addr header;
  1120. __le16 capability;
  1121. __le16 listen_interval;
  1122. /* SSID, supported rates, RSN */
  1123. struct rtllib_info_element info_element[0];
  1124. } __packed;
  1125. struct rtllib_reassoc_request_frame {
  1126. struct rtllib_hdr_3addr header;
  1127. __le16 capability;
  1128. __le16 listen_interval;
  1129. u8 current_ap[ETH_ALEN];
  1130. /* SSID, supported rates, RSN */
  1131. struct rtllib_info_element info_element[0];
  1132. } __packed;
  1133. struct rtllib_assoc_response_frame {
  1134. struct rtllib_hdr_3addr header;
  1135. __le16 capability;
  1136. __le16 status;
  1137. __le16 aid;
  1138. struct rtllib_info_element info_element[0]; /* supported rates */
  1139. } __packed;
  1140. struct rtllib_txb {
  1141. u8 nr_frags;
  1142. u8 encrypted;
  1143. u8 queue_index;
  1144. u8 rts_included;
  1145. u16 reserved;
  1146. __le16 frag_size;
  1147. __le16 payload_size;
  1148. struct sk_buff *fragments[0];
  1149. };
  1150. #define MAX_TX_AGG_COUNT 16
  1151. struct rtllib_drv_agg_txb {
  1152. u8 nr_drv_agg_frames;
  1153. struct sk_buff *tx_agg_frames[MAX_TX_AGG_COUNT];
  1154. } __packed;
  1155. #define MAX_SUBFRAME_COUNT 64
  1156. struct rtllib_rxb {
  1157. u8 nr_subframes;
  1158. struct sk_buff *subframes[MAX_SUBFRAME_COUNT];
  1159. u8 dst[ETH_ALEN];
  1160. u8 src[ETH_ALEN];
  1161. } __packed;
  1162. union frameqos {
  1163. u16 shortdata;
  1164. u8 chardata[2];
  1165. struct {
  1166. u16 tid:4;
  1167. u16 eosp:1;
  1168. u16 ack_policy:2;
  1169. u16 reserved:1;
  1170. u16 txop:8;
  1171. } field;
  1172. };
  1173. /* SWEEP TABLE ENTRIES NUMBER*/
  1174. #define MAX_SWEEP_TAB_ENTRIES 42
  1175. #define MAX_SWEEP_TAB_ENTRIES_PER_PACKET 7
  1176. /* MAX_RATES_LENGTH needs to be 12. The spec says 8, and many APs
  1177. * only use 8, and then use extended rates for the remaining supported
  1178. * rates. Other APs, however, stick all of their supported rates on the
  1179. * main rates information element... */
  1180. #define MAX_RATES_LENGTH ((u8)12)
  1181. #define MAX_RATES_EX_LENGTH ((u8)16)
  1182. #define MAX_NETWORK_COUNT 96
  1183. #define MAX_CHANNEL_NUMBER 161
  1184. #define RTLLIB_SOFTMAC_SCAN_TIME 100
  1185. #define RTLLIB_SOFTMAC_ASSOC_RETRY_TIME (HZ * 2)
  1186. #define CRC_LENGTH 4U
  1187. #define MAX_WPA_IE_LEN 64
  1188. #define MAX_WZC_IE_LEN 256
  1189. #define NETWORK_EMPTY_ESSID (1<<0)
  1190. #define NETWORK_HAS_OFDM (1<<1)
  1191. #define NETWORK_HAS_CCK (1<<2)
  1192. /* QoS structure */
  1193. #define NETWORK_HAS_QOS_PARAMETERS (1<<3)
  1194. #define NETWORK_HAS_QOS_INFORMATION (1<<4)
  1195. #define NETWORK_HAS_QOS_MASK (NETWORK_HAS_QOS_PARAMETERS | \
  1196. NETWORK_HAS_QOS_INFORMATION)
  1197. /* 802.11h */
  1198. #define NETWORK_HAS_POWER_CONSTRAINT (1<<5)
  1199. #define NETWORK_HAS_CSA (1<<6)
  1200. #define NETWORK_HAS_QUIET (1<<7)
  1201. #define NETWORK_HAS_IBSS_DFS (1<<8)
  1202. #define NETWORK_HAS_TPC_REPORT (1<<9)
  1203. #define NETWORK_HAS_ERP_VALUE (1<<10)
  1204. #define QOS_QUEUE_NUM 4
  1205. #define QOS_OUI_LEN 3
  1206. #define QOS_OUI_TYPE 2
  1207. #define QOS_ELEMENT_ID 221
  1208. #define QOS_OUI_INFO_SUB_TYPE 0
  1209. #define QOS_OUI_PARAM_SUB_TYPE 1
  1210. #define QOS_VERSION_1 1
  1211. #define QOS_AIFSN_MIN_VALUE 2
  1212. struct rtllib_qos_information_element {
  1213. u8 elementID;
  1214. u8 length;
  1215. u8 qui[QOS_OUI_LEN];
  1216. u8 qui_type;
  1217. u8 qui_subtype;
  1218. u8 version;
  1219. u8 ac_info;
  1220. } __packed;
  1221. struct rtllib_qos_ac_parameter {
  1222. u8 aci_aifsn;
  1223. u8 ecw_min_max;
  1224. __le16 tx_op_limit;
  1225. } __packed;
  1226. struct rtllib_qos_parameter_info {
  1227. struct rtllib_qos_information_element info_element;
  1228. u8 reserved;
  1229. struct rtllib_qos_ac_parameter ac_params_record[QOS_QUEUE_NUM];
  1230. } __packed;
  1231. struct rtllib_qos_parameters {
  1232. __le16 cw_min[QOS_QUEUE_NUM];
  1233. __le16 cw_max[QOS_QUEUE_NUM];
  1234. u8 aifs[QOS_QUEUE_NUM];
  1235. u8 flag[QOS_QUEUE_NUM];
  1236. __le16 tx_op_limit[QOS_QUEUE_NUM];
  1237. } __packed;
  1238. struct rtllib_qos_data {
  1239. struct rtllib_qos_parameters parameters;
  1240. unsigned int wmm_acm;
  1241. int active;
  1242. int supported;
  1243. u8 param_count;
  1244. u8 old_param_count;
  1245. };
  1246. struct rtllib_tim_parameters {
  1247. u8 tim_count;
  1248. u8 tim_period;
  1249. } __packed;
  1250. struct rtllib_wmm_ac_param {
  1251. u8 ac_aci_acm_aifsn;
  1252. u8 ac_ecwmin_ecwmax;
  1253. u16 ac_txop_limit;
  1254. };
  1255. struct rtllib_wmm_ts_info {
  1256. u8 ac_dir_tid;
  1257. u8 ac_up_psb;
  1258. u8 reserved;
  1259. } __packed;
  1260. struct rtllib_wmm_tspec_elem {
  1261. struct rtllib_wmm_ts_info ts_info;
  1262. u16 norm_msdu_size;
  1263. u16 max_msdu_size;
  1264. u32 min_serv_inter;
  1265. u32 max_serv_inter;
  1266. u32 inact_inter;
  1267. u32 suspen_inter;
  1268. u32 serv_start_time;
  1269. u32 min_data_rate;
  1270. u32 mean_data_rate;
  1271. u32 peak_data_rate;
  1272. u32 max_burst_size;
  1273. u32 delay_bound;
  1274. u32 min_phy_rate;
  1275. u16 surp_band_allow;
  1276. u16 medium_time;
  1277. } __packed;
  1278. enum eap_type {
  1279. EAP_PACKET = 0,
  1280. EAPOL_START,
  1281. EAPOL_LOGOFF,
  1282. EAPOL_KEY,
  1283. EAPOL_ENCAP_ASF_ALERT
  1284. };
  1285. static const char * const eap_types[] = {
  1286. [EAP_PACKET] = "EAP-Packet",
  1287. [EAPOL_START] = "EAPOL-Start",
  1288. [EAPOL_LOGOFF] = "EAPOL-Logoff",
  1289. [EAPOL_KEY] = "EAPOL-Key",
  1290. [EAPOL_ENCAP_ASF_ALERT] = "EAPOL-Encap-ASF-Alert"
  1291. };
  1292. static inline const char *eap_get_type(int type)
  1293. {
  1294. return ((u32)type >= ARRAY_SIZE(eap_types)) ? "Unknown" :
  1295. eap_types[type];
  1296. }
  1297. static inline u8 Frame_QoSTID(u8 *buf)
  1298. {
  1299. struct rtllib_hdr_3addr *hdr;
  1300. u16 fc;
  1301. hdr = (struct rtllib_hdr_3addr *)buf;
  1302. fc = le16_to_cpu(hdr->frame_ctl);
  1303. return (u8)((union frameqos *)(buf + (((fc & RTLLIB_FCTL_TODS) &&
  1304. (fc & RTLLIB_FCTL_FROMDS)) ? 30 : 24)))->field.tid;
  1305. }
  1306. struct eapol {
  1307. u8 snap[6];
  1308. u16 ethertype;
  1309. u8 version;
  1310. u8 type;
  1311. u16 length;
  1312. } __packed;
  1313. struct rtllib_softmac_stats {
  1314. unsigned int rx_ass_ok;
  1315. unsigned int rx_ass_err;
  1316. unsigned int rx_probe_rq;
  1317. unsigned int tx_probe_rs;
  1318. unsigned int tx_beacons;
  1319. unsigned int rx_auth_rq;
  1320. unsigned int rx_auth_rs_ok;
  1321. unsigned int rx_auth_rs_err;
  1322. unsigned int tx_auth_rq;
  1323. unsigned int no_auth_rs;
  1324. unsigned int no_ass_rs;
  1325. unsigned int tx_ass_rq;
  1326. unsigned int rx_ass_rq;
  1327. unsigned int tx_probe_rq;
  1328. unsigned int reassoc;
  1329. unsigned int swtxstop;
  1330. unsigned int swtxawake;
  1331. unsigned char CurrentShowTxate;
  1332. unsigned char last_packet_rate;
  1333. unsigned int txretrycount;
  1334. };
  1335. #define BEACON_PROBE_SSID_ID_POSITION 12
  1336. struct rtllib_info_element_hdr {
  1337. u8 id;
  1338. u8 len;
  1339. } __packed;
  1340. /*
  1341. * These are the data types that can make up management packets
  1342. *
  1343. u16 auth_algorithm;
  1344. u16 auth_sequence;
  1345. u16 beacon_interval;
  1346. u16 capability;
  1347. u8 current_ap[ETH_ALEN];
  1348. u16 listen_interval;
  1349. struct {
  1350. u16 association_id:14, reserved:2;
  1351. } __packed;
  1352. u32 time_stamp[2];
  1353. u16 reason;
  1354. u16 status;
  1355. */
  1356. #define RTLLIB_DEFAULT_TX_ESSID "Penguin"
  1357. #define RTLLIB_DEFAULT_BASIC_RATE 2
  1358. enum {WMM_all_frame, WMM_two_frame, WMM_four_frame, WMM_six_frame};
  1359. #define MAX_SP_Len (WMM_all_frame << 4)
  1360. #define RTLLIB_QOS_TID 0x0f
  1361. #define QOS_CTL_NOTCONTAIN_ACK (0x01 << 5)
  1362. #define RTLLIB_DTIM_MBCAST 4
  1363. #define RTLLIB_DTIM_UCAST 2
  1364. #define RTLLIB_DTIM_VALID 1
  1365. #define RTLLIB_DTIM_INVALID 0
  1366. #define RTLLIB_PS_DISABLED 0
  1367. #define RTLLIB_PS_UNICAST RTLLIB_DTIM_UCAST
  1368. #define RTLLIB_PS_MBCAST RTLLIB_DTIM_MBCAST
  1369. #define WME_AC_BK 0x00
  1370. #define WME_AC_BE 0x01
  1371. #define WME_AC_VI 0x02
  1372. #define WME_AC_VO 0x03
  1373. #define WME_ACI_MASK 0x03
  1374. #define WME_AIFSN_MASK 0x03
  1375. #define WME_AC_PRAM_LEN 16
  1376. #define MAX_RECEIVE_BUFFER_SIZE 9100
  1377. #define UP2AC(up) ( \
  1378. ((up) < 1) ? WME_AC_BE : \
  1379. ((up) < 3) ? WME_AC_BK : \
  1380. ((up) < 4) ? WME_AC_BE : \
  1381. ((up) < 6) ? WME_AC_VI : \
  1382. WME_AC_VO)
  1383. #define AC2UP(_ac) ( \
  1384. ((_ac) == WME_AC_VO) ? 6 : \
  1385. ((_ac) == WME_AC_VI) ? 5 : \
  1386. ((_ac) == WME_AC_BK) ? 1 : \
  1387. 0)
  1388. #define ETHER_ADDR_LEN 6 /* length of an Ethernet address */
  1389. #define ETHERNET_HEADER_SIZE 14 /* length of two Ethernet address
  1390. * plus ether type*/
  1391. struct ether_header {
  1392. u8 ether_dhost[ETHER_ADDR_LEN];
  1393. u8 ether_shost[ETHER_ADDR_LEN];
  1394. u16 ether_type;
  1395. } __packed;
  1396. #ifndef ETHERTYPE_PAE
  1397. #define ETHERTYPE_PAE 0x888e /* EAPOL PAE/802.1x */
  1398. #endif
  1399. #ifndef ETHERTYPE_IP
  1400. #define ETHERTYPE_IP 0x0800 /* IP protocol */
  1401. #endif
  1402. enum erp_t {
  1403. ERP_NonERPpresent = 0x01,
  1404. ERP_UseProtection = 0x02,
  1405. ERP_BarkerPreambleMode = 0x04,
  1406. };
  1407. struct rtllib_network {
  1408. /* These entries are used to identify a unique network */
  1409. u8 bssid[ETH_ALEN];
  1410. u8 channel;
  1411. /* Ensure null-terminated for any debug msgs */
  1412. u8 ssid[IW_ESSID_MAX_SIZE + 1];
  1413. u8 ssid_len;
  1414. u8 hidden_ssid[IW_ESSID_MAX_SIZE + 1];
  1415. u8 hidden_ssid_len;
  1416. struct rtllib_qos_data qos_data;
  1417. bool bWithAironetIE;
  1418. bool bCkipSupported;
  1419. bool bCcxRmEnable;
  1420. u16 CcxRmState[2];
  1421. bool bMBssidValid;
  1422. u8 MBssidMask;
  1423. u8 MBssid[6];
  1424. bool bWithCcxVerNum;
  1425. u8 BssCcxVerNumber;
  1426. /* These are network statistics */
  1427. struct rtllib_rx_stats stats;
  1428. u16 capability;
  1429. u8 rates[MAX_RATES_LENGTH];
  1430. u8 rates_len;
  1431. u8 rates_ex[MAX_RATES_EX_LENGTH];
  1432. u8 rates_ex_len;
  1433. unsigned long last_scanned;
  1434. u8 mode;
  1435. u32 flags;
  1436. u32 last_associate;
  1437. u32 time_stamp[2];
  1438. u16 beacon_interval;
  1439. u16 listen_interval;
  1440. u16 atim_window;
  1441. u8 erp_value;
  1442. u8 wpa_ie[MAX_WPA_IE_LEN];
  1443. size_t wpa_ie_len;
  1444. u8 rsn_ie[MAX_WPA_IE_LEN];
  1445. size_t rsn_ie_len;
  1446. u8 wzc_ie[MAX_WZC_IE_LEN];
  1447. size_t wzc_ie_len;
  1448. struct rtllib_tim_parameters tim;
  1449. u8 dtim_period;
  1450. u8 dtim_data;
  1451. u64 last_dtim_sta_time;
  1452. u8 wmm_info;
  1453. struct rtllib_wmm_ac_param wmm_param[4];
  1454. u8 Turbo_Enable;
  1455. u16 CountryIeLen;
  1456. u8 CountryIeBuf[MAX_IE_LEN];
  1457. struct bss_ht bssht;
  1458. bool broadcom_cap_exist;
  1459. bool realtek_cap_exit;
  1460. bool marvell_cap_exist;
  1461. bool ralink_cap_exist;
  1462. bool atheros_cap_exist;
  1463. bool cisco_cap_exist;
  1464. bool airgo_cap_exist;
  1465. bool unknown_cap_exist;
  1466. bool berp_info_valid;
  1467. bool buseprotection;
  1468. bool bIsNetgear854T;
  1469. u8 SignalStrength;
  1470. u8 RSSI;
  1471. struct list_head list;
  1472. };
  1473. #if 1
  1474. enum rtllib_state {
  1475. /* the card is not linked at all */
  1476. RTLLIB_NOLINK = 0,
  1477. /* RTLLIB_ASSOCIATING* are for BSS client mode
  1478. * the driver shall not perform RX filtering unless
  1479. * the state is LINKED.
  1480. * The driver shall just check for the state LINKED and
  1481. * defaults to NOLINK for ALL the other states (including
  1482. * LINKED_SCANNING)
  1483. */
  1484. /* the association procedure will start (wq scheduling)*/
  1485. RTLLIB_ASSOCIATING,
  1486. RTLLIB_ASSOCIATING_RETRY,
  1487. /* the association procedure is sending AUTH request*/
  1488. RTLLIB_ASSOCIATING_AUTHENTICATING,
  1489. /* the association procedure has successfully authenticated
  1490. * and is sending association request
  1491. */
  1492. RTLLIB_ASSOCIATING_AUTHENTICATED,
  1493. /* the link is ok. the card associated to a BSS or linked
  1494. * to a ibss cell or acting as an AP and creating the bss
  1495. */
  1496. RTLLIB_LINKED,
  1497. /* same as LINKED, but the driver shall apply RX filter
  1498. * rules as we are in NO_LINK mode. As the card is still
  1499. * logically linked, but it is doing a syncro site survey
  1500. * then it will be back to LINKED state.
  1501. */
  1502. RTLLIB_LINKED_SCANNING,
  1503. };
  1504. #else
  1505. enum rtllib_state {
  1506. RTLLIB_UNINITIALIZED = 0,
  1507. RTLLIB_INITIALIZED,
  1508. RTLLIB_ASSOCIATING,
  1509. RTLLIB_ASSOCIATED,
  1510. RTLLIB_AUTHENTICATING,
  1511. RTLLIB_AUTHENTICATED,
  1512. RTLLIB_SHUTDOWN
  1513. };
  1514. #endif
  1515. #define DEFAULT_MAX_SCAN_AGE (15 * HZ)
  1516. #define DEFAULT_FTS 2346
  1517. #define CFG_RTLLIB_RESERVE_FCS (1<<0)
  1518. #define CFG_RTLLIB_COMPUTE_FCS (1<<1)
  1519. #define CFG_RTLLIB_RTS (1<<2)
  1520. #define RTLLIB_24GHZ_MIN_CHANNEL 1
  1521. #define RTLLIB_24GHZ_MAX_CHANNEL 14
  1522. #define RTLLIB_24GHZ_CHANNELS (RTLLIB_24GHZ_MAX_CHANNEL - \
  1523. RTLLIB_24GHZ_MIN_CHANNEL + 1)
  1524. #define RTLLIB_52GHZ_MIN_CHANNEL 34
  1525. #define RTLLIB_52GHZ_MAX_CHANNEL 165
  1526. #define RTLLIB_52GHZ_CHANNELS (RTLLIB_52GHZ_MAX_CHANNEL - \
  1527. RTLLIB_52GHZ_MIN_CHANNEL + 1)
  1528. #ifndef eqMacAddr
  1529. #define eqMacAddr(a, b) \
  1530. (((a)[0] == (b)[0] && (a)[1] == (b)[1] && (a)[2] == (b)[2] && \
  1531. (a)[3] == (b)[3] && (a)[4] == (b)[4] && (a)[5] == (b)[5]) ? 1 : 0)
  1532. #endif
  1533. struct tx_pending {
  1534. int frag;
  1535. struct rtllib_txb *txb;
  1536. };
  1537. struct bandwidth_autoswitch {
  1538. long threshold_20Mhzto40Mhz;
  1539. long threshold_40Mhzto20Mhz;
  1540. bool bforced_tx20Mhz;
  1541. bool bautoswitch_enable;
  1542. };
  1543. #define REORDER_WIN_SIZE 128
  1544. #define REORDER_ENTRY_NUM 128
  1545. struct rx_reorder_entry {
  1546. struct list_head List;
  1547. u16 SeqNum;
  1548. struct rtllib_rxb *prxb;
  1549. };
  1550. enum fsync_state {
  1551. Default_Fsync,
  1552. HW_Fsync,
  1553. SW_Fsync
  1554. };
  1555. enum rt_ps_mode {
  1556. eActive,
  1557. eMaxPs,
  1558. eFastPs,
  1559. eAutoPs,
  1560. };
  1561. enum ips_callback_function {
  1562. IPS_CALLBACK_NONE = 0,
  1563. IPS_CALLBACK_MGNT_LINK_REQUEST = 1,
  1564. IPS_CALLBACK_JOIN_REQUEST = 2,
  1565. };
  1566. enum rt_join_action {
  1567. RT_JOIN_INFRA = 1,
  1568. RT_JOIN_IBSS = 2,
  1569. RT_START_IBSS = 3,
  1570. RT_NO_ACTION = 4,
  1571. };
  1572. struct ibss_parms {
  1573. u16 atimWin;
  1574. };
  1575. #define MAX_NUM_RATES 264
  1576. enum rt_rf_power_state {
  1577. eRfOn,
  1578. eRfSleep,
  1579. eRfOff
  1580. };
  1581. #define MAX_SUPPORT_WOL_PATTERN_NUM 8
  1582. #define MAX_WOL_BIT_MASK_SIZE 16
  1583. #define MAX_WOL_PATTERN_SIZE 128
  1584. enum wol_pattern_type {
  1585. eNetBIOS = 0,
  1586. eIPv4IPv6ARP,
  1587. eIPv4IPv6TCPSYN,
  1588. eMACIDOnly,
  1589. eNoDefined,
  1590. };
  1591. struct rt_pm_wol_info {
  1592. u32 PatternId;
  1593. u32 Mask[4];
  1594. u16 CrcRemainder;
  1595. u8 WFMIndex;
  1596. enum wol_pattern_type PatternType;
  1597. };
  1598. struct rt_pwr_save_ctrl {
  1599. bool bInactivePs;
  1600. bool bIPSModeBackup;
  1601. bool bHaltAdapterClkRQ;
  1602. bool bSwRfProcessing;
  1603. enum rt_rf_power_state eInactivePowerState;
  1604. struct work_struct InactivePsWorkItem;
  1605. struct timer_list InactivePsTimer;
  1606. enum ips_callback_function ReturnPoint;
  1607. bool bTmpBssDesc;
  1608. enum rt_join_action tmpJoinAction;
  1609. struct rtllib_network tmpBssDesc;
  1610. bool bTmpScanOnly;
  1611. bool bTmpActiveScan;
  1612. bool bTmpFilterHiddenAP;
  1613. bool bTmpUpdateParms;
  1614. u8 tmpSsidBuf[33];
  1615. struct octet_string tmpSsid2Scan;
  1616. bool bTmpSsid2Scan;
  1617. u8 tmpNetworkType;
  1618. u8 tmpChannelNumber;
  1619. u16 tmpBcnPeriod;
  1620. u8 tmpDtimPeriod;
  1621. u16 tmpmCap;
  1622. struct octet_string tmpSuppRateSet;
  1623. u8 tmpSuppRateBuf[MAX_NUM_RATES];
  1624. bool bTmpSuppRate;
  1625. struct ibss_parms tmpIbpm;
  1626. bool bTmpIbpm;
  1627. bool bLeisurePs;
  1628. u32 PowerProfile;
  1629. u8 LpsIdleCount;
  1630. u8 RegMaxLPSAwakeIntvl;
  1631. u8 LPSAwakeIntvl;
  1632. u32 CurPsLevel;
  1633. u32 RegRfPsLevel;
  1634. bool bFwCtrlLPS;
  1635. u8 FWCtrlPSMode;
  1636. bool LinkReqInIPSRFOffPgs;
  1637. bool BufConnectinfoBefore;
  1638. bool bGpioRfSw;
  1639. u8 RegAMDPciASPM;
  1640. u8 oWLANMode;
  1641. struct rt_pm_wol_info PmWoLPatternInfo[MAX_SUPPORT_WOL_PATTERN_NUM];
  1642. };
  1643. #define RT_RF_CHANGE_SOURCE u32
  1644. #define RF_CHANGE_BY_SW BIT31
  1645. #define RF_CHANGE_BY_HW BIT30
  1646. #define RF_CHANGE_BY_PS BIT29
  1647. #define RF_CHANGE_BY_IPS BIT28
  1648. #define RF_CHANGE_BY_INIT 0
  1649. enum country_code_type {
  1650. COUNTRY_CODE_FCC = 0,
  1651. COUNTRY_CODE_IC = 1,
  1652. COUNTRY_CODE_ETSI = 2,
  1653. COUNTRY_CODE_SPAIN = 3,
  1654. COUNTRY_CODE_FRANCE = 4,
  1655. COUNTRY_CODE_MKK = 5,
  1656. COUNTRY_CODE_MKK1 = 6,
  1657. COUNTRY_CODE_ISRAEL = 7,
  1658. COUNTRY_CODE_TELEC = 8,
  1659. COUNTRY_CODE_MIC = 9,
  1660. COUNTRY_CODE_GLOBAL_DOMAIN = 10,
  1661. COUNTRY_CODE_WORLD_WIDE_13 = 11,
  1662. COUNTRY_CODE_TELEC_NETGEAR = 12,
  1663. COUNTRY_CODE_MAX
  1664. };
  1665. enum scan_op_backup_opt {
  1666. SCAN_OPT_BACKUP = 0,
  1667. SCAN_OPT_RESTORE,
  1668. SCAN_OPT_MAX
  1669. };
  1670. enum fw_cmd_io_type {
  1671. FW_CMD_DIG_ENABLE = 0,
  1672. FW_CMD_DIG_DISABLE = 1,
  1673. FW_CMD_DIG_HALT = 2,
  1674. FW_CMD_DIG_RESUME = 3,
  1675. FW_CMD_HIGH_PWR_ENABLE = 4,
  1676. FW_CMD_HIGH_PWR_DISABLE = 5,
  1677. FW_CMD_RA_RESET = 6,
  1678. FW_CMD_RA_ACTIVE = 7,
  1679. FW_CMD_RA_REFRESH_N = 8,
  1680. FW_CMD_RA_REFRESH_BG = 9,
  1681. FW_CMD_RA_INIT = 10,
  1682. FW_CMD_IQK_ENABLE = 11,
  1683. FW_CMD_TXPWR_TRACK_ENABLE = 12,
  1684. FW_CMD_TXPWR_TRACK_DISABLE = 13,
  1685. FW_CMD_TXPWR_TRACK_THERMAL = 14,
  1686. FW_CMD_PAUSE_DM_BY_SCAN = 15,
  1687. FW_CMD_RESUME_DM_BY_SCAN = 16,
  1688. FW_CMD_RA_REFRESH_N_COMB = 17,
  1689. FW_CMD_RA_REFRESH_BG_COMB = 18,
  1690. FW_CMD_ANTENNA_SW_ENABLE = 19,
  1691. FW_CMD_ANTENNA_SW_DISABLE = 20,
  1692. FW_CMD_TX_FEEDBACK_CCX_ENABLE = 21,
  1693. FW_CMD_LPS_ENTER = 22,
  1694. FW_CMD_LPS_LEAVE = 23,
  1695. FW_CMD_DIG_MODE_SS = 24,
  1696. FW_CMD_DIG_MODE_FA = 25,
  1697. FW_CMD_ADD_A2_ENTRY = 26,
  1698. FW_CMD_CTRL_DM_BY_DRIVER = 27,
  1699. FW_CMD_CTRL_DM_BY_DRIVER_NEW = 28,
  1700. FW_CMD_PAPE_CONTROL = 29,
  1701. FW_CMD_CHAN_SET = 30,
  1702. };
  1703. #define RT_MAX_LD_SLOT_NUM 10
  1704. struct rt_link_detect {
  1705. u32 NumRecvBcnInPeriod;
  1706. u32 NumRecvDataInPeriod;
  1707. u32 RxBcnNum[RT_MAX_LD_SLOT_NUM];
  1708. u32 RxDataNum[RT_MAX_LD_SLOT_NUM];
  1709. u16 SlotNum;
  1710. u16 SlotIndex;
  1711. u32 NumTxOkInPeriod;
  1712. u32 NumRxOkInPeriod;
  1713. u32 NumRxUnicastOkInPeriod;
  1714. bool bBusyTraffic;
  1715. bool bHigherBusyTraffic;
  1716. bool bHigherBusyRxTraffic;
  1717. u8 IdleCount;
  1718. u32 NumTxUnicastOkInPeriod;
  1719. u32 LastNumTxUnicast;
  1720. u32 LastNumRxUnicast;
  1721. };
  1722. struct sw_cam_table {
  1723. u8 macaddr[6];
  1724. bool bused;
  1725. u8 key_buf[16];
  1726. u16 key_type;
  1727. u8 useDK;
  1728. u8 key_index;
  1729. };
  1730. #define TOTAL_CAM_ENTRY 32
  1731. struct rate_adaptive {
  1732. u8 rate_adaptive_disabled;
  1733. u8 ratr_state;
  1734. u16 reserve;
  1735. u32 high_rssi_thresh_for_ra;
  1736. u32 high2low_rssi_thresh_for_ra;
  1737. u8 low2high_rssi_thresh_for_ra40M;
  1738. u32 low_rssi_thresh_for_ra40M;
  1739. u8 low2high_rssi_thresh_for_ra20M;
  1740. u32 low_rssi_thresh_for_ra20M;
  1741. u32 upper_rssi_threshold_ratr;
  1742. u32 middle_rssi_threshold_ratr;
  1743. u32 low_rssi_threshold_ratr;
  1744. u32 low_rssi_threshold_ratr_40M;
  1745. u32 low_rssi_threshold_ratr_20M;
  1746. u8 ping_rssi_enable;
  1747. u32 ping_rssi_ratr;
  1748. u32 ping_rssi_thresh_for_ra;
  1749. u32 last_ratr;
  1750. u8 PreRATRState;
  1751. };
  1752. enum ratr_table_mode_8192s {
  1753. RATR_INX_WIRELESS_NGB = 0,
  1754. RATR_INX_WIRELESS_NG = 1,
  1755. RATR_INX_WIRELESS_NB = 2,
  1756. RATR_INX_WIRELESS_N = 3,
  1757. RATR_INX_WIRELESS_GB = 4,
  1758. RATR_INX_WIRELESS_G = 5,
  1759. RATR_INX_WIRELESS_B = 6,
  1760. RATR_INX_WIRELESS_MC = 7,
  1761. RATR_INX_WIRELESS_A = 8,
  1762. };
  1763. #define NUM_PMKID_CACHE 16
  1764. struct rt_pmkid_list {
  1765. u8 bUsed;
  1766. u8 Bssid[6];
  1767. u8 PMKID[16];
  1768. u8 SsidBuf[33];
  1769. u8 *ssid_octet;
  1770. u16 ssid_length;
  1771. };
  1772. struct rt_intel_promisc_mode {
  1773. bool bPromiscuousOn;
  1774. bool bFilterSourceStationFrame;
  1775. };
  1776. /*************** DRIVER STATUS *****/
  1777. #define STATUS_SCANNING 0
  1778. #define STATUS_SCAN_HW 1
  1779. #define STATUS_SCAN_ABORTING 2
  1780. #define STATUS_SETTING_CHAN 3
  1781. /*************** DRIVER STATUS *****/
  1782. enum {
  1783. NO_USE = 0,
  1784. USED = 1,
  1785. HW_SEC = 2,
  1786. SW_SEC = 3,
  1787. };
  1788. enum {
  1789. LPS_IS_WAKE = 0,
  1790. LPS_IS_SLEEP = 1,
  1791. LPS_WAIT_NULL_DATA_SEND = 2,
  1792. };
  1793. struct rtllib_device {
  1794. struct pci_dev *pdev;
  1795. struct net_device *dev;
  1796. struct rtllib_security sec;
  1797. bool disable_mgnt_queue;
  1798. unsigned long status;
  1799. short hwscan_ch_bk;
  1800. enum ht_extchnl_offset chan_offset_bk;
  1801. enum ht_channel_width bandwidth_bk;
  1802. u8 hwscan_sem_up;
  1803. u8 CntAfterLink;
  1804. enum rt_op_mode OpMode;
  1805. u8 VersionID;
  1806. /* The last AssocReq/Resp IEs */
  1807. u8 *assocreq_ies, *assocresp_ies;
  1808. size_t assocreq_ies_len, assocresp_ies_len;
  1809. bool b_customer_lenovo_id;
  1810. bool bForcedShowRxRate;
  1811. bool bForcedShowRateStill;
  1812. u8 SystemQueryDataRateCount;
  1813. bool bForcedBgMode;
  1814. bool bUseRAMask;
  1815. bool b1x1RecvCombine;
  1816. u8 RF_Type;
  1817. bool b1SSSupport;
  1818. u8 hwsec_active;
  1819. bool is_silent_reset;
  1820. bool force_mic_error;
  1821. bool is_roaming;
  1822. bool ieee_up;
  1823. bool cannot_notify;
  1824. bool bSupportRemoteWakeUp;
  1825. enum rt_ps_mode dot11PowerSaveMode;
  1826. bool actscanning;
  1827. bool FirstIe_InScan;
  1828. bool be_scan_inprogress;
  1829. bool beinretry;
  1830. enum rt_rf_power_state eRFPowerState;
  1831. RT_RF_CHANGE_SOURCE RfOffReason;
  1832. bool is_set_key;
  1833. bool wx_set_enc;
  1834. struct rt_hi_throughput *pHTInfo;
  1835. spinlock_t bw_spinlock;
  1836. spinlock_t reorder_spinlock;
  1837. u8 Regdot11HTOperationalRateSet[16];
  1838. u8 Regdot11TxHTOperationalRateSet[16];
  1839. u8 dot11HTOperationalRateSet[16];
  1840. u8 RegHTSuppRateSet[16];
  1841. u8 HTCurrentOperaRate;
  1842. u8 HTHighestOperaRate;
  1843. u8 MinSpaceCfg;
  1844. u8 MaxMssDensity;
  1845. u8 bTxDisableRateFallBack;
  1846. u8 bTxUseDriverAssingedRate;
  1847. u8 bTxEnableFwCalcDur;
  1848. atomic_t atm_chnlop;
  1849. atomic_t atm_swbw;
  1850. struct list_head Tx_TS_Admit_List;
  1851. struct list_head Tx_TS_Pending_List;
  1852. struct list_head Tx_TS_Unused_List;
  1853. struct tx_ts_record TxTsRecord[TOTAL_TS_NUM];
  1854. struct list_head Rx_TS_Admit_List;
  1855. struct list_head Rx_TS_Pending_List;
  1856. struct list_head Rx_TS_Unused_List;
  1857. struct rx_ts_record RxTsRecord[TOTAL_TS_NUM];
  1858. struct rx_reorder_entry RxReorderEntry[128];
  1859. struct list_head RxReorder_Unused_List;
  1860. u8 ForcedPriority;
  1861. /* Bookkeeping structures */
  1862. struct net_device_stats stats;
  1863. struct rtllib_stats ieee_stats;
  1864. struct rtllib_softmac_stats softmac_stats;
  1865. /* Probe / Beacon management */
  1866. struct list_head network_free_list;
  1867. struct list_head network_list;
  1868. struct rtllib_network *networks;
  1869. int scans;
  1870. int scan_age;
  1871. int iw_mode; /* operating mode (IW_MODE_*) */
  1872. bool bNetPromiscuousMode;
  1873. struct rt_intel_promisc_mode IntelPromiscuousModeInfo;
  1874. struct iw_spy_data spy_data;
  1875. spinlock_t lock;
  1876. spinlock_t wpax_suitlist_lock;
  1877. int tx_headroom; /* Set to size of any additional room needed at front
  1878. * of allocated Tx SKBs */
  1879. u32 config;
  1880. /* WEP and other encryption related settings at the device level */
  1881. int open_wep; /* Set to 1 to allow unencrypted frames */
  1882. int auth_mode;
  1883. int reset_on_keychange; /* Set to 1 if the HW needs to be reset on
  1884. * WEP key changes */
  1885. /* If the host performs {en,de}cryption, then set to 1 */
  1886. int host_encrypt;
  1887. int host_encrypt_msdu;
  1888. int host_decrypt;
  1889. /* host performs multicast decryption */
  1890. int host_mc_decrypt;
  1891. /* host should strip IV and ICV from protected frames */
  1892. /* meaningful only when hardware decryption is being used */
  1893. int host_strip_iv_icv;
  1894. int host_open_frag;
  1895. int host_build_iv;
  1896. int ieee802_1x; /* is IEEE 802.1X used */
  1897. /* WPA data */
  1898. bool bHalfNMode;
  1899. bool bHalfWirelessN24GMode;
  1900. int wpa_enabled;
  1901. int drop_unencrypted;
  1902. int tkip_countermeasures;
  1903. int privacy_invoked;
  1904. size_t wpa_ie_len;
  1905. u8 *wpa_ie;
  1906. size_t wps_ie_len;
  1907. u8 *wps_ie;
  1908. u8 ap_mac_addr[6];
  1909. u16 pairwise_key_type;
  1910. u16 group_key_type;
  1911. struct lib80211_crypt_info crypt_info;
  1912. struct sw_cam_table swcamtable[TOTAL_CAM_ENTRY];
  1913. int bcrx_sta_key; /* use individual keys to override default keys even
  1914. * with RX of broad/multicast frames */
  1915. struct rt_pmkid_list PMKIDList[NUM_PMKID_CACHE];
  1916. /* Fragmentation structures */
  1917. struct rtllib_frag_entry frag_cache[17][RTLLIB_FRAG_CACHE_LEN];
  1918. unsigned int frag_next_idx[17];
  1919. u16 fts; /* Fragmentation Threshold */
  1920. #define DEFAULT_RTS_THRESHOLD 2346U
  1921. #define MIN_RTS_THRESHOLD 1
  1922. #define MAX_RTS_THRESHOLD 2346U
  1923. u16 rts; /* RTS threshold */
  1924. /* Association info */
  1925. u8 bssid[ETH_ALEN];
  1926. /* This stores infos for the current network.
  1927. * Either the network we are associated in INFRASTRUCTURE
  1928. * or the network that we are creating in MASTER mode.
  1929. * ad-hoc is a mixture ;-).
  1930. * Note that in infrastructure mode, even when not associated,
  1931. * fields bssid and essid may be valid (if wpa_set and essid_set
  1932. * are true) as thy carry the value set by the user via iwconfig
  1933. */
  1934. struct rtllib_network current_network;
  1935. enum rtllib_state state;
  1936. int short_slot;
  1937. int reg_mode;
  1938. int mode; /* A, B, G */
  1939. int modulation; /* CCK, OFDM */
  1940. int freq_band; /* 2.4Ghz, 5.2Ghz, Mixed */
  1941. int abg_true; /* ABG flag */
  1942. /* used for forcing the ibss workqueue to terminate
  1943. * without wait for the syncro scan to terminate
  1944. */
  1945. short sync_scan_hurryup;
  1946. u16 scan_watch_dog;
  1947. int perfect_rssi;
  1948. int worst_rssi;
  1949. u16 prev_seq_ctl; /* used to drop duplicate frames */
  1950. /* map of allowed channels. 0 is dummy */
  1951. void *pDot11dInfo;
  1952. bool bGlobalDomain;
  1953. u8 active_channel_map[MAX_CHANNEL_NUMBER+1];
  1954. u8 IbssStartChnl;
  1955. u8 ibss_maxjoin_chal;
  1956. int rate; /* current rate */
  1957. int basic_rate;
  1958. u32 currentRate;
  1959. short active_scan;
  1960. /* this contains flags for selectively enable softmac support */
  1961. u16 softmac_features;
  1962. /* if the sequence control field is not filled by HW */
  1963. u16 seq_ctrl[5];
  1964. /* association procedure transaction sequence number */
  1965. u16 associate_seq;
  1966. /* AID for RTXed association responses */
  1967. u16 assoc_id;
  1968. /* power save mode related*/
  1969. u8 ack_tx_to_ieee;
  1970. short ps;
  1971. short sta_sleep;
  1972. int ps_timeout;
  1973. int ps_period;
  1974. struct tasklet_struct ps_task;
  1975. u64 ps_time;
  1976. bool polling;
  1977. short raw_tx;
  1978. /* used if IEEE_SOFTMAC_TX_QUEUE is set */
  1979. short queue_stop;
  1980. short scanning_continue ;
  1981. short proto_started;
  1982. short proto_stoppping;
  1983. struct semaphore wx_sem;
  1984. struct semaphore scan_sem;
  1985. struct semaphore ips_sem;
  1986. spinlock_t mgmt_tx_lock;
  1987. spinlock_t beacon_lock;
  1988. short beacon_txing;
  1989. short wap_set;
  1990. short ssid_set;
  1991. /* set on initialization */
  1992. u8 qos_support;
  1993. unsigned int wmm_acm;
  1994. /* for discarding duplicated packets in IBSS */
  1995. struct list_head ibss_mac_hash[IEEE_IBSS_MAC_HASH_SIZE];
  1996. /* for discarding duplicated packets in BSS */
  1997. u16 last_rxseq_num[17]; /* rx seq previous per-tid */
  1998. u16 last_rxfrag_num[17];/* tx frag previous per-tid */
  1999. unsigned long last_packet_time[17];
  2000. /* for PS mode */
  2001. unsigned long last_rx_ps_time;
  2002. bool bAwakePktSent;
  2003. u8 LPSDelayCnt;
  2004. /* used if IEEE_SOFTMAC_SINGLE_QUEUE is set */
  2005. struct sk_buff *mgmt_queue_ring[MGMT_QUEUE_NUM];
  2006. int mgmt_queue_head;
  2007. int mgmt_queue_tail;
  2008. #define RTLLIB_QUEUE_LIMIT 128
  2009. u8 AsocRetryCount;
  2010. unsigned int hw_header;
  2011. struct sk_buff_head skb_waitQ[MAX_QUEUE_SIZE];
  2012. struct sk_buff_head skb_aggQ[MAX_QUEUE_SIZE];
  2013. struct sk_buff_head skb_drv_aggQ[MAX_QUEUE_SIZE];
  2014. u32 sta_edca_param[4];
  2015. bool aggregation;
  2016. bool enable_rx_imm_BA;
  2017. bool bibsscoordinator;
  2018. bool bdynamic_txpower_enable;
  2019. bool bCTSToSelfEnable;
  2020. u8 CTSToSelfTH;
  2021. u32 fsync_time_interval;
  2022. u32 fsync_rate_bitmap;
  2023. u8 fsync_rssi_threshold;
  2024. bool bfsync_enable;
  2025. u8 fsync_multiple_timeinterval;
  2026. u32 fsync_firstdiff_ratethreshold;
  2027. u32 fsync_seconddiff_ratethreshold;
  2028. enum fsync_state fsync_state;
  2029. bool bis_any_nonbepkts;
  2030. struct bandwidth_autoswitch bandwidth_auto_switch;
  2031. bool FwRWRF;
  2032. struct rt_link_detect LinkDetectInfo;
  2033. bool bIsAggregateFrame;
  2034. struct rt_pwr_save_ctrl PowerSaveControl;
  2035. u8 amsdu_in_process;
  2036. /* used if IEEE_SOFTMAC_TX_QUEUE is set */
  2037. struct tx_pending tx_pending;
  2038. /* used if IEEE_SOFTMAC_ASSOCIATE is set */
  2039. struct timer_list associate_timer;
  2040. /* used if IEEE_SOFTMAC_BEACONS is set */
  2041. struct timer_list beacon_timer;
  2042. u8 need_sw_enc;
  2043. struct work_struct associate_complete_wq;
  2044. struct work_struct ips_leave_wq;
  2045. struct delayed_work associate_procedure_wq;
  2046. struct delayed_work softmac_scan_wq;
  2047. struct delayed_work softmac_hint11d_wq;
  2048. struct delayed_work associate_retry_wq;
  2049. struct delayed_work start_ibss_wq;
  2050. struct delayed_work hw_wakeup_wq;
  2051. struct delayed_work hw_sleep_wq;
  2052. struct delayed_work link_change_wq;
  2053. struct work_struct wx_sync_scan_wq;
  2054. struct workqueue_struct *wq;
  2055. union {
  2056. struct rtllib_rxb *RfdArray[REORDER_WIN_SIZE];
  2057. struct rtllib_rxb *stats_IndicateArray[REORDER_WIN_SIZE];
  2058. struct rtllib_rxb *prxbIndicateArray[REORDER_WIN_SIZE];
  2059. struct {
  2060. struct sw_chnl_cmd PreCommonCmd[MAX_PRECMD_CNT];
  2061. struct sw_chnl_cmd PostCommonCmd[MAX_POSTCMD_CNT];
  2062. struct sw_chnl_cmd RfDependCmd[MAX_RFDEPENDCMD_CNT];
  2063. };
  2064. };
  2065. /* Callback functions */
  2066. void (*set_security)(struct net_device *dev,
  2067. struct rtllib_security *sec);
  2068. /* Used to TX data frame by using txb structs.
  2069. * this is not used if in the softmac_features
  2070. * is set the flag IEEE_SOFTMAC_TX_QUEUE
  2071. */
  2072. int (*hard_start_xmit)(struct rtllib_txb *txb,
  2073. struct net_device *dev);
  2074. int (*reset_port)(struct net_device *dev);
  2075. int (*is_queue_full)(struct net_device *dev, int pri);
  2076. int (*handle_management)(struct net_device *dev,
  2077. struct rtllib_network *network, u16 type);
  2078. int (*is_qos_active)(struct net_device *dev, struct sk_buff *skb);
  2079. /* Softmac-generated frames (management) are TXed via this
  2080. * callback if the flag IEEE_SOFTMAC_SINGLE_QUEUE is
  2081. * not set. As some cards may have different HW queues that
  2082. * one might want to use for data and management frames
  2083. * the option to have two callbacks might be useful.
  2084. * This function can't sleep.
  2085. */
  2086. int (*softmac_hard_start_xmit)(struct sk_buff *skb,
  2087. struct net_device *dev);
  2088. /* used instead of hard_start_xmit (not softmac_hard_start_xmit)
  2089. * if the IEEE_SOFTMAC_TX_QUEUE feature is used to TX data
  2090. * frames. If the option IEEE_SOFTMAC_SINGLE_QUEUE is also set
  2091. * then also management frames are sent via this callback.
  2092. * This function can't sleep.
  2093. */
  2094. void (*softmac_data_hard_start_xmit)(struct sk_buff *skb,
  2095. struct net_device *dev, int rate);
  2096. /* stops the HW queue for DATA frames. Useful to avoid
  2097. * waste time to TX data frame when we are reassociating
  2098. * This function can sleep.
  2099. */
  2100. void (*data_hard_stop)(struct net_device *dev);
  2101. /* OK this is complementing to data_poll_hard_stop */
  2102. void (*data_hard_resume)(struct net_device *dev);
  2103. /* ask to the driver to retune the radio .
  2104. * This function can sleep. the driver should ensure
  2105. * the radio has been switched before return.
  2106. */
  2107. void (*set_chan)(struct net_device *dev, short ch);
  2108. /* These are not used if the ieee stack takes care of
  2109. * scanning (IEEE_SOFTMAC_SCAN feature set).
  2110. * In this case only the set_chan is used.
  2111. *
  2112. * The syncro version is similar to the start_scan but
  2113. * does not return until all channels has been scanned.
  2114. * this is called in user context and should sleep,
  2115. * it is called in a work_queue when switching to ad-hoc mode
  2116. * or in behalf of iwlist scan when the card is associated
  2117. * and root user ask for a scan.
  2118. * the function stop_scan should stop both the syncro and
  2119. * background scanning and can sleep.
  2120. * The function start_scan should initiate the background
  2121. * scanning and can't sleep.
  2122. */
  2123. void (*scan_syncro)(struct net_device *dev);
  2124. void (*start_scan)(struct net_device *dev);
  2125. void (*stop_scan)(struct net_device *dev);
  2126. void (*rtllib_start_hw_scan)(struct net_device *dev);
  2127. void (*rtllib_stop_hw_scan)(struct net_device *dev);
  2128. /* indicate the driver that the link state is changed
  2129. * for example it may indicate the card is associated now.
  2130. * Driver might be interested in this to apply RX filter
  2131. * rules or simply light the LINK led
  2132. */
  2133. void (*link_change)(struct net_device *dev);
  2134. /* these two function indicates to the HW when to start
  2135. * and stop to send beacons. This is used when the
  2136. * IEEE_SOFTMAC_BEACONS is not set. For now the
  2137. * stop_send_bacons is NOT guaranteed to be called only
  2138. * after start_send_beacons.
  2139. */
  2140. void (*start_send_beacons)(struct net_device *dev);
  2141. void (*stop_send_beacons)(struct net_device *dev);
  2142. /* power save mode related */
  2143. void (*sta_wake_up)(struct net_device *dev);
  2144. void (*enter_sleep_state)(struct net_device *dev, u64 time);
  2145. short (*ps_is_queue_empty)(struct net_device *dev);
  2146. int (*handle_beacon)(struct net_device *dev,
  2147. struct rtllib_beacon *beacon,
  2148. struct rtllib_network *network);
  2149. int (*handle_assoc_response)(struct net_device *dev,
  2150. struct rtllib_assoc_response_frame *resp,
  2151. struct rtllib_network *network);
  2152. /* check whether Tx hw resource available */
  2153. short (*check_nic_enough_desc)(struct net_device *dev, int queue_index);
  2154. short (*get_nic_desc_num)(struct net_device *dev, int queue_index);
  2155. void (*SetBWModeHandler)(struct net_device *dev,
  2156. enum ht_channel_width Bandwidth,
  2157. enum ht_extchnl_offset Offset);
  2158. bool (*GetNmodeSupportBySecCfg)(struct net_device *dev);
  2159. void (*SetWirelessMode)(struct net_device *dev, u8 wireless_mode);
  2160. bool (*GetHalfNmodeSupportByAPsHandler)(struct net_device *dev);
  2161. u8 (*rtllib_ap_sec_type)(struct rtllib_device *ieee);
  2162. void (*HalUsbRxAggrHandler)(struct net_device *dev, bool Value);
  2163. void (*InitialGainHandler)(struct net_device *dev, u8 Operation);
  2164. bool (*SetFwCmdHandler)(struct net_device *dev,
  2165. enum fw_cmd_io_type FwCmdIO);
  2166. void (*UpdateHalRAMaskHandler)(struct net_device *dev, bool bMulticast,
  2167. u8 macId, u8 MimoPs, u8 WirelessMode,
  2168. u8 bCurTxBW40MHz, u8 rssi_level);
  2169. void (*UpdateBeaconInterruptHandler)(struct net_device *dev,
  2170. bool start);
  2171. void (*UpdateInterruptMaskHandler)(struct net_device *dev, u32 AddMSR,
  2172. u32 RemoveMSR);
  2173. u16 (*rtl_11n_user_show_rates)(struct net_device *dev);
  2174. void (*ScanOperationBackupHandler)(struct net_device *dev,
  2175. u8 Operation);
  2176. void (*LedControlHandler)(struct net_device *dev,
  2177. enum led_ctl_mode LedAction);
  2178. void (*SetHwRegHandler)(struct net_device *dev, u8 variable, u8 *val);
  2179. void (*GetHwRegHandler)(struct net_device *dev, u8 variable, u8 *val);
  2180. void (*AllowAllDestAddrHandler)(struct net_device *dev,
  2181. bool bAllowAllDA, bool WriteIntoReg);
  2182. void (*rtllib_ips_leave_wq)(struct net_device *dev);
  2183. void (*rtllib_ips_leave)(struct net_device *dev);
  2184. void (*LeisurePSLeave)(struct net_device *dev);
  2185. void (*rtllib_rfkill_poll)(struct net_device *dev);
  2186. /* This must be the last item so that it points to the data
  2187. * allocated beyond this structure by alloc_rtllib */
  2188. u8 priv[0];
  2189. };
  2190. #define IEEE_A (1<<0)
  2191. #define IEEE_B (1<<1)
  2192. #define IEEE_G (1<<2)
  2193. #define IEEE_N_24G (1<<4)
  2194. #define IEEE_N_5G (1<<5)
  2195. #define IEEE_MODE_MASK (IEEE_A|IEEE_B|IEEE_G)
  2196. /* Generate a 802.11 header */
  2197. /* Uses the channel change callback directly
  2198. * instead of [start/stop] scan callbacks
  2199. */
  2200. #define IEEE_SOFTMAC_SCAN (1<<2)
  2201. /* Perform authentication and association handshake */
  2202. #define IEEE_SOFTMAC_ASSOCIATE (1<<3)
  2203. /* Generate probe requests */
  2204. #define IEEE_SOFTMAC_PROBERQ (1<<4)
  2205. /* Generate response to probe requests */
  2206. #define IEEE_SOFTMAC_PROBERS (1<<5)
  2207. /* The ieee802.11 stack will manage the netif queue
  2208. * wake/stop for the driver, taking care of 802.11
  2209. * fragmentation. See softmac.c for details. */
  2210. #define IEEE_SOFTMAC_TX_QUEUE (1<<7)
  2211. /* Uses only the softmac_data_hard_start_xmit
  2212. * even for TX management frames.
  2213. */
  2214. #define IEEE_SOFTMAC_SINGLE_QUEUE (1<<8)
  2215. /* Generate beacons. The stack will enqueue beacons
  2216. * to the card
  2217. */
  2218. #define IEEE_SOFTMAC_BEACONS (1<<6)
  2219. static inline void *rtllib_priv(struct net_device *dev)
  2220. {
  2221. return ((struct rtllib_device *)netdev_priv(dev))->priv;
  2222. }
  2223. static inline int rtllib_is_empty_essid(const char *essid, int essid_len)
  2224. {
  2225. /* Single white space is for Linksys APs */
  2226. if (essid_len == 1 && essid[0] == ' ')
  2227. return 1;
  2228. /* Otherwise, if the entire essid is 0, we assume it is hidden */
  2229. while (essid_len) {
  2230. essid_len--;
  2231. if (essid[essid_len] != '\0')
  2232. return 0;
  2233. }
  2234. return 1;
  2235. }
  2236. static inline int rtllib_is_valid_mode(struct rtllib_device *ieee, int mode)
  2237. {
  2238. /*
  2239. * It is possible for both access points and our device to support
  2240. * combinations of modes, so as long as there is one valid combination
  2241. * of ap/device supported modes, then return success
  2242. *
  2243. */
  2244. if ((mode & IEEE_A) &&
  2245. (ieee->modulation & RTLLIB_OFDM_MODULATION) &&
  2246. (ieee->freq_band & RTLLIB_52GHZ_BAND))
  2247. return 1;
  2248. if ((mode & IEEE_G) &&
  2249. (ieee->modulation & RTLLIB_OFDM_MODULATION) &&
  2250. (ieee->freq_band & RTLLIB_24GHZ_BAND))
  2251. return 1;
  2252. if ((mode & IEEE_B) &&
  2253. (ieee->modulation & RTLLIB_CCK_MODULATION) &&
  2254. (ieee->freq_band & RTLLIB_24GHZ_BAND))
  2255. return 1;
  2256. return 0;
  2257. }
  2258. static inline int rtllib_get_hdrlen(u16 fc)
  2259. {
  2260. int hdrlen = RTLLIB_3ADDR_LEN;
  2261. switch (WLAN_FC_GET_TYPE(fc)) {
  2262. case RTLLIB_FTYPE_DATA:
  2263. if ((fc & RTLLIB_FCTL_FROMDS) && (fc & RTLLIB_FCTL_TODS))
  2264. hdrlen = RTLLIB_4ADDR_LEN; /* Addr4 */
  2265. if (RTLLIB_QOS_HAS_SEQ(fc))
  2266. hdrlen += 2; /* QOS ctrl*/
  2267. break;
  2268. case RTLLIB_FTYPE_CTL:
  2269. switch (WLAN_FC_GET_STYPE(fc)) {
  2270. case RTLLIB_STYPE_CTS:
  2271. case RTLLIB_STYPE_ACK:
  2272. hdrlen = RTLLIB_1ADDR_LEN;
  2273. break;
  2274. default:
  2275. hdrlen = RTLLIB_2ADDR_LEN;
  2276. break;
  2277. }
  2278. break;
  2279. }
  2280. return hdrlen;
  2281. }
  2282. static inline u8 *rtllib_get_payload(struct rtllib_hdr *hdr)
  2283. {
  2284. switch (rtllib_get_hdrlen(le16_to_cpu(hdr->frame_ctl))) {
  2285. case RTLLIB_1ADDR_LEN:
  2286. return ((struct rtllib_hdr_1addr *)hdr)->payload;
  2287. case RTLLIB_2ADDR_LEN:
  2288. return ((struct rtllib_hdr_2addr *)hdr)->payload;
  2289. case RTLLIB_3ADDR_LEN:
  2290. return ((struct rtllib_hdr_3addr *)hdr)->payload;
  2291. case RTLLIB_4ADDR_LEN:
  2292. return ((struct rtllib_hdr_4addr *)hdr)->payload;
  2293. }
  2294. return NULL;
  2295. }
  2296. static inline int rtllib_is_ofdm_rate(u8 rate)
  2297. {
  2298. switch (rate & ~RTLLIB_BASIC_RATE_MASK) {
  2299. case RTLLIB_OFDM_RATE_6MB:
  2300. case RTLLIB_OFDM_RATE_9MB:
  2301. case RTLLIB_OFDM_RATE_12MB:
  2302. case RTLLIB_OFDM_RATE_18MB:
  2303. case RTLLIB_OFDM_RATE_24MB:
  2304. case RTLLIB_OFDM_RATE_36MB:
  2305. case RTLLIB_OFDM_RATE_48MB:
  2306. case RTLLIB_OFDM_RATE_54MB:
  2307. return 1;
  2308. }
  2309. return 0;
  2310. }
  2311. static inline int rtllib_is_cck_rate(u8 rate)
  2312. {
  2313. switch (rate & ~RTLLIB_BASIC_RATE_MASK) {
  2314. case RTLLIB_CCK_RATE_1MB:
  2315. case RTLLIB_CCK_RATE_2MB:
  2316. case RTLLIB_CCK_RATE_5MB:
  2317. case RTLLIB_CCK_RATE_11MB:
  2318. return 1;
  2319. }
  2320. return 0;
  2321. }
  2322. /* rtllib.c */
  2323. extern void free_rtllib(struct net_device *dev);
  2324. extern struct net_device *alloc_rtllib(int sizeof_priv);
  2325. extern int rtllib_set_encryption(struct rtllib_device *ieee);
  2326. /* rtllib_tx.c */
  2327. extern int rtllib_encrypt_fragment(
  2328. struct rtllib_device *ieee,
  2329. struct sk_buff *frag,
  2330. int hdr_len);
  2331. extern int rtllib_xmit(struct sk_buff *skb, struct net_device *dev);
  2332. extern int rtllib_xmit_inter(struct sk_buff *skb, struct net_device *dev);
  2333. extern void rtllib_txb_free(struct rtllib_txb *);
  2334. /* rtllib_rx.c */
  2335. extern int rtllib_rx(struct rtllib_device *ieee, struct sk_buff *skb,
  2336. struct rtllib_rx_stats *rx_stats);
  2337. extern void rtllib_rx_mgt(struct rtllib_device *ieee,
  2338. struct sk_buff *skb,
  2339. struct rtllib_rx_stats *stats);
  2340. extern void rtllib_rx_probe_rq(struct rtllib_device *ieee,
  2341. struct sk_buff *skb);
  2342. extern int rtllib_legal_channel(struct rtllib_device *rtllib, u8 channel);
  2343. /* rtllib_wx.c */
  2344. extern int rtllib_wx_get_scan(struct rtllib_device *ieee,
  2345. struct iw_request_info *info,
  2346. union iwreq_data *wrqu, char *key);
  2347. extern int rtllib_wx_set_encode(struct rtllib_device *ieee,
  2348. struct iw_request_info *info,
  2349. union iwreq_data *wrqu, char *key);
  2350. extern int rtllib_wx_get_encode(struct rtllib_device *ieee,
  2351. struct iw_request_info *info,
  2352. union iwreq_data *wrqu, char *key);
  2353. #if WIRELESS_EXT >= 18
  2354. extern int rtllib_wx_get_encode_ext(struct rtllib_device *ieee,
  2355. struct iw_request_info *info,
  2356. union iwreq_data *wrqu, char *extra);
  2357. extern int rtllib_wx_set_encode_ext(struct rtllib_device *ieee,
  2358. struct iw_request_info *info,
  2359. union iwreq_data *wrqu, char *extra);
  2360. #endif
  2361. extern int rtllib_wx_set_auth(struct rtllib_device *ieee,
  2362. struct iw_request_info *info,
  2363. struct iw_param *data, char *extra);
  2364. extern int rtllib_wx_set_mlme(struct rtllib_device *ieee,
  2365. struct iw_request_info *info,
  2366. union iwreq_data *wrqu, char *extra);
  2367. extern int rtllib_wx_set_gen_ie(struct rtllib_device *ieee, u8 *ie, size_t len);
  2368. /* rtllib_softmac.c */
  2369. extern short rtllib_is_54g(struct rtllib_network *net);
  2370. extern short rtllib_is_shortslot(const struct rtllib_network *net);
  2371. extern int rtllib_rx_frame_softmac(struct rtllib_device *ieee,
  2372. struct sk_buff *skb,
  2373. struct rtllib_rx_stats *rx_stats, u16 type,
  2374. u16 stype);
  2375. extern void rtllib_softmac_new_net(struct rtllib_device *ieee,
  2376. struct rtllib_network *net);
  2377. void SendDisassociation(struct rtllib_device *ieee, bool deauth, u16 asRsn);
  2378. extern void rtllib_softmac_xmit(struct rtllib_txb *txb,
  2379. struct rtllib_device *ieee);
  2380. extern void rtllib_stop_send_beacons(struct rtllib_device *ieee);
  2381. extern void notify_wx_assoc_event(struct rtllib_device *ieee);
  2382. extern void rtllib_softmac_check_all_nets(struct rtllib_device *ieee);
  2383. extern void rtllib_start_bss(struct rtllib_device *ieee);
  2384. extern void rtllib_start_master_bss(struct rtllib_device *ieee);
  2385. extern void rtllib_start_ibss(struct rtllib_device *ieee);
  2386. extern void rtllib_softmac_init(struct rtllib_device *ieee);
  2387. extern void rtllib_softmac_free(struct rtllib_device *ieee);
  2388. extern void rtllib_associate_abort(struct rtllib_device *ieee);
  2389. extern void rtllib_disassociate(struct rtllib_device *ieee);
  2390. extern void rtllib_stop_scan(struct rtllib_device *ieee);
  2391. extern bool rtllib_act_scanning(struct rtllib_device *ieee, bool sync_scan);
  2392. extern void rtllib_stop_scan_syncro(struct rtllib_device *ieee);
  2393. extern void rtllib_start_scan_syncro(struct rtllib_device *ieee, u8 is_mesh);
  2394. extern inline struct sk_buff *rtllib_probe_req(struct rtllib_device *ieee);
  2395. extern u8 MgntQuery_MgntFrameTxRate(struct rtllib_device *ieee);
  2396. extern void rtllib_sta_ps_send_null_frame(struct rtllib_device *ieee,
  2397. short pwr);
  2398. extern void rtllib_sta_wakeup(struct rtllib_device *ieee, short nl);
  2399. extern void rtllib_sta_ps_send_pspoll_frame(struct rtllib_device *ieee);
  2400. extern void rtllib_check_all_nets(struct rtllib_device *ieee);
  2401. extern void rtllib_start_protocol(struct rtllib_device *ieee);
  2402. extern void rtllib_stop_protocol(struct rtllib_device *ieee, u8 shutdown);
  2403. extern void rtllib_EnableNetMonitorMode(struct net_device *dev,
  2404. bool bInitState);
  2405. extern void rtllib_DisableNetMonitorMode(struct net_device *dev,
  2406. bool bInitState);
  2407. extern void rtllib_EnableIntelPromiscuousMode(struct net_device *dev,
  2408. bool bInitState);
  2409. extern void rtllib_DisableIntelPromiscuousMode(struct net_device *dev,
  2410. bool bInitState);
  2411. extern void rtllib_send_probe_requests(struct rtllib_device *ieee, u8 is_mesh);
  2412. extern void rtllib_softmac_stop_protocol(struct rtllib_device *ieee,
  2413. u8 mesh_flag, u8 shutdown);
  2414. extern void rtllib_softmac_start_protocol(struct rtllib_device *ieee,
  2415. u8 mesh_flag);
  2416. extern void rtllib_reset_queue(struct rtllib_device *ieee);
  2417. extern void rtllib_wake_queue(struct rtllib_device *ieee);
  2418. extern void rtllib_stop_queue(struct rtllib_device *ieee);
  2419. extern void rtllib_wake_all_queues(struct rtllib_device *ieee);
  2420. extern void rtllib_stop_all_queues(struct rtllib_device *ieee);
  2421. extern struct sk_buff *rtllib_get_beacon(struct rtllib_device *ieee);
  2422. extern void rtllib_start_send_beacons(struct rtllib_device *ieee);
  2423. extern void rtllib_stop_send_beacons(struct rtllib_device *ieee);
  2424. extern int rtllib_wpa_supplicant_ioctl(struct rtllib_device *ieee,
  2425. struct iw_point *p, u8 is_mesh);
  2426. extern void notify_wx_assoc_event(struct rtllib_device *ieee);
  2427. extern void rtllib_ps_tx_ack(struct rtllib_device *ieee, short success);
  2428. extern void softmac_mgmt_xmit(struct sk_buff *skb,
  2429. struct rtllib_device *ieee);
  2430. extern u16 rtllib_query_seqnum(struct rtllib_device *ieee,
  2431. struct sk_buff *skb, u8 *dst);
  2432. extern u8 rtllib_ap_sec_type(struct rtllib_device *ieee);
  2433. /* rtllib_crypt_ccmp&tkip&wep.c */
  2434. extern void rtllib_tkip_null(void);
  2435. extern void rtllib_wep_null(void);
  2436. extern void rtllib_ccmp_null(void);
  2437. /* rtllib_softmac_wx.c */
  2438. extern int rtllib_wx_get_wap(struct rtllib_device *ieee,
  2439. struct iw_request_info *info,
  2440. union iwreq_data *wrqu, char *ext);
  2441. extern int rtllib_wx_set_wap(struct rtllib_device *ieee,
  2442. struct iw_request_info *info,
  2443. union iwreq_data *awrq,
  2444. char *extra);
  2445. extern int rtllib_wx_get_essid(struct rtllib_device *ieee,
  2446. struct iw_request_info *a,
  2447. union iwreq_data *wrqu, char *b);
  2448. extern int rtllib_wx_set_rate(struct rtllib_device *ieee,
  2449. struct iw_request_info *info,
  2450. union iwreq_data *wrqu, char *extra);
  2451. extern int rtllib_wx_get_rate(struct rtllib_device *ieee,
  2452. struct iw_request_info *info,
  2453. union iwreq_data *wrqu, char *extra);
  2454. extern int rtllib_wx_set_mode(struct rtllib_device *ieee,
  2455. struct iw_request_info *a,
  2456. union iwreq_data *wrqu, char *b);
  2457. extern int rtllib_wx_set_scan(struct rtllib_device *ieee,
  2458. struct iw_request_info *a,
  2459. union iwreq_data *wrqu, char *b);
  2460. extern int rtllib_wx_set_essid(struct rtllib_device *ieee,
  2461. struct iw_request_info *a,
  2462. union iwreq_data *wrqu, char *extra);
  2463. extern int rtllib_wx_get_mode(struct rtllib_device *ieee,
  2464. struct iw_request_info *a,
  2465. union iwreq_data *wrqu, char *b);
  2466. extern int rtllib_wx_set_freq(struct rtllib_device *ieee,
  2467. struct iw_request_info *a,
  2468. union iwreq_data *wrqu, char *b);
  2469. extern int rtllib_wx_get_freq(struct rtllib_device *ieee,
  2470. struct iw_request_info *a,
  2471. union iwreq_data *wrqu, char *b);
  2472. extern void rtllib_wx_sync_scan_wq(void *data);
  2473. extern int rtllib_wx_set_rawtx(struct rtllib_device *ieee,
  2474. struct iw_request_info *info,
  2475. union iwreq_data *wrqu, char *extra);
  2476. extern int rtllib_wx_get_name(struct rtllib_device *ieee,
  2477. struct iw_request_info *info,
  2478. union iwreq_data *wrqu, char *extra);
  2479. extern int rtllib_wx_set_power(struct rtllib_device *ieee,
  2480. struct iw_request_info *info,
  2481. union iwreq_data *wrqu, char *extra);
  2482. extern int rtllib_wx_get_power(struct rtllib_device *ieee,
  2483. struct iw_request_info *info,
  2484. union iwreq_data *wrqu, char *extra);
  2485. extern int rtllib_wx_set_rts(struct rtllib_device *ieee,
  2486. struct iw_request_info *info,
  2487. union iwreq_data *wrqu, char *extra);
  2488. extern int rtllib_wx_get_rts(struct rtllib_device *ieee,
  2489. struct iw_request_info *info,
  2490. union iwreq_data *wrqu, char *extra);
  2491. #define MAX_RECEIVE_BUFFER_SIZE 9100
  2492. extern void HTDebugHTCapability(u8 *CapIE, u8 *TitleString);
  2493. extern void HTDebugHTInfo(u8 *InfoIE, u8 *TitleString);
  2494. void HTSetConnectBwMode(struct rtllib_device *ieee,
  2495. enum ht_channel_width Bandwidth,
  2496. enum ht_extchnl_offset Offset);
  2497. extern void HTUpdateDefaultSetting(struct rtllib_device *ieee);
  2498. extern void HTConstructCapabilityElement(struct rtllib_device *ieee,
  2499. u8 *posHTCap, u8 *len,
  2500. u8 isEncrypt, bool bAssoc);
  2501. extern void HTConstructInfoElement(struct rtllib_device *ieee,
  2502. u8 *posHTInfo, u8 *len, u8 isEncrypt);
  2503. extern void HTConstructRT2RTAggElement(struct rtllib_device *ieee,
  2504. u8 *posRT2RTAgg, u8 *len);
  2505. extern void HTOnAssocRsp(struct rtllib_device *ieee);
  2506. extern void HTInitializeHTInfo(struct rtllib_device *ieee);
  2507. extern void HTInitializeBssDesc(struct bss_ht *pBssHT);
  2508. extern void HTResetSelfAndSavePeerSetting(struct rtllib_device *ieee,
  2509. struct rtllib_network *pNetwork);
  2510. extern void HT_update_self_and_peer_setting(struct rtllib_device *ieee,
  2511. struct rtllib_network *pNetwork);
  2512. extern u8 HTGetHighestMCSRate(struct rtllib_device *ieee, u8 *pMCSRateSet,
  2513. u8 *pMCSFilter);
  2514. extern u8 MCS_FILTER_ALL[];
  2515. extern u16 MCS_DATA_RATE[2][2][77] ;
  2516. extern u8 HTCCheck(struct rtllib_device *ieee, u8 *pFrame);
  2517. extern void HTResetIOTSetting(struct rt_hi_throughput *pHTInfo);
  2518. extern bool IsHTHalfNmodeAPs(struct rtllib_device *ieee);
  2519. extern u16 HTHalfMcsToDataRate(struct rtllib_device *ieee, u8 nMcsRate);
  2520. extern u16 HTMcsToDataRate(struct rtllib_device *ieee, u8 nMcsRate);
  2521. extern u16 TxCountToDataRate(struct rtllib_device *ieee, u8 nDataRate);
  2522. extern int rtllib_rx_ADDBAReq(struct rtllib_device *ieee, struct sk_buff *skb);
  2523. extern int rtllib_rx_ADDBARsp(struct rtllib_device *ieee, struct sk_buff *skb);
  2524. extern int rtllib_rx_DELBA(struct rtllib_device *ieee, struct sk_buff *skb);
  2525. extern void TsInitAddBA(struct rtllib_device *ieee, struct tx_ts_record *pTS,
  2526. u8 Policy, u8 bOverwritePending);
  2527. extern void TsInitDelBA(struct rtllib_device *ieee,
  2528. struct ts_common_info *pTsCommonInfo,
  2529. enum tr_select TxRxSelect);
  2530. extern void BaSetupTimeOut(unsigned long data);
  2531. extern void TxBaInactTimeout(unsigned long data);
  2532. extern void RxBaInactTimeout(unsigned long data);
  2533. extern void ResetBaEntry(struct ba_record *pBA);
  2534. extern bool GetTs(
  2535. struct rtllib_device *ieee,
  2536. struct ts_common_info **ppTS,
  2537. u8 *Addr,
  2538. u8 TID,
  2539. enum tr_select TxRxSelect,
  2540. bool bAddNewTs
  2541. );
  2542. extern void TSInitialize(struct rtllib_device *ieee);
  2543. extern void TsStartAddBaProcess(struct rtllib_device *ieee,
  2544. struct tx_ts_record *pTxTS);
  2545. extern void RemovePeerTS(struct rtllib_device *ieee, u8 *Addr);
  2546. extern void RemoveAllTS(struct rtllib_device *ieee);
  2547. void rtllib_softmac_scan_syncro(struct rtllib_device *ieee, u8 is_mesh);
  2548. extern const long rtllib_wlan_frequencies[];
  2549. extern inline void rtllib_increment_scans(struct rtllib_device *ieee)
  2550. {
  2551. ieee->scans++;
  2552. }
  2553. extern inline int rtllib_get_scans(struct rtllib_device *ieee)
  2554. {
  2555. return ieee->scans;
  2556. }
  2557. static inline const char *escape_essid(const char *essid, u8 essid_len)
  2558. {
  2559. static char escaped[IW_ESSID_MAX_SIZE * 2 + 1];
  2560. if (rtllib_is_empty_essid(essid, essid_len)) {
  2561. memcpy(escaped, "<hidden>", sizeof("<hidden>"));
  2562. return escaped;
  2563. }
  2564. snprintf(escaped, sizeof(escaped), "%*pEn", essid_len, essid);
  2565. return escaped;
  2566. }
  2567. #define CONVERT_RATE(_ieee, _MGN_RATE) \
  2568. ((_MGN_RATE < MGN_MCS0) ? (_MGN_RATE) : \
  2569. (HTMcsToDataRate(_ieee, (u8)_MGN_RATE)))
  2570. /* fun with the built-in rtllib stack... */
  2571. bool rtllib_MgntDisconnect(struct rtllib_device *rtllib, u8 asRsn);
  2572. /* For the function is more related to hardware setting, it's better to use the
  2573. * ieee handler to refer to it.
  2574. */
  2575. extern void rtllib_update_active_chan_map(struct rtllib_device *ieee);
  2576. extern void rtllib_FlushRxTsPendingPkts(struct rtllib_device *ieee,
  2577. struct rx_ts_record *pTS);
  2578. extern int rtllib_data_xmit(struct sk_buff *skb, struct net_device *dev);
  2579. extern int rtllib_parse_info_param(struct rtllib_device *ieee,
  2580. struct rtllib_info_element *info_element,
  2581. u16 length,
  2582. struct rtllib_network *network,
  2583. struct rtllib_rx_stats *stats);
  2584. void rtllib_indicate_packets(struct rtllib_device *ieee,
  2585. struct rtllib_rxb **prxbIndicateArray, u8 index);
  2586. extern u8 HTFilterMCSRate(struct rtllib_device *ieee, u8 *pSupportMCS,
  2587. u8 *pOperateMCS);
  2588. extern void HTUseDefaultSetting(struct rtllib_device *ieee);
  2589. #define RT_ASOC_RETRY_LIMIT 5
  2590. u8 MgntQuery_TxRateExcludeCCKRates(struct rtllib_device *ieee);
  2591. extern void rtllib_TURBO_Info(struct rtllib_device *ieee, u8 **tag_p);
  2592. #ifndef ENABLE_LOCK_DEBUG
  2593. #define SPIN_LOCK_IEEE(plock) spin_lock_irqsave((plock), flags)
  2594. #define SPIN_UNLOCK_IEEE(plock) spin_unlock_irqrestore((plock), flags)
  2595. #define SPIN_LOCK_IEEE_REORDER(plock) spin_lock_irqsave((plock), flags)
  2596. #define SPIN_UNLOCK_IEEE_REORDER(plock) spin_unlock_irqrestore((plock), flags)
  2597. #define SPIN_LOCK_IEEE_WPAX(plock) spin_lock_irqsave((plock), flags)
  2598. #define SPIN_UNLOCK_IEEE_WPAX(plock) spin_unlock_irqrestore((plock), flags)
  2599. #define SPIN_LOCK_IEEE_MGNTTX(plock) spin_lock_irqsave((plock), flags)
  2600. #define SPIN_UNLOCK_IEEE_MGNTTX(plock) spin_unlock_irqrestore((plock), flags)
  2601. #define SPIN_LOCK_IEEE_BCN(plock) spin_lock_irqsave((plock), flags)
  2602. #define SPIN_UNLOCK_IEEE_BCN(plock) spin_unlock_irqrestore((plock), flags)
  2603. #define SPIN_LOCK_MSH_STAINFO(plock) spin_lock_irqsave((plock), flags)
  2604. #define SPIN_UNLOCK_MSH_STAINFO(plock) spin_unlock_irqrestore((plock), flags)
  2605. #define SPIN_LOCK_MSH_PREQ(plock) spin_lock_irqsave((plock), flags)
  2606. #define SPIN_UNLOCK_MSH_PREQ(plock) spin_unlock_irqrestore((plock), flags)
  2607. #define SPIN_LOCK_MSH_QUEUE(plock) spin_lock_irqsave((plock), flags)
  2608. #define SPIN_UNLOCK_MSH_QUEUE(plock) spin_unlock_irqrestore((plock), flags)
  2609. #define SPIN_LOCK_PRIV_RFPS(plock) spin_lock_irqsave((plock), flags)
  2610. #define SPIN_UNLOCK_PRIV_RFPS(plock) spin_unlock_irqrestore((plock), flags)
  2611. #define SPIN_LOCK_PRIV_IRQTH(plock) spin_lock_irqsave((plock), flags)
  2612. #define SPIN_UNLOCK_PRIV_IRQTH(plock) spin_unlock_irqrestore((plock), flags)
  2613. #define SPIN_LOCK_PRIV_TX(plock) spin_lock_irqsave((plock), flags)
  2614. #define SPIN_UNLOCK_PRIV_TX(plock) spin_unlock_irqrestore((plock), flags)
  2615. #define SPIN_LOCK_PRIV_D3(plock) spin_lock_irqsave((plock), flags)
  2616. #define SPIN_UNLOCK_PRIV_D3(plock) spin_unlock_irqrestore((plock), flags)
  2617. #define SPIN_LOCK_PRIV_RF(plock) spin_lock_irqsave((plock), flags)
  2618. #define SPIN_UNLOCK_PRIV_RF(plock) spin_unlock_irqrestore((plock), flags)
  2619. #define SPIN_LOCK_PRIV_PS(plock) spin_lock_irqsave((plock), flags)
  2620. #define SPIN_UNLOCK_PRIV_PS(plock) spin_unlock_irqrestore((plock), flags)
  2621. #define SEM_DOWN_IEEE_WX(psem) down(psem)
  2622. #define SEM_UP_IEEE_WX(psem) up(psem)
  2623. #define SEM_DOWN_IEEE_SCAN(psem) down(psem)
  2624. #define SEM_UP_IEEE_SCAN(psem) up(psem)
  2625. #define SEM_DOWN_IEEE_IPS(psem) down(psem)
  2626. #define SEM_UP_IEEE_IPS(psem) up(psem)
  2627. #define SEM_DOWN_PRIV_WX(psem) down(psem)
  2628. #define SEM_UP_PRIV_WX(psem) up(psem)
  2629. #define SEM_DOWN_PRIV_RF(psem) down(psem)
  2630. #define SEM_UP_PRIV_RF(psem) up(psem)
  2631. #define MUTEX_LOCK_PRIV(pmutex) mutex_lock(pmutex)
  2632. #define MUTEX_UNLOCK_PRIV(pmutex) mutex_unlock(pmutex)
  2633. #endif
  2634. #endif /* RTLLIB_H */