hal_api.h 62 KB

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