os_if_qmi.h 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273
  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. /**
  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. /**
  37. * enum os_if_qmi_wfds_ut_cmd_type - WFDS unit test command type
  38. * @WFDS_STOP_TRAFFIC: Stop WFDS traffic
  39. * @WFDS_START_TRAFFIC: Start WFDS Traffic
  40. * @WFDS_GET_STATS: Get WFDS traffic stats
  41. */
  42. enum os_if_qmi_wfds_ut_cmd_type {
  43. WFDS_STOP_TRAFFIC,
  44. WFDS_START_TRAFFIC,
  45. WFDS_GET_STATS
  46. };
  47. /**
  48. * struct os_if_qmi_wfds_ut_cmd_info - WFDS UT cmd info structure
  49. * @cmd: Command type
  50. * @duration: Traffic duration
  51. * @num_pkts: Buffers per flush
  52. * @flush_period: Buffer flushing periodicity
  53. * @buf_size: Buffer size
  54. * @ether_type: ether_type of packet
  55. * @dest_mac: Destination MAC address
  56. * @src_mac: Source MAC address
  57. */
  58. struct os_if_qmi_wfds_ut_cmd_info {
  59. enum os_if_qmi_wfds_ut_cmd_type cmd;
  60. uint32_t duration;
  61. uint32_t flush_period;
  62. uint32_t num_pkts;
  63. uint32_t buf_size;
  64. uint16_t ether_type;
  65. struct qdf_mac_addr src_mac;
  66. struct qdf_mac_addr dest_mac;
  67. };
  68. #ifdef QMI_COMPONENT_ENABLE
  69. /**
  70. * os_if_qmi_handle_init() - Initialize QMI handle
  71. * @qmi_hdl: QMI handle to initialize
  72. * @recv_buf_size: maximum size of incoming message
  73. * @ops: reference to callbacks for QRTR notifications
  74. * @qmi_msg_handlers: NULL-terminated list of QMI message handlers
  75. *
  76. * Returns: QDF status
  77. */
  78. QDF_STATUS
  79. os_if_qmi_handle_init(struct qmi_handle *qmi_hdl, qdf_size_t recv_buf_size,
  80. const struct qmi_ops *ops,
  81. const struct qmi_msg_handler *qmi_msg_handlers);
  82. /**
  83. * os_if_qmi_handle_release() - Release QMI handle
  84. * @qmi_hdl: QMI handle to release
  85. *
  86. * Returns: None
  87. */
  88. void os_if_qmi_handle_release(struct qmi_handle *qmi_hdl);
  89. /**
  90. * os_if_qmi_add_lookup() - Register a new lookup with the name service
  91. * @qmi_hdl: QMI handle
  92. * @service: service id of the request
  93. * @instance: instance id of the request
  94. * @version: version number of the request
  95. *
  96. * Return: QDF status
  97. */
  98. QDF_STATUS os_if_qmi_add_lookup(struct qmi_handle *qmi_hdl,
  99. unsigned int service, unsigned int version,
  100. unsigned int instance);
  101. /**
  102. * os_if_qmi_connect_to_svc() - Connect to QMI service
  103. * @qmi_hdl: QMI handle
  104. * @qmi_svc: QMI service handle
  105. *
  106. * Return: QDF status
  107. */
  108. QDF_STATUS os_if_qmi_connect_to_svc(struct qmi_handle *qmi_hdl,
  109. struct qmi_service *qmi_svc);
  110. /**
  111. * os_if_qmi_txn_init() - Initialize QMI transaction
  112. * @qmi_hdl: QMI handle
  113. * @qmi_txn: QMI transaction handle
  114. * @qmi_ei: description of how to decode a matching response (optional)
  115. * @resp: pointer to the object to decode the response into (optional)
  116. *
  117. * Return: QDF status
  118. */
  119. QDF_STATUS os_if_qmi_txn_init(struct qmi_handle *qmi_hdl,
  120. struct qmi_txn *qmi_txn,
  121. struct qmi_elem_info *qmi_ei, void *resp);
  122. /**
  123. * os_if_qmi_send_request() - Connect to QMI service
  124. * @qmi_hdl: QMI handle
  125. * @sq: destination sockaddr
  126. * @qmi_txn: QMI transaction handle
  127. * @msg_id: message id
  128. * @len: max length of the QMI message
  129. * @ei: QMI message description
  130. * @req: message to be encoded
  131. *
  132. * Return: QDF status
  133. */
  134. QDF_STATUS os_if_qmi_send_request(struct qmi_handle *qmi_hdl,
  135. struct sockaddr_qrtr *sq,
  136. struct qmi_txn *qmi_txn, int msg_id,
  137. uint32_t len, struct qmi_elem_info *ei,
  138. const void *req);
  139. /**
  140. * os_if_qmi_txn_wait() - Wait for transaction response
  141. * @qmi_txn: QMI transaction handle
  142. * @timeout: Timeout value in jiffies
  143. *
  144. * Return: QDF status
  145. */
  146. QDF_STATUS os_if_qmi_txn_wait(struct qmi_txn *qmi_txn, unsigned long timeout);
  147. /**
  148. * os_if_qmi_txn_cancel() - Cancel the QMI transaction
  149. * @qmi_txn: QMI transaction handle
  150. *
  151. * Return: None
  152. */
  153. void os_if_qmi_txn_cancel(struct qmi_txn *qmi_txn);
  154. /**
  155. * os_if_qmi_register_callbacks() - Register callback handlers
  156. * @psoc: Pointer to psoc context
  157. * @cb_obj: Callback object pointer
  158. *
  159. * Return: None
  160. */
  161. void os_if_qmi_register_callbacks(struct wlan_objmgr_psoc *psoc,
  162. struct wlan_qmi_psoc_callbacks *cb_obj);
  163. #ifdef QMI_WFDS
  164. /**
  165. * os_if_qmi_wfds_register_callbacks() - Register WFDS callback handlers
  166. * @cb_obj: Callback object pointer
  167. *
  168. * Return: None
  169. */
  170. void os_if_qmi_wfds_register_callbacks(struct wlan_qmi_psoc_callbacks *cb_obj);
  171. /**
  172. * os_if_qmi_wfds_send_ut_cmd_req_msg() - Send WFDS unit test command
  173. * @cmd_info: Unit test command info
  174. *
  175. * Return: QDF_STATUS
  176. */
  177. QDF_STATUS
  178. os_if_qmi_wfds_send_ut_cmd_req_msg(struct os_if_qmi_wfds_ut_cmd_info *cmd_info);
  179. #else
  180. static inline
  181. void os_if_qmi_wfds_register_callbacks(struct wlan_qmi_psoc_callbacks *cb_obj)
  182. {
  183. }
  184. static inline QDF_STATUS
  185. os_if_qmi_wfds_send_ut_cmd_req_msg(struct os_if_qmi_wfds_ut_cmd_info *cmd_info)
  186. {
  187. }
  188. #endif
  189. #else
  190. static inline
  191. QDF_STATUS os_if_qmi_handle_init(struct qmi_handle *qmi_hdl,
  192. qdf_size_t recv_buf_size,
  193. const struct qmi_ops *ops,
  194. const struct qmi_msg_handler *qmi_msg_handlers)
  195. {
  196. return QDF_STATUS_E_NOSUPPORT;
  197. }
  198. static inline
  199. void os_if_qmi_handle_release(struct qmi_handle *qmi_hdl)
  200. {
  201. }
  202. static inline
  203. QDF_STATUS os_if_qmi_add_lookup(struct qmi_handle *qmi_hdl,
  204. unsigned int service, unsigned int version,
  205. unsigned int instance)
  206. {
  207. return QDF_STATUS_E_NOSUPPORT;
  208. }
  209. static inline
  210. QDF_STATUS os_if_qmi_connect_to_svc(struct qmi_handle *qmi_hdl,
  211. struct qmi_service *qmi_svc)
  212. {
  213. return QDF_STATUS_E_NOSUPPORT;
  214. }
  215. static inline
  216. QDF_STATUS os_if_qmi_txn_init(struct qmi_handle *qmi_hdl,
  217. struct qmi_txn *qmi_txn,
  218. struct qmi_elem_info *qmi_ei, void *resp)
  219. {
  220. return QDF_STATUS_E_NOSUPPORT;
  221. }
  222. static inline
  223. QDF_STATUS os_if_qmi_send_request(struct qmi_handle *qmi_hdl,
  224. struct sockaddr_qrtr *sq,
  225. struct qmi_txn *qmi_txn, int msg_id,
  226. uint32_t len, struct qmi_elem_info *ei,
  227. const void *req)
  228. {
  229. return QDF_STATUS_E_NOSUPPORT;
  230. }
  231. static inline
  232. QDF_STATUS os_if_qmi_txn_wait(struct qmi_txn *qmi_txn, unsigned long timeout)
  233. {
  234. return QDF_STATUS_E_NOSUPPORT;
  235. }
  236. static inline
  237. void os_if_qmi_txn_cancel(struct qmi_txn *qmi_txn)
  238. {
  239. }
  240. static inline
  241. void os_if_qmi_register_callbacks(struct wlan_objmgr_psoc *psoc,
  242. struct wlan_qmi_psoc_callbacks *cb_obj)
  243. {
  244. }
  245. #endif
  246. #endif