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 28 /* peer flags */ 29 /* authorized for data */ 30 #define WLAN_PEER_F_AUTH 0x00000001 31 /* QoS enabled */ 32 #define WLAN_PEER_F_QOS 0x00000002 33 /* ERP enabled */ 34 #define WLAN_PEER_F_ERP 0x00000004 35 /* HT enabled */ 36 #define WLAN_PEER_F_HT 0x00000008 37 /* NB: tWLANhave the same value as IEEE80211_FC1_PWR_MGT */ 38 /* power save mode enabled */ 39 #define WLAN_PEER_F_PWR_MGT 0x00000010 40 /* keytsc for node has already been updated */ 41 #define WLAN_PEER_F_TSC_SET 0x00000020 42 /* U-APSD power save enabled */ 43 #define WLAN_PEER_F_UAPSD 0x00000040 44 /* U-APSD triggerable state */ 45 #define WLAN_PEER_F_UAPSD_TRIG 0x00000080 46 /* U-APSD SP in progress */ 47 #define WLAN_PEER_F_UAPSD_SP 0x00000100 48 /* Atheros Owl or follow-on device */ 49 #define WLAN_PEER_F_ATH 0x00000200 50 /* Owl WDS workaround needed*/ 51 #define WLAN_PEER_F_OWL_WDSWAR 0x00000400 52 /* WDS link */ 53 #define WLAN_PEER_F_WDS 0x00000800 54 /* No AMPDU support */ 55 #define WLAN_PEER_F_NOAMPDU 0x00001000 56 /* wep/tkip aggregation support */ 57 #define WLAN_PEER_F_WEPTKIPAGGR 0x00002000 58 #define WLAN_PEER_F_WEPTKIP 0x00004000 59 /* temp node (not in the node table) */ 60 #define WLAN_PEER_F_TEMP 0x00008000 61 /* 2.4ng VHT interop AMSDU disabled */ 62 #define WLAN_PEER_F_11NG_VHT_INTEROP_AMSDU_DISABLE 0x00010000 63 /* 40 MHz Intolerant */ 64 #define WLAN_PEER_F_40MHZ_INTOLERANT 0x00020000 65 /* node is paused*/ 66 #define WLAN_PEER_F_PAUSED 0x00040000 67 #define WLAN_PEER_F_EXTRADELIMWAR 0x00080000 68 /* 20 MHz requesting node */ 69 #define WLAN_PEER_F_REQ_20MHZ 0x00100000 70 /* all the tid queues in ath layer are paused*/ 71 #define WLAN_PEER_F_ATH_PAUSED 0x00200000 72 /*Require credit update*/ 73 #define WLAN_PEER_F_UAPSD_CREDIT_UPDATE 0x00400000 74 /*Require send deauth when h/w queue no data*/ 75 #define WLAN_PEER_F_KICK_OUT_DEAUTH 0x00800000 76 /* RRM enabled node */ 77 #define WLAN_PEER_F_RRM 0x01000000 78 /* Wakeup node */ 79 #define WLAN_PEER_F_WAKEUP 0x02000000 80 /* VHT enabled node */ 81 #define WLAN_PEER_F_VHT 0x04000000 82 /* deauth/Disassoc wait for node cleanup till frame goes on 83 air and tx feedback received */ 84 #define WLAN_PEER_F_DELAYED_CLEANUP 0x08000000 85 /* Extended stats enabled node */ 86 #define WLAN_PEER_F_EXT_STATS 0x10000000 87 /* Prevent _ieee80211_node_leave() from reentry */ 88 #define WLAN_PEER_F_LEAVE_ONGOING 0x20000000 89 /* band steering is enabled for this node */ 90 #define WLAN_PEER_F_BSTEERING_CAPABLE 0x40000000 91 /* node is a local mesh peer */ 92 #define WLAN_PEER_F_LOCAL_MESH_PEER 0x80000000 93 94 /** 95 * enum wlan_peer_state - peer state 96 * @WLAN_INIT_STATE: Default state 97 * @WLAN_JOIN_STATE: Station mode, STA is waiting for Join 98 * @WLAN_AUTH_STATE: AUTH in progress 99 * @WLAN_ASSOC_STATE: ASSOC in progress 100 * @WLAN_WAITKEY_STATE: 4-way KEY handshake is in progress 101 * @WLAN_CONNECTED_STATE: Connected state 102 * @WLAN_PREAUTH_STATE: Station mode: Preauth 103 * @WLAN_DISCONNECT_STATE: Disconnect is in progress 104 */ 105 enum wlan_peer_state { 106 WLAN_INIT_STATE = 1, 107 WLAN_JOIN_STATE = 2, 108 WLAN_AUTH_STATE = 3, 109 WLAN_ASSOC_STATE = 4, 110 WLAN_WAITKEY_STATE = 5, 111 WLAN_CONNECTED_STATE = 6, 112 WLAN_PREAUTH_STATE = 7, 113 WLAN_DISCONNECT_STATE = 8, 114 }; 115 116 /** 117 * struct wlan_objmgr_peer_mlme - mlme common data of peer 118 * @peer_capinfo: protocol cap info 119 * @peer_flags: PEER OP flags 120 * @peer_type: Type of PEER, (STA/AP/etc.) 121 * @phymode: phy mode of station 122 * @max_rate: Max Rate supported 123 * @state: State of the peer 124 * @seq_num: Sequence number 125 * @rssi: Last received RSSI value 126 */ 127 struct wlan_objmgr_peer_mlme { 128 uint32_t peer_capinfo; 129 uint32_t peer_flags; 130 enum wlan_peer_type peer_type; 131 enum wlan_phymode phymode; 132 uint32_t max_rate; 133 enum wlan_peer_state state; 134 uint16_t seq_num; 135 int8_t rssi; 136 bool is_authenticated; 137 }; 138 139 /** 140 * struct wlan_objmgr_peer_objmgr - object manager data of peer 141 * @vdev: VDEV pointer to which it is associated 142 * @ref_cnt: Ref count 143 * @ref_id_dbg: Array to track Ref count 144 * @print_cnt: Count to throttle Logical delete prints 145 */ 146 struct wlan_objmgr_peer_objmgr { 147 struct wlan_objmgr_vdev *vdev; 148 qdf_atomic_t ref_cnt; 149 qdf_atomic_t ref_id_dbg[WLAN_REF_ID_MAX]; 150 uint8_t print_cnt; 151 }; 152 153 /** 154 * struct wlan_peer_activity -- peer inactivity info 155 * 156 */ 157 struct wlan_peer_activity { /*TODO */ 158 159 }; 160 161 /** 162 * struct wlan_objmgr_peer - PEER common object 163 * @psoc_peer: peer list node for psoc's qdf list 164 * @vdev_peer: peer list node for vdev's qdf list 165 * @macaddr[]: Peer MAC address 166 * @peer_mlme: Peer MLME common structure 167 * @peer_activity: peer activity 168 * @peer_objmgr: Peer Object manager common structure 169 * @peer_comp_priv_obj[]: Component's private object pointers 170 * @obj_status[]: status of each component object 171 * @obj_state: Status of Peer object 172 * @dp_handle: DP module handle 173 * @peer_lock: Lock for access/update peer contents 174 */ 175 struct wlan_objmgr_peer { 176 qdf_list_node_t psoc_peer; 177 qdf_list_node_t vdev_peer; 178 uint8_t macaddr[QDF_MAC_ADDR_SIZE]; 179 struct wlan_objmgr_peer_mlme peer_mlme; 180 struct wlan_peer_activity peer_activity; 181 struct wlan_objmgr_peer_objmgr peer_objmgr; 182 void *peer_comp_priv_obj[WLAN_UMAC_MAX_COMPONENTS]; 183 QDF_STATUS obj_status[WLAN_UMAC_MAX_COMPONENTS]; 184 WLAN_OBJ_STATE obj_state; 185 void *dp_handle; 186 qdf_spinlock_t peer_lock; 187 }; 188 189 /** 190 ** APIs to Create/Delete Global object APIs 191 */ 192 /** 193 * wlan_objmgr_peer_obj_create() - peer object create 194 * @vdev: VDEV object on which this peer gets created 195 * @peer_type: peer type (AP/STA) 196 * @macaddr: MAC address 197 * 198 * Creates Peer object, intializes with default values 199 * Attaches to psoc and vdev objects 200 * Invokes the registered notifiers to create component object 201 * 202 * Return: Handle to struct wlan_objmgr_peer on successful creation, 203 * NULL on Failure (on Mem alloc failure and Component objects 204 * Failure) 205 */ 206 struct wlan_objmgr_peer *wlan_objmgr_peer_obj_create( 207 struct wlan_objmgr_vdev *vdev, 208 enum wlan_peer_type type, 209 uint8_t macaddr[]); 210 211 /** 212 * wlan_objmgr_peer_obj_delete() - peer object delete 213 * @peer: PEER object 214 * 215 * Deletes PEER object, removes it from PSOC's, VDEV's peer list 216 * Invokes the registered notifiers to destroy component objects 217 * 218 * Return: SUCCESS/FAILURE 219 */ 220 QDF_STATUS wlan_objmgr_peer_obj_delete(struct wlan_objmgr_peer *peer); 221 222 /** 223 ** APIs to attach/detach component objects 224 */ 225 /** 226 * wlan_objmgr_peer_component_obj_attach() - attach comp object to peer 227 * @peer: PEER object 228 * @id: Component id 229 * @comp_priv_obj: component's private object pointer 230 * @status: Component's private object creation status 231 * 232 * API to be used for attaching component object with PEER common object 233 * 234 * Return: SUCCESS on successful storing of component's object in common object 235 * On FAILURE (appropriate failure codes are returned) 236 */ 237 QDF_STATUS wlan_objmgr_peer_component_obj_attach( 238 struct wlan_objmgr_peer *peer, 239 enum wlan_umac_comp_id id, 240 void *comp_priv_obj, 241 QDF_STATUS status); 242 243 /** 244 * wlan_objmgr_peer_component_obj_detach() - detach comp object from peer 245 * @peer: PEER object 246 * @id: Component id 247 * @comp_priv_obj: component's private object pointer 248 * 249 * API to be used for detaching component object with PEER common object 250 * 251 * Return: SUCCESS on successful removal of component's object from common 252 * object 253 * On FAILURE (appropriate failure codes are returned) 254 */ 255 QDF_STATUS wlan_objmgr_peer_component_obj_detach( 256 struct wlan_objmgr_peer *peer, 257 enum wlan_umac_comp_id id, 258 void *comp_priv_obj); 259 260 /** 261 ** APIs to operations on peer objects 262 */ 263 264 /** 265 * wlan_objmgr_trigger_peer_comp_priv_object_creation() - create 266 * peer comp object 267 * @peer: PEER object 268 * @id: Component id 269 * 270 * API to create component private object in run time, this would 271 * be used for features which gets enabled in run time 272 * 273 * Return: SUCCESS on successful creation 274 * On FAILURE (appropriate failure codes are returned) 275 */ 276 QDF_STATUS wlan_objmgr_trigger_peer_comp_priv_object_creation( 277 struct wlan_objmgr_peer *peer, 278 enum wlan_umac_comp_id id); 279 280 /** 281 * wlan_objmgr_trigger_peer_comp_priv_object_deletion() - destroy 282 * peer comp object 283 * @peer: PEER object 284 * @id: Component id 285 * 286 * API to destroy component private object in run time, this would 287 * be used for features which gets disabled in run time 288 * 289 * Return: SUCCESS on successful deletion 290 * On FAILURE (appropriate failure codes are returned) 291 */ 292 QDF_STATUS wlan_objmgr_trigger_peer_comp_priv_object_deletion( 293 struct wlan_objmgr_peer *peer, 294 enum wlan_umac_comp_id id); 295 296 /** 297 * wlan_objmgr_peer_get_comp_private_obj() - get peer component private object 298 * @peer: PEER object 299 * @id: Component id 300 * 301 * API to get component private object 302 * 303 * Return: void *ptr on SUCCESS 304 * NULL on Failure 305 */ 306 void *wlan_objmgr_peer_get_comp_private_obj( 307 struct wlan_objmgr_peer *peer, 308 enum wlan_umac_comp_id id); 309 310 /** 311 * wlan_peer_obj_lock() - Acquire PEER spinlock 312 * @psoc: PEER object 313 * 314 * API to acquire PEER spin lock 315 * Parent lock should not be taken in child lock context 316 * but child lock can be taken in parent lock context 317 * (for ex: psoc lock can't be invoked in pdev/vdev/peer lock context) 318 * 319 * Return: void 320 */ 321 static inline void wlan_peer_obj_lock(struct wlan_objmgr_peer *peer) 322 { 323 qdf_spin_lock_bh(&peer->peer_lock); 324 } 325 326 /** 327 * wlan_peer_obj_unlock() - Release PEER spinlock 328 * @peer: PEER object 329 * 330 * API to Release PEER spin lock 331 * 332 * Return: void 333 */ 334 static inline void wlan_peer_obj_unlock(struct wlan_objmgr_peer *peer) 335 { 336 qdf_spin_unlock_bh(&peer->peer_lock); 337 } 338 339 /** 340 * DOC: Examples to use PEER ref count APIs 341 * 342 * In all the scenarios, the pair of API should be followed 343 * other it lead to memory leak 344 * 345 * scenario 1: 346 * 347 * wlan_objmgr_peer_obj_create() 348 * ---- 349 * wlan_objmgr_peer_obj_delete() 350 * 351 * scenario 2: 352 * 353 * wlan_objmgr_peer_get_ref() 354 * ---- 355 * the operations which are done on 356 * peer object 357 * ---- 358 * wlan_objmgr_peer_release_ref() 359 * 360 * scenario 3: 361 * 362 * API to retrieve peer (xxx_get_peer_xxx()) 363 * ---- 364 * the operations which are done on 365 * peer object 366 * ---- 367 * wlan_objmgr_peer_release_ref() 368 */ 369 370 /** 371 * wlan_objmgr_peer_get_ref() - increment ref count 372 * @peer: PEER object 373 * @id: Object Manager ref debug id 374 * 375 * API to increment ref count of peer 376 * 377 * Return: void 378 */ 379 void wlan_objmgr_peer_get_ref(struct wlan_objmgr_peer *peer, 380 wlan_objmgr_ref_dbgid id); 381 382 /** 383 * wlan_objmgr_peer_try_get_ref() - increment ref count, if allowed 384 * @peer: PEER object 385 * @id: Object Manager ref debug id 386 * 387 * API to increment ref count of peer, if object state is valid 388 * 389 * Return: void 390 */ 391 QDF_STATUS wlan_objmgr_peer_try_get_ref(struct wlan_objmgr_peer *peer, 392 wlan_objmgr_ref_dbgid id); 393 394 /** 395 * wlan_objmgr_peer_release_ref() - decrement ref count 396 * @peer: PEER object 397 * @id: Object Manager ref debug id 398 * 399 * API to decrement ref count of peer, if ref count is 1, it initiates the 400 * peer deletion 401 * 402 * Return: void 403 */ 404 void wlan_objmgr_peer_release_ref(struct wlan_objmgr_peer *peer, 405 wlan_objmgr_ref_dbgid id); 406 407 /** 408 * wlan_psoc_peer_list_peek_head() - get head of psoc peer list 409 * @peer_list: qdf_list_t 410 * 411 * API to get the head peer of given peer (of psoc's peer list) 412 * 413 * Caller need to acquire lock with wlan_peer_obj_lock() 414 * 415 * Return: 416 * @peer: head peer 417 */ 418 static inline struct wlan_objmgr_peer *wlan_psoc_peer_list_peek_head( 419 qdf_list_t *peer_list) 420 { 421 struct wlan_objmgr_peer *peer; 422 qdf_list_node_t *psoc_node = NULL; 423 424 /* This API is invoked with lock acquired, do not add log prints */ 425 if (qdf_list_peek_front(peer_list, &psoc_node) != QDF_STATUS_SUCCESS) 426 return NULL; 427 428 peer = qdf_container_of(psoc_node, struct wlan_objmgr_peer, psoc_peer); 429 return peer; 430 } 431 432 /** 433 * wlan_vdev_peer_list_peek_head() - get head of vdev peer list 434 * @peer_list: qdf_list_t 435 * 436 * API to get the head peer of given peer (of vdev's peer list) 437 * 438 * Caller need to acquire lock with wlan_peer_obj_lock() 439 * 440 * Return: 441 * @peer: head peer 442 */ 443 static inline struct wlan_objmgr_peer *wlan_vdev_peer_list_peek_head( 444 qdf_list_t *peer_list) 445 { 446 struct wlan_objmgr_peer *peer; 447 qdf_list_node_t *vdev_node = NULL; 448 449 /* This API is invoked with lock acquired, do not add log prints */ 450 if (qdf_list_peek_front(peer_list, &vdev_node) != QDF_STATUS_SUCCESS) 451 return NULL; 452 453 peer = qdf_container_of(vdev_node, struct wlan_objmgr_peer, vdev_peer); 454 return peer; 455 } 456 457 /** 458 * wlan_peer_get_next_peer_of_vdev() - get next peer of vdev list 459 * @peer: PEER object 460 * 461 * API to get the next peer of given peer (of vdev's peer list) 462 * 463 * Caller need to acquire lock with wlan_peer_obj_lock() 464 * 465 * Return: 466 * @next_peer: PEER object 467 */ 468 static inline struct wlan_objmgr_peer *wlan_peer_get_next_peer_of_vdev( 469 qdf_list_t *peer_list, struct wlan_objmgr_peer *peer) 470 { 471 struct wlan_objmgr_peer *peer_next; 472 qdf_list_node_t *node; 473 qdf_list_node_t *next_node = NULL; 474 475 /* This API is invoked with lock acquired, do not add log prints */ 476 if (peer == NULL) 477 return NULL; 478 479 node = &peer->vdev_peer; 480 if (qdf_list_peek_next(peer_list, node, &next_node) != 481 QDF_STATUS_SUCCESS) 482 return NULL; 483 484 peer_next = qdf_container_of(next_node, struct wlan_objmgr_peer, 485 vdev_peer); 486 return peer_next; 487 } 488 489 /** 490 * wlan_peer_set_next_peer_of_vdev() - add peer to vdev peer list 491 * @peer: PEER object 492 * @new_peer: PEER object 493 * 494 * API to set as the next peer to given peer (of vdev's peer list) 495 * 496 * Caller need to acquire lock with wlan_peer_obj_lock() 497 * 498 * Return: void 499 */ 500 static inline void wlan_peer_set_next_peer_of_vdev(qdf_list_t *peer_list, 501 struct wlan_objmgr_peer *new_peer) 502 { 503 /* This API is invoked with lock acquired, do not add log prints */ 504 /* set next peer with new peer */ 505 qdf_list_insert_back(peer_list, &new_peer->vdev_peer); 506 return; 507 } 508 509 /** 510 * wlan_peer_get_next_peer_of_psoc() - get next peer to psoc peer list 511 * @peer: PEER object 512 * 513 * API to get the next peer of given peer (of psoc'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_psoc( 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 = NULL; 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->psoc_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 psoc_peer); 538 return peer_next; 539 } 540 541 /** 542 * wlan_peer_set_next_peer_of_psoc() - add peer to psoc peer list 543 * @peer: PEER object 544 * @new_peer: PEER object 545 * 546 * API to set as the next peer to given peer (of psoc's peer list) 547 * 548 * Caller need to acquire lock with wlan_peer_obj_lock() 549 * 550 * Return: void 551 */ 552 static inline void wlan_peer_set_next_peer_of_psoc(qdf_list_t *peer_list, 553 struct wlan_objmgr_peer *new_peer) 554 { 555 /* This API is invoked with lock acquired, do not add log prints */ 556 /* set next peer with new peer */ 557 qdf_list_insert_back(peer_list, &new_peer->psoc_peer); 558 return; 559 } 560 561 /** 562 * wlan_peer_set_peer_type() - set peer type 563 * @peer: PEER object 564 * @peer_type: type of PEER 565 * 566 * API to set peer type 567 * 568 * Return: void 569 */ 570 static inline void wlan_peer_set_peer_type(struct wlan_objmgr_peer *peer, 571 enum wlan_peer_type type) 572 { 573 peer->peer_mlme.peer_type = type; 574 } 575 576 /** 577 * wlan_peer_get_peer_type() - get peer type 578 * @peer: PEER object 579 * 580 * API to get peer type 581 * 582 * Return: 583 * @peer_type: type of PEER 584 */ 585 static inline enum wlan_peer_type wlan_peer_get_peer_type( 586 struct wlan_objmgr_peer *peer) 587 { 588 return peer->peer_mlme.peer_type; 589 } 590 591 /** 592 * wlan_peer_set_macaddr() - set mac addr 593 * @peer: PEER object 594 * @macaddr: MAC address 595 * 596 * API to set peer mac address 597 * 598 * Caller need to acquire lock with wlan_peer_obj_lock() 599 * 600 * Return: void 601 */ 602 static inline void wlan_peer_set_macaddr(struct wlan_objmgr_peer *peer, 603 uint8_t *macaddr) 604 { 605 /* This API is invoked with lock acquired, do not add log prints */ 606 WLAN_ADDR_COPY(peer->macaddr, macaddr); 607 } 608 609 /** 610 * wlan_peer_get_macaddr() - get mac addr 611 * @peer: PEER object 612 * 613 * API to get peer mac address 614 * 615 * Caller need to acquire lock with wlan_peer_obj_lock() 616 * 617 * Return: 618 * @macaddr: MAC address 619 */ 620 static inline uint8_t *wlan_peer_get_macaddr(struct wlan_objmgr_peer *peer) 621 { 622 /* This API is invoked with lock acquired, do not add log prints */ 623 return peer->macaddr; 624 } 625 626 /** 627 * wlan_peer_get_vdev() - get vdev 628 * @peer: PEER object 629 * 630 * API to get peer's vdev 631 * 632 * Return: 633 * @vdev: VDEV object 634 */ 635 static inline struct wlan_objmgr_vdev *wlan_peer_get_vdev( 636 struct wlan_objmgr_peer *peer) 637 { 638 return peer->peer_objmgr.vdev; 639 } 640 641 /** 642 * wlan_peer_set_vdev() - set vdev 643 * @peer: PEER object 644 * @vdev: VDEV object 645 * 646 * API to set peer's vdev 647 * 648 * Return: void 649 */ 650 static inline void wlan_peer_set_vdev(struct wlan_objmgr_peer *peer, 651 struct wlan_objmgr_vdev *vdev) 652 { 653 peer->peer_objmgr.vdev = vdev; 654 } 655 656 /** 657 * wlan_peer_mlme_flag_set() - mlme flag set 658 * @peer: PEER object 659 * @flag: flag to be set 660 * 661 * API to set flag in peer 662 * 663 * Return: void 664 */ 665 static inline void wlan_peer_mlme_flag_set(struct wlan_objmgr_peer *peer, 666 uint32_t flag) 667 { 668 peer->peer_mlme.peer_flags |= flag; 669 } 670 671 /** 672 * wlan_peer_mlme_flag_clear() - mlme flag clear 673 * @peer: PEER object 674 * @flag: flag to be cleared 675 * 676 * API to clear flag in peer 677 * 678 * Return: void 679 */ 680 static inline void wlan_peer_mlme_flag_clear(struct wlan_objmgr_peer *peer, 681 uint32_t flag) 682 { 683 peer->peer_mlme.peer_flags &= ~flag; 684 } 685 686 /** 687 * wlan_peer_mlme_flag_get() - mlme flag get 688 * @peer: PEER object 689 * @flag: flag to be checked 690 * 691 * API to know, whether particular flag is set in peer 692 * 693 * Return: 1 (for set) or 0 (for not set) 694 */ 695 static inline uint8_t wlan_peer_mlme_flag_get(struct wlan_objmgr_peer *peer, 696 uint32_t flag) 697 { 698 return (peer->peer_mlme.peer_flags & flag) ? 1 : 0; 699 } 700 701 /** 702 * wlan_peer_mlme_set_state() - peer mlme state 703 * @peer: PEER object 704 * @state: enum wlan_peer_state 705 * 706 * API to update the current peer state 707 * 708 * Return: void 709 */ 710 static inline void wlan_peer_mlme_set_state( 711 struct wlan_objmgr_peer *peer, 712 enum wlan_peer_state state) 713 { 714 peer->peer_mlme.state = state; 715 } 716 717 /** 718 * wlan_peer_mlme_set_auth_state() - peer mlme auth state 719 * @peer: PEER object 720 * @is_authenticated: true or false 721 * 722 * API to update the current peer auth state 723 * 724 * Return: void 725 */ 726 static inline void wlan_peer_mlme_set_auth_state( 727 struct wlan_objmgr_peer *peer, 728 bool is_authenticated) 729 { 730 peer->peer_mlme.is_authenticated = is_authenticated; 731 } 732 733 /** 734 * wlan_peer_mlme_get_state() - peer mlme state 735 * @peer: PEER object 736 * 737 * API to get peer state 738 * 739 * Return: enum wlan_peer_state 740 */ 741 static inline enum wlan_peer_state wlan_peer_mlme_get_state( 742 struct wlan_objmgr_peer *peer) 743 { 744 return peer->peer_mlme.state; 745 } 746 747 /** 748 * wlan_peer_mlme_get_auth_state() - peer mlme auth state 749 * @peer: PEER object 750 * 751 * API to get peer auth state 752 * 753 * Return: auth state true/false 754 */ 755 static inline bool wlan_peer_mlme_get_auth_state( 756 struct wlan_objmgr_peer *peer) 757 { 758 return peer->peer_mlme.is_authenticated; 759 } 760 761 /** 762 * wlan_peer_mlme_get_next_seq_num() - get peer mlme next sequence number 763 * @peer: PEER object 764 * 765 * API to get mlme peer next sequence number 766 * 767 * Caller need to acquire lock with wlan_peer_obj_lock() 768 * 769 * Return: peer mlme next sequence number 770 */ 771 static inline uint32_t wlan_peer_mlme_get_next_seq_num( 772 struct wlan_objmgr_peer *peer) 773 { 774 /* This API is invoked with lock acquired, do not add log prints */ 775 if (peer->peer_mlme.seq_num < WLAN_MAX_SEQ_NUM) 776 peer->peer_mlme.seq_num++; 777 else 778 peer->peer_mlme.seq_num = 0; 779 780 return peer->peer_mlme.seq_num; 781 } 782 783 /** 784 * wlan_peer_mlme_get_seq_num() - get peer mlme sequence number 785 * @peer: PEER object 786 * 787 * API to get mlme peer sequence number 788 * 789 * Caller need to acquire lock with wlan_peer_obj_lock() 790 * 791 * Return: peer mlme sequence number 792 */ 793 static inline uint32_t wlan_peer_mlme_get_seq_num( 794 struct wlan_objmgr_peer *peer) 795 { 796 /* This API is invoked with lock acquired, do not add log prints */ 797 return peer->peer_mlme.seq_num; 798 } 799 800 /** 801 * wlan_peer_mlme_reset_seq_num() - reset peer mlme sequence number 802 * @peer: PEER object 803 * 804 * API to reset peer sequence number 805 * 806 * Caller need to acquire lock with wlan_peer_obj_lock() 807 * 808 * Return: void 809 */ 810 static inline void wlan_peer_mlme_reset_seq_num( 811 struct wlan_objmgr_peer *peer) 812 { 813 /* This API is invoked with lock acquired, do not add log prints */ 814 peer->peer_mlme.seq_num = 0; 815 } 816 817 /** 818 * wlan_peer_set_dp_handle() - set dp handle 819 * @peer: peer object pointer 820 * @dp_handle: Data path module handle 821 * 822 * Return: void 823 */ 824 static inline void wlan_peer_set_dp_handle(struct wlan_objmgr_peer *peer, 825 void *dp_handle) 826 { 827 if (qdf_unlikely(!peer)) { 828 QDF_BUG(0); 829 return; 830 } 831 832 peer->dp_handle = dp_handle; 833 } 834 835 /** 836 * wlan_peer_get_dp_handle() - get dp handle 837 * @peer: peer object pointer 838 * 839 * Return: dp handle 840 */ 841 static inline void *wlan_peer_get_dp_handle(struct wlan_objmgr_peer *peer) 842 { 843 if (qdf_unlikely(!peer)) { 844 QDF_BUG(0); 845 return NULL; 846 } 847 848 return peer->dp_handle; 849 } 850 851 #endif /* _WLAN_OBJMGR_PEER_OBJ_H_*/ 852