os_if_qmi.h 7.6 KB

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