wifi.h 71 KB

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