1 /* 2 * Copyright (c) 2017-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 #ifndef _TARGET_IF_DIRECT_BUF_RX_MAIN_H_ 20 #define _TARGET_IF_DIRECT_BUF_RX_MAIN_H_ 21 22 #include "qdf_types.h" 23 #include "qdf_status.h" 24 #include <target_if_direct_buf_rx_api.h> 25 26 struct wlan_objmgr_psoc; 27 struct wlan_lmac_if_tx_ops; 28 struct direct_buf_rx_data; 29 30 #define DBR_RING_BASE_ALIGN 8 31 32 /** 33 * struct direct_buf_rx_info - direct buffer rx operation info struct 34 * @cookie: SW cookie used to get the virtual address 35 * @paddr: Physical address pointer for DMA operation 36 * @vaddr: Virtual address pointer 37 * @offset: Offset of aligned address from unaligned 38 */ 39 struct direct_buf_rx_buf_info { 40 uint32_t cookie; 41 qdf_dma_addr_t paddr; 42 void *vaddr; 43 uint8_t offset; 44 }; 45 46 /** 47 * struct direct_buf_rx_ring_cfg - DMA ring config parameters 48 * @num_ptr: Depth or the number of physical address pointers in the ring 49 * @ring_alloc_size: Size of the HAL ring 50 * @base_paddr_unaligned: base physical addr unaligned 51 * @base_vaddr_unaligned: base virtual addr unaligned 52 * @base_paddr_aligned: base physical addr aligned 53 * @base_vaddr_aligned: base virtual addr unaligned 54 * @head_idx_addr: head index addr 55 * @tail_idx_addr: tail index addr 56 * @srng: HAL srng context 57 */ 58 struct direct_buf_rx_ring_cfg { 59 uint32_t num_ptr; 60 uint32_t ring_alloc_size; 61 qdf_dma_addr_t base_paddr_unaligned; 62 void *base_vaddr_unaligned; 63 qdf_dma_addr_t base_paddr_aligned; 64 void *base_vaddr_aligned; 65 qdf_dma_addr_t head_idx_addr; 66 qdf_dma_addr_t tail_idx_addr; 67 void *srng; 68 uint32_t buf_size; 69 }; 70 71 /** 72 * struct direct_buf_rx_ring_cap - DMA ring capabilities 73 * @ring_elems_min: Minimum number of pointers in the ring 74 * @min_buf_size: Minimum size of each buffer entry in the ring 75 * @min_buf_align: Minimum alignment of the addresses in the ring 76 */ 77 struct direct_buf_rx_ring_cap { 78 uint32_t ring_elems_min; 79 uint32_t min_buf_size; 80 uint32_t min_buf_align; 81 }; 82 83 /** 84 * struct direct_buf_rx_module_param - DMA module param 85 * @mod_id: Module ID 86 * @dbr_config: Pointer to dirct buf rx module configuration struct 87 * @dbr_ring_cap: Pointer to direct buf rx ring capabilities struct 88 * @dbr_ring_cfg: Pointer to direct buf rx ring config struct 89 * @dbr_buf_pool: Pointer to direct buf rx buffer pool struct 90 * @dbr_rsp_handler: Pointer to direct buf rx response handler for the module 91 */ 92 struct direct_buf_rx_module_param { 93 enum DBR_MODULE mod_id; 94 struct dbr_module_config dbr_config; 95 struct direct_buf_rx_ring_cap *dbr_ring_cap; 96 struct direct_buf_rx_ring_cfg *dbr_ring_cfg; 97 struct direct_buf_rx_buf_info *dbr_buf_pool; 98 bool (*dbr_rsp_handler)(struct wlan_objmgr_pdev *pdev, 99 struct direct_buf_rx_data *dbr_data); 100 }; 101 102 /** 103 * struct direct_buf_rx_pdev_obj - Direct Buf RX pdev object struct 104 * @num_modules: Number of modules registered to DBR for the pdev 105 * @dbr_mod_param: Pointer to direct buf rx module param struct 106 */ 107 struct direct_buf_rx_pdev_obj { 108 uint32_t num_modules; 109 struct direct_buf_rx_module_param *dbr_mod_param; 110 }; 111 112 /** 113 * struct direct_buf_rx_psoc_obj - Direct Buf RX psoc object struct 114 * @hal_soc: Opaque HAL SOC handle 115 * @osdev: QDF os device handle 116 */ 117 struct direct_buf_rx_psoc_obj { 118 void *hal_soc; 119 qdf_device_t osdev; 120 }; 121 122 /** 123 * struct module_ring_params - Direct buf ring params for module 124 * @num_bufs: Number of buffers alloted to this module 125 * @buf_size: size of buffers 126 */ 127 struct module_ring_params { 128 uint32_t num_bufs; 129 uint32_t buf_size; 130 }; 131 132 /** 133 * target_if_direct_buf_rx_register_events() - Register WMI events to direct 134 * buffer rx module 135 * @psoc: pointer to psoc object 136 * 137 * Return : QDF status of operation 138 */ 139 QDF_STATUS target_if_direct_buf_rx_register_events( 140 struct wlan_objmgr_psoc *psoc); 141 142 /** 143 * target_if_direct_buf_rx_unregister_events() - Unregister WMI events to direct 144 * buffer rx module 145 * @psoc: pointer to psoc object 146 * 147 * Return : QDF status of operation 148 */ 149 QDF_STATUS target_if_direct_buf_rx_unregister_events( 150 struct wlan_objmgr_psoc *psoc); 151 152 /** 153 * target_if_direct_buf_rx_print_ring_stat() - Print ring status for each 154 * module in the pdev 155 * @pdev: pointer to pdev object 156 * 157 * Return : QDF status of operation 158 */ 159 QDF_STATUS target_if_direct_buf_rx_print_ring_stat( 160 struct wlan_objmgr_pdev *pdev); 161 162 /** 163 * target_if_direct_buf_rx_pdev_create_handler() - Handler to be invoked for 164 * direct buffer rx module 165 * during pdev object create 166 * @pdev: pointer to pdev object 167 * @data: pointer to data 168 * 169 * Return : QDF status of operation 170 */ 171 QDF_STATUS target_if_direct_buf_rx_pdev_create_handler( 172 struct wlan_objmgr_pdev *pdev, void *data); 173 174 /** 175 * target_if_direct_buf_rx_pdev_destroy_handler() - Handler to be invoked for 176 * direct buffer rx module 177 * during pdev object destroy 178 * @pdev: pointer to pdev object 179 * @data: pointer to data 180 * 181 * Return : QDF status of operation 182 */ 183 QDF_STATUS target_if_direct_buf_rx_pdev_destroy_handler( 184 struct wlan_objmgr_pdev *pdev, void *data); 185 186 /** 187 * target_if_direct_buf_rx_psoc_create_handler() - Handler invoked for 188 * direct buffer rx module 189 * during attach 190 * @pdev: pointer to psoc object 191 * 192 * Return : QDF status of operation 193 */ 194 QDF_STATUS target_if_direct_buf_rx_psoc_create_handler( 195 struct wlan_objmgr_psoc *psoc, void *data); 196 197 /** 198 * target_if_direct_buf_rx_psoc_destroy_handler() - Handler invoked for 199 * direct buffer rx module 200 * during detach 201 * @pdev: pointer to psoc object 202 * 203 * Return : QDF status of operation 204 */ 205 QDF_STATUS target_if_direct_buf_rx_psoc_destroy_handler( 206 struct wlan_objmgr_psoc *psoc, void *data); 207 208 /** 209 * target_if_deinit_dbr_ring() - Function to deinitialize buffers and ring 210 * allocated for direct buffer rx module 211 * @pdev: pointer to pdev object 212 * @dbr_pdev_obj: pointer to direct buffer rx module pdev obj 213 * @mod_id: module id indicating the module using direct buffer rx framework 214 * 215 * Return : QDF status of operation 216 */ 217 QDF_STATUS target_if_deinit_dbr_ring(struct wlan_objmgr_pdev *pdev, 218 struct direct_buf_rx_pdev_obj *dbr_pdev_obj, 219 enum DBR_MODULE mod_id); 220 /** 221 * target_if_direct_buf_rx_module_register() - Function to register to direct 222 * buffer rx module 223 * @pdev: pointer to pdev object 224 * @mod_id: module id indicating the module using direct buffer rx framework 225 * @dbr_config: dbr module configuration params 226 * @dbr_rsp_handler: function pointer pointing to the response handler to be 227 * invoked for the module registering to direct buffer rx 228 * module 229 * 230 * Return: QDF status of operation 231 */ 232 QDF_STATUS target_if_direct_buf_rx_module_register( 233 struct wlan_objmgr_pdev *pdev, uint8_t mod_id, 234 struct dbr_module_config *dbr_config, 235 bool (*dbr_rsp_handler) 236 (struct wlan_objmgr_pdev *pdev, 237 struct direct_buf_rx_data *dbr_data)); 238 239 /** 240 * target_if_direct_buf_rx_module_unregister() - Function to unregister to 241 * direct buffer rx module 242 * @pdev: pointer to pdev object 243 * @mod_id: module id indicating the module using direct buffer rx framework 244 * 245 * Return: QDF status of operation 246 */ 247 QDF_STATUS target_if_direct_buf_rx_module_unregister( 248 struct wlan_objmgr_pdev *pdev, uint8_t mod_id); 249 250 /** 251 * target_if_direct_buf_rx_get_ring_params() - Function to get ring parameters 252 * for module_id 253 * @pdev: pointer to pdev object 254 * @module_ring_params: pointer to store ring params 255 * @mod_id: module idindicating module using direct buffer rx framework 256 */ 257 QDF_STATUS 258 target_if_direct_buf_rx_get_ring_params(struct wlan_objmgr_pdev *pdev, 259 struct module_ring_params *param, 260 int mod_id); 261 262 #endif /* _TARGET_IF_DIRECT_BUF_RX_MAIN_H_ */ 263