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 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 * @pdev_id: Pdev ID 171 * @peer_lock: Lock for access/update peer contents 172 */ 173 struct wlan_objmgr_peer { 174 qdf_list_node_t psoc_peer; 175 qdf_list_node_t vdev_peer; 176 uint8_t macaddr[QDF_MAC_ADDR_SIZE]; 177 uint8_t pdev_id; 178 struct wlan_objmgr_peer_mlme peer_mlme; 179 struct wlan_objmgr_peer_objmgr peer_objmgr; 180 void *peer_comp_priv_obj[WLAN_UMAC_MAX_COMPONENTS]; 181 QDF_STATUS obj_status[WLAN_UMAC_MAX_COMPONENTS]; 182 WLAN_OBJ_STATE obj_state; 183 qdf_spinlock_t peer_lock; 184 }; 185 186 /** 187 ** APIs to Create/Delete Global object APIs 188 */ 189 /** 190 * wlan_objmgr_peer_obj_create() - peer object create 191 * @vdev: VDEV object on which this peer gets created 192 * @peer_type: peer type (AP/STA) 193 * @macaddr: MAC address 194 * 195 * Creates Peer object, intializes with default values 196 * Attaches to psoc and vdev objects 197 * Invokes the registered notifiers to create component object 198 * 199 * Return: Handle to struct wlan_objmgr_peer on successful creation, 200 * NULL on Failure (on Mem alloc failure and Component objects 201 * Failure) 202 */ 203 struct wlan_objmgr_peer *wlan_objmgr_peer_obj_create( 204 struct wlan_objmgr_vdev *vdev, 205 enum wlan_peer_type type, 206 uint8_t macaddr[]); 207 208 /** 209 * wlan_objmgr_peer_obj_delete() - peer object delete 210 * @peer: PEER object 211 * 212 * Deletes PEER object, removes it from PSOC's, VDEV's peer list 213 * Invokes the registered notifiers to destroy component objects 214 * 215 * Return: SUCCESS/FAILURE 216 */ 217 QDF_STATUS wlan_objmgr_peer_obj_delete(struct wlan_objmgr_peer *peer); 218 219 /** 220 ** APIs to attach/detach component objects 221 */ 222 /** 223 * wlan_objmgr_peer_component_obj_attach() - attach comp object to peer 224 * @peer: PEER object 225 * @id: Component id 226 * @comp_priv_obj: component's private object pointer 227 * @status: Component's private object creation status 228 * 229 * API to be used for attaching component object with PEER common object 230 * 231 * Return: SUCCESS on successful storing of component's object in common object 232 * On FAILURE (appropriate failure codes are returned) 233 */ 234 QDF_STATUS wlan_objmgr_peer_component_obj_attach( 235 struct wlan_objmgr_peer *peer, 236 enum wlan_umac_comp_id id, 237 void *comp_priv_obj, 238 QDF_STATUS status); 239 240 /** 241 * wlan_objmgr_peer_component_obj_detach() - detach comp object from peer 242 * @peer: PEER object 243 * @id: Component id 244 * @comp_priv_obj: component's private object pointer 245 * 246 * API to be used for detaching component object with PEER common object 247 * 248 * Return: SUCCESS on successful removal of component's object from common 249 * object 250 * On FAILURE (appropriate failure codes are returned) 251 */ 252 QDF_STATUS wlan_objmgr_peer_component_obj_detach( 253 struct wlan_objmgr_peer *peer, 254 enum wlan_umac_comp_id id, 255 void *comp_priv_obj); 256 257 /** 258 ** APIs to operations on peer objects 259 */ 260 261 /** 262 * wlan_objmgr_trigger_peer_comp_priv_object_creation() - create 263 * peer comp object 264 * @peer: PEER object 265 * @id: Component id 266 * 267 * API to create component private object in run time, this would 268 * be used for features which gets enabled in run time 269 * 270 * Return: SUCCESS on successful creation 271 * On FAILURE (appropriate failure codes are returned) 272 */ 273 QDF_STATUS wlan_objmgr_trigger_peer_comp_priv_object_creation( 274 struct wlan_objmgr_peer *peer, 275 enum wlan_umac_comp_id id); 276 277 /** 278 * wlan_objmgr_trigger_peer_comp_priv_object_deletion() - destroy 279 * peer comp object 280 * @peer: PEER object 281 * @id: Component id 282 * 283 * API to destroy component private object in run time, this would 284 * be used for features which gets disabled in run time 285 * 286 * Return: SUCCESS on successful deletion 287 * On FAILURE (appropriate failure codes are returned) 288 */ 289 QDF_STATUS wlan_objmgr_trigger_peer_comp_priv_object_deletion( 290 struct wlan_objmgr_peer *peer, 291 enum wlan_umac_comp_id id); 292 293 /** 294 * wlan_objmgr_peer_get_comp_private_obj() - get peer component private object 295 * @peer: PEER object 296 * @id: Component id 297 * 298 * API to get component private object 299 * 300 * Return: void *ptr on SUCCESS 301 * NULL on Failure 302 */ 303 void *wlan_objmgr_peer_get_comp_private_obj( 304 struct wlan_objmgr_peer *peer, 305 enum wlan_umac_comp_id id); 306 307 /** 308 * wlan_peer_obj_lock() - Acquire PEER spinlock 309 * @psoc: PEER object 310 * 311 * API to acquire PEER spin lock 312 * Parent lock should not be taken in child lock context 313 * but child lock can be taken in parent lock context 314 * (for ex: psoc lock can't be invoked in pdev/vdev/peer lock context) 315 * 316 * Return: void 317 */ 318 static inline void wlan_peer_obj_lock(struct wlan_objmgr_peer *peer) 319 { 320 qdf_spin_lock_bh(&peer->peer_lock); 321 } 322 323 /** 324 * wlan_peer_obj_unlock() - Release PEER spinlock 325 * @peer: PEER object 326 * 327 * API to Release PEER spin lock 328 * 329 * Return: void 330 */ 331 static inline void wlan_peer_obj_unlock(struct wlan_objmgr_peer *peer) 332 { 333 qdf_spin_unlock_bh(&peer->peer_lock); 334 } 335 336 /** 337 * DOC: Examples to use PEER ref count APIs 338 * 339 * In all the scenarios, the pair of API should be followed 340 * other it lead to memory leak 341 * 342 * scenario 1: 343 * 344 * wlan_objmgr_peer_obj_create() 345 * ---- 346 * wlan_objmgr_peer_obj_delete() 347 * 348 * scenario 2: 349 * 350 * wlan_objmgr_peer_get_ref() 351 * ---- 352 * the operations which are done on 353 * peer object 354 * ---- 355 * wlan_objmgr_peer_release_ref() 356 * 357 * scenario 3: 358 * 359 * API to retrieve peer (xxx_get_peer_xxx()) 360 * ---- 361 * the operations which are done on 362 * peer object 363 * ---- 364 * wlan_objmgr_peer_release_ref() 365 */ 366 367 /** 368 * wlan_objmgr_peer_get_ref() - increment ref count 369 * @peer: PEER object 370 * @id: Object Manager ref debug id 371 * 372 * API to increment ref count of peer 373 * 374 * Return: void 375 */ 376 #ifdef WLAN_OBJMGR_REF_ID_TRACE 377 void wlan_objmgr_peer_get_ref_debug(struct wlan_objmgr_peer *peer, 378 wlan_objmgr_ref_dbgid id, 379 const char *func, int line); 380 381 #define wlan_objmgr_peer_get_ref(peer, dbgid) \ 382 wlan_objmgr_peer_get_ref_debug(peer, dbgid, __func__, __LINE__) 383 #else 384 void wlan_objmgr_peer_get_ref(struct wlan_objmgr_peer *peer, 385 wlan_objmgr_ref_dbgid id); 386 #endif 387 388 /** 389 * wlan_objmgr_peer_try_get_ref() - increment ref count, if allowed 390 * @peer: PEER object 391 * @id: Object Manager ref debug id 392 * 393 * API to increment ref count of peer, if object state is valid 394 * 395 * Return: void 396 */ 397 #ifdef WLAN_OBJMGR_REF_ID_TRACE 398 QDF_STATUS wlan_objmgr_peer_try_get_ref_debug(struct wlan_objmgr_peer *peer, 399 wlan_objmgr_ref_dbgid id, 400 const char *func, int line); 401 402 #define wlan_objmgr_peer_try_get_ref(peer, dbgid) \ 403 wlan_objmgr_peer_try_get_ref_debug(peer, dbgid, \ 404 __func__, __LINE__) 405 #else 406 QDF_STATUS wlan_objmgr_peer_try_get_ref(struct wlan_objmgr_peer *peer, 407 wlan_objmgr_ref_dbgid id); 408 #endif 409 410 /** 411 * wlan_objmgr_peer_release_ref() - decrement ref count 412 * @peer: PEER object 413 * @id: Object Manager ref debug id 414 * 415 * API to decrement ref count of peer, if ref count is 1, it initiates the 416 * peer deletion 417 * 418 * Return: void 419 */ 420 #ifdef WLAN_OBJMGR_REF_ID_TRACE 421 void wlan_objmgr_peer_release_ref_debug(struct wlan_objmgr_peer *peer, 422 wlan_objmgr_ref_dbgid id, 423 const char *func, int line); 424 425 #define wlan_objmgr_peer_release_ref(peer, dbgid) \ 426 wlan_objmgr_peer_release_ref_debug(peer, dbgid, \ 427 __func__, __LINE__) 428 #else 429 void wlan_objmgr_peer_release_ref(struct wlan_objmgr_peer *peer, 430 wlan_objmgr_ref_dbgid id); 431 #endif 432 433 /** 434 * wlan_peer_get_next_peer_of_psoc_ref() - get next peer to psoc peer list 435 * with lock and ref taken 436 * @peer_list: Peer list 437 * @hash_index: peer list hash index 438 * @peer: PEER object 439 * @dbg_id: Ref count debug module id 440 * 441 * API to get the next peer of given peer (of psoc's peer list) 442 * 443 * Return: 444 * @next_peer: PEER object 445 */ 446 #ifdef WLAN_OBJMGR_REF_ID_TRACE 447 struct wlan_objmgr_peer *wlan_peer_get_next_peer_of_psoc_ref_debug( 448 struct wlan_peer_list *peer_list, 449 uint8_t hash_index, 450 struct wlan_objmgr_peer *peer, 451 wlan_objmgr_ref_dbgid dbg_id, 452 const char *func, int line); 453 454 #define wlan_peer_get_next_peer_of_psoc_ref(peer_list, hash_index, peer, \ 455 dbgid) \ 456 wlan_peer_get_next_peer_of_psoc_ref_debug(peer_list, \ 457 hash_index, peer, dbgid, __func__, __LINE__) 458 #else 459 struct wlan_objmgr_peer *wlan_peer_get_next_peer_of_psoc_ref( 460 struct wlan_peer_list *peer_list, 461 uint8_t hash_index, 462 struct wlan_objmgr_peer *peer, 463 wlan_objmgr_ref_dbgid dbg_id); 464 #endif 465 466 /** 467 * wlan_peer_get_next_active_peer_of_psoc() - get next active peer to psoc peer 468 * list 469 * @peer_list: Peer list 470 * @hash_index: peer list hash index 471 * @peer: PEER object 472 * @dbg_id: Ref count debug module id 473 * 474 * API to get the next peer of given peer (of psoc's peer list) 475 * 476 * Return: 477 * @next_peer: PEER object 478 */ 479 #ifdef WLAN_OBJMGR_REF_ID_TRACE 480 struct wlan_objmgr_peer *wlan_peer_get_next_active_peer_of_psoc_debug( 481 struct wlan_peer_list *peer_list, 482 uint8_t hash_index, 483 struct wlan_objmgr_peer *peer, 484 wlan_objmgr_ref_dbgid dbg_id, 485 const char *func, int line); 486 487 #define wlan_peer_get_next_active_peer_of_psoc(peer_list, hash_index, \ 488 peer, dbgid) \ 489 wlan_peer_get_next_active_peer_of_psoc_debug(peer_list, \ 490 hash_index, peer, dbgid, __func__, __LINE__) 491 #else 492 struct wlan_objmgr_peer *wlan_peer_get_next_active_peer_of_psoc( 493 struct wlan_peer_list *peer_list, 494 uint8_t hash_index, 495 struct wlan_objmgr_peer *peer, 496 wlan_objmgr_ref_dbgid dbg_id); 497 #endif 498 499 /** 500 * wlan_peer_get_next_active_peer_of_vdev() - get next active_peer of vdev list 501 * @vdev: VDEV object 502 * @peer_list: Peer object list 503 * @peer: PEER object 504 * @dbg_id: Ref count debug module id 505 * 506 * API to get the next active peer of given peer (of vdev's peer list) 507 * 508 * Return: 509 * @next_peer: PEER object 510 */ 511 #ifdef WLAN_OBJMGR_REF_ID_TRACE 512 struct wlan_objmgr_peer *wlan_peer_get_next_active_peer_of_vdev_debug( 513 struct wlan_objmgr_vdev *vdev, 514 qdf_list_t *peer_list, 515 struct wlan_objmgr_peer *peer, 516 wlan_objmgr_ref_dbgid dbg_id, 517 const char *func, int line); 518 519 #define wlan_peer_get_next_active_peer_of_vdev(vdev, peer_list, peer, dbgid) \ 520 wlan_peer_get_next_active_peer_of_vdev_debug(vdev, peer_list, \ 521 peer, dbgid, __func__, __LINE__) 522 #else 523 struct wlan_objmgr_peer *wlan_peer_get_next_active_peer_of_vdev( 524 struct wlan_objmgr_vdev *vdev, 525 qdf_list_t *peer_list, 526 struct wlan_objmgr_peer *peer, 527 wlan_objmgr_ref_dbgid dbg_id); 528 #endif 529 530 /** 531 * wlan_vdev_peer_list_peek_active_head() - get active head of vdev peer list 532 * @vdev: VDEV object 533 * @peer_list: qdf_list_t 534 * @dbg_id: Ref count debug module id 535 * 536 * API to get the active head peer of given peer (of vdev's peer list) 537 * 538 * Return: 539 * @peer: active head peer 540 */ 541 #ifdef WLAN_OBJMGR_REF_ID_TRACE 542 struct wlan_objmgr_peer *wlan_vdev_peer_list_peek_active_head_debug( 543 struct wlan_objmgr_vdev *vdev, 544 qdf_list_t *peer_list, 545 wlan_objmgr_ref_dbgid dbg_id, 546 const char *func, int line); 547 548 #define wlan_vdev_peer_list_peek_active_head(vdev, peer_list, dbgid) \ 549 wlan_vdev_peer_list_peek_active_head_debug(vdev, peer_list, \ 550 dbgid, __func__, __LINE__) 551 #else 552 struct wlan_objmgr_peer *wlan_vdev_peer_list_peek_active_head( 553 struct wlan_objmgr_vdev *vdev, 554 qdf_list_t *peer_list, 555 wlan_objmgr_ref_dbgid dbg_id); 556 #endif 557 558 /** 559 * wlan_psoc_peer_list_peek_head_ref() - get head of psoc peer list 560 * with ref and lock protected 561 * @peer_list: wlan_peer_list 562 * @hash_index: peer list hash index 563 * @dbg_id: Ref count debug module id 564 * 565 * API to get the head peer of given peer (of psoc's peer list) 566 * 567 * Return: 568 * @peer: head peer 569 */ 570 #ifdef WLAN_OBJMGR_REF_ID_TRACE 571 struct wlan_objmgr_peer *wlan_psoc_peer_list_peek_head_ref_debug( 572 struct wlan_peer_list *peer_list, 573 uint8_t hash_index, 574 wlan_objmgr_ref_dbgid dbg_id, 575 const char *func, int line); 576 577 #define wlan_psoc_peer_list_peek_head_ref(peer_list, hash_index, dbgid) \ 578 wlan_psoc_peer_list_peek_head_ref_debug(peer_list, hash_index, \ 579 dbgid, __func__, __LINE__) 580 #else 581 struct wlan_objmgr_peer *wlan_psoc_peer_list_peek_head_ref( 582 struct wlan_peer_list *peer_list, 583 uint8_t hash_index, 584 wlan_objmgr_ref_dbgid dbg_id); 585 #endif 586 587 /** 588 * wlan_psoc_peer_list_peek_active_head() - get active head of psoc peer list 589 * @peer_list: wlan_peer_list 590 * @hash_index: peer list hash index 591 * @dbg_id: Ref count debug module id 592 * 593 * API to get the head peer of given peer (of psoc's peer list) 594 * 595 * Return: 596 * @peer: head peer 597 */ 598 #ifdef WLAN_OBJMGR_REF_ID_TRACE 599 struct wlan_objmgr_peer *wlan_psoc_peer_list_peek_active_head_debug( 600 struct wlan_peer_list *peer_list, 601 uint8_t hash_index, 602 wlan_objmgr_ref_dbgid dbg_id, 603 const char *func, int line); 604 605 #define wlan_psoc_peer_list_peek_active_head(peer_list, hash_index, dbgid) \ 606 wlan_psoc_peer_list_peek_active_head_debug(peer_list, \ 607 hash_index, dbgid, __func__, __LINE__) 608 #else 609 struct wlan_objmgr_peer *wlan_psoc_peer_list_peek_active_head( 610 struct wlan_peer_list *peer_list, 611 uint8_t hash_index, 612 wlan_objmgr_ref_dbgid dbg_id); 613 #endif 614 615 /** 616 * wlan_psoc_peer_list_peek_head() - get head of psoc peer list 617 * @peer_list: qdf_list_t 618 * 619 * API to get the head peer of given peer (of psoc's peer list) 620 * 621 * Caller need to acquire lock with wlan_peer_obj_lock() 622 * 623 * Return: 624 * @peer: head peer 625 */ 626 static inline struct wlan_objmgr_peer *wlan_psoc_peer_list_peek_head( 627 qdf_list_t *peer_list) 628 { 629 struct wlan_objmgr_peer *peer; 630 qdf_list_node_t *psoc_node = NULL; 631 632 /* This API is invoked with lock acquired, do not add log prints */ 633 if (qdf_list_peek_front(peer_list, &psoc_node) != QDF_STATUS_SUCCESS) 634 return NULL; 635 636 peer = qdf_container_of(psoc_node, struct wlan_objmgr_peer, psoc_peer); 637 return peer; 638 } 639 640 /** 641 * wlan_vdev_peer_list_peek_head() - get head of vdev peer list 642 * @peer_list: qdf_list_t 643 * 644 * API to get the head peer of given peer (of vdev's peer list) 645 * 646 * Caller need to acquire lock with wlan_peer_obj_lock() 647 * 648 * Return: 649 * @peer: head peer 650 */ 651 static inline struct wlan_objmgr_peer *wlan_vdev_peer_list_peek_head( 652 qdf_list_t *peer_list) 653 { 654 struct wlan_objmgr_peer *peer; 655 qdf_list_node_t *vdev_node = NULL; 656 657 /* This API is invoked with lock acquired, do not add log prints */ 658 if (qdf_list_peek_front(peer_list, &vdev_node) != QDF_STATUS_SUCCESS) 659 return NULL; 660 661 peer = qdf_container_of(vdev_node, struct wlan_objmgr_peer, vdev_peer); 662 return peer; 663 } 664 665 /** 666 * wlan_peer_get_next_peer_of_vdev() - get next peer of vdev list 667 * @peer: PEER object 668 * 669 * API to get the next peer of given peer (of vdev's peer list) 670 * 671 * Caller need to acquire lock with wlan_peer_obj_lock() 672 * 673 * Return: 674 * @next_peer: PEER object 675 */ 676 static inline struct wlan_objmgr_peer *wlan_peer_get_next_peer_of_vdev( 677 qdf_list_t *peer_list, struct wlan_objmgr_peer *peer) 678 { 679 struct wlan_objmgr_peer *peer_next; 680 qdf_list_node_t *node; 681 qdf_list_node_t *next_node = NULL; 682 683 /* This API is invoked with lock acquired, do not add log prints */ 684 if (!peer) 685 return NULL; 686 687 node = &peer->vdev_peer; 688 if (qdf_list_peek_next(peer_list, node, &next_node) != 689 QDF_STATUS_SUCCESS) 690 return NULL; 691 692 peer_next = qdf_container_of(next_node, struct wlan_objmgr_peer, 693 vdev_peer); 694 return peer_next; 695 } 696 697 /** 698 * wlan_peer_set_next_peer_of_vdev() - add peer to vdev peer list 699 * @peer: PEER object 700 * @new_peer: PEER object 701 * 702 * API to set as the next peer to given peer (of vdev's peer list) 703 * 704 * Caller need to acquire lock with wlan_peer_obj_lock() 705 * 706 * Return: void 707 */ 708 static inline void wlan_peer_set_next_peer_of_vdev(qdf_list_t *peer_list, 709 struct wlan_objmgr_peer *new_peer) 710 { 711 /* This API is invoked with lock acquired, do not add log prints */ 712 /* set next peer with new peer */ 713 qdf_list_insert_back(peer_list, &new_peer->vdev_peer); 714 return; 715 } 716 717 /** 718 * wlan_peer_get_next_peer_of_psoc() - get next peer to psoc peer list 719 * @peer_list: Peer list 720 * @peer: PEER object 721 * 722 * API to get the next peer of given peer (of psoc's peer list) 723 * 724 * Caller need to acquire lock with wlan_peer_obj_lock() 725 * 726 * Return: 727 * @next_peer: PEER object 728 */ 729 static inline struct wlan_objmgr_peer *wlan_peer_get_next_peer_of_psoc( 730 qdf_list_t *peer_list, struct wlan_objmgr_peer *peer) 731 { 732 struct wlan_objmgr_peer *peer_next; 733 qdf_list_node_t *node = NULL; 734 qdf_list_node_t *next_node = NULL; 735 736 /* This API is invoked with lock acquired, do not add log prints */ 737 if (!peer) 738 return NULL; 739 740 node = &peer->psoc_peer; 741 if (qdf_list_peek_next(peer_list, node, &next_node) != 742 QDF_STATUS_SUCCESS) 743 return NULL; 744 745 peer_next = qdf_container_of(next_node, struct wlan_objmgr_peer, 746 psoc_peer); 747 return peer_next; 748 } 749 750 /** 751 * wlan_peer_set_next_peer_of_psoc() - add peer to psoc peer list 752 * @peer: PEER object 753 * @new_peer: PEER object 754 * 755 * API to set as the next peer to given peer (of psoc's peer list) 756 * 757 * Caller need to acquire lock with wlan_peer_obj_lock() 758 * 759 * Return: void 760 */ 761 static inline void wlan_peer_set_next_peer_of_psoc(qdf_list_t *peer_list, 762 struct wlan_objmgr_peer *new_peer) 763 { 764 /* This API is invoked with lock acquired, do not add log prints */ 765 /* set next peer with new peer */ 766 qdf_list_insert_back(peer_list, &new_peer->psoc_peer); 767 return; 768 } 769 770 /** 771 * wlan_peer_set_peer_type() - set peer type 772 * @peer: PEER object 773 * @peer_type: type of PEER 774 * 775 * API to set peer type 776 * 777 * Return: void 778 */ 779 static inline void wlan_peer_set_peer_type(struct wlan_objmgr_peer *peer, 780 enum wlan_peer_type type) 781 { 782 peer->peer_mlme.peer_type = type; 783 } 784 785 /** 786 * wlan_peer_get_peer_type() - get peer type 787 * @peer: PEER object 788 * 789 * API to get peer type 790 * 791 * Return: 792 * @peer_type: type of PEER 793 */ 794 static inline enum wlan_peer_type wlan_peer_get_peer_type( 795 struct wlan_objmgr_peer *peer) 796 { 797 return peer->peer_mlme.peer_type; 798 } 799 800 /** 801 * wlan_peer_set_phymode() - set phymode 802 * @peer: PEER object 803 * @phymode: phymode of peer 804 * 805 * API to set phymode 806 * 807 * Return: void 808 */ 809 static inline void wlan_peer_set_phymode(struct wlan_objmgr_peer *peer, 810 enum wlan_phymode phymode) 811 { 812 peer->peer_mlme.phymode = phymode; 813 } 814 815 /** 816 * wlan_peer_get_phymode() - get phymode 817 * @peer: PEER object 818 * 819 * API to get phymode 820 * 821 * Return: 822 * @phymode: phymode of PEER 823 */ 824 static inline enum wlan_phymode wlan_peer_get_phymode( 825 struct wlan_objmgr_peer *peer) 826 { 827 return peer->peer_mlme.phymode; 828 } 829 830 831 /** 832 * wlan_peer_set_macaddr() - set mac addr 833 * @peer: PEER object 834 * @macaddr: MAC address 835 * 836 * API to set peer mac address 837 * 838 * Caller need to acquire lock with wlan_peer_obj_lock() 839 * 840 * Return: void 841 */ 842 static inline void wlan_peer_set_macaddr(struct wlan_objmgr_peer *peer, 843 uint8_t *macaddr) 844 { 845 /* This API is invoked with lock acquired, do not add log prints */ 846 WLAN_ADDR_COPY(peer->macaddr, macaddr); 847 } 848 849 /** 850 * wlan_peer_get_macaddr() - get mac addr 851 * @peer: PEER object 852 * 853 * API to get peer mac address 854 * 855 * Caller need to acquire lock with wlan_peer_obj_lock() 856 * 857 * Return: 858 * @macaddr: MAC address 859 */ 860 static inline uint8_t *wlan_peer_get_macaddr(struct wlan_objmgr_peer *peer) 861 { 862 /* This API is invoked with lock acquired, do not add log prints */ 863 return peer->macaddr; 864 } 865 866 /** 867 * wlan_peer_get_vdev() - get vdev 868 * @peer: PEER object 869 * 870 * API to get peer's vdev 871 * 872 * Return: 873 * @vdev: VDEV object 874 */ 875 static inline struct wlan_objmgr_vdev *wlan_peer_get_vdev( 876 struct wlan_objmgr_peer *peer) 877 { 878 return peer->peer_objmgr.vdev; 879 } 880 881 /** 882 * wlan_peer_set_vdev() - set vdev 883 * @peer: PEER object 884 * @vdev: VDEV object 885 * 886 * API to set peer's vdev 887 * 888 * Return: void 889 */ 890 static inline void wlan_peer_set_vdev(struct wlan_objmgr_peer *peer, 891 struct wlan_objmgr_vdev *vdev) 892 { 893 peer->peer_objmgr.vdev = vdev; 894 } 895 896 /** 897 * wlan_peer_mlme_flag_set() - mlme flag set 898 * @peer: PEER object 899 * @flag: flag to be set 900 * 901 * API to set flag in peer 902 * 903 * Return: void 904 */ 905 static inline void wlan_peer_mlme_flag_set(struct wlan_objmgr_peer *peer, 906 uint32_t flag) 907 { 908 peer->peer_mlme.peer_flags |= flag; 909 } 910 911 /** 912 * wlan_peer_mlme_flag_clear() - mlme flag clear 913 * @peer: PEER object 914 * @flag: flag to be cleared 915 * 916 * API to clear flag in peer 917 * 918 * Return: void 919 */ 920 static inline void wlan_peer_mlme_flag_clear(struct wlan_objmgr_peer *peer, 921 uint32_t flag) 922 { 923 peer->peer_mlme.peer_flags &= ~flag; 924 } 925 926 /** 927 * wlan_peer_mlme_flag_get() - mlme flag get 928 * @peer: PEER object 929 * @flag: flag to be checked 930 * 931 * API to know, whether particular flag is set in peer 932 * 933 * Return: 1 (for set) or 0 (for not set) 934 */ 935 static inline uint8_t wlan_peer_mlme_flag_get(struct wlan_objmgr_peer *peer, 936 uint32_t flag) 937 { 938 return (peer->peer_mlme.peer_flags & flag) ? 1 : 0; 939 } 940 941 /** 942 * wlan_peer_mlme_set_state() - peer mlme state 943 * @peer: PEER object 944 * @state: enum wlan_peer_state 945 * 946 * API to update the current peer state 947 * 948 * Return: void 949 */ 950 static inline void wlan_peer_mlme_set_state( 951 struct wlan_objmgr_peer *peer, 952 enum wlan_peer_state state) 953 { 954 peer->peer_mlme.state = state; 955 } 956 957 /** 958 * wlan_peer_mlme_set_auth_state() - peer mlme auth state 959 * @peer: PEER object 960 * @is_authenticated: true or false 961 * 962 * API to update the current peer auth state 963 * 964 * Return: void 965 */ 966 static inline void wlan_peer_mlme_set_auth_state( 967 struct wlan_objmgr_peer *peer, 968 bool is_authenticated) 969 { 970 peer->peer_mlme.is_authenticated = is_authenticated; 971 } 972 973 /** 974 * wlan_peer_mlme_get_state() - peer mlme state 975 * @peer: PEER object 976 * 977 * API to get peer state 978 * 979 * Return: enum wlan_peer_state 980 */ 981 static inline enum wlan_peer_state wlan_peer_mlme_get_state( 982 struct wlan_objmgr_peer *peer) 983 { 984 return peer->peer_mlme.state; 985 } 986 987 /** 988 * wlan_peer_mlme_get_auth_state() - peer mlme auth state 989 * @peer: PEER object 990 * 991 * API to get peer auth state 992 * 993 * Return: auth state true/false 994 */ 995 static inline bool wlan_peer_mlme_get_auth_state( 996 struct wlan_objmgr_peer *peer) 997 { 998 return peer->peer_mlme.is_authenticated; 999 } 1000 1001 /** 1002 * wlan_peer_mlme_get_next_seq_num() - get peer mlme next sequence number 1003 * @peer: PEER object 1004 * 1005 * API to get mlme peer next sequence number 1006 * 1007 * Caller need to acquire lock with wlan_peer_obj_lock() 1008 * 1009 * Return: peer mlme next sequence number 1010 */ 1011 static inline uint32_t wlan_peer_mlme_get_next_seq_num( 1012 struct wlan_objmgr_peer *peer) 1013 { 1014 /* This API is invoked with lock acquired, do not add log prints */ 1015 if (peer->peer_mlme.seq_num < WLAN_MAX_SEQ_NUM) 1016 peer->peer_mlme.seq_num++; 1017 else 1018 peer->peer_mlme.seq_num = 0; 1019 1020 return peer->peer_mlme.seq_num; 1021 } 1022 1023 /** 1024 * wlan_peer_mlme_get_seq_num() - get peer mlme sequence number 1025 * @peer: PEER object 1026 * 1027 * API to get mlme peer sequence number 1028 * 1029 * Caller need to acquire lock with wlan_peer_obj_lock() 1030 * 1031 * Return: peer mlme sequence number 1032 */ 1033 static inline uint32_t wlan_peer_mlme_get_seq_num( 1034 struct wlan_objmgr_peer *peer) 1035 { 1036 /* This API is invoked with lock acquired, do not add log prints */ 1037 return peer->peer_mlme.seq_num; 1038 } 1039 1040 /** 1041 * wlan_peer_mlme_reset_seq_num() - reset peer mlme sequence number 1042 * @peer: PEER object 1043 * 1044 * API to reset peer sequence number 1045 * 1046 * Caller need to acquire lock with wlan_peer_obj_lock() 1047 * 1048 * Return: void 1049 */ 1050 static inline void wlan_peer_mlme_reset_seq_num( 1051 struct wlan_objmgr_peer *peer) 1052 { 1053 /* This API is invoked with lock acquired, do not add log prints */ 1054 peer->peer_mlme.seq_num = 0; 1055 } 1056 1057 /** 1058 * wlan_peer_get_psoc() - get psoc 1059 * @peer: PEER object 1060 * 1061 * API to get peer's psoc 1062 * 1063 * Return: PSOC object or NULL if the psoc can not be found 1064 */ 1065 static inline struct wlan_objmgr_psoc *wlan_peer_get_psoc( 1066 struct wlan_objmgr_peer *peer) 1067 { 1068 struct wlan_objmgr_vdev *vdev; 1069 struct wlan_objmgr_psoc *psoc; 1070 1071 vdev = wlan_peer_get_vdev(peer); 1072 if (!vdev) 1073 return NULL; 1074 1075 psoc = wlan_vdev_get_psoc(vdev); 1076 1077 return psoc; 1078 } 1079 1080 /* 1081 * wlan_peer_get_pdev_id() - get pdev id 1082 * @peer: peer object pointer 1083 * 1084 * Return: pdev id 1085 */ 1086 static inline uint8_t wlan_peer_get_pdev_id(struct wlan_objmgr_peer *peer) 1087 { 1088 return peer->pdev_id; 1089 } 1090 1091 /** 1092 * wlan_peer_set_pdev_id() - set pdev id 1093 * @peer: peer object pointer 1094 * @pdev_id: pdev id 1095 * 1096 * Return: void 1097 */ 1098 static inline void wlan_peer_set_pdev_id(struct wlan_objmgr_peer *peer, 1099 uint8_t pdev_id) 1100 { 1101 peer->pdev_id = pdev_id; 1102 } 1103 1104 /** 1105 * wlan_objmgr_print_peer_ref_ids() - print peer object refs 1106 * @peer: peer object pointer 1107 * @log_level: log level 1108 * 1109 * Return: void 1110 */ 1111 void wlan_objmgr_print_peer_ref_ids(struct wlan_objmgr_peer *peer, 1112 QDF_TRACE_LEVEL log_level); 1113 1114 /** 1115 * wlan_objmgr_peer_get_comp_ref_cnt() - get component ref count for a peer 1116 * @peer: peer object pointer 1117 * @id: component id 1118 * 1119 * Return: uint32_t 1120 */ 1121 uint32_t 1122 wlan_objmgr_peer_get_comp_ref_cnt(struct wlan_objmgr_peer *peer, 1123 enum wlan_umac_comp_id id); 1124 1125 /** 1126 * wlan_objmgr_peer_trace_init_lock() - Initialize peer trace lock 1127 * @peer: peer object pointer 1128 * 1129 * Return: void 1130 */ 1131 #ifdef WLAN_OBJMGR_REF_ID_TRACE 1132 static inline void 1133 wlan_objmgr_peer_trace_init_lock(struct wlan_objmgr_peer *peer) 1134 { 1135 wlan_objmgr_trace_init_lock(&peer->peer_objmgr.trace); 1136 } 1137 #else 1138 static inline void 1139 wlan_objmgr_peer_trace_init_lock(struct wlan_objmgr_peer *peer) 1140 { 1141 } 1142 #endif 1143 1144 /** 1145 * wlan_objmgr_peer_trace_deinit_lock() - Deinitialize peer trace lock 1146 * @peer: peer object pointer 1147 * 1148 * Return: void 1149 */ 1150 #ifdef WLAN_OBJMGR_REF_ID_TRACE 1151 static inline void 1152 wlan_objmgr_peer_trace_deinit_lock(struct wlan_objmgr_peer *peer) 1153 { 1154 wlan_objmgr_trace_deinit_lock(&peer->peer_objmgr.trace); 1155 } 1156 #else 1157 static inline void 1158 wlan_objmgr_peer_trace_deinit_lock(struct wlan_objmgr_peer *peer) 1159 { 1160 } 1161 #endif 1162 1163 /** 1164 * wlan_objmgr_peer_trace_del_ref_list() - Delete peer trace reference list 1165 * @peer: peer object pointer 1166 * 1167 * Return: void 1168 */ 1169 #ifdef WLAN_OBJMGR_REF_ID_TRACE 1170 static inline void 1171 wlan_objmgr_peer_trace_del_ref_list(struct wlan_objmgr_peer *peer) 1172 { 1173 wlan_objmgr_trace_del_ref_list(&peer->peer_objmgr.trace); 1174 } 1175 #else 1176 static inline void 1177 wlan_objmgr_peer_trace_del_ref_list(struct wlan_objmgr_peer *peer) 1178 { 1179 } 1180 #endif 1181 1182 #endif /* _WLAN_OBJMGR_PEER_OBJ_H_*/ 1183