xref: /wlan-driver/qca-wifi-host-cmn/umac/cmn_services/obj_mgr/inc/wlan_objmgr_global_obj.h (revision 5113495b16420b49004c444715d2daae2066e7dc)
1 /*
2  * Copyright (c) 2016-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
6  * any purpose with or without fee is hereby granted, provided that the
7  * above copyright notice and this permission notice appear in all
8  * copies.
9  *
10  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
11  * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
12  * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
13  * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
14  * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
15  * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
16  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
17  * PERFORMANCE OF THIS SOFTWARE.
18  */
19  /**
20   * DOC: Public APIs to perform operations on Global objects
21   */
22 #ifndef _WLAN_OBJMGR_GLOBAL_OBJ_H_
23 #define _WLAN_OBJMGR_GLOBAL_OBJ_H_
24 
25 /**
26  * wlan_objmgr_global_obj_init() - global object initialization
27  *
28  * Creates global object, initializes with default values
29  *
30  * Return: SUCCESS  on successful creation,
31  *         FAILURE  on Mem alloc failure or allocated already
32  *
33  */
34 QDF_STATUS wlan_objmgr_global_obj_init(void);
35 
36 /**
37  * wlan_objmgr_global_obj_deinit() - global object deinitialization
38  *
39  * Deletes global object
40  *
41  * Return: SUCCESS  on successful deletion,
42  *         FAILURE  on object is not found
43  *
44  */
45 QDF_STATUS wlan_objmgr_global_obj_deinit(void);
46 
47 /**
48  * wlan_objmgr_global_obj_can_destroyed() - Checks whether global object
49  *					  can be destroyed
50  *
51  * Checks the psoc table of global object, if psoc table is empty
52  * returns the SUCCESS
53  *
54  * Return: SUCCESS  on can be destroyed,
55  *         FAILURE  on can't be destroyed
56  *
57  */
58 QDF_STATUS wlan_objmgr_global_obj_can_destroyed(void);
59 
60 /**
61  * wlan_objmgr_register_psoc_create_handler() - register psoc create handler
62  * @id: component id
63  * @handler: function pointer of the component
64  * @args: args, if component wants certain args to be passed on PSOC creation
65  *
66  * API, allows other UMAC components to register handler
67  * The registered handler would be invoked on PSOC creation
68  *
69  * Return: SUCCESS,
70  *         Failure (if registration fails, each failure has different error
71  *         code)
72  */
73 QDF_STATUS wlan_objmgr_register_psoc_create_handler(
74 		enum wlan_umac_comp_id id,
75 		wlan_objmgr_psoc_create_handler handler,
76 		void *args);
77 
78 /**
79  * wlan_objmgr_unregister_psoc_create_handler() - unregister psoc create handler
80  * @id: component id
81  * @handler: function pointer of the component
82  * @args: args, if component wants certain args to be passed on PSOC creation
83  *
84  * API, allows other UMAC components to unregister handler
85  *
86  * Return: SUCCESS,
87  *         Failure (if handler is not present, each failure has different error
88  *         code)
89  */
90 QDF_STATUS wlan_objmgr_unregister_psoc_create_handler(
91 		enum wlan_umac_comp_id id,
92 		wlan_objmgr_psoc_create_handler handler,
93 		void *args);
94 
95 /**
96  * wlan_objmgr_register_psoc_destroy_handler() - register destroy handler
97  * @id: component id
98  * @handler: function pointer of the component
99  * @args: args, if component wants certain args to be passed on PSOC deletion
100  *
101  * API, allows other UMAC components to register handler
102  * The registered handler would be invoked on PSOC deletion
103  *
104  * Return: SUCCESS,
105  *         Failure (if registration fails, each failure has different error
106  *         code)
107  */
108 QDF_STATUS wlan_objmgr_register_psoc_destroy_handler(
109 		enum wlan_umac_comp_id id,
110 		wlan_objmgr_psoc_destroy_handler handler,
111 		void *args);
112 
113 /**
114  * wlan_objmgr_unregister_psoc_destroy_handler() - unregister destroy handler
115  * @id: component id
116  * @handler: function pointer of the component
117  * @args: args, if component wants certain args to be passed on PSOC deletion
118  *
119  * API, allows other UMAC components to unregister handler
120  *
121  * Return: SUCCESS,
122  *         Failure (if handler is not present, each failure has different error
123  *         code)
124  */
125 QDF_STATUS wlan_objmgr_unregister_psoc_destroy_handler(
126 		enum wlan_umac_comp_id id,
127 		wlan_objmgr_psoc_destroy_handler handler,
128 		void *args);
129 
130 /**
131  * wlan_objmgr_register_psoc_status_handler() - register status handler
132  * @id: component id
133  * @handler: function pointer of the component
134  * @args: args, if component wants certain args to be passed on PSOC status
135  *         change
136  *
137  * API, allows other UMAC components to register handler
138  * The registered handler would be invoked on PSOC object status change
139  *
140  * Return: SUCCESS,
141  *         Failure (if registration fails, each failure has different error
142  *         code)
143  */
144 QDF_STATUS wlan_objmgr_register_psoc_status_handler(
145 		enum wlan_umac_comp_id id,
146 		wlan_objmgr_psoc_status_handler handler,
147 		void *args);
148 
149 /**
150  * wlan_objmgr_unregister_psoc_status_handler() - unregister status handler
151  * @id: component id
152  * @handler: function pointer of the component
153  * @args: args, if component wants certain args to be passed on PSOC status
154  *
155  * API, allows other UMAC components to unregister handler
156  *
157  * Return: SUCCESS,
158  *         Failure (if handler is not present, each failure has different error
159  *         code)
160  */
161 QDF_STATUS wlan_objmgr_unregister_psoc_status_handler(
162 		enum wlan_umac_comp_id id,
163 		wlan_objmgr_psoc_status_handler handler,
164 		void *args);
165 
166 /**
167  * wlan_objmgr_register_pdev_create_handler() - register pdev create handler
168  * @id: component id
169  * @handler: function pointer of the component
170  * @args: args, if component wants certain args to be passed on PDEV creation
171  *
172  * API, allows other UMAC components to register handler
173  * The registered handler would be invoked on PDEV creation
174  *
175  * Return: SUCCESS,
176  *         Failure (if registration fails, each failure has different error
177  *         code)
178  */
179 QDF_STATUS wlan_objmgr_register_pdev_create_handler(
180 		enum wlan_umac_comp_id id,
181 		wlan_objmgr_pdev_create_handler handler,
182 		void *args);
183 
184 /**
185  * wlan_objmgr_unregister_pdev_create_handler() - unregister pdev create handler
186  * @id: component id
187  * @handler: function pointer of the component
188  * @args: args, if component wants certain args to be passed on PDEV creation
189  *
190  * API, allows other UMAC components to unregister handler
191  *
192  * Return: SUCCESS,
193  *         Failure (if handler is not present, each failure has different error
194  *         code)
195  */
196 QDF_STATUS wlan_objmgr_unregister_pdev_create_handler(
197 		enum wlan_umac_comp_id id,
198 		wlan_objmgr_pdev_create_handler handler,
199 		void *args);
200 
201 /**
202  * wlan_objmgr_register_pdev_destroy_handler() - register pdev destroy handler
203  * @id: component id
204  * @handler: function pointer of the component
205  * @args: args, if component wants certain args to be passed on PDEV deletion
206  *
207  * API, allows other UMAC components to register handler
208  * The registered handler would be invoked on PDEV deletion
209  *
210  * Return: SUCCESS,
211  *         Failure (if registration fails, each failure has different error
212  *         code)
213  */
214 QDF_STATUS wlan_objmgr_register_pdev_destroy_handler(
215 		enum wlan_umac_comp_id id,
216 		wlan_objmgr_pdev_destroy_handler handler,
217 		void *args);
218 
219 /**
220  * wlan_objmgr_unregister_pdev_destroy_handler() - unregister pdev destroy handler
221  * @id: component id
222  * @handler: function pointer of the component
223  * @args: args, if component wants certain args to be passed on PDEV deletion
224  *
225  * API, allows other UMAC components to unregister handler
226  *
227  * Return: SUCCESS,
228  *         Failure (if handler is not present, each failure has different error
229  *         code)
230  */
231 QDF_STATUS wlan_objmgr_unregister_pdev_destroy_handler(
232 		enum wlan_umac_comp_id id,
233 		wlan_objmgr_pdev_destroy_handler handler,
234 		void *args);
235 
236 /**
237  * wlan_objmgr_register_pdev_status_handler() - register pdev status handler
238  * @id: component id
239  * @handler: function pointer of the component
240  * @args: args, if component wants certain args to be passed on PDEV status
241  *         change
242  *
243  * API, allows other UMAC components to register handler
244  * The registered handler would be invoked on PDEV object status change
245  *
246  * Return: SUCCESS,
247  *         Failure (if registration fails, each failure has different error
248  *         code)
249  */
250 QDF_STATUS wlan_objmgr_register_pdev_status_handler(
251 		enum wlan_umac_comp_id id,
252 		wlan_objmgr_pdev_status_handler handler,
253 		void *args);
254 
255 /**
256  * wlan_objmgr_unregister_pdev_status_handler() - unregister pdev status handler
257  * @id: component id
258  * @handler: function pointer of the component
259  * @args: args, if component wants certain args to be passed on PDEV status
260  *
261  * API, allows other UMAC components to unregister handler
262  *
263  * Return: SUCCESS,
264  *         Failure (if handler is not present, each failure has different error
265  *         code)
266  */
267 QDF_STATUS wlan_objmgr_unregister_pdev_status_handler(
268 		enum wlan_umac_comp_id id,
269 		wlan_objmgr_pdev_status_handler handler,
270 		void *args);
271 
272 /**
273  * wlan_objmgr_register_vdev_create_handler() - register vdev create handler
274  * @id: component id
275  * @handler: function pointer of the component
276  * @args: args, if component wants certain args to be passed on VDEV creation
277  *
278  * API, allows other UMAC components to register handler
279  * The registered handler would be invoked on VDEV creation
280  *
281  * Return: SUCCESS,
282  *         Failure (if registration fails, each failure has different error
283  *         code)
284  */
285 QDF_STATUS wlan_objmgr_register_vdev_create_handler(
286 		enum wlan_umac_comp_id id,
287 		wlan_objmgr_vdev_create_handler handler,
288 		void *args);
289 
290 /**
291  * wlan_objmgr_unregister_vdev_create_handler() - unregister vdev create handler
292  * @id: component id
293  * @handler: function pointer of the component
294  * @args: args, if component wants certain args to be passed on VDEV creation
295  *
296  * API, allows other UMAC components to unregister handler
297  *
298  * Return: SUCCESS,
299  *         Failure (if handler is not present, each failure has different error
300  *         code)
301  */
302 QDF_STATUS wlan_objmgr_unregister_vdev_create_handler(
303 		enum wlan_umac_comp_id id,
304 		wlan_objmgr_vdev_create_handler handler,
305 		void *args);
306 
307 /**
308  * wlan_objmgr_register_vdev_destroy_handler() - register vdev destroy handler
309  * @id: component id
310  * @handler: function pointer of the component
311  * @args: args, if component wants certain args to be passed on VDEV deletion
312  *
313  * API, allows other UMAC components to register handler
314  * The registered handler would be invoked on VDEV deletion
315  *
316  * Return: SUCCESS,
317  *         Failure (if registration fails, each failure has different error
318  *         code)
319  */
320 QDF_STATUS wlan_objmgr_register_vdev_destroy_handler(
321 		enum wlan_umac_comp_id id,
322 		wlan_objmgr_vdev_destroy_handler handler,
323 		void *args);
324 
325 /**
326  * wlan_objmgr_unregister_vdev_destroy_handler() - unregister vdev destroy handler
327  * @id: component id
328  * @handler: function pointer of the component
329  * @args: args, if component wants certain args to be passed on VDEV deletion
330  *
331  * API, allows other UMAC components to unregister handler
332  *
333  * Return: SUCCESS,
334  *         Failure (if handler is not present, each failure has different error
335  *         code)
336  */
337 QDF_STATUS wlan_objmgr_unregister_vdev_destroy_handler(
338 		enum wlan_umac_comp_id id,
339 		wlan_objmgr_vdev_destroy_handler handler,
340 		void *args);
341 
342 /**
343  * wlan_objmgr_register_vdev_status_handler() - register vdev status handler
344  * @id: component id
345  * @handler: function pointer of the component
346  * @args: args, if component wants certain args to be passed on VDEV status
347  *         change
348  *
349  * API, allows other UMAC components to register handler
350  * The registered handler would be invoked on VDEV object status change
351  *
352  * Return: SUCCESS,
353  *         Failure (if registration fails, each failure has different error
354  *         code)
355  */
356 QDF_STATUS wlan_objmgr_register_vdev_status_handler(
357 		enum wlan_umac_comp_id id,
358 		wlan_objmgr_vdev_status_handler handler,
359 		void *args);
360 
361 /**
362  * wlan_objmgr_unregister_vdev_status_handler() - unregister vdev status handler
363  * @id: component id
364  * @handler: function pointer of the component
365  * @args: args, if component wants certain args to be passed on VDEV status
366  *
367  * API, allows other UMAC components to unregister handler
368  *
369  * Return: SUCCESS,
370  *         Failure (if handler is not present, each failure has different error
371  *         code)
372  */
373 QDF_STATUS wlan_objmgr_unregister_vdev_status_handler(
374 		enum wlan_umac_comp_id id,
375 		wlan_objmgr_vdev_status_handler handler,
376 		void *args);
377 
378 /**
379  * wlan_objmgr_register_vdev_peer_free_notify_handler() - register vdev peer
380  *                                                        free handler
381  * @id: component id
382  * @handler: function pointer of the component
383  *
384  * API, allows other UMAC components to register handler
385  * The registered handler would be invoked on VDEV Peer gets freed
386  *
387  * Return: SUCCESS,
388  *         Failure (if registration fails, each failure has different error
389  *         code)
390  */
391 QDF_STATUS wlan_objmgr_register_vdev_peer_free_notify_handler(
392 		enum wlan_umac_comp_id id,
393 		wlan_objmgr_vdev_peer_free_notify_handler handler);
394 
395 /**
396  * wlan_objmgr_unregister_vdev_peer_free_notify_handler() - unregister vdev
397  *                                                          peer free handler
398  * @id: component id
399  * @handler: function pointer of the component
400  *
401  * API, allows other UMAC components to unregister handler
402  *
403  * Return: SUCCESS,
404  *         Failure (if handler is not present, each failure has different error
405  *         code)
406  */
407 QDF_STATUS wlan_objmgr_unregister_vdev_peer_free_notify_handler(
408 		enum wlan_umac_comp_id id,
409 		wlan_objmgr_vdev_peer_free_notify_handler handler);
410 
411 /**
412  * wlan_objmgr_register_peer_create_handler() - register peer create handler
413  * @id: component id
414  * @handler: function pointer of the component
415  * @args: args, if component wants certain args to be passed on PEER creation
416  *
417  * API, allows other UMAC components to register handler
418  * The registered handler would be invoked on PEER creation
419  *
420  * Return: SUCCESS,
421  *         Failure (if registration fails, each failure has different error
422  *         code)
423  */
424 QDF_STATUS wlan_objmgr_register_peer_create_handler(
425 		enum wlan_umac_comp_id id,
426 		wlan_objmgr_peer_create_handler handler,
427 		void *args);
428 
429 /**
430  * wlan_objmgr_unregister_peer_create_handler() - unregister peer create handler
431  * @id: component id
432  * @handler: function pointer of the component
433  * @args: args, if component wants certain args to be passed on PEER creation
434  *
435  * API, allows other UMAC components to unregister handler
436  *
437  * Return: SUCCESS,
438  *         Failure (if handler is not present, each failure has different error
439  *         code)
440  */
441 QDF_STATUS wlan_objmgr_unregister_peer_create_handler(
442 		enum wlan_umac_comp_id id,
443 		wlan_objmgr_peer_create_handler handler,
444 		void *args);
445 
446 /**
447  * wlan_objmgr_register_peer_destroy_handler() - register peer destroy handler
448  * @id: component id
449  * @handler: function pointer of the component
450  * @args: args, if component wants certain args to be passed on PEER deletion
451  *
452  * API, allows other UMAC components to register handler
453  * The registered handler would be invoked on PEER deletion
454  *
455  * Return: SUCCESS,
456  *         Failure (if registration fails, each failure has different error
457  *         code)
458  */
459 QDF_STATUS wlan_objmgr_register_peer_destroy_handler(
460 		enum wlan_umac_comp_id id,
461 		wlan_objmgr_peer_destroy_handler handler,
462 		void *args);
463 
464 /**
465  * wlan_objmgr_unregister_peer_destroy_handler() - unregister peer destroy handler
466  * @id: component id
467  * @handler: function pointer of the component
468  * @args: args, if component wants certain args to be passed on PEER deletion
469  *
470  * API, allows other UMAC components to unregister handler
471  *
472  * Return: SUCCESS,
473  *         Failure (if handler is not present, each failure has different error
474  *         code)
475  */
476 QDF_STATUS wlan_objmgr_unregister_peer_destroy_handler(
477 		enum wlan_umac_comp_id id,
478 		wlan_objmgr_peer_destroy_handler handler,
479 		void *args);
480 
481 /**
482  * wlan_objmgr_register_peer_status_handler() - register peer status handler
483  * @id: component id
484  * @handler: function pointer of the component
485  * @args: args, if component wants certain args to be passed on PEER status
486  *         change
487  *
488  * API, allows other UMAC components to register handler
489  * The registered handler would be invoked on PEER object status change
490  *
491  * Return: SUCCESS,
492  *         Failure (if registration fails, each failure has different error
493  *         code)
494  */
495 QDF_STATUS wlan_objmgr_register_peer_status_handler(
496 		enum wlan_umac_comp_id id,
497 		wlan_objmgr_peer_status_handler handler,
498 		void *args);
499 
500 /**
501  * wlan_objmgr_unregister_peer_status_handler() - unregister peer status handler
502  * @id: component id
503  * @handler: function pointer of the component
504  * @args: args, if component wants certain args to be passed on PEER status
505  *
506  * API, allows other UMAC components to unregister handler
507  *
508  * Return: SUCCESS,
509  *         Failure (if handler is not present, each failure has different error
510  *         code)
511  */
512 QDF_STATUS wlan_objmgr_unregister_peer_status_handler(
513 		enum wlan_umac_comp_id id,
514 		wlan_objmgr_peer_status_handler handler,
515 		void *args);
516 
517 /*
518  * APIs to operations on psoc
519  */
520 typedef void (*wlan_objmgr_psoc_handler)(struct wlan_objmgr_psoc *psoc,
521 					void *arg,
522 					uint8_t index);
523 
524 /**
525  * wlan_objmgr_iterate_psoc_list() - iterate through all psocs
526  *
527  * @handler: the handler will be called for each psoc
528  *           the handler should be implemented to perform required operation
529  * @arg:     arguments passed by caller
530  * @dbg_id: id of the caller
531  *
532  * API to be used for performing the operations on all psoc
533  * The "handler" here shouldn't take g_umac_glb_obj->global_lock lock when
534  * processing
535  *
536  * Return: SUCCESS/FAILURE
537  */
538 QDF_STATUS wlan_objmgr_iterate_psoc_list(
539 		wlan_objmgr_psoc_handler handler,
540 		void *arg, wlan_objmgr_ref_dbgid dbg_id);
541 
542 /**
543  * wlan_objmgr_get_psoc_by_id() - find psoc by psoc id
544  *
545  * @psoc_id: Id of PSOC to be retrieved
546  * @dbg_id: id of the caller
547  *
548  * API to find psoc object pointer by psoc id
549  *
550  * This API increments the ref count of the psoc object internally, the
551  * caller has to invoke the wlan_objmgr_psoc_release_ref() to decrement
552  * ref count
553  *
554  * Return: psoc pointer
555  *         NULL on FAILURE
556  */
557 struct wlan_objmgr_psoc
558 *wlan_objmgr_get_psoc_by_id(uint8_t psoc_id, wlan_objmgr_ref_dbgid dbg_id);
559 
560 #ifdef QCA_SUPPORT_DP_GLOBAL_CTX
561 /**
562  * wlan_objmgr_get_global_ctx() - Get global context from global umac object
563  *
564  * This API is used to get global context object from the global umac object
565  *
566  * Return: Pointer to global context
567  */
568 struct dp_global_context *wlan_objmgr_get_global_ctx(void);
569 
570 /**
571  * wlan_objmgr_set_global_ctx() - Set global context in global umac object
572  * @ctx: global context to be set
573  *
574  * This API is used to set global context object in the global umac object
575  *
576  * Return:
577  */
578 void wlan_objmgr_set_global_ctx(struct dp_global_context *ctx);
579 #endif
580 
581 #ifdef WLAN_FEATURE_11BE_MLO
582 /**
583  * wlan_objmgr_get_mlo_ctx() - Get MLO context from global umac object
584  *
585  * This API is used to get MLO context object from the global umac object
586  *
587  * Return: Pointer to the mlo context
588  */
589 struct mlo_mgr_context *wlan_objmgr_get_mlo_ctx(void);
590 
591 /**
592  * wlan_objmgr_set_mlo_ctx() - Set MLO context at global umac object
593  * @ctx: MLO context
594  *
595  * This API is used to set MLO context object at the global umac object
596  *
597  * Return: None
598  */
599 void wlan_objmgr_set_mlo_ctx(struct mlo_mgr_context *ctx);
600 
601 /**
602  * wlan_objmgr_set_dp_mlo_ctx() - set dp handle in mlo context
603  * @dp_handle: Data path module handle
604  * @grp_id: MLO group id which it belongs too
605  *
606  * Return: void
607  */
608 void wlan_objmgr_set_dp_mlo_ctx(void *dp_handle, uint8_t grp_id);
609 
610 /**
611  * wlan_objmgr_get_dp_mlo_ctx() - get dp handle from mlo_context
612  * @grp_id: MLO Group id which it belongs to
613  *
614  * Return: dp handle
615  */
616 void *wlan_objmgr_get_dp_mlo_ctx(uint8_t grp_id);
617 #else
wlan_objmgr_get_mlo_ctx(void)618 static inline struct mlo_mgr_context *wlan_objmgr_get_mlo_ctx(void)
619 {
620 	return NULL;
621 }
622 
wlan_objmgr_set_mlo_ctx(struct mlo_mgr_context * ctx)623 static inline void wlan_objmgr_set_mlo_ctx(struct mlo_mgr_context *ctx)
624 {}
625 
wlan_objmgr_get_dp_mlo_ctx(uint8_t grp_id)626 static inline void *wlan_objmgr_get_dp_mlo_ctx(uint8_t grp_id)
627 {
628 	return NULL;
629 }
630 
wlan_objmgr_set_dp_mlo_ctx(void * dp_handle,uint8_t grp_id)631 static inline void wlan_objmgr_set_dp_mlo_ctx(void *dp_handle, uint8_t grp_id)
632 {
633 }
634 #endif /* WLAN_FEATURE_11BE_MLO */
635 
636 #endif /* _WLAN_OBJMGR_GLOBAL_OBJ_H_*/
637