xref: /wlan-dirver/qca-wifi-host-cmn/umac/cmn_services/obj_mgr/inc/wlan_objmgr_psoc_obj.h (revision 8ddef7dd9a290d4a9b1efd5d3efacf51d78a1a0d)
1 /*
2  * Copyright (c) 2016-2019 The Linux Foundation. All rights reserved.
3  *
4  * Permission to use, copy, modify, and/or distribute this software for
5  * any purpose with or without fee is hereby granted, provided that the
6  * above copyright notice and this permission notice appear in all
7  * copies.
8  *
9  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
10  * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
11  * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
12  * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
13  * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
14  * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
15  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
16  * PERFORMANCE OF THIS SOFTWARE.
17  */
18  /**
19   * DOC: Define the pSoc data structure of UMAC
20   *      Public APIs to perform operations on Global objects
21   */
22 #ifndef _WLAN_OBJMGR_PSOC_OBJ_H_
23 #define _WLAN_OBJMGR_PSOC_OBJ_H_
24 
25 #include "wlan_objmgr_cmn.h"
26 #include "wlan_objmgr_debug.h"
27 #include "wlan_lmac_if_def.h"
28 
29 #define REG_DMN_CH144        0x0001
30 #define REG_DMN_ENTREPRISE   0x0002
31 
32 
33 /* fw_caps */
34 	/* CAPABILITY: WEP available */
35 #define WLAN_SOC_C_WEP                  0x00000001
36 	/* CAPABILITY: TKIP available */
37 #define WLAN_SOC_C_TKIP                 0x00000002
38 	/* CAPABILITY: AES OCB avail */
39 #define WLAN_SOC_C_AES                  0x00000004
40 	/* CAPABILITY: AES CCM avail */
41 #define WLAN_SOC_C_AES_CCM              0x00000008
42 	/* CAPABILITY: 11n HT available */
43 #define WLAN_SOC_C_HT                   0x00000010
44 	/* CAPABILITY: CKIP available */
45 #define WLAN_SOC_C_CKIP                 0x00000020
46 	/* CAPABILITY: ATH FF avail */
47 #define WLAN_SOC_C_FF                   0x00000040
48 	/* CAPABILITY: ATH Turbo avail*/
49 #define WLAN_SOC_C_TURBOP               0x00000080
50 	/* CAPABILITY: IBSS available */
51 #define WLAN_SOC_C_IBSS                 0x00000100
52 	/* CAPABILITY: Power mgmt */
53 #define WLAN_SOC_C_PMGT                 0x00000200
54 	/* CAPABILITY: HOSTAP avail */
55 #define WLAN_SOC_C_HOSTAP               0x00000400
56 	/* CAPABILITY: Old Adhoc Demo */
57 #define WLAN_SOC_C_AHDEMO               0x00000800
58 	/* CAPABILITY: tx power mgmt */
59 #define WLAN_SOC_C_TXPMGT               0x00001000
60 	/* CAPABILITY: short slottime */
61 #define WLAN_SOC_C_SHSLOT               0x00002000
62 	/* CAPABILITY: short preamble */
63 #define WLAN_SOC_C_SHPREAMBLE           0x00004000
64 	/* CAPABILITY: monitor mode */
65 #define WLAN_SOC_C_MONITOR              0x00008000
66 	/* CAPABILITY: TKIP MIC avail */
67 #define WLAN_SOC_C_TKIPMIC              0x00010000
68 	/* CAPABILITY: ATH WAPI avail */
69 #define WLAN_SOC_C_WAPI                 0x00020000
70 	/* CONF: WDS auto Detect/DELBA */
71 #define WLAN_SOC_C_WDS_AUTODETECT       0x00040000
72 	/* CAPABILITY: WPA1 avail */
73 #define WLAN_SOC_C_WPA1                 0x00080000
74 	/* CAPABILITY: WPA2 avail */
75 #define WLAN_SOC_C_WPA2                 0x00100000
76 	/* CAPABILITY: WPA1+WPA2 avail*/
77 #define WLAN_SOC_C_WPA                  0x00180000
78 	/* CAPABILITY: frame bursting */
79 #define WLAN_SOC_C_BURST                0x00200000
80 	/* CAPABILITY: WME avail */
81 #define WLAN_SOC_C_WME                  0x00400000
82 	/* CAPABILITY: 4-addr support */
83 #define WLAN_SOC_C_WDS                  0x00800000
84 	/* CAPABILITY: TKIP MIC for QoS frame */
85 #define WLAN_SOC_C_WME_TKIPMIC          0x01000000
86 	/* CAPABILITY: bg scanning */
87 #define WLAN_SOC_C_BGSCAN               0x02000000
88 	/* CAPABILITY: UAPSD */
89 #define WLAN_SOC_C_UAPSD                0x04000000
90 	/* CAPABILITY: enabled 11.h */
91 #define WLAN_SOC_C_DOTH                 0x08000000
92 
93 /* XXX protection/barker? */
94 	/* CAPABILITY: crypto alg's */
95 #define WLAN_SOC_C_CRYPTO         0x0000002f
96 
97 /* fw_caps_ext */
98 	/* CAPABILITY: fast channel change */
99 #define WLAN_SOC_CEXT_FASTCC           0x00000001
100 	/* CAPABILITY: P2P */
101 #define WLAN_SOC_CEXT_P2P              0x00000002
102 	/* CAPABILITY: Multi-Channel Operations */
103 #define WLAN_SOC_CEXT_MULTICHAN        0x00000004
104 	/* CAPABILITY: the device supports perf and power offload */
105 #define WLAN_SOC_CEXT_PERF_PWR_OFLD    0x00000008
106 	/* CAPABILITY: the device supports 11ac */
107 #define WLAN_SOC_CEXT_11AC             0x00000010
108 	/* CAPABILITY: the device support acs channel hopping */
109 #define WLAN_SOC_CEXT_ACS_CHAN_HOP     0x00000020
110 	/* CAPABILITY: the device support STA DFS */
111 #define WLAN_SOC_CEXT_STADFS           0x00000040
112 	/* NSS offload capability */
113 #define WLAN_SOC_CEXT_NSS_OFFLOAD      0x00000080
114 	/* SW cal support capability */
115 #define WLAN_SOC_CEXT_SW_CAL           0x00000100
116 	/* Hybrid mode */
117 #define WLAN_SOC_CEXT_HYBRID_MODE      0x00000200
118 	/* TT support */
119 #define WLAN_SOC_CEXT_TT_SUPPORT       0x00000400
120 	/* WMI MGMT REF */
121 #define WLAN_SOC_CEXT_WMI_MGMT_REF     0x00000800
122 	/* Wideband scan */
123 #define WLAN_SOC_CEXT_WIDEBAND_SCAN    0x00001000
124 	/* TWT Requester capable */
125 #define WLAN_SOC_CEXT_TWT_REQUESTER    0x00002000
126 	/* TWT Responder capable */
127 #define WLAN_SOC_CEXT_TWT_RESPONDER    0x00004000
128 	/* HW DB2DBM CAPABLE */
129 #define WLAN_SOC_CEXT_HW_DB2DBM        0x00008000
130 	/* OBSS Narrow Bandwidth RU Tolerance */
131 #define WLAN_SOC_CEXT_OBSS_NBW_RU      0x00010000
132 
133 /* feature_flags */
134 	/* CONF: ATH FF enabled */
135 #define WLAN_SOC_F_FF                   0x00000001
136 	/* CONF: ATH Turbo enabled*/
137 #define WLAN_SOC_F_TURBOP               0x00000002
138 	/* STATUS: promiscuous mode */
139 #define WLAN_SOC_F_PROMISC              0x00000004
140 	/* STATUS: all multicast mode */
141 #define WLAN_SOC_F_ALLMULTI             0x00000008
142 /* NB: this is intentionally setup to be IEEE80211_CAPINFO_PRIVACY */
143 	/* STATUS: start IBSS */
144 #define WLAN_SOC_F_SIBSS                0x00000010
145 /* NB: this is intentionally setup to be IEEE80211_CAPINFO_SHORT_SLOTTIME */
146 	/* CONF: Power mgmt enable */
147 #define WLAN_SOC_F_PMGTON               0x00000020
148 	/* CONF: IBSS creation enable */
149 #define WLAN_SOC_F_IBSSON               0x00000040
150 	/* force chanswitch */
151 #define WLAN_SOC_F_CHANSWITCH           0x00000080
152 
153 /* ic_flags_ext and/or iv_flags_ext */
154 	/* CONF: enable country IE */
155 #define WLAN_SOC_F_COUNTRYIE           0x00000100
156 	/* STATE: enable full bgscan completion */
157 #define WLAN_SOC_F_BGSCAN              0x00000200
158 	/* CONF: enable U-APSD */
159 #define WLAN_SOC_F_UAPSD               0x00000400
160 	/* STATUS: sleeping */
161 #define WLAN_SOC_F_SLEEP               0x00000800
162 	/* Enable marking of dfs interfernce */
163 #define WLAN_SOC_F_MARKDFS             0x00001000
164 	/* enable or disable s/w ccmp encrypt decrypt support */
165 #define WLAN_SOC_F_CCMPSW_ENCDEC       0x00002000
166 	/* STATE: hibernating */
167 #define WLAN_SOC_F_HIBERNATION         0x00004000
168 	/* CONF: desired country has been set */
169 #define WLAN_SOC_F_DESCOUNTRY          0x00008000
170 	/* CONF: enable power capability or contraint IE */
171 #define WLAN_SOC_F_PWRCNSTRIE          0x00010000
172 	/* STATUS: 11D in used */
173 #define WLAN_SOC_F_DOT11D              0x00020000
174 	/* Beacon offload */
175 #define WLAN_SOC_F_BCN_OFFLOAD         0x00040000
176 	/* QWRAP enable */
177 #define WLAN_SOC_F_QWRAP_ENABLE        0x00080000
178 	/* LTEU support */
179 #define WLAN_SOC_F_LTEU_SUPPORT        0x00100000
180 	/* BT coext support */
181 #define WLAN_SOC_F_BTCOEX_SUPPORT      0x00200000
182 	/* HOST 80211 enable*/
183 #define WLAN_SOC_F_HOST_80211_ENABLE   0x00400000
184 	/* MBSS IE enable */
185 #define WLAN_SOC_F_MBSS_IE_ENABLE      0x00800000
186 	/* Spectral disable */
187 #define WLAN_SOC_F_SPECTRAL_DISABLE    0x01000000
188 	/* FTM testmode enable */
189 #define WLAN_SOC_F_TESTMODE_ENABLE     0x02000000
190 
191 /* PSOC op flags */
192 
193 	/* Invalid VHT cap */
194 #define WLAN_SOC_OP_VHT_INVALID_CAP    0x00000001
195 /**
196  * struct wlan_objmgr_psoc_regulatory -  Regulatory sub structure of PSOC
197  * @country_code:  Country code
198  * @reg_dmn:       Regulatory Domain
199  * @reg_flags:     Regulatory flags
200  */
201 struct wlan_objmgr_psoc_regulatory {
202 	uint16_t country_code;
203 	uint16_t reg_dmn;
204 	uint16_t reg_flags;
205 };
206 
207 /**
208  * struct wlan_objmgr_psoc_user_config -  user configurations to
209  * be used by common modules
210  * @is_11d_support_enabled: Enable/disable 11d feature
211  * @is_11h_support_enabled: Enable/disable 11h feature
212  * @dot11_mode: Phy mode
213  * @skip_dfs_chnl_in_p2p_search: Skip Dfs Channel in case of P2P
214  *                             Search
215  * @band_capability: Preferred band (0:Both,  1:2G only,  2:5G only)
216  */
217 struct wlan_objmgr_psoc_user_config {
218 	bool is_11d_support_enabled;
219 	bool is_11h_support_enabled;
220 	uint8_t dot11_mode;
221 	uint8_t band_capability;
222 };
223 
224 /**
225  * struct wlan_objmgr_psoc_nif - HDD/OSIF specific sub structure of PSOC
226  * @phy_version:     phy version, read in device probe
227  * @phy_type:        OL/DA type
228  * @soc_fw_caps:     FW capabilities
229  * @soc_fw_ext_caps: FW ext capabilities
230  * @soc_feature_caps:Feature capabilities
231  * @soc_op_flags:    Flags to set/reset during operation
232  * @soc_hw_macaddr[]:HW MAC address
233  * @user_config:     user config from OS layer
234  */
235 struct wlan_objmgr_psoc_nif {
236 	uint32_t phy_version;
237 	WLAN_DEV_TYPE phy_type;
238 	uint32_t soc_fw_caps;
239 	uint32_t soc_fw_ext_caps;
240 	uint32_t soc_feature_caps;
241 	uint32_t soc_op_flags;
242 	uint8_t soc_hw_macaddr[QDF_MAC_ADDR_SIZE];
243 	struct wlan_objmgr_psoc_user_config user_config;
244 };
245 
246 /**
247  * struct wlan_objmgr_psoc_objmgr - psoc object manager sub structure
248  * @psoc_id:              The PSOC's numeric Id
249  * @wlan_pdev_count:      PDEV count
250  * @wlan_pdev_id_map:     PDEV id map, to allocate free ids
251  * @wlan_vdev_count:      VDEV count
252  * @max_vdev_count:       Max no. of VDEVs supported by this PSOC
253  * @print_cnt:            Count to throttle Logical delete prints
254  * @wlan_peer_count:      PEER count
255  * @max_peer_count:       Max no. of peers supported by this PSOC
256  * @temp_peer_count:      Temporary peer count
257  * @wlan_pdev_list[]:     PDEV list
258  * @wlan_vdev_list[]:     VDEV list
259  * @wlan_vdev_id_map[]:   VDEV id map, to allocate free ids
260  * @peer_list:            Peer list
261  * @ref_cnt:              Ref count
262  * @ref_id_dbg:           Array to track Ref count
263  * @qdf_dev:              QDF Device
264  */
265 struct wlan_objmgr_psoc_objmgr {
266 	uint8_t psoc_id;
267 	uint8_t wlan_pdev_count;
268 	uint8_t wlan_pdev_id_map;
269 	uint8_t wlan_vdev_count;
270 	uint8_t max_vdev_count;
271 	uint8_t print_cnt;
272 	uint16_t wlan_peer_count;
273 	uint16_t max_peer_count;
274 	uint16_t temp_peer_count;
275 	struct wlan_objmgr_pdev *wlan_pdev_list[WLAN_UMAC_MAX_PDEVS];
276 	struct wlan_objmgr_vdev *wlan_vdev_list[WLAN_UMAC_PSOC_MAX_VDEVS];
277 	uint32_t wlan_vdev_id_map[2];
278 	struct wlan_peer_list peer_list;
279 	qdf_atomic_t ref_cnt;
280 	qdf_atomic_t ref_id_dbg[WLAN_REF_ID_MAX];
281 	qdf_device_t qdf_dev;
282 };
283 
284 /**
285  * struct wlan_soc_southbound_cb - Southbound callbacks
286  * @tx_ops: contains southbound tx callbacks
287  * @rx_ops: contains southbound rx callbacks
288  */
289 struct wlan_soc_southbound_cb {
290 	struct wlan_lmac_if_tx_ops tx_ops;
291 	struct wlan_lmac_if_rx_ops rx_ops;
292 };
293 
294 /**
295  * struct wlan_concurrency_info - structure for concurrency info
296  *
297  */
298 struct wlan_concurrency_info {
299 };
300 
301 /**
302  * struct wlan_soc_timer - structure for soc timer
303  *
304  */
305 struct wlan_soc_timer {
306 };
307 
308 /**
309  * struct wlan_objmgr_psoc - PSOC common object
310  * @soc_reg:               regulatory sub structure
311  * @soc_nif:               nif sub strucutre
312  * @soc_objmgr:            object manager sub structure
313  * @soc_cb:                south bound callbacks
314  * @soc_timer:             soc timer for inactivity
315  * @soc_concurrency:       concurrency info
316  * @wlan_active_vdevs[]:   List of active VDEVs
317  * @soc_comp_priv_obj[]:   component private object pointers
318  * @obj_status[]:          component object status
319  * @obj_state:             object state
320  * @tgt_if_handle:         target interface handle
321  * @dp_handle:             DP module handle
322  * @psoc_lock:             psoc lock
323  */
324 struct wlan_objmgr_psoc {
325 	struct wlan_objmgr_psoc_regulatory soc_reg;
326 	struct wlan_objmgr_psoc_nif  soc_nif;
327 	struct wlan_objmgr_psoc_objmgr soc_objmgr;
328 	struct wlan_soc_southbound_cb soc_cb;
329 	struct wlan_soc_timer soc_timer;
330 	struct wlan_concurrency_info soc_concurrency; /*TODO */
331 	uint8_t wlan_active_vdevs[WLAN_UMAC_PSOC_MAX_VDEVS];
332 	void *soc_comp_priv_obj[WLAN_UMAC_MAX_COMPONENTS];
333 	QDF_STATUS obj_status[WLAN_UMAC_MAX_COMPONENTS];
334 	WLAN_OBJ_STATE obj_state;
335 	void *tgt_if_handle;
336 	void *dp_handle;
337 	qdf_spinlock_t psoc_lock;
338 };
339 
340 /**
341  * struct wlan_psoc_host_hal_reg_capabilities_ext: Below are Reg caps per PHY.
342  *                       Please note PHY ID starts with 0.
343  * @phy_id: phy id starts with 0.
344  * @eeprom_reg_domain: regdomain value specified in EEPROM
345  * @eeprom_reg_domain_ext: regdomain
346  * @regcap1: CAP1 capabilities bit map, see REGDMN_CAP1_ defines
347  * @regcap2: REGDMN EEPROM CAP, see REGDMN_EEPROM_EEREGCAP_ defines
348  * @wireless_modes: REGDMN MODE, see REGDMN_MODE_ enum
349  * @low_2ghz_chan: 2G channel low
350  * @high_2ghz_chan: 2G channel High
351  * @low_5ghz_chan: 5G channel low
352  * @high_5ghz_chan: 5G channel High
353  */
354 struct wlan_psoc_host_hal_reg_capabilities_ext {
355 	uint32_t phy_id;
356 	uint32_t eeprom_reg_domain;
357 	uint32_t eeprom_reg_domain_ext;
358 	uint32_t regcap1;
359 	uint32_t regcap2;
360 	uint32_t wireless_modes;
361 	uint32_t low_2ghz_chan;
362 	uint32_t high_2ghz_chan;
363 	uint32_t low_5ghz_chan;
364 	uint32_t high_5ghz_chan;
365 };
366 
367 /**
368  ** APIs to Create/Delete Global object APIs
369  */
370 /**
371  * wlan_objmgr_psoc_obj_create() - psoc object create
372  * @phy_version: device id (from probe)
373  * @dev_type: Offload/DA
374  *
375  * Creates PSOC object, intializes with default values
376  * Invokes the registered notifiers to create component object
377  *
378  * Return: Handle to struct wlan_objmgr_psoc on successful creation,
379  *         NULL on Failure (on Mem alloc failure and Component objects
380  *         Failure)
381  */
382 struct wlan_objmgr_psoc *wlan_objmgr_psoc_obj_create(uint32_t phy_version,
383 				WLAN_DEV_TYPE dev_type);
384 
385 /**
386  * wlan_objmgr_psoc_obj_delete() - psoc object delete
387  * @psoc: PSOC object
388  *
389  * Logically deletes PSOC object,
390  * Once all the references are released, object manager invokes the registered
391  * notifiers to destroy component objects
392  *
393  * Return: SUCCESS/FAILURE
394  */
395 QDF_STATUS wlan_objmgr_psoc_obj_delete(struct wlan_objmgr_psoc *psoc);
396 
397 /**
398  ** APIs to attach/detach component objects
399  */
400 
401 /**
402  * wlan_objmgr_psoc_component_obj_attach() - psoc comp object attach
403  * @psoc: PSOC object
404  * @id: Component id
405  * @comp_priv_obj: component's private object pointer
406  * @status: Component's private object creation status
407  *
408  * API to be used for attaching component object with PSOC common object
409  *
410  * Return: SUCCESS on successful storing of component's object in common object
411  *         On FAILURE (appropriate failure codes are returned)
412  */
413 QDF_STATUS wlan_objmgr_psoc_component_obj_attach(
414 		struct wlan_objmgr_psoc *psoc,
415 		enum wlan_umac_comp_id id,
416 		void *comp_priv_obj,
417 		QDF_STATUS status);
418 
419 /**
420  * wlan_objmgr_psoc_component_obj_detach() - psoc comp object detach
421  * @psoc: PSOC object
422  * @id: Component id
423  * @comp_priv_obj: component's private object pointer
424  *
425  * API to be used for detaching component object with PSOC common object
426  *
427  * Return: SUCCESS on successful removal of component's object from common
428  *         object
429  *         On FAILURE (appropriate failure codes are returned)
430  */
431 QDF_STATUS wlan_objmgr_psoc_component_obj_detach(
432 		struct wlan_objmgr_psoc *psoc,
433 		enum wlan_umac_comp_id id,
434 		void *comp_priv_obj);
435 
436 /**
437  ** APIs to operations on psoc objects
438  */
439 typedef void (*wlan_objmgr_op_handler)(struct wlan_objmgr_psoc *psoc,
440 					void *object,
441 					void *arg);
442 
443 /**
444  * wlan_objmgr_iterate_obj_list() - iterate through all psoc objects
445  *                                  (CREATED state)
446  * @psoc: PSOC object
447  * @obj_type: PDEV_OP/VDEV_OP/PEER_OP
448  * @handler: the handler will be called for each object of requested type
449  *            the handler should be implemented to perform required operation
450  * @arg:     agruments passed by caller
451  * @lock_free_op: its obsolete
452  * @dbg_id: id of the caller
453  *
454  * API to be used for performing the operations on all PDEV/VDEV/PEER objects
455  * of psoc
456  *
457  * Return: SUCCESS/FAILURE
458  */
459 QDF_STATUS wlan_objmgr_iterate_obj_list(
460 		struct wlan_objmgr_psoc *psoc,
461 		enum wlan_objmgr_obj_type obj_type,
462 		wlan_objmgr_op_handler handler,
463 		void *arg, uint8_t lock_free_op,
464 		wlan_objmgr_ref_dbgid dbg_id);
465 
466 /**
467  * wlan_objmgr_iterate_obj_list_all() - iterate through all psoc objects
468  * @psoc: PSOC object
469  * @obj_type: PDEV_OP/VDEV_OP/PEER_OP
470  * @handler: the handler will be called for each object of requested type
471  *            the handler should be implemented to perform required operation
472  * @arg:     agruments passed by caller
473  * @lock_free_op: its obsolete
474  * @dbg_id: id of the caller
475  *
476  * API to be used for performing the operations on all PDEV/VDEV/PEER objects
477  * of psoc
478  *
479  * Return: SUCCESS/FAILURE
480  */
481 QDF_STATUS wlan_objmgr_iterate_obj_list_all(
482 		struct wlan_objmgr_psoc *psoc,
483 		enum wlan_objmgr_obj_type obj_type,
484 		wlan_objmgr_op_handler handler,
485 		void *arg, uint8_t lock_free_op,
486 		wlan_objmgr_ref_dbgid dbg_id);
487 
488 /**
489  * wlan_objmgr_free_all_objects_per_psoc() - free all psoc objects
490  * @psoc: PSOC object
491  *
492  * API to be used free all the objects(pdev/vdev/peer) of psoc
493  *
494  * Return: SUCCESS/FAILURE
495  */
496 QDF_STATUS wlan_objmgr_free_all_objects_per_psoc(
497 		struct wlan_objmgr_psoc *psoc);
498 
499 /**
500  * wlan_objmgr_trigger_psoc_comp_priv_object_creation() - create
501  * psoc comp object
502  * @psoc: PSOC object
503  * @id: Component id
504  *
505  * API to create component private object in run time, this would
506  * be used for features which gets enabled in run time
507  *
508  * Return: SUCCESS on successful creation
509  *         On FAILURE (appropriate failure codes are returned)
510  */
511 QDF_STATUS wlan_objmgr_trigger_psoc_comp_priv_object_creation(
512 		struct wlan_objmgr_psoc *psoc,
513 		enum wlan_umac_comp_id id);
514 
515 /**
516  * wlan_objmgr_trigger_psoc_comp_priv_object_deletion() - destroy
517  * psoc comp object
518  * @psoc: PSOC object
519  * @id: Component id
520  *
521  * API to destroy component private object in run time, this would
522  * be used for features which gets disabled in run time
523  *
524  * Return: SUCCESS on successful deletion
525  *         On FAILURE (appropriate failure codes are returned)
526  */
527 QDF_STATUS wlan_objmgr_trigger_psoc_comp_priv_object_deletion(
528 		struct wlan_objmgr_psoc *psoc,
529 		enum wlan_umac_comp_id id);
530 
531 /**
532  * wlan_objmgr_get_peer_by_mac() - find peer from psoc's peer list
533  * @psoc: PSOC object
534  * @macaddr: MAC address
535  * @dbg_id: id of the caller
536  *
537  * API to find peer object pointer by MAC addr
538  *
539  * This API increments the ref count of the peer object internally, the
540  * caller has to invoke the wlan_objmgr_peer_release_ref() to decrement
541  * ref count
542  *
543  * Return: peer pointer
544  *         NULL on FAILURE
545  */
546 struct wlan_objmgr_peer *wlan_objmgr_get_peer_by_mac(
547 		struct wlan_objmgr_psoc *psoc, uint8_t *macaddr,
548 		wlan_objmgr_ref_dbgid dbg_id);
549 
550 /**
551  * wlan_objmgr_get_peer() - find peer from psoc's peer list
552  * @psoc: PSOC object
553  * @pdev_id: Pdev id
554  * @macaddr: MAC address
555  * @dbg_id: id of the caller
556  *
557  * API to find peer object pointer by MAC addr and pdev id
558  *
559  * This API increments the ref count of the peer object internally, the
560  * caller has to invoke the wlan_objmgr_peer_release_ref() to decrement
561  * ref count
562  *
563  * Return: peer pointer
564  *         NULL on FAILURE
565  */
566 struct wlan_objmgr_peer *wlan_objmgr_get_peer(
567 			struct wlan_objmgr_psoc *psoc, uint8_t pdev_id,
568 			uint8_t *macaddr, wlan_objmgr_ref_dbgid dbg_id);
569 
570 /**
571  * wlan_objmgr_get_peer_nolock() - find peer from psoc's peer list (lock free)
572  * @psoc: PSOC object
573  * @pdev_id: Pdev id
574  * @macaddr: MAC address
575  * @dbg_id: id of the caller
576  *
577  * API to find peer object pointer by MAC addr
578  *
579  * This API increments the ref count of the peer object internally, the
580  * caller has to invoke the wlan_objmgr_peer_release_ref() to decrement
581  * ref count
582  *
583  * Return: peer pointer
584  *         NULL on FAILURE
585  */
586 struct wlan_objmgr_peer *wlan_objmgr_get_peer_nolock(
587 			struct wlan_objmgr_psoc *psoc, uint8_t pdev_id,
588 			uint8_t *macaddr, wlan_objmgr_ref_dbgid dbg_id);
589 
590 /**
591  * wlan_objmgr_get_peer_logically_deleted() - find peer
592  * from psoc's peer list
593  * @psoc: PSOC object
594  * @macaddr: MAC address
595  * @dbg_id: id of the caller
596  *
597  * API to find peer object pointer of logically deleted peer
598  *
599  * This API increments the ref count of the peer object internally, the
600  * caller has to invoke the wlan_objmgr_peer_release_ref() to decrement
601  * ref count
602  *
603  * Return: peer pointer
604  *         NULL on FAILURE
605  */
606 struct wlan_objmgr_peer *wlan_objmgr_get_peer_logically_deleted(
607 			struct wlan_objmgr_psoc *psoc, uint8_t *macaddr,
608 			wlan_objmgr_ref_dbgid dbg_id);
609 
610 /**
611  * wlan_objmgr_get_peer_no_state() - find peer from psoc's peer list
612  * @psoc: PSOC object
613  * @pdev_id: Pdev id
614  * @macaddr: MAC address
615  * @dbg_id: id of the caller
616  *
617  * API to find peer object pointer by MAC addr and pdev id,
618  * ignores the state check
619  *
620  * This API increments the ref count of the peer object internally, the
621  * caller has to invoke the wlan_objmgr_peer_release_ref() to decrement
622  * ref count
623  *
624  * Return: peer pointer
625  *         NULL on FAILURE
626  */
627 struct wlan_objmgr_peer *wlan_objmgr_get_peer_no_state(
628 			struct wlan_objmgr_psoc *psoc, uint8_t pdev_id,
629 			uint8_t *macaddr, wlan_objmgr_ref_dbgid dbg_id);
630 
631 /**
632  * wlan_objmgr_populate_logically_deleted_peerlist_by_mac_n_vdev() - get peer from
633  *                                                psoc peer list using
634  *                                                mac and vdev
635  *                                                self mac
636  * @psoc: PSOC object
637  * @pdev_id: Pdev id
638  * @bssid: BSSID address
639  * @macaddr: MAC address
640  * @dbg_id: id of the caller
641  *
642  * API to find peer object pointer by MAC addr, vdev self mac
643  * address and pdev id for a node that is logically in deleted state
644  *
645  * This API increments the ref count of the peer object internally, the
646  * caller has to invoke the wlan_objmgr_peer_release_ref() to decrement
647  * ref count
648  *
649  * Return: List of peer pointers
650  *         NULL on FAILURE
651  */
652 qdf_list_t *wlan_objmgr_populate_logically_deleted_peerlist_by_mac_n_vdev(
653 			struct wlan_objmgr_psoc *psoc, uint8_t pdev_id,
654 			uint8_t *bssid, uint8_t *macaddr,
655 			wlan_objmgr_ref_dbgid dbg_id);
656 
657 /**
658  * wlan_objmgr_get_peer_by_mac_n_vdev() - find peer from psoc's peer list
659  *                                          using mac address and bssid
660  * @psoc: PSOC object
661  * @pdev_id: Pdev id
662  * @bssid: MAC address of AP its associated
663  * @macaddr: MAC address
664  * @dbg_id: id of the caller
665  *
666  * API to find peer object pointer by MAC addr and vdev self mac address
667  * and pdev id
668  *
669  * This API increments the ref count of the peer object internally, the
670  * caller has to invoke the wlan_objmgr_peer_release_ref() to decrement
671  * ref count
672  *
673  * Return: peer pointer
674  *         NULL on FAILURE
675  */
676 struct wlan_objmgr_peer *wlan_objmgr_get_peer_by_mac_n_vdev(
677 			struct wlan_objmgr_psoc *psoc, uint8_t pdev_id,
678 			uint8_t *bssid, uint8_t *macaddr,
679 			wlan_objmgr_ref_dbgid dbg_id);
680 
681 /**
682  * wlan_objmgr_get_peer_by_mac_n_vdev_no_state() - find peer from psoc's peer
683  *                                          list using mac address and bssid
684  * @psoc: PSOC object
685  * @pdev_id: Pdev id
686  * @bssid: MAC address of AP its associated
687  * @macaddr: MAC address
688  * @dbg_id: id of the caller
689  *
690  * API to find peer object pointer by MAC addr, vdev self mac address,
691  * and pdev id ,ignores the state
692  *
693  * This API increments the ref count of the peer object internally, the
694  * caller has to invoke the wlan_objmgr_peer_release_ref() to decrement
695  * ref count
696  *
697  * Return: peer pointer
698  *         NULL on FAILURE
699  */
700 struct wlan_objmgr_peer *wlan_objmgr_get_peer_by_mac_n_vdev_no_state(
701 			struct wlan_objmgr_psoc *psoc, uint8_t pdev_id,
702 			uint8_t *bssid,  uint8_t *macaddr,
703 			wlan_objmgr_ref_dbgid dbg_id);
704 
705 /**
706  * wlan_objmgr_get_pdev_by_id() - retrieve pdev by id
707  * @psoc: PSOC object
708  * @id: pdev id
709  * @dbg_id: id of the caller
710  *
711  * API to find pdev object pointer by pdev id
712  *
713  * This API increments the ref count of the pdev object internally, the
714  * caller has to invoke the wlan_objmgr_pdev_release_ref() to decrement
715  * ref count
716  *
717  * Return: pdev pointer
718  *         NULL on FAILURE
719  */
720 struct wlan_objmgr_pdev *wlan_objmgr_get_pdev_by_id(
721 		struct wlan_objmgr_psoc *psoc, uint8_t id,
722 		wlan_objmgr_ref_dbgid dbg_id);
723 
724 /**
725  * wlan_objmgr_get_pdev_by_id_no_state() - retrieve pdev by id
726  * @psoc: PSOC object
727  * @id: pdev id
728  * @dbg_id: id of the caller
729  *
730  * API to find pdev object pointer by pdev id, Ignores the state check
731  *
732  * This API increments the ref count of the pdev object internally, the
733  * caller has to invoke the wlan_objmgr_pdev_release_ref() to decrement
734  * ref count
735  *
736  * Return: pdev pointer
737  *         NULL on FAILURE
738  */
739 struct wlan_objmgr_pdev *wlan_objmgr_get_pdev_by_id_no_state(
740 			struct wlan_objmgr_psoc *psoc, uint8_t id,
741 			wlan_objmgr_ref_dbgid dbg_id);
742 
743 /**
744  * wlan_objmgr_get_pdev_by_macaddr() - retrieve pdev by macaddr
745  * @psoc: PSOC object
746  * @macaddr: MAC address
747  * @dbg_id: id of the caller
748  *
749  * API to find pdev object pointer by pdev macaddr
750  *
751  * This API increments the ref count of the pdev object internally, the
752  * caller has to invoke the wlan_objmgr_pdev_release_ref() to decrement
753  * ref count
754  *
755  * Return: pdev pointer
756  *         NULL on FAILURE
757  */
758 struct wlan_objmgr_pdev *wlan_objmgr_get_pdev_by_macaddr(
759 		struct wlan_objmgr_psoc *psoc, uint8_t *macaddr,
760 		wlan_objmgr_ref_dbgid dbg_id);
761 
762 /**
763  * wlan_objmgr_get_pdev_by_macaddr_no_state() - retrieve pdev by macaddr
764  * @psoc: PSOC object
765  * @macaddr: MAC address
766  * @dbg_id: id of the caller
767  *
768  * API to find pdev object pointer by pdev macaddr, ignores the state check
769  *
770  * This API increments the ref count of the pdev object internally, the
771  * caller has to invoke the wlan_objmgr_pdev_release_ref() to decrement
772  * ref count
773  *
774  * Return: pdev pointer
775  *         NULL on FAILURE
776  */
777 struct wlan_objmgr_pdev *wlan_objmgr_get_pdev_by_macaddr_no_state(
778 		struct wlan_objmgr_psoc *psoc, uint8_t *macaddr,
779 		wlan_objmgr_ref_dbgid dbg_id);
780 
781 /**
782  * wlan_objmgr_get_vdev_by_opmode_from_psoc() - retrieve vdev by opmode
783  * @psoc: PSOC object
784  * @opmode: vdev operating mode
785  * @dbg_id: id of the caller
786  *
787  * API to find vdev object pointer by vdev operating mode from psoc
788  *
789  * This API increments the ref count of the vdev object internally, the
790  * caller has to invoke the wlan_objmgr_vdev_release_ref() to decrement
791  * ref count
792  *
793  * Return: vdev pointer
794  *         NULL on FAILURE
795  */
796 struct wlan_objmgr_vdev *wlan_objmgr_get_vdev_by_opmode_from_psoc(
797 			struct wlan_objmgr_psoc *psoc,
798 			enum QDF_OPMODE opmode,
799 			wlan_objmgr_ref_dbgid dbg_id);
800 
801 /**
802  * wlan_objmgr_get_vdev_by_id_from_psoc() - retrieve vdev by id
803  * @psoc: PSOC object
804  * @id: vdev id
805  * @dbg_id: id of the caller
806  *
807  * API to find vdev object pointer by vdev id from psoc
808  *
809  * This API increments the ref count of the vdev object internally, the
810  * caller has to invoke the wlan_objmgr_vdev_release_ref() to decrement
811  * ref count
812  *
813  * Return: vdev pointer
814  *         NULL on FAILURE
815  */
816 struct wlan_objmgr_vdev *wlan_objmgr_get_vdev_by_id_from_psoc(
817 			struct wlan_objmgr_psoc *psoc, uint8_t vdev_id,
818 			wlan_objmgr_ref_dbgid dbg_id);
819 
820 /**
821  * wlan_objmgr_get_vdev_by_id_from_psoc_no_state() - retrieve vdev by id
822  * @psoc: PSOC object
823  * @id: vdev id
824  * @dbg_id: id of the caller
825  *
826  * API to find vdev object pointer by vdev id from psoc, ignores the
827  * state check
828  *
829  * This API increments the ref count of the vdev object internally, the
830  * caller has to invoke the wlan_objmgr_vdev_release_ref() to decrement
831  * ref count
832  *
833  * Return: vdev pointer
834  *         NULL on FAILURE
835  */
836 struct wlan_objmgr_vdev *wlan_objmgr_get_vdev_by_id_from_psoc_no_state(
837 			struct wlan_objmgr_psoc *psoc, uint8_t vdev_id,
838 			wlan_objmgr_ref_dbgid dbg_id);
839 
840 /**
841  * wlan_objmgr_get_vdev_by_macaddr_from_psoc() - retrieve vdev by macaddr
842  * @psoc: PSOC object
843  * @pdev_id: Pdev id
844  * @macaddr: macaddr
845  * @dbg_id: id of the caller
846  *
847  * API to find vdev object pointer by vdev macaddr from pdev
848  *
849  * This API increments the ref count of the vdev object internally, the
850  * caller has to invoke the wlan_objmgr_vdev_release_ref() to decrement
851  * ref count
852  *
853  * Return: vdev pointer
854  *         NULL on FAILURE
855  */
856 struct wlan_objmgr_vdev *wlan_objmgr_get_vdev_by_macaddr_from_psoc(
857 		struct wlan_objmgr_psoc *psoc, uint8_t pdev_id,
858 		uint8_t *macaddr, wlan_objmgr_ref_dbgid dbg_id);
859 
860 /**
861  * wlan_objmgr_get_vdev_by_macaddr_from_psoc_no_state() - retrieve vdev by
862  *                                                           macaddr
863  * @psoc: PSOC object
864  * @pdev_id: Pdev id
865  * @macaddr: macaddr
866  * @dbg_id: id of the caller
867  *
868  * API to find vdev object pointer by vdev macaddr from psoc, ignores the state
869  * check
870  *
871  * This API increments the ref count of the vdev object internally, the
872  * caller has to invoke the wlan_objmgr_vdev_release_ref() to decrement
873  * ref count
874  *
875  * Return: vdev pointer
876  *         NULL on FAILURE
877  */
878 struct wlan_objmgr_vdev *wlan_objmgr_get_vdev_by_macaddr_from_psoc_no_state(
879 		struct wlan_objmgr_psoc *psoc, uint8_t pdev_id,
880 		uint8_t *macaddr, wlan_objmgr_ref_dbgid dbg_id);
881 
882 /**
883  * wlan_psoc_obj_lock() - Acquire PSOC spinlock
884  * @psoc: PSOC object
885  *
886  * API to acquire PSOC lock
887  * Parent lock should not be taken in child lock context
888  * but child lock can be taken in parent lock context
889  * (for ex: psoc lock can't be invoked in pdev/vdev/peer lock context)
890  *
891  * Return: void
892  */
893 static inline void wlan_psoc_obj_lock(struct wlan_objmgr_psoc *psoc)
894 {
895 	qdf_spin_lock_bh(&psoc->psoc_lock);
896 }
897 
898 /**
899  * wlan_psoc_obj_unlock() - Release PSOC spinlock
900  * @psoc: PSOC object
901  *
902  * API to Release PSOC lock
903  *
904  * Return: void
905  */
906 static inline void wlan_psoc_obj_unlock(struct wlan_objmgr_psoc *psoc)
907 {
908 	qdf_spin_unlock_bh(&psoc->psoc_lock);
909 }
910 
911 /**
912  * wlan_psoc_set_nif_phy_version() - set nif phy version
913  * @psoc: PSOC object
914  * @phy_ver: phy version
915  *
916  * API to set nif phy version in psoc
917  *
918  * Return: void
919  */
920 static inline void wlan_psoc_set_nif_phy_version(struct wlan_objmgr_psoc *psoc,
921 			uint32_t phy_ver)
922 {
923 	psoc->soc_nif.phy_version = phy_ver;
924 }
925 
926 /**
927  * wlan_psoc_get_nif_phy_version() - get nif phy version
928  * @psoc: PSOC object
929  *
930  * API to set nif phy version in psoc
931  *
932  * Return: @phy_ver: phy version
933  */
934 static inline uint32_t wlan_psoc_get_nif_phy_version(
935 			struct wlan_objmgr_psoc *psoc)
936 {
937 	if (psoc == NULL)
938 		return (uint32_t)-1;
939 
940 	return psoc->soc_nif.phy_version;
941 }
942 
943 /**
944  * wlan_psoc_set_dev_type() - set dev type
945  * @psoc: PSOC object
946  * @phy_type: phy type (OL/DA)
947  *
948  * API to set dev type in psoc
949  *
950  * Return: void
951  */
952 static inline void wlan_psoc_set_dev_type(struct wlan_objmgr_psoc *psoc,
953 				WLAN_DEV_TYPE phy_type)
954 {
955 	psoc->soc_nif.phy_type = phy_type;
956 }
957 
958 /**
959  * wlan_objmgr_psoc_get_dev_type - get dev type
960  * @psoc: PSOC object
961  *
962  * API to get dev type in psoc
963  *
964  * Return: phy type (OL/DA)
965  */
966 static inline WLAN_DEV_TYPE wlan_objmgr_psoc_get_dev_type(
967 				struct wlan_objmgr_psoc *psoc)
968 {
969 	if (psoc == NULL)
970 		return (uint32_t)-1;
971 
972 	return psoc->soc_nif.phy_type;
973 }
974 
975 /**
976  * wlan_psoc_nif_fw_cap_set() - set fw caps
977  * @psoc: PSOC object
978  * @cap: capability flag to be set
979  *
980  * API to set fw caps in psoc
981  *
982  * Return: void
983  */
984 static inline void wlan_psoc_nif_fw_cap_set(struct wlan_objmgr_psoc *psoc,
985 					uint32_t cap)
986 {
987 	psoc->soc_nif.soc_fw_caps |= cap;
988 }
989 
990 /**
991  * wlan_psoc_nif_fw_cap_clear() - clear fw caps
992  * @psoc: PSOC object
993  * @cap: capability flag to be cleared
994  *
995  * API to clear fw caps in psoc
996  *
997  * Return: void
998  */
999 static inline void wlan_psoc_nif_fw_cap_clear(struct wlan_objmgr_psoc *psoc,
1000 				uint32_t cap)
1001 {
1002 	psoc->soc_nif.soc_fw_caps &= ~cap;
1003 }
1004 
1005 /**
1006  * wlan_psoc_nif_fw_cap_get() - get fw caps
1007  * @psoc: PSOC object
1008  * @cap: capability flag to be checked
1009  *
1010  * API to know, whether particular fw caps flag is set in psoc
1011  *
1012  * Return: 1 (for set) or 0 (for not set)
1013  */
1014 static inline uint8_t wlan_psoc_nif_fw_cap_get(struct wlan_objmgr_psoc *psoc,
1015 				uint32_t cap)
1016 {
1017 	return (psoc->soc_nif.soc_fw_caps & cap) ? 1 : 0;
1018 }
1019 
1020 /**
1021  * wlan_psoc_nif_fw_ext_cap_set() - set fw ext caps
1022  * @psoc: PSOC object
1023  * @ext_cap: capability flag to be set
1024  *
1025  * API to set fw ext caps in psoc
1026  *
1027  * Return: void
1028  */
1029 static inline void wlan_psoc_nif_fw_ext_cap_set(struct wlan_objmgr_psoc *psoc,
1030 				uint32_t ext_cap)
1031 {
1032 	psoc->soc_nif.soc_fw_ext_caps |= ext_cap;
1033 }
1034 
1035 /**
1036  * wlan_psoc_nif_fw_ext_cap_clear() - clear fw ext caps
1037  * @psoc: PSOC object
1038  * @ext_cap: capability flag to be cleared
1039  *
1040  * API to clear fw ext caps in psoc
1041  *
1042  * Return: void
1043  */
1044 static inline void wlan_psoc_nif_fw_ext_cap_clear(struct wlan_objmgr_psoc *psoc,
1045 				uint32_t ext_cap)
1046 {
1047 	psoc->soc_nif.soc_fw_ext_caps &= ~ext_cap;
1048 }
1049 
1050 /**
1051  * wlan_psoc_nif_fw_ext_cap_get() - get fw caps
1052  * @psoc: PSOC object
1053  * @ext_cap: capability flag to be checked
1054  *
1055  * API to know, whether particular fw caps flag is set in psoc
1056  *
1057  * Return: 1 (for set) or 0 (for not set)
1058  */
1059 static inline uint8_t wlan_psoc_nif_fw_ext_cap_get(
1060 		struct wlan_objmgr_psoc *psoc, uint32_t ext_cap)
1061 {
1062 	return (psoc->soc_nif.soc_fw_ext_caps & ext_cap) ? 1 : 0;
1063 }
1064 
1065 /**
1066  * wlan_psoc_nif_feat_cap_set() - set feature caps
1067  * @psoc: PSOC object
1068  * @cap: feature flag to be set
1069  *
1070  * API to set feature caps in psoc
1071  *
1072  * Return: void
1073  */
1074 static inline void wlan_psoc_nif_feat_cap_set(struct wlan_objmgr_psoc *psoc,
1075 				uint32_t feat_cap)
1076 {
1077 	psoc->soc_nif.soc_feature_caps |= feat_cap;
1078 }
1079 
1080 /**
1081  * wlan_psoc_nif_feat_cap_clear() - clear feature caps
1082  * @psoc: PSOC object
1083  * @cap: feature flag to be cleared
1084  *
1085  * API to clear feature caps in psoc
1086  *
1087  * Return: void
1088  */
1089 static inline void wlan_psoc_nif_feat_cap_clear(struct wlan_objmgr_psoc *psoc,
1090 				uint32_t feat_cap)
1091 {
1092 	psoc->soc_nif.soc_feature_caps &= ~feat_cap;
1093 }
1094 
1095 /**
1096  * wlan_psoc_nif_feat_cap_get() - get feature caps
1097  * @psoc: PSOC object
1098  * @cap: feature flag to be checked
1099  *
1100  * API to know, whether particular feature cap flag is set in psoc
1101  *
1102  * Return: 1 (for set) or 0 (for not set)
1103  */
1104 static inline uint8_t wlan_psoc_nif_feat_cap_get(struct wlan_objmgr_psoc *psoc,
1105 							uint32_t feat_cap)
1106 {
1107 	return (psoc->soc_nif.soc_feature_caps & feat_cap) ? 1 : 0;
1108 }
1109 
1110 /**
1111  * wlan_psoc_nif_op_flag_get() - get op flags
1112  * @psoc: PSOC object
1113  * @flag: op flag to be checked
1114  *
1115  * API to know, whether particular op flag is set in psoc
1116  *
1117  * Return: 1 (for set) or 0 (for not set)
1118  */
1119 static inline uint8_t wlan_psoc_nif_op_flag_get(struct wlan_objmgr_psoc *psoc,
1120 						uint32_t flag)
1121 {
1122 	return (psoc->soc_nif.soc_op_flags & flag) ? 1 : 0;
1123 }
1124 
1125 /**
1126  * wlan_psoc_nif_op_flag_set() - set op flag
1127  * @psoc: PSOC object
1128  * @flag: op flag to be set
1129  *
1130  * API to set op flag in psoc
1131  *
1132  * Return: void
1133  */
1134 static inline void wlan_psoc_nif_op_flag_set(struct wlan_objmgr_psoc *psoc,
1135 						uint32_t flag)
1136 {
1137 	psoc->soc_nif.soc_op_flags |= flag;
1138 }
1139 
1140 /**
1141  * wlan_psoc_nif_op_flag_clear() - clear op flag
1142  * @psoc: PSOC object
1143  * @flag: op flag to be cleared
1144  *
1145  * API to clear op flag in psoc
1146  *
1147  * Return: void
1148  */
1149 static inline void wlan_psoc_nif_op_flag_clear(struct wlan_objmgr_psoc *psoc,
1150 						uint32_t flag)
1151 {
1152 	psoc->soc_nif.soc_op_flags &= ~flag;
1153 }
1154 
1155 /**
1156  * wlan_psoc_set_hw_macaddr() - set hw mac addr
1157  * @psoc: PSOC object
1158  * @macaddr: hw macaddr
1159  *
1160  * API to set hw macaddr of psoc
1161  *
1162  * Caller need to acquire lock with wlan_psoc_obj_lock()
1163  *
1164  * Return: void
1165  */
1166 static inline void wlan_psoc_set_hw_macaddr(struct wlan_objmgr_psoc *psoc,
1167 					uint8_t *macaddr)
1168 {
1169 	/* This API is invoked with lock acquired, do not add log prints */
1170 	if (psoc != NULL)
1171 		WLAN_ADDR_COPY(psoc->soc_nif.soc_hw_macaddr, macaddr);
1172 }
1173 
1174 /**
1175  * wlan_psoc_get_hw_macaddr() - get hw macaddr
1176  * @psoc: PSOC object
1177  *
1178  * API to set hw macaddr of psoc
1179  *
1180  * Return: hw macaddr
1181  */
1182 static inline uint8_t *wlan_psoc_get_hw_macaddr(struct wlan_objmgr_psoc *psoc)
1183 {
1184 	if (psoc == NULL)
1185 		return NULL;
1186 
1187 	return psoc->soc_nif.soc_hw_macaddr;
1188 }
1189 
1190 /**
1191  * wlan_objmgr_psoc_get_comp_private_obj(): API to retrieve component object
1192  * @psoc: Psoc pointer
1193  * @id: component id
1194  *
1195  * This API is used to get the component private object pointer tied to the
1196  * corresponding psoc object
1197  *
1198  * Return: Component private object
1199  */
1200 void *wlan_objmgr_psoc_get_comp_private_obj(struct wlan_objmgr_psoc *psoc,
1201 					enum wlan_umac_comp_id id);
1202 /**
1203  * wlan_psoc_get_pdev_count() - get pdev count for psoc
1204  * @psoc: PSOC object
1205  *
1206  * API to get number of pdev's attached to the psoc
1207  *
1208  * Return: number of pdev's
1209  */
1210 static inline uint8_t wlan_psoc_get_pdev_count(struct wlan_objmgr_psoc *psoc)
1211 {
1212 	if (psoc == NULL)
1213 		return 0;
1214 
1215 	return psoc->soc_objmgr.wlan_pdev_count;
1216 }
1217 
1218 /**
1219  * wlan_psoc_set_tgt_if_handle(): API to set target if handle in psoc object
1220  * @psoc: Psoc pointer
1221  * @tgt_if_handle: target interface handle
1222  *
1223  * API to set target interface handle in psoc object
1224  *
1225  * Return: None
1226  */
1227 static inline void wlan_psoc_set_tgt_if_handle(struct wlan_objmgr_psoc *psoc,
1228 			void *tgt_if_handle)
1229 {
1230 	if (psoc == NULL)
1231 		return;
1232 
1233 	psoc->tgt_if_handle = tgt_if_handle;
1234 }
1235 
1236 /**
1237  * wlan_psoc_get_tgt_if_handle(): API to get target interface handle
1238  * @psoc: Psoc pointer
1239  *
1240  * API to get target interface handle from psoc object
1241  *
1242  * Return: target interface handle
1243  */
1244 static inline void *wlan_psoc_get_tgt_if_handle(struct wlan_objmgr_psoc *psoc)
1245 {
1246 	if (psoc == NULL)
1247 		return NULL;
1248 
1249 	return psoc->tgt_if_handle;
1250 }
1251 
1252 /**
1253  * wlan_psoc_get_qdf_dev(): API to get qdf device
1254  * @psoc: Psoc pointer
1255  *
1256  * API to get qdf device from psoc object
1257  *
1258  * Return: qdf_device_t
1259  */
1260 static inline qdf_device_t wlan_psoc_get_qdf_dev(
1261 			struct wlan_objmgr_psoc *psoc)
1262 {
1263 	if (psoc == NULL)
1264 		return NULL;
1265 
1266 	return psoc->soc_objmgr.qdf_dev;
1267 }
1268 
1269 /**
1270  * wlan_psoc_set_qdf_dev(): API to get qdf device
1271  * @psoc: Psoc pointer
1272  * dev: qdf device
1273  *
1274  * API to set qdf device from psoc object
1275  *
1276  * Return: None
1277  */
1278 static inline void wlan_psoc_set_qdf_dev(
1279 			struct wlan_objmgr_psoc *psoc,
1280 			qdf_device_t dev)
1281 {
1282 	if (psoc == NULL)
1283 		return;
1284 
1285 	psoc->soc_objmgr.qdf_dev = dev;
1286 }
1287 
1288 /**
1289  * wlan_psoc_set_max_vdev_count() - set psoc max vdev count
1290  * @psoc: PSOC object
1291  * @vdev count: Max vdev count
1292  *
1293  * API to set Max vdev count
1294  *
1295  * Return: void
1296  */
1297 static inline void wlan_psoc_set_max_vdev_count(struct wlan_objmgr_psoc *psoc,
1298 						uint8_t max_vdev_count)
1299 {
1300 	psoc->soc_objmgr.max_vdev_count = max_vdev_count;
1301 }
1302 
1303 /**
1304  * wlan_psoc_get_max_vdev_count() - get psoc max vdev count
1305  * @psoc: PSOC object
1306  *
1307  * API to set Max vdev count
1308  *
1309  * Return: @vdev count: Max vdev count
1310  */
1311 static inline uint8_t wlan_psoc_get_max_vdev_count(
1312 					struct wlan_objmgr_psoc *psoc)
1313 {
1314 	return psoc->soc_objmgr.max_vdev_count;
1315 }
1316 
1317 /**
1318  * wlan_psoc_set_max_peer_count() - set psoc max peer count
1319  * @psoc: PSOC object
1320  * @peer count: Max peer count
1321  *
1322  * API to set Max peer count
1323  *
1324  * Return: void
1325  */
1326 static inline void wlan_psoc_set_max_peer_count(struct wlan_objmgr_psoc *psoc,
1327 						uint16_t max_peer_count)
1328 {
1329 	psoc->soc_objmgr.max_peer_count = max_peer_count;
1330 }
1331 
1332 /**
1333  * wlan_psoc_get_max_peer_count() - get psoc max peer count
1334  * @psoc: PSOC object
1335  *
1336  * API to set Max peer count
1337  *
1338  * Return: @peer count: Max peer count
1339  */
1340 static inline uint16_t wlan_psoc_get_max_peer_count(
1341 					struct wlan_objmgr_psoc *psoc)
1342 {
1343 	return psoc->soc_objmgr.max_peer_count;
1344 }
1345 
1346 /**
1347  * wlan_psoc_get_peer_count() - get psoc peer count
1348  * @psoc: PSOC object
1349  *
1350  * API to get peer count
1351  *
1352  * Return: @peer count: peer count
1353  */
1354 static inline uint16_t wlan_psoc_get_peer_count(
1355 					struct wlan_objmgr_psoc *psoc)
1356 {
1357 	return psoc->soc_objmgr.wlan_peer_count;
1358 }
1359 
1360 
1361 /**
1362  * DOC: Examples to use PSOC ref count APIs
1363  *
1364  * In all the scenarios, the pair of API should be followed
1365  * other it lead to memory leak
1366  *
1367  *  scenario 1:
1368  *
1369  *     wlan_objmgr_psoc_obj_create()
1370  *     ----
1371  *     wlan_objmgr_psoc_obj_delete()
1372  *
1373  *  scenario 2:
1374  *
1375  *     wlan_objmgr_psoc_get_ref()
1376  *     ----
1377  *     the operations which are done on
1378  *     psoc object
1379  *     ----
1380  *     wlan_objmgr_psoc_release_ref()
1381  */
1382 
1383 /**
1384  * wlan_objmgr_psoc_get_ref() - increment ref count
1385  * @psoc: PSOC object
1386  * @id:   Object Manager ref debug id
1387  *
1388  * API to increment ref count of psoc
1389  *
1390  * Return: void
1391  */
1392 void wlan_objmgr_psoc_get_ref(struct wlan_objmgr_psoc *psoc,
1393 					wlan_objmgr_ref_dbgid id);
1394 
1395 /**
1396  * wlan_objmgr_psoc_try_get_ref() - increment ref count, if allowed
1397  * @psoc: PSOC object
1398  * @id:   Object Manager ref debug id
1399  *
1400  * API to increment ref count after checking valid object state
1401  *
1402  * Return: void
1403  */
1404 QDF_STATUS wlan_objmgr_psoc_try_get_ref(struct wlan_objmgr_psoc *psoc,
1405 						wlan_objmgr_ref_dbgid id);
1406 
1407 /**
1408  * wlan_objmgr_psoc_release_ref() - decrement ref count
1409  * @psoc: PSOC object
1410  * @id:   Object Manager ref debug id
1411  *
1412  * API to decrement ref count of psoc, if ref count is 1, it initiates the
1413  * PSOC deletion
1414  *
1415  * Return: void
1416  */
1417 void wlan_objmgr_psoc_release_ref(struct wlan_objmgr_psoc *psoc,
1418 						wlan_objmgr_ref_dbgid id);
1419 
1420 /**
1421  * wlan_objmgr_print_ref_all_objects_per_psoc() - print all psoc objects'
1422  *                                                ref counts
1423  * @psoc: PSOC object
1424  *
1425  * API to be used for printing all the objects(pdev/vdev/peer) ref counts
1426  *
1427  * Return: SUCCESS/FAILURE
1428  */
1429 QDF_STATUS wlan_objmgr_print_ref_all_objects_per_psoc(
1430 		struct wlan_objmgr_psoc *psoc);
1431 
1432 /**
1433 * wlan_objmgr_psoc_set_user_config () - populate user config
1434 * data in psoc
1435 * @psoc: psoc object pointer
1436 * @user_config_data: pointer to user config data filled up by os
1437 *                  dependent component
1438 * it is intended to set all elements by OSIF/HDD and it not
1439 * intended to modify a single element
1440 * Return: QDF status
1441 */
1442 QDF_STATUS wlan_objmgr_psoc_set_user_config(struct wlan_objmgr_psoc *psoc,
1443 		struct wlan_objmgr_psoc_user_config *user_config_data);
1444 
1445 /**
1446  * wlan_objmgr_psoc_check_for_pdev_leaks() - Assert no pdevs attached to @psoc
1447  * @psoc: The psoc to check
1448  *
1449  * Return: None
1450  */
1451 void wlan_objmgr_psoc_check_for_pdev_leaks(struct wlan_objmgr_psoc *psoc);
1452 
1453 /**
1454  * wlan_objmgr_psoc_check_for_vdev_leaks() - Assert no vdevs attached to @psoc
1455  * @psoc: The psoc to check
1456  *
1457  * Return: None
1458  */
1459 void wlan_objmgr_psoc_check_for_vdev_leaks(struct wlan_objmgr_psoc *psoc);
1460 
1461 /**
1462  * wlan_objmgr_psoc_check_for_peer_leaks() - Assert no peers attached to @psoc
1463  * @psoc: The psoc to check
1464  *
1465  * Return: None
1466  */
1467 void wlan_objmgr_psoc_check_for_peer_leaks(struct wlan_objmgr_psoc *psoc);
1468 
1469 /**
1470 * wlan_objmgr_psoc_get_band_capability () - get user config
1471 * data for band capability
1472 * @psoc: psoc object pointer
1473 *
1474 * Return: band_capability
1475 */
1476 static inline uint8_t wlan_objmgr_psoc_get_band_capability(
1477 		struct wlan_objmgr_psoc *psoc)
1478 {
1479 	if (psoc == NULL)
1480 		return 0;
1481 
1482 	return psoc->soc_nif.user_config.band_capability;
1483 }
1484 
1485 /**
1486  * wlan_psoc_set_dp_handle() - set dp handle
1487  * @psoc: psoc object pointer
1488  * @dp_handle: Data path module handle
1489  *
1490  * Return: void
1491  */
1492 static inline void wlan_psoc_set_dp_handle(struct wlan_objmgr_psoc *psoc,
1493 		void *dp_handle)
1494 {
1495 	if (qdf_unlikely(!psoc)) {
1496 		QDF_BUG(0);
1497 		return;
1498 	}
1499 
1500 	psoc->dp_handle = dp_handle;
1501 }
1502 
1503 /**
1504  * wlan_psoc_get_dp_handle() - get dp handle
1505  * @psoc: psoc object pointer
1506  *
1507  * Return: dp handle
1508  */
1509 static inline void *wlan_psoc_get_dp_handle(struct wlan_objmgr_psoc *psoc)
1510 {
1511 	if (qdf_unlikely(!psoc)) {
1512 		QDF_BUG(0);
1513 		return NULL;
1514 	}
1515 
1516 	return psoc->dp_handle;
1517 }
1518 
1519 struct wlan_logically_del_peer {
1520 	qdf_list_node_t list;
1521 	struct wlan_objmgr_peer *peer;
1522 };
1523 
1524 /**
1525  * wlan_psoc_get_lmac_if_txops() - get lmac if txops for the psoc
1526  * @psoc: psoc object pointer
1527  *
1528  * Return: Pointer to wlan_lmac_if_tx_ops
1529  */
1530 static inline struct wlan_lmac_if_tx_ops *
1531 wlan_psoc_get_lmac_if_txops(struct wlan_objmgr_psoc *psoc)
1532 {
1533 	return &((psoc->soc_cb.tx_ops));
1534 }
1535 #endif /* _WLAN_OBJMGR_PSOC_OBJ_H_*/
1536