hal_api.h 61 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217
  1. /*
  2. * Copyright (c) 2016-2020 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. /* calculate the register address offset from bar0 of shadow register x */
  28. #if defined(QCA_WIFI_QCA6390) || defined(QCA_WIFI_QCA6490)
  29. #define SHADOW_REGISTER_START_ADDRESS_OFFSET 0x000008FC
  30. #define SHADOW_REGISTER_END_ADDRESS_OFFSET \
  31. ((SHADOW_REGISTER_START_ADDRESS_OFFSET) + (4 * (MAX_SHADOW_REGISTERS)))
  32. #define SHADOW_REGISTER(x) ((SHADOW_REGISTER_START_ADDRESS_OFFSET) + (4 * (x)))
  33. #elif defined(QCA_WIFI_QCA6290) || defined(QCA_WIFI_QCN9000)
  34. #define SHADOW_REGISTER_START_ADDRESS_OFFSET 0x00003024
  35. #define SHADOW_REGISTER_END_ADDRESS_OFFSET \
  36. ((SHADOW_REGISTER_START_ADDRESS_OFFSET) + (4 * (MAX_SHADOW_REGISTERS)))
  37. #define SHADOW_REGISTER(x) ((SHADOW_REGISTER_START_ADDRESS_OFFSET) + (4 * (x)))
  38. #elif defined(QCA_WIFI_QCA6750)
  39. #define SHADOW_REGISTER_START_ADDRESS_OFFSET 0x00000504
  40. #define SHADOW_REGISTER_END_ADDRESS_OFFSET \
  41. ((SHADOW_REGISTER_START_ADDRESS_OFFSET) + (4 * (MAX_SHADOW_REGISTERS)))
  42. #define SHADOW_REGISTER(x) ((SHADOW_REGISTER_START_ADDRESS_OFFSET) + (4 * (x)))
  43. #else
  44. #define SHADOW_REGISTER(x) 0
  45. #endif /* QCA_WIFI_QCA6390 || QCA_WIFI_QCA6490 || QCA_WIFI_QCA6750 */
  46. #define MAX_UNWINDOWED_ADDRESS 0x80000
  47. #if defined(QCA_WIFI_QCA6390) || defined(QCA_WIFI_QCA6490) || \
  48. defined(QCA_WIFI_QCN9000) || defined(QCA_WIFI_QCA6750)
  49. #define WINDOW_ENABLE_BIT 0x40000000
  50. #else
  51. #define WINDOW_ENABLE_BIT 0x80000000
  52. #endif
  53. #define WINDOW_REG_ADDRESS 0x310C
  54. #define WINDOW_SHIFT 19
  55. #define WINDOW_VALUE_MASK 0x3F
  56. #define WINDOW_START MAX_UNWINDOWED_ADDRESS
  57. #define WINDOW_RANGE_MASK 0x7FFFF
  58. /*
  59. * BAR + 4K is always accessible, any access outside this
  60. * space requires force wake procedure.
  61. * OFFSET = 4K - 32 bytes = 0xFE0
  62. */
  63. #define MAPPED_REF_OFF 0xFE0
  64. #ifdef ENABLE_VERBOSE_DEBUG
  65. static inline void
  66. hal_set_verbose_debug(bool flag)
  67. {
  68. is_hal_verbose_debug_enabled = flag;
  69. }
  70. #endif
  71. #ifdef ENABLE_HAL_SOC_STATS
  72. #define HAL_STATS_INC(_handle, _field, _delta) \
  73. { \
  74. if (likely(_handle)) \
  75. _handle->stats._field += _delta; \
  76. }
  77. #else
  78. #define HAL_STATS_INC(_handle, _field, _delta)
  79. #endif
  80. #ifdef ENABLE_HAL_REG_WR_HISTORY
  81. #define HAL_REG_WRITE_FAIL_HIST_ADD(hal_soc, offset, wr_val, rd_val) \
  82. hal_reg_wr_fail_history_add(hal_soc, offset, wr_val, rd_val)
  83. void hal_reg_wr_fail_history_add(struct hal_soc *hal_soc,
  84. uint32_t offset,
  85. uint32_t wr_val,
  86. uint32_t rd_val);
  87. static inline int hal_history_get_next_index(qdf_atomic_t *table_index,
  88. int array_size)
  89. {
  90. int record_index = qdf_atomic_inc_return(table_index);
  91. return record_index & (array_size - 1);
  92. }
  93. #else
  94. #define HAL_REG_WRITE_FAIL_HIST_ADD(hal_soc, offset, wr_val, rd_val) \
  95. hal_err("write failed at reg offset 0x%x, write 0x%x read 0x%x\n", \
  96. offset, \
  97. wr_val, \
  98. rd_val)
  99. #endif
  100. /**
  101. * hal_reg_write_result_check() - check register writing result
  102. * @hal_soc: HAL soc handle
  103. * @offset: register offset to read
  104. * @exp_val: the expected value of register
  105. * @ret_confirm: result confirm flag
  106. *
  107. * Return: none
  108. */
  109. static inline void hal_reg_write_result_check(struct hal_soc *hal_soc,
  110. uint32_t offset,
  111. uint32_t exp_val)
  112. {
  113. uint32_t value;
  114. value = qdf_ioread32(hal_soc->dev_base_addr + offset);
  115. if (exp_val != value) {
  116. HAL_REG_WRITE_FAIL_HIST_ADD(hal_soc, offset, exp_val, value);
  117. HAL_STATS_INC(hal_soc, reg_write_fail, 1);
  118. }
  119. }
  120. #if !defined(QCA_WIFI_QCA6390) && !defined(QCA_WIFI_QCA6490) || \
  121. !defined(QCA_WIFI_QCA6750)
  122. static inline void hal_lock_reg_access(struct hal_soc *soc,
  123. unsigned long *flags)
  124. {
  125. qdf_spin_lock_irqsave(&soc->register_access_lock);
  126. }
  127. static inline void hal_unlock_reg_access(struct hal_soc *soc,
  128. unsigned long *flags)
  129. {
  130. qdf_spin_unlock_irqrestore(&soc->register_access_lock);
  131. }
  132. #else
  133. static inline void hal_lock_reg_access(struct hal_soc *soc,
  134. unsigned long *flags)
  135. {
  136. pld_lock_reg_window(soc->qdf_dev->dev, flags);
  137. }
  138. static inline void hal_unlock_reg_access(struct hal_soc *soc,
  139. unsigned long *flags)
  140. {
  141. pld_unlock_reg_window(soc->qdf_dev->dev, flags);
  142. }
  143. #endif
  144. #ifdef PCIE_REG_WINDOW_LOCAL_NO_CACHE
  145. static inline void hal_select_window(struct hal_soc *hal_soc, uint32_t offset)
  146. {
  147. uint32_t window = (offset >> WINDOW_SHIFT) & WINDOW_VALUE_MASK;
  148. qdf_iowrite32(hal_soc->dev_base_addr + WINDOW_REG_ADDRESS,
  149. WINDOW_ENABLE_BIT | window);
  150. hal_soc->register_window = window;
  151. }
  152. /**
  153. * hal_select_window_confirm() - write remap window register and
  154. check writing result
  155. *
  156. */
  157. static inline void hal_select_window_confirm(struct hal_soc *hal_soc,
  158. uint32_t offset)
  159. {
  160. uint32_t window = (offset >> WINDOW_SHIFT) & WINDOW_VALUE_MASK;
  161. qdf_iowrite32(hal_soc->dev_base_addr + WINDOW_REG_ADDRESS,
  162. WINDOW_ENABLE_BIT | window);
  163. hal_soc->register_window = window;
  164. hal_reg_write_result_check(hal_soc, WINDOW_REG_ADDRESS,
  165. WINDOW_ENABLE_BIT | window);
  166. }
  167. #else
  168. static inline void hal_select_window(struct hal_soc *hal_soc, uint32_t offset)
  169. {
  170. uint32_t window = (offset >> WINDOW_SHIFT) & WINDOW_VALUE_MASK;
  171. if (window != hal_soc->register_window) {
  172. qdf_iowrite32(hal_soc->dev_base_addr + WINDOW_REG_ADDRESS,
  173. WINDOW_ENABLE_BIT | window);
  174. hal_soc->register_window = window;
  175. }
  176. }
  177. static inline void hal_select_window_confirm(struct hal_soc *hal_soc,
  178. uint32_t offset)
  179. {
  180. uint32_t window = (offset >> WINDOW_SHIFT) & WINDOW_VALUE_MASK;
  181. if (window != hal_soc->register_window) {
  182. qdf_iowrite32(hal_soc->dev_base_addr + WINDOW_REG_ADDRESS,
  183. WINDOW_ENABLE_BIT | window);
  184. hal_soc->register_window = window;
  185. hal_reg_write_result_check(
  186. hal_soc,
  187. WINDOW_REG_ADDRESS,
  188. WINDOW_ENABLE_BIT | window);
  189. }
  190. }
  191. #endif
  192. static inline qdf_iomem_t hal_get_window_address(struct hal_soc *hal_soc,
  193. qdf_iomem_t addr)
  194. {
  195. return hal_soc->ops->hal_get_window_address(hal_soc, addr);
  196. }
  197. static inline void hal_tx_init_cmd_credit_ring(hal_soc_handle_t hal_soc_hdl,
  198. hal_ring_handle_t hal_ring_hdl)
  199. {
  200. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  201. return hal_soc->ops->hal_tx_init_cmd_credit_ring(hal_soc_hdl,
  202. hal_ring_hdl);
  203. }
  204. /**
  205. * hal_write32_mb() - Access registers to update configuration
  206. * @hal_soc: hal soc handle
  207. * @offset: offset address from the BAR
  208. * @value: value to write
  209. *
  210. * Return: None
  211. *
  212. * Description: Register address space is split below:
  213. * SHADOW REGION UNWINDOWED REGION WINDOWED REGION
  214. * |--------------------|-------------------|------------------|
  215. * BAR NO FORCE WAKE BAR+4K FORCE WAKE BAR+512K FORCE WAKE
  216. *
  217. * 1. Any access to the shadow region, doesn't need force wake
  218. * and windowing logic to access.
  219. * 2. Any access beyond BAR + 4K:
  220. * If init_phase enabled, no force wake is needed and access
  221. * should be based on windowed or unwindowed access.
  222. * If init_phase disabled, force wake is needed and access
  223. * should be based on windowed or unwindowed access.
  224. *
  225. * note1: WINDOW_RANGE_MASK = (1 << WINDOW_SHIFT) -1
  226. * note2: 1 << WINDOW_SHIFT = MAX_UNWINDOWED_ADDRESS
  227. * note3: WINDOW_VALUE_MASK = big enough that trying to write past
  228. * that window would be a bug
  229. */
  230. #if !defined(QCA_WIFI_QCA6390) && !defined(QCA_WIFI_QCA6490) && \
  231. !defined(QCA_WIFI_QCA6750)
  232. static inline void hal_write32_mb(struct hal_soc *hal_soc, uint32_t offset,
  233. uint32_t value)
  234. {
  235. unsigned long flags;
  236. qdf_iomem_t new_addr;
  237. if (!hal_soc->use_register_windowing ||
  238. offset < MAX_UNWINDOWED_ADDRESS) {
  239. qdf_iowrite32(hal_soc->dev_base_addr + offset, value);
  240. } else if (hal_soc->static_window_map) {
  241. new_addr = hal_get_window_address(hal_soc,
  242. hal_soc->dev_base_addr + offset);
  243. qdf_iowrite32(new_addr, value);
  244. } else {
  245. hal_lock_reg_access(hal_soc, &flags);
  246. hal_select_window(hal_soc, offset);
  247. qdf_iowrite32(hal_soc->dev_base_addr + WINDOW_START +
  248. (offset & WINDOW_RANGE_MASK), value);
  249. hal_unlock_reg_access(hal_soc, &flags);
  250. }
  251. }
  252. #define hal_write32_mb_confirm(_hal_soc, _offset, _value) \
  253. hal_write32_mb(_hal_soc, _offset, _value)
  254. #else
  255. static inline void hal_write32_mb(struct hal_soc *hal_soc, uint32_t offset,
  256. uint32_t value)
  257. {
  258. int ret;
  259. unsigned long flags;
  260. qdf_iomem_t new_addr;
  261. /* Region < BAR + 4K can be directly accessed */
  262. if (offset < MAPPED_REF_OFF) {
  263. qdf_iowrite32(hal_soc->dev_base_addr + offset, value);
  264. return;
  265. }
  266. /* Region greater than BAR + 4K */
  267. if (!hal_soc->init_phase) {
  268. ret = hif_force_wake_request(hal_soc->hif_handle);
  269. if (ret) {
  270. hal_err("Wake up request failed");
  271. qdf_check_state_before_panic();
  272. return;
  273. }
  274. }
  275. if (!hal_soc->use_register_windowing ||
  276. offset < MAX_UNWINDOWED_ADDRESS) {
  277. qdf_iowrite32(hal_soc->dev_base_addr + offset, value);
  278. } else if (hal_soc->static_window_map) {
  279. new_addr = hal_get_window_address(
  280. hal_soc,
  281. hal_soc->dev_base_addr + offset);
  282. qdf_iowrite32(new_addr, value);
  283. } else {
  284. hal_lock_reg_access(hal_soc, &flags);
  285. hal_select_window(hal_soc, offset);
  286. qdf_iowrite32(hal_soc->dev_base_addr + WINDOW_START +
  287. (offset & WINDOW_RANGE_MASK), value);
  288. hal_unlock_reg_access(hal_soc, &flags);
  289. }
  290. if (!hal_soc->init_phase) {
  291. ret = hif_force_wake_release(hal_soc->hif_handle);
  292. if (ret) {
  293. hal_err("Wake up release failed");
  294. qdf_check_state_before_panic();
  295. return;
  296. }
  297. }
  298. }
  299. /**
  300. * hal_write32_mb_confirm() - write register and check wirting result
  301. *
  302. */
  303. static inline void hal_write32_mb_confirm(struct hal_soc *hal_soc,
  304. uint32_t offset,
  305. uint32_t value)
  306. {
  307. int ret;
  308. unsigned long flags;
  309. qdf_iomem_t new_addr;
  310. /* Region < BAR + 4K can be directly accessed */
  311. if (offset < MAPPED_REF_OFF) {
  312. qdf_iowrite32(hal_soc->dev_base_addr + offset, value);
  313. return;
  314. }
  315. /* Region greater than BAR + 4K */
  316. if (!hal_soc->init_phase) {
  317. ret = hif_force_wake_request(hal_soc->hif_handle);
  318. if (ret) {
  319. hal_err("Wake up request failed");
  320. qdf_check_state_before_panic();
  321. return;
  322. }
  323. }
  324. if (!hal_soc->use_register_windowing ||
  325. offset < MAX_UNWINDOWED_ADDRESS) {
  326. qdf_iowrite32(hal_soc->dev_base_addr + offset, value);
  327. hal_reg_write_result_check(hal_soc, offset,
  328. value);
  329. } else if (hal_soc->static_window_map) {
  330. new_addr = hal_get_window_address(
  331. hal_soc,
  332. hal_soc->dev_base_addr + offset);
  333. qdf_iowrite32(new_addr, value);
  334. hal_reg_write_result_check(hal_soc,
  335. new_addr - hal_soc->dev_base_addr,
  336. value);
  337. } else {
  338. hal_lock_reg_access(hal_soc, &flags);
  339. hal_select_window_confirm(hal_soc, offset);
  340. qdf_iowrite32(hal_soc->dev_base_addr + WINDOW_START +
  341. (offset & WINDOW_RANGE_MASK), value);
  342. hal_reg_write_result_check(
  343. hal_soc,
  344. WINDOW_START + (offset & WINDOW_RANGE_MASK),
  345. value);
  346. hal_unlock_reg_access(hal_soc, &flags);
  347. }
  348. if (!hal_soc->init_phase) {
  349. ret = hif_force_wake_release(hal_soc->hif_handle);
  350. if (ret) {
  351. hal_err("Wake up release failed");
  352. qdf_check_state_before_panic();
  353. return;
  354. }
  355. }
  356. }
  357. #endif
  358. /**
  359. * hal_write_address_32_mb - write a value to a register
  360. *
  361. */
  362. static inline
  363. void hal_write_address_32_mb(struct hal_soc *hal_soc,
  364. qdf_iomem_t addr, uint32_t value, bool wr_confirm)
  365. {
  366. uint32_t offset;
  367. if (!hal_soc->use_register_windowing)
  368. return qdf_iowrite32(addr, value);
  369. offset = addr - hal_soc->dev_base_addr;
  370. if (qdf_unlikely(wr_confirm))
  371. hal_write32_mb_confirm(hal_soc, offset, value);
  372. else
  373. hal_write32_mb(hal_soc, offset, value);
  374. }
  375. #ifdef DP_HAL_MULTIWINDOW_DIRECT_ACCESS
  376. static inline void hal_srng_write_address_32_mb(struct hal_soc *hal_soc,
  377. struct hal_srng *srng,
  378. void __iomem *addr,
  379. uint32_t value)
  380. {
  381. qdf_iowrite32(addr, value);
  382. }
  383. #elif defined(FEATURE_HAL_DELAYED_REG_WRITE)
  384. static inline void hal_srng_write_address_32_mb(struct hal_soc *hal_soc,
  385. struct hal_srng *srng,
  386. void __iomem *addr,
  387. uint32_t value)
  388. {
  389. hal_delayed_reg_write(hal_soc, srng, addr, value);
  390. }
  391. #else
  392. static inline void hal_srng_write_address_32_mb(struct hal_soc *hal_soc,
  393. struct hal_srng *srng,
  394. void __iomem *addr,
  395. uint32_t value)
  396. {
  397. hal_write_address_32_mb(hal_soc, addr, value, false);
  398. }
  399. #endif
  400. #if !defined(QCA_WIFI_QCA6390) && !defined(QCA_WIFI_QCA6490) && \
  401. !defined(QCA_WIFI_QCA6750)
  402. /**
  403. * hal_read32_mb() - Access registers to read configuration
  404. * @hal_soc: hal soc handle
  405. * @offset: offset address from the BAR
  406. * @value: value to write
  407. *
  408. * Description: Register address space is split below:
  409. * SHADOW REGION UNWINDOWED REGION WINDOWED REGION
  410. * |--------------------|-------------------|------------------|
  411. * BAR NO FORCE WAKE BAR+4K FORCE WAKE BAR+512K FORCE WAKE
  412. *
  413. * 1. Any access to the shadow region, doesn't need force wake
  414. * and windowing logic to access.
  415. * 2. Any access beyond BAR + 4K:
  416. * If init_phase enabled, no force wake is needed and access
  417. * should be based on windowed or unwindowed access.
  418. * If init_phase disabled, force wake is needed and access
  419. * should be based on windowed or unwindowed access.
  420. *
  421. * Return: < 0 for failure/>= 0 for success
  422. */
  423. static inline uint32_t hal_read32_mb(struct hal_soc *hal_soc, uint32_t offset)
  424. {
  425. uint32_t ret;
  426. unsigned long flags;
  427. qdf_iomem_t new_addr;
  428. if (!hal_soc->use_register_windowing ||
  429. offset < MAX_UNWINDOWED_ADDRESS) {
  430. return qdf_ioread32(hal_soc->dev_base_addr + offset);
  431. } else if (hal_soc->static_window_map) {
  432. new_addr = hal_get_window_address(hal_soc, hal_soc->dev_base_addr + offset);
  433. return qdf_ioread32(new_addr);
  434. }
  435. hal_lock_reg_access(hal_soc, &flags);
  436. hal_select_window(hal_soc, offset);
  437. ret = qdf_ioread32(hal_soc->dev_base_addr + WINDOW_START +
  438. (offset & WINDOW_RANGE_MASK));
  439. hal_unlock_reg_access(hal_soc, &flags);
  440. return ret;
  441. }
  442. #else
  443. static
  444. uint32_t hal_read32_mb(struct hal_soc *hal_soc, uint32_t offset)
  445. {
  446. uint32_t ret;
  447. unsigned long flags;
  448. qdf_iomem_t new_addr;
  449. /* Region < BAR + 4K can be directly accessed */
  450. if (offset < MAPPED_REF_OFF)
  451. return qdf_ioread32(hal_soc->dev_base_addr + offset);
  452. if ((!hal_soc->init_phase) &&
  453. hif_force_wake_request(hal_soc->hif_handle)) {
  454. hal_err("Wake up request failed");
  455. qdf_check_state_before_panic();
  456. return 0;
  457. }
  458. if (!hal_soc->use_register_windowing ||
  459. offset < MAX_UNWINDOWED_ADDRESS) {
  460. ret = qdf_ioread32(hal_soc->dev_base_addr + offset);
  461. } else if (hal_soc->static_window_map) {
  462. new_addr = hal_get_window_address(
  463. hal_soc,
  464. hal_soc->dev_base_addr + offset);
  465. ret = qdf_ioread32(new_addr);
  466. } else {
  467. hal_lock_reg_access(hal_soc, &flags);
  468. hal_select_window(hal_soc, offset);
  469. ret = qdf_ioread32(hal_soc->dev_base_addr + WINDOW_START +
  470. (offset & WINDOW_RANGE_MASK));
  471. hal_unlock_reg_access(hal_soc, &flags);
  472. }
  473. if ((!hal_soc->init_phase) &&
  474. hif_force_wake_release(hal_soc->hif_handle)) {
  475. hal_err("Wake up release failed");
  476. qdf_check_state_before_panic();
  477. return 0;
  478. }
  479. return ret;
  480. }
  481. #endif
  482. #ifdef FEATURE_HAL_DELAYED_REG_WRITE
  483. /**
  484. * hal_dump_reg_write_srng_stats() - dump SRNG reg write stats
  485. * @hal_soc: HAL soc handle
  486. *
  487. * Return: none
  488. */
  489. void hal_dump_reg_write_srng_stats(hal_soc_handle_t hal_soc_hdl);
  490. /**
  491. * hal_dump_reg_write_stats() - dump reg write stats
  492. * @hal_soc: HAL soc handle
  493. *
  494. * Return: none
  495. */
  496. void hal_dump_reg_write_stats(hal_soc_handle_t hal_soc_hdl);
  497. #else
  498. static inline void hal_dump_reg_write_srng_stats(hal_soc_handle_t hal_soc_hdl)
  499. {
  500. }
  501. static inline void hal_dump_reg_write_stats(hal_soc_handle_t hal_soc_hdl)
  502. {
  503. }
  504. #endif
  505. /**
  506. * hal_read_address_32_mb() - Read 32-bit value from the register
  507. * @soc: soc handle
  508. * @addr: register address to read
  509. *
  510. * Return: 32-bit value
  511. */
  512. static inline
  513. uint32_t hal_read_address_32_mb(struct hal_soc *soc,
  514. qdf_iomem_t addr)
  515. {
  516. uint32_t offset;
  517. uint32_t ret;
  518. if (!soc->use_register_windowing)
  519. return qdf_ioread32(addr);
  520. offset = addr - soc->dev_base_addr;
  521. ret = hal_read32_mb(soc, offset);
  522. return ret;
  523. }
  524. /**
  525. * hal_attach - Initialize HAL layer
  526. * @hif_handle: Opaque HIF handle
  527. * @qdf_dev: QDF device
  528. *
  529. * Return: Opaque HAL SOC handle
  530. * NULL on failure (if given ring is not available)
  531. *
  532. * This function should be called as part of HIF initialization (for accessing
  533. * copy engines). DP layer will get hal_soc handle using hif_get_hal_handle()
  534. */
  535. void *hal_attach(struct hif_opaque_softc *hif_handle, qdf_device_t qdf_dev);
  536. /**
  537. * hal_detach - Detach HAL layer
  538. * @hal_soc: HAL SOC handle
  539. *
  540. * This function should be called as part of HIF detach
  541. *
  542. */
  543. extern void hal_detach(void *hal_soc);
  544. /* SRNG type to be passed in APIs hal_srng_get_entrysize and hal_srng_setup */
  545. enum hal_ring_type {
  546. REO_DST = 0,
  547. REO_EXCEPTION = 1,
  548. REO_REINJECT = 2,
  549. REO_CMD = 3,
  550. REO_STATUS = 4,
  551. TCL_DATA = 5,
  552. TCL_CMD_CREDIT = 6,
  553. TCL_STATUS = 7,
  554. CE_SRC = 8,
  555. CE_DST = 9,
  556. CE_DST_STATUS = 10,
  557. WBM_IDLE_LINK = 11,
  558. SW2WBM_RELEASE = 12,
  559. WBM2SW_RELEASE = 13,
  560. RXDMA_BUF = 14,
  561. RXDMA_DST = 15,
  562. RXDMA_MONITOR_BUF = 16,
  563. RXDMA_MONITOR_STATUS = 17,
  564. RXDMA_MONITOR_DST = 18,
  565. RXDMA_MONITOR_DESC = 19,
  566. DIR_BUF_RX_DMA_SRC = 20,
  567. #ifdef WLAN_FEATURE_CIF_CFR
  568. WIFI_POS_SRC,
  569. #endif
  570. MAX_RING_TYPES
  571. };
  572. #define HAL_SRNG_LMAC_RING 0x80000000
  573. /* SRNG flags passed in hal_srng_params.flags */
  574. #define HAL_SRNG_MSI_SWAP 0x00000008
  575. #define HAL_SRNG_RING_PTR_SWAP 0x00000010
  576. #define HAL_SRNG_DATA_TLV_SWAP 0x00000020
  577. #define HAL_SRNG_LOW_THRES_INTR_ENABLE 0x00010000
  578. #define HAL_SRNG_MSI_INTR 0x00020000
  579. #define HAL_SRNG_CACHED_DESC 0x00040000
  580. #ifdef QCA_WIFI_QCA6490
  581. #define HAL_SRNG_PREFETCH_TIMER 1
  582. #else
  583. #define HAL_SRNG_PREFETCH_TIMER 0
  584. #endif
  585. #define PN_SIZE_24 0
  586. #define PN_SIZE_48 1
  587. #define PN_SIZE_128 2
  588. #ifdef FORCE_WAKE
  589. /**
  590. * hal_set_init_phase() - Indicate initialization of
  591. * datapath rings
  592. * @soc: hal_soc handle
  593. * @init_phase: flag to indicate datapath rings
  594. * initialization status
  595. *
  596. * Return: None
  597. */
  598. void hal_set_init_phase(hal_soc_handle_t soc, bool init_phase);
  599. #else
  600. static inline
  601. void hal_set_init_phase(hal_soc_handle_t soc, bool init_phase)
  602. {
  603. }
  604. #endif /* FORCE_WAKE */
  605. /**
  606. * hal_srng_get_entrysize - Returns size of ring entry in bytes. Should be
  607. * used by callers for calculating the size of memory to be allocated before
  608. * calling hal_srng_setup to setup the ring
  609. *
  610. * @hal_soc: Opaque HAL SOC handle
  611. * @ring_type: one of the types from hal_ring_type
  612. *
  613. */
  614. extern uint32_t hal_srng_get_entrysize(void *hal_soc, int ring_type);
  615. /**
  616. * hal_srng_max_entries - Returns maximum possible number of ring entries
  617. * @hal_soc: Opaque HAL SOC handle
  618. * @ring_type: one of the types from hal_ring_type
  619. *
  620. * Return: Maximum number of entries for the given ring_type
  621. */
  622. uint32_t hal_srng_max_entries(void *hal_soc, int ring_type);
  623. /**
  624. * hal_srng_dump - Dump ring status
  625. * @srng: hal srng pointer
  626. */
  627. void hal_srng_dump(struct hal_srng *srng);
  628. /**
  629. * hal_srng_get_dir - Returns the direction of the ring
  630. * @hal_soc: Opaque HAL SOC handle
  631. * @ring_type: one of the types from hal_ring_type
  632. *
  633. * Return: Ring direction
  634. */
  635. enum hal_srng_dir hal_srng_get_dir(void *hal_soc, int ring_type);
  636. /* HAL memory information */
  637. struct hal_mem_info {
  638. /* dev base virutal addr */
  639. void *dev_base_addr;
  640. /* dev base physical addr */
  641. void *dev_base_paddr;
  642. /* Remote virtual pointer memory for HW/FW updates */
  643. void *shadow_rdptr_mem_vaddr;
  644. /* Remote physical pointer memory for HW/FW updates */
  645. void *shadow_rdptr_mem_paddr;
  646. /* Shared memory for ring pointer updates from host to FW */
  647. void *shadow_wrptr_mem_vaddr;
  648. /* Shared physical memory for ring pointer updates from host to FW */
  649. void *shadow_wrptr_mem_paddr;
  650. };
  651. /* SRNG parameters to be passed to hal_srng_setup */
  652. struct hal_srng_params {
  653. /* Physical base address of the ring */
  654. qdf_dma_addr_t ring_base_paddr;
  655. /* Virtual base address of the ring */
  656. void *ring_base_vaddr;
  657. /* Number of entries in ring */
  658. uint32_t num_entries;
  659. /* max transfer length */
  660. uint16_t max_buffer_length;
  661. /* MSI Address */
  662. qdf_dma_addr_t msi_addr;
  663. /* MSI data */
  664. uint32_t msi_data;
  665. /* Interrupt timer threshold – in micro seconds */
  666. uint32_t intr_timer_thres_us;
  667. /* Interrupt batch counter threshold – in number of ring entries */
  668. uint32_t intr_batch_cntr_thres_entries;
  669. /* Low threshold – in number of ring entries
  670. * (valid for src rings only)
  671. */
  672. uint32_t low_threshold;
  673. /* Misc flags */
  674. uint32_t flags;
  675. /* Unique ring id */
  676. uint8_t ring_id;
  677. /* Source or Destination ring */
  678. enum hal_srng_dir ring_dir;
  679. /* Size of ring entry */
  680. uint32_t entry_size;
  681. /* hw register base address */
  682. void *hwreg_base[MAX_SRNG_REG_GROUPS];
  683. /* prefetch timer config - in micro seconds */
  684. uint32_t prefetch_timer;
  685. };
  686. /* hal_construct_shadow_config() - initialize the shadow registers for dp rings
  687. * @hal_soc: hal handle
  688. *
  689. * Return: QDF_STATUS_OK on success
  690. */
  691. extern QDF_STATUS hal_construct_shadow_config(void *hal_soc);
  692. /* hal_set_one_shadow_config() - add a config for the specified ring
  693. * @hal_soc: hal handle
  694. * @ring_type: ring type
  695. * @ring_num: ring num
  696. *
  697. * The ring type and ring num uniquely specify the ring. After this call,
  698. * the hp/tp will be added as the next entry int the shadow register
  699. * configuration table. The hal code will use the shadow register address
  700. * in place of the hp/tp address.
  701. *
  702. * This function is exposed, so that the CE module can skip configuring shadow
  703. * registers for unused ring and rings assigned to the firmware.
  704. *
  705. * Return: QDF_STATUS_OK on success
  706. */
  707. extern QDF_STATUS hal_set_one_shadow_config(void *hal_soc, int ring_type,
  708. int ring_num);
  709. /**
  710. * hal_get_shadow_config() - retrieve the config table
  711. * @hal_soc: hal handle
  712. * @shadow_config: will point to the table after
  713. * @num_shadow_registers_configured: will contain the number of valid entries
  714. */
  715. extern void hal_get_shadow_config(void *hal_soc,
  716. struct pld_shadow_reg_v2_cfg **shadow_config,
  717. int *num_shadow_registers_configured);
  718. /**
  719. * hal_srng_setup - Initialize HW SRNG ring.
  720. *
  721. * @hal_soc: Opaque HAL SOC handle
  722. * @ring_type: one of the types from hal_ring_type
  723. * @ring_num: Ring number if there are multiple rings of
  724. * same type (staring from 0)
  725. * @mac_id: valid MAC Id should be passed if ring type is one of lmac rings
  726. * @ring_params: SRNG ring params in hal_srng_params structure.
  727. * Callers are expected to allocate contiguous ring memory of size
  728. * 'num_entries * entry_size' bytes and pass the physical and virtual base
  729. * addresses through 'ring_base_paddr' and 'ring_base_vaddr' in hal_srng_params
  730. * structure. Ring base address should be 8 byte aligned and size of each ring
  731. * entry should be queried using the API hal_srng_get_entrysize
  732. *
  733. * Return: Opaque pointer to ring on success
  734. * NULL on failure (if given ring is not available)
  735. */
  736. extern void *hal_srng_setup(void *hal_soc, int ring_type, int ring_num,
  737. int mac_id, struct hal_srng_params *ring_params);
  738. /* Remapping ids of REO rings */
  739. #define REO_REMAP_TCL 0
  740. #define REO_REMAP_SW1 1
  741. #define REO_REMAP_SW2 2
  742. #define REO_REMAP_SW3 3
  743. #define REO_REMAP_SW4 4
  744. #define REO_REMAP_RELEASE 5
  745. #define REO_REMAP_FW 6
  746. #define REO_REMAP_UNUSED 7
  747. /*
  748. * Macro to access HWIO_REO_R0_ERROR_DESTINATION_RING_CTRL_IX_0
  749. * to map destination to rings
  750. */
  751. #define HAL_REO_ERR_REMAP_IX0(_VALUE, _OFFSET) \
  752. ((_VALUE) << \
  753. (HWIO_REO_R0_ERROR_DESTINATION_MAPPING_IX_0_ERROR_ ## \
  754. DESTINATION_RING_ ## _OFFSET ## _SHFT))
  755. /*
  756. * Macro to access HWIO_REO_R0_DESTINATION_RING_CTRL_IX_0
  757. * to map destination to rings
  758. */
  759. #define HAL_REO_REMAP_IX0(_VALUE, _OFFSET) \
  760. ((_VALUE) << \
  761. (HWIO_REO_R0_DESTINATION_RING_CTRL_IX_0_DEST_RING_MAPPING_ ## \
  762. _OFFSET ## _SHFT))
  763. /*
  764. * Macro to access HWIO_REO_R0_DESTINATION_RING_CTRL_IX_1
  765. * to map destination to rings
  766. */
  767. #define HAL_REO_REMAP_IX2(_VALUE, _OFFSET) \
  768. ((_VALUE) << \
  769. (HWIO_REO_R0_DESTINATION_RING_CTRL_IX_2_DEST_RING_MAPPING_ ## \
  770. _OFFSET ## _SHFT))
  771. /*
  772. * Macro to access HWIO_REO_R0_DESTINATION_RING_CTRL_IX_3
  773. * to map destination to rings
  774. */
  775. #define HAL_REO_REMAP_IX3(_VALUE, _OFFSET) \
  776. ((_VALUE) << \
  777. (HWIO_REO_R0_DESTINATION_RING_CTRL_IX_3_DEST_RING_MAPPING_ ## \
  778. _OFFSET ## _SHFT))
  779. /**
  780. * hal_reo_read_write_ctrl_ix - Read or write REO_DESTINATION_RING_CTRL_IX
  781. * @hal_soc_hdl: HAL SOC handle
  782. * @read: boolean value to indicate if read or write
  783. * @ix0: pointer to store IX0 reg value
  784. * @ix1: pointer to store IX1 reg value
  785. * @ix2: pointer to store IX2 reg value
  786. * @ix3: pointer to store IX3 reg value
  787. */
  788. void hal_reo_read_write_ctrl_ix(hal_soc_handle_t hal_soc_hdl, bool read,
  789. uint32_t *ix0, uint32_t *ix1,
  790. uint32_t *ix2, uint32_t *ix3);
  791. /**
  792. * hal_srng_set_hp_paddr() - Set physical address to dest SRNG head pointer
  793. * @sring: sring pointer
  794. * @paddr: physical address
  795. */
  796. extern void hal_srng_dst_set_hp_paddr(struct hal_srng *sring, uint64_t paddr);
  797. /**
  798. * hal_srng_dst_init_hp() - Initilaize head pointer with cached head pointer
  799. * @srng: sring pointer
  800. * @vaddr: virtual address
  801. */
  802. extern void hal_srng_dst_init_hp(struct hal_srng *srng, uint32_t *vaddr);
  803. /**
  804. * hal_srng_cleanup - Deinitialize HW SRNG ring.
  805. * @hal_soc: Opaque HAL SOC handle
  806. * @hal_srng: Opaque HAL SRNG pointer
  807. */
  808. void hal_srng_cleanup(void *hal_soc, hal_ring_handle_t hal_ring_hdl);
  809. static inline bool hal_srng_initialized(hal_ring_handle_t hal_ring_hdl)
  810. {
  811. struct hal_srng *srng = (struct hal_srng *)hal_ring_hdl;
  812. return !!srng->initialized;
  813. }
  814. /**
  815. * hal_srng_dst_peek - Check if there are any entries in the ring (peek)
  816. * @hal_soc: Opaque HAL SOC handle
  817. * @hal_ring_hdl: Destination ring pointer
  818. *
  819. * Caller takes responsibility for any locking needs.
  820. *
  821. * Return: Opaque pointer for next ring entry; NULL on failire
  822. */
  823. static inline
  824. void *hal_srng_dst_peek(hal_soc_handle_t hal_soc_hdl,
  825. hal_ring_handle_t hal_ring_hdl)
  826. {
  827. struct hal_srng *srng = (struct hal_srng *)hal_ring_hdl;
  828. if (srng->u.dst_ring.tp != srng->u.dst_ring.cached_hp)
  829. return (void *)(&srng->ring_base_vaddr[srng->u.dst_ring.tp]);
  830. return NULL;
  831. }
  832. /**
  833. * hal_srng_access_start_unlocked - Start ring access (unlocked). Should use
  834. * hal_srng_access_start if locked access is required
  835. *
  836. * @hal_soc: Opaque HAL SOC handle
  837. * @hal_ring_hdl: Ring pointer (Source or Destination ring)
  838. *
  839. * Return: 0 on success; error on failire
  840. */
  841. static inline int
  842. hal_srng_access_start_unlocked(hal_soc_handle_t hal_soc_hdl,
  843. hal_ring_handle_t hal_ring_hdl)
  844. {
  845. struct hal_srng *srng = (struct hal_srng *)hal_ring_hdl;
  846. struct hal_soc *soc = (struct hal_soc *)hal_soc_hdl;
  847. uint32_t *desc;
  848. if (srng->ring_dir == HAL_SRNG_SRC_RING)
  849. srng->u.src_ring.cached_tp =
  850. *(volatile uint32_t *)(srng->u.src_ring.tp_addr);
  851. else {
  852. srng->u.dst_ring.cached_hp =
  853. *(volatile uint32_t *)(srng->u.dst_ring.hp_addr);
  854. if (srng->flags & HAL_SRNG_CACHED_DESC) {
  855. desc = hal_srng_dst_peek(hal_soc_hdl, hal_ring_hdl);
  856. if (qdf_likely(desc)) {
  857. qdf_mem_dma_cache_sync(soc->qdf_dev,
  858. qdf_mem_virt_to_phys
  859. (desc),
  860. QDF_DMA_FROM_DEVICE,
  861. (srng->entry_size *
  862. sizeof(uint32_t)));
  863. qdf_prefetch(desc);
  864. }
  865. }
  866. }
  867. return 0;
  868. }
  869. /**
  870. * hal_srng_access_start - Start (locked) ring access
  871. *
  872. * @hal_soc: Opaque HAL SOC handle
  873. * @hal_ring_hdl: Ring pointer (Source or Destination ring)
  874. *
  875. * Return: 0 on success; error on failire
  876. */
  877. static inline int hal_srng_access_start(hal_soc_handle_t hal_soc_hdl,
  878. hal_ring_handle_t hal_ring_hdl)
  879. {
  880. struct hal_srng *srng = (struct hal_srng *)hal_ring_hdl;
  881. if (qdf_unlikely(!hal_ring_hdl)) {
  882. qdf_print("Error: Invalid hal_ring\n");
  883. return -EINVAL;
  884. }
  885. SRNG_LOCK(&(srng->lock));
  886. return hal_srng_access_start_unlocked(hal_soc_hdl, hal_ring_hdl);
  887. }
  888. /**
  889. * hal_srng_dst_get_next - Get next entry from a destination ring
  890. * @hal_soc: Opaque HAL SOC handle
  891. * @hal_ring_hdl: Destination ring pointer
  892. *
  893. * Return: Opaque pointer for next ring entry; NULL on failure
  894. */
  895. static inline
  896. void *hal_srng_dst_get_next(void *hal_soc,
  897. hal_ring_handle_t hal_ring_hdl)
  898. {
  899. struct hal_srng *srng = (struct hal_srng *)hal_ring_hdl;
  900. uint32_t *desc;
  901. if (srng->u.dst_ring.tp == srng->u.dst_ring.cached_hp)
  902. return NULL;
  903. desc = &srng->ring_base_vaddr[srng->u.dst_ring.tp];
  904. /* TODO: Using % is expensive, but we have to do this since
  905. * size of some SRNG rings is not power of 2 (due to descriptor
  906. * sizes). Need to create separate API for rings used
  907. * per-packet, with sizes power of 2 (TCL2SW, REO2SW,
  908. * SW2RXDMA and CE rings)
  909. */
  910. srng->u.dst_ring.tp = (srng->u.dst_ring.tp + srng->entry_size);
  911. if (srng->u.dst_ring.tp == srng->ring_size)
  912. srng->u.dst_ring.tp = 0;
  913. if (srng->flags & HAL_SRNG_CACHED_DESC) {
  914. struct hal_soc *soc = (struct hal_soc *)hal_soc;
  915. uint32_t *desc_next;
  916. uint32_t tp;
  917. tp = srng->u.dst_ring.tp;
  918. desc_next = &srng->ring_base_vaddr[srng->u.dst_ring.tp];
  919. qdf_mem_dma_cache_sync(soc->qdf_dev,
  920. qdf_mem_virt_to_phys(desc_next),
  921. QDF_DMA_FROM_DEVICE,
  922. (srng->entry_size *
  923. sizeof(uint32_t)));
  924. qdf_prefetch(desc_next);
  925. }
  926. return (void *)desc;
  927. }
  928. /**
  929. * hal_srng_dst_get_next_cached - Get cached next entry
  930. * @hal_soc: Opaque HAL SOC handle
  931. * @hal_ring_hdl: Destination ring pointer
  932. *
  933. * Get next entry from a destination ring and move cached tail pointer
  934. *
  935. * Return: Opaque pointer for next ring entry; NULL on failure
  936. */
  937. static inline
  938. void *hal_srng_dst_get_next_cached(void *hal_soc,
  939. hal_ring_handle_t hal_ring_hdl)
  940. {
  941. struct hal_srng *srng = (struct hal_srng *)hal_ring_hdl;
  942. uint32_t *desc;
  943. uint32_t *desc_next;
  944. if (srng->u.dst_ring.tp == srng->u.dst_ring.cached_hp)
  945. return NULL;
  946. desc = &srng->ring_base_vaddr[srng->u.dst_ring.tp];
  947. /* TODO: Using % is expensive, but we have to do this since
  948. * size of some SRNG rings is not power of 2 (due to descriptor
  949. * sizes). Need to create separate API for rings used
  950. * per-packet, with sizes power of 2 (TCL2SW, REO2SW,
  951. * SW2RXDMA and CE rings)
  952. */
  953. srng->u.dst_ring.tp = (srng->u.dst_ring.tp + srng->entry_size);
  954. if (srng->u.dst_ring.tp == srng->ring_size)
  955. srng->u.dst_ring.tp = 0;
  956. desc_next = &srng->ring_base_vaddr[srng->u.dst_ring.tp];
  957. qdf_prefetch(desc_next);
  958. return (void *)desc;
  959. }
  960. /**
  961. * hal_srng_dst_get_next_hp - Get next entry from a destination ring and move
  962. * cached head pointer
  963. *
  964. * @hal_soc: Opaque HAL SOC handle
  965. * @hal_ring_hdl: Destination ring pointer
  966. *
  967. * Return: Opaque pointer for next ring entry; NULL on failire
  968. */
  969. static inline void *
  970. hal_srng_dst_get_next_hp(hal_soc_handle_t hal_soc_hdl,
  971. hal_ring_handle_t hal_ring_hdl)
  972. {
  973. struct hal_srng *srng = (struct hal_srng *)hal_ring_hdl;
  974. uint32_t *desc;
  975. /* TODO: Using % is expensive, but we have to do this since
  976. * size of some SRNG rings is not power of 2 (due to descriptor
  977. * sizes). Need to create separate API for rings used
  978. * per-packet, with sizes power of 2 (TCL2SW, REO2SW,
  979. * SW2RXDMA and CE rings)
  980. */
  981. uint32_t next_hp = (srng->u.dst_ring.cached_hp + srng->entry_size) %
  982. srng->ring_size;
  983. if (next_hp != srng->u.dst_ring.tp) {
  984. desc = &(srng->ring_base_vaddr[srng->u.dst_ring.cached_hp]);
  985. srng->u.dst_ring.cached_hp = next_hp;
  986. return (void *)desc;
  987. }
  988. return NULL;
  989. }
  990. /**
  991. * hal_srng_dst_peek_sync - Check if there are any entries in the ring (peek)
  992. * @hal_soc: Opaque HAL SOC handle
  993. * @hal_ring_hdl: Destination ring pointer
  994. *
  995. * Sync cached head pointer with HW.
  996. * Caller takes responsibility for any locking needs.
  997. *
  998. * Return: Opaque pointer for next ring entry; NULL on failire
  999. */
  1000. static inline
  1001. void *hal_srng_dst_peek_sync(hal_soc_handle_t hal_soc_hdl,
  1002. hal_ring_handle_t hal_ring_hdl)
  1003. {
  1004. struct hal_srng *srng = (struct hal_srng *)hal_ring_hdl;
  1005. srng->u.dst_ring.cached_hp =
  1006. *(volatile uint32_t *)(srng->u.dst_ring.hp_addr);
  1007. if (srng->u.dst_ring.tp != srng->u.dst_ring.cached_hp)
  1008. return (void *)(&(srng->ring_base_vaddr[srng->u.dst_ring.tp]));
  1009. return NULL;
  1010. }
  1011. /**
  1012. * hal_srng_dst_peek_sync_locked - Peek for any entries in the ring
  1013. * @hal_soc: Opaque HAL SOC handle
  1014. * @hal_ring_hdl: Destination ring pointer
  1015. *
  1016. * Sync cached head pointer with HW.
  1017. * This function takes up SRNG_LOCK. Should not be called with SRNG lock held.
  1018. *
  1019. * Return: Opaque pointer for next ring entry; NULL on failire
  1020. */
  1021. static inline
  1022. void *hal_srng_dst_peek_sync_locked(hal_soc_handle_t hal_soc_hdl,
  1023. hal_ring_handle_t hal_ring_hdl)
  1024. {
  1025. struct hal_srng *srng = (struct hal_srng *)hal_ring_hdl;
  1026. void *ring_desc_ptr = NULL;
  1027. if (qdf_unlikely(!hal_ring_hdl)) {
  1028. qdf_print("Error: Invalid hal_ring\n");
  1029. return NULL;
  1030. }
  1031. SRNG_LOCK(&srng->lock);
  1032. ring_desc_ptr = hal_srng_dst_peek_sync(hal_soc_hdl, hal_ring_hdl);
  1033. SRNG_UNLOCK(&srng->lock);
  1034. return ring_desc_ptr;
  1035. }
  1036. /**
  1037. * hal_srng_dst_num_valid - Returns number of valid entries (to be processed
  1038. * by SW) in destination ring
  1039. *
  1040. * @hal_soc: Opaque HAL SOC handle
  1041. * @hal_ring_hdl: Destination ring pointer
  1042. * @sync_hw_ptr: Sync cached head pointer with HW
  1043. *
  1044. */
  1045. static inline
  1046. uint32_t hal_srng_dst_num_valid(void *hal_soc,
  1047. hal_ring_handle_t hal_ring_hdl,
  1048. int sync_hw_ptr)
  1049. {
  1050. struct hal_srng *srng = (struct hal_srng *)hal_ring_hdl;
  1051. uint32_t hp;
  1052. uint32_t tp = srng->u.dst_ring.tp;
  1053. if (sync_hw_ptr) {
  1054. hp = *(volatile uint32_t *)(srng->u.dst_ring.hp_addr);
  1055. srng->u.dst_ring.cached_hp = hp;
  1056. } else {
  1057. hp = srng->u.dst_ring.cached_hp;
  1058. }
  1059. if (hp >= tp)
  1060. return (hp - tp) / srng->entry_size;
  1061. return (srng->ring_size - tp + hp) / srng->entry_size;
  1062. }
  1063. /**
  1064. * hal_srng_dst_inv_cached_descs - API to invalidate descriptors in batch mode
  1065. * @hal_soc: Opaque HAL SOC handle
  1066. * @hal_ring_hdl: Destination ring pointer
  1067. * @entry_count: Number of descriptors to be invalidated
  1068. *
  1069. * Invalidates a set of cached descriptors starting from tail to
  1070. * provided count worth
  1071. *
  1072. * Return - None
  1073. */
  1074. static inline void hal_srng_dst_inv_cached_descs(void *hal_soc,
  1075. hal_ring_handle_t hal_ring_hdl,
  1076. uint32_t entry_count)
  1077. {
  1078. struct hal_srng *srng = (struct hal_srng *)hal_ring_hdl;
  1079. uint32_t hp = srng->u.dst_ring.cached_hp;
  1080. uint32_t tp = srng->u.dst_ring.tp;
  1081. uint32_t sync_p = 0;
  1082. /*
  1083. * If SRNG does not have cached descriptors this
  1084. * API call should be a no op
  1085. */
  1086. if (!(srng->flags & HAL_SRNG_CACHED_DESC))
  1087. return;
  1088. if (qdf_unlikely(entry_count == 0))
  1089. return;
  1090. sync_p = (entry_count - 1) * srng->entry_size;
  1091. if (hp > tp) {
  1092. qdf_nbuf_dma_inv_range(&srng->ring_base_vaddr[tp],
  1093. &srng->ring_base_vaddr[tp + sync_p]
  1094. + (srng->entry_size * sizeof(uint32_t)));
  1095. } else {
  1096. /*
  1097. * We have wrapped around
  1098. */
  1099. uint32_t wrap_cnt = ((srng->ring_size - tp) / srng->entry_size);
  1100. if (entry_count <= wrap_cnt) {
  1101. qdf_nbuf_dma_inv_range(&srng->ring_base_vaddr[tp],
  1102. &srng->ring_base_vaddr[tp + sync_p] +
  1103. (srng->entry_size * sizeof(uint32_t)));
  1104. return;
  1105. }
  1106. entry_count -= wrap_cnt;
  1107. sync_p = (entry_count - 1) * srng->entry_size;
  1108. qdf_nbuf_dma_inv_range(&srng->ring_base_vaddr[tp],
  1109. &srng->ring_base_vaddr[srng->ring_size - srng->entry_size] +
  1110. (srng->entry_size * sizeof(uint32_t)));
  1111. qdf_nbuf_dma_inv_range(&srng->ring_base_vaddr[0],
  1112. &srng->ring_base_vaddr[sync_p]
  1113. + (srng->entry_size * sizeof(uint32_t)));
  1114. }
  1115. }
  1116. /**
  1117. * hal_srng_dst_num_valid_locked - Returns num valid entries to be processed
  1118. *
  1119. * @hal_soc: Opaque HAL SOC handle
  1120. * @hal_ring_hdl: Destination ring pointer
  1121. * @sync_hw_ptr: Sync cached head pointer with HW
  1122. *
  1123. * Returns number of valid entries to be processed by the host driver. The
  1124. * function takes up SRNG lock.
  1125. *
  1126. * Return: Number of valid destination entries
  1127. */
  1128. static inline uint32_t
  1129. hal_srng_dst_num_valid_locked(hal_soc_handle_t hal_soc,
  1130. hal_ring_handle_t hal_ring_hdl,
  1131. int sync_hw_ptr)
  1132. {
  1133. uint32_t num_valid;
  1134. struct hal_srng *srng = (struct hal_srng *)hal_ring_hdl;
  1135. SRNG_LOCK(&srng->lock);
  1136. num_valid = hal_srng_dst_num_valid(hal_soc, hal_ring_hdl, sync_hw_ptr);
  1137. SRNG_UNLOCK(&srng->lock);
  1138. return num_valid;
  1139. }
  1140. /**
  1141. * hal_srng_sync_cachedhp - sync cachehp pointer from hw hp
  1142. *
  1143. * @hal_soc: Opaque HAL SOC handle
  1144. * @hal_ring_hdl: Destination ring pointer
  1145. *
  1146. */
  1147. static inline
  1148. void hal_srng_sync_cachedhp(void *hal_soc,
  1149. hal_ring_handle_t hal_ring_hdl)
  1150. {
  1151. struct hal_srng *srng = (struct hal_srng *)hal_ring_hdl;
  1152. uint32_t hp;
  1153. hp = *(volatile uint32_t *)(srng->u.dst_ring.hp_addr);
  1154. srng->u.dst_ring.cached_hp = hp;
  1155. }
  1156. /**
  1157. * hal_srng_src_reap_next - Reap next entry from a source ring and move reap
  1158. * pointer. This can be used to release any buffers associated with completed
  1159. * ring entries. Note that this should not be used for posting new descriptor
  1160. * entries. Posting of new entries should be done only using
  1161. * hal_srng_src_get_next_reaped when this function is used for reaping.
  1162. *
  1163. * @hal_soc: Opaque HAL SOC handle
  1164. * @hal_ring_hdl: Source ring pointer
  1165. *
  1166. * Return: Opaque pointer for next ring entry; NULL on failire
  1167. */
  1168. static inline void *
  1169. hal_srng_src_reap_next(void *hal_soc, hal_ring_handle_t hal_ring_hdl)
  1170. {
  1171. struct hal_srng *srng = (struct hal_srng *)hal_ring_hdl;
  1172. uint32_t *desc;
  1173. /* TODO: Using % is expensive, but we have to do this since
  1174. * size of some SRNG rings is not power of 2 (due to descriptor
  1175. * sizes). Need to create separate API for rings used
  1176. * per-packet, with sizes power of 2 (TCL2SW, REO2SW,
  1177. * SW2RXDMA and CE rings)
  1178. */
  1179. uint32_t next_reap_hp = (srng->u.src_ring.reap_hp + srng->entry_size) %
  1180. srng->ring_size;
  1181. if (next_reap_hp != srng->u.src_ring.cached_tp) {
  1182. desc = &(srng->ring_base_vaddr[next_reap_hp]);
  1183. srng->u.src_ring.reap_hp = next_reap_hp;
  1184. return (void *)desc;
  1185. }
  1186. return NULL;
  1187. }
  1188. /**
  1189. * hal_srng_src_get_next_reaped - Get next entry from a source ring that is
  1190. * already reaped using hal_srng_src_reap_next, for posting new entries to
  1191. * the ring
  1192. *
  1193. * @hal_soc: Opaque HAL SOC handle
  1194. * @hal_ring_hdl: Source ring pointer
  1195. *
  1196. * Return: Opaque pointer for next (reaped) source ring entry; NULL on failire
  1197. */
  1198. static inline void *
  1199. hal_srng_src_get_next_reaped(void *hal_soc, hal_ring_handle_t hal_ring_hdl)
  1200. {
  1201. struct hal_srng *srng = (struct hal_srng *)hal_ring_hdl;
  1202. uint32_t *desc;
  1203. if (srng->u.src_ring.hp != srng->u.src_ring.reap_hp) {
  1204. desc = &(srng->ring_base_vaddr[srng->u.src_ring.hp]);
  1205. srng->u.src_ring.hp = (srng->u.src_ring.hp + srng->entry_size) %
  1206. srng->ring_size;
  1207. return (void *)desc;
  1208. }
  1209. return NULL;
  1210. }
  1211. /**
  1212. * hal_srng_src_pending_reap_next - Reap next entry from a source ring and
  1213. * move reap pointer. This API is used in detach path to release any buffers
  1214. * associated with ring entries which are pending reap.
  1215. *
  1216. * @hal_soc: Opaque HAL SOC handle
  1217. * @hal_ring_hdl: Source ring pointer
  1218. *
  1219. * Return: Opaque pointer for next ring entry; NULL on failire
  1220. */
  1221. static inline void *
  1222. hal_srng_src_pending_reap_next(void *hal_soc, hal_ring_handle_t hal_ring_hdl)
  1223. {
  1224. struct hal_srng *srng = (struct hal_srng *)hal_ring_hdl;
  1225. uint32_t *desc;
  1226. uint32_t next_reap_hp = (srng->u.src_ring.reap_hp + srng->entry_size) %
  1227. srng->ring_size;
  1228. if (next_reap_hp != srng->u.src_ring.hp) {
  1229. desc = &(srng->ring_base_vaddr[next_reap_hp]);
  1230. srng->u.src_ring.reap_hp = next_reap_hp;
  1231. return (void *)desc;
  1232. }
  1233. return NULL;
  1234. }
  1235. /**
  1236. * hal_srng_src_done_val -
  1237. *
  1238. * @hal_soc: Opaque HAL SOC handle
  1239. * @hal_ring_hdl: Source ring pointer
  1240. *
  1241. * Return: Opaque pointer for next ring entry; NULL on failire
  1242. */
  1243. static inline uint32_t
  1244. hal_srng_src_done_val(void *hal_soc, hal_ring_handle_t hal_ring_hdl)
  1245. {
  1246. struct hal_srng *srng = (struct hal_srng *)hal_ring_hdl;
  1247. /* TODO: Using % is expensive, but we have to do this since
  1248. * size of some SRNG rings is not power of 2 (due to descriptor
  1249. * sizes). Need to create separate API for rings used
  1250. * per-packet, with sizes power of 2 (TCL2SW, REO2SW,
  1251. * SW2RXDMA and CE rings)
  1252. */
  1253. uint32_t next_reap_hp = (srng->u.src_ring.reap_hp + srng->entry_size) %
  1254. srng->ring_size;
  1255. if (next_reap_hp == srng->u.src_ring.cached_tp)
  1256. return 0;
  1257. if (srng->u.src_ring.cached_tp > next_reap_hp)
  1258. return (srng->u.src_ring.cached_tp - next_reap_hp) /
  1259. srng->entry_size;
  1260. else
  1261. return ((srng->ring_size - next_reap_hp) +
  1262. srng->u.src_ring.cached_tp) / srng->entry_size;
  1263. }
  1264. /**
  1265. * hal_get_entrysize_from_srng() - Retrieve ring entry size
  1266. * @hal_ring_hdl: Source ring pointer
  1267. *
  1268. * Return: uint8_t
  1269. */
  1270. static inline
  1271. uint8_t hal_get_entrysize_from_srng(hal_ring_handle_t hal_ring_hdl)
  1272. {
  1273. struct hal_srng *srng = (struct hal_srng *)hal_ring_hdl;
  1274. return srng->entry_size;
  1275. }
  1276. /**
  1277. * hal_get_sw_hptp - Get SW head and tail pointer location for any ring
  1278. * @hal_soc: Opaque HAL SOC handle
  1279. * @hal_ring_hdl: Source ring pointer
  1280. * @tailp: Tail Pointer
  1281. * @headp: Head Pointer
  1282. *
  1283. * Return: Update tail pointer and head pointer in arguments.
  1284. */
  1285. static inline
  1286. void hal_get_sw_hptp(void *hal_soc, hal_ring_handle_t hal_ring_hdl,
  1287. uint32_t *tailp, uint32_t *headp)
  1288. {
  1289. struct hal_srng *srng = (struct hal_srng *)hal_ring_hdl;
  1290. if (srng->ring_dir == HAL_SRNG_SRC_RING) {
  1291. *headp = srng->u.src_ring.hp;
  1292. *tailp = *srng->u.src_ring.tp_addr;
  1293. } else {
  1294. *tailp = srng->u.dst_ring.tp;
  1295. *headp = *srng->u.dst_ring.hp_addr;
  1296. }
  1297. }
  1298. /**
  1299. * hal_srng_src_get_next - Get next entry from a source ring and move cached tail pointer
  1300. *
  1301. * @hal_soc: Opaque HAL SOC handle
  1302. * @hal_ring_hdl: Source ring pointer
  1303. *
  1304. * Return: Opaque pointer for next ring entry; NULL on failire
  1305. */
  1306. static inline
  1307. void *hal_srng_src_get_next(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. /* TODO: Using % is expensive, but we have to do this since
  1313. * size of some SRNG rings is not power of 2 (due to descriptor
  1314. * sizes). Need to create separate API for rings used
  1315. * per-packet, with sizes power of 2 (TCL2SW, REO2SW,
  1316. * SW2RXDMA and CE rings)
  1317. */
  1318. uint32_t next_hp = (srng->u.src_ring.hp + srng->entry_size) %
  1319. srng->ring_size;
  1320. if (next_hp != srng->u.src_ring.cached_tp) {
  1321. desc = &(srng->ring_base_vaddr[srng->u.src_ring.hp]);
  1322. srng->u.src_ring.hp = next_hp;
  1323. /* TODO: Since reap function is not used by all rings, we can
  1324. * remove the following update of reap_hp in this function
  1325. * if we can ensure that only hal_srng_src_get_next_reaped
  1326. * is used for the rings requiring reap functionality
  1327. */
  1328. srng->u.src_ring.reap_hp = next_hp;
  1329. return (void *)desc;
  1330. }
  1331. return NULL;
  1332. }
  1333. /**
  1334. * hal_srng_src_peek_n_get_next - Get next entry from a ring without
  1335. * moving head pointer.
  1336. * hal_srng_src_get_next should be called subsequently to move the head pointer
  1337. *
  1338. * @hal_soc: Opaque HAL SOC handle
  1339. * @hal_ring_hdl: Source ring pointer
  1340. *
  1341. * Return: Opaque pointer for next ring entry; NULL on failire
  1342. */
  1343. static inline
  1344. void *hal_srng_src_peek_n_get_next(hal_soc_handle_t hal_soc_hdl,
  1345. hal_ring_handle_t hal_ring_hdl)
  1346. {
  1347. struct hal_srng *srng = (struct hal_srng *)hal_ring_hdl;
  1348. uint32_t *desc;
  1349. /* TODO: Using % is expensive, but we have to do this since
  1350. * size of some SRNG rings is not power of 2 (due to descriptor
  1351. * sizes). Need to create separate API for rings used
  1352. * per-packet, with sizes power of 2 (TCL2SW, REO2SW,
  1353. * SW2RXDMA and CE rings)
  1354. */
  1355. if (((srng->u.src_ring.hp + srng->entry_size) %
  1356. srng->ring_size) != srng->u.src_ring.cached_tp) {
  1357. desc = &(srng->ring_base_vaddr[(srng->u.src_ring.hp +
  1358. srng->entry_size) %
  1359. srng->ring_size]);
  1360. return (void *)desc;
  1361. }
  1362. return NULL;
  1363. }
  1364. /**
  1365. * hal_srng_src_get_cur_hp_n_move_next () - API returns current hp
  1366. * and move hp to next in src ring
  1367. *
  1368. * Usage: This API should only be used at init time replenish.
  1369. *
  1370. * @hal_soc_hdl: HAL soc handle
  1371. * @hal_ring_hdl: Source ring pointer
  1372. *
  1373. */
  1374. static inline void *
  1375. hal_srng_src_get_cur_hp_n_move_next(hal_soc_handle_t hal_soc_hdl,
  1376. hal_ring_handle_t hal_ring_hdl)
  1377. {
  1378. struct hal_srng *srng = (struct hal_srng *)hal_ring_hdl;
  1379. uint32_t *cur_desc = NULL;
  1380. uint32_t next_hp;
  1381. cur_desc = &srng->ring_base_vaddr[(srng->u.src_ring.hp)];
  1382. next_hp = (srng->u.src_ring.hp + srng->entry_size) %
  1383. srng->ring_size;
  1384. if (next_hp != srng->u.src_ring.cached_tp)
  1385. srng->u.src_ring.hp = next_hp;
  1386. return (void *)cur_desc;
  1387. }
  1388. /**
  1389. * hal_srng_src_num_avail - Returns number of available entries in src ring
  1390. *
  1391. * @hal_soc: Opaque HAL SOC handle
  1392. * @hal_ring_hdl: Source ring pointer
  1393. * @sync_hw_ptr: Sync cached tail pointer with HW
  1394. *
  1395. */
  1396. static inline uint32_t
  1397. hal_srng_src_num_avail(void *hal_soc,
  1398. hal_ring_handle_t hal_ring_hdl, int sync_hw_ptr)
  1399. {
  1400. struct hal_srng *srng = (struct hal_srng *)hal_ring_hdl;
  1401. uint32_t tp;
  1402. uint32_t hp = srng->u.src_ring.hp;
  1403. if (sync_hw_ptr) {
  1404. tp = *(srng->u.src_ring.tp_addr);
  1405. srng->u.src_ring.cached_tp = tp;
  1406. } else {
  1407. tp = srng->u.src_ring.cached_tp;
  1408. }
  1409. if (tp > hp)
  1410. return ((tp - hp) / srng->entry_size) - 1;
  1411. else
  1412. return ((srng->ring_size - hp + tp) / srng->entry_size) - 1;
  1413. }
  1414. /**
  1415. * hal_srng_access_end_unlocked - End ring access (unlocked) - update cached
  1416. * ring head/tail pointers to HW.
  1417. * This should be used only if hal_srng_access_start_unlocked to start ring
  1418. * access
  1419. *
  1420. * @hal_soc: Opaque HAL SOC handle
  1421. * @hal_ring_hdl: Ring pointer (Source or Destination ring)
  1422. *
  1423. * Return: 0 on success; error on failire
  1424. */
  1425. static inline void
  1426. hal_srng_access_end_unlocked(void *hal_soc, hal_ring_handle_t hal_ring_hdl)
  1427. {
  1428. struct hal_srng *srng = (struct hal_srng *)hal_ring_hdl;
  1429. /* TODO: See if we need a write memory barrier here */
  1430. if (srng->flags & HAL_SRNG_LMAC_RING) {
  1431. /* For LMAC rings, ring pointer updates are done through FW and
  1432. * hence written to a shared memory location that is read by FW
  1433. */
  1434. if (srng->ring_dir == HAL_SRNG_SRC_RING) {
  1435. *(srng->u.src_ring.hp_addr) = srng->u.src_ring.hp;
  1436. } else {
  1437. *(srng->u.dst_ring.tp_addr) = srng->u.dst_ring.tp;
  1438. }
  1439. } else {
  1440. if (srng->ring_dir == HAL_SRNG_SRC_RING)
  1441. hal_srng_write_address_32_mb(hal_soc,
  1442. srng,
  1443. srng->u.src_ring.hp_addr,
  1444. srng->u.src_ring.hp);
  1445. else
  1446. hal_srng_write_address_32_mb(hal_soc,
  1447. srng,
  1448. srng->u.dst_ring.tp_addr,
  1449. srng->u.dst_ring.tp);
  1450. }
  1451. }
  1452. /**
  1453. * hal_srng_access_end - Unlock ring access and update cached ring head/tail
  1454. * pointers to HW
  1455. * This should be used only if hal_srng_access_start to start ring access
  1456. *
  1457. * @hal_soc: Opaque HAL SOC handle
  1458. * @hal_ring_hdl: Ring pointer (Source or Destination ring)
  1459. *
  1460. * Return: 0 on success; error on failire
  1461. */
  1462. static inline void
  1463. hal_srng_access_end(void *hal_soc, hal_ring_handle_t hal_ring_hdl)
  1464. {
  1465. struct hal_srng *srng = (struct hal_srng *)hal_ring_hdl;
  1466. if (qdf_unlikely(!hal_ring_hdl)) {
  1467. qdf_print("Error: Invalid hal_ring\n");
  1468. return;
  1469. }
  1470. hal_srng_access_end_unlocked(hal_soc, hal_ring_hdl);
  1471. SRNG_UNLOCK(&(srng->lock));
  1472. }
  1473. /**
  1474. * hal_srng_access_end_reap - Unlock ring access
  1475. * This should be used only if hal_srng_access_start to start ring access
  1476. * and should be used only while reaping SRC ring completions
  1477. *
  1478. * @hal_soc: Opaque HAL SOC handle
  1479. * @hal_ring_hdl: Ring pointer (Source or Destination ring)
  1480. *
  1481. * Return: 0 on success; error on failire
  1482. */
  1483. static inline void
  1484. hal_srng_access_end_reap(void *hal_soc, hal_ring_handle_t hal_ring_hdl)
  1485. {
  1486. struct hal_srng *srng = (struct hal_srng *)hal_ring_hdl;
  1487. SRNG_UNLOCK(&(srng->lock));
  1488. }
  1489. /* TODO: Check if the following definitions is available in HW headers */
  1490. #define WBM_IDLE_SCATTER_BUF_SIZE 32704
  1491. #define NUM_MPDUS_PER_LINK_DESC 6
  1492. #define NUM_MSDUS_PER_LINK_DESC 7
  1493. #define REO_QUEUE_DESC_ALIGN 128
  1494. #define LINK_DESC_ALIGN 128
  1495. #define ADDRESS_MATCH_TAG_VAL 0x5
  1496. /* Number of mpdu link pointers is 9 in case of TX_MPDU_QUEUE_HEAD and 14 in
  1497. * of TX_MPDU_QUEUE_EXT. We are defining a common average count here
  1498. */
  1499. #define NUM_MPDU_LINKS_PER_QUEUE_DESC 12
  1500. /* TODO: Check with HW team on the scatter buffer size supported. As per WBM
  1501. * MLD, scatter_buffer_size in IDLE_LIST_CONTROL register is 9 bits and size
  1502. * should be specified in 16 word units. But the number of bits defined for
  1503. * this field in HW header files is 5.
  1504. */
  1505. #define WBM_IDLE_SCATTER_BUF_NEXT_PTR_SIZE 8
  1506. /**
  1507. * hal_idle_list_scatter_buf_size - Get the size of each scatter buffer
  1508. * in an idle list
  1509. *
  1510. * @hal_soc: Opaque HAL SOC handle
  1511. *
  1512. */
  1513. static inline
  1514. uint32_t hal_idle_list_scatter_buf_size(hal_soc_handle_t hal_soc_hdl)
  1515. {
  1516. return WBM_IDLE_SCATTER_BUF_SIZE;
  1517. }
  1518. /**
  1519. * hal_get_link_desc_size - Get the size of each link descriptor
  1520. *
  1521. * @hal_soc: Opaque HAL SOC handle
  1522. *
  1523. */
  1524. static inline uint32_t hal_get_link_desc_size(hal_soc_handle_t hal_soc_hdl)
  1525. {
  1526. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  1527. if (!hal_soc || !hal_soc->ops) {
  1528. qdf_print("Error: Invalid ops\n");
  1529. QDF_BUG(0);
  1530. return -EINVAL;
  1531. }
  1532. if (!hal_soc->ops->hal_get_link_desc_size) {
  1533. qdf_print("Error: Invalid function pointer\n");
  1534. QDF_BUG(0);
  1535. return -EINVAL;
  1536. }
  1537. return hal_soc->ops->hal_get_link_desc_size();
  1538. }
  1539. /**
  1540. * hal_get_link_desc_align - Get the required start address alignment for
  1541. * link descriptors
  1542. *
  1543. * @hal_soc: Opaque HAL SOC handle
  1544. *
  1545. */
  1546. static inline
  1547. uint32_t hal_get_link_desc_align(hal_soc_handle_t hal_soc_hdl)
  1548. {
  1549. return LINK_DESC_ALIGN;
  1550. }
  1551. /**
  1552. * hal_num_mpdus_per_link_desc - Get number of mpdus each link desc can hold
  1553. *
  1554. * @hal_soc: Opaque HAL SOC handle
  1555. *
  1556. */
  1557. static inline
  1558. uint32_t hal_num_mpdus_per_link_desc(hal_soc_handle_t hal_soc_hdl)
  1559. {
  1560. return NUM_MPDUS_PER_LINK_DESC;
  1561. }
  1562. /**
  1563. * hal_num_msdus_per_link_desc - Get number of msdus each link desc can hold
  1564. *
  1565. * @hal_soc: Opaque HAL SOC handle
  1566. *
  1567. */
  1568. static inline
  1569. uint32_t hal_num_msdus_per_link_desc(hal_soc_handle_t hal_soc_hdl)
  1570. {
  1571. return NUM_MSDUS_PER_LINK_DESC;
  1572. }
  1573. /**
  1574. * hal_num_mpdu_links_per_queue_desc - Get number of mpdu links each queue
  1575. * descriptor can hold
  1576. *
  1577. * @hal_soc: Opaque HAL SOC handle
  1578. *
  1579. */
  1580. static inline
  1581. uint32_t hal_num_mpdu_links_per_queue_desc(hal_soc_handle_t hal_soc_hdl)
  1582. {
  1583. return NUM_MPDU_LINKS_PER_QUEUE_DESC;
  1584. }
  1585. /**
  1586. * hal_idle_list_scatter_buf_num_entries - Get the number of link desc entries
  1587. * that the given buffer size
  1588. *
  1589. * @hal_soc: Opaque HAL SOC handle
  1590. * @scatter_buf_size: Size of scatter buffer
  1591. *
  1592. */
  1593. static inline
  1594. uint32_t hal_idle_scatter_buf_num_entries(hal_soc_handle_t hal_soc_hdl,
  1595. uint32_t scatter_buf_size)
  1596. {
  1597. return (scatter_buf_size - WBM_IDLE_SCATTER_BUF_NEXT_PTR_SIZE) /
  1598. hal_srng_get_entrysize(hal_soc_hdl, WBM_IDLE_LINK);
  1599. }
  1600. /**
  1601. * hal_idle_list_num_scatter_bufs - Get the number of sctater buffer
  1602. * each given buffer size
  1603. *
  1604. * @hal_soc: Opaque HAL SOC handle
  1605. * @total_mem: size of memory to be scattered
  1606. * @scatter_buf_size: Size of scatter buffer
  1607. *
  1608. */
  1609. static inline
  1610. uint32_t hal_idle_list_num_scatter_bufs(hal_soc_handle_t hal_soc_hdl,
  1611. uint32_t total_mem,
  1612. uint32_t scatter_buf_size)
  1613. {
  1614. uint8_t rem = (total_mem % (scatter_buf_size -
  1615. WBM_IDLE_SCATTER_BUF_NEXT_PTR_SIZE)) ? 1 : 0;
  1616. uint32_t num_scatter_bufs = (total_mem / (scatter_buf_size -
  1617. WBM_IDLE_SCATTER_BUF_NEXT_PTR_SIZE)) + rem;
  1618. return num_scatter_bufs;
  1619. }
  1620. enum hal_pn_type {
  1621. HAL_PN_NONE,
  1622. HAL_PN_WPA,
  1623. HAL_PN_WAPI_EVEN,
  1624. HAL_PN_WAPI_UNEVEN,
  1625. };
  1626. #define HAL_RX_MAX_BA_WINDOW 256
  1627. /**
  1628. * hal_get_reo_qdesc_align - Get start address alignment for reo
  1629. * queue descriptors
  1630. *
  1631. * @hal_soc: Opaque HAL SOC handle
  1632. *
  1633. */
  1634. static inline
  1635. uint32_t hal_get_reo_qdesc_align(hal_soc_handle_t hal_soc_hdl)
  1636. {
  1637. return REO_QUEUE_DESC_ALIGN;
  1638. }
  1639. /**
  1640. * hal_reo_qdesc_setup - Setup HW REO queue descriptor
  1641. *
  1642. * @hal_soc: Opaque HAL SOC handle
  1643. * @ba_window_size: BlockAck window size
  1644. * @start_seq: Starting sequence number
  1645. * @hw_qdesc_vaddr: Virtual address of REO queue descriptor memory
  1646. * @hw_qdesc_paddr: Physical address of REO queue descriptor memory
  1647. * @pn_type: PN type (one of the types defined in 'enum hal_pn_type')
  1648. *
  1649. */
  1650. void hal_reo_qdesc_setup(hal_soc_handle_t hal_soc_hdl,
  1651. int tid, uint32_t ba_window_size,
  1652. uint32_t start_seq, void *hw_qdesc_vaddr,
  1653. qdf_dma_addr_t hw_qdesc_paddr,
  1654. int pn_type);
  1655. /**
  1656. * hal_srng_get_hp_addr - Get head pointer physical address
  1657. *
  1658. * @hal_soc: Opaque HAL SOC handle
  1659. * @hal_ring_hdl: Ring pointer (Source or Destination ring)
  1660. *
  1661. */
  1662. static inline qdf_dma_addr_t
  1663. hal_srng_get_hp_addr(void *hal_soc,
  1664. hal_ring_handle_t hal_ring_hdl)
  1665. {
  1666. struct hal_srng *srng = (struct hal_srng *)hal_ring_hdl;
  1667. struct hal_soc *hal = (struct hal_soc *)hal_soc;
  1668. if (srng->ring_dir == HAL_SRNG_SRC_RING) {
  1669. return hal->shadow_wrptr_mem_paddr +
  1670. ((unsigned long)(srng->u.src_ring.hp_addr) -
  1671. (unsigned long)(hal->shadow_wrptr_mem_vaddr));
  1672. } else {
  1673. return hal->shadow_rdptr_mem_paddr +
  1674. ((unsigned long)(srng->u.dst_ring.hp_addr) -
  1675. (unsigned long)(hal->shadow_rdptr_mem_vaddr));
  1676. }
  1677. }
  1678. /**
  1679. * hal_srng_get_tp_addr - Get tail pointer physical address
  1680. *
  1681. * @hal_soc: Opaque HAL SOC handle
  1682. * @hal_ring_hdl: Ring pointer (Source or Destination ring)
  1683. *
  1684. */
  1685. static inline qdf_dma_addr_t
  1686. hal_srng_get_tp_addr(void *hal_soc, hal_ring_handle_t hal_ring_hdl)
  1687. {
  1688. struct hal_srng *srng = (struct hal_srng *)hal_ring_hdl;
  1689. struct hal_soc *hal = (struct hal_soc *)hal_soc;
  1690. if (srng->ring_dir == HAL_SRNG_SRC_RING) {
  1691. return hal->shadow_rdptr_mem_paddr +
  1692. ((unsigned long)(srng->u.src_ring.tp_addr) -
  1693. (unsigned long)(hal->shadow_rdptr_mem_vaddr));
  1694. } else {
  1695. return hal->shadow_wrptr_mem_paddr +
  1696. ((unsigned long)(srng->u.dst_ring.tp_addr) -
  1697. (unsigned long)(hal->shadow_wrptr_mem_vaddr));
  1698. }
  1699. }
  1700. /**
  1701. * hal_srng_get_num_entries - Get total entries in the HAL Srng
  1702. *
  1703. * @hal_soc: Opaque HAL SOC handle
  1704. * @hal_ring_hdl: Ring pointer (Source or Destination ring)
  1705. *
  1706. * Return: total number of entries in hal ring
  1707. */
  1708. static inline
  1709. uint32_t hal_srng_get_num_entries(hal_soc_handle_t hal_soc_hdl,
  1710. hal_ring_handle_t hal_ring_hdl)
  1711. {
  1712. struct hal_srng *srng = (struct hal_srng *)hal_ring_hdl;
  1713. return srng->num_entries;
  1714. }
  1715. /**
  1716. * hal_get_srng_params - Retrieve SRNG parameters for a given ring from HAL
  1717. *
  1718. * @hal_soc: Opaque HAL SOC handle
  1719. * @hal_ring_hdl: Ring pointer (Source or Destination ring)
  1720. * @ring_params: SRNG parameters will be returned through this structure
  1721. */
  1722. void hal_get_srng_params(hal_soc_handle_t hal_soc_hdl,
  1723. hal_ring_handle_t hal_ring_hdl,
  1724. struct hal_srng_params *ring_params);
  1725. /**
  1726. * hal_mem_info - Retrieve hal memory base address
  1727. *
  1728. * @hal_soc: Opaque HAL SOC handle
  1729. * @mem: pointer to structure to be updated with hal mem info
  1730. */
  1731. void hal_get_meminfo(hal_soc_handle_t hal_soc_hdl, struct hal_mem_info *mem);
  1732. /**
  1733. * hal_get_target_type - Return target type
  1734. *
  1735. * @hal_soc: Opaque HAL SOC handle
  1736. */
  1737. uint32_t hal_get_target_type(hal_soc_handle_t hal_soc_hdl);
  1738. /**
  1739. * hal_get_ba_aging_timeout - Retrieve BA aging timeout
  1740. *
  1741. * @hal_soc: Opaque HAL SOC handle
  1742. * @ac: Access category
  1743. * @value: timeout duration in millisec
  1744. */
  1745. void hal_get_ba_aging_timeout(hal_soc_handle_t hal_soc_hdl, uint8_t ac,
  1746. uint32_t *value);
  1747. /**
  1748. * hal_set_aging_timeout - Set BA aging timeout
  1749. *
  1750. * @hal_soc: Opaque HAL SOC handle
  1751. * @ac: Access category in millisec
  1752. * @value: timeout duration value
  1753. */
  1754. void hal_set_ba_aging_timeout(hal_soc_handle_t hal_soc_hdl, uint8_t ac,
  1755. uint32_t value);
  1756. /**
  1757. * hal_srng_dst_hw_init - Private function to initialize SRNG
  1758. * destination ring HW
  1759. * @hal_soc: HAL SOC handle
  1760. * @srng: SRNG ring pointer
  1761. */
  1762. static inline void hal_srng_dst_hw_init(struct hal_soc *hal,
  1763. struct hal_srng *srng)
  1764. {
  1765. hal->ops->hal_srng_dst_hw_init(hal, srng);
  1766. }
  1767. /**
  1768. * hal_srng_src_hw_init - Private function to initialize SRNG
  1769. * source ring HW
  1770. * @hal_soc: HAL SOC handle
  1771. * @srng: SRNG ring pointer
  1772. */
  1773. static inline void hal_srng_src_hw_init(struct hal_soc *hal,
  1774. struct hal_srng *srng)
  1775. {
  1776. hal->ops->hal_srng_src_hw_init(hal, srng);
  1777. }
  1778. /**
  1779. * hal_get_hw_hptp() - Get HW head and tail pointer value for any ring
  1780. * @hal_soc: Opaque HAL SOC handle
  1781. * @hal_ring_hdl: Source ring pointer
  1782. * @headp: Head Pointer
  1783. * @tailp: Tail Pointer
  1784. * @ring_type: Ring
  1785. *
  1786. * Return: Update tail pointer and head pointer in arguments.
  1787. */
  1788. static inline
  1789. void hal_get_hw_hptp(hal_soc_handle_t hal_soc_hdl,
  1790. hal_ring_handle_t hal_ring_hdl,
  1791. uint32_t *headp, uint32_t *tailp,
  1792. uint8_t ring_type)
  1793. {
  1794. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  1795. hal_soc->ops->hal_get_hw_hptp(hal_soc, hal_ring_hdl,
  1796. headp, tailp, ring_type);
  1797. }
  1798. /**
  1799. * hal_reo_setup - Initialize HW REO block
  1800. *
  1801. * @hal_soc: Opaque HAL SOC handle
  1802. * @reo_params: parameters needed by HAL for REO config
  1803. */
  1804. static inline void hal_reo_setup(hal_soc_handle_t hal_soc_hdl,
  1805. void *reoparams)
  1806. {
  1807. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  1808. hal_soc->ops->hal_reo_setup(hal_soc, reoparams);
  1809. }
  1810. /**
  1811. * hal_setup_link_idle_list - Setup scattered idle list using the
  1812. * buffer list provided
  1813. *
  1814. * @hal_soc: Opaque HAL SOC handle
  1815. * @scatter_bufs_base_paddr: Array of physical base addresses
  1816. * @scatter_bufs_base_vaddr: Array of virtual base addresses
  1817. * @num_scatter_bufs: Number of scatter buffers in the above lists
  1818. * @scatter_buf_size: Size of each scatter buffer
  1819. * @last_buf_end_offset: Offset to the last entry
  1820. * @num_entries: Total entries of all scatter bufs
  1821. *
  1822. */
  1823. static inline
  1824. void hal_setup_link_idle_list(hal_soc_handle_t hal_soc_hdl,
  1825. qdf_dma_addr_t scatter_bufs_base_paddr[],
  1826. void *scatter_bufs_base_vaddr[],
  1827. uint32_t num_scatter_bufs,
  1828. uint32_t scatter_buf_size,
  1829. uint32_t last_buf_end_offset,
  1830. uint32_t num_entries)
  1831. {
  1832. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  1833. hal_soc->ops->hal_setup_link_idle_list(hal_soc, scatter_bufs_base_paddr,
  1834. scatter_bufs_base_vaddr, num_scatter_bufs,
  1835. scatter_buf_size, last_buf_end_offset,
  1836. num_entries);
  1837. }
  1838. /**
  1839. * hal_srng_dump_ring_desc() - Dump ring descriptor info
  1840. *
  1841. * @hal_soc: Opaque HAL SOC handle
  1842. * @hal_ring_hdl: Source ring pointer
  1843. * @ring_desc: Opaque ring descriptor handle
  1844. */
  1845. static inline void hal_srng_dump_ring_desc(hal_soc_handle_t hal_soc_hdl,
  1846. hal_ring_handle_t hal_ring_hdl,
  1847. hal_ring_desc_t ring_desc)
  1848. {
  1849. struct hal_srng *srng = (struct hal_srng *)hal_ring_hdl;
  1850. QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_INFO_HIGH,
  1851. ring_desc, (srng->entry_size << 2));
  1852. }
  1853. /**
  1854. * hal_srng_dump_ring() - Dump last 128 descs of the ring
  1855. *
  1856. * @hal_soc: Opaque HAL SOC handle
  1857. * @hal_ring_hdl: Source ring pointer
  1858. */
  1859. static inline void hal_srng_dump_ring(hal_soc_handle_t hal_soc_hdl,
  1860. hal_ring_handle_t hal_ring_hdl)
  1861. {
  1862. struct hal_srng *srng = (struct hal_srng *)hal_ring_hdl;
  1863. uint32_t *desc;
  1864. uint32_t tp, i;
  1865. tp = srng->u.dst_ring.tp;
  1866. for (i = 0; i < 128; i++) {
  1867. if (!tp)
  1868. tp = srng->ring_size;
  1869. desc = &srng->ring_base_vaddr[tp - srng->entry_size];
  1870. QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_DP,
  1871. QDF_TRACE_LEVEL_DEBUG,
  1872. desc, (srng->entry_size << 2));
  1873. tp -= srng->entry_size;
  1874. }
  1875. }
  1876. /*
  1877. * hal_rxdma_desc_to_hal_ring_desc - API to convert rxdma ring desc
  1878. * to opaque dp_ring desc type
  1879. * @ring_desc - rxdma ring desc
  1880. *
  1881. * Return: hal_rxdma_desc_t type
  1882. */
  1883. static inline
  1884. hal_ring_desc_t hal_rxdma_desc_to_hal_ring_desc(hal_rxdma_desc_t ring_desc)
  1885. {
  1886. return (hal_ring_desc_t)ring_desc;
  1887. }
  1888. /**
  1889. * hal_srng_set_event() - Set hal_srng event
  1890. * @hal_ring_hdl: Source ring pointer
  1891. * @event: SRNG ring event
  1892. *
  1893. * Return: None
  1894. */
  1895. static inline void hal_srng_set_event(hal_ring_handle_t hal_ring_hdl, int event)
  1896. {
  1897. struct hal_srng *srng = (struct hal_srng *)hal_ring_hdl;
  1898. qdf_atomic_set_bit(event, &srng->srng_event);
  1899. }
  1900. /**
  1901. * hal_srng_clear_event() - Clear hal_srng event
  1902. * @hal_ring_hdl: Source ring pointer
  1903. * @event: SRNG ring event
  1904. *
  1905. * Return: None
  1906. */
  1907. static inline
  1908. void hal_srng_clear_event(hal_ring_handle_t hal_ring_hdl, int event)
  1909. {
  1910. struct hal_srng *srng = (struct hal_srng *)hal_ring_hdl;
  1911. qdf_atomic_clear_bit(event, &srng->srng_event);
  1912. }
  1913. /**
  1914. * hal_srng_get_clear_event() - Clear srng event and return old value
  1915. * @hal_ring_hdl: Source ring pointer
  1916. * @event: SRNG ring event
  1917. *
  1918. * Return: Return old event value
  1919. */
  1920. static inline
  1921. int hal_srng_get_clear_event(hal_ring_handle_t hal_ring_hdl, int event)
  1922. {
  1923. struct hal_srng *srng = (struct hal_srng *)hal_ring_hdl;
  1924. return qdf_atomic_test_and_clear_bit(event, &srng->srng_event);
  1925. }
  1926. /**
  1927. * hal_srng_set_flush_last_ts() - Record last flush time stamp
  1928. * @hal_ring_hdl: Source ring pointer
  1929. *
  1930. * Return: None
  1931. */
  1932. static inline void hal_srng_set_flush_last_ts(hal_ring_handle_t hal_ring_hdl)
  1933. {
  1934. struct hal_srng *srng = (struct hal_srng *)hal_ring_hdl;
  1935. srng->last_flush_ts = qdf_get_log_timestamp();
  1936. }
  1937. /**
  1938. * hal_srng_inc_flush_cnt() - Increment flush counter
  1939. * @hal_ring_hdl: Source ring pointer
  1940. *
  1941. * Return: None
  1942. */
  1943. static inline void hal_srng_inc_flush_cnt(hal_ring_handle_t hal_ring_hdl)
  1944. {
  1945. struct hal_srng *srng = (struct hal_srng *)hal_ring_hdl;
  1946. srng->flush_count++;
  1947. }
  1948. /**
  1949. * hal_rx_sw_mon_desc_info_get () - Get SW monitor desc info
  1950. *
  1951. * @hal: Core HAL soc handle
  1952. * @ring_desc: Mon dest ring descriptor
  1953. * @desc_info: Desc info to be populated
  1954. *
  1955. * Return void
  1956. */
  1957. static inline void
  1958. hal_rx_sw_mon_desc_info_get(struct hal_soc *hal,
  1959. hal_ring_desc_t ring_desc,
  1960. hal_rx_mon_desc_info_t desc_info)
  1961. {
  1962. return hal->ops->hal_rx_sw_mon_desc_info_get(ring_desc, desc_info);
  1963. }
  1964. /**
  1965. * hal_reo_set_err_dst_remap() - Set REO error destination ring remap
  1966. * register value.
  1967. *
  1968. * @hal_soc_hdl: Opaque HAL soc handle
  1969. *
  1970. * Return: None
  1971. */
  1972. static inline void hal_reo_set_err_dst_remap(hal_soc_handle_t hal_soc_hdl)
  1973. {
  1974. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  1975. if (hal_soc->ops->hal_reo_set_err_dst_remap)
  1976. hal_soc->ops->hal_reo_set_err_dst_remap(hal_soc);
  1977. }
  1978. #endif /* _HAL_APIH_ */