xref: /wlan-dirver/qca-wifi-host-cmn/spectral/dispatcher/inc/wlan_spectral_utils_api.h (revision a86b23ee68a2491aede2e03991f3fb37046f4e41)
1 /*
2  * Copyright (c) 2017-2020 The Linux Foundation. All rights reserved.
3  *
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 
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() - Check if spectral feature is disabled
33  * @psoc - the physical device object.
34  *
35  * Return : true if spectral is disabled, else false.
36  */
37 bool wlan_spectral_is_feature_disabled(struct wlan_objmgr_psoc *psoc);
38 
39 /**
40  * wlan_spectral_init() - API to init spectral component
41  *
42  * This API is invoked from dispatcher init during all component init.
43  * This API will register all required handlers for pdev and peer object
44  * create/delete notification.
45  *
46  * Return: SUCCESS,
47  *         Failure
48  */
49 QDF_STATUS wlan_spectral_init(void);
50 
51 /**
52  * wlan_spectral_deinit() - API to deinit spectral component
53  *
54  * This API is invoked from dispatcher deinit during all component deinit.
55  * This API will unregister all registered handlers for pdev and peer object
56  * create/delete notification.
57  *
58  * Return: SUCCESS,
59  *         Failure
60  */
61 QDF_STATUS wlan_spectral_deinit(void);
62 
63 /**
64  * wlan_lmac_if_sptrl_register_rx_ops() - Register lmac interface Rx operations
65  * @rx_ops: Pointer to lmac interface Rx operations structure
66  *
67  * API to register spectral related lmac interface Rx operations
68  *
69  * Return: None
70  */
71 void
72 wlan_lmac_if_sptrl_register_rx_ops(struct wlan_lmac_if_rx_ops *rx_ops);
73 
74 /**
75  * wlan_register_spectral_wmi_ops() - Register Spectral WMI operations
76  * @psoc - Pointer to psoc object
77  * @wmi_ops - pointer to the structure holding the Spectral WMI
78  *            operations
79  *
80  * API to register Spectral WMI operations
81  *
82  * Return: QDF_STATUS
83 */
84 QDF_STATUS
85 wlan_register_spectral_wmi_ops(struct wlan_objmgr_psoc *psoc,
86 			       struct spectral_wmi_ops *wmi_ops);
87 
88 /**
89  * wlan_register_spectral_tgt_ops() - Register Spectral target operations
90  * @psoc - Pointer to psoc object
91  * @tgt_ops - pointer to the structure holding the Spectral target
92  *            operations
93  *
94  * API to register Spectral target operations
95  *
96  * Return: QDF_STATUS
97  */
98 QDF_STATUS
99 wlan_register_spectral_tgt_ops(struct wlan_objmgr_psoc *psoc,
100 			       struct spectral_tgt_ops *tgt_ops);
101 
102 /**
103  * struct spectral_legacy_cbacks - Spectral legacy callbacks
104  * @vdev_get_chan_freq:          Get channel frequency
105  * @vdev_get_chan_freq_seg2:     Get secondary 80 center frequency
106  * @vdev_get_ch_width:           Get channel width
107  * @vdev_get_sec20chan_freq_mhz: Get seconadry 20 frequency
108  */
109 struct spectral_legacy_cbacks {
110 	int16_t (*vdev_get_chan_freq)(struct wlan_objmgr_vdev *vdev);
111 	int16_t (*vdev_get_chan_freq_seg2)(struct wlan_objmgr_vdev *vdev);
112 	enum phy_ch_width (*vdev_get_ch_width)(struct wlan_objmgr_vdev *vdev);
113 	int (*vdev_get_sec20chan_freq_mhz)(struct wlan_objmgr_vdev *vdev,
114 					   uint16_t *sec20chan_freq);
115 };
116 
117 /**
118  * spectral_vdev_get_chan_freq - Get vdev channel frequency
119  * @vdev:          vdev object
120  *
121  * Return: vdev operating frequency
122  */
123 int16_t spectral_vdev_get_chan_freq(struct wlan_objmgr_vdev *vdev);
124 
125 /**
126  * spectral_vdev_get_chan_freq_seg2 - Get vdev's secondary 80 center frequency
127  * @vdev: vdev object
128  *
129  * Return: vdev secondary 80 center frequency
130  */
131 int16_t spectral_vdev_get_chan_freq_seg2(struct wlan_objmgr_vdev *vdev);
132 
133 /**
134  * spectral_vdev_get_sec20chan_freq_mhz - Get vdev secondary channel frequency
135  * @vdev:   vdev object
136  * @sec20chan_freq: secondary channel frequency
137  *
138  * Return: secondary channel freq
139  */
140 int spectral_vdev_get_sec20chan_freq_mhz(struct wlan_objmgr_vdev *vdev,
141 					uint16_t *sec20chan_freq);
142 
143 /**
144  * spectral_register_legacy_cb() - Register spectral legacy callbacks
145  * commands on spectral parameters
146  * @psoc    - the physical device object
147  * @legacy_cbacks - Reference to struct spectral_legacy_cbacks from which
148  * function pointers need to be copied
149  *
150  * API to register spectral related legacy callbacks
151  *
152  * Return: QDF_STATUS_SUCCESS upon successful registration,
153  *         QDF_STATUS_E_FAILURE upon failure
154  */
155 QDF_STATUS spectral_register_legacy_cb(
156 	struct wlan_objmgr_psoc *psoc,
157 	struct spectral_legacy_cbacks *legacy_cbacks);
158 
159 /**
160  * spectral_vdev_get_ch_width() - Get the channel bandwidth
161  * @vdev    - Pointer to vdev
162  *
163  * API to get the channel bandwidth of a given vdev
164  *
165  * Return: Enumeration corresponding to the channel bandwidth
166  */
167 enum phy_ch_width
168 spectral_vdev_get_ch_width(struct wlan_objmgr_vdev *vdev);
169 
170 /**
171  * spectral_pdev_open() - Spectral pdev open handler
172  * @pdev:  pointer to pdev object
173  *
174  * API to execute operations on pdev open
175  *
176  * Return: QDF_STATUS_SUCCESS upon successful registration,
177  *         QDF_STATUS_E_FAILURE upon failure
178  */
179 QDF_STATUS spectral_pdev_open(struct wlan_objmgr_pdev *pdev);
180 
181 /**
182  * wlan_spectral_psoc_open() - Spectral psoc open handler
183  * @psoc:  pointer to psoc object
184  *
185  * API to execute operations on psoc open
186  *
187  * Return: QDF_STATUS_SUCCESS upon successful registration,
188  *         QDF_STATUS_E_FAILURE upon failure
189  */
190 QDF_STATUS wlan_spectral_psoc_open(struct wlan_objmgr_psoc *psoc);
191 
192 /**
193  * wlan_spectral_psoc_close() - Spectral psoc close handler
194  * @psoc:  pointer to psoc object
195  *
196  * API to execute operations on psoc close
197  *
198  * Return: QDF_STATUS_SUCCESS upon successful registration,
199  *         QDF_STATUS_E_FAILURE upon failure
200  */
201 QDF_STATUS wlan_spectral_psoc_close(struct wlan_objmgr_psoc *psoc);
202 
203 /**
204  * wlan_spectral_psoc_enable() - Spectral psoc enable handler
205  * @psoc:  pointer to psoc object
206  *
207  * API to execute operations on psoc enable
208  *
209  * Return: QDF_STATUS_SUCCESS upon successful registration,
210  *         QDF_STATUS_E_FAILURE upon failure
211  */
212 QDF_STATUS wlan_spectral_psoc_enable(struct wlan_objmgr_psoc *psoc);
213 
214 /**
215  * wlan_spectral_psoc_disable() - Spectral psoc disable handler
216  * @psoc:  pointer to psoc object
217  *
218  * API to execute operations on psoc disable
219  *
220  * Return: QDF_STATUS_SUCCESS upon successful registration,
221  *         QDF_STATUS_E_FAILURE upon failure
222  */
223 QDF_STATUS wlan_spectral_psoc_disable(struct wlan_objmgr_psoc *psoc);
224 
225 /**
226  * spectral_register_dbr() - register Spectral event handler with DDMA
227  * @pdev:  pointer to pdev object
228  *
229  * API to register event handler with Direct DMA
230  *
231  * Return: QDF_STATUS_SUCCESS upon successful registration,
232  *         QDF_STATUS_E_FAILURE upon failure
233  */
234 
235 QDF_STATUS spectral_register_dbr(struct wlan_objmgr_pdev *pdev);
236 
237 /**
238  * spectral_unregister_dbr() - unregister Spectral event handler with DDMA
239  * @pdev:  pointer to pdev object
240  *
241  * API to unregister event handler with Direct DMA
242  *
243  * Return: QDF_STATUS_SUCCESS upon successful unregistration,
244  *         QDF_STATUS_E_FAILURE upon failure
245  */
246 QDF_STATUS spectral_unregister_dbr(struct wlan_objmgr_pdev *pdev);
247 
248 #ifdef DIRECT_BUF_RX_ENABLE
249 /**
250  * spectral_dbr_event_handler() - Spectral dbr event handler
251  * @pdev:  pointer to pdev object
252  * @payload: dbr event buffer
253  *
254  * API to handle spectral dbr event
255  *
256  * Return: true to release buf
257  */
258 bool spectral_dbr_event_handler(struct wlan_objmgr_pdev *pdev,
259 				struct direct_buf_rx_data *payload);
260 #endif
261 #endif /* _WLAN_SPECTRAL_UTILS_API_H_*/
262