1 /*
2 * Copyright (c) 2020-2021, The Linux Foundation. All rights reserved.
3 * Copyright (c) 2021-2023 Qualcomm Innovation Center, Inc. All rights reserved.
4 *
5 * Permission to use, copy, modify, and/or distribute this software for any
6 * purpose with or without fee is hereby granted, provided that the above
7 * copyright notice and this permission notice appear in all copies.
8 *
9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16 */
17
18 /**
19 * DOC: This file has the dcs dispatcher API which is exposed to outside of dcs
20 * component.
21 */
22 #ifndef _WLAN_DCS_UCFG_API_H_
23 #define _WLAN_DCS_UCFG_API_H_
24
25 #include <qdf_status.h>
26 #include <wlan_objmgr_pdev_obj.h>
27 #include <wlan_dcs_public_structs.h>
28
29 /**
30 * typedef dcs_callback() - DCS callback
31 * @psoc: Pointer to psoc
32 * @mac_id: mac id
33 * @interference_type: interference type
34 * @arg: list of arguments
35 */
36 typedef void (*dcs_callback)(
37 struct wlan_objmgr_psoc *psoc,
38 uint8_t mac_id,
39 uint8_t interference_type,
40 void *arg);
41
42 /**
43 * typedef dcs_switch_chan_cb() - DCS callback for switching channel
44 * @vdev: Pointer to vdev
45 * @tgt_freq: target channel frequency
46 * @tgt_width: target channel width
47 */
48 typedef QDF_STATUS (*dcs_switch_chan_cb)(struct wlan_objmgr_vdev *vdev,
49 qdf_freq_t tgt_freq,
50 enum phy_ch_width tgt_width);
51
52 /**
53 * typedef dcs_afc_select_chan_cb() - DCS callback for AFC channel selection
54 * @arg: pointer to argument
55 * @vdev_id: vdev id
56 * @cur_freq: current channel frequency
57 * @cur_bw: current channel bandwidth
58 * @pref_bw: pointer to bandwidth of prefer bandwidth when input, and target
59 * bandwidth switch to when output
60 */
61 typedef qdf_freq_t (*dcs_afc_select_chan_cb)(void *arg,
62 uint32_t vdev_id,
63 qdf_freq_t cur_freq,
64 enum phy_ch_width cur_bw,
65 enum phy_ch_width *pref_bw);
66
67 #ifdef DCS_INTERFERENCE_DETECTION
68 /**
69 * ucfg_dcs_register_cb() - API to register dcs callback
70 * @psoc: pointer to psoc object
71 * @cbk: dcs callback to be registered
72 * @arg: argument
73 *
74 * This function gets called to register dcs callback function
75 *
76 * Return: None
77 */
78 void ucfg_dcs_register_cb(
79 struct wlan_objmgr_psoc *psoc,
80 dcs_callback cbk,
81 void *arg);
82
83 /**
84 * ucfg_dcs_register_user_cb() - API to register dcs user callback
85 * @psoc: pointer to psoc object
86 * @mac_id: mac id
87 * @vdev_id: vdev id
88 * @cb: dcs user callback to be registered
89 *
90 * Return: None
91 */
92 void ucfg_dcs_register_user_cb(struct wlan_objmgr_psoc *psoc,
93 uint8_t mac_id, uint8_t vdev_id,
94 void (*cb)(uint8_t vdev_id,
95 struct wlan_host_dcs_im_user_stats *stats,
96 int status));
97
98 /**
99 * ucfg_dcs_register_awgn_cb() - API to register dcs awgn callback
100 * @psoc: pointer to psoc object
101 * @cb: dcs switch channel callback to be registered
102 *
103 * Return: QDF_STATUS
104 */
105 QDF_STATUS ucfg_dcs_register_awgn_cb(struct wlan_objmgr_psoc *psoc,
106 dcs_switch_chan_cb cb);
107
108 /**
109 * ucfg_dcs_register_afc_sel_chan_cb() - API to register SAP channel selection
110 * callback for AFC DCS
111 * @psoc: pointer to psoc object
112 * @cb: dcs user callback to be registered
113 * @arg: argument
114 *
115 * Return: QDF_STATUS
116 */
117 QDF_STATUS ucfg_dcs_register_afc_sel_chan_cb(struct wlan_objmgr_psoc *psoc,
118 dcs_afc_select_chan_cb cb,
119 void *arg);
120 /**
121 * ucfg_wlan_dcs_cmd(): API to send dcs command
122 * @psoc: pointer to psoc object
123 * @mac_id: mac id
124 * @is_host_pdev_id: pdev_id is host id or not
125 *
126 * This function gets called to send dcs command
127 *
128 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
129 */
130 QDF_STATUS
131 ucfg_wlan_dcs_cmd(struct wlan_objmgr_psoc *psoc,
132 uint32_t mac_id,
133 bool is_host_pdev_id);
134
135 /**
136 * ucfg_config_dcs_enable() - API to config dcs enable
137 * @psoc: pointer to psoc object
138 * @mac_id: mac id
139 * @interference_type: type mask(WLAN_HOST_DCS_CWIM / WLAN_HOST_DCS_WLANIM)
140 *
141 * This function gets called to config dcs enable
142 *
143 * Return: None
144 */
145 void ucfg_config_dcs_enable(struct wlan_objmgr_psoc *psoc,
146 uint32_t mac_id,
147 uint8_t interference_type);
148
149 /**
150 * ucfg_config_dcs_disable() - API to config dcs disable
151 * @psoc: pointer to psoc object
152 * @mac_id: mac id
153 * @interference_type: type mask(WLAN_HOST_DCS_CWIM / WLAN_HOST_DCS_WLANIM)
154 *
155 * This function gets called to config dcs disable
156 *
157 * Return: None
158 */
159 void ucfg_config_dcs_disable(struct wlan_objmgr_psoc *psoc,
160 uint32_t mac_id,
161 uint8_t interference_type);
162
163 /**
164 * ucfg_get_dcs_enable() - API to get dcs enable
165 * @psoc: pointer to psoc object
166 * @mac_id: mac id
167 *
168 * This function gets called to get current host
169 * config dcs enable/disable status
170 *
171 * Return: WLANIM/CWIM enable status
172 */
173 uint8_t ucfg_get_dcs_enable(struct wlan_objmgr_psoc *psoc, uint8_t mac_id);
174
175 /**
176 * ucfg_dcs_clear() - API to clear dcs related information
177 * @psoc: pointer to psoc object
178 * @mac_id: mac id
179 *
180 * This function gets called to clear dcs related information
181 *
182 * Return: None
183 */
184 void ucfg_dcs_clear(struct wlan_objmgr_psoc *psoc, uint32_t mac_id);
185
186 /**
187 * ucfg_config_dcs_event_data() - config dcs event data to do algorithm
188 * process or not
189 * @psoc: psoc pointer
190 * @mac_id: mac id
191 * @dcs_algorithm_process: dcs algorithm process or not
192 *
193 * The function gets called to config dcs event data to do algorithm
194 * process or not
195 *
196 * Return: None
197 */
198 void ucfg_config_dcs_event_data(struct wlan_objmgr_psoc *psoc, uint32_t mac_id,
199 bool dcs_algorithm_process);
200
201 /*
202 * ucfg_dcs_reset_user_stats() - API to reset dcs user stats
203 * @psoc: pointer to psoc object
204 * @mac_id: mac id
205 *
206 * Return: None
207 */
208 void ucfg_dcs_reset_user_stats(struct wlan_objmgr_psoc *psoc, uint8_t mac_id);
209
210 /**
211 * ucfg_dcs_set_user_request() - API to set dcs user stats request counter
212 * @psoc: pointer to psoc object
213 * @mac_id: mac id
214 * @user_request_count: user stats request counter
215 *
216 * Return: None
217 */
218 void ucfg_dcs_set_user_request(struct wlan_objmgr_psoc *psoc, uint8_t mac_id,
219 uint32_t user_request_count);
220
221 /**
222 * ucfg_dcs_get_ch_util() - API to get channel interference values
223 * @psoc: pointer to psoc object
224 * @mac_id: mac id
225 * @dcs_stats: pointer to wlan_host_dcs_ch_util_stats
226 *
227 * Return: Integer
228 */
229 QDF_STATUS ucfg_dcs_get_ch_util(struct wlan_objmgr_psoc *psoc, uint8_t mac_id,
230 struct wlan_host_dcs_ch_util_stats *dcs_stats);
231 /**
232 * ucfg_dcs_switch_chan() - switch channel for vdev
233 * @vdev: vdev ptr
234 * @tgt_freq: target frequency
235 * @tgt_width: target channel width
236 *
237 * Return: QDF_STATUS
238 */
239 QDF_STATUS
240 ucfg_dcs_switch_chan(struct wlan_objmgr_vdev *vdev, qdf_freq_t tgt_freq,
241 enum phy_ch_width tgt_width);
242 #else
243 static inline void
ucfg_dcs_register_cb(struct wlan_objmgr_psoc * psoc,dcs_callback cbk,void * arg)244 ucfg_dcs_register_cb(struct wlan_objmgr_psoc *psoc, dcs_callback cbk, void *arg)
245 {
246 }
247
248 static inline void
ucfg_dcs_register_user_cb(struct wlan_objmgr_psoc * psoc,uint8_t mac_id,uint8_t vdev_id,void (* cb)(uint8_t vdev_id,struct wlan_host_dcs_im_user_stats * stats,int status))249 ucfg_dcs_register_user_cb(struct wlan_objmgr_psoc *psoc,
250 uint8_t mac_id, uint8_t vdev_id,
251 void (*cb)(uint8_t vdev_id,
252 struct wlan_host_dcs_im_user_stats *stats,
253 int status))
254 {
255 }
256
257 static inline QDF_STATUS
ucfg_wlan_dcs_cmd(struct wlan_objmgr_psoc * psoc,uint32_t mac_id,bool is_host_pdev_id)258 ucfg_wlan_dcs_cmd(struct wlan_objmgr_psoc *psoc, uint32_t mac_id,
259 bool is_host_pdev_id)
260 {
261 return QDF_STATUS_SUCCESS;
262 }
263
264 static inline void
ucfg_config_dcs_enable(struct wlan_objmgr_psoc * psoc,uint32_t mac_id,uint8_t interference_type)265 ucfg_config_dcs_enable(struct wlan_objmgr_psoc *psoc, uint32_t mac_id,
266 uint8_t interference_type)
267 {
268 }
269
270 static inline void
ucfg_config_dcs_disable(struct wlan_objmgr_psoc * psoc,uint32_t mac_id,uint8_t interference_type)271 ucfg_config_dcs_disable(struct wlan_objmgr_psoc *psoc, uint32_t mac_id,
272 uint8_t interference_type)
273 {
274 }
275
276 static inline uint8_t
ucfg_get_dcs_enable(struct wlan_objmgr_psoc * psoc,uint8_t mac_id)277 ucfg_get_dcs_enable(struct wlan_objmgr_psoc *psoc, uint8_t mac_id)
278 {
279 return 0;
280 }
281
282 static inline void
ucfg_dcs_clear(struct wlan_objmgr_psoc * psoc,uint32_t mac_id)283 ucfg_dcs_clear(struct wlan_objmgr_psoc *psoc, uint32_t mac_id)
284 {
285 }
286
287 static inline void
ucfg_config_dcs_event_data(struct wlan_objmgr_psoc * psoc,uint32_t mac_id,bool dcs_algorithm_process)288 ucfg_config_dcs_event_data(struct wlan_objmgr_psoc *psoc, uint32_t mac_id,
289 bool dcs_algorithm_process)
290 {
291 }
292
293 static inline void
ucfg_dcs_reset_user_stats(struct wlan_objmgr_psoc * psoc,uint8_t mac_id)294 ucfg_dcs_reset_user_stats(struct wlan_objmgr_psoc *psoc, uint8_t mac_id)
295 {
296 }
297
298 static inline void
ucfg_dcs_set_user_request(struct wlan_objmgr_psoc * psoc,uint8_t mac_id,uint32_t user_request_count)299 ucfg_dcs_set_user_request(struct wlan_objmgr_psoc *psoc, uint8_t mac_id,
300 uint32_t user_request_count)
301 {
302 }
303
304 static inline QDF_STATUS
ucfg_dcs_get_ch_util(struct wlan_objmgr_psoc * psoc,uint8_t mac_id,struct wlan_host_dcs_ch_util_stats * dcs_stats)305 ucfg_dcs_get_ch_util(struct wlan_objmgr_psoc *psoc, uint8_t mac_id,
306 struct wlan_host_dcs_ch_util_stats *dcs_stats)
307 {
308 return QDF_STATUS_SUCCESS;
309 }
310
311 static inline QDF_STATUS
ucfg_dcs_switch_chan(struct wlan_objmgr_vdev * vdev,qdf_freq_t tgt_freq,enum phy_ch_width tgt_width)312 ucfg_dcs_switch_chan(struct wlan_objmgr_vdev *vdev, qdf_freq_t tgt_freq,
313 enum phy_ch_width tgt_width)
314 {
315 return QDF_STATUS_SUCCESS;
316 }
317
318 #endif
319 #endif /* _WLAN_DCS_UCFG_API_H_ */
320