dp_umac_reset.h 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374
  1. /*
  2. * Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All rights reserved.
  3. *
  4. * Permission to use, copy, modify, and/or distribute this software for any
  5. * purpose with or without fee is hereby granted, provided that the above
  6. * copyright notice and this permission notice appear in all copies.
  7. *
  8. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  9. * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  10. * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  11. * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  12. * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  13. * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  14. * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  15. */
  16. #ifndef _DP_UMAC_RESET_H_
  17. #define _DP_UMAC_RESET_H_
  18. #include <qdf_types.h>
  19. struct dp_soc;
  20. #define DP_UMAC_RESET_NOTIFY_DONE 20
  21. /**
  22. * enum umac_reset_action - Actions supported by the UMAC reset
  23. * @UMAC_RESET_ACTION_NONE: No action
  24. * @UMAC_RESET_ACTION_DO_TRIGGER_RECOVERY: Trigger umac recovery
  25. * @UMAC_RESET_ACTION_DO_PRE_RESET: DO_PRE_RESET
  26. * @UMAC_RESET_ACTION_DO_POST_RESET_START: DO_POST_RESET_START
  27. * @UMAC_RESET_ACTION_DO_POST_RESET_COMPLETE: DO_POST_RESET_COMPLETE
  28. * @UMAC_RESET_ACTION_ABORT: Abort the current Umac reset session
  29. * @UMAC_RESET_ACTION_MAX: Maximum actions
  30. */
  31. enum umac_reset_action {
  32. UMAC_RESET_ACTION_NONE,
  33. UMAC_RESET_ACTION_DO_TRIGGER_RECOVERY,
  34. UMAC_RESET_ACTION_DO_PRE_RESET,
  35. UMAC_RESET_ACTION_DO_POST_RESET_START,
  36. UMAC_RESET_ACTION_DO_POST_RESET_COMPLETE,
  37. UMAC_RESET_ACTION_ABORT,
  38. UMAC_RESET_ACTION_MAX
  39. };
  40. #ifdef DP_UMAC_HW_RESET_SUPPORT
  41. #define dp_umac_reset_alert(params...) \
  42. QDF_TRACE_FATAL(QDF_MODULE_ID_DP_UMAC_RESET, params)
  43. #define dp_umac_reset_err(params...) \
  44. QDF_TRACE_ERROR(QDF_MODULE_ID_DP_UMAC_RESET, params)
  45. #define dp_umac_reset_warn(params...) \
  46. QDF_TRACE_WARN(QDF_MODULE_ID_DP_UMAC_RESET, params)
  47. #define dp_umac_reset_notice(params...) \
  48. QDF_TRACE_INFO(QDF_MODULE_ID_DP_UMAC_RESET, params)
  49. #define dp_umac_reset_info(params...) \
  50. QDF_TRACE_INFO(QDF_MODULE_ID_DP_UMAC_RESET, params)
  51. #define dp_umac_reset_debug(params...) \
  52. QDF_TRACE_DEBUG(QDF_MODULE_ID_DP_UMAC_RESET, params)
  53. #define DP_UMAC_RESET_PRINT_STATS(fmt, args ...)\
  54. QDF_TRACE(QDF_MODULE_ID_DP_UMAC_RESET, QDF_TRACE_LEVEL_FATAL,\
  55. fmt, ## args)
  56. #define DP_UMAC_RESET_SHMEM_ALIGN 8
  57. #define DP_UMAC_RESET_SHMEM_MAGIC_NUM (0xDEADBEEF)
  58. /**
  59. * enum umac_reset_state - States required by the UMAC reset state machine
  60. * @UMAC_RESET_STATE_WAIT_FOR_TRIGGER: Waiting for trigger event
  61. * @UMAC_RESET_STATE_DO_TRIGGER_RECEIVED: Received the DO_TRIGGER event
  62. * @UMAC_RESET_STATE_HOST_TRIGGER_DONE: Host completed handling Trigger event
  63. * @UMAC_RESET_STATE_WAIT_FOR_DO_PRE_RESET: Waiting for the DO_PRE_RESET event
  64. * @UMAC_RESET_STATE_DO_PRE_RESET_RECEIVED: Received the DO_PRE_RESET event
  65. * @UMAC_RESET_STATE_HOST_PRE_RESET_DONE: Host has completed handling the
  66. * PRE_RESET event
  67. * @UMAC_RESET_STATE_WAIT_FOR_DO_POST_RESET_START: Waiting for the
  68. * DO_POST_RESET_START event
  69. * @UMAC_RESET_STATE_DO_POST_RESET_START_RECEIVED: Received the
  70. * DO_POST_RESET_START event
  71. * @UMAC_RESET_STATE_HOST_POST_RESET_START_DONE: Host has completed handling the
  72. * POST_RESET_START event
  73. * @UMAC_RESET_STATE_WAIT_FOR_DO_POST_RESET_COMPLETE: Waiting for the
  74. * DO_POST_RESET_COMPLETE event
  75. * @UMAC_RESET_STATE_DO_POST_RESET_COMPLETE_RECEIVED: Received the
  76. * DO_POST_RESET_COMPLETE event
  77. * @UMAC_RESET_STATE_HOST_POST_RESET_COMPLETE_DONE: Host has completed handling
  78. * the DO_POST_RESET_COMPLETE event
  79. */
  80. enum umac_reset_state {
  81. UMAC_RESET_STATE_WAIT_FOR_TRIGGER = 0,
  82. UMAC_RESET_STATE_DO_TRIGGER_RECEIVED,
  83. UMAC_RESET_STATE_HOST_TRIGGER_DONE,
  84. UMAC_RESET_STATE_WAIT_FOR_DO_PRE_RESET,
  85. UMAC_RESET_STATE_DO_PRE_RESET_RECEIVED,
  86. UMAC_RESET_STATE_HOST_PRE_RESET_DONE,
  87. UMAC_RESET_STATE_WAIT_FOR_DO_POST_RESET_START,
  88. UMAC_RESET_STATE_DO_POST_RESET_START_RECEIVED,
  89. UMAC_RESET_STATE_HOST_POST_RESET_START_DONE,
  90. UMAC_RESET_STATE_WAIT_FOR_DO_POST_RESET_COMPLETE,
  91. UMAC_RESET_STATE_DO_POST_RESET_COMPLETE_RECEIVED,
  92. UMAC_RESET_STATE_HOST_POST_RESET_COMPLETE_DONE,
  93. };
  94. /**
  95. * enum umac_reset_rx_event - Rx events deduced by the UMAC reset
  96. * @UMAC_RESET_RX_EVENT_NONE: No event
  97. * @UMAC_RESET_RX_EVENT_DO_TRIGGER_RECOVERY: ACTION_DO_TRIGGER_RECOVERY event
  98. * @UMAC_RESET_RX_EVENT_DO_TRIGGER_TR_SYNC: ACTION_DO_TRIGGER_RECOVERY event
  99. * @UMAC_RESET_RX_EVENT_DO_PRE_RESET: DO_PRE_RESET event
  100. * @UMAC_RESET_RX_EVENT_DO_POST_RESET_START: DO_POST_RESET_START event
  101. * @UMAC_RESET_RX_EVENT_DO_POST_RESET_COMPELTE: DO_POST_RESET_COMPELTE event
  102. * @UMAC_RESET_RX_EVENT_ERROR: Error while processing the Rx event
  103. */
  104. enum umac_reset_rx_event {
  105. UMAC_RESET_RX_EVENT_NONE = 0x0,
  106. UMAC_RESET_RX_EVENT_DO_TRIGGER_RECOVERY,
  107. UMAC_RESET_RX_EVENT_DO_TRIGGER_TR_SYNC,
  108. UMAC_RESET_RX_EVENT_DO_PRE_RESET,
  109. UMAC_RESET_RX_EVENT_DO_POST_RESET_START,
  110. UMAC_RESET_RX_EVENT_DO_POST_RESET_COMPELTE,
  111. UMAC_RESET_RX_EVENT_ERROR = 0xFFFFFFFF,
  112. };
  113. /**
  114. * enum umac_reset_tx_cmd: UMAC reset Tx command
  115. * @UMAC_RESET_TX_CMD_TRIGGER_DONE: TRIGGER_DONE
  116. * @UMAC_RESET_TX_CMD_PRE_RESET_DONE: PRE_RESET_DONE
  117. * @UMAC_RESET_TX_CMD_POST_RESET_START_DONE: POST_RESET_START_DONE
  118. * @UMAC_RESET_TX_CMD_POST_RESET_COMPLETE_DONE: POST_RESET_COMPLETE_DONE
  119. */
  120. enum umac_reset_tx_cmd {
  121. UMAC_RESET_TX_CMD_TRIGGER_DONE,
  122. UMAC_RESET_TX_CMD_PRE_RESET_DONE,
  123. UMAC_RESET_TX_CMD_POST_RESET_START_DONE,
  124. UMAC_RESET_TX_CMD_POST_RESET_COMPLETE_DONE,
  125. };
  126. /**
  127. * struct umac_reset_rx_actions - callbacks for handling UMAC reset actions
  128. * @cb: Array of pointers where each pointer contains callback for each UMAC
  129. * reset action for that index
  130. */
  131. struct umac_reset_rx_actions {
  132. QDF_STATUS (*cb[UMAC_RESET_ACTION_MAX])(struct dp_soc *soc);
  133. };
  134. /**
  135. * struct reset_ts - timestamps of for umac reset events for debug
  136. * @trigger_start: Umac reset trigger event timestamp
  137. * @trigger_done: Umac reset trigger done timestamp
  138. * @pre_reset_start: Umac prereset start event timestamp
  139. * @pre_reset_done: Umac prereset done timestamp
  140. * @post_reset_start: Umac postreset start event timestamp
  141. * @post_reset_done: Umac postreset done timestamp
  142. * @post_reset_complete_start: Umac postreset complete event timestamp
  143. * @post_reset_complete_done: Umac postreset complete done timestamp
  144. */
  145. struct reset_ts {
  146. uint64_t trigger_start;
  147. uint64_t trigger_done;
  148. uint64_t pre_reset_start;
  149. uint64_t pre_reset_done;
  150. uint64_t post_reset_start;
  151. uint64_t post_reset_done;
  152. uint64_t post_reset_complete_start;
  153. uint64_t post_reset_complete_done;
  154. };
  155. #if defined(WLAN_FEATURE_11BE_MLO) && defined(WLAN_MLO_MULTI_CHIP)
  156. /**
  157. * struct dp_soc_mlo_umac_reset_ctx - UMAC reset context at mlo group level
  158. * @partner_map: Partner soc map
  159. * @request_map: Partner soc request map
  160. * @response_map: Partner soc response map
  161. * @grp_ctx_lock: lock for accessing group level umac reset context
  162. * @umac_reset_in_progress: Flag to indicate if umac reset is in progress
  163. * @is_target_recovery: Flag to indicate if this is for target recovery
  164. * @tx_desc_pool_cleaned: Global tx_desc pool clean up has been done
  165. * @initiator_chip_id: chip id of the Umac reset initiator
  166. * @umac_reset_count: Number of times Umac reset happened on this MLO group
  167. */
  168. struct dp_soc_mlo_umac_reset_ctx {
  169. unsigned long partner_map;
  170. unsigned long request_map;
  171. unsigned long response_map;
  172. qdf_spinlock_t grp_ctx_lock;
  173. uint8_t umac_reset_in_progress:1,
  174. is_target_recovery:1,
  175. tx_desc_pool_cleaned:1;
  176. uint8_t initiator_chip_id;
  177. uint32_t umac_reset_count;
  178. };
  179. #endif
  180. /**
  181. * struct dp_soc_umac_reset_ctx - UMAC reset context at soc level
  182. * @shmem_paddr_unaligned: Physical address of the shared memory (unaligned)
  183. * @shmem_vaddr_unaligned: Virtual address of the shared memory (unaligned)
  184. * @shmem_paddr_aligned: Physical address of the shared memory (aligned)
  185. * @shmem_vaddr_aligned: Virtual address of the shared memory (aligned)
  186. * @shmem_size: Size of the shared memory
  187. * @intr_offset: Offset of the UMAC reset interrupt w.r.t DP base interrupt
  188. * @current_state: current state of the UMAC reset state machine
  189. * @shmem_exp_magic_num: Expected magic number in the shared memory
  190. * @rx_actions: callbacks for handling UMAC reset actions
  191. * @pending_action: Action pending to be executed.
  192. * @intr_ctx_bkp: DP Interrupts ring masks backup
  193. * @nbuf_list: skb list for delayed free
  194. * @skel_enable: Enable skeleton code for umac reset
  195. * @ts: timestamps debug
  196. */
  197. struct dp_soc_umac_reset_ctx {
  198. qdf_dma_addr_t shmem_paddr_unaligned;
  199. void *shmem_vaddr_unaligned;
  200. qdf_dma_addr_t shmem_paddr_aligned;
  201. htt_umac_hang_recovery_msg_shmem_t *shmem_vaddr_aligned;
  202. size_t shmem_size;
  203. int intr_offset;
  204. enum umac_reset_state current_state;
  205. uint32_t shmem_exp_magic_num;
  206. struct umac_reset_rx_actions rx_actions;
  207. enum umac_reset_action pending_action;
  208. struct dp_intr_bkp *intr_ctx_bkp;
  209. qdf_nbuf_t nbuf_list;
  210. bool skel_enable;
  211. struct reset_ts ts;
  212. };
  213. /**
  214. * dp_soc_umac_reset_init() - Initialize UMAC reset context
  215. * @txrx_soc: DP soc object
  216. *
  217. * Return: QDF status of operation
  218. */
  219. QDF_STATUS dp_soc_umac_reset_init(struct cdp_soc_t *txrx_soc);
  220. /**
  221. * dp_soc_umac_reset_deinit() - De-initialize UMAC reset context
  222. * @txrx_soc: DP soc object
  223. *
  224. * Return: QDF status of operation
  225. */
  226. QDF_STATUS dp_soc_umac_reset_deinit(struct cdp_soc_t *txrx_soc);
  227. /**
  228. * dp_umac_reset_interrupt_attach() - Register handlers for UMAC reset interrupt
  229. * @soc: DP soc object
  230. *
  231. * Return: QDF status of operation
  232. */
  233. QDF_STATUS dp_umac_reset_interrupt_attach(struct dp_soc *soc);
  234. /**
  235. * dp_umac_reset_interrupt_detach() - Unregister UMAC reset interrupt handlers
  236. * @soc: DP soc object
  237. *
  238. * Return: QDF status of operation
  239. */
  240. QDF_STATUS dp_umac_reset_interrupt_detach(struct dp_soc *soc);
  241. /**
  242. * dp_umac_reset_register_rx_action_callback() - Register a callback for a given
  243. * UMAC reset action
  244. * @soc: DP soc object
  245. * @handler: callback handler to be registered
  246. * @action: UMAC reset action for which @handler needs to be registered
  247. *
  248. * Return: QDF status of operation
  249. */
  250. QDF_STATUS dp_umac_reset_register_rx_action_callback(
  251. struct dp_soc *soc,
  252. QDF_STATUS (*handler)(struct dp_soc *soc),
  253. enum umac_reset_action action);
  254. /**
  255. * dp_umac_reset_notify_action_completion() - Notify that a given action has
  256. * been completed
  257. * @soc: DP soc object
  258. * @action: UMAC reset action that got completed
  259. *
  260. * Return: QDF status of operation
  261. */
  262. QDF_STATUS dp_umac_reset_notify_action_completion(
  263. struct dp_soc *soc,
  264. enum umac_reset_action action);
  265. /**
  266. * dp_umac_reset_post_tx_cmd_via_shmem() - Post Tx command using shared memory
  267. * @soc: DP soc object
  268. * @ctxt: Tx command to be posted
  269. * @chip_id: Chip id of the mlo soc
  270. *
  271. * Return: None
  272. */
  273. void dp_umac_reset_post_tx_cmd_via_shmem(struct dp_soc *soc, void *ctxt,
  274. int chip_id);
  275. /**
  276. * dp_check_umac_reset_in_progress() - Check if Umac reset is in progress
  277. * @soc: dp soc handle
  278. *
  279. * Return: true if Umac reset is in progress or false otherwise
  280. */
  281. bool dp_check_umac_reset_in_progress(struct dp_soc *soc);
  282. /**
  283. * dp_umac_reset_stats_print - API to print UMAC reset stats
  284. * @soc: dp soc handle
  285. *
  286. * Return: QDF_STATUS
  287. */
  288. QDF_STATUS dp_umac_reset_stats_print(struct dp_soc *soc);
  289. /**
  290. * dp_umac_reset_validate_n_update_state_machine_on_rx() - Validate the state
  291. * machine for a given rx event and update the state machine
  292. * @umac_reset_ctx: UMAC reset context
  293. * @rx_event: Rx event
  294. * @current_exp_state: Expected state
  295. * @next_state: The state to which the state machine needs to be updated
  296. *
  297. * Return: QDF_STATUS of operation
  298. */
  299. QDF_STATUS
  300. dp_umac_reset_validate_n_update_state_machine_on_rx(
  301. struct dp_soc_umac_reset_ctx *umac_reset_ctx,
  302. enum umac_reset_rx_event rx_event,
  303. enum umac_reset_state current_exp_state,
  304. enum umac_reset_state next_state);
  305. #else
  306. static inline bool dp_check_umac_reset_in_progress(struct dp_soc *soc)
  307. {
  308. return false;
  309. }
  310. static inline
  311. QDF_STATUS dp_soc_umac_reset_init(struct cdp_soc_t *txrx_soc)
  312. {
  313. return QDF_STATUS_SUCCESS;
  314. }
  315. static inline
  316. QDF_STATUS dp_soc_umac_reset_deinit(struct cdp_soc_t *txrx_soc)
  317. {
  318. return QDF_STATUS_SUCCESS;
  319. }
  320. static inline
  321. QDF_STATUS dp_umac_reset_register_rx_action_callback(
  322. struct dp_soc *soc,
  323. QDF_STATUS (*handler)(struct dp_soc *soc),
  324. enum umac_reset_action action)
  325. {
  326. return QDF_STATUS_SUCCESS;
  327. }
  328. static inline
  329. QDF_STATUS dp_umac_reset_notify_action_completion(
  330. struct dp_soc *soc,
  331. enum umac_reset_action action)
  332. {
  333. return QDF_STATUS_SUCCESS;
  334. }
  335. static inline
  336. QDF_STATUS dp_umac_reset_stats_print(struct dp_soc *soc)
  337. {
  338. return QDF_STATUS_SUCCESS;
  339. }
  340. #endif /* DP_UMAC_HW_RESET_SUPPORT */
  341. #endif /* _DP_UMAC_RESET_H_ */