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