xref: /wlan-dirver/qca-wifi-host-cmn/umac/cp_stats/dispatcher/inc/wlan_cp_stats_utils_api.h (revision 06d0b5348967845f004ebe7c2348bf8f467ad2f9)
1 /*
2  * Copyright (c) 2018,2020 The Linux Foundation. All rights reserved.
3  * Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All rights reserved.
4  *
5  * Permission to use, copy, modify, and/or distribute this software for
6  * any purpose with or without fee is hereby granted, provided that the
7  * above copyright notice and this permission notice appear in all
8  * copies.
9  *
10  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
11  * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
12  * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
13  * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
14  * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
15  * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
16  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
17  * PERFORMANCE OF THIS SOFTWARE.
18  */
19 
20 /**
21  * DOC: wlan_cp_stats_utils_api.h
22  *
23  * This header file provide declaration to public APIs exposed for other UMAC
24  * components to init/deinit, (de)register to required WMI events on
25  * soc enable/disable
26  */
27 
28 #ifndef __WLAN_CP_STATS_UTILS_API_H__
29 #define __WLAN_CP_STATS_UTILS_API_H__
30 
31 #ifdef QCA_SUPPORT_CP_STATS
32 #include <wlan_objmgr_cmn.h>
33 #include <wlan_twt_public_structs.h>
34 
35 #define cp_stats_debug(args ...) \
36 		QDF_TRACE_DEBUG(QDF_MODULE_ID_CP_STATS, ## args)
37 #define cp_stats_err(args ...) \
38 		QDF_TRACE_ERROR(QDF_MODULE_ID_CP_STATS, ## args)
39 #define cp_stats_rl_err(args ...) \
40 		QDF_TRACE_ERROR_RL(QDF_MODULE_ID_CP_STATS, ## args)
41 #define cp_stats_nofl_debug(args ...) \
42 		QDF_TRACE_DEBUG_NO_FL(QDF_MODULE_ID_CP_STATS, ## args)
43 /**
44  * enum wlan_cp_stats_cfg_state - State of Object configuration to
45  * indicate whether object has to be attached/detached in cp stats
46  * @WLAN_CP_STATS_OBJ_DETACH: Object has to be detached
47  * @WLAN_CP_STATS_OBJ_ATTACH: Object has to be attached
48  * @WLAN_CP_STATS_OBJ_INVALID: Object is invalid
49  */
50 enum wlan_cp_stats_cfg_state {
51 	WLAN_CP_STATS_OBJ_DETACH = 0,
52 	WLAN_CP_STATS_OBJ_ATTACH = 1,
53 	WLAN_CP_STATS_OBJ_INVALID
54 };
55 
56 /**
57  * enum wlan_cp_stats_comp_id - component id for other umac components
58  * @WLAN_CP_STATS_ATF: ATF component specific id
59  * @WLAN_CP_STATS_MAX_COMPONENTS : Max id of cp stats components
60  */
61 enum wlan_cp_stats_comp_id {
62 	WLAN_CP_STATS_ATF = 0,
63 	WLAN_CP_STATS_MAX_COMPONENTS,
64 };
65 
66 /**
67  * wlan_cp_stats_init(): API to init stats component
68  *
69  * This API is invoked from dispatcher init during all component init.
70  * This API will register all required handlers for psoc, pdev,vdev
71  * and peer object create/delete notification.
72  *
73  * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
74  */
75 QDF_STATUS wlan_cp_stats_init(void);
76 
77 /**
78  * wlan_cp_stats_init(): API to deinit stats component
79  *
80  * This API is invoked from dispatcher deinit during all component deinit.
81  * This API will unregister all required handlers for psoc, pdev,vdev
82  * and peer object create/delete notification.
83  *
84  * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
85  */
86 QDF_STATUS wlan_cp_stats_deinit(void);
87 
88 /**
89  * wlan_cp_stats_open(): API to open cp stats component
90  * @psoc: pointer to psoc
91  *
92  * This API is invoked from dispatcher psoc open.
93  * This API will initialize psoc level cp stats object.
94  *
95  * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
96  */
97 QDF_STATUS wlan_cp_stats_open(struct wlan_objmgr_psoc *psoc);
98 
99 /**
100  * wlan_cp_stats_close(): API to close cp stats component
101  * @psoc: pointer to psoc
102  *
103  * This API is invoked from dispatcher psoc close.
104  * This API will de-initialize psoc level cp stats object.
105  *
106  * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
107  */
108 QDF_STATUS wlan_cp_stats_close(struct wlan_objmgr_psoc *psoc);
109 
110 /**
111  * wlan_cp_stats_enable(): API to enable cp stats component
112  * @psoc: pointer to psoc
113  *
114  * This API is invoked from dispatcher psoc enable.
115  * This API will register cp_stats WMI event handlers.
116  *
117  * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
118  */
119 QDF_STATUS wlan_cp_stats_enable(struct wlan_objmgr_psoc *psoc);
120 
121 /**
122  * wlan_cp_stats_disable(): API to disable cp stats component
123  * @psoc: pointer to psoc
124  *
125  * This API is invoked from dispatcher psoc disable.
126  * This API will unregister cp_stats WMI event handlers.
127  *
128  * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
129  */
130 QDF_STATUS wlan_cp_stats_disable(struct wlan_objmgr_psoc *psoc);
131 
132 /**
133  * wlan_cp_stats_comp_obj_cfg() - public API to umac for
134  * attach/detach
135  * component specific stat obj to cp stats obj
136  * @obj_type: common object type
137  * @cfg_state: config state either to attach of detach
138  * @comp_id: umac component id
139  * @cmn_obj: pointer to common object
140  * @comp_priv_obj: pointer to component specific cp stats object
141  *
142  * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
143  */
144 QDF_STATUS wlan_cp_stats_comp_obj_cfg(
145 		enum wlan_objmgr_obj_type obj_type,
146 		enum wlan_cp_stats_cfg_state cfg_state,
147 		enum wlan_umac_comp_id comp_id,
148 		void *cmn_obj,
149 		void *data);
150 
151 /**
152  * wlan_cp_stats_vdev_mcast_rx_pnerr() - public API to umac for updating
153  * vdev rx_pnerr stats
154  * @vdev: pointer to vdev
155  *
156  * Return: None
157  */
158 void wlan_cp_stats_vdev_mcast_rx_pnerr(struct wlan_objmgr_vdev *vdev);
159 
160 /**
161  * wlan_cp_stats_peer_rx_pnerr() - public API to umac for updating
162  * peer rx_pnerr stats
163  * @peer: pointer to peer
164  *
165  * Return: None
166  */
167 void wlan_cp_stats_peer_rx_pnerr(struct wlan_objmgr_peer *peer);
168 
169 #if defined(WLAN_SUPPORT_TWT) && defined(WLAN_TWT_CONV_SUPPORTED)
170 /**
171  * tgt_cp_stats_twt_get_session_evt_handler() - twt get sessions evt handler
172  * @psoc: pointer to psoc object
173  * @twt_params: twt params
174  *
175  * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
176  */
177 QDF_STATUS
178 tgt_cp_stats_twt_get_session_evt_handler(
179 				struct wlan_objmgr_psoc *psoc,
180 				struct twt_session_stats_info *twt_params);
181 #else
182 static inline QDF_STATUS
183 tgt_cp_stats_twt_get_session_evt_handler(
184 				struct wlan_objmgr_psoc *psoc,
185 				struct twt_session_stats_info *twt_params)
186 {
187 	return QDF_STATUS_E_NOSUPPORT;
188 }
189 #endif
190 
191 #else /* QCA_SUPPORT_CP_STATS */
192 static inline
193 void wlan_cp_stats_vdev_mcast_rx_pnerr(struct wlan_objmgr_vdev *vdev)
194 {}
195 
196 static inline
197 void wlan_cp_stats_peer_rx_pnerr(struct wlan_objmgr_peer *peer)
198 {}
199 
200 #endif /* QCA_SUPPORT_CP_STATS */
201 #endif /* __WLAN_CP_STATS_UTILS_API_H__ */
202