hal_reo.c 43 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411
  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. #include "hal_api.h"
  19. #include "hal_hw_headers.h"
  20. #include "hal_reo.h"
  21. #include "hal_tx.h"
  22. #include "hal_rx.h"
  23. #include "qdf_module.h"
  24. /* TODO: See if the following definition is available in HW headers */
  25. #define HAL_REO_OWNED 4
  26. #define HAL_REO_QUEUE_DESC 8
  27. #define HAL_REO_QUEUE_EXT_DESC 9
  28. /* TODO: Using associated link desc counter 1 for Rx. Check with FW on
  29. * how these counters are assigned
  30. */
  31. #define HAL_RX_LINK_DESC_CNTR 1
  32. /* TODO: Following definition should be from HW headers */
  33. #define HAL_DESC_REO_OWNED 4
  34. /**
  35. * hal_uniform_desc_hdr_setup - setup reo_queue_ext descritpro
  36. * @owner - owner info
  37. * @buffer_type - buffer type
  38. */
  39. static inline void hal_uniform_desc_hdr_setup(uint32_t *desc, uint32_t owner,
  40. uint32_t buffer_type)
  41. {
  42. HAL_DESC_SET_FIELD(desc, UNIFORM_DESCRIPTOR_HEADER_0, OWNER,
  43. owner);
  44. HAL_DESC_SET_FIELD(desc, UNIFORM_DESCRIPTOR_HEADER_0, BUFFER_TYPE,
  45. buffer_type);
  46. }
  47. #ifndef TID_TO_WME_AC
  48. #define WME_AC_BE 0 /* best effort */
  49. #define WME_AC_BK 1 /* background */
  50. #define WME_AC_VI 2 /* video */
  51. #define WME_AC_VO 3 /* voice */
  52. #define TID_TO_WME_AC(_tid) ( \
  53. (((_tid) == 0) || ((_tid) == 3)) ? WME_AC_BE : \
  54. (((_tid) == 1) || ((_tid) == 2)) ? WME_AC_BK : \
  55. (((_tid) == 4) || ((_tid) == 5)) ? WME_AC_VI : \
  56. WME_AC_VO)
  57. #endif
  58. #define HAL_NON_QOS_TID 16
  59. #ifdef HAL_DISABLE_NON_BA_2K_JUMP_ERROR
  60. static inline uint32_t hal_update_non_ba_win_size(int tid,
  61. uint32_t ba_window_size)
  62. {
  63. return ba_window_size;
  64. }
  65. #else
  66. static inline uint32_t hal_update_non_ba_win_size(int tid,
  67. uint32_t ba_window_size)
  68. {
  69. if ((ba_window_size == 1) && (tid != HAL_NON_QOS_TID))
  70. ba_window_size++;
  71. return ba_window_size;
  72. }
  73. #endif
  74. /**
  75. * hal_reo_qdesc_setup - Setup HW REO queue descriptor
  76. *
  77. * @hal_soc: Opaque HAL SOC handle
  78. * @ba_window_size: BlockAck window size
  79. * @start_seq: Starting sequence number
  80. * @hw_qdesc_vaddr: Virtual address of REO queue descriptor memory
  81. * @hw_qdesc_paddr: Physical address of REO queue descriptor memory
  82. * @tid: TID
  83. *
  84. */
  85. void hal_reo_qdesc_setup(hal_soc_handle_t hal_soc_hdl, int tid,
  86. uint32_t ba_window_size,
  87. uint32_t start_seq, void *hw_qdesc_vaddr,
  88. qdf_dma_addr_t hw_qdesc_paddr,
  89. int pn_type)
  90. {
  91. uint32_t *reo_queue_desc = (uint32_t *)hw_qdesc_vaddr;
  92. uint32_t *reo_queue_ext_desc;
  93. uint32_t reg_val;
  94. uint32_t pn_enable;
  95. uint32_t pn_size = 0;
  96. qdf_mem_zero(hw_qdesc_vaddr, sizeof(struct rx_reo_queue));
  97. hal_uniform_desc_hdr_setup(reo_queue_desc, HAL_DESC_REO_OWNED,
  98. HAL_REO_QUEUE_DESC);
  99. /* Fixed pattern in reserved bits for debugging */
  100. HAL_DESC_SET_FIELD(reo_queue_desc, UNIFORM_DESCRIPTOR_HEADER_0,
  101. RESERVED_0A, 0xDDBEEF);
  102. /* This a just a SW meta data and will be copied to REO destination
  103. * descriptors indicated by hardware.
  104. * TODO: Setting TID in this field. See if we should set something else.
  105. */
  106. HAL_DESC_SET_FIELD(reo_queue_desc, RX_REO_QUEUE_1,
  107. RECEIVE_QUEUE_NUMBER, tid);
  108. HAL_DESC_SET_FIELD(reo_queue_desc, RX_REO_QUEUE_2,
  109. VLD, 1);
  110. HAL_DESC_SET_FIELD(reo_queue_desc, RX_REO_QUEUE_2,
  111. ASSOCIATED_LINK_DESCRIPTOR_COUNTER, HAL_RX_LINK_DESC_CNTR);
  112. /*
  113. * Fields DISABLE_DUPLICATE_DETECTION and SOFT_REORDER_ENABLE will be 0
  114. */
  115. reg_val = TID_TO_WME_AC(tid);
  116. HAL_DESC_SET_FIELD(reo_queue_desc, RX_REO_QUEUE_2, AC, reg_val);
  117. if (ba_window_size < 1)
  118. ba_window_size = 1;
  119. /* WAR to get 2k exception in Non BA case.
  120. * Setting window size to 2 to get 2k jump exception
  121. * when we receive aggregates in Non BA case
  122. */
  123. ba_window_size = hal_update_non_ba_win_size(tid, ba_window_size);
  124. /* Set RTY bit for non-BA case. Duplicate detection is currently not
  125. * done by HW in non-BA case if RTY bit is not set.
  126. * TODO: This is a temporary War and should be removed once HW fix is
  127. * made to check and discard duplicates even if RTY bit is not set.
  128. */
  129. if (ba_window_size == 1)
  130. HAL_DESC_SET_FIELD(reo_queue_desc, RX_REO_QUEUE_2, RTY, 1);
  131. HAL_DESC_SET_FIELD(reo_queue_desc, RX_REO_QUEUE_2, BA_WINDOW_SIZE,
  132. ba_window_size - 1);
  133. switch (pn_type) {
  134. case HAL_PN_WPA:
  135. pn_enable = 1;
  136. pn_size = PN_SIZE_48;
  137. break;
  138. case HAL_PN_WAPI_EVEN:
  139. case HAL_PN_WAPI_UNEVEN:
  140. pn_enable = 1;
  141. pn_size = PN_SIZE_128;
  142. break;
  143. default:
  144. pn_enable = 0;
  145. break;
  146. }
  147. HAL_DESC_SET_FIELD(reo_queue_desc, RX_REO_QUEUE_2, PN_CHECK_NEEDED,
  148. pn_enable);
  149. if (pn_type == HAL_PN_WAPI_EVEN)
  150. HAL_DESC_SET_FIELD(reo_queue_desc, RX_REO_QUEUE_2,
  151. PN_SHALL_BE_EVEN, 1);
  152. else if (pn_type == HAL_PN_WAPI_UNEVEN)
  153. HAL_DESC_SET_FIELD(reo_queue_desc, RX_REO_QUEUE_2,
  154. PN_SHALL_BE_UNEVEN, 1);
  155. /*
  156. * TODO: Need to check if PN handling in SW needs to be enabled
  157. * So far this is not a requirement
  158. */
  159. HAL_DESC_SET_FIELD(reo_queue_desc, RX_REO_QUEUE_2, PN_SIZE,
  160. pn_size);
  161. /* TODO: Check if RX_REO_QUEUE_2_IGNORE_AMPDU_FLAG need to be set
  162. * based on BA window size and/or AMPDU capabilities
  163. */
  164. HAL_DESC_SET_FIELD(reo_queue_desc, RX_REO_QUEUE_2,
  165. IGNORE_AMPDU_FLAG, 1);
  166. if (start_seq <= 0xfff)
  167. HAL_DESC_SET_FIELD(reo_queue_desc, RX_REO_QUEUE_3, SSN,
  168. start_seq);
  169. /* TODO: SVLD should be set to 1 if a valid SSN is received in ADDBA,
  170. * but REO is not delivering packets if we set it to 1. Need to enable
  171. * this once the issue is resolved
  172. */
  173. HAL_DESC_SET_FIELD(reo_queue_desc, RX_REO_QUEUE_3, SVLD, 0);
  174. /* TODO: Check if we should set start PN for WAPI */
  175. #ifdef notyet
  176. /* Setup first queue extension if BA window size is more than 1 */
  177. if (ba_window_size > 1) {
  178. reo_queue_ext_desc =
  179. (uint32_t *)(((struct rx_reo_queue *)reo_queue_desc) +
  180. 1);
  181. qdf_mem_zero(reo_queue_ext_desc,
  182. sizeof(struct rx_reo_queue_ext));
  183. hal_uniform_desc_hdr_setup(reo_queue_ext_desc,
  184. HAL_DESC_REO_OWNED, HAL_REO_QUEUE_EXT_DESC);
  185. }
  186. /* Setup second queue extension if BA window size is more than 105 */
  187. if (ba_window_size > 105) {
  188. reo_queue_ext_desc = (uint32_t *)
  189. (((struct rx_reo_queue_ext *)reo_queue_ext_desc) + 1);
  190. qdf_mem_zero(reo_queue_ext_desc,
  191. sizeof(struct rx_reo_queue_ext));
  192. hal_uniform_desc_hdr_setup(reo_queue_ext_desc,
  193. HAL_DESC_REO_OWNED, HAL_REO_QUEUE_EXT_DESC);
  194. }
  195. /* Setup third queue extension if BA window size is more than 210 */
  196. if (ba_window_size > 210) {
  197. reo_queue_ext_desc = (uint32_t *)
  198. (((struct rx_reo_queue_ext *)reo_queue_ext_desc) + 1);
  199. qdf_mem_zero(reo_queue_ext_desc,
  200. sizeof(struct rx_reo_queue_ext));
  201. hal_uniform_desc_hdr_setup(reo_queue_ext_desc,
  202. HAL_DESC_REO_OWNED, HAL_REO_QUEUE_EXT_DESC);
  203. }
  204. #else
  205. /* TODO: HW queue descriptors are currently allocated for max BA
  206. * window size for all QOS TIDs so that same descriptor can be used
  207. * later when ADDBA request is recevied. This should be changed to
  208. * allocate HW queue descriptors based on BA window size being
  209. * negotiated (0 for non BA cases), and reallocate when BA window
  210. * size changes and also send WMI message to FW to change the REO
  211. * queue descriptor in Rx peer entry as part of dp_rx_tid_update.
  212. */
  213. if (tid != HAL_NON_QOS_TID) {
  214. reo_queue_ext_desc = (uint32_t *)
  215. (((struct rx_reo_queue *)reo_queue_desc) + 1);
  216. qdf_mem_zero(reo_queue_ext_desc, 3 *
  217. sizeof(struct rx_reo_queue_ext));
  218. /* Initialize first reo queue extension descriptor */
  219. hal_uniform_desc_hdr_setup(reo_queue_ext_desc,
  220. HAL_DESC_REO_OWNED, HAL_REO_QUEUE_EXT_DESC);
  221. /* Fixed pattern in reserved bits for debugging */
  222. HAL_DESC_SET_FIELD(reo_queue_ext_desc,
  223. UNIFORM_DESCRIPTOR_HEADER_0, RESERVED_0A, 0xADBEEF);
  224. /* Initialize second reo queue extension descriptor */
  225. reo_queue_ext_desc = (uint32_t *)
  226. (((struct rx_reo_queue_ext *)reo_queue_ext_desc) + 1);
  227. hal_uniform_desc_hdr_setup(reo_queue_ext_desc,
  228. HAL_DESC_REO_OWNED, HAL_REO_QUEUE_EXT_DESC);
  229. /* Fixed pattern in reserved bits for debugging */
  230. HAL_DESC_SET_FIELD(reo_queue_ext_desc,
  231. UNIFORM_DESCRIPTOR_HEADER_0, RESERVED_0A, 0xBDBEEF);
  232. /* Initialize third reo queue extension descriptor */
  233. reo_queue_ext_desc = (uint32_t *)
  234. (((struct rx_reo_queue_ext *)reo_queue_ext_desc) + 1);
  235. hal_uniform_desc_hdr_setup(reo_queue_ext_desc,
  236. HAL_DESC_REO_OWNED, HAL_REO_QUEUE_EXT_DESC);
  237. /* Fixed pattern in reserved bits for debugging */
  238. HAL_DESC_SET_FIELD(reo_queue_ext_desc,
  239. UNIFORM_DESCRIPTOR_HEADER_0, RESERVED_0A, 0xCDBEEF);
  240. }
  241. #endif
  242. }
  243. qdf_export_symbol(hal_reo_qdesc_setup);
  244. /**
  245. * hal_get_ba_aging_timeout - Get BA Aging timeout
  246. *
  247. * @hal_soc: Opaque HAL SOC handle
  248. * @ac: Access category
  249. * @value: window size to get
  250. */
  251. void hal_get_ba_aging_timeout(hal_soc_handle_t hal_soc_hdl, uint8_t ac,
  252. uint32_t *value)
  253. {
  254. struct hal_soc *soc = (struct hal_soc *)hal_soc_hdl;
  255. switch (ac) {
  256. case WME_AC_BE:
  257. *value = HAL_REG_READ(soc,
  258. HWIO_REO_R0_AGING_THRESHOLD_IX_0_ADDR(
  259. SEQ_WCSS_UMAC_REO_REG_OFFSET)) / 1000;
  260. break;
  261. case WME_AC_BK:
  262. *value = HAL_REG_READ(soc,
  263. HWIO_REO_R0_AGING_THRESHOLD_IX_1_ADDR(
  264. SEQ_WCSS_UMAC_REO_REG_OFFSET)) / 1000;
  265. break;
  266. case WME_AC_VI:
  267. *value = HAL_REG_READ(soc,
  268. HWIO_REO_R0_AGING_THRESHOLD_IX_2_ADDR(
  269. SEQ_WCSS_UMAC_REO_REG_OFFSET)) / 1000;
  270. break;
  271. case WME_AC_VO:
  272. *value = HAL_REG_READ(soc,
  273. HWIO_REO_R0_AGING_THRESHOLD_IX_3_ADDR(
  274. SEQ_WCSS_UMAC_REO_REG_OFFSET)) / 1000;
  275. break;
  276. default:
  277. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  278. "Invalid AC: %d\n", ac);
  279. }
  280. }
  281. qdf_export_symbol(hal_get_ba_aging_timeout);
  282. /**
  283. * hal_set_ba_aging_timeout - Set BA Aging timeout
  284. *
  285. * @hal_soc: Opaque HAL SOC handle
  286. * @ac: Access category
  287. * ac: 0 - Background, 1 - Best Effort, 2 - Video, 3 - Voice
  288. * @value: Input value to set
  289. */
  290. void hal_set_ba_aging_timeout(hal_soc_handle_t hal_soc_hdl, uint8_t ac,
  291. uint32_t value)
  292. {
  293. struct hal_soc *soc = (struct hal_soc *)hal_soc_hdl;
  294. switch (ac) {
  295. case WME_AC_BE:
  296. HAL_REG_WRITE(soc,
  297. HWIO_REO_R0_AGING_THRESHOLD_IX_0_ADDR(
  298. SEQ_WCSS_UMAC_REO_REG_OFFSET),
  299. value * 1000);
  300. break;
  301. case WME_AC_BK:
  302. HAL_REG_WRITE(soc,
  303. HWIO_REO_R0_AGING_THRESHOLD_IX_1_ADDR(
  304. SEQ_WCSS_UMAC_REO_REG_OFFSET),
  305. value * 1000);
  306. break;
  307. case WME_AC_VI:
  308. HAL_REG_WRITE(soc,
  309. HWIO_REO_R0_AGING_THRESHOLD_IX_2_ADDR(
  310. SEQ_WCSS_UMAC_REO_REG_OFFSET),
  311. value * 1000);
  312. break;
  313. case WME_AC_VO:
  314. HAL_REG_WRITE(soc,
  315. HWIO_REO_R0_AGING_THRESHOLD_IX_3_ADDR(
  316. SEQ_WCSS_UMAC_REO_REG_OFFSET),
  317. value * 1000);
  318. break;
  319. default:
  320. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  321. "Invalid AC: %d\n", ac);
  322. }
  323. }
  324. qdf_export_symbol(hal_set_ba_aging_timeout);
  325. #define BLOCK_RES_MASK 0xF
  326. static inline uint8_t hal_find_one_bit(uint8_t x)
  327. {
  328. uint8_t y = (x & (~x + 1)) & BLOCK_RES_MASK;
  329. uint8_t pos;
  330. for (pos = 0; y; y >>= 1)
  331. pos++;
  332. return pos-1;
  333. }
  334. static inline uint8_t hal_find_zero_bit(uint8_t x)
  335. {
  336. uint8_t y = (~x & (x+1)) & BLOCK_RES_MASK;
  337. uint8_t pos;
  338. for (pos = 0; y; y >>= 1)
  339. pos++;
  340. return pos-1;
  341. }
  342. inline void hal_reo_cmd_set_descr_addr(uint32_t *reo_desc,
  343. enum hal_reo_cmd_type type,
  344. uint32_t paddr_lo,
  345. uint8_t paddr_hi)
  346. {
  347. switch (type) {
  348. case CMD_GET_QUEUE_STATS:
  349. HAL_DESC_SET_FIELD(reo_desc, REO_GET_QUEUE_STATS_1,
  350. RX_REO_QUEUE_DESC_ADDR_31_0, paddr_lo);
  351. HAL_DESC_SET_FIELD(reo_desc, REO_GET_QUEUE_STATS_2,
  352. RX_REO_QUEUE_DESC_ADDR_39_32, paddr_hi);
  353. break;
  354. case CMD_FLUSH_QUEUE:
  355. HAL_DESC_SET_FIELD(reo_desc, REO_FLUSH_QUEUE_1,
  356. FLUSH_DESC_ADDR_31_0, paddr_lo);
  357. HAL_DESC_SET_FIELD(reo_desc, REO_FLUSH_QUEUE_2,
  358. FLUSH_DESC_ADDR_39_32, paddr_hi);
  359. break;
  360. case CMD_FLUSH_CACHE:
  361. HAL_DESC_SET_FIELD(reo_desc, REO_FLUSH_CACHE_1,
  362. FLUSH_ADDR_31_0, paddr_lo);
  363. HAL_DESC_SET_FIELD(reo_desc, REO_FLUSH_CACHE_2,
  364. FLUSH_ADDR_39_32, paddr_hi);
  365. break;
  366. case CMD_UPDATE_RX_REO_QUEUE:
  367. HAL_DESC_SET_FIELD(reo_desc, REO_UPDATE_RX_REO_QUEUE_1,
  368. RX_REO_QUEUE_DESC_ADDR_31_0, paddr_lo);
  369. HAL_DESC_SET_FIELD(reo_desc, REO_UPDATE_RX_REO_QUEUE_2,
  370. RX_REO_QUEUE_DESC_ADDR_39_32, paddr_hi);
  371. break;
  372. default:
  373. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
  374. "%s: Invalid REO command type", __func__);
  375. break;
  376. }
  377. }
  378. inline int hal_reo_cmd_queue_stats(hal_ring_handle_t hal_ring_hdl,
  379. hal_soc_handle_t hal_soc_hdl,
  380. struct hal_reo_cmd_params *cmd)
  381. {
  382. uint32_t *reo_desc, val;
  383. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  384. hal_srng_access_start(hal_soc_hdl, hal_ring_hdl);
  385. reo_desc = hal_srng_src_get_next(hal_soc, hal_ring_hdl);
  386. if (!reo_desc) {
  387. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_DEBUG,
  388. "%s: Out of cmd ring entries", __func__);
  389. hal_srng_access_end(hal_soc, hal_ring_hdl);
  390. return -EBUSY;
  391. }
  392. HAL_SET_TLV_HDR(reo_desc, WIFIREO_GET_QUEUE_STATS_E,
  393. sizeof(struct reo_get_queue_stats));
  394. /* Offsets of descriptor fields defined in HW headers start from
  395. * the field after TLV header */
  396. reo_desc += (sizeof(struct tlv_32_hdr) >> 2);
  397. qdf_mem_zero((reo_desc + NUM_OF_DWORDS_UNIFORM_REO_CMD_HEADER),
  398. sizeof(struct reo_get_queue_stats) -
  399. (NUM_OF_DWORDS_UNIFORM_REO_CMD_HEADER << 2));
  400. HAL_DESC_SET_FIELD(reo_desc, UNIFORM_REO_CMD_HEADER_0,
  401. REO_STATUS_REQUIRED, cmd->std.need_status);
  402. hal_reo_cmd_set_descr_addr(reo_desc, CMD_GET_QUEUE_STATS,
  403. cmd->std.addr_lo,
  404. cmd->std.addr_hi);
  405. HAL_DESC_SET_FIELD(reo_desc, REO_GET_QUEUE_STATS_2, CLEAR_STATS,
  406. cmd->u.stats_params.clear);
  407. if (hif_pm_runtime_get(hal_soc->hif_handle,
  408. RTPM_ID_HAL_REO_CMD) == 0) {
  409. hal_srng_access_end(hal_soc_hdl, hal_ring_hdl);
  410. hif_pm_runtime_put(hal_soc->hif_handle,
  411. RTPM_ID_HAL_REO_CMD);
  412. } else {
  413. hal_srng_access_end_reap(hal_soc_hdl, hal_ring_hdl);
  414. hal_srng_set_event(hal_ring_hdl, HAL_SRNG_FLUSH_EVENT);
  415. hal_srng_inc_flush_cnt(hal_ring_hdl);
  416. }
  417. val = reo_desc[CMD_HEADER_DW_OFFSET];
  418. return HAL_GET_FIELD(UNIFORM_REO_CMD_HEADER_0, REO_CMD_NUMBER,
  419. val);
  420. }
  421. qdf_export_symbol(hal_reo_cmd_queue_stats);
  422. inline int hal_reo_cmd_flush_queue(hal_ring_handle_t hal_ring_hdl,
  423. hal_soc_handle_t hal_soc_hdl,
  424. struct hal_reo_cmd_params *cmd)
  425. {
  426. uint32_t *reo_desc, val;
  427. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  428. hal_srng_access_start(hal_soc_hdl, hal_ring_hdl);
  429. reo_desc = hal_srng_src_get_next(hal_soc, hal_ring_hdl);
  430. if (!reo_desc) {
  431. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_DEBUG,
  432. "%s: Out of cmd ring entries", __func__);
  433. hal_srng_access_end(hal_soc, hal_ring_hdl);
  434. return -EBUSY;
  435. }
  436. HAL_SET_TLV_HDR(reo_desc, WIFIREO_FLUSH_QUEUE_E,
  437. sizeof(struct reo_flush_queue));
  438. /* Offsets of descriptor fields defined in HW headers start from
  439. * the field after TLV header */
  440. reo_desc += (sizeof(struct tlv_32_hdr) >> 2);
  441. qdf_mem_zero((reo_desc + NUM_OF_DWORDS_UNIFORM_REO_CMD_HEADER),
  442. sizeof(struct reo_flush_queue) -
  443. (NUM_OF_DWORDS_UNIFORM_REO_CMD_HEADER << 2));
  444. HAL_DESC_SET_FIELD(reo_desc, UNIFORM_REO_CMD_HEADER_0,
  445. REO_STATUS_REQUIRED, cmd->std.need_status);
  446. hal_reo_cmd_set_descr_addr(reo_desc, CMD_FLUSH_QUEUE, cmd->std.addr_lo,
  447. cmd->std.addr_hi);
  448. HAL_DESC_SET_FIELD(reo_desc, REO_FLUSH_QUEUE_2,
  449. BLOCK_DESC_ADDR_USAGE_AFTER_FLUSH,
  450. cmd->u.fl_queue_params.block_use_after_flush);
  451. if (cmd->u.fl_queue_params.block_use_after_flush) {
  452. HAL_DESC_SET_FIELD(reo_desc, REO_FLUSH_QUEUE_2,
  453. BLOCK_RESOURCE_INDEX, cmd->u.fl_queue_params.index);
  454. }
  455. hal_srng_access_end(hal_soc, hal_ring_hdl);
  456. val = reo_desc[CMD_HEADER_DW_OFFSET];
  457. return HAL_GET_FIELD(UNIFORM_REO_CMD_HEADER_0, REO_CMD_NUMBER,
  458. val);
  459. }
  460. qdf_export_symbol(hal_reo_cmd_flush_queue);
  461. inline int hal_reo_cmd_flush_cache(hal_ring_handle_t hal_ring_hdl,
  462. hal_soc_handle_t hal_soc_hdl,
  463. struct hal_reo_cmd_params *cmd)
  464. {
  465. uint32_t *reo_desc, val;
  466. struct hal_reo_cmd_flush_cache_params *cp;
  467. uint8_t index = 0;
  468. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  469. cp = &cmd->u.fl_cache_params;
  470. hal_srng_access_start(hal_soc_hdl, hal_ring_hdl);
  471. /* We need a cache block resource for this operation, and REO HW has
  472. * only 4 such blocking resources. These resources are managed using
  473. * reo_res_bitmap, and we return failure if none is available.
  474. */
  475. if (cp->block_use_after_flush) {
  476. index = hal_find_zero_bit(hal_soc->reo_res_bitmap);
  477. if (index > 3) {
  478. qdf_print("%s, No blocking resource available!",
  479. __func__);
  480. hal_srng_access_end(hal_soc, hal_ring_hdl);
  481. return -EBUSY;
  482. }
  483. hal_soc->index = index;
  484. }
  485. reo_desc = hal_srng_src_get_next(hal_soc, hal_ring_hdl);
  486. if (!reo_desc) {
  487. hal_srng_access_end(hal_soc, hal_ring_hdl);
  488. hal_srng_dump(hal_ring_handle_to_hal_srng(hal_ring_hdl));
  489. return -EBUSY;
  490. }
  491. HAL_SET_TLV_HDR(reo_desc, WIFIREO_FLUSH_CACHE_E,
  492. sizeof(struct reo_flush_cache));
  493. /* Offsets of descriptor fields defined in HW headers start from
  494. * the field after TLV header */
  495. reo_desc += (sizeof(struct tlv_32_hdr) >> 2);
  496. qdf_mem_zero((reo_desc + NUM_OF_DWORDS_UNIFORM_REO_CMD_HEADER),
  497. sizeof(struct reo_flush_cache) -
  498. (NUM_OF_DWORDS_UNIFORM_REO_CMD_HEADER << 2));
  499. HAL_DESC_SET_FIELD(reo_desc, UNIFORM_REO_CMD_HEADER_0,
  500. REO_STATUS_REQUIRED, cmd->std.need_status);
  501. hal_reo_cmd_set_descr_addr(reo_desc, CMD_FLUSH_CACHE, cmd->std.addr_lo,
  502. cmd->std.addr_hi);
  503. HAL_DESC_SET_FIELD(reo_desc, REO_FLUSH_CACHE_2,
  504. FORWARD_ALL_MPDUS_IN_QUEUE, cp->fwd_mpdus_in_queue);
  505. /* set it to 0 for now */
  506. cp->rel_block_index = 0;
  507. HAL_DESC_SET_FIELD(reo_desc, REO_FLUSH_CACHE_2,
  508. RELEASE_CACHE_BLOCK_INDEX, cp->rel_block_index);
  509. if (cp->block_use_after_flush) {
  510. HAL_DESC_SET_FIELD(reo_desc, REO_FLUSH_CACHE_2,
  511. CACHE_BLOCK_RESOURCE_INDEX, index);
  512. }
  513. HAL_DESC_SET_FIELD(reo_desc, REO_FLUSH_CACHE_2,
  514. FLUSH_WITHOUT_INVALIDATE, cp->flush_no_inval);
  515. HAL_DESC_SET_FIELD(reo_desc, REO_FLUSH_CACHE_2,
  516. BLOCK_CACHE_USAGE_AFTER_FLUSH, cp->block_use_after_flush);
  517. HAL_DESC_SET_FIELD(reo_desc, REO_FLUSH_CACHE_2, FLUSH_ENTIRE_CACHE,
  518. cp->flush_all);
  519. if (hif_pm_runtime_get(hal_soc->hif_handle,
  520. RTPM_ID_HAL_REO_CMD) == 0) {
  521. hal_srng_access_end(hal_soc_hdl, hal_ring_hdl);
  522. hif_pm_runtime_put(hal_soc->hif_handle,
  523. RTPM_ID_HAL_REO_CMD);
  524. } else {
  525. hal_srng_access_end_reap(hal_soc_hdl, hal_ring_hdl);
  526. hal_srng_set_event(hal_ring_hdl, HAL_SRNG_FLUSH_EVENT);
  527. hal_srng_inc_flush_cnt(hal_ring_hdl);
  528. }
  529. val = reo_desc[CMD_HEADER_DW_OFFSET];
  530. return HAL_GET_FIELD(UNIFORM_REO_CMD_HEADER_0, REO_CMD_NUMBER,
  531. val);
  532. }
  533. qdf_export_symbol(hal_reo_cmd_flush_cache);
  534. inline int hal_reo_cmd_unblock_cache(hal_ring_handle_t hal_ring_hdl,
  535. hal_soc_handle_t hal_soc_hdl,
  536. struct hal_reo_cmd_params *cmd)
  537. {
  538. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  539. uint32_t *reo_desc, val;
  540. uint8_t index = 0;
  541. hal_srng_access_start(hal_soc_hdl, hal_ring_hdl);
  542. if (cmd->u.unblk_cache_params.type == UNBLOCK_RES_INDEX) {
  543. index = hal_find_one_bit(hal_soc->reo_res_bitmap);
  544. if (index > 3) {
  545. hal_srng_access_end(hal_soc, hal_ring_hdl);
  546. qdf_print("%s: No blocking resource to unblock!",
  547. __func__);
  548. return -EBUSY;
  549. }
  550. }
  551. reo_desc = hal_srng_src_get_next(hal_soc, hal_ring_hdl);
  552. if (!reo_desc) {
  553. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_DEBUG,
  554. "%s: Out of cmd ring entries", __func__);
  555. hal_srng_access_end(hal_soc, hal_ring_hdl);
  556. return -EBUSY;
  557. }
  558. HAL_SET_TLV_HDR(reo_desc, WIFIREO_UNBLOCK_CACHE_E,
  559. sizeof(struct reo_unblock_cache));
  560. /* Offsets of descriptor fields defined in HW headers start from
  561. * the field after TLV header */
  562. reo_desc += (sizeof(struct tlv_32_hdr) >> 2);
  563. qdf_mem_zero((reo_desc + NUM_OF_DWORDS_UNIFORM_REO_CMD_HEADER),
  564. sizeof(struct reo_unblock_cache) -
  565. (NUM_OF_DWORDS_UNIFORM_REO_CMD_HEADER << 2));
  566. HAL_DESC_SET_FIELD(reo_desc, UNIFORM_REO_CMD_HEADER_0,
  567. REO_STATUS_REQUIRED, cmd->std.need_status);
  568. HAL_DESC_SET_FIELD(reo_desc, REO_UNBLOCK_CACHE_1,
  569. UNBLOCK_TYPE, cmd->u.unblk_cache_params.type);
  570. if (cmd->u.unblk_cache_params.type == UNBLOCK_RES_INDEX) {
  571. HAL_DESC_SET_FIELD(reo_desc, REO_UNBLOCK_CACHE_1,
  572. CACHE_BLOCK_RESOURCE_INDEX,
  573. cmd->u.unblk_cache_params.index);
  574. }
  575. hal_srng_access_end(hal_soc, hal_ring_hdl);
  576. val = reo_desc[CMD_HEADER_DW_OFFSET];
  577. return HAL_GET_FIELD(UNIFORM_REO_CMD_HEADER_0, REO_CMD_NUMBER,
  578. val);
  579. }
  580. qdf_export_symbol(hal_reo_cmd_unblock_cache);
  581. inline int hal_reo_cmd_flush_timeout_list(hal_ring_handle_t hal_ring_hdl,
  582. hal_soc_handle_t hal_soc_hdl,
  583. struct hal_reo_cmd_params *cmd)
  584. {
  585. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  586. uint32_t *reo_desc, val;
  587. hal_srng_access_start(hal_soc_hdl, hal_ring_hdl);
  588. reo_desc = hal_srng_src_get_next(hal_soc, hal_ring_hdl);
  589. if (!reo_desc) {
  590. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_DEBUG,
  591. "%s: Out of cmd ring entries", __func__);
  592. hal_srng_access_end(hal_soc, hal_ring_hdl);
  593. return -EBUSY;
  594. }
  595. HAL_SET_TLV_HDR(reo_desc, WIFIREO_FLUSH_TIMEOUT_LIST_E,
  596. sizeof(struct reo_flush_timeout_list));
  597. /* Offsets of descriptor fields defined in HW headers start from
  598. * the field after TLV header */
  599. reo_desc += (sizeof(struct tlv_32_hdr) >> 2);
  600. qdf_mem_zero((reo_desc + NUM_OF_DWORDS_UNIFORM_REO_CMD_HEADER),
  601. sizeof(struct reo_flush_timeout_list) -
  602. (NUM_OF_DWORDS_UNIFORM_REO_CMD_HEADER << 2));
  603. HAL_DESC_SET_FIELD(reo_desc, UNIFORM_REO_CMD_HEADER_0,
  604. REO_STATUS_REQUIRED, cmd->std.need_status);
  605. HAL_DESC_SET_FIELD(reo_desc, REO_FLUSH_TIMEOUT_LIST_1, AC_TIMOUT_LIST,
  606. cmd->u.fl_tim_list_params.ac_list);
  607. HAL_DESC_SET_FIELD(reo_desc, REO_FLUSH_TIMEOUT_LIST_2,
  608. MINIMUM_RELEASE_DESC_COUNT,
  609. cmd->u.fl_tim_list_params.min_rel_desc);
  610. HAL_DESC_SET_FIELD(reo_desc, REO_FLUSH_TIMEOUT_LIST_2,
  611. MINIMUM_FORWARD_BUF_COUNT,
  612. cmd->u.fl_tim_list_params.min_fwd_buf);
  613. hal_srng_access_end(hal_soc, hal_ring_hdl);
  614. val = reo_desc[CMD_HEADER_DW_OFFSET];
  615. return HAL_GET_FIELD(UNIFORM_REO_CMD_HEADER_0, REO_CMD_NUMBER,
  616. val);
  617. }
  618. qdf_export_symbol(hal_reo_cmd_flush_timeout_list);
  619. inline int hal_reo_cmd_update_rx_queue(hal_ring_handle_t hal_ring_hdl,
  620. hal_soc_handle_t hal_soc_hdl,
  621. struct hal_reo_cmd_params *cmd)
  622. {
  623. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  624. uint32_t *reo_desc, val;
  625. struct hal_reo_cmd_update_queue_params *p;
  626. p = &cmd->u.upd_queue_params;
  627. hal_srng_access_start(hal_soc_hdl, hal_ring_hdl);
  628. reo_desc = hal_srng_src_get_next(hal_soc, hal_ring_hdl);
  629. if (!reo_desc) {
  630. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_DEBUG,
  631. "%s: Out of cmd ring entries", __func__);
  632. hal_srng_access_end(hal_soc, hal_ring_hdl);
  633. return -EBUSY;
  634. }
  635. HAL_SET_TLV_HDR(reo_desc, WIFIREO_UPDATE_RX_REO_QUEUE_E,
  636. sizeof(struct reo_update_rx_reo_queue));
  637. /* Offsets of descriptor fields defined in HW headers start from
  638. * the field after TLV header */
  639. reo_desc += (sizeof(struct tlv_32_hdr) >> 2);
  640. qdf_mem_zero((reo_desc + NUM_OF_DWORDS_UNIFORM_REO_CMD_HEADER),
  641. sizeof(struct reo_update_rx_reo_queue) -
  642. (NUM_OF_DWORDS_UNIFORM_REO_CMD_HEADER << 2));
  643. HAL_DESC_SET_FIELD(reo_desc, UNIFORM_REO_CMD_HEADER_0,
  644. REO_STATUS_REQUIRED, cmd->std.need_status);
  645. hal_reo_cmd_set_descr_addr(reo_desc, CMD_UPDATE_RX_REO_QUEUE,
  646. cmd->std.addr_lo, cmd->std.addr_hi);
  647. HAL_DESC_SET_FIELD(reo_desc, REO_UPDATE_RX_REO_QUEUE_2,
  648. UPDATE_RECEIVE_QUEUE_NUMBER, p->update_rx_queue_num);
  649. HAL_DESC_SET_FIELD(reo_desc, REO_UPDATE_RX_REO_QUEUE_2, UPDATE_VLD,
  650. p->update_vld);
  651. HAL_DESC_SET_FIELD(reo_desc, REO_UPDATE_RX_REO_QUEUE_2,
  652. UPDATE_ASSOCIATED_LINK_DESCRIPTOR_COUNTER,
  653. p->update_assoc_link_desc);
  654. HAL_DESC_SET_FIELD(reo_desc, REO_UPDATE_RX_REO_QUEUE_2,
  655. UPDATE_DISABLE_DUPLICATE_DETECTION,
  656. p->update_disable_dup_detect);
  657. HAL_DESC_SET_FIELD(reo_desc, REO_UPDATE_RX_REO_QUEUE_2,
  658. UPDATE_DISABLE_DUPLICATE_DETECTION,
  659. p->update_disable_dup_detect);
  660. HAL_DESC_SET_FIELD(reo_desc, REO_UPDATE_RX_REO_QUEUE_2,
  661. UPDATE_SOFT_REORDER_ENABLE,
  662. p->update_soft_reorder_enab);
  663. HAL_DESC_SET_FIELD(reo_desc, REO_UPDATE_RX_REO_QUEUE_2,
  664. UPDATE_AC, p->update_ac);
  665. HAL_DESC_SET_FIELD(reo_desc, REO_UPDATE_RX_REO_QUEUE_2,
  666. UPDATE_BAR, p->update_bar);
  667. HAL_DESC_SET_FIELD(reo_desc, REO_UPDATE_RX_REO_QUEUE_2,
  668. UPDATE_BAR, p->update_bar);
  669. HAL_DESC_SET_FIELD(reo_desc, REO_UPDATE_RX_REO_QUEUE_2,
  670. UPDATE_RTY, p->update_rty);
  671. HAL_DESC_SET_FIELD(reo_desc, REO_UPDATE_RX_REO_QUEUE_2,
  672. UPDATE_CHK_2K_MODE, p->update_chk_2k_mode);
  673. HAL_DESC_SET_FIELD(reo_desc, REO_UPDATE_RX_REO_QUEUE_2,
  674. UPDATE_OOR_MODE, p->update_oor_mode);
  675. HAL_DESC_SET_FIELD(reo_desc, REO_UPDATE_RX_REO_QUEUE_2,
  676. UPDATE_BA_WINDOW_SIZE, p->update_ba_window_size);
  677. HAL_DESC_SET_FIELD(reo_desc, REO_UPDATE_RX_REO_QUEUE_2,
  678. UPDATE_PN_CHECK_NEEDED, p->update_pn_check_needed);
  679. HAL_DESC_SET_FIELD(reo_desc, REO_UPDATE_RX_REO_QUEUE_2,
  680. UPDATE_PN_SHALL_BE_EVEN, p->update_pn_even);
  681. HAL_DESC_SET_FIELD(reo_desc, REO_UPDATE_RX_REO_QUEUE_2,
  682. UPDATE_PN_SHALL_BE_UNEVEN, p->update_pn_uneven);
  683. HAL_DESC_SET_FIELD(reo_desc, REO_UPDATE_RX_REO_QUEUE_2,
  684. UPDATE_PN_HANDLING_ENABLE, p->update_pn_hand_enab);
  685. HAL_DESC_SET_FIELD(reo_desc, REO_UPDATE_RX_REO_QUEUE_2,
  686. UPDATE_PN_SIZE, p->update_pn_size);
  687. HAL_DESC_SET_FIELD(reo_desc, REO_UPDATE_RX_REO_QUEUE_2,
  688. UPDATE_IGNORE_AMPDU_FLAG, p->update_ignore_ampdu);
  689. HAL_DESC_SET_FIELD(reo_desc, REO_UPDATE_RX_REO_QUEUE_2,
  690. UPDATE_SVLD, p->update_svld);
  691. HAL_DESC_SET_FIELD(reo_desc, REO_UPDATE_RX_REO_QUEUE_2,
  692. UPDATE_SSN, p->update_ssn);
  693. HAL_DESC_SET_FIELD(reo_desc, REO_UPDATE_RX_REO_QUEUE_2,
  694. UPDATE_SEQ_2K_ERROR_DETECTED_FLAG,
  695. p->update_seq_2k_err_detect);
  696. HAL_DESC_SET_FIELD(reo_desc, REO_UPDATE_RX_REO_QUEUE_2,
  697. UPDATE_PN_VALID, p->update_pn_valid);
  698. HAL_DESC_SET_FIELD(reo_desc, REO_UPDATE_RX_REO_QUEUE_2,
  699. UPDATE_PN, p->update_pn);
  700. HAL_DESC_SET_FIELD(reo_desc, REO_UPDATE_RX_REO_QUEUE_3,
  701. RECEIVE_QUEUE_NUMBER, p->rx_queue_num);
  702. HAL_DESC_SET_FIELD(reo_desc, REO_UPDATE_RX_REO_QUEUE_3,
  703. VLD, p->vld);
  704. HAL_DESC_SET_FIELD(reo_desc, REO_UPDATE_RX_REO_QUEUE_3,
  705. ASSOCIATED_LINK_DESCRIPTOR_COUNTER,
  706. p->assoc_link_desc);
  707. HAL_DESC_SET_FIELD(reo_desc, REO_UPDATE_RX_REO_QUEUE_3,
  708. DISABLE_DUPLICATE_DETECTION, p->disable_dup_detect);
  709. HAL_DESC_SET_FIELD(reo_desc, REO_UPDATE_RX_REO_QUEUE_3,
  710. SOFT_REORDER_ENABLE, p->soft_reorder_enab);
  711. HAL_DESC_SET_FIELD(reo_desc, REO_UPDATE_RX_REO_QUEUE_3, AC, p->ac);
  712. HAL_DESC_SET_FIELD(reo_desc, REO_UPDATE_RX_REO_QUEUE_3,
  713. BAR, p->bar);
  714. HAL_DESC_SET_FIELD(reo_desc, REO_UPDATE_RX_REO_QUEUE_3,
  715. CHK_2K_MODE, p->chk_2k_mode);
  716. HAL_DESC_SET_FIELD(reo_desc, REO_UPDATE_RX_REO_QUEUE_3,
  717. RTY, p->rty);
  718. HAL_DESC_SET_FIELD(reo_desc, REO_UPDATE_RX_REO_QUEUE_3,
  719. OOR_MODE, p->oor_mode);
  720. HAL_DESC_SET_FIELD(reo_desc, REO_UPDATE_RX_REO_QUEUE_3,
  721. PN_CHECK_NEEDED, p->pn_check_needed);
  722. HAL_DESC_SET_FIELD(reo_desc, REO_UPDATE_RX_REO_QUEUE_3,
  723. PN_SHALL_BE_EVEN, p->pn_even);
  724. HAL_DESC_SET_FIELD(reo_desc, REO_UPDATE_RX_REO_QUEUE_3,
  725. PN_SHALL_BE_UNEVEN, p->pn_uneven);
  726. HAL_DESC_SET_FIELD(reo_desc, REO_UPDATE_RX_REO_QUEUE_3,
  727. PN_HANDLING_ENABLE, p->pn_hand_enab);
  728. HAL_DESC_SET_FIELD(reo_desc, REO_UPDATE_RX_REO_QUEUE_3,
  729. IGNORE_AMPDU_FLAG, p->ignore_ampdu);
  730. if (p->ba_window_size < 1)
  731. p->ba_window_size = 1;
  732. /*
  733. * WAR to get 2k exception in Non BA case.
  734. * Setting window size to 2 to get 2k jump exception
  735. * when we receive aggregates in Non BA case
  736. */
  737. if (p->ba_window_size == 1)
  738. p->ba_window_size++;
  739. HAL_DESC_SET_FIELD(reo_desc, REO_UPDATE_RX_REO_QUEUE_4,
  740. BA_WINDOW_SIZE, p->ba_window_size - 1);
  741. if (p->pn_size == 24)
  742. p->pn_size = PN_SIZE_24;
  743. else if (p->pn_size == 48)
  744. p->pn_size = PN_SIZE_48;
  745. else if (p->pn_size == 128)
  746. p->pn_size = PN_SIZE_128;
  747. HAL_DESC_SET_FIELD(reo_desc, REO_UPDATE_RX_REO_QUEUE_4,
  748. PN_SIZE, p->pn_size);
  749. HAL_DESC_SET_FIELD(reo_desc, REO_UPDATE_RX_REO_QUEUE_4,
  750. SVLD, p->svld);
  751. HAL_DESC_SET_FIELD(reo_desc, REO_UPDATE_RX_REO_QUEUE_4,
  752. SSN, p->ssn);
  753. HAL_DESC_SET_FIELD(reo_desc, REO_UPDATE_RX_REO_QUEUE_4,
  754. SEQ_2K_ERROR_DETECTED_FLAG, p->seq_2k_err_detect);
  755. HAL_DESC_SET_FIELD(reo_desc, REO_UPDATE_RX_REO_QUEUE_4,
  756. PN_ERROR_DETECTED_FLAG, p->pn_err_detect);
  757. HAL_DESC_SET_FIELD(reo_desc, REO_UPDATE_RX_REO_QUEUE_5,
  758. PN_31_0, p->pn_31_0);
  759. HAL_DESC_SET_FIELD(reo_desc, REO_UPDATE_RX_REO_QUEUE_6,
  760. PN_63_32, p->pn_63_32);
  761. HAL_DESC_SET_FIELD(reo_desc, REO_UPDATE_RX_REO_QUEUE_7,
  762. PN_95_64, p->pn_95_64);
  763. HAL_DESC_SET_FIELD(reo_desc, REO_UPDATE_RX_REO_QUEUE_8,
  764. PN_127_96, p->pn_127_96);
  765. if (hif_pm_runtime_get(hal_soc->hif_handle,
  766. RTPM_ID_HAL_REO_CMD) == 0) {
  767. hal_srng_access_end(hal_soc_hdl, hal_ring_hdl);
  768. hif_pm_runtime_put(hal_soc->hif_handle,
  769. RTPM_ID_HAL_REO_CMD);
  770. } else {
  771. hal_srng_access_end_reap(hal_soc_hdl, hal_ring_hdl);
  772. hal_srng_set_event(hal_ring_hdl, HAL_SRNG_FLUSH_EVENT);
  773. hal_srng_inc_flush_cnt(hal_ring_hdl);
  774. }
  775. val = reo_desc[CMD_HEADER_DW_OFFSET];
  776. return HAL_GET_FIELD(UNIFORM_REO_CMD_HEADER_0, REO_CMD_NUMBER,
  777. val);
  778. }
  779. qdf_export_symbol(hal_reo_cmd_update_rx_queue);
  780. inline void
  781. hal_reo_queue_stats_status(uint32_t *reo_desc,
  782. struct hal_reo_queue_status *st,
  783. hal_soc_handle_t hal_soc_hdl)
  784. {
  785. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  786. uint32_t val;
  787. /* Offsets of descriptor fields defined in HW headers start
  788. * from the field after TLV header */
  789. reo_desc += (sizeof(struct tlv_32_hdr) >> 2);
  790. /* header */
  791. hal_reo_status_get_header(reo_desc, HAL_REO_QUEUE_STATS_STATUS_TLV,
  792. &(st->header), hal_soc);
  793. /* SSN */
  794. val = reo_desc[HAL_OFFSET_DW(REO_GET_QUEUE_STATS_STATUS_2, SSN)];
  795. st->ssn = HAL_GET_FIELD(REO_GET_QUEUE_STATS_STATUS_2, SSN, val);
  796. /* current index */
  797. val = reo_desc[HAL_OFFSET_DW(REO_GET_QUEUE_STATS_STATUS_2,
  798. CURRENT_INDEX)];
  799. st->curr_idx =
  800. HAL_GET_FIELD(REO_GET_QUEUE_STATS_STATUS_2,
  801. CURRENT_INDEX, val);
  802. /* PN bits */
  803. val = reo_desc[HAL_OFFSET_DW(REO_GET_QUEUE_STATS_STATUS_3,
  804. PN_31_0)];
  805. st->pn_31_0 =
  806. HAL_GET_FIELD(REO_GET_QUEUE_STATS_STATUS_3,
  807. PN_31_0, val);
  808. val = reo_desc[HAL_OFFSET_DW(REO_GET_QUEUE_STATS_STATUS_4,
  809. PN_63_32)];
  810. st->pn_63_32 =
  811. HAL_GET_FIELD(REO_GET_QUEUE_STATS_STATUS_4,
  812. PN_63_32, val);
  813. val = reo_desc[HAL_OFFSET_DW(REO_GET_QUEUE_STATS_STATUS_5,
  814. PN_95_64)];
  815. st->pn_95_64 =
  816. HAL_GET_FIELD(REO_GET_QUEUE_STATS_STATUS_5,
  817. PN_95_64, val);
  818. val = reo_desc[HAL_OFFSET_DW(REO_GET_QUEUE_STATS_STATUS_6,
  819. PN_127_96)];
  820. st->pn_127_96 =
  821. HAL_GET_FIELD(REO_GET_QUEUE_STATS_STATUS_6,
  822. PN_127_96, val);
  823. /* timestamps */
  824. val = reo_desc[HAL_OFFSET_DW(REO_GET_QUEUE_STATS_STATUS_7,
  825. LAST_RX_ENQUEUE_TIMESTAMP)];
  826. st->last_rx_enq_tstamp =
  827. HAL_GET_FIELD(REO_GET_QUEUE_STATS_STATUS_7,
  828. LAST_RX_ENQUEUE_TIMESTAMP, val);
  829. val = reo_desc[HAL_OFFSET_DW(REO_GET_QUEUE_STATS_STATUS_8,
  830. LAST_RX_DEQUEUE_TIMESTAMP)];
  831. st->last_rx_deq_tstamp =
  832. HAL_GET_FIELD(REO_GET_QUEUE_STATS_STATUS_8,
  833. LAST_RX_DEQUEUE_TIMESTAMP, val);
  834. /* rx bitmap */
  835. val = reo_desc[HAL_OFFSET_DW(REO_GET_QUEUE_STATS_STATUS_9,
  836. RX_BITMAP_31_0)];
  837. st->rx_bitmap_31_0 =
  838. HAL_GET_FIELD(REO_GET_QUEUE_STATS_STATUS_9,
  839. RX_BITMAP_31_0, val);
  840. val = reo_desc[HAL_OFFSET_DW(REO_GET_QUEUE_STATS_STATUS_10,
  841. RX_BITMAP_63_32)];
  842. st->rx_bitmap_63_32 =
  843. HAL_GET_FIELD(REO_GET_QUEUE_STATS_STATUS_10,
  844. RX_BITMAP_63_32, val);
  845. val = reo_desc[HAL_OFFSET_DW(REO_GET_QUEUE_STATS_STATUS_11,
  846. RX_BITMAP_95_64)];
  847. st->rx_bitmap_95_64 =
  848. HAL_GET_FIELD(REO_GET_QUEUE_STATS_STATUS_11,
  849. RX_BITMAP_95_64, val);
  850. val = reo_desc[HAL_OFFSET_DW(REO_GET_QUEUE_STATS_STATUS_12,
  851. RX_BITMAP_127_96)];
  852. st->rx_bitmap_127_96 =
  853. HAL_GET_FIELD(REO_GET_QUEUE_STATS_STATUS_12,
  854. RX_BITMAP_127_96, val);
  855. val = reo_desc[HAL_OFFSET_DW(REO_GET_QUEUE_STATS_STATUS_13,
  856. RX_BITMAP_159_128)];
  857. st->rx_bitmap_159_128 =
  858. HAL_GET_FIELD(REO_GET_QUEUE_STATS_STATUS_13,
  859. RX_BITMAP_159_128, val);
  860. val = reo_desc[HAL_OFFSET_DW(REO_GET_QUEUE_STATS_STATUS_14,
  861. RX_BITMAP_191_160)];
  862. st->rx_bitmap_191_160 =
  863. HAL_GET_FIELD(REO_GET_QUEUE_STATS_STATUS_14,
  864. RX_BITMAP_191_160, val);
  865. val = reo_desc[HAL_OFFSET_DW(REO_GET_QUEUE_STATS_STATUS_15,
  866. RX_BITMAP_223_192)];
  867. st->rx_bitmap_223_192 =
  868. HAL_GET_FIELD(REO_GET_QUEUE_STATS_STATUS_15,
  869. RX_BITMAP_223_192, val);
  870. val = reo_desc[HAL_OFFSET_DW(REO_GET_QUEUE_STATS_STATUS_16,
  871. RX_BITMAP_255_224)];
  872. st->rx_bitmap_255_224 =
  873. HAL_GET_FIELD(REO_GET_QUEUE_STATS_STATUS_16,
  874. RX_BITMAP_255_224, val);
  875. /* various counts */
  876. val = reo_desc[HAL_OFFSET_DW(REO_GET_QUEUE_STATS_STATUS_17,
  877. CURRENT_MPDU_COUNT)];
  878. st->curr_mpdu_cnt =
  879. HAL_GET_FIELD(REO_GET_QUEUE_STATS_STATUS_17,
  880. CURRENT_MPDU_COUNT, val);
  881. val = reo_desc[HAL_OFFSET_DW(REO_GET_QUEUE_STATS_STATUS_17,
  882. CURRENT_MSDU_COUNT)];
  883. st->curr_msdu_cnt =
  884. HAL_GET_FIELD(REO_GET_QUEUE_STATS_STATUS_17,
  885. CURRENT_MSDU_COUNT, val);
  886. val = reo_desc[HAL_OFFSET_DW(REO_GET_QUEUE_STATS_STATUS_18,
  887. TIMEOUT_COUNT)];
  888. st->fwd_timeout_cnt =
  889. HAL_GET_FIELD(REO_GET_QUEUE_STATS_STATUS_18,
  890. TIMEOUT_COUNT, val);
  891. val = reo_desc[HAL_OFFSET_DW(REO_GET_QUEUE_STATS_STATUS_18,
  892. FORWARD_DUE_TO_BAR_COUNT)];
  893. st->fwd_bar_cnt =
  894. HAL_GET_FIELD(REO_GET_QUEUE_STATS_STATUS_18,
  895. FORWARD_DUE_TO_BAR_COUNT, val);
  896. val = reo_desc[HAL_OFFSET_DW(REO_GET_QUEUE_STATS_STATUS_18,
  897. DUPLICATE_COUNT)];
  898. st->dup_cnt =
  899. HAL_GET_FIELD(REO_GET_QUEUE_STATS_STATUS_18,
  900. DUPLICATE_COUNT, val);
  901. val = reo_desc[HAL_OFFSET_DW(REO_GET_QUEUE_STATS_STATUS_19,
  902. FRAMES_IN_ORDER_COUNT)];
  903. st->frms_in_order_cnt =
  904. HAL_GET_FIELD(REO_GET_QUEUE_STATS_STATUS_19,
  905. FRAMES_IN_ORDER_COUNT, val);
  906. val = reo_desc[HAL_OFFSET_DW(REO_GET_QUEUE_STATS_STATUS_19,
  907. BAR_RECEIVED_COUNT)];
  908. st->bar_rcvd_cnt =
  909. HAL_GET_FIELD(REO_GET_QUEUE_STATS_STATUS_19,
  910. BAR_RECEIVED_COUNT, val);
  911. val = reo_desc[HAL_OFFSET_DW(REO_GET_QUEUE_STATS_STATUS_20,
  912. MPDU_FRAMES_PROCESSED_COUNT)];
  913. st->mpdu_frms_cnt =
  914. HAL_GET_FIELD(REO_GET_QUEUE_STATS_STATUS_20,
  915. MPDU_FRAMES_PROCESSED_COUNT, val);
  916. val = reo_desc[HAL_OFFSET_DW(REO_GET_QUEUE_STATS_STATUS_21,
  917. MSDU_FRAMES_PROCESSED_COUNT)];
  918. st->msdu_frms_cnt =
  919. HAL_GET_FIELD(REO_GET_QUEUE_STATS_STATUS_21,
  920. MSDU_FRAMES_PROCESSED_COUNT, val);
  921. val = reo_desc[HAL_OFFSET_DW(REO_GET_QUEUE_STATS_STATUS_22,
  922. TOTAL_PROCESSED_BYTE_COUNT)];
  923. st->total_cnt =
  924. HAL_GET_FIELD(REO_GET_QUEUE_STATS_STATUS_22,
  925. TOTAL_PROCESSED_BYTE_COUNT, val);
  926. val = reo_desc[HAL_OFFSET_DW(REO_GET_QUEUE_STATS_STATUS_23,
  927. LATE_RECEIVE_MPDU_COUNT)];
  928. st->late_recv_mpdu_cnt =
  929. HAL_GET_FIELD(REO_GET_QUEUE_STATS_STATUS_23,
  930. LATE_RECEIVE_MPDU_COUNT, val);
  931. val = reo_desc[HAL_OFFSET_DW(REO_GET_QUEUE_STATS_STATUS_23,
  932. WINDOW_JUMP_2K)];
  933. st->win_jump_2k =
  934. HAL_GET_FIELD(REO_GET_QUEUE_STATS_STATUS_23,
  935. WINDOW_JUMP_2K, val);
  936. val = reo_desc[HAL_OFFSET_DW(REO_GET_QUEUE_STATS_STATUS_23,
  937. HOLE_COUNT)];
  938. st->hole_cnt =
  939. HAL_GET_FIELD(REO_GET_QUEUE_STATS_STATUS_23,
  940. HOLE_COUNT, val);
  941. }
  942. qdf_export_symbol(hal_reo_queue_stats_status);
  943. inline void
  944. hal_reo_flush_queue_status(uint32_t *reo_desc,
  945. struct hal_reo_flush_queue_status *st,
  946. hal_soc_handle_t hal_soc_hdl)
  947. {
  948. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  949. uint32_t val;
  950. /* Offsets of descriptor fields defined in HW headers start
  951. * from the field after TLV header */
  952. reo_desc += (sizeof(struct tlv_32_hdr) >> 2);
  953. /* header */
  954. hal_reo_status_get_header(reo_desc, HAL_REO_FLUSH_QUEUE_STATUS_TLV,
  955. &(st->header), hal_soc);
  956. /* error bit */
  957. val = reo_desc[HAL_OFFSET(REO_FLUSH_QUEUE_STATUS_2,
  958. ERROR_DETECTED)];
  959. st->error = HAL_GET_FIELD(REO_FLUSH_QUEUE_STATUS_2, ERROR_DETECTED,
  960. val);
  961. }
  962. qdf_export_symbol(hal_reo_flush_queue_status);
  963. inline void
  964. hal_reo_flush_cache_status(uint32_t *reo_desc,
  965. struct hal_reo_flush_cache_status *st,
  966. hal_soc_handle_t hal_soc_hdl)
  967. {
  968. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  969. uint32_t val;
  970. /* Offsets of descriptor fields defined in HW headers start
  971. * from the field after TLV header */
  972. reo_desc += (sizeof(struct tlv_32_hdr) >> 2);
  973. /* header */
  974. hal_reo_status_get_header(reo_desc, HAL_REO_FLUSH_CACHE_STATUS_TLV,
  975. &(st->header), hal_soc);
  976. /* error bit */
  977. val = reo_desc[HAL_OFFSET_DW(REO_FLUSH_CACHE_STATUS_2,
  978. ERROR_DETECTED)];
  979. st->error = HAL_GET_FIELD(REO_FLUSH_QUEUE_STATUS_2, ERROR_DETECTED,
  980. val);
  981. /* block error */
  982. val = reo_desc[HAL_OFFSET_DW(REO_FLUSH_CACHE_STATUS_2,
  983. BLOCK_ERROR_DETAILS)];
  984. st->block_error = HAL_GET_FIELD(REO_FLUSH_CACHE_STATUS_2,
  985. BLOCK_ERROR_DETAILS,
  986. val);
  987. if (!st->block_error)
  988. qdf_set_bit(hal_soc->index,
  989. (unsigned long *)&hal_soc->reo_res_bitmap);
  990. /* cache flush status */
  991. val = reo_desc[HAL_OFFSET_DW(REO_FLUSH_CACHE_STATUS_2,
  992. CACHE_CONTROLLER_FLUSH_STATUS_HIT)];
  993. st->cache_flush_status = HAL_GET_FIELD(REO_FLUSH_CACHE_STATUS_2,
  994. CACHE_CONTROLLER_FLUSH_STATUS_HIT,
  995. val);
  996. /* cache flush descriptor type */
  997. val = reo_desc[HAL_OFFSET_DW(REO_FLUSH_CACHE_STATUS_2,
  998. CACHE_CONTROLLER_FLUSH_STATUS_DESC_TYPE)];
  999. st->cache_flush_status_desc_type =
  1000. HAL_GET_FIELD(REO_FLUSH_CACHE_STATUS_2,
  1001. CACHE_CONTROLLER_FLUSH_STATUS_DESC_TYPE,
  1002. val);
  1003. /* cache flush count */
  1004. val = reo_desc[HAL_OFFSET_DW(REO_FLUSH_CACHE_STATUS_2,
  1005. CACHE_CONTROLLER_FLUSH_COUNT)];
  1006. st->cache_flush_cnt =
  1007. HAL_GET_FIELD(REO_FLUSH_CACHE_STATUS_2,
  1008. CACHE_CONTROLLER_FLUSH_COUNT,
  1009. val);
  1010. }
  1011. qdf_export_symbol(hal_reo_flush_cache_status);
  1012. inline void hal_reo_unblock_cache_status(uint32_t *reo_desc,
  1013. hal_soc_handle_t hal_soc_hdl,
  1014. struct hal_reo_unblk_cache_status *st)
  1015. {
  1016. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  1017. uint32_t val;
  1018. /* Offsets of descriptor fields defined in HW headers start
  1019. * from the field after TLV header */
  1020. reo_desc += (sizeof(struct tlv_32_hdr) >> 2);
  1021. /* header */
  1022. hal_reo_status_get_header(reo_desc, HAL_REO_UNBLK_CACHE_STATUS_TLV,
  1023. &st->header, hal_soc);
  1024. /* error bit */
  1025. val = reo_desc[HAL_OFFSET_DW(REO_UNBLOCK_CACHE_STATUS_2,
  1026. ERROR_DETECTED)];
  1027. st->error = HAL_GET_FIELD(REO_UNBLOCK_CACHE_STATUS_2,
  1028. ERROR_DETECTED,
  1029. val);
  1030. /* unblock type */
  1031. val = reo_desc[HAL_OFFSET_DW(REO_UNBLOCK_CACHE_STATUS_2,
  1032. UNBLOCK_TYPE)];
  1033. st->unblock_type = HAL_GET_FIELD(REO_UNBLOCK_CACHE_STATUS_2,
  1034. UNBLOCK_TYPE,
  1035. val);
  1036. if (!st->error && (st->unblock_type == UNBLOCK_RES_INDEX))
  1037. qdf_clear_bit(hal_soc->index,
  1038. (unsigned long *)&hal_soc->reo_res_bitmap);
  1039. }
  1040. qdf_export_symbol(hal_reo_unblock_cache_status);
  1041. inline void hal_reo_flush_timeout_list_status(
  1042. uint32_t *reo_desc,
  1043. struct hal_reo_flush_timeout_list_status *st,
  1044. hal_soc_handle_t hal_soc_hdl)
  1045. {
  1046. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  1047. uint32_t val;
  1048. /* Offsets of descriptor fields defined in HW headers start
  1049. * from the field after TLV header */
  1050. reo_desc += (sizeof(struct tlv_32_hdr) >> 2);
  1051. /* header */
  1052. hal_reo_status_get_header(reo_desc, HAL_REO_TIMOUT_LIST_STATUS_TLV,
  1053. &(st->header), hal_soc);
  1054. /* error bit */
  1055. val = reo_desc[HAL_OFFSET_DW(REO_FLUSH_TIMEOUT_LIST_STATUS_2,
  1056. ERROR_DETECTED)];
  1057. st->error = HAL_GET_FIELD(REO_FLUSH_TIMEOUT_LIST_STATUS_2,
  1058. ERROR_DETECTED,
  1059. val);
  1060. /* list empty */
  1061. val = reo_desc[HAL_OFFSET_DW(REO_FLUSH_TIMEOUT_LIST_STATUS_2,
  1062. TIMOUT_LIST_EMPTY)];
  1063. st->list_empty = HAL_GET_FIELD(REO_FLUSH_TIMEOUT_LIST_STATUS_2,
  1064. TIMOUT_LIST_EMPTY,
  1065. val);
  1066. /* release descriptor count */
  1067. val = reo_desc[HAL_OFFSET_DW(REO_FLUSH_TIMEOUT_LIST_STATUS_3,
  1068. RELEASE_DESC_COUNT)];
  1069. st->rel_desc_cnt = HAL_GET_FIELD(REO_FLUSH_TIMEOUT_LIST_STATUS_3,
  1070. RELEASE_DESC_COUNT,
  1071. val);
  1072. /* forward buf count */
  1073. val = reo_desc[HAL_OFFSET_DW(REO_FLUSH_TIMEOUT_LIST_STATUS_3,
  1074. FORWARD_BUF_COUNT)];
  1075. st->fwd_buf_cnt = HAL_GET_FIELD(REO_FLUSH_TIMEOUT_LIST_STATUS_3,
  1076. FORWARD_BUF_COUNT,
  1077. val);
  1078. }
  1079. qdf_export_symbol(hal_reo_flush_timeout_list_status);
  1080. inline void hal_reo_desc_thres_reached_status(
  1081. uint32_t *reo_desc,
  1082. struct hal_reo_desc_thres_reached_status *st,
  1083. hal_soc_handle_t hal_soc_hdl)
  1084. {
  1085. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  1086. uint32_t val;
  1087. /* Offsets of descriptor fields defined in HW headers start
  1088. * from the field after TLV header */
  1089. reo_desc += (sizeof(struct tlv_32_hdr) >> 2);
  1090. /* header */
  1091. hal_reo_status_get_header(reo_desc,
  1092. HAL_REO_DESC_THRES_STATUS_TLV,
  1093. &(st->header), hal_soc);
  1094. /* threshold index */
  1095. val = reo_desc[HAL_OFFSET_DW(
  1096. REO_DESCRIPTOR_THRESHOLD_REACHED_STATUS_2,
  1097. THRESHOLD_INDEX)];
  1098. st->thres_index = HAL_GET_FIELD(
  1099. REO_DESCRIPTOR_THRESHOLD_REACHED_STATUS_2,
  1100. THRESHOLD_INDEX,
  1101. val);
  1102. /* link desc counters */
  1103. val = reo_desc[HAL_OFFSET_DW(
  1104. REO_DESCRIPTOR_THRESHOLD_REACHED_STATUS_3,
  1105. LINK_DESCRIPTOR_COUNTER0)];
  1106. st->link_desc_counter0 = HAL_GET_FIELD(
  1107. REO_DESCRIPTOR_THRESHOLD_REACHED_STATUS_3,
  1108. LINK_DESCRIPTOR_COUNTER0,
  1109. val);
  1110. val = reo_desc[HAL_OFFSET_DW(
  1111. REO_DESCRIPTOR_THRESHOLD_REACHED_STATUS_4,
  1112. LINK_DESCRIPTOR_COUNTER1)];
  1113. st->link_desc_counter1 = HAL_GET_FIELD(
  1114. REO_DESCRIPTOR_THRESHOLD_REACHED_STATUS_4,
  1115. LINK_DESCRIPTOR_COUNTER1,
  1116. val);
  1117. val = reo_desc[HAL_OFFSET_DW(
  1118. REO_DESCRIPTOR_THRESHOLD_REACHED_STATUS_5,
  1119. LINK_DESCRIPTOR_COUNTER2)];
  1120. st->link_desc_counter2 = HAL_GET_FIELD(
  1121. REO_DESCRIPTOR_THRESHOLD_REACHED_STATUS_5,
  1122. LINK_DESCRIPTOR_COUNTER2,
  1123. val);
  1124. val = reo_desc[HAL_OFFSET_DW(
  1125. REO_DESCRIPTOR_THRESHOLD_REACHED_STATUS_6,
  1126. LINK_DESCRIPTOR_COUNTER_SUM)];
  1127. st->link_desc_counter_sum = HAL_GET_FIELD(
  1128. REO_DESCRIPTOR_THRESHOLD_REACHED_STATUS_6,
  1129. LINK_DESCRIPTOR_COUNTER_SUM,
  1130. val);
  1131. }
  1132. qdf_export_symbol(hal_reo_desc_thres_reached_status);
  1133. inline void
  1134. hal_reo_rx_update_queue_status(uint32_t *reo_desc,
  1135. struct hal_reo_update_rx_queue_status *st,
  1136. hal_soc_handle_t hal_soc_hdl)
  1137. {
  1138. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  1139. /* Offsets of descriptor fields defined in HW headers start
  1140. * from the field after TLV header */
  1141. reo_desc += (sizeof(struct tlv_32_hdr) >> 2);
  1142. /* header */
  1143. hal_reo_status_get_header(reo_desc,
  1144. HAL_REO_UPDATE_RX_QUEUE_STATUS_TLV,
  1145. &(st->header), hal_soc);
  1146. }
  1147. qdf_export_symbol(hal_reo_rx_update_queue_status);
  1148. /**
  1149. * hal_reo_init_cmd_ring() - Initialize descriptors of REO command SRNG
  1150. * with command number
  1151. * @hal_soc: Handle to HAL SoC structure
  1152. * @hal_ring: Handle to HAL SRNG structure
  1153. *
  1154. * Return: none
  1155. */
  1156. inline void hal_reo_init_cmd_ring(hal_soc_handle_t hal_soc_hdl,
  1157. hal_ring_handle_t hal_ring_hdl)
  1158. {
  1159. int cmd_num;
  1160. uint32_t *desc_addr;
  1161. struct hal_srng_params srng_params;
  1162. uint32_t desc_size;
  1163. uint32_t num_desc;
  1164. struct hal_soc *soc = (struct hal_soc *)hal_soc_hdl;
  1165. hal_get_srng_params(hal_soc_hdl, hal_ring_hdl, &srng_params);
  1166. desc_addr = (uint32_t *)(srng_params.ring_base_vaddr);
  1167. desc_addr += (sizeof(struct tlv_32_hdr) >> 2);
  1168. desc_size = hal_srng_get_entrysize(soc, REO_CMD) >> 2;
  1169. num_desc = srng_params.num_entries;
  1170. cmd_num = 1;
  1171. while (num_desc) {
  1172. /* Offsets of descriptor fields defined in HW headers start
  1173. * from the field after TLV header */
  1174. HAL_DESC_SET_FIELD(desc_addr, UNIFORM_REO_CMD_HEADER_0,
  1175. REO_CMD_NUMBER, cmd_num);
  1176. desc_addr += desc_size;
  1177. num_desc--; cmd_num++;
  1178. }
  1179. soc->reo_res_bitmap = 0;
  1180. }
  1181. qdf_export_symbol(hal_reo_init_cmd_ring);