dp_umac_reset.h 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  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. /**
  48. * enum umac_reset_state - States required by the UMAC reset state machine
  49. * @UMAC_RESET_STATE_WAIT_FOR_DO_PRE_RESET: Waiting for the DO_PRE_RESET event
  50. * @UMAC_RESET_STATE_DO_PRE_RESET_RECEIVED: Received the DO_PRE_RESET event
  51. * @UMAC_RESET_STATE_HOST_PRE_RESET_DONE: Host has completed handling the
  52. * PRE_RESET event
  53. * @UMAC_RESET_STATE_WAIT_FOR_DO_POST_RESET_START: Waiting for the
  54. * DO_POST_RESET_START event
  55. * @UMAC_RESET_STATE_DO_POST_RESET_START_RECEIVED: Received the
  56. * DO_POST_RESET_START event
  57. * @UMAC_RESET_STATE_HOST_POST_RESET_START_DONE: Host has completed handling the
  58. * POST_RESET_START event
  59. * @UMAC_RESET_STATE_WAIT_FOR_DO_POST_RESET_COMPLETE: Waiting for the
  60. * DO_POST_RESET_COMPLETE event
  61. * @UMAC_RESET_STATE_DO_POST_RESET_COMPLETE_RECEIVED: Received the
  62. * DO_POST_RESET_COMPLETE event
  63. * @UMAC_RESET_STATE_HOST_POST_RESET_COMPLETE_DONE: Host has completed handling
  64. * the DO_POST_RESET_COMPLETE event
  65. */
  66. enum umac_reset_state {
  67. UMAC_RESET_STATE_WAIT_FOR_DO_PRE_RESET = 0,
  68. UMAC_RESET_STATE_DO_PRE_RESET_RECEIVED,
  69. UMAC_RESET_STATE_HOST_PRE_RESET_DONE,
  70. UMAC_RESET_STATE_WAIT_FOR_DO_POST_RESET_START,
  71. UMAC_RESET_STATE_DO_POST_RESET_START_RECEIVED,
  72. UMAC_RESET_STATE_HOST_POST_RESET_START_DONE,
  73. UMAC_RESET_STATE_WAIT_FOR_DO_POST_RESET_COMPLETE,
  74. UMAC_RESET_STATE_DO_POST_RESET_COMPLETE_RECEIVED,
  75. UMAC_RESET_STATE_HOST_POST_RESET_COMPLETE_DONE,
  76. };
  77. /**
  78. * enum umac_reset_rx_event - Rx events deduced by the UMAC reset
  79. * @UMAC_RESET_RX_EVENT_NONE: No event
  80. * @UMAC_RESET_RX_EVENT_DO_PRE_RESET: DO_PRE_RESET event
  81. * @UMAC_RESET_RX_EVENT_DO_POST_RESET_START: DO_POST_RESET_START event
  82. * @UMAC_RESET_RX_EVENT_DO_POST_RESET_COMPELTE: DO_POST_RESET_COMPELTE event
  83. * @UMAC_RESET_RX_EVENT_ERROR: Error while processing the Rx event
  84. */
  85. enum umac_reset_rx_event {
  86. UMAC_RESET_RX_EVENT_NONE = 0x0,
  87. UMAC_RESET_RX_EVENT_DO_PRE_RESET = 0x1,
  88. UMAC_RESET_RX_EVENT_DO_POST_RESET_START = 0x2,
  89. UMAC_RESET_RX_EVENT_DO_POST_RESET_COMPELTE = 0x4,
  90. UMAC_RESET_RX_EVENT_ERROR = 0xFFFFFFFF,
  91. };
  92. /**
  93. * enum umac_reset_tx_cmd: UMAC reset Tx command
  94. * @UMAC_RESET_TX_CMD_PRE_RESET_DONE: PRE_RESET_DONE
  95. * @UMAC_RESET_TX_CMD_POST_RESET_START_DONE: POST_RESET_START_DONE
  96. * @UMAC_RESET_TX_CMD_POST_RESET_COMPLETE_DONE: POST_RESET_COMPLETE_DONE
  97. */
  98. enum umac_reset_tx_cmd {
  99. UMAC_RESET_TX_CMD_PRE_RESET_DONE,
  100. UMAC_RESET_TX_CMD_POST_RESET_START_DONE,
  101. UMAC_RESET_TX_CMD_POST_RESET_COMPLETE_DONE,
  102. };
  103. /**
  104. * struct umac_reset_rx_actions - callbacks for handling UMAC reset actions
  105. * @cb: Array of pointers where each pointer contains callback for each UMAC
  106. * reset action for that index
  107. */
  108. struct umac_reset_rx_actions {
  109. QDF_STATUS (*cb[UMAC_RESET_ACTION_MAX])(struct dp_soc *soc);
  110. };
  111. /**
  112. * struct dp_soc_umac_reset_ctx - UMAC reset context at soc level
  113. * @shmem_paddr_unaligned: Physical address of the shared memory (unaligned)
  114. * @shmem_vaddr_unaligned: Virtual address of the shared memory (unaligned)
  115. * @shmem_paddr_aligned: Physical address of the shared memory (aligned)
  116. * @shmem_vaddr_aligned: Virtual address of the shared memory (aligned)
  117. * @intr_offset: Offset of the UMAC reset interrupt w.r.t DP base interrupt
  118. * @current_state: current state of the UMAC reset state machine
  119. * @supported: Whether UMAC reset is supported on this soc
  120. * @shmem_exp_magic_num: Expected magic number in the shared memory
  121. * @rx_actions: callbacks for handling UMAC reset actions
  122. */
  123. struct dp_soc_umac_reset_ctx {
  124. qdf_dma_addr_t shmem_paddr_unaligned;
  125. void *shmem_vaddr_unaligned;
  126. qdf_dma_addr_t shmem_paddr_aligned;
  127. htt_umac_hang_recovery_msg_shmem_t *shmem_vaddr_aligned;
  128. int intr_offset;
  129. enum umac_reset_state current_state;
  130. bool supported;
  131. uint32_t shmem_exp_magic_num;
  132. struct umac_reset_rx_actions rx_actions;
  133. };
  134. /**
  135. * dp_soc_umac_reset_init() - Initialize UMAC reset context
  136. * @soc: DP soc object
  137. *
  138. * Return: QDF status of operation
  139. */
  140. QDF_STATUS dp_soc_umac_reset_init(struct dp_soc *soc);
  141. /**
  142. * dp_umac_reset_interrupt_attach() - Register handlers for UMAC reset interrupt
  143. * @soc: DP soc object
  144. *
  145. * Return: QDF status of operation
  146. */
  147. QDF_STATUS dp_umac_reset_interrupt_attach(struct dp_soc *soc);
  148. /**
  149. * dp_umac_reset_interrupt_detach() - Unregister UMAC reset interrupt handlers
  150. * @soc: DP soc object
  151. *
  152. * Return: QDF status of operation
  153. */
  154. QDF_STATUS dp_umac_reset_interrupt_detach(struct dp_soc *soc);
  155. /**
  156. * dp_umac_reset_register_rx_action_callback() - Register a callback for a given
  157. * UMAC reset action
  158. * @soc: DP soc object
  159. * @handler: callback handler to be registered
  160. * @action: UMAC reset action for which @handler needs to be registered
  161. *
  162. * Return: QDF status of operation
  163. */
  164. QDF_STATUS dp_umac_reset_register_rx_action_callback(
  165. struct dp_soc *soc,
  166. QDF_STATUS (*handler)(struct dp_soc *soc),
  167. enum umac_reset_action action);
  168. /**
  169. * dp_umac_reset_notify_action_completion() - Notify that a given action has
  170. * been completed
  171. * @soc: DP soc object
  172. * @action: UMAC reset action that got completed
  173. *
  174. * Return: QDF status of operation
  175. */
  176. QDF_STATUS dp_umac_reset_notify_action_completion(
  177. struct dp_soc *soc,
  178. enum umac_reset_action action);
  179. #else
  180. static inline
  181. QDF_STATUS dp_soc_umac_reset_init(struct dp_soc *soc)
  182. {
  183. return QDF_STATUS_SUCCESS;
  184. }
  185. static inline
  186. QDF_STATUS dp_umac_reset_register_rx_action_callback(
  187. struct dp_soc *soc,
  188. QDF_STATUS (*handler)(struct dp_soc *soc),
  189. enum umac_reset_action action)
  190. {
  191. return QDF_STATUS_SUCCESS;
  192. }
  193. static inline
  194. QDF_STATUS dp_umac_reset_notify_action_completion(
  195. struct dp_soc *soc,
  196. enum umac_reset_action action)
  197. {
  198. return QDF_STATUS_SUCCESS;
  199. }
  200. #endif /* DP_UMAC_HW_RESET_SUPPORT */
  201. #endif /* _DP_UMAC_RESET_H_ */