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