1 /* 2 * Copyright (c) 2018-2019 The Linux Foundation. All rights reserved. 3 * 4 * Permission to use, copy, modify, and/or distribute this software for 5 * any purpose with or without fee is hereby granted, provided that the 6 * above copyright notice and this permission notice appear in all 7 * copies. 8 * 9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL 10 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED 11 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE 12 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL 13 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR 14 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER 15 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 16 * PERFORMANCE OF THIS SOFTWARE. 17 */ 18 19 /** 20 * DOC: qdf_platform.h 21 * This file defines platform API abstractions. 22 */ 23 24 #ifndef _QDF_PLATFORM_H 25 #define _QDF_PLATFORM_H 26 27 #include "qdf_types.h" 28 29 /** 30 * qdf_self_recovery_callback() - callback for self recovery 31 * @reason: the reason for the recovery request 32 * @func: the caller's function name 33 * @line: the line number of the callsite 34 * 35 * Return: none 36 */ 37 typedef void (*qdf_self_recovery_callback)(enum qdf_hang_reason reason, 38 const char *func, 39 const uint32_t line); 40 41 /** 42 * qdf_is_fw_down_callback() - callback to query if fw is down 43 * 44 * Return: true if fw is down and false if fw is not down 45 */ 46 typedef bool (*qdf_is_fw_down_callback)(void); 47 48 /** 49 * qdf_register_fw_down_callback() - API to register fw down callback 50 * @is_fw_down: callback to query if fw is down or not 51 * 52 * Return: none 53 */ 54 void qdf_register_fw_down_callback(qdf_is_fw_down_callback is_fw_down); 55 56 /** 57 * qdf_is_fw_down() - API to check if fw is down or not 58 * 59 * Return: true: if fw is down 60 * false: if fw is not down 61 */ 62 bool qdf_is_fw_down(void); 63 64 /** 65 * qdf_wmi_recv_qmi_cb() - callback to receive WMI over QMI 66 * @cb_ctx: WMI event recv callback context(wmi_handle) 67 * @buf: WMI buffer 68 * @len: WMI buffer len 69 * 70 * Return: 0 if success otherwise -EINVAL 71 */ 72 typedef int (*qdf_wmi_recv_qmi_cb)(void *cb_ctx, void *buf, int len); 73 74 /** 75 * qdf_wmi_send_over_qmi_callback() - callback to send WMI over QMI 76 * @buf: WMI buffer 77 * @len: WMI buffer len 78 * @cb_ctx: WMI event recv callback context(wmi_handle) 79 * @wmi_rx_cb: WMI event receive call back 80 * 81 * Return: QDF_STATUS_SUCCESS if success otherwise QDF error code 82 */ 83 typedef QDF_STATUS (*qdf_wmi_send_over_qmi_callback)(void *buf, uint32_t len, 84 void *cb_ctx, 85 qdf_wmi_recv_qmi_cb 86 wmi_rx_cb); 87 88 /** 89 * qdf_register_wmi_send_recv_qmi_callback() - Register WMI over QMI callback 90 * @qdf_wmi_send_over_qmi_callback: callback to send recv WMI data over QMI 91 * 92 * Return: none 93 */ 94 void qdf_register_wmi_send_recv_qmi_callback(qdf_wmi_send_over_qmi_callback 95 wmi_send_recv_qmi_cb); 96 97 /** 98 * qdf_wmi_send_recv_qmi() - API to send receive WMI data over QMI 99 * @buf: WMI buffer 100 * @len: WMI buffer len 101 * @cb_ctx: WMI event recv callback context(wmi_handle) 102 * @wmi_rx_cb: WMI event receive call back 103 * 104 * Return: QDF STATUS of operation 105 */ 106 QDF_STATUS qdf_wmi_send_recv_qmi(void *buf, uint32_t len, void *cb_ctx, 107 qdf_wmi_recv_qmi_cb wmi_rx_cb); 108 109 /** 110 * qdf_register_self_recovery_callback() - register self recovery callback 111 * @callback: self recovery callback 112 * 113 * Return: None 114 */ 115 void qdf_register_self_recovery_callback(qdf_self_recovery_callback callback); 116 117 /** 118 * qdf_trigger_self_recovery () - trigger self recovery 119 * @reason: the reason for the recovery request 120 * 121 * Call API only in case of fatal error, 122 * if self_recovery_cb callback is registered, injcets fw crash and recovers 123 * else raises QDF_BUG() 124 * 125 * Return: None 126 */ 127 #define qdf_trigger_self_recovery(reason) \ 128 __qdf_trigger_self_recovery(reason, __func__, __LINE__) 129 void __qdf_trigger_self_recovery(enum qdf_hang_reason reason, 130 const char *func, const uint32_t line); 131 132 /** 133 * qdf_is_recovering_callback() - callback to get driver recovering in progress 134 * or not 135 * 136 * Return: true if driver is doing recovering else false 137 */ 138 typedef bool (*qdf_is_recovering_callback)(void); 139 140 /** 141 * qdf_register_recovering_state_query_callback() - register recover status 142 * query callback 143 * 144 * Return: none 145 */ 146 void qdf_register_recovering_state_query_callback( 147 qdf_is_recovering_callback is_recovering); 148 149 /** 150 * qdf_is_recovering() - get driver recovering in progress status 151 * or not 152 * 153 * Return: true if driver is doing recovering else false 154 */ 155 bool qdf_is_recovering(void); 156 157 /** 158 * struct qdf_op_sync - opaque operation synchronization context handle 159 */ 160 struct qdf_op_sync; 161 162 typedef int (*qdf_op_protect_cb)(void **out_sync, const char *func); 163 typedef void (*qdf_op_unprotect_cb)(void *sync, const char *func); 164 165 /** 166 * qdf_op_protect() - attempt to protect a driver operation 167 * @out_sync: output parameter for the synchronization context, populated on 168 * success 169 * 170 * Return: Errno 171 */ 172 #define qdf_op_protect(out_sync) __qdf_op_protect(out_sync, __func__) 173 174 qdf_must_check int 175 __qdf_op_protect(struct qdf_op_sync **out_sync, const char *func); 176 177 /** 178 * qdf_op_unprotect() - release driver operation protection 179 * @sync: synchronization context returned from qdf_op_protect() 180 * 181 * Return: None 182 */ 183 #define qdf_op_unprotect(sync) __qdf_op_unprotect(sync, __func__) 184 185 void __qdf_op_unprotect(struct qdf_op_sync *sync, const char *func); 186 187 /** 188 * qdf_op_callbacks_register() - register driver operation protection callbacks 189 * 190 * Return: None 191 */ 192 void qdf_op_callbacks_register(qdf_op_protect_cb on_protect, 193 qdf_op_unprotect_cb on_unprotect); 194 195 /** 196 * qdf_is_drv_connected_callback() - callback to query if drv is connected 197 * 198 * Return: true if drv is connected else false 199 */ 200 typedef bool (*qdf_is_drv_connected_callback)(void); 201 202 /** 203 * qdf_is_drv_connected() - API to check if drv is connected or not 204 * 205 * DRV is dynamic request voting using which fw can do page fault and 206 * bring in page back without apps wake up 207 * 208 * Return: true: if drv is connected 209 * false: if drv is not connected 210 */ 211 bool qdf_is_drv_connected(void); 212 213 /** 214 * qdf_register_drv_connected_callback() - API to register drv connected cb 215 * @is_drv_connected: callback to query if drv is connected or not 216 * 217 * Return: none 218 */ 219 void qdf_register_drv_connected_callback(qdf_is_drv_connected_callback 220 is_drv_connected); 221 222 #endif /*_QDF_PLATFORM_H*/ 223 224