xref: /wlan-driver/qca-wifi-host-cmn/umac/cmn_services/obj_mgr/inc/wlan_objmgr_peer_obj.h (revision 5113495b16420b49004c444715d2daae2066e7dc) !
1 /*
2  * Copyright (c) 2016-2021 The Linux Foundation. All rights reserved.
3  * Copyright (c) 2021-2023 Qualcomm Innovation Center, Inc. All rights reserved.
4  *
5  * Permission to use, copy, modify, and/or distribute this software for
6  * any purpose with or without fee is hereby granted, provided that the
7  * above copyright notice and this permission notice appear in all
8  * copies.
9  *
10  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
11  * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
12  * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
13  * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
14  * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
15  * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
16  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
17  * PERFORMANCE OF THIS SOFTWARE.
18  */
19 /**
20  * DOC: Define the peer data structure of UMAC
21  *	Public APIs to perform operations on Global objects
22  */
23 #ifndef _WLAN_OBJMGR_PEER_OBJ_H_
24 #define _WLAN_OBJMGR_PEER_OBJ_H_
25 
26 #include <qdf_types.h>
27 #include <qdf_atomic.h>
28 #include "wlan_objmgr_vdev_obj.h"
29 #ifdef WLAN_FEATURE_11BE_MLO
30 #include "wlan_mlo_mgr_public_structs.h"
31 #endif
32 
33 /* peer flags */
34 /* authorized for data */
35 #define WLAN_PEER_F_AUTH                            0x00000001
36 /* QoS enabled */
37 #define WLAN_PEER_F_QOS                             0x00000002
38 /* ERP enabled */
39 #define WLAN_PEER_F_ERP                             0x00000004
40 /* HT enabled */
41 #define WLAN_PEER_F_HT                              0x00000008
42 /* NB: tWLANhave the same value as IEEE80211_FC1_PWR_MGT */
43 /* power save mode enabled */
44 #define WLAN_PEER_F_PWR_MGT                         0x00000010
45 /* keytsc for node has already been updated */
46 #define WLAN_PEER_F_TSC_SET                         0x00000020
47 /* U-APSD power save enabled */
48 #define WLAN_PEER_F_UAPSD                           0x00000040
49 /* U-APSD triggerable state */
50 #define WLAN_PEER_F_UAPSD_TRIG                      0x00000080
51 /* U-APSD SP in progress */
52 #define WLAN_PEER_F_UAPSD_SP                        0x00000100
53 /* Atheros Owl or follow-on device */
54 #define WLAN_PEER_F_ATH                             0x00000200
55 /* Owl WDS workaround needed*/
56 #define WLAN_PEER_F_OWL_WDSWAR                      0x00000400
57 /* WDS link */
58 #define WLAN_PEER_F_WDS                             0x00000800
59 /* No AMPDU support */
60 #define WLAN_PEER_F_NOAMPDU                         0x00001000
61 /* wep/tkip aggregation support */
62 #define WLAN_PEER_F_WEPTKIPAGGR                     0x00002000
63 #define WLAN_PEER_F_WEPTKIP                         0x00004000
64 /* temp node (not in the node table) */
65 #define WLAN_PEER_F_TEMP                            0x00008000
66 /* 2.4ng VHT interop AMSDU disabled */
67 #define WLAN_PEER_F_11NG_VHT_INTEROP_AMSDU_DISABLE  0x00010000
68 /* 40 MHz Intolerant  */
69 #define WLAN_PEER_F_40MHZ_INTOLERANT                0x00020000
70 /* node is  paused*/
71 #define WLAN_PEER_F_PAUSED                          0x00040000
72 #define WLAN_PEER_F_EXTRADELIMWAR                   0x00080000
73 /* 20 MHz requesting node */
74 #define WLAN_PEER_F_REQ_20MHZ                       0x00100000
75 /* all the tid queues in ath layer are paused*/
76 #define WLAN_PEER_F_ATH_PAUSED                      0x00200000
77 /*Require credit update*/
78 #define WLAN_PEER_F_UAPSD_CREDIT_UPDATE             0x00400000
79 /*Require send deauth when h/w queue no data*/
80 #define WLAN_PEER_F_KICK_OUT_DEAUTH                 0x00800000
81 /* RRM enabled node */
82 #define WLAN_PEER_F_RRM                             0x01000000
83 /* Wakeup node */
84 #define WLAN_PEER_F_WAKEUP                          0x02000000
85 /* VHT enabled node */
86 #define WLAN_PEER_F_VHT                             0x04000000
87 /* deauth/Disassoc wait for node cleanup till frame goes on
88    air and tx feedback received */
89 #define WLAN_PEER_F_DELAYED_CLEANUP                 0x08000000
90 /* Extended stats enabled node */
91 #define WLAN_PEER_F_EXT_STATS                       0x10000000
92 /* Prevent _ieee80211_node_leave() from reentry */
93 #define WLAN_PEER_F_LEAVE_ONGOING                   0x20000000
94 /* band steering is enabled for this node */
95 #define WLAN_PEER_F_BSTEERING_CAPABLE               0x40000000
96 /* node is a local mesh peer */
97 #define WLAN_PEER_F_LOCAL_MESH_PEER                 0x80000000
98 
99 /* MLO enabled peer */
100 #define WLAN_PEER_FEXT_MLO                          0x00000001
101 /* Peer is QCN Node */
102 #define WLAN_PEER_QCN_NODE                          0x00000010
103 /* Peer is 4 Address node */
104 #define WLAN_PEER_MESH_NODE                         0x00000020
105 
106 /**
107  * enum wlan_peer_state  - peer state
108  * @WLAN_INIT_STATE:       Default state
109  * @WLAN_JOIN_STATE:       Station mode, STA is waiting for Join
110  * @WLAN_AUTH_STATE:       AUTH in progress
111  * @WLAN_ASSOC_STATE:      ASSOC in progress
112  * @WLAN_WAITKEY_STATE:    4-way KEY handshake is in progress
113  * @WLAN_CONNECTED_STATE:  Connected state
114  * @WLAN_PREAUTH_STATE:    Station mode: Preauth
115  * @WLAN_DISCONNECT_STATE: Disconnect is in progress
116  */
117 enum wlan_peer_state {
118 	WLAN_INIT_STATE       = 1,
119 	WLAN_JOIN_STATE       = 2,
120 	WLAN_AUTH_STATE       = 3,
121 	WLAN_ASSOC_STATE      = 4,
122 	WLAN_WAITKEY_STATE    = 5,
123 	WLAN_CONNECTED_STATE  = 6,
124 	WLAN_PREAUTH_STATE    = 7,
125 	WLAN_DISCONNECT_STATE = 8,
126 };
127 
128 /**
129  * struct wlan_objmgr_peer_mlme - mlme common data of peer
130  * @peer_capinfo:    protocol cap info
131  * @peer_flags:      PEER OP flags
132  * @peer_ext_flags:  PEER OP ext flags
133  * @peer_type:       Type of PEER, (STA/AP/etc.)
134  * @phymode:         phy mode of station
135  * @max_rate:        Max Rate supported
136  * @state:           State of the peer
137  * @seq_num:         Sequence number
138  * @rssi:            Last received RSSI value
139  * @is_authenticated: true if peer is authenticated
140  * @assoc_peer:      assoc req/response is handled in this peer
141  */
142 struct wlan_objmgr_peer_mlme {
143 	uint32_t peer_capinfo;
144 	uint32_t peer_flags;
145 	uint32_t peer_ext_flags;
146 	enum wlan_peer_type peer_type;
147 	enum wlan_phymode phymode;
148 	uint32_t max_rate;
149 	enum wlan_peer_state state;
150 	uint16_t seq_num;
151 	int8_t rssi;
152 	bool is_authenticated;
153 #ifdef WLAN_FEATURE_11BE_MLO
154 	bool assoc_peer;
155 #endif
156 };
157 
158 /**
159  * struct wlan_objmgr_peer_objmgr - object manager data of peer
160  * @vdev:              VDEV pointer to which it is associated
161  * @ref_cnt:           Ref count
162  * @ref_id_dbg:        Array to track Ref count
163  * @print_cnt:         Count to throttle Logical delete prints
164  * @trace:             Trace ref and deref
165  */
166 struct wlan_objmgr_peer_objmgr {
167 	struct wlan_objmgr_vdev *vdev;
168 	qdf_atomic_t ref_cnt;
169 #ifdef WLAN_OBJMGR_REF_ID_DEBUG
170 	qdf_atomic_t ref_id_dbg[WLAN_REF_ID_MAX];
171 #endif
172 	uint8_t print_cnt;
173 #ifdef WLAN_OBJMGR_REF_ID_TRACE
174 	struct wlan_objmgr_trace trace;
175 #endif
176 };
177 
178 /**
179  * struct wlan_objmgr_peer -  PEER common object
180  * @psoc_peer:        peer list node for psoc's qdf list
181  * @vdev_peer:        peer list node for vdev's qdf list
182  * @free_node:        peer list node for free in a delayed work
183  * @macaddr:          Peer MAC address
184  * @peer_mlme:	      Peer MLME common structure
185  * @peer_objmgr:      Peer Object manager common structure
186  * @peer_comp_priv_obj:  Component's private object pointers
187  * @obj_status:       status of each component object
188  * @obj_state:        Status of Peer object
189  * @pdev_id:          Pdev ID
190  * @peer_lock:        Lock for access/update peer contents
191  * @mlo_peer_ctx:     Reference to MLO Peer context
192  * @mldaddr:          Peer MLD MAC address
193  * @mlo_bridge_peer:  Indicates bridge peer
194  * @peer_flags:        QCN flag and 4 address mode flag
195  */
196 struct wlan_objmgr_peer {
197 	qdf_list_node_t psoc_peer;
198 	qdf_list_node_t vdev_peer;
199 #ifdef FEATURE_DELAYED_PEER_OBJ_DESTROY
200 	qdf_list_node_t free_node;
201 #endif
202 	uint8_t macaddr[QDF_MAC_ADDR_SIZE];
203 	uint8_t pdev_id;
204 	struct wlan_objmgr_peer_mlme peer_mlme;
205 	struct wlan_objmgr_peer_objmgr peer_objmgr;
206 	void *peer_comp_priv_obj[WLAN_UMAC_MAX_COMPONENTS];
207 	QDF_STATUS obj_status[WLAN_UMAC_MAX_COMPONENTS];
208 	WLAN_OBJ_STATE obj_state;
209 	qdf_spinlock_t peer_lock;
210 #ifdef WLAN_FEATURE_11BE_MLO
211 	struct wlan_mlo_peer_context *mlo_peer_ctx;
212 	uint8_t mldaddr[QDF_MAC_ADDR_SIZE];
213 	u_int32_t peer_flags;
214 	bool mlo_bridge_peer;
215 #endif
216 };
217 
218 /*
219  * APIs to Create/Delete Global object APIs
220  */
221 /**
222  * wlan_objmgr_peer_obj_create() - peer object create
223  * @vdev: VDEV object on which this peer gets created
224  * @type: peer type (AP/STA)
225  * @macaddr: MAC address
226  *
227  * Creates Peer object, initializes with default values
228  * Attaches to psoc and vdev objects
229  * Invokes the registered notifiers to create component object
230  *
231  * Return: Handle to struct wlan_objmgr_peer on successful creation,
232  *         NULL on Failure (on Mem alloc failure and Component objects
233  *         Failure)
234  */
235 struct wlan_objmgr_peer *wlan_objmgr_peer_obj_create(
236 			struct wlan_objmgr_vdev *vdev,
237 			enum wlan_peer_type type,
238 			uint8_t macaddr[]);
239 
240 /**
241  * wlan_objmgr_peer_obj_delete() - peer object delete
242  * @peer: PEER object
243  *
244  * Deletes PEER object, removes it from PSOC's, VDEV's peer list
245  * Invokes the registered notifiers to destroy component objects
246  *
247  * Return: SUCCESS/FAILURE
248  */
249 QDF_STATUS wlan_objmgr_peer_obj_delete(struct wlan_objmgr_peer *peer);
250 
251 #ifdef FEATURE_DELAYED_PEER_OBJ_DESTROY
252 /**
253  * wlan_delayed_peer_obj_free_init() - Init for delayed peer obj freed queue
254  * @data: PDEV object
255  *
256  * Initialize main data structures to process peer obj destroy in a delayed
257  * workqueue.
258  *
259  * Return: QDF_STATUS_SUCCESS on success else a QDF error.
260  */
261 QDF_STATUS wlan_delayed_peer_obj_free_init(void *data);
262 
263 /**
264  * wlan_delayed_peer_obj_free_deinit() - De-Init delayed peer freed processing
265  * @data: PDEV object
266  *
267  * De-initialize main data structures to process peer obj freed in a delayed
268  * workqueue.
269  *
270  * Return: QDF_STATUS_SUCCESS on success else a QDF error.
271  */
272 QDF_STATUS wlan_delayed_peer_obj_free_deinit(void *data);
273 #else
wlan_delayed_peer_obj_free_init(void * data)274 static inline QDF_STATUS wlan_delayed_peer_obj_free_init(void *data)
275 {
276 	return QDF_STATUS_SUCCESS;
277 }
278 
wlan_delayed_peer_obj_free_deinit(void * data)279 static inline QDF_STATUS wlan_delayed_peer_obj_free_deinit(void *data)
280 {
281 	return QDF_STATUS_SUCCESS;
282 }
283 #endif
284 
285 /*
286  * APIs to attach/detach component objects
287  */
288 /**
289  * wlan_objmgr_peer_component_obj_attach() - attach comp object to peer
290  * @peer: PEER object
291  * @id: Component id
292  * @comp_priv_obj: component's private object pointer
293  * @status: Component's private object creation status
294  *
295  * API to be used for attaching component object with PEER common object
296  *
297  * Return: SUCCESS on successful storing of component's object in common object
298  *         On FAILURE (appropriate failure codes are returned)
299  */
300 QDF_STATUS wlan_objmgr_peer_component_obj_attach(
301 		struct wlan_objmgr_peer *peer,
302 		enum wlan_umac_comp_id id,
303 		void *comp_priv_obj,
304 		QDF_STATUS status);
305 
306 /**
307  * wlan_objmgr_peer_component_obj_detach() - detach comp object from peer
308  * @peer: PEER object
309  * @id: Component id
310  * @comp_priv_obj: component's private object pointer
311  *
312  * API to be used for detaching component object with PEER common object
313  *
314  * Return: SUCCESS on successful removal of component's object from common
315  *         object
316  *         On FAILURE (appropriate failure codes are returned)
317  */
318 QDF_STATUS wlan_objmgr_peer_component_obj_detach(
319 		struct wlan_objmgr_peer *peer,
320 		enum wlan_umac_comp_id id,
321 		void *comp_priv_obj);
322 
323 /*
324  * APIs to operations on peer objects
325  */
326 
327 /**
328  * wlan_objmgr_trigger_peer_comp_priv_object_creation() - create
329  * peer comp object
330  * @peer: PEER object
331  * @id: Component id
332  *
333  * API to create component private object in run time, this would
334  * be used for features which gets enabled in run time
335  *
336  * Return: SUCCESS on successful creation
337  *         On FAILURE (appropriate failure codes are returned)
338  */
339 QDF_STATUS wlan_objmgr_trigger_peer_comp_priv_object_creation(
340 		struct wlan_objmgr_peer *peer,
341 		enum wlan_umac_comp_id id);
342 
343 /**
344  * wlan_objmgr_trigger_peer_comp_priv_object_deletion() - destroy
345  * peer comp object
346  * @peer: PEER object
347  * @id: Component id
348  *
349  * API to destroy component private object in run time, this would
350  * be used for features which gets disabled in run time
351  *
352  * Return: SUCCESS on successful deletion
353  *         On FAILURE (appropriate failure codes are returned)
354  */
355 QDF_STATUS wlan_objmgr_trigger_peer_comp_priv_object_deletion(
356 		struct wlan_objmgr_peer *peer,
357 		enum wlan_umac_comp_id id);
358 
359 /**
360  * wlan_objmgr_peer_get_comp_private_obj() - get peer component private object
361  * @peer: PEER object
362  * @id: Component id
363  *
364  * API to get component private object
365  *
366  * Return: void *ptr on SUCCESS
367  *         NULL on Failure
368  */
369 void *wlan_objmgr_peer_get_comp_private_obj(
370 		struct wlan_objmgr_peer *peer,
371 		enum wlan_umac_comp_id id);
372 
373 /**
374  * wlan_peer_obj_lock() - Acquire PEER spinlock
375  * @peer: PEER object
376  *
377  * API to acquire PEER spin lock
378  * Parent lock should not be taken in child lock context
379  * but child lock can be taken in parent lock context
380  * (for ex: psoc lock can't be invoked in pdev/vdev/peer lock context)
381  *
382  * Return: void
383  */
wlan_peer_obj_lock(struct wlan_objmgr_peer * peer)384 static inline void wlan_peer_obj_lock(struct wlan_objmgr_peer *peer)
385 {
386 	qdf_spin_lock_bh(&peer->peer_lock);
387 }
388 
389 /**
390  * wlan_peer_obj_unlock() - Release PEER spinlock
391  * @peer: PEER object
392  *
393  * API to Release PEER spin lock
394  *
395  * Return: void
396  */
wlan_peer_obj_unlock(struct wlan_objmgr_peer * peer)397 static inline void wlan_peer_obj_unlock(struct wlan_objmgr_peer *peer)
398 {
399 	qdf_spin_unlock_bh(&peer->peer_lock);
400 }
401 
402 /**
403  * DOC: Examples to use PEER ref count APIs
404  *
405  * In all the scenarios, the pair of API should be followed
406  * other it lead to memory leak
407  *
408  *  scenario 1:
409  *
410  *     wlan_objmgr_peer_obj_create()
411  *     ----
412  *     wlan_objmgr_peer_obj_delete()
413  *
414  *  scenario 2:
415  *
416  *     wlan_objmgr_peer_get_ref()
417  *     ----
418  *     the operations which are done on
419  *     peer object
420  *     ----
421  *     wlan_objmgr_peer_release_ref()
422  *
423  *  scenario 3:
424  *
425  *     API to retrieve peer (xxx_get_peer_xxx())
426  *     ----
427  *     the operations which are done on
428  *     peer object
429  *     ----
430  *     wlan_objmgr_peer_release_ref()
431  */
432 
433 /**
434  * wlan_objmgr_peer_get_ref() - increment ref count
435  * @peer: PEER object
436  * @id:   Object Manager ref debug id
437  *
438  * API to increment ref count of peer
439  *
440  * Return: void
441  */
442 #ifdef WLAN_OBJMGR_REF_ID_TRACE
443 #define wlan_objmgr_peer_get_ref(peer, id) \
444 		wlan_objmgr_peer_get_ref_debug(peer, id, __func__, __LINE__)
445 
446 void wlan_objmgr_peer_get_ref_debug(struct wlan_objmgr_peer *peer,
447 				    wlan_objmgr_ref_dbgid id,
448 				    const char *func, int line);
449 #else
450 void wlan_objmgr_peer_get_ref(struct wlan_objmgr_peer *peer,
451 					wlan_objmgr_ref_dbgid id);
452 #endif
453 
454 /**
455  * wlan_objmgr_peer_try_get_ref() - increment ref count, if allowed
456  * @peer: PEER object
457  * @id:   Object Manager ref debug id
458  *
459  * API to increment ref count of peer, if object state is valid
460  *
461  * Return: void
462  */
463 #ifdef WLAN_OBJMGR_REF_ID_TRACE
464 #define wlan_objmgr_peer_try_get_ref(peer, id) \
465 		wlan_objmgr_peer_try_get_ref_debug(peer, id, \
466 		__func__, __LINE__)
467 
468 QDF_STATUS wlan_objmgr_peer_try_get_ref_debug(struct wlan_objmgr_peer *peer,
469 					      wlan_objmgr_ref_dbgid id,
470 					      const char *func, int line);
471 #else
472 QDF_STATUS wlan_objmgr_peer_try_get_ref(struct wlan_objmgr_peer *peer,
473 						 wlan_objmgr_ref_dbgid id);
474 #endif
475 
476 /**
477  * wlan_objmgr_peer_release_ref() - decrement ref count
478  * @peer: PEER object
479  * @id:   Object Manager ref debug id
480  *
481  * API to decrement ref count of peer, if ref count is 1, it initiates the
482  * peer deletion
483  *
484  * Return: void
485  */
486 #ifdef WLAN_OBJMGR_REF_ID_TRACE
487 #define wlan_objmgr_peer_release_ref(peer, id) \
488 		wlan_objmgr_peer_release_ref_debug(peer, id, \
489 		__func__, __LINE__)
490 
491 void wlan_objmgr_peer_release_ref_debug(struct wlan_objmgr_peer *peer,
492 					wlan_objmgr_ref_dbgid id,
493 					const char *func, int line);
494 #else
495 void wlan_objmgr_peer_release_ref(struct wlan_objmgr_peer *peer,
496 						 wlan_objmgr_ref_dbgid id);
497 #endif
498 
499 /**
500  * wlan_peer_get_next_peer_of_psoc_ref() - get next peer to psoc peer list
501  *                                         with lock and ref taken
502  * @peer_list: Peer list
503  * @hash_index: peer list hash index
504  * @peer: PEER object
505  * @dbg_id: Ref count debug module id
506  *
507  * API to get the next peer of given peer (of psoc's peer list)
508  *
509  * Return: PEER object
510  */
511 #ifdef WLAN_OBJMGR_REF_ID_TRACE
512 #define wlan_peer_get_next_peer_of_psoc_ref(peer_list, hash_index, peer, \
513 	dbg_id) \
514 		wlan_peer_get_next_peer_of_psoc_ref_debug(peer_list, \
515 		hash_index, peer, dbg_id, __func__, __LINE__)
516 
517 struct wlan_objmgr_peer *wlan_peer_get_next_peer_of_psoc_ref_debug(
518 				struct wlan_peer_list *peer_list,
519 				uint8_t hash_index,
520 				struct wlan_objmgr_peer *peer,
521 				wlan_objmgr_ref_dbgid dbg_id,
522 				const char *func, int line);
523 #else
524 struct wlan_objmgr_peer *wlan_peer_get_next_peer_of_psoc_ref(
525 				struct wlan_peer_list *peer_list,
526 				uint8_t hash_index,
527 				struct wlan_objmgr_peer *peer,
528 				wlan_objmgr_ref_dbgid dbg_id);
529 #endif
530 
531 /**
532  * wlan_peer_get_next_active_peer_of_psoc() - get next active peer to psoc peer
533  *                                            list
534  * @peer_list: Peer list
535  * @hash_index: peer list hash index
536  * @peer: PEER object
537  * @dbg_id: Ref count debug module id
538  *
539  * API to get the next peer of given peer (of psoc's peer list)
540  *
541  * Return: PEER object
542  */
543 #ifdef WLAN_OBJMGR_REF_ID_TRACE
544 #define wlan_peer_get_next_active_peer_of_psoc(peer_list, hash_index, \
545 	peer, dbg_id) \
546 		wlan_peer_get_next_active_peer_of_psoc_debug(peer_list, \
547 		hash_index, peer, dbg_id, __func__, __LINE__)
548 
549 struct wlan_objmgr_peer *wlan_peer_get_next_active_peer_of_psoc_debug(
550 					struct wlan_peer_list *peer_list,
551 					uint8_t hash_index,
552 					struct wlan_objmgr_peer *peer,
553 					wlan_objmgr_ref_dbgid dbg_id,
554 					const char *func, int line);
555 #else
556 struct wlan_objmgr_peer *wlan_peer_get_next_active_peer_of_psoc(
557 					struct wlan_peer_list *peer_list,
558 					uint8_t hash_index,
559 					struct wlan_objmgr_peer *peer,
560 					wlan_objmgr_ref_dbgid dbg_id);
561 #endif
562 
563 /**
564  * wlan_peer_get_next_active_peer_of_vdev() - get next active_peer of vdev list
565  * @vdev: VDEV object
566  * @peer_list: Peer object list
567  * @peer: PEER object
568  * @dbg_id: Ref count debug module id
569  *
570  * API to get the next active peer of given peer (of vdev's peer list)
571  *
572  * Return: PEER object
573  */
574 #ifdef WLAN_OBJMGR_REF_ID_TRACE
575 #define wlan_peer_get_next_active_peer_of_vdev(vdev, peer_list, peer, dbg_id) \
576 		wlan_peer_get_next_active_peer_of_vdev_debug(vdev, peer_list, \
577 		peer, dbg_id, __func__, __LINE__)
578 
579 struct wlan_objmgr_peer *wlan_peer_get_next_active_peer_of_vdev_debug(
580 				struct wlan_objmgr_vdev *vdev,
581 				qdf_list_t *peer_list,
582 				struct wlan_objmgr_peer *peer,
583 				wlan_objmgr_ref_dbgid dbg_id,
584 				const char *func, int line);
585 #else
586 struct wlan_objmgr_peer *wlan_peer_get_next_active_peer_of_vdev(
587 				struct wlan_objmgr_vdev *vdev,
588 				qdf_list_t *peer_list,
589 				struct wlan_objmgr_peer *peer,
590 				wlan_objmgr_ref_dbgid dbg_id);
591 #endif
592 
593 /**
594  * wlan_vdev_peer_list_peek_active_head() - get active head of vdev peer list
595  * @vdev: VDEV object
596  * @peer_list: qdf_list_t
597  * @dbg_id: Ref count debug module id
598  *
599  * API to get the active head peer of given peer (of vdev's peer list)
600  *
601  * Return: active head peer
602  */
603 #ifdef WLAN_OBJMGR_REF_ID_TRACE
604 #define wlan_vdev_peer_list_peek_active_head(vdev, peer_list, dbg_id) \
605 		wlan_vdev_peer_list_peek_active_head_debug(vdev, peer_list, \
606 		dbg_id, __func__, __LINE__)
607 
608 struct wlan_objmgr_peer *wlan_vdev_peer_list_peek_active_head_debug(
609 				struct wlan_objmgr_vdev *vdev,
610 				qdf_list_t *peer_list,
611 				wlan_objmgr_ref_dbgid dbg_id,
612 				const char *func, int line);
613 #else
614 struct wlan_objmgr_peer *wlan_vdev_peer_list_peek_active_head(
615 				struct wlan_objmgr_vdev *vdev,
616 				qdf_list_t *peer_list,
617 				wlan_objmgr_ref_dbgid dbg_id);
618 #endif
619 
620 /**
621  * wlan_psoc_peer_list_peek_head_ref() - get head of psoc peer list
622  *                                            with ref and lock protected
623  * @peer_list: wlan_peer_list
624  * @hash_index: peer list hash index
625  * @dbg_id: Ref count debug module id
626  *
627  * API to get the head peer of given peer (of psoc's peer list)
628  *
629  * Return: head peer
630  */
631 #ifdef WLAN_OBJMGR_REF_ID_TRACE
632 #define wlan_psoc_peer_list_peek_head_ref(peer_list, hash_index, dbg_id) \
633 		wlan_psoc_peer_list_peek_head_ref_debug(peer_list, hash_index, \
634 		dbg_id, __func__, __LINE__)
635 
636 struct wlan_objmgr_peer *wlan_psoc_peer_list_peek_head_ref_debug(
637 					struct wlan_peer_list *peer_list,
638 					uint8_t hash_index,
639 					wlan_objmgr_ref_dbgid dbg_id,
640 					const char *func, int line);
641 
642 #else
643 struct wlan_objmgr_peer *wlan_psoc_peer_list_peek_head_ref(
644 					struct wlan_peer_list *peer_list,
645 					uint8_t hash_index,
646 					wlan_objmgr_ref_dbgid dbg_id);
647 #endif
648 
649 /**
650  * wlan_psoc_peer_list_peek_active_head() - get active head of psoc peer list
651  * @peer_list: wlan_peer_list
652  * @hash_index: peer list hash index
653  * @dbg_id: Ref count debug module id
654  *
655  * API to get the head peer of given peer (of psoc's peer list)
656  *
657  * Return: head peer
658  */
659 #ifdef WLAN_OBJMGR_REF_ID_TRACE
660 #define wlan_psoc_peer_list_peek_active_head(peer_list, hash_index, dbg_id) \
661 		wlan_psoc_peer_list_peek_active_head_debug(peer_list, \
662 		hash_index, dbg_id, __func__, __LINE__)
663 
664 struct wlan_objmgr_peer *wlan_psoc_peer_list_peek_active_head_debug(
665 					struct wlan_peer_list *peer_list,
666 					uint8_t hash_index,
667 					wlan_objmgr_ref_dbgid dbg_id,
668 					const char *func, int line);
669 #else
670 struct wlan_objmgr_peer *wlan_psoc_peer_list_peek_active_head(
671 					struct wlan_peer_list *peer_list,
672 					uint8_t hash_index,
673 					wlan_objmgr_ref_dbgid dbg_id);
674 #endif
675 
676 /**
677  * wlan_psoc_peer_list_peek_head() - get head of psoc peer list
678  * @peer_list: qdf_list_t
679  *
680  * API to get the head peer of given peer (of psoc's peer list)
681  *
682  * Caller need to acquire lock with wlan_peer_obj_lock()
683  *
684  * Return: head peer
685  */
wlan_psoc_peer_list_peek_head(qdf_list_t * peer_list)686 static inline struct wlan_objmgr_peer *wlan_psoc_peer_list_peek_head(
687 					qdf_list_t *peer_list)
688 {
689 	struct wlan_objmgr_peer *peer;
690 	qdf_list_node_t *psoc_node = NULL;
691 
692 	/* This API is invoked with lock acquired, do not add log prints */
693 	if (qdf_list_peek_front(peer_list, &psoc_node) != QDF_STATUS_SUCCESS)
694 		return NULL;
695 
696 	peer = qdf_container_of(psoc_node, struct wlan_objmgr_peer, psoc_peer);
697 	return peer;
698 }
699 
700 /**
701  * wlan_vdev_peer_list_peek_head() - get head of vdev peer list
702  * @peer_list: qdf_list_t
703  *
704  * API to get the head peer of given peer (of vdev's peer list)
705  *
706  * Caller need to acquire lock with wlan_peer_obj_lock()
707  *
708  * Return: head peer
709  */
wlan_vdev_peer_list_peek_head(qdf_list_t * peer_list)710 static inline struct wlan_objmgr_peer *wlan_vdev_peer_list_peek_head(
711 					qdf_list_t *peer_list)
712 {
713 	struct wlan_objmgr_peer *peer;
714 	qdf_list_node_t *vdev_node = NULL;
715 
716 	/* This API is invoked with lock acquired, do not add log prints */
717 	if (qdf_list_peek_front(peer_list, &vdev_node) != QDF_STATUS_SUCCESS)
718 		return NULL;
719 
720 	peer = qdf_container_of(vdev_node, struct wlan_objmgr_peer, vdev_peer);
721 	return peer;
722 }
723 
724 /**
725  * wlan_peer_get_next_peer_of_vdev() - get next peer of vdev list
726  * @peer_list: PEER object list
727  * @peer: PEER object
728  *
729  * API to get the next peer of given peer (of vdev's peer list)
730  *
731  * Caller need to acquire lock with wlan_peer_obj_lock()
732  *
733  * Return: PEER object
734  */
wlan_peer_get_next_peer_of_vdev(qdf_list_t * peer_list,struct wlan_objmgr_peer * peer)735 static inline struct wlan_objmgr_peer *wlan_peer_get_next_peer_of_vdev(
736 			qdf_list_t *peer_list, struct wlan_objmgr_peer *peer)
737 {
738 	struct wlan_objmgr_peer *peer_next;
739 	qdf_list_node_t *node;
740 	qdf_list_node_t *next_node = NULL;
741 
742 	/* This API is invoked with lock acquired, do not add log prints */
743 	if (!peer)
744 		return NULL;
745 
746 	node = &peer->vdev_peer;
747 	if (qdf_list_peek_next(peer_list, node, &next_node) !=
748 						QDF_STATUS_SUCCESS)
749 		return NULL;
750 
751 	peer_next = qdf_container_of(next_node, struct wlan_objmgr_peer,
752 					vdev_peer);
753 	return peer_next;
754 }
755 
756 /**
757  * wlan_peer_set_next_peer_of_vdev() - add peer to vdev peer list
758  * @peer_list: PEER object list
759  * @new_peer: PEER object
760  *
761  * API to set as the next peer to given peer (of vdev's peer list)
762  *
763  * Caller need to acquire lock with wlan_peer_obj_lock()
764  *
765  * Return: void
766  */
wlan_peer_set_next_peer_of_vdev(qdf_list_t * peer_list,struct wlan_objmgr_peer * new_peer)767 static inline void wlan_peer_set_next_peer_of_vdev(qdf_list_t *peer_list,
768 				struct wlan_objmgr_peer *new_peer)
769 {
770 	/* This API is invoked with lock acquired, do not add log prints */
771 	/* set next peer with new peer */
772 	qdf_list_insert_back(peer_list, &new_peer->vdev_peer);
773 	return;
774 }
775 
776 /**
777  * wlan_peer_get_next_peer_of_psoc() - get next peer to psoc peer list
778  * @peer_list: Peer list
779  * @peer: PEER object
780  *
781  * API to get the next peer of given peer (of psoc's peer list)
782  *
783  * Caller need to acquire lock with wlan_peer_obj_lock()
784  *
785  * Return: PEER object
786  */
wlan_peer_get_next_peer_of_psoc(qdf_list_t * peer_list,struct wlan_objmgr_peer * peer)787 static inline struct wlan_objmgr_peer *wlan_peer_get_next_peer_of_psoc(
788 			qdf_list_t *peer_list, struct wlan_objmgr_peer *peer)
789 {
790 	struct wlan_objmgr_peer *peer_next;
791 	qdf_list_node_t *node = NULL;
792 	qdf_list_node_t *next_node = NULL;
793 
794 	/* This API is invoked with lock acquired, do not add log prints */
795 	if (!peer)
796 		return NULL;
797 
798 	node = &peer->psoc_peer;
799 	if (qdf_list_peek_next(peer_list, node, &next_node) !=
800 						QDF_STATUS_SUCCESS)
801 		return NULL;
802 
803 	peer_next = qdf_container_of(next_node, struct wlan_objmgr_peer,
804 					psoc_peer);
805 	return peer_next;
806 }
807 
808 /**
809  * wlan_peer_set_next_peer_of_psoc() - add peer to psoc peer list
810  * @peer_list: PEER object list
811  * @new_peer: PEER object
812  *
813  * API to set as the next peer to given peer (of psoc's peer list)
814  *
815  * Caller need to acquire lock with wlan_peer_obj_lock()
816  *
817  * Return: void
818  */
wlan_peer_set_next_peer_of_psoc(qdf_list_t * peer_list,struct wlan_objmgr_peer * new_peer)819 static inline void wlan_peer_set_next_peer_of_psoc(qdf_list_t *peer_list,
820 					struct wlan_objmgr_peer *new_peer)
821 {
822 	/* This API is invoked with lock acquired, do not add log prints */
823 	/* set next peer with new peer */
824 	qdf_list_insert_back(peer_list, &new_peer->psoc_peer);
825 	return;
826 }
827 
828 /**
829  * wlan_peer_set_peer_type() - set peer type
830  * @peer: PEER object
831  * @type: type of PEER
832  *
833  * API to set peer type
834  *
835  * Return: void
836  */
wlan_peer_set_peer_type(struct wlan_objmgr_peer * peer,enum wlan_peer_type type)837 static inline void wlan_peer_set_peer_type(struct wlan_objmgr_peer *peer,
838 			enum wlan_peer_type type)
839 {
840 	peer->peer_mlme.peer_type = type;
841 }
842 
843 /**
844  * wlan_peer_get_peer_type() - get peer type
845  * @peer: PEER object
846  *
847  * API to get peer type
848  *
849  * Return: type of PEER
850  */
wlan_peer_get_peer_type(struct wlan_objmgr_peer * peer)851 static inline enum wlan_peer_type wlan_peer_get_peer_type(
852 				struct wlan_objmgr_peer *peer)
853 {
854 	return peer->peer_mlme.peer_type;
855 }
856 
857 /**
858  * wlan_peer_set_phymode() - set phymode
859  * @peer: PEER object
860  * @phymode: phymode of peer
861  *
862  * API to set phymode
863  *
864  * Return: void
865  */
wlan_peer_set_phymode(struct wlan_objmgr_peer * peer,enum wlan_phymode phymode)866 static inline void wlan_peer_set_phymode(struct wlan_objmgr_peer *peer,
867 					 enum wlan_phymode phymode)
868 {
869 	peer->peer_mlme.phymode = phymode;
870 }
871 
872 /**
873  * wlan_peer_get_phymode() - get phymode
874  * @peer: PEER object
875  *
876  * API to get phymode
877  *
878  * Return: phymode of PEER
879  */
wlan_peer_get_phymode(struct wlan_objmgr_peer * peer)880 static inline enum wlan_phymode wlan_peer_get_phymode(
881 				struct wlan_objmgr_peer *peer)
882 {
883 	return peer->peer_mlme.phymode;
884 }
885 
886 /**
887  * wlan_peer_set_rssi() - set RSSI
888  * @peer: PEER object
889  * @rssi: RSSI
890  *
891  * API to set rssi
892  *
893  * Return: void
894  */
wlan_peer_set_rssi(struct wlan_objmgr_peer * peer,int8_t rssi)895 static inline void wlan_peer_set_rssi(struct wlan_objmgr_peer *peer,
896 				      int8_t rssi)
897 {
898 	peer->peer_mlme.rssi = rssi;
899 }
900 
901 /**
902  * wlan_peer_get_rssi() - get RSSI
903  * @peer: PEER object
904  *
905  * API to get RSSI
906  *
907  * Return: RSSI of PEER
908  */
wlan_peer_get_rssi(struct wlan_objmgr_peer * peer)909 static inline int8_t wlan_peer_get_rssi(
910 				struct wlan_objmgr_peer *peer)
911 {
912 	return peer->peer_mlme.rssi;
913 }
914 
915 /**
916  * wlan_peer_set_macaddr() - set mac addr
917  * @peer: PEER object
918  * @macaddr: MAC address
919  *
920  * API to set peer mac address
921  *
922  * Caller need to acquire lock with wlan_peer_obj_lock()
923  *
924  * Return: void
925  */
wlan_peer_set_macaddr(struct wlan_objmgr_peer * peer,uint8_t * macaddr)926 static inline void wlan_peer_set_macaddr(struct wlan_objmgr_peer *peer,
927 			uint8_t *macaddr)
928 {
929 	/* This API is invoked with lock acquired, do not add log prints */
930 	WLAN_ADDR_COPY(peer->macaddr, macaddr);
931 }
932 
933 #ifdef WLAN_FEATURE_DYNAMIC_MAC_ADDR_UPDATE
934 /**
935  * wlan_peer_update_macaddr() - Update peer MAC address
936  * @peer: PEER object
937  * @new_macaddr: New MAC address
938  *
939  * API to update peer MAC address and corresponding peer hash entry in PSOC
940  * peer list.
941  *
942  * Return: SUCCESS/FAILURE
943  */
944 QDF_STATUS wlan_peer_update_macaddr(struct wlan_objmgr_peer *peer,
945 				    uint8_t *new_macaddr);
946 #endif
947 
948 /**
949  * wlan_peer_get_macaddr() - get mac addr
950  * @peer: PEER object
951  *
952  * API to get peer mac address
953  *
954  * Caller need to acquire lock with wlan_peer_obj_lock()
955  *
956  * Return: MAC address
957  */
wlan_peer_get_macaddr(struct wlan_objmgr_peer * peer)958 static inline uint8_t *wlan_peer_get_macaddr(struct wlan_objmgr_peer *peer)
959 {
960 	/* This API is invoked with lock acquired, do not add log prints */
961 	return peer->macaddr;
962 }
963 
964 /**
965  * wlan_peer_get_vdev() - get vdev
966  * @peer: PEER object
967  *
968  * API to get peer's vdev
969  *
970  * Return: VDEV object
971  */
wlan_peer_get_vdev(struct wlan_objmgr_peer * peer)972 static inline struct wlan_objmgr_vdev *wlan_peer_get_vdev(
973 			struct wlan_objmgr_peer *peer)
974 {
975 	return peer->peer_objmgr.vdev;
976 }
977 
978 /**
979  * wlan_peer_set_vdev() - set vdev
980  * @peer: PEER object
981  * @vdev: VDEV object
982  *
983  * API to set peer's vdev
984  *
985  * Return: void
986  */
wlan_peer_set_vdev(struct wlan_objmgr_peer * peer,struct wlan_objmgr_vdev * vdev)987 static inline void wlan_peer_set_vdev(struct wlan_objmgr_peer *peer,
988 		struct wlan_objmgr_vdev *vdev)
989 {
990 	peer->peer_objmgr.vdev = vdev;
991 }
992 
993 /**
994  * wlan_peer_mlme_flag_set() - mlme flag set
995  * @peer: PEER object
996  * @flag: flag to be set
997  *
998  * API to set flag in peer
999  *
1000  * Return: void
1001  */
wlan_peer_mlme_flag_set(struct wlan_objmgr_peer * peer,uint32_t flag)1002 static inline void wlan_peer_mlme_flag_set(struct wlan_objmgr_peer *peer,
1003 					   uint32_t flag)
1004 {
1005 	peer->peer_mlme.peer_flags |= flag;
1006 }
1007 
1008 /**
1009  * wlan_peer_mlme_flag_clear() - mlme flag clear
1010  * @peer: PEER object
1011  * @flag: flag to be cleared
1012  *
1013  * API to clear flag in peer
1014  *
1015  * Return: void
1016  */
wlan_peer_mlme_flag_clear(struct wlan_objmgr_peer * peer,uint32_t flag)1017 static inline void wlan_peer_mlme_flag_clear(struct wlan_objmgr_peer *peer,
1018 				uint32_t flag)
1019 {
1020 	peer->peer_mlme.peer_flags &= ~flag;
1021 }
1022 
1023 /**
1024  * wlan_peer_mlme_flag_get() - mlme flag get
1025  * @peer: PEER object
1026  * @flag: flag to be checked
1027  *
1028  * API to know, whether particular flag is set in peer
1029  *
1030  * Return: 1 (for set) or 0 (for not set)
1031  */
wlan_peer_mlme_flag_get(struct wlan_objmgr_peer * peer,uint32_t flag)1032 static inline uint8_t wlan_peer_mlme_flag_get(struct wlan_objmgr_peer *peer,
1033 				uint32_t flag)
1034 {
1035 	return (peer->peer_mlme.peer_flags & flag) ? 1 : 0;
1036 }
1037 
1038 /**
1039  * wlan_peer_mlme_flag_ext_set() - mlme ext flag set
1040  * @peer: PEER object
1041  * @flag: ext flag to be set
1042  *
1043  * API to set ext flag in peer
1044  *
1045  * Return: void
1046  */
wlan_peer_mlme_flag_ext_set(struct wlan_objmgr_peer * peer,uint32_t flag)1047 static inline void wlan_peer_mlme_flag_ext_set(struct wlan_objmgr_peer *peer,
1048 					       uint32_t flag)
1049 {
1050 	peer->peer_mlme.peer_ext_flags |= flag;
1051 }
1052 
1053 /**
1054  * wlan_peer_mlme_flag_ext_clear() - mlme ext flag clear
1055  * @peer: PEER object
1056  * @flag: ext flag to be cleared
1057  *
1058  * API to clear ext flag in peer
1059  *
1060  * Return: void
1061  */
wlan_peer_mlme_flag_ext_clear(struct wlan_objmgr_peer * peer,uint32_t flag)1062 static inline void wlan_peer_mlme_flag_ext_clear(struct wlan_objmgr_peer *peer,
1063 						 uint32_t flag)
1064 {
1065 	peer->peer_mlme.peer_ext_flags &= ~flag;
1066 }
1067 
1068 /**
1069  * wlan_peer_mlme_flag_ext_get() - mlme ext flag get
1070  * @peer: PEER object
1071  * @flag: ext flag to be checked
1072  *
1073  * API to know, whether particular ext flag is set in peer
1074  *
1075  * Return: 1 (for set) or 0 (for not set)
1076  */
wlan_peer_mlme_flag_ext_get(struct wlan_objmgr_peer * peer,uint32_t flag)1077 static inline uint8_t wlan_peer_mlme_flag_ext_get(struct wlan_objmgr_peer *peer,
1078 						  uint32_t flag)
1079 {
1080 	return (peer->peer_mlme.peer_ext_flags & flag) ? 1 : 0;
1081 }
1082 
1083 /**
1084  * wlan_peer_mlme_set_state() - peer mlme state
1085  * @peer: PEER object
1086  * @state: enum wlan_peer_state
1087  *
1088  * API to update the current peer state
1089  *
1090  * Return: void
1091  */
wlan_peer_mlme_set_state(struct wlan_objmgr_peer * peer,enum wlan_peer_state state)1092 static inline void wlan_peer_mlme_set_state(
1093 				struct wlan_objmgr_peer *peer,
1094 				enum wlan_peer_state state)
1095 {
1096 	peer->peer_mlme.state = state;
1097 }
1098 
1099 #ifdef WLAN_FEATURE_11BE_MLO
1100 /**
1101  * wlan_peer_mlme_get_mldaddr() - get peer mldaddr
1102  * @peer: PEER object
1103  *
1104  * API to get MLD address from peer object
1105  *
1106  * Return: mld address
1107  */
wlan_peer_mlme_get_mldaddr(struct wlan_objmgr_peer * peer)1108 static inline uint8_t *wlan_peer_mlme_get_mldaddr(struct wlan_objmgr_peer *peer)
1109 {
1110 	return peer->mldaddr;
1111 }
1112 
1113 /**
1114  * wlan_peer_mlme_set_mldaddr() - set peer mldaddr
1115  * @peer: PEER object
1116  * @mldaddr: MLD address
1117  *
1118  * API to set MLD addr in peer object
1119  *
1120  * Return: void
1121  */
wlan_peer_mlme_set_mldaddr(struct wlan_objmgr_peer * peer,uint8_t * mldaddr)1122 static inline void wlan_peer_mlme_set_mldaddr(struct wlan_objmgr_peer *peer,
1123 					      uint8_t *mldaddr)
1124 {
1125 	WLAN_ADDR_COPY(peer->mldaddr, mldaddr);
1126 }
1127 
1128 /**
1129  * wlan_peer_mlme_set_assoc_peer() - assoc frames is received on this peer
1130  * @peer: PEER object
1131  * @is_assoc_link: whether assoc frames is received on this peer or not
1132  *
1133  * API to update assoc peer
1134  *
1135  * Return: void
1136  */
wlan_peer_mlme_set_assoc_peer(struct wlan_objmgr_peer * peer,bool is_assoc_link)1137 static inline void wlan_peer_mlme_set_assoc_peer(
1138 				struct wlan_objmgr_peer *peer,
1139 				bool is_assoc_link)
1140 {
1141 	peer->peer_mlme.assoc_peer = is_assoc_link;
1142 }
1143 
1144 /**
1145  * wlan_peer_mlme_is_assoc_peer() - check peer is assoc peer or not
1146  * @peer: PEER object
1147  *
1148  * API to get assoc peer info
1149  *
1150  * Return: whether assoc frames is received on this peer or not
1151  */
wlan_peer_mlme_is_assoc_peer(struct wlan_objmgr_peer * peer)1152 static inline bool wlan_peer_mlme_is_assoc_peer(
1153 				struct wlan_objmgr_peer *peer)
1154 {
1155 	return peer->peer_mlme.assoc_peer;
1156 }
1157 #else
1158 
wlan_peer_mlme_get_mldaddr(struct wlan_objmgr_peer * peer)1159 static inline uint8_t *wlan_peer_mlme_get_mldaddr(struct wlan_objmgr_peer *peer)
1160 {
1161 	return NULL;
1162 }
1163 
wlan_peer_mlme_set_mldaddr(struct wlan_objmgr_peer * peer,uint8_t * mldaddr)1164 static inline void wlan_peer_mlme_set_mldaddr(struct wlan_objmgr_peer *peer,
1165 					      uint8_t *mldaddr)
1166 {
1167 }
1168 
wlan_peer_mlme_set_assoc_peer(struct wlan_objmgr_peer * peer,bool is_assoc_link)1169 static inline void wlan_peer_mlme_set_assoc_peer(
1170 				struct wlan_objmgr_peer *peer,
1171 				bool is_assoc_link)
1172 {
1173 }
1174 
wlan_peer_mlme_is_assoc_peer(struct wlan_objmgr_peer * peer)1175 static inline bool wlan_peer_mlme_is_assoc_peer(
1176 				struct wlan_objmgr_peer *peer)
1177 {
1178 	return true;
1179 }
1180 #endif
1181 
1182 /**
1183  * wlan_peer_mlme_set_auth_state() - peer mlme auth state
1184  * @peer: PEER object
1185  * @is_authenticated: true or false
1186  *
1187  * API to update the current peer auth state
1188  *
1189  * Return: void
1190  */
wlan_peer_mlme_set_auth_state(struct wlan_objmgr_peer * peer,bool is_authenticated)1191 static inline void wlan_peer_mlme_set_auth_state(
1192 				struct wlan_objmgr_peer *peer,
1193 				bool is_authenticated)
1194 {
1195 	peer->peer_mlme.is_authenticated = is_authenticated;
1196 }
1197 
1198 /**
1199  * wlan_peer_mlme_get_state() - peer mlme state
1200  * @peer: PEER object
1201  *
1202  * API to get peer state
1203  *
1204  * Return: enum wlan_peer_state
1205  */
wlan_peer_mlme_get_state(struct wlan_objmgr_peer * peer)1206 static inline enum wlan_peer_state wlan_peer_mlme_get_state(
1207 				struct wlan_objmgr_peer *peer)
1208 {
1209 	return peer->peer_mlme.state;
1210 }
1211 
1212 /**
1213  * wlan_peer_mlme_get_auth_state() - peer mlme auth state
1214  * @peer: PEER object
1215  *
1216  * API to get peer auth state
1217  *
1218  * Return: auth state true/false
1219  */
wlan_peer_mlme_get_auth_state(struct wlan_objmgr_peer * peer)1220 static inline bool wlan_peer_mlme_get_auth_state(
1221 				struct wlan_objmgr_peer *peer)
1222 {
1223 	return peer->peer_mlme.is_authenticated;
1224 }
1225 
1226 /**
1227  * wlan_peer_mlme_get_next_seq_num() - get peer mlme next sequence number
1228  * @peer: PEER object
1229  *
1230  * API to get mlme peer next sequence number
1231  *
1232  * Caller need to acquire lock with wlan_peer_obj_lock()
1233  *
1234  * Return: peer mlme next sequence number
1235  */
wlan_peer_mlme_get_next_seq_num(struct wlan_objmgr_peer * peer)1236 static inline uint32_t wlan_peer_mlme_get_next_seq_num(
1237 				struct wlan_objmgr_peer *peer)
1238 {
1239 	/* This API is invoked with lock acquired, do not add log prints */
1240 	if (peer->peer_mlme.seq_num < WLAN_MAX_SEQ_NUM)
1241 		peer->peer_mlme.seq_num++;
1242 	else
1243 		peer->peer_mlme.seq_num = 0;
1244 
1245 	return peer->peer_mlme.seq_num;
1246 }
1247 
1248 /**
1249  * wlan_peer_mlme_get_seq_num() - get peer mlme sequence number
1250  * @peer: PEER object
1251  *
1252  * API to get mlme peer sequence number
1253  *
1254  * Caller need to acquire lock with wlan_peer_obj_lock()
1255  *
1256  * Return: peer mlme sequence number
1257  */
wlan_peer_mlme_get_seq_num(struct wlan_objmgr_peer * peer)1258 static inline uint32_t wlan_peer_mlme_get_seq_num(
1259 				struct wlan_objmgr_peer *peer)
1260 {
1261 	/* This API is invoked with lock acquired, do not add log prints */
1262 	return peer->peer_mlme.seq_num;
1263 }
1264 
1265 /**
1266  * wlan_peer_mlme_reset_seq_num() - reset peer mlme sequence number
1267  * @peer: PEER object
1268  *
1269  * API to reset peer sequence number
1270  *
1271  * Caller need to acquire lock with wlan_peer_obj_lock()
1272  *
1273  * Return: void
1274  */
wlan_peer_mlme_reset_seq_num(struct wlan_objmgr_peer * peer)1275 static inline void wlan_peer_mlme_reset_seq_num(
1276 				struct wlan_objmgr_peer *peer)
1277 {
1278 	/* This API is invoked with lock acquired, do not add log prints */
1279 	peer->peer_mlme.seq_num = 0;
1280 }
1281 
1282 /**
1283  * wlan_peer_get_psoc() - get psoc
1284  * @peer: PEER object
1285  *
1286  * API to get peer's psoc
1287  *
1288  * Return: PSOC object or NULL if the psoc can not be found
1289  */
wlan_peer_get_psoc(struct wlan_objmgr_peer * peer)1290 static inline struct wlan_objmgr_psoc *wlan_peer_get_psoc(
1291 			struct wlan_objmgr_peer *peer)
1292 {
1293 	struct wlan_objmgr_vdev *vdev;
1294 	struct wlan_objmgr_psoc *psoc;
1295 
1296 	vdev = wlan_peer_get_vdev(peer);
1297 	if (!vdev)
1298 		return NULL;
1299 
1300 	psoc = wlan_vdev_get_psoc(vdev);
1301 
1302 	return psoc;
1303 }
1304 
1305 /**
1306  * wlan_peer_get_psoc_id() - get psoc id
1307  * @peer: PEER object
1308  *
1309  * API to get peer's psoc id
1310  *
1311  * Return: @psoc_id: psoc id
1312  */
wlan_peer_get_psoc_id(struct wlan_objmgr_peer * peer)1313 static inline uint8_t wlan_peer_get_psoc_id(struct wlan_objmgr_peer *peer)
1314 {
1315 	struct wlan_objmgr_psoc *psoc;
1316 
1317 	psoc = wlan_peer_get_psoc(peer);
1318 
1319 	return wlan_psoc_get_id(psoc);
1320 }
1321 
1322 /*
1323  * wlan_peer_get_pdev_id() - get pdev id
1324  * @peer: peer object pointer
1325  *
1326  * Return: pdev id
1327  */
wlan_peer_get_pdev_id(struct wlan_objmgr_peer * peer)1328 static inline uint8_t wlan_peer_get_pdev_id(struct wlan_objmgr_peer *peer)
1329 {
1330 	return peer->pdev_id;
1331 }
1332 
1333 /**
1334  * wlan_peer_set_pdev_id() - set pdev id
1335  * @peer: peer object pointer
1336  * @pdev_id: pdev id
1337  *
1338  * Return: void
1339  */
wlan_peer_set_pdev_id(struct wlan_objmgr_peer * peer,uint8_t pdev_id)1340 static inline void wlan_peer_set_pdev_id(struct wlan_objmgr_peer *peer,
1341 					 uint8_t pdev_id)
1342 {
1343 	peer->pdev_id = pdev_id;
1344 }
1345 
1346 /**
1347  * wlan_objmgr_print_peer_ref_ids() - print peer object refs
1348  * @peer: peer object pointer
1349  * @log_level: log level
1350  *
1351  * Return: void
1352  */
1353 void wlan_objmgr_print_peer_ref_ids(struct wlan_objmgr_peer *peer,
1354 				    QDF_TRACE_LEVEL log_level);
1355 
1356 /**
1357  * wlan_objmgr_peer_get_comp_ref_cnt() - get component ref count for a peer
1358  * @peer: peer object pointer
1359  * @id: component id
1360  *
1361  * Return: uint32_t
1362  */
1363 uint32_t
1364 wlan_objmgr_peer_get_comp_ref_cnt(struct wlan_objmgr_peer *peer,
1365 				  enum wlan_umac_comp_id id);
1366 
1367 /**
1368  * wlan_objmgr_peer_trace_init_lock() - Initialize peer trace lock
1369  * @peer: peer object pointer
1370  *
1371  * Return: void
1372  */
1373 #ifdef WLAN_OBJMGR_REF_ID_TRACE
1374 static inline void
wlan_objmgr_peer_trace_init_lock(struct wlan_objmgr_peer * peer)1375 wlan_objmgr_peer_trace_init_lock(struct wlan_objmgr_peer *peer)
1376 {
1377 	wlan_objmgr_trace_init_lock(&peer->peer_objmgr.trace);
1378 }
1379 #else
1380 static inline void
wlan_objmgr_peer_trace_init_lock(struct wlan_objmgr_peer * peer)1381 wlan_objmgr_peer_trace_init_lock(struct wlan_objmgr_peer *peer)
1382 {
1383 }
1384 #endif
1385 
1386 /**
1387  * wlan_objmgr_peer_trace_deinit_lock() - Deinitialize peer trace lock
1388  * @peer: peer object pointer
1389  *
1390  * Return: void
1391  */
1392 #ifdef WLAN_OBJMGR_REF_ID_TRACE
1393 static inline void
wlan_objmgr_peer_trace_deinit_lock(struct wlan_objmgr_peer * peer)1394 wlan_objmgr_peer_trace_deinit_lock(struct wlan_objmgr_peer *peer)
1395 {
1396 	wlan_objmgr_trace_deinit_lock(&peer->peer_objmgr.trace);
1397 }
1398 #else
1399 static inline void
wlan_objmgr_peer_trace_deinit_lock(struct wlan_objmgr_peer * peer)1400 wlan_objmgr_peer_trace_deinit_lock(struct wlan_objmgr_peer *peer)
1401 {
1402 }
1403 #endif
1404 
1405 /**
1406  * wlan_objmgr_peer_trace_del_ref_list() - Delete peer trace reference list
1407  * @peer: peer object pointer
1408  *
1409  * Return: void
1410  */
1411 #ifdef WLAN_OBJMGR_REF_ID_TRACE
1412 static inline void
wlan_objmgr_peer_trace_del_ref_list(struct wlan_objmgr_peer * peer)1413 wlan_objmgr_peer_trace_del_ref_list(struct wlan_objmgr_peer *peer)
1414 {
1415 	wlan_objmgr_trace_del_ref_list(&peer->peer_objmgr.trace);
1416 }
1417 #else
1418 static inline void
wlan_objmgr_peer_trace_del_ref_list(struct wlan_objmgr_peer * peer)1419 wlan_objmgr_peer_trace_del_ref_list(struct wlan_objmgr_peer *peer)
1420 {
1421 }
1422 #endif
1423 
1424 #endif /* _WLAN_OBJMGR_PEER_OBJ_H_*/
1425