1 /*
2 * Copyright (c) 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: contains MLO manager containing init/deinit public api's
20 */
21 #ifndef _WLAN_MLO_MGR_MAIN_H_
22 #define _WLAN_MLO_MGR_MAIN_H_
23
24 #include <qdf_atomic.h>
25 #include <wlan_objmgr_psoc_obj.h>
26 #include <wlan_objmgr_pdev_obj.h>
27 #include <wlan_objmgr_vdev_obj.h>
28
29 #ifdef WLAN_FEATURE_11BE_MLO
30 #include <wlan_mlo_mgr_public_structs.h>
31
32 /**
33 * wlan_mlo_mgr_init() - Initialize the MLO data structures
34 *
35 * Return: QDF_STATUS
36 */
37 QDF_STATUS wlan_mlo_mgr_init(void);
38
39 /**
40 * wlan_mlo_mgr_deinit() - De-init the MLO data structures
41 *
42 * Return: QDF_STATUS
43 */
44 QDF_STATUS wlan_mlo_mgr_deinit(void);
45
46 /**
47 * wlan_mlo_mgr_vdev_created_notification() - mlo mgr vdev create handler
48 * @vdev: vdev object
49 * @arg_list: Argument list
50 *
51 * This function is called as part of vdev creation. This will initialize
52 * the MLO dev context if the interface type is ML.
53 *
54 * Return: QDF_STATUS
55 */
56 QDF_STATUS wlan_mlo_mgr_vdev_created_notification(struct wlan_objmgr_vdev *vdev,
57 void *arg_list);
58
59 /**
60 * wlan_mlo_mgr_vdev_destroyed_notification() - mlo mgr vdev delete handler
61 * @vdev: vdev object
62 * @arg_list: Argument list
63 *
64 * This function is called as part of vdev delete. This will de-initialize
65 * the MLO dev context if the interface type is ML.
66 *
67 * Return: QDF_STATUS
68 */
69 QDF_STATUS wlan_mlo_mgr_vdev_destroyed_notification(struct wlan_objmgr_vdev *vdev,
70 void *arg_list);
71
72 #ifdef WLAN_MLO_USE_SPINLOCK
73 /**
74 * ml_link_lock_create - Create MLO link mutex/spinlock
75 * @mlo_ctx: MLO manager global context
76 *
77 * Creates mutex/spinlock
78 *
79 * Return: void
80 */
81 static inline
ml_link_lock_create(struct mlo_mgr_context * mlo_ctx)82 void ml_link_lock_create(struct mlo_mgr_context *mlo_ctx)
83 {
84 qdf_spinlock_create(&mlo_ctx->ml_dev_list_lock);
85 }
86
87 /**
88 * ml_link_lock_destroy - Destroy ml link mutex/spinlock
89 * @mlo_ctx: MLO manager global context
90 *
91 * Destroy mutex/spinlock
92 *
93 * Return: void
94 */
95 static inline void
ml_link_lock_destroy(struct mlo_mgr_context * mlo_ctx)96 ml_link_lock_destroy(struct mlo_mgr_context *mlo_ctx)
97 {
98 qdf_spinlock_destroy(&mlo_ctx->ml_dev_list_lock);
99 }
100
101 /**
102 * ml_link_lock_acquire - acquire ml link mutex/spinlock
103 * @mlo_ctx: MLO manager global context
104 *
105 * acquire mutex/spinlock
106 *
107 * return: void
108 */
109 static inline
ml_link_lock_acquire(struct mlo_mgr_context * mlo_ctx)110 void ml_link_lock_acquire(struct mlo_mgr_context *mlo_ctx)
111 {
112 qdf_spin_lock_bh(&mlo_ctx->ml_dev_list_lock);
113 }
114
115 /**
116 * ml_link_lock_release - release MLO dev mutex/spinlock
117 * @mlo_ctx: MLO manager global context
118 *
119 * release mutex/spinlock
120 *
121 * return: void
122 */
123 static inline
ml_link_lock_release(struct mlo_mgr_context * mlo_ctx)124 void ml_link_lock_release(struct mlo_mgr_context *mlo_ctx)
125 {
126 qdf_spin_unlock_bh(&mlo_ctx->ml_dev_list_lock);
127 }
128
129 /**
130 * mlo_dev_lock_create - Create MLO device mutex/spinlock
131 * @mldev: ML device context
132 *
133 * Creates mutex/spinlock
134 *
135 * Return: void
136 */
137 static inline void
mlo_dev_lock_create(struct wlan_mlo_dev_context * mldev)138 mlo_dev_lock_create(struct wlan_mlo_dev_context *mldev)
139 {
140 qdf_spinlock_create(&mldev->mlo_dev_lock);
141 }
142
143 /**
144 * mlo_dev_lock_destroy - Destroy CM SM mutex/spinlock
145 * @mldev: ML device context
146 *
147 * Destroy mutex/spinlock
148 *
149 * Return: void
150 */
151 static inline void
mlo_dev_lock_destroy(struct wlan_mlo_dev_context * mldev)152 mlo_dev_lock_destroy(struct wlan_mlo_dev_context *mldev)
153 {
154 qdf_spinlock_destroy(&mldev->mlo_dev_lock);
155 }
156
157 /**
158 * mlo_dev_lock_acquire - acquire CM SM mutex/spinlock
159 * @mldev: ML device context
160 *
161 * acquire mutex/spinlock
162 *
163 * return: void
164 */
165 static inline
mlo_dev_lock_acquire(struct wlan_mlo_dev_context * mldev)166 void mlo_dev_lock_acquire(struct wlan_mlo_dev_context *mldev)
167 {
168 qdf_spin_lock_bh(&mldev->mlo_dev_lock);
169 }
170
171 /**
172 * mlo_dev_lock_release - release MLO dev mutex/spinlock
173 * @mldev: ML device context
174 *
175 * release mutex/spinlock
176 *
177 * return: void
178 */
179 static inline
mlo_dev_lock_release(struct wlan_mlo_dev_context * mldev)180 void mlo_dev_lock_release(struct wlan_mlo_dev_context *mldev)
181 {
182 qdf_spin_unlock_bh(&mldev->mlo_dev_lock);
183 }
184
185 /**
186 * ml_aid_lock_create - Create MLO aid mutex/spinlock
187 * @mlo_ctx: MLO manager global context
188 *
189 * Creates mutex/spinlock
190 *
191 * Return: void
192 */
193 static inline
ml_aid_lock_create(struct mlo_mgr_context * mlo_ctx)194 void ml_aid_lock_create(struct mlo_mgr_context *mlo_ctx)
195 {
196 qdf_spinlock_create(&mlo_ctx->aid_lock);
197 }
198
199 /**
200 * ml_aid_lock_destroy - Destroy ml aid mutex/spinlock
201 * @mlo_ctx: MLO manager global context
202 *
203 * Destroy mutex/spinlock
204 *
205 * Return: void
206 */
207 static inline void
ml_aid_lock_destroy(struct mlo_mgr_context * mlo_ctx)208 ml_aid_lock_destroy(struct mlo_mgr_context *mlo_ctx)
209 {
210 qdf_spinlock_destroy(&mlo_ctx->aid_lock);
211 }
212
213 /**
214 * ml_aid_lock_acquire - acquire ml aid mutex/spinlock
215 * @mlo_ctx: MLO manager global context
216 *
217 * acquire mutex/spinlock
218 *
219 * return: void
220 */
221 static inline
ml_aid_lock_acquire(struct mlo_mgr_context * mlo_ctx)222 void ml_aid_lock_acquire(struct mlo_mgr_context *mlo_ctx)
223 {
224 qdf_spin_lock_bh(&mlo_ctx->aid_lock);
225 }
226
227 /**
228 * ml_aid_lock_release - release MLO aid mutex/spinlock
229 * @mlo_ctx: MLO manager global context
230 *
231 * release mutex/spinlock
232 *
233 * return: void
234 */
235 static inline
ml_aid_lock_release(struct mlo_mgr_context * mlo_ctx)236 void ml_aid_lock_release(struct mlo_mgr_context *mlo_ctx)
237 {
238 qdf_spin_unlock_bh(&mlo_ctx->aid_lock);
239 }
240
241 /**
242 * ml_peerid_lock_create - Create MLO peer mutex/spinlock
243 * @mlo_ctx: MLO manager global context
244 *
245 * Creates mutex/spinlock
246 *
247 * Return: void
248 */
249 static inline
ml_peerid_lock_create(struct mlo_mgr_context * mlo_ctx)250 void ml_peerid_lock_create(struct mlo_mgr_context *mlo_ctx)
251 {
252 qdf_spinlock_create(&mlo_ctx->ml_peerid_lock);
253 }
254
255 /**
256 * ml_peerid_lock_destroy - Destroy ml peerid mutex/spinlock
257 * @mlo_ctx: MLO manager global context
258 *
259 * Destroy mutex/spinlock
260 *
261 * Return: void
262 */
263 static inline void
ml_peerid_lock_destroy(struct mlo_mgr_context * mlo_ctx)264 ml_peerid_lock_destroy(struct mlo_mgr_context *mlo_ctx)
265 {
266 qdf_spinlock_destroy(&mlo_ctx->ml_peerid_lock);
267 }
268
269 /**
270 * ml_peerid_lock_acquire - acquire ml peerid mutex/spinlock
271 * @mlo_ctx: MLO manager global context
272 *
273 * acquire mutex/spinlock
274 *
275 * return: void
276 */
277 static inline
ml_peerid_lock_acquire(struct mlo_mgr_context * mlo_ctx)278 void ml_peerid_lock_acquire(struct mlo_mgr_context *mlo_ctx)
279 {
280 qdf_spin_lock_bh(&mlo_ctx->ml_peerid_lock);
281 }
282
283 /**
284 * ml_peerid_lock_release - release MLO peerid mutex/spinlock
285 * @mlo_ctx: MLO manager global context
286 *
287 * release mutex/spinlock
288 *
289 * return: void
290 */
291 static inline
ml_peerid_lock_release(struct mlo_mgr_context * mlo_ctx)292 void ml_peerid_lock_release(struct mlo_mgr_context *mlo_ctx)
293 {
294 qdf_spin_unlock_bh(&mlo_ctx->ml_peerid_lock);
295 }
296
297 /**
298 * mlo_peer_lock_create - Create MLO peer mutex/spinlock
299 * @mlpeer: ML peer
300 *
301 * Creates mutex/spinlock
302 *
303 * Return: void
304 */
305 static inline void
mlo_peer_lock_create(struct wlan_mlo_peer_context * mlpeer)306 mlo_peer_lock_create(struct wlan_mlo_peer_context *mlpeer)
307 {
308 qdf_spinlock_create(&mlpeer->mlo_peer_lock);
309 }
310
311 /**
312 * mlo_peer_lock_destroy - Destroy MLO peer mutex/spinlock
313 * @mlpeer: ML peer
314 *
315 * Destroy mutex/spinlock
316 *
317 * Return: void
318 */
319 static inline void
mlo_peer_lock_destroy(struct wlan_mlo_peer_context * mlpeer)320 mlo_peer_lock_destroy(struct wlan_mlo_peer_context *mlpeer)
321 {
322 qdf_spinlock_destroy(&mlpeer->mlo_peer_lock);
323 }
324
325 /**
326 * mlo_peer_lock_acquire - acquire mlo peer mutex/spinlock
327 * @mlpeer: MLO peer context
328 *
329 * acquire mutex/spinlock
330 *
331 * return: void
332 */
333 static inline
mlo_peer_lock_acquire(struct wlan_mlo_peer_context * mlpeer)334 void mlo_peer_lock_acquire(struct wlan_mlo_peer_context *mlpeer)
335 {
336 qdf_spin_lock_bh(&mlpeer->mlo_peer_lock);
337 }
338
339 /**
340 * mlo_peer_lock_release - release MLO peer mutex/spinlock
341 * @mlpeer: MLO peer context
342 *
343 * release mutex/spinlock
344 *
345 * return: void
346 */
347 static inline
mlo_peer_lock_release(struct wlan_mlo_peer_context * mlpeer)348 void mlo_peer_lock_release(struct wlan_mlo_peer_context *mlpeer)
349 {
350 qdf_spin_unlock_bh(&mlpeer->mlo_peer_lock);
351 }
352
353 /**
354 * ml_peerlist_lock_create - Create MLO peer list mutex/spinlock
355 * @ml_peerlist: ML peer list context
356 *
357 * Creates mutex/spinlock
358 *
359 * Return: void
360 */
361 static inline void
ml_peerlist_lock_create(struct wlan_mlo_peer_list * ml_peerlist)362 ml_peerlist_lock_create(struct wlan_mlo_peer_list *ml_peerlist)
363 {
364 qdf_spinlock_create(&ml_peerlist->peer_list_lock);
365 }
366
367 /**
368 * ml_peerlist_lock_destroy - Destroy MLO peer list mutex/spinlock
369 * @ml_peerlist: ML peer list context
370 *
371 * Destroy mutex/spinlock
372 *
373 * Return: void
374 */
375 static inline void
ml_peerlist_lock_destroy(struct wlan_mlo_peer_list * ml_peerlist)376 ml_peerlist_lock_destroy(struct wlan_mlo_peer_list *ml_peerlist)
377 {
378 qdf_spinlock_destroy(&ml_peerlist->peer_list_lock);
379 }
380
381 /**
382 * ml_peerlist_lock_acquire - acquire ML peer list mutex/spinlock
383 * @ml_peerlist: ML peer list context
384 *
385 * acquire mutex/spinlock
386 *
387 * return: void
388 */
389 static inline
ml_peerlist_lock_acquire(struct wlan_mlo_peer_list * ml_peerlist)390 void ml_peerlist_lock_acquire(struct wlan_mlo_peer_list *ml_peerlist)
391 {
392 qdf_spin_lock_bh(&ml_peerlist->peer_list_lock);
393 }
394
395 /**
396 * ml_peerlist_lock_release - release ML peer list mutex/spinlock
397 * @ml_peerlist: ML peer list context
398 *
399 * release mutex/spinlock
400 *
401 * return: void
402 */
403 static inline
ml_peerlist_lock_release(struct wlan_mlo_peer_list * ml_peerlist)404 void ml_peerlist_lock_release(struct wlan_mlo_peer_list *ml_peerlist)
405 {
406 qdf_spin_unlock_bh(&ml_peerlist->peer_list_lock);
407 }
408
409 /**
410 * copied_conn_req_lock_create - Create original connect req mutex/spinlock
411 * @sta_ctx: MLO STA related information
412 *
413 * Create mutex/spinlock
414 *
415 * return: void
416 */
417 static inline
copied_conn_req_lock_create(struct wlan_mlo_sta * sta_ctx)418 void copied_conn_req_lock_create(struct wlan_mlo_sta *sta_ctx)
419 {
420 qdf_spinlock_create(&sta_ctx->copied_conn_req_lock);
421 }
422
423 /**
424 * copied_conn_req_lock_destroy - Destroy original connect req mutex/spinlock
425 * @sta_ctx: MLO STA related information
426 *
427 * Destroy mutex/spinlock
428 *
429 * return: void
430 */
431 static inline
copied_conn_req_lock_destroy(struct wlan_mlo_sta * sta_ctx)432 void copied_conn_req_lock_destroy(struct wlan_mlo_sta *sta_ctx)
433 {
434 qdf_spinlock_destroy(&sta_ctx->copied_conn_req_lock);
435 }
436
437 /**
438 * copied_conn_req_lock_acquire - Acquire original connect req mutex/spinlock
439 * @sta_ctx: MLO STA related information
440 *
441 * Acquire mutex/spinlock
442 *
443 * return: void
444 */
445 static inline
copied_conn_req_lock_acquire(struct wlan_mlo_sta * sta_ctx)446 void copied_conn_req_lock_acquire(struct wlan_mlo_sta *sta_ctx)
447 {
448 qdf_spin_lock_bh(&sta_ctx->copied_conn_req_lock);
449 }
450
451 /**
452 * copied_conn_req_lock_release - Release original connect req mutex/spinlock
453 * @sta_ctx: MLO STA related information
454 *
455 * Release mutex/spinlock
456 *
457 * return: void
458 */
459 static inline
copied_conn_req_lock_release(struct wlan_mlo_sta * sta_ctx)460 void copied_conn_req_lock_release(struct wlan_mlo_sta *sta_ctx)
461 {
462 qdf_spin_unlock_bh(&sta_ctx->copied_conn_req_lock);
463 }
464
465 /**
466 * tsf_recalculation_lock_create - Create TSF recalculation mutex/spinlock
467 * @mldev: ML device context
468 *
469 * Creates mutex/spinlock
470 *
471 * Return: void
472 */
473 static inline void
tsf_recalculation_lock_create(struct wlan_mlo_dev_context * mldev)474 tsf_recalculation_lock_create(struct wlan_mlo_dev_context *mldev)
475 {
476 qdf_spinlock_create(&mldev->tsf_recalculation_lock);
477 }
478
479 /**
480 * tsf_recalculation_lock_destroy - Destroy TSF recalculation mutex/spinlock
481 * @mldev: ML device context
482 *
483 * Destroy mutex/spinlock
484 *
485 * Return: void
486 */
487 static inline void
tsf_recalculation_lock_destroy(struct wlan_mlo_dev_context * mldev)488 tsf_recalculation_lock_destroy(struct wlan_mlo_dev_context *mldev)
489 {
490 qdf_spinlock_destroy(&mldev->tsf_recalculation_lock);
491 }
492
493 /**
494 * tsf_recalculation_lock_acquire - Acquire TSF recalculation mutex/spinlock
495 * @mldev: ML device context
496 *
497 * Acquire mutex/spinlock
498 *
499 * return: void
500 */
501 static inline
tsf_recalculation_lock_acquire(struct wlan_mlo_dev_context * mldev)502 void tsf_recalculation_lock_acquire(struct wlan_mlo_dev_context *mldev)
503 {
504 qdf_spin_lock_bh(&mldev->tsf_recalculation_lock);
505 }
506
507 /**
508 * tsf_recalculation_lock_release - Release TSF recalculation mutex/spinlock
509 * @mldev: ML device context
510 *
511 * release mutex/spinlock
512 *
513 * return: void
514 */
515 static inline
tsf_recalculation_lock_release(struct wlan_mlo_dev_context * mldev)516 void tsf_recalculation_lock_release(struct wlan_mlo_dev_context *mldev)
517 {
518 qdf_spin_unlock_bh(&mldev->tsf_recalculation_lock);
519 }
520
521 /**
522 * mlo_ap_lock_create - Create MLO AP mutex/spinlock
523 * @ap_ctx: ML device AP context
524 *
525 * Creates mutex/spinlock
526 *
527 * Return: void
528 */
529 static inline
mlo_ap_lock_create(struct wlan_mlo_ap * ap_ctx)530 void mlo_ap_lock_create(struct wlan_mlo_ap *ap_ctx)
531 {
532 qdf_spinlock_create(&ap_ctx->mlo_ap_lock);
533 }
534
535 /**
536 * mlo_ap_lock_destroy - Destroy MLO AP mutex/spinlock
537 * @ap_ctx: ML device AP context
538 *
539 * Destroy mutex/spinlock
540 *
541 * Return: void
542 */
543 static inline
mlo_ap_lock_destroy(struct wlan_mlo_ap * ap_ctx)544 void mlo_ap_lock_destroy(struct wlan_mlo_ap *ap_ctx)
545 {
546 qdf_spinlock_destroy(&ap_ctx->mlo_ap_lock);
547 }
548
549 /**
550 * mlo_ap_lock_acquire - Acquire MLO AP mutex/spinlock
551 * @ap_ctx: ML device AP context
552 *
553 * acquire mutex/spinlock
554 *
555 * return: void
556 */
557 static inline
mlo_ap_lock_acquire(struct wlan_mlo_ap * ap_ctx)558 void mlo_ap_lock_acquire(struct wlan_mlo_ap *ap_ctx)
559 {
560 qdf_spin_lock_bh(&ap_ctx->mlo_ap_lock);
561 }
562
563 /**
564 * mlo_ap_lock_release - Release MLO AP mutex/spinlock
565 * @ap_ctx: ML device AP context
566 *
567 * release mutex/spinlock
568 *
569 * return: void
570 */
571 static inline
mlo_ap_lock_release(struct wlan_mlo_ap * ap_ctx)572 void mlo_ap_lock_release(struct wlan_mlo_ap *ap_ctx)
573 {
574 qdf_spin_unlock_bh(&ap_ctx->mlo_ap_lock);
575 }
576 #else /* WLAN_MLO_USE_SPINLOCK */
577 static inline
ml_link_lock_create(struct mlo_mgr_context * mlo_ctx)578 void ml_link_lock_create(struct mlo_mgr_context *mlo_ctx)
579 {
580 qdf_mutex_create(&mlo_ctx->ml_dev_list_lock);
581 }
582
583 static inline void
ml_link_lock_destroy(struct mlo_mgr_context * mlo_ctx)584 ml_link_lock_destroy(struct mlo_mgr_context *mlo_ctx)
585 {
586 qdf_mutex_destroy(&mlo_ctx->ml_dev_list_lock);
587 }
588
589 static inline
ml_link_lock_acquire(struct mlo_mgr_context * mlo_ctx)590 void ml_link_lock_acquire(struct mlo_mgr_context *mlo_ctx)
591 {
592 qdf_mutex_acquire(&mlo_ctx->ml_dev_list_lock);
593 }
594
595 static inline
ml_link_lock_release(struct mlo_mgr_context * mlo_ctx)596 void ml_link_lock_release(struct mlo_mgr_context *mlo_ctx)
597 {
598 qdf_mutex_release(&mlo_ctx->ml_dev_list_lock);
599 }
600
601 static inline
mlo_dev_lock_create(struct wlan_mlo_dev_context * mldev)602 void mlo_dev_lock_create(struct wlan_mlo_dev_context *mldev)
603 {
604 qdf_mutex_create(&mldev->mlo_dev_lock);
605 }
606
607 static inline
mlo_dev_lock_destroy(struct wlan_mlo_dev_context * mldev)608 void mlo_dev_lock_destroy(struct wlan_mlo_dev_context *mldev)
609 {
610 qdf_mutex_destroy(&mldev->mlo_dev_lock);
611 }
612
mlo_dev_lock_acquire(struct wlan_mlo_dev_context * mldev)613 static inline void mlo_dev_lock_acquire(struct wlan_mlo_dev_context *mldev)
614 {
615 qdf_mutex_acquire(&mldev->mlo_dev_lock);
616 }
617
mlo_dev_lock_release(struct wlan_mlo_dev_context * mldev)618 static inline void mlo_dev_lock_release(struct wlan_mlo_dev_context *mldev)
619 {
620 qdf_mutex_release(&mldev->mlo_dev_lock);
621 }
622
623 static inline
ml_aid_lock_create(struct mlo_mgr_context * mlo_ctx)624 void ml_aid_lock_create(struct mlo_mgr_context *mlo_ctx)
625 {
626 qdf_mutex_create(&mlo_ctx->aid_lock);
627 }
628
629 static inline void
ml_aid_lock_destroy(struct mlo_mgr_context * mlo_ctx)630 ml_aid_lock_destroy(struct mlo_mgr_context *mlo_ctx)
631 {
632 qdf_mutex_destroy(&mlo_ctx->aid_lock);
633 }
634
635 static inline
ml_aid_lock_acquire(struct mlo_mgr_context * mlo_ctx)636 void ml_aid_lock_acquire(struct mlo_mgr_context *mlo_ctx)
637 {
638 qdf_mutex_acquire(&mlo_ctx->aid_lock);
639 }
640
641 static inline
ml_aid_lock_release(struct mlo_mgr_context * mlo_ctx)642 void ml_aid_lock_release(struct mlo_mgr_context *mlo_ctx)
643 {
644 qdf_mutex_release(&mlo_ctx->aid_lock);
645 }
646
647 static inline
ml_peerid_lock_create(struct mlo_mgr_context * mlo_ctx)648 void ml_peerid_lock_create(struct mlo_mgr_context *mlo_ctx)
649 {
650 qdf_mutex_create(&mlo_ctx->ml_peerid_lock);
651 }
652
653 static inline void
ml_peerid_lock_destroy(struct mlo_mgr_context * mlo_ctx)654 ml_peerid_lock_destroy(struct mlo_mgr_context *mlo_ctx)
655 {
656 qdf_mutex_destroy(&mlo_ctx->ml_peerid_lock);
657 }
658
659 static inline
ml_peerid_lock_acquire(struct mlo_mgr_context * mlo_ctx)660 void ml_peerid_lock_acquire(struct mlo_mgr_context *mlo_ctx)
661 {
662 qdf_mutex_acquire(&mlo_ctx->ml_peerid_lock);
663 }
664
665 static inline
ml_peerid_lock_release(struct mlo_mgr_context * mlo_ctx)666 void ml_peerid_lock_release(struct mlo_mgr_context *mlo_ctx)
667 {
668 qdf_mutex_release(&mlo_ctx->ml_peerid_lock);
669 }
670
671 static inline void
mlo_peer_lock_create(struct wlan_mlo_peer_context * mlpeer)672 mlo_peer_lock_create(struct wlan_mlo_peer_context *mlpeer)
673 {
674 qdf_mutex_create(&mlpeer->mlo_peer_lock);
675 }
676
677 static inline void
mlo_peer_lock_destroy(struct wlan_mlo_peer_context * mlpeer)678 mlo_peer_lock_destroy(struct wlan_mlo_peer_context *mlpeer)
679 {
680 qdf_mutex_destroy(&mlpeer->mlo_peer_lock);
681 }
682
683 static inline
mlo_peer_lock_acquire(struct wlan_mlo_peer_context * mlpeer)684 void mlo_peer_lock_acquire(struct wlan_mlo_peer_context *mlpeer)
685 {
686 qdf_mutex_acquire(&mlpeer->mlo_peer_lock);
687 }
688
689 static inline
mlo_peer_lock_release(struct wlan_mlo_peer_context * mlpeer)690 void mlo_peer_lock_release(struct wlan_mlo_peer_context *mlpeer)
691 {
692 qdf_mutex_release(&mlpeer->mlo_peer_lock);
693 }
694
695 static inline void
ml_peerlist_lock_create(struct wlan_mlo_peer_list * ml_peerlist)696 ml_peerlist_lock_create(struct wlan_mlo_peer_list *ml_peerlist)
697 {
698 qdf_mutex_create(&ml_peerlist->peer_list_lock);
699 }
700
701 static inline void
ml_peerlist_lock_destroy(struct wlan_mlo_peer_list * ml_peerlist)702 ml_peerlist_lock_destroy(struct wlan_mlo_peer_list *ml_peerlist)
703 {
704 qdf_mutex_destroy(&ml_peerlist->peer_list_lock);
705 }
706
707 static inline
ml_peerlist_lock_acquire(struct wlan_mlo_peer_list * ml_peerlist)708 void ml_peerlist_lock_acquire(struct wlan_mlo_peer_list *ml_peerlist)
709 {
710 qdf_mutex_acquire(&ml_peerlist->peer_list_lock);
711 }
712
713 static inline
ml_peerlist_lock_release(struct wlan_mlo_peer_list * ml_peerlist)714 void ml_peerlist_lock_release(struct wlan_mlo_peer_list *ml_peerlist)
715 {
716 qdf_mutex_release(&ml_peerlist->peer_list_lock);
717 }
718
719 static inline
copied_conn_req_lock_create(struct wlan_mlo_sta * sta_ctx)720 void copied_conn_req_lock_create(struct wlan_mlo_sta *sta_ctx)
721 {
722 qdf_mutex_create(&sta_ctx->copied_conn_req_lock);
723 }
724
725 static inline
copied_conn_req_lock_destroy(struct wlan_mlo_sta * sta_ctx)726 void copied_conn_req_lock_destroy(struct wlan_mlo_sta *sta_ctx)
727 {
728 qdf_mutex_destroy(&sta_ctx->copied_conn_req_lock);
729 }
730
731 static inline
copied_conn_req_lock_acquire(struct wlan_mlo_sta * sta_ctx)732 void copied_conn_req_lock_acquire(struct wlan_mlo_sta *sta_ctx)
733 {
734 qdf_mutex_acquire(&sta_ctx->copied_conn_req_lock);
735 }
736
737 static inline
copied_conn_req_lock_release(struct wlan_mlo_sta * sta_ctx)738 void copied_conn_req_lock_release(struct wlan_mlo_sta *sta_ctx)
739 {
740 qdf_mutex_release(&sta_ctx->copied_conn_req_lock);
741 }
742
743 /**
744 * tsf_recalculation_lock_create - Create TSF recalculation mutex/spinlock
745 * @mldev: ML device context
746 *
747 * Creates mutex/spinlock
748 *
749 * Return: void
750 */
751 static inline void
tsf_recalculation_lock_create(struct wlan_mlo_dev_context * mldev)752 tsf_recalculation_lock_create(struct wlan_mlo_dev_context *mldev)
753 {
754 qdf_mutex_create(&mldev->tsf_recalculation_lock);
755 }
756
757 /**
758 * tsf_recalculation_lock_destroy - Destroy TSF recalculation mutex/spinlock
759 * @mldev: ML device context
760 *
761 * Destroy mutex/spinlock
762 *
763 * Return: void
764 */
765 static inline void
tsf_recalculation_lock_destroy(struct wlan_mlo_dev_context * mldev)766 tsf_recalculation_lock_destroy(struct wlan_mlo_dev_context *mldev)
767 {
768 qdf_mutex_destroy(&mldev->tsf_recalculation_lock);
769 }
770
771 /**
772 * tsf_recalculation_lock_acquire - Acquire TSF recalculation mutex/spinlock
773 * @mldev: ML device context
774 *
775 * Acquire mutex/spinlock
776 *
777 * return: void
778 */
779 static inline
tsf_recalculation_lock_acquire(struct wlan_mlo_dev_context * mldev)780 void tsf_recalculation_lock_acquire(struct wlan_mlo_dev_context *mldev)
781 {
782 qdf_mutex_acquire(&mldev->tsf_recalculation_lock);
783 }
784
785 /**
786 * tsf_recalculation_lock_release - Release TSF recalculation mutex/spinlock
787 * @mldev: ML device context
788 *
789 * release mutex/spinlock
790 *
791 * return: void
792 */
793 static inline
tsf_recalculation_lock_release(struct wlan_mlo_dev_context * mldev)794 void tsf_recalculation_lock_release(struct wlan_mlo_dev_context *mldev)
795 {
796 qdf_mutex_release(&mldev->tsf_recalculation_lock);
797 }
798
799 static inline
mlo_ap_lock_create(struct wlan_mlo_ap * ap_ctx)800 void mlo_ap_lock_create(struct wlan_mlo_ap *ap_ctx)
801 {
802 qdf_mutex_create(&ap_ctx->mlo_ap_lock);
803 }
804
805 static inline
mlo_ap_lock_destroy(struct wlan_mlo_ap * ap_ctx)806 void mlo_ap_lock_destroy(struct wlan_mlo_ap *ap_ctx)
807 {
808 qdf_mutex_destroy(&ap_ctx->mlo_ap_lock);
809 }
810
811 static inline
mlo_ap_lock_acquire(struct wlan_mlo_ap * ap_ctx)812 void mlo_ap_lock_acquire(struct wlan_mlo_ap *ap_ctx)
813 {
814 qdf_mutex_acquire(&ap_ctx->mlo_ap_lock);
815 }
816
817 static inline
mlo_ap_lock_release(struct wlan_mlo_ap * ap_ctx)818 void mlo_ap_lock_release(struct wlan_mlo_ap *ap_ctx)
819 {
820 qdf_mutex_release(&ap_ctx->mlo_ap_lock);
821 }
822 #endif /* WLAN_MLO_USE_SPINLOCK */
823
824 /**
825 * wlan_mlo_mgr_psoc_enable() - MLO psoc enable handler
826 * @psoc: psoc pointer
827 *
828 * API to execute operations on psoc enable
829 *
830 * Return: QDF_STATUS
831 */
832 QDF_STATUS wlan_mlo_mgr_psoc_enable(struct wlan_objmgr_psoc *psoc);
833
834 /**
835 * wlan_mlo_mgr_psoc_disable() - MLO psoc disable handler
836 * @psoc: psoc pointer
837 *
838 * API to execute operations on psoc disable
839 *
840 * Return: QDF_STATUS
841 */
842 QDF_STATUS wlan_mlo_mgr_psoc_disable(struct wlan_objmgr_psoc *psoc);
843
844 /**
845 * wlan_mlo_mgr_update_mld_addr() - Update MLD MAC address
846 * @old_mac: Old MLD MAC address
847 * @new_mac: New MLD MAC address
848 *
849 * API to update MLD MAC address once ML dev context is created.
850 *
851 * Return: QDF_STATUS
852 */
853 QDF_STATUS wlan_mlo_mgr_update_mld_addr(struct qdf_mac_addr *old_mac,
854 struct qdf_mac_addr *new_mac);
855
856 /**
857 * wlan_mlo_is_mld_ctx_exist() - check whether MLD exist with MLD MAC address
858 * @mldaddr: MLD MAC address
859 *
860 * API to check whether MLD is present with MLD MAC address.
861 *
862 * Return: true, if it is present
863 * false, if it is not present
864 */
865 bool wlan_mlo_is_mld_ctx_exist(struct qdf_mac_addr *mldaddr);
866
867 /**
868 * wlan_mlo_get_sta_mld_ctx_count() - Get number of sta mld device context
869 *
870 * API to get number of sta mld device context
871 *
872 * Return: number of sta mld device context
873 */
874 uint8_t wlan_mlo_get_sta_mld_ctx_count(void);
875
876 /**
877 * wlan_mlo_get_mld_ctx_by_mldaddr() - Get mld device context using mld
878 * MAC address
879 *
880 * @mldaddr: MAC address of the MLD device
881 *
882 * API to get mld device context using the mld mac address
883 *
884 * Return: Pointer to mlo device context
885 */
886 struct wlan_mlo_dev_context
887 *wlan_mlo_get_mld_ctx_by_mldaddr(struct qdf_mac_addr *mldaddr);
888
889 /**
890 * wlan_mlo_list_peek_head() - Returns the head of linked list
891 *
892 * @ml_list: Pointer to the list of MLDs
893 *
894 * API to retrieve the head from the list of active MLDs
895 *
896 * Return: Pointer to mlo device context
897 */
898 struct wlan_mlo_dev_context *wlan_mlo_list_peek_head(qdf_list_t *ml_list);
899
900 /**
901 * wlan_mlo_get_next_mld_ctx() - Return next mlo dev node from the list
902 *
903 * @ml_list: Pointer to the list of MLDs
904 * @mld_cur: Pointer to the current mlo dev node
905 *
906 * API to retrieve the next node from the list of active MLDs
907 *
908 * Return: Pointer to mlo device context
909 */
910 struct wlan_mlo_dev_context *wlan_mlo_get_next_mld_ctx(qdf_list_t *ml_list,
911 struct wlan_mlo_dev_context *mld_cur);
912
913 /**
914 * wlan_mlo_check_valid_config() - Check vap config is valid for mld
915 *
916 * @ml_dev: Pointer to structure of mlo device context
917 * @pdev: Reference pdev to check against MLD list
918 * @opmode: Operating mode of vdev (SAP/STA etc..)
919 *
920 * API to check if vaps config is valid
921 *
922 * Return: QDF_STATUS
923 */
924 QDF_STATUS wlan_mlo_check_valid_config(struct wlan_mlo_dev_context *ml_dev,
925 struct wlan_objmgr_pdev *pdev,
926 enum QDF_OPMODE opmode);
927
928 /**
929 * mlo_mgr_ml_peer_exist_on_diff_ml_ctx() - Check if MAC address matches any
930 * MLD address
931 * @peer_addr: Address to search for a match
932 * @peer_vdev_id: vdev ID of peer
933 *
934 * The API iterates through all the ML dev ctx in the global MLO
935 * manager to check if MAC address pointed by @peer_addr matches
936 * the MLD address of any ML dev context or its ML peers.
937 * If @peer_vdev_id is a valid pointer address, then API returns
938 * true only if the matching MAC address is not part of the same
939 * ML dev context.
940 *
941 * Return: True if a matching entity is found else false.
942 */
943 bool mlo_mgr_ml_peer_exist_on_diff_ml_ctx(uint8_t *peer_addr,
944 uint8_t *peer_vdev_id);
945
946 /**
947 * wlan_mlo_update_action_frame_from_user() - Change MAC address in WLAN frame
948 * received from userspace.
949 * @vdev: VDEV objmgr pointer.
950 * @frame: Pointer to start of WLAN MAC frame.
951 * @frame_len: Length of the frame.
952 *
953 * The API will translate MLD address in the SA, DA, BSSID for the action
954 * frames received from userspace with link address to send over the air.
955 * The API will not modify if the frame is a Public Action category frame and
956 * for VDEV other then STA mode.
957 *
958 * Return: void
959 */
960 void wlan_mlo_update_action_frame_from_user(struct wlan_objmgr_vdev *vdev,
961 uint8_t *frame,
962 uint32_t frame_len);
963
964 /**
965 * wlan_mlo_update_action_frame_to_user() - Change MAC address in WLAN frame
966 * received over the air.
967 * @vdev: VDEV objmgr pointer.
968 * @frame: Pointer to start of WLAN MAC frame.
969 * @frame_len: Length of the frame.
970 *
971 * The API will translate link address in the SA, DA, BSSID for the action
972 * frames received over the air with MLD address to send to userspace.
973 * The API will not modify if the frame is a Public Action category frame and
974 * for VDEV other then STA mode.
975 *
976 * Return: void
977 */
978 void wlan_mlo_update_action_frame_to_user(struct wlan_objmgr_vdev *vdev,
979 uint8_t *frame,
980 uint32_t frame_len);
981
982 /**
983 * wlan_mlo_mgr_mld_vdev_attach() - Attach VDEV to MLD
984 * @vdev: VDEV object
985 * @mld_addr: MLD address of MLD, where this VDEV should be attached
986 *
987 * API to set MLD MAC address and Attaches VDEV to existing MLD.
988 *
989 * Return: QDF_STATUS
990 */
991 QDF_STATUS wlan_mlo_mgr_mld_vdev_attach(struct wlan_objmgr_vdev *vdev,
992 struct qdf_mac_addr *mld_addr);
993
994 /**
995 * wlan_mlo_mgr_mld_vdev_detach() - Detach VDEV from MLD
996 * @vdev: VDEV object
997 *
998 * API to reset MLD MAC address and Detaches VDEV from its MLD.
999 *
1000 * Return: QDF_STATUS
1001 */
1002 QDF_STATUS wlan_mlo_mgr_mld_vdev_detach(struct wlan_objmgr_vdev *vdev);
1003
1004 #ifdef WLAN_MLO_MULTI_CHIP
1005 /**
1006 * mlo_mgr_is_mld_has_active_link() - Check if any MLD has active link
1007 *
1008 * @is_active: Buffer indicating links are active or not
1009 *
1010 * The API iterates through all the ML dev ctx in the global MLO
1011 * manager to check if there is atleast one active link present in
1012 * any of the MLDs
1013 *
1014 * Return: QDF_STATUS_SUCCESS if link information is retrieved
1015 * successfully else QDF_STATUS_E*.
1016 */
1017 QDF_STATUS mlo_mgr_is_mld_has_active_link(bool *is_active);
1018
1019 #ifdef WLAN_WSI_STATS_SUPPORT
1020 /**
1021 * mlo_wsi_link_info_update_soc() - Update PSOC group in WSI stats
1022 * @psoc: PSOC object
1023 * @grp_id: Group ID
1024 *
1025 * API to update PSOC group id in WSI statas.
1026 *
1027 * Return: void
1028 */
1029 void mlo_wsi_link_info_update_soc(struct wlan_objmgr_psoc *psoc,
1030 uint8_t grp_id);
1031 #else
mlo_wsi_link_info_update_soc(struct wlan_objmgr_psoc * psoc,uint8_t grp_id)1032 static void mlo_wsi_link_info_update_soc(struct wlan_objmgr_psoc *psoc,
1033 uint8_t grp_id)
1034 {
1035 }
1036 #endif
1037 #else
1038 static inline
mlo_mgr_is_mld_has_active_link(bool * is_active)1039 QDF_STATUS mlo_mgr_is_mld_has_active_link(bool *is_active)
1040 {
1041 return QDF_STATUS_E_FAILURE;
1042 }
1043 #endif
1044
1045 #else
wlan_mlo_mgr_init(void)1046 static inline QDF_STATUS wlan_mlo_mgr_init(void)
1047 {
1048 return QDF_STATUS_SUCCESS;
1049 }
1050
wlan_mlo_mgr_deinit(void)1051 static inline QDF_STATUS wlan_mlo_mgr_deinit(void)
1052 {
1053 return QDF_STATUS_SUCCESS;
1054 }
1055
1056 static inline QDF_STATUS
wlan_mlo_mgr_update_mld_addr(struct qdf_mac_addr * old_mac,struct qdf_mac_addr * new_mac)1057 wlan_mlo_mgr_update_mld_addr(struct qdf_mac_addr *old_mac,
1058 struct qdf_mac_addr *new_mac)
1059 {
1060 return QDF_STATUS_SUCCESS;
1061 }
1062
1063 static inline
mlo_mgr_ml_peer_exist_on_diff_ml_ctx(uint8_t * peer_addr,uint8_t * peer_vdev_id)1064 bool mlo_mgr_ml_peer_exist_on_diff_ml_ctx(uint8_t *peer_addr,
1065 uint8_t *peer_vdev_id)
1066 {
1067 return false;
1068 }
1069
1070 static inline
wlan_mlo_update_action_frame_from_user(struct wlan_objmgr_vdev * vdev,uint8_t * frame,uint32_t frame_len)1071 void wlan_mlo_update_action_frame_from_user(struct wlan_objmgr_vdev *vdev,
1072 uint8_t *frame,
1073 uint32_t frame_len)
1074 {
1075 }
1076
1077 static inline
wlan_mlo_update_action_frame_to_user(struct wlan_objmgr_vdev * vdev,uint8_t * frame,uint32_t frame_len)1078 void wlan_mlo_update_action_frame_to_user(struct wlan_objmgr_vdev *vdev,
1079 uint8_t *frame,
1080 uint32_t frame_len)
1081 {
1082 }
1083
1084 static inline
wlan_mlo_get_sta_mld_ctx_count(void)1085 uint8_t wlan_mlo_get_sta_mld_ctx_count(void)
1086 {
1087 return 0;
1088 }
1089
1090 static inline
wlan_mlo_mgr_mld_vdev_attach(struct wlan_objmgr_vdev * vdev,struct qdf_mac_addr * mld_addr)1091 QDF_STATUS wlan_mlo_mgr_mld_vdev_attach(struct wlan_objmgr_vdev *vdev,
1092 struct qdf_mac_addr *mld_addr)
1093 {
1094 return QDF_STATUS_SUCCESS;
1095 }
1096
1097 static inline
wlan_mlo_mgr_mld_vdev_detach(struct wlan_objmgr_vdev * vdev)1098 QDF_STATUS wlan_mlo_mgr_mld_vdev_detach(struct wlan_objmgr_vdev *vdev)
1099 {
1100 return QDF_STATUS_SUCCESS;
1101 }
1102
1103 #endif
1104 #endif
1105