xref: /wlan-dirver/qca-wifi-host-cmn/umac/cmn_services/obj_mgr/inc/wlan_objmgr_peer_obj.h (revision 4865edfd190c086bbe2c69aae12a8226f877b91e)
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_vdev_peer_list_peek_head() - get head of vdev peer list
437  * @peer_list: qdf_list_t
438  *
439  * API to get the head peer of given peer (of vdev's peer list)
440  *
441  * Caller need to acquire lock with wlan_peer_obj_lock()
442  *
443  * Return:
444  * @peer: head peer
445  */
446 static inline struct wlan_objmgr_peer *wlan_vdev_peer_list_peek_head(
447 					qdf_list_t *peer_list)
448 {
449 	struct wlan_objmgr_peer *peer;
450 	qdf_list_node_t *vdev_node = NULL;
451 
452 	/* This API is invoked with lock acquired, do not add log prints */
453 	if (qdf_list_peek_front(peer_list, &vdev_node) != QDF_STATUS_SUCCESS)
454 		return NULL;
455 
456 	peer = qdf_container_of(vdev_node, struct wlan_objmgr_peer, vdev_peer);
457 	return peer;
458 }
459 
460 /**
461  * wlan_peer_get_next_peer_of_vdev() - get next peer of vdev list
462  * @peer: PEER object
463  *
464  * API to get the next peer of given peer (of vdev's peer list)
465  *
466  * Caller need to acquire lock with wlan_peer_obj_lock()
467  *
468  * Return:
469  * @next_peer: PEER object
470  */
471 static inline struct wlan_objmgr_peer *wlan_peer_get_next_peer_of_vdev(
472 			qdf_list_t *peer_list, struct wlan_objmgr_peer *peer)
473 {
474 	struct wlan_objmgr_peer *peer_next;
475 	qdf_list_node_t *node;
476 	qdf_list_node_t *next_node = NULL;
477 
478 	/* This API is invoked with lock acquired, do not add log prints */
479 	if (peer == NULL)
480 		return NULL;
481 
482 	node = &peer->vdev_peer;
483 	if (qdf_list_peek_next(peer_list, node, &next_node) !=
484 						QDF_STATUS_SUCCESS)
485 		return NULL;
486 
487 	peer_next = qdf_container_of(next_node, struct wlan_objmgr_peer,
488 					vdev_peer);
489 	return peer_next;
490 }
491 
492 /**
493  * wlan_peer_set_next_peer_of_vdev() - add peer to vdev peer list
494  * @peer: PEER object
495  * @new_peer: PEER object
496  *
497  * API to set as the next peer to given peer (of vdev's peer list)
498  *
499  * Caller need to acquire lock with wlan_peer_obj_lock()
500  *
501  * Return: void
502  */
503 static inline void wlan_peer_set_next_peer_of_vdev(qdf_list_t *peer_list,
504 				struct wlan_objmgr_peer *new_peer)
505 {
506 	/* This API is invoked with lock acquired, do not add log prints */
507 	/* set next peer with new peer */
508 	qdf_list_insert_back(peer_list, &new_peer->vdev_peer);
509 	return;
510 }
511 
512 /**
513  * wlan_peer_get_next_peer_of_psoc() - get next peer to psoc peer list
514  * @peer: PEER object
515  *
516  * API to get the next peer of given peer (of psoc's peer list)
517  *
518  * Caller need to acquire lock with wlan_peer_obj_lock()
519  *
520  * Return:
521  * @next_peer: PEER object
522  */
523 static inline struct wlan_objmgr_peer *wlan_peer_get_next_peer_of_psoc(
524 			qdf_list_t *peer_list, struct wlan_objmgr_peer *peer)
525 {
526 	struct wlan_objmgr_peer *peer_next;
527 	qdf_list_node_t *node = NULL;
528 	qdf_list_node_t *next_node = NULL;
529 
530 	/* This API is invoked with lock acquired, do not add log prints */
531 	if (peer == NULL)
532 		return NULL;
533 
534 	node = &peer->psoc_peer;
535 	if (qdf_list_peek_next(peer_list, node, &next_node) !=
536 						QDF_STATUS_SUCCESS)
537 		return NULL;
538 
539 	peer_next = qdf_container_of(next_node, struct wlan_objmgr_peer,
540 					psoc_peer);
541 	return peer_next;
542 }
543 
544 /**
545  * wlan_peer_set_next_peer_of_psoc() - add peer to psoc peer list
546  * @peer: PEER object
547  * @new_peer: PEER object
548  *
549  * API to set as the next peer to given peer (of psoc's peer list)
550  *
551  * Caller need to acquire lock with wlan_peer_obj_lock()
552  *
553  * Return: void
554  */
555 static inline void wlan_peer_set_next_peer_of_psoc(qdf_list_t *peer_list,
556 					struct wlan_objmgr_peer *new_peer)
557 {
558 	/* This API is invoked with lock acquired, do not add log prints */
559 	/* set next peer with new peer */
560 	qdf_list_insert_back(peer_list, &new_peer->psoc_peer);
561 	return;
562 }
563 
564 /**
565  * wlan_peer_set_peer_type() - set peer type
566  * @peer: PEER object
567  * @peer_type: type of PEER
568  *
569  * API to set peer type
570  *
571  * Return: void
572  */
573 static inline void wlan_peer_set_peer_type(struct wlan_objmgr_peer *peer,
574 			enum wlan_peer_type type)
575 {
576 	peer->peer_mlme.peer_type = type;
577 }
578 
579 /**
580  * wlan_peer_get_peer_type() - get peer type
581  * @peer: PEER object
582  *
583  * API to get peer type
584  *
585  * Return:
586  * @peer_type: type of PEER
587  */
588 static inline enum wlan_peer_type wlan_peer_get_peer_type(
589 				struct wlan_objmgr_peer *peer)
590 {
591 	return peer->peer_mlme.peer_type;
592 }
593 
594 /**
595  * wlan_peer_set_phymode() - set phymode
596  * @peer: PEER object
597  * @phymode: phymode of peer
598  *
599  * API to set phymode
600  *
601  * Return: void
602  */
603 static inline void wlan_peer_set_phymode(struct wlan_objmgr_peer *peer,
604 					 enum wlan_phymode phymode)
605 {
606 	peer->peer_mlme.phymode = phymode;
607 }
608 
609 /**
610  * wlan_peer_get_phymode() - get phymode
611  * @peer: PEER object
612  *
613  * API to get phymode
614  *
615  * Return:
616  * @phymode: phymode of PEER
617  */
618 static inline enum wlan_phymode wlan_peer_get_phymode(
619 				struct wlan_objmgr_peer *peer)
620 {
621 	return peer->peer_mlme.phymode;
622 }
623 
624 
625 /**
626  * wlan_peer_set_macaddr() - set mac addr
627  * @peer: PEER object
628  * @macaddr: MAC address
629  *
630  * API to set peer mac address
631  *
632  * Caller need to acquire lock with wlan_peer_obj_lock()
633  *
634  * Return: void
635  */
636 static inline void wlan_peer_set_macaddr(struct wlan_objmgr_peer *peer,
637 			uint8_t *macaddr)
638 {
639 	/* This API is invoked with lock acquired, do not add log prints */
640 	WLAN_ADDR_COPY(peer->macaddr, macaddr);
641 }
642 
643 /**
644  * wlan_peer_get_macaddr() - get mac addr
645  * @peer: PEER object
646  *
647  * API to get peer mac address
648  *
649  * Caller need to acquire lock with wlan_peer_obj_lock()
650  *
651  * Return:
652  * @macaddr: MAC address
653  */
654 static inline uint8_t *wlan_peer_get_macaddr(struct wlan_objmgr_peer *peer)
655 {
656 	/* This API is invoked with lock acquired, do not add log prints */
657 	return peer->macaddr;
658 }
659 
660 /**
661  * wlan_peer_get_vdev() - get vdev
662  * @peer: PEER object
663  *
664  * API to get peer's vdev
665  *
666  * Return:
667  * @vdev: VDEV object
668  */
669 static inline struct wlan_objmgr_vdev *wlan_peer_get_vdev(
670 			struct wlan_objmgr_peer *peer)
671 {
672 	return peer->peer_objmgr.vdev;
673 }
674 
675 /**
676  * wlan_peer_set_vdev() - set vdev
677  * @peer: PEER object
678  * @vdev: VDEV object
679  *
680  * API to set peer's vdev
681  *
682  * Return: void
683  */
684 static inline void wlan_peer_set_vdev(struct wlan_objmgr_peer *peer,
685 		struct wlan_objmgr_vdev *vdev)
686 {
687 	peer->peer_objmgr.vdev = vdev;
688 }
689 
690 /**
691  * wlan_peer_mlme_flag_set() - mlme flag set
692  * @peer: PEER object
693  * @flag: flag to be set
694  *
695  * API to set flag in peer
696  *
697  * Return: void
698  */
699 static inline void wlan_peer_mlme_flag_set(struct wlan_objmgr_peer *peer,
700 				uint32_t flag)
701 {
702 	peer->peer_mlme.peer_flags |= flag;
703 }
704 
705 /**
706  * wlan_peer_mlme_flag_clear() - mlme flag clear
707  * @peer: PEER object
708  * @flag: flag to be cleared
709  *
710  * API to clear flag in peer
711  *
712  * Return: void
713  */
714 static inline void wlan_peer_mlme_flag_clear(struct wlan_objmgr_peer *peer,
715 				uint32_t flag)
716 {
717 	peer->peer_mlme.peer_flags &= ~flag;
718 }
719 
720 /**
721  * wlan_peer_mlme_flag_get() - mlme flag get
722  * @peer: PEER object
723  * @flag: flag to be checked
724  *
725  * API to know, whether particular flag is set in peer
726  *
727  * Return: 1 (for set) or 0 (for not set)
728  */
729 static inline uint8_t wlan_peer_mlme_flag_get(struct wlan_objmgr_peer *peer,
730 				uint32_t flag)
731 {
732 	return (peer->peer_mlme.peer_flags & flag) ? 1 : 0;
733 }
734 
735 /**
736  * wlan_peer_mlme_set_state() - peer mlme state
737  * @peer: PEER object
738  * @state: enum wlan_peer_state
739  *
740  * API to update the current peer state
741  *
742  * Return: void
743  */
744 static inline void wlan_peer_mlme_set_state(
745 				struct wlan_objmgr_peer *peer,
746 				enum wlan_peer_state state)
747 {
748 	peer->peer_mlme.state = state;
749 }
750 
751 /**
752  * wlan_peer_mlme_set_auth_state() - peer mlme auth state
753  * @peer: PEER object
754  * @is_authenticated: true or false
755  *
756  * API to update the current peer auth state
757  *
758  * Return: void
759  */
760 static inline void wlan_peer_mlme_set_auth_state(
761 				struct wlan_objmgr_peer *peer,
762 				bool is_authenticated)
763 {
764 	peer->peer_mlme.is_authenticated = is_authenticated;
765 }
766 
767 /**
768  * wlan_peer_mlme_get_state() - peer mlme state
769  * @peer: PEER object
770  *
771  * API to get peer state
772  *
773  * Return: enum wlan_peer_state
774  */
775 static inline enum wlan_peer_state wlan_peer_mlme_get_state(
776 				struct wlan_objmgr_peer *peer)
777 {
778 	return peer->peer_mlme.state;
779 }
780 
781 /**
782  * wlan_peer_mlme_get_auth_state() - peer mlme auth state
783  * @peer: PEER object
784  *
785  * API to get peer auth state
786  *
787  * Return: auth state true/false
788  */
789 static inline bool wlan_peer_mlme_get_auth_state(
790 				struct wlan_objmgr_peer *peer)
791 {
792 	return peer->peer_mlme.is_authenticated;
793 }
794 
795 /**
796  * wlan_peer_mlme_get_next_seq_num() - get peer mlme next sequence number
797  * @peer: PEER object
798  *
799  * API to get mlme peer next sequence number
800  *
801  * Caller need to acquire lock with wlan_peer_obj_lock()
802  *
803  * Return: peer mlme next sequence number
804  */
805 static inline uint32_t wlan_peer_mlme_get_next_seq_num(
806 				struct wlan_objmgr_peer *peer)
807 {
808 	/* This API is invoked with lock acquired, do not add log prints */
809 	if (peer->peer_mlme.seq_num < WLAN_MAX_SEQ_NUM)
810 		peer->peer_mlme.seq_num++;
811 	else
812 		peer->peer_mlme.seq_num = 0;
813 
814 	return peer->peer_mlme.seq_num;
815 }
816 
817 /**
818  * wlan_peer_mlme_get_seq_num() - get peer mlme sequence number
819  * @peer: PEER object
820  *
821  * API to get mlme peer sequence number
822  *
823  * Caller need to acquire lock with wlan_peer_obj_lock()
824  *
825  * Return: peer mlme sequence number
826  */
827 static inline uint32_t wlan_peer_mlme_get_seq_num(
828 				struct wlan_objmgr_peer *peer)
829 {
830 	/* This API is invoked with lock acquired, do not add log prints */
831 	return peer->peer_mlme.seq_num;
832 }
833 
834 /**
835  * wlan_peer_mlme_reset_seq_num() - reset peer mlme sequence number
836  * @peer: PEER object
837  *
838  * API to reset peer sequence number
839  *
840  * Caller need to acquire lock with wlan_peer_obj_lock()
841  *
842  * Return: void
843  */
844 static inline void wlan_peer_mlme_reset_seq_num(
845 				struct wlan_objmgr_peer *peer)
846 {
847 	/* This API is invoked with lock acquired, do not add log prints */
848 	peer->peer_mlme.seq_num = 0;
849 }
850 
851 /**
852  * wlan_peer_set_dp_handle() - set dp handle
853  * @peer: peer object pointer
854  * @dp_handle: Data path module handle
855  *
856  * Return: void
857  */
858 static inline void wlan_peer_set_dp_handle(struct wlan_objmgr_peer *peer,
859 		void *dp_handle)
860 {
861 	if (qdf_unlikely(!peer)) {
862 		QDF_BUG(0);
863 		return;
864 	}
865 
866 	peer->dp_handle = dp_handle;
867 }
868 
869 /**
870  * wlan_peer_get_dp_handle() - get dp handle
871  * @peer: peer object pointer
872  *
873  * Return: dp handle
874  */
875 static inline void *wlan_peer_get_dp_handle(struct wlan_objmgr_peer *peer)
876 {
877 	if (qdf_unlikely(!peer)) {
878 		QDF_BUG(0);
879 		return NULL;
880 	}
881 
882 	return peer->dp_handle;
883 }
884 
885 /**
886  * wlan_peer_get_psoc() - get psoc
887  * @peer: PEER object
888  *
889  * API to get peer's psoc
890  *
891  * Return: PSOC object or NULL if the psoc can not be found
892  */
893 static inline struct wlan_objmgr_psoc *wlan_peer_get_psoc(
894 			struct wlan_objmgr_peer *peer)
895 {
896 	struct wlan_objmgr_vdev *vdev;
897 	struct wlan_objmgr_psoc *psoc;
898 
899 	vdev = wlan_peer_get_vdev(peer);
900 	if (!vdev)
901 		return NULL;
902 
903 	psoc = wlan_vdev_get_psoc(vdev);
904 
905 	return psoc;
906 }
907 
908 /*
909  * wlan_peer_get_pdev_id() - get pdev id
910  * @peer: peer object pointer
911  *
912  * Return: pdev id
913  */
914 static inline uint8_t wlan_peer_get_pdev_id(struct wlan_objmgr_peer *peer)
915 {
916 	return peer->pdev_id;
917 }
918 
919 /**
920  * wlan_peer_set_pdev_id() - set pdev id
921  * @peer: peer object pointer
922  * @pdev_id: pdev id
923  *
924  * Return: void
925  */
926 static inline void wlan_peer_set_pdev_id(struct wlan_objmgr_peer *peer,
927 					 uint8_t pdev_id)
928 {
929 	peer->pdev_id = pdev_id;
930 }
931 
932 #endif /* _WLAN_OBJMGR_PEER_OBJ_H_*/
933