1 /* 2 * Copyright (c) 2016-2021 The Linux Foundation. All rights reserved. 3 * Copyright (c) 2021 Qualcomm Innovation Center, Inc. All rights reserved. 4 * 5 * Permission to use, copy, modify, and/or distribute this software for any 6 * purpose with or without fee is hereby granted, provided that the above 7 * copyright notice and this permission notice appear in all copies. 8 * 9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 10 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 11 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 12 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 13 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 14 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 15 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 16 */ 17 18 /** 19 * DOC: Define the pdev data structure of UMAC 20 * Public APIs to perform operations on Global objects 21 */ 22 23 #ifndef _WLAN_OBJMGR_PDEV_OBJ_H_ 24 #define _WLAN_OBJMGR_PDEV_OBJ_H_ 25 26 #include <wlan_objmgr_cmn.h> 27 #include "wlan_objmgr_psoc_obj.h" 28 #include <target_if_pub.h> 29 #include <qdf_defer.h> 30 31 /* STATUS: scanning */ 32 #define WLAN_PDEV_F_SCAN 0x00000001 33 /* STATUS: use short slot time*/ 34 #define WLAN_PDEV_F_SHSLOT 0x00000002 35 /* STATUS: channel switch event pending after DFS RADAR */ 36 #define WLAN_PDEV_F_DFS_CHANSWITCH_PENDING 0x00000004 37 /* TX Power: fixed rate */ 38 #define WLAN_PDEV_F_TXPOW_FIXED 0x00000008 39 /* STATUS: use short preamble */ 40 #define WLAN_PDEV_F_SHPREAMBLE 0x00000010 41 /* CONF: do alignment pad */ 42 #define WLAN_PDEV_F_DATAPAD 0x00000020 43 /* STATUS: protection enabled */ 44 #define WLAN_PDEV_F_USEPROT 0x00000040 45 /* STATUS: use barker preamble*/ 46 #define WLAN_PDEV_F_USEBARKER 0x00000080 47 /* CONF: DISABLE 2040 coexistence */ 48 #define WLAN_PDEV_F_COEXT_DISABLE 0x00000100 49 /* STATE: scan pending */ 50 #define WLAN_PDEV_F_SCAN_PENDING 0x00000200 51 /* CONF: send regclassids in country ie */ 52 #define WLAN_PDEV_F_REGCLASS 0x00000400 53 /* CONF: block the use of DFS channels */ 54 #define WLAN_PDEV_F_BLKDFSCHAN 0x00000800 55 /* STATUS: 11D in used */ 56 #define WLAN_PDEV_F_DOT11D 0x00001000 57 /* STATUS: 11D channel-switch detected */ 58 #define WLAN_PDEV_F_RADAR 0x00002000 59 /* CONF: A-MPDU supported */ 60 #define WLAN_PDEV_F_AMPDU 0x00004000 61 /* CONF: A-MSDU supported */ 62 #define WLAN_PDEV_F_AMSDU 0x00008000 63 /* CONF: HT traffic protected */ 64 #define WLAN_PDEV_F_HTPROT 0x00010000 65 /* CONF: Reset once */ 66 #define WLAN_PDEV_F_RESET 0x00020000 67 /* CONF: ignore 11d beacon */ 68 #define WLAN_PDEV_F_IGNORE_11D_BEACON 0x00040000 69 /* HT CAP IE present */ 70 #define WLAN_PDEV_F_HTVIE 0x00080000 71 /* radio in middle of CSA */ 72 #define WLAN_PDEV_F_CSA_WAIT 0x00100000 73 /* wnm support flag */ 74 #define WLAN_PDEV_F_WNM 0x00200000 75 #define WLAN_PDEV_F_2G_CSA 0x00400000 76 /* enhanced independent repeater */ 77 #define WLAN_PDEV_F_ENH_REP_IND 0x00800000 78 /* Disable Tx AMSDU for station vap */ 79 #define WLAN_PDEV_F_STA_AMPDU_DIS 0x01000000 80 /* do not send probe request in passive channel */ 81 #define WLAN_PDEV_F_STRICT_PSCAN_EN 0x02000000 82 /* dupie (ANA,pre ANA ) */ 83 /*#define WLAN_PDEV_F_DUPIE 0x00200000*/ 84 /* Chan concurrency enabled */ 85 #define WLAN_PDEV_F_CHAN_CONCURRENCY 0x08000000 86 /* Multivdev restart enabled */ 87 #define WLAN_PDEV_F_MULTIVDEV_RESTART 0x10000000 88 /* MBSS IE enable */ 89 #define WLAN_PDEV_F_MBSS_IE_ENABLE 0x20000000 90 /* VDEV Peer delete all */ 91 #define WLAN_PDEV_F_DELETE_ALL_PEER 0x40000000 92 /* PDEV BEacon Protection */ 93 #define WLAN_PDEV_F_BEACON_PROTECTION 0x80000000 94 95 /* PDEV ext flags */ 96 /* CFR support enabled */ 97 #define WLAN_PDEV_FEXT_CFR_EN 0x00000001 98 /* EMA AP support enable */ 99 #define WLAN_PDEV_FEXT_EMA_AP_ENABLE 0x00000002 100 /* scan radio support */ 101 #define WLAN_PDEV_FEXT_SCAN_RADIO 0x00000004 102 /* DFS disable, valid only for scan radio supported pdevs */ 103 #define WLAN_PDEV_FEXT_SCAN_RADIO_DFS_DIS 0x00000008 104 /* normal Spectral scan support disable */ 105 #define WLAN_PDEV_FEXT_NORMAL_SPECTRAL_SCAN_DIS 0x00000010 106 /* agile Spectral scan support disable for 20/40/80 MHz */ 107 #define WLAN_PDEV_FEXT_AGILE_SPECTRAL_SCAN_DIS 0x00000020 108 /* agile Spectral scan support disable for 160 MHz */ 109 #define WLAN_PDEV_FEXT_AGILE_SPECTRAL_SCAN_160_DIS 0x00000040 110 /* agile Spectral scan support disable for 80+80 MHz */ 111 #define WLAN_PDEV_FEXT_AGILE_SPECTRAL_SCAN_80P80_DIS 0x00000080 112 /* agile Spectral scan support disable for 320 MHz */ 113 #define WLAN_PDEV_FEXT_AGILE_SPECTRAL_SCAN_320_DIS 0x00000100 114 /* WiFi Radar support enabled */ 115 #define WLAN_PDEV_FEXT_WIFI_RADAR_ENABLE 0x00000200 116 117 /* PDEV op flags */ 118 /* Enable htrate for wep and tkip */ 119 #define WLAN_PDEV_OP_WEP_TKIP_HTRATE 0x00000001 120 /* non HT AP found flag */ 121 #define WLAN_PDEV_OP_NON_HT_AP 0x00000002 122 /* block the use of DFS channels flag */ 123 #define WLAN_PDEV_OP_BLK_DFS_CHAN 0x00000004 124 /* 11.h flag */ 125 #define WLAN_PDEV_OP_DOTH 0x00000008 126 /* Off-channel support enabled */ 127 #define WLAN_PDEV_OP_OFFCHAN 0x00000010 128 #define WLAN_PDEV_OP_HT20ADHOC 0x00000020 129 #define WLAN_PDEV_OP_HT40ADHOC 0x00000040 130 #define WLAN_PDEV_OP_HTADHOC_AGGR 0x00000080 131 /* disallow CC change when assoc completes */ 132 #define WLAN_PDEV_OP_DISALLOW_AUTO_CC 0x00000100 133 /* Is P2P Enabled? */ 134 #define WLAN_PDEV_OP_P2P 0x00000200 135 /* disallowed */ 136 #define WLAN_PDEV_OP_IGNORE_DYNHALT 0x00000400 137 /* overwrite probe response IE with beacon IE */ 138 #define WLAN_PDEV_OP_OVERRIDE_PROBERESP 0x00000800 139 #define WLAN_PDEV_OP_DROPSTA_QUERY 0x00001000 140 #define WLAN_PDEV_OP_BLK_REPORT_FLOOD 0x00002000 141 /* Offchan scan */ 142 #define WLAN_PDEV_OP_OFFCHAN_SCAN 0x00004000 143 /*Consider OBSS non-erp to change to long slot*/ 144 #define WLAN_PDEV_OP_OBSS_LONGSLOT 0x00008000 145 /* enable/disable min rssi cli block */ 146 #define WLAN_PDEV_OP_MIN_RSSI_ENABLE 0x00010000 147 /* PDEV VDEV restart is in progress */ 148 #define WLAN_PDEV_OP_RESTART_INPROGRESS 0x00020000 149 /* PDEV MBSSID VDEV restart trigger */ 150 #define WLAN_PDEV_OP_MBSSID_RESTART 0x00040000 151 /* RADAR DETECT Defer */ 152 #define WLAN_PDEV_OP_RADAR_DETECT_DEFER 0x00080000 153 154 155 struct osif_pdev_priv; 156 157 /** 158 * struct wlan_objmgr_pdev_nif - pdev object nif structure 159 * @pdev_fw_caps: radio specific FW capabilities 160 * @pdev_feature_caps: radio specific feature capabilities 161 * @pdev_feature_ext_caps: radio specific feature capabilities extended 162 * @pdev_ospriv: OS specific pointer 163 * @macaddr[]: MAC address 164 * @notified_ap_vdev: ap vdev 165 */ 166 struct wlan_objmgr_pdev_nif { 167 uint32_t pdev_fw_caps; 168 uint32_t pdev_feature_caps; 169 uint32_t pdev_feature_ext_caps; 170 struct pdev_osif_priv *pdev_ospriv; 171 uint8_t macaddr[QDF_MAC_ADDR_SIZE]; 172 uint8_t notified_ap_vdev; 173 }; 174 175 /** 176 * struct wlan_objmgr_pdev_mlme - pdev object mlme structure 177 * @pdev_op_flags: PDEV operation flags, can be used to know the 178 * operation status (deletion progress, etc) 179 */ 180 struct wlan_objmgr_pdev_mlme { 181 uint32_t pdev_op_flags; 182 }; 183 184 /** 185 * struct wlan_objmgr_pdev_objmgr - pdev object object manager structure 186 * @wlan_pdev_id: PDEV id 187 * @wlan_vdev_count: VDEVs count 188 * @max_vdev_count: Max no. of VDEVs supported by this PDEV 189 * @print_cnt: Count to throttle Logical delete prints 190 * @wlan_vdev_list: List maintains the VDEVs created on this PDEV 191 * @wlan_peer_count: Peer count 192 * @max_peer_count: Max Peer count 193 * @temp_peer_count: Temporary peer count 194 * @max_monitor_vdev_count: Max monitor vdev count 195 * @wlan_psoc: back pointer to PSOC, its attached to 196 * @ref_cnt: Ref count 197 * @ref_id_dbg: Array to track Ref count 198 */ 199 struct wlan_objmgr_pdev_objmgr { 200 uint8_t wlan_pdev_id; 201 uint8_t wlan_vdev_count; 202 uint8_t max_vdev_count; 203 uint8_t print_cnt; 204 qdf_list_t wlan_vdev_list; 205 uint16_t wlan_peer_count; 206 uint16_t max_peer_count; 207 uint16_t temp_peer_count; 208 uint8_t max_monitor_vdev_count; 209 struct wlan_objmgr_psoc *wlan_psoc; 210 qdf_atomic_t ref_cnt; 211 qdf_atomic_t ref_id_dbg[WLAN_REF_ID_MAX]; 212 }; 213 214 /** 215 * struct wlan_objmgr_pdev - PDEV common object 216 * @current_chan_list: Active/current Channel list of the radio 217 * @pdev_nif: pdev nif structure 218 * @pdev_objmgr: pdev object manager structure 219 * @pdev_mlme: pdev MLME structure 220 * @pdev_comp_priv_obj[]: component's private object array 221 * @obj_status[]: object status of each component object 222 * @obj_state: object state 223 * @tgt_if_handle: Target interface handle 224 * @pdev_lock: lock to protect object 225 * @peer_free_lock: lock to protect peer object free 226 * @peer_free_list: list to hold freed peer 227 * @peer_obj_free_work:delayed work to be queued into workqueue 228 * @active_work_cnt: active work counts 229 */ 230 struct wlan_objmgr_pdev { 231 struct wlan_chan_list *current_chan_list; 232 struct wlan_objmgr_pdev_nif pdev_nif; 233 struct wlan_objmgr_pdev_objmgr pdev_objmgr; 234 struct wlan_objmgr_pdev_mlme pdev_mlme; 235 void *pdev_comp_priv_obj[WLAN_UMAC_MAX_COMPONENTS]; 236 QDF_STATUS obj_status[WLAN_UMAC_MAX_COMPONENTS]; 237 WLAN_OBJ_STATE obj_state; 238 target_pdev_info_t *tgt_if_handle; 239 qdf_spinlock_t pdev_lock; 240 #ifdef FEATURE_DELAYED_PEER_OBJ_DESTROY 241 qdf_spinlock_t peer_free_lock; 242 qdf_list_t peer_free_list; 243 qdf_work_t peer_obj_free_work; 244 uint32_t active_work_cnt; 245 #endif 246 }; 247 248 /** 249 ** APIs to Create/Delete Global object APIs 250 */ 251 /** 252 * wlan_objmgr_pdev_obj_create() - pdev create 253 * @psoc: PSOC object 254 * @scn: os private object 255 * 256 * Creates PDEV object, intializes with default values 257 * Invokes the registered notifiers to create component object 258 * 259 * Return: Handle to struct wlan_objmgr_psoc on successful creation, 260 * NULL on Failure (on Mem alloc failure and Component objects 261 * Failure) 262 */ 263 struct wlan_objmgr_pdev *wlan_objmgr_pdev_obj_create( 264 struct wlan_objmgr_psoc *psoc, struct pdev_osif_priv *osif_priv); 265 266 /** 267 * wlan_objmgr_pdev_obj_delete() - pdev delete 268 * @psoc: PDEV object 269 * 270 * Logically deletes PDEV object, 271 * Once all the references are released, object manager invokes the registered 272 * notifiers to destroy component objects 273 * 274 * Return: SUCCESS/FAILURE 275 */ 276 QDF_STATUS wlan_objmgr_pdev_obj_delete(struct wlan_objmgr_pdev *pdev); 277 278 /** 279 ** APIs to attach/detach component objects 280 */ 281 /** 282 * wlan_objmgr_pdev_component_obj_attach() - pdev comp object attach 283 * @psoc: PDEV object 284 * @id: Component id 285 * @comp_priv_obj: component's private object pointer 286 * @status: Component's private object creation status 287 * 288 * API to be used for attaching component object with PDEV common object 289 * 290 * Return: SUCCESS on successful storing of component's object in common object 291 * On FAILURE (appropriate failure codes are returned) 292 */ 293 QDF_STATUS wlan_objmgr_pdev_component_obj_attach( 294 struct wlan_objmgr_pdev *pdev, 295 enum wlan_umac_comp_id id, 296 void *comp_priv_obj, 297 QDF_STATUS status); 298 299 /** 300 * wlan_objmgr_pdev_component_obj_detach() - pdev comp object detach 301 * @psoc: PDEV object 302 * @id: Component id 303 * @comp_priv_obj: component's private object pointer 304 * 305 * API to be used for detaching component object with PDEV common object 306 * 307 * Return: SUCCESS on successful removal of component's object from common 308 * object 309 * On FAILURE (appropriate failure codes are returned) 310 */ 311 QDF_STATUS wlan_objmgr_pdev_component_obj_detach( 312 struct wlan_objmgr_pdev *pdev, 313 enum wlan_umac_comp_id id, 314 void *comp_priv_obj); 315 316 /** 317 ** APIs to operations on pdev objects 318 */ 319 320 typedef void (*wlan_objmgr_pdev_op_handler)(struct wlan_objmgr_pdev *pdev, 321 void *object, 322 void *arg); 323 324 /** 325 * wlan_objmgr_pdev_iterate_obj_list() - operate on all objects of pdev 326 * @pdev: PDEV object 327 * @obj_type: VDEV_OP/PEER_OP 328 * @handler: the handler will be called for each object of requested type 329 * the handler should be implemented to perform required operation 330 * @arg: agruments passed by caller 331 * @lock_free_op: its obsolete 332 * @dbg_id: id of the caller 333 * 334 * API to be used for performing the operations on all VDEV/PEER objects 335 * of pdev 336 * 337 * Return: SUCCESS/FAILURE 338 */ 339 QDF_STATUS wlan_objmgr_pdev_iterate_obj_list( 340 struct wlan_objmgr_pdev *pdev, 341 enum wlan_objmgr_obj_type obj_type, 342 wlan_objmgr_pdev_op_handler handler, 343 void *arg, uint8_t lock_free_op, 344 wlan_objmgr_ref_dbgid dbg_id); 345 346 /** 347 * wlan_objmgr_trigger_pdev_comp_priv_object_creation() - create 348 * comp object of pdev 349 * @pdev: PDEV object 350 * @id: Component id 351 * 352 * API to create component private object in run time, this would be 353 * used for features which gets enabled in run time 354 * 355 * Return: SUCCESS on successful creation 356 * On FAILURE (appropriate failure codes are returned) 357 */ 358 QDF_STATUS wlan_objmgr_trigger_pdev_comp_priv_object_creation( 359 struct wlan_objmgr_pdev *pdev, 360 enum wlan_umac_comp_id id); 361 362 /** 363 * wlan_objmgr_trigger_pdev_comp_priv_object_deletion() - destroy 364 * comp object of pdev 365 * @pdev: PDEV object 366 * @id: Component id 367 * 368 * API to destroy component private object in run time, this would 369 * be used for features which gets disabled in run time 370 * 371 * Return: SUCCESS on successful deletion 372 * On FAILURE (appropriate failure codes are returned) 373 */ 374 QDF_STATUS wlan_objmgr_trigger_pdev_comp_priv_object_deletion( 375 struct wlan_objmgr_pdev *pdev, 376 enum wlan_umac_comp_id id); 377 378 /** 379 * wlan_objmgr_get_vdev_by_id_from_pdev() - find vdev using id from pdev 380 * @pdev: PDEV object 381 * @vdev_id: vdev id 382 * @dbg_id: id of the caller 383 * 384 * API to find vdev object pointer by vdev id from pdev's vdev list 385 * 386 * This API increments the ref count of the vdev object internally, the 387 * caller has to invoke the wlan_objmgr_vdev_release_ref() to decrement 388 * ref count 389 * 390 * Return: vdev pointer 391 * NULL on FAILURE 392 */ 393 #ifdef WLAN_OBJMGR_REF_ID_TRACE 394 struct wlan_objmgr_vdev *wlan_objmgr_get_vdev_by_id_from_pdev_debug( 395 struct wlan_objmgr_pdev *pdev, uint8_t vdev_id, 396 wlan_objmgr_ref_dbgid dbg_id, 397 const char *func, int line); 398 399 #define wlan_objmgr_get_vdev_by_id_from_pdev(pdev, vdev_id, dbgid) \ 400 wlan_objmgr_get_vdev_by_id_from_pdev_debug(pdev, \ 401 vdev_id, dbgid, __func__, __LINE__) 402 #else 403 struct wlan_objmgr_vdev *wlan_objmgr_get_vdev_by_id_from_pdev( 404 struct wlan_objmgr_pdev *pdev, uint8_t vdev_id, 405 wlan_objmgr_ref_dbgid dbg_id); 406 #endif 407 408 /** 409 * wlan_objmgr_get_vdev_by_id_from_pdev_no_state() - find vdev using id 410 * from pdev 411 * @pdev: PDEV object 412 * @vdev_id: vdev id 413 * @dbg_id: id of the caller 414 * 415 * API to find vdev object pointer by vdev id from pdev's vdev list 416 * 417 * This API increments the ref count of the vdev object internally, the 418 * caller has to invoke the wlan_objmgr_vdev_release_ref() to decrement 419 * ref count 420 * 421 * Return: vdev pointer 422 * NULL on FAILURE 423 */ 424 #ifdef WLAN_OBJMGR_REF_ID_TRACE 425 struct wlan_objmgr_vdev *wlan_objmgr_get_vdev_by_id_from_pdev_no_state_debug( 426 struct wlan_objmgr_pdev *pdev, uint8_t vdev_id, 427 wlan_objmgr_ref_dbgid dbg_id, 428 const char *func, int line); 429 430 #define wlan_objmgr_get_vdev_by_id_from_pdev_no_state(pdev, \ 431 vdev_id, dbgid) \ 432 wlan_objmgr_get_vdev_by_id_from_pdev_no_state_debug(pdev, \ 433 vdev_id, dbgid, __func__, __LINE__) 434 #else 435 struct wlan_objmgr_vdev *wlan_objmgr_get_vdev_by_id_from_pdev_no_state( 436 struct wlan_objmgr_pdev *pdev, uint8_t vdev_id, 437 wlan_objmgr_ref_dbgid dbg_id); 438 #endif 439 440 /** 441 * wlan_objmgr_get_vdev_by_macaddr_from_pdev() - find vdev using macaddr 442 * @pdev: PDEV object 443 * @macaddr: MAC address 444 * @dbg_id: id of the caller 445 * 446 * API to find vdev object pointer by vdev mac addr from pdev's vdev list 447 * 448 * This API increments the ref count of the vdev object internally, the 449 * caller has to invoke the wlan_objmgr_vdev_release_ref() to decrement 450 * ref count 451 * 452 * Return: vdev pointer 453 * NULL on FAILURE 454 */ 455 #ifdef WLAN_OBJMGR_REF_ID_TRACE 456 struct wlan_objmgr_vdev *wlan_objmgr_get_vdev_by_macaddr_from_pdev_debug( 457 struct wlan_objmgr_pdev *pdev, uint8_t *macaddr, 458 wlan_objmgr_ref_dbgid dbg_id, 459 const char *fnc, int ln); 460 461 #define wlan_objmgr_get_vdev_by_macaddr_from_pdev(pdev, macaddr, dbgid) \ 462 wlan_objmgr_get_vdev_by_macaddr_from_pdev_debug(pdev, macaddr, \ 463 dbgid, __func__, __LINE__) 464 #else 465 struct wlan_objmgr_vdev *wlan_objmgr_get_vdev_by_macaddr_from_pdev( 466 struct wlan_objmgr_pdev *pdev, uint8_t *macaddr, 467 wlan_objmgr_ref_dbgid dbg_id); 468 #endif 469 470 /** 471 * wlan_objmgr_get_vdev_by_macaddr_from_pdev_no_state() - find vdev using 472 * macaddr 473 * @pdev: PDEV object 474 * @macaddr: MAC address 475 * @dbg_id: id of the caller 476 * 477 * API to find vdev object pointer by vdev mac addr from pdev's vdev list 478 * 479 * This API increments the ref count of the vdev object internally, the 480 * caller has to invoke the wlan_objmgr_vdev_release_ref() to decrement 481 * ref count 482 * 483 * Return: vdev pointer 484 * NULL on FAILURE 485 */ 486 #ifdef WLAN_OBJMGR_REF_ID_TRACE 487 struct wlan_objmgr_vdev 488 *wlan_objmgr_get_vdev_by_macaddr_from_pdev_no_state_debug( 489 struct wlan_objmgr_pdev *pdev, uint8_t *macaddr, 490 wlan_objmgr_ref_dbgid dbg_id, 491 const char *func, int line); 492 493 #define wlan_objmgr_get_vdev_by_macaddr_from_pdev_no_state(pdev, macaddr, \ 494 dbgid) \ 495 wlan_objmgr_get_vdev_by_macaddr_from_pdev_no_state_debug(pdev, \ 496 macaddr, dbgid, __func__, __LINE__) 497 #else 498 struct wlan_objmgr_vdev *wlan_objmgr_get_vdev_by_macaddr_from_pdev_no_state( 499 struct wlan_objmgr_pdev *pdev, uint8_t *macaddr, 500 wlan_objmgr_ref_dbgid dbg_id); 501 #endif 502 503 /** 504 * wlan_objmgr_pdev_get_first_vdev() - Get first vdev of pdev 505 * @pdev: PDEV object 506 * @dbg_id: Object Manager ref debug id 507 * 508 * API to get reference to first vdev of pdev. 509 * 510 * Return: reference to first vdev 511 */ 512 #ifdef WLAN_OBJMGR_REF_ID_TRACE 513 struct wlan_objmgr_vdev *wlan_objmgr_pdev_get_first_vdev_debug( 514 struct wlan_objmgr_pdev *pdev, 515 wlan_objmgr_ref_dbgid dbg_id, 516 const char *func, int line); 517 518 #define wlan_objmgr_pdev_get_first_vdev(pdev, dbgid) \ 519 wlan_objmgr_pdev_get_first_vdev_debug(pdev, dbgid, \ 520 __func__, __LINE__) 521 #else 522 struct wlan_objmgr_vdev *wlan_objmgr_pdev_get_first_vdev( 523 struct wlan_objmgr_pdev *pdev, 524 wlan_objmgr_ref_dbgid dbg_id); 525 #endif 526 527 /** 528 * wlan_objmgr_pdev_get_comp_private_obj() - get pdev component private object 529 * @pdev: PDEV object 530 * @id: Component id 531 * 532 * API to get component private object 533 * 534 * Return: void *ptr on SUCCESS 535 * NULL on Failure 536 */ 537 void *wlan_objmgr_pdev_get_comp_private_obj( 538 struct wlan_objmgr_pdev *pdev, 539 enum wlan_umac_comp_id id); 540 541 /** 542 * wlan_pdev_obj_lock() - Acquire PDEV spinlock 543 * @pdev: PDEV object 544 * 545 * API to acquire PDEV lock 546 * Parent lock should not be taken in child lock context 547 * but child lock can be taken in parent lock context 548 * (for ex: psoc lock can't be invoked in pdev/vdev/peer lock context) 549 * 550 * Return: void 551 */ 552 static inline void wlan_pdev_obj_lock(struct wlan_objmgr_pdev *pdev) 553 { 554 qdf_spin_lock_bh(&pdev->pdev_lock); 555 } 556 557 /** 558 * wlan_pdev_obj_unlock() - Release PDEV spinlock 559 * @pdev: PDEV object 560 * 561 * API to Release PDEV lock 562 * 563 * Return: void 564 */ 565 static inline void wlan_pdev_obj_unlock(struct wlan_objmgr_pdev *pdev) 566 { 567 qdf_spin_unlock_bh(&pdev->pdev_lock); 568 } 569 570 /** 571 * wlan_pdev_get_psoc() - get psoc 572 * @pdev: PDEV object 573 * 574 * API to get the psoc object from PDEV 575 * 576 * Return: 577 * @psoc: PSOC object 578 */ 579 static inline struct wlan_objmgr_psoc *wlan_pdev_get_psoc( 580 struct wlan_objmgr_pdev *pdev) 581 { 582 return pdev->pdev_objmgr.wlan_psoc; 583 } 584 585 /** 586 * wlan_pdev_set_psoc() - set psoc 587 * @pdev: PDEV object 588 * @psoc: PSOC object 589 * 590 * API to set the psoc object from PDEV 591 * 592 * Return: void 593 */ 594 static inline void wlan_pdev_set_psoc(struct wlan_objmgr_pdev *pdev, 595 struct wlan_objmgr_psoc *psoc) 596 { 597 pdev->pdev_objmgr.wlan_psoc = psoc; 598 } 599 600 /** 601 * wlan_pdev_nif_fw_cap_set() - set fw caps 602 * @pdev: PDEV object 603 * @cap: capability flag to be set 604 * 605 * API to set fw caps in pdev 606 * 607 * Return: void 608 */ 609 static inline void wlan_pdev_nif_fw_cap_set(struct wlan_objmgr_pdev *pdev, 610 uint32_t cap) 611 { 612 pdev->pdev_nif.pdev_fw_caps |= cap; 613 } 614 615 /** 616 * wlan_pdev_nif_fw_cap_clear() - clear fw cap 617 * @pdev: PDEV object 618 * @cap: capability flag to be cleared 619 * 620 * API to clear fw caps in pdev 621 * 622 * Return: void 623 */ 624 static inline void wlan_pdev_nif_fw_cap_clear(struct wlan_objmgr_pdev *pdev, 625 uint32_t cap) 626 { 627 pdev->pdev_nif.pdev_fw_caps &= ~cap; 628 } 629 630 /** 631 * wlan_pdev_nif_fw_cap_get() - get fw caps 632 * @pdev: PDEV object 633 * @cap: capability flag to be checked 634 * 635 * API to know, whether particular fw caps flag is set in pdev 636 * 637 * Return: 1 (for set) or 0 (for not set) 638 */ 639 static inline uint8_t wlan_pdev_nif_fw_cap_get(struct wlan_objmgr_pdev *pdev, 640 uint32_t cap) 641 { 642 return (pdev->pdev_nif.pdev_fw_caps & cap) ? 1 : 0; 643 } 644 645 /** 646 * wlan_pdev_nif_feat_cap_set() - set feature caps 647 * @pdev: PDEV object 648 * @cap: capability flag to be set 649 * 650 * API to set feat caps in pdev 651 * 652 * Return: void 653 */ 654 static inline void wlan_pdev_nif_feat_cap_set(struct wlan_objmgr_pdev *pdev, 655 uint32_t cap) 656 { 657 pdev->pdev_nif.pdev_feature_caps |= cap; 658 } 659 660 /** 661 * wlan_pdev_nif_feat_cap_clear() - clear feature caps 662 * @pdev: PDEV object 663 * @cap: capability flag to be cleared 664 * 665 * API to clear feat caps in pdev 666 * 667 * Return: void 668 */ 669 static inline void wlan_pdev_nif_feat_cap_clear(struct wlan_objmgr_pdev *pdev, 670 uint32_t cap) 671 { 672 pdev->pdev_nif.pdev_feature_caps &= ~cap; 673 } 674 675 /** 676 * wlan_pdev_nif_feat_cap_get() - get feature caps 677 * @pdev: PDEV object 678 * @cap: capability flag to be checked 679 * 680 * API to know, whether particular feat caps flag is set in pdev 681 * 682 * Return: 1 (for set) or 0 (for not set) 683 */ 684 static inline uint8_t wlan_pdev_nif_feat_cap_get(struct wlan_objmgr_pdev *pdev, 685 uint32_t cap) 686 { 687 return (pdev->pdev_nif.pdev_feature_caps & cap) ? 1 : 0; 688 } 689 690 /** 691 * wlan_pdev_nif_feat_ext_cap_set() - set feature ext caps 692 * @pdev: PDEV object 693 * @cap: capability flag to be set 694 * 695 * API to set feat ext caps in pdev 696 * 697 * Return: void 698 */ 699 static inline 700 void wlan_pdev_nif_feat_ext_cap_set(struct wlan_objmgr_pdev *pdev, 701 uint32_t cap) 702 { 703 pdev->pdev_nif.pdev_feature_ext_caps |= cap; 704 } 705 706 /** 707 * wlan_pdev_nif_feat_ext_cap_clear() - clear feature ext caps 708 * @pdev: PDEV object 709 * @cap: capability flag to be cleared 710 * 711 * API to clear feat ext caps in pdev 712 * 713 * Return: void 714 */ 715 static inline 716 void wlan_pdev_nif_feat_ext_cap_clear(struct wlan_objmgr_pdev *pdev, 717 uint32_t cap) 718 { 719 pdev->pdev_nif.pdev_feature_ext_caps &= ~cap; 720 } 721 722 /** 723 * wlan_pdev_nif_feat_ext_cap_get() - get feature ext caps 724 * @pdev: PDEV object 725 * @cap: capability flag to be checked 726 * 727 * API to know, whether particular feat ext caps flag is set in pdev 728 * 729 * Return: 1 (for set) or 0 (for not set) 730 */ 731 static inline 732 uint8_t wlan_pdev_nif_feat_ext_cap_get(struct wlan_objmgr_pdev *pdev, 733 uint32_t cap) 734 { 735 return (pdev->pdev_nif.pdev_feature_ext_caps & cap) ? 1 : 0; 736 } 737 738 /** 739 * wlan_pdev_mlme_op_set() - set operation flags 740 * @pdev: PDEV object 741 * @op: Operation flag to be set 742 * 743 * API to set operation flag in pdev 744 * 745 * Return: void 746 */ 747 static inline void wlan_pdev_mlme_op_set(struct wlan_objmgr_pdev *pdev, 748 uint32_t op) 749 { 750 pdev->pdev_mlme.pdev_op_flags |= op; 751 } 752 753 /** 754 * wlan_pdev_mlme_op_clear() - clear op flags 755 * @pdev: PDEV object 756 * @op: Operation flag to be cleared 757 * 758 * API to clear op flag in pdev 759 * 760 * Return: void 761 */ 762 static inline void wlan_pdev_mlme_op_clear(struct wlan_objmgr_pdev *pdev, 763 uint32_t op) 764 { 765 pdev->pdev_mlme.pdev_op_flags &= ~op; 766 } 767 768 /** 769 * wlan_pdev_mlme_op_get() - get op flag 770 * @pdev: PDEV object 771 * @op: Operation flag to be checked 772 * 773 * API to know, whether particular operation flag is set in pdev 774 * 775 * Return: 1 (for set) or 0 (for not set) 776 */ 777 static inline uint8_t wlan_pdev_mlme_op_get(struct wlan_objmgr_pdev *pdev, 778 uint32_t op) 779 { 780 return (pdev->pdev_mlme.pdev_op_flags & op) ? 1 : 0; 781 } 782 783 /** 784 * wlan_pdev_get_hw_macaddr() - get hw macaddr 785 * @pdev: PDEV object 786 * 787 * API to get HW MAC address form PDEV 788 * 789 * Caller need to acquire lock with wlan_pdev_obj_lock() 790 * 791 * Return: @macaddr -MAC address 792 */ 793 static inline uint8_t *wlan_pdev_get_hw_macaddr(struct wlan_objmgr_pdev *pdev) 794 { 795 if (!pdev) 796 return NULL; 797 798 /* This API is invoked with lock acquired, do not add log prints */ 799 return pdev->pdev_nif.macaddr; 800 } 801 802 /** 803 * wlan_pdev_set_hw_macaddr() - set hw macaddr 804 * @pdev: PDEV object 805 * @macaddr: MAC address 806 * 807 * API to set HW MAC address form PDEV 808 * 809 * Caller need to acquire lock with wlan_pdev_obj_lock() 810 * 811 * Return: void 812 */ 813 static inline void wlan_pdev_set_hw_macaddr(struct wlan_objmgr_pdev *pdev, 814 uint8_t *macaddr) 815 { 816 /* This API is invoked with lock acquired, do not add log prints */ 817 WLAN_ADDR_COPY(pdev->pdev_nif.macaddr, macaddr); 818 } 819 820 /** 821 * wlan_pdev_get_ospriv() - get os priv pointer 822 * @pdev: PDEV object 823 * 824 * API to get OS private pointer from PDEV 825 * 826 * Return: ospriv - private pointer 827 */ 828 static inline struct pdev_osif_priv *wlan_pdev_get_ospriv( 829 struct wlan_objmgr_pdev *pdev) 830 { 831 return pdev->pdev_nif.pdev_ospriv; 832 } 833 834 /** 835 * wlan_pdev_reset_ospriv() - reset os priv pointer 836 * @pdev: PDEV object 837 * 838 * API to reset OS private pointer in PDEV 839 * 840 * Return: void 841 */ 842 static inline void wlan_pdev_reset_ospriv(struct wlan_objmgr_pdev *pdev) 843 { 844 pdev->pdev_nif.pdev_ospriv = NULL; 845 } 846 847 /** 848 * wlan_pdev_set_max_vdev_count() - set pdev max vdev count 849 * @pdev: PDEV object 850 * @vdev count: Max vdev count 851 * 852 * API to set Max vdev count 853 * 854 * Return: void 855 */ 856 static inline void wlan_pdev_set_max_vdev_count(struct wlan_objmgr_pdev *pdev, 857 uint8_t max_vdev_count) 858 { 859 if (max_vdev_count > WLAN_UMAC_PDEV_MAX_VDEVS) 860 QDF_BUG(0); 861 862 pdev->pdev_objmgr.max_vdev_count = max_vdev_count; 863 } 864 865 /** 866 * wlan_pdev_get_max_vdev_count() - get pdev max vdev count 867 * @pdev: PDEV object 868 * 869 * API to set Max vdev count 870 * 871 * Return: @vdev count: Max vdev count 872 */ 873 static inline uint8_t wlan_pdev_get_max_vdev_count( 874 struct wlan_objmgr_pdev *pdev) 875 { 876 return pdev->pdev_objmgr.max_vdev_count; 877 } 878 879 /** 880 * DOC: Examples to use PDEV ref count APIs 881 * 882 * In all the scenarios, the pair of API should be followed 883 * otherwise it lead to memory leak 884 * 885 * scenario 1: 886 * 887 * wlan_objmgr_pdev_obj_create() 888 * ---- 889 * wlan_objmgr_pdev_obj_delete() 890 * 891 * scenario 2: 892 * 893 * wlan_objmgr_pdev_get_ref() 894 * ---- 895 * the operations which are done on 896 * pdev object 897 * ---- 898 * wlan_objmgr_pdev_release_ref() 899 * 900 * scenario 3: 901 * 902 * wlan_objmgr_get_pdev_by_id[_no_state]() 903 * ---- 904 * the operations which are done on 905 * pdev object 906 * ---- 907 * wlan_objmgr_pdev_release_ref() 908 * 909 * scenario 4: 910 * 911 * wlan_objmgr_get_pdev_by_macaddr[_no_state]() 912 * ---- 913 * the operations which are done on 914 * pdev object 915 * ---- 916 * wlan_objmgr_pdev_release_ref() 917 */ 918 919 /** 920 * wlan_objmgr_pdev_get_ref() - increment ref count 921 * @pdev: PDEV object 922 * @id: Object Manager ref debug id 923 * 924 * API to increment ref count of pdev 925 * 926 * Return: void 927 */ 928 void wlan_objmgr_pdev_get_ref(struct wlan_objmgr_pdev *pdev, 929 wlan_objmgr_ref_dbgid id); 930 931 /** 932 * wlan_objmgr_pdev_try_get_ref() - increment ref count, if allowed 933 * @pdev: PDEV object 934 * @id: Object Manager ref debug id 935 * 936 * API to increment ref count of pdev after checking valid object state 937 * 938 * Return: void 939 */ 940 QDF_STATUS wlan_objmgr_pdev_try_get_ref(struct wlan_objmgr_pdev *pdev, 941 wlan_objmgr_ref_dbgid id); 942 943 /** 944 * wlan_objmgr_pdev_release_ref() - decrement ref count 945 * @pdev: PDEV object 946 * @id: Object Manager ref debug id 947 * 948 * API to decrement ref count of pdev, if ref count is 1, it initiates the 949 * PDEV deletion 950 * 951 * Return: void 952 */ 953 void wlan_objmgr_pdev_release_ref(struct wlan_objmgr_pdev *pdev, 954 wlan_objmgr_ref_dbgid id); 955 956 /** 957 * wlan_objmgr_pdev_get_pdev_id() - get pdev id 958 * @pdev: PDEV object 959 * 960 * API to get pdev id from pdev object 961 * 962 * Return: @pdev id 963 */ 964 static inline 965 uint8_t wlan_objmgr_pdev_get_pdev_id(struct wlan_objmgr_pdev *pdev) 966 { 967 return pdev->pdev_objmgr.wlan_pdev_id; 968 } 969 970 /** 971 * wlan_pdev_set_tgt_if_handle(): API to set target if handle in pdev object 972 * @pdev: Pdev pointer 973 * @tgt_if_handle: target interface handle 974 * 975 * API to set target interface handle in pdev object 976 * 977 * Caller needs to acquire lock with wlan_pdev_obj_lock() 978 * 979 * Return: None 980 */ 981 static inline 982 void wlan_pdev_set_tgt_if_handle(struct wlan_objmgr_pdev *pdev, 983 target_pdev_info_t *tgt_if_handle) 984 { 985 /* This API is invoked with lock acquired, do not add log prints */ 986 if (!pdev) 987 return; 988 989 pdev->tgt_if_handle = tgt_if_handle; 990 } 991 992 /** 993 * wlan_pdev_get_tgt_if_handle(): API to get target interface handle 994 * @pdev: Pdev pointer 995 * 996 * API to get target interface handle from pdev object 997 * 998 * Return: target interface handle 999 */ 1000 static inline 1001 target_pdev_info_t *wlan_pdev_get_tgt_if_handle(struct wlan_objmgr_pdev *pdev) 1002 { 1003 if (!pdev) 1004 return NULL; 1005 1006 return pdev->tgt_if_handle; 1007 } 1008 1009 /** 1010 * wlan_pdev_set_max_peer_count() - set max peer count 1011 * @vdev: PDEV object 1012 * @count: Max peer count 1013 * 1014 * API to set max peer count of PDEV 1015 * 1016 * Return: void 1017 */ 1018 static inline void wlan_pdev_set_max_peer_count(struct wlan_objmgr_pdev *pdev, 1019 uint16_t count) 1020 { 1021 pdev->pdev_objmgr.max_peer_count = count; 1022 } 1023 1024 /** 1025 * wlan_pdev_get_max_peer_count() - get max peer count 1026 * @pdev: PDEV object 1027 * 1028 * API to get max peer count of PDEV 1029 * 1030 * Return: max peer count 1031 */ 1032 static inline uint16_t wlan_pdev_get_max_peer_count( 1033 struct wlan_objmgr_pdev *pdev) 1034 { 1035 return pdev->pdev_objmgr.max_peer_count; 1036 } 1037 1038 /** 1039 * wlan_pdev_set_max_monitor_vdev_count() - set max monitor vdev count 1040 * @pdev: PDEV object 1041 * @count: Max monitor vdev count 1042 * 1043 * API to set max monitor vdev count of PDEV 1044 * 1045 * Return: void 1046 */ 1047 static inline void wlan_pdev_set_max_monitor_vdev_count( 1048 struct wlan_objmgr_pdev *pdev, 1049 uint16_t count) 1050 { 1051 pdev->pdev_objmgr.max_monitor_vdev_count = count; 1052 } 1053 1054 /** 1055 * wlan_pdev_get_max_monitor_vdev_count() - get max monitor vdev count 1056 * @pdev: PDEV object 1057 * 1058 * API to get max monitor vdev count of PDEV 1059 * 1060 * Return: max monitor vdev count 1061 */ 1062 static inline uint16_t wlan_pdev_get_max_monitor_vdev_count( 1063 struct wlan_objmgr_pdev *pdev) 1064 { 1065 return pdev->pdev_objmgr.max_monitor_vdev_count; 1066 } 1067 1068 /** 1069 * wlan_pdev_get_peer_count() - get pdev peer count 1070 * @pdev: PDEV object 1071 * 1072 * API to get peer count from PDEV 1073 * 1074 * Return: peer_count - pdev's peer count 1075 */ 1076 static inline uint16_t wlan_pdev_get_peer_count(struct wlan_objmgr_pdev *pdev) 1077 { 1078 return pdev->pdev_objmgr.wlan_peer_count; 1079 } 1080 1081 /** 1082 * wlan_pdev_get_temp_peer_count() - get pdev temporary peer count 1083 * @pdev: PDEV object 1084 * 1085 * API to get temporary peer count from PDEV 1086 * 1087 * Return: temp_peer_count - pdev's temporary peer count 1088 */ 1089 static inline uint16_t wlan_pdev_get_temp_peer_count(struct wlan_objmgr_pdev *pdev) 1090 { 1091 return pdev->pdev_objmgr.temp_peer_count; 1092 } 1093 1094 1095 /** 1096 * wlan_pdev_incr_peer_count() - increment pdev peer count 1097 * @pdev: PDEV object 1098 * 1099 * API to increment peer count of PDEV by 1 1100 * 1101 * Return: void 1102 */ 1103 static inline void wlan_pdev_incr_peer_count(struct wlan_objmgr_pdev *pdev) 1104 { 1105 pdev->pdev_objmgr.wlan_peer_count++; 1106 } 1107 1108 /** 1109 * wlan_pdev_decr_peer_count() - decrement pdev peer count 1110 * @pdev: PDEV object 1111 * 1112 * API to decrement peer count of PDEV by 1 1113 * 1114 * Return: void 1115 */ 1116 static inline void wlan_pdev_decr_peer_count(struct wlan_objmgr_pdev *pdev) 1117 { 1118 pdev->pdev_objmgr.wlan_peer_count--; 1119 } 1120 1121 /** 1122 * wlan_pdev_incr_temp_peer_count() - increment temporary pdev peer count 1123 * @pdev: PDEV object 1124 * 1125 * API to increment temporary peer count of PDEV by 1 1126 * 1127 * Return: void 1128 */ 1129 static inline void wlan_pdev_incr_temp_peer_count(struct wlan_objmgr_pdev *pdev) 1130 { 1131 pdev->pdev_objmgr.temp_peer_count++; 1132 } 1133 1134 /** 1135 * wlan_pdev_decr_temp_peer_count() - decrement pdev temporary peer count 1136 * @pdev: PDEV object 1137 * 1138 * API to decrement temporary peer count of PDEV by 1 1139 * 1140 * Return: void 1141 */ 1142 static inline void wlan_pdev_decr_temp_peer_count(struct wlan_objmgr_pdev *pdev) 1143 { 1144 pdev->pdev_objmgr.temp_peer_count--; 1145 } 1146 1147 /** 1148 * wlan_pdev_get_vdev_count() - get PDEV vdev count 1149 * @pdev: PDEV object 1150 * 1151 * API to get vdev count from PDEV 1152 * 1153 * Return: vdev_count - pdev's vdev count 1154 */ 1155 static inline uint8_t wlan_pdev_get_vdev_count(struct wlan_objmgr_pdev *pdev) 1156 { 1157 return pdev->pdev_objmgr.wlan_vdev_count; 1158 } 1159 1160 /** 1161 * wlan_print_pdev_info() - print pdev members 1162 * @pdev: pdev object pointer 1163 * 1164 * Return: void 1165 */ 1166 #ifdef WLAN_OBJMGR_DEBUG 1167 void wlan_print_pdev_info(struct wlan_objmgr_pdev *pdev); 1168 #else 1169 static inline void wlan_print_pdev_info(struct wlan_objmgr_pdev *pdev) {} 1170 #endif 1171 1172 #endif /* _WLAN_OBJMGR_PDEV_H_*/ 1173