1 /*
2 * Copyright (c) 2022-2024, Qualcomm Innovation Center, Inc. All rights reserved.
3 *
4 * Permission to use, copy, modify, and/or distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
7 *
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 */
16
17 /**
18 * DOC: Declare public API related to the pre_cac called by north bound
19 * HDD/OSIF/LIM
20 */
21
22 #ifndef _WLAN_PRE_CAC_UCFG_API_H_
23 #define _WLAN_PRE_CAC_UCFG_API_H_
24
25 #include <qdf_status.h>
26 #include <qdf_types.h>
27 #include "wlan_pre_cac_public_struct.h"
28 #include "wlan_objmgr_psoc_obj.h"
29
30 #ifdef PRE_CAC_SUPPORT
31 /**
32 * ucfg_pre_cac_init() - pre cac component initialization.
33 *
34 * This function initializes the pre cac component and registers
35 * the handlers which are invoked on vdev creation.
36 *
37 * Return: For successful registration - QDF_STATUS_SUCCESS,
38 * else QDF_STATUS error codes.
39 */
40 QDF_STATUS ucfg_pre_cac_init(void);
41
42 /**
43 * ucfg_pre_cac_deinit() - pre cac component deinit.
44 *
45 * This function deinits pre cac component.
46 *
47 * Return: None
48 */
49 void ucfg_pre_cac_deinit(void);
50
51 /*
52 * ucfg_pre_cac_set_osif_cb() - set pre cac osif callbacks.
53 * @pre_cac_ops: pre cac ops
54 *
55 * Return: None
56 */
57 void ucfg_pre_cac_set_osif_cb(struct pre_cac_ops *pre_cac_ops);
58
59 /**
60 * ucfg_pre_cac_clear_work() - clear pre cac work fn and arg.
61 * @psoc: psoc object manager
62 *
63 * Return: None
64 */
65 void ucfg_pre_cac_clear_work(struct wlan_objmgr_psoc *psoc);
66
67 /**
68 * ucfg_pre_cac_is_active(): status of pre_cac
69 * @psoc: psoc object manager
70 *
71 * Return: status of pre_cac
72 */
73 bool ucfg_pre_cac_is_active(struct wlan_objmgr_psoc *psoc);
74
75 /**
76 * ucfg_pre_cac_validate_and_get_freq() - Validate and get pre cac frequency
77 * @pdev: pdev object manager
78 * @chan_freq: Channel frequency requested by userspace
79 * @pre_cac_chan_freq: Pointer to the pre CAC channel frequency storage
80 * @cac_ch_width: bandwidth of channel frequency pre_cac_chan_freq
81 *
82 * Validates the channel provided by userspace. If user provided channel 0,
83 * a valid outdoor channel must be selected from the regulatory channel.
84 *
85 * Return: Zero on success and non zero value on error
86 */
87 int ucfg_pre_cac_validate_and_get_freq(struct wlan_objmgr_pdev *pdev,
88 uint32_t chan_freq,
89 uint32_t *pre_cac_chan_freq,
90 enum phy_ch_width cac_ch_width);
91
92 #if defined(FEATURE_SAP_COND_CHAN_SWITCH)
93 /**
94 * ucfg_pre_cac_set_status() - Set pre cac status
95 * @vdev: vdev object manager
96 * @status: status of pre_cac
97 *
98 * Sets pre_cac status
99 *
100 * Return: Zero on success and non zero value on error
101 */
102 QDF_STATUS ucfg_pre_cac_set_status(struct wlan_objmgr_vdev *vdev, bool status);
103 #else
104 static inline QDF_STATUS
ucfg_pre_cac_set_status(struct wlan_objmgr_vdev * vdev,bool status)105 ucfg_pre_cac_set_status(struct wlan_objmgr_vdev *vdev, bool status)
106 {
107 return QDF_STATUS_SUCCESS;
108 }
109 #endif
110
111 /**
112 * ucfg_pre_cac_get_vdev_id() - Get pre cac vdev id
113 * @psoc: psoc object manager
114 * @vdev_id: pre cac vdev id
115 *
116 * Return: None
117 */
118 void ucfg_pre_cac_get_vdev_id(struct wlan_objmgr_psoc *psoc,
119 uint8_t *vdev_id);
120
121 /**
122 * ucfg_pre_cac_adapter_set() - Set pre cac adapter flag
123 * @vdev: vdev object manager
124 * @status: status
125 *
126 * Return: None
127 */
128 void ucfg_pre_cac_adapter_set(struct wlan_objmgr_vdev *vdev,
129 bool status);
130
131 /**
132 * ucfg_pre_cac_adapter_is_active() - Get pre cac adapter status
133 * @vdev: vdev object manager
134 *
135 * Return: pre cac complete status
136 */
137 bool ucfg_pre_cac_adapter_is_active(struct wlan_objmgr_vdev *vdev);
138
139 #if defined(FEATURE_SAP_COND_CHAN_SWITCH)
140 /**
141 * ucfg_pre_cac_set_freq_before_pre_cac() - Set frequency before pre cac
142 * @vdev: vdev object manager
143 * @freq: frequency
144 *
145 * Return: None
146 */
147 void ucfg_pre_cac_set_freq_before_pre_cac(struct wlan_objmgr_vdev *vdev,
148 qdf_freq_t freq);
149 #else
150 static inline void
ucfg_pre_cac_set_freq_before_pre_cac(struct wlan_objmgr_vdev * vdev,qdf_freq_t freq)151 ucfg_pre_cac_set_freq_before_pre_cac(struct wlan_objmgr_vdev *vdev,
152 qdf_freq_t freq)
153 {
154 }
155 #endif
156
157 /**
158 * ucfg_pre_cac_set_freq() - Set pre cac frequency
159 * @vdev: vdev object manager
160 * @freq: pre cac frequency
161 *
162 * Return: None
163 */
164 void ucfg_pre_cac_set_freq(struct wlan_objmgr_vdev *vdev,
165 qdf_freq_t freq);
166
167 /**
168 * ucfg_pre_cac_get_freq() - Get pre cac frequency
169 * @vdev: vdev object manager
170 *
171 * Return: pre cac frequency
172 */
173 qdf_freq_t ucfg_pre_cac_get_freq(struct wlan_objmgr_vdev *vdev);
174
175 /**
176 * ucfg_pre_cac_complete_set() - Set pre cac complete status
177 * @vdev: vdev object manager
178 * @status: status
179 *
180 * Return: None
181 */
182 void ucfg_pre_cac_complete_set(struct wlan_objmgr_vdev *vdev,
183 bool status);
184
185 /**
186 * ucfg_pre_cac_stop() - Stop pre cac
187 * @psoc: psoc object manager
188 *
189 * Return: None
190 */
191 void ucfg_pre_cac_stop(struct wlan_objmgr_psoc *psoc);
192
193 /**
194 * ucfg_pre_cac_clean_up() - Cleanup pre cac
195 * @psoc: psoc object manager
196 *
197 * Return: None
198 */
199 void ucfg_pre_cac_clean_up(struct wlan_objmgr_psoc *psoc);
200 #else
201 static inline
ucfg_pre_cac_init(void)202 QDF_STATUS ucfg_pre_cac_init(void)
203 {
204 return QDF_STATUS_SUCCESS;
205 }
206
207 static inline
ucfg_pre_cac_deinit(void)208 void ucfg_pre_cac_deinit(void)
209 {
210 }
211
212 static inline void
ucfg_pre_cac_set_osif_cb(struct pre_cac_ops * pre_cac_ops)213 ucfg_pre_cac_set_osif_cb(struct pre_cac_ops *pre_cac_ops)
214 {
215 }
216
217 static inline
ucfg_pre_cac_clear_work(struct wlan_objmgr_psoc * psoc)218 void ucfg_pre_cac_clear_work(struct wlan_objmgr_psoc *psoc)
219 {
220 }
221
222 static inline bool
ucfg_pre_cac_is_active(struct wlan_objmgr_psoc * psoc)223 ucfg_pre_cac_is_active(struct wlan_objmgr_psoc *psoc)
224 {
225 return false;
226 }
227
228 static inline int
ucfg_pre_cac_validate_and_get_freq(struct wlan_objmgr_pdev * pdev,uint32_t chan_freq,uint32_t * pre_cac_chan_freq,enum phy_ch_width cac_ch_width)229 ucfg_pre_cac_validate_and_get_freq(struct wlan_objmgr_pdev *pdev,
230 uint32_t chan_freq,
231 uint32_t *pre_cac_chan_freq,
232 enum phy_ch_width cac_ch_width)
233 {
234 return 0;
235 }
236
237 static inline QDF_STATUS
ucfg_pre_cac_set_status(struct wlan_objmgr_vdev * vdev,bool status)238 ucfg_pre_cac_set_status(struct wlan_objmgr_vdev *vdev, bool status)
239 {
240 return QDF_STATUS_SUCCESS;
241 }
242
243 static inline void
ucfg_pre_cac_get_vdev_id(struct wlan_objmgr_psoc * psoc,uint8_t * vdev_id)244 ucfg_pre_cac_get_vdev_id(struct wlan_objmgr_psoc *psoc,
245 uint8_t *vdev_id)
246 {
247 }
248
249 static inline void
ucfg_pre_cac_adapter_set(struct wlan_objmgr_vdev * vdev,bool status)250 ucfg_pre_cac_adapter_set(struct wlan_objmgr_vdev *vdev,
251 bool status)
252 {
253 }
254
255 static inline bool
ucfg_pre_cac_adapter_is_active(struct wlan_objmgr_vdev * vdev)256 ucfg_pre_cac_adapter_is_active(struct wlan_objmgr_vdev *vdev)
257 {
258 return false;
259 }
260
261 static inline void
ucfg_pre_cac_set_freq(struct wlan_objmgr_vdev * vdev,qdf_freq_t freq)262 ucfg_pre_cac_set_freq(struct wlan_objmgr_vdev *vdev,
263 qdf_freq_t freq)
264 {
265 }
266
267 static inline qdf_freq_t
ucfg_pre_cac_get_freq(struct wlan_objmgr_vdev * vdev)268 ucfg_pre_cac_get_freq(struct wlan_objmgr_vdev *vdev)
269 {
270 return 0;
271 }
272
273 static inline void
ucfg_pre_cac_complete_set(struct wlan_objmgr_vdev * vdev,bool status)274 ucfg_pre_cac_complete_set(struct wlan_objmgr_vdev *vdev,
275 bool status)
276 {
277 }
278
279 static inline void
ucfg_pre_cac_stop(struct wlan_objmgr_psoc * psoc)280 ucfg_pre_cac_stop(struct wlan_objmgr_psoc *psoc)
281 {
282 }
283
284 static inline void
ucfg_pre_cac_clean_up(struct wlan_objmgr_psoc * psoc)285 ucfg_pre_cac_clean_up(struct wlan_objmgr_psoc *psoc)
286 {
287 }
288 #endif /* PRE_CAC_SUPPORT */
289 #endif /* _WLAN_PRE_CAC_UCFG_API_H_ */
290