hal_reo.c 43 KB

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