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