wifi.h 67 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790
  1. /******************************************************************************
  2. *
  3. * Copyright(c) 2009-2012 Realtek Corporation.
  4. *
  5. * This program is free software; you can redistribute it and/or modify it
  6. * under the terms of version 2 of the GNU General Public License as
  7. * published by the Free Software Foundation.
  8. *
  9. * This program is distributed in the hope that it will be useful, but WITHOUT
  10. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  12. * more details.
  13. *
  14. * You should have received a copy of the GNU General Public License along with
  15. * this program; if not, write to the Free Software Foundation, Inc.,
  16. * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
  17. *
  18. * The full GNU General Public License is included in this distribution in the
  19. * file called LICENSE.
  20. *
  21. * Contact Information:
  22. * wlanfae <wlanfae@realtek.com>
  23. * Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
  24. * Hsinchu 300, Taiwan.
  25. *
  26. * Larry Finger <Larry.Finger@lwfinger.net>
  27. *
  28. *****************************************************************************/
  29. #ifndef __RTL_WIFI_H__
  30. #define __RTL_WIFI_H__
  31. #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
  32. #include <linux/sched.h>
  33. #include <linux/firmware.h>
  34. #include <linux/etherdevice.h>
  35. #include <linux/vmalloc.h>
  36. #include <linux/usb.h>
  37. #include <net/mac80211.h>
  38. #include <linux/completion.h>
  39. #include "debug.h"
  40. #define MASKBYTE0 0xff
  41. #define MASKBYTE1 0xff00
  42. #define MASKBYTE2 0xff0000
  43. #define MASKBYTE3 0xff000000
  44. #define MASKHWORD 0xffff0000
  45. #define MASKLWORD 0x0000ffff
  46. #define MASKDWORD 0xffffffff
  47. #define MASK12BITS 0xfff
  48. #define MASKH4BITS 0xf0000000
  49. #define MASKOFDM_D 0xffc00000
  50. #define MASKCCK 0x3f3f3f3f
  51. #define MASK4BITS 0x0f
  52. #define MASK20BITS 0xfffff
  53. #define RFREG_OFFSET_MASK 0xfffff
  54. #define MASKBYTE0 0xff
  55. #define MASKBYTE1 0xff00
  56. #define MASKBYTE2 0xff0000
  57. #define MASKBYTE3 0xff000000
  58. #define MASKHWORD 0xffff0000
  59. #define MASKLWORD 0x0000ffff
  60. #define MASKDWORD 0xffffffff
  61. #define MASK12BITS 0xfff
  62. #define MASKH4BITS 0xf0000000
  63. #define MASKOFDM_D 0xffc00000
  64. #define MASKCCK 0x3f3f3f3f
  65. #define MASK4BITS 0x0f
  66. #define MASK20BITS 0xfffff
  67. #define RFREG_OFFSET_MASK 0xfffff
  68. #define RF_CHANGE_BY_INIT 0
  69. #define RF_CHANGE_BY_IPS BIT(28)
  70. #define RF_CHANGE_BY_PS BIT(29)
  71. #define RF_CHANGE_BY_HW BIT(30)
  72. #define RF_CHANGE_BY_SW BIT(31)
  73. #define IQK_ADDA_REG_NUM 16
  74. #define IQK_MAC_REG_NUM 4
  75. #define IQK_THRESHOLD 8
  76. #define MAX_KEY_LEN 61
  77. #define KEY_BUF_SIZE 5
  78. /* QoS related. */
  79. /*aci: 0x00 Best Effort*/
  80. /*aci: 0x01 Background*/
  81. /*aci: 0x10 Video*/
  82. /*aci: 0x11 Voice*/
  83. /*Max: define total number.*/
  84. #define AC0_BE 0
  85. #define AC1_BK 1
  86. #define AC2_VI 2
  87. #define AC3_VO 3
  88. #define AC_MAX 4
  89. #define QOS_QUEUE_NUM 4
  90. #define RTL_MAC80211_NUM_QUEUE 5
  91. #define REALTEK_USB_VENQT_MAX_BUF_SIZE 254
  92. #define RTL_USB_MAX_RX_COUNT 100
  93. #define QBSS_LOAD_SIZE 5
  94. #define MAX_WMMELE_LENGTH 64
  95. #define TOTAL_CAM_ENTRY 32
  96. /*slot time for 11g. */
  97. #define RTL_SLOT_TIME_9 9
  98. #define RTL_SLOT_TIME_20 20
  99. /*related to tcp/ip. */
  100. #define SNAP_SIZE 6
  101. #define PROTOC_TYPE_SIZE 2
  102. /*related with 802.11 frame*/
  103. #define MAC80211_3ADDR_LEN 24
  104. #define MAC80211_4ADDR_LEN 30
  105. #define CHANNEL_MAX_NUMBER (14 + 24 + 21) /* 14 is the max channel no */
  106. #define CHANNEL_MAX_NUMBER_2G 14
  107. #define CHANNEL_MAX_NUMBER_5G 54 /* Please refer to
  108. *"phy_GetChnlGroup8812A" and
  109. * "Hal_ReadTxPowerInfo8812A"
  110. */
  111. #define CHANNEL_MAX_NUMBER_5G_80M 7
  112. #define CHANNEL_GROUP_MAX (3 + 9) /* ch1~3, 4~9, 10~14 = three groups */
  113. #define CHANNEL_MAX_NUMBER_5G 54 /* Please refer to
  114. *"phy_GetChnlGroup8812A" and
  115. * "Hal_ReadTxPowerInfo8812A"
  116. */
  117. #define CHANNEL_MAX_NUMBER_5G_80M 7
  118. #define MAX_PG_GROUP 13
  119. #define CHANNEL_GROUP_MAX_2G 3
  120. #define CHANNEL_GROUP_IDX_5GL 3
  121. #define CHANNEL_GROUP_IDX_5GM 6
  122. #define CHANNEL_GROUP_IDX_5GH 9
  123. #define CHANNEL_GROUP_MAX_5G 9
  124. #define CHANNEL_MAX_NUMBER_2G 14
  125. #define AVG_THERMAL_NUM 8
  126. #define AVG_THERMAL_NUM_88E 4
  127. #define AVG_THERMAL_NUM_8723BE 4
  128. #define MAX_TID_COUNT 9
  129. /* for early mode */
  130. #define FCS_LEN 4
  131. #define EM_HDR_LEN 8
  132. #define MAX_TX_COUNT 4
  133. #define MAX_RF_PATH 4
  134. #define MAX_CHNL_GROUP_24G 6
  135. #define MAX_CHNL_GROUP_5G 14
  136. #define TX_PWR_BY_RATE_NUM_BAND 2
  137. #define TX_PWR_BY_RATE_NUM_RF 4
  138. #define TX_PWR_BY_RATE_NUM_SECTION 12
  139. #define MAX_BASE_NUM_IN_PHY_REG_PG_24G 6
  140. #define MAX_BASE_NUM_IN_PHY_REG_PG_5G 5
  141. #define RTL8192EE_SEG_NUM 1 /* 0:2 seg, 1: 4 seg, 2: 8 seg */
  142. #define DEL_SW_IDX_SZ 30
  143. #define BAND_NUM 3
  144. enum rf_tx_num {
  145. RF_1TX = 0,
  146. RF_2TX,
  147. RF_MAX_TX_NUM,
  148. RF_TX_NUM_NONIMPLEMENT,
  149. };
  150. struct txpower_info_2g {
  151. u8 index_cck_base[MAX_RF_PATH][MAX_CHNL_GROUP_24G];
  152. u8 index_bw40_base[MAX_RF_PATH][MAX_CHNL_GROUP_24G];
  153. /*If only one tx, only BW20 and OFDM are used.*/
  154. u8 cck_diff[MAX_RF_PATH][MAX_TX_COUNT];
  155. u8 ofdm_diff[MAX_RF_PATH][MAX_TX_COUNT];
  156. u8 bw20_diff[MAX_RF_PATH][MAX_TX_COUNT];
  157. u8 bw40_diff[MAX_RF_PATH][MAX_TX_COUNT];
  158. u8 bw80_diff[MAX_RF_PATH][MAX_TX_COUNT];
  159. u8 bw160_diff[MAX_RF_PATH][MAX_TX_COUNT];
  160. };
  161. struct txpower_info_5g {
  162. u8 index_bw40_base[MAX_RF_PATH][MAX_CHNL_GROUP_5G];
  163. /*If only one tx, only BW20, OFDM, BW80 and BW160 are used.*/
  164. u8 ofdm_diff[MAX_RF_PATH][MAX_TX_COUNT];
  165. u8 bw20_diff[MAX_RF_PATH][MAX_TX_COUNT];
  166. u8 bw40_diff[MAX_RF_PATH][MAX_TX_COUNT];
  167. u8 bw80_diff[MAX_RF_PATH][MAX_TX_COUNT];
  168. u8 bw160_diff[MAX_RF_PATH][MAX_TX_COUNT];
  169. };
  170. enum rate_section {
  171. CCK = 0,
  172. OFDM,
  173. HT_MCS0_MCS7,
  174. HT_MCS8_MCS15,
  175. VHT_1SSMCS0_1SSMCS9,
  176. VHT_2SSMCS0_2SSMCS9,
  177. };
  178. enum intf_type {
  179. INTF_PCI = 0,
  180. INTF_USB = 1,
  181. };
  182. enum radio_path {
  183. RF90_PATH_A = 0,
  184. RF90_PATH_B = 1,
  185. RF90_PATH_C = 2,
  186. RF90_PATH_D = 3,
  187. };
  188. enum rt_eeprom_type {
  189. EEPROM_93C46,
  190. EEPROM_93C56,
  191. EEPROM_BOOT_EFUSE,
  192. };
  193. enum ttl_status {
  194. RTL_STATUS_INTERFACE_START = 0,
  195. };
  196. enum hardware_type {
  197. HARDWARE_TYPE_RTL8192E,
  198. HARDWARE_TYPE_RTL8192U,
  199. HARDWARE_TYPE_RTL8192SE,
  200. HARDWARE_TYPE_RTL8192SU,
  201. HARDWARE_TYPE_RTL8192CE,
  202. HARDWARE_TYPE_RTL8192CU,
  203. HARDWARE_TYPE_RTL8192DE,
  204. HARDWARE_TYPE_RTL8192DU,
  205. HARDWARE_TYPE_RTL8723AE,
  206. HARDWARE_TYPE_RTL8723U,
  207. HARDWARE_TYPE_RTL8723BE,
  208. HARDWARE_TYPE_RTL8188EE,
  209. HARDWARE_TYPE_RTL8821AE,
  210. HARDWARE_TYPE_RTL8812AE,
  211. /* keep it last */
  212. HARDWARE_TYPE_NUM
  213. };
  214. #define IS_HARDWARE_TYPE_8192SU(rtlhal) \
  215. (rtlhal->hw_type == HARDWARE_TYPE_RTL8192SU)
  216. #define IS_HARDWARE_TYPE_8192SE(rtlhal) \
  217. (rtlhal->hw_type == HARDWARE_TYPE_RTL8192SE)
  218. #define IS_HARDWARE_TYPE_8192CE(rtlhal) \
  219. (rtlhal->hw_type == HARDWARE_TYPE_RTL8192CE)
  220. #define IS_HARDWARE_TYPE_8192CU(rtlhal) \
  221. (rtlhal->hw_type == HARDWARE_TYPE_RTL8192CU)
  222. #define IS_HARDWARE_TYPE_8192DE(rtlhal) \
  223. (rtlhal->hw_type == HARDWARE_TYPE_RTL8192DE)
  224. #define IS_HARDWARE_TYPE_8192DU(rtlhal) \
  225. (rtlhal->hw_type == HARDWARE_TYPE_RTL8192DU)
  226. #define IS_HARDWARE_TYPE_8723E(rtlhal) \
  227. (rtlhal->hw_type == HARDWARE_TYPE_RTL8723E)
  228. #define IS_HARDWARE_TYPE_8723U(rtlhal) \
  229. (rtlhal->hw_type == HARDWARE_TYPE_RTL8723U)
  230. #define IS_HARDWARE_TYPE_8192S(rtlhal) \
  231. (IS_HARDWARE_TYPE_8192SE(rtlhal) || IS_HARDWARE_TYPE_8192SU(rtlhal))
  232. #define IS_HARDWARE_TYPE_8192C(rtlhal) \
  233. (IS_HARDWARE_TYPE_8192CE(rtlhal) || IS_HARDWARE_TYPE_8192CU(rtlhal))
  234. #define IS_HARDWARE_TYPE_8192D(rtlhal) \
  235. (IS_HARDWARE_TYPE_8192DE(rtlhal) || IS_HARDWARE_TYPE_8192DU(rtlhal))
  236. #define IS_HARDWARE_TYPE_8723(rtlhal) \
  237. (IS_HARDWARE_TYPE_8723E(rtlhal) || IS_HARDWARE_TYPE_8723U(rtlhal))
  238. #define RX_HAL_IS_CCK_RATE(_pdesc)\
  239. (_pdesc->rxmcs == DESC92_RATE1M || \
  240. _pdesc->rxmcs == DESC92_RATE2M || \
  241. _pdesc->rxmcs == DESC92_RATE5_5M || \
  242. _pdesc->rxmcs == DESC92_RATE11M)
  243. #define RTL8723E_RX_HAL_IS_CCK_RATE(rxmcs) \
  244. ((rxmcs) == DESC92_RATE1M || \
  245. (rxmcs) == DESC92_RATE2M || \
  246. (rxmcs) == DESC92_RATE5_5M || \
  247. (rxmcs) == DESC92_RATE11M)
  248. enum scan_operation_backup_opt {
  249. SCAN_OPT_BACKUP = 0,
  250. SCAN_OPT_BACKUP_BAND0 = 0,
  251. SCAN_OPT_BACKUP_BAND1,
  252. SCAN_OPT_RESTORE,
  253. SCAN_OPT_MAX
  254. };
  255. /*RF state.*/
  256. enum rf_pwrstate {
  257. ERFON,
  258. ERFSLEEP,
  259. ERFOFF
  260. };
  261. struct bb_reg_def {
  262. u32 rfintfs;
  263. u32 rfintfi;
  264. u32 rfintfo;
  265. u32 rfintfe;
  266. u32 rf3wire_offset;
  267. u32 rflssi_select;
  268. u32 rftxgain_stage;
  269. u32 rfhssi_para1;
  270. u32 rfhssi_para2;
  271. u32 rfsw_ctrl;
  272. u32 rfagc_control1;
  273. u32 rfagc_control2;
  274. u32 rfrxiq_imbal;
  275. u32 rfrx_afe;
  276. u32 rftxiq_imbal;
  277. u32 rftx_afe;
  278. u32 rf_rb; /* rflssi_readback */
  279. u32 rf_rbpi; /* rflssi_readbackpi */
  280. };
  281. enum io_type {
  282. IO_CMD_PAUSE_DM_BY_SCAN = 0,
  283. IO_CMD_PAUSE_BAND0_DM_BY_SCAN = 0,
  284. IO_CMD_PAUSE_BAND1_DM_BY_SCAN = 1,
  285. IO_CMD_RESUME_DM_BY_SCAN = 2,
  286. };
  287. enum hw_variables {
  288. HW_VAR_ETHER_ADDR,
  289. HW_VAR_MULTICAST_REG,
  290. HW_VAR_BASIC_RATE,
  291. HW_VAR_BSSID,
  292. HW_VAR_MEDIA_STATUS,
  293. HW_VAR_SECURITY_CONF,
  294. HW_VAR_BEACON_INTERVAL,
  295. HW_VAR_ATIM_WINDOW,
  296. HW_VAR_LISTEN_INTERVAL,
  297. HW_VAR_CS_COUNTER,
  298. HW_VAR_DEFAULTKEY0,
  299. HW_VAR_DEFAULTKEY1,
  300. HW_VAR_DEFAULTKEY2,
  301. HW_VAR_DEFAULTKEY3,
  302. HW_VAR_SIFS,
  303. HW_VAR_DIFS,
  304. HW_VAR_EIFS,
  305. HW_VAR_SLOT_TIME,
  306. HW_VAR_ACK_PREAMBLE,
  307. HW_VAR_CW_CONFIG,
  308. HW_VAR_CW_VALUES,
  309. HW_VAR_RATE_FALLBACK_CONTROL,
  310. HW_VAR_CONTENTION_WINDOW,
  311. HW_VAR_RETRY_COUNT,
  312. HW_VAR_TR_SWITCH,
  313. HW_VAR_COMMAND,
  314. HW_VAR_WPA_CONFIG,
  315. HW_VAR_AMPDU_MIN_SPACE,
  316. HW_VAR_SHORTGI_DENSITY,
  317. HW_VAR_AMPDU_FACTOR,
  318. HW_VAR_MCS_RATE_AVAILABLE,
  319. HW_VAR_AC_PARAM,
  320. HW_VAR_ACM_CTRL,
  321. HW_VAR_DIS_Req_Qsize,
  322. HW_VAR_CCX_CHNL_LOAD,
  323. HW_VAR_CCX_NOISE_HISTOGRAM,
  324. HW_VAR_CCX_CLM_NHM,
  325. HW_VAR_TxOPLimit,
  326. HW_VAR_TURBO_MODE,
  327. HW_VAR_RF_STATE,
  328. HW_VAR_RF_OFF_BY_HW,
  329. HW_VAR_BUS_SPEED,
  330. HW_VAR_SET_DEV_POWER,
  331. HW_VAR_RCR,
  332. HW_VAR_RATR_0,
  333. HW_VAR_RRSR,
  334. HW_VAR_CPU_RST,
  335. HW_VAR_CHECK_BSSID,
  336. HW_VAR_LBK_MODE,
  337. HW_VAR_AES_11N_FIX,
  338. HW_VAR_USB_RX_AGGR,
  339. HW_VAR_USER_CONTROL_TURBO_MODE,
  340. HW_VAR_RETRY_LIMIT,
  341. HW_VAR_INIT_TX_RATE,
  342. HW_VAR_TX_RATE_REG,
  343. HW_VAR_EFUSE_USAGE,
  344. HW_VAR_EFUSE_BYTES,
  345. HW_VAR_AUTOLOAD_STATUS,
  346. HW_VAR_RF_2R_DISABLE,
  347. HW_VAR_SET_RPWM,
  348. HW_VAR_H2C_FW_PWRMODE,
  349. HW_VAR_H2C_FW_JOINBSSRPT,
  350. HW_VAR_H2C_FW_MEDIASTATUSRPT,
  351. HW_VAR_H2C_FW_P2P_PS_OFFLOAD,
  352. HW_VAR_FW_PSMODE_STATUS,
  353. HW_VAR_RESUME_CLK_ON,
  354. HW_VAR_FW_LPS_ACTION,
  355. HW_VAR_1X1_RECV_COMBINE,
  356. HW_VAR_STOP_SEND_BEACON,
  357. HW_VAR_TSF_TIMER,
  358. HW_VAR_IO_CMD,
  359. HW_VAR_RF_RECOVERY,
  360. HW_VAR_H2C_FW_UPDATE_GTK,
  361. HW_VAR_WF_MASK,
  362. HW_VAR_WF_CRC,
  363. HW_VAR_WF_IS_MAC_ADDR,
  364. HW_VAR_H2C_FW_OFFLOAD,
  365. HW_VAR_RESET_WFCRC,
  366. HW_VAR_HANDLE_FW_C2H,
  367. HW_VAR_DL_FW_RSVD_PAGE,
  368. HW_VAR_AID,
  369. HW_VAR_HW_SEQ_ENABLE,
  370. HW_VAR_CORRECT_TSF,
  371. HW_VAR_BCN_VALID,
  372. HW_VAR_FWLPS_RF_ON,
  373. HW_VAR_DUAL_TSF_RST,
  374. HW_VAR_SWITCH_EPHY_WoWLAN,
  375. HW_VAR_INT_MIGRATION,
  376. HW_VAR_INT_AC,
  377. HW_VAR_RF_TIMING,
  378. HAL_DEF_WOWLAN,
  379. HW_VAR_MRC,
  380. HW_VAR_KEEP_ALIVE,
  381. HW_VAR_NAV_UPPER,
  382. HW_VAR_MGT_FILTER,
  383. HW_VAR_CTRL_FILTER,
  384. HW_VAR_DATA_FILTER,
  385. };
  386. enum _RT_MEDIA_STATUS {
  387. RT_MEDIA_DISCONNECT = 0,
  388. RT_MEDIA_CONNECT = 1
  389. };
  390. enum rt_oem_id {
  391. RT_CID_DEFAULT = 0,
  392. RT_CID_8187_ALPHA0 = 1,
  393. RT_CID_8187_SERCOMM_PS = 2,
  394. RT_CID_8187_HW_LED = 3,
  395. RT_CID_8187_NETGEAR = 4,
  396. RT_CID_WHQL = 5,
  397. RT_CID_819X_CAMEO = 6,
  398. RT_CID_819X_RUNTOP = 7,
  399. RT_CID_819X_SENAO = 8,
  400. RT_CID_TOSHIBA = 9,
  401. RT_CID_819X_NETCORE = 10,
  402. RT_CID_NETTRONIX = 11,
  403. RT_CID_DLINK = 12,
  404. RT_CID_PRONET = 13,
  405. RT_CID_COREGA = 14,
  406. RT_CID_819X_ALPHA = 15,
  407. RT_CID_819X_SITECOM = 16,
  408. RT_CID_CCX = 17,
  409. RT_CID_819X_LENOVO = 18,
  410. RT_CID_819X_QMI = 19,
  411. RT_CID_819X_EDIMAX_BELKIN = 20,
  412. RT_CID_819X_SERCOMM_BELKIN = 21,
  413. RT_CID_819X_CAMEO1 = 22,
  414. RT_CID_819X_MSI = 23,
  415. RT_CID_819X_ACER = 24,
  416. RT_CID_819X_HP = 27,
  417. RT_CID_819X_CLEVO = 28,
  418. RT_CID_819X_ARCADYAN_BELKIN = 29,
  419. RT_CID_819X_SAMSUNG = 30,
  420. RT_CID_819X_WNC_COREGA = 31,
  421. RT_CID_819X_FOXCOON = 32,
  422. RT_CID_819X_DELL = 33,
  423. RT_CID_819X_PRONETS = 34,
  424. RT_CID_819X_EDIMAX_ASUS = 35,
  425. RT_CID_NETGEAR = 36,
  426. RT_CID_PLANEX = 37,
  427. RT_CID_CC_C = 38,
  428. };
  429. enum hw_descs {
  430. HW_DESC_OWN,
  431. HW_DESC_RXOWN,
  432. HW_DESC_TX_NEXTDESC_ADDR,
  433. HW_DESC_TXBUFF_ADDR,
  434. HW_DESC_RXBUFF_ADDR,
  435. HW_DESC_RXPKT_LEN,
  436. HW_DESC_RXERO,
  437. HW_DESC_RX_PREPARE,
  438. };
  439. enum prime_sc {
  440. PRIME_CHNL_OFFSET_DONT_CARE = 0,
  441. PRIME_CHNL_OFFSET_LOWER = 1,
  442. PRIME_CHNL_OFFSET_UPPER = 2,
  443. };
  444. enum rf_type {
  445. RF_1T1R = 0,
  446. RF_1T2R = 1,
  447. RF_2T2R = 2,
  448. RF_2T2R_GREEN = 3,
  449. };
  450. enum ht_channel_width {
  451. HT_CHANNEL_WIDTH_20 = 0,
  452. HT_CHANNEL_WIDTH_20_40 = 1,
  453. HT_CHANNEL_WIDTH_80 = 2,
  454. };
  455. /* Ref: 802.11i sepc D10.0 7.3.2.25.1
  456. Cipher Suites Encryption Algorithms */
  457. enum rt_enc_alg {
  458. NO_ENCRYPTION = 0,
  459. WEP40_ENCRYPTION = 1,
  460. TKIP_ENCRYPTION = 2,
  461. RSERVED_ENCRYPTION = 3,
  462. AESCCMP_ENCRYPTION = 4,
  463. WEP104_ENCRYPTION = 5,
  464. AESCMAC_ENCRYPTION = 6, /*IEEE802.11w */
  465. };
  466. enum rtl_hal_state {
  467. _HAL_STATE_STOP = 0,
  468. _HAL_STATE_START = 1,
  469. };
  470. enum rtl_desc92_rate {
  471. DESC92_RATE1M = 0x00,
  472. DESC92_RATE2M = 0x01,
  473. DESC92_RATE5_5M = 0x02,
  474. DESC92_RATE11M = 0x03,
  475. DESC92_RATE6M = 0x04,
  476. DESC92_RATE9M = 0x05,
  477. DESC92_RATE12M = 0x06,
  478. DESC92_RATE18M = 0x07,
  479. DESC92_RATE24M = 0x08,
  480. DESC92_RATE36M = 0x09,
  481. DESC92_RATE48M = 0x0a,
  482. DESC92_RATE54M = 0x0b,
  483. DESC92_RATEMCS0 = 0x0c,
  484. DESC92_RATEMCS1 = 0x0d,
  485. DESC92_RATEMCS2 = 0x0e,
  486. DESC92_RATEMCS3 = 0x0f,
  487. DESC92_RATEMCS4 = 0x10,
  488. DESC92_RATEMCS5 = 0x11,
  489. DESC92_RATEMCS6 = 0x12,
  490. DESC92_RATEMCS7 = 0x13,
  491. DESC92_RATEMCS8 = 0x14,
  492. DESC92_RATEMCS9 = 0x15,
  493. DESC92_RATEMCS10 = 0x16,
  494. DESC92_RATEMCS11 = 0x17,
  495. DESC92_RATEMCS12 = 0x18,
  496. DESC92_RATEMCS13 = 0x19,
  497. DESC92_RATEMCS14 = 0x1a,
  498. DESC92_RATEMCS15 = 0x1b,
  499. DESC92_RATEMCS15_SG = 0x1c,
  500. DESC92_RATEMCS32 = 0x20,
  501. };
  502. enum rtl_var_map {
  503. /*reg map */
  504. SYS_ISO_CTRL = 0,
  505. SYS_FUNC_EN,
  506. SYS_CLK,
  507. MAC_RCR_AM,
  508. MAC_RCR_AB,
  509. MAC_RCR_ACRC32,
  510. MAC_RCR_ACF,
  511. MAC_RCR_AAP,
  512. MAC_HIMR,
  513. MAC_HIMRE,
  514. MAC_HSISR,
  515. /*efuse map */
  516. EFUSE_TEST,
  517. EFUSE_CTRL,
  518. EFUSE_CLK,
  519. EFUSE_CLK_CTRL,
  520. EFUSE_PWC_EV12V,
  521. EFUSE_FEN_ELDR,
  522. EFUSE_LOADER_CLK_EN,
  523. EFUSE_ANA8M,
  524. EFUSE_HWSET_MAX_SIZE,
  525. EFUSE_MAX_SECTION_MAP,
  526. EFUSE_REAL_CONTENT_SIZE,
  527. EFUSE_OOB_PROTECT_BYTES_LEN,
  528. EFUSE_ACCESS,
  529. /*CAM map */
  530. RWCAM,
  531. WCAMI,
  532. RCAMO,
  533. CAMDBG,
  534. SECR,
  535. SEC_CAM_NONE,
  536. SEC_CAM_WEP40,
  537. SEC_CAM_TKIP,
  538. SEC_CAM_AES,
  539. SEC_CAM_WEP104,
  540. /*IMR map */
  541. RTL_IMR_BCNDMAINT6, /*Beacon DMA Interrupt 6 */
  542. RTL_IMR_BCNDMAINT5, /*Beacon DMA Interrupt 5 */
  543. RTL_IMR_BCNDMAINT4, /*Beacon DMA Interrupt 4 */
  544. RTL_IMR_BCNDMAINT3, /*Beacon DMA Interrupt 3 */
  545. RTL_IMR_BCNDMAINT2, /*Beacon DMA Interrupt 2 */
  546. RTL_IMR_BCNDMAINT1, /*Beacon DMA Interrupt 1 */
  547. RTL_IMR_BCNDOK8, /*Beacon Queue DMA OK Interrup 8 */
  548. RTL_IMR_BCNDOK7, /*Beacon Queue DMA OK Interrup 7 */
  549. RTL_IMR_BCNDOK6, /*Beacon Queue DMA OK Interrup 6 */
  550. RTL_IMR_BCNDOK5, /*Beacon Queue DMA OK Interrup 5 */
  551. RTL_IMR_BCNDOK4, /*Beacon Queue DMA OK Interrup 4 */
  552. RTL_IMR_BCNDOK3, /*Beacon Queue DMA OK Interrup 3 */
  553. RTL_IMR_BCNDOK2, /*Beacon Queue DMA OK Interrup 2 */
  554. RTL_IMR_BCNDOK1, /*Beacon Queue DMA OK Interrup 1 */
  555. RTL_IMR_TIMEOUT2, /*Timeout interrupt 2 */
  556. RTL_IMR_TIMEOUT1, /*Timeout interrupt 1 */
  557. RTL_IMR_TXFOVW, /*Transmit FIFO Overflow */
  558. RTL_IMR_PSTIMEOUT, /*Power save time out interrupt */
  559. RTL_IMR_BCNINT, /*Beacon DMA Interrupt 0 */
  560. RTL_IMR_RXFOVW, /*Receive FIFO Overflow */
  561. RTL_IMR_RDU, /*Receive Descriptor Unavailable */
  562. RTL_IMR_ATIMEND, /*For 92C,ATIM Window End Interrupt */
  563. RTL_IMR_BDOK, /*Beacon Queue DMA OK Interrup */
  564. RTL_IMR_HIGHDOK, /*High Queue DMA OK Interrupt */
  565. RTL_IMR_COMDOK, /*Command Queue DMA OK Interrupt*/
  566. RTL_IMR_TBDOK, /*Transmit Beacon OK interrup */
  567. RTL_IMR_MGNTDOK, /*Management Queue DMA OK Interrupt */
  568. RTL_IMR_TBDER, /*For 92C,Transmit Beacon Error Interrupt */
  569. RTL_IMR_BKDOK, /*AC_BK DMA OK Interrupt */
  570. RTL_IMR_BEDOK, /*AC_BE DMA OK Interrupt */
  571. RTL_IMR_VIDOK, /*AC_VI DMA OK Interrupt */
  572. RTL_IMR_VODOK, /*AC_VO DMA Interrupt */
  573. RTL_IMR_ROK, /*Receive DMA OK Interrupt */
  574. RTL_IBSS_INT_MASKS, /*(RTL_IMR_BCNINT | RTL_IMR_TBDOK |
  575. * RTL_IMR_TBDER) */
  576. RTL_IMR_C2HCMD, /*fw interrupt*/
  577. /*CCK Rates, TxHT = 0 */
  578. RTL_RC_CCK_RATE1M,
  579. RTL_RC_CCK_RATE2M,
  580. RTL_RC_CCK_RATE5_5M,
  581. RTL_RC_CCK_RATE11M,
  582. /*OFDM Rates, TxHT = 0 */
  583. RTL_RC_OFDM_RATE6M,
  584. RTL_RC_OFDM_RATE9M,
  585. RTL_RC_OFDM_RATE12M,
  586. RTL_RC_OFDM_RATE18M,
  587. RTL_RC_OFDM_RATE24M,
  588. RTL_RC_OFDM_RATE36M,
  589. RTL_RC_OFDM_RATE48M,
  590. RTL_RC_OFDM_RATE54M,
  591. RTL_RC_HT_RATEMCS7,
  592. RTL_RC_HT_RATEMCS15,
  593. /*keep it last */
  594. RTL_VAR_MAP_MAX,
  595. };
  596. /*Firmware PS mode for control LPS.*/
  597. enum _fw_ps_mode {
  598. FW_PS_ACTIVE_MODE = 0,
  599. FW_PS_MIN_MODE = 1,
  600. FW_PS_MAX_MODE = 2,
  601. FW_PS_DTIM_MODE = 3,
  602. FW_PS_VOIP_MODE = 4,
  603. FW_PS_UAPSD_WMM_MODE = 5,
  604. FW_PS_UAPSD_MODE = 6,
  605. FW_PS_IBSS_MODE = 7,
  606. FW_PS_WWLAN_MODE = 8,
  607. FW_PS_PM_Radio_Off = 9,
  608. FW_PS_PM_Card_Disable = 10,
  609. };
  610. enum rt_psmode {
  611. EACTIVE, /*Active/Continuous access. */
  612. EMAXPS, /*Max power save mode. */
  613. EFASTPS, /*Fast power save mode. */
  614. EAUTOPS, /*Auto power save mode. */
  615. };
  616. /*LED related.*/
  617. enum led_ctl_mode {
  618. LED_CTL_POWER_ON = 1,
  619. LED_CTL_LINK = 2,
  620. LED_CTL_NO_LINK = 3,
  621. LED_CTL_TX = 4,
  622. LED_CTL_RX = 5,
  623. LED_CTL_SITE_SURVEY = 6,
  624. LED_CTL_POWER_OFF = 7,
  625. LED_CTL_START_TO_LINK = 8,
  626. LED_CTL_START_WPS = 9,
  627. LED_CTL_STOP_WPS = 10,
  628. };
  629. enum rtl_led_pin {
  630. LED_PIN_GPIO0,
  631. LED_PIN_LED0,
  632. LED_PIN_LED1,
  633. LED_PIN_LED2
  634. };
  635. /*QoS related.*/
  636. /*acm implementation method.*/
  637. enum acm_method {
  638. eAcmWay0_SwAndHw = 0,
  639. eAcmWay1_HW = 1,
  640. EACMWAY2_SW = 2,
  641. };
  642. enum macphy_mode {
  643. SINGLEMAC_SINGLEPHY = 0,
  644. DUALMAC_DUALPHY,
  645. DUALMAC_SINGLEPHY,
  646. };
  647. enum band_type {
  648. BAND_ON_2_4G = 0,
  649. BAND_ON_5G,
  650. BAND_ON_BOTH,
  651. BANDMAX
  652. };
  653. /*aci/aifsn Field.
  654. Ref: WMM spec 2.2.2: WME Parameter Element, p.12.*/
  655. union aci_aifsn {
  656. u8 char_data;
  657. struct {
  658. u8 aifsn:4;
  659. u8 acm:1;
  660. u8 aci:2;
  661. u8 reserved:1;
  662. } f; /* Field */
  663. };
  664. /*mlme related.*/
  665. enum wireless_mode {
  666. WIRELESS_MODE_UNKNOWN = 0x00,
  667. WIRELESS_MODE_A = 0x01,
  668. WIRELESS_MODE_B = 0x02,
  669. WIRELESS_MODE_G = 0x04,
  670. WIRELESS_MODE_AUTO = 0x08,
  671. WIRELESS_MODE_N_24G = 0x10,
  672. WIRELESS_MODE_N_5G = 0x20,
  673. WIRELESS_MODE_AC_5G = 0x40,
  674. WIRELESS_MODE_AC_24G = 0x80
  675. };
  676. #define IS_WIRELESS_MODE_A(wirelessmode) \
  677. (wirelessmode == WIRELESS_MODE_A)
  678. #define IS_WIRELESS_MODE_B(wirelessmode) \
  679. (wirelessmode == WIRELESS_MODE_B)
  680. #define IS_WIRELESS_MODE_G(wirelessmode) \
  681. (wirelessmode == WIRELESS_MODE_G)
  682. #define IS_WIRELESS_MODE_N_24G(wirelessmode) \
  683. (wirelessmode == WIRELESS_MODE_N_24G)
  684. #define IS_WIRELESS_MODE_N_5G(wirelessmode) \
  685. (wirelessmode == WIRELESS_MODE_N_5G)
  686. enum ratr_table_mode {
  687. RATR_INX_WIRELESS_NGB = 0,
  688. RATR_INX_WIRELESS_NG = 1,
  689. RATR_INX_WIRELESS_NB = 2,
  690. RATR_INX_WIRELESS_N = 3,
  691. RATR_INX_WIRELESS_GB = 4,
  692. RATR_INX_WIRELESS_G = 5,
  693. RATR_INX_WIRELESS_B = 6,
  694. RATR_INX_WIRELESS_MC = 7,
  695. RATR_INX_WIRELESS_A = 8,
  696. RATR_INX_WIRELESS_AC_5N = 8,
  697. RATR_INX_WIRELESS_AC_24N = 9,
  698. };
  699. enum rtl_link_state {
  700. MAC80211_NOLINK = 0,
  701. MAC80211_LINKING = 1,
  702. MAC80211_LINKED = 2,
  703. MAC80211_LINKED_SCANNING = 3,
  704. };
  705. enum act_category {
  706. ACT_CAT_QOS = 1,
  707. ACT_CAT_DLS = 2,
  708. ACT_CAT_BA = 3,
  709. ACT_CAT_HT = 7,
  710. ACT_CAT_WMM = 17,
  711. };
  712. enum ba_action {
  713. ACT_ADDBAREQ = 0,
  714. ACT_ADDBARSP = 1,
  715. ACT_DELBA = 2,
  716. };
  717. enum rt_polarity_ctl {
  718. RT_POLARITY_LOW_ACT = 0,
  719. RT_POLARITY_HIGH_ACT = 1,
  720. };
  721. struct octet_string {
  722. u8 *octet;
  723. u16 length;
  724. };
  725. struct rtl_hdr_3addr {
  726. __le16 frame_ctl;
  727. __le16 duration_id;
  728. u8 addr1[ETH_ALEN];
  729. u8 addr2[ETH_ALEN];
  730. u8 addr3[ETH_ALEN];
  731. __le16 seq_ctl;
  732. u8 payload[0];
  733. } __packed;
  734. struct rtl_info_element {
  735. u8 id;
  736. u8 len;
  737. u8 data[0];
  738. } __packed;
  739. struct rtl_probe_rsp {
  740. struct rtl_hdr_3addr header;
  741. u32 time_stamp[2];
  742. __le16 beacon_interval;
  743. __le16 capability;
  744. /*SSID, supported rates, FH params, DS params,
  745. CF params, IBSS params, TIM (if beacon), RSN */
  746. struct rtl_info_element info_element[0];
  747. } __packed;
  748. /*LED related.*/
  749. /*ledpin Identify how to implement this SW led.*/
  750. struct rtl_led {
  751. void *hw;
  752. enum rtl_led_pin ledpin;
  753. bool ledon;
  754. };
  755. struct rtl_led_ctl {
  756. bool led_opendrain;
  757. struct rtl_led sw_led0;
  758. struct rtl_led sw_led1;
  759. };
  760. struct rtl_qos_parameters {
  761. __le16 cw_min;
  762. __le16 cw_max;
  763. u8 aifs;
  764. u8 flag;
  765. __le16 tx_op;
  766. } __packed;
  767. struct rt_smooth_data {
  768. u32 elements[100]; /*array to store values */
  769. u32 index; /*index to current array to store */
  770. u32 total_num; /*num of valid elements */
  771. u32 total_val; /*sum of valid elements */
  772. };
  773. struct false_alarm_statistics {
  774. u32 cnt_parity_fail;
  775. u32 cnt_rate_illegal;
  776. u32 cnt_crc8_fail;
  777. u32 cnt_mcs_fail;
  778. u32 cnt_fast_fsync_fail;
  779. u32 cnt_sb_search_fail;
  780. u32 cnt_ofdm_fail;
  781. u32 cnt_cck_fail;
  782. u32 cnt_all;
  783. u32 cnt_ofdm_cca;
  784. u32 cnt_cck_cca;
  785. u32 cnt_cca_all;
  786. u32 cnt_bw_usc;
  787. u32 cnt_bw_lsc;
  788. };
  789. struct init_gain {
  790. u8 xaagccore1;
  791. u8 xbagccore1;
  792. u8 xcagccore1;
  793. u8 xdagccore1;
  794. u8 cca;
  795. };
  796. struct wireless_stats {
  797. unsigned long txbytesunicast;
  798. unsigned long txbytesmulticast;
  799. unsigned long txbytesbroadcast;
  800. unsigned long rxbytesunicast;
  801. long rx_snr_db[4];
  802. /*Correct smoothed ss in Dbm, only used
  803. in driver to report real power now. */
  804. long recv_signal_power;
  805. long signal_quality;
  806. long last_sigstrength_inpercent;
  807. u32 rssi_calculate_cnt;
  808. /*Transformed, in dbm. Beautified signal
  809. strength for UI, not correct. */
  810. long signal_strength;
  811. u8 rx_rssi_percentage[4];
  812. u8 rx_evm_dbm[4];
  813. u8 rx_evm_percentage[2];
  814. u16 rx_cfo_short[4];
  815. u16 rx_cfo_tail[4];
  816. struct rt_smooth_data ui_rssi;
  817. struct rt_smooth_data ui_link_quality;
  818. };
  819. struct rate_adaptive {
  820. u8 rate_adaptive_disabled;
  821. u8 ratr_state;
  822. u16 reserve;
  823. u32 high_rssi_thresh_for_ra;
  824. u32 high2low_rssi_thresh_for_ra;
  825. u8 low2high_rssi_thresh_for_ra40m;
  826. u32 low_rssi_thresh_for_ra40m;
  827. u8 low2high_rssi_thresh_for_ra20m;
  828. u32 low_rssi_thresh_for_ra20m;
  829. u32 upper_rssi_threshold_ratr;
  830. u32 middleupper_rssi_threshold_ratr;
  831. u32 middle_rssi_threshold_ratr;
  832. u32 middlelow_rssi_threshold_ratr;
  833. u32 low_rssi_threshold_ratr;
  834. u32 ultralow_rssi_threshold_ratr;
  835. u32 low_rssi_threshold_ratr_40m;
  836. u32 low_rssi_threshold_ratr_20m;
  837. u8 ping_rssi_enable;
  838. u32 ping_rssi_ratr;
  839. u32 ping_rssi_thresh_for_ra;
  840. u32 last_ratr;
  841. u8 pre_ratr_state;
  842. u8 ldpc_thres;
  843. bool use_ldpc;
  844. bool lower_rts_rate;
  845. bool is_special_data;
  846. };
  847. struct regd_pair_mapping {
  848. u16 reg_dmnenum;
  849. u16 reg_5ghz_ctl;
  850. u16 reg_2ghz_ctl;
  851. };
  852. struct dynamic_primary_cca {
  853. u8 pricca_flag;
  854. u8 intf_flag;
  855. u8 intf_type;
  856. u8 dup_rts_flag;
  857. u8 monitor_flag;
  858. u8 ch_offset;
  859. u8 mf_state;
  860. };
  861. struct rtl_regulatory {
  862. char alpha2[2];
  863. u16 country_code;
  864. u16 max_power_level;
  865. u32 tp_scale;
  866. u16 current_rd;
  867. u16 current_rd_ext;
  868. int16_t power_limit;
  869. struct regd_pair_mapping *regpair;
  870. };
  871. struct rtl_rfkill {
  872. bool rfkill_state; /*0 is off, 1 is on */
  873. };
  874. /*for P2P PS**/
  875. #define P2P_MAX_NOA_NUM 2
  876. enum p2p_role {
  877. P2P_ROLE_DISABLE = 0,
  878. P2P_ROLE_DEVICE = 1,
  879. P2P_ROLE_CLIENT = 2,
  880. P2P_ROLE_GO = 3
  881. };
  882. enum p2p_ps_state {
  883. P2P_PS_DISABLE = 0,
  884. P2P_PS_ENABLE = 1,
  885. P2P_PS_SCAN = 2,
  886. P2P_PS_SCAN_DONE = 3,
  887. P2P_PS_ALLSTASLEEP = 4, /* for P2P GO */
  888. };
  889. enum p2p_ps_mode {
  890. P2P_PS_NONE = 0,
  891. P2P_PS_CTWINDOW = 1,
  892. P2P_PS_NOA = 2,
  893. P2P_PS_MIX = 3, /* CTWindow and NoA */
  894. };
  895. struct rtl_p2p_ps_info {
  896. enum p2p_ps_mode p2p_ps_mode; /* indicate p2p ps mode */
  897. enum p2p_ps_state p2p_ps_state; /* indicate p2p ps state */
  898. u8 noa_index; /* Identifies instance of Notice of Absence timing. */
  899. /* Client traffic window. A period of time in TU after TBTT. */
  900. u8 ctwindow;
  901. u8 opp_ps; /* opportunistic power save. */
  902. u8 noa_num; /* number of NoA descriptor in P2P IE. */
  903. /* Count for owner, Type of client. */
  904. u8 noa_count_type[P2P_MAX_NOA_NUM];
  905. /* Max duration for owner, preferred or min acceptable duration
  906. * for client.
  907. */
  908. u32 noa_duration[P2P_MAX_NOA_NUM];
  909. /* Length of interval for owner, preferred or max acceptable intervali
  910. * of client.
  911. */
  912. u32 noa_interval[P2P_MAX_NOA_NUM];
  913. /* schedule in terms of the lower 4 bytes of the TSF timer. */
  914. u32 noa_start_time[P2P_MAX_NOA_NUM];
  915. };
  916. struct p2p_ps_offload_t {
  917. u8 offload_en:1;
  918. u8 role:1; /* 1: Owner, 0: Client */
  919. u8 ctwindow_en:1;
  920. u8 noa0_en:1;
  921. u8 noa1_en:1;
  922. u8 allstasleep:1;
  923. u8 discovery:1;
  924. u8 reserved:1;
  925. };
  926. #define IQK_MATRIX_REG_NUM 8
  927. #define IQK_MATRIX_SETTINGS_NUM (1 + 24 + 21)
  928. struct iqk_matrix_regs {
  929. bool iqk_done;
  930. long value[1][IQK_MATRIX_REG_NUM];
  931. };
  932. struct phy_parameters {
  933. u16 length;
  934. u32 *pdata;
  935. };
  936. enum hw_param_tab_index {
  937. PHY_REG_2T,
  938. PHY_REG_1T,
  939. PHY_REG_PG,
  940. RADIOA_2T,
  941. RADIOB_2T,
  942. RADIOA_1T,
  943. RADIOB_1T,
  944. MAC_REG,
  945. AGCTAB_2T,
  946. AGCTAB_1T,
  947. MAX_TAB
  948. };
  949. struct rtl_phy {
  950. struct bb_reg_def phyreg_def[4]; /*Radio A/B/C/D */
  951. struct init_gain initgain_backup;
  952. enum io_type current_io_type;
  953. u8 rf_mode;
  954. u8 rf_type;
  955. u8 current_chan_bw;
  956. u8 set_bwmode_inprogress;
  957. u8 sw_chnl_inprogress;
  958. u8 sw_chnl_stage;
  959. u8 sw_chnl_step;
  960. u8 current_channel;
  961. u8 h2c_box_num;
  962. u8 set_io_inprogress;
  963. u8 lck_inprogress;
  964. /* record for power tracking */
  965. s32 reg_e94;
  966. s32 reg_e9c;
  967. s32 reg_ea4;
  968. s32 reg_eac;
  969. s32 reg_eb4;
  970. s32 reg_ebc;
  971. s32 reg_ec4;
  972. s32 reg_ecc;
  973. u8 rfpienable;
  974. u8 reserve_0;
  975. u16 reserve_1;
  976. u32 reg_c04, reg_c08, reg_874;
  977. u32 adda_backup[16];
  978. u32 iqk_mac_backup[IQK_MAC_REG_NUM];
  979. u32 iqk_bb_backup[10];
  980. bool iqk_initialized;
  981. bool rfpath_rx_enable[MAX_RF_PATH];
  982. u8 reg_837;
  983. /* Dual mac */
  984. bool need_iqk;
  985. struct iqk_matrix_regs iqk_matrix[IQK_MATRIX_SETTINGS_NUM];
  986. bool rfpi_enable;
  987. bool iqk_in_progress;
  988. u8 pwrgroup_cnt;
  989. u8 cck_high_power;
  990. /* MAX_PG_GROUP groups of pwr diff by rates */
  991. u32 mcs_offset[MAX_PG_GROUP][16];
  992. u32 tx_power_by_rate_offset[TX_PWR_BY_RATE_NUM_BAND]
  993. [TX_PWR_BY_RATE_NUM_RF]
  994. [TX_PWR_BY_RATE_NUM_RF]
  995. [TX_PWR_BY_RATE_NUM_SECTION];
  996. u8 txpwr_by_rate_base_24g[TX_PWR_BY_RATE_NUM_RF]
  997. [TX_PWR_BY_RATE_NUM_RF]
  998. [MAX_BASE_NUM_IN_PHY_REG_PG_24G];
  999. u8 txpwr_by_rate_base_5g[TX_PWR_BY_RATE_NUM_RF]
  1000. [TX_PWR_BY_RATE_NUM_RF]
  1001. [MAX_BASE_NUM_IN_PHY_REG_PG_5G];
  1002. u8 default_initialgain[4];
  1003. /* the current Tx power level */
  1004. u8 cur_cck_txpwridx;
  1005. u8 cur_ofdm24g_txpwridx;
  1006. u8 cur_bw20_txpwridx;
  1007. u8 cur_bw40_txpwridx;
  1008. u32 rfreg_chnlval[2];
  1009. bool apk_done;
  1010. u32 reg_rf3c[2]; /* pathA / pathB */
  1011. u32 backup_rf_0x1a;/*92ee*/
  1012. /* bfsync */
  1013. u8 framesync;
  1014. u32 framesync_c34;
  1015. u8 num_total_rfpath;
  1016. struct phy_parameters hwparam_tables[MAX_TAB];
  1017. u16 rf_pathmap;
  1018. u8 hw_rof_enable; /*Enable GPIO[9] as WL RF HW PDn source*/
  1019. enum rt_polarity_ctl polarity_ctl;
  1020. };
  1021. #define MAX_TID_COUNT 9
  1022. #define RTL_AGG_STOP 0
  1023. #define RTL_AGG_PROGRESS 1
  1024. #define RTL_AGG_START 2
  1025. #define RTL_AGG_OPERATIONAL 3
  1026. #define RTL_AGG_OFF 0
  1027. #define RTL_AGG_ON 1
  1028. #define RTL_RX_AGG_START 1
  1029. #define RTL_RX_AGG_STOP 0
  1030. #define RTL_AGG_EMPTYING_HW_QUEUE_ADDBA 2
  1031. #define RTL_AGG_EMPTYING_HW_QUEUE_DELBA 3
  1032. struct rtl_ht_agg {
  1033. u16 txq_id;
  1034. u16 wait_for_ba;
  1035. u16 start_idx;
  1036. u64 bitmap;
  1037. u32 rate_n_flags;
  1038. u8 agg_state;
  1039. u8 rx_agg_state;
  1040. };
  1041. struct rssi_sta {
  1042. long undec_sm_pwdb;
  1043. long undec_sm_cck;
  1044. };
  1045. struct rtl_tid_data {
  1046. u16 seq_number;
  1047. struct rtl_ht_agg agg;
  1048. };
  1049. struct rtl_sta_info {
  1050. struct list_head list;
  1051. u8 ratr_index;
  1052. u8 wireless_mode;
  1053. u8 mimo_ps;
  1054. u8 mac_addr[ETH_ALEN];
  1055. struct rtl_tid_data tids[MAX_TID_COUNT];
  1056. /* just used for ap adhoc or mesh*/
  1057. struct rssi_sta rssi_stat;
  1058. } __packed;
  1059. struct rtl_priv;
  1060. struct rtl_io {
  1061. struct device *dev;
  1062. struct mutex bb_mutex;
  1063. /*PCI MEM map */
  1064. unsigned long pci_mem_end; /*shared mem end */
  1065. unsigned long pci_mem_start; /*shared mem start */
  1066. /*PCI IO map */
  1067. unsigned long pci_base_addr; /*device I/O address */
  1068. void (*write8_async) (struct rtl_priv *rtlpriv, u32 addr, u8 val);
  1069. void (*write16_async) (struct rtl_priv *rtlpriv, u32 addr, u16 val);
  1070. void (*write32_async) (struct rtl_priv *rtlpriv, u32 addr, u32 val);
  1071. void (*writeN_sync) (struct rtl_priv *rtlpriv, u32 addr, void *buf,
  1072. u16 len);
  1073. u8(*read8_sync) (struct rtl_priv *rtlpriv, u32 addr);
  1074. u16(*read16_sync) (struct rtl_priv *rtlpriv, u32 addr);
  1075. u32(*read32_sync) (struct rtl_priv *rtlpriv, u32 addr);
  1076. };
  1077. struct rtl_mac {
  1078. u8 mac_addr[ETH_ALEN];
  1079. u8 mac80211_registered;
  1080. u8 beacon_enabled;
  1081. u32 tx_ss_num;
  1082. u32 rx_ss_num;
  1083. struct ieee80211_supported_band bands[IEEE80211_NUM_BANDS];
  1084. struct ieee80211_hw *hw;
  1085. struct ieee80211_vif *vif;
  1086. enum nl80211_iftype opmode;
  1087. /*Probe Beacon management */
  1088. struct rtl_tid_data tids[MAX_TID_COUNT];
  1089. enum rtl_link_state link_state;
  1090. int n_channels;
  1091. int n_bitrates;
  1092. bool offchan_delay;
  1093. u8 p2p; /*using p2p role*/
  1094. bool p2p_in_use;
  1095. /*filters */
  1096. u32 rx_conf;
  1097. u16 rx_mgt_filter;
  1098. u16 rx_ctrl_filter;
  1099. u16 rx_data_filter;
  1100. bool act_scanning;
  1101. u8 cnt_after_linked;
  1102. bool skip_scan;
  1103. /* early mode */
  1104. /* skb wait queue */
  1105. struct sk_buff_head skb_waitq[MAX_TID_COUNT];
  1106. /*RDG*/
  1107. bool rdg_en;
  1108. /*AP*/
  1109. u8 bssid[6];
  1110. u32 vendor;
  1111. u8 mcs[16]; /* 16 bytes mcs for HT rates. */
  1112. u32 basic_rates; /* b/g rates */
  1113. u8 ht_enable;
  1114. u8 sgi_40;
  1115. u8 sgi_20;
  1116. u8 bw_40;
  1117. u8 mode; /* wireless mode */
  1118. u8 slot_time;
  1119. u8 short_preamble;
  1120. u8 use_cts_protect;
  1121. u8 cur_40_prime_sc;
  1122. u8 cur_40_prime_sc_bk;
  1123. u8 cur_80_prime_sc;
  1124. u64 tsf;
  1125. u8 retry_short;
  1126. u8 retry_long;
  1127. u16 assoc_id;
  1128. bool hiddenssid;
  1129. /*IBSS*/
  1130. int beacon_interval;
  1131. /*AMPDU*/
  1132. u8 min_space_cfg; /*For Min spacing configurations */
  1133. u8 max_mss_density;
  1134. u8 current_ampdu_factor;
  1135. u8 current_ampdu_density;
  1136. /*QOS & EDCA */
  1137. struct ieee80211_tx_queue_params edca_param[RTL_MAC80211_NUM_QUEUE];
  1138. struct rtl_qos_parameters ac[AC_MAX];
  1139. /* counters */
  1140. u64 last_txok_cnt;
  1141. u64 last_rxok_cnt;
  1142. u32 last_bt_edca_ul;
  1143. u32 last_bt_edca_dl;
  1144. };
  1145. struct btdm_8723 {
  1146. bool all_off;
  1147. bool agc_table_en;
  1148. bool adc_back_off_on;
  1149. bool b2_ant_hid_en;
  1150. bool low_penalty_rate_adaptive;
  1151. bool rf_rx_lpf_shrink;
  1152. bool reject_aggre_pkt;
  1153. bool tra_tdma_on;
  1154. u8 tra_tdma_nav;
  1155. u8 tra_tdma_ant;
  1156. bool tdma_on;
  1157. u8 tdma_ant;
  1158. u8 tdma_nav;
  1159. u8 tdma_dac_swing;
  1160. u8 fw_dac_swing_lvl;
  1161. bool ps_tdma_on;
  1162. u8 ps_tdma_byte[5];
  1163. bool pta_on;
  1164. u32 val_0x6c0;
  1165. u32 val_0x6c8;
  1166. u32 val_0x6cc;
  1167. bool sw_dac_swing_on;
  1168. u32 sw_dac_swing_lvl;
  1169. u32 wlan_act_hi;
  1170. u32 wlan_act_lo;
  1171. u32 bt_retry_index;
  1172. bool dec_bt_pwr;
  1173. bool ignore_wlan_act;
  1174. };
  1175. struct bt_coexist_8723 {
  1176. u32 high_priority_tx;
  1177. u32 high_priority_rx;
  1178. u32 low_priority_tx;
  1179. u32 low_priority_rx;
  1180. u8 c2h_bt_info;
  1181. bool c2h_bt_info_req_sent;
  1182. bool c2h_bt_inquiry_page;
  1183. u32 bt_inq_page_start_time;
  1184. u8 bt_retry_cnt;
  1185. u8 c2h_bt_info_original;
  1186. u8 bt_inquiry_page_cnt;
  1187. struct btdm_8723 btdm;
  1188. };
  1189. struct rtl_hal {
  1190. struct ieee80211_hw *hw;
  1191. bool driver_is_goingto_unload;
  1192. bool up_first_time;
  1193. bool first_init;
  1194. bool being_init_adapter;
  1195. bool bbrf_ready;
  1196. bool mac_func_enable;
  1197. bool pre_edcca_enable;
  1198. struct bt_coexist_8723 hal_coex_8723;
  1199. enum intf_type interface;
  1200. u16 hw_type; /*92c or 92d or 92s and so on */
  1201. u8 ic_class;
  1202. u8 oem_id;
  1203. u32 version; /*version of chip */
  1204. u8 state; /*stop 0, start 1 */
  1205. u8 board_type;
  1206. /*firmware */
  1207. u32 fwsize;
  1208. u8 *pfirmware;
  1209. u16 fw_version;
  1210. u16 fw_subversion;
  1211. bool h2c_setinprogress;
  1212. u8 last_hmeboxnum;
  1213. bool fw_ready;
  1214. /*Reserve page start offset except beacon in TxQ. */
  1215. u8 fw_rsvdpage_startoffset;
  1216. u8 h2c_txcmd_seq;
  1217. u8 current_ra_rate;
  1218. /* FW Cmd IO related */
  1219. u16 fwcmd_iomap;
  1220. u32 fwcmd_ioparam;
  1221. bool set_fwcmd_inprogress;
  1222. u8 current_fwcmd_io;
  1223. struct p2p_ps_offload_t p2p_ps_offload;
  1224. bool fw_clk_change_in_progress;
  1225. bool allow_sw_to_change_hwclc;
  1226. u8 fw_ps_state;
  1227. /**/
  1228. bool driver_going2unload;
  1229. /*AMPDU init min space*/
  1230. u8 minspace_cfg; /*For Min spacing configurations */
  1231. /* Dual mac */
  1232. enum macphy_mode macphymode;
  1233. enum band_type current_bandtype; /* 0:2.4G, 1:5G */
  1234. enum band_type current_bandtypebackup;
  1235. enum band_type bandset;
  1236. /* dual MAC 0--Mac0 1--Mac1 */
  1237. u32 interfaceindex;
  1238. /* just for DualMac S3S4 */
  1239. u8 macphyctl_reg;
  1240. bool earlymode_enable;
  1241. u8 max_earlymode_num;
  1242. /* Dual mac*/
  1243. bool during_mac0init_radiob;
  1244. bool during_mac1init_radioa;
  1245. bool reloadtxpowerindex;
  1246. /* True if IMR or IQK have done
  1247. for 2.4G in scan progress */
  1248. bool load_imrandiqk_setting_for2g;
  1249. bool disable_amsdu_8k;
  1250. bool master_of_dmsp;
  1251. bool slave_of_dmsp;
  1252. u16 rx_tag;/*for 92ee*/
  1253. u8 rts_en;
  1254. };
  1255. struct rtl_security {
  1256. /*default 0 */
  1257. bool use_sw_sec;
  1258. bool being_setkey;
  1259. bool use_defaultkey;
  1260. /*Encryption Algorithm for Unicast Packet */
  1261. enum rt_enc_alg pairwise_enc_algorithm;
  1262. /*Encryption Algorithm for Brocast/Multicast */
  1263. enum rt_enc_alg group_enc_algorithm;
  1264. /*Cam Entry Bitmap */
  1265. u32 hwsec_cam_bitmap;
  1266. u8 hwsec_cam_sta_addr[TOTAL_CAM_ENTRY][ETH_ALEN];
  1267. /*local Key buffer, indx 0 is for
  1268. pairwise key 1-4 is for agoup key. */
  1269. u8 key_buf[KEY_BUF_SIZE][MAX_KEY_LEN];
  1270. u8 key_len[KEY_BUF_SIZE];
  1271. /*The pointer of Pairwise Key,
  1272. it always points to KeyBuf[4] */
  1273. u8 *pairwise_key;
  1274. };
  1275. #define ASSOCIATE_ENTRY_NUM 33
  1276. struct fast_ant_training {
  1277. u8 bssid[6];
  1278. u8 antsel_rx_keep_0;
  1279. u8 antsel_rx_keep_1;
  1280. u8 antsel_rx_keep_2;
  1281. u32 ant_sum[7];
  1282. u32 ant_cnt[7];
  1283. u32 ant_ave[7];
  1284. u8 fat_state;
  1285. u32 train_idx;
  1286. u8 antsel_a[ASSOCIATE_ENTRY_NUM];
  1287. u8 antsel_b[ASSOCIATE_ENTRY_NUM];
  1288. u8 antsel_c[ASSOCIATE_ENTRY_NUM];
  1289. u32 main_ant_sum[ASSOCIATE_ENTRY_NUM];
  1290. u32 aux_ant_sum[ASSOCIATE_ENTRY_NUM];
  1291. u32 main_ant_cnt[ASSOCIATE_ENTRY_NUM];
  1292. u32 aux_ant_cnt[ASSOCIATE_ENTRY_NUM];
  1293. u8 rx_idle_ant;
  1294. bool becomelinked;
  1295. };
  1296. struct dm_phy_dbg_info {
  1297. char rx_snrdb[4];
  1298. u64 num_qry_phy_status;
  1299. u64 num_qry_phy_status_cck;
  1300. u64 num_qry_phy_status_ofdm;
  1301. u16 num_qry_beacon_pkt;
  1302. u16 num_non_be_pkt;
  1303. s32 rx_evm[4];
  1304. };
  1305. struct rtl_dm {
  1306. /*PHY status for Dynamic Management */
  1307. long entry_min_undec_sm_pwdb;
  1308. long undec_sm_cck;
  1309. long undec_sm_pwdb; /*out dm */
  1310. long entry_max_undec_sm_pwdb;
  1311. s32 ofdm_pkt_cnt;
  1312. bool dm_initialgain_enable;
  1313. bool dynamic_txpower_enable;
  1314. bool current_turbo_edca;
  1315. bool is_any_nonbepkts; /*out dm */
  1316. bool is_cur_rdlstate;
  1317. bool txpower_trackinginit;
  1318. bool disable_framebursting;
  1319. bool cck_inch14;
  1320. bool txpower_tracking;
  1321. bool useramask;
  1322. bool rfpath_rxenable[4];
  1323. bool inform_fw_driverctrldm;
  1324. bool current_mrc_switch;
  1325. u8 txpowercount;
  1326. u8 powerindex_backup[6];
  1327. u8 thermalvalue_rxgain;
  1328. u8 thermalvalue_iqk;
  1329. u8 thermalvalue_lck;
  1330. u8 thermalvalue;
  1331. u8 last_dtp_lvl;
  1332. u8 thermalvalue_avg[AVG_THERMAL_NUM];
  1333. u8 thermalvalue_avg_index;
  1334. bool done_txpower;
  1335. u8 dynamic_txhighpower_lvl; /*Tx high power level */
  1336. u8 dm_flag; /*Indicate each dynamic mechanism's status. */
  1337. u8 dm_flag_tmp;
  1338. u8 dm_type;
  1339. u8 dm_rssi_sel;
  1340. u8 txpower_track_control;
  1341. bool interrupt_migration;
  1342. bool disable_tx_int;
  1343. char ofdm_index[MAX_RF_PATH];
  1344. u8 default_ofdm_index;
  1345. u8 default_cck_index;
  1346. char cck_index;
  1347. char delta_power_index[MAX_RF_PATH];
  1348. char delta_power_index_last[MAX_RF_PATH];
  1349. char power_index_offset[MAX_RF_PATH];
  1350. char absolute_ofdm_swing_idx[MAX_RF_PATH];
  1351. char remnant_ofdm_swing_idx[MAX_RF_PATH];
  1352. char remnant_cck_idx;
  1353. bool modify_txagc_flag_path_a;
  1354. bool modify_txagc_flag_path_b;
  1355. bool one_entry_only;
  1356. struct dm_phy_dbg_info dbginfo;
  1357. /* Dynamic ATC switch */
  1358. bool atc_status;
  1359. bool large_cfo_hit;
  1360. bool is_freeze;
  1361. int cfo_tail[2];
  1362. int cfo_ave_pre;
  1363. int crystal_cap;
  1364. u8 cfo_threshold;
  1365. u32 packet_count;
  1366. u32 packet_count_pre;
  1367. u8 tx_rate;
  1368. /*88e tx power tracking*/
  1369. u8 swing_idx_ofdm[MAX_RF_PATH];
  1370. u8 swing_idx_ofdm_cur;
  1371. u8 swing_idx_ofdm_base[MAX_RF_PATH];
  1372. bool swing_flag_ofdm;
  1373. u8 swing_idx_cck;
  1374. u8 swing_idx_cck_cur;
  1375. u8 swing_idx_cck_base;
  1376. bool swing_flag_cck;
  1377. char swing_diff_2g;
  1378. char swing_diff_5g;
  1379. u8 delta_swing_table_idx_24gccka_p[DEL_SW_IDX_SZ];
  1380. u8 delta_swing_table_idx_24gccka_n[DEL_SW_IDX_SZ];
  1381. u8 delta_swing_table_idx_24gcckb_p[DEL_SW_IDX_SZ];
  1382. u8 delta_swing_table_idx_24gcckb_n[DEL_SW_IDX_SZ];
  1383. u8 delta_swing_table_idx_24ga_p[DEL_SW_IDX_SZ];
  1384. u8 delta_swing_table_idx_24ga_n[DEL_SW_IDX_SZ];
  1385. u8 delta_swing_table_idx_24gb_p[DEL_SW_IDX_SZ];
  1386. u8 delta_swing_table_idx_24gb_n[DEL_SW_IDX_SZ];
  1387. u8 delta_swing_table_idx_5ga_p[BAND_NUM][DEL_SW_IDX_SZ];
  1388. u8 delta_swing_table_idx_5ga_n[BAND_NUM][DEL_SW_IDX_SZ];
  1389. u8 delta_swing_table_idx_5gb_p[BAND_NUM][DEL_SW_IDX_SZ];
  1390. u8 delta_swing_table_idx_5gb_n[BAND_NUM][DEL_SW_IDX_SZ];
  1391. u8 delta_swing_table_idx_24ga_p_8188e[DEL_SW_IDX_SZ];
  1392. u8 delta_swing_table_idx_24ga_n_8188e[DEL_SW_IDX_SZ];
  1393. /* DMSP */
  1394. bool supp_phymode_switch;
  1395. /* DulMac */
  1396. struct fast_ant_training fat_table;
  1397. u8 resp_tx_path;
  1398. u8 path_sel;
  1399. u32 patha_sum;
  1400. u32 pathb_sum;
  1401. u32 patha_cnt;
  1402. u32 pathb_cnt;
  1403. u8 pre_channel;
  1404. u8 *p_channel;
  1405. u8 linked_interval;
  1406. u64 last_tx_ok_cnt;
  1407. u64 last_rx_ok_cnt;
  1408. };
  1409. #define EFUSE_MAX_LOGICAL_SIZE 512
  1410. struct rtl_efuse {
  1411. bool autoLoad_ok;
  1412. bool bootfromefuse;
  1413. u16 max_physical_size;
  1414. u8 efuse_map[2][EFUSE_MAX_LOGICAL_SIZE];
  1415. u16 efuse_usedbytes;
  1416. u8 efuse_usedpercentage;
  1417. #ifdef EFUSE_REPG_WORKAROUND
  1418. bool efuse_re_pg_sec1flag;
  1419. u8 efuse_re_pg_data[8];
  1420. #endif
  1421. u8 autoload_failflag;
  1422. u8 autoload_status;
  1423. short epromtype;
  1424. u16 eeprom_vid;
  1425. u16 eeprom_did;
  1426. u16 eeprom_svid;
  1427. u16 eeprom_smid;
  1428. u8 eeprom_oemid;
  1429. u16 eeprom_channelplan;
  1430. u8 eeprom_version;
  1431. u8 board_type;
  1432. u8 external_pa;
  1433. u8 dev_addr[6];
  1434. u8 wowlan_enable;
  1435. u8 antenna_div_cfg;
  1436. u8 antenna_div_type;
  1437. bool txpwr_fromeprom;
  1438. u8 eeprom_crystalcap;
  1439. u8 eeprom_tssi[2];
  1440. u8 eeprom_tssi_5g[3][2]; /* for 5GL/5GM/5GH band. */
  1441. u8 eeprom_pwrlimit_ht20[CHANNEL_GROUP_MAX];
  1442. u8 eeprom_pwrlimit_ht40[CHANNEL_GROUP_MAX];
  1443. u8 eeprom_chnlarea_txpwr_cck[MAX_RF_PATH][CHANNEL_GROUP_MAX_2G];
  1444. u8 eeprom_chnlarea_txpwr_ht40_1s[MAX_RF_PATH][CHANNEL_GROUP_MAX];
  1445. u8 eprom_chnl_txpwr_ht40_2sdf[MAX_RF_PATH][CHANNEL_GROUP_MAX];
  1446. u8 internal_pa_5g[2]; /* pathA / pathB */
  1447. u8 eeprom_c9;
  1448. u8 eeprom_cc;
  1449. /*For power group */
  1450. u8 eeprom_pwrgroup[2][3];
  1451. u8 pwrgroup_ht20[2][CHANNEL_MAX_NUMBER];
  1452. u8 pwrgroup_ht40[2][CHANNEL_MAX_NUMBER];
  1453. u8 txpwrlevel_cck[MAX_RF_PATH][CHANNEL_MAX_NUMBER_2G];
  1454. /*For HT 40MHZ pwr */
  1455. u8 txpwrlevel_ht40_1s[MAX_RF_PATH][CHANNEL_MAX_NUMBER];
  1456. /*For HT 40MHZ pwr */
  1457. u8 txpwrlevel_ht40_2s[MAX_RF_PATH][CHANNEL_MAX_NUMBER];
  1458. /*--------------------------------------------------------*
  1459. * 8192CE\8192SE\8192DE\8723AE use the following 4 arrays,
  1460. * other ICs (8188EE\8723BE\8192EE\8812AE...)
  1461. * define new arrays in Windows code.
  1462. * BUT, in linux code, we use the same array for all ICs.
  1463. *
  1464. * The Correspondance relation between two arrays is:
  1465. * txpwr_cckdiff[][] == CCK_24G_Diff[][]
  1466. * txpwr_ht20diff[][] == BW20_24G_Diff[][]
  1467. * txpwr_ht40diff[][] == BW40_24G_Diff[][]
  1468. * txpwr_legacyhtdiff[][] == OFDM_24G_Diff[][]
  1469. *
  1470. * Sizes of these arrays are decided by the larger ones.
  1471. */
  1472. char txpwr_cckdiff[MAX_RF_PATH][CHANNEL_MAX_NUMBER];
  1473. char txpwr_ht20diff[MAX_RF_PATH][CHANNEL_MAX_NUMBER];
  1474. char txpwr_ht40diff[MAX_RF_PATH][CHANNEL_MAX_NUMBER];
  1475. char txpwr_legacyhtdiff[MAX_RF_PATH][CHANNEL_MAX_NUMBER];
  1476. u8 txpwr_5g_bw40base[MAX_RF_PATH][CHANNEL_MAX_NUMBER];
  1477. u8 txpwr_5g_bw80base[MAX_RF_PATH][CHANNEL_MAX_NUMBER_5G_80M];
  1478. char txpwr_5g_ofdmdiff[MAX_RF_PATH][MAX_TX_COUNT];
  1479. char txpwr_5g_bw20diff[MAX_RF_PATH][MAX_TX_COUNT];
  1480. char txpwr_5g_bw40diff[MAX_RF_PATH][MAX_TX_COUNT];
  1481. char txpwr_5g_bw80diff[MAX_RF_PATH][MAX_TX_COUNT];
  1482. u8 txpwr_safetyflag; /* Band edge enable flag */
  1483. u16 eeprom_txpowerdiff;
  1484. u8 legacy_httxpowerdiff; /* Legacy to HT rate power diff */
  1485. u8 antenna_txpwdiff[3];
  1486. u8 eeprom_regulatory;
  1487. u8 eeprom_thermalmeter;
  1488. u8 thermalmeter[2]; /*ThermalMeter, index 0 for RFIC0, 1 for RFIC1 */
  1489. u16 tssi_13dbm;
  1490. u8 crystalcap; /* CrystalCap. */
  1491. u8 delta_iqk;
  1492. u8 delta_lck;
  1493. u8 legacy_ht_txpowerdiff; /*Legacy to HT rate power diff */
  1494. bool apk_thermalmeterignore;
  1495. bool b1x1_recvcombine;
  1496. bool b1ss_support;
  1497. /*channel plan */
  1498. u8 channel_plan;
  1499. };
  1500. struct rtl_ps_ctl {
  1501. bool pwrdomain_protect;
  1502. bool in_powersavemode;
  1503. bool rfchange_inprogress;
  1504. bool swrf_processing;
  1505. bool hwradiooff;
  1506. /*
  1507. * just for PCIE ASPM
  1508. * If it supports ASPM, Offset[560h] = 0x40,
  1509. * otherwise Offset[560h] = 0x00.
  1510. * */
  1511. bool support_aspm;
  1512. bool support_backdoor;
  1513. /*for LPS */
  1514. enum rt_psmode dot11_psmode; /*Power save mode configured. */
  1515. bool swctrl_lps;
  1516. bool leisure_ps;
  1517. bool fwctrl_lps;
  1518. u8 fwctrl_psmode;
  1519. /*For Fw control LPS mode */
  1520. u8 reg_fwctrl_lps;
  1521. /*Record Fw PS mode status. */
  1522. bool fw_current_inpsmode;
  1523. u8 reg_max_lps_awakeintvl;
  1524. bool report_linked;
  1525. bool low_power_enable;/*for 32k*/
  1526. /*for IPS */
  1527. bool inactiveps;
  1528. u32 rfoff_reason;
  1529. /*RF OFF Level */
  1530. u32 cur_ps_level;
  1531. u32 reg_rfps_level;
  1532. /*just for PCIE ASPM */
  1533. u8 const_amdpci_aspm;
  1534. bool pwrdown_mode;
  1535. enum rf_pwrstate inactive_pwrstate;
  1536. enum rf_pwrstate rfpwr_state; /*cur power state */
  1537. /* for SW LPS*/
  1538. bool sw_ps_enabled;
  1539. bool state;
  1540. bool state_inap;
  1541. bool multi_buffered;
  1542. u16 nullfunc_seq;
  1543. unsigned int dtim_counter;
  1544. unsigned int sleep_ms;
  1545. unsigned long last_sleep_jiffies;
  1546. unsigned long last_awake_jiffies;
  1547. unsigned long last_delaylps_stamp_jiffies;
  1548. unsigned long last_dtim;
  1549. unsigned long last_beacon;
  1550. unsigned long last_action;
  1551. unsigned long last_slept;
  1552. /*For P2P PS */
  1553. struct rtl_p2p_ps_info p2p_ps_info;
  1554. u8 pwr_mode;
  1555. u8 smart_ps;
  1556. };
  1557. struct rtl_stats {
  1558. u8 psaddr[ETH_ALEN];
  1559. u32 mac_time[2];
  1560. s8 rssi;
  1561. u8 signal;
  1562. u8 noise;
  1563. u8 rate; /* hw desc rate */
  1564. u8 received_channel;
  1565. u8 control;
  1566. u8 mask;
  1567. u8 freq;
  1568. u16 len;
  1569. u64 tsf;
  1570. u32 beacon_time;
  1571. u8 nic_type;
  1572. u16 length;
  1573. u8 signalquality; /*in 0-100 index. */
  1574. /*
  1575. * Real power in dBm for this packet,
  1576. * no beautification and aggregation.
  1577. * */
  1578. s32 recvsignalpower;
  1579. s8 rxpower; /*in dBm Translate from PWdB */
  1580. u8 signalstrength; /*in 0-100 index. */
  1581. u16 hwerror:1;
  1582. u16 crc:1;
  1583. u16 icv:1;
  1584. u16 shortpreamble:1;
  1585. u16 antenna:1;
  1586. u16 decrypted:1;
  1587. u16 wakeup:1;
  1588. u32 timestamp_low;
  1589. u32 timestamp_high;
  1590. u8 rx_drvinfo_size;
  1591. u8 rx_bufshift;
  1592. bool isampdu;
  1593. bool isfirst_ampdu;
  1594. bool rx_is40Mhzpacket;
  1595. u32 rx_pwdb_all;
  1596. u8 rx_mimo_signalstrength[4]; /*in 0~100 index */
  1597. s8 rx_mimo_sig_qual[4];
  1598. u8 rx_pwr[4]; /* per-path's pwdb */
  1599. u8 rx_snr[4]; /* per-path's SNR */
  1600. bool packet_matchbssid;
  1601. bool is_cck;
  1602. bool is_ht;
  1603. bool packet_toself;
  1604. bool packet_beacon; /*for rssi */
  1605. char cck_adc_pwdb[4]; /*for rx path selection */
  1606. u8 packet_report_type;
  1607. u32 macid;
  1608. u8 wake_match;
  1609. u32 bt_rx_rssi_percentage;
  1610. u32 macid_valid_entry[2];
  1611. };
  1612. struct rt_link_detect {
  1613. /* count for roaming */
  1614. u32 bcn_rx_inperiod;
  1615. u32 roam_times;
  1616. u32 num_tx_in4period[4];
  1617. u32 num_rx_in4period[4];
  1618. u32 num_tx_inperiod;
  1619. u32 num_rx_inperiod;
  1620. bool busytraffic;
  1621. bool tx_busy_traffic;
  1622. bool rx_busy_traffic;
  1623. bool higher_busytraffic;
  1624. bool higher_busyrxtraffic;
  1625. u32 tidtx_in4period[MAX_TID_COUNT][4];
  1626. u32 tidtx_inperiod[MAX_TID_COUNT];
  1627. bool higher_busytxtraffic[MAX_TID_COUNT];
  1628. };
  1629. struct rtl_tcb_desc {
  1630. u8 packet_bw:1;
  1631. u8 multicast:1;
  1632. u8 broadcast:1;
  1633. u8 rts_stbc:1;
  1634. u8 rts_enable:1;
  1635. u8 cts_enable:1;
  1636. u8 rts_use_shortpreamble:1;
  1637. u8 rts_use_shortgi:1;
  1638. u8 rts_sc:1;
  1639. u8 rts_bw:1;
  1640. u8 rts_rate;
  1641. u8 use_shortgi:1;
  1642. u8 use_shortpreamble:1;
  1643. u8 use_driver_rate:1;
  1644. u8 disable_ratefallback:1;
  1645. u8 ratr_index;
  1646. u8 mac_id;
  1647. u8 hw_rate;
  1648. u8 last_inipkt:1;
  1649. u8 cmd_or_init:1;
  1650. u8 queue_index;
  1651. /* early mode */
  1652. u8 empkt_num;
  1653. /* The max value by HW */
  1654. u32 empkt_len[10];
  1655. bool btx_enable_sw_calc_duration;
  1656. };
  1657. struct rtl92c_firmware_header;
  1658. struct rtl_hal_ops {
  1659. int (*init_sw_vars) (struct ieee80211_hw *hw);
  1660. void (*deinit_sw_vars) (struct ieee80211_hw *hw);
  1661. void (*read_chip_version)(struct ieee80211_hw *hw);
  1662. void (*read_eeprom_info) (struct ieee80211_hw *hw);
  1663. void (*interrupt_recognized) (struct ieee80211_hw *hw,
  1664. u32 *p_inta, u32 *p_intb);
  1665. int (*hw_init) (struct ieee80211_hw *hw);
  1666. void (*hw_disable) (struct ieee80211_hw *hw);
  1667. void (*hw_suspend) (struct ieee80211_hw *hw);
  1668. void (*hw_resume) (struct ieee80211_hw *hw);
  1669. void (*enable_interrupt) (struct ieee80211_hw *hw);
  1670. void (*disable_interrupt) (struct ieee80211_hw *hw);
  1671. int (*set_network_type) (struct ieee80211_hw *hw,
  1672. enum nl80211_iftype type);
  1673. void (*set_chk_bssid)(struct ieee80211_hw *hw,
  1674. bool check_bssid);
  1675. void (*set_bw_mode) (struct ieee80211_hw *hw,
  1676. enum nl80211_channel_type ch_type);
  1677. u8(*switch_channel) (struct ieee80211_hw *hw);
  1678. void (*set_qos) (struct ieee80211_hw *hw, int aci);
  1679. void (*set_bcn_reg) (struct ieee80211_hw *hw);
  1680. void (*set_bcn_intv) (struct ieee80211_hw *hw);
  1681. void (*update_interrupt_mask) (struct ieee80211_hw *hw,
  1682. u32 add_msr, u32 rm_msr);
  1683. void (*get_hw_reg) (struct ieee80211_hw *hw, u8 variable, u8 *val);
  1684. void (*set_hw_reg) (struct ieee80211_hw *hw, u8 variable, u8 *val);
  1685. void (*update_rate_tbl) (struct ieee80211_hw *hw,
  1686. struct ieee80211_sta *sta, u8 rssi_level);
  1687. void (*pre_fill_tx_bd_desc)(struct ieee80211_hw *hw, u8 *tx_bd_desc,
  1688. u8 *desc, u8 queue_index,
  1689. struct sk_buff *skb, dma_addr_t addr);
  1690. void (*update_rate_mask) (struct ieee80211_hw *hw, u8 rssi_level);
  1691. u16 (*rx_desc_buff_remained_cnt)(struct ieee80211_hw *hw,
  1692. u8 queue_index);
  1693. void (*rx_check_dma_ok)(struct ieee80211_hw *hw, u8 *header_desc,
  1694. u8 queue_index);
  1695. void (*fill_tx_desc) (struct ieee80211_hw *hw,
  1696. struct ieee80211_hdr *hdr, u8 *pdesc_tx,
  1697. u8 *pbd_desc_tx,
  1698. struct ieee80211_tx_info *info,
  1699. struct ieee80211_sta *sta,
  1700. struct sk_buff *skb, u8 hw_queue,
  1701. struct rtl_tcb_desc *ptcb_desc);
  1702. void (*fill_fake_txdesc) (struct ieee80211_hw *hw, u8 *pDesc,
  1703. u32 buffer_len, bool bIsPsPoll);
  1704. void (*fill_tx_cmddesc) (struct ieee80211_hw *hw, u8 *pdesc,
  1705. bool firstseg, bool lastseg,
  1706. struct sk_buff *skb);
  1707. bool (*cmd_send_packet)(struct ieee80211_hw *hw, struct sk_buff *skb);
  1708. bool (*query_rx_desc) (struct ieee80211_hw *hw,
  1709. struct rtl_stats *stats,
  1710. struct ieee80211_rx_status *rx_status,
  1711. u8 *pdesc, struct sk_buff *skb);
  1712. void (*set_channel_access) (struct ieee80211_hw *hw);
  1713. bool (*radio_onoff_checking) (struct ieee80211_hw *hw, u8 *valid);
  1714. void (*dm_watchdog) (struct ieee80211_hw *hw);
  1715. void (*scan_operation_backup) (struct ieee80211_hw *hw, u8 operation);
  1716. bool (*set_rf_power_state) (struct ieee80211_hw *hw,
  1717. enum rf_pwrstate rfpwr_state);
  1718. void (*led_control) (struct ieee80211_hw *hw,
  1719. enum led_ctl_mode ledaction);
  1720. void (*set_desc)(struct ieee80211_hw *hw, u8 *pdesc, bool istx,
  1721. u8 desc_name, u8 *val);
  1722. u32 (*get_desc) (u8 *pdesc, bool istx, u8 desc_name);
  1723. bool (*is_tx_desc_closed) (struct ieee80211_hw *hw,
  1724. u8 hw_queue, u16 index);
  1725. void (*tx_polling) (struct ieee80211_hw *hw, u8 hw_queue);
  1726. void (*enable_hw_sec) (struct ieee80211_hw *hw);
  1727. void (*set_key) (struct ieee80211_hw *hw, u32 key_index,
  1728. u8 *macaddr, bool is_group, u8 enc_algo,
  1729. bool is_wepkey, bool clear_all);
  1730. void (*init_sw_leds) (struct ieee80211_hw *hw);
  1731. void (*deinit_sw_leds) (struct ieee80211_hw *hw);
  1732. u32 (*get_bbreg) (struct ieee80211_hw *hw, u32 regaddr, u32 bitmask);
  1733. void (*set_bbreg) (struct ieee80211_hw *hw, u32 regaddr, u32 bitmask,
  1734. u32 data);
  1735. u32 (*get_rfreg) (struct ieee80211_hw *hw, enum radio_path rfpath,
  1736. u32 regaddr, u32 bitmask);
  1737. void (*set_rfreg) (struct ieee80211_hw *hw, enum radio_path rfpath,
  1738. u32 regaddr, u32 bitmask, u32 data);
  1739. void (*linked_set_reg) (struct ieee80211_hw *hw);
  1740. void (*chk_switch_dmdp) (struct ieee80211_hw *hw);
  1741. void (*dualmac_easy_concurrent) (struct ieee80211_hw *hw);
  1742. void (*dualmac_switch_to_dmdp) (struct ieee80211_hw *hw);
  1743. bool (*phy_rf6052_config) (struct ieee80211_hw *hw);
  1744. void (*phy_rf6052_set_cck_txpower) (struct ieee80211_hw *hw,
  1745. u8 *powerlevel);
  1746. void (*phy_rf6052_set_ofdm_txpower) (struct ieee80211_hw *hw,
  1747. u8 *ppowerlevel, u8 channel);
  1748. bool (*config_bb_with_headerfile) (struct ieee80211_hw *hw,
  1749. u8 configtype);
  1750. bool (*config_bb_with_pgheaderfile) (struct ieee80211_hw *hw,
  1751. u8 configtype);
  1752. void (*phy_lc_calibrate) (struct ieee80211_hw *hw, bool is2t);
  1753. void (*phy_set_bw_mode_callback) (struct ieee80211_hw *hw);
  1754. void (*dm_dynamic_txpower) (struct ieee80211_hw *hw);
  1755. void (*c2h_command_handle) (struct ieee80211_hw *hw);
  1756. void (*bt_wifi_media_status_notify) (struct ieee80211_hw *hw,
  1757. bool mstate);
  1758. void (*bt_coex_off_before_lps) (struct ieee80211_hw *hw);
  1759. void (*fill_h2c_cmd) (struct ieee80211_hw *hw, u8 element_id,
  1760. u32 cmd_len, u8 *p_cmdbuffer);
  1761. bool (*get_btc_status) (void);
  1762. bool (*is_fw_header) (struct rtl92c_firmware_header *hdr);
  1763. u32 (*rx_command_packet)(struct ieee80211_hw *hw,
  1764. struct rtl_stats status, struct sk_buff *skb);
  1765. };
  1766. struct rtl_intf_ops {
  1767. /*com */
  1768. void (*read_efuse_byte)(struct ieee80211_hw *hw, u16 _offset, u8 *pbuf);
  1769. int (*adapter_start) (struct ieee80211_hw *hw);
  1770. void (*adapter_stop) (struct ieee80211_hw *hw);
  1771. bool (*check_buddy_priv)(struct ieee80211_hw *hw,
  1772. struct rtl_priv **buddy_priv);
  1773. int (*adapter_tx) (struct ieee80211_hw *hw,
  1774. struct ieee80211_sta *sta,
  1775. struct sk_buff *skb,
  1776. struct rtl_tcb_desc *ptcb_desc);
  1777. void (*flush)(struct ieee80211_hw *hw, bool drop);
  1778. int (*reset_trx_ring) (struct ieee80211_hw *hw);
  1779. bool (*waitq_insert) (struct ieee80211_hw *hw,
  1780. struct ieee80211_sta *sta,
  1781. struct sk_buff *skb);
  1782. /*pci */
  1783. void (*disable_aspm) (struct ieee80211_hw *hw);
  1784. void (*enable_aspm) (struct ieee80211_hw *hw);
  1785. /*usb */
  1786. };
  1787. struct rtl_mod_params {
  1788. /* default: 0 = using hardware encryption */
  1789. bool sw_crypto;
  1790. /* default: 0 = DBG_EMERG (0)*/
  1791. int debug;
  1792. /* default: 1 = using no linked power save */
  1793. bool inactiveps;
  1794. /* default: 1 = using linked sw power save */
  1795. bool swctrl_lps;
  1796. /* default: 1 = using linked fw power save */
  1797. bool fwctrl_lps;
  1798. /* default: 0 = not using MSI interrupts mode */
  1799. /* submodules should set their own defalut value */
  1800. bool msi_support;
  1801. };
  1802. struct rtl_hal_usbint_cfg {
  1803. /* data - rx */
  1804. u32 in_ep_num;
  1805. u32 rx_urb_num;
  1806. u32 rx_max_size;
  1807. /* op - rx */
  1808. void (*usb_rx_hdl)(struct ieee80211_hw *, struct sk_buff *);
  1809. void (*usb_rx_segregate_hdl)(struct ieee80211_hw *, struct sk_buff *,
  1810. struct sk_buff_head *);
  1811. /* tx */
  1812. void (*usb_tx_cleanup)(struct ieee80211_hw *, struct sk_buff *);
  1813. int (*usb_tx_post_hdl)(struct ieee80211_hw *, struct urb *,
  1814. struct sk_buff *);
  1815. struct sk_buff *(*usb_tx_aggregate_hdl)(struct ieee80211_hw *,
  1816. struct sk_buff_head *);
  1817. /* endpoint mapping */
  1818. int (*usb_endpoint_mapping)(struct ieee80211_hw *hw);
  1819. u16 (*usb_mq_to_hwq)(__le16 fc, u16 mac80211_queue_index);
  1820. };
  1821. struct rtl_hal_cfg {
  1822. u8 bar_id;
  1823. bool write_readback;
  1824. char *name;
  1825. char *fw_name;
  1826. char *alt_fw_name;
  1827. struct rtl_hal_ops *ops;
  1828. struct rtl_mod_params *mod_params;
  1829. struct rtl_hal_usbint_cfg *usb_interface_cfg;
  1830. /*this map used for some registers or vars
  1831. defined int HAL but used in MAIN */
  1832. u32 maps[RTL_VAR_MAP_MAX];
  1833. };
  1834. struct rtl_locks {
  1835. /* mutex */
  1836. struct mutex conf_mutex;
  1837. struct mutex ps_mutex;
  1838. /*spin lock */
  1839. spinlock_t ips_lock;
  1840. spinlock_t irq_th_lock;
  1841. spinlock_t irq_pci_lock;
  1842. spinlock_t tx_lock;
  1843. spinlock_t h2c_lock;
  1844. spinlock_t rf_ps_lock;
  1845. spinlock_t rf_lock;
  1846. spinlock_t lps_lock;
  1847. spinlock_t waitq_lock;
  1848. spinlock_t entry_list_lock;
  1849. spinlock_t usb_lock;
  1850. /*FW clock change */
  1851. spinlock_t fw_ps_lock;
  1852. /*Dual mac*/
  1853. spinlock_t cck_and_rw_pagea_lock;
  1854. /*Easy concurrent*/
  1855. spinlock_t check_sendpkt_lock;
  1856. spinlock_t iqk_lock;
  1857. };
  1858. struct rtl_works {
  1859. struct ieee80211_hw *hw;
  1860. /*timer */
  1861. struct timer_list watchdog_timer;
  1862. struct timer_list dualmac_easyconcurrent_retrytimer;
  1863. struct timer_list fw_clockoff_timer;
  1864. struct timer_list fast_antenna_training_timer;
  1865. /*task */
  1866. struct tasklet_struct irq_tasklet;
  1867. struct tasklet_struct irq_prepare_bcn_tasklet;
  1868. /*work queue */
  1869. struct workqueue_struct *rtl_wq;
  1870. struct delayed_work watchdog_wq;
  1871. struct delayed_work ips_nic_off_wq;
  1872. /* For SW LPS */
  1873. struct delayed_work ps_work;
  1874. struct delayed_work ps_rfon_wq;
  1875. struct delayed_work fwevt_wq;
  1876. struct work_struct lps_change_work;
  1877. struct work_struct fill_h2c_cmd;
  1878. };
  1879. struct rtl_debug {
  1880. u32 dbgp_type[DBGP_TYPE_MAX];
  1881. int global_debuglevel;
  1882. u64 global_debugcomponents;
  1883. /* add for proc debug */
  1884. struct proc_dir_entry *proc_dir;
  1885. char proc_name[20];
  1886. };
  1887. #define MIMO_PS_STATIC 0
  1888. #define MIMO_PS_DYNAMIC 1
  1889. #define MIMO_PS_NOLIMIT 3
  1890. struct rtl_dualmac_easy_concurrent_ctl {
  1891. enum band_type currentbandtype_backfordmdp;
  1892. bool close_bbandrf_for_dmsp;
  1893. bool change_to_dmdp;
  1894. bool change_to_dmsp;
  1895. bool switch_in_process;
  1896. };
  1897. struct rtl_dmsp_ctl {
  1898. bool activescan_for_slaveofdmsp;
  1899. bool scan_for_anothermac_fordmsp;
  1900. bool scan_for_itself_fordmsp;
  1901. bool writedig_for_anothermacofdmsp;
  1902. u32 curdigvalue_for_anothermacofdmsp;
  1903. bool changecckpdstate_for_anothermacofdmsp;
  1904. u8 curcckpdstate_for_anothermacofdmsp;
  1905. bool changetxhighpowerlvl_for_anothermacofdmsp;
  1906. u8 curtxhighlvl_for_anothermacofdmsp;
  1907. long rssivalmin_for_anothermacofdmsp;
  1908. };
  1909. struct ps_t {
  1910. u8 pre_ccastate;
  1911. u8 cur_ccasate;
  1912. u8 pre_rfstate;
  1913. u8 cur_rfstate;
  1914. u8 initialize;
  1915. long rssi_val_min;
  1916. };
  1917. struct dig_t {
  1918. u32 rssi_lowthresh;
  1919. u32 rssi_highthresh;
  1920. u32 fa_lowthresh;
  1921. u32 fa_highthresh;
  1922. long last_min_undec_pwdb_for_dm;
  1923. long rssi_highpower_lowthresh;
  1924. long rssi_highpower_highthresh;
  1925. u32 recover_cnt;
  1926. u32 pre_igvalue;
  1927. u32 cur_igvalue;
  1928. long rssi_val;
  1929. u8 dig_enable_flag;
  1930. u8 dig_ext_port_stage;
  1931. u8 dig_algorithm;
  1932. u8 dig_twoport_algorithm;
  1933. u8 dig_dbgmode;
  1934. u8 dig_slgorithm_switch;
  1935. u8 cursta_cstate;
  1936. u8 presta_cstate;
  1937. u8 curmultista_cstate;
  1938. u8 stop_dig;
  1939. char back_val;
  1940. char back_range_max;
  1941. char back_range_min;
  1942. u8 rx_gain_max;
  1943. u8 rx_gain_min;
  1944. u8 min_undec_pwdb_for_dm;
  1945. u8 rssi_val_min;
  1946. u8 pre_cck_cca_thres;
  1947. u8 cur_cck_cca_thres;
  1948. u8 pre_cck_pd_state;
  1949. u8 cur_cck_pd_state;
  1950. u8 pre_cck_fa_state;
  1951. u8 cur_cck_fa_state;
  1952. u8 pre_ccastate;
  1953. u8 cur_ccasate;
  1954. u8 large_fa_hit;
  1955. u8 dig_dynamic_min;
  1956. u8 dig_dynamic_min_1;
  1957. u8 forbidden_igi;
  1958. u8 dig_state;
  1959. u8 dig_highpwrstate;
  1960. u8 cur_sta_cstate;
  1961. u8 pre_sta_cstate;
  1962. u8 cur_ap_cstate;
  1963. u8 pre_ap_cstate;
  1964. u8 cur_pd_thstate;
  1965. u8 pre_pd_thstate;
  1966. u8 cur_cs_ratiostate;
  1967. u8 pre_cs_ratiostate;
  1968. u8 backoff_enable_flag;
  1969. char backoffval_range_max;
  1970. char backoffval_range_min;
  1971. u8 dig_min_0;
  1972. u8 dig_min_1;
  1973. u8 bt30_cur_igi;
  1974. bool media_connect_0;
  1975. bool media_connect_1;
  1976. u32 antdiv_rssi_max;
  1977. u32 rssi_max;
  1978. };
  1979. struct rtl_global_var {
  1980. /* from this list we can get
  1981. * other adapter's rtl_priv */
  1982. struct list_head glb_priv_list;
  1983. spinlock_t glb_list_lock;
  1984. };
  1985. struct rtl_btc_info {
  1986. u8 bt_type;
  1987. u8 btcoexist;
  1988. u8 ant_num;
  1989. };
  1990. struct bt_coexist_info {
  1991. struct rtl_btc_ops *btc_ops;
  1992. struct rtl_btc_info btc_info;
  1993. /* EEPROM BT info. */
  1994. u8 eeprom_bt_coexist;
  1995. u8 eeprom_bt_type;
  1996. u8 eeprom_bt_ant_num;
  1997. u8 eeprom_bt_ant_isol;
  1998. u8 eeprom_bt_radio_shared;
  1999. u8 bt_coexistence;
  2000. u8 bt_ant_num;
  2001. u8 bt_coexist_type;
  2002. u8 bt_state;
  2003. u8 bt_cur_state; /* 0:on, 1:off */
  2004. u8 bt_ant_isolation; /* 0:good, 1:bad */
  2005. u8 bt_pape_ctrl; /* 0:SW, 1:SW/HW dynamic */
  2006. u8 bt_service;
  2007. u8 bt_radio_shared_type;
  2008. u8 bt_rfreg_origin_1e;
  2009. u8 bt_rfreg_origin_1f;
  2010. u8 bt_rssi_state;
  2011. u32 ratio_tx;
  2012. u32 ratio_pri;
  2013. u32 bt_edca_ul;
  2014. u32 bt_edca_dl;
  2015. bool init_set;
  2016. bool bt_busy_traffic;
  2017. bool bt_traffic_mode_set;
  2018. bool bt_non_traffic_mode_set;
  2019. bool fw_coexist_all_off;
  2020. bool sw_coexist_all_off;
  2021. bool hw_coexist_all_off;
  2022. u32 cstate;
  2023. u32 previous_state;
  2024. u32 cstate_h;
  2025. u32 previous_state_h;
  2026. u8 bt_pre_rssi_state;
  2027. u8 bt_pre_rssi_state1;
  2028. u8 reg_bt_iso;
  2029. u8 reg_bt_sco;
  2030. bool balance_on;
  2031. u8 bt_active_zero_cnt;
  2032. bool cur_bt_disabled;
  2033. bool pre_bt_disabled;
  2034. u8 bt_profile_case;
  2035. u8 bt_profile_action;
  2036. bool bt_busy;
  2037. bool hold_for_bt_operation;
  2038. u8 lps_counter;
  2039. };
  2040. struct rtl_btc_ops {
  2041. void (*btc_init_variables) (struct rtl_priv *rtlpriv);
  2042. void (*btc_init_hal_vars) (struct rtl_priv *rtlpriv);
  2043. void (*btc_init_hw_config) (struct rtl_priv *rtlpriv);
  2044. void (*btc_ips_notify) (struct rtl_priv *rtlpriv, u8 type);
  2045. void (*btc_scan_notify) (struct rtl_priv *rtlpriv, u8 scantype);
  2046. void (*btc_connect_notify) (struct rtl_priv *rtlpriv, u8 action);
  2047. void (*btc_mediastatus_notify) (struct rtl_priv *rtlpriv,
  2048. enum _RT_MEDIA_STATUS mstatus);
  2049. void (*btc_periodical) (struct rtl_priv *rtlpriv);
  2050. void (*btc_halt_notify) (void);
  2051. void (*btc_btinfo_notify) (struct rtl_priv *rtlpriv,
  2052. u8 *tmp_buf, u8 length);
  2053. bool (*btc_is_limited_dig) (struct rtl_priv *rtlpriv);
  2054. bool (*btc_is_disable_edca_turbo) (struct rtl_priv *rtlpriv);
  2055. bool (*btc_is_bt_disabled) (struct rtl_priv *rtlpriv);
  2056. };
  2057. struct proxim {
  2058. bool proxim_on;
  2059. void *proximity_priv;
  2060. int (*proxim_rx)(struct ieee80211_hw *hw, struct rtl_stats *status,
  2061. struct sk_buff *skb);
  2062. u8 (*proxim_get_var)(struct ieee80211_hw *hw, u8 type);
  2063. };
  2064. struct rtl_priv {
  2065. struct ieee80211_hw *hw;
  2066. struct completion firmware_loading_complete;
  2067. struct list_head list;
  2068. struct rtl_priv *buddy_priv;
  2069. struct rtl_global_var *glb_var;
  2070. struct rtl_dualmac_easy_concurrent_ctl easy_concurrent_ctl;
  2071. struct rtl_dmsp_ctl dmsp_ctl;
  2072. struct rtl_locks locks;
  2073. struct rtl_works works;
  2074. struct rtl_mac mac80211;
  2075. struct rtl_hal rtlhal;
  2076. struct rtl_regulatory regd;
  2077. struct rtl_rfkill rfkill;
  2078. struct rtl_io io;
  2079. struct rtl_phy phy;
  2080. struct rtl_dm dm;
  2081. struct rtl_security sec;
  2082. struct rtl_efuse efuse;
  2083. struct rtl_ps_ctl psc;
  2084. struct rate_adaptive ra;
  2085. struct dynamic_primary_cca primarycca;
  2086. struct wireless_stats stats;
  2087. struct rt_link_detect link_info;
  2088. struct false_alarm_statistics falsealm_cnt;
  2089. struct rtl_rate_priv *rate_priv;
  2090. /* sta entry list for ap adhoc or mesh */
  2091. struct list_head entry_list;
  2092. struct rtl_debug dbg;
  2093. int max_fw_size;
  2094. /*
  2095. *hal_cfg : for diff cards
  2096. *intf_ops : for diff interrface usb/pcie
  2097. */
  2098. struct rtl_hal_cfg *cfg;
  2099. struct rtl_intf_ops *intf_ops;
  2100. /*this var will be set by set_bit,
  2101. and was used to indicate status of
  2102. interface or hardware */
  2103. unsigned long status;
  2104. /* tables for dm */
  2105. struct dig_t dm_digtable;
  2106. struct ps_t dm_pstable;
  2107. u32 reg_874;
  2108. u32 reg_c70;
  2109. u32 reg_85c;
  2110. u32 reg_a74;
  2111. bool reg_init; /* true if regs saved */
  2112. bool bt_operation_on;
  2113. __le32 *usb_data;
  2114. int usb_data_index;
  2115. bool initialized;
  2116. bool enter_ps; /* true when entering PS */
  2117. u8 rate_mask[5];
  2118. /* intel Proximity, should be alloc mem
  2119. * in intel Proximity module and can only
  2120. * be used in intel Proximity mode
  2121. */
  2122. struct proxim proximity;
  2123. /*for bt coexist use*/
  2124. struct bt_coexist_info btcoexist;
  2125. /* separate 92ee from other ICs,
  2126. * 92ee use new trx flow.
  2127. */
  2128. bool use_new_trx_flow;
  2129. /*This must be the last item so
  2130. that it points to the data allocated
  2131. beyond this structure like:
  2132. rtl_pci_priv or rtl_usb_priv */
  2133. u8 priv[0] __aligned(sizeof(void *));
  2134. };
  2135. #define rtl_priv(hw) (((struct rtl_priv *)(hw)->priv))
  2136. #define rtl_mac(rtlpriv) (&((rtlpriv)->mac80211))
  2137. #define rtl_hal(rtlpriv) (&((rtlpriv)->rtlhal))
  2138. #define rtl_efuse(rtlpriv) (&((rtlpriv)->efuse))
  2139. #define rtl_psc(rtlpriv) (&((rtlpriv)->psc))
  2140. /***************************************
  2141. Bluetooth Co-existence Related
  2142. ****************************************/
  2143. enum bt_ant_num {
  2144. ANT_X2 = 0,
  2145. ANT_X1 = 1,
  2146. };
  2147. enum bt_co_type {
  2148. BT_2WIRE = 0,
  2149. BT_ISSC_3WIRE = 1,
  2150. BT_ACCEL = 2,
  2151. BT_CSR_BC4 = 3,
  2152. BT_CSR_BC8 = 4,
  2153. BT_RTL8756 = 5,
  2154. BT_RTL8723A = 6,
  2155. BT_RTL8821A = 7,
  2156. BT_RTL8723B = 8,
  2157. BT_RTL8192E = 9,
  2158. BT_RTL8812A = 11,
  2159. };
  2160. enum bt_total_ant_num {
  2161. ANT_TOTAL_X2 = 0,
  2162. ANT_TOTAL_X1 = 1
  2163. };
  2164. enum bt_cur_state {
  2165. BT_OFF = 0,
  2166. BT_ON = 1,
  2167. };
  2168. enum bt_service_type {
  2169. BT_SCO = 0,
  2170. BT_A2DP = 1,
  2171. BT_HID = 2,
  2172. BT_HID_IDLE = 3,
  2173. BT_SCAN = 4,
  2174. BT_IDLE = 5,
  2175. BT_OTHER_ACTION = 6,
  2176. BT_BUSY = 7,
  2177. BT_OTHERBUSY = 8,
  2178. BT_PAN = 9,
  2179. };
  2180. enum bt_radio_shared {
  2181. BT_RADIO_SHARED = 0,
  2182. BT_RADIO_INDIVIDUAL = 1,
  2183. };
  2184. /****************************************
  2185. mem access macro define start
  2186. Call endian free function when
  2187. 1. Read/write packet content.
  2188. 2. Before write integer to IO.
  2189. 3. After read integer from IO.
  2190. ****************************************/
  2191. /* Convert little data endian to host ordering */
  2192. #define EF1BYTE(_val) \
  2193. ((u8)(_val))
  2194. #define EF2BYTE(_val) \
  2195. (le16_to_cpu(_val))
  2196. #define EF4BYTE(_val) \
  2197. (le32_to_cpu(_val))
  2198. /* Read data from memory */
  2199. #define READEF1BYTE(_ptr) \
  2200. EF1BYTE(*((u8 *)(_ptr)))
  2201. /* Read le16 data from memory and convert to host ordering */
  2202. #define READEF2BYTE(_ptr) \
  2203. EF2BYTE(*(_ptr))
  2204. #define READEF4BYTE(_ptr) \
  2205. EF4BYTE(*(_ptr))
  2206. /* Write data to memory */
  2207. #define WRITEEF1BYTE(_ptr, _val) \
  2208. (*((u8 *)(_ptr))) = EF1BYTE(_val)
  2209. /* Write le16 data to memory in host ordering */
  2210. #define WRITEEF2BYTE(_ptr, _val) \
  2211. (*((u16 *)(_ptr))) = EF2BYTE(_val)
  2212. #define WRITEEF4BYTE(_ptr, _val) \
  2213. (*((u32 *)(_ptr))) = EF2BYTE(_val)
  2214. /* Create a bit mask
  2215. * Examples:
  2216. * BIT_LEN_MASK_32(0) => 0x00000000
  2217. * BIT_LEN_MASK_32(1) => 0x00000001
  2218. * BIT_LEN_MASK_32(2) => 0x00000003
  2219. * BIT_LEN_MASK_32(32) => 0xFFFFFFFF
  2220. */
  2221. #define BIT_LEN_MASK_32(__bitlen) \
  2222. (0xFFFFFFFF >> (32 - (__bitlen)))
  2223. #define BIT_LEN_MASK_16(__bitlen) \
  2224. (0xFFFF >> (16 - (__bitlen)))
  2225. #define BIT_LEN_MASK_8(__bitlen) \
  2226. (0xFF >> (8 - (__bitlen)))
  2227. /* Create an offset bit mask
  2228. * Examples:
  2229. * BIT_OFFSET_LEN_MASK_32(0, 2) => 0x00000003
  2230. * BIT_OFFSET_LEN_MASK_32(16, 2) => 0x00030000
  2231. */
  2232. #define BIT_OFFSET_LEN_MASK_32(__bitoffset, __bitlen) \
  2233. (BIT_LEN_MASK_32(__bitlen) << (__bitoffset))
  2234. #define BIT_OFFSET_LEN_MASK_16(__bitoffset, __bitlen) \
  2235. (BIT_LEN_MASK_16(__bitlen) << (__bitoffset))
  2236. #define BIT_OFFSET_LEN_MASK_8(__bitoffset, __bitlen) \
  2237. (BIT_LEN_MASK_8(__bitlen) << (__bitoffset))
  2238. /*Description:
  2239. * Return 4-byte value in host byte ordering from
  2240. * 4-byte pointer in little-endian system.
  2241. */
  2242. #define LE_P4BYTE_TO_HOST_4BYTE(__pstart) \
  2243. (EF4BYTE(*((__le32 *)(__pstart))))
  2244. #define LE_P2BYTE_TO_HOST_2BYTE(__pstart) \
  2245. (EF2BYTE(*((__le16 *)(__pstart))))
  2246. #define LE_P1BYTE_TO_HOST_1BYTE(__pstart) \
  2247. (EF1BYTE(*((u8 *)(__pstart))))
  2248. /*Description:
  2249. Translate subfield (continuous bits in little-endian) of 4-byte
  2250. value to host byte ordering.*/
  2251. #define LE_BITS_TO_4BYTE(__pstart, __bitoffset, __bitlen) \
  2252. ( \
  2253. (LE_P4BYTE_TO_HOST_4BYTE(__pstart) >> (__bitoffset)) & \
  2254. BIT_LEN_MASK_32(__bitlen) \
  2255. )
  2256. #define LE_BITS_TO_2BYTE(__pstart, __bitoffset, __bitlen) \
  2257. ( \
  2258. (LE_P2BYTE_TO_HOST_2BYTE(__pstart) >> (__bitoffset)) & \
  2259. BIT_LEN_MASK_16(__bitlen) \
  2260. )
  2261. #define LE_BITS_TO_1BYTE(__pstart, __bitoffset, __bitlen) \
  2262. ( \
  2263. (LE_P1BYTE_TO_HOST_1BYTE(__pstart) >> (__bitoffset)) & \
  2264. BIT_LEN_MASK_8(__bitlen) \
  2265. )
  2266. /* Description:
  2267. * Mask subfield (continuous bits in little-endian) of 4-byte value
  2268. * and return the result in 4-byte value in host byte ordering.
  2269. */
  2270. #define LE_BITS_CLEARED_TO_4BYTE(__pstart, __bitoffset, __bitlen) \
  2271. ( \
  2272. LE_P4BYTE_TO_HOST_4BYTE(__pstart) & \
  2273. (~BIT_OFFSET_LEN_MASK_32(__bitoffset, __bitlen)) \
  2274. )
  2275. #define LE_BITS_CLEARED_TO_2BYTE(__pstart, __bitoffset, __bitlen) \
  2276. ( \
  2277. LE_P2BYTE_TO_HOST_2BYTE(__pstart) & \
  2278. (~BIT_OFFSET_LEN_MASK_16(__bitoffset, __bitlen)) \
  2279. )
  2280. #define LE_BITS_CLEARED_TO_1BYTE(__pstart, __bitoffset, __bitlen) \
  2281. ( \
  2282. LE_P1BYTE_TO_HOST_1BYTE(__pstart) & \
  2283. (~BIT_OFFSET_LEN_MASK_8(__bitoffset, __bitlen)) \
  2284. )
  2285. /* Description:
  2286. * Set subfield of little-endian 4-byte value to specified value.
  2287. */
  2288. #define SET_BITS_TO_LE_4BYTE(__pstart, __bitoffset, __bitlen, __val) \
  2289. *((u32 *)(__pstart)) = \
  2290. ( \
  2291. LE_BITS_CLEARED_TO_4BYTE(__pstart, __bitoffset, __bitlen) | \
  2292. ((((u32)__val) & BIT_LEN_MASK_32(__bitlen)) << (__bitoffset)) \
  2293. );
  2294. #define SET_BITS_TO_LE_2BYTE(__pstart, __bitoffset, __bitlen, __val) \
  2295. *((u16 *)(__pstart)) = \
  2296. ( \
  2297. LE_BITS_CLEARED_TO_2BYTE(__pstart, __bitoffset, __bitlen) | \
  2298. ((((u16)__val) & BIT_LEN_MASK_16(__bitlen)) << (__bitoffset)) \
  2299. );
  2300. #define SET_BITS_TO_LE_1BYTE(__pstart, __bitoffset, __bitlen, __val) \
  2301. *((u8 *)(__pstart)) = EF1BYTE \
  2302. ( \
  2303. LE_BITS_CLEARED_TO_1BYTE(__pstart, __bitoffset, __bitlen) | \
  2304. ((((u8)__val) & BIT_LEN_MASK_8(__bitlen)) << (__bitoffset)) \
  2305. );
  2306. #define N_BYTE_ALIGMENT(__value, __aligment) ((__aligment == 1) ? \
  2307. (__value) : (((__value + __aligment - 1) / __aligment) * __aligment))
  2308. /****************************************
  2309. mem access macro define end
  2310. ****************************************/
  2311. #define byte(x, n) ((x >> (8 * n)) & 0xff)
  2312. #define packet_get_type(_packet) (EF1BYTE((_packet).octet[0]) & 0xFC)
  2313. #define RTL_WATCH_DOG_TIME 2000
  2314. #define MSECS(t) msecs_to_jiffies(t)
  2315. #define WLAN_FC_GET_VERS(fc) (le16_to_cpu(fc) & IEEE80211_FCTL_VERS)
  2316. #define WLAN_FC_GET_TYPE(fc) (le16_to_cpu(fc) & IEEE80211_FCTL_FTYPE)
  2317. #define WLAN_FC_GET_STYPE(fc) (le16_to_cpu(fc) & IEEE80211_FCTL_STYPE)
  2318. #define WLAN_FC_MORE_DATA(fc) (le16_to_cpu(fc) & IEEE80211_FCTL_MOREDATA)
  2319. #define rtl_dm(rtlpriv) (&((rtlpriv)->dm))
  2320. #define RT_RF_OFF_LEVL_ASPM BIT(0) /*PCI ASPM */
  2321. #define RT_RF_OFF_LEVL_CLK_REQ BIT(1) /*PCI clock request */
  2322. #define RT_RF_OFF_LEVL_PCI_D3 BIT(2) /*PCI D3 mode */
  2323. /*NIC halt, re-initialize hw parameters*/
  2324. #define RT_RF_OFF_LEVL_HALT_NIC BIT(3)
  2325. #define RT_RF_OFF_LEVL_FREE_FW BIT(4) /*FW free, re-download the FW */
  2326. #define RT_RF_OFF_LEVL_FW_32K BIT(5) /*FW in 32k */
  2327. /*Always enable ASPM and Clock Req in initialization.*/
  2328. #define RT_RF_PS_LEVEL_ALWAYS_ASPM BIT(6)
  2329. /* no matter RFOFF or SLEEP we set PS_ASPM_LEVL*/
  2330. #define RT_PS_LEVEL_ASPM BIT(7)
  2331. /*When LPS is on, disable 2R if no packet is received or transmittd.*/
  2332. #define RT_RF_LPS_DISALBE_2R BIT(30)
  2333. #define RT_RF_LPS_LEVEL_ASPM BIT(31) /*LPS with ASPM */
  2334. #define RT_IN_PS_LEVEL(ppsc, _ps_flg) \
  2335. ((ppsc->cur_ps_level & _ps_flg) ? true : false)
  2336. #define RT_CLEAR_PS_LEVEL(ppsc, _ps_flg) \
  2337. (ppsc->cur_ps_level &= (~(_ps_flg)))
  2338. #define RT_SET_PS_LEVEL(ppsc, _ps_flg) \
  2339. (ppsc->cur_ps_level |= _ps_flg)
  2340. #define container_of_dwork_rtl(x, y, z) \
  2341. container_of(container_of(x, struct delayed_work, work), y, z)
  2342. #define FILL_OCTET_STRING(_os, _octet, _len) \
  2343. (_os).octet = (u8 *)(_octet); \
  2344. (_os).length = (_len);
  2345. #define CP_MACADDR(des, src) \
  2346. ((des)[0] = (src)[0], (des)[1] = (src)[1],\
  2347. (des)[2] = (src)[2], (des)[3] = (src)[3],\
  2348. (des)[4] = (src)[4], (des)[5] = (src)[5])
  2349. static inline u8 rtl_read_byte(struct rtl_priv *rtlpriv, u32 addr)
  2350. {
  2351. return rtlpriv->io.read8_sync(rtlpriv, addr);
  2352. }
  2353. static inline u16 rtl_read_word(struct rtl_priv *rtlpriv, u32 addr)
  2354. {
  2355. return rtlpriv->io.read16_sync(rtlpriv, addr);
  2356. }
  2357. static inline u32 rtl_read_dword(struct rtl_priv *rtlpriv, u32 addr)
  2358. {
  2359. return rtlpriv->io.read32_sync(rtlpriv, addr);
  2360. }
  2361. static inline void rtl_write_byte(struct rtl_priv *rtlpriv, u32 addr, u8 val8)
  2362. {
  2363. rtlpriv->io.write8_async(rtlpriv, addr, val8);
  2364. if (rtlpriv->cfg->write_readback)
  2365. rtlpriv->io.read8_sync(rtlpriv, addr);
  2366. }
  2367. static inline void rtl_write_word(struct rtl_priv *rtlpriv, u32 addr, u16 val16)
  2368. {
  2369. rtlpriv->io.write16_async(rtlpriv, addr, val16);
  2370. if (rtlpriv->cfg->write_readback)
  2371. rtlpriv->io.read16_sync(rtlpriv, addr);
  2372. }
  2373. static inline void rtl_write_dword(struct rtl_priv *rtlpriv,
  2374. u32 addr, u32 val32)
  2375. {
  2376. rtlpriv->io.write32_async(rtlpriv, addr, val32);
  2377. if (rtlpriv->cfg->write_readback)
  2378. rtlpriv->io.read32_sync(rtlpriv, addr);
  2379. }
  2380. static inline u32 rtl_get_bbreg(struct ieee80211_hw *hw,
  2381. u32 regaddr, u32 bitmask)
  2382. {
  2383. struct rtl_priv *rtlpriv = hw->priv;
  2384. return rtlpriv->cfg->ops->get_bbreg(hw, regaddr, bitmask);
  2385. }
  2386. static inline void rtl_set_bbreg(struct ieee80211_hw *hw, u32 regaddr,
  2387. u32 bitmask, u32 data)
  2388. {
  2389. struct rtl_priv *rtlpriv = hw->priv;
  2390. rtlpriv->cfg->ops->set_bbreg(hw, regaddr, bitmask, data);
  2391. }
  2392. static inline u32 rtl_get_rfreg(struct ieee80211_hw *hw,
  2393. enum radio_path rfpath, u32 regaddr,
  2394. u32 bitmask)
  2395. {
  2396. struct rtl_priv *rtlpriv = hw->priv;
  2397. return rtlpriv->cfg->ops->get_rfreg(hw, rfpath, regaddr, bitmask);
  2398. }
  2399. static inline void rtl_set_rfreg(struct ieee80211_hw *hw,
  2400. enum radio_path rfpath, u32 regaddr,
  2401. u32 bitmask, u32 data)
  2402. {
  2403. struct rtl_priv *rtlpriv = hw->priv;
  2404. rtlpriv->cfg->ops->set_rfreg(hw, rfpath, regaddr, bitmask, data);
  2405. }
  2406. static inline bool is_hal_stop(struct rtl_hal *rtlhal)
  2407. {
  2408. return (_HAL_STATE_STOP == rtlhal->state);
  2409. }
  2410. static inline void set_hal_start(struct rtl_hal *rtlhal)
  2411. {
  2412. rtlhal->state = _HAL_STATE_START;
  2413. }
  2414. static inline void set_hal_stop(struct rtl_hal *rtlhal)
  2415. {
  2416. rtlhal->state = _HAL_STATE_STOP;
  2417. }
  2418. static inline u8 get_rf_type(struct rtl_phy *rtlphy)
  2419. {
  2420. return rtlphy->rf_type;
  2421. }
  2422. static inline struct ieee80211_hdr *rtl_get_hdr(struct sk_buff *skb)
  2423. {
  2424. return (struct ieee80211_hdr *)(skb->data);
  2425. }
  2426. static inline __le16 rtl_get_fc(struct sk_buff *skb)
  2427. {
  2428. return rtl_get_hdr(skb)->frame_control;
  2429. }
  2430. static inline u16 rtl_get_tid_h(struct ieee80211_hdr *hdr)
  2431. {
  2432. return (ieee80211_get_qos_ctl(hdr))[0] & IEEE80211_QOS_CTL_TID_MASK;
  2433. }
  2434. static inline u16 rtl_get_tid(struct sk_buff *skb)
  2435. {
  2436. return rtl_get_tid_h(rtl_get_hdr(skb));
  2437. }
  2438. static inline struct ieee80211_sta *get_sta(struct ieee80211_hw *hw,
  2439. struct ieee80211_vif *vif,
  2440. const u8 *bssid)
  2441. {
  2442. return ieee80211_find_sta(vif, bssid);
  2443. }
  2444. static inline struct ieee80211_sta *rtl_find_sta(struct ieee80211_hw *hw,
  2445. u8 *mac_addr)
  2446. {
  2447. struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
  2448. return ieee80211_find_sta(mac->vif, mac_addr);
  2449. }
  2450. #endif