1 /* 2 * Copyright (c) 2016-2017 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 /** 20 * DOC: Define the pdev data structure of UMAC 21 * Public APIs to perform operations on Global objects 22 */ 23 24 #ifndef _WLAN_OBJMGR_PDEV_OBJ_H_ 25 #define _WLAN_OBJMGR_PDEV_OBJ_H_ 26 27 #include <wlan_objmgr_cmn.h> 28 #include "wlan_objmgr_psoc_obj.h" 29 30 /* STATUS: scanning */ 31 #define WLAN_PDEV_F_SCAN 0x00000001 32 /* STATUS: use short slot time*/ 33 #define WLAN_PDEV_F_SHSLOT 0x00000002 34 /* STATUS: channel switch event pending after DFS RADAR */ 35 #define WLAN_PDEV_F_DFS_CHANSWITCH_PENDING 0x00000004 36 /* TX Power: fixed rate */ 37 #define WLAN_PDEV_F_TXPOW_FIXED 0x00000008 38 /* STATUS: use short preamble */ 39 #define WLAN_PDEV_F_SHPREAMBLE 0x00000010 40 /* CONF: do alignment pad */ 41 #define WLAN_PDEV_F_DATAPAD 0x00000020 42 /* STATUS: protection enabled */ 43 #define WLAN_PDEV_F_USEPROT 0x00000040 44 /* STATUS: use barker preamble*/ 45 #define WLAN_PDEV_F_USEBARKER 0x00000080 46 /* CONF: DISABLE 2040 coexistance */ 47 #define WLAN_PDEV_F_COEXT_DISABLE 0x00000100 48 /* STATE: scan pending */ 49 #define WLAN_PDEV_F_SCAN_PENDING 0x00000200 50 /* CONF: send regclassids in country ie */ 51 #define WLAN_PDEV_F_REGCLASS 0x00000400 52 /* CONF: block the use of DFS channels */ 53 #define WLAN_PDEV_F_BLKDFSCHAN 0x00000800 54 /* STATUS: 11D in used */ 55 #define WLAN_PDEV_F_DOT11D 0x00001000 56 /* STATUS: 11D channel-switch detected */ 57 #define WLAN_PDEV_F_RADAR 0x00002000 58 /* CONF: A-MPDU supported */ 59 #define WLAN_PDEV_F_AMPDU 0x00004000 60 /* CONF: A-MSDU supported */ 61 #define WLAN_PDEV_F_AMSDU 0x00008000 62 /* CONF: HT traffic protected */ 63 #define WLAN_PDEV_F_HTPROT 0x00010000 64 /* CONF: Reset once */ 65 #define WLAN_PDEV_F_RESET 0x00020000 66 /* CONF: ignore 11d beacon */ 67 #define WLAN_PDEV_F_IGNORE_11D_BEACON 0x00040000 68 /* HT CAP IE present */ 69 #define WLAN_PDEV_F_HTVIE 0x00080000 70 /* radio in middle of CSA */ 71 #define WLAN_PDEV_F_CSA_WAIT 0x00100000 72 /* wnm support flag */ 73 #define WLAN_PDEV_F_WNM 0x00200000 74 #define WLAN_PDEV_F_2G_CSA 0x00400000 75 /* enhanced independent repeater */ 76 #define WLAN_PDEV_F_ENH_REP_IND 0x00800000 77 /* Disable Tx AMSDU for station vap */ 78 #define WLAN_PDEV_F_STA_AMPDU_DIS 0x01000000 79 /* do not send probe request in passive channel */ 80 #define WLAN_PDEV_F_STRICT_PSCAN_EN 0x02000000 81 /* dupie (ANA,pre ANA ) */ 82 /*#define WLAN_PDEV_F_DUPIE 0x00200000*/ 83 84 /* PDEV op flags */ 85 /* Enable htrate for wep and tkip */ 86 #define WLAN_PDEV_OP_WEP_TKIP_HTRATE 0x00000001 87 /* non HT AP found flag */ 88 #define WLAN_PDEV_OP_NON_HT_AP 0x00000002 89 /* block the use of DFS channels flag */ 90 #define WLAN_PDEV_OP_BLK_DFS_CHAN 0x00000004 91 /* 11.h flag */ 92 #define WLAN_PDEV_OP_DOTH 0x00000008 93 /* Off-channel support enabled */ 94 #define WLAN_PDEV_OP_OFFCHAN 0x00000010 95 #define WLAN_PDEV_OP_HT20ADHOC 0x00000020 96 #define WLAN_PDEV_OP_HT40ADHOC 0x00000040 97 #define WLAN_PDEV_OP_HTADHOC_AGGR 0x00000080 98 /* disallow CC change when assoc completes */ 99 #define WLAN_PDEV_OP_DISALLOW_AUTO_CC 0x00000100 100 /* Is P2P Enabled? */ 101 #define WLAN_PDEV_OP_P2P 0x00000200 102 /* disallowed */ 103 #define WLAN_PDEV_OP_IGNORE_DYNHALT 0x00000400 104 /* overwrite probe response IE with beacon IE */ 105 #define WLAN_PDEV_OP_OVERRIDE_PROBERESP 0x00000800 106 #define WLAN_PDEV_OP_DROPSTA_QUERY 0x00001000 107 #define WLAN_PDEV_OP_BLK_REPORT_FLOOD 0x00002000 108 /* Offchan scan */ 109 #define WLAN_PDEV_OP_OFFCHAN_SCAN 0x00004000 110 /*Consider OBSS non-erp to change to long slot*/ 111 #define WLAN_PDEV_OP_OBSS_LONGSLOT 0x00008000 112 /* enable/disable min rssi cli block */ 113 #define WLAN_PDEV_OP_MIN_RSSI_ENABLE 0x00010000 114 115 116 struct osif_pdev_priv; 117 118 /** 119 * struct wlan_objmgr_pdev_nif - pdev object nif structure 120 * @pdev_fw_caps: radio specific FW capabilities 121 * @pdev_feature_caps: radio specific feature capabilities 122 * @pdev_ospriv: OS specific pointer 123 * @notified_ap_vdev: ap vdev 124 */ 125 struct wlan_objmgr_pdev_nif { 126 uint32_t pdev_fw_caps; 127 uint32_t pdev_feature_caps; 128 struct pdev_osif_priv *pdev_ospriv; 129 uint8_t notified_ap_vdev; 130 }; 131 132 /** 133 * struct wlan_objmgr_pdev_mlme - pdev object mlme structure 134 * @pdev_op_flags: PDEV operation flags, can be used to know the 135 * operation status (deletion progress, etc) 136 */ 137 struct wlan_objmgr_pdev_mlme { 138 uint32_t pdev_op_flags; 139 }; 140 141 /** 142 * struct wlan_objmgr_pdev_objmgr - pdev object object manager structure 143 * @wlan_pdev_id: PDEV id 144 * @wlan_vdev_list: List maintains the VDEVs created on this PDEV 145 * @wlan_vdev_count: VDEVs count 146 * @max_vdev_count: Max no. of VDEVs supported by this PDEV 147 * @wlan_psoc: back pointer to PSOC, its attached to 148 * @ref_cnt: Ref count 149 * @ref_id_dbg: Array to track Ref count 150 * @print_cnt: Count to throttle Logical delete prints 151 */ 152 struct wlan_objmgr_pdev_objmgr { 153 uint8_t wlan_pdev_id; 154 qdf_list_t wlan_vdev_list; 155 uint8_t wlan_vdev_count; 156 uint8_t max_vdev_count; 157 struct wlan_objmgr_psoc *wlan_psoc; 158 qdf_atomic_t ref_cnt; 159 qdf_atomic_t ref_id_dbg[WLAN_REF_ID_MAX]; 160 uint8_t print_cnt; 161 }; 162 163 /** 164 * struct wlan_objmgr_pdev - PDEV common object 165 * @current_chan_list: Active/current Channel list of the radio 166 * @pdev_nif: pdev nif structure 167 * @pdev_objmgr: pdev object manager structure 168 * @pdev_mlme: pdev MLME structure 169 * @pdev_comp_priv_obj[]: component's private object array 170 * @obj_status[]: object status of each component object 171 * @obj_state: object state 172 * @tgt_if_handle Target interface handle 173 * @pdev_lock: lock to protect object 174 */ 175 struct wlan_objmgr_pdev { 176 struct wlan_chan_list *current_chan_list; 177 struct wlan_objmgr_pdev_nif pdev_nif; 178 struct wlan_objmgr_pdev_objmgr pdev_objmgr; 179 struct wlan_objmgr_pdev_mlme pdev_mlme; 180 void *pdev_comp_priv_obj[WLAN_UMAC_MAX_COMPONENTS]; 181 QDF_STATUS obj_status[WLAN_UMAC_MAX_COMPONENTS]; 182 WLAN_OBJ_STATE obj_state; 183 void *tgt_if_handle; 184 qdf_spinlock_t pdev_lock; 185 }; 186 187 188 /** 189 ** APIs to Create/Delete Global object APIs 190 */ 191 /** 192 * wlan_objmgr_pdev_obj_create() - pdev create 193 * @psoc: PSOC object 194 * @scn: os private object 195 * 196 * Creates PDEV object, intializes with default values 197 * Invokes the registered notifiers to create component object 198 * 199 * Return: Handle to struct wlan_objmgr_psoc on successful creation, 200 * NULL on Failure (on Mem alloc failure and Component objects 201 * Failure) 202 */ 203 struct wlan_objmgr_pdev *wlan_objmgr_pdev_obj_create( 204 struct wlan_objmgr_psoc *psoc, struct pdev_osif_priv *osif_priv); 205 206 /** 207 * wlan_objmgr_pdev_obj_delete() - pdev delete 208 * @psoc: PDEV object 209 * 210 * Logically deletes PDEV object, 211 * Once all the references are released, object manager invokes the registered 212 * notifiers to destroy component objects 213 * 214 * Return: SUCCESS/FAILURE 215 */ 216 QDF_STATUS wlan_objmgr_pdev_obj_delete(struct wlan_objmgr_pdev *pdev); 217 218 /** 219 ** APIs to attach/detach component objects 220 */ 221 /** 222 * wlan_objmgr_pdev_component_obj_attach() - pdev comp object attach 223 * @psoc: PDEV object 224 * @id: Component id 225 * @comp_priv_obj: component's private object pointer 226 * @status: Component's private object creation status 227 * 228 * API to be used for attaching component object with PDEV common object 229 * 230 * Return: SUCCESS on successful storing of component's object in common object 231 * On FAILURE (appropriate failure codes are returned) 232 */ 233 QDF_STATUS wlan_objmgr_pdev_component_obj_attach( 234 struct wlan_objmgr_pdev *pdev, 235 enum wlan_umac_comp_id id, 236 void *comp_priv_obj, 237 QDF_STATUS status); 238 239 /** 240 * wlan_objmgr_pdev_component_obj_detach() - pdev comp object detach 241 * @psoc: PDEV object 242 * @id: Component id 243 * @comp_priv_obj: component's private object pointer 244 * 245 * API to be used for detaching component object with PDEV common object 246 * 247 * Return: SUCCESS on successful removal of component's object from common 248 * object 249 * On FAILURE (appropriate failure codes are returned) 250 */ 251 QDF_STATUS wlan_objmgr_pdev_component_obj_detach( 252 struct wlan_objmgr_pdev *pdev, 253 enum wlan_umac_comp_id id, 254 void *comp_priv_obj); 255 256 /** 257 ** APIs to operations on pdev objects 258 */ 259 260 typedef void (*wlan_objmgr_pdev_op_handler)(struct wlan_objmgr_pdev *pdev, 261 void *object, 262 void *arg); 263 264 /** 265 * wlan_objmgr_pdev_iterate_obj_list() - operate on all objects of pdev 266 * @pdev: PDEV object 267 * @obj_type: VDEV_OP/PEER_OP 268 * @handler: the handler will be called for each object of requested type 269 * the handler should be implemented to perform required operation 270 * @arg: agruments passed by caller 271 * @lock_free_op: This gives provision to run this API with out lock protected 272 * It would be useful, for operations like Obj Delete, where 273 * lock should not be taken by caller. 274 * @dbg_id: id of the caller 275 * 276 * API to be used for performing the operations on all VDEV/PEER objects 277 * of pdev 278 * 279 * Return: SUCCESS/FAILURE 280 */ 281 QDF_STATUS wlan_objmgr_pdev_iterate_obj_list( 282 struct wlan_objmgr_pdev *pdev, 283 enum wlan_objmgr_obj_type obj_type, 284 wlan_objmgr_pdev_op_handler handler, 285 void *arg, uint8_t lock_free_op, 286 wlan_objmgr_ref_dbgid dbg_id); 287 288 /** 289 * wlan_objmgr_trigger_pdev_comp_priv_object_creation() - create 290 * comp object of pdev 291 * @pdev: PDEV object 292 * @id: Component id 293 * 294 * API to create component private object in run time, this would be 295 * used for features which gets enabled in run time 296 * 297 * Return: SUCCESS on successful creation 298 * On FAILURE (appropriate failure codes are returned) 299 */ 300 QDF_STATUS wlan_objmgr_trigger_pdev_comp_priv_object_creation( 301 struct wlan_objmgr_pdev *pdev, 302 enum wlan_umac_comp_id id); 303 304 /** 305 * wlan_objmgr_trigger_pdev_comp_priv_object_deletion() - destroy 306 * comp object of pdev 307 * @pdev: PDEV object 308 * @id: Component id 309 * 310 * API to destroy component private object in run time, this would 311 * be used for features which gets disabled in run time 312 * 313 * Return: SUCCESS on successful deletion 314 * On FAILURE (appropriate failure codes are returned) 315 */ 316 QDF_STATUS wlan_objmgr_trigger_pdev_comp_priv_object_deletion( 317 struct wlan_objmgr_pdev *pdev, 318 enum wlan_umac_comp_id id); 319 320 /** 321 * wlan_objmgr_get_vdev_by_id_from_pdev() - find vdev using id from pdev 322 * @pdev: PDEV object 323 * @vdev_id: vdev id 324 * @dbg_id: id of the caller 325 * 326 * API to find vdev object pointer by vdev id from pdev's vdev list 327 * 328 * This API increments the ref count of the vdev object internally, the 329 * caller has to invoke the wlan_objmgr_vdev_release_ref() to decrement 330 * ref count 331 * 332 * Return: vdev pointer 333 * NULL on FAILURE 334 */ 335 struct wlan_objmgr_vdev *wlan_objmgr_get_vdev_by_id_from_pdev( 336 struct wlan_objmgr_pdev *pdev, uint8_t vdev_id, 337 wlan_objmgr_ref_dbgid dbg_id); 338 339 /** 340 * wlan_objmgr_get_vdev_by_id_from_pdev_no_state() - find vdev using id from 341 * pdev 342 * @pdev: PDEV object 343 * @vdev_id: vdev id 344 * @dbg_id: id of the caller 345 * 346 * API to find vdev object pointer by vdev id from pdev's vdev list 347 * 348 * This API increments the ref count of the vdev object internally, the 349 * caller has to invoke the wlan_objmgr_vdev_release_ref() to decrement 350 * ref count 351 * 352 * Return: vdev pointer 353 * NULL on FAILURE 354 */ 355 struct wlan_objmgr_vdev *wlan_objmgr_get_vdev_by_id_from_pdev_no_state( 356 struct wlan_objmgr_pdev *pdev, uint8_t vdev_id, 357 wlan_objmgr_ref_dbgid dbg_id); 358 359 /** 360 * wlan_objmgr_get_vdev_by_macaddr_from_pdev() - find vdev using macaddr 361 * @pdev: PDEV object 362 * @macaddr: MAC address 363 * @dbg_id: id of the caller 364 * 365 * API to find vdev object pointer by vdev mac addr from pdev's vdev list 366 * 367 * This API increments the ref count of the vdev object internally, the 368 * caller has to invoke the wlan_objmgr_vdev_release_ref() to decrement 369 * ref count 370 * 371 * Return: vdev pointer 372 * NULL on FAILURE 373 */ 374 struct wlan_objmgr_vdev *wlan_objmgr_get_vdev_by_macaddr_from_pdev( 375 struct wlan_objmgr_pdev *pdev, uint8_t *macaddr, 376 wlan_objmgr_ref_dbgid dbg_id); 377 378 /** 379 * wlan_objmgr_get_vdev_by_macaddr_from_pdev_no_state() - find vdev using 380 * macaddr 381 * @pdev: PDEV object 382 * @macaddr: MAC address 383 * @dbg_id: id of the caller 384 * 385 * API to find vdev object pointer by vdev mac addr from pdev's vdev list 386 * 387 * This API increments the ref count of the vdev object internally, the 388 * caller has to invoke the wlan_objmgr_vdev_release_ref() to decrement 389 * ref count 390 * 391 * Return: vdev pointer 392 * NULL on FAILURE 393 */ 394 struct wlan_objmgr_vdev *wlan_objmgr_get_vdev_by_macaddr_from_pdev_no_state( 395 struct wlan_objmgr_pdev *pdev, uint8_t *macaddr, 396 wlan_objmgr_ref_dbgid dbg_id); 397 398 /** 399 * wlan_objmgr_pdev_get_comp_private_obj() - get pdev component private object 400 * @pdev: PDEV object 401 * @id: Component id 402 * 403 * API to get component private object 404 * 405 * Return: void *ptr on SUCCESS 406 * NULL on Failure 407 */ 408 void *wlan_objmgr_pdev_get_comp_private_obj( 409 struct wlan_objmgr_pdev *pdev, 410 enum wlan_umac_comp_id id); 411 412 /** 413 * wlan_pdev_obj_lock() - Acquire PDEV spinlock 414 * @pdev: PDEV object 415 * 416 * API to acquire PDEV lock 417 * Parent lock should not be taken in child lock context 418 * but child lock can be taken in parent lock context 419 * (for ex: psoc lock can't be invoked in pdev/vdev/peer lock context) 420 * 421 * Return: void 422 */ 423 static inline void wlan_pdev_obj_lock(struct wlan_objmgr_pdev *pdev) 424 { 425 qdf_spin_lock_bh(&pdev->pdev_lock); 426 } 427 428 /** 429 * wlan_pdev_obj_unlock() - Release PDEV spinlock 430 * @pdev: PDEV object 431 * 432 * API to Release PDEV lock 433 * 434 * Return: void 435 */ 436 static inline void wlan_pdev_obj_unlock(struct wlan_objmgr_pdev *pdev) 437 { 438 qdf_spin_unlock_bh(&pdev->pdev_lock); 439 } 440 441 /** 442 * wlan_pdev_get_psoc() - get psoc 443 * @pdev: PDEV object 444 * 445 * API to get the psoc object from PDEV 446 * 447 * Return: 448 * @psoc: PSOC object 449 */ 450 static inline struct wlan_objmgr_psoc *wlan_pdev_get_psoc( 451 struct wlan_objmgr_pdev *pdev) 452 { 453 return pdev->pdev_objmgr.wlan_psoc; 454 } 455 456 /** 457 * wlan_pdev_set_psoc() - set psoc 458 * @pdev: PDEV object 459 * @psoc: PSOC object 460 * 461 * API to set the psoc object from PDEV 462 * 463 * Return: void 464 */ 465 static inline void wlan_pdev_set_psoc(struct wlan_objmgr_pdev *pdev, 466 struct wlan_objmgr_psoc *psoc) 467 { 468 pdev->pdev_objmgr.wlan_psoc = psoc; 469 } 470 471 /** 472 * wlan_pdev_nif_fw_cap_set() - set fw caps 473 * @pdev: PDEV object 474 * @cap: capability flag to be set 475 * 476 * API to set fw caps in pdev 477 * 478 * Return: void 479 */ 480 static inline void wlan_pdev_nif_fw_cap_set(struct wlan_objmgr_pdev *pdev, 481 uint32_t cap) 482 { 483 pdev->pdev_nif.pdev_fw_caps |= cap; 484 } 485 486 /** 487 * wlan_pdev_nif_fw_cap_clear() - clear fw cap 488 * @pdev: PDEV object 489 * @cap: capability flag to be cleared 490 * 491 * API to clear fw caps in pdev 492 * 493 * Return: void 494 */ 495 static inline void wlan_pdev_nif_fw_cap_clear(struct wlan_objmgr_pdev *pdev, 496 uint32_t cap) 497 { 498 pdev->pdev_nif.pdev_fw_caps &= ~cap; 499 } 500 501 /** 502 * wlan_pdev_nif_fw_cap_get() - get fw caps 503 * @pdev: PDEV object 504 * @cap: capability flag to be checked 505 * 506 * API to know, whether particular fw caps flag is set in pdev 507 * 508 * Return: 1 (for set) or 0 (for not set) 509 */ 510 static inline uint8_t wlan_pdev_nif_fw_cap_get(struct wlan_objmgr_pdev *pdev, 511 uint32_t cap) 512 { 513 return (pdev->pdev_nif.pdev_fw_caps & cap) ? 1 : 0; 514 } 515 516 /** 517 * wlan_pdev_nif_feat_cap_set() - set feature caps 518 * @pdev: PDEV object 519 * @cap: capability flag to be set 520 * 521 * API to set feat caps in pdev 522 * 523 * Return: void 524 */ 525 static inline void wlan_pdev_nif_feat_cap_set(struct wlan_objmgr_pdev *pdev, 526 uint32_t cap) 527 { 528 pdev->pdev_nif.pdev_feature_caps |= cap; 529 } 530 531 /** 532 * wlan_pdev_nif_feat_cap_clear() - clear feature caps 533 * @pdev: PDEV object 534 * @cap: capability flag to be cleared 535 * 536 * API to clear feat caps in pdev 537 * 538 * Return: void 539 */ 540 static inline void wlan_pdev_nif_feat_cap_clear(struct wlan_objmgr_pdev *pdev, 541 uint32_t cap) 542 { 543 pdev->pdev_nif.pdev_feature_caps &= ~cap; 544 } 545 546 /** 547 * wlan_pdev_nif_feat_cap_get() - get feature caps 548 * @pdev: PDEV object 549 * @cap: capability flag to be checked 550 * 551 * API to know, whether particular feat caps flag is set in pdev 552 * 553 * Return: 1 (for set) or 0 (for not set) 554 */ 555 static inline uint8_t wlan_pdev_nif_feat_cap_get(struct wlan_objmgr_pdev *pdev, 556 uint32_t cap) 557 { 558 return (pdev->pdev_nif.pdev_feature_caps & cap) ? 1 : 0; 559 } 560 561 /** 562 * wlan_pdev_get_hw_macaddr() - get hw macaddr 563 * @pdev: PDEV object 564 * 565 * API to get HW MAC address form PDEV 566 * 567 * Caller need to acquire lock with wlan_pdev_obj_lock() 568 * 569 * Return: @macaddr -MAC address 570 */ 571 static inline uint8_t *wlan_pdev_get_hw_macaddr(struct wlan_objmgr_pdev *pdev) 572 { 573 struct wlan_objmgr_psoc *psoc = wlan_pdev_get_psoc(pdev); 574 575 /* This API is invoked with lock acquired, do not add log prints */ 576 return wlan_psoc_get_hw_macaddr(psoc); 577 } 578 579 /** 580 * wlan_pdev_set_hw_macaddr() - set hw macaddr 581 * @pdev: PDEV object 582 * @macaddr: MAC address 583 * 584 * API to set HW MAC address form PDEV 585 * 586 * Caller need to acquire lock with wlan_pdev_obj_lock() 587 * 588 * Return: void 589 */ 590 static inline void wlan_pdev_set_hw_macaddr(struct wlan_objmgr_pdev *pdev, 591 uint8_t *macaddr) 592 { 593 struct wlan_objmgr_psoc *psoc = wlan_pdev_get_psoc(pdev); 594 595 /* This API is invoked with lock acquired, do not add log prints */ 596 if (psoc != NULL) 597 wlan_psoc_set_hw_macaddr(psoc, macaddr); 598 } 599 600 /** 601 * wlan_pdev_get_ospriv() - get os priv pointer 602 * @pdev: PDEV object 603 * 604 * API to get OS private pointer from PDEV 605 * 606 * Return: ospriv - private pointer 607 */ 608 static inline struct pdev_osif_priv *wlan_pdev_get_ospriv( 609 struct wlan_objmgr_pdev *pdev) 610 { 611 return pdev->pdev_nif.pdev_ospriv; 612 } 613 614 /** 615 * wlan_pdev_reset_ospriv() - reset os priv pointer 616 * @pdev: PDEV object 617 * 618 * API to reset OS private pointer in PDEV 619 * 620 * Return: void 621 */ 622 static inline void wlan_pdev_reset_ospriv(struct wlan_objmgr_pdev *pdev) 623 { 624 pdev->pdev_nif.pdev_ospriv = NULL; 625 } 626 627 /** 628 * wlan_pdev_set_max_vdev_count() - set pdev max vdev count 629 * @pdev: PDEV object 630 * @vdev count: Max vdev count 631 * 632 * API to set Max vdev count 633 * 634 * Return: void 635 */ 636 static inline void wlan_pdev_set_max_vdev_count(struct wlan_objmgr_pdev *pdev, 637 uint8_t max_vdev_count) 638 { 639 pdev->pdev_objmgr.max_vdev_count = max_vdev_count; 640 } 641 642 /** 643 * wlan_pdev_get_max_vdev_count() - get pdev max vdev count 644 * @pdev: PDEV object 645 * 646 * API to set Max vdev count 647 * 648 * Return: @vdev count: Max vdev count 649 */ 650 static inline uint8_t wlan_pdev_get_max_vdev_count( 651 struct wlan_objmgr_pdev *pdev) 652 { 653 return pdev->pdev_objmgr.max_vdev_count; 654 } 655 656 /** 657 * DOC: Examples to use PDEV ref count APIs 658 * 659 * In all the scenarios, the pair of API should be followed 660 * otherwise it lead to memory leak 661 * 662 * scenario 1: 663 * 664 * wlan_objmgr_pdev_obj_create() 665 * ---- 666 * wlan_objmgr_pdev_obj_delete() 667 * 668 * scenario 2: 669 * 670 * wlan_objmgr_pdev_get_ref() 671 * ---- 672 * the operations which are done on 673 * pdev object 674 * ---- 675 * wlan_objmgr_pdev_release_ref() 676 * 677 * scenario 3: 678 * 679 * wlan_objmgr_get_pdev_by_id[_no_state]() 680 * ---- 681 * the operations which are done on 682 * pdev object 683 * ---- 684 * wlan_objmgr_pdev_release_ref() 685 * 686 * scenario 4: 687 * 688 * wlan_objmgr_get_pdev_by_macaddr[_no_state]() 689 * ---- 690 * the operations which are done on 691 * pdev object 692 * ---- 693 * wlan_objmgr_pdev_release_ref() 694 */ 695 696 /** 697 * wlan_objmgr_pdev_get_ref() - increment ref count 698 * @pdev: PDEV object 699 * @id: Object Manager ref debug id 700 * 701 * API to increment ref count of pdev 702 * 703 * Return: void 704 */ 705 void wlan_objmgr_pdev_get_ref(struct wlan_objmgr_pdev *pdev, 706 wlan_objmgr_ref_dbgid id); 707 708 /** 709 * wlan_objmgr_pdev_try_get_ref() - increment ref count, if allowed 710 * @pdev: PDEV object 711 * @id: Object Manager ref debug id 712 * 713 * API to increment ref count of pdev after checking valid object state 714 * 715 * Return: void 716 */ 717 QDF_STATUS wlan_objmgr_pdev_try_get_ref(struct wlan_objmgr_pdev *pdev, 718 wlan_objmgr_ref_dbgid id); 719 720 /** 721 * wlan_objmgr_pdev_release_ref() - decrement ref count 722 * @pdev: PDEV object 723 * @id: Object Manager ref debug id 724 * 725 * API to decrement ref count of pdev, if ref count is 1, it initiates the 726 * PDEV deletion 727 * 728 * Return: void 729 */ 730 void wlan_objmgr_pdev_release_ref(struct wlan_objmgr_pdev *pdev, 731 wlan_objmgr_ref_dbgid id); 732 733 /** 734 * wlan_objmgr_pdev_get_pdev_id() - get pdev id 735 * @pdev: PDEV object 736 * 737 * API to get pdev id from pdev object 738 * 739 * Return: @pdev id 740 */ 741 static inline 742 uint8_t wlan_objmgr_pdev_get_pdev_id(struct wlan_objmgr_pdev *pdev) 743 { 744 return pdev->pdev_objmgr.wlan_pdev_id; 745 } 746 747 /** 748 * wlan_pdev_set_tgt_if_handle(): API to set target if handle in pdev object 749 * @pdev: Pdev pointer 750 * @tgt_if_handle: target interface handle 751 * 752 * API to set target interface handle in pdev object 753 * 754 * Caller needs to acquire lock with wlan_pdev_obj_lock() 755 * 756 * Return: None 757 */ 758 static inline void wlan_pdev_set_tgt_if_handle(struct wlan_objmgr_pdev *pdev, 759 void *tgt_if_handle) 760 { 761 /* This API is invoked with lock acquired, do not add log prints */ 762 if (pdev == NULL) 763 return; 764 765 pdev->tgt_if_handle = tgt_if_handle; 766 } 767 768 /** 769 * wlan_pdev_get_tgt_if_handle(): API to get target interface handle 770 * @pdev: Pdev pointer 771 * 772 * API to get target interface handle from pdev object 773 * 774 * Return: target interface handle 775 */ 776 static inline void *wlan_pdev_get_tgt_if_handle(struct wlan_objmgr_pdev *pdev) 777 { 778 if (pdev == NULL) 779 return NULL; 780 781 return pdev->tgt_if_handle; 782 } 783 #endif /* _WLAN_OBJMGR_PDEV_H_*/ 784