hal_reo.h 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718
  1. /*
  2. * Copyright (c) 2017-2019, 2021 The Linux Foundation. All rights reserved.
  3. *
  4. * Permission to use, copy, modify, and/or distribute this software for
  5. * any purpose with or without fee is hereby granted, provided that the
  6. * above copyright notice and this permission notice appear in all
  7. * copies.
  8. *
  9. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
  10. * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
  11. * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
  12. * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
  13. * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
  14. * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  15. * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  16. * PERFORMANCE OF THIS SOFTWARE.
  17. */
  18. #ifndef _HAL_REO_H_
  19. #define _HAL_REO_H_
  20. #include <qdf_types.h>
  21. /* HW headers */
  22. #include <reo_descriptor_threshold_reached_status.h>
  23. #include <reo_flush_queue.h>
  24. #include <reo_flush_timeout_list_status.h>
  25. #include <reo_unblock_cache.h>
  26. #include <reo_flush_cache.h>
  27. #include <reo_flush_queue_status.h>
  28. #include <reo_get_queue_stats.h>
  29. #include <reo_unblock_cache_status.h>
  30. #include <reo_flush_cache_status.h>
  31. #include <reo_flush_timeout_list.h>
  32. #include <reo_get_queue_stats_status.h>
  33. #include <reo_update_rx_reo_queue.h>
  34. #include <reo_update_rx_reo_queue_status.h>
  35. #include <tlv_tag_def.h>
  36. /* SW headers */
  37. #include "hal_api.h"
  38. #include "hal_rx_hw_defines.h"
  39. /*---------------------------------------------------------------------------
  40. Preprocessor definitions and constants
  41. ---------------------------------------------------------------------------*/
  42. /* TLV values */
  43. #define HAL_REO_GET_QUEUE_STATS_TLV WIFIREO_GET_QUEUE_STATS_E
  44. #define HAL_REO_FLUSH_QUEUE_TLV WIFIREO_FLUSH_QUEUE_E
  45. #define HAL_REO_FLUSH_CACHE_TLV WIFIREO_FLUSH_CACHE_E
  46. #define HAL_REO_UNBLOCK_CACHE_TLV WIFIREO_UNBLOCK_CACHE_E
  47. #define HAL_REO_FLUSH_TIMEOUT_LIST_TLV WIFIREO_FLUSH_TIMEOUT_LIST_E
  48. #define HAL_REO_RX_UPDATE_QUEUE_TLV WIFIREO_UPDATE_RX_REO_QUEUE_E
  49. #define HAL_REO_QUEUE_STATS_STATUS_TLV WIFIREO_GET_QUEUE_STATS_STATUS_E
  50. #define HAL_REO_FLUSH_QUEUE_STATUS_TLV WIFIREO_FLUSH_QUEUE_STATUS_E
  51. #define HAL_REO_FLUSH_CACHE_STATUS_TLV WIFIREO_FLUSH_CACHE_STATUS_E
  52. #define HAL_REO_UNBLK_CACHE_STATUS_TLV WIFIREO_UNBLOCK_CACHE_STATUS_E
  53. #define HAL_REO_TIMOUT_LIST_STATUS_TLV WIFIREO_FLUSH_TIMEOUT_LIST_STATUS_E
  54. #define HAL_REO_DESC_THRES_STATUS_TLV \
  55. WIFIREO_DESCRIPTOR_THRESHOLD_REACHED_STATUS_E
  56. #define HAL_REO_UPDATE_RX_QUEUE_STATUS_TLV WIFIREO_UPDATE_RX_REO_QUEUE_STATUS_E
  57. #define HAL_SET_FIELD(block, field, value) \
  58. ((value << (block ## _ ## field ## _LSB)) & \
  59. (block ## _ ## field ## _MASK))
  60. #define HAL_GET_FIELD(block, field, value) \
  61. ((value & (block ## _ ## field ## _MASK)) >> \
  62. (block ## _ ## field ## _LSB))
  63. #define HAL_SET_TLV_HDR(desc, tag, len) \
  64. do { \
  65. ((struct tlv_32_hdr *) desc)->tlv_tag = tag; \
  66. ((struct tlv_32_hdr *) desc)->tlv_len = len; \
  67. } while (0)
  68. #define HAL_GET_TLV(desc) (((struct tlv_32_hdr *) desc)->tlv_tag)
  69. #define HAL_OFFSET_DW(_block, _field) (HAL_OFFSET(_block, _field) >> 2)
  70. #define HAL_OFFSET_QW(_block, _field) (HAL_OFFSET(_block, _field) >> 3)
  71. /* dword offsets in REO cmd TLV */
  72. #define CMD_HEADER_DW_OFFSET 0
  73. /* TODO: See if the following definition is available in HW headers */
  74. #define HAL_REO_OWNED 4
  75. #define HAL_REO_QUEUE_DESC 8
  76. /* TODO: Using associated link desc counter 1 for Rx. Check with FW on
  77. * how these counters are assigned
  78. */
  79. #define HAL_RX_LINK_DESC_CNTR 1
  80. /* TODO: Following definition should be from HW headers */
  81. #define HAL_DESC_REO_OWNED 4
  82. #ifndef TID_TO_WME_AC
  83. /**
  84. * enum hal_wme_access_category: Access category enums
  85. * @WME_AC_BE: best effort
  86. * @WME_AC_BK: background
  87. * @WME_AC_VI: video
  88. * @WME_AC_VO: voice
  89. */
  90. enum hal_wme_access_category {
  91. WME_AC_BE,
  92. WME_AC_BK,
  93. WME_AC_VI,
  94. WME_AC_VO
  95. };
  96. #define TID_TO_WME_AC(_tid) ( \
  97. (((_tid) == 0) || ((_tid) == 3)) ? WME_AC_BE : \
  98. (((_tid) == 1) || ((_tid) == 2)) ? WME_AC_BK : \
  99. (((_tid) == 4) || ((_tid) == 5)) ? WME_AC_VI : \
  100. WME_AC_VO)
  101. #endif
  102. #define HAL_NON_QOS_TID 16
  103. /**
  104. * enum reo_unblock_cache_type: Enum for unblock type in REO unblock command
  105. * @UNBLOCK_RES_INDEX: Unblock a block resource
  106. * @UNBLOCK_CACHE: Unblock cache
  107. */
  108. enum reo_unblock_cache_type {
  109. UNBLOCK_RES_INDEX = 0,
  110. UNBLOCK_CACHE = 1
  111. };
  112. /**
  113. * enum reo_thres_index_reg: Enum for reo descriptor usage counter for
  114. * which threshold status is being indicated.
  115. * @reo_desc_counter0_threshold: counter0 reached threshold
  116. * @reo_desc_counter1_threshold: counter1 reached threshold
  117. * @reo_desc_counter2_threshold: counter2 reached threshold
  118. * @reo_desc_counter_sum_threshold: Total count reached threshold
  119. */
  120. enum reo_thres_index_reg {
  121. reo_desc_counter0_threshold = 0,
  122. reo_desc_counter1_threshold = 1,
  123. reo_desc_counter2_threshold = 2,
  124. reo_desc_counter_sum_threshold = 3
  125. };
  126. /**
  127. * enum reo_cmd_exec_status: Enum for execution status of REO command
  128. *
  129. * @HAL_REO_CMD_SUCCESS: Command has successfully be executed
  130. * @HAL_REO_CMD_BLOCKED: Command could not be executed as the queue or cache
  131. * was blocked
  132. * @HAL_REO_CMD_FAILED: Command has encountered problems when executing, like
  133. * the queue descriptor not being valid
  134. */
  135. enum reo_cmd_exec_status {
  136. HAL_REO_CMD_SUCCESS = 0,
  137. HAL_REO_CMD_BLOCKED = 1,
  138. HAL_REO_CMD_FAILED = 2,
  139. HAL_REO_CMD_RESOURCE_BLOCKED = 3,
  140. HAL_REO_CMD_DRAIN = 0xff
  141. };
  142. /**
  143. * struct hal_reo_cmd_params_std: Standard REO command parameters
  144. * @need_status: Status required for the command
  145. * @addr_lo: Lower 32 bits of REO queue descriptor address
  146. * @addr_hi: Upper 8 bits of REO queue descriptor address
  147. */
  148. struct hal_reo_cmd_params_std {
  149. bool need_status;
  150. uint32_t addr_lo;
  151. uint8_t addr_hi;
  152. };
  153. /**
  154. * struct hal_reo_cmd_get_queue_stats_params: Parameters to
  155. * CMD_GET_QUEUE_STATScommand
  156. * @clear: Clear stats after retreiving
  157. */
  158. struct hal_reo_cmd_get_queue_stats_params {
  159. bool clear;
  160. };
  161. /**
  162. * struct hal_reo_cmd_flush_queue_params: Parameters to CMD_FLUSH_QUEUE
  163. * @use_after_flush: Block usage after flush till unblock command
  164. * @index: Blocking resource to be used
  165. */
  166. struct hal_reo_cmd_flush_queue_params {
  167. bool block_use_after_flush;
  168. uint8_t index;
  169. };
  170. /**
  171. * struct hal_reo_cmd_flush_cache_params: Parameters to CMD_FLUSH_CACHE
  172. * @fwd_mpdus_in_queue: Forward MPDUs before flushing descriptor
  173. * @rel_block_index: Release blocking resource used earlier
  174. * @cache_block_res_index: Blocking resource to be used
  175. * @flush_no_inval: Flush without invalidatig descriptor
  176. * @use_after_flush: Block usage after flush till unblock command
  177. * @flush_entire_cache: Flush entire REO cache
  178. */
  179. struct hal_reo_cmd_flush_cache_params {
  180. bool fwd_mpdus_in_queue;
  181. bool rel_block_index;
  182. uint8_t cache_block_res_index;
  183. bool flush_no_inval;
  184. bool block_use_after_flush;
  185. bool flush_entire_cache;
  186. };
  187. /**
  188. * struct hal_reo_cmd_unblock_cache_params: Parameters to CMD_UNBLOCK_CACHE
  189. * @type: Unblock type (enum reo_unblock_cache_type)
  190. * @index: Blocking index to be released
  191. */
  192. struct hal_reo_cmd_unblock_cache_params {
  193. enum reo_unblock_cache_type type;
  194. uint8_t index;
  195. };
  196. /**
  197. * struct hal_reo_cmd_flush_timeout_list_params: Parameters to
  198. * CMD_FLUSH_TIMEOUT_LIST
  199. * @ac_list: AC timeout list to be flushed
  200. * @min_rel_desc: Min. number of link descriptors to be release
  201. * @min_fwd_buf: Min. number of buffers to be forwarded
  202. */
  203. struct hal_reo_cmd_flush_timeout_list_params {
  204. uint8_t ac_list;
  205. uint16_t min_rel_desc;
  206. uint16_t min_fwd_buf;
  207. };
  208. /**
  209. * struct hal_reo_cmd_update_queue_params: Parameters to CMD_UPDATE_RX_REO_QUEUE
  210. * @update_rx_queue_num: Update receive queue number
  211. * @update_vld: Update valid bit
  212. * @update_assoc_link_desc: Update associated link descriptor
  213. * @update_disable_dup_detect: Update duplicate detection
  214. * @update_soft_reorder_enab: Update soft reorder enable
  215. * @update_ac: Update access category
  216. * @update_bar: Update BAR received bit
  217. * @update_rty: Update retry bit
  218. * @update_chk_2k_mode: Update chk_2k_mode setting
  219. * @update_oor_mode: Update OOR mode setting
  220. * @update_ba_window_size: Update BA window size
  221. * @update_pn_check_needed: Update pn_check_needed
  222. * @update_pn_even: Update pn_even
  223. * @update_pn_uneven: Update pn_uneven
  224. * @update_pn_hand_enab: Update pn_handling_enable
  225. * @update_pn_size: Update pn_size
  226. * @update_ignore_ampdu: Update ignore_ampdu
  227. * @update_svld: update svld
  228. * @update_ssn: Update SSN
  229. * @update_seq_2k_err_detect: Update seq_2k_err_detected flag
  230. * @update_pn_err_detect: Update pn_err_detected flag
  231. * @update_pn_valid: Update pn_valid
  232. * @update_pn: Update PN
  233. * @rx_queue_num: rx_queue_num to be updated
  234. * @vld: valid bit to be updated
  235. * @assoc_link_desc: assoc_link_desc counter
  236. * @disable_dup_detect: disable_dup_detect to be updated
  237. * @soft_reorder_enab: soft_reorder_enab to be updated
  238. * @ac: AC to be updated
  239. * @bar: BAR flag to be updated
  240. * @rty: RTY flag to be updated
  241. * @chk_2k_mode: check_2k_mode setting to be updated
  242. * @oor_mode: oor_mode to be updated
  243. * @pn_check_needed: pn_check_needed to be updated
  244. * @pn_even: pn_even to be updated
  245. * @pn_uneven: pn_uneven to be updated
  246. * @pn_hand_enab: pn_handling_enable to be updated
  247. * @ignore_ampdu: ignore_ampdu to be updated
  248. * @ba_window_size: BA window size to be updated
  249. * @pn_size: pn_size to be updated
  250. * @svld: svld flag to be updated
  251. * @ssn: SSN to be updated
  252. * @seq_2k_err_detect: seq_2k_err_detected flag to be updated
  253. * @pn_err_detect: pn_err_detected flag to be updated
  254. * @pn_31_0: PN bits 31-0
  255. * @pn_63_32: PN bits 63-32
  256. * @pn_95_64: PN bits 95-64
  257. * @pn_127_96: PN bits 127-96
  258. */
  259. struct hal_reo_cmd_update_queue_params {
  260. uint32_t update_rx_queue_num:1,
  261. update_vld:1,
  262. update_assoc_link_desc:1,
  263. update_disable_dup_detect:1,
  264. update_soft_reorder_enab:1,
  265. update_ac:1,
  266. update_bar:1,
  267. update_rty:1,
  268. update_chk_2k_mode:1,
  269. update_oor_mode:1,
  270. update_ba_window_size:1,
  271. update_pn_check_needed:1,
  272. update_pn_even:1,
  273. update_pn_uneven:1,
  274. update_pn_hand_enab:1,
  275. update_pn_size:1,
  276. update_ignore_ampdu:1,
  277. update_svld:1,
  278. update_ssn:1,
  279. update_seq_2k_err_detect:1,
  280. update_pn_err_detect:1,
  281. update_pn_valid:1,
  282. update_pn:1;
  283. uint32_t rx_queue_num:16,
  284. vld:1,
  285. assoc_link_desc:2,
  286. disable_dup_detect:1,
  287. soft_reorder_enab:1,
  288. ac:2,
  289. bar:1,
  290. rty:1,
  291. chk_2k_mode:1,
  292. oor_mode:1,
  293. pn_check_needed:1,
  294. pn_even:1,
  295. pn_uneven:1,
  296. pn_hand_enab:1,
  297. ignore_ampdu:1;
  298. uint32_t ba_window_size:9,
  299. pn_size:8,
  300. svld:1,
  301. ssn:12,
  302. seq_2k_err_detect:1,
  303. pn_err_detect:1;
  304. uint32_t pn_31_0:32;
  305. uint32_t pn_63_32:32;
  306. uint32_t pn_95_64:32;
  307. uint32_t pn_127_96:32;
  308. };
  309. /**
  310. * struct hal_reo_cmd_params: Common structure to pass REO command parameters
  311. * @hal_reo_cmd_params_std: Standard parameters
  312. * @u: Union of various REO command parameters
  313. */
  314. struct hal_reo_cmd_params {
  315. struct hal_reo_cmd_params_std std;
  316. union {
  317. struct hal_reo_cmd_get_queue_stats_params stats_params;
  318. struct hal_reo_cmd_flush_queue_params fl_queue_params;
  319. struct hal_reo_cmd_flush_cache_params fl_cache_params;
  320. struct hal_reo_cmd_unblock_cache_params unblk_cache_params;
  321. struct hal_reo_cmd_flush_timeout_list_params fl_tim_list_params;
  322. struct hal_reo_cmd_update_queue_params upd_queue_params;
  323. } u;
  324. };
  325. /**
  326. * struct hal_reo_status_header: Common REO status header
  327. * @cmd_num: Command number
  328. * @exec_time: execution time
  329. * @status: command execution status
  330. * @tstamp: Timestamp of status updated
  331. */
  332. struct hal_reo_status_header {
  333. uint16_t cmd_num;
  334. uint16_t exec_time;
  335. enum reo_cmd_exec_status status;
  336. uint32_t tstamp;
  337. };
  338. /**
  339. * struct hal_reo_queue_status: REO queue status structure
  340. * @header: Common REO status header
  341. * @ssn: SSN of current BA window
  342. * @curr_idx: last forwarded pkt
  343. * @pn_31_0, pn_63_32, pn_95_64, pn_127_96:
  344. * PN number bits extracted from IV field
  345. * @last_rx_enq_tstamp: Last enqueue timestamp
  346. * @last_rx_deq_tstamp: Last dequeue timestamp
  347. * @rx_bitmap_31_0, rx_bitmap_63_32, rx_bitmap_95_64
  348. * @rx_bitmap_127_96, rx_bitmap_159_128, rx_bitmap_191_160
  349. * @rx_bitmap_223_192, rx_bitmap_255_224: Each bit corresonds to a frame
  350. * held in re-order queue
  351. * @curr_mpdu_cnt, curr_msdu_cnt: Number of MPDUs and MSDUs in the queue
  352. * @fwd_timeout_cnt: Frames forwarded due to timeout
  353. * @fwd_bar_cnt: Frames forwarded BAR frame
  354. * @dup_cnt: duplicate frames detected
  355. * @frms_in_order_cnt: Frames received in order
  356. * @bar_rcvd_cnt: BAR frame count
  357. * @mpdu_frms_cnt, msdu_frms_cnt, total_cnt: MPDU, MSDU, total frames
  358. processed by REO
  359. * @late_recv_mpdu_cnt; received after window had moved on
  360. * @win_jump_2k: 2K jump count
  361. * @hole_cnt: sequence hole count
  362. */
  363. struct hal_reo_queue_status {
  364. struct hal_reo_status_header header;
  365. uint16_t ssn;
  366. uint8_t curr_idx;
  367. uint32_t pn_31_0, pn_63_32, pn_95_64, pn_127_96;
  368. uint32_t last_rx_enq_tstamp, last_rx_deq_tstamp;
  369. uint32_t rx_bitmap_31_0, rx_bitmap_63_32, rx_bitmap_95_64;
  370. uint32_t rx_bitmap_127_96, rx_bitmap_159_128, rx_bitmap_191_160;
  371. uint32_t rx_bitmap_223_192, rx_bitmap_255_224;
  372. uint8_t curr_mpdu_cnt, curr_msdu_cnt;
  373. uint8_t fwd_timeout_cnt, fwd_bar_cnt;
  374. uint16_t dup_cnt;
  375. uint32_t frms_in_order_cnt;
  376. uint8_t bar_rcvd_cnt;
  377. uint32_t mpdu_frms_cnt, msdu_frms_cnt, total_cnt;
  378. uint16_t late_recv_mpdu_cnt;
  379. uint8_t win_jump_2k;
  380. uint16_t hole_cnt;
  381. };
  382. /**
  383. * struct hal_reo_flush_queue_status: FLUSH_QUEUE status structure
  384. * @header: Common REO status header
  385. * @error: Error detected
  386. */
  387. struct hal_reo_flush_queue_status {
  388. struct hal_reo_status_header header;
  389. bool error;
  390. };
  391. /**
  392. * struct hal_reo_flush_cache_status: FLUSH_CACHE status structure
  393. * @header: Common REO status header
  394. * @error: Error detected
  395. * @block_error: Blocking related error
  396. * @cache_flush_status: Cache hit/miss
  397. * @cache_flush_status_desc_type: type of descriptor flushed
  398. * @cache_flush_cnt: number of lines actually flushed
  399. */
  400. struct hal_reo_flush_cache_status {
  401. struct hal_reo_status_header header;
  402. bool error;
  403. uint8_t block_error;
  404. bool cache_flush_status;
  405. uint8_t cache_flush_status_desc_type;
  406. uint8_t cache_flush_cnt;
  407. };
  408. /**
  409. * struct hal_reo_unblk_cache_status: UNBLOCK_CACHE status structure
  410. * @header: Common REO status header
  411. * @error: error detected
  412. * unblock_type: resoure or cache
  413. */
  414. struct hal_reo_unblk_cache_status {
  415. struct hal_reo_status_header header;
  416. bool error;
  417. enum reo_unblock_cache_type unblock_type;
  418. };
  419. /**
  420. * struct hal_reo_flush_timeout_list_status: FLUSH_TIMEOUT_LIST status structure
  421. * @header: Common REO status header
  422. * @error: error detected
  423. * @list_empty: timeout list empty
  424. * @rel_desc_cnt: number of link descriptors released
  425. * @fwd_buf_cnt: number of buffers forwarded to REO destination ring
  426. */
  427. struct hal_reo_flush_timeout_list_status {
  428. struct hal_reo_status_header header;
  429. bool error;
  430. bool list_empty;
  431. uint16_t rel_desc_cnt;
  432. uint16_t fwd_buf_cnt;
  433. };
  434. /**
  435. * struct hal_reo_desc_thres_reached_status: desc_thres_reached status structure
  436. * @header: Common REO status header
  437. * @thres_index: Index of descriptor threshold counter
  438. * @link_desc_counter0, link_desc_counter1, link_desc_counter2: descriptor
  439. * counter values
  440. * @link_desc_counter_sum: overall descriptor count
  441. */
  442. struct hal_reo_desc_thres_reached_status {
  443. struct hal_reo_status_header header;
  444. enum reo_thres_index_reg thres_index;
  445. uint32_t link_desc_counter0, link_desc_counter1, link_desc_counter2;
  446. uint32_t link_desc_counter_sum;
  447. };
  448. /**
  449. * struct hal_reo_update_rx_queue_status: UPDATE_RX_QUEUE status structure
  450. * @header: Common REO status header
  451. */
  452. struct hal_reo_update_rx_queue_status {
  453. struct hal_reo_status_header header;
  454. };
  455. /**
  456. * union hal_reo_status: Union to pass REO status to callbacks
  457. * @queue_status: Refer to struct hal_reo_queue_status
  458. * @fl_cache_status: Refer to struct hal_reo_flush_cache_status
  459. * @fl_queue_status: Refer to struct hal_reo_flush_queue_status
  460. * @fl_timeout_status: Refer to struct hal_reo_flush_timeout_list_status
  461. * @unblk_cache_status: Refer to struct hal_reo_unblk_cache_status
  462. * @thres_status: struct hal_reo_desc_thres_reached_status
  463. * @rx_queue_status: struct hal_reo_update_rx_queue_status
  464. */
  465. union hal_reo_status {
  466. struct hal_reo_queue_status queue_status;
  467. struct hal_reo_flush_cache_status fl_cache_status;
  468. struct hal_reo_flush_queue_status fl_queue_status;
  469. struct hal_reo_flush_timeout_list_status fl_timeout_status;
  470. struct hal_reo_unblk_cache_status unblk_cache_status;
  471. struct hal_reo_desc_thres_reached_status thres_status;
  472. struct hal_reo_update_rx_queue_status rx_queue_status;
  473. };
  474. #ifdef HAL_DISABLE_NON_BA_2K_JUMP_ERROR
  475. static inline uint32_t hal_update_non_ba_win_size(int tid,
  476. uint32_t ba_window_size)
  477. {
  478. return ba_window_size;
  479. }
  480. #else
  481. static inline uint32_t hal_update_non_ba_win_size(int tid,
  482. uint32_t ba_window_size)
  483. {
  484. if ((ba_window_size == 1) && (tid != HAL_NON_QOS_TID))
  485. ba_window_size++;
  486. return ba_window_size;
  487. }
  488. #endif
  489. #define BLOCK_RES_MASK 0xF
  490. static inline uint8_t hal_find_one_bit(uint8_t x)
  491. {
  492. uint8_t y = (x & (~x + 1)) & BLOCK_RES_MASK;
  493. uint8_t pos;
  494. for (pos = 0; y; y >>= 1)
  495. pos++;
  496. return pos-1;
  497. }
  498. static inline uint8_t hal_find_zero_bit(uint8_t x)
  499. {
  500. uint8_t y = (~x & (x+1)) & BLOCK_RES_MASK;
  501. uint8_t pos;
  502. for (pos = 0; y; y >>= 1)
  503. pos++;
  504. return pos-1;
  505. }
  506. /* REO command ring routines */
  507. /**
  508. * hal_uniform_desc_hdr_setup - setup reo_queue_ext descritpro
  509. * @owner - owner info
  510. * @buffer_type - buffer type
  511. */
  512. static inline void
  513. hal_uniform_desc_hdr_setup(uint32_t *desc, uint32_t owner, uint32_t buffer_type)
  514. {
  515. HAL_DESC_SET_FIELD(desc, HAL_UNIFORM_DESCRIPTOR_HEADER, OWNER,
  516. owner);
  517. HAL_DESC_SET_FIELD(desc, HAL_UNIFORM_DESCRIPTOR_HEADER, BUFFER_TYPE,
  518. buffer_type);
  519. }
  520. /**
  521. * hal_reo_send_cmd() - Send reo cmd using the params provided.
  522. * @hal_soc_hdl: HAL soc handle
  523. * @hal_soc_hdl: srng handle
  524. * @cmd: cmd ID
  525. * @cmd_params: command params
  526. *
  527. * Return: cmd number
  528. */
  529. static inline int
  530. hal_reo_send_cmd(hal_soc_handle_t hal_soc_hdl,
  531. hal_ring_handle_t hal_ring_hdl,
  532. enum hal_reo_cmd_type cmd,
  533. struct hal_reo_cmd_params *cmd_params)
  534. {
  535. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  536. if (!hal_soc || !hal_soc->ops) {
  537. hal_err("hal handle is NULL");
  538. QDF_BUG(0);
  539. return -EINVAL;
  540. }
  541. if (hal_soc->ops->hal_reo_send_cmd)
  542. return hal_soc->ops->hal_reo_send_cmd(hal_soc_hdl, hal_ring_hdl,
  543. cmd, cmd_params);
  544. return -EINVAL;
  545. }
  546. static inline QDF_STATUS
  547. hal_reo_status_update(hal_soc_handle_t hal_soc_hdl,
  548. hal_ring_desc_t reo_desc, void *st_handle,
  549. uint32_t tlv, int *num_ref)
  550. {
  551. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  552. if (hal_soc->ops->hal_reo_send_cmd)
  553. return hal_soc->ops->hal_reo_status_update(hal_soc_hdl,
  554. reo_desc,
  555. st_handle,
  556. tlv, num_ref);
  557. return QDF_STATUS_E_FAILURE;
  558. }
  559. /* REO Status ring routines */
  560. static inline void hal_reo_qdesc_setup(hal_soc_handle_t hal_soc_hdl, int tid,
  561. uint32_t ba_window_size,
  562. uint32_t start_seq, void *hw_qdesc_vaddr,
  563. qdf_dma_addr_t hw_qdesc_paddr,
  564. int pn_type)
  565. {
  566. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  567. if (!hal_soc || !hal_soc->ops) {
  568. hal_err("hal handle is NULL");
  569. QDF_BUG(0);
  570. return;
  571. }
  572. if (hal_soc->ops->hal_reo_qdesc_setup)
  573. hal_soc->ops->hal_reo_qdesc_setup(hal_soc_hdl, tid,
  574. ba_window_size, start_seq,
  575. hw_qdesc_vaddr,
  576. hw_qdesc_paddr, pn_type);
  577. }
  578. /**
  579. * hal_get_ba_aging_timeout - Retrieve BA aging timeout
  580. *
  581. * @hal_soc: Opaque HAL SOC handle
  582. * @ac: Access category
  583. * @value: timeout duration in millisec
  584. */
  585. static inline void hal_get_ba_aging_timeout(hal_soc_handle_t hal_soc_hdl,
  586. uint8_t ac,
  587. uint32_t *value)
  588. {
  589. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  590. hal_soc->ops->hal_get_ba_aging_timeout(hal_soc_hdl, ac, value);
  591. }
  592. /**
  593. * hal_set_aging_timeout - Set BA aging timeout
  594. *
  595. * @hal_soc: Opaque HAL SOC handle
  596. * @ac: Access category in millisec
  597. * @value: timeout duration value
  598. */
  599. static inline void hal_set_ba_aging_timeout(hal_soc_handle_t hal_soc_hdl,
  600. uint8_t ac,
  601. uint32_t value)
  602. {
  603. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  604. hal_soc->ops->hal_set_ba_aging_timeout(hal_soc_hdl, ac, value);
  605. }
  606. /**
  607. * hal_get_reo_reg_base_offset() - Get REO register base offset
  608. * @hal_soc_hdl: HAL soc handle
  609. *
  610. * Return: REO register base
  611. */
  612. static inline uint32_t hal_get_reo_reg_base_offset(hal_soc_handle_t hal_soc_hdl)
  613. {
  614. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  615. return hal_soc->ops->hal_get_reo_reg_base_offset();
  616. }
  617. static inline uint32_t
  618. hal_gen_reo_remap_val(hal_soc_handle_t hal_soc_hdl,
  619. enum hal_reo_remap_reg remap_reg,
  620. uint8_t *ix0_map)
  621. {
  622. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  623. if (!hal_soc || !hal_soc->ops) {
  624. hal_err("hal handle is NULL");
  625. QDF_BUG(0);
  626. return 0;
  627. }
  628. if (hal_soc->ops->hal_gen_reo_remap_val)
  629. return hal_soc->ops->hal_gen_reo_remap_val(remap_reg, ix0_map);
  630. return 0;
  631. }
  632. static inline uint8_t
  633. hal_get_tlv_hdr_size(hal_soc_handle_t hal_soc_hdl)
  634. {
  635. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  636. if (hal_soc->ops->hal_get_tlv_hdr_size)
  637. return hal_soc->ops->hal_get_tlv_hdr_size();
  638. return 0;
  639. }
  640. /* Function Proto-types */
  641. /**
  642. * hal_reo_init_cmd_ring() - Initialize descriptors of REO command SRNG
  643. * with command number
  644. * @hal_soc: Handle to HAL SoC structure
  645. * @hal_ring: Handle to HAL SRNG structure
  646. * Return: none
  647. */
  648. void hal_reo_init_cmd_ring(hal_soc_handle_t hal_soc_hdl,
  649. hal_ring_handle_t hal_ring_hdl);
  650. #endif /* _HAL_REO_H */