hal_reo.c 43 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389
  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. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_DEBUG,
  472. "%s: Out of cmd ring entries", __func__);
  473. hal_srng_access_end(hal_soc, hal_ring_hdl);
  474. hal_srng_dump(hal_ring_handle_to_hal_srng(hal_ring_hdl));
  475. return -EBUSY;
  476. }
  477. HAL_SET_TLV_HDR(reo_desc, WIFIREO_FLUSH_CACHE_E,
  478. sizeof(struct reo_flush_cache));
  479. /* Offsets of descriptor fields defined in HW headers start from
  480. * the field after TLV header */
  481. reo_desc += (sizeof(struct tlv_32_hdr) >> 2);
  482. qdf_mem_zero((reo_desc + NUM_OF_DWORDS_UNIFORM_REO_CMD_HEADER),
  483. sizeof(struct reo_flush_cache) -
  484. (NUM_OF_DWORDS_UNIFORM_REO_CMD_HEADER << 2));
  485. HAL_DESC_SET_FIELD(reo_desc, UNIFORM_REO_CMD_HEADER_0,
  486. REO_STATUS_REQUIRED, cmd->std.need_status);
  487. hal_reo_cmd_set_descr_addr(reo_desc, CMD_FLUSH_CACHE, cmd->std.addr_lo,
  488. cmd->std.addr_hi);
  489. HAL_DESC_SET_FIELD(reo_desc, REO_FLUSH_CACHE_2,
  490. FORWARD_ALL_MPDUS_IN_QUEUE, cp->fwd_mpdus_in_queue);
  491. /* set it to 0 for now */
  492. cp->rel_block_index = 0;
  493. HAL_DESC_SET_FIELD(reo_desc, REO_FLUSH_CACHE_2,
  494. RELEASE_CACHE_BLOCK_INDEX, cp->rel_block_index);
  495. if (cp->block_use_after_flush) {
  496. HAL_DESC_SET_FIELD(reo_desc, REO_FLUSH_CACHE_2,
  497. CACHE_BLOCK_RESOURCE_INDEX, index);
  498. }
  499. HAL_DESC_SET_FIELD(reo_desc, REO_FLUSH_CACHE_2,
  500. FLUSH_WITHOUT_INVALIDATE, cp->flush_no_inval);
  501. HAL_DESC_SET_FIELD(reo_desc, REO_FLUSH_CACHE_2,
  502. BLOCK_CACHE_USAGE_AFTER_FLUSH, cp->block_use_after_flush);
  503. HAL_DESC_SET_FIELD(reo_desc, REO_FLUSH_CACHE_2, FLUSH_ENTIRE_CACHE,
  504. cp->flush_all);
  505. if (hif_pm_runtime_get(hal_soc->hif_handle) == 0) {
  506. hal_srng_access_end(hal_soc_hdl, hal_ring_hdl);
  507. hif_pm_runtime_put(hal_soc->hif_handle);
  508. } else {
  509. hal_srng_access_end_reap(hal_soc_hdl, hal_ring_hdl);
  510. hal_srng_set_event(hal_ring_hdl, HAL_SRNG_FLUSH_EVENT);
  511. hal_srng_inc_flush_cnt(hal_ring_hdl);
  512. }
  513. val = reo_desc[CMD_HEADER_DW_OFFSET];
  514. return HAL_GET_FIELD(UNIFORM_REO_CMD_HEADER_0, REO_CMD_NUMBER,
  515. val);
  516. }
  517. qdf_export_symbol(hal_reo_cmd_flush_cache);
  518. inline int hal_reo_cmd_unblock_cache(hal_ring_handle_t hal_ring_hdl,
  519. hal_soc_handle_t hal_soc_hdl,
  520. struct hal_reo_cmd_params *cmd)
  521. {
  522. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  523. uint32_t *reo_desc, val;
  524. uint8_t index = 0;
  525. hal_srng_access_start(hal_soc_hdl, hal_ring_hdl);
  526. if (cmd->u.unblk_cache_params.type == UNBLOCK_RES_INDEX) {
  527. index = hal_find_one_bit(hal_soc->reo_res_bitmap);
  528. if (index > 3) {
  529. hal_srng_access_end(hal_soc, hal_ring_hdl);
  530. qdf_print("%s: No blocking resource to unblock!",
  531. __func__);
  532. return -EBUSY;
  533. }
  534. }
  535. reo_desc = hal_srng_src_get_next(hal_soc, hal_ring_hdl);
  536. if (!reo_desc) {
  537. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_DEBUG,
  538. "%s: Out of cmd ring entries", __func__);
  539. hal_srng_access_end(hal_soc, hal_ring_hdl);
  540. return -EBUSY;
  541. }
  542. HAL_SET_TLV_HDR(reo_desc, WIFIREO_UNBLOCK_CACHE_E,
  543. sizeof(struct reo_unblock_cache));
  544. /* Offsets of descriptor fields defined in HW headers start from
  545. * the field after TLV header */
  546. reo_desc += (sizeof(struct tlv_32_hdr) >> 2);
  547. qdf_mem_zero((reo_desc + NUM_OF_DWORDS_UNIFORM_REO_CMD_HEADER),
  548. sizeof(struct reo_unblock_cache) -
  549. (NUM_OF_DWORDS_UNIFORM_REO_CMD_HEADER << 2));
  550. HAL_DESC_SET_FIELD(reo_desc, UNIFORM_REO_CMD_HEADER_0,
  551. REO_STATUS_REQUIRED, cmd->std.need_status);
  552. HAL_DESC_SET_FIELD(reo_desc, REO_UNBLOCK_CACHE_1,
  553. UNBLOCK_TYPE, cmd->u.unblk_cache_params.type);
  554. if (cmd->u.unblk_cache_params.type == UNBLOCK_RES_INDEX) {
  555. HAL_DESC_SET_FIELD(reo_desc, REO_UNBLOCK_CACHE_1,
  556. CACHE_BLOCK_RESOURCE_INDEX,
  557. cmd->u.unblk_cache_params.index);
  558. }
  559. hal_srng_access_end(hal_soc, hal_ring_hdl);
  560. val = reo_desc[CMD_HEADER_DW_OFFSET];
  561. return HAL_GET_FIELD(UNIFORM_REO_CMD_HEADER_0, REO_CMD_NUMBER,
  562. val);
  563. }
  564. qdf_export_symbol(hal_reo_cmd_unblock_cache);
  565. inline int hal_reo_cmd_flush_timeout_list(hal_ring_handle_t hal_ring_hdl,
  566. hal_soc_handle_t hal_soc_hdl,
  567. struct hal_reo_cmd_params *cmd)
  568. {
  569. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  570. uint32_t *reo_desc, val;
  571. hal_srng_access_start(hal_soc_hdl, hal_ring_hdl);
  572. reo_desc = hal_srng_src_get_next(hal_soc, hal_ring_hdl);
  573. if (!reo_desc) {
  574. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_DEBUG,
  575. "%s: Out of cmd ring entries", __func__);
  576. hal_srng_access_end(hal_soc, hal_ring_hdl);
  577. return -EBUSY;
  578. }
  579. HAL_SET_TLV_HDR(reo_desc, WIFIREO_FLUSH_TIMEOUT_LIST_E,
  580. sizeof(struct reo_flush_timeout_list));
  581. /* Offsets of descriptor fields defined in HW headers start from
  582. * the field after TLV header */
  583. reo_desc += (sizeof(struct tlv_32_hdr) >> 2);
  584. qdf_mem_zero((reo_desc + NUM_OF_DWORDS_UNIFORM_REO_CMD_HEADER),
  585. sizeof(struct reo_flush_timeout_list) -
  586. (NUM_OF_DWORDS_UNIFORM_REO_CMD_HEADER << 2));
  587. HAL_DESC_SET_FIELD(reo_desc, UNIFORM_REO_CMD_HEADER_0,
  588. REO_STATUS_REQUIRED, cmd->std.need_status);
  589. HAL_DESC_SET_FIELD(reo_desc, REO_FLUSH_TIMEOUT_LIST_1, AC_TIMOUT_LIST,
  590. cmd->u.fl_tim_list_params.ac_list);
  591. HAL_DESC_SET_FIELD(reo_desc, REO_FLUSH_TIMEOUT_LIST_2,
  592. MINIMUM_RELEASE_DESC_COUNT,
  593. cmd->u.fl_tim_list_params.min_rel_desc);
  594. HAL_DESC_SET_FIELD(reo_desc, REO_FLUSH_TIMEOUT_LIST_2,
  595. MINIMUM_FORWARD_BUF_COUNT,
  596. cmd->u.fl_tim_list_params.min_fwd_buf);
  597. hal_srng_access_end(hal_soc, hal_ring_hdl);
  598. val = reo_desc[CMD_HEADER_DW_OFFSET];
  599. return HAL_GET_FIELD(UNIFORM_REO_CMD_HEADER_0, REO_CMD_NUMBER,
  600. val);
  601. }
  602. qdf_export_symbol(hal_reo_cmd_flush_timeout_list);
  603. inline int hal_reo_cmd_update_rx_queue(hal_ring_handle_t hal_ring_hdl,
  604. hal_soc_handle_t hal_soc_hdl,
  605. struct hal_reo_cmd_params *cmd)
  606. {
  607. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  608. uint32_t *reo_desc, val;
  609. struct hal_reo_cmd_update_queue_params *p;
  610. p = &cmd->u.upd_queue_params;
  611. hal_srng_access_start(hal_soc_hdl, hal_ring_hdl);
  612. reo_desc = hal_srng_src_get_next(hal_soc, hal_ring_hdl);
  613. if (!reo_desc) {
  614. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_DEBUG,
  615. "%s: Out of cmd ring entries", __func__);
  616. hal_srng_access_end(hal_soc, hal_ring_hdl);
  617. return -EBUSY;
  618. }
  619. HAL_SET_TLV_HDR(reo_desc, WIFIREO_UPDATE_RX_REO_QUEUE_E,
  620. sizeof(struct reo_update_rx_reo_queue));
  621. /* Offsets of descriptor fields defined in HW headers start from
  622. * the field after TLV header */
  623. reo_desc += (sizeof(struct tlv_32_hdr) >> 2);
  624. qdf_mem_zero((reo_desc + NUM_OF_DWORDS_UNIFORM_REO_CMD_HEADER),
  625. sizeof(struct reo_update_rx_reo_queue) -
  626. (NUM_OF_DWORDS_UNIFORM_REO_CMD_HEADER << 2));
  627. HAL_DESC_SET_FIELD(reo_desc, UNIFORM_REO_CMD_HEADER_0,
  628. REO_STATUS_REQUIRED, cmd->std.need_status);
  629. hal_reo_cmd_set_descr_addr(reo_desc, CMD_UPDATE_RX_REO_QUEUE,
  630. cmd->std.addr_lo, cmd->std.addr_hi);
  631. HAL_DESC_SET_FIELD(reo_desc, REO_UPDATE_RX_REO_QUEUE_2,
  632. UPDATE_RECEIVE_QUEUE_NUMBER, p->update_rx_queue_num);
  633. HAL_DESC_SET_FIELD(reo_desc, REO_UPDATE_RX_REO_QUEUE_2, UPDATE_VLD,
  634. p->update_vld);
  635. HAL_DESC_SET_FIELD(reo_desc, REO_UPDATE_RX_REO_QUEUE_2,
  636. UPDATE_ASSOCIATED_LINK_DESCRIPTOR_COUNTER,
  637. p->update_assoc_link_desc);
  638. HAL_DESC_SET_FIELD(reo_desc, REO_UPDATE_RX_REO_QUEUE_2,
  639. UPDATE_DISABLE_DUPLICATE_DETECTION,
  640. p->update_disable_dup_detect);
  641. HAL_DESC_SET_FIELD(reo_desc, REO_UPDATE_RX_REO_QUEUE_2,
  642. UPDATE_DISABLE_DUPLICATE_DETECTION,
  643. p->update_disable_dup_detect);
  644. HAL_DESC_SET_FIELD(reo_desc, REO_UPDATE_RX_REO_QUEUE_2,
  645. UPDATE_SOFT_REORDER_ENABLE,
  646. p->update_soft_reorder_enab);
  647. HAL_DESC_SET_FIELD(reo_desc, REO_UPDATE_RX_REO_QUEUE_2,
  648. UPDATE_AC, p->update_ac);
  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_BAR, p->update_bar);
  653. HAL_DESC_SET_FIELD(reo_desc, REO_UPDATE_RX_REO_QUEUE_2,
  654. UPDATE_RTY, p->update_rty);
  655. HAL_DESC_SET_FIELD(reo_desc, REO_UPDATE_RX_REO_QUEUE_2,
  656. UPDATE_CHK_2K_MODE, p->update_chk_2k_mode);
  657. HAL_DESC_SET_FIELD(reo_desc, REO_UPDATE_RX_REO_QUEUE_2,
  658. UPDATE_OOR_MODE, p->update_oor_mode);
  659. HAL_DESC_SET_FIELD(reo_desc, REO_UPDATE_RX_REO_QUEUE_2,
  660. UPDATE_BA_WINDOW_SIZE, p->update_ba_window_size);
  661. HAL_DESC_SET_FIELD(reo_desc, REO_UPDATE_RX_REO_QUEUE_2,
  662. UPDATE_PN_CHECK_NEEDED, p->update_pn_check_needed);
  663. HAL_DESC_SET_FIELD(reo_desc, REO_UPDATE_RX_REO_QUEUE_2,
  664. UPDATE_PN_SHALL_BE_EVEN, p->update_pn_even);
  665. HAL_DESC_SET_FIELD(reo_desc, REO_UPDATE_RX_REO_QUEUE_2,
  666. UPDATE_PN_SHALL_BE_UNEVEN, p->update_pn_uneven);
  667. HAL_DESC_SET_FIELD(reo_desc, REO_UPDATE_RX_REO_QUEUE_2,
  668. UPDATE_PN_HANDLING_ENABLE, p->update_pn_hand_enab);
  669. HAL_DESC_SET_FIELD(reo_desc, REO_UPDATE_RX_REO_QUEUE_2,
  670. UPDATE_PN_SIZE, p->update_pn_size);
  671. HAL_DESC_SET_FIELD(reo_desc, REO_UPDATE_RX_REO_QUEUE_2,
  672. UPDATE_IGNORE_AMPDU_FLAG, p->update_ignore_ampdu);
  673. HAL_DESC_SET_FIELD(reo_desc, REO_UPDATE_RX_REO_QUEUE_2,
  674. UPDATE_SVLD, p->update_svld);
  675. HAL_DESC_SET_FIELD(reo_desc, REO_UPDATE_RX_REO_QUEUE_2,
  676. UPDATE_SSN, p->update_ssn);
  677. HAL_DESC_SET_FIELD(reo_desc, REO_UPDATE_RX_REO_QUEUE_2,
  678. UPDATE_SEQ_2K_ERROR_DETECTED_FLAG,
  679. p->update_seq_2k_err_detect);
  680. HAL_DESC_SET_FIELD(reo_desc, REO_UPDATE_RX_REO_QUEUE_2,
  681. UPDATE_PN_VALID, p->update_pn_valid);
  682. HAL_DESC_SET_FIELD(reo_desc, REO_UPDATE_RX_REO_QUEUE_2,
  683. UPDATE_PN, p->update_pn);
  684. HAL_DESC_SET_FIELD(reo_desc, REO_UPDATE_RX_REO_QUEUE_3,
  685. RECEIVE_QUEUE_NUMBER, p->rx_queue_num);
  686. HAL_DESC_SET_FIELD(reo_desc, REO_UPDATE_RX_REO_QUEUE_3,
  687. VLD, p->vld);
  688. HAL_DESC_SET_FIELD(reo_desc, REO_UPDATE_RX_REO_QUEUE_3,
  689. ASSOCIATED_LINK_DESCRIPTOR_COUNTER,
  690. p->assoc_link_desc);
  691. HAL_DESC_SET_FIELD(reo_desc, REO_UPDATE_RX_REO_QUEUE_3,
  692. DISABLE_DUPLICATE_DETECTION, p->disable_dup_detect);
  693. HAL_DESC_SET_FIELD(reo_desc, REO_UPDATE_RX_REO_QUEUE_3,
  694. SOFT_REORDER_ENABLE, p->soft_reorder_enab);
  695. HAL_DESC_SET_FIELD(reo_desc, REO_UPDATE_RX_REO_QUEUE_3, AC, p->ac);
  696. HAL_DESC_SET_FIELD(reo_desc, REO_UPDATE_RX_REO_QUEUE_3,
  697. BAR, p->bar);
  698. HAL_DESC_SET_FIELD(reo_desc, REO_UPDATE_RX_REO_QUEUE_3,
  699. CHK_2K_MODE, p->chk_2k_mode);
  700. HAL_DESC_SET_FIELD(reo_desc, REO_UPDATE_RX_REO_QUEUE_3,
  701. RTY, p->rty);
  702. HAL_DESC_SET_FIELD(reo_desc, REO_UPDATE_RX_REO_QUEUE_3,
  703. OOR_MODE, p->oor_mode);
  704. HAL_DESC_SET_FIELD(reo_desc, REO_UPDATE_RX_REO_QUEUE_3,
  705. PN_CHECK_NEEDED, p->pn_check_needed);
  706. HAL_DESC_SET_FIELD(reo_desc, REO_UPDATE_RX_REO_QUEUE_3,
  707. PN_SHALL_BE_EVEN, p->pn_even);
  708. HAL_DESC_SET_FIELD(reo_desc, REO_UPDATE_RX_REO_QUEUE_3,
  709. PN_SHALL_BE_UNEVEN, p->pn_uneven);
  710. HAL_DESC_SET_FIELD(reo_desc, REO_UPDATE_RX_REO_QUEUE_3,
  711. PN_HANDLING_ENABLE, p->pn_hand_enab);
  712. HAL_DESC_SET_FIELD(reo_desc, REO_UPDATE_RX_REO_QUEUE_3,
  713. IGNORE_AMPDU_FLAG, p->ignore_ampdu);
  714. if (p->ba_window_size < 1)
  715. p->ba_window_size = 1;
  716. /*
  717. * WAR to get 2k exception in Non BA case.
  718. * Setting window size to 2 to get 2k jump exception
  719. * when we receive aggregates in Non BA case
  720. */
  721. if (p->ba_window_size == 1)
  722. p->ba_window_size++;
  723. HAL_DESC_SET_FIELD(reo_desc, REO_UPDATE_RX_REO_QUEUE_4,
  724. BA_WINDOW_SIZE, p->ba_window_size - 1);
  725. if (p->pn_size == 24)
  726. p->pn_size = PN_SIZE_24;
  727. else if (p->pn_size == 48)
  728. p->pn_size = PN_SIZE_48;
  729. else if (p->pn_size == 128)
  730. p->pn_size = PN_SIZE_128;
  731. HAL_DESC_SET_FIELD(reo_desc, REO_UPDATE_RX_REO_QUEUE_4,
  732. PN_SIZE, p->pn_size);
  733. HAL_DESC_SET_FIELD(reo_desc, REO_UPDATE_RX_REO_QUEUE_4,
  734. SVLD, p->svld);
  735. HAL_DESC_SET_FIELD(reo_desc, REO_UPDATE_RX_REO_QUEUE_4,
  736. SSN, p->ssn);
  737. HAL_DESC_SET_FIELD(reo_desc, REO_UPDATE_RX_REO_QUEUE_4,
  738. SEQ_2K_ERROR_DETECTED_FLAG, p->seq_2k_err_detect);
  739. HAL_DESC_SET_FIELD(reo_desc, REO_UPDATE_RX_REO_QUEUE_4,
  740. PN_ERROR_DETECTED_FLAG, p->pn_err_detect);
  741. HAL_DESC_SET_FIELD(reo_desc, REO_UPDATE_RX_REO_QUEUE_5,
  742. PN_31_0, p->pn_31_0);
  743. HAL_DESC_SET_FIELD(reo_desc, REO_UPDATE_RX_REO_QUEUE_6,
  744. PN_63_32, p->pn_63_32);
  745. HAL_DESC_SET_FIELD(reo_desc, REO_UPDATE_RX_REO_QUEUE_7,
  746. PN_95_64, p->pn_95_64);
  747. HAL_DESC_SET_FIELD(reo_desc, REO_UPDATE_RX_REO_QUEUE_8,
  748. PN_127_96, p->pn_127_96);
  749. if (hif_pm_runtime_get(hal_soc->hif_handle) == 0) {
  750. hal_srng_access_end(hal_soc_hdl, hal_ring_hdl);
  751. hif_pm_runtime_put(hal_soc->hif_handle);
  752. } else {
  753. hal_srng_access_end_reap(hal_soc_hdl, hal_ring_hdl);
  754. hal_srng_set_event(hal_ring_hdl, HAL_SRNG_FLUSH_EVENT);
  755. hal_srng_inc_flush_cnt(hal_ring_hdl);
  756. }
  757. val = reo_desc[CMD_HEADER_DW_OFFSET];
  758. return HAL_GET_FIELD(UNIFORM_REO_CMD_HEADER_0, REO_CMD_NUMBER,
  759. val);
  760. }
  761. qdf_export_symbol(hal_reo_cmd_update_rx_queue);
  762. inline void
  763. hal_reo_queue_stats_status(uint32_t *reo_desc,
  764. struct hal_reo_queue_status *st,
  765. hal_soc_handle_t hal_soc_hdl)
  766. {
  767. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  768. uint32_t val;
  769. /* Offsets of descriptor fields defined in HW headers start
  770. * from the field after TLV header */
  771. reo_desc += (sizeof(struct tlv_32_hdr) >> 2);
  772. /* header */
  773. hal_reo_status_get_header(reo_desc, HAL_REO_QUEUE_STATS_STATUS_TLV,
  774. &(st->header), hal_soc);
  775. /* SSN */
  776. val = reo_desc[HAL_OFFSET_DW(REO_GET_QUEUE_STATS_STATUS_2, SSN)];
  777. st->ssn = HAL_GET_FIELD(REO_GET_QUEUE_STATS_STATUS_2, SSN, val);
  778. /* current index */
  779. val = reo_desc[HAL_OFFSET_DW(REO_GET_QUEUE_STATS_STATUS_2,
  780. CURRENT_INDEX)];
  781. st->curr_idx =
  782. HAL_GET_FIELD(REO_GET_QUEUE_STATS_STATUS_2,
  783. CURRENT_INDEX, val);
  784. /* PN bits */
  785. val = reo_desc[HAL_OFFSET_DW(REO_GET_QUEUE_STATS_STATUS_3,
  786. PN_31_0)];
  787. st->pn_31_0 =
  788. HAL_GET_FIELD(REO_GET_QUEUE_STATS_STATUS_3,
  789. PN_31_0, val);
  790. val = reo_desc[HAL_OFFSET_DW(REO_GET_QUEUE_STATS_STATUS_4,
  791. PN_63_32)];
  792. st->pn_63_32 =
  793. HAL_GET_FIELD(REO_GET_QUEUE_STATS_STATUS_4,
  794. PN_63_32, val);
  795. val = reo_desc[HAL_OFFSET_DW(REO_GET_QUEUE_STATS_STATUS_5,
  796. PN_95_64)];
  797. st->pn_95_64 =
  798. HAL_GET_FIELD(REO_GET_QUEUE_STATS_STATUS_5,
  799. PN_95_64, val);
  800. val = reo_desc[HAL_OFFSET_DW(REO_GET_QUEUE_STATS_STATUS_6,
  801. PN_127_96)];
  802. st->pn_127_96 =
  803. HAL_GET_FIELD(REO_GET_QUEUE_STATS_STATUS_6,
  804. PN_127_96, val);
  805. /* timestamps */
  806. val = reo_desc[HAL_OFFSET_DW(REO_GET_QUEUE_STATS_STATUS_7,
  807. LAST_RX_ENQUEUE_TIMESTAMP)];
  808. st->last_rx_enq_tstamp =
  809. HAL_GET_FIELD(REO_GET_QUEUE_STATS_STATUS_7,
  810. LAST_RX_ENQUEUE_TIMESTAMP, val);
  811. val = reo_desc[HAL_OFFSET_DW(REO_GET_QUEUE_STATS_STATUS_8,
  812. LAST_RX_DEQUEUE_TIMESTAMP)];
  813. st->last_rx_deq_tstamp =
  814. HAL_GET_FIELD(REO_GET_QUEUE_STATS_STATUS_8,
  815. LAST_RX_DEQUEUE_TIMESTAMP, val);
  816. /* rx bitmap */
  817. val = reo_desc[HAL_OFFSET_DW(REO_GET_QUEUE_STATS_STATUS_9,
  818. RX_BITMAP_31_0)];
  819. st->rx_bitmap_31_0 =
  820. HAL_GET_FIELD(REO_GET_QUEUE_STATS_STATUS_9,
  821. RX_BITMAP_31_0, val);
  822. val = reo_desc[HAL_OFFSET_DW(REO_GET_QUEUE_STATS_STATUS_10,
  823. RX_BITMAP_63_32)];
  824. st->rx_bitmap_63_32 =
  825. HAL_GET_FIELD(REO_GET_QUEUE_STATS_STATUS_10,
  826. RX_BITMAP_63_32, val);
  827. val = reo_desc[HAL_OFFSET_DW(REO_GET_QUEUE_STATS_STATUS_11,
  828. RX_BITMAP_95_64)];
  829. st->rx_bitmap_95_64 =
  830. HAL_GET_FIELD(REO_GET_QUEUE_STATS_STATUS_11,
  831. RX_BITMAP_95_64, val);
  832. val = reo_desc[HAL_OFFSET_DW(REO_GET_QUEUE_STATS_STATUS_12,
  833. RX_BITMAP_127_96)];
  834. st->rx_bitmap_127_96 =
  835. HAL_GET_FIELD(REO_GET_QUEUE_STATS_STATUS_12,
  836. RX_BITMAP_127_96, val);
  837. val = reo_desc[HAL_OFFSET_DW(REO_GET_QUEUE_STATS_STATUS_13,
  838. RX_BITMAP_159_128)];
  839. st->rx_bitmap_159_128 =
  840. HAL_GET_FIELD(REO_GET_QUEUE_STATS_STATUS_13,
  841. RX_BITMAP_159_128, val);
  842. val = reo_desc[HAL_OFFSET_DW(REO_GET_QUEUE_STATS_STATUS_14,
  843. RX_BITMAP_191_160)];
  844. st->rx_bitmap_191_160 =
  845. HAL_GET_FIELD(REO_GET_QUEUE_STATS_STATUS_14,
  846. RX_BITMAP_191_160, val);
  847. val = reo_desc[HAL_OFFSET_DW(REO_GET_QUEUE_STATS_STATUS_15,
  848. RX_BITMAP_223_192)];
  849. st->rx_bitmap_223_192 =
  850. HAL_GET_FIELD(REO_GET_QUEUE_STATS_STATUS_15,
  851. RX_BITMAP_223_192, val);
  852. val = reo_desc[HAL_OFFSET_DW(REO_GET_QUEUE_STATS_STATUS_16,
  853. RX_BITMAP_255_224)];
  854. st->rx_bitmap_255_224 =
  855. HAL_GET_FIELD(REO_GET_QUEUE_STATS_STATUS_16,
  856. RX_BITMAP_255_224, val);
  857. /* various counts */
  858. val = reo_desc[HAL_OFFSET_DW(REO_GET_QUEUE_STATS_STATUS_17,
  859. CURRENT_MPDU_COUNT)];
  860. st->curr_mpdu_cnt =
  861. HAL_GET_FIELD(REO_GET_QUEUE_STATS_STATUS_17,
  862. CURRENT_MPDU_COUNT, val);
  863. val = reo_desc[HAL_OFFSET_DW(REO_GET_QUEUE_STATS_STATUS_17,
  864. CURRENT_MSDU_COUNT)];
  865. st->curr_msdu_cnt =
  866. HAL_GET_FIELD(REO_GET_QUEUE_STATS_STATUS_17,
  867. CURRENT_MSDU_COUNT, val);
  868. val = reo_desc[HAL_OFFSET_DW(REO_GET_QUEUE_STATS_STATUS_18,
  869. TIMEOUT_COUNT)];
  870. st->fwd_timeout_cnt =
  871. HAL_GET_FIELD(REO_GET_QUEUE_STATS_STATUS_18,
  872. TIMEOUT_COUNT, val);
  873. val = reo_desc[HAL_OFFSET_DW(REO_GET_QUEUE_STATS_STATUS_18,
  874. FORWARD_DUE_TO_BAR_COUNT)];
  875. st->fwd_bar_cnt =
  876. HAL_GET_FIELD(REO_GET_QUEUE_STATS_STATUS_18,
  877. FORWARD_DUE_TO_BAR_COUNT, val);
  878. val = reo_desc[HAL_OFFSET_DW(REO_GET_QUEUE_STATS_STATUS_18,
  879. DUPLICATE_COUNT)];
  880. st->dup_cnt =
  881. HAL_GET_FIELD(REO_GET_QUEUE_STATS_STATUS_18,
  882. DUPLICATE_COUNT, val);
  883. val = reo_desc[HAL_OFFSET_DW(REO_GET_QUEUE_STATS_STATUS_19,
  884. FRAMES_IN_ORDER_COUNT)];
  885. st->frms_in_order_cnt =
  886. HAL_GET_FIELD(REO_GET_QUEUE_STATS_STATUS_19,
  887. FRAMES_IN_ORDER_COUNT, val);
  888. val = reo_desc[HAL_OFFSET_DW(REO_GET_QUEUE_STATS_STATUS_19,
  889. BAR_RECEIVED_COUNT)];
  890. st->bar_rcvd_cnt =
  891. HAL_GET_FIELD(REO_GET_QUEUE_STATS_STATUS_19,
  892. BAR_RECEIVED_COUNT, val);
  893. val = reo_desc[HAL_OFFSET_DW(REO_GET_QUEUE_STATS_STATUS_20,
  894. MPDU_FRAMES_PROCESSED_COUNT)];
  895. st->mpdu_frms_cnt =
  896. HAL_GET_FIELD(REO_GET_QUEUE_STATS_STATUS_20,
  897. MPDU_FRAMES_PROCESSED_COUNT, val);
  898. val = reo_desc[HAL_OFFSET_DW(REO_GET_QUEUE_STATS_STATUS_21,
  899. MSDU_FRAMES_PROCESSED_COUNT)];
  900. st->msdu_frms_cnt =
  901. HAL_GET_FIELD(REO_GET_QUEUE_STATS_STATUS_21,
  902. MSDU_FRAMES_PROCESSED_COUNT, val);
  903. val = reo_desc[HAL_OFFSET_DW(REO_GET_QUEUE_STATS_STATUS_22,
  904. TOTAL_PROCESSED_BYTE_COUNT)];
  905. st->total_cnt =
  906. HAL_GET_FIELD(REO_GET_QUEUE_STATS_STATUS_22,
  907. TOTAL_PROCESSED_BYTE_COUNT, val);
  908. val = reo_desc[HAL_OFFSET_DW(REO_GET_QUEUE_STATS_STATUS_23,
  909. LATE_RECEIVE_MPDU_COUNT)];
  910. st->late_recv_mpdu_cnt =
  911. HAL_GET_FIELD(REO_GET_QUEUE_STATS_STATUS_23,
  912. LATE_RECEIVE_MPDU_COUNT, val);
  913. val = reo_desc[HAL_OFFSET_DW(REO_GET_QUEUE_STATS_STATUS_23,
  914. WINDOW_JUMP_2K)];
  915. st->win_jump_2k =
  916. HAL_GET_FIELD(REO_GET_QUEUE_STATS_STATUS_23,
  917. WINDOW_JUMP_2K, val);
  918. val = reo_desc[HAL_OFFSET_DW(REO_GET_QUEUE_STATS_STATUS_23,
  919. HOLE_COUNT)];
  920. st->hole_cnt =
  921. HAL_GET_FIELD(REO_GET_QUEUE_STATS_STATUS_23,
  922. HOLE_COUNT, val);
  923. }
  924. qdf_export_symbol(hal_reo_queue_stats_status);
  925. inline void
  926. hal_reo_flush_queue_status(uint32_t *reo_desc,
  927. struct hal_reo_flush_queue_status *st,
  928. hal_soc_handle_t hal_soc_hdl)
  929. {
  930. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  931. uint32_t val;
  932. /* Offsets of descriptor fields defined in HW headers start
  933. * from the field after TLV header */
  934. reo_desc += (sizeof(struct tlv_32_hdr) >> 2);
  935. /* header */
  936. hal_reo_status_get_header(reo_desc, HAL_REO_FLUSH_QUEUE_STATUS_TLV,
  937. &(st->header), hal_soc);
  938. /* error bit */
  939. val = reo_desc[HAL_OFFSET(REO_FLUSH_QUEUE_STATUS_2,
  940. ERROR_DETECTED)];
  941. st->error = HAL_GET_FIELD(REO_FLUSH_QUEUE_STATUS_2, ERROR_DETECTED,
  942. val);
  943. }
  944. qdf_export_symbol(hal_reo_flush_queue_status);
  945. inline void
  946. hal_reo_flush_cache_status(uint32_t *reo_desc,
  947. struct hal_reo_flush_cache_status *st,
  948. hal_soc_handle_t hal_soc_hdl)
  949. {
  950. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  951. uint32_t val;
  952. /* Offsets of descriptor fields defined in HW headers start
  953. * from the field after TLV header */
  954. reo_desc += (sizeof(struct tlv_32_hdr) >> 2);
  955. /* header */
  956. hal_reo_status_get_header(reo_desc, HAL_REO_FLUSH_CACHE_STATUS_TLV,
  957. &(st->header), hal_soc);
  958. /* error bit */
  959. val = reo_desc[HAL_OFFSET_DW(REO_FLUSH_CACHE_STATUS_2,
  960. ERROR_DETECTED)];
  961. st->error = HAL_GET_FIELD(REO_FLUSH_QUEUE_STATUS_2, ERROR_DETECTED,
  962. val);
  963. /* block error */
  964. val = reo_desc[HAL_OFFSET_DW(REO_FLUSH_CACHE_STATUS_2,
  965. BLOCK_ERROR_DETAILS)];
  966. st->block_error = HAL_GET_FIELD(REO_FLUSH_CACHE_STATUS_2,
  967. BLOCK_ERROR_DETAILS,
  968. val);
  969. if (!st->block_error)
  970. qdf_set_bit(hal_soc->index,
  971. (unsigned long *)&hal_soc->reo_res_bitmap);
  972. /* cache flush status */
  973. val = reo_desc[HAL_OFFSET_DW(REO_FLUSH_CACHE_STATUS_2,
  974. CACHE_CONTROLLER_FLUSH_STATUS_HIT)];
  975. st->cache_flush_status = HAL_GET_FIELD(REO_FLUSH_CACHE_STATUS_2,
  976. CACHE_CONTROLLER_FLUSH_STATUS_HIT,
  977. val);
  978. /* cache flush descriptor type */
  979. val = reo_desc[HAL_OFFSET_DW(REO_FLUSH_CACHE_STATUS_2,
  980. CACHE_CONTROLLER_FLUSH_STATUS_DESC_TYPE)];
  981. st->cache_flush_status_desc_type =
  982. HAL_GET_FIELD(REO_FLUSH_CACHE_STATUS_2,
  983. CACHE_CONTROLLER_FLUSH_STATUS_DESC_TYPE,
  984. val);
  985. /* cache flush count */
  986. val = reo_desc[HAL_OFFSET_DW(REO_FLUSH_CACHE_STATUS_2,
  987. CACHE_CONTROLLER_FLUSH_COUNT)];
  988. st->cache_flush_cnt =
  989. HAL_GET_FIELD(REO_FLUSH_CACHE_STATUS_2,
  990. CACHE_CONTROLLER_FLUSH_COUNT,
  991. val);
  992. }
  993. qdf_export_symbol(hal_reo_flush_cache_status);
  994. inline void hal_reo_unblock_cache_status(uint32_t *reo_desc,
  995. hal_soc_handle_t hal_soc_hdl,
  996. struct hal_reo_unblk_cache_status *st)
  997. {
  998. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  999. uint32_t val;
  1000. /* Offsets of descriptor fields defined in HW headers start
  1001. * from the field after TLV header */
  1002. reo_desc += (sizeof(struct tlv_32_hdr) >> 2);
  1003. /* header */
  1004. hal_reo_status_get_header(reo_desc, HAL_REO_UNBLK_CACHE_STATUS_TLV,
  1005. &st->header, hal_soc);
  1006. /* error bit */
  1007. val = reo_desc[HAL_OFFSET_DW(REO_UNBLOCK_CACHE_STATUS_2,
  1008. ERROR_DETECTED)];
  1009. st->error = HAL_GET_FIELD(REO_UNBLOCK_CACHE_STATUS_2,
  1010. ERROR_DETECTED,
  1011. val);
  1012. /* unblock type */
  1013. val = reo_desc[HAL_OFFSET_DW(REO_UNBLOCK_CACHE_STATUS_2,
  1014. UNBLOCK_TYPE)];
  1015. st->unblock_type = HAL_GET_FIELD(REO_UNBLOCK_CACHE_STATUS_2,
  1016. UNBLOCK_TYPE,
  1017. val);
  1018. if (!st->error && (st->unblock_type == UNBLOCK_RES_INDEX))
  1019. qdf_clear_bit(hal_soc->index,
  1020. (unsigned long *)&hal_soc->reo_res_bitmap);
  1021. }
  1022. qdf_export_symbol(hal_reo_unblock_cache_status);
  1023. inline void hal_reo_flush_timeout_list_status(
  1024. uint32_t *reo_desc,
  1025. struct hal_reo_flush_timeout_list_status *st,
  1026. hal_soc_handle_t hal_soc_hdl)
  1027. {
  1028. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  1029. uint32_t val;
  1030. /* Offsets of descriptor fields defined in HW headers start
  1031. * from the field after TLV header */
  1032. reo_desc += (sizeof(struct tlv_32_hdr) >> 2);
  1033. /* header */
  1034. hal_reo_status_get_header(reo_desc, HAL_REO_TIMOUT_LIST_STATUS_TLV,
  1035. &(st->header), hal_soc);
  1036. /* error bit */
  1037. val = reo_desc[HAL_OFFSET_DW(REO_FLUSH_TIMEOUT_LIST_STATUS_2,
  1038. ERROR_DETECTED)];
  1039. st->error = HAL_GET_FIELD(REO_FLUSH_TIMEOUT_LIST_STATUS_2,
  1040. ERROR_DETECTED,
  1041. val);
  1042. /* list empty */
  1043. val = reo_desc[HAL_OFFSET_DW(REO_FLUSH_TIMEOUT_LIST_STATUS_2,
  1044. TIMOUT_LIST_EMPTY)];
  1045. st->list_empty = HAL_GET_FIELD(REO_FLUSH_TIMEOUT_LIST_STATUS_2,
  1046. TIMOUT_LIST_EMPTY,
  1047. val);
  1048. /* release descriptor count */
  1049. val = reo_desc[HAL_OFFSET_DW(REO_FLUSH_TIMEOUT_LIST_STATUS_3,
  1050. RELEASE_DESC_COUNT)];
  1051. st->rel_desc_cnt = HAL_GET_FIELD(REO_FLUSH_TIMEOUT_LIST_STATUS_3,
  1052. RELEASE_DESC_COUNT,
  1053. val);
  1054. /* forward buf count */
  1055. val = reo_desc[HAL_OFFSET_DW(REO_FLUSH_TIMEOUT_LIST_STATUS_3,
  1056. FORWARD_BUF_COUNT)];
  1057. st->fwd_buf_cnt = HAL_GET_FIELD(REO_FLUSH_TIMEOUT_LIST_STATUS_3,
  1058. FORWARD_BUF_COUNT,
  1059. val);
  1060. }
  1061. qdf_export_symbol(hal_reo_flush_timeout_list_status);
  1062. inline void hal_reo_desc_thres_reached_status(
  1063. uint32_t *reo_desc,
  1064. struct hal_reo_desc_thres_reached_status *st,
  1065. hal_soc_handle_t hal_soc_hdl)
  1066. {
  1067. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  1068. uint32_t val;
  1069. /* Offsets of descriptor fields defined in HW headers start
  1070. * from the field after TLV header */
  1071. reo_desc += (sizeof(struct tlv_32_hdr) >> 2);
  1072. /* header */
  1073. hal_reo_status_get_header(reo_desc,
  1074. HAL_REO_DESC_THRES_STATUS_TLV,
  1075. &(st->header), hal_soc);
  1076. /* threshold index */
  1077. val = reo_desc[HAL_OFFSET_DW(
  1078. REO_DESCRIPTOR_THRESHOLD_REACHED_STATUS_2,
  1079. THRESHOLD_INDEX)];
  1080. st->thres_index = HAL_GET_FIELD(
  1081. REO_DESCRIPTOR_THRESHOLD_REACHED_STATUS_2,
  1082. THRESHOLD_INDEX,
  1083. val);
  1084. /* link desc counters */
  1085. val = reo_desc[HAL_OFFSET_DW(
  1086. REO_DESCRIPTOR_THRESHOLD_REACHED_STATUS_3,
  1087. LINK_DESCRIPTOR_COUNTER0)];
  1088. st->link_desc_counter0 = HAL_GET_FIELD(
  1089. REO_DESCRIPTOR_THRESHOLD_REACHED_STATUS_3,
  1090. LINK_DESCRIPTOR_COUNTER0,
  1091. val);
  1092. val = reo_desc[HAL_OFFSET_DW(
  1093. REO_DESCRIPTOR_THRESHOLD_REACHED_STATUS_4,
  1094. LINK_DESCRIPTOR_COUNTER1)];
  1095. st->link_desc_counter1 = HAL_GET_FIELD(
  1096. REO_DESCRIPTOR_THRESHOLD_REACHED_STATUS_4,
  1097. LINK_DESCRIPTOR_COUNTER1,
  1098. val);
  1099. val = reo_desc[HAL_OFFSET_DW(
  1100. REO_DESCRIPTOR_THRESHOLD_REACHED_STATUS_5,
  1101. LINK_DESCRIPTOR_COUNTER2)];
  1102. st->link_desc_counter2 = HAL_GET_FIELD(
  1103. REO_DESCRIPTOR_THRESHOLD_REACHED_STATUS_5,
  1104. LINK_DESCRIPTOR_COUNTER2,
  1105. val);
  1106. val = reo_desc[HAL_OFFSET_DW(
  1107. REO_DESCRIPTOR_THRESHOLD_REACHED_STATUS_6,
  1108. LINK_DESCRIPTOR_COUNTER_SUM)];
  1109. st->link_desc_counter_sum = HAL_GET_FIELD(
  1110. REO_DESCRIPTOR_THRESHOLD_REACHED_STATUS_6,
  1111. LINK_DESCRIPTOR_COUNTER_SUM,
  1112. val);
  1113. }
  1114. qdf_export_symbol(hal_reo_desc_thres_reached_status);
  1115. inline void
  1116. hal_reo_rx_update_queue_status(uint32_t *reo_desc,
  1117. struct hal_reo_update_rx_queue_status *st,
  1118. hal_soc_handle_t hal_soc_hdl)
  1119. {
  1120. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  1121. /* Offsets of descriptor fields defined in HW headers start
  1122. * from the field after TLV header */
  1123. reo_desc += (sizeof(struct tlv_32_hdr) >> 2);
  1124. /* header */
  1125. hal_reo_status_get_header(reo_desc,
  1126. HAL_REO_UPDATE_RX_QUEUE_STATUS_TLV,
  1127. &(st->header), hal_soc);
  1128. }
  1129. qdf_export_symbol(hal_reo_rx_update_queue_status);
  1130. /**
  1131. * hal_reo_init_cmd_ring() - Initialize descriptors of REO command SRNG
  1132. * with command number
  1133. * @hal_soc: Handle to HAL SoC structure
  1134. * @hal_ring: Handle to HAL SRNG structure
  1135. *
  1136. * Return: none
  1137. */
  1138. inline void hal_reo_init_cmd_ring(hal_soc_handle_t hal_soc_hdl,
  1139. hal_ring_handle_t hal_ring_hdl)
  1140. {
  1141. int cmd_num;
  1142. uint32_t *desc_addr;
  1143. struct hal_srng_params srng_params;
  1144. uint32_t desc_size;
  1145. uint32_t num_desc;
  1146. struct hal_soc *soc = (struct hal_soc *)hal_soc_hdl;
  1147. hal_get_srng_params(hal_soc_hdl, hal_ring_hdl, &srng_params);
  1148. desc_addr = (uint32_t *)(srng_params.ring_base_vaddr);
  1149. desc_addr += (sizeof(struct tlv_32_hdr) >> 2);
  1150. desc_size = hal_srng_get_entrysize(soc, REO_CMD) >> 2;
  1151. num_desc = srng_params.num_entries;
  1152. cmd_num = 1;
  1153. while (num_desc) {
  1154. /* Offsets of descriptor fields defined in HW headers start
  1155. * from the field after TLV header */
  1156. HAL_DESC_SET_FIELD(desc_addr, UNIFORM_REO_CMD_HEADER_0,
  1157. REO_CMD_NUMBER, cmd_num);
  1158. desc_addr += desc_size;
  1159. num_desc--; cmd_num++;
  1160. }
  1161. soc->reo_res_bitmap = 0;
  1162. }
  1163. qdf_export_symbol(hal_reo_init_cmd_ring);