wifi.h 61 KB

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