1 /* 2 * Copyright (c) 2016-2017 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 * @rssi: Last received RSSI value 123 * @max_rate: Max Rate supported 124 * @seq_num: Sequence number 125 * @state: State of the peer 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 int8_t rssi; 133 uint32_t max_rate; 134 uint16_t seq_num; 135 enum wlan_peer_state state; 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 * @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[WLAN_MACADDR_LEN]; 178 struct wlan_objmgr_peer_mlme peer_mlme; 179 struct wlan_peer_activity peer_activity; 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 qdf_spinlock_t peer_lock; 185 }; 186 187 /** 188 ** APIs to Create/Delete Global object APIs 189 */ 190 /** 191 * wlan_objmgr_peer_obj_create() - peer object create 192 * @vdev: VDEV object on which this peer gets created 193 * @peer_type: peer type (AP/STA) 194 * @macaddr: MAC address 195 * 196 * Creates Peer object, intializes with default values 197 * Attaches to psoc and vdev objects 198 * Invokes the registered notifiers to create component object 199 * 200 * Return: Handle to struct wlan_objmgr_peer on successful creation, 201 * NULL on Failure (on Mem alloc failure and Component objects 202 * Failure) 203 */ 204 struct wlan_objmgr_peer *wlan_objmgr_peer_obj_create( 205 struct wlan_objmgr_vdev *vdev, 206 enum wlan_peer_type type, 207 uint8_t macaddr[]); 208 209 /** 210 * wlan_objmgr_peer_obj_delete() - peer object delete 211 * @peer: PEER object 212 * 213 * Deletes PEER object, removes it from PSOC's, VDEV's peer list 214 * Invokes the registered notifiers to destroy component objects 215 * 216 * Return: SUCCESS/FAILURE 217 */ 218 QDF_STATUS wlan_objmgr_peer_obj_delete(struct wlan_objmgr_peer *peer); 219 220 /** 221 ** APIs to attach/detach component objects 222 */ 223 /** 224 * wlan_objmgr_peer_component_obj_attach() - attach comp object to peer 225 * @peer: PEER object 226 * @id: Component id 227 * @comp_priv_obj: component's private object pointer 228 * @status: Component's private object creation status 229 * 230 * API to be used for attaching component object with PEER common object 231 * 232 * Return: SUCCESS on successful storing of component's object in common object 233 * On FAILURE (appropriate failure codes are returned) 234 */ 235 QDF_STATUS wlan_objmgr_peer_component_obj_attach( 236 struct wlan_objmgr_peer *peer, 237 enum wlan_umac_comp_id id, 238 void *comp_priv_obj, 239 QDF_STATUS status); 240 241 /** 242 * wlan_objmgr_peer_component_obj_detach() - detach comp object from peer 243 * @peer: PEER object 244 * @id: Component id 245 * @comp_priv_obj: component's private object pointer 246 * 247 * API to be used for detaching component object with PEER common object 248 * 249 * Return: SUCCESS on successful removal of component's object from common 250 * object 251 * On FAILURE (appropriate failure codes are returned) 252 */ 253 QDF_STATUS wlan_objmgr_peer_component_obj_detach( 254 struct wlan_objmgr_peer *peer, 255 enum wlan_umac_comp_id id, 256 void *comp_priv_obj); 257 258 /** 259 ** APIs to operations on peer objects 260 */ 261 262 /** 263 * wlan_objmgr_trigger_peer_comp_priv_object_creation() - create 264 * peer comp object 265 * @peer: PEER object 266 * @id: Component id 267 * 268 * API to create component private object in run time, this would 269 * be used for features which gets enabled in run time 270 * 271 * Return: SUCCESS on successful creation 272 * On FAILURE (appropriate failure codes are returned) 273 */ 274 QDF_STATUS wlan_objmgr_trigger_peer_comp_priv_object_creation( 275 struct wlan_objmgr_peer *peer, 276 enum wlan_umac_comp_id id); 277 278 /** 279 * wlan_objmgr_trigger_peer_comp_priv_object_deletion() - destroy 280 * peer comp object 281 * @peer: PEER object 282 * @id: Component id 283 * 284 * API to destroy component private object in run time, this would 285 * be used for features which gets disabled in run time 286 * 287 * Return: SUCCESS on successful deletion 288 * On FAILURE (appropriate failure codes are returned) 289 */ 290 QDF_STATUS wlan_objmgr_trigger_peer_comp_priv_object_deletion( 291 struct wlan_objmgr_peer *peer, 292 enum wlan_umac_comp_id id); 293 294 /** 295 * wlan_objmgr_peer_get_comp_private_obj() - get peer component private object 296 * @peer: PEER object 297 * @id: Component id 298 * 299 * API to get component private object 300 * 301 * Return: void *ptr on SUCCESS 302 * NULL on Failure 303 */ 304 void *wlan_objmgr_peer_get_comp_private_obj( 305 struct wlan_objmgr_peer *peer, 306 enum wlan_umac_comp_id id); 307 308 /** 309 * wlan_peer_obj_lock() - Acquire PEER spinlock 310 * @psoc: PEER object 311 * 312 * API to acquire PEER spin lock 313 * Parent lock should not be taken in child lock context 314 * but child lock can be taken in parent lock context 315 * (for ex: psoc lock can't be invoked in pdev/vdev/peer lock context) 316 * 317 * Return: void 318 */ 319 static inline void wlan_peer_obj_lock(struct wlan_objmgr_peer *peer) 320 { 321 qdf_spin_lock_bh(&peer->peer_lock); 322 } 323 324 /** 325 * wlan_peer_obj_unlock() - Release PEER spinlock 326 * @peer: PEER object 327 * 328 * API to Release PEER spin lock 329 * 330 * Return: void 331 */ 332 static inline void wlan_peer_obj_unlock(struct wlan_objmgr_peer *peer) 333 { 334 qdf_spin_unlock_bh(&peer->peer_lock); 335 } 336 337 /** 338 * DOC: Examples to use PEER ref count APIs 339 * 340 * In all the scenarios, the pair of API should be followed 341 * other it lead to memory leak 342 * 343 * scenario 1: 344 * 345 * wlan_objmgr_peer_obj_create() 346 * ---- 347 * wlan_objmgr_peer_obj_delete() 348 * 349 * scenario 2: 350 * 351 * wlan_objmgr_peer_get_ref() 352 * ---- 353 * the operations which are done on 354 * peer object 355 * ---- 356 * wlan_objmgr_peer_release_ref() 357 * 358 * scenario 3: 359 * 360 * API to retrieve peer (xxx_get_peer_xxx()) 361 * ---- 362 * the operations which are done on 363 * peer object 364 * ---- 365 * wlan_objmgr_peer_release_ref() 366 */ 367 368 /** 369 * wlan_objmgr_peer_get_ref() - increment ref count 370 * @peer: PEER object 371 * @id: Object Manager ref debug id 372 * 373 * API to increment ref count of peer 374 * 375 * Return: void 376 */ 377 void wlan_objmgr_peer_get_ref(struct wlan_objmgr_peer *peer, 378 wlan_objmgr_ref_dbgid id); 379 380 /** 381 * wlan_objmgr_peer_try_get_ref() - increment ref count, if allowed 382 * @peer: PEER object 383 * @id: Object Manager ref debug id 384 * 385 * API to increment ref count of peer, if object state is valid 386 * 387 * Return: void 388 */ 389 QDF_STATUS wlan_objmgr_peer_try_get_ref(struct wlan_objmgr_peer *peer, 390 wlan_objmgr_ref_dbgid id); 391 392 /** 393 * wlan_objmgr_peer_release_ref() - decrement ref count 394 * @peer: PEER object 395 * @id: Object Manager ref debug id 396 * 397 * API to decrement ref count of peer, if ref count is 1, it initiates the 398 * peer deletion 399 * 400 * Return: void 401 */ 402 void wlan_objmgr_peer_release_ref(struct wlan_objmgr_peer *peer, 403 wlan_objmgr_ref_dbgid id); 404 405 /** 406 * wlan_psoc_peer_list_peek_head() - get head of psoc peer list 407 * @peer_list: qdf_list_t 408 * 409 * API to get the head peer of given peer (of psoc's peer list) 410 * 411 * Caller need to acquire lock with wlan_peer_obj_lock() 412 * 413 * Return: 414 * @peer: head peer 415 */ 416 static inline struct wlan_objmgr_peer *wlan_psoc_peer_list_peek_head( 417 qdf_list_t *peer_list) 418 { 419 struct wlan_objmgr_peer *peer; 420 qdf_list_node_t *psoc_node = NULL; 421 422 /* This API is invoked with lock acquired, do not add log prints */ 423 if (qdf_list_peek_front(peer_list, &psoc_node) != QDF_STATUS_SUCCESS) 424 return NULL; 425 426 peer = qdf_container_of(psoc_node, struct wlan_objmgr_peer, psoc_peer); 427 return peer; 428 } 429 430 /** 431 * wlan_vdev_peer_list_peek_head() - get head of vdev peer list 432 * @peer_list: qdf_list_t 433 * 434 * API to get the head peer of given peer (of vdev's peer list) 435 * 436 * Caller need to acquire lock with wlan_peer_obj_lock() 437 * 438 * Return: 439 * @peer: head peer 440 */ 441 static inline struct wlan_objmgr_peer *wlan_vdev_peer_list_peek_head( 442 qdf_list_t *peer_list) 443 { 444 struct wlan_objmgr_peer *peer; 445 qdf_list_node_t *vdev_node = NULL; 446 447 /* This API is invoked with lock acquired, do not add log prints */ 448 if (qdf_list_peek_front(peer_list, &vdev_node) != QDF_STATUS_SUCCESS) 449 return NULL; 450 451 peer = qdf_container_of(vdev_node, struct wlan_objmgr_peer, vdev_peer); 452 return peer; 453 } 454 455 /** 456 * wlan_peer_get_next_peer_of_vdev() - get next peer of vdev list 457 * @peer: PEER object 458 * 459 * API to get the next peer of given peer (of vdev's peer list) 460 * 461 * Caller need to acquire lock with wlan_peer_obj_lock() 462 * 463 * Return: 464 * @next_peer: PEER object 465 */ 466 static inline struct wlan_objmgr_peer *wlan_peer_get_next_peer_of_vdev( 467 qdf_list_t *peer_list, struct wlan_objmgr_peer *peer) 468 { 469 struct wlan_objmgr_peer *peer_next; 470 qdf_list_node_t *node; 471 qdf_list_node_t *next_node = NULL; 472 473 /* This API is invoked with lock acquired, do not add log prints */ 474 if (peer == NULL) 475 return NULL; 476 477 node = &peer->vdev_peer; 478 if (qdf_list_peek_next(peer_list, node, &next_node) != 479 QDF_STATUS_SUCCESS) 480 return NULL; 481 482 peer_next = qdf_container_of(next_node, struct wlan_objmgr_peer, 483 vdev_peer); 484 return peer_next; 485 } 486 487 /** 488 * wlan_peer_set_next_peer_of_vdev() - add peer to vdev peer list 489 * @peer: PEER object 490 * @new_peer: PEER object 491 * 492 * API to set as the next peer to given peer (of vdev's peer list) 493 * 494 * Caller need to acquire lock with wlan_peer_obj_lock() 495 * 496 * Return: void 497 */ 498 static inline void wlan_peer_set_next_peer_of_vdev(qdf_list_t *peer_list, 499 struct wlan_objmgr_peer *new_peer) 500 { 501 /* This API is invoked with lock acquired, do not add log prints */ 502 /* set next peer with new peer */ 503 qdf_list_insert_back(peer_list, &new_peer->vdev_peer); 504 return; 505 } 506 507 /** 508 * wlan_peer_get_next_peer_of_psoc() - get next peer to psoc peer list 509 * @peer: PEER object 510 * 511 * API to get the next peer of given peer (of psoc's peer list) 512 * 513 * Caller need to acquire lock with wlan_peer_obj_lock() 514 * 515 * Return: 516 * @next_peer: PEER object 517 */ 518 static inline struct wlan_objmgr_peer *wlan_peer_get_next_peer_of_psoc( 519 qdf_list_t *peer_list, struct wlan_objmgr_peer *peer) 520 { 521 struct wlan_objmgr_peer *peer_next; 522 qdf_list_node_t *node = NULL; 523 qdf_list_node_t *next_node = NULL; 524 525 /* This API is invoked with lock acquired, do not add log prints */ 526 if (peer == NULL) 527 return NULL; 528 529 node = &peer->psoc_peer; 530 if (qdf_list_peek_next(peer_list, node, &next_node) != 531 QDF_STATUS_SUCCESS) 532 return NULL; 533 534 peer_next = qdf_container_of(next_node, struct wlan_objmgr_peer, 535 psoc_peer); 536 return peer_next; 537 } 538 539 /** 540 * wlan_peer_set_next_peer_of_psoc() - add peer to psoc peer list 541 * @peer: PEER object 542 * @new_peer: PEER object 543 * 544 * API to set as the next peer to given peer (of psoc's peer list) 545 * 546 * Caller need to acquire lock with wlan_peer_obj_lock() 547 * 548 * Return: void 549 */ 550 static inline void wlan_peer_set_next_peer_of_psoc(qdf_list_t *peer_list, 551 struct wlan_objmgr_peer *new_peer) 552 { 553 /* This API is invoked with lock acquired, do not add log prints */ 554 /* set next peer with new peer */ 555 qdf_list_insert_back(peer_list, &new_peer->psoc_peer); 556 return; 557 } 558 559 /** 560 * wlan_peer_set_peer_type() - set peer type 561 * @peer: PEER object 562 * @peer_type: type of PEER 563 * 564 * API to set peer type 565 * 566 * Return: void 567 */ 568 static inline void wlan_peer_set_peer_type(struct wlan_objmgr_peer *peer, 569 enum wlan_peer_type type) 570 { 571 peer->peer_mlme.peer_type = type; 572 } 573 574 /** 575 * wlan_peer_get_peer_type() - get peer type 576 * @peer: PEER object 577 * 578 * API to get peer type 579 * 580 * Return: 581 * @peer_type: type of PEER 582 */ 583 static inline enum wlan_peer_type wlan_peer_get_peer_type( 584 struct wlan_objmgr_peer *peer) 585 { 586 return peer->peer_mlme.peer_type; 587 } 588 589 /** 590 * wlan_peer_set_macaddr() - set mac addr 591 * @peer: PEER object 592 * @macaddr: MAC address 593 * 594 * API to set peer mac address 595 * 596 * Caller need to acquire lock with wlan_peer_obj_lock() 597 * 598 * Return: void 599 */ 600 static inline void wlan_peer_set_macaddr(struct wlan_objmgr_peer *peer, 601 uint8_t *macaddr) 602 { 603 /* This API is invoked with lock acquired, do not add log prints */ 604 WLAN_ADDR_COPY(peer->macaddr, macaddr); 605 } 606 607 /** 608 * wlan_peer_get_macaddr() - get mac addr 609 * @peer: PEER object 610 * 611 * API to get peer mac address 612 * 613 * Caller need to acquire lock with wlan_peer_obj_lock() 614 * 615 * Return: 616 * @macaddr: MAC address 617 */ 618 static inline uint8_t *wlan_peer_get_macaddr(struct wlan_objmgr_peer *peer) 619 { 620 /* This API is invoked with lock acquired, do not add log prints */ 621 return peer->macaddr; 622 } 623 624 /** 625 * wlan_peer_get_vdev() - get vdev 626 * @peer: PEER object 627 * 628 * API to get peer's vdev 629 * 630 * Return: 631 * @vdev: VDEV object 632 */ 633 static inline struct wlan_objmgr_vdev *wlan_peer_get_vdev( 634 struct wlan_objmgr_peer *peer) 635 { 636 return peer->peer_objmgr.vdev; 637 } 638 639 /** 640 * wlan_peer_set_vdev() - set vdev 641 * @peer: PEER object 642 * @vdev: VDEV object 643 * 644 * API to set peer's vdev 645 * 646 * Return: void 647 */ 648 static inline void wlan_peer_set_vdev(struct wlan_objmgr_peer *peer, 649 struct wlan_objmgr_vdev *vdev) 650 { 651 peer->peer_objmgr.vdev = vdev; 652 } 653 654 /** 655 * wlan_peer_mlme_flag_set() - mlme flag set 656 * @peer: PEER object 657 * @flag: flag to be set 658 * 659 * API to set flag in peer 660 * 661 * Return: void 662 */ 663 static inline void wlan_peer_mlme_flag_set(struct wlan_objmgr_peer *peer, 664 uint32_t flag) 665 { 666 peer->peer_mlme.peer_flags |= flag; 667 } 668 669 /** 670 * wlan_peer_mlme_flag_clear() - mlme flag clear 671 * @peer: PEER object 672 * @flag: flag to be cleared 673 * 674 * API to clear flag in peer 675 * 676 * Return: void 677 */ 678 static inline void wlan_peer_mlme_flag_clear(struct wlan_objmgr_peer *peer, 679 uint32_t flag) 680 { 681 peer->peer_mlme.peer_flags &= ~flag; 682 } 683 684 /** 685 * wlan_peer_mlme_flag_get() - mlme flag get 686 * @peer: PEER object 687 * @flag: flag to be checked 688 * 689 * API to know, whether particular flag is set in peer 690 * 691 * Return: 1 (for set) or 0 (for not set) 692 */ 693 static inline uint8_t wlan_peer_mlme_flag_get(struct wlan_objmgr_peer *peer, 694 uint32_t flag) 695 { 696 return (peer->peer_mlme.peer_flags & flag) ? 1 : 0; 697 } 698 699 /** 700 * wlan_peer_mlme_set_state() - peer mlme state 701 * @peer: PEER object 702 * @state: enum wlan_peer_state 703 * 704 * API to update the current peer state 705 * 706 * Return: void 707 */ 708 static inline void wlan_peer_mlme_set_state( 709 struct wlan_objmgr_peer *peer, 710 enum wlan_peer_state state) 711 { 712 peer->peer_mlme.state = state; 713 } 714 715 /** 716 * wlan_peer_mlme_set_auth_state() - peer mlme auth state 717 * @peer: PEER object 718 * @is_authenticated: true or false 719 * 720 * API to update the current peer auth state 721 * 722 * Return: void 723 */ 724 static inline void wlan_peer_mlme_set_auth_state( 725 struct wlan_objmgr_peer *peer, 726 bool is_authenticated) 727 { 728 peer->peer_mlme.is_authenticated = is_authenticated; 729 } 730 731 /** 732 * wlan_peer_mlme_get_state() - peer mlme state 733 * @peer: PEER object 734 * 735 * API to get peer state 736 * 737 * Return: enum wlan_peer_state 738 */ 739 static inline enum wlan_peer_state wlan_peer_mlme_get_state( 740 struct wlan_objmgr_peer *peer) 741 { 742 return peer->peer_mlme.state; 743 } 744 745 /** 746 * wlan_peer_mlme_get_auth_state() - peer mlme auth state 747 * @peer: PEER object 748 * 749 * API to get peer auth state 750 * 751 * Return: auth state true/false 752 */ 753 static inline bool wlan_peer_mlme_get_auth_state( 754 struct wlan_objmgr_peer *peer) 755 { 756 return peer->peer_mlme.is_authenticated; 757 } 758 759 /** 760 * wlan_peer_mlme_get_next_seq_num() - get peer mlme next sequence number 761 * @peer: PEER object 762 * 763 * API to get mlme peer next sequence number 764 * 765 * Caller need to acquire lock with wlan_peer_obj_lock() 766 * 767 * Return: peer mlme next sequence number 768 */ 769 static inline uint32_t wlan_peer_mlme_get_next_seq_num( 770 struct wlan_objmgr_peer *peer) 771 { 772 /* This API is invoked with lock acquired, do not add log prints */ 773 if (peer->peer_mlme.seq_num < WLAN_MAX_SEQ_NUM) 774 peer->peer_mlme.seq_num++; 775 else 776 peer->peer_mlme.seq_num = 0; 777 778 return peer->peer_mlme.seq_num; 779 } 780 781 /** 782 * wlan_peer_mlme_get_seq_num() - get peer mlme sequence number 783 * @peer: PEER object 784 * 785 * API to get mlme peer sequence number 786 * 787 * Caller need to acquire lock with wlan_peer_obj_lock() 788 * 789 * Return: peer mlme sequence number 790 */ 791 static inline uint32_t wlan_peer_mlme_get_seq_num( 792 struct wlan_objmgr_peer *peer) 793 { 794 /* This API is invoked with lock acquired, do not add log prints */ 795 return peer->peer_mlme.seq_num; 796 } 797 798 /** 799 * wlan_peer_mlme_reset_seq_num() - reset peer mlme sequence number 800 * @peer: PEER object 801 * 802 * API to reset peer sequence number 803 * 804 * Caller need to acquire lock with wlan_peer_obj_lock() 805 * 806 * Return: void 807 */ 808 static inline void wlan_peer_mlme_reset_seq_num( 809 struct wlan_objmgr_peer *peer) 810 { 811 /* This API is invoked with lock acquired, do not add log prints */ 812 peer->peer_mlme.seq_num = 0; 813 } 814 815 #endif /* _WLAN_OBJMGR_PEER_OBJ_H_*/ 816