xref: /wlan-dirver/qca-wifi-host-cmn/umac/cmn_services/obj_mgr/inc/wlan_objmgr_pdev_obj.h (revision 2f4b444fb7e689b83a4ab0e7b3b38f0bf4def8e0)
1 /*
2  * Copyright (c) 2016-2021 The Linux Foundation. All rights reserved.
3  *
4  * Permission to use, copy, modify, and/or distribute this software for any
5  * purpose with or without fee is hereby granted, provided that the above
6  * copyright notice and this permission notice appear in all copies.
7  *
8  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15  */
16 
17 /**
18  * DOC: Define the pdev data structure of UMAC
19  * Public APIs to perform operations on Global objects
20  */
21 
22 #ifndef _WLAN_OBJMGR_PDEV_OBJ_H_
23 #define _WLAN_OBJMGR_PDEV_OBJ_H_
24 
25 #include <wlan_objmgr_cmn.h>
26 #include "wlan_objmgr_psoc_obj.h"
27 #include <target_if_pub.h>
28 
29 /* STATUS: scanning */
30 #define WLAN_PDEV_F_SCAN                    0x00000001
31 /* STATUS: use short slot time*/
32 #define WLAN_PDEV_F_SHSLOT                  0x00000002
33   /* STATUS: channel switch event pending after DFS RADAR */
34 #define WLAN_PDEV_F_DFS_CHANSWITCH_PENDING  0x00000004
35   /* TX Power: fixed rate */
36 #define WLAN_PDEV_F_TXPOW_FIXED             0x00000008
37   /* STATUS: use short preamble */
38 #define WLAN_PDEV_F_SHPREAMBLE              0x00000010
39   /* CONF: do alignment pad */
40 #define WLAN_PDEV_F_DATAPAD                 0x00000020
41   /* STATUS: protection enabled */
42 #define WLAN_PDEV_F_USEPROT                 0x00000040
43   /* STATUS: use barker preamble*/
44 #define WLAN_PDEV_F_USEBARKER               0x00000080
45   /* CONF: DISABLE 2040 coexistence */
46 #define WLAN_PDEV_F_COEXT_DISABLE           0x00000100
47   /* STATE: scan pending */
48 #define WLAN_PDEV_F_SCAN_PENDING            0x00000200
49   /* CONF: send regclassids in country ie */
50 #define WLAN_PDEV_F_REGCLASS                0x00000400
51   /* CONF: block the use of DFS channels */
52 #define WLAN_PDEV_F_BLKDFSCHAN              0x00000800
53   /* STATUS: 11D in used */
54 #define WLAN_PDEV_F_DOT11D                  0x00001000
55   /* STATUS: 11D channel-switch detected */
56 #define WLAN_PDEV_F_RADAR                   0x00002000
57   /* CONF: A-MPDU supported */
58 #define WLAN_PDEV_F_AMPDU                   0x00004000
59   /* CONF: A-MSDU supported */
60 #define WLAN_PDEV_F_AMSDU                   0x00008000
61   /* CONF: HT traffic protected */
62 #define WLAN_PDEV_F_HTPROT                  0x00010000
63   /* CONF: Reset once */
64 #define WLAN_PDEV_F_RESET                   0x00020000
65   /* CONF: ignore 11d beacon */
66 #define WLAN_PDEV_F_IGNORE_11D_BEACON       0x00040000
67   /* HT CAP IE present */
68 #define WLAN_PDEV_F_HTVIE                   0x00080000
69  /* radio in middle of CSA */
70 #define WLAN_PDEV_F_CSA_WAIT                0x00100000
71  /* wnm support flag */
72 #define WLAN_PDEV_F_WNM                     0x00200000
73 #define WLAN_PDEV_F_2G_CSA                  0x00400000
74   /* enhanced independent repeater  */
75 #define WLAN_PDEV_F_ENH_REP_IND             0x00800000
76  /* Disable Tx AMSDU for station vap */
77 #define WLAN_PDEV_F_STA_AMPDU_DIS           0x01000000
78 /* do not send probe request in passive channel */
79 #define WLAN_PDEV_F_STRICT_PSCAN_EN         0x02000000
80   /* dupie (ANA,pre ANA ) */
81 /*#define WLAN_PDEV_F_DUPIE                 0x00200000*/
82 /* Chan concurrency enabled */
83 #define WLAN_PDEV_F_CHAN_CONCURRENCY        0x08000000
84 /* Multivdev restart enabled */
85 #define WLAN_PDEV_F_MULTIVDEV_RESTART       0x10000000
86 /* MBSS IE enable */
87 #define WLAN_PDEV_F_MBSS_IE_ENABLE          0x20000000
88 /* VDEV Peer delete all */
89 #define WLAN_PDEV_F_DELETE_ALL_PEER         0x40000000
90 /* PDEV BEacon Protection */
91 #define WLAN_PDEV_F_BEACON_PROTECTION       0x80000000
92 
93 /* PDEV ext flags */
94 /* CFR support enabled */
95 #define WLAN_PDEV_FEXT_CFR_EN               0x00000001
96 /* EMA AP support enable */
97 #define WLAN_PDEV_FEXT_EMA_AP_ENABLE        0x00000002
98 /* scan radio support */
99 #define WLAN_PDEV_FEXT_SCAN_RADIO           0x00000004
100 /* DFS disable, valid only for scan radio supported pdevs */
101 #define WLAN_PDEV_FEXT_SCAN_RADIO_DFS_DIS   0x00000008
102 /* normal Spectral scan support disable */
103 #define WLAN_PDEV_FEXT_NORMAL_SPECTRAL_SCAN_DIS          0x00000010
104 /* agile Spectral scan support disable for 20/40/80 MHz */
105 #define WLAN_PDEV_FEXT_AGILE_SPECTRAL_SCAN_DIS           0x00000020
106 /* agile Spectral scan support disable for 160 MHz */
107 #define WLAN_PDEV_FEXT_AGILE_SPECTRAL_SCAN_160_DIS       0x00000040
108 /* agile Spectral scan support disable for 80+80 MHz */
109 #define WLAN_PDEV_FEXT_AGILE_SPECTRAL_SCAN_80P80_DIS     0x00000080
110 
111 /* PDEV op flags */
112    /* Enable htrate for wep and tkip */
113 #define WLAN_PDEV_OP_WEP_TKIP_HTRATE    0x00000001
114   /* non HT AP found flag */
115 #define WLAN_PDEV_OP_NON_HT_AP          0x00000002
116   /* block the use of DFS channels flag */
117 #define WLAN_PDEV_OP_BLK_DFS_CHAN       0x00000004
118   /* 11.h flag */
119 #define WLAN_PDEV_OP_DOTH               0x00000008
120   /* Off-channel support enabled */
121 #define WLAN_PDEV_OP_OFFCHAN            0x00000010
122 #define WLAN_PDEV_OP_HT20ADHOC          0x00000020
123 #define WLAN_PDEV_OP_HT40ADHOC          0x00000040
124 #define WLAN_PDEV_OP_HTADHOC_AGGR       0x00000080
125    /* disallow CC change when assoc completes */
126 #define WLAN_PDEV_OP_DISALLOW_AUTO_CC   0x00000100
127    /* Is P2P Enabled? */
128 #define WLAN_PDEV_OP_P2P                0x00000200
129    /* disallowed  */
130 #define WLAN_PDEV_OP_IGNORE_DYNHALT     0x00000400
131    /* overwrite probe response IE with beacon IE */
132 #define WLAN_PDEV_OP_OVERRIDE_PROBERESP 0x00000800
133 #define WLAN_PDEV_OP_DROPSTA_QUERY      0x00001000
134 #define WLAN_PDEV_OP_BLK_REPORT_FLOOD   0x00002000
135    /* Offchan scan */
136 #define WLAN_PDEV_OP_OFFCHAN_SCAN       0x00004000
137    /*Consider OBSS non-erp to change to long slot*/
138 #define WLAN_PDEV_OP_OBSS_LONGSLOT      0x00008000
139    /* enable/disable min rssi cli block */
140 #define WLAN_PDEV_OP_MIN_RSSI_ENABLE    0x00010000
141    /* PDEV VDEV restart is in progress */
142 #define WLAN_PDEV_OP_RESTART_INPROGRESS 0x00020000
143    /* PDEV MBSSID VDEV restart trigger */
144 #define WLAN_PDEV_OP_MBSSID_RESTART     0x00040000
145    /* RADAR DETECT Defer */
146 #define WLAN_PDEV_OP_RADAR_DETECT_DEFER 0x00080000
147 
148 
149 struct osif_pdev_priv;
150 
151 /**
152  * struct wlan_objmgr_pdev_nif  - pdev object nif structure
153  * @pdev_fw_caps:       radio specific FW capabilities
154  * @pdev_feature_caps:  radio specific feature capabilities
155  * @pdev_feature_ext_caps:  radio specific feature capabilities extended
156  * @pdev_ospriv:        OS specific pointer
157  * @macaddr[]:          MAC address
158  * @notified_ap_vdev:   ap vdev
159  */
160 struct wlan_objmgr_pdev_nif {
161 	uint32_t pdev_fw_caps;
162 	uint32_t pdev_feature_caps;
163 	uint32_t pdev_feature_ext_caps;
164 	struct pdev_osif_priv *pdev_ospriv;
165 	uint8_t macaddr[QDF_MAC_ADDR_SIZE];
166 	uint8_t notified_ap_vdev;
167 };
168 
169 /**
170  * struct wlan_objmgr_pdev_mlme - pdev object mlme structure
171  * @pdev_op_flags:    PDEV operation flags, can be used to know the
172  *                    operation status (deletion progress, etc)
173  */
174 struct wlan_objmgr_pdev_mlme {
175 	uint32_t pdev_op_flags;
176 };
177 
178 /**
179  * struct wlan_objmgr_pdev_objmgr - pdev object object manager structure
180  * @wlan_pdev_id:      PDEV id
181  * @wlan_vdev_count:   VDEVs count
182  * @max_vdev_count:    Max no. of VDEVs supported by this PDEV
183  * @print_cnt:         Count to throttle Logical delete prints
184  * @wlan_vdev_list:    List maintains the VDEVs created on this PDEV
185  * @wlan_peer_count:   Peer count
186  * @max_peer_count:    Max Peer count
187  * @temp_peer_count:   Temporary peer count
188  * @max_monitor_vdev_count: Max monitor vdev count
189  * @wlan_psoc:         back pointer to PSOC, its attached to
190  * @ref_cnt:           Ref count
191  * @ref_id_dbg:        Array to track Ref count
192  */
193 struct wlan_objmgr_pdev_objmgr {
194 	uint8_t wlan_pdev_id;
195 	uint8_t wlan_vdev_count;
196 	uint8_t max_vdev_count;
197 	uint8_t print_cnt;
198 	qdf_list_t wlan_vdev_list;
199 	uint16_t wlan_peer_count;
200 	uint16_t max_peer_count;
201 	uint16_t temp_peer_count;
202 	uint8_t max_monitor_vdev_count;
203 	struct wlan_objmgr_psoc *wlan_psoc;
204 	qdf_atomic_t ref_cnt;
205 	qdf_atomic_t ref_id_dbg[WLAN_REF_ID_MAX];
206 };
207 
208 /**
209  * struct wlan_objmgr_pdev - PDEV common object
210  * @current_chan_list: Active/current Channel list of the radio
211  * @pdev_nif:          pdev nif structure
212  * @pdev_objmgr:       pdev object manager structure
213  * @pdev_mlme:         pdev MLME structure
214  * @pdev_comp_priv_obj[]:   component's private object array
215  * @obj_status[]:      object status of each component object
216  * @obj_state:         object state
217  * @tgt_if_handle:     Target interface handle
218  * @pdev_lock:         lock to protect object
219 */
220 struct wlan_objmgr_pdev {
221 	struct wlan_chan_list *current_chan_list;
222 	struct wlan_objmgr_pdev_nif  pdev_nif;
223 	struct wlan_objmgr_pdev_objmgr pdev_objmgr;
224 	struct wlan_objmgr_pdev_mlme   pdev_mlme;
225 	void *pdev_comp_priv_obj[WLAN_UMAC_MAX_COMPONENTS];
226 	QDF_STATUS obj_status[WLAN_UMAC_MAX_COMPONENTS];
227 	WLAN_OBJ_STATE obj_state;
228 	target_pdev_info_t *tgt_if_handle;
229 	qdf_spinlock_t pdev_lock;
230 };
231 
232 /**
233  ** APIs to Create/Delete Global object APIs
234  */
235 /**
236  * wlan_objmgr_pdev_obj_create() - pdev create
237  * @psoc: PSOC object
238  * @scn: os private object
239  *
240  * Creates PDEV object, intializes with default values
241  * Invokes the registered notifiers to create component object
242  *
243  * Return: Handle to struct wlan_objmgr_psoc on successful creation,
244  *         NULL on Failure (on Mem alloc failure and Component objects
245  *         Failure)
246  */
247 struct wlan_objmgr_pdev *wlan_objmgr_pdev_obj_create(
248 	struct wlan_objmgr_psoc *psoc, struct pdev_osif_priv *osif_priv);
249 
250 /**
251  * wlan_objmgr_pdev_obj_delete() - pdev delete
252  * @psoc: PDEV object
253  *
254  * Logically deletes PDEV object,
255  * Once all the references are released, object manager invokes the registered
256  * notifiers to destroy component objects
257  *
258  * Return: SUCCESS/FAILURE
259  */
260 QDF_STATUS wlan_objmgr_pdev_obj_delete(struct wlan_objmgr_pdev *pdev);
261 
262 /**
263  ** APIs to attach/detach component objects
264  */
265 /**
266  * wlan_objmgr_pdev_component_obj_attach() - pdev comp object attach
267  * @psoc: PDEV object
268  * @id: Component id
269  * @comp_priv_obj: component's private object pointer
270  * @status: Component's private object creation status
271  *
272  * API to be used for attaching component object with PDEV common object
273  *
274  * Return: SUCCESS on successful storing of component's object in common object
275  *         On FAILURE (appropriate failure codes are returned)
276  */
277 QDF_STATUS wlan_objmgr_pdev_component_obj_attach(
278 		struct wlan_objmgr_pdev *pdev,
279 		enum wlan_umac_comp_id id,
280 		void *comp_priv_obj,
281 		QDF_STATUS status);
282 
283 /**
284  * wlan_objmgr_pdev_component_obj_detach() - pdev comp object detach
285  * @psoc: PDEV object
286  * @id: Component id
287  * @comp_priv_obj: component's private object pointer
288  *
289  * API to be used for detaching component object with PDEV common object
290  *
291  * Return: SUCCESS on successful removal of component's object from common
292  *         object
293  *         On FAILURE (appropriate failure codes are returned)
294  */
295 QDF_STATUS wlan_objmgr_pdev_component_obj_detach(
296 		struct wlan_objmgr_pdev *pdev,
297 		enum wlan_umac_comp_id id,
298 		void *comp_priv_obj);
299 
300 /**
301  ** APIs to operations on pdev objects
302  */
303 
304 typedef void (*wlan_objmgr_pdev_op_handler)(struct wlan_objmgr_pdev *pdev,
305 					void *object,
306 					void *arg);
307 
308 /**
309  * wlan_objmgr_pdev_iterate_obj_list() - operate on all objects of pdev
310  * @pdev: PDEV object
311  * @obj_type: VDEV_OP/PEER_OP
312  * @handler: the handler will be called for each object of requested type
313  *           the handler should be implemented to perform required operation
314  * @arg: agruments passed by caller
315  * @lock_free_op: its obsolete
316  * @dbg_id: id of the caller
317  *
318  * API to be used for performing the operations on all VDEV/PEER objects
319  * of pdev
320  *
321  * Return: SUCCESS/FAILURE
322  */
323 QDF_STATUS wlan_objmgr_pdev_iterate_obj_list(
324 		struct wlan_objmgr_pdev *pdev,
325 		enum wlan_objmgr_obj_type obj_type,
326 		wlan_objmgr_pdev_op_handler handler,
327 		void *arg, uint8_t lock_free_op,
328 		wlan_objmgr_ref_dbgid dbg_id);
329 
330 /**
331  * wlan_objmgr_trigger_pdev_comp_priv_object_creation() - create
332  * comp object of pdev
333  * @pdev: PDEV object
334  * @id: Component id
335  *
336  * API to create component private object in run time, this would be
337  * used for features which gets enabled in run time
338  *
339  * Return: SUCCESS on successful creation
340  *         On FAILURE (appropriate failure codes are returned)
341  */
342 QDF_STATUS wlan_objmgr_trigger_pdev_comp_priv_object_creation(
343 		struct wlan_objmgr_pdev *pdev,
344 		enum wlan_umac_comp_id id);
345 
346 /**
347  * wlan_objmgr_trigger_pdev_comp_priv_object_deletion() - destroy
348  * comp object of pdev
349  * @pdev: PDEV object
350  * @id: Component id
351  *
352  * API to destroy component private object in run time, this would
353  * be used for features which gets disabled in run time
354  *
355  * Return: SUCCESS on successful deletion
356  *         On FAILURE (appropriate failure codes are returned)
357  */
358 QDF_STATUS wlan_objmgr_trigger_pdev_comp_priv_object_deletion(
359 		struct wlan_objmgr_pdev *pdev,
360 		enum wlan_umac_comp_id id);
361 
362 /**
363  * wlan_objmgr_get_vdev_by_id_from_pdev() - find vdev using id from pdev
364  * @pdev: PDEV object
365  * @vdev_id: vdev id
366  * @dbg_id: id of the caller
367  *
368  * API to find vdev object pointer by vdev id from pdev's vdev list
369  *
370  * This API increments the ref count of the vdev object internally, the
371  * caller has to invoke the wlan_objmgr_vdev_release_ref() to decrement
372  * ref count
373  *
374  * Return: vdev pointer
375  *         NULL on FAILURE
376  */
377 #ifdef WLAN_OBJMGR_REF_ID_TRACE
378 struct wlan_objmgr_vdev *wlan_objmgr_get_vdev_by_id_from_pdev_debug(
379 			struct wlan_objmgr_pdev *pdev, uint8_t vdev_id,
380 			wlan_objmgr_ref_dbgid dbg_id,
381 			const char *func, int line);
382 
383 #define wlan_objmgr_get_vdev_by_id_from_pdev(pdev, vdev_id, dbgid) \
384 		wlan_objmgr_get_vdev_by_id_from_pdev_debug(pdev, \
385 		vdev_id, dbgid, __func__, __LINE__)
386 #else
387 struct wlan_objmgr_vdev *wlan_objmgr_get_vdev_by_id_from_pdev(
388 			struct wlan_objmgr_pdev *pdev, uint8_t vdev_id,
389 			wlan_objmgr_ref_dbgid dbg_id);
390 #endif
391 
392 /**
393  * wlan_objmgr_get_vdev_by_id_from_pdev_no_state() - find vdev using id
394  *                                                         from pdev
395  * @pdev: PDEV object
396  * @vdev_id: vdev id
397  * @dbg_id: id of the caller
398  *
399  * API to find vdev object pointer by vdev id from pdev's vdev list
400  *
401  * This API increments the ref count of the vdev object internally, the
402  * caller has to invoke the wlan_objmgr_vdev_release_ref() to decrement
403  * ref count
404  *
405  * Return: vdev pointer
406  *         NULL on FAILURE
407  */
408 #ifdef WLAN_OBJMGR_REF_ID_TRACE
409 struct wlan_objmgr_vdev *wlan_objmgr_get_vdev_by_id_from_pdev_no_state_debug(
410 			struct wlan_objmgr_pdev *pdev, uint8_t vdev_id,
411 			wlan_objmgr_ref_dbgid dbg_id,
412 			const char *func, int line);
413 
414 #define wlan_objmgr_get_vdev_by_id_from_pdev_no_state(pdev, \
415 	vdev_id, dbgid) \
416 		wlan_objmgr_get_vdev_by_id_from_pdev_no_state_debug(pdev, \
417 		vdev_id, dbgid, __func__, __LINE__)
418 #else
419 struct wlan_objmgr_vdev *wlan_objmgr_get_vdev_by_id_from_pdev_no_state(
420 			struct wlan_objmgr_pdev *pdev, uint8_t vdev_id,
421 			wlan_objmgr_ref_dbgid dbg_id);
422 #endif
423 
424 /**
425  * wlan_objmgr_get_vdev_by_macaddr_from_pdev() - find vdev using macaddr
426  * @pdev: PDEV object
427  * @macaddr: MAC address
428  * @dbg_id: id of the caller
429  *
430  * API to find vdev object pointer by vdev mac addr from pdev's vdev list
431  *
432  * This API increments the ref count of the vdev object internally, the
433  * caller has to invoke the wlan_objmgr_vdev_release_ref() to decrement
434  * ref count
435  *
436  * Return: vdev pointer
437  *         NULL on FAILURE
438  */
439 #ifdef WLAN_OBJMGR_REF_ID_TRACE
440 struct wlan_objmgr_vdev *wlan_objmgr_get_vdev_by_macaddr_from_pdev_debug(
441 		struct wlan_objmgr_pdev *pdev, uint8_t *macaddr,
442 		wlan_objmgr_ref_dbgid dbg_id,
443 		const char *fnc, int ln);
444 
445 #define wlan_objmgr_get_vdev_by_macaddr_from_pdev(pdev, macaddr, dbgid) \
446 		wlan_objmgr_get_vdev_by_macaddr_from_pdev_debug(pdev, macaddr, \
447 		dbgid, __func__, __LINE__)
448 #else
449 struct wlan_objmgr_vdev *wlan_objmgr_get_vdev_by_macaddr_from_pdev(
450 		struct wlan_objmgr_pdev *pdev, uint8_t *macaddr,
451 		wlan_objmgr_ref_dbgid dbg_id);
452 #endif
453 
454 /**
455  * wlan_objmgr_get_vdev_by_macaddr_from_pdev_no_state() - find vdev using
456  *                                                           macaddr
457  * @pdev: PDEV object
458  * @macaddr: MAC address
459  * @dbg_id: id of the caller
460  *
461  * API to find vdev object pointer by vdev mac addr from pdev's vdev list
462  *
463  * This API increments the ref count of the vdev object internally, the
464  * caller has to invoke the wlan_objmgr_vdev_release_ref() to decrement
465  * ref count
466  *
467  * Return: vdev pointer
468  *         NULL on FAILURE
469  */
470 #ifdef WLAN_OBJMGR_REF_ID_TRACE
471 struct wlan_objmgr_vdev
472 	*wlan_objmgr_get_vdev_by_macaddr_from_pdev_no_state_debug(
473 		struct wlan_objmgr_pdev *pdev, uint8_t *macaddr,
474 		wlan_objmgr_ref_dbgid dbg_id,
475 		const char *func, int line);
476 
477 #define wlan_objmgr_get_vdev_by_macaddr_from_pdev_no_state(pdev, macaddr, \
478 	dbgid) \
479 		wlan_objmgr_get_vdev_by_macaddr_from_pdev_no_state_debug(pdev, \
480 		macaddr, dbgid, __func__, __LINE__)
481 #else
482 struct wlan_objmgr_vdev *wlan_objmgr_get_vdev_by_macaddr_from_pdev_no_state(
483 		struct wlan_objmgr_pdev *pdev, uint8_t *macaddr,
484 		wlan_objmgr_ref_dbgid dbg_id);
485 #endif
486 
487 /**
488  * wlan_objmgr_pdev_get_first_vdev() - Get first vdev of pdev
489  * @pdev: PDEV object
490  * @dbg_id:   Object Manager ref debug id
491  *
492  * API to get reference to first vdev of pdev.
493  *
494  * Return: reference to first vdev
495  */
496 #ifdef WLAN_OBJMGR_REF_ID_TRACE
497 struct wlan_objmgr_vdev *wlan_objmgr_pdev_get_first_vdev_debug(
498 		struct wlan_objmgr_pdev *pdev,
499 		wlan_objmgr_ref_dbgid dbg_id,
500 		const char *func, int line);
501 
502 #define wlan_objmgr_pdev_get_first_vdev(pdev, dbgid) \
503 		wlan_objmgr_pdev_get_first_vdev_debug(pdev, dbgid, \
504 		__func__, __LINE__)
505 #else
506 struct wlan_objmgr_vdev *wlan_objmgr_pdev_get_first_vdev(
507 		struct wlan_objmgr_pdev *pdev,
508 		wlan_objmgr_ref_dbgid dbg_id);
509 #endif
510 
511 /**
512  * wlan_objmgr_pdev_get_comp_private_obj() - get pdev component private object
513  * @pdev: PDEV object
514  * @id: Component id
515  *
516  * API to get component private object
517  *
518  * Return: void *ptr on SUCCESS
519  *         NULL on Failure
520  */
521 void *wlan_objmgr_pdev_get_comp_private_obj(
522 		struct wlan_objmgr_pdev *pdev,
523 		enum wlan_umac_comp_id id);
524 
525 /**
526  * wlan_pdev_obj_lock() - Acquire PDEV spinlock
527  * @pdev: PDEV object
528  *
529  * API to acquire PDEV lock
530  * Parent lock should not be taken in child lock context
531  * but child lock can be taken in parent lock context
532  * (for ex: psoc lock can't be invoked in pdev/vdev/peer lock context)
533  *
534  * Return: void
535  */
536 static inline void wlan_pdev_obj_lock(struct wlan_objmgr_pdev *pdev)
537 {
538 	qdf_spin_lock_bh(&pdev->pdev_lock);
539 }
540 
541 /**
542  * wlan_pdev_obj_unlock() - Release PDEV spinlock
543  * @pdev: PDEV object
544  *
545  * API to Release PDEV lock
546  *
547  * Return: void
548  */
549 static inline void wlan_pdev_obj_unlock(struct wlan_objmgr_pdev *pdev)
550 {
551 	qdf_spin_unlock_bh(&pdev->pdev_lock);
552 }
553 
554 /**
555  * wlan_pdev_get_psoc() - get psoc
556  * @pdev: PDEV object
557  *
558  * API to get the psoc object from PDEV
559  *
560  * Return:
561  * @psoc: PSOC object
562  */
563 static inline struct wlan_objmgr_psoc *wlan_pdev_get_psoc(
564 			struct wlan_objmgr_pdev *pdev)
565 {
566 	return pdev->pdev_objmgr.wlan_psoc;
567 }
568 
569 /**
570  * wlan_pdev_set_psoc() - set psoc
571  * @pdev: PDEV object
572  * @psoc: PSOC object
573  *
574  * API to set the psoc object from PDEV
575  *
576  * Return: void
577  */
578 static inline void wlan_pdev_set_psoc(struct wlan_objmgr_pdev *pdev,
579 				struct wlan_objmgr_psoc *psoc)
580 {
581 	pdev->pdev_objmgr.wlan_psoc = psoc;
582 }
583 
584 /**
585  * wlan_pdev_nif_fw_cap_set() - set fw caps
586  * @pdev: PDEV object
587  * @cap: capability flag to be set
588  *
589  * API to set fw caps in pdev
590  *
591  * Return: void
592  */
593 static inline void wlan_pdev_nif_fw_cap_set(struct wlan_objmgr_pdev *pdev,
594 				uint32_t cap)
595 {
596 	pdev->pdev_nif.pdev_fw_caps |= cap;
597 }
598 
599 /**
600  * wlan_pdev_nif_fw_cap_clear() - clear fw cap
601  * @pdev: PDEV object
602  * @cap: capability flag to be cleared
603  *
604  * API to clear fw caps in pdev
605  *
606  * Return: void
607  */
608 static inline void wlan_pdev_nif_fw_cap_clear(struct wlan_objmgr_pdev *pdev,
609 				uint32_t cap)
610 {
611 	pdev->pdev_nif.pdev_fw_caps &= ~cap;
612 }
613 
614 /**
615  * wlan_pdev_nif_fw_cap_get() - get fw caps
616  * @pdev: PDEV object
617  * @cap: capability flag to be checked
618  *
619  * API to know, whether particular fw caps flag is set in pdev
620  *
621  * Return: 1 (for set) or 0 (for not set)
622  */
623 static inline uint8_t wlan_pdev_nif_fw_cap_get(struct wlan_objmgr_pdev *pdev,
624 				uint32_t cap)
625 {
626 	return (pdev->pdev_nif.pdev_fw_caps & cap) ? 1 : 0;
627 }
628 
629 /**
630  * wlan_pdev_nif_feat_cap_set() - set feature caps
631  * @pdev: PDEV object
632  * @cap: capability flag to be set
633  *
634  * API to set feat caps in pdev
635  *
636  * Return: void
637  */
638 static inline void wlan_pdev_nif_feat_cap_set(struct wlan_objmgr_pdev *pdev,
639 				uint32_t cap)
640 {
641 	pdev->pdev_nif.pdev_feature_caps |= cap;
642 }
643 
644 /**
645  * wlan_pdev_nif_feat_cap_clear() - clear feature caps
646  * @pdev: PDEV object
647  * @cap: capability flag to be cleared
648  *
649  * API to clear feat caps in pdev
650  *
651  * Return: void
652  */
653 static inline void wlan_pdev_nif_feat_cap_clear(struct wlan_objmgr_pdev *pdev,
654 				uint32_t cap)
655 {
656 	pdev->pdev_nif.pdev_feature_caps &= ~cap;
657 }
658 
659 /**
660  * wlan_pdev_nif_feat_cap_get() - get feature caps
661  * @pdev: PDEV object
662  * @cap: capability flag to be checked
663  *
664  * API to know, whether particular feat caps flag is set in pdev
665  *
666  * Return: 1 (for set) or 0 (for not set)
667  */
668 static inline uint8_t wlan_pdev_nif_feat_cap_get(struct wlan_objmgr_pdev *pdev,
669 				uint32_t cap)
670 {
671 	return (pdev->pdev_nif.pdev_feature_caps & cap) ? 1 : 0;
672 }
673 
674 /**
675  * wlan_pdev_nif_feat_ext_cap_set() - set feature ext caps
676  * @pdev: PDEV object
677  * @cap: capability flag to be set
678  *
679  * API to set feat ext caps in pdev
680  *
681  * Return: void
682  */
683 static inline
684 void wlan_pdev_nif_feat_ext_cap_set(struct wlan_objmgr_pdev *pdev,
685 				    uint32_t cap)
686 {
687 	pdev->pdev_nif.pdev_feature_ext_caps |= cap;
688 }
689 
690 /**
691  * wlan_pdev_nif_feat_ext_cap_clear() - clear feature ext caps
692  * @pdev: PDEV object
693  * @cap: capability flag to be cleared
694  *
695  * API to clear feat ext caps in pdev
696  *
697  * Return: void
698  */
699 static inline
700 void wlan_pdev_nif_feat_ext_cap_clear(struct wlan_objmgr_pdev *pdev,
701 				      uint32_t cap)
702 {
703 	pdev->pdev_nif.pdev_feature_ext_caps &= ~cap;
704 }
705 
706 /**
707  * wlan_pdev_nif_feat_ext_cap_get() - get feature ext caps
708  * @pdev: PDEV object
709  * @cap: capability flag to be checked
710  *
711  * API to know, whether particular feat ext caps flag is set in pdev
712  *
713  * Return: 1 (for set) or 0 (for not set)
714  */
715 static inline
716 uint8_t wlan_pdev_nif_feat_ext_cap_get(struct wlan_objmgr_pdev *pdev,
717 				       uint32_t cap)
718 {
719 	return (pdev->pdev_nif.pdev_feature_ext_caps & cap) ? 1 : 0;
720 }
721 
722 /**
723  * wlan_pdev_mlme_op_set() - set operation flags
724  * @pdev: PDEV object
725  * @op: Operation flag to be set
726  *
727  * API to set operation flag in pdev
728  *
729  * Return: void
730  */
731 static inline void wlan_pdev_mlme_op_set(struct wlan_objmgr_pdev *pdev,
732 					 uint32_t op)
733 {
734 	pdev->pdev_mlme.pdev_op_flags |= op;
735 }
736 
737 /**
738  * wlan_pdev_mlme_op_clear() - clear op flags
739  * @pdev: PDEV object
740  * @op: Operation flag to be cleared
741  *
742  * API to clear op flag in pdev
743  *
744  * Return: void
745  */
746 static inline void wlan_pdev_mlme_op_clear(struct wlan_objmgr_pdev *pdev,
747 					   uint32_t op)
748 {
749 	pdev->pdev_mlme.pdev_op_flags &= ~op;
750 }
751 
752 /**
753  * wlan_pdev_mlme_op_get() - get op flag
754  * @pdev: PDEV object
755  * @op: Operation flag to be checked
756  *
757  * API to know, whether particular operation flag is set in pdev
758  *
759  * Return: 1 (for set) or 0 (for not set)
760  */
761 static inline uint8_t wlan_pdev_mlme_op_get(struct wlan_objmgr_pdev *pdev,
762 					    uint32_t op)
763 {
764 	return (pdev->pdev_mlme.pdev_op_flags & op) ? 1 : 0;
765 }
766 
767 /**
768  * wlan_pdev_get_hw_macaddr() - get hw macaddr
769  * @pdev: PDEV object
770  *
771  * API to get HW MAC address form PDEV
772  *
773  * Caller need to acquire lock with wlan_pdev_obj_lock()
774  *
775  * Return: @macaddr -MAC address
776  */
777 static inline uint8_t *wlan_pdev_get_hw_macaddr(struct wlan_objmgr_pdev *pdev)
778 {
779 	if (!pdev)
780 		return NULL;
781 
782 	/* This API is invoked with lock acquired, do not add log prints */
783 	return pdev->pdev_nif.macaddr;
784 }
785 
786 /**
787  * wlan_pdev_set_hw_macaddr() - set hw macaddr
788  * @pdev: PDEV object
789  * @macaddr: MAC address
790  *
791  * API to set HW MAC address form PDEV
792  *
793  * Caller need to acquire lock with wlan_pdev_obj_lock()
794  *
795  * Return: void
796  */
797 static inline void wlan_pdev_set_hw_macaddr(struct wlan_objmgr_pdev *pdev,
798 			uint8_t *macaddr)
799 {
800 	/* This API is invoked with lock acquired, do not add log prints */
801 	WLAN_ADDR_COPY(pdev->pdev_nif.macaddr, macaddr);
802 }
803 
804 /**
805  * wlan_pdev_get_ospriv() - get os priv pointer
806  * @pdev: PDEV object
807  *
808  * API to get OS private pointer from PDEV
809  *
810  * Return: ospriv - private pointer
811  */
812 static inline struct pdev_osif_priv *wlan_pdev_get_ospriv(
813 				struct wlan_objmgr_pdev *pdev)
814 {
815 	return pdev->pdev_nif.pdev_ospriv;
816 }
817 
818 /**
819  * wlan_pdev_reset_ospriv() - reset os priv pointer
820  * @pdev: PDEV object
821  *
822  * API to reset OS private pointer in PDEV
823  *
824  * Return: void
825  */
826 static inline void wlan_pdev_reset_ospriv(struct wlan_objmgr_pdev *pdev)
827 {
828 	pdev->pdev_nif.pdev_ospriv = NULL;
829 }
830 
831 /**
832  * wlan_pdev_set_max_vdev_count() - set pdev max vdev count
833  * @pdev: PDEV object
834  * @vdev count: Max vdev count
835  *
836  * API to set Max vdev count
837  *
838  * Return: void
839  */
840 static inline void wlan_pdev_set_max_vdev_count(struct wlan_objmgr_pdev *pdev,
841 					   uint8_t max_vdev_count)
842 {
843 	if (max_vdev_count > WLAN_UMAC_PDEV_MAX_VDEVS)
844 		QDF_BUG(0);
845 
846 	pdev->pdev_objmgr.max_vdev_count = max_vdev_count;
847 }
848 
849 /**
850  * wlan_pdev_get_max_vdev_count() - get pdev max vdev count
851  * @pdev: PDEV object
852  *
853  * API to set Max vdev count
854  *
855  * Return: @vdev count: Max vdev count
856  */
857 static inline uint8_t wlan_pdev_get_max_vdev_count(
858 					struct wlan_objmgr_pdev *pdev)
859 {
860 	return pdev->pdev_objmgr.max_vdev_count;
861 }
862 
863 /**
864  * DOC: Examples to use PDEV ref count APIs
865  *
866  * In all the scenarios, the pair of API should be followed
867  * otherwise it lead to memory leak
868  *
869  *  scenario 1:
870  *
871  *     wlan_objmgr_pdev_obj_create()
872  *     ----
873  *     wlan_objmgr_pdev_obj_delete()
874  *
875  *  scenario 2:
876  *
877  *     wlan_objmgr_pdev_get_ref()
878  *     ----
879  *     the operations which are done on
880  *     pdev object
881  *     ----
882  *     wlan_objmgr_pdev_release_ref()
883  *
884  *  scenario 3:
885  *
886  *     wlan_objmgr_get_pdev_by_id[_no_state]()
887  *     ----
888  *     the operations which are done on
889  *     pdev object
890  *     ----
891  *     wlan_objmgr_pdev_release_ref()
892  *
893  *  scenario 4:
894  *
895  *     wlan_objmgr_get_pdev_by_macaddr[_no_state]()
896  *     ----
897  *     the operations which are done on
898  *     pdev object
899  *     ----
900  *     wlan_objmgr_pdev_release_ref()
901  */
902 
903 /**
904  * wlan_objmgr_pdev_get_ref() - increment ref count
905  * @pdev: PDEV object
906  * @id:   Object Manager ref debug id
907  *
908  * API to increment ref count of pdev
909  *
910  * Return: void
911  */
912 void wlan_objmgr_pdev_get_ref(struct wlan_objmgr_pdev *pdev,
913 					wlan_objmgr_ref_dbgid id);
914 
915 /**
916  * wlan_objmgr_pdev_try_get_ref() - increment ref count, if allowed
917  * @pdev: PDEV object
918  * @id:   Object Manager ref debug id
919  *
920  * API to increment ref count of pdev after checking valid object state
921  *
922  * Return: void
923  */
924 QDF_STATUS wlan_objmgr_pdev_try_get_ref(struct wlan_objmgr_pdev *pdev,
925 						wlan_objmgr_ref_dbgid id);
926 
927 /**
928  * wlan_objmgr_pdev_release_ref() - decrement ref count
929  * @pdev: PDEV object
930  * @id:   Object Manager ref debug id
931  *
932  * API to decrement ref count of pdev, if ref count is 1, it initiates the
933  * PDEV deletion
934  *
935  * Return: void
936  */
937 void wlan_objmgr_pdev_release_ref(struct wlan_objmgr_pdev *pdev,
938 						wlan_objmgr_ref_dbgid id);
939 
940 /**
941  * wlan_objmgr_pdev_get_pdev_id() - get pdev id
942  * @pdev: PDEV object
943  *
944  * API to get pdev id from pdev object
945  *
946  * Return: @pdev id
947  */
948 static inline
949 uint8_t wlan_objmgr_pdev_get_pdev_id(struct wlan_objmgr_pdev *pdev)
950 {
951 	return pdev->pdev_objmgr.wlan_pdev_id;
952 }
953 
954 /**
955  * wlan_pdev_set_tgt_if_handle(): API to set target if handle in pdev object
956  * @pdev: Pdev pointer
957  * @tgt_if_handle: target interface handle
958  *
959  * API to set target interface handle in pdev object
960  *
961  * Caller needs to acquire lock with wlan_pdev_obj_lock()
962  *
963  * Return: None
964  */
965 static inline
966 void wlan_pdev_set_tgt_if_handle(struct wlan_objmgr_pdev *pdev,
967 				 target_pdev_info_t *tgt_if_handle)
968 {
969 	/* This API is invoked with lock acquired, do not add log prints */
970 	if (!pdev)
971 		return;
972 
973 	pdev->tgt_if_handle = tgt_if_handle;
974 }
975 
976 /**
977  * wlan_pdev_get_tgt_if_handle(): API to get target interface handle
978  * @pdev: Pdev pointer
979  *
980  * API to get target interface handle from pdev object
981  *
982  * Return: target interface handle
983  */
984 static inline
985 target_pdev_info_t *wlan_pdev_get_tgt_if_handle(struct wlan_objmgr_pdev *pdev)
986 {
987 	if (!pdev)
988 		return NULL;
989 
990 	return pdev->tgt_if_handle;
991 }
992 
993 /**
994  * wlan_pdev_set_max_peer_count() - set max peer count
995  * @vdev: PDEV object
996  * @count: Max peer count
997  *
998  * API to set max peer count of PDEV
999  *
1000  * Return: void
1001  */
1002 static inline void wlan_pdev_set_max_peer_count(struct wlan_objmgr_pdev *pdev,
1003 						uint16_t count)
1004 {
1005 	pdev->pdev_objmgr.max_peer_count = count;
1006 }
1007 
1008 /**
1009  * wlan_pdev_get_max_peer_count() - get max peer count
1010  * @pdev: PDEV object
1011  *
1012  * API to get max peer count of PDEV
1013  *
1014  * Return: max peer count
1015  */
1016 static inline uint16_t wlan_pdev_get_max_peer_count(
1017 						struct wlan_objmgr_pdev *pdev)
1018 {
1019 	return pdev->pdev_objmgr.max_peer_count;
1020 }
1021 
1022 /**
1023  * wlan_pdev_set_max_monitor_vdev_count() - set max monitor vdev count
1024  * @pdev: PDEV object
1025  * @count: Max monitor vdev count
1026  *
1027  * API to set max monitor vdev count of PDEV
1028  *
1029  * Return: void
1030  */
1031 static inline void wlan_pdev_set_max_monitor_vdev_count(
1032 		struct wlan_objmgr_pdev *pdev,
1033 		uint16_t count)
1034 {
1035 	pdev->pdev_objmgr.max_monitor_vdev_count = count;
1036 }
1037 
1038 /**
1039  * wlan_pdev_get_max_monitor_vdev_count() - get max monitor vdev count
1040  * @pdev: PDEV object
1041  *
1042  * API to get max monitor vdev count of PDEV
1043  *
1044  * Return: max monitor vdev count
1045  */
1046 static inline uint16_t wlan_pdev_get_max_monitor_vdev_count(
1047 		struct wlan_objmgr_pdev *pdev)
1048 {
1049 	return pdev->pdev_objmgr.max_monitor_vdev_count;
1050 }
1051 
1052 /**
1053  * wlan_pdev_get_peer_count() - get pdev peer count
1054  * @pdev: PDEV object
1055  *
1056  * API to get peer count from PDEV
1057  *
1058  * Return: peer_count - pdev's peer count
1059  */
1060 static inline uint16_t wlan_pdev_get_peer_count(struct wlan_objmgr_pdev *pdev)
1061 {
1062 	return pdev->pdev_objmgr.wlan_peer_count;
1063 }
1064 
1065 /**
1066  * wlan_pdev_get_temp_peer_count() - get pdev temporary peer count
1067  * @pdev: PDEV object
1068  *
1069  * API to get temporary peer count from PDEV
1070  *
1071  * Return: temp_peer_count - pdev's temporary peer count
1072  */
1073 static inline uint16_t wlan_pdev_get_temp_peer_count(struct wlan_objmgr_pdev *pdev)
1074 {
1075 	return pdev->pdev_objmgr.temp_peer_count;
1076 }
1077 
1078 
1079 /**
1080  * wlan_pdev_incr_peer_count() - increment pdev peer count
1081  * @pdev: PDEV object
1082  *
1083  * API to increment peer count of PDEV by 1
1084  *
1085  * Return: void
1086  */
1087 static inline void wlan_pdev_incr_peer_count(struct wlan_objmgr_pdev *pdev)
1088 {
1089 	pdev->pdev_objmgr.wlan_peer_count++;
1090 }
1091 
1092 /**
1093  * wlan_pdev_decr_peer_count() - decrement pdev peer count
1094  * @pdev: PDEV object
1095  *
1096  * API to decrement peer count of PDEV by 1
1097  *
1098  * Return: void
1099  */
1100 static inline void wlan_pdev_decr_peer_count(struct wlan_objmgr_pdev *pdev)
1101 {
1102 	pdev->pdev_objmgr.wlan_peer_count--;
1103 }
1104 
1105 /**
1106  * wlan_pdev_incr_temp_peer_count() - increment temporary pdev peer count
1107  * @pdev: PDEV object
1108  *
1109  * API to increment temporary  peer count of PDEV by 1
1110  *
1111  * Return: void
1112  */
1113 static inline void wlan_pdev_incr_temp_peer_count(struct wlan_objmgr_pdev *pdev)
1114 {
1115 	pdev->pdev_objmgr.temp_peer_count++;
1116 }
1117 
1118 /**
1119  * wlan_pdev_decr_temp_peer_count() - decrement pdev temporary peer count
1120  * @pdev: PDEV object
1121  *
1122  * API to decrement temporary peer count of PDEV by 1
1123  *
1124  * Return: void
1125  */
1126 static inline void wlan_pdev_decr_temp_peer_count(struct wlan_objmgr_pdev *pdev)
1127 {
1128 	pdev->pdev_objmgr.temp_peer_count--;
1129 }
1130 
1131 /**
1132  * wlan_pdev_get_vdev_count() - get PDEV vdev count
1133  * @pdev: PDEV object
1134  *
1135  * API to get vdev count from PDEV
1136  *
1137  * Return: vdev_count - pdev's vdev count
1138  */
1139 static inline uint8_t wlan_pdev_get_vdev_count(struct wlan_objmgr_pdev *pdev)
1140 {
1141 	return pdev->pdev_objmgr.wlan_vdev_count;
1142 }
1143 
1144 /**
1145  * wlan_print_pdev_info() - print pdev members
1146  * @pdev: pdev object pointer
1147  *
1148  * Return: void
1149  */
1150 #ifdef WLAN_OBJMGR_DEBUG
1151 void wlan_print_pdev_info(struct wlan_objmgr_pdev *pdev);
1152 #else
1153 static inline void wlan_print_pdev_info(struct wlan_objmgr_pdev *pdev) {}
1154 #endif
1155 
1156 #endif /* _WLAN_OBJMGR_PDEV_H_*/
1157