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 any
6  * purpose with or without fee is hereby granted, provided that the above
7  * copyright notice and this permission notice appear in all copies.
8  *
9  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16  */
17 
18 /**
19  * DOC: Define the pdev data structure of UMAC
20  * Public APIs to perform operations on Global objects
21  */
22 
23 #ifndef _WLAN_OBJMGR_PDEV_OBJ_H_
24 #define _WLAN_OBJMGR_PDEV_OBJ_H_
25 
26 #include <wlan_objmgr_cmn.h>
27 #include "wlan_objmgr_psoc_obj.h"
28 #include <target_if_pub.h>
29 #include <qdf_defer.h>
30 
31 /* STATUS: scanning */
32 #define WLAN_PDEV_F_SCAN                    0x00000001
33 /* STATUS: use short slot time*/
34 #define WLAN_PDEV_F_SHSLOT                  0x00000002
35   /* STATUS: channel switch event pending after DFS RADAR */
36 #define WLAN_PDEV_F_DFS_CHANSWITCH_PENDING  0x00000004
37   /* TX Power: fixed rate */
38 #define WLAN_PDEV_F_TXPOW_FIXED             0x00000008
39   /* STATUS: use short preamble */
40 #define WLAN_PDEV_F_SHPREAMBLE              0x00000010
41   /* CONF: do alignment pad */
42 #define WLAN_PDEV_F_DATAPAD                 0x00000020
43   /* STATUS: protection enabled */
44 #define WLAN_PDEV_F_USEPROT                 0x00000040
45   /* STATUS: use barker preamble*/
46 #define WLAN_PDEV_F_USEBARKER               0x00000080
47   /* CONF: DISABLE 2040 coexistence */
48 #define WLAN_PDEV_F_COEXT_DISABLE           0x00000100
49   /* STATE: scan pending */
50 #define WLAN_PDEV_F_SCAN_PENDING            0x00000200
51   /* CONF: send regclassids in country ie */
52 #define WLAN_PDEV_F_REGCLASS                0x00000400
53   /* CONF: block the use of DFS channels */
54 #define WLAN_PDEV_F_BLKDFSCHAN              0x00000800
55   /* STATUS: 11D in used */
56 #define WLAN_PDEV_F_DOT11D                  0x00001000
57   /* STATUS: 11D channel-switch detected */
58 #define WLAN_PDEV_F_RADAR                   0x00002000
59   /* CONF: A-MPDU supported */
60 #define WLAN_PDEV_F_AMPDU                   0x00004000
61   /* CONF: A-MSDU supported */
62 #define WLAN_PDEV_F_AMSDU                   0x00008000
63   /* CONF: HT traffic protected */
64 #define WLAN_PDEV_F_HTPROT                  0x00010000
65   /* CONF: Reset once */
66 #define WLAN_PDEV_F_RESET                   0x00020000
67   /* CONF: ignore 11d beacon */
68 #define WLAN_PDEV_F_IGNORE_11D_BEACON       0x00040000
69   /* HT CAP IE present */
70 #define WLAN_PDEV_F_HTVIE                   0x00080000
71  /* radio in middle of CSA */
72 #define WLAN_PDEV_F_CSA_WAIT                0x00100000
73  /* wnm support flag */
74 #define WLAN_PDEV_F_WNM                     0x00200000
75 #define WLAN_PDEV_F_2G_CSA                  0x00400000
76   /* enhanced independent repeater  */
77 #define WLAN_PDEV_F_ENH_REP_IND             0x00800000
78  /* Disable Tx AMSDU for station vap */
79 #define WLAN_PDEV_F_STA_AMPDU_DIS           0x01000000
80 /* do not send probe request in passive channel */
81 #define WLAN_PDEV_F_STRICT_PSCAN_EN         0x02000000
82 /* Multivdev restart enabled with Bitmap */
83 #define WLAN_PDEV_F_MULTIVDEV_RESTART_BMAP  0x04000000
84 /* Chan concurrency enabled */
85 #define WLAN_PDEV_F_CHAN_CONCURRENCY        0x08000000
86 /* Multivdev restart enabled */
87 #define WLAN_PDEV_F_MULTIVDEV_RESTART       0x10000000
88 /* MBSS IE enable */
89 #define WLAN_PDEV_F_MBSS_IE_ENABLE          0x20000000
90 /* VDEV Peer delete all */
91 #define WLAN_PDEV_F_DELETE_ALL_PEER         0x40000000
92 /* PDEV BEacon Protection */
93 #define WLAN_PDEV_F_BEACON_PROTECTION       0x80000000
94 
95 /* PDEV ext flags */
96 /* CFR support enabled */
97 #define WLAN_PDEV_FEXT_CFR_EN               0x00000001
98 /* EMA AP support enable */
99 #define WLAN_PDEV_FEXT_EMA_AP_ENABLE        0x00000002
100 /* scan radio support */
101 #define WLAN_PDEV_FEXT_SCAN_RADIO           0x00000004
102 /* DFS disable, valid only for scan radio supported pdevs */
103 #define WLAN_PDEV_FEXT_SCAN_RADIO_DFS_DIS   0x00000008
104 /* normal Spectral scan support disable */
105 #define WLAN_PDEV_FEXT_NORMAL_SPECTRAL_SCAN_DIS          0x00000010
106 /* agile Spectral scan support disable for 20/40/80 MHz */
107 #define WLAN_PDEV_FEXT_AGILE_SPECTRAL_SCAN_DIS           0x00000020
108 /* agile Spectral scan support disable for 160 MHz */
109 #define WLAN_PDEV_FEXT_AGILE_SPECTRAL_SCAN_160_DIS       0x00000040
110 /* agile Spectral scan support disable for 80+80 MHz */
111 #define WLAN_PDEV_FEXT_AGILE_SPECTRAL_SCAN_80P80_DIS     0x00000080
112 /* agile Spectral scan support disable for 320 MHz */
113 #define WLAN_PDEV_FEXT_AGILE_SPECTRAL_SCAN_320_DIS     0x00000100
114 /* WiFi Radar support enabled */
115 #define WLAN_PDEV_FEXT_WIFI_RADAR_ENABLE               0x00000200
116 /* Scan blanking support enabled.valid only for scan radio supported pdevs */
117 #define WLAN_PDEV_FEXT_SCAN_BLANKING_EN                0x00000400
118 /* Overlapping frequency support */
119 #define WLAN_PDEV_FEXT_OVERLAPPING_FREQ                0x00000800
120 
121 /* PDEV op flags */
122    /* Enable htrate for wep and tkip */
123 #define WLAN_PDEV_OP_WEP_TKIP_HTRATE    0x00000001
124   /* non HT AP found flag */
125 #define WLAN_PDEV_OP_NON_HT_AP          0x00000002
126   /* block the use of DFS channels flag */
127 #define WLAN_PDEV_OP_BLK_DFS_CHAN       0x00000004
128   /* 11.h flag */
129 #define WLAN_PDEV_OP_DOTH               0x00000008
130   /* Off-channel support enabled */
131 #define WLAN_PDEV_OP_OFFCHAN            0x00000010
132 #define WLAN_PDEV_OP_HT20ADHOC          0x00000020
133 #define WLAN_PDEV_OP_HT40ADHOC          0x00000040
134 #define WLAN_PDEV_OP_HTADHOC_AGGR       0x00000080
135    /* disallow CC change when assoc completes */
136 #define WLAN_PDEV_OP_DISALLOW_AUTO_CC   0x00000100
137    /* Is P2P Enabled? */
138 #define WLAN_PDEV_OP_P2P                0x00000200
139    /* disallowed  */
140 #define WLAN_PDEV_OP_IGNORE_DYNHALT     0x00000400
141    /* overwrite probe response IE with beacon IE */
142 #define WLAN_PDEV_OP_OVERRIDE_PROBERESP 0x00000800
143 #define WLAN_PDEV_OP_DROPSTA_QUERY      0x00001000
144 #define WLAN_PDEV_OP_BLK_REPORT_FLOOD   0x00002000
145    /* Offchan scan */
146 #define WLAN_PDEV_OP_OFFCHAN_SCAN       0x00004000
147    /*Consider OBSS non-erp to change to long slot*/
148 #define WLAN_PDEV_OP_OBSS_LONGSLOT      0x00008000
149    /* enable/disable min rssi cli block */
150 #define WLAN_PDEV_OP_MIN_RSSI_ENABLE    0x00010000
151    /* PDEV VDEV restart is in progress */
152 #define WLAN_PDEV_OP_RESTART_INPROGRESS 0x00020000
153    /* PDEV MBSSID VDEV restart trigger */
154 #define WLAN_PDEV_OP_MBSSID_RESTART     0x00040000
155    /* RADAR DETECT Defer */
156 #define WLAN_PDEV_OP_RADAR_DETECT_DEFER 0x00080000
157 
158 
159 struct osif_pdev_priv;
160 
161 /**
162  * struct wlan_objmgr_pdev_nif  - pdev object nif structure
163  * @pdev_fw_caps:       radio specific FW capabilities
164  * @pdev_feature_caps:  radio specific feature capabilities
165  * @pdev_feature_ext_caps:  radio specific feature capabilities extended
166  * @pdev_ospriv:        OS specific pointer
167  * @macaddr:            MAC address
168  * @notified_ap_vdev:   ap vdev
169  */
170 struct wlan_objmgr_pdev_nif {
171 	uint32_t pdev_fw_caps;
172 	uint32_t pdev_feature_caps;
173 	uint32_t pdev_feature_ext_caps;
174 	struct pdev_osif_priv *pdev_ospriv;
175 	uint8_t macaddr[QDF_MAC_ADDR_SIZE];
176 	uint8_t notified_ap_vdev;
177 };
178 
179 /**
180  * struct wlan_objmgr_pdev_mlme - pdev object mlme structure
181  * @pdev_op_flags:    PDEV operation flags, can be used to know the
182  *                    operation status (deletion progress, etc)
183  */
184 struct wlan_objmgr_pdev_mlme {
185 	uint32_t pdev_op_flags;
186 };
187 
188 /**
189  * struct wlan_beacon_process - wlan beacon structure
190  * @bcn_rate_limit:    To indicate if beacon ratelimiting is enabled or not
191  * @wlan_beacon_count: Per pdev beacon count received
192  * @max_beacon_count:  Per vdev max beacon count, defaults to 100
193  * @max_beacon_limit:  Limit of beacons to be processed
194  * @dropped_beacon:    Dropped beacons
195  */
196 struct wlan_beacon_process {
197 	bool bcn_rate_limit;
198 	uint64_t wlan_beacon_count;
199 	uint64_t max_beacon_count;
200 	uint8_t max_beacon_limit;
201 	uint64_t dropped_beacon;
202 };
203 
204 /**
205  * struct wlan_objmgr_pdev_objmgr - pdev object object manager structure
206  * @wlan_pdev_id:      PDEV id
207  * @wlan_vdev_count:   VDEVs count
208  * @max_vdev_count:    Max no. of VDEVs supported by this PDEV
209  * @print_cnt:         Count to throttle Logical delete prints
210  * @wlan_vdev_list:    List maintains the VDEVs created on this PDEV
211  * @wlan_peer_count:   Peer count
212  * @max_peer_count:    Max Peer count
213  * @temp_peer_count:   Temporary peer count
214  * @max_monitor_vdev_count: Max monitor vdev count
215  * @max_bridge_vdev_count: Max bridge vdev count
216  * @wlan_psoc:         back pointer to PSOC, its attached to
217  * @ref_cnt:           Ref count
218  * @ref_id_dbg:        Array to track Ref count
219  * @wlan_mlo_vdev_count: MLO VDEVs count
220  * @wlan_mlo_bridge_vdev_count: MLO bridge VDEVs count
221  * @bcn:               Struct to keep track of beacon count
222  */
223 struct wlan_objmgr_pdev_objmgr {
224 	uint8_t wlan_pdev_id;
225 	uint8_t wlan_vdev_count;
226 	uint8_t max_vdev_count;
227 	uint8_t print_cnt;
228 	qdf_list_t wlan_vdev_list;
229 	uint16_t wlan_peer_count;
230 	uint16_t max_peer_count;
231 	uint16_t temp_peer_count;
232 	uint8_t max_monitor_vdev_count;
233 	uint8_t max_bridge_vdev_count;
234 	struct wlan_objmgr_psoc *wlan_psoc;
235 	qdf_atomic_t ref_cnt;
236 	qdf_atomic_t ref_id_dbg[WLAN_REF_ID_MAX];
237 #ifdef WLAN_FEATURE_11BE_MLO
238 	qdf_atomic_t wlan_mlo_vdev_count;
239 	qdf_atomic_t wlan_mlo_bridge_vdev_count;
240 #endif
241 	struct wlan_beacon_process bcn;
242 };
243 
244 /**
245  * struct wlan_objmgr_pdev - PDEV common object
246  * @current_chan_list: Active/current Channel list of the radio
247  * @pdev_nif:          pdev nif structure
248  * @pdev_objmgr:       pdev object manager structure
249  * @pdev_mlme:         pdev MLME structure
250  * @pdev_comp_priv_obj:   component's private object array
251  * @obj_status:        object status of each component object
252  * @obj_state:         object state
253  * @tgt_if_handle:     Target interface handle
254  * @pdev_lock:         lock to protect object
255  * @peer_free_lock:    lock to protect peer object free
256  * @peer_free_list:    list to hold freed peer
257  * @peer_obj_free_work:delayed work to be queued into workqueue
258  * @active_work_cnt:   active work counts
259  * @standby_active: Pdev in standby mode while power down
260 */
261 struct wlan_objmgr_pdev {
262 	struct wlan_chan_list *current_chan_list;
263 	struct wlan_objmgr_pdev_nif  pdev_nif;
264 	struct wlan_objmgr_pdev_objmgr pdev_objmgr;
265 	struct wlan_objmgr_pdev_mlme   pdev_mlme;
266 	void *pdev_comp_priv_obj[WLAN_UMAC_MAX_COMPONENTS];
267 	QDF_STATUS obj_status[WLAN_UMAC_MAX_COMPONENTS];
268 	WLAN_OBJ_STATE obj_state;
269 	target_pdev_info_t *tgt_if_handle;
270 	qdf_spinlock_t pdev_lock;
271 #ifdef FEATURE_DELAYED_PEER_OBJ_DESTROY
272 	qdf_spinlock_t peer_free_lock;
273 	qdf_list_t peer_free_list;
274 	qdf_work_t peer_obj_free_work;
275 	uint32_t active_work_cnt;
276 #endif
277 	bool standby_active;
278 };
279 
280 /*
281  * APIs to Create/Delete Global object APIs
282  */
283 /**
284  * wlan_objmgr_pdev_obj_create() - pdev create
285  * @psoc: PSOC object
286  * @osif_priv: os private object
287  *
288  * Creates PDEV object, initializes with default values
289  * Invokes the registered notifiers to create component object
290  *
291  * Return: Handle to struct wlan_objmgr_psoc on successful creation,
292  *         NULL on Failure (on Mem alloc failure and Component objects
293  *         Failure)
294  */
295 struct wlan_objmgr_pdev *wlan_objmgr_pdev_obj_create(
296 	struct wlan_objmgr_psoc *psoc, struct pdev_osif_priv *osif_priv);
297 
298 /**
299  * wlan_objmgr_pdev_obj_delete() - pdev delete
300  * @pdev: PDEV object
301  *
302  * Logically deletes PDEV object,
303  * Once all the references are released, object manager invokes the registered
304  * notifiers to destroy component objects
305  *
306  * Return: SUCCESS/FAILURE
307  */
308 QDF_STATUS wlan_objmgr_pdev_obj_delete(struct wlan_objmgr_pdev *pdev);
309 
310 /*
311  * APIs to attach/detach component objects
312  */
313 /**
314  * wlan_objmgr_pdev_component_obj_attach() - pdev comp object attach
315  * @pdev: PDEV object
316  * @id: Component id
317  * @comp_priv_obj: component's private object pointer
318  * @status: Component's private object creation status
319  *
320  * API to be used for attaching component object with PDEV common object
321  *
322  * Return: SUCCESS on successful storing of component's object in common object
323  *         On FAILURE (appropriate failure codes are returned)
324  */
325 QDF_STATUS wlan_objmgr_pdev_component_obj_attach(
326 		struct wlan_objmgr_pdev *pdev,
327 		enum wlan_umac_comp_id id,
328 		void *comp_priv_obj,
329 		QDF_STATUS status);
330 
331 /**
332  * wlan_objmgr_pdev_component_obj_detach() - pdev comp object detach
333  * @pdev: PDEV object
334  * @id: Component id
335  * @comp_priv_obj: component's private object pointer
336  *
337  * API to be used for detaching component object with PDEV common object
338  *
339  * Return: SUCCESS on successful removal of component's object from common
340  *         object
341  *         On FAILURE (appropriate failure codes are returned)
342  */
343 QDF_STATUS wlan_objmgr_pdev_component_obj_detach(
344 		struct wlan_objmgr_pdev *pdev,
345 		enum wlan_umac_comp_id id,
346 		void *comp_priv_obj);
347 
348 /*
349  * APIs to operations on pdev objects
350  */
351 
352 typedef void (*wlan_objmgr_pdev_op_handler)(struct wlan_objmgr_pdev *pdev,
353 					void *object,
354 					void *arg);
355 
356 /**
357  * wlan_objmgr_pdev_iterate_obj_list() - operate on all objects of pdev
358  * @pdev: PDEV object
359  * @obj_type: VDEV_OP/PEER_OP
360  * @handler: the handler will be called for each object of requested type
361  *           the handler should be implemented to perform required operation
362  * @arg: arguments passed by caller
363  * @lock_free_op: its obsolete
364  * @dbg_id: id of the caller
365  *
366  * API to be used for performing the operations on all VDEV/PEER objects
367  * of pdev
368  *
369  * Return: SUCCESS/FAILURE
370  */
371 QDF_STATUS wlan_objmgr_pdev_iterate_obj_list(
372 		struct wlan_objmgr_pdev *pdev,
373 		enum wlan_objmgr_obj_type obj_type,
374 		wlan_objmgr_pdev_op_handler handler,
375 		void *arg, uint8_t lock_free_op,
376 		wlan_objmgr_ref_dbgid dbg_id);
377 
378 /**
379  * wlan_objmgr_trigger_pdev_comp_priv_object_creation() - create
380  * comp object of pdev
381  * @pdev: PDEV object
382  * @id: Component id
383  *
384  * API to create component private object in run time, this would be
385  * used for features which gets enabled in run time
386  *
387  * Return: SUCCESS on successful creation
388  *         On FAILURE (appropriate failure codes are returned)
389  */
390 QDF_STATUS wlan_objmgr_trigger_pdev_comp_priv_object_creation(
391 		struct wlan_objmgr_pdev *pdev,
392 		enum wlan_umac_comp_id id);
393 
394 /**
395  * wlan_objmgr_trigger_pdev_comp_priv_object_deletion() - destroy
396  * comp object of pdev
397  * @pdev: PDEV object
398  * @id: Component id
399  *
400  * API to destroy component private object in run time, this would
401  * be used for features which gets disabled in run time
402  *
403  * Return: SUCCESS on successful deletion
404  *         On FAILURE (appropriate failure codes are returned)
405  */
406 QDF_STATUS wlan_objmgr_trigger_pdev_comp_priv_object_deletion(
407 		struct wlan_objmgr_pdev *pdev,
408 		enum wlan_umac_comp_id id);
409 
410 /**
411  * wlan_objmgr_get_vdev_by_id_from_pdev() - find vdev using id from pdev
412  * @pdev: PDEV object
413  * @vdev_id: vdev id
414  * @dbg_id: id of the caller
415  *
416  * API to find vdev object pointer by vdev id from pdev's vdev list
417  *
418  * This API increments the ref count of the vdev object internally, the
419  * caller has to invoke the wlan_objmgr_vdev_release_ref() to decrement
420  * ref count
421  *
422  * Return: vdev pointer
423  *         NULL on FAILURE
424  */
425 #ifdef WLAN_OBJMGR_REF_ID_TRACE
426 #define wlan_objmgr_get_vdev_by_id_from_pdev(pdev, vdev_id, dbg_id) \
427 		wlan_objmgr_get_vdev_by_id_from_pdev_debug(pdev, \
428 		vdev_id, dbg_id, __func__, __LINE__)
429 
430 struct wlan_objmgr_vdev *wlan_objmgr_get_vdev_by_id_from_pdev_debug(
431 			struct wlan_objmgr_pdev *pdev, uint8_t vdev_id,
432 			wlan_objmgr_ref_dbgid dbg_id,
433 			const char *func, int line);
434 #else
435 struct wlan_objmgr_vdev *wlan_objmgr_get_vdev_by_id_from_pdev(
436 			struct wlan_objmgr_pdev *pdev, uint8_t vdev_id,
437 			wlan_objmgr_ref_dbgid dbg_id);
438 #endif
439 
440 /**
441  * wlan_objmgr_get_vdev_by_id_from_pdev_no_state() - find vdev using id
442  *                                                         from pdev
443  * @pdev: PDEV object
444  * @vdev_id: vdev id
445  * @dbg_id: id of the caller
446  *
447  * API to find vdev object pointer by vdev id from pdev's vdev list
448  *
449  * This API increments the ref count of the vdev object internally, the
450  * caller has to invoke the wlan_objmgr_vdev_release_ref() to decrement
451  * ref count
452  *
453  * Return: vdev pointer
454  *         NULL on FAILURE
455  */
456 #ifdef WLAN_OBJMGR_REF_ID_TRACE
457 #define wlan_objmgr_get_vdev_by_id_from_pdev_no_state(pdev, \
458 	vdev_id, dbg_id) \
459 		wlan_objmgr_get_vdev_by_id_from_pdev_no_state_debug(pdev, \
460 		vdev_id, dbg_id, __func__, __LINE__)
461 
462 struct wlan_objmgr_vdev *wlan_objmgr_get_vdev_by_id_from_pdev_no_state_debug(
463 			struct wlan_objmgr_pdev *pdev, uint8_t vdev_id,
464 			wlan_objmgr_ref_dbgid dbg_id,
465 			const char *func, int line);
466 #else
467 struct wlan_objmgr_vdev *wlan_objmgr_get_vdev_by_id_from_pdev_no_state(
468 			struct wlan_objmgr_pdev *pdev, uint8_t vdev_id,
469 			wlan_objmgr_ref_dbgid dbg_id);
470 #endif
471 
472 /**
473  * wlan_objmgr_get_vdev_by_macaddr_from_pdev() - find vdev using macaddr
474  * @pdev: PDEV object
475  * @macaddr: MAC address
476  * @dbg_id: id of the caller
477  *
478  * API to find vdev object pointer by vdev mac addr from pdev's vdev list
479  *
480  * This API increments the ref count of the vdev object internally, the
481  * caller has to invoke the wlan_objmgr_vdev_release_ref() to decrement
482  * ref count
483  *
484  * Return: vdev pointer
485  *         NULL on FAILURE
486  */
487 #ifdef WLAN_OBJMGR_REF_ID_TRACE
488 #define wlan_objmgr_get_vdev_by_macaddr_from_pdev(pdev, macaddr, dbg_id) \
489 		wlan_objmgr_get_vdev_by_macaddr_from_pdev_debug(pdev, macaddr, \
490 		dbg_id, __func__, __LINE__)
491 
492 struct wlan_objmgr_vdev *wlan_objmgr_get_vdev_by_macaddr_from_pdev_debug(
493 		struct wlan_objmgr_pdev *pdev, const uint8_t *macaddr,
494 		wlan_objmgr_ref_dbgid dbg_id,
495 		const char *fnc, int ln);
496 #else
497 struct wlan_objmgr_vdev *wlan_objmgr_get_vdev_by_macaddr_from_pdev(
498 		struct wlan_objmgr_pdev *pdev, const uint8_t *macaddr,
499 		wlan_objmgr_ref_dbgid dbg_id);
500 #endif
501 
502 /**
503  * wlan_objmgr_get_vdev_by_macaddr_from_pdev_no_state() - find vdev using
504  *                                                           macaddr
505  * @pdev: PDEV object
506  * @macaddr: MAC address
507  * @dbg_id: id of the caller
508  *
509  * API to find vdev object pointer by vdev mac addr from pdev's vdev list
510  *
511  * This API increments the ref count of the vdev object internally, the
512  * caller has to invoke the wlan_objmgr_vdev_release_ref() to decrement
513  * ref count
514  *
515  * Return: vdev pointer
516  *         NULL on FAILURE
517  */
518 #ifdef WLAN_OBJMGR_REF_ID_TRACE
519 #define wlan_objmgr_get_vdev_by_macaddr_from_pdev_no_state(pdev, macaddr, \
520 	dbg_id) \
521 		wlan_objmgr_get_vdev_by_macaddr_from_pdev_no_state_debug(pdev, \
522 		macaddr, dbg_id, __func__, __LINE__)
523 
524 struct wlan_objmgr_vdev
525 	*wlan_objmgr_get_vdev_by_macaddr_from_pdev_no_state_debug(
526 		struct wlan_objmgr_pdev *pdev, const uint8_t *macaddr,
527 		wlan_objmgr_ref_dbgid dbg_id,
528 		const char *func, int line);
529 #else
530 struct wlan_objmgr_vdev *wlan_objmgr_get_vdev_by_macaddr_from_pdev_no_state(
531 		struct wlan_objmgr_pdev *pdev, const uint8_t *macaddr,
532 		wlan_objmgr_ref_dbgid dbg_id);
533 #endif
534 
535 /**
536  * wlan_objmgr_pdev_get_first_vdev() - Get first vdev of pdev
537  * @pdev: PDEV object
538  * @dbg_id:   Object Manager ref debug id
539  *
540  * API to get reference to first vdev of pdev.
541  *
542  * Return: reference to first vdev
543  */
544 #ifdef WLAN_OBJMGR_REF_ID_TRACE
545 #define wlan_objmgr_pdev_get_first_vdev(pdev, dbg_id) \
546 		wlan_objmgr_pdev_get_first_vdev_debug(pdev, dbg_id, \
547 		__func__, __LINE__)
548 
549 struct wlan_objmgr_vdev *wlan_objmgr_pdev_get_first_vdev_debug(
550 		struct wlan_objmgr_pdev *pdev,
551 		wlan_objmgr_ref_dbgid dbg_id,
552 		const char *func, int line);
553 #else
554 struct wlan_objmgr_vdev *wlan_objmgr_pdev_get_first_vdev(
555 		struct wlan_objmgr_pdev *pdev,
556 		wlan_objmgr_ref_dbgid dbg_id);
557 #endif
558 
559 /**
560  * wlan_objmgr_pdev_get_roam_vdev() - Get roam vdev of pdev
561  * @pdev: PDEV object
562  * @dbg_id: Object Manager ref debug id
563  *
564  * API to get reference to vdev which is in roaming from pdev.
565  *
566  * Return: reference to roam vdev
567  */
568 struct wlan_objmgr_vdev *wlan_objmgr_pdev_get_roam_vdev(
569 						struct wlan_objmgr_pdev *pdev,
570 						wlan_objmgr_ref_dbgid dbg_id);
571 
572 /**
573  * wlan_objmgr_pdev_get_comp_private_obj() - get pdev component private object
574  * @pdev: PDEV object
575  * @id: Component id
576  *
577  * API to get component private object
578  *
579  * Return: void *ptr on SUCCESS
580  *         NULL on Failure
581  */
582 void *wlan_objmgr_pdev_get_comp_private_obj(
583 		struct wlan_objmgr_pdev *pdev,
584 		enum wlan_umac_comp_id id);
585 
586 /**
587  * wlan_pdev_obj_lock() - Acquire PDEV spinlock
588  * @pdev: PDEV object
589  *
590  * API to acquire PDEV lock
591  * Parent lock should not be taken in child lock context
592  * but child lock can be taken in parent lock context
593  * (for ex: psoc lock can't be invoked in pdev/vdev/peer lock context)
594  *
595  * Return: void
596  */
wlan_pdev_obj_lock(struct wlan_objmgr_pdev * pdev)597 static inline void wlan_pdev_obj_lock(struct wlan_objmgr_pdev *pdev)
598 {
599 	qdf_spin_lock_bh(&pdev->pdev_lock);
600 }
601 
602 /**
603  * wlan_pdev_obj_unlock() - Release PDEV spinlock
604  * @pdev: PDEV object
605  *
606  * API to Release PDEV lock
607  *
608  * Return: void
609  */
wlan_pdev_obj_unlock(struct wlan_objmgr_pdev * pdev)610 static inline void wlan_pdev_obj_unlock(struct wlan_objmgr_pdev *pdev)
611 {
612 	qdf_spin_unlock_bh(&pdev->pdev_lock);
613 }
614 
615 /**
616  * wlan_pdev_get_psoc() - get psoc
617  * @pdev: PDEV object
618  *
619  * API to get the psoc object from PDEV
620  *
621  * Return: PSOC object
622  */
wlan_pdev_get_psoc(struct wlan_objmgr_pdev * pdev)623 static inline struct wlan_objmgr_psoc *wlan_pdev_get_psoc(
624 			struct wlan_objmgr_pdev *pdev)
625 {
626 	return pdev->pdev_objmgr.wlan_psoc;
627 }
628 
629 /**
630  * wlan_pdev_set_psoc() - set psoc
631  * @pdev: PDEV object
632  * @psoc: PSOC object
633  *
634  * API to set the psoc object from PDEV
635  *
636  * Return: void
637  */
wlan_pdev_set_psoc(struct wlan_objmgr_pdev * pdev,struct wlan_objmgr_psoc * psoc)638 static inline void wlan_pdev_set_psoc(struct wlan_objmgr_pdev *pdev,
639 				struct wlan_objmgr_psoc *psoc)
640 {
641 	pdev->pdev_objmgr.wlan_psoc = psoc;
642 }
643 
644 /**
645  * wlan_pdev_nif_fw_cap_set() - set fw caps
646  * @pdev: PDEV object
647  * @cap: capability flag to be set
648  *
649  * API to set fw caps in pdev
650  *
651  * Return: void
652  */
wlan_pdev_nif_fw_cap_set(struct wlan_objmgr_pdev * pdev,uint32_t cap)653 static inline void wlan_pdev_nif_fw_cap_set(struct wlan_objmgr_pdev *pdev,
654 				uint32_t cap)
655 {
656 	pdev->pdev_nif.pdev_fw_caps |= cap;
657 }
658 
659 /**
660  * wlan_pdev_nif_fw_cap_clear() - clear fw cap
661  * @pdev: PDEV object
662  * @cap: capability flag to be cleared
663  *
664  * API to clear fw caps in pdev
665  *
666  * Return: void
667  */
wlan_pdev_nif_fw_cap_clear(struct wlan_objmgr_pdev * pdev,uint32_t cap)668 static inline void wlan_pdev_nif_fw_cap_clear(struct wlan_objmgr_pdev *pdev,
669 				uint32_t cap)
670 {
671 	pdev->pdev_nif.pdev_fw_caps &= ~cap;
672 }
673 
674 /**
675  * wlan_pdev_nif_fw_cap_get() - get fw caps
676  * @pdev: PDEV object
677  * @cap: capability flag to be checked
678  *
679  * API to know, whether particular fw caps flag is set in pdev
680  *
681  * Return: 1 (for set) or 0 (for not set)
682  */
wlan_pdev_nif_fw_cap_get(struct wlan_objmgr_pdev * pdev,uint32_t cap)683 static inline uint8_t wlan_pdev_nif_fw_cap_get(struct wlan_objmgr_pdev *pdev,
684 				uint32_t cap)
685 {
686 	return (pdev->pdev_nif.pdev_fw_caps & cap) ? 1 : 0;
687 }
688 
689 /**
690  * wlan_pdev_nif_feat_cap_set() - set feature caps
691  * @pdev: PDEV object
692  * @cap: capability flag to be set
693  *
694  * API to set feat caps in pdev
695  *
696  * Return: void
697  */
wlan_pdev_nif_feat_cap_set(struct wlan_objmgr_pdev * pdev,uint32_t cap)698 static inline void wlan_pdev_nif_feat_cap_set(struct wlan_objmgr_pdev *pdev,
699 				uint32_t cap)
700 {
701 	pdev->pdev_nif.pdev_feature_caps |= cap;
702 }
703 
704 /**
705  * wlan_pdev_nif_feat_cap_clear() - clear feature caps
706  * @pdev: PDEV object
707  * @cap: capability flag to be cleared
708  *
709  * API to clear feat caps in pdev
710  *
711  * Return: void
712  */
wlan_pdev_nif_feat_cap_clear(struct wlan_objmgr_pdev * pdev,uint32_t cap)713 static inline void wlan_pdev_nif_feat_cap_clear(struct wlan_objmgr_pdev *pdev,
714 				uint32_t cap)
715 {
716 	pdev->pdev_nif.pdev_feature_caps &= ~cap;
717 }
718 
719 /**
720  * wlan_pdev_nif_feat_cap_get() - get feature caps
721  * @pdev: PDEV object
722  * @cap: capability flag to be checked
723  *
724  * API to know, whether particular feat caps flag is set in pdev
725  *
726  * Return: 1 (for set) or 0 (for not set)
727  */
wlan_pdev_nif_feat_cap_get(struct wlan_objmgr_pdev * pdev,uint32_t cap)728 static inline uint8_t wlan_pdev_nif_feat_cap_get(struct wlan_objmgr_pdev *pdev,
729 				uint32_t cap)
730 {
731 	return (pdev->pdev_nif.pdev_feature_caps & cap) ? 1 : 0;
732 }
733 
734 /**
735  * wlan_pdev_nif_feat_ext_cap_set() - set feature ext caps
736  * @pdev: PDEV object
737  * @cap: capability flag to be set
738  *
739  * API to set feat ext caps in pdev
740  *
741  * Return: void
742  */
743 static inline
wlan_pdev_nif_feat_ext_cap_set(struct wlan_objmgr_pdev * pdev,uint32_t cap)744 void wlan_pdev_nif_feat_ext_cap_set(struct wlan_objmgr_pdev *pdev,
745 				    uint32_t cap)
746 {
747 	pdev->pdev_nif.pdev_feature_ext_caps |= cap;
748 }
749 
750 /**
751  * wlan_pdev_nif_feat_ext_cap_clear() - clear feature ext caps
752  * @pdev: PDEV object
753  * @cap: capability flag to be cleared
754  *
755  * API to clear feat ext caps in pdev
756  *
757  * Return: void
758  */
759 static inline
wlan_pdev_nif_feat_ext_cap_clear(struct wlan_objmgr_pdev * pdev,uint32_t cap)760 void wlan_pdev_nif_feat_ext_cap_clear(struct wlan_objmgr_pdev *pdev,
761 				      uint32_t cap)
762 {
763 	pdev->pdev_nif.pdev_feature_ext_caps &= ~cap;
764 }
765 
766 /**
767  * wlan_pdev_nif_feat_ext_cap_get() - get feature ext caps
768  * @pdev: PDEV object
769  * @cap: capability flag to be checked
770  *
771  * API to know, whether particular feat ext caps flag is set in pdev
772  *
773  * Return: 1 (for set) or 0 (for not set)
774  */
775 static inline
wlan_pdev_nif_feat_ext_cap_get(struct wlan_objmgr_pdev * pdev,uint32_t cap)776 uint8_t wlan_pdev_nif_feat_ext_cap_get(struct wlan_objmgr_pdev *pdev,
777 				       uint32_t cap)
778 {
779 	return (pdev->pdev_nif.pdev_feature_ext_caps & cap) ? 1 : 0;
780 }
781 
782 /**
783  * wlan_pdev_mlme_op_set() - set operation flags
784  * @pdev: PDEV object
785  * @op: Operation flag to be set
786  *
787  * API to set operation flag in pdev
788  *
789  * Return: void
790  */
wlan_pdev_mlme_op_set(struct wlan_objmgr_pdev * pdev,uint32_t op)791 static inline void wlan_pdev_mlme_op_set(struct wlan_objmgr_pdev *pdev,
792 					 uint32_t op)
793 {
794 	pdev->pdev_mlme.pdev_op_flags |= op;
795 }
796 
797 /**
798  * wlan_pdev_mlme_op_clear() - clear op flags
799  * @pdev: PDEV object
800  * @op: Operation flag to be cleared
801  *
802  * API to clear op flag in pdev
803  *
804  * Return: void
805  */
wlan_pdev_mlme_op_clear(struct wlan_objmgr_pdev * pdev,uint32_t op)806 static inline void wlan_pdev_mlme_op_clear(struct wlan_objmgr_pdev *pdev,
807 					   uint32_t op)
808 {
809 	pdev->pdev_mlme.pdev_op_flags &= ~op;
810 }
811 
812 /**
813  * wlan_pdev_mlme_op_get() - get op flag
814  * @pdev: PDEV object
815  * @op: Operation flag to be checked
816  *
817  * API to know, whether particular operation flag is set in pdev
818  *
819  * Return: 1 (for set) or 0 (for not set)
820  */
wlan_pdev_mlme_op_get(struct wlan_objmgr_pdev * pdev,uint32_t op)821 static inline uint8_t wlan_pdev_mlme_op_get(struct wlan_objmgr_pdev *pdev,
822 					    uint32_t op)
823 {
824 	return (pdev->pdev_mlme.pdev_op_flags & op) ? 1 : 0;
825 }
826 
827 /**
828  * wlan_pdev_get_hw_macaddr() - get hw macaddr
829  * @pdev: PDEV object
830  *
831  * API to get HW MAC address form PDEV
832  *
833  * Caller need to acquire lock with wlan_pdev_obj_lock()
834  *
835  * Return: @macaddr -MAC address
836  */
wlan_pdev_get_hw_macaddr(struct wlan_objmgr_pdev * pdev)837 static inline uint8_t *wlan_pdev_get_hw_macaddr(struct wlan_objmgr_pdev *pdev)
838 {
839 	if (!pdev)
840 		return NULL;
841 
842 	/* This API is invoked with lock acquired, do not add log prints */
843 	return pdev->pdev_nif.macaddr;
844 }
845 
846 /**
847  * wlan_pdev_set_hw_macaddr() - set hw macaddr
848  * @pdev: PDEV object
849  * @macaddr: MAC address
850  *
851  * API to set HW MAC address form PDEV
852  *
853  * Caller need to acquire lock with wlan_pdev_obj_lock()
854  *
855  * Return: void
856  */
wlan_pdev_set_hw_macaddr(struct wlan_objmgr_pdev * pdev,uint8_t * macaddr)857 static inline void wlan_pdev_set_hw_macaddr(struct wlan_objmgr_pdev *pdev,
858 			uint8_t *macaddr)
859 {
860 	/* This API is invoked with lock acquired, do not add log prints */
861 	WLAN_ADDR_COPY(pdev->pdev_nif.macaddr, macaddr);
862 }
863 
864 /**
865  * wlan_pdev_get_ospriv() - get os priv pointer
866  * @pdev: PDEV object
867  *
868  * API to get OS private pointer from PDEV
869  *
870  * Return: ospriv - private pointer
871  */
wlan_pdev_get_ospriv(struct wlan_objmgr_pdev * pdev)872 static inline struct pdev_osif_priv *wlan_pdev_get_ospriv(
873 				struct wlan_objmgr_pdev *pdev)
874 {
875 	return pdev->pdev_nif.pdev_ospriv;
876 }
877 
878 /**
879  * wlan_pdev_reset_ospriv() - reset os priv pointer
880  * @pdev: PDEV object
881  *
882  * API to reset OS private pointer in PDEV
883  *
884  * Return: void
885  */
wlan_pdev_reset_ospriv(struct wlan_objmgr_pdev * pdev)886 static inline void wlan_pdev_reset_ospriv(struct wlan_objmgr_pdev *pdev)
887 {
888 	pdev->pdev_nif.pdev_ospriv = NULL;
889 }
890 
891 /**
892  * wlan_pdev_set_max_vdev_count() - set pdev max vdev count
893  * @pdev: PDEV object
894  * @max_vdev_count: Max vdev count
895  *
896  * API to set Max vdev count
897  *
898  * Return: void
899  */
wlan_pdev_set_max_vdev_count(struct wlan_objmgr_pdev * pdev,uint8_t max_vdev_count)900 static inline void wlan_pdev_set_max_vdev_count(struct wlan_objmgr_pdev *pdev,
901 					   uint8_t max_vdev_count)
902 {
903 	if (max_vdev_count > WLAN_UMAC_PDEV_MAX_VDEVS)
904 		QDF_BUG(0);
905 
906 	pdev->pdev_objmgr.max_vdev_count = max_vdev_count;
907 }
908 
909 /**
910  * wlan_pdev_get_max_vdev_count() - get pdev max vdev count
911  * @pdev: PDEV object
912  *
913  * API to set Max vdev count
914  *
915  * Return: @vdev count: Max vdev count
916  */
wlan_pdev_get_max_vdev_count(struct wlan_objmgr_pdev * pdev)917 static inline uint8_t wlan_pdev_get_max_vdev_count(
918 					struct wlan_objmgr_pdev *pdev)
919 {
920 	return pdev->pdev_objmgr.max_vdev_count;
921 }
922 
923 /**
924  * DOC: Examples to use PDEV ref count APIs
925  *
926  * In all the scenarios, the pair of API should be followed
927  * otherwise it lead to memory leak
928  *
929  *  scenario 1:
930  *
931  *     wlan_objmgr_pdev_obj_create()
932  *     ----
933  *     wlan_objmgr_pdev_obj_delete()
934  *
935  *  scenario 2:
936  *
937  *     wlan_objmgr_pdev_get_ref()
938  *     ----
939  *     the operations which are done on
940  *     pdev object
941  *     ----
942  *     wlan_objmgr_pdev_release_ref()
943  *
944  *  scenario 3:
945  *
946  *     wlan_objmgr_get_pdev_by_id[_no_state]()
947  *     ----
948  *     the operations which are done on
949  *     pdev object
950  *     ----
951  *     wlan_objmgr_pdev_release_ref()
952  *
953  *  scenario 4:
954  *
955  *     wlan_objmgr_get_pdev_by_macaddr[_no_state]()
956  *     ----
957  *     the operations which are done on
958  *     pdev object
959  *     ----
960  *     wlan_objmgr_pdev_release_ref()
961  */
962 
963 /**
964  * wlan_objmgr_pdev_get_ref() - increment ref count
965  * @pdev: PDEV object
966  * @id:   Object Manager ref debug id
967  *
968  * API to increment ref count of pdev
969  *
970  * Return: void
971  */
972 void wlan_objmgr_pdev_get_ref(struct wlan_objmgr_pdev *pdev,
973 					wlan_objmgr_ref_dbgid id);
974 
975 /**
976  * wlan_objmgr_pdev_try_get_ref() - increment ref count, if allowed
977  * @pdev: PDEV object
978  * @id:   Object Manager ref debug id
979  *
980  * API to increment ref count of pdev after checking valid object state
981  *
982  * Return: void
983  */
984 QDF_STATUS wlan_objmgr_pdev_try_get_ref(struct wlan_objmgr_pdev *pdev,
985 						wlan_objmgr_ref_dbgid id);
986 
987 /**
988  * wlan_objmgr_pdev_release_ref() - decrement ref count
989  * @pdev: PDEV object
990  * @id:   Object Manager ref debug id
991  *
992  * API to decrement ref count of pdev, if ref count is 1, it initiates the
993  * PDEV deletion
994  *
995  * Return: void
996  */
997 void wlan_objmgr_pdev_release_ref(struct wlan_objmgr_pdev *pdev,
998 						wlan_objmgr_ref_dbgid id);
999 
1000 /**
1001  * wlan_objmgr_pdev_get_pdev_id() - get pdev id
1002  * @pdev: PDEV object
1003  *
1004  * API to get pdev id from pdev object
1005  *
1006  * Return: @pdev id
1007  */
1008 static inline
wlan_objmgr_pdev_get_pdev_id(struct wlan_objmgr_pdev * pdev)1009 uint8_t wlan_objmgr_pdev_get_pdev_id(struct wlan_objmgr_pdev *pdev)
1010 {
1011 	return pdev->pdev_objmgr.wlan_pdev_id;
1012 }
1013 
1014 /**
1015  * wlan_pdev_set_tgt_if_handle(): API to set target if handle in pdev object
1016  * @pdev: Pdev pointer
1017  * @tgt_if_handle: target interface handle
1018  *
1019  * API to set target interface handle in pdev object
1020  *
1021  * Caller needs to acquire lock with wlan_pdev_obj_lock()
1022  *
1023  * Return: None
1024  */
1025 static inline
wlan_pdev_set_tgt_if_handle(struct wlan_objmgr_pdev * pdev,target_pdev_info_t * tgt_if_handle)1026 void wlan_pdev_set_tgt_if_handle(struct wlan_objmgr_pdev *pdev,
1027 				 target_pdev_info_t *tgt_if_handle)
1028 {
1029 	/* This API is invoked with lock acquired, do not add log prints */
1030 	if (!pdev)
1031 		return;
1032 
1033 	pdev->tgt_if_handle = tgt_if_handle;
1034 }
1035 
1036 /**
1037  * wlan_pdev_get_tgt_if_handle(): API to get target interface handle
1038  * @pdev: Pdev pointer
1039  *
1040  * API to get target interface handle from pdev object
1041  *
1042  * Return: target interface handle
1043  */
1044 static inline
wlan_pdev_get_tgt_if_handle(struct wlan_objmgr_pdev * pdev)1045 target_pdev_info_t *wlan_pdev_get_tgt_if_handle(struct wlan_objmgr_pdev *pdev)
1046 {
1047 	if (!pdev)
1048 		return NULL;
1049 
1050 	return pdev->tgt_if_handle;
1051 }
1052 
1053 /**
1054  * wlan_pdev_set_max_peer_count() - set max peer count
1055  * @pdev: PDEV object
1056  * @count: Max peer count
1057  *
1058  * API to set max peer count of PDEV
1059  *
1060  * Return: void
1061  */
wlan_pdev_set_max_peer_count(struct wlan_objmgr_pdev * pdev,uint16_t count)1062 static inline void wlan_pdev_set_max_peer_count(struct wlan_objmgr_pdev *pdev,
1063 						uint16_t count)
1064 {
1065 	pdev->pdev_objmgr.max_peer_count = count;
1066 }
1067 
1068 /**
1069  * wlan_pdev_get_max_peer_count() - get max peer count
1070  * @pdev: PDEV object
1071  *
1072  * API to get max peer count of PDEV
1073  *
1074  * Return: max peer count
1075  */
wlan_pdev_get_max_peer_count(struct wlan_objmgr_pdev * pdev)1076 static inline uint16_t wlan_pdev_get_max_peer_count(
1077 						struct wlan_objmgr_pdev *pdev)
1078 {
1079 	return pdev->pdev_objmgr.max_peer_count;
1080 }
1081 
1082 /**
1083  * wlan_pdev_set_max_beacon_count() - set max beacon count
1084  * @pdev: pdev object
1085  * @count: Max beacon count
1086  *
1087  * API to set max beacon count of pdev
1088  *
1089  * Return: void
1090  */
wlan_pdev_set_max_beacon_count(struct wlan_objmgr_pdev * pdev,uint64_t count)1091 static inline void wlan_pdev_set_max_beacon_count(
1092 					struct wlan_objmgr_pdev *pdev,
1093 					uint64_t count)
1094 {
1095 	pdev->pdev_objmgr.bcn.max_beacon_count = count;
1096 }
1097 
1098 /**
1099  * wlan_pdev_get_max_beacon_count() - get max beacon count
1100  * @pdev: pdev object
1101  *
1102  * API to get max beacon count of pdev
1103  *
1104  * Return: max beacon count
1105  */
wlan_pdev_get_max_beacon_count(struct wlan_objmgr_pdev * pdev)1106 static inline uint64_t wlan_pdev_get_max_beacon_count(
1107 					struct wlan_objmgr_pdev *pdev)
1108 {
1109 	return pdev->pdev_objmgr.bcn.max_beacon_count;
1110 }
1111 
1112 /**
1113  * wlan_pdev_incr_wlan_beacon_count() - incr beacon count for rx beacon frames
1114  * @pdev: pdev object
1115  *
1116  * API to incr beacon count of pdev
1117  *
1118  * Return: void
1119  */
wlan_pdev_incr_wlan_beacon_count(struct wlan_objmgr_pdev * pdev)1120 static inline void wlan_pdev_incr_wlan_beacon_count(
1121 					struct wlan_objmgr_pdev *pdev)
1122 {
1123 	pdev->pdev_objmgr.bcn.wlan_beacon_count++;
1124 }
1125 
1126 /**
1127  * wlan_pdev_set_wlan_beacon_count() - set wlan beacon count
1128  * @pdev: pdev object
1129  * @count: count to reset beacon count
1130  *
1131  * API to get wlan beacon count of pdev
1132  *
1133  */
wlan_pdev_set_wlan_beacon_count(struct wlan_objmgr_pdev * pdev,uint64_t count)1134 static inline void wlan_pdev_set_wlan_beacon_count(
1135 					struct wlan_objmgr_pdev *pdev,
1136 					uint64_t count)
1137 {
1138 	pdev->pdev_objmgr.bcn.wlan_beacon_count = count;
1139 }
1140 
1141 /**
1142  * wlan_pdev_get_wlan_beacon_count() - get wlan beacon count
1143  * @pdev: pdev object
1144  *
1145  * API to get wlan beacon count of pdev
1146  *
1147  * Return: beacon count
1148  */
wlan_pdev_get_wlan_beacon_count(struct wlan_objmgr_pdev * pdev)1149 static inline uint64_t wlan_pdev_get_wlan_beacon_count(
1150 					struct wlan_objmgr_pdev *pdev)
1151 {
1152 	return pdev->pdev_objmgr.bcn.wlan_beacon_count;
1153 }
1154 
1155 /**
1156  * wlan_pdev_set_max_beacon_limit() - set max beacon limit
1157  * @pdev: pdev object
1158  * @limit: limit for thresholding
1159  *
1160  * API to set wlan beacon limit of pdev
1161  *
1162  */
wlan_pdev_set_max_beacon_limit(struct wlan_objmgr_pdev * pdev,uint64_t limit)1163 static inline void wlan_pdev_set_max_beacon_limit(
1164 					struct wlan_objmgr_pdev *pdev,
1165 					uint64_t limit)
1166 {
1167 	pdev->pdev_objmgr.bcn.max_beacon_limit = limit;
1168 }
1169 
1170 /**
1171  * wlan_pdev_get_max_beacon_limit() - get max beacon limit
1172  * @pdev: pdev object
1173  *
1174  * API to get wlan beacon limit of pdev
1175  *
1176  * Return: beacon limit
1177  */
wlan_pdev_get_max_beacon_limit(struct wlan_objmgr_pdev * pdev)1178 static inline uint64_t wlan_pdev_get_max_beacon_limit(
1179 					struct wlan_objmgr_pdev *pdev)
1180 {
1181 	return pdev->pdev_objmgr.bcn.max_beacon_limit;
1182 }
1183 
1184 /**
1185  * wlan_pdev_incr_dropped_beacon_count() - increment dropped bcn cnt
1186  * @pdev: pdev object
1187  *
1188  * API to increment dropped beacon count
1189  *
1190  * Return: beacon limit
1191  */
wlan_pdev_incr_dropped_beacon_count(struct wlan_objmgr_pdev * pdev)1192 static inline void wlan_pdev_incr_dropped_beacon_count(
1193 					struct wlan_objmgr_pdev *pdev)
1194 {
1195 	pdev->pdev_objmgr.bcn.dropped_beacon++;
1196 }
1197 
1198 /**
1199  * wlan_pdev_set_dropped_beacon_count() - reset dropped beacon count
1200  * @pdev: pdev object
1201  * @count: count value
1202  *
1203  * API to set beacon drop count
1204  *
1205  */
wlan_pdev_set_dropped_beacon_count(struct wlan_objmgr_pdev * pdev,uint64_t count)1206 static inline void wlan_pdev_set_dropped_beacon_count(
1207 					struct wlan_objmgr_pdev *pdev,
1208 					uint64_t count)
1209 {
1210 	pdev->pdev_objmgr.bcn.dropped_beacon = count;
1211 }
1212 
1213 /**
1214  * wlan_pdev_get_dropped_beacon_count() - get drop beacon count
1215  * @pdev: pdev object
1216  *
1217  * API to get dropped beacon count
1218  *
1219  * Return: beacon limit
1220  */
wlan_pdev_get_dropped_beacon_count(struct wlan_objmgr_pdev * pdev)1221 static inline uint64_t wlan_pdev_get_dropped_beacon_count(
1222 					struct wlan_objmgr_pdev *pdev)
1223 {
1224 	return pdev->pdev_objmgr.bcn.dropped_beacon;
1225 }
1226 
1227 /**
1228  * wlan_pdev_set_max_monitor_vdev_count() - set max monitor vdev count
1229  * @pdev: PDEV object
1230  * @count: Max monitor vdev count
1231  *
1232  * API to set max monitor vdev count of PDEV
1233  *
1234  * Return: void
1235  */
wlan_pdev_set_max_monitor_vdev_count(struct wlan_objmgr_pdev * pdev,uint16_t count)1236 static inline void wlan_pdev_set_max_monitor_vdev_count(
1237 		struct wlan_objmgr_pdev *pdev,
1238 		uint16_t count)
1239 {
1240 	pdev->pdev_objmgr.max_monitor_vdev_count = count;
1241 }
1242 
1243 /**
1244  * wlan_pdev_get_max_monitor_vdev_count() - get max monitor vdev count
1245  * @pdev: PDEV object
1246  *
1247  * API to get max monitor vdev count of PDEV
1248  *
1249  * Return: max monitor vdev count
1250  */
wlan_pdev_get_max_monitor_vdev_count(struct wlan_objmgr_pdev * pdev)1251 static inline uint16_t wlan_pdev_get_max_monitor_vdev_count(
1252 		struct wlan_objmgr_pdev *pdev)
1253 {
1254 	return pdev->pdev_objmgr.max_monitor_vdev_count;
1255 }
1256 
1257 /**
1258  * wlan_pdev_set_max_bridge_vdev_count() - set max bridge vdev count
1259  * @pdev: PDEV object
1260  * @count: Max bridge vdev count
1261  *
1262  * API to set max bridge vdev count of PDEV
1263  *
1264  * Return: void
1265  */
wlan_pdev_set_max_bridge_vdev_count(struct wlan_objmgr_pdev * pdev,uint16_t count)1266 static inline void wlan_pdev_set_max_bridge_vdev_count(
1267 		struct wlan_objmgr_pdev *pdev,
1268 		uint16_t count)
1269 {
1270 	pdev->pdev_objmgr.max_bridge_vdev_count = count;
1271 }
1272 
1273 /**
1274  * wlan_pdev_get_max_bridge_vdev_count() - get max bridge vdev count
1275  * @pdev: PDEV object
1276  *
1277  * API to get max bridge vdev count of PDEV
1278  *
1279  * Return: max bridge vdev count
1280  */
wlan_pdev_get_max_bridge_vdev_count(struct wlan_objmgr_pdev * pdev)1281 static inline uint16_t wlan_pdev_get_max_bridge_vdev_count(
1282 		struct wlan_objmgr_pdev *pdev)
1283 {
1284 	return pdev->pdev_objmgr.max_bridge_vdev_count;
1285 }
1286 
1287 /**
1288  * wlan_pdev_get_peer_count() - get pdev peer count
1289  * @pdev: PDEV object
1290  *
1291  * API to get peer count from PDEV
1292  *
1293  * Return: peer_count - pdev's peer count
1294  */
wlan_pdev_get_peer_count(struct wlan_objmgr_pdev * pdev)1295 static inline uint16_t wlan_pdev_get_peer_count(struct wlan_objmgr_pdev *pdev)
1296 {
1297 	return pdev->pdev_objmgr.wlan_peer_count;
1298 }
1299 
1300 /**
1301  * wlan_pdev_get_temp_peer_count() - get pdev temporary peer count
1302  * @pdev: PDEV object
1303  *
1304  * API to get temporary peer count from PDEV
1305  *
1306  * Return: temp_peer_count - pdev's temporary peer count
1307  */
wlan_pdev_get_temp_peer_count(struct wlan_objmgr_pdev * pdev)1308 static inline uint16_t wlan_pdev_get_temp_peer_count(struct wlan_objmgr_pdev *pdev)
1309 {
1310 	return pdev->pdev_objmgr.temp_peer_count;
1311 }
1312 
1313 
1314 /**
1315  * wlan_pdev_incr_peer_count() - increment pdev peer count
1316  * @pdev: PDEV object
1317  *
1318  * API to increment peer count of PDEV by 1
1319  *
1320  * Return: void
1321  */
wlan_pdev_incr_peer_count(struct wlan_objmgr_pdev * pdev)1322 static inline void wlan_pdev_incr_peer_count(struct wlan_objmgr_pdev *pdev)
1323 {
1324 	pdev->pdev_objmgr.wlan_peer_count++;
1325 }
1326 
1327 /**
1328  * wlan_pdev_decr_peer_count() - decrement pdev peer count
1329  * @pdev: PDEV object
1330  *
1331  * API to decrement peer count of PDEV by 1
1332  *
1333  * Return: void
1334  */
wlan_pdev_decr_peer_count(struct wlan_objmgr_pdev * pdev)1335 static inline void wlan_pdev_decr_peer_count(struct wlan_objmgr_pdev *pdev)
1336 {
1337 	pdev->pdev_objmgr.wlan_peer_count--;
1338 }
1339 
1340 /**
1341  * wlan_pdev_incr_temp_peer_count() - increment temporary pdev peer count
1342  * @pdev: PDEV object
1343  *
1344  * API to increment temporary  peer count of PDEV by 1
1345  *
1346  * Return: void
1347  */
wlan_pdev_incr_temp_peer_count(struct wlan_objmgr_pdev * pdev)1348 static inline void wlan_pdev_incr_temp_peer_count(struct wlan_objmgr_pdev *pdev)
1349 {
1350 	pdev->pdev_objmgr.temp_peer_count++;
1351 }
1352 
1353 /**
1354  * wlan_pdev_decr_temp_peer_count() - decrement pdev temporary peer count
1355  * @pdev: PDEV object
1356  *
1357  * API to decrement temporary peer count of PDEV by 1
1358  *
1359  * Return: void
1360  */
wlan_pdev_decr_temp_peer_count(struct wlan_objmgr_pdev * pdev)1361 static inline void wlan_pdev_decr_temp_peer_count(struct wlan_objmgr_pdev *pdev)
1362 {
1363 	pdev->pdev_objmgr.temp_peer_count--;
1364 }
1365 
1366 /**
1367  * wlan_pdev_get_vdev_count() - get PDEV vdev count
1368  * @pdev: PDEV object
1369  *
1370  * API to get vdev count from PDEV
1371  *
1372  * Return: vdev_count - pdev's vdev count
1373  */
wlan_pdev_get_vdev_count(struct wlan_objmgr_pdev * pdev)1374 static inline uint8_t wlan_pdev_get_vdev_count(struct wlan_objmgr_pdev *pdev)
1375 {
1376 	return pdev->pdev_objmgr.wlan_vdev_count;
1377 }
1378 
1379 #ifdef WLAN_FEATURE_11BE_MLO
1380 /**
1381  * wlan_pdev_init_mlo_vdev_count() - Initialize PDEV MLO vdev count
1382  * @pdev: PDEV object
1383  *
1384  * API to initialize MLO vdev count from PDEV
1385  *
1386  * Return: void
1387  */
1388 static inline
wlan_pdev_init_mlo_vdev_count(struct wlan_objmgr_pdev * pdev)1389 void wlan_pdev_init_mlo_vdev_count(struct wlan_objmgr_pdev *pdev)
1390 {
1391 	qdf_atomic_init(&pdev->pdev_objmgr.wlan_mlo_vdev_count);
1392 }
1393 
1394 /**
1395  * wlan_pdev_get_mlo_vdev_count() - get PDEV MLO vdev count
1396  * @pdev: PDEV object
1397  *
1398  * API to get MLO vdev count from PDEV
1399  *
1400  * Return: MLO vdev_count - pdev's MLO vdev count
1401  */
1402 static inline
wlan_pdev_get_mlo_vdev_count(struct wlan_objmgr_pdev * pdev)1403 uint32_t wlan_pdev_get_mlo_vdev_count(struct wlan_objmgr_pdev *pdev)
1404 {
1405 	return qdf_atomic_read(&pdev->pdev_objmgr.wlan_mlo_vdev_count);
1406 }
1407 
1408 /**
1409  * wlan_pdev_inc_mlo_vdev_count() - Increment PDEV MLO vdev count
1410  * @pdev: PDEV object
1411  *
1412  * API to increment MLO vdev count from PDEV
1413  *
1414  * Return: void
1415  */
1416 static inline
wlan_pdev_inc_mlo_vdev_count(struct wlan_objmgr_pdev * pdev)1417 void wlan_pdev_inc_mlo_vdev_count(struct wlan_objmgr_pdev *pdev)
1418 {
1419 	qdf_atomic_inc(&pdev->pdev_objmgr.wlan_mlo_vdev_count);
1420 }
1421 
1422 /**
1423  * wlan_pdev_dec_mlo_vdev_count() - Decrement PDEV MLO vdev count
1424  * @pdev: PDEV object
1425  *
1426  * API to decrement MLO vdev count from PDEV
1427  *
1428  * Return: void
1429  */
1430 static inline
wlan_pdev_dec_mlo_vdev_count(struct wlan_objmgr_pdev * pdev)1431 void wlan_pdev_dec_mlo_vdev_count(struct wlan_objmgr_pdev *pdev)
1432 {
1433 	qdf_assert_always
1434 		(qdf_atomic_read(&pdev->pdev_objmgr.wlan_mlo_vdev_count));
1435 
1436 	qdf_atomic_dec(&pdev->pdev_objmgr.wlan_mlo_vdev_count);
1437 }
1438 
1439 /**
1440  * wlan_pdev_init_mlo_bridge_vdev_count() - Initialize PDEV MLO bridge
1441  *					    vdev count
1442  * @pdev: PDEV object
1443  *
1444  * API to initialize MLO bridge vdev count from PDEV
1445  *
1446  * Return: void
1447  */
1448 static inline
wlan_pdev_init_mlo_bridge_vdev_count(struct wlan_objmgr_pdev * pdev)1449 void wlan_pdev_init_mlo_bridge_vdev_count(struct wlan_objmgr_pdev *pdev)
1450 {
1451 	qdf_atomic_init(&pdev->pdev_objmgr.wlan_mlo_bridge_vdev_count);
1452 }
1453 
1454 /**
1455  * wlan_pdev_get_mlo_bridge_vdev_count() - get PDEV MLO bridge vdev count
1456  * @pdev: PDEV object
1457  *
1458  * API to get MLO bridge vdev count from PDEV
1459  *
1460  * Return: MLO vdev_count - pdev's MLO bridge vdev count
1461  */
1462 static inline
wlan_pdev_get_mlo_bridge_vdev_count(struct wlan_objmgr_pdev * pdev)1463 uint32_t wlan_pdev_get_mlo_bridge_vdev_count(struct wlan_objmgr_pdev *pdev)
1464 {
1465 	return qdf_atomic_read(&pdev->pdev_objmgr.wlan_mlo_bridge_vdev_count);
1466 }
1467 
1468 /**
1469  * wlan_pdev_inc_mlo_bridge_vdev_count() - Increment PDEV MLO bridge vdev count
1470  * @pdev: PDEV object
1471  *
1472  * API to increment MLO bridge vdev count from PDEV
1473  *
1474  * Return: void
1475  */
1476 static inline
wlan_pdev_inc_mlo_bridge_vdev_count(struct wlan_objmgr_pdev * pdev)1477 void wlan_pdev_inc_mlo_bridge_vdev_count(struct wlan_objmgr_pdev *pdev)
1478 {
1479 	qdf_atomic_inc(&pdev->pdev_objmgr.wlan_mlo_bridge_vdev_count);
1480 }
1481 
1482 /**
1483  * wlan_pdev_dec_mlo_bridge_vdev_count() - Decrement PDEV MLO bridge vdev count
1484  * @pdev: PDEV object
1485  *
1486  * API to decrement MLO bridge vdev count from PDEV
1487  *
1488  * Return: void
1489  */
1490 static inline
wlan_pdev_dec_mlo_bridge_vdev_count(struct wlan_objmgr_pdev * pdev)1491 void wlan_pdev_dec_mlo_bridge_vdev_count(struct wlan_objmgr_pdev *pdev)
1492 {
1493 	qdf_assert_always
1494 	(qdf_atomic_read(&pdev->pdev_objmgr.wlan_mlo_bridge_vdev_count));
1495 
1496 	qdf_atomic_dec(&pdev->pdev_objmgr.wlan_mlo_bridge_vdev_count);
1497 }
1498 #else
1499 static inline
wlan_pdev_init_mlo_vdev_count(struct wlan_objmgr_pdev * pdev)1500 void wlan_pdev_init_mlo_vdev_count(struct wlan_objmgr_pdev *pdev)
1501 {
1502 }
1503 
1504 static inline
wlan_pdev_get_mlo_vdev_count(struct wlan_objmgr_pdev * pdev)1505 uint32_t wlan_pdev_get_mlo_vdev_count(struct wlan_objmgr_pdev *pdev)
1506 {
1507 	return 0;
1508 }
1509 
1510 static inline
wlan_pdev_inc_mlo_vdev_count(struct wlan_objmgr_pdev * pdev)1511 void wlan_pdev_inc_mlo_vdev_count(struct wlan_objmgr_pdev *pdev)
1512 {
1513 }
1514 
1515 static inline
wlan_pdev_dec_mlo_vdev_count(struct wlan_objmgr_pdev * pdev)1516 void wlan_pdev_dec_mlo_vdev_count(struct wlan_objmgr_pdev *pdev)
1517 {
1518 }
1519 
1520 static inline
wlan_pdev_init_mlo_bridge_vdev_count(struct wlan_objmgr_pdev * pdev)1521 void wlan_pdev_init_mlo_bridge_vdev_count(struct wlan_objmgr_pdev *pdev)
1522 {
1523 }
1524 
1525 static inline
wlan_pdev_get_mlo_bridge_vdev_count(struct wlan_objmgr_pdev * pdev)1526 uint32_t wlan_pdev_get_mlo_bridge_vdev_count(struct wlan_objmgr_pdev *pdev)
1527 {
1528 	return 0;
1529 }
1530 
1531 static inline
wlan_pdev_inc_mlo_bridge_vdev_count(struct wlan_objmgr_pdev * pdev)1532 void wlan_pdev_inc_mlo_bridge_vdev_count(struct wlan_objmgr_pdev *pdev)
1533 {
1534 }
1535 
1536 static inline
wlan_pdev_dec_mlo_bridge_vdev_count(struct wlan_objmgr_pdev * pdev)1537 void wlan_pdev_dec_mlo_bridge_vdev_count(struct wlan_objmgr_pdev *pdev)
1538 {
1539 }
1540 #endif /* WLAN_FEATURE_11BE_MLO */
1541 
1542 /**
1543  * wlan_print_pdev_info() - print pdev members
1544  * @pdev: pdev object pointer
1545  *
1546  * Return: void
1547  */
1548 #ifdef WLAN_OBJMGR_DEBUG
1549 void wlan_print_pdev_info(struct wlan_objmgr_pdev *pdev);
1550 #else
wlan_print_pdev_info(struct wlan_objmgr_pdev * pdev)1551 static inline void wlan_print_pdev_info(struct wlan_objmgr_pdev *pdev) {}
1552 #endif
1553 
1554 #endif /* _WLAN_OBJMGR_PDEV_H_*/
1555