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_REF_ID_MAX: Max id used to generate ref count tracking array 236 */ 237 /* New value added to the enum must also be reflected in function 238 * string_from_dbgid() 239 */ 240 typedef enum { 241 WLAN_OBJMGR_ID = 0, 242 WLAN_MLME_SB_ID = 1, 243 WLAN_MLME_NB_ID = 2, 244 WLAN_MGMT_SB_ID = 3, 245 WLAN_MGMT_NB_ID = 4, 246 WLAN_HDD_ID_OBJ_MGR = 5, 247 WLAN_OSIF_ID = 6, 248 WLAN_LEGACY_MAC_ID = 7, 249 WLAN_LEGACY_WMA_ID = 8, 250 WLAN_SERIALIZATION_ID = 9, 251 WLAN_PMO_ID = 10, 252 WLAN_LEGACY_SME_ID = 11, 253 WLAN_SCAN_ID = 12, 254 WLAN_WIFI_POS_CORE_ID = 13, 255 WLAN_DFS_ID = 14, 256 WLAN_P2P_ID = 15, 257 WLAN_TDLS_SB_ID = 16, 258 WLAN_TDLS_NB_ID = 17, 259 WLAN_ATF_ID = 18, 260 WLAN_CRYPTO_ID = 19, 261 WLAN_NAN_ID = 20, 262 WLAN_REGULATORY_SB_ID = 21, 263 WLAN_REGULATORY_NB_ID = 22, 264 WLAN_OFFCHAN_TXRX_ID = 23, 265 WLAN_POLICY_MGR_ID = 24, 266 WLAN_SON_ID = 25, 267 WLAN_SA_API_ID = 26, 268 WLAN_SPECTRAL_ID = 27, 269 WLAN_SPLITMAC_ID = 28, 270 WLAN_DEBUG_ID = 29, 271 WLAN_DIRECT_BUF_RX_ID = 30, 272 WLAN_DISA_ID = 31, 273 WLAN_FTM_ID = 32, 274 WLAN_FD_ID = 33, 275 WLAN_OCB_NB_ID = 34, 276 WLAN_OCB_SB_ID = 35, 277 WLAN_INIT_DEINIT_ID = 36, 278 WLAN_IPA_ID = 37, 279 WLAN_CP_STATS_ID = 38, 280 WLAN_GREEN_AP_ID = 39, 281 WLAN_WIFI_POS_OSIF_ID = 40, 282 WLAN_WIFI_POS_TGT_IF_ID = 41, 283 WLAN_MLME_OBJ_DEL_ID = 42, 284 WLAN_ACTION_OUI_ID = 43, 285 WLAN_LEGACY_SAP_ID = 44, 286 WLAN_TGT_IF_DP_PEER_REF_ID = 45, 287 WLAN_MLME_SER_IF_ID = 46, 288 WLAN_SCHEDULER_ID = 47, 289 WLAN_REF_ID_MAX, 290 } wlan_objmgr_ref_dbgid; 291 292 /** 293 * string_from_dbgid() - Convert Refcnt dbgid to respective string 294 * @id - Reference count debug id 295 * 296 * Debug support function to convert refcnt dbgid to string. 297 * Please note to add new string in the array at index equal to 298 * its enum value in wlan_objmgr_ref_dbgid. 299 */ 300 static inline char *string_from_dbgid(wlan_objmgr_ref_dbgid id) 301 { 302 static const char *strings[] = { "WLAN_OBJMGR_ID", 303 "WLAN_MLME_SB_ID", 304 "WLAN_MLME_NB_ID", 305 "WLAN_MGMT_SB_ID", 306 "WLAN_MGMT_NB_ID", 307 "WLAN_HDD_ID_OBJ_MGR", 308 "WLAN_OSIF_ID", 309 "WLAN_LEGACY_MAC_ID", 310 "WLAN_LEGACY_WMA_ID", 311 "WLAN_SERIALIZATION_ID", 312 "WLAN_PMO_ID", 313 "WLAN_LEGACY_SME_ID", 314 "WLAN_SCAN_ID", 315 "WLAN_WIFI_POS_CORE_ID", 316 "WLAN_DFS_ID", 317 "WLAN_P2P_ID", 318 "WLAN_TDLS_SB_ID", 319 "WLAN_TDLS_NB_ID", 320 "WLAN_ATF_ID", 321 "WLAN_CRYPTO_ID", 322 "WLAN_NAN_ID", 323 "WLAN_REGULATORY_SB_ID", 324 "WLAN_REGULATORY_NB_ID", 325 "WLAN_OFFCHAN_TXRX_ID", 326 "WLAN_POLICY_MGR_ID", 327 "WLAN_SON_ID", 328 "WLAN_SA_API_ID", 329 "WLAN_SPECTRAL_ID", 330 "WLAN_SPLITMAC_ID", 331 "WLAN_DEBUG_ID", 332 "WLAN_DIRECT_BUF_RX_ID", 333 "WLAN_DISA_ID", 334 "WLAN_FTM_ID", 335 "WLAN_FD_ID", 336 "WLAN_OCB_NB_ID", 337 "WLAN_OCB_SB_ID", 338 "WLAN_INIT_DEINIT_ID", 339 "WLAN_IPA_ID", 340 "WLAN_CP_STATS_ID", 341 "WLAN_GREEN_AP_ID", 342 "WLAN_WIFI_POS_OSIF_ID", 343 "WLAN_WIFI_POS_TGT_IF_ID", 344 "WLAN_MLME_OBJ_DEL_ID", 345 "WLAN_ACTION_OUI_ID", 346 "WLAN_LEGACY_SAP_ID", 347 "WLAN_TGT_IF_DP_PEER_REF_ID", 348 "WLAN_MLME_SER_IF_ID", 349 "WLAN_SCHEDULER_ID", 350 "WLAN_REF_ID_MAX"}; 351 352 return (char *)strings[id]; 353 } 354 355 #ifdef WLAN_OBJMGR_DEBUG 356 #define WLAN_OBJMGR_BUG(val) QDF_BUG(val) 357 #else 358 #define WLAN_OBJMGR_BUG(val) 359 #endif 360 #define WLAN_OBJMGR_RATELIMIT_THRESH 2 361 #endif /* _WLAN_OBJMGR_CMN_H_*/ 362