xref: /wlan-dirver/qca-wifi-host-cmn/umac/mlme/vdev_mgr/dispatcher/inc/wlan_vdev_mlme_api.h (revision 8cfe6b10058a04cafb17eed051f2ddf11bee8931)
1 /*
2  * Copyright (c) 2018-2019, 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: Define VDEV MLME public APIs
20  */
21 
22 #ifndef _WLAN_VDEV_MLME_API_H_
23 #define _WLAN_VDEV_MLME_API_H_
24 
25 #include <wlan_ext_mlme_obj_types.h>
26 
27 #define WLAN_INVALID_VDEV_ID 255
28 #define WILDCARD_PDEV_ID 0x0
29 
30 #ifdef WLAN_FEATURE_SR
31 #define PSR_DISALLOWED 1
32 #define NON_SRG_SPR_ENABLE_SIZE 1
33 #define SR_PARAM_VAL_DBM_UNIT 1
34 #define SR_PARAM_VAL_DBM_POS 29
35 #define NON_SRG_PARAM_VAL_DBM_SIZE 1
36 #define NON_SRG_MAX_PD_OFFSET_POS 0
37 #define NON_SRG_MAX_PD_OFFSET_SIZE 8
38 #define SR_PD_THRESHOLD_MIN -82
39 #define SRG_SPR_ENABLE_POS 30
40 #define SRG_THRESHOLD_MAX_PD_POS 8
41 #define NON_SRG_PD_SR_DISALLOWED 0x02
42 #define HE_SIG_VAL_15_ALLOWED 0x10
43 #define NON_SRG_OFFSET_PRESENT 0x04
44 #define SRG_INFO_PRESENT 0x08
45 #define NON_SRG_SPR_ENABLE_POS 31
46 #define NON_SRG_SPR_ENABLE 0x80
47 #define NON_SR_PD_THRESHOLD_DISABLED 0x80
48 #define SR_PADDING_BYTE 8
49 #endif
50 
51 
52 /**
53  * enum wlan_mlme_peer_param_id - peer param id in mlme layer
54  * @WLAN_MLME_PEER_BW_PUNCTURE: update puncture 20 MHz bitmap
55  * @WLAN_MLME_PEER_MAX: max enumeration
56  */
57 enum wlan_mlme_peer_param_id {
58 	WLAN_MLME_PEER_BW_PUNCTURE,
59 	WLAN_MLME_PEER_MAX
60 };
61 
62 /**
63  * wlan_vdev_mlme_get_cmpt_obj - Retrieves MLME component object
64  * from VDEV object
65  * @vdev: pointer to vdev object
66  *
67  * Retrieves MLME component object from VDEV object
68  *
69  * Return: comp handle on SUCCESS
70  *         NULL, if it fails to retrieve
71  */
72 struct vdev_mlme_obj *wlan_vdev_mlme_get_cmpt_obj(
73 						struct wlan_objmgr_vdev *vdev);
74 /**
75  * wlan_vdev_mlme_set_ext_hdl - Sets legacy handle
76  * @vdev: pointer to vdev object
77  * @ext_hdl: pointer to legacy handle
78  *
79  * Sets Legacy handle to MLME component object
80  *
81  * Return:
82  */
83 void wlan_vdev_mlme_set_ext_hdl(struct wlan_objmgr_vdev *vdev,
84 				mlme_vdev_ext_t *ext_hdl);
85 
86 /**
87  * wlan_vdev_mlme_get_ext_hdl - Returns legacy handle
88  * @vdev: pointer to vdev object
89  *
90  * Retrieves legacy handle from vdev mlme component object
91  *
92  * Return: legacy handle on SUCCESS
93  *         NULL, if it fails to retrieve
94  */
95 mlme_vdev_ext_t *wlan_vdev_mlme_get_ext_hdl(struct wlan_objmgr_vdev *vdev);
96 
97 /**
98  * wlan_vdev_mlme_sm_deliver_evt() - Delivers event to VDEV MLME SM
99  * @vdev: Object manager VDEV object
100  * @event: MLME event
101  * @event_data_len: data size
102  * @event_data: event data
103  *
104  * API to dispatch event to VDEV MLME SM with lock acquired
105  *
106  * Return: SUCCESS: on handling event
107  *         FAILURE: on ignoring the event
108  */
109 QDF_STATUS wlan_vdev_mlme_sm_deliver_evt(struct wlan_objmgr_vdev *vdev,
110 					 enum wlan_vdev_sm_evt event,
111 					 uint16_t event_data_len,
112 					 void *event_data);
113 
114 /**
115  * wlan_vdev_mlme_sm_deliver_evt_sync() - Delivers event to VDEV MLME SM sync
116  * @vdev: Object manager VDEV object
117  * @event: MLME event
118  * @event_data_len: data size
119  * @event_data: event data
120  *
121  * API to dispatch event to VDEV MLME SM with lock acquired
122  *
123  * Return: SUCCESS: on handling event
124  *         FAILURE: on ignoring the event
125  */
126 QDF_STATUS wlan_vdev_mlme_sm_deliver_evt_sync(struct wlan_objmgr_vdev *vdev,
127 					      enum wlan_vdev_sm_evt event,
128 					      uint16_t event_data_len,
129 					      void *event_data);
130 
131 #ifdef SM_ENG_HIST_ENABLE
132 /**
133  * wlan_vdev_mlme_sm_history_print() - Prints SM history
134  * @vdev: Object manager VDEV object
135  *
136  * API to print SM history
137  *
138  * Return: void
139  */
140 void wlan_vdev_mlme_sm_history_print(struct wlan_objmgr_vdev *vdev);
141 
142 #endif
143 
144 /**
145  * wlan_vdev_allow_connect_n_tx() - Checks whether VDEV is in operational state
146  * @vdev: Object manager VDEV object
147  *
148  * API to checks the VDEV MLME SM state to allow tx or connections
149  *
150  * Return: SUCCESS: to allow tx or connection
151  *         FAILURE: otherwise failure
152  */
153 QDF_STATUS wlan_vdev_allow_connect_n_tx(struct wlan_objmgr_vdev *vdev);
154 
155 /**
156  * wlan_vdev_mlme_is_active() - Checks whether VDEV is in active state
157  * @vdev: Object manager VDEV object
158  *
159  * API to checks the VDEV MLME SM state to check channel is configured in FW
160  *
161  * Return: SUCCESS: valid channel is configured
162  *         FAILURE: otherwise failure
163  */
164 QDF_STATUS wlan_vdev_mlme_is_active(struct wlan_objmgr_vdev *vdev);
165 
166 /**
167  * wlan_vdev_chan_config_valid() - Checks whether VDEV chan config valid
168  * @vdev: Object manager VDEV object
169  *
170  * API to checks the VDEV MLME SM state to check channel is configured in Host
171  *
172  * Return: SUCCESS: valid channel is configured
173  *         FAILURE: otherwise failure
174  */
175 QDF_STATUS wlan_vdev_chan_config_valid(struct wlan_objmgr_vdev *vdev);
176 
177 /**
178  * wlan_vdev_mlme_is_csa_restart() - Checks whether VDEV MLME SM is in CSA
179  * @vdev: Object manager VDEV object
180  *
181  * API to checks the VDEV MLME SM state for CSA_RESTART substate
182  *
183  * Return: SUCCESS: if it is in CSA_RESTART sub state
184  *         FAILURE: otherwise failure
185  */
186 QDF_STATUS wlan_vdev_mlme_is_csa_restart(struct wlan_objmgr_vdev *vdev);
187 
188 /**
189  * wlan_vdev_is_going_down() - Checks whether VDEV is being brought down
190  * @vdev: Object manager VDEV object
191  *
192  * API to checks the VDEV MLME SM state to check VDEV is being brought down
193  *
194  * Return: SUCCESS: valid channel is configured
195  *         FAILURE: otherwise failure
196  */
197 QDF_STATUS wlan_vdev_is_going_down(struct wlan_objmgr_vdev *vdev);
198 
199 /**
200  * wlan_vdev_is_mlo_peer_create_allowed() - Checks whether PEER can be created
201  * @vdev: Object manager VDEV object
202  *
203  * API to check the VDEV MLME SM state to allow PEER association in MLD
204  *
205  * Return: SUCCESS: if peer create can be allowed
206  *         FAILURE: otherwise failure
207  */
208 QDF_STATUS wlan_vdev_is_mlo_peer_create_allowed(struct wlan_objmgr_vdev *vdev);
209 
210 /**
211  * wlan_vdev_is_restart_progress() - Checks VDEV restart is in progress
212  * @vdev: Object manager VDEV object
213  *
214  * API to check whether restarts is in progress
215  *
216  * Return: SUCCESS: if restart is in progress
217  *         FAILURE: otherwise failure
218  */
219 QDF_STATUS wlan_vdev_is_restart_progress(struct wlan_objmgr_vdev *vdev);
220 
221 /**
222  * wlan_vdev_is_dfs_cac_wait() - Checks VDEV is in cac wait state
223  * @vdev: Object manager VDEV object
224  *
225  * API to check whether state is cac wait state
226  *
227  * Return: SUCCESS: if state is cac wait state
228  *         FAILURE: otherwise failure
229  */
230 QDF_STATUS wlan_vdev_is_dfs_cac_wait(struct wlan_objmgr_vdev *vdev);
231 
232 /**
233  * wlan_vdev_mlme_cmd_lock - Acquire lock for command queuing atomicity
234  * @vdev: Object manager VDEV object
235  *
236  * API to take VDEV MLME command lock
237  *
238  * Return: void
239  */
240 void wlan_vdev_mlme_cmd_lock(struct wlan_objmgr_vdev *vdev);
241 
242 /**
243  * wlan_vdev_mlme_cmd_unlock - Release lock for command queuing atomicity
244  * @vdev: Object manager VDEV object
245  *
246  * API to release VDEV MLME command lock
247  *
248  * Return: void
249  */
250 void wlan_vdev_mlme_cmd_unlock(struct wlan_objmgr_vdev *vdev);
251 
252 /**
253  * wlan_vdev_mlme_is_scan_allowed() - Checks whether scan is allowed
254  * @vdev: Object manager VDEV object
255  *
256  * API to checks the VDEV MLME SM state to check scan is allowed
257  *
258  * Return: SUCCESS: if scan is allowed
259  *         FAILURE: otherwise failure
260  */
261 QDF_STATUS wlan_vdev_mlme_is_scan_allowed(struct wlan_objmgr_vdev *vdev);
262 
263 /**
264  * wlan_vdev_mlme_is_init_state() - Checks whether vdev is in init state
265  * @vdev: Object manager VDEV object
266  *
267  * API to checks the VDEV MLME SM state is in init state or not
268  *
269  * Return: SUCCESS: if vdev is in init state
270  *         FAILURE: otherwise failure
271  */
272 QDF_STATUS wlan_vdev_mlme_is_init_state(struct wlan_objmgr_vdev *vdev);
273 
274 /**
275  * wlan_vdev_is_up_active_state() - Checks whether vdev is in up active state
276  * @vdev: Object manager VDEV object
277  *
278  * API to checks the VDEV MLME SM state is in UP ACTIVE state
279  *
280  * Return: SUCCESS: if vdev is in UP ACTIVE state
281  *         FAILURE: otherwise failure
282  */
283 QDF_STATUS wlan_vdev_is_up_active_state(struct wlan_objmgr_vdev *vdev);
284 
285 #ifdef WLAN_FEATURE_11BE_MLO
286 /**
287  * wlan_vdev_mlme_get_is_mlo_link() - check if its mlo link vdev
288  * @psoc: PSOC object
289  * @vdev_id: VDEV Id
290  *
291  * Return: True if it is mlo link, otherwise false.
292  */
293 bool
294 wlan_vdev_mlme_get_is_mlo_link(struct wlan_objmgr_psoc *psoc,
295 			       uint8_t vdev_id);
296 
297 /**
298  * wlan_vdev_mlme_get_is_mlo_vdev() - check if its mlo assoc vdev
299  * @psoc: PSOC object
300  * @vdev_id: VDEV Id
301  *
302  * Return: True if it is mlo link, otherwise false.
303  */
304 bool
305 wlan_vdev_mlme_get_is_mlo_vdev(struct wlan_objmgr_psoc *psoc,
306 			       uint8_t vdev_id);
307 #else
308 static inline bool
309 wlan_vdev_mlme_get_is_mlo_link(struct wlan_objmgr_psoc *psoc,
310 			       uint8_t vdev_id)
311 {
312 	return false;
313 }
314 
315 static inline bool
316 wlan_vdev_mlme_get_is_mlo_vdev(struct wlan_objmgr_psoc *psoc,
317 			       uint8_t vdev_id)
318 {
319 	return false;
320 }
321 #endif
322 #ifdef WLAN_FEATURE_SR
323 /**
324  * wlan_mlme_update_sr_data() - Updates SR values
325  * @vdev: Object manager VDEV object
326  * @val: SR value
327  * @srg_pd_threshold: SRG PD threshold sent by userspace
328  * @non_srg_pd_threshold: NON SRG PD threshold sent by userspace
329  * @is_sr_enable: SR enable/disable from userspace
330  *
331  * API to Update SR value based on AP advertisement and provided by userspace
332  *
333  * Return: true/flase
334  */
335 void
336 wlan_mlme_update_sr_data(struct wlan_objmgr_vdev *vdev, int *val,
337 			 int32_t srg_pd_threshold, int32_t non_srg_pd_threshold,
338 			 bool is_sr_enable);
339 #else
340 static inline void
341 wlan_mlme_update_sr_data(struct wlan_objmgr_vdev *vdev, int *val,
342 			 int32_t srg_pd_threshold, int32_t non_srg_pd_threshold,
343 			 bool is_sr_enable)
344 {}
345 #endif
346 #endif
347