hal_reo.h 24 KB

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