dp_umac_reset.h 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263
  1. /*
  2. * Copyright (c) 2022 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. /**
  21. * enum umac_reset_action - Actions supported by the UMAC reset
  22. * @UMAC_RESET_ACTION_DO_PRE_RESET: DO_PRE_RESET
  23. * @UMAC_RESET_ACTION_DO_POST_RESET_START: DO_POST_RESET_START
  24. * @UMAC_RESET_ACTION_DO_POST_RESET_COMPLETE: DO_POST_RESET_COMPLETE
  25. * @UMAC_RESET_ACTION_MAX: Maximum actions
  26. */
  27. enum umac_reset_action {
  28. UMAC_RESET_ACTION_DO_PRE_RESET = 0,
  29. UMAC_RESET_ACTION_DO_POST_RESET_START = 1,
  30. UMAC_RESET_ACTION_DO_POST_RESET_COMPLETE = 2,
  31. UMAC_RESET_ACTION_MAX
  32. };
  33. #ifdef DP_UMAC_HW_RESET_SUPPORT
  34. #define dp_umac_reset_alert(params...) \
  35. QDF_TRACE_FATAL(QDF_MODULE_ID_DP_UMAC_RESET, params)
  36. #define dp_umac_reset_err(params...) \
  37. QDF_TRACE_ERROR(QDF_MODULE_ID_DP_UMAC_RESET, params)
  38. #define dp_umac_reset_warn(params...) \
  39. QDF_TRACE_WARN(QDF_MODULE_ID_DP_UMAC_RESET, params)
  40. #define dp_umac_reset_notice(params...) \
  41. QDF_TRACE_INFO(QDF_MODULE_ID_DP_UMAC_RESET, params)
  42. #define dp_umac_reset_info(params...) \
  43. QDF_TRACE_INFO(QDF_MODULE_ID_DP_UMAC_RESET, params)
  44. #define dp_umac_reset_debug(params...) \
  45. QDF_TRACE_DEBUG(QDF_MODULE_ID_DP_UMAC_RESET, params)
  46. #define DP_UMAC_RESET_SHMEM_ALIGN 8
  47. #define DP_UMAC_RESET_SHMEM_MAGIC_NUM (0xDEADBEEF)
  48. /**
  49. * enum umac_reset_state - States required by the UMAC reset state machine
  50. * @UMAC_RESET_STATE_WAIT_FOR_DO_PRE_RESET: Waiting for the DO_PRE_RESET event
  51. * @UMAC_RESET_STATE_DO_PRE_RESET_RECEIVED: Received the DO_PRE_RESET event
  52. * @UMAC_RESET_STATE_HOST_PRE_RESET_DONE: Host has completed handling the
  53. * PRE_RESET event
  54. * @UMAC_RESET_STATE_WAIT_FOR_DO_POST_RESET_START: Waiting for the
  55. * DO_POST_RESET_START event
  56. * @UMAC_RESET_STATE_DO_POST_RESET_START_RECEIVED: Received the
  57. * DO_POST_RESET_START event
  58. * @UMAC_RESET_STATE_HOST_POST_RESET_START_DONE: Host has completed handling the
  59. * POST_RESET_START event
  60. * @UMAC_RESET_STATE_WAIT_FOR_DO_POST_RESET_COMPLETE: Waiting for the
  61. * DO_POST_RESET_COMPLETE event
  62. * @UMAC_RESET_STATE_DO_POST_RESET_COMPLETE_RECEIVED: Received the
  63. * DO_POST_RESET_COMPLETE event
  64. * @UMAC_RESET_STATE_HOST_POST_RESET_COMPLETE_DONE: Host has completed handling
  65. * the DO_POST_RESET_COMPLETE event
  66. */
  67. enum umac_reset_state {
  68. UMAC_RESET_STATE_WAIT_FOR_DO_PRE_RESET = 0,
  69. UMAC_RESET_STATE_DO_PRE_RESET_RECEIVED,
  70. UMAC_RESET_STATE_HOST_PRE_RESET_DONE,
  71. UMAC_RESET_STATE_WAIT_FOR_DO_POST_RESET_START,
  72. UMAC_RESET_STATE_DO_POST_RESET_START_RECEIVED,
  73. UMAC_RESET_STATE_HOST_POST_RESET_START_DONE,
  74. UMAC_RESET_STATE_WAIT_FOR_DO_POST_RESET_COMPLETE,
  75. UMAC_RESET_STATE_DO_POST_RESET_COMPLETE_RECEIVED,
  76. UMAC_RESET_STATE_HOST_POST_RESET_COMPLETE_DONE,
  77. };
  78. /**
  79. * enum umac_reset_rx_event - Rx events deduced by the UMAC reset
  80. * @UMAC_RESET_RX_EVENT_NONE: No event
  81. * @UMAC_RESET_RX_EVENT_DO_PRE_RESET: DO_PRE_RESET event
  82. * @UMAC_RESET_RX_EVENT_DO_POST_RESET_START: DO_POST_RESET_START event
  83. * @UMAC_RESET_RX_EVENT_DO_POST_RESET_COMPELTE: DO_POST_RESET_COMPELTE event
  84. * @UMAC_RESET_RX_EVENT_ERROR: Error while processing the Rx event
  85. */
  86. enum umac_reset_rx_event {
  87. UMAC_RESET_RX_EVENT_NONE = 0x0,
  88. UMAC_RESET_RX_EVENT_DO_PRE_RESET = 0x1,
  89. UMAC_RESET_RX_EVENT_DO_POST_RESET_START = 0x2,
  90. UMAC_RESET_RX_EVENT_DO_POST_RESET_COMPELTE = 0x4,
  91. UMAC_RESET_RX_EVENT_ERROR = 0xFFFFFFFF,
  92. };
  93. /**
  94. * enum umac_reset_tx_cmd: UMAC reset Tx command
  95. * @UMAC_RESET_TX_CMD_PRE_RESET_DONE: PRE_RESET_DONE
  96. * @UMAC_RESET_TX_CMD_POST_RESET_START_DONE: POST_RESET_START_DONE
  97. * @UMAC_RESET_TX_CMD_POST_RESET_COMPLETE_DONE: POST_RESET_COMPLETE_DONE
  98. */
  99. enum umac_reset_tx_cmd {
  100. UMAC_RESET_TX_CMD_PRE_RESET_DONE,
  101. UMAC_RESET_TX_CMD_POST_RESET_START_DONE,
  102. UMAC_RESET_TX_CMD_POST_RESET_COMPLETE_DONE,
  103. };
  104. /**
  105. * struct umac_reset_rx_actions - callbacks for handling UMAC reset actions
  106. * @cb: Array of pointers where each pointer contains callback for each UMAC
  107. * reset action for that index
  108. */
  109. struct umac_reset_rx_actions {
  110. QDF_STATUS (*cb[UMAC_RESET_ACTION_MAX])(struct dp_soc *soc);
  111. };
  112. /**
  113. * struct reset_ts - timestamps of for umac reset events for debug
  114. * @pre_reset_start: Umac prereset start event timestamp
  115. * @pre_reset_done: Umac prereset done timestamp
  116. * @post_reset_start: Umac postreset start event timestamp
  117. * @post_reset_done: Umac postreset done timestamp
  118. * @post_reset_complete_start: Umac postreset complete event timestamp
  119. * @post_reset_complete_done: Umac postreset complete done timestamp
  120. */
  121. struct reset_ts {
  122. uint64_t pre_reset_start;
  123. uint64_t pre_reset_done;
  124. uint64_t post_reset_start;
  125. uint64_t post_reset_done;
  126. uint64_t post_reset_complete_start;
  127. uint64_t post_reset_complete_done;
  128. };
  129. /**
  130. * struct dp_soc_umac_reset_ctx - UMAC reset context at soc level
  131. * @shmem_paddr_unaligned: Physical address of the shared memory (unaligned)
  132. * @shmem_vaddr_unaligned: Virtual address of the shared memory (unaligned)
  133. * @shmem_paddr_aligned: Physical address of the shared memory (aligned)
  134. * @shmem_vaddr_aligned: Virtual address of the shared memory (aligned)
  135. * @shmem_size: Size of the shared memory
  136. * @intr_offset: Offset of the UMAC reset interrupt w.r.t DP base interrupt
  137. * @current_state: current state of the UMAC reset state machine
  138. * @shmem_exp_magic_num: Expected magic number in the shared memory
  139. * @rx_actions: callbacks for handling UMAC reset actions
  140. * @intr_ctx_bkp: DP Interrupts ring masks backup
  141. * @nbuf_list: skb list for delayed free
  142. * @skel_enable: Enable skeleton code for umac reset
  143. * @ts: timestamps debug
  144. */
  145. struct dp_soc_umac_reset_ctx {
  146. qdf_dma_addr_t shmem_paddr_unaligned;
  147. void *shmem_vaddr_unaligned;
  148. qdf_dma_addr_t shmem_paddr_aligned;
  149. htt_umac_hang_recovery_msg_shmem_t *shmem_vaddr_aligned;
  150. size_t shmem_size;
  151. int intr_offset;
  152. enum umac_reset_state current_state;
  153. uint32_t shmem_exp_magic_num;
  154. struct umac_reset_rx_actions rx_actions;
  155. struct dp_intr_bkp *intr_ctx_bkp;
  156. qdf_nbuf_t nbuf_list;
  157. bool skel_enable;
  158. struct reset_ts ts;
  159. };
  160. /**
  161. * dp_soc_umac_reset_init() - Initialize UMAC reset context
  162. * @soc: DP soc object
  163. *
  164. * Return: QDF status of operation
  165. */
  166. QDF_STATUS dp_soc_umac_reset_init(struct dp_soc *soc);
  167. /**
  168. * dp_soc_umac_reset_deinit() - De-initialize UMAC reset context
  169. * @txrx_soc: DP soc object
  170. *
  171. * Return: QDF status of operation
  172. */
  173. QDF_STATUS dp_soc_umac_reset_deinit(struct cdp_soc_t *txrx_soc);
  174. /**
  175. * dp_umac_reset_interrupt_attach() - Register handlers for UMAC reset interrupt
  176. * @soc: DP soc object
  177. *
  178. * Return: QDF status of operation
  179. */
  180. QDF_STATUS dp_umac_reset_interrupt_attach(struct dp_soc *soc);
  181. /**
  182. * dp_umac_reset_interrupt_detach() - Unregister UMAC reset interrupt handlers
  183. * @soc: DP soc object
  184. *
  185. * Return: QDF status of operation
  186. */
  187. QDF_STATUS dp_umac_reset_interrupt_detach(struct dp_soc *soc);
  188. /**
  189. * dp_umac_reset_register_rx_action_callback() - Register a callback for a given
  190. * UMAC reset action
  191. * @soc: DP soc object
  192. * @handler: callback handler to be registered
  193. * @action: UMAC reset action for which @handler needs to be registered
  194. *
  195. * Return: QDF status of operation
  196. */
  197. QDF_STATUS dp_umac_reset_register_rx_action_callback(
  198. struct dp_soc *soc,
  199. QDF_STATUS (*handler)(struct dp_soc *soc),
  200. enum umac_reset_action action);
  201. /**
  202. * dp_umac_reset_notify_action_completion() - Notify that a given action has
  203. * been completed
  204. * @soc: DP soc object
  205. * @action: UMAC reset action that got completed
  206. *
  207. * Return: QDF status of operation
  208. */
  209. QDF_STATUS dp_umac_reset_notify_action_completion(
  210. struct dp_soc *soc,
  211. enum umac_reset_action action);
  212. #else
  213. static inline
  214. QDF_STATUS dp_soc_umac_reset_init(struct dp_soc *soc)
  215. {
  216. return QDF_STATUS_SUCCESS;
  217. }
  218. static inline
  219. QDF_STATUS dp_soc_umac_reset_deinit(struct cdp_soc_t *txrx_soc)
  220. {
  221. return QDF_STATUS_SUCCESS;
  222. }
  223. static inline
  224. QDF_STATUS dp_umac_reset_register_rx_action_callback(
  225. struct dp_soc *soc,
  226. QDF_STATUS (*handler)(struct dp_soc *soc),
  227. enum umac_reset_action action)
  228. {
  229. return QDF_STATUS_SUCCESS;
  230. }
  231. static inline
  232. QDF_STATUS dp_umac_reset_notify_action_completion(
  233. struct dp_soc *soc,
  234. enum umac_reset_action action)
  235. {
  236. return QDF_STATUS_SUCCESS;
  237. }
  238. #endif /* DP_UMAC_HW_RESET_SUPPORT */
  239. #endif /* _DP_UMAC_RESET_H_ */