1 /*
2  * Copyright (c) 2017-2021 The Linux Foundation. All rights reserved.
3  * Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All rights reserved.
4  *
5  * Permission to use, copy, modify, and/or distribute this software for
6  * any purpose with or without fee is hereby granted, provided that the
7  * above copyright notice and this permission notice appear in all
8  * copies.
9  *
10  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
11  * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
12  * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
13  * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
14  * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
15  * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
16  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
17  * PERFORMANCE OF THIS SOFTWARE.
18  */
19 
20 #ifndef _WLAN_SPECTRAL_UTILS_API_H_
21 #define _WLAN_SPECTRAL_UTILS_API_H_
22 #ifdef WLAN_CONV_SPECTRAL_ENABLE
23 #include <wlan_objmgr_cmn.h>
24 #include <wlan_lmac_if_def.h>
25 
26 /* Forward declaration */
27 struct direct_buf_rx_data;
28 struct spectral_wmi_ops;
29 struct spectral_tgt_ops;
30 
31 /**
32  * wlan_spectral_is_feature_disabled_pdev() - Check if spectral feature
33  * is disabled for a given pdev
34  * @pdev: pointer to pdev
35  *
36  * Return : true if spectral is disabled, else false.
37  */
38 bool wlan_spectral_is_feature_disabled_pdev(struct wlan_objmgr_pdev *pdev);
39 
40 /**
41  * wlan_spectral_is_feature_disabled_ini() - Check if spectral feature
42  * is disabled in INI
43  * @psoc: pointer to psoc
44  *
45  * Return : true if spectral is disabled, else false.
46  */
47 bool wlan_spectral_is_feature_disabled_ini(struct wlan_objmgr_psoc *psoc);
48 
49 /**
50  * wlan_spectral_is_feature_disabled_psoc() - Check if spectral feature
51  * is disabled for a given psoc
52  * @psoc: pointer to psoc
53  *
54  * Return : true if spectral is disabled, else false.
55  */
56 bool wlan_spectral_is_feature_disabled_psoc(struct wlan_objmgr_psoc *psoc);
57 
58 /**
59  * wlan_spectral_is_mode_disabled_pdev() - Check if a given spectral mode
60  * is disabled for a given pdev
61  * @pdev: pointer to pdev
62  * @smode: spectral scan mode
63  *
64  * Return : true if spectral mode is disabled, else false.
65  */
66 bool wlan_spectral_is_mode_disabled_pdev(struct wlan_objmgr_pdev *pdev,
67 					 enum spectral_scan_mode smode);
68 
69 /**
70  * wlan_spectral_init() - API to init spectral component
71  *
72  * This API is invoked from dispatcher init during all component init.
73  * This API will register all required handlers for pdev and peer object
74  * create/delete notification.
75  *
76  * Return: SUCCESS,
77  *         Failure
78  */
79 QDF_STATUS wlan_spectral_init(void);
80 
81 /**
82  * wlan_spectral_deinit() - API to deinit spectral component
83  *
84  * This API is invoked from dispatcher deinit during all component deinit.
85  * This API will unregister all registered handlers for pdev and peer object
86  * create/delete notification.
87  *
88  * Return: SUCCESS,
89  *         Failure
90  */
91 QDF_STATUS wlan_spectral_deinit(void);
92 
93 /**
94  * wlan_lmac_if_sptrl_register_rx_ops() - Register lmac interface Rx operations
95  * @rx_ops: Pointer to lmac interface Rx operations structure
96  *
97  * API to register spectral related lmac interface Rx operations
98  *
99  * Return: None
100  */
101 void
102 wlan_lmac_if_sptrl_register_rx_ops(struct wlan_lmac_if_rx_ops *rx_ops);
103 
104 /**
105  * wlan_register_spectral_wmi_ops() - Register Spectral WMI operations
106  * @psoc: Pointer to psoc object
107  * @wmi_ops: pointer to the structure holding the Spectral WMI
108  *            operations
109  *
110  * API to register Spectral WMI operations
111  *
112  * Return: QDF_STATUS
113 */
114 QDF_STATUS
115 wlan_register_spectral_wmi_ops(struct wlan_objmgr_psoc *psoc,
116 			       struct spectral_wmi_ops *wmi_ops);
117 
118 /**
119  * wlan_register_spectral_tgt_ops() - Register Spectral target operations
120  * @psoc: Pointer to psoc object
121  * @tgt_ops: pointer to the structure holding the Spectral target
122  *            operations
123  *
124  * API to register Spectral target operations
125  *
126  * Return: QDF_STATUS
127  */
128 QDF_STATUS
129 wlan_register_spectral_tgt_ops(struct wlan_objmgr_psoc *psoc,
130 			       struct spectral_tgt_ops *tgt_ops);
131 
132 /**
133  * struct spectral_legacy_cbacks - Spectral legacy callbacks
134  * @vdev_get_chan_freq:          Get channel frequency
135  * @vdev_get_chan_freq_seg2:     Get secondary 80 center frequency
136  * @vdev_get_ch_width:           Get channel width
137  * @vdev_get_sec20chan_freq_mhz: Get secondary 20 frequency
138  */
139 struct spectral_legacy_cbacks {
140 	int16_t (*vdev_get_chan_freq)(struct wlan_objmgr_vdev *vdev);
141 	int16_t (*vdev_get_chan_freq_seg2)(struct wlan_objmgr_vdev *vdev);
142 	enum phy_ch_width (*vdev_get_ch_width)(struct wlan_objmgr_vdev *vdev);
143 	int (*vdev_get_sec20chan_freq_mhz)(struct wlan_objmgr_vdev *vdev,
144 					   uint16_t *sec20chan_freq);
145 };
146 
147 /**
148  * spectral_vdev_get_chan_freq() - Get vdev channel frequency
149  * @vdev:          vdev object
150  *
151  * Return: vdev operating frequency
152  */
153 int16_t spectral_vdev_get_chan_freq(struct wlan_objmgr_vdev *vdev);
154 
155 /**
156  * spectral_vdev_get_chan_freq_seg2() - Get vdev's secondary 80 center frequency
157  * @vdev: vdev object
158  *
159  * Return: vdev secondary 80 center frequency
160  */
161 int16_t spectral_vdev_get_chan_freq_seg2(struct wlan_objmgr_vdev *vdev);
162 
163 /**
164  * spectral_vdev_get_sec20chan_freq_mhz() - Get vdev secondary channel frequency
165  * @vdev:   vdev object
166  * @sec20chan_freq: secondary channel frequency
167  *
168  * Return: secondary channel freq
169  */
170 int spectral_vdev_get_sec20chan_freq_mhz(struct wlan_objmgr_vdev *vdev,
171 					uint16_t *sec20chan_freq);
172 
173 /**
174  * spectral_register_legacy_cb() - Register spectral legacy callbacks
175  * commands on spectral parameters
176  * @psoc: the physical device object
177  * @legacy_cbacks: Reference to struct spectral_legacy_cbacks from which
178  * function pointers need to be copied
179  *
180  * API to register spectral related legacy callbacks
181  *
182  * Return: QDF_STATUS_SUCCESS upon successful registration,
183  *         QDF_STATUS_E_FAILURE upon failure
184  */
185 QDF_STATUS spectral_register_legacy_cb(
186 	struct wlan_objmgr_psoc *psoc,
187 	struct spectral_legacy_cbacks *legacy_cbacks);
188 
189 /**
190  * spectral_vdev_get_ch_width() - Get the channel bandwidth
191  * @vdev: Pointer to vdev
192  *
193  * API to get the channel bandwidth of a given vdev
194  *
195  * Return: Enumeration corresponding to the channel bandwidth
196  */
197 enum phy_ch_width
198 spectral_vdev_get_ch_width(struct wlan_objmgr_vdev *vdev);
199 
200 /**
201  * spectral_pdev_open() - Spectral pdev open handler
202  * @pdev:  pointer to pdev object
203  *
204  * API to execute operations on pdev open
205  *
206  * Return: QDF_STATUS_SUCCESS upon successful registration,
207  *         QDF_STATUS_E_FAILURE upon failure
208  */
209 QDF_STATUS spectral_pdev_open(struct wlan_objmgr_pdev *pdev);
210 
211 /**
212  * wlan_spectral_psoc_open() - Spectral psoc open handler
213  * @psoc:  pointer to psoc object
214  *
215  * API to execute operations on psoc open
216  *
217  * Return: QDF_STATUS_SUCCESS upon successful registration,
218  *         QDF_STATUS_E_FAILURE upon failure
219  */
220 QDF_STATUS wlan_spectral_psoc_open(struct wlan_objmgr_psoc *psoc);
221 
222 /**
223  * wlan_spectral_psoc_close() - Spectral psoc close handler
224  * @psoc:  pointer to psoc object
225  *
226  * API to execute operations on psoc close
227  *
228  * Return: QDF_STATUS_SUCCESS upon successful registration,
229  *         QDF_STATUS_E_FAILURE upon failure
230  */
231 QDF_STATUS wlan_spectral_psoc_close(struct wlan_objmgr_psoc *psoc);
232 
233 /**
234  * wlan_spectral_psoc_enable() - Spectral psoc enable handler
235  * @psoc:  pointer to psoc object
236  *
237  * API to execute operations on psoc enable
238  *
239  * Return: QDF_STATUS_SUCCESS upon successful registration,
240  *         QDF_STATUS_E_FAILURE upon failure
241  */
242 QDF_STATUS wlan_spectral_psoc_enable(struct wlan_objmgr_psoc *psoc);
243 
244 /**
245  * wlan_spectral_psoc_disable() - Spectral psoc disable handler
246  * @psoc:  pointer to psoc object
247  *
248  * API to execute operations on psoc disable
249  *
250  * Return: QDF_STATUS_SUCCESS upon successful registration,
251  *         QDF_STATUS_E_FAILURE upon failure
252  */
253 QDF_STATUS wlan_spectral_psoc_disable(struct wlan_objmgr_psoc *psoc);
254 
255 /**
256  * spectral_register_dbr() - register Spectral event handler with DDMA
257  * @pdev:  pointer to pdev object
258  *
259  * API to register event handler with Direct DMA
260  *
261  * Return: QDF_STATUS_SUCCESS upon successful registration,
262  *         QDF_STATUS_E_FAILURE upon failure
263  */
264 
265 QDF_STATUS spectral_register_dbr(struct wlan_objmgr_pdev *pdev);
266 
267 /**
268  * spectral_unregister_dbr() - unregister Spectral event handler with DDMA
269  * @pdev:  pointer to pdev object
270  *
271  * API to unregister event handler with Direct DMA
272  *
273  * Return: QDF_STATUS_SUCCESS upon successful unregistration,
274  *         QDF_STATUS_E_FAILURE upon failure
275  */
276 QDF_STATUS spectral_unregister_dbr(struct wlan_objmgr_pdev *pdev);
277 
278 /**
279  * wlan_spectral_init_pdev_feature_caps() - API to initialize
280  * spectral pdev feature caps
281  * @pdev:  pointer to pdev object
282  *
283  * API to initialize Spectral feature caps for a given pdev.
284  *
285  * Return: QDF_STATUS_SUCCESS upon successful initialization,
286  *         QDF_STATUS_E_FAILURE upon failure
287  */
288 QDF_STATUS wlan_spectral_init_pdev_feature_caps(struct wlan_objmgr_pdev *pdev);
289 
290 /**
291  * wlan_spectral_init_psoc_feature_cap() - API to initialize
292  * spectral psoc feature caps
293  * @psoc:  pointer to psoc object
294  *
295  * API to initialize Spectral feature caps for a given psoc.
296  *
297  * Return: QDF_STATUS_SUCCESS upon successful initialization,
298  *         QDF_STATUS_E_FAILURE upon failure
299  */
300 QDF_STATUS wlan_spectral_init_psoc_feature_cap(struct wlan_objmgr_psoc *psoc);
301 
302 /**
303  * wlan_spectral_pdev_get_lmac_if_txops() - API to get pointer
304  * to Spectral txops structure
305  * @pdev:  pointer to pdev object
306  *
307  * API to get pointer to Spectral txops structure
308  *
309  * Return: Pointer to Spectral txops structure, NULL in case of
310  *         error.
311  */
312 struct wlan_lmac_if_sptrl_tx_ops *
313 wlan_spectral_pdev_get_lmac_if_txops(struct wlan_objmgr_pdev *pdev);
314 
315 #ifdef DIRECT_BUF_RX_ENABLE
316 /**
317  * spectral_dbr_event_handler() - Spectral dbr event handler
318  * @pdev:  pointer to pdev object
319  * @payload: dbr event buffer
320  *
321  * API to handle spectral dbr event
322  *
323  * Return: true to release buf
324  */
325 bool spectral_dbr_event_handler(struct wlan_objmgr_pdev *pdev,
326 				struct direct_buf_rx_data *payload);
327 #endif
328 #endif /* WLAN_CONV_SPECTRAL_ENABLE */
329 #endif /* _WLAN_SPECTRAL_UTILS_API_H_*/
330