hal_reo.h 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846
  1. /*
  2. * Copyright (c) 2017-2019, 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. #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. * @HAL_REO_CMD_RESOURCE_BLOCKED: Command could not be executed as a resource
  136. * was blocked
  137. * @HAL_REO_CMD_DRAIN: Command was drained before it could be executed
  138. */
  139. enum reo_cmd_exec_status {
  140. HAL_REO_CMD_SUCCESS = 0,
  141. HAL_REO_CMD_BLOCKED = 1,
  142. HAL_REO_CMD_FAILED = 2,
  143. HAL_REO_CMD_RESOURCE_BLOCKED = 3,
  144. HAL_REO_CMD_DRAIN = 0xff
  145. };
  146. /**
  147. * struct hal_reo_cmd_params_std - Standard REO command parameters
  148. * @need_status: Status required for the command
  149. * @addr_lo: Lower 32 bits of REO queue descriptor address
  150. * @addr_hi: Upper 8 bits of REO queue descriptor address
  151. */
  152. struct hal_reo_cmd_params_std {
  153. bool need_status;
  154. uint32_t addr_lo;
  155. uint8_t addr_hi;
  156. };
  157. /**
  158. * struct hal_reo_cmd_get_queue_stats_params - Parameters to
  159. * CMD_GET_QUEUE_STATScommand
  160. * @clear: Clear stats after retrieving
  161. */
  162. struct hal_reo_cmd_get_queue_stats_params {
  163. bool clear;
  164. };
  165. /**
  166. * struct hal_reo_cmd_flush_queue_params - Parameters to CMD_FLUSH_QUEUE
  167. * @block_use_after_flush: Block usage after flush till unblock command
  168. * @index: Blocking resource to be used
  169. */
  170. struct hal_reo_cmd_flush_queue_params {
  171. bool block_use_after_flush;
  172. uint8_t index;
  173. };
  174. /**
  175. * struct hal_reo_cmd_flush_cache_params - Parameters to CMD_FLUSH_CACHE
  176. * @fwd_mpdus_in_queue: Forward MPDUs before flushing descriptor
  177. * @rel_block_index: Release blocking resource used earlier
  178. * @cache_block_res_index: Blocking resource to be used
  179. * @flush_no_inval: Flush without invalidatig descriptor
  180. * @block_use_after_flush: Block usage after flush till unblock command
  181. * @flush_entire_cache: Flush entire REO cache
  182. * @flush_q_1k_desc:
  183. */
  184. struct hal_reo_cmd_flush_cache_params {
  185. bool fwd_mpdus_in_queue;
  186. bool rel_block_index;
  187. uint8_t cache_block_res_index;
  188. bool flush_no_inval;
  189. bool block_use_after_flush;
  190. bool flush_entire_cache;
  191. bool flush_q_1k_desc;
  192. };
  193. /**
  194. * struct hal_reo_cmd_unblock_cache_params - Parameters to CMD_UNBLOCK_CACHE
  195. * @type: Unblock type (enum reo_unblock_cache_type)
  196. * @index: Blocking index to be released
  197. */
  198. struct hal_reo_cmd_unblock_cache_params {
  199. enum reo_unblock_cache_type type;
  200. uint8_t index;
  201. };
  202. /**
  203. * struct hal_reo_cmd_flush_timeout_list_params - Parameters to
  204. * CMD_FLUSH_TIMEOUT_LIST
  205. * @ac_list: AC timeout list to be flushed
  206. * @min_rel_desc: Min. number of link descriptors to be release
  207. * @min_fwd_buf: Min. number of buffers to be forwarded
  208. */
  209. struct hal_reo_cmd_flush_timeout_list_params {
  210. uint8_t ac_list;
  211. uint16_t min_rel_desc;
  212. uint16_t min_fwd_buf;
  213. };
  214. /**
  215. * struct hal_reo_cmd_update_queue_params - Parameters to
  216. * CMD_UPDATE_RX_REO_QUEUE
  217. * @update_rx_queue_num: Update receive queue number
  218. * @update_vld: Update valid bit
  219. * @update_assoc_link_desc: Update associated link descriptor
  220. * @update_disable_dup_detect: Update duplicate detection
  221. * @update_soft_reorder_enab: Update soft reorder enable
  222. * @update_ac: Update access category
  223. * @update_bar: Update BAR received bit
  224. * @update_rty: Update retry bit
  225. * @update_chk_2k_mode: Update chk_2k_mode setting
  226. * @update_oor_mode: Update OOR mode setting
  227. * @update_ba_window_size: Update BA window size
  228. * @update_pn_check_needed: Update pn_check_needed
  229. * @update_pn_even: Update pn_even
  230. * @update_pn_uneven: Update pn_uneven
  231. * @update_pn_hand_enab: Update pn_handling_enable
  232. * @update_pn_size: Update pn_size
  233. * @update_ignore_ampdu: Update ignore_ampdu
  234. * @update_svld: update svld
  235. * @update_ssn: Update SSN
  236. * @update_seq_2k_err_detect: Update seq_2k_err_detected flag
  237. * @update_pn_err_detect: Update pn_err_detected flag
  238. * @update_pn_valid: Update pn_valid
  239. * @update_pn: Update PN
  240. * @rx_queue_num: rx_queue_num to be updated
  241. * @vld: valid bit to be updated
  242. * @assoc_link_desc: assoc_link_desc counter
  243. * @disable_dup_detect: disable_dup_detect to be updated
  244. * @soft_reorder_enab: soft_reorder_enab to be updated
  245. * @ac: AC to be updated
  246. * @bar: BAR flag to be updated
  247. * @rty: RTY flag to be updated
  248. * @chk_2k_mode: check_2k_mode setting to be updated
  249. * @oor_mode: oor_mode to be updated
  250. * @pn_check_needed: pn_check_needed to be updated
  251. * @pn_even: pn_even to be updated
  252. * @pn_uneven: pn_uneven to be updated
  253. * @pn_hand_enab: pn_handling_enable to be updated
  254. * @ignore_ampdu: ignore_ampdu to be updated
  255. * @ba_window_size: BA window size to be updated
  256. * @pn_size: pn_size to be updated
  257. * @svld: svld flag to be updated
  258. * @ssn: SSN to be updated
  259. * @seq_2k_err_detect: seq_2k_err_detected flag to be updated
  260. * @pn_err_detect: pn_err_detected flag to be updated
  261. * @pn_31_0: PN bits 31-0
  262. * @pn_63_32: PN bits 63-32
  263. * @pn_95_64: PN bits 95-64
  264. * @pn_127_96: PN bits 127-96
  265. */
  266. struct hal_reo_cmd_update_queue_params {
  267. uint32_t update_rx_queue_num:1,
  268. update_vld:1,
  269. update_assoc_link_desc:1,
  270. update_disable_dup_detect:1,
  271. update_soft_reorder_enab:1,
  272. update_ac:1,
  273. update_bar:1,
  274. update_rty:1,
  275. update_chk_2k_mode:1,
  276. update_oor_mode:1,
  277. update_ba_window_size:1,
  278. update_pn_check_needed:1,
  279. update_pn_even:1,
  280. update_pn_uneven:1,
  281. update_pn_hand_enab:1,
  282. update_pn_size:1,
  283. update_ignore_ampdu:1,
  284. update_svld:1,
  285. update_ssn:1,
  286. update_seq_2k_err_detect:1,
  287. update_pn_err_detect:1,
  288. update_pn_valid:1,
  289. update_pn:1;
  290. uint32_t rx_queue_num:16,
  291. vld:1,
  292. assoc_link_desc:2,
  293. disable_dup_detect:1,
  294. soft_reorder_enab:1,
  295. ac:2,
  296. bar:1,
  297. rty:1,
  298. chk_2k_mode:1,
  299. oor_mode:1,
  300. pn_check_needed:1,
  301. pn_even:1,
  302. pn_uneven:1,
  303. pn_hand_enab:1,
  304. ignore_ampdu:1;
  305. uint32_t ba_window_size:15,
  306. pn_size:2,
  307. svld:1,
  308. ssn:12,
  309. seq_2k_err_detect:1,
  310. pn_err_detect:1;
  311. uint32_t pn_31_0:32;
  312. uint32_t pn_63_32:32;
  313. uint32_t pn_95_64:32;
  314. uint32_t pn_127_96:32;
  315. };
  316. /**
  317. * struct hal_reo_cmd_params - Common structure to pass REO command parameters
  318. * @std: Standard parameters
  319. * @u: Union of various REO command parameters
  320. */
  321. struct hal_reo_cmd_params {
  322. struct hal_reo_cmd_params_std std;
  323. union {
  324. struct hal_reo_cmd_get_queue_stats_params stats_params;
  325. struct hal_reo_cmd_flush_queue_params fl_queue_params;
  326. struct hal_reo_cmd_flush_cache_params fl_cache_params;
  327. struct hal_reo_cmd_unblock_cache_params unblk_cache_params;
  328. struct hal_reo_cmd_flush_timeout_list_params fl_tim_list_params;
  329. struct hal_reo_cmd_update_queue_params upd_queue_params;
  330. } u;
  331. };
  332. /**
  333. * struct hal_reo_status_header - Common REO status header
  334. * @cmd_num: Command number
  335. * @exec_time: execution time
  336. * @status: command execution status
  337. * @tstamp: Timestamp of status updated
  338. */
  339. struct hal_reo_status_header {
  340. uint16_t cmd_num;
  341. uint16_t exec_time;
  342. enum reo_cmd_exec_status status;
  343. uint32_t tstamp;
  344. };
  345. /**
  346. * struct hal_reo_queue_status - REO queue status structure
  347. * @header: Common REO status header
  348. * @ssn: SSN of current BA window
  349. * @curr_idx: last forwarded pkt
  350. * @pn_31_0:
  351. * @pn_63_32:
  352. * @pn_95_64:
  353. * @pn_127_96: PN number bits extracted from IV field
  354. * @last_rx_enq_tstamp: Last enqueue timestamp
  355. * @last_rx_deq_tstamp: Last dequeue timestamp
  356. * @rx_bitmap_31_0:
  357. * @rx_bitmap_63_32:
  358. * @rx_bitmap_95_64:
  359. * @rx_bitmap_127_96:
  360. * @rx_bitmap_159_128:
  361. * @rx_bitmap_191_160:
  362. * @rx_bitmap_223_192:
  363. * @rx_bitmap_255_224: bits of rx bitmap where each bit corresponds to a frame
  364. * held in re-order queue
  365. * @curr_mpdu_cnt: Number of MPDUs in the queue
  366. * @curr_msdu_cnt: Number of MSDUs in the queue
  367. * @fwd_timeout_cnt: Frames forwarded due to timeout
  368. * @fwd_bar_cnt: Frames forwarded BAR frame
  369. * @dup_cnt: duplicate frames detected
  370. * @frms_in_order_cnt: Frames received in order
  371. * @bar_rcvd_cnt: BAR frame count
  372. * @mpdu_frms_cnt: MPDUs processed by REO
  373. * @msdu_frms_cnt: MSDUs processed by REO
  374. * @total_cnt: frames processed by REO
  375. * @late_recv_mpdu_cnt: received after window had moved on
  376. * @win_jump_2k: 2K jump count
  377. * @hole_cnt: sequence hole count
  378. */
  379. struct hal_reo_queue_status {
  380. struct hal_reo_status_header header;
  381. uint16_t ssn;
  382. uint8_t curr_idx;
  383. uint32_t pn_31_0, pn_63_32, pn_95_64, pn_127_96;
  384. uint32_t last_rx_enq_tstamp, last_rx_deq_tstamp;
  385. uint32_t rx_bitmap_31_0, rx_bitmap_63_32, rx_bitmap_95_64;
  386. uint32_t rx_bitmap_127_96, rx_bitmap_159_128, rx_bitmap_191_160;
  387. uint32_t rx_bitmap_223_192, rx_bitmap_255_224;
  388. uint8_t curr_mpdu_cnt, curr_msdu_cnt;
  389. uint8_t fwd_timeout_cnt, fwd_bar_cnt;
  390. uint16_t dup_cnt;
  391. uint32_t frms_in_order_cnt;
  392. uint8_t bar_rcvd_cnt;
  393. uint32_t mpdu_frms_cnt, msdu_frms_cnt, total_cnt;
  394. uint16_t late_recv_mpdu_cnt;
  395. uint8_t win_jump_2k;
  396. uint16_t hole_cnt;
  397. };
  398. /**
  399. * struct hal_reo_flush_queue_status - FLUSH_QUEUE status structure
  400. * @header: Common REO status header
  401. * @error: Error detected
  402. */
  403. struct hal_reo_flush_queue_status {
  404. struct hal_reo_status_header header;
  405. bool error;
  406. };
  407. /**
  408. * struct hal_reo_flush_cache_status - FLUSH_CACHE status structure
  409. * @header: Common REO status header
  410. * @error: Error detected
  411. * @block_error: Blocking related error
  412. * @cache_flush_status: Cache hit/miss
  413. * @cache_flush_status_desc_type: type of descriptor flushed
  414. * @cache_flush_cnt: number of lines actually flushed
  415. */
  416. struct hal_reo_flush_cache_status {
  417. struct hal_reo_status_header header;
  418. bool error;
  419. uint8_t block_error;
  420. bool cache_flush_status;
  421. uint8_t cache_flush_status_desc_type;
  422. uint8_t cache_flush_cnt;
  423. };
  424. /**
  425. * struct hal_reo_unblk_cache_status - UNBLOCK_CACHE status structure
  426. * @header: Common REO status header
  427. * @error: error detected
  428. * @unblock_type: resource or cache
  429. */
  430. struct hal_reo_unblk_cache_status {
  431. struct hal_reo_status_header header;
  432. bool error;
  433. enum reo_unblock_cache_type unblock_type;
  434. };
  435. /**
  436. * struct hal_reo_flush_timeout_list_status - FLUSH_TIMEOUT_LIST status
  437. * structure
  438. * @header: Common REO status header
  439. * @error: error detected
  440. * @list_empty: timeout list empty
  441. * @rel_desc_cnt: number of link descriptors released
  442. * @fwd_buf_cnt: number of buffers forwarded to REO destination ring
  443. */
  444. struct hal_reo_flush_timeout_list_status {
  445. struct hal_reo_status_header header;
  446. bool error;
  447. bool list_empty;
  448. uint16_t rel_desc_cnt;
  449. uint16_t fwd_buf_cnt;
  450. };
  451. /**
  452. * struct hal_reo_desc_thres_reached_status - desc_thres_reached status
  453. * structure
  454. * @header: Common REO status header
  455. * @thres_index: Index of descriptor threshold counter
  456. * @link_desc_counter0: descriptor counter value
  457. * @link_desc_counter1: descriptor counter value
  458. * @link_desc_counter2: descriptor counter value
  459. * @link_desc_counter_sum: overall descriptor count
  460. */
  461. struct hal_reo_desc_thres_reached_status {
  462. struct hal_reo_status_header header;
  463. enum reo_thres_index_reg thres_index;
  464. uint32_t link_desc_counter0, link_desc_counter1, link_desc_counter2;
  465. uint32_t link_desc_counter_sum;
  466. };
  467. /**
  468. * struct hal_reo_update_rx_queue_status - UPDATE_RX_QUEUE status structure
  469. * @header: Common REO status header
  470. */
  471. struct hal_reo_update_rx_queue_status {
  472. struct hal_reo_status_header header;
  473. };
  474. /**
  475. * union hal_reo_status - Union to pass REO status to callbacks
  476. * @queue_status: Refer to struct hal_reo_queue_status
  477. * @fl_cache_status: Refer to struct hal_reo_flush_cache_status
  478. * @fl_queue_status: Refer to struct hal_reo_flush_queue_status
  479. * @fl_timeout_status: Refer to struct hal_reo_flush_timeout_list_status
  480. * @unblk_cache_status: Refer to struct hal_reo_unblk_cache_status
  481. * @thres_status: struct hal_reo_desc_thres_reached_status
  482. * @rx_queue_status: struct hal_reo_update_rx_queue_status
  483. */
  484. union hal_reo_status {
  485. struct hal_reo_queue_status queue_status;
  486. struct hal_reo_flush_cache_status fl_cache_status;
  487. struct hal_reo_flush_queue_status fl_queue_status;
  488. struct hal_reo_flush_timeout_list_status fl_timeout_status;
  489. struct hal_reo_unblk_cache_status unblk_cache_status;
  490. struct hal_reo_desc_thres_reached_status thres_status;
  491. struct hal_reo_update_rx_queue_status rx_queue_status;
  492. };
  493. #ifdef HAL_DISABLE_NON_BA_2K_JUMP_ERROR
  494. static inline uint32_t hal_update_non_ba_win_size(int tid,
  495. uint32_t ba_window_size)
  496. {
  497. return ba_window_size;
  498. }
  499. #else
  500. static inline uint32_t hal_update_non_ba_win_size(int tid,
  501. uint32_t ba_window_size)
  502. {
  503. if ((ba_window_size == 1) && (tid != HAL_NON_QOS_TID))
  504. ba_window_size++;
  505. return ba_window_size;
  506. }
  507. #endif
  508. #define BLOCK_RES_MASK 0xF
  509. static inline uint8_t hal_find_one_bit(uint8_t x)
  510. {
  511. uint8_t y = (x & (~x + 1)) & BLOCK_RES_MASK;
  512. uint8_t pos;
  513. for (pos = 0; y; y >>= 1)
  514. pos++;
  515. return pos-1;
  516. }
  517. static inline uint8_t hal_find_zero_bit(uint8_t x)
  518. {
  519. uint8_t y = (~x & (x+1)) & BLOCK_RES_MASK;
  520. uint8_t pos;
  521. for (pos = 0; y; y >>= 1)
  522. pos++;
  523. return pos-1;
  524. }
  525. /* REO command ring routines */
  526. /**
  527. * hal_uniform_desc_hdr_setup() - setup reo_queue_ext descriptor
  528. * @desc: descriptor to setup
  529. * @owner: owner info
  530. * @buffer_type: buffer type
  531. */
  532. static inline void
  533. hal_uniform_desc_hdr_setup(uint32_t *desc, uint32_t owner, uint32_t buffer_type)
  534. {
  535. HAL_DESC_SET_FIELD(desc, HAL_UNIFORM_DESCRIPTOR_HEADER, OWNER,
  536. owner);
  537. HAL_DESC_SET_FIELD(desc, HAL_UNIFORM_DESCRIPTOR_HEADER, BUFFER_TYPE,
  538. buffer_type);
  539. }
  540. /**
  541. * hal_reo_send_cmd() - Send reo cmd using the params provided.
  542. * @hal_soc_hdl: HAL soc handle
  543. * @hal_ring_hdl: srng handle
  544. * @cmd: cmd ID
  545. * @cmd_params: command params
  546. *
  547. * Return: cmd number
  548. */
  549. static inline int
  550. hal_reo_send_cmd(hal_soc_handle_t hal_soc_hdl,
  551. hal_ring_handle_t hal_ring_hdl,
  552. enum hal_reo_cmd_type cmd,
  553. struct hal_reo_cmd_params *cmd_params)
  554. {
  555. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  556. if (!hal_soc || !hal_soc->ops) {
  557. hal_err("hal handle is NULL");
  558. QDF_BUG(0);
  559. return -EINVAL;
  560. }
  561. if (hal_soc->ops->hal_reo_send_cmd)
  562. return hal_soc->ops->hal_reo_send_cmd(hal_soc_hdl, hal_ring_hdl,
  563. cmd, cmd_params);
  564. return -EINVAL;
  565. }
  566. #ifdef DP_UMAC_HW_RESET_SUPPORT
  567. /**
  568. * hal_register_reo_send_cmd() - Register Reo send command callback.
  569. * @hal_soc_hdl: HAL soc handle
  570. *
  571. * Return: void
  572. */
  573. static inline void hal_register_reo_send_cmd(hal_soc_handle_t hal_soc_hdl)
  574. {
  575. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  576. if (!hal_soc || !hal_soc->ops) {
  577. hal_err("hal handle is NULL");
  578. QDF_BUG(0);
  579. return;
  580. }
  581. if (hal_soc->ops->hal_register_reo_send_cmd)
  582. hal_soc->ops->hal_register_reo_send_cmd(hal_soc);
  583. }
  584. /**
  585. * hal_unregister_reo_send_cmd() - Unregister Reo send command callback.
  586. * @hal_soc_hdl: HAL soc handle
  587. *
  588. * Return: void
  589. */
  590. static inline void
  591. hal_unregister_reo_send_cmd(hal_soc_handle_t hal_soc_hdl)
  592. {
  593. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  594. if (!hal_soc || !hal_soc->ops) {
  595. hal_err("hal handle is NULL");
  596. QDF_BUG(0);
  597. return;
  598. }
  599. if (hal_soc->ops->hal_unregister_reo_send_cmd)
  600. return hal_soc->ops->hal_unregister_reo_send_cmd(hal_soc);
  601. }
  602. static inline void
  603. hal_reset_rx_reo_tid_queue(hal_soc_handle_t hal_soc_hdl, void *hw_qdesc_vaddr,
  604. uint32_t size)
  605. {
  606. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  607. if (hal_soc->ops->hal_reset_rx_reo_tid_q)
  608. hal_soc->ops->hal_reset_rx_reo_tid_q(hal_soc, hw_qdesc_vaddr,
  609. size);
  610. }
  611. #endif
  612. static inline QDF_STATUS
  613. hal_reo_status_update(hal_soc_handle_t hal_soc_hdl,
  614. hal_ring_desc_t reo_desc, void *st_handle,
  615. uint32_t tlv, int *num_ref)
  616. {
  617. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  618. if (hal_soc->ops->hal_reo_send_cmd)
  619. return hal_soc->ops->hal_reo_status_update(hal_soc_hdl,
  620. reo_desc,
  621. st_handle,
  622. tlv, num_ref);
  623. return QDF_STATUS_E_FAILURE;
  624. }
  625. /* REO Status ring routines */
  626. static inline void hal_reo_qdesc_setup(hal_soc_handle_t hal_soc_hdl, int tid,
  627. uint32_t ba_window_size,
  628. uint32_t start_seq, void *hw_qdesc_vaddr,
  629. qdf_dma_addr_t hw_qdesc_paddr,
  630. int pn_type, uint8_t vdev_stats_id)
  631. {
  632. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  633. if (!hal_soc || !hal_soc->ops) {
  634. hal_err("hal handle is NULL");
  635. QDF_BUG(0);
  636. return;
  637. }
  638. if (hal_soc->ops->hal_reo_qdesc_setup)
  639. hal_soc->ops->hal_reo_qdesc_setup(hal_soc_hdl, tid,
  640. ba_window_size, start_seq,
  641. hw_qdesc_vaddr,
  642. hw_qdesc_paddr, pn_type,
  643. vdev_stats_id);
  644. }
  645. /**
  646. * hal_get_ba_aging_timeout - Retrieve BA aging timeout
  647. * @hal_soc_hdl: Opaque HAL SOC handle
  648. * @ac: Access category
  649. * @value: timeout duration in millisec
  650. */
  651. static inline void hal_get_ba_aging_timeout(hal_soc_handle_t hal_soc_hdl,
  652. uint8_t ac,
  653. uint32_t *value)
  654. {
  655. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  656. hal_soc->ops->hal_get_ba_aging_timeout(hal_soc_hdl, ac, value);
  657. }
  658. /**
  659. * hal_set_ba_aging_timeout() - Set BA aging timeout
  660. * @hal_soc_hdl: Opaque HAL SOC handle
  661. * @ac: Access category
  662. * @value: timeout duration value in millisec
  663. */
  664. static inline void hal_set_ba_aging_timeout(hal_soc_handle_t hal_soc_hdl,
  665. uint8_t ac,
  666. uint32_t value)
  667. {
  668. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  669. hal_soc->ops->hal_set_ba_aging_timeout(hal_soc_hdl, ac, value);
  670. }
  671. /**
  672. * hal_get_reo_reg_base_offset() - Get REO register base offset
  673. * @hal_soc_hdl: HAL soc handle
  674. *
  675. * Return: REO register base
  676. */
  677. static inline uint32_t hal_get_reo_reg_base_offset(hal_soc_handle_t hal_soc_hdl)
  678. {
  679. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  680. return hal_soc->ops->hal_get_reo_reg_base_offset();
  681. }
  682. static inline uint32_t
  683. hal_gen_reo_remap_val(hal_soc_handle_t hal_soc_hdl,
  684. enum hal_reo_remap_reg remap_reg,
  685. uint8_t *ix0_map)
  686. {
  687. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  688. if (!hal_soc || !hal_soc->ops) {
  689. hal_err("hal handle is NULL");
  690. QDF_BUG(0);
  691. return 0;
  692. }
  693. if (hal_soc->ops->hal_gen_reo_remap_val)
  694. return hal_soc->ops->hal_gen_reo_remap_val(remap_reg, ix0_map);
  695. return 0;
  696. }
  697. static inline uint8_t
  698. hal_get_tlv_hdr_size(hal_soc_handle_t hal_soc_hdl)
  699. {
  700. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  701. if (hal_soc->ops->hal_get_tlv_hdr_size)
  702. return hal_soc->ops->hal_get_tlv_hdr_size();
  703. return 0;
  704. }
  705. /* Function Proto-types */
  706. /**
  707. * hal_reo_init_cmd_ring() - Initialize descriptors of REO command SRNG
  708. * with command number
  709. * @hal_soc_hdl: Handle to HAL SoC structure
  710. * @hal_ring_hdl: Handle to HAL SRNG structure
  711. *
  712. * Return: none
  713. */
  714. void hal_reo_init_cmd_ring(hal_soc_handle_t hal_soc_hdl,
  715. hal_ring_handle_t hal_ring_hdl);
  716. #ifdef REO_SHARED_QREF_TABLE_EN
  717. /**
  718. * hal_reo_shared_qaddr_setup(): Setup reo qref LUT
  719. * @hal_soc_hdl: Hal soc pointer
  720. * @reo_qref: REO QREF table to populate
  721. *
  722. * Allocate MLO and Non MLO table for storing REO queue
  723. * reference pointers
  724. *
  725. * Return: QDF_STATUS_SUCCESS on success else a QDF error.
  726. */
  727. static inline QDF_STATUS
  728. hal_reo_shared_qaddr_setup(hal_soc_handle_t hal_soc_hdl,
  729. struct reo_queue_ref_table *reo_qref)
  730. {
  731. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  732. if (hal_soc->ops->hal_reo_shared_qaddr_setup)
  733. return hal_soc->ops->hal_reo_shared_qaddr_setup(hal_soc_hdl,
  734. reo_qref);
  735. return QDF_STATUS_SUCCESS;
  736. }
  737. /**
  738. * hal_reo_shared_qaddr_detach(): Detach reo qref LUT
  739. * @hal_soc_hdl: Hal soc pointer
  740. *
  741. * Detach MLO and Non MLO table start addr to HW reg
  742. *
  743. * Return: void
  744. */
  745. static inline void
  746. hal_reo_shared_qaddr_detach(hal_soc_handle_t hal_soc_hdl)
  747. {
  748. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  749. if (hal_soc->ops->hal_reo_shared_qaddr_detach)
  750. return hal_soc->ops->hal_reo_shared_qaddr_detach(hal_soc_hdl);
  751. }
  752. #else
  753. static inline QDF_STATUS
  754. hal_reo_shared_qaddr_setup(hal_soc_handle_t hal_soc_hdl,
  755. struct reo_queue_ref_table *reo_qref)
  756. {
  757. return QDF_STATUS_SUCCESS;
  758. }
  759. static inline void
  760. hal_reo_shared_qaddr_detach(hal_soc_handle_t hal_soc_hdl) {}
  761. #endif /* REO_SHARED_QREF_TABLE_EN */
  762. #endif /* _HAL_REO_H */