hal_be_reo.c 36 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136
  1. /*
  2. * Copyright (c) 2016-2021 The Linux Foundation. All rights reserved.
  3. * Copyright (c) 2021-2023 Qualcomm Innovation Center, Inc. All rights reserved.
  4. *
  5. * Permission to use, copy, modify, and/or distribute this software for
  6. * any purpose with or without fee is hereby granted, provided that the
  7. * above copyright notice and this permission notice appear in all
  8. * copies.
  9. *
  10. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
  11. * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
  12. * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
  13. * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
  14. * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
  15. * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  16. * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  17. * PERFORMANCE OF THIS SOFTWARE.
  18. */
  19. #include "qdf_module.h"
  20. #include "hal_hw_headers.h"
  21. #include "hal_be_hw_headers.h"
  22. #include "hal_reo.h"
  23. #include "hal_be_reo.h"
  24. #include "hal_be_api.h"
  25. uint32_t hal_get_reo_reg_base_offset_be(void)
  26. {
  27. return REO_REG_REG_BASE;
  28. }
  29. void hal_reo_qdesc_setup_be(hal_soc_handle_t hal_soc_hdl, int tid,
  30. uint32_t ba_window_size,
  31. uint32_t start_seq, void *hw_qdesc_vaddr,
  32. qdf_dma_addr_t hw_qdesc_paddr,
  33. int pn_type, uint8_t vdev_stats_id)
  34. {
  35. uint32_t *reo_queue_desc = (uint32_t *)hw_qdesc_vaddr;
  36. uint32_t *reo_queue_ext_desc;
  37. uint32_t reg_val;
  38. uint32_t pn_enable;
  39. uint32_t pn_size = 0;
  40. qdf_mem_zero(hw_qdesc_vaddr, sizeof(struct rx_reo_queue));
  41. hal_uniform_desc_hdr_setup(reo_queue_desc, HAL_DESC_REO_OWNED,
  42. HAL_REO_QUEUE_DESC);
  43. /* Fixed pattern in reserved bits for debugging */
  44. HAL_DESC_SET_FIELD(reo_queue_desc, UNIFORM_DESCRIPTOR_HEADER,
  45. RESERVED_0A, 0xDDBEEF);
  46. /* This a just a SW meta data and will be copied to REO destination
  47. * descriptors indicated by hardware.
  48. * TODO: Setting TID in this field. See if we should set something else.
  49. */
  50. HAL_DESC_SET_FIELD(reo_queue_desc, RX_REO_QUEUE,
  51. RECEIVE_QUEUE_NUMBER, tid);
  52. HAL_DESC_SET_FIELD(reo_queue_desc, RX_REO_QUEUE,
  53. VLD, 1);
  54. HAL_DESC_SET_FIELD(reo_queue_desc, RX_REO_QUEUE,
  55. ASSOCIATED_LINK_DESCRIPTOR_COUNTER,
  56. HAL_RX_LINK_DESC_CNTR);
  57. /*
  58. * Fields DISABLE_DUPLICATE_DETECTION and SOFT_REORDER_ENABLE will be 0
  59. */
  60. reg_val = TID_TO_WME_AC(tid);
  61. HAL_DESC_SET_FIELD(reo_queue_desc, RX_REO_QUEUE, AC, reg_val);
  62. if (ba_window_size < 1)
  63. ba_window_size = 1;
  64. /* WAR to get 2k exception in Non BA case.
  65. * Setting window size to 2 to get 2k jump exception
  66. * when we receive aggregates in Non BA case
  67. */
  68. ba_window_size = hal_update_non_ba_win_size(tid, ba_window_size);
  69. /* Set RTY bit for non-BA case. Duplicate detection is currently not
  70. * done by HW in non-BA case if RTY bit is not set.
  71. * TODO: This is a temporary War and should be removed once HW fix is
  72. * made to check and discard duplicates even if RTY bit is not set.
  73. */
  74. if (ba_window_size == 1)
  75. HAL_DESC_SET_FIELD(reo_queue_desc, RX_REO_QUEUE, RTY, 1);
  76. HAL_DESC_SET_FIELD(reo_queue_desc, RX_REO_QUEUE, BA_WINDOW_SIZE,
  77. ba_window_size - 1);
  78. switch (pn_type) {
  79. case HAL_PN_WPA:
  80. pn_enable = 1;
  81. pn_size = PN_SIZE_48;
  82. break;
  83. case HAL_PN_WAPI_EVEN:
  84. case HAL_PN_WAPI_UNEVEN:
  85. pn_enable = 1;
  86. pn_size = PN_SIZE_128;
  87. break;
  88. default:
  89. pn_enable = 0;
  90. break;
  91. }
  92. HAL_DESC_SET_FIELD(reo_queue_desc, RX_REO_QUEUE, PN_CHECK_NEEDED,
  93. pn_enable);
  94. if (pn_type == HAL_PN_WAPI_EVEN)
  95. HAL_DESC_SET_FIELD(reo_queue_desc, RX_REO_QUEUE,
  96. PN_SHALL_BE_EVEN, 1);
  97. else if (pn_type == HAL_PN_WAPI_UNEVEN)
  98. HAL_DESC_SET_FIELD(reo_queue_desc, RX_REO_QUEUE,
  99. PN_SHALL_BE_UNEVEN, 1);
  100. /*
  101. * TODO: Need to check if PN handling in SW needs to be enabled
  102. * So far this is not a requirement
  103. */
  104. HAL_DESC_SET_FIELD(reo_queue_desc, RX_REO_QUEUE, PN_SIZE,
  105. pn_size);
  106. /* TODO: Check if RX_REO_QUEUE_IGNORE_AMPDU_FLAG need to be set
  107. * based on BA window size and/or AMPDU capabilities
  108. */
  109. HAL_DESC_SET_FIELD(reo_queue_desc, RX_REO_QUEUE,
  110. IGNORE_AMPDU_FLAG, 1);
  111. if (start_seq <= 0xfff)
  112. HAL_DESC_SET_FIELD(reo_queue_desc, RX_REO_QUEUE, SSN,
  113. start_seq);
  114. /* TODO: SVLD should be set to 1 if a valid SSN is received in ADDBA,
  115. * but REO is not delivering packets if we set it to 1. Need to enable
  116. * this once the issue is resolved
  117. */
  118. HAL_DESC_SET_FIELD(reo_queue_desc, RX_REO_QUEUE, SVLD, 0);
  119. hal_update_stats_counter_index(reo_queue_desc, vdev_stats_id);
  120. /* TODO: Check if we should set start PN for WAPI */
  121. /* TODO: HW queue descriptors are currently allocated for max BA
  122. * window size for all QOS TIDs so that same descriptor can be used
  123. * later when ADDBA request is received. This should be changed to
  124. * allocate HW queue descriptors based on BA window size being
  125. * negotiated (0 for non BA cases), and reallocate when BA window
  126. * size changes and also send WMI message to FW to change the REO
  127. * queue descriptor in Rx peer entry as part of dp_rx_tid_update.
  128. */
  129. if (tid == HAL_NON_QOS_TID)
  130. return;
  131. reo_queue_ext_desc = (uint32_t *)
  132. (((struct rx_reo_queue *)reo_queue_desc) + 1);
  133. qdf_mem_zero(reo_queue_ext_desc, 3 *
  134. sizeof(struct rx_reo_queue_ext));
  135. /* Initialize first reo queue extension descriptor */
  136. hal_uniform_desc_hdr_setup(reo_queue_ext_desc,
  137. HAL_DESC_REO_OWNED,
  138. HAL_REO_QUEUE_EXT_DESC);
  139. /* Fixed pattern in reserved bits for debugging */
  140. HAL_DESC_SET_FIELD(reo_queue_ext_desc,
  141. UNIFORM_DESCRIPTOR_HEADER, RESERVED_0A,
  142. 0xADBEEF);
  143. /* Initialize second reo queue extension descriptor */
  144. reo_queue_ext_desc = (uint32_t *)
  145. (((struct rx_reo_queue_ext *)reo_queue_ext_desc) + 1);
  146. hal_uniform_desc_hdr_setup(reo_queue_ext_desc,
  147. HAL_DESC_REO_OWNED,
  148. HAL_REO_QUEUE_EXT_DESC);
  149. /* Fixed pattern in reserved bits for debugging */
  150. HAL_DESC_SET_FIELD(reo_queue_ext_desc,
  151. UNIFORM_DESCRIPTOR_HEADER, RESERVED_0A,
  152. 0xBDBEEF);
  153. /* Initialize third reo queue extension descriptor */
  154. reo_queue_ext_desc = (uint32_t *)
  155. (((struct rx_reo_queue_ext *)reo_queue_ext_desc) + 1);
  156. hal_uniform_desc_hdr_setup(reo_queue_ext_desc,
  157. HAL_DESC_REO_OWNED,
  158. HAL_REO_QUEUE_EXT_DESC);
  159. /* Fixed pattern in reserved bits for debugging */
  160. HAL_DESC_SET_FIELD(reo_queue_ext_desc,
  161. UNIFORM_DESCRIPTOR_HEADER, RESERVED_0A,
  162. 0xCDBEEF);
  163. }
  164. qdf_export_symbol(hal_reo_qdesc_setup_be);
  165. static void
  166. hal_reo_cmd_set_descr_addr_be(uint32_t *reo_desc,
  167. enum hal_reo_cmd_type type,
  168. uint32_t paddr_lo,
  169. uint8_t paddr_hi)
  170. {
  171. struct reo_get_queue_stats *reo_get_queue_stats;
  172. struct reo_flush_queue *reo_flush_queue;
  173. struct reo_flush_cache *reo_flush_cache;
  174. struct reo_update_rx_reo_queue *reo_update_rx_reo_queue;
  175. switch (type) {
  176. case CMD_GET_QUEUE_STATS:
  177. reo_get_queue_stats = (struct reo_get_queue_stats *)reo_desc;
  178. reo_get_queue_stats->rx_reo_queue_desc_addr_31_0 = paddr_lo;
  179. reo_get_queue_stats->rx_reo_queue_desc_addr_39_32 = paddr_hi;
  180. break;
  181. case CMD_FLUSH_QUEUE:
  182. reo_flush_queue = (struct reo_flush_queue *)reo_desc;
  183. reo_flush_queue->flush_desc_addr_31_0 = paddr_lo;
  184. reo_flush_queue->flush_desc_addr_39_32 = paddr_hi;
  185. break;
  186. case CMD_FLUSH_CACHE:
  187. reo_flush_cache = (struct reo_flush_cache *)reo_desc;
  188. reo_flush_cache->flush_addr_31_0 = paddr_lo;
  189. reo_flush_cache->flush_addr_39_32 = paddr_hi;
  190. break;
  191. case CMD_UPDATE_RX_REO_QUEUE:
  192. reo_update_rx_reo_queue =
  193. (struct reo_update_rx_reo_queue *)reo_desc;
  194. reo_update_rx_reo_queue->rx_reo_queue_desc_addr_31_0 = paddr_lo;
  195. reo_update_rx_reo_queue->rx_reo_queue_desc_addr_39_32 =
  196. paddr_hi;
  197. break;
  198. default:
  199. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
  200. "%s: Invalid REO command type", __func__);
  201. break;
  202. }
  203. }
  204. static int
  205. hal_reo_cmd_queue_stats_be(hal_ring_handle_t hal_ring_hdl,
  206. hal_soc_handle_t hal_soc_hdl,
  207. struct hal_reo_cmd_params *cmd)
  208. {
  209. uint32_t *reo_desc, val;
  210. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  211. struct reo_get_queue_stats *reo_get_queue_stats;
  212. hal_srng_access_start(hal_soc_hdl, hal_ring_hdl);
  213. reo_desc = hal_srng_src_get_next(hal_soc, hal_ring_hdl);
  214. if (!reo_desc) {
  215. hal_srng_access_end_reap(hal_soc, hal_ring_hdl);
  216. hal_warn_rl("Out of cmd ring entries");
  217. return -EBUSY;
  218. }
  219. HAL_SET_TLV_HDR(reo_desc, WIFIREO_GET_QUEUE_STATS_E,
  220. sizeof(struct reo_get_queue_stats));
  221. /*
  222. * Offsets of descriptor fields defined in HW headers start from
  223. * the field after TLV header
  224. */
  225. reo_desc += (sizeof(struct tlv_32_hdr) >> 2);
  226. qdf_mem_zero((reo_desc + NUM_OF_DWORDS_UNIFORM_REO_CMD_HEADER),
  227. sizeof(struct reo_get_queue_stats) -
  228. (NUM_OF_DWORDS_UNIFORM_REO_CMD_HEADER << 2));
  229. reo_get_queue_stats = (struct reo_get_queue_stats *)reo_desc;
  230. reo_get_queue_stats->cmd_header.reo_status_required =
  231. cmd->std.need_status;
  232. hal_reo_cmd_set_descr_addr_be(reo_desc, CMD_GET_QUEUE_STATS,
  233. cmd->std.addr_lo,
  234. cmd->std.addr_hi);
  235. reo_get_queue_stats->clear_stats = cmd->u.stats_params.clear;
  236. hal_srng_access_end_v1(hal_soc_hdl, hal_ring_hdl,
  237. HIF_RTPM_ID_HAL_REO_CMD);
  238. val = reo_desc[CMD_HEADER_DW_OFFSET];
  239. return HAL_GET_FIELD(UNIFORM_REO_CMD_HEADER, REO_CMD_NUMBER,
  240. val);
  241. }
  242. static int
  243. hal_reo_cmd_flush_queue_be(hal_ring_handle_t hal_ring_hdl,
  244. hal_soc_handle_t hal_soc_hdl,
  245. struct hal_reo_cmd_params *cmd)
  246. {
  247. uint32_t *reo_desc, val;
  248. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  249. struct reo_flush_queue *reo_flush_queue;
  250. hal_srng_access_start(hal_soc_hdl, hal_ring_hdl);
  251. reo_desc = hal_srng_src_get_next(hal_soc, hal_ring_hdl);
  252. if (!reo_desc) {
  253. hal_srng_access_end_reap(hal_soc, hal_ring_hdl);
  254. hal_warn_rl("Out of cmd ring entries");
  255. return -EBUSY;
  256. }
  257. HAL_SET_TLV_HDR(reo_desc, WIFIREO_FLUSH_QUEUE_E,
  258. sizeof(struct reo_flush_queue));
  259. /*
  260. * Offsets of descriptor fields defined in HW headers start from
  261. * the field after TLV header
  262. */
  263. reo_desc += (sizeof(struct tlv_32_hdr) >> 2);
  264. qdf_mem_zero((reo_desc + NUM_OF_DWORDS_UNIFORM_REO_CMD_HEADER),
  265. sizeof(struct reo_flush_queue) -
  266. (NUM_OF_DWORDS_UNIFORM_REO_CMD_HEADER << 2));
  267. reo_flush_queue = (struct reo_flush_queue *)reo_desc;
  268. reo_flush_queue->cmd_header.reo_status_required = cmd->std.need_status;
  269. hal_reo_cmd_set_descr_addr_be(reo_desc, CMD_FLUSH_QUEUE,
  270. cmd->std.addr_lo, cmd->std.addr_hi);
  271. reo_flush_queue->block_desc_addr_usage_after_flush =
  272. cmd->u.fl_queue_params.block_use_after_flush;
  273. if (cmd->u.fl_queue_params.block_use_after_flush)
  274. reo_flush_queue->block_resource_index =
  275. cmd->u.fl_queue_params.index;
  276. hal_srng_access_end_v1(hal_soc_hdl, hal_ring_hdl,
  277. HIF_RTPM_ID_HAL_REO_CMD);
  278. val = reo_desc[CMD_HEADER_DW_OFFSET];
  279. return HAL_GET_FIELD(UNIFORM_REO_CMD_HEADER, REO_CMD_NUMBER,
  280. val);
  281. }
  282. static int
  283. hal_reo_cmd_flush_cache_be(hal_ring_handle_t hal_ring_hdl,
  284. hal_soc_handle_t hal_soc_hdl,
  285. struct hal_reo_cmd_params *cmd)
  286. {
  287. uint32_t *reo_desc, val;
  288. struct hal_reo_cmd_flush_cache_params *cp;
  289. uint8_t index = 0;
  290. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  291. struct reo_flush_cache *reo_flush_cache;
  292. cp = &cmd->u.fl_cache_params;
  293. hal_srng_access_start(hal_soc_hdl, hal_ring_hdl);
  294. /* We need a cache block resource for this operation, and REO HW has
  295. * only 4 such blocking resources. These resources are managed using
  296. * reo_res_bitmap, and we return failure if none is available.
  297. */
  298. if (cp->block_use_after_flush) {
  299. index = hal_find_zero_bit(hal_soc->reo_res_bitmap);
  300. if (index > 3) {
  301. hal_srng_access_end_reap(hal_soc, hal_ring_hdl);
  302. hal_warn_rl("No blocking resource available!");
  303. return -EBUSY;
  304. }
  305. hal_soc->index = index;
  306. }
  307. reo_desc = hal_srng_src_get_next(hal_soc, hal_ring_hdl);
  308. if (!reo_desc) {
  309. hal_srng_access_end_reap(hal_soc, hal_ring_hdl);
  310. hal_srng_dump(hal_ring_handle_to_hal_srng(hal_ring_hdl));
  311. return -EBUSY;
  312. }
  313. HAL_SET_TLV_HDR(reo_desc, WIFIREO_FLUSH_CACHE_E,
  314. sizeof(struct reo_flush_cache));
  315. /*
  316. * Offsets of descriptor fields defined in HW headers start from
  317. * the field after TLV header
  318. */
  319. reo_desc += (sizeof(struct tlv_32_hdr) >> 2);
  320. qdf_mem_zero((reo_desc + NUM_OF_DWORDS_UNIFORM_REO_CMD_HEADER),
  321. sizeof(struct reo_flush_cache) -
  322. (NUM_OF_DWORDS_UNIFORM_REO_CMD_HEADER << 2));
  323. reo_flush_cache = (struct reo_flush_cache *)reo_desc;
  324. reo_flush_cache->cmd_header.reo_status_required = cmd->std.need_status;
  325. hal_reo_cmd_set_descr_addr_be(reo_desc, CMD_FLUSH_CACHE,
  326. cmd->std.addr_lo, cmd->std.addr_hi);
  327. reo_flush_cache->forward_all_mpdus_in_queue = cp->fwd_mpdus_in_queue;
  328. /* set it to 0 for now */
  329. cp->rel_block_index = 0;
  330. reo_flush_cache->release_cache_block_index = cp->rel_block_index;
  331. if (cp->block_use_after_flush) {
  332. reo_flush_cache->cache_block_resource_index = index;
  333. }
  334. reo_flush_cache->flush_without_invalidate = cp->flush_no_inval;
  335. reo_flush_cache->flush_queue_1k_desc = cp->flush_q_1k_desc;
  336. reo_flush_cache->block_cache_usage_after_flush =
  337. cp->block_use_after_flush;
  338. reo_flush_cache->flush_entire_cache = cp->flush_entire_cache;
  339. hal_srng_access_end_v1(hal_soc_hdl, hal_ring_hdl,
  340. HIF_RTPM_ID_HAL_REO_CMD);
  341. val = reo_desc[CMD_HEADER_DW_OFFSET];
  342. return HAL_GET_FIELD(UNIFORM_REO_CMD_HEADER, REO_CMD_NUMBER,
  343. val);
  344. }
  345. static int
  346. hal_reo_cmd_unblock_cache_be(hal_ring_handle_t hal_ring_hdl,
  347. hal_soc_handle_t hal_soc_hdl,
  348. struct hal_reo_cmd_params *cmd)
  349. {
  350. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  351. uint32_t *reo_desc, val;
  352. uint8_t index = 0;
  353. struct reo_unblock_cache *reo_unblock_cache;
  354. hal_srng_access_start(hal_soc_hdl, hal_ring_hdl);
  355. if (cmd->u.unblk_cache_params.type == UNBLOCK_RES_INDEX) {
  356. index = hal_find_one_bit(hal_soc->reo_res_bitmap);
  357. if (index > 3) {
  358. hal_srng_access_end(hal_soc, hal_ring_hdl);
  359. qdf_print("No blocking resource to unblock!");
  360. return -EBUSY;
  361. }
  362. }
  363. reo_desc = hal_srng_src_get_next(hal_soc, hal_ring_hdl);
  364. if (!reo_desc) {
  365. hal_srng_access_end_reap(hal_soc, hal_ring_hdl);
  366. hal_warn_rl("Out of cmd ring entries");
  367. return -EBUSY;
  368. }
  369. HAL_SET_TLV_HDR(reo_desc, WIFIREO_UNBLOCK_CACHE_E,
  370. sizeof(struct reo_unblock_cache));
  371. /*
  372. * Offsets of descriptor fields defined in HW headers start from
  373. * the field after TLV header
  374. */
  375. reo_desc += (sizeof(struct tlv_32_hdr) >> 2);
  376. qdf_mem_zero((reo_desc + NUM_OF_DWORDS_UNIFORM_REO_CMD_HEADER),
  377. sizeof(struct reo_unblock_cache) -
  378. (NUM_OF_DWORDS_UNIFORM_REO_CMD_HEADER << 2));
  379. reo_unblock_cache = (struct reo_unblock_cache *)reo_desc;
  380. reo_unblock_cache->cmd_header.reo_status_required =
  381. cmd->std.need_status;
  382. reo_unblock_cache->unblock_type = cmd->u.unblk_cache_params.type;
  383. if (cmd->u.unblk_cache_params.type == UNBLOCK_RES_INDEX)
  384. reo_unblock_cache->cache_block_resource_index =
  385. cmd->u.unblk_cache_params.index;
  386. hal_srng_access_end(hal_soc, hal_ring_hdl);
  387. val = reo_desc[CMD_HEADER_DW_OFFSET];
  388. return HAL_GET_FIELD(UNIFORM_REO_CMD_HEADER, REO_CMD_NUMBER,
  389. val);
  390. }
  391. static int
  392. hal_reo_cmd_flush_timeout_list_be(hal_ring_handle_t hal_ring_hdl,
  393. hal_soc_handle_t hal_soc_hdl,
  394. struct hal_reo_cmd_params *cmd)
  395. {
  396. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  397. uint32_t *reo_desc, val;
  398. struct reo_flush_timeout_list *reo_flush_timeout_list;
  399. hal_srng_access_start(hal_soc_hdl, hal_ring_hdl);
  400. reo_desc = hal_srng_src_get_next(hal_soc, hal_ring_hdl);
  401. if (!reo_desc) {
  402. hal_srng_access_end_reap(hal_soc, hal_ring_hdl);
  403. hal_warn_rl("Out of cmd ring entries");
  404. return -EBUSY;
  405. }
  406. HAL_SET_TLV_HDR(reo_desc, WIFIREO_FLUSH_TIMEOUT_LIST_E,
  407. sizeof(struct reo_flush_timeout_list));
  408. /*
  409. * Offsets of descriptor fields defined in HW headers start from
  410. * the field after TLV header
  411. */
  412. reo_desc += (sizeof(struct tlv_32_hdr) >> 2);
  413. qdf_mem_zero((reo_desc + NUM_OF_DWORDS_UNIFORM_REO_CMD_HEADER),
  414. sizeof(struct reo_flush_timeout_list) -
  415. (NUM_OF_DWORDS_UNIFORM_REO_CMD_HEADER << 2));
  416. reo_flush_timeout_list = (struct reo_flush_timeout_list *)reo_desc;
  417. reo_flush_timeout_list->cmd_header.reo_status_required =
  418. cmd->std.need_status;
  419. reo_flush_timeout_list->ac_timout_list =
  420. cmd->u.fl_tim_list_params.ac_list;
  421. reo_flush_timeout_list->minimum_release_desc_count =
  422. cmd->u.fl_tim_list_params.min_rel_desc;
  423. reo_flush_timeout_list->minimum_forward_buf_count =
  424. cmd->u.fl_tim_list_params.min_fwd_buf;
  425. hal_srng_access_end(hal_soc, hal_ring_hdl);
  426. val = reo_desc[CMD_HEADER_DW_OFFSET];
  427. return HAL_GET_FIELD(UNIFORM_REO_CMD_HEADER, REO_CMD_NUMBER,
  428. val);
  429. }
  430. static int
  431. hal_reo_cmd_update_rx_queue_be(hal_ring_handle_t hal_ring_hdl,
  432. hal_soc_handle_t hal_soc_hdl,
  433. struct hal_reo_cmd_params *cmd)
  434. {
  435. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  436. uint32_t *reo_desc, val;
  437. struct hal_reo_cmd_update_queue_params *p;
  438. struct reo_update_rx_reo_queue *reo_update_rx_reo_queue;
  439. p = &cmd->u.upd_queue_params;
  440. hal_srng_access_start(hal_soc_hdl, hal_ring_hdl);
  441. reo_desc = hal_srng_src_get_next(hal_soc, hal_ring_hdl);
  442. if (!reo_desc) {
  443. hal_srng_access_end_reap(hal_soc, hal_ring_hdl);
  444. hal_warn_rl("Out of cmd ring entries");
  445. return -EBUSY;
  446. }
  447. HAL_SET_TLV_HDR(reo_desc, WIFIREO_UPDATE_RX_REO_QUEUE_E,
  448. sizeof(struct reo_update_rx_reo_queue));
  449. /*
  450. * Offsets of descriptor fields defined in HW headers start from
  451. * the field after TLV header
  452. */
  453. reo_desc += (sizeof(struct tlv_32_hdr) >> 2);
  454. qdf_mem_zero((reo_desc + NUM_OF_DWORDS_UNIFORM_REO_CMD_HEADER),
  455. sizeof(struct reo_update_rx_reo_queue) -
  456. (NUM_OF_DWORDS_UNIFORM_REO_CMD_HEADER << 2));
  457. reo_update_rx_reo_queue = (struct reo_update_rx_reo_queue *)reo_desc;
  458. reo_update_rx_reo_queue->cmd_header.reo_status_required =
  459. cmd->std.need_status;
  460. hal_reo_cmd_set_descr_addr_be(reo_desc, CMD_UPDATE_RX_REO_QUEUE,
  461. cmd->std.addr_lo, cmd->std.addr_hi);
  462. reo_update_rx_reo_queue->update_receive_queue_number =
  463. p->update_rx_queue_num;
  464. reo_update_rx_reo_queue->update_vld = p->update_vld;
  465. reo_update_rx_reo_queue->update_associated_link_descriptor_counter =
  466. p->update_assoc_link_desc;
  467. reo_update_rx_reo_queue->update_disable_duplicate_detection =
  468. p->update_disable_dup_detect;
  469. reo_update_rx_reo_queue->update_soft_reorder_enable =
  470. p->update_soft_reorder_enab;
  471. reo_update_rx_reo_queue->update_ac = p->update_ac;
  472. reo_update_rx_reo_queue->update_bar = p->update_bar;
  473. reo_update_rx_reo_queue->update_rty = p->update_rty;
  474. reo_update_rx_reo_queue->update_chk_2k_mode = p->update_chk_2k_mode;
  475. reo_update_rx_reo_queue->update_oor_mode = p->update_oor_mode;
  476. reo_update_rx_reo_queue->update_ba_window_size =
  477. p->update_ba_window_size;
  478. reo_update_rx_reo_queue->update_pn_check_needed =
  479. p->update_pn_check_needed;
  480. reo_update_rx_reo_queue->update_pn_shall_be_even = p->update_pn_even;
  481. reo_update_rx_reo_queue->update_pn_shall_be_uneven =
  482. p->update_pn_uneven;
  483. reo_update_rx_reo_queue->update_pn_handling_enable =
  484. p->update_pn_hand_enab;
  485. reo_update_rx_reo_queue->update_pn_size = p->update_pn_size;
  486. reo_update_rx_reo_queue->update_ignore_ampdu_flag =
  487. p->update_ignore_ampdu;
  488. reo_update_rx_reo_queue->update_svld = p->update_svld;
  489. reo_update_rx_reo_queue->update_ssn = p->update_ssn;
  490. reo_update_rx_reo_queue->update_seq_2k_error_detected_flag =
  491. p->update_seq_2k_err_detect;
  492. reo_update_rx_reo_queue->update_pn_valid = p->update_pn_valid;
  493. reo_update_rx_reo_queue->update_pn = p->update_pn;
  494. reo_update_rx_reo_queue->receive_queue_number = p->rx_queue_num;
  495. reo_update_rx_reo_queue->vld = p->vld;
  496. reo_update_rx_reo_queue->associated_link_descriptor_counter =
  497. p->assoc_link_desc;
  498. reo_update_rx_reo_queue->disable_duplicate_detection =
  499. p->disable_dup_detect;
  500. reo_update_rx_reo_queue->soft_reorder_enable = p->soft_reorder_enab;
  501. reo_update_rx_reo_queue->ac = p->ac;
  502. reo_update_rx_reo_queue->bar = p->bar;
  503. reo_update_rx_reo_queue->chk_2k_mode = p->chk_2k_mode;
  504. reo_update_rx_reo_queue->rty = p->rty;
  505. reo_update_rx_reo_queue->oor_mode = p->oor_mode;
  506. reo_update_rx_reo_queue->pn_check_needed = p->pn_check_needed;
  507. reo_update_rx_reo_queue->pn_shall_be_even = p->pn_even;
  508. reo_update_rx_reo_queue->pn_shall_be_uneven = p->pn_uneven;
  509. reo_update_rx_reo_queue->pn_handling_enable = p->pn_hand_enab;
  510. reo_update_rx_reo_queue->ignore_ampdu_flag = p->ignore_ampdu;
  511. if (p->ba_window_size < 1)
  512. p->ba_window_size = 1;
  513. /*
  514. * WAR to get 2k exception in Non BA case.
  515. * Setting window size to 2 to get 2k jump exception
  516. * when we receive aggregates in Non BA case
  517. */
  518. if (p->ba_window_size == 1)
  519. p->ba_window_size++;
  520. reo_update_rx_reo_queue->ba_window_size = p->ba_window_size - 1;
  521. reo_update_rx_reo_queue->pn_size = p->pn_size;
  522. reo_update_rx_reo_queue->svld = p->svld;
  523. reo_update_rx_reo_queue->ssn = p->ssn;
  524. reo_update_rx_reo_queue->seq_2k_error_detected_flag =
  525. p->seq_2k_err_detect;
  526. reo_update_rx_reo_queue->pn_error_detected_flag = p->pn_err_detect;
  527. reo_update_rx_reo_queue->pn_31_0 = p->pn_31_0;
  528. reo_update_rx_reo_queue->pn_63_32 = p->pn_63_32;
  529. reo_update_rx_reo_queue->pn_95_64 = p->pn_95_64;
  530. reo_update_rx_reo_queue->pn_127_96 = p->pn_127_96;
  531. hal_srng_access_end_v1(hal_soc_hdl, hal_ring_hdl,
  532. HIF_RTPM_ID_HAL_REO_CMD);
  533. val = reo_desc[CMD_HEADER_DW_OFFSET];
  534. return HAL_GET_FIELD(UNIFORM_REO_CMD_HEADER, REO_CMD_NUMBER,
  535. val);
  536. }
  537. int hal_reo_send_cmd_be(hal_soc_handle_t hal_soc_hdl,
  538. hal_ring_handle_t hal_ring_hdl,
  539. enum hal_reo_cmd_type cmd,
  540. void *params)
  541. {
  542. struct hal_reo_cmd_params *cmd_params =
  543. (struct hal_reo_cmd_params *)params;
  544. int num = 0;
  545. switch (cmd) {
  546. case CMD_GET_QUEUE_STATS:
  547. num = hal_reo_cmd_queue_stats_be(hal_ring_hdl,
  548. hal_soc_hdl, cmd_params);
  549. break;
  550. case CMD_FLUSH_QUEUE:
  551. num = hal_reo_cmd_flush_queue_be(hal_ring_hdl,
  552. hal_soc_hdl, cmd_params);
  553. break;
  554. case CMD_FLUSH_CACHE:
  555. num = hal_reo_cmd_flush_cache_be(hal_ring_hdl,
  556. hal_soc_hdl, cmd_params);
  557. break;
  558. case CMD_UNBLOCK_CACHE:
  559. num = hal_reo_cmd_unblock_cache_be(hal_ring_hdl,
  560. hal_soc_hdl, cmd_params);
  561. break;
  562. case CMD_FLUSH_TIMEOUT_LIST:
  563. num = hal_reo_cmd_flush_timeout_list_be(hal_ring_hdl,
  564. hal_soc_hdl,
  565. cmd_params);
  566. break;
  567. case CMD_UPDATE_RX_REO_QUEUE:
  568. num = hal_reo_cmd_update_rx_queue_be(hal_ring_hdl,
  569. hal_soc_hdl, cmd_params);
  570. break;
  571. default:
  572. hal_err("Invalid REO command type: %d", cmd);
  573. return -EINVAL;
  574. };
  575. return num;
  576. }
  577. void
  578. hal_reo_queue_stats_status_be(hal_ring_desc_t ring_desc,
  579. void *st_handle,
  580. hal_soc_handle_t hal_soc_hdl)
  581. {
  582. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  583. struct hal_reo_queue_status *st =
  584. (struct hal_reo_queue_status *)st_handle;
  585. uint64_t *reo_desc = (uint64_t *)ring_desc;
  586. uint64_t val;
  587. /*
  588. * Offsets of descriptor fields defined in HW headers start
  589. * from the field after TLV header
  590. */
  591. reo_desc += HAL_GET_NUM_QWORDS(sizeof(struct tlv_32_hdr));
  592. /* header */
  593. hal_reo_status_get_header(ring_desc, HAL_REO_QUEUE_STATS_STATUS_TLV,
  594. &(st->header), hal_soc);
  595. /* SSN */
  596. val = reo_desc[HAL_OFFSET_QW(REO_GET_QUEUE_STATS_STATUS, SSN)];
  597. st->ssn = HAL_GET_FIELD(REO_GET_QUEUE_STATS_STATUS, SSN, val);
  598. /* current index */
  599. val = reo_desc[HAL_OFFSET_QW(REO_GET_QUEUE_STATS_STATUS,
  600. CURRENT_INDEX)];
  601. st->curr_idx =
  602. HAL_GET_FIELD(REO_GET_QUEUE_STATS_STATUS,
  603. CURRENT_INDEX, val);
  604. /* PN bits */
  605. val = reo_desc[HAL_OFFSET_QW(REO_GET_QUEUE_STATS_STATUS,
  606. PN_31_0)];
  607. st->pn_31_0 =
  608. HAL_GET_FIELD(REO_GET_QUEUE_STATS_STATUS,
  609. PN_31_0, val);
  610. val = reo_desc[HAL_OFFSET_QW(REO_GET_QUEUE_STATS_STATUS,
  611. PN_63_32)];
  612. st->pn_63_32 =
  613. HAL_GET_FIELD(REO_GET_QUEUE_STATS_STATUS,
  614. PN_63_32, val);
  615. val = reo_desc[HAL_OFFSET_QW(REO_GET_QUEUE_STATS_STATUS,
  616. PN_95_64)];
  617. st->pn_95_64 =
  618. HAL_GET_FIELD(REO_GET_QUEUE_STATS_STATUS,
  619. PN_95_64, val);
  620. val = reo_desc[HAL_OFFSET_QW(REO_GET_QUEUE_STATS_STATUS,
  621. PN_127_96)];
  622. st->pn_127_96 =
  623. HAL_GET_FIELD(REO_GET_QUEUE_STATS_STATUS,
  624. PN_127_96, val);
  625. /* timestamps */
  626. val = reo_desc[HAL_OFFSET_QW(REO_GET_QUEUE_STATS_STATUS,
  627. LAST_RX_ENQUEUE_TIMESTAMP)];
  628. st->last_rx_enq_tstamp =
  629. HAL_GET_FIELD(REO_GET_QUEUE_STATS_STATUS,
  630. LAST_RX_ENQUEUE_TIMESTAMP, val);
  631. val = reo_desc[HAL_OFFSET_QW(REO_GET_QUEUE_STATS_STATUS,
  632. LAST_RX_DEQUEUE_TIMESTAMP)];
  633. st->last_rx_deq_tstamp =
  634. HAL_GET_FIELD(REO_GET_QUEUE_STATS_STATUS,
  635. LAST_RX_DEQUEUE_TIMESTAMP, val);
  636. /* rx bitmap */
  637. val = reo_desc[HAL_OFFSET_QW(REO_GET_QUEUE_STATS_STATUS,
  638. RX_BITMAP_31_0)];
  639. st->rx_bitmap_31_0 =
  640. HAL_GET_FIELD(REO_GET_QUEUE_STATS_STATUS,
  641. RX_BITMAP_31_0, val);
  642. val = reo_desc[HAL_OFFSET_QW(REO_GET_QUEUE_STATS_STATUS,
  643. RX_BITMAP_63_32)];
  644. st->rx_bitmap_63_32 =
  645. HAL_GET_FIELD(REO_GET_QUEUE_STATS_STATUS,
  646. RX_BITMAP_63_32, val);
  647. val = reo_desc[HAL_OFFSET_QW(REO_GET_QUEUE_STATS_STATUS,
  648. RX_BITMAP_95_64)];
  649. st->rx_bitmap_95_64 =
  650. HAL_GET_FIELD(REO_GET_QUEUE_STATS_STATUS,
  651. RX_BITMAP_95_64, val);
  652. val = reo_desc[HAL_OFFSET_QW(REO_GET_QUEUE_STATS_STATUS,
  653. RX_BITMAP_127_96)];
  654. st->rx_bitmap_127_96 =
  655. HAL_GET_FIELD(REO_GET_QUEUE_STATS_STATUS,
  656. RX_BITMAP_127_96, val);
  657. val = reo_desc[HAL_OFFSET_QW(REO_GET_QUEUE_STATS_STATUS,
  658. RX_BITMAP_159_128)];
  659. st->rx_bitmap_159_128 =
  660. HAL_GET_FIELD(REO_GET_QUEUE_STATS_STATUS,
  661. RX_BITMAP_159_128, val);
  662. val = reo_desc[HAL_OFFSET_QW(REO_GET_QUEUE_STATS_STATUS,
  663. RX_BITMAP_191_160)];
  664. st->rx_bitmap_191_160 =
  665. HAL_GET_FIELD(REO_GET_QUEUE_STATS_STATUS,
  666. RX_BITMAP_191_160, val);
  667. val = reo_desc[HAL_OFFSET_QW(REO_GET_QUEUE_STATS_STATUS,
  668. RX_BITMAP_223_192)];
  669. st->rx_bitmap_223_192 =
  670. HAL_GET_FIELD(REO_GET_QUEUE_STATS_STATUS,
  671. RX_BITMAP_223_192, val);
  672. val = reo_desc[HAL_OFFSET_QW(REO_GET_QUEUE_STATS_STATUS,
  673. RX_BITMAP_255_224)];
  674. st->rx_bitmap_255_224 =
  675. HAL_GET_FIELD(REO_GET_QUEUE_STATS_STATUS,
  676. RX_BITMAP_255_224, val);
  677. /* various counts */
  678. val = reo_desc[HAL_OFFSET_QW(REO_GET_QUEUE_STATS_STATUS,
  679. CURRENT_MPDU_COUNT)];
  680. st->curr_mpdu_cnt =
  681. HAL_GET_FIELD(REO_GET_QUEUE_STATS_STATUS,
  682. CURRENT_MPDU_COUNT, val);
  683. val = reo_desc[HAL_OFFSET_QW(REO_GET_QUEUE_STATS_STATUS,
  684. CURRENT_MSDU_COUNT)];
  685. st->curr_msdu_cnt =
  686. HAL_GET_FIELD(REO_GET_QUEUE_STATS_STATUS,
  687. CURRENT_MSDU_COUNT, val);
  688. val = reo_desc[HAL_OFFSET_QW(REO_GET_QUEUE_STATS_STATUS,
  689. TIMEOUT_COUNT)];
  690. st->fwd_timeout_cnt =
  691. HAL_GET_FIELD(REO_GET_QUEUE_STATS_STATUS,
  692. TIMEOUT_COUNT, val);
  693. val = reo_desc[HAL_OFFSET_QW(REO_GET_QUEUE_STATS_STATUS,
  694. FORWARD_DUE_TO_BAR_COUNT)];
  695. st->fwd_bar_cnt =
  696. HAL_GET_FIELD(REO_GET_QUEUE_STATS_STATUS,
  697. FORWARD_DUE_TO_BAR_COUNT, val);
  698. val = reo_desc[HAL_OFFSET_QW(REO_GET_QUEUE_STATS_STATUS,
  699. DUPLICATE_COUNT)];
  700. st->dup_cnt =
  701. HAL_GET_FIELD(REO_GET_QUEUE_STATS_STATUS,
  702. DUPLICATE_COUNT, val);
  703. val = reo_desc[HAL_OFFSET_QW(REO_GET_QUEUE_STATS_STATUS,
  704. FRAMES_IN_ORDER_COUNT)];
  705. st->frms_in_order_cnt =
  706. HAL_GET_FIELD(REO_GET_QUEUE_STATS_STATUS,
  707. FRAMES_IN_ORDER_COUNT, val);
  708. val = reo_desc[HAL_OFFSET_QW(REO_GET_QUEUE_STATS_STATUS,
  709. BAR_RECEIVED_COUNT)];
  710. st->bar_rcvd_cnt =
  711. HAL_GET_FIELD(REO_GET_QUEUE_STATS_STATUS,
  712. BAR_RECEIVED_COUNT, val);
  713. val = reo_desc[HAL_OFFSET_QW(REO_GET_QUEUE_STATS_STATUS,
  714. MPDU_FRAMES_PROCESSED_COUNT)];
  715. st->mpdu_frms_cnt =
  716. HAL_GET_FIELD(REO_GET_QUEUE_STATS_STATUS,
  717. MPDU_FRAMES_PROCESSED_COUNT, val);
  718. val = reo_desc[HAL_OFFSET_QW(REO_GET_QUEUE_STATS_STATUS,
  719. MSDU_FRAMES_PROCESSED_COUNT)];
  720. st->msdu_frms_cnt =
  721. HAL_GET_FIELD(REO_GET_QUEUE_STATS_STATUS,
  722. MSDU_FRAMES_PROCESSED_COUNT, val);
  723. val = reo_desc[HAL_OFFSET_QW(REO_GET_QUEUE_STATS_STATUS,
  724. TOTAL_PROCESSED_BYTE_COUNT)];
  725. st->total_cnt =
  726. HAL_GET_FIELD(REO_GET_QUEUE_STATS_STATUS,
  727. TOTAL_PROCESSED_BYTE_COUNT, val);
  728. val = reo_desc[HAL_OFFSET_QW(REO_GET_QUEUE_STATS_STATUS,
  729. LATE_RECEIVE_MPDU_COUNT)];
  730. st->late_recv_mpdu_cnt =
  731. HAL_GET_FIELD(REO_GET_QUEUE_STATS_STATUS,
  732. LATE_RECEIVE_MPDU_COUNT, val);
  733. val = reo_desc[HAL_OFFSET_QW(REO_GET_QUEUE_STATS_STATUS,
  734. WINDOW_JUMP_2K)];
  735. st->win_jump_2k =
  736. HAL_GET_FIELD(REO_GET_QUEUE_STATS_STATUS,
  737. WINDOW_JUMP_2K, val);
  738. val = reo_desc[HAL_OFFSET_QW(REO_GET_QUEUE_STATS_STATUS,
  739. HOLE_COUNT)];
  740. st->hole_cnt =
  741. HAL_GET_FIELD(REO_GET_QUEUE_STATS_STATUS,
  742. HOLE_COUNT, val);
  743. }
  744. void
  745. hal_reo_flush_queue_status_be(hal_ring_desc_t ring_desc,
  746. void *st_handle,
  747. hal_soc_handle_t hal_soc_hdl)
  748. {
  749. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  750. struct hal_reo_flush_queue_status *st =
  751. (struct hal_reo_flush_queue_status *)st_handle;
  752. uint64_t *reo_desc = (uint64_t *)ring_desc;
  753. uint64_t val;
  754. /*
  755. * Offsets of descriptor fields defined in HW headers start
  756. * from the field after TLV header
  757. */
  758. reo_desc += HAL_GET_NUM_QWORDS(sizeof(struct tlv_32_hdr));
  759. /* header */
  760. hal_reo_status_get_header(ring_desc, HAL_REO_FLUSH_QUEUE_STATUS_TLV,
  761. &(st->header), hal_soc);
  762. /* error bit */
  763. val = reo_desc[HAL_OFFSET(REO_FLUSH_QUEUE_STATUS,
  764. ERROR_DETECTED)];
  765. st->error = HAL_GET_FIELD(REO_FLUSH_QUEUE_STATUS, ERROR_DETECTED,
  766. val);
  767. }
  768. void
  769. hal_reo_flush_cache_status_be(hal_ring_desc_t ring_desc,
  770. void *st_handle,
  771. hal_soc_handle_t hal_soc_hdl)
  772. {
  773. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  774. struct hal_reo_flush_cache_status *st =
  775. (struct hal_reo_flush_cache_status *)st_handle;
  776. uint64_t *reo_desc = (uint64_t *)ring_desc;
  777. uint64_t val;
  778. /*
  779. * Offsets of descriptor fields defined in HW headers start
  780. * from the field after TLV header
  781. */
  782. reo_desc += HAL_GET_NUM_QWORDS(sizeof(struct tlv_32_hdr));
  783. /* header */
  784. hal_reo_status_get_header(ring_desc, HAL_REO_FLUSH_CACHE_STATUS_TLV,
  785. &(st->header), hal_soc);
  786. /* error bit */
  787. val = reo_desc[HAL_OFFSET_QW(REO_FLUSH_CACHE_STATUS,
  788. ERROR_DETECTED)];
  789. st->error = HAL_GET_FIELD(REO_FLUSH_QUEUE_STATUS, ERROR_DETECTED,
  790. val);
  791. /* block error */
  792. val = reo_desc[HAL_OFFSET_QW(REO_FLUSH_CACHE_STATUS,
  793. BLOCK_ERROR_DETAILS)];
  794. st->block_error = HAL_GET_FIELD(REO_FLUSH_CACHE_STATUS,
  795. BLOCK_ERROR_DETAILS,
  796. val);
  797. if (!st->block_error)
  798. qdf_set_bit(hal_soc->index,
  799. (unsigned long *)&hal_soc->reo_res_bitmap);
  800. /* cache flush status */
  801. val = reo_desc[HAL_OFFSET_QW(REO_FLUSH_CACHE_STATUS,
  802. CACHE_CONTROLLER_FLUSH_STATUS_HIT)];
  803. st->cache_flush_status = HAL_GET_FIELD(REO_FLUSH_CACHE_STATUS,
  804. CACHE_CONTROLLER_FLUSH_STATUS_HIT,
  805. val);
  806. /* cache flush descriptor type */
  807. val = reo_desc[HAL_OFFSET_QW(REO_FLUSH_CACHE_STATUS,
  808. CACHE_CONTROLLER_FLUSH_STATUS_DESC_TYPE)];
  809. st->cache_flush_status_desc_type =
  810. HAL_GET_FIELD(REO_FLUSH_CACHE_STATUS,
  811. CACHE_CONTROLLER_FLUSH_STATUS_DESC_TYPE,
  812. val);
  813. /* cache flush count */
  814. val = reo_desc[HAL_OFFSET_QW(REO_FLUSH_CACHE_STATUS,
  815. CACHE_CONTROLLER_FLUSH_COUNT)];
  816. st->cache_flush_cnt =
  817. HAL_GET_FIELD(REO_FLUSH_CACHE_STATUS,
  818. CACHE_CONTROLLER_FLUSH_COUNT,
  819. val);
  820. }
  821. void
  822. hal_reo_unblock_cache_status_be(hal_ring_desc_t ring_desc,
  823. hal_soc_handle_t hal_soc_hdl,
  824. void *st_handle)
  825. {
  826. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  827. struct hal_reo_unblk_cache_status *st =
  828. (struct hal_reo_unblk_cache_status *)st_handle;
  829. uint64_t *reo_desc = (uint64_t *)ring_desc;
  830. uint64_t val;
  831. /*
  832. * Offsets of descriptor fields defined in HW headers start
  833. * from the field after TLV header
  834. */
  835. reo_desc += HAL_GET_NUM_QWORDS(sizeof(struct tlv_32_hdr));
  836. /* header */
  837. hal_reo_status_get_header(ring_desc, HAL_REO_UNBLK_CACHE_STATUS_TLV,
  838. &st->header, hal_soc);
  839. /* error bit */
  840. val = reo_desc[HAL_OFFSET_QW(REO_UNBLOCK_CACHE_STATUS,
  841. ERROR_DETECTED)];
  842. st->error = HAL_GET_FIELD(REO_UNBLOCK_CACHE_STATUS,
  843. ERROR_DETECTED,
  844. val);
  845. /* unblock type */
  846. val = reo_desc[HAL_OFFSET_QW(REO_UNBLOCK_CACHE_STATUS,
  847. UNBLOCK_TYPE)];
  848. st->unblock_type = HAL_GET_FIELD(REO_UNBLOCK_CACHE_STATUS,
  849. UNBLOCK_TYPE,
  850. val);
  851. if (!st->error && (st->unblock_type == UNBLOCK_RES_INDEX))
  852. qdf_clear_bit(hal_soc->index,
  853. (unsigned long *)&hal_soc->reo_res_bitmap);
  854. }
  855. void hal_reo_flush_timeout_list_status_be(hal_ring_desc_t ring_desc,
  856. void *st_handle,
  857. hal_soc_handle_t hal_soc_hdl)
  858. {
  859. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  860. struct hal_reo_flush_timeout_list_status *st =
  861. (struct hal_reo_flush_timeout_list_status *)st_handle;
  862. uint64_t *reo_desc = (uint64_t *)ring_desc;
  863. uint64_t val;
  864. /*
  865. * Offsets of descriptor fields defined in HW headers start
  866. * from the field after TLV header
  867. */
  868. reo_desc += HAL_GET_NUM_QWORDS(sizeof(struct tlv_32_hdr));
  869. /* header */
  870. hal_reo_status_get_header(ring_desc, HAL_REO_TIMOUT_LIST_STATUS_TLV,
  871. &(st->header), hal_soc);
  872. /* error bit */
  873. val = reo_desc[HAL_OFFSET_QW(REO_FLUSH_TIMEOUT_LIST_STATUS,
  874. ERROR_DETECTED)];
  875. st->error = HAL_GET_FIELD(REO_FLUSH_TIMEOUT_LIST_STATUS,
  876. ERROR_DETECTED,
  877. val);
  878. /* list empty */
  879. val = reo_desc[HAL_OFFSET_QW(REO_FLUSH_TIMEOUT_LIST_STATUS,
  880. TIMOUT_LIST_EMPTY)];
  881. st->list_empty = HAL_GET_FIELD(REO_FLUSH_TIMEOUT_LIST_STATUS,
  882. TIMOUT_LIST_EMPTY,
  883. val);
  884. /* release descriptor count */
  885. val = reo_desc[HAL_OFFSET_QW(REO_FLUSH_TIMEOUT_LIST_STATUS,
  886. RELEASE_DESC_COUNT)];
  887. st->rel_desc_cnt = HAL_GET_FIELD(REO_FLUSH_TIMEOUT_LIST_STATUS,
  888. RELEASE_DESC_COUNT,
  889. val);
  890. /* forward buf count */
  891. val = reo_desc[HAL_OFFSET_QW(REO_FLUSH_TIMEOUT_LIST_STATUS,
  892. FORWARD_BUF_COUNT)];
  893. st->fwd_buf_cnt = HAL_GET_FIELD(REO_FLUSH_TIMEOUT_LIST_STATUS,
  894. FORWARD_BUF_COUNT,
  895. val);
  896. }
  897. void hal_reo_desc_thres_reached_status_be(hal_ring_desc_t ring_desc,
  898. void *st_handle,
  899. hal_soc_handle_t hal_soc_hdl)
  900. {
  901. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  902. struct hal_reo_desc_thres_reached_status *st =
  903. (struct hal_reo_desc_thres_reached_status *)st_handle;
  904. uint64_t *reo_desc = (uint64_t *)ring_desc;
  905. uint64_t val;
  906. /*
  907. * Offsets of descriptor fields defined in HW headers start
  908. * from the field after TLV header
  909. */
  910. reo_desc += HAL_GET_NUM_QWORDS(sizeof(struct tlv_32_hdr));
  911. /* header */
  912. hal_reo_status_get_header(ring_desc,
  913. HAL_REO_DESC_THRES_STATUS_TLV,
  914. &(st->header), hal_soc);
  915. /* threshold index */
  916. val = reo_desc[HAL_OFFSET_QW(
  917. REO_DESCRIPTOR_THRESHOLD_REACHED_STATUS,
  918. THRESHOLD_INDEX)];
  919. st->thres_index = HAL_GET_FIELD(
  920. REO_DESCRIPTOR_THRESHOLD_REACHED_STATUS,
  921. THRESHOLD_INDEX,
  922. val);
  923. /* link desc counters */
  924. val = reo_desc[HAL_OFFSET_QW(
  925. REO_DESCRIPTOR_THRESHOLD_REACHED_STATUS,
  926. LINK_DESCRIPTOR_COUNTER0)];
  927. st->link_desc_counter0 = HAL_GET_FIELD(
  928. REO_DESCRIPTOR_THRESHOLD_REACHED_STATUS,
  929. LINK_DESCRIPTOR_COUNTER0,
  930. val);
  931. val = reo_desc[HAL_OFFSET_QW(
  932. REO_DESCRIPTOR_THRESHOLD_REACHED_STATUS,
  933. LINK_DESCRIPTOR_COUNTER1)];
  934. st->link_desc_counter1 = HAL_GET_FIELD(
  935. REO_DESCRIPTOR_THRESHOLD_REACHED_STATUS,
  936. LINK_DESCRIPTOR_COUNTER1,
  937. val);
  938. val = reo_desc[HAL_OFFSET_QW(
  939. REO_DESCRIPTOR_THRESHOLD_REACHED_STATUS,
  940. LINK_DESCRIPTOR_COUNTER2)];
  941. st->link_desc_counter2 = HAL_GET_FIELD(
  942. REO_DESCRIPTOR_THRESHOLD_REACHED_STATUS,
  943. LINK_DESCRIPTOR_COUNTER2,
  944. val);
  945. val = reo_desc[HAL_OFFSET_QW(
  946. REO_DESCRIPTOR_THRESHOLD_REACHED_STATUS,
  947. LINK_DESCRIPTOR_COUNTER_SUM)];
  948. st->link_desc_counter_sum = HAL_GET_FIELD(
  949. REO_DESCRIPTOR_THRESHOLD_REACHED_STATUS,
  950. LINK_DESCRIPTOR_COUNTER_SUM,
  951. val);
  952. }
  953. void
  954. hal_reo_rx_update_queue_status_be(hal_ring_desc_t ring_desc,
  955. void *st_handle,
  956. hal_soc_handle_t hal_soc_hdl)
  957. {
  958. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  959. struct hal_reo_update_rx_queue_status *st =
  960. (struct hal_reo_update_rx_queue_status *)st_handle;
  961. uint64_t *reo_desc = (uint64_t *)ring_desc;
  962. /*
  963. * Offsets of descriptor fields defined in HW headers start
  964. * from the field after TLV header
  965. */
  966. reo_desc += HAL_GET_NUM_QWORDS(sizeof(struct tlv_32_hdr));
  967. /* header */
  968. hal_reo_status_get_header(ring_desc,
  969. HAL_REO_UPDATE_RX_QUEUE_STATUS_TLV,
  970. &(st->header), hal_soc);
  971. }
  972. uint8_t hal_get_tlv_hdr_size_be(void)
  973. {
  974. return sizeof(struct tlv_32_hdr);
  975. }