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_deinit(): 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 attach/detach
134  * component specific stat obj to cp stats obj
135  * @obj_type: common object type
136  * @cfg_state: config state either to attach of detach
137  * @comp_id: umac component id
138  * @cmn_obj: pointer to common object
139  * @data: pointer to component specific cp stats object
140  *
141  * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
142  */
143 QDF_STATUS wlan_cp_stats_comp_obj_cfg(
144 		enum wlan_objmgr_obj_type obj_type,
145 		enum wlan_cp_stats_cfg_state cfg_state,
146 		enum wlan_umac_comp_id comp_id,
147 		void *cmn_obj,
148 		void *data);
149 
150 /**
151  * wlan_cp_stats_vdev_mcast_rx_pnerr() - public API to umac for updating
152  * vdev rx_pnerr stats
153  * @vdev: pointer to vdev
154  *
155  * Return: None
156  */
157 void wlan_cp_stats_vdev_mcast_rx_pnerr(struct wlan_objmgr_vdev *vdev);
158 
159 /**
160  * wlan_cp_stats_peer_rx_pnerr() - public API to umac for updating
161  * peer rx_pnerr stats
162  * @peer: pointer to peer
163  *
164  * Return: None
165  */
166 void wlan_cp_stats_peer_rx_pnerr(struct wlan_objmgr_peer *peer);
167 
168 #if defined(WLAN_SUPPORT_TWT) && defined(WLAN_TWT_CONV_SUPPORTED)
169 /**
170  * tgt_cp_stats_twt_get_session_evt_handler() - twt get sessions evt handler
171  * @psoc: pointer to psoc object
172  * @twt_params: twt params
173  *
174  * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
175  */
176 QDF_STATUS
177 tgt_cp_stats_twt_get_session_evt_handler(
178 				struct wlan_objmgr_psoc *psoc,
179 				struct twt_session_stats_info *twt_params);
180 #else
181 static inline QDF_STATUS
tgt_cp_stats_twt_get_session_evt_handler(struct wlan_objmgr_psoc * psoc,struct twt_session_stats_info * twt_params)182 tgt_cp_stats_twt_get_session_evt_handler(
183 				struct wlan_objmgr_psoc *psoc,
184 				struct twt_session_stats_info *twt_params)
185 {
186 	return QDF_STATUS_E_NOSUPPORT;
187 }
188 #endif
189 
190 #else /* QCA_SUPPORT_CP_STATS */
191 static inline
wlan_cp_stats_vdev_mcast_rx_pnerr(struct wlan_objmgr_vdev * vdev)192 void wlan_cp_stats_vdev_mcast_rx_pnerr(struct wlan_objmgr_vdev *vdev)
193 {}
194 
195 static inline
wlan_cp_stats_peer_rx_pnerr(struct wlan_objmgr_peer * peer)196 void wlan_cp_stats_peer_rx_pnerr(struct wlan_objmgr_peer *peer)
197 {}
198 
199 #endif /* QCA_SUPPORT_CP_STATS */
200 #endif /* __WLAN_CP_STATS_UTILS_API_H__ */
201