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