1 /* 2 * Copyright (c) 2016-2019 The Linux Foundation. All rights reserved. 3 * 4 * Permission to use, copy, modify, and/or distribute this software for 5 * any purpose with or without fee is hereby granted, provided that the 6 * above copyright notice and this permission notice appear in all 7 * copies. 8 * 9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL 10 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED 11 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE 12 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL 13 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR 14 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER 15 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 16 * PERFORMANCE OF THIS SOFTWARE. 17 */ 18 /** 19 * DOC: Define the peer data structure of UMAC 20 * Public APIs to perform operations on Global objects 21 */ 22 #ifndef _WLAN_OBJMGR_PEER_OBJ_H_ 23 #define _WLAN_OBJMGR_PEER_OBJ_H_ 24 25 #include <qdf_types.h> 26 #include <qdf_atomic.h> 27 #include "wlan_objmgr_vdev_obj.h" 28 29 /* peer flags */ 30 /* authorized for data */ 31 #define WLAN_PEER_F_AUTH 0x00000001 32 /* QoS enabled */ 33 #define WLAN_PEER_F_QOS 0x00000002 34 /* ERP enabled */ 35 #define WLAN_PEER_F_ERP 0x00000004 36 /* HT enabled */ 37 #define WLAN_PEER_F_HT 0x00000008 38 /* NB: tWLANhave the same value as IEEE80211_FC1_PWR_MGT */ 39 /* power save mode enabled */ 40 #define WLAN_PEER_F_PWR_MGT 0x00000010 41 /* keytsc for node has already been updated */ 42 #define WLAN_PEER_F_TSC_SET 0x00000020 43 /* U-APSD power save enabled */ 44 #define WLAN_PEER_F_UAPSD 0x00000040 45 /* U-APSD triggerable state */ 46 #define WLAN_PEER_F_UAPSD_TRIG 0x00000080 47 /* U-APSD SP in progress */ 48 #define WLAN_PEER_F_UAPSD_SP 0x00000100 49 /* Atheros Owl or follow-on device */ 50 #define WLAN_PEER_F_ATH 0x00000200 51 /* Owl WDS workaround needed*/ 52 #define WLAN_PEER_F_OWL_WDSWAR 0x00000400 53 /* WDS link */ 54 #define WLAN_PEER_F_WDS 0x00000800 55 /* No AMPDU support */ 56 #define WLAN_PEER_F_NOAMPDU 0x00001000 57 /* wep/tkip aggregation support */ 58 #define WLAN_PEER_F_WEPTKIPAGGR 0x00002000 59 #define WLAN_PEER_F_WEPTKIP 0x00004000 60 /* temp node (not in the node table) */ 61 #define WLAN_PEER_F_TEMP 0x00008000 62 /* 2.4ng VHT interop AMSDU disabled */ 63 #define WLAN_PEER_F_11NG_VHT_INTEROP_AMSDU_DISABLE 0x00010000 64 /* 40 MHz Intolerant */ 65 #define WLAN_PEER_F_40MHZ_INTOLERANT 0x00020000 66 /* node is paused*/ 67 #define WLAN_PEER_F_PAUSED 0x00040000 68 #define WLAN_PEER_F_EXTRADELIMWAR 0x00080000 69 /* 20 MHz requesting node */ 70 #define WLAN_PEER_F_REQ_20MHZ 0x00100000 71 /* all the tid queues in ath layer are paused*/ 72 #define WLAN_PEER_F_ATH_PAUSED 0x00200000 73 /*Require credit update*/ 74 #define WLAN_PEER_F_UAPSD_CREDIT_UPDATE 0x00400000 75 /*Require send deauth when h/w queue no data*/ 76 #define WLAN_PEER_F_KICK_OUT_DEAUTH 0x00800000 77 /* RRM enabled node */ 78 #define WLAN_PEER_F_RRM 0x01000000 79 /* Wakeup node */ 80 #define WLAN_PEER_F_WAKEUP 0x02000000 81 /* VHT enabled node */ 82 #define WLAN_PEER_F_VHT 0x04000000 83 /* deauth/Disassoc wait for node cleanup till frame goes on 84 air and tx feedback received */ 85 #define WLAN_PEER_F_DELAYED_CLEANUP 0x08000000 86 /* Extended stats enabled node */ 87 #define WLAN_PEER_F_EXT_STATS 0x10000000 88 /* Prevent _ieee80211_node_leave() from reentry */ 89 #define WLAN_PEER_F_LEAVE_ONGOING 0x20000000 90 /* band steering is enabled for this node */ 91 #define WLAN_PEER_F_BSTEERING_CAPABLE 0x40000000 92 /* node is a local mesh peer */ 93 #define WLAN_PEER_F_LOCAL_MESH_PEER 0x80000000 94 95 /** 96 * enum wlan_peer_state - peer state 97 * @WLAN_INIT_STATE: Default state 98 * @WLAN_JOIN_STATE: Station mode, STA is waiting for Join 99 * @WLAN_AUTH_STATE: AUTH in progress 100 * @WLAN_ASSOC_STATE: ASSOC in progress 101 * @WLAN_WAITKEY_STATE: 4-way KEY handshake is in progress 102 * @WLAN_CONNECTED_STATE: Connected state 103 * @WLAN_PREAUTH_STATE: Station mode: Preauth 104 * @WLAN_DISCONNECT_STATE: Disconnect is in progress 105 */ 106 enum wlan_peer_state { 107 WLAN_INIT_STATE = 1, 108 WLAN_JOIN_STATE = 2, 109 WLAN_AUTH_STATE = 3, 110 WLAN_ASSOC_STATE = 4, 111 WLAN_WAITKEY_STATE = 5, 112 WLAN_CONNECTED_STATE = 6, 113 WLAN_PREAUTH_STATE = 7, 114 WLAN_DISCONNECT_STATE = 8, 115 }; 116 117 /** 118 * struct wlan_objmgr_peer_mlme - mlme common data of peer 119 * @peer_capinfo: protocol cap info 120 * @peer_flags: PEER OP flags 121 * @peer_type: Type of PEER, (STA/AP/etc.) 122 * @phymode: phy mode of station 123 * @max_rate: Max Rate supported 124 * @state: State of the peer 125 * @seq_num: Sequence number 126 * @rssi: Last received RSSI value 127 */ 128 struct wlan_objmgr_peer_mlme { 129 uint32_t peer_capinfo; 130 uint32_t peer_flags; 131 enum wlan_peer_type peer_type; 132 enum wlan_phymode phymode; 133 uint32_t max_rate; 134 enum wlan_peer_state state; 135 uint16_t seq_num; 136 int8_t rssi; 137 bool is_authenticated; 138 }; 139 140 /** 141 * struct wlan_objmgr_peer_objmgr - object manager data of peer 142 * @vdev: VDEV pointer to which it is associated 143 * @ref_cnt: Ref count 144 * @ref_id_dbg: Array to track Ref count 145 * @print_cnt: Count to throttle Logical delete prints 146 * @wlan_objmgr_trace: Trace ref and deref 147 */ 148 struct wlan_objmgr_peer_objmgr { 149 struct wlan_objmgr_vdev *vdev; 150 qdf_atomic_t ref_cnt; 151 #ifdef WLAN_OBJMGR_REF_ID_DEBUG 152 qdf_atomic_t ref_id_dbg[WLAN_REF_ID_MAX]; 153 #endif 154 uint8_t print_cnt; 155 #ifdef WLAN_OBJMGR_REF_ID_TRACE 156 struct wlan_objmgr_trace trace; 157 #endif 158 }; 159 160 /** 161 * struct wlan_objmgr_peer - PEER common object 162 * @psoc_peer: peer list node for psoc's qdf list 163 * @vdev_peer: peer list node for vdev's qdf list 164 * @macaddr[]: Peer MAC address 165 * @peer_mlme: Peer MLME common structure 166 * @peer_objmgr: Peer Object manager common structure 167 * @peer_comp_priv_obj[]: Component's private object pointers 168 * @obj_status[]: status of each component object 169 * @obj_state: Status of Peer object 170 * @dp_handle: DP module handle 171 * @pdev_id: Pdev ID 172 * @peer_lock: Lock for access/update peer contents 173 */ 174 struct wlan_objmgr_peer { 175 qdf_list_node_t psoc_peer; 176 qdf_list_node_t vdev_peer; 177 uint8_t macaddr[QDF_MAC_ADDR_SIZE]; 178 uint8_t pdev_id; 179 struct wlan_objmgr_peer_mlme peer_mlme; 180 struct wlan_objmgr_peer_objmgr peer_objmgr; 181 void *peer_comp_priv_obj[WLAN_UMAC_MAX_COMPONENTS]; 182 QDF_STATUS obj_status[WLAN_UMAC_MAX_COMPONENTS]; 183 WLAN_OBJ_STATE obj_state; 184 void *dp_handle; 185 qdf_spinlock_t peer_lock; 186 }; 187 188 /** 189 ** APIs to Create/Delete Global object APIs 190 */ 191 /** 192 * wlan_objmgr_peer_obj_create() - peer object create 193 * @vdev: VDEV object on which this peer gets created 194 * @peer_type: peer type (AP/STA) 195 * @macaddr: MAC address 196 * 197 * Creates Peer object, intializes with default values 198 * Attaches to psoc and vdev objects 199 * Invokes the registered notifiers to create component object 200 * 201 * Return: Handle to struct wlan_objmgr_peer on successful creation, 202 * NULL on Failure (on Mem alloc failure and Component objects 203 * Failure) 204 */ 205 struct wlan_objmgr_peer *wlan_objmgr_peer_obj_create( 206 struct wlan_objmgr_vdev *vdev, 207 enum wlan_peer_type type, 208 uint8_t macaddr[]); 209 210 /** 211 * wlan_objmgr_peer_obj_delete() - peer object delete 212 * @peer: PEER object 213 * 214 * Deletes PEER object, removes it from PSOC's, VDEV's peer list 215 * Invokes the registered notifiers to destroy component objects 216 * 217 * Return: SUCCESS/FAILURE 218 */ 219 QDF_STATUS wlan_objmgr_peer_obj_delete(struct wlan_objmgr_peer *peer); 220 221 /** 222 ** APIs to attach/detach component objects 223 */ 224 /** 225 * wlan_objmgr_peer_component_obj_attach() - attach comp object to peer 226 * @peer: PEER object 227 * @id: Component id 228 * @comp_priv_obj: component's private object pointer 229 * @status: Component's private object creation status 230 * 231 * API to be used for attaching component object with PEER common object 232 * 233 * Return: SUCCESS on successful storing of component's object in common object 234 * On FAILURE (appropriate failure codes are returned) 235 */ 236 QDF_STATUS wlan_objmgr_peer_component_obj_attach( 237 struct wlan_objmgr_peer *peer, 238 enum wlan_umac_comp_id id, 239 void *comp_priv_obj, 240 QDF_STATUS status); 241 242 /** 243 * wlan_objmgr_peer_component_obj_detach() - detach comp object from peer 244 * @peer: PEER object 245 * @id: Component id 246 * @comp_priv_obj: component's private object pointer 247 * 248 * API to be used for detaching component object with PEER common object 249 * 250 * Return: SUCCESS on successful removal of component's object from common 251 * object 252 * On FAILURE (appropriate failure codes are returned) 253 */ 254 QDF_STATUS wlan_objmgr_peer_component_obj_detach( 255 struct wlan_objmgr_peer *peer, 256 enum wlan_umac_comp_id id, 257 void *comp_priv_obj); 258 259 /** 260 ** APIs to operations on peer objects 261 */ 262 263 /** 264 * wlan_objmgr_trigger_peer_comp_priv_object_creation() - create 265 * peer comp object 266 * @peer: PEER object 267 * @id: Component id 268 * 269 * API to create component private object in run time, this would 270 * be used for features which gets enabled in run time 271 * 272 * Return: SUCCESS on successful creation 273 * On FAILURE (appropriate failure codes are returned) 274 */ 275 QDF_STATUS wlan_objmgr_trigger_peer_comp_priv_object_creation( 276 struct wlan_objmgr_peer *peer, 277 enum wlan_umac_comp_id id); 278 279 /** 280 * wlan_objmgr_trigger_peer_comp_priv_object_deletion() - destroy 281 * peer comp object 282 * @peer: PEER object 283 * @id: Component id 284 * 285 * API to destroy component private object in run time, this would 286 * be used for features which gets disabled in run time 287 * 288 * Return: SUCCESS on successful deletion 289 * On FAILURE (appropriate failure codes are returned) 290 */ 291 QDF_STATUS wlan_objmgr_trigger_peer_comp_priv_object_deletion( 292 struct wlan_objmgr_peer *peer, 293 enum wlan_umac_comp_id id); 294 295 /** 296 * wlan_objmgr_peer_get_comp_private_obj() - get peer component private object 297 * @peer: PEER object 298 * @id: Component id 299 * 300 * API to get component private object 301 * 302 * Return: void *ptr on SUCCESS 303 * NULL on Failure 304 */ 305 void *wlan_objmgr_peer_get_comp_private_obj( 306 struct wlan_objmgr_peer *peer, 307 enum wlan_umac_comp_id id); 308 309 /** 310 * wlan_peer_obj_lock() - Acquire PEER spinlock 311 * @psoc: PEER object 312 * 313 * API to acquire PEER spin lock 314 * Parent lock should not be taken in child lock context 315 * but child lock can be taken in parent lock context 316 * (for ex: psoc lock can't be invoked in pdev/vdev/peer lock context) 317 * 318 * Return: void 319 */ 320 static inline void wlan_peer_obj_lock(struct wlan_objmgr_peer *peer) 321 { 322 qdf_spin_lock_bh(&peer->peer_lock); 323 } 324 325 /** 326 * wlan_peer_obj_unlock() - Release PEER spinlock 327 * @peer: PEER object 328 * 329 * API to Release PEER spin lock 330 * 331 * Return: void 332 */ 333 static inline void wlan_peer_obj_unlock(struct wlan_objmgr_peer *peer) 334 { 335 qdf_spin_unlock_bh(&peer->peer_lock); 336 } 337 338 /** 339 * DOC: Examples to use PEER ref count APIs 340 * 341 * In all the scenarios, the pair of API should be followed 342 * other it lead to memory leak 343 * 344 * scenario 1: 345 * 346 * wlan_objmgr_peer_obj_create() 347 * ---- 348 * wlan_objmgr_peer_obj_delete() 349 * 350 * scenario 2: 351 * 352 * wlan_objmgr_peer_get_ref() 353 * ---- 354 * the operations which are done on 355 * peer object 356 * ---- 357 * wlan_objmgr_peer_release_ref() 358 * 359 * scenario 3: 360 * 361 * API to retrieve peer (xxx_get_peer_xxx()) 362 * ---- 363 * the operations which are done on 364 * peer object 365 * ---- 366 * wlan_objmgr_peer_release_ref() 367 */ 368 369 /** 370 * wlan_objmgr_peer_get_ref() - increment ref count 371 * @peer: PEER object 372 * @id: Object Manager ref debug id 373 * 374 * API to increment ref count of peer 375 * 376 * Return: void 377 */ 378 #ifdef WLAN_OBJMGR_REF_ID_TRACE 379 void wlan_objmgr_peer_get_ref_debug(struct wlan_objmgr_peer *peer, 380 wlan_objmgr_ref_dbgid id, 381 const char *func, int line); 382 383 #define wlan_objmgr_peer_get_ref(peer, dbgid) \ 384 wlan_objmgr_peer_get_ref_debug(peer, dbgid, __func__, __LINE__) 385 #else 386 void wlan_objmgr_peer_get_ref(struct wlan_objmgr_peer *peer, 387 wlan_objmgr_ref_dbgid id); 388 #endif 389 390 /** 391 * wlan_objmgr_peer_try_get_ref() - increment ref count, if allowed 392 * @peer: PEER object 393 * @id: Object Manager ref debug id 394 * 395 * API to increment ref count of peer, if object state is valid 396 * 397 * Return: void 398 */ 399 #ifdef WLAN_OBJMGR_REF_ID_TRACE 400 QDF_STATUS wlan_objmgr_peer_try_get_ref_debug(struct wlan_objmgr_peer *peer, 401 wlan_objmgr_ref_dbgid id, 402 const char *func, int line); 403 404 #define wlan_objmgr_peer_try_get_ref(peer, dbgid) \ 405 wlan_objmgr_peer_try_get_ref_debug(peer, dbgid, \ 406 __func__, __LINE__) 407 #else 408 QDF_STATUS wlan_objmgr_peer_try_get_ref(struct wlan_objmgr_peer *peer, 409 wlan_objmgr_ref_dbgid id); 410 #endif 411 412 /** 413 * wlan_objmgr_peer_release_ref() - decrement ref count 414 * @peer: PEER object 415 * @id: Object Manager ref debug id 416 * 417 * API to decrement ref count of peer, if ref count is 1, it initiates the 418 * peer deletion 419 * 420 * Return: void 421 */ 422 #ifdef WLAN_OBJMGR_REF_ID_TRACE 423 void wlan_objmgr_peer_release_ref_debug(struct wlan_objmgr_peer *peer, 424 wlan_objmgr_ref_dbgid id, 425 const char *func, int line); 426 427 #define wlan_objmgr_peer_release_ref(peer, dbgid) \ 428 wlan_objmgr_peer_release_ref_debug(peer, dbgid, \ 429 __func__, __LINE__) 430 #else 431 void wlan_objmgr_peer_release_ref(struct wlan_objmgr_peer *peer, 432 wlan_objmgr_ref_dbgid id); 433 #endif 434 435 /** 436 * wlan_peer_get_next_peer_of_psoc_ref() - get next peer to psoc peer list 437 * with lock and ref taken 438 * @peer_list: Peer list 439 * @hash_index: peer list hash index 440 * @peer: PEER object 441 * @dbg_id: Ref count debug module id 442 * 443 * API to get the next peer of given peer (of psoc's peer list) 444 * 445 * Return: 446 * @next_peer: PEER object 447 */ 448 #ifdef WLAN_OBJMGR_REF_ID_TRACE 449 struct wlan_objmgr_peer *wlan_peer_get_next_peer_of_psoc_ref_debug( 450 struct wlan_peer_list *peer_list, 451 uint8_t hash_index, 452 struct wlan_objmgr_peer *peer, 453 wlan_objmgr_ref_dbgid dbg_id, 454 const char *func, int line); 455 456 #define wlan_peer_get_next_peer_of_psoc_ref(peer_list, hash_index, peer, \ 457 dbgid) \ 458 wlan_peer_get_next_peer_of_psoc_ref_debug(peer_list, \ 459 hash_index, peer, dbgid, __func__, __LINE__) 460 #else 461 struct wlan_objmgr_peer *wlan_peer_get_next_peer_of_psoc_ref( 462 struct wlan_peer_list *peer_list, 463 uint8_t hash_index, 464 struct wlan_objmgr_peer *peer, 465 wlan_objmgr_ref_dbgid dbg_id); 466 #endif 467 468 /** 469 * wlan_peer_get_next_active_peer_of_psoc() - get next active peer to psoc peer 470 * list 471 * @peer_list: Peer list 472 * @hash_index: peer list hash index 473 * @peer: PEER object 474 * @dbg_id: Ref count debug module id 475 * 476 * API to get the next peer of given peer (of psoc's peer list) 477 * 478 * Return: 479 * @next_peer: PEER object 480 */ 481 #ifdef WLAN_OBJMGR_REF_ID_TRACE 482 struct wlan_objmgr_peer *wlan_peer_get_next_active_peer_of_psoc_debug( 483 struct wlan_peer_list *peer_list, 484 uint8_t hash_index, 485 struct wlan_objmgr_peer *peer, 486 wlan_objmgr_ref_dbgid dbg_id, 487 const char *func, int line); 488 489 #define wlan_peer_get_next_active_peer_of_psoc(peer_list, hash_index, \ 490 peer, dbgid) \ 491 wlan_peer_get_next_active_peer_of_psoc_debug(peer_list, \ 492 hash_index, peer, dbgid, __func__, __LINE__) 493 #else 494 struct wlan_objmgr_peer *wlan_peer_get_next_active_peer_of_psoc( 495 struct wlan_peer_list *peer_list, 496 uint8_t hash_index, 497 struct wlan_objmgr_peer *peer, 498 wlan_objmgr_ref_dbgid dbg_id); 499 #endif 500 501 /** 502 * wlan_peer_get_next_active_peer_of_vdev() - get next active_peer of vdev list 503 * @vdev: VDEV object 504 * @peer_list: Peer object list 505 * @peer: PEER object 506 * @dbg_id: Ref count debug module id 507 * 508 * API to get the next active peer of given peer (of vdev's peer list) 509 * 510 * Return: 511 * @next_peer: PEER object 512 */ 513 #ifdef WLAN_OBJMGR_REF_ID_TRACE 514 struct wlan_objmgr_peer *wlan_peer_get_next_active_peer_of_vdev_debug( 515 struct wlan_objmgr_vdev *vdev, 516 qdf_list_t *peer_list, 517 struct wlan_objmgr_peer *peer, 518 wlan_objmgr_ref_dbgid dbg_id, 519 const char *func, int line); 520 521 #define wlan_peer_get_next_active_peer_of_vdev(vdev, peer_list, peer, dbgid) \ 522 wlan_peer_get_next_active_peer_of_vdev_debug(vdev, peer_list, \ 523 peer, dbgid, __func__, __LINE__) 524 #else 525 struct wlan_objmgr_peer *wlan_peer_get_next_active_peer_of_vdev( 526 struct wlan_objmgr_vdev *vdev, 527 qdf_list_t *peer_list, 528 struct wlan_objmgr_peer *peer, 529 wlan_objmgr_ref_dbgid dbg_id); 530 #endif 531 532 /** 533 * wlan_vdev_peer_list_peek_active_head() - get active head of vdev peer list 534 * @vdev: VDEV object 535 * @peer_list: qdf_list_t 536 * @dbg_id: Ref count debug module id 537 * 538 * API to get the active head peer of given peer (of vdev's peer list) 539 * 540 * Return: 541 * @peer: active head peer 542 */ 543 #ifdef WLAN_OBJMGR_REF_ID_TRACE 544 struct wlan_objmgr_peer *wlan_vdev_peer_list_peek_active_head_debug( 545 struct wlan_objmgr_vdev *vdev, 546 qdf_list_t *peer_list, 547 wlan_objmgr_ref_dbgid dbg_id, 548 const char *func, int line); 549 550 #define wlan_vdev_peer_list_peek_active_head(vdev, peer_list, dbgid) \ 551 wlan_vdev_peer_list_peek_active_head_debug(vdev, peer_list, \ 552 dbgid, __func__, __LINE__) 553 #else 554 struct wlan_objmgr_peer *wlan_vdev_peer_list_peek_active_head( 555 struct wlan_objmgr_vdev *vdev, 556 qdf_list_t *peer_list, 557 wlan_objmgr_ref_dbgid dbg_id); 558 #endif 559 560 /** 561 * wlan_psoc_peer_list_peek_head_ref() - get head of psoc peer list 562 * with ref and lock protected 563 * @peer_list: wlan_peer_list 564 * @hash_index: peer list hash index 565 * @dbg_id: Ref count debug module id 566 * 567 * API to get the head peer of given peer (of psoc's peer list) 568 * 569 * Return: 570 * @peer: head peer 571 */ 572 #ifdef WLAN_OBJMGR_REF_ID_TRACE 573 struct wlan_objmgr_peer *wlan_psoc_peer_list_peek_head_ref_debug( 574 struct wlan_peer_list *peer_list, 575 uint8_t hash_index, 576 wlan_objmgr_ref_dbgid dbg_id, 577 const char *func, int line); 578 579 #define wlan_psoc_peer_list_peek_head_ref(peer_list, hash_index, dbgid) \ 580 wlan_psoc_peer_list_peek_head_ref_debug(peer_list, hash_index, \ 581 dbgid, __func__, __LINE__) 582 #else 583 struct wlan_objmgr_peer *wlan_psoc_peer_list_peek_head_ref( 584 struct wlan_peer_list *peer_list, 585 uint8_t hash_index, 586 wlan_objmgr_ref_dbgid dbg_id); 587 #endif 588 589 /** 590 * wlan_psoc_peer_list_peek_active_head() - get active head of psoc peer list 591 * @peer_list: wlan_peer_list 592 * @hash_index: peer list hash index 593 * @dbg_id: Ref count debug module id 594 * 595 * API to get the head peer of given peer (of psoc's peer list) 596 * 597 * Return: 598 * @peer: head peer 599 */ 600 #ifdef WLAN_OBJMGR_REF_ID_TRACE 601 struct wlan_objmgr_peer *wlan_psoc_peer_list_peek_active_head_debug( 602 struct wlan_peer_list *peer_list, 603 uint8_t hash_index, 604 wlan_objmgr_ref_dbgid dbg_id, 605 const char *func, int line); 606 607 #define wlan_psoc_peer_list_peek_active_head(peer_list, hash_index, dbgid) \ 608 wlan_psoc_peer_list_peek_active_head_debug(peer_list, \ 609 hash_index, dbgid, __func__, __LINE__) 610 #else 611 struct wlan_objmgr_peer *wlan_psoc_peer_list_peek_active_head( 612 struct wlan_peer_list *peer_list, 613 uint8_t hash_index, 614 wlan_objmgr_ref_dbgid dbg_id); 615 #endif 616 617 /** 618 * wlan_psoc_peer_list_peek_head() - get head of psoc peer list 619 * @peer_list: qdf_list_t 620 * 621 * API to get the head peer of given peer (of psoc's peer list) 622 * 623 * Caller need to acquire lock with wlan_peer_obj_lock() 624 * 625 * Return: 626 * @peer: head peer 627 */ 628 static inline struct wlan_objmgr_peer *wlan_psoc_peer_list_peek_head( 629 qdf_list_t *peer_list) 630 { 631 struct wlan_objmgr_peer *peer; 632 qdf_list_node_t *psoc_node = NULL; 633 634 /* This API is invoked with lock acquired, do not add log prints */ 635 if (qdf_list_peek_front(peer_list, &psoc_node) != QDF_STATUS_SUCCESS) 636 return NULL; 637 638 peer = qdf_container_of(psoc_node, struct wlan_objmgr_peer, psoc_peer); 639 return peer; 640 } 641 642 /** 643 * wlan_vdev_peer_list_peek_head() - get head of vdev peer list 644 * @peer_list: qdf_list_t 645 * 646 * API to get the head peer of given peer (of vdev's peer list) 647 * 648 * Caller need to acquire lock with wlan_peer_obj_lock() 649 * 650 * Return: 651 * @peer: head peer 652 */ 653 static inline struct wlan_objmgr_peer *wlan_vdev_peer_list_peek_head( 654 qdf_list_t *peer_list) 655 { 656 struct wlan_objmgr_peer *peer; 657 qdf_list_node_t *vdev_node = NULL; 658 659 /* This API is invoked with lock acquired, do not add log prints */ 660 if (qdf_list_peek_front(peer_list, &vdev_node) != QDF_STATUS_SUCCESS) 661 return NULL; 662 663 peer = qdf_container_of(vdev_node, struct wlan_objmgr_peer, vdev_peer); 664 return peer; 665 } 666 667 /** 668 * wlan_peer_get_next_peer_of_vdev() - get next peer of vdev list 669 * @peer: PEER object 670 * 671 * API to get the next peer of given peer (of vdev's peer list) 672 * 673 * Caller need to acquire lock with wlan_peer_obj_lock() 674 * 675 * Return: 676 * @next_peer: PEER object 677 */ 678 static inline struct wlan_objmgr_peer *wlan_peer_get_next_peer_of_vdev( 679 qdf_list_t *peer_list, struct wlan_objmgr_peer *peer) 680 { 681 struct wlan_objmgr_peer *peer_next; 682 qdf_list_node_t *node; 683 qdf_list_node_t *next_node = NULL; 684 685 /* This API is invoked with lock acquired, do not add log prints */ 686 if (!peer) 687 return NULL; 688 689 node = &peer->vdev_peer; 690 if (qdf_list_peek_next(peer_list, node, &next_node) != 691 QDF_STATUS_SUCCESS) 692 return NULL; 693 694 peer_next = qdf_container_of(next_node, struct wlan_objmgr_peer, 695 vdev_peer); 696 return peer_next; 697 } 698 699 /** 700 * wlan_peer_set_next_peer_of_vdev() - add peer to vdev peer list 701 * @peer: PEER object 702 * @new_peer: PEER object 703 * 704 * API to set as the next peer to given peer (of vdev's peer list) 705 * 706 * Caller need to acquire lock with wlan_peer_obj_lock() 707 * 708 * Return: void 709 */ 710 static inline void wlan_peer_set_next_peer_of_vdev(qdf_list_t *peer_list, 711 struct wlan_objmgr_peer *new_peer) 712 { 713 /* This API is invoked with lock acquired, do not add log prints */ 714 /* set next peer with new peer */ 715 qdf_list_insert_back(peer_list, &new_peer->vdev_peer); 716 return; 717 } 718 719 /** 720 * wlan_peer_get_next_peer_of_psoc() - get next peer to psoc peer list 721 * @peer_list: Peer list 722 * @peer: PEER object 723 * 724 * API to get the next peer of given peer (of psoc's peer list) 725 * 726 * Caller need to acquire lock with wlan_peer_obj_lock() 727 * 728 * Return: 729 * @next_peer: PEER object 730 */ 731 static inline struct wlan_objmgr_peer *wlan_peer_get_next_peer_of_psoc( 732 qdf_list_t *peer_list, struct wlan_objmgr_peer *peer) 733 { 734 struct wlan_objmgr_peer *peer_next; 735 qdf_list_node_t *node = NULL; 736 qdf_list_node_t *next_node = NULL; 737 738 /* This API is invoked with lock acquired, do not add log prints */ 739 if (!peer) 740 return NULL; 741 742 node = &peer->psoc_peer; 743 if (qdf_list_peek_next(peer_list, node, &next_node) != 744 QDF_STATUS_SUCCESS) 745 return NULL; 746 747 peer_next = qdf_container_of(next_node, struct wlan_objmgr_peer, 748 psoc_peer); 749 return peer_next; 750 } 751 752 /** 753 * wlan_peer_set_next_peer_of_psoc() - add peer to psoc peer list 754 * @peer: PEER object 755 * @new_peer: PEER object 756 * 757 * API to set as the next peer to given peer (of psoc's peer list) 758 * 759 * Caller need to acquire lock with wlan_peer_obj_lock() 760 * 761 * Return: void 762 */ 763 static inline void wlan_peer_set_next_peer_of_psoc(qdf_list_t *peer_list, 764 struct wlan_objmgr_peer *new_peer) 765 { 766 /* This API is invoked with lock acquired, do not add log prints */ 767 /* set next peer with new peer */ 768 qdf_list_insert_back(peer_list, &new_peer->psoc_peer); 769 return; 770 } 771 772 /** 773 * wlan_peer_set_peer_type() - set peer type 774 * @peer: PEER object 775 * @peer_type: type of PEER 776 * 777 * API to set peer type 778 * 779 * Return: void 780 */ 781 static inline void wlan_peer_set_peer_type(struct wlan_objmgr_peer *peer, 782 enum wlan_peer_type type) 783 { 784 peer->peer_mlme.peer_type = type; 785 } 786 787 /** 788 * wlan_peer_get_peer_type() - get peer type 789 * @peer: PEER object 790 * 791 * API to get peer type 792 * 793 * Return: 794 * @peer_type: type of PEER 795 */ 796 static inline enum wlan_peer_type wlan_peer_get_peer_type( 797 struct wlan_objmgr_peer *peer) 798 { 799 return peer->peer_mlme.peer_type; 800 } 801 802 /** 803 * wlan_peer_set_phymode() - set phymode 804 * @peer: PEER object 805 * @phymode: phymode of peer 806 * 807 * API to set phymode 808 * 809 * Return: void 810 */ 811 static inline void wlan_peer_set_phymode(struct wlan_objmgr_peer *peer, 812 enum wlan_phymode phymode) 813 { 814 peer->peer_mlme.phymode = phymode; 815 } 816 817 /** 818 * wlan_peer_get_phymode() - get phymode 819 * @peer: PEER object 820 * 821 * API to get phymode 822 * 823 * Return: 824 * @phymode: phymode of PEER 825 */ 826 static inline enum wlan_phymode wlan_peer_get_phymode( 827 struct wlan_objmgr_peer *peer) 828 { 829 return peer->peer_mlme.phymode; 830 } 831 832 833 /** 834 * wlan_peer_set_macaddr() - set mac addr 835 * @peer: PEER object 836 * @macaddr: MAC address 837 * 838 * API to set peer mac address 839 * 840 * Caller need to acquire lock with wlan_peer_obj_lock() 841 * 842 * Return: void 843 */ 844 static inline void wlan_peer_set_macaddr(struct wlan_objmgr_peer *peer, 845 uint8_t *macaddr) 846 { 847 /* This API is invoked with lock acquired, do not add log prints */ 848 WLAN_ADDR_COPY(peer->macaddr, macaddr); 849 } 850 851 /** 852 * wlan_peer_get_macaddr() - get mac addr 853 * @peer: PEER object 854 * 855 * API to get peer mac address 856 * 857 * Caller need to acquire lock with wlan_peer_obj_lock() 858 * 859 * Return: 860 * @macaddr: MAC address 861 */ 862 static inline uint8_t *wlan_peer_get_macaddr(struct wlan_objmgr_peer *peer) 863 { 864 /* This API is invoked with lock acquired, do not add log prints */ 865 return peer->macaddr; 866 } 867 868 /** 869 * wlan_peer_get_vdev() - get vdev 870 * @peer: PEER object 871 * 872 * API to get peer's vdev 873 * 874 * Return: 875 * @vdev: VDEV object 876 */ 877 static inline struct wlan_objmgr_vdev *wlan_peer_get_vdev( 878 struct wlan_objmgr_peer *peer) 879 { 880 return peer->peer_objmgr.vdev; 881 } 882 883 /** 884 * wlan_peer_set_vdev() - set vdev 885 * @peer: PEER object 886 * @vdev: VDEV object 887 * 888 * API to set peer's vdev 889 * 890 * Return: void 891 */ 892 static inline void wlan_peer_set_vdev(struct wlan_objmgr_peer *peer, 893 struct wlan_objmgr_vdev *vdev) 894 { 895 peer->peer_objmgr.vdev = vdev; 896 } 897 898 /** 899 * wlan_peer_mlme_flag_set() - mlme flag set 900 * @peer: PEER object 901 * @flag: flag to be set 902 * 903 * API to set flag in peer 904 * 905 * Return: void 906 */ 907 static inline void wlan_peer_mlme_flag_set(struct wlan_objmgr_peer *peer, 908 uint32_t flag) 909 { 910 peer->peer_mlme.peer_flags |= flag; 911 } 912 913 /** 914 * wlan_peer_mlme_flag_clear() - mlme flag clear 915 * @peer: PEER object 916 * @flag: flag to be cleared 917 * 918 * API to clear flag in peer 919 * 920 * Return: void 921 */ 922 static inline void wlan_peer_mlme_flag_clear(struct wlan_objmgr_peer *peer, 923 uint32_t flag) 924 { 925 peer->peer_mlme.peer_flags &= ~flag; 926 } 927 928 /** 929 * wlan_peer_mlme_flag_get() - mlme flag get 930 * @peer: PEER object 931 * @flag: flag to be checked 932 * 933 * API to know, whether particular flag is set in peer 934 * 935 * Return: 1 (for set) or 0 (for not set) 936 */ 937 static inline uint8_t wlan_peer_mlme_flag_get(struct wlan_objmgr_peer *peer, 938 uint32_t flag) 939 { 940 return (peer->peer_mlme.peer_flags & flag) ? 1 : 0; 941 } 942 943 /** 944 * wlan_peer_mlme_set_state() - peer mlme state 945 * @peer: PEER object 946 * @state: enum wlan_peer_state 947 * 948 * API to update the current peer state 949 * 950 * Return: void 951 */ 952 static inline void wlan_peer_mlme_set_state( 953 struct wlan_objmgr_peer *peer, 954 enum wlan_peer_state state) 955 { 956 peer->peer_mlme.state = state; 957 } 958 959 /** 960 * wlan_peer_mlme_set_auth_state() - peer mlme auth state 961 * @peer: PEER object 962 * @is_authenticated: true or false 963 * 964 * API to update the current peer auth state 965 * 966 * Return: void 967 */ 968 static inline void wlan_peer_mlme_set_auth_state( 969 struct wlan_objmgr_peer *peer, 970 bool is_authenticated) 971 { 972 peer->peer_mlme.is_authenticated = is_authenticated; 973 } 974 975 /** 976 * wlan_peer_mlme_get_state() - peer mlme state 977 * @peer: PEER object 978 * 979 * API to get peer state 980 * 981 * Return: enum wlan_peer_state 982 */ 983 static inline enum wlan_peer_state wlan_peer_mlme_get_state( 984 struct wlan_objmgr_peer *peer) 985 { 986 return peer->peer_mlme.state; 987 } 988 989 /** 990 * wlan_peer_mlme_get_auth_state() - peer mlme auth state 991 * @peer: PEER object 992 * 993 * API to get peer auth state 994 * 995 * Return: auth state true/false 996 */ 997 static inline bool wlan_peer_mlme_get_auth_state( 998 struct wlan_objmgr_peer *peer) 999 { 1000 return peer->peer_mlme.is_authenticated; 1001 } 1002 1003 /** 1004 * wlan_peer_mlme_get_next_seq_num() - get peer mlme next sequence number 1005 * @peer: PEER object 1006 * 1007 * API to get mlme peer next sequence number 1008 * 1009 * Caller need to acquire lock with wlan_peer_obj_lock() 1010 * 1011 * Return: peer mlme next sequence number 1012 */ 1013 static inline uint32_t wlan_peer_mlme_get_next_seq_num( 1014 struct wlan_objmgr_peer *peer) 1015 { 1016 /* This API is invoked with lock acquired, do not add log prints */ 1017 if (peer->peer_mlme.seq_num < WLAN_MAX_SEQ_NUM) 1018 peer->peer_mlme.seq_num++; 1019 else 1020 peer->peer_mlme.seq_num = 0; 1021 1022 return peer->peer_mlme.seq_num; 1023 } 1024 1025 /** 1026 * wlan_peer_mlme_get_seq_num() - get peer mlme sequence number 1027 * @peer: PEER object 1028 * 1029 * API to get mlme peer sequence number 1030 * 1031 * Caller need to acquire lock with wlan_peer_obj_lock() 1032 * 1033 * Return: peer mlme sequence number 1034 */ 1035 static inline uint32_t wlan_peer_mlme_get_seq_num( 1036 struct wlan_objmgr_peer *peer) 1037 { 1038 /* This API is invoked with lock acquired, do not add log prints */ 1039 return peer->peer_mlme.seq_num; 1040 } 1041 1042 /** 1043 * wlan_peer_mlme_reset_seq_num() - reset peer mlme sequence number 1044 * @peer: PEER object 1045 * 1046 * API to reset peer sequence number 1047 * 1048 * Caller need to acquire lock with wlan_peer_obj_lock() 1049 * 1050 * Return: void 1051 */ 1052 static inline void wlan_peer_mlme_reset_seq_num( 1053 struct wlan_objmgr_peer *peer) 1054 { 1055 /* This API is invoked with lock acquired, do not add log prints */ 1056 peer->peer_mlme.seq_num = 0; 1057 } 1058 1059 /** 1060 * wlan_peer_set_dp_handle() - set dp handle 1061 * @peer: peer object pointer 1062 * @dp_handle: Data path module handle 1063 * 1064 * Return: void 1065 */ 1066 static inline void wlan_peer_set_dp_handle(struct wlan_objmgr_peer *peer, 1067 void *dp_handle) 1068 { 1069 if (qdf_unlikely(!peer)) { 1070 QDF_BUG(0); 1071 return; 1072 } 1073 1074 peer->dp_handle = dp_handle; 1075 } 1076 1077 /** 1078 * wlan_peer_get_dp_handle() - get dp handle 1079 * @peer: peer object pointer 1080 * 1081 * Return: dp handle 1082 */ 1083 static inline void *wlan_peer_get_dp_handle(struct wlan_objmgr_peer *peer) 1084 { 1085 if (qdf_unlikely(!peer)) { 1086 QDF_BUG(0); 1087 return NULL; 1088 } 1089 1090 return peer->dp_handle; 1091 } 1092 1093 /** 1094 * wlan_peer_get_psoc() - get psoc 1095 * @peer: PEER object 1096 * 1097 * API to get peer's psoc 1098 * 1099 * Return: PSOC object or NULL if the psoc can not be found 1100 */ 1101 static inline struct wlan_objmgr_psoc *wlan_peer_get_psoc( 1102 struct wlan_objmgr_peer *peer) 1103 { 1104 struct wlan_objmgr_vdev *vdev; 1105 struct wlan_objmgr_psoc *psoc; 1106 1107 vdev = wlan_peer_get_vdev(peer); 1108 if (!vdev) 1109 return NULL; 1110 1111 psoc = wlan_vdev_get_psoc(vdev); 1112 1113 return psoc; 1114 } 1115 1116 /* 1117 * wlan_peer_get_pdev_id() - get pdev id 1118 * @peer: peer object pointer 1119 * 1120 * Return: pdev id 1121 */ 1122 static inline uint8_t wlan_peer_get_pdev_id(struct wlan_objmgr_peer *peer) 1123 { 1124 return peer->pdev_id; 1125 } 1126 1127 /** 1128 * wlan_peer_set_pdev_id() - set pdev id 1129 * @peer: peer object pointer 1130 * @pdev_id: pdev id 1131 * 1132 * Return: void 1133 */ 1134 static inline void wlan_peer_set_pdev_id(struct wlan_objmgr_peer *peer, 1135 uint8_t pdev_id) 1136 { 1137 peer->pdev_id = pdev_id; 1138 } 1139 1140 /** 1141 * wlan_objmgr_print_peer_ref_ids() - print peer object refs 1142 * @peer: peer object pointer 1143 * @log_level: log level 1144 * 1145 * Return: void 1146 */ 1147 void wlan_objmgr_print_peer_ref_ids(struct wlan_objmgr_peer *peer, 1148 QDF_TRACE_LEVEL log_level); 1149 1150 /** 1151 * wlan_objmgr_peer_get_comp_ref_cnt() - get component ref count for a peer 1152 * @peer: peer object pointer 1153 * @id: component id 1154 * 1155 * Return: uint32_t 1156 */ 1157 uint32_t 1158 wlan_objmgr_peer_get_comp_ref_cnt(struct wlan_objmgr_peer *peer, 1159 enum wlan_umac_comp_id id); 1160 1161 /** 1162 * wlan_objmgr_peer_trace_init_lock() - Initialize peer trace lock 1163 * @peer: peer object pointer 1164 * 1165 * Return: void 1166 */ 1167 #ifdef WLAN_OBJMGR_TRACE 1168 static inline void 1169 wlan_objmgr_peer_trace_init_lock(struct wlan_objmgr_peer *peer) 1170 { 1171 wlan_objmgr_trace_init_lock(&peer->peer_objmgr.trace); 1172 } 1173 #else 1174 static inline void 1175 wlan_objmgr_peer_trace_init_lock(struct wlan_objmgr_peer *peer) 1176 { 1177 } 1178 #endif 1179 1180 /** 1181 * wlan_objmgr_peer_trace_deinit_lock() - Deinitialize peer trace lock 1182 * @peer: peer object pointer 1183 * 1184 * Return: void 1185 */ 1186 #ifdef WLAN_OBJMGR_TRACE 1187 static inline void 1188 wlan_objmgr_peer_trace_deinit_lock(struct wlan_objmgr_peer *peer) 1189 { 1190 wlan_objmgr_trace_deinit_lock(&peer->peer_objmgr.trace); 1191 } 1192 #else 1193 static inline void 1194 wlan_objmgr_peer_trace_deinit_lock(struct wlan_objmgr_peer *peer) 1195 { 1196 } 1197 #endif 1198 1199 /** 1200 * wlan_objmgr_peer_trace_del_ref_list() - Delete peer trace reference list 1201 * @peer: peer object pointer 1202 * 1203 * Return: void 1204 */ 1205 #ifdef WLAN_OBJMGR_REF_ID_TRACE 1206 static inline void 1207 wlan_objmgr_peer_trace_del_ref_list(struct wlan_objmgr_peer *peer) 1208 { 1209 wlan_objmgr_trace_del_ref_list(&peer->peer_objmgr.trace); 1210 } 1211 #else 1212 static inline void 1213 wlan_objmgr_peer_trace_del_ref_list(struct wlan_objmgr_peer *peer) 1214 { 1215 } 1216 #endif 1217 1218 #endif /* _WLAN_OBJMGR_PEER_OBJ_H_*/ 1219