hal_api.h 61 KB

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