os_if_qmi.h 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  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. /**
  17. * DOC: os_if_qmi.h
  18. *
  19. * This file contains declarations for wrapper APIs for QMI HLOS APIs
  20. */
  21. #ifndef _OS_IF_QMI_H_
  22. #define _OS_IF_QMI_H_
  23. #include "wlan_qmi_public_struct.h"
  24. #include <qdf_types.h>
  25. #include <linux/soc/qcom/qmi.h>
  26. #include <linux/net.h>
  27. #include <linux/types.h>
  28. #include "wlan_cfg80211.h"
  29. #include "wlan_objmgr_psoc_obj.h"
  30. #include <qdf_time.h>
  31. #define QMI_WFDS_MAX_RECV_BUF_SIZE 4096
  32. #define QMI_WFDS_SERVICE_INS_ID_V01 0x0
  33. #define QMI_WFDS_TIMEOUT_MS 10000
  34. #define QMI_WFDS_TIMEOUT_JF \
  35. qdf_system_msecs_to_ticks(QMI_WFDS_TIMEOUT_MS)
  36. #ifdef QMI_COMPONENT_ENABLE
  37. /**
  38. * os_if_qmi_handle_init() - Initialize QMI handle
  39. * @qmi_hdl: QMI handle to initialize
  40. * @recv_buf_size: maximum size of incoming message
  41. * @ops: reference to callbacks for QRTR notifications
  42. * @qmi_msg_handlers: NULL-terminated list of QMI message handlers
  43. *
  44. * Returns: QDF status
  45. */
  46. QDF_STATUS
  47. os_if_qmi_handle_init(struct qmi_handle *qmi_hdl, qdf_size_t recv_buf_size,
  48. const struct qmi_ops *ops,
  49. const struct qmi_msg_handler *qmi_msg_handlers);
  50. /**
  51. * os_if_qmi_handle_release() - Release QMI handle
  52. * @qmi_hdl: QMI handle to release
  53. *
  54. * Returns: None
  55. */
  56. void os_if_qmi_handle_release(struct qmi_handle *qmi_hdl);
  57. /**
  58. * os_if_qmi_add_lookup() - Register a new lookup with the name service
  59. * @qmi_hdl: QMI handle
  60. * @service: service id of the request
  61. * @instance: instance id of the request
  62. * @version: version number of the request
  63. *
  64. * Return: QDF status
  65. */
  66. QDF_STATUS os_if_qmi_add_lookup(struct qmi_handle *qmi_hdl,
  67. unsigned int service, unsigned int version,
  68. unsigned int instance);
  69. /**
  70. * os_if_qmi_connect_to_svc() - Connect to QMI service
  71. * @qmi_hdl: QMI handle
  72. * @qmi_svc: QMI service handle
  73. *
  74. * Return: QDF status
  75. */
  76. QDF_STATUS os_if_qmi_connect_to_svc(struct qmi_handle *qmi_hdl,
  77. struct qmi_service *qmi_svc);
  78. /**
  79. * os_if_qmi_txn_init() - Initialize QMI transaction
  80. * @qmi_hdl: QMI handle
  81. * @qmi_txn: QMI transaction handle
  82. * @qmi_ei: description of how to decode a matching response (optional)
  83. * @resp: pointer to the object to decode the response into (optional)
  84. *
  85. * Return: QDF status
  86. */
  87. QDF_STATUS os_if_qmi_txn_init(struct qmi_handle *qmi_hdl,
  88. struct qmi_txn *qmi_txn,
  89. struct qmi_elem_info *qmi_ei, void *resp);
  90. /**
  91. * os_if_qmi_send_request() - Connect to QMI service
  92. * @qmi_hdl: QMI handle
  93. * @sq: destination sockaddr
  94. * @qmi_txn: QMI transaction handle
  95. * @msg_id: message id
  96. * @len: max length of the QMI message
  97. * @ei: QMI message description
  98. * @req: message to be encoded
  99. *
  100. * Return: QDF status
  101. */
  102. QDF_STATUS os_if_qmi_send_request(struct qmi_handle *qmi_hdl,
  103. struct sockaddr_qrtr *sq,
  104. struct qmi_txn *qmi_txn, int msg_id,
  105. uint32_t len, struct qmi_elem_info *ei,
  106. const void *req);
  107. /**
  108. * os_if_qmi_txn_wait() - Wait for transaction response
  109. * @qmi_txn: QMI transaction handle
  110. * @timeout: Timeout value in jiffies
  111. *
  112. * Return: QDF status
  113. */
  114. QDF_STATUS os_if_qmi_txn_wait(struct qmi_txn *qmi_txn, unsigned long timeout);
  115. /**
  116. * os_if_qmi_txn_cancel() - Cancel the QMI transaction
  117. * @qmi_txn: QMI transaction handle
  118. *
  119. * Return: None
  120. */
  121. void os_if_qmi_txn_cancel(struct qmi_txn *qmi_txn);
  122. /**
  123. * os_if_qmi_register_callbacks() - Register callback handlers
  124. * @psoc: Pointer to psoc context
  125. * @cb_obj: Callback object pointer
  126. *
  127. * Return: None
  128. */
  129. void os_if_qmi_register_callbacks(struct wlan_objmgr_psoc *psoc,
  130. struct wlan_qmi_psoc_callbacks *cb_obj);
  131. #ifdef QMI_WFDS
  132. /**
  133. * os_if_qmi_wfds_register_callbacks() - Register WFDS callback handlers
  134. * @cb_obj: Callback object pointer
  135. *
  136. * Return: None
  137. */
  138. void os_if_qmi_wfds_register_callbacks(struct wlan_qmi_psoc_callbacks *cb_obj);
  139. #else
  140. static inline
  141. void os_if_qmi_wfds_register_callbacks(struct wlan_qmi_psoc_callbacks *cb_obj)
  142. {
  143. }
  144. #endif
  145. #else
  146. static inline
  147. QDF_STATUS os_if_qmi_handle_init(struct qmi_handle *qmi_hdl,
  148. qdf_size_t recv_buf_size,
  149. const struct qmi_ops *ops,
  150. const struct qmi_msg_handler *qmi_msg_handlers)
  151. {
  152. return QDF_STATUS_E_NOSUPPORT;
  153. }
  154. static inline
  155. void os_if_qmi_handle_release(struct qmi_handle *qmi_hdl)
  156. {
  157. }
  158. static inline
  159. QDF_STATUS os_if_qmi_add_lookup(struct qmi_handle *qmi_hdl,
  160. unsigned int service, unsigned int version,
  161. unsigned int instance)
  162. {
  163. return QDF_STATUS_E_NOSUPPORT;
  164. }
  165. static inline
  166. QDF_STATUS os_if_qmi_connect_to_svc(struct qmi_handle *qmi_hdl,
  167. struct qmi_service *qmi_svc)
  168. {
  169. return QDF_STATUS_E_NOSUPPORT;
  170. }
  171. static inline
  172. QDF_STATUS os_if_qmi_txn_init(struct qmi_handle *qmi_hdl,
  173. struct qmi_txn *qmi_txn,
  174. struct qmi_elem_info *qmi_ei, void *resp)
  175. {
  176. return QDF_STATUS_E_NOSUPPORT;
  177. }
  178. static inline
  179. QDF_STATUS os_if_qmi_send_request(struct qmi_handle *qmi_hdl,
  180. struct sockaddr_qrtr *sq,
  181. struct qmi_txn *qmi_txn, int msg_id,
  182. uint32_t len, struct qmi_elem_info *ei,
  183. const void *req)
  184. {
  185. return QDF_STATUS_E_NOSUPPORT;
  186. }
  187. static inline
  188. QDF_STATUS os_if_qmi_txn_wait(struct qmi_txn *qmi_txn, unsigned long timeout)
  189. {
  190. return QDF_STATUS_E_NOSUPPORT;
  191. }
  192. static inline
  193. void os_if_qmi_txn_cancel(struct qmi_txn *qmi_txn)
  194. {
  195. }
  196. static inline
  197. void os_if_qmi_register_callbacks(struct wlan_objmgr_psoc *psoc,
  198. struct wlan_qmi_psoc_callbacks *cb_obj)
  199. {
  200. }
  201. #endif
  202. #endif