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