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