qdf_platform.h 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429
  1. /*
  2. * Copyright (c) 2018-2021 The Linux Foundation. All rights reserved.
  3. * Copyright (c) 2023-2024 Qualcomm Innovation Center, Inc. All rights reserved.
  4. *
  5. * Permission to use, copy, modify, and/or distribute this software for
  6. * any purpose with or without fee is hereby granted, provided that the
  7. * above copyright notice and this permission notice appear in all
  8. * copies.
  9. *
  10. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
  11. * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
  12. * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
  13. * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
  14. * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
  15. * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  16. * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  17. * PERFORMANCE OF THIS SOFTWARE.
  18. */
  19. /**
  20. * DOC: qdf_platform.h
  21. * This file defines platform API abstractions.
  22. */
  23. #ifndef _QDF_PLATFORM_H
  24. #define _QDF_PLATFORM_H
  25. #include "qdf_types.h"
  26. /**
  27. * typedef qdf_self_recovery_callback() - callback for self recovery
  28. * @psoc: pointer to the posc object
  29. * @reason: the reason for the recovery request
  30. * @func: the caller's function name
  31. * @line: the line number of the callsite
  32. *
  33. * Return: none
  34. */
  35. typedef void (*qdf_self_recovery_callback)(void *psoc,
  36. enum qdf_hang_reason reason,
  37. const char *func,
  38. const uint32_t line);
  39. /**
  40. * typedef qdf_is_fw_down_callback() - callback to query if fw is down
  41. *
  42. * Return: true if fw is down and false if fw is not down
  43. */
  44. typedef bool (*qdf_is_fw_down_callback)(void);
  45. /**
  46. * qdf_register_fw_down_callback() - API to register fw down callback
  47. * @is_fw_down: callback to query if fw is down or not
  48. *
  49. * Return: none
  50. */
  51. void qdf_register_fw_down_callback(qdf_is_fw_down_callback is_fw_down);
  52. /**
  53. * qdf_is_fw_down() - API to check if fw is down or not
  54. *
  55. * Return: true: if fw is down
  56. * false: if fw is not down
  57. */
  58. bool qdf_is_fw_down(void);
  59. /**
  60. * typedef qdf_wmi_recv_qmi_cb() - callback to receive WMI over QMI
  61. * @cb_ctx: WMI event recv callback context(wmi_handle)
  62. * @buf: WMI buffer
  63. * @len: WMI buffer len
  64. *
  65. * Return: 0 if success otherwise -EINVAL
  66. */
  67. typedef int (*qdf_wmi_recv_qmi_cb)(void *cb_ctx, void *buf, int len);
  68. /**
  69. * typedef qdf_qmi_ind_cb() - callback to receive QMI Indication
  70. * @cb_ctx: QMI indication callback context
  71. * @type: Indication type
  72. * @event: Indication Event
  73. * @event_len: QMI indication event buffer len
  74. *
  75. * Return: 0 if success otherwise -EINVAL
  76. */
  77. typedef int (*qdf_qmi_ind_cb)(void *cb_ctx, uint16_t type,
  78. void *event, int event_len);
  79. /**
  80. * typedef qdf_wmi_send_over_qmi_callback() - callback to send WMI over QMI
  81. * @buf: WMI buffer
  82. * @len: WMI buffer len
  83. * @cb_ctx: WMI event recv callback context(wmi_handle)
  84. * @wmi_rx_cb: WMI event receive call back
  85. *
  86. * Return: QDF_STATUS_SUCCESS if success otherwise QDF error code
  87. */
  88. typedef QDF_STATUS (*qdf_wmi_send_over_qmi_callback)(void *buf, uint32_t len,
  89. void *cb_ctx,
  90. qdf_wmi_recv_qmi_cb
  91. wmi_rx_cb);
  92. /**
  93. * typedef qdf_send_ind_over_qmi_callback() - callback to receive QMI Indication
  94. * @cb_ctx: QMI Indication recv callback context
  95. * @qmi_ind_cb: QMI Indication receive callback
  96. *
  97. * Return: QDF_STATUS_SUCCESS if success otherwise QDF error code
  98. */
  99. typedef QDF_STATUS (*qdf_send_ind_over_qmi_callback)(void *cb_ctx,
  100. qdf_qmi_ind_cb qmi_ind_cb);
  101. /**
  102. * qdf_register_wmi_send_recv_qmi_callback() - Register WMI over QMI callback
  103. * @wmi_send_recv_qmi_cb: callback to send recv WMI data over QMI
  104. *
  105. * Return: none
  106. */
  107. void qdf_register_wmi_send_recv_qmi_callback(qdf_wmi_send_over_qmi_callback
  108. wmi_send_recv_qmi_cb);
  109. /**
  110. * qdf_register_qmi_indication_callback() - Register QMI Indication callback
  111. * @qmi_ind_cb: callback to receive QMI Indications
  112. *
  113. * Return: none
  114. */
  115. void qdf_register_qmi_indication_callback(qdf_send_ind_over_qmi_callback qmi_ind_cb);
  116. /**
  117. * qdf_wmi_send_recv_qmi() - API to send receive WMI data over QMI
  118. * @buf: WMI buffer
  119. * @len: WMI buffer len
  120. * @cb_ctx: WMI event recv callback context(wmi_handle)
  121. * @wmi_rx_cb: WMI event receive call back
  122. *
  123. * Return: QDF STATUS of operation
  124. */
  125. QDF_STATUS qdf_wmi_send_recv_qmi(void *buf, uint32_t len, void *cb_ctx,
  126. qdf_wmi_recv_qmi_cb wmi_rx_cb);
  127. /**
  128. * qdf_reg_qmi_indication() - API to receive QMI Indication data
  129. * @cb_ctx: QMI Indication recv callback context
  130. * @qmi_ind_cb: QMI Indication event receive callback
  131. *
  132. * Return: QDF STATUS of operation
  133. */
  134. QDF_STATUS qdf_reg_qmi_indication(void *cb_ctx, qdf_qmi_ind_cb qmi_ind_cb);
  135. /**
  136. * typedef qdf_is_driver_unloading_callback() - callback to get driver
  137. * unloading in progress or not
  138. *
  139. * Return: true if driver is unloading else false
  140. */
  141. typedef bool (*qdf_is_driver_unloading_callback)(void);
  142. /**
  143. * qdf_register_is_driver_unloading_callback() - driver unloading callback
  144. * @callback: driver unloading callback
  145. *
  146. * Return: None
  147. */
  148. void qdf_register_is_driver_unloading_callback(
  149. qdf_is_driver_unloading_callback callback);
  150. /**
  151. * typedef qdf_is_driver_state_module_stop_callback() - callback to get driver
  152. * state is module stop or not
  153. *
  154. * Return: true if driver state is module stop else false
  155. */
  156. typedef bool (*qdf_is_driver_state_module_stop_callback)(void);
  157. /**
  158. * qdf_register_is_driver_state_module_stop_callback() - driver state is
  159. * module stop or not
  160. * @callback: driver state module stop callback
  161. *
  162. * Return: None
  163. */
  164. void qdf_register_is_driver_state_module_stop_callback(
  165. qdf_is_driver_state_module_stop_callback callback);
  166. /**
  167. * qdf_register_self_recovery_callback() - register self recovery callback
  168. * @callback: self recovery callback
  169. *
  170. * Return: None
  171. */
  172. void qdf_register_self_recovery_callback(qdf_self_recovery_callback callback);
  173. /**
  174. * qdf_trigger_self_recovery () - trigger self recovery
  175. * @psoc: the psoc at which the recovery is being triggered
  176. * @reason: the reason for the recovery request
  177. *
  178. * Call API only in case of fatal error,
  179. * if self_recovery_cb callback is registered, injcets fw crash and recovers
  180. * else raises QDF_BUG()
  181. *
  182. * Return: None
  183. */
  184. #define qdf_trigger_self_recovery(psoc, reason) \
  185. __qdf_trigger_self_recovery(psoc, reason, __func__, __LINE__)
  186. void __qdf_trigger_self_recovery(void *psoc, enum qdf_hang_reason reason,
  187. const char *func, const uint32_t line);
  188. /**
  189. * typedef qdf_is_recovering_callback() - callback to get driver recovering in
  190. * progress or not
  191. *
  192. * Return: true if driver is doing recovering else false
  193. */
  194. typedef bool (*qdf_is_recovering_callback)(void);
  195. /**
  196. * qdf_register_recovering_state_query_callback() - register recover status
  197. * query callback
  198. * @is_recovering: true if driver is recovering
  199. *
  200. * Return: none
  201. */
  202. void qdf_register_recovering_state_query_callback(
  203. qdf_is_recovering_callback is_recovering);
  204. /**
  205. * qdf_is_driver_unloading() - get driver unloading in progress status
  206. * or not
  207. *
  208. * Return: true if driver is unloading else false
  209. */
  210. bool qdf_is_driver_unloading(void);
  211. /**
  212. * qdf_is_driver_state_module_stop() - get driver state is module stop or not
  213. *
  214. * Return: true if driver state is module stop else false
  215. */
  216. bool qdf_is_driver_state_module_stop(void);
  217. /**
  218. * qdf_is_recovering() - get driver recovering in progress status
  219. * or not
  220. *
  221. * Return: true if driver is doing recovering else false
  222. */
  223. bool qdf_is_recovering(void);
  224. /*
  225. * struct qdf_op_sync - opaque operation synchronization context handle
  226. */
  227. struct qdf_op_sync;
  228. typedef int (*qdf_op_protect_cb)(void **out_sync, const char *func);
  229. typedef void (*qdf_op_unprotect_cb)(void *sync, const char *func);
  230. /**
  231. * qdf_op_protect() - attempt to protect a driver operation
  232. * @out_sync: output parameter for the synchronization context, populated on
  233. * success
  234. *
  235. * Return: Errno
  236. */
  237. #define qdf_op_protect(out_sync) __qdf_op_protect(out_sync, __func__)
  238. qdf_must_check int
  239. __qdf_op_protect(struct qdf_op_sync **out_sync, const char *func);
  240. /**
  241. * qdf_op_unprotect() - release driver operation protection
  242. * @sync: synchronization context returned from qdf_op_protect()
  243. *
  244. * Return: None
  245. */
  246. #define qdf_op_unprotect(sync) __qdf_op_unprotect(sync, __func__)
  247. void __qdf_op_unprotect(struct qdf_op_sync *sync, const char *func);
  248. /**
  249. * qdf_op_callbacks_register() - register driver operation protection callbacks
  250. * @on_protect: callback on protect
  251. * @on_unprotect: callback on unprotect
  252. *
  253. * Return: None
  254. */
  255. void qdf_op_callbacks_register(qdf_op_protect_cb on_protect,
  256. qdf_op_unprotect_cb on_unprotect);
  257. /**
  258. * typedef qdf_is_drv_connected_callback() - callback to query if drv
  259. * is connected
  260. *
  261. * Return: true if drv is connected else false
  262. */
  263. typedef bool (*qdf_is_drv_connected_callback)(void);
  264. /**
  265. * qdf_is_drv_connected() - API to check if drv is connected or not
  266. *
  267. * DRV is dynamic request voting using which fw can do page fault and
  268. * bring in page back without apps wake up
  269. *
  270. * Return: true: if drv is connected
  271. * false: if drv is not connected
  272. */
  273. bool qdf_is_drv_connected(void);
  274. /**
  275. * qdf_register_drv_connected_callback() - API to register drv connected cb
  276. * @is_drv_connected: callback to query if drv is connected or not
  277. *
  278. * Return: none
  279. */
  280. void qdf_register_drv_connected_callback(qdf_is_drv_connected_callback
  281. is_drv_connected);
  282. /**
  283. * qdf_check_state_before_panic() - API to check if FW is down
  284. * or driver is in recovery before calling assert
  285. * @func: Caller function pointer used for debug info
  286. * @line: Caller function line number
  287. *
  288. * Return: none
  289. */
  290. void qdf_check_state_before_panic(const char *func, const uint32_t line);
  291. /**
  292. *typedef qdf_is_drv_supported_callback() - callback to query if drv is supported
  293. *
  294. * Return: true if drv is supported else false
  295. */
  296. typedef bool (*qdf_is_drv_supported_callback)(void);
  297. /**
  298. * qdf_is_drv_supported() - API to check if drv is supported or not
  299. *
  300. * DRV is dynamic request voting using which fw can do page fault and
  301. * bring in page back without apps wake up
  302. *
  303. * Return: true: if drv is supported
  304. * false: if drv is not supported
  305. */
  306. bool qdf_is_drv_supported(void);
  307. /**
  308. * qdf_register_drv_supported_callback() - API to register drv supported cb
  309. * @is_drv_supported: callback to query if drv is supported or not
  310. *
  311. * Return: none
  312. */
  313. void qdf_register_drv_supported_callback(qdf_is_drv_supported_callback
  314. is_drv_supported);
  315. /**
  316. * typedef qdf_recovery_reason_update_callback() - recovery reason update callback
  317. * @reason: recovery reason
  318. */
  319. typedef void (*qdf_recovery_reason_update_callback)(enum qdf_hang_reason
  320. reason);
  321. /**
  322. * qdf_register_recovery_reason_update() - Register callback to update recovery
  323. * reason
  324. * @callback: callback to update recovery reason
  325. *
  326. * Return: none
  327. */
  328. void qdf_register_recovery_reason_update(qdf_recovery_reason_update_callback
  329. callback);
  330. /**
  331. * qdf_recovery_reason_update() - update recovery reason
  332. * @reason: recovery reason
  333. *
  334. * Return: none
  335. */
  336. void qdf_recovery_reason_update(enum qdf_hang_reason reason);
  337. /**
  338. * typedef qdf_bus_reg_dump() - callback for getting bus specific register dump
  339. * @dev: Bus specific device
  340. * @buf: Hang event buffer in which the data will be populated
  341. * @len: length of data to be populated in the hang event buffer
  342. *
  343. * Return: none
  344. */
  345. typedef void (*qdf_bus_reg_dump)(struct device *dev, uint8_t *buf,
  346. uint32_t len);
  347. /**
  348. * qdf_register_get_bus_reg_dump() - Register callback to update bus register
  349. * dump
  350. * @callback: callback to update bus register dump
  351. *
  352. * Return: none
  353. */
  354. void qdf_register_get_bus_reg_dump(qdf_bus_reg_dump callback);
  355. /**
  356. * qdf_get_bus_reg_dump() - Get the register dump for the bus
  357. * @dev: device
  358. * @buf: buffer for hang data
  359. * @len: len of hang data
  360. *
  361. * Return: none
  362. */
  363. void qdf_get_bus_reg_dump(struct device *dev, uint8_t *buf, uint32_t len);
  364. #ifdef WLAN_SUPPORT_DPDK
  365. /**
  366. * qdf_uio_register_device() - register dev to UIO dev
  367. * @parent: parent device to be registered with UIO dev
  368. * @info: UIO device capabilities
  369. *
  370. * Return: zero on success or a negative error code
  371. */
  372. int qdf_uio_register_device(struct device *parent, qdf_uio_info_t *info);
  373. /**
  374. * qdf_uio_unregister_device - unregister a UIO device
  375. * @info: UIO device capabilities
  376. *
  377. * Return: none
  378. */
  379. void qdf_uio_unregister_device(qdf_uio_info_t *info);
  380. #endif
  381. #endif /*_QDF_PLATFORM_H*/