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