1 /* 2 * Copyright (c) 2016-2018 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 defintions 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 44 #define obj_mgr_logfl(level, format, args...) \ 45 obj_mgr_log(level, FL(format), ## args) 46 47 #define obj_mgr_alert(format, args...) \ 48 obj_mgr_logfl(QDF_TRACE_LEVEL_FATAL, format, ## args) 49 50 #define obj_mgr_err(format, args...) \ 51 obj_mgr_logfl(QDF_TRACE_LEVEL_ERROR, format, ## args) 52 53 #define obj_mgr_warn(format, args...) \ 54 obj_mgr_logfl(QDF_TRACE_LEVEL_WARN, format, ## args) 55 56 #define obj_mgr_info(format, args...) \ 57 obj_mgr_logfl(QDF_TRACE_LEVEL_INFO, format, ## args) 58 59 #define obj_mgr_debug(format, args...) \ 60 obj_mgr_logfl(QDF_TRACE_LEVEL_DEBUG, format, ## args) 61 62 63 /** 64 * enum WLAN_OBJ_STATE - State of Object 65 * @WLAN_OBJ_STATE_ALLOCATED: Common object is allocated, but not 66 * fully initialized 67 * @WLAN_OBJ_STATE_CREATED: All component objects are created 68 * @WLAN_OBJ_STATE_DELETED: All component objects are destroyed 69 * @WLAN_OBJ_STATE_PARTIALLY_CREATED: Few/All component objects creation is 70 * in progress 71 * @WLAN_OBJ_STATE_PARTIALLY_DELETED: Component objects deletion is triggered, 72 * they are yet to be destroyed 73 * @WLAN_OBJ_STATE_COMP_DEL_PROGRESS: If a component is disabled run time, 74 * and this state is used to represent the 75 * deletion in progress after that 76 * component object is destroyed, object 77 * state would be moved to CREATED state 78 * @WLAN_OBJ_STATE_LOGICALLY_DELETED: Object deletion has been initiated, 79 * object destroy invoked once references 80 * are released 81 * @WLAN_OBJ_STATE_CREATION_FAILED: any component object is failed to be 82 * created 83 * @WLAN_OBJ_STATE_DELETION_FAILED: any component object is failed to be 84 * destroyed 85 */ 86 typedef enum { 87 WLAN_OBJ_STATE_ALLOCATED = 0, 88 WLAN_OBJ_STATE_CREATED = 1, 89 WLAN_OBJ_STATE_DELETED = 2, 90 WLAN_OBJ_STATE_PARTIALLY_CREATED = 3, 91 WLAN_OBJ_STATE_PARTIALLY_DELETED = 4, 92 WLAN_OBJ_STATE_COMP_DEL_PROGRESS = 5, 93 WLAN_OBJ_STATE_LOGICALLY_DELETED = 6, 94 WLAN_OBJ_STATE_CREATION_FAILED = 7, 95 WLAN_OBJ_STATE_DELETION_FAILED = 8, 96 } WLAN_OBJ_STATE; 97 98 /* Object type is assigned with value */ 99 enum wlan_objmgr_obj_type { 100 WLAN_PSOC_OP = 0, 101 WLAN_PDEV_OP = 1, 102 WLAN_VDEV_OP = 2, 103 WLAN_PEER_OP = 3, 104 }; 105 106 /** 107 * struct wlan_peer_list { 108 * @peer_hash[]: peer sub lists 109 * @peer_list_lock: List lock, this has to be acquired on 110 * accessing/updating the list 111 * 112 * Peer list, it maintains sublists based on the MAC address as hash 113 * Note: For DA WDS similar peer list has to be maintained 114 * This peer list will not have WDS nodes 115 */ 116 struct wlan_peer_list { 117 qdf_list_t peer_hash[WLAN_PEER_HASHSIZE]; 118 qdf_spinlock_t peer_list_lock; 119 }; 120 121 struct wlan_objmgr_psoc; 122 struct wlan_objmgr_pdev; 123 struct wlan_objmgr_vdev; 124 struct wlan_objmgr_peer; 125 126 /* Create handler would return the following status 127 QDF_STATUS_SUCCESS-- 128 For synchronous handler:- this is returned on successful 129 component object creation 130 131 QDF_STATUS_COMP_DISABLED-- 132 For synchronous handler:- this is returned on if component 133 doesn't want to allocate 134 135 QDF_STATUS_COMP_ASYNC-- 136 For asynchronous handler:- this is returned on if component 137 needs a context break 138 139 QDF_STATUS_E_NOMEM-- 140 For synchronous handler:- this is returned on if component 141 can't allocate 142 QDF_STATUS_E_FAILURE-- 143 For synchronous handler:- If it is failed, 144 For asynchronous handler:- If it is failed to post message 145 (means, not required)/feature is not supported 146 */ 147 typedef QDF_STATUS (*wlan_objmgr_psoc_create_handler)( 148 struct wlan_objmgr_psoc *psoc, void *arg); 149 typedef QDF_STATUS (*wlan_objmgr_psoc_destroy_handler)( 150 struct wlan_objmgr_psoc *psoc, void *arg); 151 typedef void (*wlan_objmgr_psoc_status_handler)(struct wlan_objmgr_psoc *psoc, 152 void *arg, QDF_STATUS status); 153 154 typedef QDF_STATUS (*wlan_objmgr_pdev_create_handler)( 155 struct wlan_objmgr_pdev *pdev, void *arg); 156 typedef QDF_STATUS (*wlan_objmgr_pdev_destroy_handler)( 157 struct wlan_objmgr_pdev *pdev, void *arg); 158 typedef void (*wlan_objmgr_pdev_status_handler)( 159 struct wlan_objmgr_pdev *pdev, void *arg, 160 QDF_STATUS status); 161 162 typedef QDF_STATUS (*wlan_objmgr_vdev_create_handler)( 163 struct wlan_objmgr_vdev *vdev, void *arg); 164 typedef QDF_STATUS (*wlan_objmgr_vdev_destroy_handler)( 165 struct wlan_objmgr_vdev *vdev, void *arg); 166 typedef void (*wlan_objmgr_vdev_status_handler)( 167 struct wlan_objmgr_vdev *vdev, void *arg, 168 QDF_STATUS status); 169 170 typedef QDF_STATUS (*wlan_objmgr_peer_create_handler)( 171 struct wlan_objmgr_peer *peer, void *arg); 172 typedef QDF_STATUS (*wlan_objmgr_peer_destroy_handler)( 173 struct wlan_objmgr_peer *peer, void *arg); 174 typedef void (*wlan_objmgr_peer_status_handler)( 175 struct wlan_objmgr_peer *peer, void *arg, 176 QDF_STATUS status); 177 178 /** 179 * enum wlan_objmgr_ref_dbgid - ref count debug id 180 * @WLAN_OBJMGR_ID: Object manager internal operations 181 * @WLAN_MLME_SB_ID: MLME Southbound operations 182 * @WLAN_MLME_NB_ID: MLME Northbound operations 183 * @WLAN_MGMT_SB_ID: MGMT Northbound operations 184 * @WLAN_MGMT_NB_ID: MGMT Southbound operations 185 * @WLAN_HDD_ID_OBJ_MGR: HDD Object Manager operations 186 * @WLAN_OSIF_ID: New component's OS IF ID 187 * @WLAN_LEGACY_MAC_ID: Legacy MAC operations 188 * @WLAN_LEGACY_WMA_ID: Legacy WMA operations 189 * @WLAN_SERIALIZATION_ID: Serialization operations 190 * @WLAN_PMO_ID: power manager offload (PMO) ID 191 * @WLAN_LEGACY_SME_ID: Legacy SME operations 192 * @WLAN_SCAN_ID: scan operations 193 * @WLAN_WIFI_POS_ID: wifi positioning 194 * @WLAN_DFS_ID: DFS operations 195 * @WLAN_P2P_ID: P2P operations 196 * @WLAN_TDLS_SB_ID: TDLS Southbound operations 197 * @WLAN_TDLS_NB_ID: TDLS Northbound operations 198 * @WLAN_ATF_ID: Airtime Fairness operations 199 * @WLAN_CRYPTO_ID: Crypto service operation 200 * @WLAN_NAN_ID: nan operations 201 * @WLAN_REGULATORY_SB_ID: SB regulatory operations 202 * @WLAN_REGULATORY_NB_ID: NB regulatory operations 203 * @WLAN_POLICY_MGR_ID: Policy Manager operations 204 * @WLAN_SON_ID: SON 205 * @WLAN_SA_API_ID: SA PAI 206 * @WLAN_SPECTRAL_ID: Spectral operations 207 * @WLAN_SPLITMAC_ID: SplitMac 208 * @WLAN_DEBUG_ID: Debug operations 209 * @WLAN_DIRECT_BUF_RX_ID: Direct Buffer Receive operations 210 * @WLAN_DISA_ID: DISA (encryption test) operations 211 * @WLAN_FTM_ID: FTM module 212 * @WLAN_FD_ID: FILS Discovery 213 * @WLAN_OCB_NB_ID: OCB Northbound operations 214 * @WLAN_OCB_SB_ID: OCB Southbound operations 215 * @WLAN_INIT_DEINIT_ID: Init deinit module 216 * @WLAN_REF_ID_MAX: Max id used to generate ref count tracking array 217 */ 218 /* New value added to the enum must also be reflected in function 219 * string_from_dbgid() 220 */ 221 typedef enum { 222 WLAN_OBJMGR_ID = 0, 223 WLAN_MLME_SB_ID = 1, 224 WLAN_MLME_NB_ID = 2, 225 WLAN_MGMT_SB_ID = 3, 226 WLAN_MGMT_NB_ID = 4, 227 WLAN_HDD_ID_OBJ_MGR = 5, 228 WLAN_OSIF_ID = 6, 229 WLAN_LEGACY_MAC_ID = 7, 230 WLAN_LEGACY_WMA_ID = 8, 231 WLAN_SERIALIZATION_ID = 9, 232 WLAN_PMO_ID = 10, 233 WLAN_LEGACY_SME_ID = 11, 234 WLAN_SCAN_ID = 12, 235 WLAN_WIFI_POS_ID = 13, 236 WLAN_DFS_ID = 14, 237 WLAN_P2P_ID = 15, 238 WLAN_TDLS_SB_ID = 16, 239 WLAN_TDLS_NB_ID = 17, 240 WLAN_ATF_ID = 18, 241 WLAN_CRYPTO_ID = 19, 242 WLAN_NAN_ID = 20, 243 WLAN_REGULATORY_SB_ID = 21, 244 WLAN_REGULATORY_NB_ID = 22, 245 WLAN_OFFCHAN_TXRX_ID = 23, 246 WLAN_POLICY_MGR_ID = 24, 247 WLAN_SON_ID = 25, 248 WLAN_SA_API_ID = 26, 249 WLAN_SPECTRAL_ID = 27, 250 WLAN_SPLITMAC_ID = 28, 251 WLAN_DEBUG_ID = 29, 252 WLAN_DIRECT_BUF_RX_ID = 30, 253 WLAN_DISA_ID = 31, 254 WLAN_FTM_ID = 32, 255 WLAN_FD_ID = 33, 256 WLAN_OCB_NB_ID = 34, 257 WLAN_OCB_SB_ID = 35, 258 WLAN_INIT_DEINIT_ID = 36, 259 WLAN_REF_ID_MAX, 260 } wlan_objmgr_ref_dbgid; 261 262 /** 263 * string_from_dbgid() - Convert Refcnt dbgid to respective string 264 * @id - Reference count debug id 265 * 266 * Debug support function to convert refcnt dbgid to string. 267 * Please note to add new string in the array at index equal to 268 * its enum value in wlan_objmgr_ref_dbgid. 269 */ 270 static inline char *string_from_dbgid(wlan_objmgr_ref_dbgid id) 271 { 272 static const char *strings[] = { "WLAN_OBJMGR_ID", 273 "WLAN_MLME_SB_ID", 274 "WLAN_MLME_NB_ID", 275 "WLAN_MGMT_SB_ID", 276 "WLAN_MGMT_NB_ID", 277 "WLAN_HDD_ID_OBJ_MGR", 278 "WLAN_OSIF_ID", 279 "WLAN_LEGACY_MAC_ID", 280 "WLAN_LEGACY_WMA_ID", 281 "WLAN_SERIALIZATION_ID", 282 "WLAN_PMO_ID", 283 "WLAN_LEGACY_SME_ID", 284 "WLAN_SCAN_ID", 285 "WLAN_WIFI_POS_ID", 286 "WLAN_DFS_ID", 287 "WLAN_P2P_ID", 288 "WLAN_TDLS_SB_ID", 289 "WLAN_TDLS_NB_ID", 290 "WLAN_ATF_ID", 291 "WLAN_CRYPTO_ID", 292 "WLAN_NAN_ID", 293 "WLAN_REGULATORY_SB_ID", 294 "WLAN_REGULATORY_NB_ID", 295 "WLAN_OFFCHAN_TXRX_ID", 296 "WLAN_POLICY_MGR_ID", 297 "WLAN_SON_ID", 298 "WLAN_SA_API_ID", 299 "WLAN_SPECTRAL_ID", 300 "WLAN_SPLITMAC_ID", 301 "WLAN_DEBUG_ID", 302 "WLAN_DIRECT_BUF_RX_ID", 303 "WLAN_DISA_ID", 304 "WLAN_FTM_ID", 305 "WLAN_FD_ID", 306 "WLAN_OCB_NB_ID", 307 "WLAN_OCB_SB_ID", 308 "WLAN_INIT_DEINIT_ID", 309 "WLAN_REF_ID_MAX" }; 310 311 return (char *)strings[id]; 312 } 313 314 #ifdef WLAN_OBJMGR_DEBUG 315 #define WLAN_OBJMGR_BUG(val) QDF_BUG(val) 316 #else 317 #define WLAN_OBJMGR_BUG(val) 318 #endif 319 #define WLAN_OBJMGR_RATELIMIT_THRESH 2 320 #endif /* _WLAN_OBJMGR_CMN_H_*/ 321