1 /* 2 * Copyright (c) 2017-2021 The Linux Foundation. All rights reserved. 3 * Copyright (c) 2022 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 #ifndef _TARGET_IF_DIRECT_BUF_RX_API_H_ 21 #define _TARGET_IF_DIRECT_BUF_RX_API_H_ 22 23 #include "qdf_nbuf.h" 24 #include "qdf_atomic.h" 25 #include "wmi_unified_api.h" 26 27 /** 28 * enum DBR_MODULE - Enum containing the modules supporting direct buf rx 29 * @DBR_MODULE_SPECTRAL: Module ID for Spectral 30 * @DBR_MODULE_CFR: Module ID for CFR 31 * @DBR_MODULE_MAX: Max module ID 32 */ 33 enum DBR_MODULE { 34 DBR_MODULE_SPECTRAL = 0, 35 DBR_MODULE_CFR = 1, 36 DBR_MODULE_MAX, 37 }; 38 39 #ifdef DIRECT_BUF_RX_ENABLE 40 #ifdef WLAN_DEBUGFS 41 #ifdef DIRECT_BUF_RX_DEBUG 42 /* Base debugfs entry for DBR module */ 43 extern qdf_dentry_t dbr_debugfs_entry; 44 #endif /* DIRECT_BUF_RX_DEBUG */ 45 #endif /* WLAN_DEBUGFS */ 46 47 #define direct_buf_rx_alert(params...) \ 48 QDF_TRACE_FATAL(QDF_MODULE_ID_DIRECT_BUF_RX, params) 49 #define direct_buf_rx_err(params...) \ 50 QDF_TRACE_ERROR(QDF_MODULE_ID_DIRECT_BUF_RX, params) 51 #define direct_buf_rx_warn(params...) \ 52 QDF_TRACE_WARN(QDF_MODULE_ID_DIRECT_BUF_RX, params) 53 #define direct_buf_rx_notice(params...) \ 54 QDF_TRACE_INFO(QDF_MODULE_ID_DIRECT_BUF_RX, params) 55 #define direct_buf_rx_info(params...) \ 56 QDF_TRACE_INFO(QDF_MODULE_ID_DIRECT_BUF_RX, params) 57 #define direct_buf_rx_debug(params...) \ 58 QDF_TRACE_DEBUG(QDF_MODULE_ID_DIRECT_BUF_RX, params) 59 #define direct_buf_rx_enter() \ 60 QDF_TRACE_ENTER(QDF_MODULE_ID_DIRECT_BUF_RX, "enter") 61 #define direct_buf_rx_exit() \ 62 QDF_TRACE_EXIT(QDF_MODULE_ID_DIRECT_BUF_RX, "exit") 63 64 #define directbuf_nofl_alert(params...) \ 65 QDF_TRACE_FATAL_NO_FL(QDF_MODULE_ID_DIRECT_BUF_RX, params) 66 #define directbuf_nofl_err(params...) \ 67 QDF_TRACE_ERROR_NO_FL(QDF_MODULE_ID_DIRECT_BUF_RX, params) 68 #define directbuf_nofl_warn(params...) \ 69 QDF_TRACE_WARN_NO_FL(QDF_MODULE_ID_DIRECT_BUF_RX, params) 70 #define directbuf_nofl_info(params...) \ 71 QDF_TRACE_INFO_NO_FL(QDF_MODULE_ID_DIRECT_BUF_RX, params) 72 #define directbuf_nofl_debug(params...) \ 73 QDF_TRACE_DEBUG_NO_FL(QDF_MODULE_ID_DIRECT_BUF_RX, params) 74 75 #define DBR_MAX_CHAINS (8) 76 77 struct wlan_objmgr_psoc; 78 struct wlan_lmac_if_tx_ops; 79 80 #ifdef WMI_DBR_SUPPORT 81 /** 82 * struct direct_buf_rx_data - direct buffer rx data 83 * @dbr_len: Length of the buffer DMAed 84 * @vaddr: Virtual address of the buffer that has DMAed data 85 * @cookie: Cookie for the buffer rxed from target 86 * @paddr: physical address of buffer corresponding to vaddr 87 * @meta_data_valid: Indicates that metadata is valid 88 * @meta_data: Meta data 89 */ 90 struct direct_buf_rx_data { 91 size_t dbr_len; 92 void *vaddr; 93 uint32_t cookie; 94 qdf_dma_addr_t paddr; 95 bool meta_data_valid; 96 struct direct_buf_rx_metadata meta_data; 97 }; 98 #endif 99 100 /** 101 * struct dbr_module_config - module configuration for dbr 102 * @num_resp_per_event: Number of events to be packed together 103 * @event_timeout_in_ms: Timeout until which multiple events can be packed 104 */ 105 struct dbr_module_config { 106 uint32_t num_resp_per_event; 107 uint32_t event_timeout_in_ms; 108 }; 109 110 /** 111 * direct_buf_rx_init() - Function to initialize direct buf rx module 112 * 113 * Return: QDF status of operation 114 */ 115 QDF_STATUS direct_buf_rx_init(void); 116 117 /** 118 * direct_buf_rx_deinit() - Function to deinitialize direct buf rx module 119 * 120 * Return: QDF status of operation 121 */ 122 QDF_STATUS direct_buf_rx_deinit(void); 123 124 /** 125 * direct_buf_rx_target_attach() - Attach hal_soc,osdev in direct buf rx psoc obj 126 * @psoc: pointer to psoc object 127 * @hal_soc: Opaque HAL SOC handle 128 * @osdev: QDF os device handle 129 * 130 * Return: QDF status of operation 131 */ 132 QDF_STATUS direct_buf_rx_target_attach(struct wlan_objmgr_psoc *psoc, 133 void *hal_soc, qdf_device_t osdev); 134 135 /** 136 * target_if_direct_buf_rx_register_tx_ops() - Register tx ops for direct buffer 137 * rx module 138 * @tx_ops: pointer to lmac interface tx ops 139 * 140 * Return: None 141 */ 142 void target_if_direct_buf_rx_register_tx_ops( 143 struct wlan_lmac_if_tx_ops *tx_ops); 144 145 /** 146 * target_if_dbr_cookie_lookup() - Function to retrieve cookie from 147 * buffer address(paddr) 148 * @pdev: pointer to pdev object 149 * @mod_id: module id indicating the module using direct buffer rx framework 150 * @paddr: Physical address of buffer for which cookie info is required 151 * @cookie: cookie will be returned in this param 152 * @srng_id: srng ID 153 * 154 * Return: QDF status of operation 155 */ 156 QDF_STATUS target_if_dbr_cookie_lookup(struct wlan_objmgr_pdev *pdev, 157 uint8_t mod_id, qdf_dma_addr_t paddr, 158 uint32_t *cookie, uint8_t srng_id); 159 160 /** 161 * target_if_dbr_buf_release() - Notify direct buf that a previously provided 162 * buffer can be released. 163 * @pdev: pointer to pdev object 164 * @mod_id: module id indicating the module using direct buffer rx framework 165 * @paddr: Physical address of buffer for which cookie info is required 166 * @cookie: cookie value corresponding to the paddr 167 * @srng_id: srng ID 168 * 169 * Return: QDF status of operation 170 */ 171 QDF_STATUS target_if_dbr_buf_release(struct wlan_objmgr_pdev *pdev, 172 uint8_t mod_id, qdf_dma_addr_t paddr, 173 uint32_t cookie, uint8_t srng_id); 174 175 /** 176 * target_if_dbr_update_pdev_for_hw_mode_change() - Update DBR object in pdev 177 * structure for hw mode change 178 * @pdev: pointer to pdev object 179 * @phy_idx: Phy index 180 */ 181 QDF_STATUS target_if_dbr_update_pdev_for_hw_mode_change( 182 struct wlan_objmgr_pdev *pdev, int phy_idx); 183 184 /** 185 * target_if_dbr_set_event_handler_ctx() - Set the context for 186 * DBR event execution 187 * @psoc: Pointer to psoc object 188 * @dbr_handler_ctx: DBR event handler context 189 * 190 * Return: QDF status of operation 191 */ 192 QDF_STATUS target_if_dbr_set_event_handler_ctx( 193 struct wlan_objmgr_psoc *psoc, 194 enum wmi_rx_exec_ctx dbr_handler_ctx); 195 #else /* DIRECT_BUF_RX_ENABLE*/ 196 197 static inline QDF_STATUS 198 target_if_dbr_cookie_lookup(struct wlan_objmgr_pdev *pdev, 199 uint8_t mod_id, qdf_dma_addr_t paddr, 200 uint32_t *cookie, uint8_t srng_id) 201 { 202 return QDF_STATUS_SUCCESS; 203 } 204 205 static inline QDF_STATUS 206 target_if_dbr_buf_release(struct wlan_objmgr_pdev *pdev, 207 uint8_t mod_id, qdf_dma_addr_t paddr, 208 uint32_t cookie, uint8_t srng_id) 209 { 210 return QDF_STATUS_SUCCESS; 211 } 212 213 static inline QDF_STATUS 214 target_if_dbr_update_pdev_for_hw_mode_change( 215 struct wlan_objmgr_pdev *pdev, int phy_idx) 216 { 217 return QDF_STATUS_SUCCESS; 218 } 219 220 static inline QDF_STATUS 221 target_if_dbr_set_event_handler_ctx( 222 struct wlan_objmgr_psoc *psoc, 223 enum wmi_rx_exec_ctx dbr_handler_ctx) 224 { 225 return QDF_STATUS_SUCCESS; 226 } 227 #endif /* DIRECT_BUF_RX_ENABLE */ 228 #endif /* _TARGET_IF_DIRECT_BUF_RX_API_H_ */ 229