xref: /wlan-dirver/qca-wifi-host-cmn/umac/cmn_services/obj_mgr/inc/wlan_objmgr_cmn.h (revision 11f5a63a6cbdda84849a730de22f0a71e635d58c)
1 /*
2  * Copyright (c) 2016-2019 The Linux Foundation. All rights reserved.
3  *
4  * Permission to use, copy, modify, and/or distribute this software for
5  * any purpose with or without fee is hereby granted, provided that the
6  * above copyright notice and this permission notice appear in all
7  * copies.
8  *
9  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
10  * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
11  * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
12  * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
13  * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
14  * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
15  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
16  * PERFORMANCE OF THIS SOFTWARE.
17  */
18  /**
19   * DOC: This file provides the common definitions for object manager
20   */
21 
22 #ifndef _WLAN_OBJMGR_CMN_H_
23 #define _WLAN_OBJMGR_CMN_H_
24 
25 #include "qdf_lock.h"
26 #include "qdf_list.h"
27 #include "qdf_status.h"
28 #include "wlan_cmn.h"
29 #include "qdf_atomic.h"
30 
31 /* No. of PSOCs can be supported */
32 #define WLAN_OBJMGR_MAX_DEVICES 3
33 
34 /* size of Hash */
35 #define WLAN_PEER_HASHSIZE 64
36 
37 /* simple hash is enough for variation of macaddr */
38 #define WLAN_PEER_HASH(addr)   \
39 (((const uint8_t *)(addr))[QDF_MAC_ADDR_SIZE - 1] % WLAN_PEER_HASHSIZE)
40 
41 #define obj_mgr_log(level, args...) \
42 		QDF_TRACE(QDF_MODULE_ID_OBJ_MGR, level, ## args)
43 #define obj_mgr_logfl(level, format, args...) \
44 		obj_mgr_log(level, FL(format), ## args)
45 #define obj_mgr_log_level(level, format, args...)\
46 		obj_mgr_logfl(level, format, ## args)
47 
48 #define obj_mgr_alert(params...) \
49 	QDF_TRACE_FATAL(QDF_MODULE_ID_OBJ_MGR, params)
50 #define obj_mgr_err(params...) \
51 	QDF_TRACE_ERROR(QDF_MODULE_ID_OBJ_MGR, params)
52 #define obj_mgr_warn(params...) \
53 	QDF_TRACE_WARN(QDF_MODULE_ID_OBJ_MGR, params)
54 #define obj_mgr_info(params...) \
55 	QDF_TRACE_INFO(QDF_MODULE_ID_OBJ_MGR, params)
56 #define obj_mgr_debug(params...) \
57 	QDF_TRACE_DEBUG(QDF_MODULE_ID_OBJ_MGR, params)
58 
59 #define objmgr_nofl_alert(params...) \
60 	QDF_TRACE_FATAL_NO_FL(QDF_MODULE_ID_OBJ_MGR, params)
61 #define objmgr_nofl_err(params...) \
62 	QDF_TRACE_ERROR_NO_FL(QDF_MODULE_ID_OBJ_MGR, params)
63 #define objmgr_nofl_warn(params...) \
64 	QDF_TRACE_WARN_NO_FL(QDF_MODULE_ID_OBJ_MGR, params)
65 #define objmgr_nofl_info(params...) \
66 	QDF_TRACE_INFO_NO_FL(QDF_MODULE_ID_OBJ_MGR, params)
67 #define objmgr_nofl_debug(params...) \
68 	QDF_TRACE_DEBUG_NO_FL(QDF_MODULE_ID_OBJ_MGR, params)
69 
70 /**
71  * enum WLAN_OBJ_STATE - State of Object
72  * @WLAN_OBJ_STATE_ALLOCATED:           Common object is allocated, but not
73  *                                      fully initialized
74  * @WLAN_OBJ_STATE_CREATED:             All component objects are created
75  * @WLAN_OBJ_STATE_DELETED:             All component objects are destroyed
76  * @WLAN_OBJ_STATE_PARTIALLY_CREATED:   Few/All component objects creation is
77  *                                      in progress
78  * @WLAN_OBJ_STATE_PARTIALLY_DELETED:   Component objects deletion is triggered,
79  *                                      they are yet to be destroyed
80  * @WLAN_OBJ_STATE_COMP_DEL_PROGRESS:   If a component is disabled run time,
81  *                                      and this state is used to represent the
82  *                                      deletion in progress after that
83  *                                      component object is destroyed, object
84  *                                      state would be moved to CREATED state
85  * @WLAN_OBJ_STATE_LOGICALLY_DELETED:   Object deletion has been initiated,
86  *                                      object destroy invoked once references
87  *                                      are released
88  * @WLAN_OBJ_STATE_CREATION_FAILED:     any component object is failed to be
89  *                                      created
90  * @WLAN_OBJ_STATE_DELETION_FAILED:     any component object is failed to be
91  *                                      destroyed
92  */
93 typedef enum {
94 	WLAN_OBJ_STATE_ALLOCATED          = 0,
95 	WLAN_OBJ_STATE_CREATED            = 1,
96 	WLAN_OBJ_STATE_DELETED            = 2,
97 	WLAN_OBJ_STATE_PARTIALLY_CREATED  = 3,
98 	WLAN_OBJ_STATE_PARTIALLY_DELETED  = 4,
99 	WLAN_OBJ_STATE_COMP_DEL_PROGRESS  = 5,
100 	WLAN_OBJ_STATE_LOGICALLY_DELETED  = 6,
101 	WLAN_OBJ_STATE_CREATION_FAILED    = 7,
102 	WLAN_OBJ_STATE_DELETION_FAILED    = 8,
103 } WLAN_OBJ_STATE;
104 
105 /* Object type is assigned with value */
106 enum wlan_objmgr_obj_type {
107 	WLAN_PSOC_OP      = 0,
108 	WLAN_PDEV_OP      = 1,
109 	WLAN_VDEV_OP      = 2,
110 	WLAN_PEER_OP      = 3,
111 	WLAN_OBJ_TYPE_MAX = 4,
112 };
113 
114 /**
115  * struct wlan_peer_list {
116  * @peer_hash[]:    peer sub lists
117  * @peer_list_lock: List lock, this has to be acquired on
118  *		    accessing/updating the list
119  *
120  *  Peer list, it maintains sublists based on the MAC address as hash
121  *  Note: For DA WDS similar peer list has to be maintained
122  *  This peer list will not have WDS nodes
123  */
124 struct wlan_peer_list {
125 	qdf_list_t peer_hash[WLAN_PEER_HASHSIZE];
126 	qdf_spinlock_t peer_list_lock;
127 };
128 
129 struct wlan_objmgr_psoc;
130 struct wlan_objmgr_pdev;
131 struct wlan_objmgr_vdev;
132 struct wlan_objmgr_peer;
133 
134 /* Create handler would return the following status
135 	QDF_STATUS_SUCCESS--
136 		For synchronous handler:- this is returned on successful
137 	component object creation
138 
139 	QDF_STATUS_COMP_DISABLED--
140 		For synchronous handler:- this is returned on if component
141 	doesn't want to allocate
142 
143 	QDF_STATUS_COMP_ASYNC--
144 		For asynchronous handler:- this is returned on if component
145 	needs a context break
146 
147 	QDF_STATUS_E_NOMEM--
148 		For synchronous handler:- this is returned on if component
149 	can't allocate
150 	QDF_STATUS_E_FAILURE--
151 		For synchronous handler:- If it is failed,
152 		For asynchronous handler:- If it is failed to post message
153 	(means, not required)/feature is not supported
154 */
155 typedef QDF_STATUS (*wlan_objmgr_psoc_create_handler)(
156 				struct wlan_objmgr_psoc *psoc, void *arg);
157 typedef QDF_STATUS (*wlan_objmgr_psoc_destroy_handler)(
158 				struct wlan_objmgr_psoc *psoc, void *arg);
159 typedef void (*wlan_objmgr_psoc_status_handler)(struct wlan_objmgr_psoc *psoc,
160 					 void *arg, QDF_STATUS status);
161 
162 typedef QDF_STATUS (*wlan_objmgr_pdev_create_handler)(
163 				struct wlan_objmgr_pdev *pdev, void *arg);
164 typedef QDF_STATUS (*wlan_objmgr_pdev_destroy_handler)(
165 				struct wlan_objmgr_pdev *pdev, void *arg);
166 typedef void (*wlan_objmgr_pdev_status_handler)(
167 				struct wlan_objmgr_pdev *pdev, void *arg,
168 						QDF_STATUS status);
169 
170 typedef QDF_STATUS (*wlan_objmgr_vdev_create_handler)(
171 				struct wlan_objmgr_vdev *vdev, void *arg);
172 typedef QDF_STATUS (*wlan_objmgr_vdev_destroy_handler)(
173 				struct wlan_objmgr_vdev *vdev, void *arg);
174 typedef void (*wlan_objmgr_vdev_status_handler)(
175 				struct wlan_objmgr_vdev *vdev, void *arg,
176 						QDF_STATUS status);
177 
178 typedef QDF_STATUS (*wlan_objmgr_peer_create_handler)(
179 				struct wlan_objmgr_peer *peer, void *arg);
180 typedef QDF_STATUS (*wlan_objmgr_peer_destroy_handler)(
181 				struct wlan_objmgr_peer *peer, void *arg);
182 typedef void (*wlan_objmgr_peer_status_handler)(
183 				struct wlan_objmgr_peer *peer, void *arg,
184 						QDF_STATUS status);
185 
186 /**
187  * enum wlan_objmgr_ref_dbgid - ref count debug id
188  * @WLAN_OBJMGR_ID:             Object manager internal operations
189  * @WLAN_MLME_SB_ID:            MLME Southbound operations
190  * @WLAN_MLME_NB_ID:            MLME Northbound operations
191  * @WLAN_MGMT_SB_ID:            MGMT Northbound operations
192  * @WLAN_MGMT_NB_ID:            MGMT Southbound operations
193  * @WLAN_HDD_ID_OBJ_MGR:        HDD Object Manager operations
194  * @WLAN_OSIF_ID:               New component's OS IF ID
195  * @WLAN_LEGACY_MAC_ID:         Legacy MAC operations
196  * @WLAN_LEGACY_WMA_ID:         Legacy WMA operations
197  * @WLAN_SERIALIZATION_ID:      Serialization operations
198  * @WLAN_PMO_ID:                power manager offload (PMO) ID
199  * @WLAN_LEGACY_SME_ID:         Legacy SME operations
200  * @WLAN_SCAN_ID:               scan operations
201  * @WLAN_WIFI_POS_CORE_ID:      wifi positioning (CORE)
202  * @WLAN_DFS_ID:                DFS operations
203  * @WLAN_P2P_ID:                P2P operations
204  * @WLAN_TDLS_SB_ID:            TDLS Southbound operations
205  * @WLAN_TDLS_NB_ID:            TDLS Northbound operations
206  * @WLAN_ATF_ID:                Airtime Fairness operations
207  * @WLAN_CRYPTO_ID:             Crypto service operation
208  * @WLAN_NAN_ID:                nan operations
209  * @WLAN_REGULATORY_SB_ID:      SB regulatory operations
210  * @WLAN_REGULATORY_NB_ID:      NB regulatory operations
211  * @WLAN_POLICY_MGR_ID:         Policy Manager operations
212  * @WLAN_SON_ID:                SON
213  * @WLAN_SA_API_ID:             SA PAI
214  * @WLAN_SPECTRAL_ID:           Spectral operations
215  * @WLAN_SPLITMAC_ID:           SplitMac
216  * @WLAN_DEBUG_ID:              Debug operations
217  * @WLAN_DIRECT_BUF_RX_ID:      Direct Buffer Receive operations
218  * @WLAN_DISA_ID:               DISA (encryption test) operations
219  * @WLAN_FTM_ID:                FTM module
220  * @WLAN_FD_ID:                 FILS Discovery
221  * @WLAN_OCB_NB_ID:             OCB Northbound operations
222  * @WLAN_OCB_SB_ID:             OCB Southbound operations
223  * @WLAN_INIT_DEINIT_ID:        Init deinit module
224  * @WLAN_IPA_ID:                IPA operations
225  * @WLAN_CP_STATS_ID:           Control Plane Statistics Module
226  * @WLAN_GREEN_AP_ID:           Green AP operations
227  * @WLAN_WIFI_POS_OSIF_ID:      wifi positioning (OSID)
228  * @WLAN_WIFI_POS_TGT_IF_ID:    wifi positioning (Target IF)
229  * @WLAN_MLME_OBJ_DEL_ID:       Object delete req/resp tracking with FW
230  * @WLAN_ACTION_OUI_ID:         action oui operations
231  * @WLAN_LEGACY_SAP_ID:         legacy sap fsm
232  * @WLAN_TGT_IF_DP_PEER_REF_ID: cp peer reference in dp (Target IF)
233  * @WLAN_MLME_SER_IF_ID:        mlme serialization interface layer
234  * @WLAN_SCHEDULER_ID:          mlme scheduler
235  * @WLAN_CFR_ID:                CFG Capture method
236  * @WLAN_VDEV_TARGET_IF_ID:     Target interface layer
237  * @WLAN_RX_PKT_TAG_ID:         RX protocol tag operations
238  * @WLAN_INTEROP_ISSUES_AP_ID:  interop issues ap operation
239  * @WLAN_WDS_ID:                WDS operations
240  * @WLAN_PROXY_ARP_ID:          AP proxy ARP
241  * @WLAN_WNM_ID:                wireless network management operations
242  * @WLAN_RRM_ID:                Radio resource management operations
243  * @WLAN_TR69_ID:               TR69 operations
244  * @WLAN_MGMT_RX_ID:            Legacy offload management frame input handler
245  * @WLAN_MGMT_TX_ID:            Legacy offload management frame output handler
246  * @WLAN_NSS_IF_ID:             NSS offload interface operations
247  * @WLAN_MBO_ID:                MBO operations
248  * @WLAN_RTT_ID:                RTT operations
249  * @WLAN_ALD_ID:                Ath Link Diagnostic operations
250  * @WLAN_ME_ID:                 Multicast enhancement operations
251  * @WLAN_MGMT_HANDLER_ID:       Management frame handler
252  * @WLAN_MLME_HANDLER_ID:       MLME handler
253  * @WLAN_DBDC_ID:               Dual Band Dual Concurrent mode operations
254  * @WLAN_MLME_OBJMGR_ID:        MLME object manager operations VAP, Node
255  * @WLAN_OFFCHAN_TX_ID:         Offchannel Tx operations
256  * @WLAN_MISC_ID:               power manager, PAPI, rate set, etc.
257  * @WLAN_FWOL_NB_ID:            fw offload northbound operations
258  * @WLAN_FWOL_SB_ID:            fw offload southbound operations
259  * @WLAN_REF_ID_MAX:            Max id used to generate ref count tracking array
260  */
261  /* New value added to the enum must also be reflected in function
262   * string_from_dbgid()
263   */
264 typedef enum {
265 	WLAN_OBJMGR_ID        = 0,
266 	WLAN_MLME_SB_ID       = 1,
267 	WLAN_MLME_NB_ID       = 2,
268 	WLAN_MGMT_SB_ID       = 3,
269 	WLAN_MGMT_NB_ID       = 4,
270 	WLAN_HDD_ID_OBJ_MGR   = 5,
271 	WLAN_OSIF_ID          = 6,
272 	WLAN_LEGACY_MAC_ID    = 7,
273 	WLAN_LEGACY_WMA_ID    = 8,
274 	WLAN_SERIALIZATION_ID = 9,
275 	WLAN_PMO_ID           = 10,
276 	WLAN_LEGACY_SME_ID    = 11,
277 	WLAN_SCAN_ID          = 12,
278 	WLAN_WIFI_POS_CORE_ID = 13,
279 	WLAN_DFS_ID           = 14,
280 	WLAN_P2P_ID           = 15,
281 	WLAN_TDLS_SB_ID       = 16,
282 	WLAN_TDLS_NB_ID       = 17,
283 	WLAN_ATF_ID           = 18,
284 	WLAN_CRYPTO_ID        = 19,
285 	WLAN_NAN_ID           = 20,
286 	WLAN_REGULATORY_SB_ID = 21,
287 	WLAN_REGULATORY_NB_ID = 22,
288 	WLAN_OFFCHAN_TXRX_ID  = 23,
289 	WLAN_POLICY_MGR_ID    = 24,
290 	WLAN_SON_ID           = 25,
291 	WLAN_SA_API_ID        = 26,
292 	WLAN_SPECTRAL_ID      = 27,
293 	WLAN_SPLITMAC_ID      = 28,
294 	WLAN_DEBUG_ID         = 29,
295 	WLAN_DIRECT_BUF_RX_ID = 30,
296 	WLAN_DISA_ID          = 31,
297 	WLAN_FTM_ID           = 32,
298 	WLAN_FD_ID            = 33,
299 	WLAN_OCB_NB_ID        = 34,
300 	WLAN_OCB_SB_ID        = 35,
301 	WLAN_INIT_DEINIT_ID   = 36,
302 	WLAN_IPA_ID           = 37,
303 	WLAN_CP_STATS_ID      = 38,
304 	WLAN_GREEN_AP_ID      = 39,
305 	WLAN_WIFI_POS_OSIF_ID = 40,
306 	WLAN_WIFI_POS_TGT_IF_ID = 41,
307 	WLAN_MLME_OBJ_DEL_ID    = 42,
308 	WLAN_ACTION_OUI_ID      = 43,
309 	WLAN_LEGACY_SAP_ID      = 44,
310 	WLAN_TGT_IF_DP_PEER_REF_ID = 45,
311 	WLAN_MLME_SER_IF_ID        = 46,
312 	WLAN_SCHEDULER_ID          = 47,
313 	WLAN_CFR_ID                = 48,
314 	WLAN_VDEV_TARGET_IF_ID     = 49,
315 	WLAN_RX_PKT_TAG_ID         = 50,
316 	WLAN_INTEROP_ISSUES_AP_ID           = 51,
317 	WLAN_WDS_ID           = 52,
318 	WLAN_PROXY_ARP_ID     = 53,
319 	WLAN_WNM_ID           = 54,
320 	WLAN_RRM_ID           = 55,
321 	WLAN_TR69_ID          = 56,
322 	WLAN_MGMT_RX_ID       = 57,
323 	WLAN_MGMT_TX_ID       = 58,
324 	WLAN_NSS_IF_ID        = 59,
325 	WLAN_MBO_ID           = 60,
326 	WLAN_RTT_ID           = 61,
327 	WLAN_ALD_ID           = 62,
328 	WLAN_ME_ID            = 63,
329 	WLAN_MGMT_HANDLER_ID  = 64,
330 	WLAN_MLME_HANDLER_ID  = 65,
331 	WLAN_DBDC_ID          = 66,
332 	WLAN_MLME_OBJMGR_ID   = 67,
333 	WLAN_OFFCHAN_TX_ID    = 68,
334 	WLAN_MISC_ID          = 69,
335 	WLAN_FWOL_NB_ID       = 70,
336 	WLAN_FWOL_SB_ID       = 71,
337 	WLAN_REF_ID_MAX,
338 } wlan_objmgr_ref_dbgid;
339 
340 /**
341  * string_from_dbgid() - Convert Refcnt dbgid to respective string
342  * @id - Reference count debug id
343  *
344  * Debug support function to convert refcnt dbgid to string.
345  * Please note to add new string in the array at index equal to
346  * its enum value in wlan_objmgr_ref_dbgid.
347  */
348 static inline char *string_from_dbgid(wlan_objmgr_ref_dbgid id)
349 {
350 	static const char *strings[] = { "WLAN_OBJMGR_ID",
351 					"WLAN_MLME_SB_ID",
352 					"WLAN_MLME_NB_ID",
353 					"WLAN_MGMT_SB_ID",
354 					"WLAN_MGMT_NB_ID",
355 					"WLAN_HDD_ID_OBJ_MGR",
356 					"WLAN_OSIF_ID",
357 					"WLAN_LEGACY_MAC_ID",
358 					"WLAN_LEGACY_WMA_ID",
359 					"WLAN_SERIALIZATION_ID",
360 					"WLAN_PMO_ID",
361 					"WLAN_LEGACY_SME_ID",
362 					"WLAN_SCAN_ID",
363 					"WLAN_WIFI_POS_CORE_ID",
364 					"WLAN_DFS_ID",
365 					"WLAN_P2P_ID",
366 					"WLAN_TDLS_SB_ID",
367 					"WLAN_TDLS_NB_ID",
368 					"WLAN_ATF_ID",
369 					"WLAN_CRYPTO_ID",
370 					"WLAN_NAN_ID",
371 					"WLAN_REGULATORY_SB_ID",
372 					"WLAN_REGULATORY_NB_ID",
373 					"WLAN_OFFCHAN_TXRX_ID",
374 					"WLAN_POLICY_MGR_ID",
375 					"WLAN_SON_ID",
376 					"WLAN_SA_API_ID",
377 					"WLAN_SPECTRAL_ID",
378 					"WLAN_SPLITMAC_ID",
379 					"WLAN_DEBUG_ID",
380 					"WLAN_DIRECT_BUF_RX_ID",
381 					"WLAN_DISA_ID",
382 					"WLAN_FTM_ID",
383 					"WLAN_FD_ID",
384 					"WLAN_OCB_NB_ID",
385 					"WLAN_OCB_SB_ID",
386 					"WLAN_INIT_DEINIT_ID",
387 					"WLAN_IPA_ID",
388 					"WLAN_CP_STATS_ID",
389 					"WLAN_GREEN_AP_ID",
390 					"WLAN_WIFI_POS_OSIF_ID",
391 					"WLAN_WIFI_POS_TGT_IF_ID",
392 					"WLAN_MLME_OBJ_DEL_ID",
393 					"WLAN_ACTION_OUI_ID",
394 					"WLAN_LEGACY_SAP_ID",
395 					"WLAN_TGT_IF_DP_PEER_REF_ID",
396 					"WLAN_MLME_SER_IF_ID",
397 					"WLAN_SCHEDULER_ID",
398 					"WLAN_CFR_ID",
399 					"WLAN_VDEV_TARGET_IF_ID",
400 					"WLAN_RX_PKT_TAG_ID",
401 					"WLAN_INTEROP_ISSUES_AP_ID",
402 					"WLAN_WDS_ID",
403 					"WLAN_PROXY_ARP_ID",
404 					"WLAN_WNM_ID",
405 					"WLAN_RRM_ID",
406 					"WLAN_TR69_ID",
407 					"WLAN_MGMT_RX_ID",
408 					"WLAN_MGMT_TX_ID",
409 					"WLAN_NSS_IF_ID",
410 					"WLAN_MBO_ID",
411 					"WLAN_RTT_ID",
412 					"WLAN_ALD_ID",
413 					"WLAN_ME_ID",
414 					"WLAN_MGMT_HANDLER_ID",
415 					"WLAN_MLME_HANDLER_ID",
416 					"WLAN_DBDC_ID",
417 					"WLAN_MLME_OBJMGR_ID",
418 					"WLAN_OFFCHAN_TX_ID",
419 					"WLAN_MISC_ID",
420 					"WLAN_FWOL_NB_ID",
421 					"WLAN_FWOL_SB_ID",
422 					"WLAN_REF_ID_MAX"};
423 
424 	return (char *)strings[id];
425 }
426 
427 #ifdef WLAN_OBJMGR_DEBUG
428 #define WLAN_OBJMGR_BUG(val) QDF_BUG(val)
429 #else
430 #define WLAN_OBJMGR_BUG(val)
431 #endif
432 #define WLAN_OBJMGR_RATELIMIT_THRESH 2
433 #endif /* _WLAN_OBJMGR_CMN_H_*/
434