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