wifi.h 69 KB

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