hal_api.h 76 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757
  1. /*
  2. * Copyright (c) 2016-2021 The Linux Foundation. All rights reserved.
  3. *
  4. * Permission to use, copy, modify, and/or distribute this software for
  5. * any purpose with or without fee is hereby granted, provided that the
  6. * above copyright notice and this permission notice appear in all
  7. * copies.
  8. *
  9. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
  10. * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
  11. * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
  12. * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
  13. * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
  14. * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  15. * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  16. * PERFORMANCE OF THIS SOFTWARE.
  17. */
  18. #ifndef _HAL_API_H_
  19. #define _HAL_API_H_
  20. #include "qdf_types.h"
  21. #include "qdf_util.h"
  22. #include "qdf_atomic.h"
  23. #include "hal_internal.h"
  24. #include "hif.h"
  25. #include "hif_io32.h"
  26. #include "qdf_platform.h"
  27. /* Ring index for WBM2SW2 release ring */
  28. #define HAL_IPA_TX_COMP_RING_IDX 2
  29. /* calculate the register address offset from bar0 of shadow register x */
  30. #if defined(QCA_WIFI_QCA6390) || defined(QCA_WIFI_QCA6490)
  31. #define SHADOW_REGISTER_START_ADDRESS_OFFSET 0x000008FC
  32. #define SHADOW_REGISTER_END_ADDRESS_OFFSET \
  33. ((SHADOW_REGISTER_START_ADDRESS_OFFSET) + (4 * (MAX_SHADOW_REGISTERS)))
  34. #define SHADOW_REGISTER(x) ((SHADOW_REGISTER_START_ADDRESS_OFFSET) + (4 * (x)))
  35. #elif defined(QCA_WIFI_QCA6290) || defined(QCA_WIFI_QCN9000)
  36. #define SHADOW_REGISTER_START_ADDRESS_OFFSET 0x00003024
  37. #define SHADOW_REGISTER_END_ADDRESS_OFFSET \
  38. ((SHADOW_REGISTER_START_ADDRESS_OFFSET) + (4 * (MAX_SHADOW_REGISTERS)))
  39. #define SHADOW_REGISTER(x) ((SHADOW_REGISTER_START_ADDRESS_OFFSET) + (4 * (x)))
  40. #elif defined(QCA_WIFI_QCA6750)
  41. #define SHADOW_REGISTER_START_ADDRESS_OFFSET 0x00000504
  42. #define SHADOW_REGISTER_END_ADDRESS_OFFSET \
  43. ((SHADOW_REGISTER_START_ADDRESS_OFFSET) + (4 * (MAX_SHADOW_REGISTERS)))
  44. #define SHADOW_REGISTER(x) ((SHADOW_REGISTER_START_ADDRESS_OFFSET) + (4 * (x)))
  45. #else
  46. #define SHADOW_REGISTER(x) 0
  47. #endif /* QCA_WIFI_QCA6390 || QCA_WIFI_QCA6490 || QCA_WIFI_QCA6750 */
  48. #define MAX_UNWINDOWED_ADDRESS 0x80000
  49. #if defined(QCA_WIFI_QCA6390) || defined(QCA_WIFI_QCA6490) || \
  50. defined(QCA_WIFI_QCN9000) || defined(QCA_WIFI_QCA6750)
  51. #define WINDOW_ENABLE_BIT 0x40000000
  52. #else
  53. #define WINDOW_ENABLE_BIT 0x80000000
  54. #endif
  55. #define WINDOW_REG_ADDRESS 0x310C
  56. #define WINDOW_SHIFT 19
  57. #define WINDOW_VALUE_MASK 0x3F
  58. #define WINDOW_START MAX_UNWINDOWED_ADDRESS
  59. #define WINDOW_RANGE_MASK 0x7FFFF
  60. /*
  61. * BAR + 4K is always accessible, any access outside this
  62. * space requires force wake procedure.
  63. * OFFSET = 4K - 32 bytes = 0xFE0
  64. */
  65. #define MAPPED_REF_OFF 0xFE0
  66. #ifdef ENABLE_VERBOSE_DEBUG
  67. static inline void
  68. hal_set_verbose_debug(bool flag)
  69. {
  70. is_hal_verbose_debug_enabled = flag;
  71. }
  72. #endif
  73. #ifdef ENABLE_HAL_SOC_STATS
  74. #define HAL_STATS_INC(_handle, _field, _delta) \
  75. { \
  76. if (likely(_handle)) \
  77. _handle->stats._field += _delta; \
  78. }
  79. #else
  80. #define HAL_STATS_INC(_handle, _field, _delta)
  81. #endif
  82. #ifdef ENABLE_HAL_REG_WR_HISTORY
  83. #define HAL_REG_WRITE_FAIL_HIST_ADD(hal_soc, offset, wr_val, rd_val) \
  84. hal_reg_wr_fail_history_add(hal_soc, offset, wr_val, rd_val)
  85. void hal_reg_wr_fail_history_add(struct hal_soc *hal_soc,
  86. uint32_t offset,
  87. uint32_t wr_val,
  88. uint32_t rd_val);
  89. static inline int hal_history_get_next_index(qdf_atomic_t *table_index,
  90. int array_size)
  91. {
  92. int record_index = qdf_atomic_inc_return(table_index);
  93. return record_index & (array_size - 1);
  94. }
  95. #else
  96. #define HAL_REG_WRITE_FAIL_HIST_ADD(hal_soc, offset, wr_val, rd_val) \
  97. hal_err("write failed at reg offset 0x%x, write 0x%x read 0x%x\n", \
  98. offset, \
  99. wr_val, \
  100. rd_val)
  101. #endif
  102. /**
  103. * hal_reg_write_result_check() - check register writing result
  104. * @hal_soc: HAL soc handle
  105. * @offset: register offset to read
  106. * @exp_val: the expected value of register
  107. * @ret_confirm: result confirm flag
  108. *
  109. * Return: none
  110. */
  111. static inline void hal_reg_write_result_check(struct hal_soc *hal_soc,
  112. uint32_t offset,
  113. uint32_t exp_val)
  114. {
  115. uint32_t value;
  116. value = qdf_ioread32(hal_soc->dev_base_addr + offset);
  117. if (exp_val != value) {
  118. HAL_REG_WRITE_FAIL_HIST_ADD(hal_soc, offset, exp_val, value);
  119. HAL_STATS_INC(hal_soc, reg_write_fail, 1);
  120. }
  121. }
  122. #if !defined(QCA_WIFI_QCA6390) && !defined(QCA_WIFI_QCA6490)
  123. static inline void hal_lock_reg_access(struct hal_soc *soc,
  124. unsigned long *flags)
  125. {
  126. qdf_spin_lock_irqsave(&soc->register_access_lock);
  127. }
  128. static inline void hal_unlock_reg_access(struct hal_soc *soc,
  129. unsigned long *flags)
  130. {
  131. qdf_spin_unlock_irqrestore(&soc->register_access_lock);
  132. }
  133. #else
  134. static inline void hal_lock_reg_access(struct hal_soc *soc,
  135. unsigned long *flags)
  136. {
  137. pld_lock_reg_window(soc->qdf_dev->dev, flags);
  138. }
  139. static inline void hal_unlock_reg_access(struct hal_soc *soc,
  140. unsigned long *flags)
  141. {
  142. pld_unlock_reg_window(soc->qdf_dev->dev, flags);
  143. }
  144. #endif
  145. #ifdef PCIE_REG_WINDOW_LOCAL_NO_CACHE
  146. /**
  147. * hal_select_window_confirm() - write remap window register and
  148. check writing result
  149. *
  150. */
  151. static inline void hal_select_window_confirm(struct hal_soc *hal_soc,
  152. uint32_t offset)
  153. {
  154. uint32_t window = (offset >> WINDOW_SHIFT) & WINDOW_VALUE_MASK;
  155. qdf_iowrite32(hal_soc->dev_base_addr + WINDOW_REG_ADDRESS,
  156. WINDOW_ENABLE_BIT | window);
  157. hal_soc->register_window = window;
  158. hal_reg_write_result_check(hal_soc, WINDOW_REG_ADDRESS,
  159. WINDOW_ENABLE_BIT | window);
  160. }
  161. #else
  162. static inline void hal_select_window_confirm(struct hal_soc *hal_soc,
  163. uint32_t offset)
  164. {
  165. uint32_t window = (offset >> WINDOW_SHIFT) & WINDOW_VALUE_MASK;
  166. if (window != hal_soc->register_window) {
  167. qdf_iowrite32(hal_soc->dev_base_addr + WINDOW_REG_ADDRESS,
  168. WINDOW_ENABLE_BIT | window);
  169. hal_soc->register_window = window;
  170. hal_reg_write_result_check(
  171. hal_soc,
  172. WINDOW_REG_ADDRESS,
  173. WINDOW_ENABLE_BIT | window);
  174. }
  175. }
  176. #endif
  177. static inline qdf_iomem_t hal_get_window_address(struct hal_soc *hal_soc,
  178. qdf_iomem_t addr)
  179. {
  180. return hal_soc->ops->hal_get_window_address(hal_soc, addr);
  181. }
  182. static inline void hal_tx_init_cmd_credit_ring(hal_soc_handle_t hal_soc_hdl,
  183. hal_ring_handle_t hal_ring_hdl)
  184. {
  185. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  186. return hal_soc->ops->hal_tx_init_cmd_credit_ring(hal_soc_hdl,
  187. hal_ring_hdl);
  188. }
  189. /**
  190. * hal_write32_mb() - Access registers to update configuration
  191. * @hal_soc: hal soc handle
  192. * @offset: offset address from the BAR
  193. * @value: value to write
  194. *
  195. * Return: None
  196. *
  197. * Description: Register address space is split below:
  198. * SHADOW REGION UNWINDOWED REGION WINDOWED REGION
  199. * |--------------------|-------------------|------------------|
  200. * BAR NO FORCE WAKE BAR+4K FORCE WAKE BAR+512K FORCE WAKE
  201. *
  202. * 1. Any access to the shadow region, doesn't need force wake
  203. * and windowing logic to access.
  204. * 2. Any access beyond BAR + 4K:
  205. * If init_phase enabled, no force wake is needed and access
  206. * should be based on windowed or unwindowed access.
  207. * If init_phase disabled, force wake is needed and access
  208. * should be based on windowed or unwindowed access.
  209. *
  210. * note1: WINDOW_RANGE_MASK = (1 << WINDOW_SHIFT) -1
  211. * note2: 1 << WINDOW_SHIFT = MAX_UNWINDOWED_ADDRESS
  212. * note3: WINDOW_VALUE_MASK = big enough that trying to write past
  213. * that window would be a bug
  214. */
  215. #if !defined(QCA_WIFI_QCA6390) && !defined(QCA_WIFI_QCA6490) && \
  216. !defined(QCA_WIFI_QCA6750)
  217. static inline void hal_write32_mb(struct hal_soc *hal_soc, uint32_t offset,
  218. uint32_t value)
  219. {
  220. unsigned long flags;
  221. qdf_iomem_t new_addr;
  222. if (!hal_soc->use_register_windowing ||
  223. offset < MAX_UNWINDOWED_ADDRESS) {
  224. qdf_iowrite32(hal_soc->dev_base_addr + offset, value);
  225. } else if (hal_soc->static_window_map) {
  226. new_addr = hal_get_window_address(hal_soc,
  227. hal_soc->dev_base_addr + offset);
  228. qdf_iowrite32(new_addr, value);
  229. } else {
  230. hal_lock_reg_access(hal_soc, &flags);
  231. hal_select_window_confirm(hal_soc, offset);
  232. qdf_iowrite32(hal_soc->dev_base_addr + WINDOW_START +
  233. (offset & WINDOW_RANGE_MASK), value);
  234. hal_unlock_reg_access(hal_soc, &flags);
  235. }
  236. }
  237. #define hal_write32_mb_confirm(_hal_soc, _offset, _value) \
  238. hal_write32_mb(_hal_soc, _offset, _value)
  239. #define hal_write32_mb_cmem(_hal_soc, _offset, _value)
  240. #else
  241. static inline void hal_write32_mb(struct hal_soc *hal_soc, uint32_t offset,
  242. uint32_t value)
  243. {
  244. int ret;
  245. unsigned long flags;
  246. qdf_iomem_t new_addr;
  247. if (!TARGET_ACCESS_ALLOWED(HIF_GET_SOFTC(
  248. hal_soc->hif_handle))) {
  249. hal_err_rl("target access is not allowed");
  250. return;
  251. }
  252. /* Region < BAR + 4K can be directly accessed */
  253. if (offset < MAPPED_REF_OFF) {
  254. qdf_iowrite32(hal_soc->dev_base_addr + offset, value);
  255. return;
  256. }
  257. /* Region greater than BAR + 4K */
  258. if (!hal_soc->init_phase) {
  259. ret = hif_force_wake_request(hal_soc->hif_handle);
  260. if (ret) {
  261. hal_err_rl("Wake up request failed");
  262. qdf_check_state_before_panic();
  263. return;
  264. }
  265. }
  266. if (!hal_soc->use_register_windowing ||
  267. offset < MAX_UNWINDOWED_ADDRESS) {
  268. qdf_iowrite32(hal_soc->dev_base_addr + offset, value);
  269. } else if (hal_soc->static_window_map) {
  270. new_addr = hal_get_window_address(
  271. hal_soc,
  272. hal_soc->dev_base_addr + offset);
  273. qdf_iowrite32(new_addr, value);
  274. } else {
  275. hal_lock_reg_access(hal_soc, &flags);
  276. hal_select_window_confirm(hal_soc, offset);
  277. qdf_iowrite32(hal_soc->dev_base_addr + WINDOW_START +
  278. (offset & WINDOW_RANGE_MASK), value);
  279. hal_unlock_reg_access(hal_soc, &flags);
  280. }
  281. if (!hal_soc->init_phase) {
  282. ret = hif_force_wake_release(hal_soc->hif_handle);
  283. if (ret) {
  284. hal_err("Wake up release failed");
  285. qdf_check_state_before_panic();
  286. return;
  287. }
  288. }
  289. }
  290. /**
  291. * hal_write32_mb_confirm() - write register and check wirting result
  292. *
  293. */
  294. static inline void hal_write32_mb_confirm(struct hal_soc *hal_soc,
  295. uint32_t offset,
  296. uint32_t value)
  297. {
  298. int ret;
  299. unsigned long flags;
  300. qdf_iomem_t new_addr;
  301. if (!TARGET_ACCESS_ALLOWED(HIF_GET_SOFTC(
  302. hal_soc->hif_handle))) {
  303. hal_err_rl("target access is not allowed");
  304. return;
  305. }
  306. /* Region < BAR + 4K can be directly accessed */
  307. if (offset < MAPPED_REF_OFF) {
  308. qdf_iowrite32(hal_soc->dev_base_addr + offset, value);
  309. return;
  310. }
  311. /* Region greater than BAR + 4K */
  312. if (!hal_soc->init_phase) {
  313. ret = hif_force_wake_request(hal_soc->hif_handle);
  314. if (ret) {
  315. hal_err("Wake up request failed");
  316. qdf_check_state_before_panic();
  317. return;
  318. }
  319. }
  320. if (!hal_soc->use_register_windowing ||
  321. offset < MAX_UNWINDOWED_ADDRESS) {
  322. qdf_iowrite32(hal_soc->dev_base_addr + offset, value);
  323. hal_reg_write_result_check(hal_soc, offset,
  324. value);
  325. } else if (hal_soc->static_window_map) {
  326. new_addr = hal_get_window_address(
  327. hal_soc,
  328. hal_soc->dev_base_addr + offset);
  329. qdf_iowrite32(new_addr, value);
  330. hal_reg_write_result_check(hal_soc,
  331. new_addr - hal_soc->dev_base_addr,
  332. value);
  333. } else {
  334. hal_lock_reg_access(hal_soc, &flags);
  335. hal_select_window_confirm(hal_soc, offset);
  336. qdf_iowrite32(hal_soc->dev_base_addr + WINDOW_START +
  337. (offset & WINDOW_RANGE_MASK), value);
  338. hal_reg_write_result_check(
  339. hal_soc,
  340. WINDOW_START + (offset & WINDOW_RANGE_MASK),
  341. value);
  342. hal_unlock_reg_access(hal_soc, &flags);
  343. }
  344. if (!hal_soc->init_phase) {
  345. ret = hif_force_wake_release(hal_soc->hif_handle);
  346. if (ret) {
  347. hal_err("Wake up release failed");
  348. qdf_check_state_before_panic();
  349. return;
  350. }
  351. }
  352. }
  353. static inline void hal_write32_mb_cmem(struct hal_soc *hal_soc, uint32_t offset,
  354. uint32_t value)
  355. {
  356. unsigned long flags;
  357. qdf_iomem_t new_addr;
  358. if (!TARGET_ACCESS_ALLOWED(HIF_GET_SOFTC(
  359. hal_soc->hif_handle))) {
  360. hal_err_rl("%s: target access is not allowed", __func__);
  361. return;
  362. }
  363. if (!hal_soc->use_register_windowing ||
  364. offset < MAX_UNWINDOWED_ADDRESS) {
  365. qdf_iowrite32(hal_soc->dev_base_addr + offset, value);
  366. } else if (hal_soc->static_window_map) {
  367. new_addr = hal_get_window_address(
  368. hal_soc,
  369. hal_soc->dev_base_addr + offset);
  370. qdf_iowrite32(new_addr, value);
  371. } else {
  372. hal_lock_reg_access(hal_soc, &flags);
  373. hal_select_window_confirm(hal_soc, offset);
  374. qdf_iowrite32(hal_soc->dev_base_addr + WINDOW_START +
  375. (offset & WINDOW_RANGE_MASK), value);
  376. hal_unlock_reg_access(hal_soc, &flags);
  377. }
  378. }
  379. #endif
  380. /**
  381. * hal_write_address_32_mb - write a value to a register
  382. *
  383. */
  384. static inline
  385. void hal_write_address_32_mb(struct hal_soc *hal_soc,
  386. qdf_iomem_t addr, uint32_t value, bool wr_confirm)
  387. {
  388. uint32_t offset;
  389. if (!hal_soc->use_register_windowing)
  390. return qdf_iowrite32(addr, value);
  391. offset = addr - hal_soc->dev_base_addr;
  392. if (qdf_unlikely(wr_confirm))
  393. hal_write32_mb_confirm(hal_soc, offset, value);
  394. else
  395. hal_write32_mb(hal_soc, offset, value);
  396. }
  397. #ifdef DP_HAL_MULTIWINDOW_DIRECT_ACCESS
  398. static inline void hal_srng_write_address_32_mb(struct hal_soc *hal_soc,
  399. struct hal_srng *srng,
  400. void __iomem *addr,
  401. uint32_t value)
  402. {
  403. qdf_iowrite32(addr, value);
  404. }
  405. #elif defined(FEATURE_HAL_DELAYED_REG_WRITE)
  406. static inline void hal_srng_write_address_32_mb(struct hal_soc *hal_soc,
  407. struct hal_srng *srng,
  408. void __iomem *addr,
  409. uint32_t value)
  410. {
  411. hal_delayed_reg_write(hal_soc, srng, addr, value);
  412. }
  413. #else
  414. static inline void hal_srng_write_address_32_mb(struct hal_soc *hal_soc,
  415. struct hal_srng *srng,
  416. void __iomem *addr,
  417. uint32_t value)
  418. {
  419. hal_write_address_32_mb(hal_soc, addr, value, false);
  420. }
  421. #endif
  422. #if !defined(QCA_WIFI_QCA6390) && !defined(QCA_WIFI_QCA6490) && \
  423. !defined(QCA_WIFI_QCA6750)
  424. /**
  425. * hal_read32_mb() - Access registers to read configuration
  426. * @hal_soc: hal soc handle
  427. * @offset: offset address from the BAR
  428. * @value: value to write
  429. *
  430. * Description: Register address space is split below:
  431. * SHADOW REGION UNWINDOWED REGION WINDOWED REGION
  432. * |--------------------|-------------------|------------------|
  433. * BAR NO FORCE WAKE BAR+4K FORCE WAKE BAR+512K FORCE WAKE
  434. *
  435. * 1. Any access to the shadow region, doesn't need force wake
  436. * and windowing logic to access.
  437. * 2. Any access beyond BAR + 4K:
  438. * If init_phase enabled, no force wake is needed and access
  439. * should be based on windowed or unwindowed access.
  440. * If init_phase disabled, force wake is needed and access
  441. * should be based on windowed or unwindowed access.
  442. *
  443. * Return: < 0 for failure/>= 0 for success
  444. */
  445. static inline uint32_t hal_read32_mb(struct hal_soc *hal_soc, uint32_t offset)
  446. {
  447. uint32_t ret;
  448. unsigned long flags;
  449. qdf_iomem_t new_addr;
  450. if (!hal_soc->use_register_windowing ||
  451. offset < MAX_UNWINDOWED_ADDRESS) {
  452. return qdf_ioread32(hal_soc->dev_base_addr + offset);
  453. } else if (hal_soc->static_window_map) {
  454. new_addr = hal_get_window_address(hal_soc, hal_soc->dev_base_addr + offset);
  455. return qdf_ioread32(new_addr);
  456. }
  457. hal_lock_reg_access(hal_soc, &flags);
  458. hal_select_window_confirm(hal_soc, offset);
  459. ret = qdf_ioread32(hal_soc->dev_base_addr + WINDOW_START +
  460. (offset & WINDOW_RANGE_MASK));
  461. hal_unlock_reg_access(hal_soc, &flags);
  462. return ret;
  463. }
  464. #define hal_read32_mb_cmem(_hal_soc, _offset)
  465. #else
  466. static
  467. uint32_t hal_read32_mb(struct hal_soc *hal_soc, uint32_t offset)
  468. {
  469. uint32_t ret;
  470. unsigned long flags;
  471. qdf_iomem_t new_addr;
  472. if (!TARGET_ACCESS_ALLOWED(HIF_GET_SOFTC(
  473. hal_soc->hif_handle))) {
  474. hal_err_rl("target access is not allowed");
  475. return 0;
  476. }
  477. /* Region < BAR + 4K can be directly accessed */
  478. if (offset < MAPPED_REF_OFF)
  479. return qdf_ioread32(hal_soc->dev_base_addr + offset);
  480. if ((!hal_soc->init_phase) &&
  481. hif_force_wake_request(hal_soc->hif_handle)) {
  482. hal_err("Wake up request failed");
  483. qdf_check_state_before_panic();
  484. return 0;
  485. }
  486. if (!hal_soc->use_register_windowing ||
  487. offset < MAX_UNWINDOWED_ADDRESS) {
  488. ret = qdf_ioread32(hal_soc->dev_base_addr + offset);
  489. } else if (hal_soc->static_window_map) {
  490. new_addr = hal_get_window_address(
  491. hal_soc,
  492. hal_soc->dev_base_addr + offset);
  493. ret = qdf_ioread32(new_addr);
  494. } else {
  495. hal_lock_reg_access(hal_soc, &flags);
  496. hal_select_window_confirm(hal_soc, offset);
  497. ret = qdf_ioread32(hal_soc->dev_base_addr + WINDOW_START +
  498. (offset & WINDOW_RANGE_MASK));
  499. hal_unlock_reg_access(hal_soc, &flags);
  500. }
  501. if ((!hal_soc->init_phase) &&
  502. hif_force_wake_release(hal_soc->hif_handle)) {
  503. hal_err("Wake up release failed");
  504. qdf_check_state_before_panic();
  505. return 0;
  506. }
  507. return ret;
  508. }
  509. static inline
  510. uint32_t hal_read32_mb_cmem(struct hal_soc *hal_soc, uint32_t offset)
  511. {
  512. uint32_t ret;
  513. unsigned long flags;
  514. qdf_iomem_t new_addr;
  515. if (!TARGET_ACCESS_ALLOWED(HIF_GET_SOFTC(
  516. hal_soc->hif_handle))) {
  517. hal_err_rl("%s: target access is not allowed", __func__);
  518. return 0;
  519. }
  520. if (!hal_soc->use_register_windowing ||
  521. offset < MAX_UNWINDOWED_ADDRESS) {
  522. ret = qdf_ioread32(hal_soc->dev_base_addr + offset);
  523. } else if (hal_soc->static_window_map) {
  524. new_addr = hal_get_window_address(
  525. hal_soc,
  526. hal_soc->dev_base_addr + offset);
  527. ret = qdf_ioread32(new_addr);
  528. } else {
  529. hal_lock_reg_access(hal_soc, &flags);
  530. hal_select_window_confirm(hal_soc, offset);
  531. ret = qdf_ioread32(hal_soc->dev_base_addr + WINDOW_START +
  532. (offset & WINDOW_RANGE_MASK));
  533. hal_unlock_reg_access(hal_soc, &flags);
  534. }
  535. return ret;
  536. }
  537. #endif
  538. /* Max times allowed for register writing retry */
  539. #define HAL_REG_WRITE_RETRY_MAX 5
  540. /* Delay milliseconds for each time retry */
  541. #define HAL_REG_WRITE_RETRY_DELAY 1
  542. #ifdef GENERIC_SHADOW_REGISTER_ACCESS_ENABLE
  543. /* To check shadow config index range between 0..31 */
  544. #define HAL_SHADOW_REG_INDEX_LOW 32
  545. /* To check shadow config index range between 32..39 */
  546. #define HAL_SHADOW_REG_INDEX_HIGH 40
  547. /* Dirty bit reg offsets corresponding to shadow config index */
  548. #define HAL_SHADOW_REG_DIRTY_BIT_DATA_LOW_OFFSET 0x30C8
  549. #define HAL_SHADOW_REG_DIRTY_BIT_DATA_HIGH_OFFSET 0x30C4
  550. /* PCIE_PCIE_TOP base addr offset */
  551. #define HAL_PCIE_PCIE_TOP_WRAPPER 0x01E00000
  552. /* Max retry attempts to read the dirty bit reg */
  553. #ifdef HAL_CONFIG_SLUB_DEBUG_ON
  554. #define HAL_SHADOW_DIRTY_BIT_POLL_MAX 10000
  555. #else
  556. #define HAL_SHADOW_DIRTY_BIT_POLL_MAX 2000
  557. #endif
  558. /* Delay in usecs for polling dirty bit reg */
  559. #define HAL_SHADOW_DIRTY_BIT_POLL_DELAY 5
  560. /**
  561. * hal_poll_dirty_bit_reg() - Poll dirty register bit to confirm
  562. * write was successful
  563. * @hal_soc: hal soc handle
  564. * @shadow_config_index: index of shadow reg used to confirm
  565. * write
  566. *
  567. * Return: QDF_STATUS_SUCCESS on success
  568. */
  569. static inline QDF_STATUS hal_poll_dirty_bit_reg(struct hal_soc *hal,
  570. int shadow_config_index)
  571. {
  572. uint32_t read_value = 0;
  573. int retry_cnt = 0;
  574. uint32_t reg_offset = 0;
  575. if (shadow_config_index > 0 &&
  576. shadow_config_index < HAL_SHADOW_REG_INDEX_LOW) {
  577. reg_offset =
  578. HAL_SHADOW_REG_DIRTY_BIT_DATA_LOW_OFFSET;
  579. } else if (shadow_config_index >= HAL_SHADOW_REG_INDEX_LOW &&
  580. shadow_config_index < HAL_SHADOW_REG_INDEX_HIGH) {
  581. reg_offset =
  582. HAL_SHADOW_REG_DIRTY_BIT_DATA_HIGH_OFFSET;
  583. } else {
  584. hal_err("Invalid shadow_config_index = %d",
  585. shadow_config_index);
  586. return QDF_STATUS_E_INVAL;
  587. }
  588. while (retry_cnt < HAL_SHADOW_DIRTY_BIT_POLL_MAX) {
  589. read_value = hal_read32_mb(
  590. hal, HAL_PCIE_PCIE_TOP_WRAPPER + reg_offset);
  591. /* Check if dirty bit corresponding to shadow_index is set */
  592. if (read_value & BIT(shadow_config_index)) {
  593. /* Dirty reg bit not reset */
  594. qdf_udelay(HAL_SHADOW_DIRTY_BIT_POLL_DELAY);
  595. retry_cnt++;
  596. } else {
  597. hal_debug("Shadow write: offset 0x%x read val 0x%x",
  598. reg_offset, read_value);
  599. return QDF_STATUS_SUCCESS;
  600. }
  601. }
  602. return QDF_STATUS_E_TIMEOUT;
  603. }
  604. /**
  605. * hal_write32_mb_shadow_confirm() - write to shadow reg and
  606. * poll dirty register bit to confirm write
  607. * @hal_soc: hal soc handle
  608. * @reg_offset: target reg offset address from BAR
  609. * @value: value to write
  610. *
  611. * Return: QDF_STATUS_SUCCESS on success
  612. */
  613. static inline QDF_STATUS hal_write32_mb_shadow_confirm(
  614. struct hal_soc *hal,
  615. uint32_t reg_offset,
  616. uint32_t value)
  617. {
  618. int i;
  619. QDF_STATUS ret;
  620. uint32_t shadow_reg_offset;
  621. int shadow_config_index;
  622. bool is_reg_offset_present = false;
  623. for (i = 0; i < MAX_GENERIC_SHADOW_REG; i++) {
  624. /* Found the shadow config for the reg_offset */
  625. struct shadow_reg_config *hal_shadow_reg_list =
  626. &hal->list_shadow_reg_config[i];
  627. if (hal_shadow_reg_list->target_register ==
  628. reg_offset) {
  629. shadow_config_index =
  630. hal_shadow_reg_list->shadow_config_index;
  631. shadow_reg_offset =
  632. SHADOW_REGISTER(shadow_config_index);
  633. hal_write32_mb_confirm(
  634. hal, shadow_reg_offset, value);
  635. is_reg_offset_present = true;
  636. break;
  637. }
  638. ret = QDF_STATUS_E_FAILURE;
  639. }
  640. if (is_reg_offset_present) {
  641. ret = hal_poll_dirty_bit_reg(hal, shadow_config_index);
  642. hal_info("Shadow write:reg 0x%x val 0x%x ret %d",
  643. reg_offset, value, ret);
  644. if (QDF_IS_STATUS_ERROR(ret)) {
  645. HAL_STATS_INC(hal, shadow_reg_write_fail, 1);
  646. return ret;
  647. }
  648. HAL_STATS_INC(hal, shadow_reg_write_succ, 1);
  649. }
  650. return ret;
  651. }
  652. /**
  653. * hal_write32_mb_confirm_retry() - write register with confirming and
  654. do retry/recovery if writing failed
  655. * @hal_soc: hal soc handle
  656. * @offset: offset address from the BAR
  657. * @value: value to write
  658. * @recovery: is recovery needed or not.
  659. *
  660. * Write the register value with confirming and read it back, if
  661. * read back value is not as expected, do retry for writing, if
  662. * retry hit max times allowed but still fail, check if recovery
  663. * needed.
  664. *
  665. * Return: None
  666. */
  667. static inline void hal_write32_mb_confirm_retry(struct hal_soc *hal_soc,
  668. uint32_t offset,
  669. uint32_t value,
  670. bool recovery)
  671. {
  672. QDF_STATUS ret;
  673. ret = hal_write32_mb_shadow_confirm(hal_soc, offset, value);
  674. if (QDF_IS_STATUS_ERROR(ret) && recovery)
  675. qdf_trigger_self_recovery(NULL, QDF_HAL_REG_WRITE_FAILURE);
  676. }
  677. #else /* GENERIC_SHADOW_REGISTER_ACCESS_ENABLE */
  678. static inline void hal_write32_mb_confirm_retry(struct hal_soc *hal_soc,
  679. uint32_t offset,
  680. uint32_t value,
  681. bool recovery)
  682. {
  683. uint8_t retry_cnt = 0;
  684. uint32_t read_value;
  685. while (retry_cnt <= HAL_REG_WRITE_RETRY_MAX) {
  686. hal_write32_mb_confirm(hal_soc, offset, value);
  687. read_value = hal_read32_mb(hal_soc, offset);
  688. if (qdf_likely(read_value == value))
  689. break;
  690. /* write failed, do retry */
  691. hal_warn("Retry reg offset 0x%x, value 0x%x, read value 0x%x",
  692. offset, value, read_value);
  693. qdf_mdelay(HAL_REG_WRITE_RETRY_DELAY);
  694. retry_cnt++;
  695. }
  696. if (retry_cnt > HAL_REG_WRITE_RETRY_MAX && recovery)
  697. qdf_trigger_self_recovery(NULL, QDF_HAL_REG_WRITE_FAILURE);
  698. }
  699. #endif /* GENERIC_SHADOW_REGISTER_ACCESS_ENABLE */
  700. #ifdef FEATURE_HAL_DELAYED_REG_WRITE
  701. /**
  702. * hal_dump_reg_write_srng_stats() - dump SRNG reg write stats
  703. * @hal_soc: HAL soc handle
  704. *
  705. * Return: none
  706. */
  707. void hal_dump_reg_write_srng_stats(hal_soc_handle_t hal_soc_hdl);
  708. /**
  709. * hal_dump_reg_write_stats() - dump reg write stats
  710. * @hal_soc: HAL soc handle
  711. *
  712. * Return: none
  713. */
  714. void hal_dump_reg_write_stats(hal_soc_handle_t hal_soc_hdl);
  715. /**
  716. * hal_get_reg_write_pending_work() - get the number of entries
  717. * pending in the workqueue to be processed.
  718. * @hal_soc: HAL soc handle
  719. *
  720. * Returns: the number of entries pending to be processed
  721. */
  722. int hal_get_reg_write_pending_work(void *hal_soc);
  723. #else
  724. static inline void hal_dump_reg_write_srng_stats(hal_soc_handle_t hal_soc_hdl)
  725. {
  726. }
  727. static inline void hal_dump_reg_write_stats(hal_soc_handle_t hal_soc_hdl)
  728. {
  729. }
  730. static inline int hal_get_reg_write_pending_work(void *hal_soc)
  731. {
  732. return 0;
  733. }
  734. #endif
  735. /**
  736. * hal_read_address_32_mb() - Read 32-bit value from the register
  737. * @soc: soc handle
  738. * @addr: register address to read
  739. *
  740. * Return: 32-bit value
  741. */
  742. static inline
  743. uint32_t hal_read_address_32_mb(struct hal_soc *soc,
  744. qdf_iomem_t addr)
  745. {
  746. uint32_t offset;
  747. uint32_t ret;
  748. if (!soc->use_register_windowing)
  749. return qdf_ioread32(addr);
  750. offset = addr - soc->dev_base_addr;
  751. ret = hal_read32_mb(soc, offset);
  752. return ret;
  753. }
  754. /**
  755. * hal_attach - Initialize HAL layer
  756. * @hif_handle: Opaque HIF handle
  757. * @qdf_dev: QDF device
  758. *
  759. * Return: Opaque HAL SOC handle
  760. * NULL on failure (if given ring is not available)
  761. *
  762. * This function should be called as part of HIF initialization (for accessing
  763. * copy engines). DP layer will get hal_soc handle using hif_get_hal_handle()
  764. */
  765. void *hal_attach(struct hif_opaque_softc *hif_handle, qdf_device_t qdf_dev);
  766. /**
  767. * hal_detach - Detach HAL layer
  768. * @hal_soc: HAL SOC handle
  769. *
  770. * This function should be called as part of HIF detach
  771. *
  772. */
  773. extern void hal_detach(void *hal_soc);
  774. /* SRNG type to be passed in APIs hal_srng_get_entrysize and hal_srng_setup */
  775. enum hal_ring_type {
  776. REO_DST = 0,
  777. REO_EXCEPTION = 1,
  778. REO_REINJECT = 2,
  779. REO_CMD = 3,
  780. REO_STATUS = 4,
  781. TCL_DATA = 5,
  782. TCL_CMD_CREDIT = 6,
  783. TCL_STATUS = 7,
  784. CE_SRC = 8,
  785. CE_DST = 9,
  786. CE_DST_STATUS = 10,
  787. WBM_IDLE_LINK = 11,
  788. SW2WBM_RELEASE = 12,
  789. WBM2SW_RELEASE = 13,
  790. RXDMA_BUF = 14,
  791. RXDMA_DST = 15,
  792. RXDMA_MONITOR_BUF = 16,
  793. RXDMA_MONITOR_STATUS = 17,
  794. RXDMA_MONITOR_DST = 18,
  795. RXDMA_MONITOR_DESC = 19,
  796. DIR_BUF_RX_DMA_SRC = 20,
  797. #ifdef WLAN_FEATURE_CIF_CFR
  798. WIFI_POS_SRC,
  799. #endif
  800. MAX_RING_TYPES
  801. };
  802. #define HAL_SRNG_LMAC_RING 0x80000000
  803. /* SRNG flags passed in hal_srng_params.flags */
  804. #define HAL_SRNG_MSI_SWAP 0x00000008
  805. #define HAL_SRNG_RING_PTR_SWAP 0x00000010
  806. #define HAL_SRNG_DATA_TLV_SWAP 0x00000020
  807. #define HAL_SRNG_LOW_THRES_INTR_ENABLE 0x00010000
  808. #define HAL_SRNG_MSI_INTR 0x00020000
  809. #define HAL_SRNG_CACHED_DESC 0x00040000
  810. #ifdef QCA_WIFI_QCA6490
  811. #define HAL_SRNG_PREFETCH_TIMER 1
  812. #else
  813. #define HAL_SRNG_PREFETCH_TIMER 0
  814. #endif
  815. #define PN_SIZE_24 0
  816. #define PN_SIZE_48 1
  817. #define PN_SIZE_128 2
  818. #ifdef FORCE_WAKE
  819. /**
  820. * hal_set_init_phase() - Indicate initialization of
  821. * datapath rings
  822. * @soc: hal_soc handle
  823. * @init_phase: flag to indicate datapath rings
  824. * initialization status
  825. *
  826. * Return: None
  827. */
  828. void hal_set_init_phase(hal_soc_handle_t soc, bool init_phase);
  829. #else
  830. static inline
  831. void hal_set_init_phase(hal_soc_handle_t soc, bool init_phase)
  832. {
  833. }
  834. #endif /* FORCE_WAKE */
  835. /**
  836. * hal_srng_get_entrysize - Returns size of ring entry in bytes. Should be
  837. * used by callers for calculating the size of memory to be allocated before
  838. * calling hal_srng_setup to setup the ring
  839. *
  840. * @hal_soc: Opaque HAL SOC handle
  841. * @ring_type: one of the types from hal_ring_type
  842. *
  843. */
  844. extern uint32_t hal_srng_get_entrysize(void *hal_soc, int ring_type);
  845. /**
  846. * hal_srng_max_entries - Returns maximum possible number of ring entries
  847. * @hal_soc: Opaque HAL SOC handle
  848. * @ring_type: one of the types from hal_ring_type
  849. *
  850. * Return: Maximum number of entries for the given ring_type
  851. */
  852. uint32_t hal_srng_max_entries(void *hal_soc, int ring_type);
  853. void hal_set_low_threshold(hal_ring_handle_t hal_ring_hdl,
  854. uint32_t low_threshold);
  855. /**
  856. * hal_srng_dump - Dump ring status
  857. * @srng: hal srng pointer
  858. */
  859. void hal_srng_dump(struct hal_srng *srng);
  860. /**
  861. * hal_srng_get_dir - Returns the direction of the ring
  862. * @hal_soc: Opaque HAL SOC handle
  863. * @ring_type: one of the types from hal_ring_type
  864. *
  865. * Return: Ring direction
  866. */
  867. enum hal_srng_dir hal_srng_get_dir(void *hal_soc, int ring_type);
  868. /* HAL memory information */
  869. struct hal_mem_info {
  870. /* dev base virutal addr */
  871. void *dev_base_addr;
  872. /* dev base physical addr */
  873. void *dev_base_paddr;
  874. /* dev base ce virutal addr - applicable only for qca5018 */
  875. /* In qca5018 CE register are outside wcss block */
  876. /* using a separate address space to access CE registers */
  877. void *dev_base_addr_ce;
  878. /* dev base ce physical addr */
  879. void *dev_base_paddr_ce;
  880. /* Remote virtual pointer memory for HW/FW updates */
  881. void *shadow_rdptr_mem_vaddr;
  882. /* Remote physical pointer memory for HW/FW updates */
  883. void *shadow_rdptr_mem_paddr;
  884. /* Shared memory for ring pointer updates from host to FW */
  885. void *shadow_wrptr_mem_vaddr;
  886. /* Shared physical memory for ring pointer updates from host to FW */
  887. void *shadow_wrptr_mem_paddr;
  888. };
  889. /* SRNG parameters to be passed to hal_srng_setup */
  890. struct hal_srng_params {
  891. /* Physical base address of the ring */
  892. qdf_dma_addr_t ring_base_paddr;
  893. /* Virtual base address of the ring */
  894. void *ring_base_vaddr;
  895. /* Number of entries in ring */
  896. uint32_t num_entries;
  897. /* max transfer length */
  898. uint16_t max_buffer_length;
  899. /* MSI Address */
  900. qdf_dma_addr_t msi_addr;
  901. /* MSI data */
  902. uint32_t msi_data;
  903. /* Interrupt timer threshold – in micro seconds */
  904. uint32_t intr_timer_thres_us;
  905. /* Interrupt batch counter threshold – in number of ring entries */
  906. uint32_t intr_batch_cntr_thres_entries;
  907. /* Low threshold – in number of ring entries
  908. * (valid for src rings only)
  909. */
  910. uint32_t low_threshold;
  911. /* Misc flags */
  912. uint32_t flags;
  913. /* Unique ring id */
  914. uint8_t ring_id;
  915. /* Source or Destination ring */
  916. enum hal_srng_dir ring_dir;
  917. /* Size of ring entry */
  918. uint32_t entry_size;
  919. /* hw register base address */
  920. void *hwreg_base[MAX_SRNG_REG_GROUPS];
  921. /* prefetch timer config - in micro seconds */
  922. uint32_t prefetch_timer;
  923. };
  924. /* hal_construct_srng_shadow_regs() - initialize the shadow
  925. * registers for srngs
  926. * @hal_soc: hal handle
  927. *
  928. * Return: QDF_STATUS_OK on success
  929. */
  930. QDF_STATUS hal_construct_srng_shadow_regs(void *hal_soc);
  931. /* hal_set_one_shadow_config() - add a config for the specified ring
  932. * @hal_soc: hal handle
  933. * @ring_type: ring type
  934. * @ring_num: ring num
  935. *
  936. * The ring type and ring num uniquely specify the ring. After this call,
  937. * the hp/tp will be added as the next entry int the shadow register
  938. * configuration table. The hal code will use the shadow register address
  939. * in place of the hp/tp address.
  940. *
  941. * This function is exposed, so that the CE module can skip configuring shadow
  942. * registers for unused ring and rings assigned to the firmware.
  943. *
  944. * Return: QDF_STATUS_OK on success
  945. */
  946. QDF_STATUS hal_set_one_shadow_config(void *hal_soc, int ring_type,
  947. int ring_num);
  948. /**
  949. * hal_get_shadow_config() - retrieve the config table
  950. * @hal_soc: hal handle
  951. * @shadow_config: will point to the table after
  952. * @num_shadow_registers_configured: will contain the number of valid entries
  953. */
  954. extern void hal_get_shadow_config(void *hal_soc,
  955. struct pld_shadow_reg_v2_cfg **shadow_config,
  956. int *num_shadow_registers_configured);
  957. /**
  958. * hal_srng_setup - Initialize HW SRNG ring.
  959. *
  960. * @hal_soc: Opaque HAL SOC handle
  961. * @ring_type: one of the types from hal_ring_type
  962. * @ring_num: Ring number if there are multiple rings of
  963. * same type (staring from 0)
  964. * @mac_id: valid MAC Id should be passed if ring type is one of lmac rings
  965. * @ring_params: SRNG ring params in hal_srng_params structure.
  966. * Callers are expected to allocate contiguous ring memory of size
  967. * 'num_entries * entry_size' bytes and pass the physical and virtual base
  968. * addresses through 'ring_base_paddr' and 'ring_base_vaddr' in hal_srng_params
  969. * structure. Ring base address should be 8 byte aligned and size of each ring
  970. * entry should be queried using the API hal_srng_get_entrysize
  971. *
  972. * Return: Opaque pointer to ring on success
  973. * NULL on failure (if given ring is not available)
  974. */
  975. extern void *hal_srng_setup(void *hal_soc, int ring_type, int ring_num,
  976. int mac_id, struct hal_srng_params *ring_params);
  977. /* Remapping ids of REO rings */
  978. #define REO_REMAP_TCL 0
  979. #define REO_REMAP_SW1 1
  980. #define REO_REMAP_SW2 2
  981. #define REO_REMAP_SW3 3
  982. #define REO_REMAP_SW4 4
  983. #define REO_REMAP_RELEASE 5
  984. #define REO_REMAP_FW 6
  985. #define REO_REMAP_UNUSED 7
  986. /*
  987. * Macro to access HWIO_REO_R0_ERROR_DESTINATION_RING_CTRL_IX_0
  988. * to map destination to rings
  989. */
  990. #define HAL_REO_ERR_REMAP_IX0(_VALUE, _OFFSET) \
  991. ((_VALUE) << \
  992. (HWIO_REO_R0_ERROR_DESTINATION_MAPPING_IX_0_ERROR_ ## \
  993. DESTINATION_RING_ ## _OFFSET ## _SHFT))
  994. /*
  995. * Macro to access HWIO_REO_R0_ERROR_DESTINATION_RING_CTRL_IX_1
  996. * to map destination to rings
  997. */
  998. #define HAL_REO_ERR_REMAP_IX1(_VALUE, _OFFSET) \
  999. ((_VALUE) << \
  1000. (HWIO_REO_R0_ERROR_DESTINATION_MAPPING_IX_1_ERROR_ ## \
  1001. DESTINATION_RING_ ## _OFFSET ## _SHFT))
  1002. /*
  1003. * Macro to access HWIO_REO_R0_DESTINATION_RING_CTRL_IX_0
  1004. * to map destination to rings
  1005. */
  1006. #define HAL_REO_REMAP_IX0(_VALUE, _OFFSET) \
  1007. ((_VALUE) << \
  1008. (HWIO_REO_R0_DESTINATION_RING_CTRL_IX_0_DEST_RING_MAPPING_ ## \
  1009. _OFFSET ## _SHFT))
  1010. /*
  1011. * Macro to access HWIO_REO_R0_DESTINATION_RING_CTRL_IX_1
  1012. * to map destination to rings
  1013. */
  1014. #define HAL_REO_REMAP_IX2(_VALUE, _OFFSET) \
  1015. ((_VALUE) << \
  1016. (HWIO_REO_R0_DESTINATION_RING_CTRL_IX_2_DEST_RING_MAPPING_ ## \
  1017. _OFFSET ## _SHFT))
  1018. /*
  1019. * Macro to access HWIO_REO_R0_DESTINATION_RING_CTRL_IX_3
  1020. * to map destination to rings
  1021. */
  1022. #define HAL_REO_REMAP_IX3(_VALUE, _OFFSET) \
  1023. ((_VALUE) << \
  1024. (HWIO_REO_R0_DESTINATION_RING_CTRL_IX_3_DEST_RING_MAPPING_ ## \
  1025. _OFFSET ## _SHFT))
  1026. /**
  1027. * hal_reo_read_write_ctrl_ix - Read or write REO_DESTINATION_RING_CTRL_IX
  1028. * @hal_soc_hdl: HAL SOC handle
  1029. * @read: boolean value to indicate if read or write
  1030. * @ix0: pointer to store IX0 reg value
  1031. * @ix1: pointer to store IX1 reg value
  1032. * @ix2: pointer to store IX2 reg value
  1033. * @ix3: pointer to store IX3 reg value
  1034. */
  1035. void hal_reo_read_write_ctrl_ix(hal_soc_handle_t hal_soc_hdl, bool read,
  1036. uint32_t *ix0, uint32_t *ix1,
  1037. uint32_t *ix2, uint32_t *ix3);
  1038. /**
  1039. * hal_srng_set_hp_paddr_confirm() - Set physical address to dest SRNG head
  1040. * pointer and confirm that write went through by reading back the value
  1041. * @sring: sring pointer
  1042. * @paddr: physical address
  1043. *
  1044. * Return: None
  1045. */
  1046. extern void hal_srng_dst_set_hp_paddr_confirm(struct hal_srng *sring,
  1047. uint64_t paddr);
  1048. /**
  1049. * hal_srng_dst_init_hp() - Initilaize head pointer with cached head pointer
  1050. * @hal_soc: hal_soc handle
  1051. * @srng: sring pointer
  1052. * @vaddr: virtual address
  1053. */
  1054. void hal_srng_dst_init_hp(struct hal_soc_handle *hal_soc,
  1055. struct hal_srng *srng,
  1056. uint32_t *vaddr);
  1057. /**
  1058. * hal_srng_cleanup - Deinitialize HW SRNG ring.
  1059. * @hal_soc: Opaque HAL SOC handle
  1060. * @hal_srng: Opaque HAL SRNG pointer
  1061. */
  1062. void hal_srng_cleanup(void *hal_soc, hal_ring_handle_t hal_ring_hdl);
  1063. static inline bool hal_srng_initialized(hal_ring_handle_t hal_ring_hdl)
  1064. {
  1065. struct hal_srng *srng = (struct hal_srng *)hal_ring_hdl;
  1066. return !!srng->initialized;
  1067. }
  1068. /**
  1069. * hal_srng_dst_peek - Check if there are any entries in the ring (peek)
  1070. * @hal_soc: Opaque HAL SOC handle
  1071. * @hal_ring_hdl: Destination ring pointer
  1072. *
  1073. * Caller takes responsibility for any locking needs.
  1074. *
  1075. * Return: Opaque pointer for next ring entry; NULL on failire
  1076. */
  1077. static inline
  1078. void *hal_srng_dst_peek(hal_soc_handle_t hal_soc_hdl,
  1079. hal_ring_handle_t hal_ring_hdl)
  1080. {
  1081. struct hal_srng *srng = (struct hal_srng *)hal_ring_hdl;
  1082. if (srng->u.dst_ring.tp != srng->u.dst_ring.cached_hp)
  1083. return (void *)(&srng->ring_base_vaddr[srng->u.dst_ring.tp]);
  1084. return NULL;
  1085. }
  1086. /**
  1087. * hal_mem_dma_cache_sync - Cache sync the specified virtual address Range
  1088. * @hal_soc: HAL soc handle
  1089. * @desc: desc start address
  1090. * @entry_size: size of memory to sync
  1091. *
  1092. * Return: void
  1093. */
  1094. #if defined(__LINUX_MIPS32_ARCH__) || defined(__LINUX_MIPS64_ARCH__)
  1095. static inline void hal_mem_dma_cache_sync(struct hal_soc *soc, uint32_t *desc,
  1096. uint32_t entry_size)
  1097. {
  1098. qdf_nbuf_dma_inv_range((void *)desc, (void *)(desc + entry_size));
  1099. }
  1100. #else
  1101. static inline void hal_mem_dma_cache_sync(struct hal_soc *soc, uint32_t *desc,
  1102. uint32_t entry_size)
  1103. {
  1104. qdf_mem_dma_cache_sync(soc->qdf_dev, qdf_mem_virt_to_phys(desc),
  1105. QDF_DMA_FROM_DEVICE,
  1106. (entry_size * sizeof(uint32_t)));
  1107. }
  1108. #endif
  1109. /**
  1110. * hal_srng_access_start_unlocked - Start ring access (unlocked). Should use
  1111. * hal_srng_access_start if locked access is required
  1112. *
  1113. * @hal_soc: Opaque HAL SOC handle
  1114. * @hal_ring_hdl: Ring pointer (Source or Destination ring)
  1115. *
  1116. * This API doesn't implement any byte-order conversion on reading hp/tp.
  1117. * So, Use API only for those srngs for which the target writes hp/tp values to
  1118. * the DDR in the Host order.
  1119. *
  1120. * Return: 0 on success; error on failire
  1121. */
  1122. static inline int
  1123. hal_srng_access_start_unlocked(hal_soc_handle_t hal_soc_hdl,
  1124. hal_ring_handle_t hal_ring_hdl)
  1125. {
  1126. struct hal_srng *srng = (struct hal_srng *)hal_ring_hdl;
  1127. struct hal_soc *soc = (struct hal_soc *)hal_soc_hdl;
  1128. uint32_t *desc;
  1129. if (srng->ring_dir == HAL_SRNG_SRC_RING)
  1130. srng->u.src_ring.cached_tp =
  1131. *(volatile uint32_t *)(srng->u.src_ring.tp_addr);
  1132. else {
  1133. srng->u.dst_ring.cached_hp =
  1134. *(volatile uint32_t *)(srng->u.dst_ring.hp_addr);
  1135. if (srng->flags & HAL_SRNG_CACHED_DESC) {
  1136. desc = hal_srng_dst_peek(hal_soc_hdl, hal_ring_hdl);
  1137. if (qdf_likely(desc)) {
  1138. hal_mem_dma_cache_sync(soc, desc,
  1139. srng->entry_size);
  1140. qdf_prefetch(desc);
  1141. }
  1142. }
  1143. }
  1144. return 0;
  1145. }
  1146. /**
  1147. * hal_le_srng_access_start_unlocked_in_cpu_order - Start ring access
  1148. * (unlocked) with endianness correction.
  1149. * @hal_soc: Opaque HAL SOC handle
  1150. * @hal_ring_hdl: Ring pointer (Source or Destination ring)
  1151. *
  1152. * This API provides same functionally as hal_srng_access_start_unlocked()
  1153. * except that it converts the little-endian formatted hp/tp values to
  1154. * Host order on reading them. So, this API should only be used for those srngs
  1155. * for which the target always writes hp/tp values in little-endian order
  1156. * regardless of Host order.
  1157. *
  1158. * Also, this API doesn't take the lock. For locked access, use
  1159. * hal_srng_access_start/hal_le_srng_access_start_in_cpu_order.
  1160. *
  1161. * Return: 0 on success; error on failire
  1162. */
  1163. static inline int
  1164. hal_le_srng_access_start_unlocked_in_cpu_order(
  1165. hal_soc_handle_t hal_soc_hdl,
  1166. hal_ring_handle_t hal_ring_hdl)
  1167. {
  1168. struct hal_srng *srng = (struct hal_srng *)hal_ring_hdl;
  1169. struct hal_soc *soc = (struct hal_soc *)hal_soc_hdl;
  1170. uint32_t *desc;
  1171. if (srng->ring_dir == HAL_SRNG_SRC_RING)
  1172. srng->u.src_ring.cached_tp =
  1173. qdf_le32_to_cpu(*(volatile uint32_t *)
  1174. (srng->u.src_ring.tp_addr));
  1175. else {
  1176. srng->u.dst_ring.cached_hp =
  1177. qdf_le32_to_cpu(*(volatile uint32_t *)
  1178. (srng->u.dst_ring.hp_addr));
  1179. if (srng->flags & HAL_SRNG_CACHED_DESC) {
  1180. desc = hal_srng_dst_peek(hal_soc_hdl, hal_ring_hdl);
  1181. if (qdf_likely(desc)) {
  1182. hal_mem_dma_cache_sync(soc, desc,
  1183. srng->entry_size);
  1184. qdf_prefetch(desc);
  1185. }
  1186. }
  1187. }
  1188. return 0;
  1189. }
  1190. /**
  1191. * hal_srng_try_access_start - Try to start (locked) ring access
  1192. *
  1193. * @hal_soc: Opaque HAL SOC handle
  1194. * @hal_ring_hdl: Ring pointer (Source or Destination ring)
  1195. *
  1196. * Return: 0 on success; error on failure
  1197. */
  1198. static inline int hal_srng_try_access_start(hal_soc_handle_t hal_soc_hdl,
  1199. hal_ring_handle_t hal_ring_hdl)
  1200. {
  1201. struct hal_srng *srng = (struct hal_srng *)hal_ring_hdl;
  1202. if (qdf_unlikely(!hal_ring_hdl)) {
  1203. qdf_print("Error: Invalid hal_ring\n");
  1204. return -EINVAL;
  1205. }
  1206. if (!SRNG_TRY_LOCK(&(srng->lock)))
  1207. return -EINVAL;
  1208. return hal_srng_access_start_unlocked(hal_soc_hdl, hal_ring_hdl);
  1209. }
  1210. /**
  1211. * hal_srng_access_start - Start (locked) ring access
  1212. *
  1213. * @hal_soc: Opaque HAL SOC handle
  1214. * @hal_ring_hdl: Ring pointer (Source or Destination ring)
  1215. *
  1216. * This API doesn't implement any byte-order conversion on reading hp/tp.
  1217. * So, Use API only for those srngs for which the target writes hp/tp values to
  1218. * the DDR in the Host order.
  1219. *
  1220. * Return: 0 on success; error on failire
  1221. */
  1222. static inline int hal_srng_access_start(hal_soc_handle_t hal_soc_hdl,
  1223. hal_ring_handle_t hal_ring_hdl)
  1224. {
  1225. struct hal_srng *srng = (struct hal_srng *)hal_ring_hdl;
  1226. if (qdf_unlikely(!hal_ring_hdl)) {
  1227. qdf_print("Error: Invalid hal_ring\n");
  1228. return -EINVAL;
  1229. }
  1230. SRNG_LOCK(&(srng->lock));
  1231. return hal_srng_access_start_unlocked(hal_soc_hdl, hal_ring_hdl);
  1232. }
  1233. /**
  1234. * hal_le_srng_access_start_in_cpu_order - Start (locked) ring access with
  1235. * endianness correction
  1236. * @hal_soc: Opaque HAL SOC handle
  1237. * @hal_ring_hdl: Ring pointer (Source or Destination ring)
  1238. *
  1239. * This API provides same functionally as hal_srng_access_start()
  1240. * except that it converts the little-endian formatted hp/tp values to
  1241. * Host order on reading them. So, this API should only be used for those srngs
  1242. * for which the target always writes hp/tp values in little-endian order
  1243. * regardless of Host order.
  1244. *
  1245. * Return: 0 on success; error on failire
  1246. */
  1247. static inline int
  1248. hal_le_srng_access_start_in_cpu_order(
  1249. hal_soc_handle_t hal_soc_hdl,
  1250. hal_ring_handle_t hal_ring_hdl)
  1251. {
  1252. struct hal_srng *srng = (struct hal_srng *)hal_ring_hdl;
  1253. if (qdf_unlikely(!hal_ring_hdl)) {
  1254. qdf_print("Error: Invalid hal_ring\n");
  1255. return -EINVAL;
  1256. }
  1257. SRNG_LOCK(&(srng->lock));
  1258. return hal_le_srng_access_start_unlocked_in_cpu_order(
  1259. hal_soc_hdl, hal_ring_hdl);
  1260. }
  1261. /**
  1262. * hal_srng_dst_get_next - Get next entry from a destination ring
  1263. * @hal_soc: Opaque HAL SOC handle
  1264. * @hal_ring_hdl: Destination ring pointer
  1265. *
  1266. * Return: Opaque pointer for next ring entry; NULL on failure
  1267. */
  1268. static inline
  1269. void *hal_srng_dst_get_next(void *hal_soc,
  1270. hal_ring_handle_t hal_ring_hdl)
  1271. {
  1272. struct hal_srng *srng = (struct hal_srng *)hal_ring_hdl;
  1273. uint32_t *desc;
  1274. if (srng->u.dst_ring.tp == srng->u.dst_ring.cached_hp)
  1275. return NULL;
  1276. desc = &srng->ring_base_vaddr[srng->u.dst_ring.tp];
  1277. /* TODO: Using % is expensive, but we have to do this since
  1278. * size of some SRNG rings is not power of 2 (due to descriptor
  1279. * sizes). Need to create separate API for rings used
  1280. * per-packet, with sizes power of 2 (TCL2SW, REO2SW,
  1281. * SW2RXDMA and CE rings)
  1282. */
  1283. srng->u.dst_ring.tp = (srng->u.dst_ring.tp + srng->entry_size);
  1284. if (srng->u.dst_ring.tp == srng->ring_size)
  1285. srng->u.dst_ring.tp = 0;
  1286. if (srng->flags & HAL_SRNG_CACHED_DESC) {
  1287. struct hal_soc *soc = (struct hal_soc *)hal_soc;
  1288. uint32_t *desc_next;
  1289. uint32_t tp;
  1290. tp = srng->u.dst_ring.tp;
  1291. desc_next = &srng->ring_base_vaddr[srng->u.dst_ring.tp];
  1292. hal_mem_dma_cache_sync(soc, desc_next, srng->entry_size);
  1293. qdf_prefetch(desc_next);
  1294. }
  1295. return (void *)desc;
  1296. }
  1297. /**
  1298. * hal_srng_dst_get_next_cached - Get cached next entry
  1299. * @hal_soc: Opaque HAL SOC handle
  1300. * @hal_ring_hdl: Destination ring pointer
  1301. *
  1302. * Get next entry from a destination ring and move cached tail pointer
  1303. *
  1304. * Return: Opaque pointer for next ring entry; NULL on failure
  1305. */
  1306. static inline
  1307. void *hal_srng_dst_get_next_cached(void *hal_soc,
  1308. hal_ring_handle_t hal_ring_hdl)
  1309. {
  1310. struct hal_srng *srng = (struct hal_srng *)hal_ring_hdl;
  1311. uint32_t *desc;
  1312. uint32_t *desc_next;
  1313. if (srng->u.dst_ring.tp == srng->u.dst_ring.cached_hp)
  1314. return NULL;
  1315. desc = &srng->ring_base_vaddr[srng->u.dst_ring.tp];
  1316. /* TODO: Using % is expensive, but we have to do this since
  1317. * size of some SRNG rings is not power of 2 (due to descriptor
  1318. * sizes). Need to create separate API for rings used
  1319. * per-packet, with sizes power of 2 (TCL2SW, REO2SW,
  1320. * SW2RXDMA and CE rings)
  1321. */
  1322. srng->u.dst_ring.tp = (srng->u.dst_ring.tp + srng->entry_size);
  1323. if (srng->u.dst_ring.tp == srng->ring_size)
  1324. srng->u.dst_ring.tp = 0;
  1325. desc_next = &srng->ring_base_vaddr[srng->u.dst_ring.tp];
  1326. qdf_prefetch(desc_next);
  1327. return (void *)desc;
  1328. }
  1329. /**
  1330. * hal_srng_dst_get_next_hp - Get next entry from a destination ring and move
  1331. * cached head pointer
  1332. *
  1333. * @hal_soc: Opaque HAL SOC handle
  1334. * @hal_ring_hdl: Destination ring pointer
  1335. *
  1336. * Return: Opaque pointer for next ring entry; NULL on failire
  1337. */
  1338. static inline void *
  1339. hal_srng_dst_get_next_hp(hal_soc_handle_t hal_soc_hdl,
  1340. hal_ring_handle_t hal_ring_hdl)
  1341. {
  1342. struct hal_srng *srng = (struct hal_srng *)hal_ring_hdl;
  1343. uint32_t *desc;
  1344. /* TODO: Using % is expensive, but we have to do this since
  1345. * size of some SRNG rings is not power of 2 (due to descriptor
  1346. * sizes). Need to create separate API for rings used
  1347. * per-packet, with sizes power of 2 (TCL2SW, REO2SW,
  1348. * SW2RXDMA and CE rings)
  1349. */
  1350. uint32_t next_hp = (srng->u.dst_ring.cached_hp + srng->entry_size) %
  1351. srng->ring_size;
  1352. if (next_hp != srng->u.dst_ring.tp) {
  1353. desc = &(srng->ring_base_vaddr[srng->u.dst_ring.cached_hp]);
  1354. srng->u.dst_ring.cached_hp = next_hp;
  1355. return (void *)desc;
  1356. }
  1357. return NULL;
  1358. }
  1359. /**
  1360. * hal_srng_dst_peek_sync - Check if there are any entries in the ring (peek)
  1361. * @hal_soc: Opaque HAL SOC handle
  1362. * @hal_ring_hdl: Destination ring pointer
  1363. *
  1364. * Sync cached head pointer with HW.
  1365. * Caller takes responsibility for any locking needs.
  1366. *
  1367. * Return: Opaque pointer for next ring entry; NULL on failire
  1368. */
  1369. static inline
  1370. void *hal_srng_dst_peek_sync(hal_soc_handle_t hal_soc_hdl,
  1371. hal_ring_handle_t hal_ring_hdl)
  1372. {
  1373. struct hal_srng *srng = (struct hal_srng *)hal_ring_hdl;
  1374. srng->u.dst_ring.cached_hp =
  1375. *(volatile uint32_t *)(srng->u.dst_ring.hp_addr);
  1376. if (srng->u.dst_ring.tp != srng->u.dst_ring.cached_hp)
  1377. return (void *)(&(srng->ring_base_vaddr[srng->u.dst_ring.tp]));
  1378. return NULL;
  1379. }
  1380. /**
  1381. * hal_srng_dst_peek_sync_locked - Peek for any entries in the ring
  1382. * @hal_soc: Opaque HAL SOC handle
  1383. * @hal_ring_hdl: Destination ring pointer
  1384. *
  1385. * Sync cached head pointer with HW.
  1386. * This function takes up SRNG_LOCK. Should not be called with SRNG lock held.
  1387. *
  1388. * Return: Opaque pointer for next ring entry; NULL on failire
  1389. */
  1390. static inline
  1391. void *hal_srng_dst_peek_sync_locked(hal_soc_handle_t hal_soc_hdl,
  1392. hal_ring_handle_t hal_ring_hdl)
  1393. {
  1394. struct hal_srng *srng = (struct hal_srng *)hal_ring_hdl;
  1395. void *ring_desc_ptr = NULL;
  1396. if (qdf_unlikely(!hal_ring_hdl)) {
  1397. qdf_print("Error: Invalid hal_ring\n");
  1398. return NULL;
  1399. }
  1400. SRNG_LOCK(&srng->lock);
  1401. ring_desc_ptr = hal_srng_dst_peek_sync(hal_soc_hdl, hal_ring_hdl);
  1402. SRNG_UNLOCK(&srng->lock);
  1403. return ring_desc_ptr;
  1404. }
  1405. /**
  1406. * hal_srng_dst_num_valid - Returns number of valid entries (to be processed
  1407. * by SW) in destination ring
  1408. *
  1409. * @hal_soc: Opaque HAL SOC handle
  1410. * @hal_ring_hdl: Destination ring pointer
  1411. * @sync_hw_ptr: Sync cached head pointer with HW
  1412. *
  1413. */
  1414. static inline
  1415. uint32_t hal_srng_dst_num_valid(void *hal_soc,
  1416. hal_ring_handle_t hal_ring_hdl,
  1417. int sync_hw_ptr)
  1418. {
  1419. struct hal_srng *srng = (struct hal_srng *)hal_ring_hdl;
  1420. uint32_t hp;
  1421. uint32_t tp = srng->u.dst_ring.tp;
  1422. if (sync_hw_ptr) {
  1423. hp = *(volatile uint32_t *)(srng->u.dst_ring.hp_addr);
  1424. srng->u.dst_ring.cached_hp = hp;
  1425. } else {
  1426. hp = srng->u.dst_ring.cached_hp;
  1427. }
  1428. if (hp >= tp)
  1429. return (hp - tp) / srng->entry_size;
  1430. return (srng->ring_size - tp + hp) / srng->entry_size;
  1431. }
  1432. /**
  1433. * hal_srng_dst_inv_cached_descs - API to invalidate descriptors in batch mode
  1434. * @hal_soc: Opaque HAL SOC handle
  1435. * @hal_ring_hdl: Destination ring pointer
  1436. * @entry_count: Number of descriptors to be invalidated
  1437. *
  1438. * Invalidates a set of cached descriptors starting from tail to
  1439. * provided count worth
  1440. *
  1441. * Return - None
  1442. */
  1443. static inline void hal_srng_dst_inv_cached_descs(void *hal_soc,
  1444. hal_ring_handle_t hal_ring_hdl,
  1445. uint32_t entry_count)
  1446. {
  1447. struct hal_srng *srng = (struct hal_srng *)hal_ring_hdl;
  1448. uint32_t hp = srng->u.dst_ring.cached_hp;
  1449. uint32_t tp = srng->u.dst_ring.tp;
  1450. uint32_t sync_p = 0;
  1451. /*
  1452. * If SRNG does not have cached descriptors this
  1453. * API call should be a no op
  1454. */
  1455. if (!(srng->flags & HAL_SRNG_CACHED_DESC))
  1456. return;
  1457. if (qdf_unlikely(entry_count == 0))
  1458. return;
  1459. sync_p = (entry_count - 1) * srng->entry_size;
  1460. if (hp > tp) {
  1461. qdf_nbuf_dma_inv_range(&srng->ring_base_vaddr[tp],
  1462. &srng->ring_base_vaddr[tp + sync_p]
  1463. + (srng->entry_size * sizeof(uint32_t)));
  1464. } else {
  1465. /*
  1466. * We have wrapped around
  1467. */
  1468. uint32_t wrap_cnt = ((srng->ring_size - tp) / srng->entry_size);
  1469. if (entry_count <= wrap_cnt) {
  1470. qdf_nbuf_dma_inv_range(&srng->ring_base_vaddr[tp],
  1471. &srng->ring_base_vaddr[tp + sync_p] +
  1472. (srng->entry_size * sizeof(uint32_t)));
  1473. return;
  1474. }
  1475. entry_count -= wrap_cnt;
  1476. sync_p = (entry_count - 1) * srng->entry_size;
  1477. qdf_nbuf_dma_inv_range(&srng->ring_base_vaddr[tp],
  1478. &srng->ring_base_vaddr[srng->ring_size - srng->entry_size] +
  1479. (srng->entry_size * sizeof(uint32_t)));
  1480. qdf_nbuf_dma_inv_range(&srng->ring_base_vaddr[0],
  1481. &srng->ring_base_vaddr[sync_p]
  1482. + (srng->entry_size * sizeof(uint32_t)));
  1483. }
  1484. }
  1485. /**
  1486. * hal_srng_dst_num_valid_locked - Returns num valid entries to be processed
  1487. *
  1488. * @hal_soc: Opaque HAL SOC handle
  1489. * @hal_ring_hdl: Destination ring pointer
  1490. * @sync_hw_ptr: Sync cached head pointer with HW
  1491. *
  1492. * Returns number of valid entries to be processed by the host driver. The
  1493. * function takes up SRNG lock.
  1494. *
  1495. * Return: Number of valid destination entries
  1496. */
  1497. static inline uint32_t
  1498. hal_srng_dst_num_valid_locked(hal_soc_handle_t hal_soc,
  1499. hal_ring_handle_t hal_ring_hdl,
  1500. int sync_hw_ptr)
  1501. {
  1502. uint32_t num_valid;
  1503. struct hal_srng *srng = (struct hal_srng *)hal_ring_hdl;
  1504. SRNG_LOCK(&srng->lock);
  1505. num_valid = hal_srng_dst_num_valid(hal_soc, hal_ring_hdl, sync_hw_ptr);
  1506. SRNG_UNLOCK(&srng->lock);
  1507. return num_valid;
  1508. }
  1509. /**
  1510. * hal_srng_sync_cachedhp - sync cachehp pointer from hw hp
  1511. *
  1512. * @hal_soc: Opaque HAL SOC handle
  1513. * @hal_ring_hdl: Destination ring pointer
  1514. *
  1515. */
  1516. static inline
  1517. void hal_srng_sync_cachedhp(void *hal_soc,
  1518. hal_ring_handle_t hal_ring_hdl)
  1519. {
  1520. struct hal_srng *srng = (struct hal_srng *)hal_ring_hdl;
  1521. uint32_t hp;
  1522. hp = *(volatile uint32_t *)(srng->u.dst_ring.hp_addr);
  1523. srng->u.dst_ring.cached_hp = hp;
  1524. }
  1525. /**
  1526. * hal_srng_src_reap_next - Reap next entry from a source ring and move reap
  1527. * pointer. This can be used to release any buffers associated with completed
  1528. * ring entries. Note that this should not be used for posting new descriptor
  1529. * entries. Posting of new entries should be done only using
  1530. * hal_srng_src_get_next_reaped when this function is used for reaping.
  1531. *
  1532. * @hal_soc: Opaque HAL SOC handle
  1533. * @hal_ring_hdl: Source ring pointer
  1534. *
  1535. * Return: Opaque pointer for next ring entry; NULL on failire
  1536. */
  1537. static inline void *
  1538. hal_srng_src_reap_next(void *hal_soc, hal_ring_handle_t hal_ring_hdl)
  1539. {
  1540. struct hal_srng *srng = (struct hal_srng *)hal_ring_hdl;
  1541. uint32_t *desc;
  1542. /* TODO: Using % is expensive, but we have to do this since
  1543. * size of some SRNG rings is not power of 2 (due to descriptor
  1544. * sizes). Need to create separate API for rings used
  1545. * per-packet, with sizes power of 2 (TCL2SW, REO2SW,
  1546. * SW2RXDMA and CE rings)
  1547. */
  1548. uint32_t next_reap_hp = (srng->u.src_ring.reap_hp + srng->entry_size) %
  1549. srng->ring_size;
  1550. if (next_reap_hp != srng->u.src_ring.cached_tp) {
  1551. desc = &(srng->ring_base_vaddr[next_reap_hp]);
  1552. srng->u.src_ring.reap_hp = next_reap_hp;
  1553. return (void *)desc;
  1554. }
  1555. return NULL;
  1556. }
  1557. /**
  1558. * hal_srng_src_get_next_reaped - Get next entry from a source ring that is
  1559. * already reaped using hal_srng_src_reap_next, for posting new entries to
  1560. * the ring
  1561. *
  1562. * @hal_soc: Opaque HAL SOC handle
  1563. * @hal_ring_hdl: Source ring pointer
  1564. *
  1565. * Return: Opaque pointer for next (reaped) source ring entry; NULL on failire
  1566. */
  1567. static inline void *
  1568. hal_srng_src_get_next_reaped(void *hal_soc, hal_ring_handle_t hal_ring_hdl)
  1569. {
  1570. struct hal_srng *srng = (struct hal_srng *)hal_ring_hdl;
  1571. uint32_t *desc;
  1572. if (srng->u.src_ring.hp != srng->u.src_ring.reap_hp) {
  1573. desc = &(srng->ring_base_vaddr[srng->u.src_ring.hp]);
  1574. srng->u.src_ring.hp = (srng->u.src_ring.hp + srng->entry_size) %
  1575. srng->ring_size;
  1576. return (void *)desc;
  1577. }
  1578. return NULL;
  1579. }
  1580. /**
  1581. * hal_srng_src_pending_reap_next - Reap next entry from a source ring and
  1582. * move reap pointer. This API is used in detach path to release any buffers
  1583. * associated with ring entries which are pending reap.
  1584. *
  1585. * @hal_soc: Opaque HAL SOC handle
  1586. * @hal_ring_hdl: Source ring pointer
  1587. *
  1588. * Return: Opaque pointer for next ring entry; NULL on failire
  1589. */
  1590. static inline void *
  1591. hal_srng_src_pending_reap_next(void *hal_soc, hal_ring_handle_t hal_ring_hdl)
  1592. {
  1593. struct hal_srng *srng = (struct hal_srng *)hal_ring_hdl;
  1594. uint32_t *desc;
  1595. uint32_t next_reap_hp = (srng->u.src_ring.reap_hp + srng->entry_size) %
  1596. srng->ring_size;
  1597. if (next_reap_hp != srng->u.src_ring.hp) {
  1598. desc = &(srng->ring_base_vaddr[next_reap_hp]);
  1599. srng->u.src_ring.reap_hp = next_reap_hp;
  1600. return (void *)desc;
  1601. }
  1602. return NULL;
  1603. }
  1604. /**
  1605. * hal_srng_src_done_val -
  1606. *
  1607. * @hal_soc: Opaque HAL SOC handle
  1608. * @hal_ring_hdl: Source ring pointer
  1609. *
  1610. * Return: Opaque pointer for next ring entry; NULL on failire
  1611. */
  1612. static inline uint32_t
  1613. hal_srng_src_done_val(void *hal_soc, hal_ring_handle_t hal_ring_hdl)
  1614. {
  1615. struct hal_srng *srng = (struct hal_srng *)hal_ring_hdl;
  1616. /* TODO: Using % is expensive, but we have to do this since
  1617. * size of some SRNG rings is not power of 2 (due to descriptor
  1618. * sizes). Need to create separate API for rings used
  1619. * per-packet, with sizes power of 2 (TCL2SW, REO2SW,
  1620. * SW2RXDMA and CE rings)
  1621. */
  1622. uint32_t next_reap_hp = (srng->u.src_ring.reap_hp + srng->entry_size) %
  1623. srng->ring_size;
  1624. if (next_reap_hp == srng->u.src_ring.cached_tp)
  1625. return 0;
  1626. if (srng->u.src_ring.cached_tp > next_reap_hp)
  1627. return (srng->u.src_ring.cached_tp - next_reap_hp) /
  1628. srng->entry_size;
  1629. else
  1630. return ((srng->ring_size - next_reap_hp) +
  1631. srng->u.src_ring.cached_tp) / srng->entry_size;
  1632. }
  1633. /**
  1634. * hal_get_entrysize_from_srng() - Retrieve ring entry size
  1635. * @hal_ring_hdl: Source ring pointer
  1636. *
  1637. * Return: uint8_t
  1638. */
  1639. static inline
  1640. uint8_t hal_get_entrysize_from_srng(hal_ring_handle_t hal_ring_hdl)
  1641. {
  1642. struct hal_srng *srng = (struct hal_srng *)hal_ring_hdl;
  1643. return srng->entry_size;
  1644. }
  1645. /**
  1646. * hal_get_sw_hptp - Get SW head and tail pointer location for any ring
  1647. * @hal_soc: Opaque HAL SOC handle
  1648. * @hal_ring_hdl: Source ring pointer
  1649. * @tailp: Tail Pointer
  1650. * @headp: Head Pointer
  1651. *
  1652. * Return: Update tail pointer and head pointer in arguments.
  1653. */
  1654. static inline
  1655. void hal_get_sw_hptp(void *hal_soc, hal_ring_handle_t hal_ring_hdl,
  1656. uint32_t *tailp, uint32_t *headp)
  1657. {
  1658. struct hal_srng *srng = (struct hal_srng *)hal_ring_hdl;
  1659. if (srng->ring_dir == HAL_SRNG_SRC_RING) {
  1660. *headp = srng->u.src_ring.hp;
  1661. *tailp = *srng->u.src_ring.tp_addr;
  1662. } else {
  1663. *tailp = srng->u.dst_ring.tp;
  1664. *headp = *srng->u.dst_ring.hp_addr;
  1665. }
  1666. }
  1667. /**
  1668. * hal_srng_src_get_next - Get next entry from a source ring and move cached tail pointer
  1669. *
  1670. * @hal_soc: Opaque HAL SOC handle
  1671. * @hal_ring_hdl: Source ring pointer
  1672. *
  1673. * Return: Opaque pointer for next ring entry; NULL on failire
  1674. */
  1675. static inline
  1676. void *hal_srng_src_get_next(void *hal_soc,
  1677. hal_ring_handle_t hal_ring_hdl)
  1678. {
  1679. struct hal_srng *srng = (struct hal_srng *)hal_ring_hdl;
  1680. uint32_t *desc;
  1681. /* TODO: Using % is expensive, but we have to do this since
  1682. * size of some SRNG rings is not power of 2 (due to descriptor
  1683. * sizes). Need to create separate API for rings used
  1684. * per-packet, with sizes power of 2 (TCL2SW, REO2SW,
  1685. * SW2RXDMA and CE rings)
  1686. */
  1687. uint32_t next_hp = (srng->u.src_ring.hp + srng->entry_size) %
  1688. srng->ring_size;
  1689. if (next_hp != srng->u.src_ring.cached_tp) {
  1690. desc = &(srng->ring_base_vaddr[srng->u.src_ring.hp]);
  1691. srng->u.src_ring.hp = next_hp;
  1692. /* TODO: Since reap function is not used by all rings, we can
  1693. * remove the following update of reap_hp in this function
  1694. * if we can ensure that only hal_srng_src_get_next_reaped
  1695. * is used for the rings requiring reap functionality
  1696. */
  1697. srng->u.src_ring.reap_hp = next_hp;
  1698. return (void *)desc;
  1699. }
  1700. return NULL;
  1701. }
  1702. /**
  1703. * hal_srng_src_peek_n_get_next - Get next entry from a ring without
  1704. * moving head pointer.
  1705. * hal_srng_src_get_next should be called subsequently to move the head pointer
  1706. *
  1707. * @hal_soc: Opaque HAL SOC handle
  1708. * @hal_ring_hdl: Source ring pointer
  1709. *
  1710. * Return: Opaque pointer for next ring entry; NULL on failire
  1711. */
  1712. static inline
  1713. void *hal_srng_src_peek_n_get_next(hal_soc_handle_t hal_soc_hdl,
  1714. hal_ring_handle_t hal_ring_hdl)
  1715. {
  1716. struct hal_srng *srng = (struct hal_srng *)hal_ring_hdl;
  1717. uint32_t *desc;
  1718. /* TODO: Using % is expensive, but we have to do this since
  1719. * size of some SRNG rings is not power of 2 (due to descriptor
  1720. * sizes). Need to create separate API for rings used
  1721. * per-packet, with sizes power of 2 (TCL2SW, REO2SW,
  1722. * SW2RXDMA and CE rings)
  1723. */
  1724. if (((srng->u.src_ring.hp + srng->entry_size) %
  1725. srng->ring_size) != srng->u.src_ring.cached_tp) {
  1726. desc = &(srng->ring_base_vaddr[(srng->u.src_ring.hp +
  1727. srng->entry_size) %
  1728. srng->ring_size]);
  1729. return (void *)desc;
  1730. }
  1731. return NULL;
  1732. }
  1733. /**
  1734. * hal_srng_src_peek_n_get_next_next - Get next to next, i.e HP + 2 entry
  1735. * from a ring without moving head pointer.
  1736. *
  1737. * @hal_soc: Opaque HAL SOC handle
  1738. * @hal_ring_hdl: Source ring pointer
  1739. *
  1740. * Return: Opaque pointer for next to next ring entry; NULL on failire
  1741. */
  1742. static inline
  1743. void *hal_srng_src_peek_n_get_next_next(hal_soc_handle_t hal_soc_hdl,
  1744. hal_ring_handle_t hal_ring_hdl)
  1745. {
  1746. struct hal_srng *srng = (struct hal_srng *)hal_ring_hdl;
  1747. uint32_t *desc;
  1748. /* TODO: Using % is expensive, but we have to do this since
  1749. * size of some SRNG rings is not power of 2 (due to descriptor
  1750. * sizes). Need to create separate API for rings used
  1751. * per-packet, with sizes power of 2 (TCL2SW, REO2SW,
  1752. * SW2RXDMA and CE rings)
  1753. */
  1754. if ((((srng->u.src_ring.hp + (srng->entry_size)) %
  1755. srng->ring_size) != srng->u.src_ring.cached_tp) &&
  1756. (((srng->u.src_ring.hp + (srng->entry_size * 2)) %
  1757. srng->ring_size) != srng->u.src_ring.cached_tp)) {
  1758. desc = &(srng->ring_base_vaddr[(srng->u.src_ring.hp +
  1759. (srng->entry_size * 2)) %
  1760. srng->ring_size]);
  1761. return (void *)desc;
  1762. }
  1763. return NULL;
  1764. }
  1765. /**
  1766. * hal_srng_src_get_cur_hp_n_move_next () - API returns current hp
  1767. * and move hp to next in src ring
  1768. *
  1769. * Usage: This API should only be used at init time replenish.
  1770. *
  1771. * @hal_soc_hdl: HAL soc handle
  1772. * @hal_ring_hdl: Source ring pointer
  1773. *
  1774. */
  1775. static inline void *
  1776. hal_srng_src_get_cur_hp_n_move_next(hal_soc_handle_t hal_soc_hdl,
  1777. hal_ring_handle_t hal_ring_hdl)
  1778. {
  1779. struct hal_srng *srng = (struct hal_srng *)hal_ring_hdl;
  1780. uint32_t *cur_desc = NULL;
  1781. uint32_t next_hp;
  1782. cur_desc = &srng->ring_base_vaddr[(srng->u.src_ring.hp)];
  1783. next_hp = (srng->u.src_ring.hp + srng->entry_size) %
  1784. srng->ring_size;
  1785. if (next_hp != srng->u.src_ring.cached_tp)
  1786. srng->u.src_ring.hp = next_hp;
  1787. return (void *)cur_desc;
  1788. }
  1789. /**
  1790. * hal_srng_src_num_avail - Returns number of available entries in src ring
  1791. *
  1792. * @hal_soc: Opaque HAL SOC handle
  1793. * @hal_ring_hdl: Source ring pointer
  1794. * @sync_hw_ptr: Sync cached tail pointer with HW
  1795. *
  1796. */
  1797. static inline uint32_t
  1798. hal_srng_src_num_avail(void *hal_soc,
  1799. hal_ring_handle_t hal_ring_hdl, int sync_hw_ptr)
  1800. {
  1801. struct hal_srng *srng = (struct hal_srng *)hal_ring_hdl;
  1802. uint32_t tp;
  1803. uint32_t hp = srng->u.src_ring.hp;
  1804. if (sync_hw_ptr) {
  1805. tp = *(srng->u.src_ring.tp_addr);
  1806. srng->u.src_ring.cached_tp = tp;
  1807. } else {
  1808. tp = srng->u.src_ring.cached_tp;
  1809. }
  1810. if (tp > hp)
  1811. return ((tp - hp) / srng->entry_size) - 1;
  1812. else
  1813. return ((srng->ring_size - hp + tp) / srng->entry_size) - 1;
  1814. }
  1815. /**
  1816. * hal_srng_access_end_unlocked - End ring access (unlocked) - update cached
  1817. * ring head/tail pointers to HW.
  1818. *
  1819. * @hal_soc: Opaque HAL SOC handle
  1820. * @hal_ring_hdl: Ring pointer (Source or Destination ring)
  1821. *
  1822. * The target expects cached head/tail pointer to be updated to the
  1823. * shared location in the little-endian order, This API ensures that.
  1824. * This API should be used only if hal_srng_access_start_unlocked was used to
  1825. * start ring access
  1826. *
  1827. * Return: None
  1828. */
  1829. static inline void
  1830. hal_srng_access_end_unlocked(void *hal_soc, hal_ring_handle_t hal_ring_hdl)
  1831. {
  1832. struct hal_srng *srng = (struct hal_srng *)hal_ring_hdl;
  1833. /* TODO: See if we need a write memory barrier here */
  1834. if (srng->flags & HAL_SRNG_LMAC_RING) {
  1835. /* For LMAC rings, ring pointer updates are done through FW and
  1836. * hence written to a shared memory location that is read by FW
  1837. */
  1838. if (srng->ring_dir == HAL_SRNG_SRC_RING) {
  1839. *srng->u.src_ring.hp_addr =
  1840. qdf_cpu_to_le32(srng->u.src_ring.hp);
  1841. } else {
  1842. *srng->u.dst_ring.tp_addr =
  1843. qdf_cpu_to_le32(srng->u.dst_ring.tp);
  1844. }
  1845. } else {
  1846. if (srng->ring_dir == HAL_SRNG_SRC_RING)
  1847. hal_srng_write_address_32_mb(hal_soc,
  1848. srng,
  1849. srng->u.src_ring.hp_addr,
  1850. srng->u.src_ring.hp);
  1851. else
  1852. hal_srng_write_address_32_mb(hal_soc,
  1853. srng,
  1854. srng->u.dst_ring.tp_addr,
  1855. srng->u.dst_ring.tp);
  1856. }
  1857. }
  1858. /* hal_srng_access_end_unlocked already handles endianness conversion,
  1859. * use the same.
  1860. */
  1861. #define hal_le_srng_access_end_unlocked_in_cpu_order \
  1862. hal_srng_access_end_unlocked
  1863. /**
  1864. * hal_srng_access_end - Unlock ring access and update cached ring head/tail
  1865. * pointers to HW
  1866. *
  1867. * @hal_soc: Opaque HAL SOC handle
  1868. * @hal_ring_hdl: Ring pointer (Source or Destination ring)
  1869. *
  1870. * The target expects cached head/tail pointer to be updated to the
  1871. * shared location in the little-endian order, This API ensures that.
  1872. * This API should be used only if hal_srng_access_start was used to
  1873. * start ring access
  1874. *
  1875. * Return: 0 on success; error on failire
  1876. */
  1877. static inline void
  1878. hal_srng_access_end(void *hal_soc, hal_ring_handle_t hal_ring_hdl)
  1879. {
  1880. struct hal_srng *srng = (struct hal_srng *)hal_ring_hdl;
  1881. if (qdf_unlikely(!hal_ring_hdl)) {
  1882. qdf_print("Error: Invalid hal_ring\n");
  1883. return;
  1884. }
  1885. hal_srng_access_end_unlocked(hal_soc, hal_ring_hdl);
  1886. SRNG_UNLOCK(&(srng->lock));
  1887. }
  1888. /* hal_srng_access_end already handles endianness conversion, so use the same */
  1889. #define hal_le_srng_access_end_in_cpu_order \
  1890. hal_srng_access_end
  1891. /**
  1892. * hal_srng_access_end_reap - Unlock ring access
  1893. * This should be used only if hal_srng_access_start to start ring access
  1894. * and should be used only while reaping SRC ring completions
  1895. *
  1896. * @hal_soc: Opaque HAL SOC handle
  1897. * @hal_ring_hdl: Ring pointer (Source or Destination ring)
  1898. *
  1899. * Return: 0 on success; error on failire
  1900. */
  1901. static inline void
  1902. hal_srng_access_end_reap(void *hal_soc, hal_ring_handle_t hal_ring_hdl)
  1903. {
  1904. struct hal_srng *srng = (struct hal_srng *)hal_ring_hdl;
  1905. SRNG_UNLOCK(&(srng->lock));
  1906. }
  1907. /* TODO: Check if the following definitions is available in HW headers */
  1908. #define WBM_IDLE_SCATTER_BUF_SIZE 32704
  1909. #define NUM_MPDUS_PER_LINK_DESC 6
  1910. #define NUM_MSDUS_PER_LINK_DESC 7
  1911. #define REO_QUEUE_DESC_ALIGN 128
  1912. #define LINK_DESC_ALIGN 128
  1913. #define ADDRESS_MATCH_TAG_VAL 0x5
  1914. /* Number of mpdu link pointers is 9 in case of TX_MPDU_QUEUE_HEAD and 14 in
  1915. * of TX_MPDU_QUEUE_EXT. We are defining a common average count here
  1916. */
  1917. #define NUM_MPDU_LINKS_PER_QUEUE_DESC 12
  1918. /* TODO: Check with HW team on the scatter buffer size supported. As per WBM
  1919. * MLD, scatter_buffer_size in IDLE_LIST_CONTROL register is 9 bits and size
  1920. * should be specified in 16 word units. But the number of bits defined for
  1921. * this field in HW header files is 5.
  1922. */
  1923. #define WBM_IDLE_SCATTER_BUF_NEXT_PTR_SIZE 8
  1924. /**
  1925. * hal_idle_list_scatter_buf_size - Get the size of each scatter buffer
  1926. * in an idle list
  1927. *
  1928. * @hal_soc: Opaque HAL SOC handle
  1929. *
  1930. */
  1931. static inline
  1932. uint32_t hal_idle_list_scatter_buf_size(hal_soc_handle_t hal_soc_hdl)
  1933. {
  1934. return WBM_IDLE_SCATTER_BUF_SIZE;
  1935. }
  1936. /**
  1937. * hal_get_link_desc_size - Get the size of each link descriptor
  1938. *
  1939. * @hal_soc: Opaque HAL SOC handle
  1940. *
  1941. */
  1942. static inline uint32_t hal_get_link_desc_size(hal_soc_handle_t hal_soc_hdl)
  1943. {
  1944. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  1945. if (!hal_soc || !hal_soc->ops) {
  1946. qdf_print("Error: Invalid ops\n");
  1947. QDF_BUG(0);
  1948. return -EINVAL;
  1949. }
  1950. if (!hal_soc->ops->hal_get_link_desc_size) {
  1951. qdf_print("Error: Invalid function pointer\n");
  1952. QDF_BUG(0);
  1953. return -EINVAL;
  1954. }
  1955. return hal_soc->ops->hal_get_link_desc_size();
  1956. }
  1957. /**
  1958. * hal_get_link_desc_align - Get the required start address alignment for
  1959. * link descriptors
  1960. *
  1961. * @hal_soc: Opaque HAL SOC handle
  1962. *
  1963. */
  1964. static inline
  1965. uint32_t hal_get_link_desc_align(hal_soc_handle_t hal_soc_hdl)
  1966. {
  1967. return LINK_DESC_ALIGN;
  1968. }
  1969. /**
  1970. * hal_num_mpdus_per_link_desc - Get number of mpdus each link desc can hold
  1971. *
  1972. * @hal_soc: Opaque HAL SOC handle
  1973. *
  1974. */
  1975. static inline
  1976. uint32_t hal_num_mpdus_per_link_desc(hal_soc_handle_t hal_soc_hdl)
  1977. {
  1978. return NUM_MPDUS_PER_LINK_DESC;
  1979. }
  1980. /**
  1981. * hal_num_msdus_per_link_desc - Get number of msdus each link desc can hold
  1982. *
  1983. * @hal_soc: Opaque HAL SOC handle
  1984. *
  1985. */
  1986. static inline
  1987. uint32_t hal_num_msdus_per_link_desc(hal_soc_handle_t hal_soc_hdl)
  1988. {
  1989. return NUM_MSDUS_PER_LINK_DESC;
  1990. }
  1991. /**
  1992. * hal_num_mpdu_links_per_queue_desc - Get number of mpdu links each queue
  1993. * descriptor can hold
  1994. *
  1995. * @hal_soc: Opaque HAL SOC handle
  1996. *
  1997. */
  1998. static inline
  1999. uint32_t hal_num_mpdu_links_per_queue_desc(hal_soc_handle_t hal_soc_hdl)
  2000. {
  2001. return NUM_MPDU_LINKS_PER_QUEUE_DESC;
  2002. }
  2003. /**
  2004. * hal_idle_list_scatter_buf_num_entries - Get the number of link desc entries
  2005. * that the given buffer size
  2006. *
  2007. * @hal_soc: Opaque HAL SOC handle
  2008. * @scatter_buf_size: Size of scatter buffer
  2009. *
  2010. */
  2011. static inline
  2012. uint32_t hal_idle_scatter_buf_num_entries(hal_soc_handle_t hal_soc_hdl,
  2013. uint32_t scatter_buf_size)
  2014. {
  2015. return (scatter_buf_size - WBM_IDLE_SCATTER_BUF_NEXT_PTR_SIZE) /
  2016. hal_srng_get_entrysize(hal_soc_hdl, WBM_IDLE_LINK);
  2017. }
  2018. /**
  2019. * hal_idle_list_num_scatter_bufs - Get the number of sctater buffer
  2020. * each given buffer size
  2021. *
  2022. * @hal_soc: Opaque HAL SOC handle
  2023. * @total_mem: size of memory to be scattered
  2024. * @scatter_buf_size: Size of scatter buffer
  2025. *
  2026. */
  2027. static inline
  2028. uint32_t hal_idle_list_num_scatter_bufs(hal_soc_handle_t hal_soc_hdl,
  2029. uint32_t total_mem,
  2030. uint32_t scatter_buf_size)
  2031. {
  2032. uint8_t rem = (total_mem % (scatter_buf_size -
  2033. WBM_IDLE_SCATTER_BUF_NEXT_PTR_SIZE)) ? 1 : 0;
  2034. uint32_t num_scatter_bufs = (total_mem / (scatter_buf_size -
  2035. WBM_IDLE_SCATTER_BUF_NEXT_PTR_SIZE)) + rem;
  2036. return num_scatter_bufs;
  2037. }
  2038. enum hal_pn_type {
  2039. HAL_PN_NONE,
  2040. HAL_PN_WPA,
  2041. HAL_PN_WAPI_EVEN,
  2042. HAL_PN_WAPI_UNEVEN,
  2043. };
  2044. #define HAL_RX_MAX_BA_WINDOW 256
  2045. /**
  2046. * hal_get_reo_qdesc_align - Get start address alignment for reo
  2047. * queue descriptors
  2048. *
  2049. * @hal_soc: Opaque HAL SOC handle
  2050. *
  2051. */
  2052. static inline
  2053. uint32_t hal_get_reo_qdesc_align(hal_soc_handle_t hal_soc_hdl)
  2054. {
  2055. return REO_QUEUE_DESC_ALIGN;
  2056. }
  2057. /**
  2058. * hal_reo_qdesc_setup - Setup HW REO queue descriptor
  2059. *
  2060. * @hal_soc: Opaque HAL SOC handle
  2061. * @ba_window_size: BlockAck window size
  2062. * @start_seq: Starting sequence number
  2063. * @hw_qdesc_vaddr: Virtual address of REO queue descriptor memory
  2064. * @hw_qdesc_paddr: Physical address of REO queue descriptor memory
  2065. * @pn_type: PN type (one of the types defined in 'enum hal_pn_type')
  2066. *
  2067. */
  2068. void hal_reo_qdesc_setup(hal_soc_handle_t hal_soc_hdl,
  2069. int tid, uint32_t ba_window_size,
  2070. uint32_t start_seq, void *hw_qdesc_vaddr,
  2071. qdf_dma_addr_t hw_qdesc_paddr,
  2072. int pn_type);
  2073. /**
  2074. * hal_srng_get_hp_addr - Get head pointer physical address
  2075. *
  2076. * @hal_soc: Opaque HAL SOC handle
  2077. * @hal_ring_hdl: Ring pointer (Source or Destination ring)
  2078. *
  2079. */
  2080. static inline qdf_dma_addr_t
  2081. hal_srng_get_hp_addr(void *hal_soc,
  2082. hal_ring_handle_t hal_ring_hdl)
  2083. {
  2084. struct hal_srng *srng = (struct hal_srng *)hal_ring_hdl;
  2085. struct hal_soc *hal = (struct hal_soc *)hal_soc;
  2086. if (srng->ring_dir == HAL_SRNG_SRC_RING) {
  2087. return hal->shadow_wrptr_mem_paddr +
  2088. ((unsigned long)(srng->u.src_ring.hp_addr) -
  2089. (unsigned long)(hal->shadow_wrptr_mem_vaddr));
  2090. } else {
  2091. return hal->shadow_rdptr_mem_paddr +
  2092. ((unsigned long)(srng->u.dst_ring.hp_addr) -
  2093. (unsigned long)(hal->shadow_rdptr_mem_vaddr));
  2094. }
  2095. }
  2096. /**
  2097. * hal_srng_get_tp_addr - Get tail pointer physical address
  2098. *
  2099. * @hal_soc: Opaque HAL SOC handle
  2100. * @hal_ring_hdl: Ring pointer (Source or Destination ring)
  2101. *
  2102. */
  2103. static inline qdf_dma_addr_t
  2104. hal_srng_get_tp_addr(void *hal_soc, hal_ring_handle_t hal_ring_hdl)
  2105. {
  2106. struct hal_srng *srng = (struct hal_srng *)hal_ring_hdl;
  2107. struct hal_soc *hal = (struct hal_soc *)hal_soc;
  2108. if (srng->ring_dir == HAL_SRNG_SRC_RING) {
  2109. return hal->shadow_rdptr_mem_paddr +
  2110. ((unsigned long)(srng->u.src_ring.tp_addr) -
  2111. (unsigned long)(hal->shadow_rdptr_mem_vaddr));
  2112. } else {
  2113. return hal->shadow_wrptr_mem_paddr +
  2114. ((unsigned long)(srng->u.dst_ring.tp_addr) -
  2115. (unsigned long)(hal->shadow_wrptr_mem_vaddr));
  2116. }
  2117. }
  2118. /**
  2119. * hal_srng_get_num_entries - Get total entries in the HAL Srng
  2120. *
  2121. * @hal_soc: Opaque HAL SOC handle
  2122. * @hal_ring_hdl: Ring pointer (Source or Destination ring)
  2123. *
  2124. * Return: total number of entries in hal ring
  2125. */
  2126. static inline
  2127. uint32_t hal_srng_get_num_entries(hal_soc_handle_t hal_soc_hdl,
  2128. hal_ring_handle_t hal_ring_hdl)
  2129. {
  2130. struct hal_srng *srng = (struct hal_srng *)hal_ring_hdl;
  2131. return srng->num_entries;
  2132. }
  2133. /**
  2134. * hal_get_srng_params - Retrieve SRNG parameters for a given ring from HAL
  2135. *
  2136. * @hal_soc: Opaque HAL SOC handle
  2137. * @hal_ring_hdl: Ring pointer (Source or Destination ring)
  2138. * @ring_params: SRNG parameters will be returned through this structure
  2139. */
  2140. void hal_get_srng_params(hal_soc_handle_t hal_soc_hdl,
  2141. hal_ring_handle_t hal_ring_hdl,
  2142. struct hal_srng_params *ring_params);
  2143. /**
  2144. * hal_mem_info - Retrieve hal memory base address
  2145. *
  2146. * @hal_soc: Opaque HAL SOC handle
  2147. * @mem: pointer to structure to be updated with hal mem info
  2148. */
  2149. void hal_get_meminfo(hal_soc_handle_t hal_soc_hdl, struct hal_mem_info *mem);
  2150. /**
  2151. * hal_get_target_type - Return target type
  2152. *
  2153. * @hal_soc: Opaque HAL SOC handle
  2154. */
  2155. uint32_t hal_get_target_type(hal_soc_handle_t hal_soc_hdl);
  2156. /**
  2157. * hal_get_ba_aging_timeout - Retrieve BA aging timeout
  2158. *
  2159. * @hal_soc: Opaque HAL SOC handle
  2160. * @ac: Access category
  2161. * @value: timeout duration in millisec
  2162. */
  2163. void hal_get_ba_aging_timeout(hal_soc_handle_t hal_soc_hdl, uint8_t ac,
  2164. uint32_t *value);
  2165. /**
  2166. * hal_set_aging_timeout - Set BA aging timeout
  2167. *
  2168. * @hal_soc: Opaque HAL SOC handle
  2169. * @ac: Access category in millisec
  2170. * @value: timeout duration value
  2171. */
  2172. void hal_set_ba_aging_timeout(hal_soc_handle_t hal_soc_hdl, uint8_t ac,
  2173. uint32_t value);
  2174. /**
  2175. * hal_srng_dst_hw_init - Private function to initialize SRNG
  2176. * destination ring HW
  2177. * @hal_soc: HAL SOC handle
  2178. * @srng: SRNG ring pointer
  2179. */
  2180. static inline void hal_srng_dst_hw_init(struct hal_soc *hal,
  2181. struct hal_srng *srng)
  2182. {
  2183. hal->ops->hal_srng_dst_hw_init(hal, srng);
  2184. }
  2185. /**
  2186. * hal_srng_src_hw_init - Private function to initialize SRNG
  2187. * source ring HW
  2188. * @hal_soc: HAL SOC handle
  2189. * @srng: SRNG ring pointer
  2190. */
  2191. static inline void hal_srng_src_hw_init(struct hal_soc *hal,
  2192. struct hal_srng *srng)
  2193. {
  2194. hal->ops->hal_srng_src_hw_init(hal, srng);
  2195. }
  2196. /**
  2197. * hal_get_hw_hptp() - Get HW head and tail pointer value for any ring
  2198. * @hal_soc: Opaque HAL SOC handle
  2199. * @hal_ring_hdl: Source ring pointer
  2200. * @headp: Head Pointer
  2201. * @tailp: Tail Pointer
  2202. * @ring_type: Ring
  2203. *
  2204. * Return: Update tail pointer and head pointer in arguments.
  2205. */
  2206. static inline
  2207. void hal_get_hw_hptp(hal_soc_handle_t hal_soc_hdl,
  2208. hal_ring_handle_t hal_ring_hdl,
  2209. uint32_t *headp, uint32_t *tailp,
  2210. uint8_t ring_type)
  2211. {
  2212. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  2213. hal_soc->ops->hal_get_hw_hptp(hal_soc, hal_ring_hdl,
  2214. headp, tailp, ring_type);
  2215. }
  2216. /**
  2217. * hal_reo_setup - Initialize HW REO block
  2218. *
  2219. * @hal_soc: Opaque HAL SOC handle
  2220. * @reo_params: parameters needed by HAL for REO config
  2221. */
  2222. static inline void hal_reo_setup(hal_soc_handle_t hal_soc_hdl,
  2223. void *reoparams)
  2224. {
  2225. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  2226. hal_soc->ops->hal_reo_setup(hal_soc, reoparams);
  2227. }
  2228. static inline
  2229. void hal_compute_reo_remap_ix2_ix3(hal_soc_handle_t hal_soc_hdl,
  2230. uint32_t *ring, uint32_t num_rings,
  2231. uint32_t *remap1, uint32_t *remap2)
  2232. {
  2233. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  2234. return hal_soc->ops->hal_compute_reo_remap_ix2_ix3(ring,
  2235. num_rings, remap1, remap2);
  2236. }
  2237. /**
  2238. * hal_setup_link_idle_list - Setup scattered idle list using the
  2239. * buffer list provided
  2240. *
  2241. * @hal_soc: Opaque HAL SOC handle
  2242. * @scatter_bufs_base_paddr: Array of physical base addresses
  2243. * @scatter_bufs_base_vaddr: Array of virtual base addresses
  2244. * @num_scatter_bufs: Number of scatter buffers in the above lists
  2245. * @scatter_buf_size: Size of each scatter buffer
  2246. * @last_buf_end_offset: Offset to the last entry
  2247. * @num_entries: Total entries of all scatter bufs
  2248. *
  2249. */
  2250. static inline
  2251. void hal_setup_link_idle_list(hal_soc_handle_t hal_soc_hdl,
  2252. qdf_dma_addr_t scatter_bufs_base_paddr[],
  2253. void *scatter_bufs_base_vaddr[],
  2254. uint32_t num_scatter_bufs,
  2255. uint32_t scatter_buf_size,
  2256. uint32_t last_buf_end_offset,
  2257. uint32_t num_entries)
  2258. {
  2259. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  2260. hal_soc->ops->hal_setup_link_idle_list(hal_soc, scatter_bufs_base_paddr,
  2261. scatter_bufs_base_vaddr, num_scatter_bufs,
  2262. scatter_buf_size, last_buf_end_offset,
  2263. num_entries);
  2264. }
  2265. /**
  2266. * hal_srng_dump_ring_desc() - Dump ring descriptor info
  2267. *
  2268. * @hal_soc: Opaque HAL SOC handle
  2269. * @hal_ring_hdl: Source ring pointer
  2270. * @ring_desc: Opaque ring descriptor handle
  2271. */
  2272. static inline void hal_srng_dump_ring_desc(hal_soc_handle_t hal_soc_hdl,
  2273. hal_ring_handle_t hal_ring_hdl,
  2274. hal_ring_desc_t ring_desc)
  2275. {
  2276. struct hal_srng *srng = (struct hal_srng *)hal_ring_hdl;
  2277. QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_INFO_HIGH,
  2278. ring_desc, (srng->entry_size << 2));
  2279. }
  2280. /**
  2281. * hal_srng_dump_ring() - Dump last 128 descs of the ring
  2282. *
  2283. * @hal_soc: Opaque HAL SOC handle
  2284. * @hal_ring_hdl: Source ring pointer
  2285. */
  2286. static inline void hal_srng_dump_ring(hal_soc_handle_t hal_soc_hdl,
  2287. hal_ring_handle_t hal_ring_hdl)
  2288. {
  2289. struct hal_srng *srng = (struct hal_srng *)hal_ring_hdl;
  2290. uint32_t *desc;
  2291. uint32_t tp, i;
  2292. tp = srng->u.dst_ring.tp;
  2293. for (i = 0; i < 128; i++) {
  2294. if (!tp)
  2295. tp = srng->ring_size;
  2296. desc = &srng->ring_base_vaddr[tp - srng->entry_size];
  2297. QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_DP,
  2298. QDF_TRACE_LEVEL_DEBUG,
  2299. desc, (srng->entry_size << 2));
  2300. tp -= srng->entry_size;
  2301. }
  2302. }
  2303. /*
  2304. * hal_rxdma_desc_to_hal_ring_desc - API to convert rxdma ring desc
  2305. * to opaque dp_ring desc type
  2306. * @ring_desc - rxdma ring desc
  2307. *
  2308. * Return: hal_rxdma_desc_t type
  2309. */
  2310. static inline
  2311. hal_ring_desc_t hal_rxdma_desc_to_hal_ring_desc(hal_rxdma_desc_t ring_desc)
  2312. {
  2313. return (hal_ring_desc_t)ring_desc;
  2314. }
  2315. /**
  2316. * hal_srng_set_event() - Set hal_srng event
  2317. * @hal_ring_hdl: Source ring pointer
  2318. * @event: SRNG ring event
  2319. *
  2320. * Return: None
  2321. */
  2322. static inline void hal_srng_set_event(hal_ring_handle_t hal_ring_hdl, int event)
  2323. {
  2324. struct hal_srng *srng = (struct hal_srng *)hal_ring_hdl;
  2325. qdf_atomic_set_bit(event, &srng->srng_event);
  2326. }
  2327. /**
  2328. * hal_srng_clear_event() - Clear hal_srng event
  2329. * @hal_ring_hdl: Source ring pointer
  2330. * @event: SRNG ring event
  2331. *
  2332. * Return: None
  2333. */
  2334. static inline
  2335. void hal_srng_clear_event(hal_ring_handle_t hal_ring_hdl, int event)
  2336. {
  2337. struct hal_srng *srng = (struct hal_srng *)hal_ring_hdl;
  2338. qdf_atomic_clear_bit(event, &srng->srng_event);
  2339. }
  2340. /**
  2341. * hal_srng_get_clear_event() - Clear srng event and return old value
  2342. * @hal_ring_hdl: Source ring pointer
  2343. * @event: SRNG ring event
  2344. *
  2345. * Return: Return old event value
  2346. */
  2347. static inline
  2348. int hal_srng_get_clear_event(hal_ring_handle_t hal_ring_hdl, int event)
  2349. {
  2350. struct hal_srng *srng = (struct hal_srng *)hal_ring_hdl;
  2351. return qdf_atomic_test_and_clear_bit(event, &srng->srng_event);
  2352. }
  2353. /**
  2354. * hal_srng_set_flush_last_ts() - Record last flush time stamp
  2355. * @hal_ring_hdl: Source ring pointer
  2356. *
  2357. * Return: None
  2358. */
  2359. static inline void hal_srng_set_flush_last_ts(hal_ring_handle_t hal_ring_hdl)
  2360. {
  2361. struct hal_srng *srng = (struct hal_srng *)hal_ring_hdl;
  2362. srng->last_flush_ts = qdf_get_log_timestamp();
  2363. }
  2364. /**
  2365. * hal_srng_inc_flush_cnt() - Increment flush counter
  2366. * @hal_ring_hdl: Source ring pointer
  2367. *
  2368. * Return: None
  2369. */
  2370. static inline void hal_srng_inc_flush_cnt(hal_ring_handle_t hal_ring_hdl)
  2371. {
  2372. struct hal_srng *srng = (struct hal_srng *)hal_ring_hdl;
  2373. srng->flush_count++;
  2374. }
  2375. /**
  2376. * hal_rx_sw_mon_desc_info_get () - Get SW monitor desc info
  2377. *
  2378. * @hal: Core HAL soc handle
  2379. * @ring_desc: Mon dest ring descriptor
  2380. * @desc_info: Desc info to be populated
  2381. *
  2382. * Return void
  2383. */
  2384. static inline void
  2385. hal_rx_sw_mon_desc_info_get(struct hal_soc *hal,
  2386. hal_ring_desc_t ring_desc,
  2387. hal_rx_mon_desc_info_t desc_info)
  2388. {
  2389. return hal->ops->hal_rx_sw_mon_desc_info_get(ring_desc, desc_info);
  2390. }
  2391. /**
  2392. * hal_reo_set_err_dst_remap() - Set REO error destination ring remap
  2393. * register value.
  2394. *
  2395. * @hal_soc_hdl: Opaque HAL soc handle
  2396. *
  2397. * Return: None
  2398. */
  2399. static inline void hal_reo_set_err_dst_remap(hal_soc_handle_t hal_soc_hdl)
  2400. {
  2401. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  2402. if (hal_soc->ops->hal_reo_set_err_dst_remap)
  2403. hal_soc->ops->hal_reo_set_err_dst_remap(hal_soc);
  2404. }
  2405. #ifdef GENERIC_SHADOW_REGISTER_ACCESS_ENABLE
  2406. /**
  2407. * hal_set_one_target_reg_config() - Populate the target reg
  2408. * offset in hal_soc for one non srng related register at the
  2409. * given list index
  2410. * @hal_soc: hal handle
  2411. * @target_reg_offset: target register offset
  2412. * @list_index: index in hal list for shadow regs
  2413. *
  2414. * Return: none
  2415. */
  2416. void hal_set_one_target_reg_config(struct hal_soc *hal,
  2417. uint32_t target_reg_offset,
  2418. int list_index);
  2419. /**
  2420. * hal_set_shadow_regs() - Populate register offset for
  2421. * registers that need to be populated in list_shadow_reg_config
  2422. * in order to be sent to FW. These reg offsets will be mapped
  2423. * to shadow registers.
  2424. * @hal_soc: hal handle
  2425. *
  2426. * Return: QDF_STATUS_OK on success
  2427. */
  2428. QDF_STATUS hal_set_shadow_regs(void *hal_soc);
  2429. /**
  2430. * hal_construct_shadow_regs() - initialize the shadow registers
  2431. * for non-srng related register configs
  2432. * @hal_soc: hal handle
  2433. *
  2434. * Return: QDF_STATUS_OK on success
  2435. */
  2436. QDF_STATUS hal_construct_shadow_regs(void *hal_soc);
  2437. #else /* GENERIC_SHADOW_REGISTER_ACCESS_ENABLE */
  2438. static inline void hal_set_one_target_reg_config(
  2439. struct hal_soc *hal,
  2440. uint32_t target_reg_offset,
  2441. int list_index)
  2442. {
  2443. }
  2444. static inline QDF_STATUS hal_set_shadow_regs(void *hal_soc)
  2445. {
  2446. return QDF_STATUS_SUCCESS;
  2447. }
  2448. static inline QDF_STATUS hal_construct_shadow_regs(void *hal_soc)
  2449. {
  2450. return QDF_STATUS_SUCCESS;
  2451. }
  2452. #endif /* GENERIC_SHADOW_REGISTER_ACCESS_ENABLE */
  2453. #ifdef FEATURE_HAL_DELAYED_REG_WRITE
  2454. /**
  2455. * hal_flush_reg_write_work() - flush all writes from register write queue
  2456. * @arg: hal_soc pointer
  2457. *
  2458. * Return: None
  2459. */
  2460. void hal_flush_reg_write_work(hal_soc_handle_t hal_handle);
  2461. #else
  2462. static inline void hal_flush_reg_write_work(hal_soc_handle_t hal_handle) { }
  2463. #endif
  2464. #endif /* _HAL_APIH_ */