wmi_unified_api.h 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  1. /*
  2. * Copyright (c) 2013-2016 The Linux Foundation. All rights reserved.
  3. *
  4. * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
  5. *
  6. *
  7. * Permission to use, copy, modify, and/or distribute this software for
  8. * any purpose with or without fee is hereby granted, provided that the
  9. * above copyright notice and this permission notice appear in all
  10. * copies.
  11. *
  12. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
  13. * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
  14. * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
  15. * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
  16. * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
  17. * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  18. * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  19. * PERFORMANCE OF THIS SOFTWARE.
  20. */
  21. /*
  22. * This file was originally distributed by Qualcomm Atheros, Inc.
  23. * under proprietary terms before Copyright ownership was assigned
  24. * to the Linux Foundation.
  25. */
  26. /*
  27. * This file contains the API definitions for the Unified Wireless Module
  28. * Interface (WMI).
  29. */
  30. #ifndef _WMI_UNIFIED_API_H_
  31. #define _WMI_UNIFIED_API_H_
  32. #include <osdep.h>
  33. #include "a_types.h"
  34. #include "ol_defines.h"
  35. #include "wmi.h"
  36. #include "htc_api.h"
  37. typedef cdf_nbuf_t wmi_buf_t;
  38. #define wmi_buf_data(_buf) cdf_nbuf_data(_buf)
  39. /**
  40. * struct wmi_ops - service callbacks to upper layer
  41. * @service_ready_cbk: service ready callback
  42. * @service_ready_ext_cbk: service ready ext callback
  43. * @ready_cbk: ready calback
  44. * @wma_process_fw_event_handler_cbk: generic event handler callback
  45. */
  46. struct wmi_ops {
  47. void (*service_ready_cbk)(void *ctx, void *ev);
  48. void (*service_ready_ext_cbk)(void *ctx, void *ev);
  49. void (*ready_cbk)(void *ctx, void *ev);
  50. int (*wma_process_fw_event_handler_cbk)(void *ctx,
  51. void *ev);
  52. };
  53. /**
  54. * enum wmi_target_type - type of supported wmi command
  55. * @WMI_TLV_TARGET: tlv based target
  56. * @WMI_NON_TLV_TARGET: non-tlv based target
  57. *
  58. */
  59. enum wmi_target_type {
  60. WMI_TLV_TARGET,
  61. WMI_NON_TLV_TARGET
  62. };
  63. /**
  64. * attach for unified WMI
  65. *
  66. * @param scn_handle : handle to SCN.
  67. * @return opaque handle.
  68. */
  69. void *wmi_unified_attach(void *scn_handle,
  70. osdev_t osdev, enum wmi_target_type target_type,
  71. bool use_cookie, struct wmi_ops *ops);
  72. /**
  73. * detach for unified WMI
  74. *
  75. * @param wmi_handle : handle to WMI.
  76. * @return void.
  77. */
  78. void wmi_unified_detach(struct wmi_unified *wmi_handle);
  79. void
  80. wmi_unified_remove_work(struct wmi_unified *wmi_handle);
  81. /**
  82. * generic function to allocate WMI buffer
  83. *
  84. * @param wmi_handle : handle to WMI.
  85. * @param len : length of the buffer
  86. * @return wmi_buf_t.
  87. */
  88. #ifdef MEMORY_DEBUG
  89. #define wmi_buf_alloc(h, l) wmi_buf_alloc_debug(h, l, __FILE__, __LINE__)
  90. wmi_buf_t
  91. wmi_buf_alloc_debug(wmi_unified_t wmi_handle, uint16_t len,
  92. uint8_t *file_name, uint32_t line_num);
  93. #else
  94. wmi_buf_t wmi_buf_alloc(wmi_unified_t wmi_handle, uint16_t len);
  95. #endif
  96. /**
  97. * generic function frees WMI net buffer
  98. *
  99. * @param net_buf : Pointer ot net_buf to be freed
  100. */
  101. void wmi_buf_free(wmi_buf_t net_buf);
  102. /**
  103. * generic function to send unified WMI command
  104. *
  105. * @param wmi_handle : handle to WMI.
  106. * @param buf : wmi command buffer
  107. * @param buflen : wmi command buffer length
  108. * @return 0 on success and -ve on failure.
  109. */
  110. int
  111. wmi_unified_cmd_send(wmi_unified_t wmi_handle, wmi_buf_t buf, uint32_t buflen,
  112. WMI_CMD_ID cmd_id);
  113. /**
  114. * WMI event handler register function
  115. *
  116. * @param wmi_handle : handle to WMI.
  117. * @param event_id : WMI event ID
  118. * @param handler_func : Event handler call back function
  119. * @return 0 on success and -ve on failure.
  120. */
  121. int
  122. wmi_unified_register_event_handler(wmi_unified_t wmi_handle,
  123. WMI_EVT_ID event_id,
  124. wmi_unified_event_handler handler_func);
  125. /**
  126. * WMI event handler unregister function
  127. *
  128. * @param wmi_handle : handle to WMI.
  129. * @param event_id : WMI event ID
  130. * @return 0 on success and -ve on failure.
  131. */
  132. int
  133. wmi_unified_unregister_event_handler(wmi_unified_t wmi_handle,
  134. WMI_EVT_ID event_id);
  135. /**
  136. * request wmi to connet its htc service.
  137. * @param wmi_handle : handle to WMI.
  138. * @return void
  139. */
  140. int
  141. wmi_unified_connect_htc_service(struct wmi_unified *wmi_handle,
  142. void *htc_handle);
  143. /*
  144. * WMI API to verify the host has enough credits to suspend
  145. */
  146. int wmi_is_suspend_ready(wmi_unified_t wmi_handle);
  147. /**
  148. WMI API to get updated host_credits
  149. */
  150. int wmi_get_host_credits(wmi_unified_t wmi_handle);
  151. /**
  152. WMI API to get WMI Pending Commands in the HTC queue
  153. */
  154. int wmi_get_pending_cmds(wmi_unified_t wmi_handle);
  155. /**
  156. WMI API to set target suspend state
  157. */
  158. void wmi_set_target_suspend(wmi_unified_t wmi_handle, bool val);
  159. #ifdef FEATURE_RUNTIME_PM
  160. void
  161. wmi_set_runtime_pm_inprogress(wmi_unified_t wmi_handle, bool val);
  162. bool wmi_get_runtime_pm_inprogress(wmi_unified_t wmi_handle);
  163. #else
  164. static inline void
  165. wmi_set_runtime_pm_inprogress(wmi_unified_t wmi_handle, bool val)
  166. {
  167. return;
  168. }
  169. static inline bool wmi_get_runtime_pm_inprogress(wmi_unified_t wmi_handle)
  170. {
  171. return false;
  172. }
  173. #endif
  174. /**
  175. * WMA Callback to process fw event.
  176. */
  177. void wmi_process_fw_event(struct wmi_unified *wmi_handle, wmi_buf_t evt_buf);
  178. uint16_t wmi_get_max_msg_len(wmi_unified_t wmi_handle);
  179. #endif /* _WMI_UNIFIED_API_H_ */