xref: /wlan-dirver/qca-wifi-host-cmn/umac/mlo_mgr/inc/wlan_mlo_mgr_main.h (revision 2f4b444fb7e689b83a4ab0e7b3b38f0bf4def8e0)
1 /*
2  * Copyright (c) 2021, The Linux Foundation. All rights reserved.
3  *
4  * Permission to use, copy, modify, and/or distribute this software for any
5  * purpose with or without fee is hereby granted, provided that the above
6  * copyright notice and this permission notice appear in all copies.
7  *
8  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15  */
16 
17 /*
18  * DOC: contains MLO manager containing init/deinit public api's
19  */
20 #ifndef _WLAN_MLO_MGR_MAIN_H_
21 #define _WLAN_MLO_MGR_MAIN_H_
22 
23 #include <qdf_atomic.h>
24 #include <wlan_objmgr_psoc_obj.h>
25 #include <wlan_objmgr_pdev_obj.h>
26 #include <wlan_objmgr_vdev_obj.h>
27 
28 #ifdef WLAN_FEATURE_11BE_MLO
29 #include <wlan_mlo_mgr_public_structs.h>
30 /**
31  * wlan_mlo_mgr_init() - Initialize the MLO data structures
32  *
33  * Return: QDF_STATUS
34  */
35 QDF_STATUS wlan_mlo_mgr_init(void);
36 
37 /**
38  * wlan_mlo_mgr_deinit() - De-init the MLO data structures
39  *
40  * Return: QDF_STATUS
41  */
42 QDF_STATUS wlan_mlo_mgr_deinit(void);
43 
44 /**
45  * wlan_mlo_mgr_vdev_created_notification() - mlo mgr vdev create handler
46  * @vdev: vdev object
47  * @arg_list: Argument list
48  *
49  * This function is called as part of vdev creation. This will initialize
50  * the MLO dev context if the interface type is ML.
51  *
52  * Return: QDF_STATUS
53  */
54 QDF_STATUS wlan_mlo_mgr_vdev_created_notification(struct wlan_objmgr_vdev *vdev,
55 						  void *arg_list);
56 
57 /**
58  * wlan_mlo_mgr_vdev_destroyed_notification() - mlo mgr vdev delete handler
59  * @vdev: vdev object
60  * @arg_list: Argument list
61  *
62  * This function is called as part of vdev delete. This will de-initialize
63  * the MLO dev context if the interface type is ML.
64  *
65  * Return: QDF_STATUS
66  */
67 QDF_STATUS wlan_mlo_mgr_vdev_destroyed_notification(struct wlan_objmgr_vdev *vdev,
68 						    void *arg_list);
69 
70 #ifdef WLAN_MLO_USE_SPINLOCK
71 /**
72  * ml_link_lock_create - Create MLO link mutex/spinlock
73  * @mlo_ctx:  MLO manager global context
74  *
75  * Creates mutex/spinlock
76  *
77  * Return: void
78  */
79 static inline
80 void ml_link_lock_create(struct mlo_mgr_context *mlo_ctx)
81 {
82 	qdf_spinlock_create(&mlo_ctx->ml_dev_list_lock);
83 }
84 
85 /**
86  * ml_link_lock_destroy - Destroy ml link mutex/spinlock
87  * @mlo_ctx:  MLO manager global context
88  *
89  * Destroy mutex/spinlock
90  *
91  * Return: void
92  */
93 static inline void
94 ml_link_lock_destroy(struct mlo_mgr_context *mlo_ctx)
95 {
96 	qdf_spinlock_destroy(&mlo_ctx->ml_dev_list_lock);
97 }
98 
99 /**
100  * ml_link_lock_acquire - acquire ml link mutex/spinlock
101  * @mlo_ctx:  MLO manager global context
102  *
103  * acquire mutex/spinlock
104  *
105  * return: void
106  */
107 static inline
108 void ml_link_lock_acquire(struct mlo_mgr_context *mlo_ctx)
109 {
110 	qdf_spin_lock_bh(&mlo_ctx->ml_dev_list_lock);
111 }
112 
113 /**
114  * ml_link_lock_release - release MLO dev mutex/spinlock
115  * @mlo_ctx:  MLO manager global context
116  *
117  * release mutex/spinlock
118  *
119  * return: void
120  */
121 static inline
122 void ml_link_lock_release(struct mlo_mgr_context *mlo_ctx)
123 {
124 	qdf_spin_unlock_bh(&mlo_ctx->ml_dev_list_lock);
125 }
126 
127 /**
128  * mlo_dev_lock_create - Create MLO device mutex/spinlock
129  * @mldev:  ML device context
130  *
131  * Creates mutex/spinlock
132  *
133  * Return: void
134  */
135 static inline void
136 mlo_dev_lock_create(struct wlan_mlo_dev_context *mldev)
137 {
138 	qdf_spinlock_create(&mldev->mlo_dev_lock);
139 }
140 
141 /**
142  * mlo_dev_lock_destroy - Destroy CM SM mutex/spinlock
143  * @mldev:  ML device context
144  *
145  * Destroy mutex/spinlock
146  *
147  * Return: void
148  */
149 static inline void
150 mlo_dev_lock_destroy(struct wlan_mlo_dev_context *mldev)
151 {
152 	qdf_spinlock_destroy(&mldev->mlo_dev_lock);
153 }
154 
155 /**
156  * mlo_dev_lock_acquire - acquire CM SM mutex/spinlock
157  * @mldev:  ML device context
158  *
159  * acquire mutex/spinlock
160  *
161  * return: void
162  */
163 static inline
164 void mlo_dev_lock_acquire(struct wlan_mlo_dev_context *mldev)
165 {
166 	qdf_spin_lock_bh(&mldev->mlo_dev_lock);
167 }
168 
169 /**
170  * mlo_dev_lock_release - release MLO dev mutex/spinlock
171  * @mldev:  ML device context
172  *
173  * release mutex/spinlock
174  *
175  * return: void
176  */
177 static inline
178 void mlo_dev_lock_release(struct wlan_mlo_dev_context *mldev)
179 {
180 	qdf_spin_unlock_bh(&mldev->mlo_dev_lock);
181 }
182 
183 /**
184  * ml_aid_lock_create - Create MLO aid mutex/spinlock
185  * @mlo_ctx:  MLO manager global context
186  *
187  * Creates mutex/spinlock
188  *
189  * Return: void
190  */
191 static inline
192 void ml_aid_lock_create(struct mlo_mgr_context *mlo_ctx)
193 {
194 	qdf_spinlock_create(&mlo_ctx->aid_lock);
195 }
196 
197 /**
198  * ml_aid_lock_destroy - Destroy ml aid mutex/spinlock
199  * @mlo_ctx:  MLO manager global context
200  *
201  * Destroy mutex/spinlock
202  *
203  * Return: void
204  */
205 static inline void
206 ml_aid_lock_destroy(struct mlo_mgr_context *mlo_ctx)
207 {
208 	qdf_spinlock_destroy(&mlo_ctx->aid_lock);
209 }
210 
211 /**
212  * ml_aid_lock_acquire - acquire ml aid mutex/spinlock
213  * @mlo_ctx:  MLO manager global context
214  *
215  * acquire mutex/spinlock
216  *
217  * return: void
218  */
219 static inline
220 void ml_aid_lock_acquire(struct mlo_mgr_context *mlo_ctx)
221 {
222 	qdf_spin_lock_bh(&mlo_ctx->aid_lock);
223 }
224 
225 /**
226  * ml_aid_lock_release - release MLO aid mutex/spinlock
227  * @mlo_ctx:  MLO manager global context
228  *
229  * release mutex/spinlock
230  *
231  * return: void
232  */
233 static inline
234 void ml_aid_lock_release(struct mlo_mgr_context *mlo_ctx)
235 {
236 	qdf_spin_unlock_bh(&mlo_ctx->aid_lock);
237 }
238 
239 /**
240  * ml_peerid_lock_create - Create MLO peer mutex/spinlock
241  * @mlo_ctx:  MLO manager global context
242  *
243  * Creates mutex/spinlock
244  *
245  * Return: void
246  */
247 static inline
248 void ml_peerid_lock_create(struct mlo_mgr_context *mlo_ctx)
249 {
250 	qdf_spinlock_create(&mlo_ctx->ml_peerid_lock);
251 }
252 
253 /**
254  * ml_peerid_lock_destroy - Destroy ml peerid mutex/spinlock
255  * @mlo_ctx:  MLO manager global context
256  *
257  * Destroy mutex/spinlock
258  *
259  * Return: void
260  */
261 static inline void
262 ml_peerid_lock_destroy(struct mlo_mgr_context *mlo_ctx)
263 {
264 	qdf_spinlock_destroy(&mlo_ctx->ml_peerid_lock);
265 }
266 
267 /**
268  * ml_peerid_lock_acquire - acquire ml peerid mutex/spinlock
269  * @mlo_ctx:  MLO manager global context
270  *
271  * acquire mutex/spinlock
272  *
273  * return: void
274  */
275 static inline
276 void ml_peerid_lock_acquire(struct mlo_mgr_context *mlo_ctx)
277 {
278 	qdf_spin_lock_bh(&mlo_ctx->ml_peerid_lock);
279 }
280 
281 /**
282  * ml_peerid_lock_release - release MLO peerid mutex/spinlock
283  * @mlo_ctx:  MLO manager global context
284  *
285  * release mutex/spinlock
286  *
287  * return: void
288  */
289 static inline
290 void ml_peerid_lock_release(struct mlo_mgr_context *mlo_ctx)
291 {
292 	qdf_spin_unlock_bh(&mlo_ctx->ml_peerid_lock);
293 }
294 
295 /**
296  * mlo_peer_lock_create - Create MLO peer mutex/spinlock
297  * @mlpeer:  ML peer
298  *
299  * Creates mutex/spinlock
300  *
301  * Return: void
302  */
303 static inline void
304 mlo_peer_lock_create(struct wlan_mlo_peer_context *mlpeer)
305 {
306 	qdf_spinlock_create(&mlpeer->mlo_peer_lock);
307 }
308 
309 /**
310  * mlo_peer_lock_destroy - Destroy MLO peer mutex/spinlock
311  * @mlpeer:  ML peer
312  *
313  * Destroy mutex/spinlock
314  *
315  * Return: void
316  */
317 static inline void
318 mlo_peer_lock_destroy(struct wlan_mlo_peer_context *mlpeer)
319 {
320 	qdf_spinlock_destroy(&mlpeer->mlo_peer_lock);
321 }
322 
323 /**
324  * mlo_peer_lock_acquire - acquire mlo peer mutex/spinlock
325  * @mlpeer:  MLO peer context
326  *
327  * acquire mutex/spinlock
328  *
329  * return: void
330  */
331 static inline
332 void mlo_peer_lock_acquire(struct wlan_mlo_peer_context *mlpeer)
333 {
334 	qdf_spin_lock_bh(&mlpeer->mlo_peer_lock);
335 }
336 
337 /**
338  * mlo_peer_lock_release - release MLO peer mutex/spinlock
339  * @mlpeer:  MLO peer context
340  *
341  * release mutex/spinlock
342  *
343  * return: void
344  */
345 static inline
346 void mlo_peer_lock_release(struct wlan_mlo_peer_context *mlpeer)
347 {
348 	qdf_spin_unlock_bh(&mlpeer->mlo_peer_lock);
349 }
350 
351 /**
352  * ml_peerlist_lock_create - Create MLO peer list mutex/spinlock
353  * @ml_peerlist:  ML peer list context
354  *
355  * Creates mutex/spinlock
356  *
357  * Return: void
358  */
359 static inline void
360 ml_peerlist_lock_create(struct wlan_mlo_peer_list *ml_peerlist)
361 {
362 	qdf_spinlock_create(&ml_peerlist->peer_list_lock);
363 }
364 
365 /**
366  * ml_peerlist_lock_destroy - Destroy MLO peer list mutex/spinlock
367  * @ml_peerlist:  ML peer list context
368  *
369  * Destroy mutex/spinlock
370  *
371  * Return: void
372  */
373 static inline void
374 ml_peerlist_lock_destroy(struct wlan_mlo_peer_list *ml_peerlist)
375 {
376 	qdf_spinlock_destroy(&ml_peerlist->peer_list_lock);
377 }
378 
379 /**
380  * ml_peerlist_lock_acquire - acquire ML peer list mutex/spinlock
381  * @ml_peerlist:  ML peer list context
382  *
383  * acquire mutex/spinlock
384  *
385  * return: void
386  */
387 static inline
388 void ml_peerlist_lock_acquire(struct wlan_mlo_peer_list *ml_peerlist)
389 {
390 	qdf_spin_lock_bh(&ml_peerlist->peer_list_lock);
391 }
392 
393 /**
394  * ml_peerlist_lock_release - release ML peer list mutex/spinlock
395  * @ml_peerlist:  ML peer list context
396  *
397  * release mutex/spinlock
398  *
399  * return: void
400  */
401 static inline
402 void ml_peerlist_lock_release(struct wlan_mlo_peer_list *ml_peerlist)
403 {
404 	qdf_spin_unlock_bh(&ml_peerlist->peer_list_lock);
405 }
406 
407 #else
408 static inline
409 void ml_link_lock_create(struct mlo_mgr_context *mlo_ctx)
410 {
411 	qdf_mutex_create(&mlo_ctx->ml_dev_list_lock);
412 }
413 
414 static inline void
415 ml_link_lock_destroy(struct mlo_mgr_context *mlo_ctx)
416 {
417 	qdf_mutex_destroy(&mlo_ctx->ml_dev_list_lock);
418 }
419 
420 static inline
421 void ml_link_lock_acquire(struct mlo_mgr_context *mlo_ctx)
422 {
423 	qdf_mutex_acquire(&mlo_ctx->ml_dev_list_lock);
424 }
425 
426 static inline
427 void ml_link_lock_release(struct mlo_mgr_context *mlo_ctx)
428 {
429 	qdf_mutex_release(&mlo_ctx->ml_dev_list_lock);
430 }
431 
432 static inline
433 void mlo_dev_lock_create(struct wlan_mlo_dev_context *mldev)
434 {
435 	qdf_mutex_create(&mldev->mlo_dev_lock);
436 }
437 
438 static inline
439 void mlo_dev_lock_destroy(struct wlan_mlo_dev_context *mldev)
440 {
441 	qdf_mutex_destroy(&mldev->mlo_dev_lock);
442 }
443 
444 static inline void mlo_dev_lock_acquire(struct wlan_mlo_dev_context *mldev)
445 {
446 	qdf_mutex_acquire(&mldev->mlo_dev_lock);
447 }
448 
449 static inline void mlo_dev_lock_release(struct wlan_mlo_dev_context *mldev)
450 {
451 	qdf_mutex_release(&mldev->mlo_dev_lock);
452 }
453 
454 static inline
455 void ml_aid_lock_create(struct mlo_mgr_context *mlo_ctx)
456 {
457 	qdf_mutex_create(&mlo_ctx->aid_lock);
458 }
459 
460 static inline void
461 ml_aid_lock_destroy(struct mlo_mgr_context *mlo_ctx)
462 {
463 	qdf_mutex_destroy(&mlo_ctx->aid_lock);
464 }
465 
466 static inline
467 void ml_aid_lock_acquire(struct mlo_mgr_context *mlo_ctx)
468 {
469 	qdf_mutex_acquire(&mlo_ctx->aid_lock);
470 }
471 
472 static inline
473 void ml_aid_lock_release(struct mlo_mgr_context *mlo_ctx)
474 {
475 	qdf_mutex_release(&mlo_ctx->aid_lock);
476 }
477 
478 static inline
479 void ml_peerid_lock_create(struct mlo_mgr_context *mlo_ctx)
480 {
481 	qdf_mutex_create(&mlo_ctx->ml_peerid_lock);
482 }
483 
484 static inline void
485 ml_peerid_lock_destroy(struct mlo_mgr_context *mlo_ctx)
486 {
487 	qdf_mutex_destroy(&mlo_ctx->ml_peerid_lock);
488 }
489 
490 static inline
491 void ml_peerid_lock_acquire(struct mlo_mgr_context *mlo_ctx)
492 {
493 	qdf_mutex_acquire(&mlo_ctx->ml_peerid_lock);
494 }
495 
496 static inline
497 void ml_peerid_lock_release(struct mlo_mgr_context *mlo_ctx)
498 {
499 	qdf_mutex_release(&mlo_ctx->ml_peerid_lock);
500 }
501 
502 static inline void
503 mlo_peer_lock_create(struct wlan_mlo_peer_context *mlpeer)
504 {
505 	qdf_mutex_create(&mlpeer->mlo_peer_lock);
506 }
507 
508 static inline void
509 mlo_peer_lock_destroy(struct wlan_mlo_peer_context *mlpeer)
510 {
511 	qdf_mutex_destroy(&mlpeer->mlo_peer_lock);
512 }
513 
514 static inline
515 void mlo_peer_lock_acquire(struct wlan_mlo_peer_context *mlpeer)
516 {
517 	qdf_mutex_acquire(&mlpeer->mlo_peer_lock);
518 }
519 
520 static inline
521 void mlo_peer_lock_release(struct wlan_mlo_peer_context *mlpeer)
522 {
523 	qdf_mutex_release(&mlpeer->mlo_peer_lock);
524 }
525 
526 static inline void
527 ml_peerlist_lock_create(struct wlan_mlo_peer_list *ml_peerlist)
528 {
529 	qdf_mutex_create(&ml_peerlist->peer_list_lock);
530 }
531 
532 static inline void
533 ml_peerlist_lock_destroy(struct wlan_mlo_peer_list *ml_peerlist)
534 {
535 	qdf_mutex_destroy(&ml_peerlist->peer_list_lock);
536 }
537 
538 static inline
539 void ml_peerlist_lock_acquire(struct wlan_mlo_peer_list *ml_peerlist)
540 {
541 	qdf_mutex_acquire(&ml_peerlist->peer_list_lock);
542 }
543 
544 static inline
545 void ml_peerlist_lock_release(struct wlan_mlo_peer_list *ml_peerlist)
546 {
547 	qdf_mutex_release(&ml_peerlist->peer_list_lock);
548 }
549 #endif /* WLAN_MLO_USE_SPINLOCK */
550 
551 #else
552 static inline QDF_STATUS wlan_mlo_mgr_init(void)
553 {
554 	return QDF_STATUS_SUCCESS;
555 }
556 
557 static inline QDF_STATUS wlan_mlo_mgr_deinit(void)
558 {
559 	return QDF_STATUS_SUCCESS;
560 }
561 #endif
562 #endif
563