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