1 /* 2 * Copyright (c) 2017-2018 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 1 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 = 1, 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_pdev_create_handler() - Handler to be invoked for 153 * direct buffer rx module 154 * during pdev object create 155 * @pdev: pointer to pdev object 156 * @data: pointer to data 157 * 158 * Return : QDF status of operation 159 */ 160 QDF_STATUS target_if_direct_buf_rx_pdev_create_handler( 161 struct wlan_objmgr_pdev *pdev, void *data); 162 163 /** 164 * target_if_direct_buf_rx_pdev_destroy_handler() - Handler to be invoked for 165 * direct buffer rx module 166 * during pdev object destroy 167 * @pdev: pointer to pdev object 168 * @data: pointer to data 169 * 170 * Return : QDF status of operation 171 */ 172 QDF_STATUS target_if_direct_buf_rx_pdev_destroy_handler( 173 struct wlan_objmgr_pdev *pdev, void *data); 174 175 /** 176 * target_if_direct_buf_rx_psoc_create_handler() - Handler invoked for 177 * direct buffer rx module 178 * during attach 179 * @pdev: pointer to psoc object 180 * 181 * Return : QDF status of operation 182 */ 183 QDF_STATUS target_if_direct_buf_rx_psoc_create_handler( 184 struct wlan_objmgr_psoc *psoc, void *data); 185 186 /** 187 * target_if_direct_buf_rx_psoc_destroy_handler() - Handler invoked for 188 * direct buffer rx module 189 * during detach 190 * @pdev: pointer to psoc object 191 * 192 * Return : QDF status of operation 193 */ 194 QDF_STATUS target_if_direct_buf_rx_psoc_destroy_handler( 195 struct wlan_objmgr_psoc *psoc, void *data); 196 197 /** 198 * target_if_deinit_dbr_ring() - Function to deinitialize buffers and ring 199 * allocated for direct buffer rx module 200 * @pdev: pointer to pdev object 201 * @dbr_pdev_obj: pointer to direct buffer rx module pdev obj 202 * @mod_id: module id indicating the module using direct buffer rx framework 203 * 204 * Return : QDF status of operation 205 */ 206 QDF_STATUS target_if_deinit_dbr_ring(struct wlan_objmgr_pdev *pdev, 207 struct direct_buf_rx_pdev_obj *dbr_pdev_obj, 208 enum DBR_MODULE mod_id); 209 /** 210 * target_if_direct_buf_rx_module_register() - Function to register to direct 211 * buffer rx module 212 * @pdev: pointer to pdev object 213 * @mod_id: module id indicating the module using direct buffer rx framework 214 * @dbr_rsp_handler: function pointer pointing to the response handler to be 215 * invoked for the module registering to direct buffer rx 216 * module 217 * 218 * Return: QDF status of operation 219 */ 220 QDF_STATUS target_if_direct_buf_rx_module_register( 221 struct wlan_objmgr_pdev *pdev, uint8_t mod_id, 222 int (*dbr_rsp_handler)(struct wlan_objmgr_pdev *pdev, 223 struct direct_buf_rx_data *dbr_data)); 224 225 #endif /* _TARGET_IF_DIRECT_BUF_RX_MAIN_H_ */ 226