hal_api.h 61 KB

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