xref: /wlan-dirver/qca-wifi-host-cmn/umac/mlo_mgr/inc/wlan_mlo_mgr_ap.h (revision 901120c066e139c7f8a2c8e4820561fdd83c67ef) !
1 /*
2  * Copyright (c) 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: contains MLO manager public file containing AP functionality
20  */
21 #ifndef _WLAN_MLO_MGR_AP_H_
22 #define _WLAN_MLO_MGR_AP_H_
23 
24 #include <wlan_mlo_mgr_cmn.h>
25 #include <wlan_mlo_mgr_public_structs.h>
26 #include "wlan_mlo_mgr_msgq.h"
27 
28 #define WLAN_RESV_AID_BITS 0xc000
29 #define WLAN_AID(b)    ((b) & ~0xc000)
30 /**
31  * mlo_ap_vdev_attach() - update vdev obj and vdev count to
32  *                         wlan_mlo_dev_context
33  * @vdev: vdev pointer
34  * @link_id: link id
35  * @vdev_count: number of vdev in the mlo
36  *
37  * Return: true if succeeds
38  */
39 bool mlo_ap_vdev_attach(struct wlan_objmgr_vdev *vdev,
40 			uint8_t link_id,
41 			uint16_t vdev_count);
42 
43 /**
44  * mlo_ap_get_vdev_list() - get mlo vdev list
45  * @vdev: vdev pointer
46  * @vdev_count: vdev count
47  * @wlan_vdev_list: vdev list
48  *
49  * This API gets all partner vdev's which have WLAN_VDEV_FEXT2_MLO bit
50  * set.
51  *
52  * It takes references for all vdev's with bit set in the list. Callers
53  * of this API should properly release references before destroying the
54  * list.
55  *
56  * Return: None
57  */
58 void mlo_ap_get_vdev_list(struct wlan_objmgr_vdev *vdev,
59 			  uint16_t *vdev_count,
60 			  struct wlan_objmgr_vdev **wlan_vdev_list);
61 
62 /**
63  * mlo_ap_get_partner_vdev_list_from_mld() - get partner vdev from MLD
64  *                                           vdev_list without checking
65  *                                           WLAN_VDEV_FEXT2_MLO bit
66  * @vdev: vdev pointer
67  * @vdev_count: vdev count
68  * @wlan_vdev_list: vdev list
69  *
70  * This API gets all partner vdev's irrespective of WLAN_VDEV_FEXT2_MLO
71  * bit. Ideally, it copies all partners of the MLD with references.
72  *
73  * It takes references for all vdev's in the list. The callers of this
74  * API should properly release references before destroying the list.
75  *
76  * Return: None
77  */
78 void mlo_ap_get_partner_vdev_list_from_mld(
79 		struct wlan_objmgr_vdev *vdev,
80 		uint16_t *vdev_count,
81 		struct wlan_objmgr_vdev **wlan_vdev_list);
82 
83 /**
84  * mlo_ap_link_sync_wait_notify() - notify the mlo manager, once vdev
85  *                                  enters WLAN_VDEV_SS_MLO_SYNC_WAIT
86  * @vdev: vdev pointer
87  *
88  * Return: None
89  */
90 void mlo_ap_link_sync_wait_notify(struct wlan_objmgr_vdev *vdev);
91 
92 /**
93  * mlo_ap_link_start_rsp_notify - Notify that the link start is completed
94  *
95  * @vdev: pointer to vdev
96  *
97  * Return: none
98  */
99 void mlo_ap_link_start_rsp_notify(struct wlan_objmgr_vdev *vdev);
100 
101 /**
102  * mlo_ap_vdev_detach() - notify the mlo manager to detach given vdev
103  * @vdev: vdev pointer
104  *
105  * Return: None
106  */
107 void mlo_ap_vdev_detach(struct wlan_objmgr_vdev *vdev);
108 
109 /**
110  * mlo_ap_link_down_cmpl_notify() - notify the mlo manager, once vdev
111  *                                  is down completely
112  * @vdev: vdev pointer
113  *
114  * Return: None
115  */
116 void mlo_ap_link_down_cmpl_notify(struct wlan_objmgr_vdev *vdev);
117 
118 /**
119  * wlan_vdev_mlme_aid_mgr_max_aid_set() - set VDEV Max AID
120  * @vdev: vdev pointer
121  * @max_aid: max AID
122  *
123  * This function sets max AID for the VDEV
124  *
125  * Return: void
126  */
127 void wlan_vdev_mlme_aid_mgr_max_aid_set(struct wlan_objmgr_vdev *vdev,
128 					uint16_t max_aid);
129 
130 /**
131  * wlan_vdev_mlme_set_start_aid() - set VDEV start AID
132  * @vdev: vdev pointer
133  * @start_aid: start AID
134  *
135  * This function sets start AID for the VDEV
136  *
137  * Return: void
138  */
139 QDF_STATUS wlan_vdev_mlme_set_start_aid(struct wlan_objmgr_vdev *vdev,
140 					uint16_t start_aid);
141 
142 /**
143  * wlan_vdev_mlme_get_start_aid() - set VDEV start AID
144  * @vdev: vdev pointer
145  *
146  * This function sets start AID for the VDEV
147  *
148  * Return: start AID
149  */
150 uint16_t wlan_vdev_mlme_get_start_aid(struct wlan_objmgr_vdev *vdev);
151 
152 /**
153  * wlan_mlo_vdev_init_mbss_aid_mgr() - Assigns tx vdev aid mgr to a VDEV
154  * @ml_dev: MLO DEV context
155  * @vdev: VDEV
156  * @tx_vdev: Transmit VDEV
157  *
158  * This function assigns Tx VDEV's AID mgr to non-Tx VDEV
159  *
160  * Return: SUCCESS if assigned successfully
161  */
162 QDF_STATUS wlan_mlo_vdev_init_mbss_aid_mgr(struct wlan_mlo_dev_context *ml_dev,
163 					   struct wlan_objmgr_vdev *vdev,
164 					   struct wlan_objmgr_vdev *tx_vdev);
165 
166 /**
167  * wlan_mlo_vdev_deinit_mbss_aid_mgr() - Resets aid mgr to a non-Tx VDEV
168  * @mldev: MLO DEV context
169  * @vdev: VDEV
170  * @tx_vdev: Transmit VDEV
171  *
172  * This function resets AID mgr of non-Tx VDEV
173  *
174  * Return: SUCCESS if reset successfully
175  */
176 QDF_STATUS wlan_mlo_vdev_deinit_mbss_aid_mgr(struct wlan_mlo_dev_context *mldev,
177 					     struct wlan_objmgr_vdev *vdev,
178 					     struct wlan_objmgr_vdev *tx_vdev);
179 
180 /**
181  * wlan_mlme_vdev_init_mbss_aid_mgr() - Assigns tx vdev aid mgr to a VDEV
182  * @vdev: VDEV
183  * @tx_vdev: Transmit VDEV
184  *
185  * This function assigns Tx VDEV's AID mgr to non-Tx VDEV
186  *
187  * Return: SUCCESS if assigned successfully
188  */
189 QDF_STATUS wlan_mlme_vdev_init_mbss_aid_mgr(struct wlan_objmgr_vdev *vdev,
190 					    struct wlan_objmgr_vdev *tx_vdev);
191 
192 /**
193  * wlan_mlme_vdev_deinit_mbss_aid_mgr() - Resets aid mgr to a non-Tx VDEV
194  * @vdev: VDEV
195  * @tx_vdev: Transmit VDEV
196  *
197  * This function resets AID mgr of non-Tx VDEV
198  *
199  * Return: SUCCESS if reset successfully
200  */
201 QDF_STATUS wlan_mlme_vdev_deinit_mbss_aid_mgr(struct wlan_objmgr_vdev *vdev,
202 					      struct wlan_objmgr_vdev *tx_vdev);
203 
204 /**
205  * wlan_vdev_aid_mgr_init() - VDEV AID mgr init
206  * @max_aid: max AID
207  *
208  * This function is called as part of vdev/MLO DEV initialization.
209  * This will allocate aid mgr structure for a VDEV
210  *
211  * Return: aid_mgr
212  */
213 struct wlan_vdev_aid_mgr *wlan_vdev_aid_mgr_init(uint16_t max_aid);
214 
215 /**
216  * wlan_vdev_aid_mgr_free() - VDEV AID mgr free
217  * @aid_mgr: AID mgr
218  *
219  * This function frees the aid mgr of the VDEV
220  *
221  * Return: void
222  */
223 void wlan_vdev_aid_mgr_free(struct wlan_vdev_aid_mgr *aid_mgr);
224 
225 /**
226  * wlan_mlo_vdev_aid_mgr_init() - MLO AID mgr init
227  * @ml_dev: MLO DEV context
228  *
229  * This function allocate AID space for all associated VDEVs of MLD
230  *
231  * Return: SUCCESS if allocated successfully
232  */
233 QDF_STATUS wlan_mlo_vdev_aid_mgr_init(struct wlan_mlo_dev_context *ml_dev);
234 
235 /**
236  * wlan_mlo_vdev_aid_mgr_deinit() - MLO AID mgr free
237  * @ml_dev: MLO DEV context
238  *
239  * This function frees AID space for all associated VDEVs of MLD
240  *
241  * Return: void
242  */
243 void wlan_mlo_vdev_aid_mgr_deinit(struct wlan_mlo_dev_context *ml_dev);
244 
245 /**
246  * wlan_mlo_vdev_alloc_aid_mgr() - Allocate AID space for a VDEV
247  * @ml_dev: MLO DEV context
248  * @vdev: VDEV
249  *
250  * This function allocates AID space for an associated VDEV of MLD
251  *
252  * Return: SUCCESS if allocated successfully
253  */
254 QDF_STATUS wlan_mlo_vdev_alloc_aid_mgr(struct wlan_mlo_dev_context *ml_dev,
255 				       struct wlan_objmgr_vdev *vdev);
256 
257 /**
258  * wlan_mlo_vdev_free_aid_mgr() - Free AID space for a VDEV
259  * @ml_dev: MLO DEV context
260  * @vdev: VDEV
261  *
262  * This function frees AID space for an associated VDEV of MLD
263  *
264  * Return: SUCCESS if freed successfully
265  */
266 QDF_STATUS wlan_mlo_vdev_free_aid_mgr(struct wlan_mlo_dev_context *ml_dev,
267 				      struct wlan_objmgr_vdev *vdev);
268 
269 /**
270  * mlo_peer_allocate_aid() - Allocate AID for MLO peer
271  * @ml_dev: MLO DEV context
272  * @ml_peer: MLO peer object
273  *
274  * This function allocates AID for an MLO peer
275  *
276  * Return: SUCCESS if allocated successfully
277  */
278 QDF_STATUS mlo_peer_allocate_aid(
279 		struct wlan_mlo_dev_context *ml_dev,
280 		struct wlan_mlo_peer_context *ml_peer);
281 
282 /**
283  * mlo_get_aid() - Allocate AID for a associated station
284  * @vdev: VDEV
285  *
286  * This function allocates AID for an associated station of MLD
287  *
288  * Return: AID
289  */
290 uint16_t mlo_get_aid(struct wlan_objmgr_vdev *vdev);
291 
292 /**
293  * mlo_free_aid() - Frees AID for a station
294  * @vdev: VDEV
295  * @assoc_id: Assoc ID
296  *
297  * This function frees AID for an associated station of MLD
298  *
299  * Return: SUCCESS if freed
300  */
301 QDF_STATUS mlo_free_aid(struct wlan_objmgr_vdev *vdev, uint16_t assoc_id);
302 
303 /**
304  * mlme_get_aid() - Allocate AID for a non-MLD station
305  * @vdev: VDEV
306  *
307  * This function allocates AID for an associated NON-MLD station of MLD
308  *
309  * Return: AID
310  */
311 uint16_t mlme_get_aid(struct wlan_objmgr_vdev *vdev);
312 
313 /**
314  * mlme_is_aid_set() - Check whether the AID is already allocated
315  * @vdev: VDEV
316  * @assoc_id: Assoc ID
317  *
318  * This function checks whether the AID is already allocated
319  *
320  * Return: 1 for AID is already allocated
321  *         0 for AID is available
322  */
323 int mlme_is_aid_set(struct wlan_objmgr_vdev *vdev, uint16_t assoc_id);
324 
325 /**
326  * wlan_mlo_peer_free_aid() - Free assoc id
327  * @ml_aid_mgr: MLO AID mgr
328  * @link_ix: Link index
329  * @assoc_id: Assoc id to be freed
330  *
331  * This function frees assoc id, resets bit in all bitmaps
332  *
333  * Return: SUCCESS,if it freed
334  */
335 QDF_STATUS wlan_mlo_peer_free_aid(
336 		struct wlan_ml_vdev_aid_mgr *ml_aid_mgr,
337 		uint8_t link_ix,
338 		uint16_t assoc_id);
339 
340 /**
341  * wlan_mlme_peer_free_aid() - Free link assoc id
342  * @vdev_aid_mgr: VDEV AID mgr
343  * @no_lock: lock needed for the operation
344  * @assoc_id: Assoc id to be freed
345  *
346  * This function frees assoc id of a specific VDEV
347  *
348  * Return: void
349  */
350 void wlan_mlme_peer_free_aid(
351 		struct wlan_vdev_aid_mgr *vdev_aid_mgr,
352 		bool no_lock, uint16_t assoc_id);
353 
354 /**
355  * mlo_peer_free_aid() - public API to free AID
356  * @ml_dev: MLO DEV context
357  * @ml_peer: MLO peer object
358  *
359  * This function invokes low level API to free assoc id
360  *
361  * Return: SUCCESS, if it freed
362  */
363 QDF_STATUS mlo_peer_free_aid(struct wlan_mlo_dev_context *ml_dev,
364 			     struct wlan_mlo_peer_context *ml_peer);
365 
366 /**
367  * mlme_free_aid() - public API to free link assoc id
368  * @vdev: VDEV object
369  * @assoc_id: Assoc id to be freed
370  *
371  * This function invokes low level API to free assoc id of a specific VDEV
372  *
373  * Return: void
374  */
375 void mlme_free_aid(struct wlan_objmgr_vdev *vdev, uint16_t assoc_id);
376 
377 /**
378  * mlo_set_aid() - public API to reserve AID
379  * @vdev: VDEV object
380  * @assoc_id: Assoc id to be reserved
381  *
382  * This function reserves AID of MLO VDEV
383  *
384  * Return: SUCCESS, if it is reserved
385  *         FAILURE, if it is already allocated
386  */
387 QDF_STATUS mlo_set_aid(struct wlan_objmgr_vdev *vdev,
388 		       uint16_t assoc_id);
389 
390 /**
391  * mlme_set_aid() - public API to reserve AID
392  * @vdev: VDEV object
393  * @assoc_id: Assoc id to be reserved
394  *
395  * This function reserves AID of VDEV
396  *
397  * Return: SUCCESS, if it is reserved
398  *         FAILURE, if it is already allocated
399  */
400 QDF_STATUS mlme_set_aid(struct wlan_objmgr_vdev *vdev,
401 			uint16_t assoc_id);
402 
403 /**
404  * wlan_mlme_get_aid_count() - public API to get AID count
405  * @vdev: VDEV object
406  *
407  * This function counts number AIDs allocated for the VDEV
408  *
409  * Return: aid count value
410  */
411 uint16_t wlan_mlme_get_aid_count(struct wlan_objmgr_vdev *vdev);
412 
413 /**
414  * mlo_ap_ml_peerid_alloc() - public API to allocate MLO peer id
415  *
416  * This function allocates MLO peer ID
417  *
418  * Return: mlo_peer_id on success,
419 	 MLO_INVALID_PEER_ID on failure
420  */
421 uint16_t mlo_ap_ml_peerid_alloc(void);
422 
423 /**
424  * mlo_ap_ml_peerid_free() - public API to free MLO peer id
425  * @ml_peer_id: ML peer id
426  *
427  * This function frees MLO peer ID
428  *
429  * Return: void
430  */
431 void mlo_ap_ml_peerid_free(uint16_t mlo_peer_id);
432 
433 #define ML_PRIMARY_UMAC_ID_INVAL 0xff
434 /**
435  * mlo_peer_assign_primary_umac() - Assign Primary UMAC
436  * @ml_peer: MLO peer object
437  * @peer_entry: Link peer entry
438  *
439  * This function assigns primary UMAC flag in peer entry
440  *
441  * Return: SUCCESS,if it allocated
442  */
443 void mlo_peer_assign_primary_umac(
444 		struct wlan_mlo_peer_context *ml_peer,
445 		struct wlan_mlo_link_peer_entry *peer_entry);
446 
447 /**
448  * mlo_peer_allocate_primary_umac() - Allocate Primary UMAC
449  * @ml_dev: MLO DEV context
450  * @ml_peer: MLO peer object
451  * @link_vdev: link vdev array
452  *
453  * This function allocates primary UMAC for a MLO peer
454  *
455  * Return: SUCCESS,if it allocated
456  */
457 QDF_STATUS mlo_peer_allocate_primary_umac(
458 		struct wlan_mlo_dev_context *ml_dev,
459 		struct wlan_mlo_peer_context *ml_peer,
460 		struct wlan_objmgr_vdev *link_vdevs[]);
461 
462 /**
463  * mlo_peer_free_primary_umac() - Free Primary UMAC
464  * @ml_dev: MLO DEV context
465  * @ml_peer: MLO peer object
466  *
467  * This function frees primary UMAC for a MLO peer
468  *
469  * Return: SUCCESS,if it is freed
470  */
471 QDF_STATUS mlo_peer_free_primary_umac(
472 		struct wlan_mlo_dev_context *ml_dev,
473 		struct wlan_mlo_peer_context *ml_peer);
474 
475 /**
476  * mlo_ap_vdev_quiet_set() - Set quiet bitmap for requested vdev
477  * @vdev: Pointer to object manager vdev
478  *
479  * Return: void
480  */
481 void mlo_ap_vdev_quiet_set(struct wlan_objmgr_vdev *vdev);
482 
483 /**
484  * mlo_ap_vdev_quiet_clear() - Clear quiet bitmap for requested vdev
485  * @vdev: Pointer to object manager vdev
486  *
487  * Return: void
488  */
489 void mlo_ap_vdev_quiet_clear(struct wlan_objmgr_vdev *vdev);
490 
491 /**
492  * mlo_ap_vdev_quiet_is_any_idx_set() - Check if any index is set in
493  * quiet bitmap
494  * @vdev: Pointer to object manager vdev
495  *
496  * Return: true, if any index is set, else false
497  */
498 bool mlo_ap_vdev_quiet_is_any_idx_set(struct wlan_objmgr_vdev *vdev);
499 
500 #ifdef UMAC_SUPPORT_MLNAWDS
501 /**
502  * mlo_peer_populate_nawds_params() - Populate nawds parameters in ml_peer
503  * @ml_peer: ml_peer to which nawds config parameters need to be populated
504  * @ml_info: ml_info with nawds config associated with this link
505  *
506  * Return: void
507  */
508 void mlo_peer_populate_nawds_params(
509 		struct wlan_mlo_peer_context *ml_peer,
510 		struct mlo_partner_info *ml_info);
511 #else
512 static inline
513 void mlo_peer_populate_nawds_params(
514 		struct wlan_mlo_peer_context *ml_peer,
515 		struct mlo_partner_info *ml_info)
516 {
517 }
518 #endif
519 
520 /**
521  * mlo_peer_create_get_frm_buf() - get frm_buf to peer_create
522  * @ml_peer: MLO peer
523  * @peer_create: pointer to peer_create_notif context
524  * @frm_buf: pointer to frame buffer to be cloned to peer_create
525  *
526  * Return: SUCCESS if
527  * - peer_create frame buffer cloned successfully in non NAWDS case Or
528  * - ml_peer is in NAWDS mode.
529  */
530 QDF_STATUS mlo_peer_create_get_frm_buf(
531 		struct wlan_mlo_peer_context *ml_peer,
532 		struct peer_create_notif_s *peer_create,
533 		qdf_nbuf_t frm_buf);
534 #endif
535