xref: /wlan-dirver/qca-wifi-host-cmn/dp/inc/cdp_txrx_host_stats.h (revision 4865edfd190c086bbe2c69aae12a8226f877b91e)
1 /*
2  * Copyright (c) 2016-2018 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 /**
20  * @file cdp_txrx_host_stats.h
21  * @brief Define the host data path stats API functions
22  * called by the host control SW and the OS interface module
23  */
24 #ifndef _CDP_TXRX_HOST_STATS_H_
25 #define _CDP_TXRX_HOST_STATS_H_
26 #include "cdp_txrx_handle.h"
27 /**
28  * cdp_host_stats_get: cdp call to get host stats
29  * @soc: SOC handle
30  * @req: Requirement type
31  *
32  * return: 0 for Success, Failure returns error message
33  */
34 static inline int cdp_host_stats_get(ol_txrx_soc_handle soc,
35 		struct cdp_vdev *vdev,
36 		struct ol_txrx_stats_req *req)
37 {
38 	if (!soc || !soc->ops) {
39 		QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
40 				"%s: Invalid Instance", __func__);
41 		QDF_BUG(0);
42 		return 0;
43 	}
44 
45 	if (!soc->ops->host_stats_ops ||
46 	    !soc->ops->host_stats_ops->txrx_host_stats_get)
47 		return 0;
48 
49 	return soc->ops->host_stats_ops->txrx_host_stats_get(vdev, req);
50 }
51 
52 /**
53  * cdp_host_stats_clr: cdp call to clear host stats
54  * @vdev: vdev handle
55  *
56  * return: void
57  */
58 static inline void
59 cdp_host_stats_clr(ol_txrx_soc_handle soc, struct cdp_vdev *vdev)
60 {
61 	if (!soc || !soc->ops) {
62 		QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
63 				"%s: Invalid Instance", __func__);
64 		QDF_BUG(0);
65 		return;
66 	}
67 
68 	if (!soc->ops->host_stats_ops ||
69 	    !soc->ops->host_stats_ops->txrx_host_stats_clr)
70 		return;
71 
72 	soc->ops->host_stats_ops->txrx_host_stats_clr(vdev);
73 }
74 
75 static inline void
76 cdp_host_ce_stats(ol_txrx_soc_handle soc, struct cdp_vdev *vdev)
77 {
78 	if (!soc || !soc->ops) {
79 		QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
80 				"%s: Invalid Instance", __func__);
81 		QDF_BUG(0);
82 		return;
83 	}
84 
85 	if (!soc->ops->host_stats_ops ||
86 	    !soc->ops->host_stats_ops->txrx_host_ce_stats)
87 		return;
88 
89 	soc->ops->host_stats_ops->txrx_host_ce_stats(vdev);
90 }
91 
92 static inline int cdp_stats_publish
93 	(ol_txrx_soc_handle soc, struct cdp_pdev *pdev,
94 	struct ol_txrx_stats *buf)
95 {
96 	if (!soc || !soc->ops) {
97 		QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
98 				"%s: Invalid Instance", __func__);
99 		QDF_BUG(0);
100 		return 0;
101 	}
102 
103 	if (!soc->ops->host_stats_ops ||
104 	    !soc->ops->host_stats_ops->txrx_stats_publish)
105 		return 0;
106 
107 	return soc->ops->host_stats_ops->txrx_stats_publish(pdev, buf);
108 }
109 
110 /**
111  * @brief Enable enhanced stats functionality.
112  *
113  * @param pdev - the physical device object
114  * @return - void
115  */
116 static inline void
117 cdp_enable_enhanced_stats(ol_txrx_soc_handle soc, struct cdp_pdev *pdev)
118 {
119 	if (!soc || !soc->ops) {
120 		QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
121 				"%s: Invalid Instance", __func__);
122 		QDF_BUG(0);
123 		return;
124 	}
125 
126 	if (!soc->ops->host_stats_ops ||
127 	    !soc->ops->host_stats_ops->txrx_enable_enhanced_stats)
128 		return;
129 
130 	soc->ops->host_stats_ops->txrx_enable_enhanced_stats
131 			(pdev);
132 }
133 
134 /**
135  * @brief Disable enhanced stats functionality.
136  *
137  * @param pdev - the physical device object
138  * @return - void
139  */
140 static inline void
141 cdp_disable_enhanced_stats(ol_txrx_soc_handle soc, struct cdp_pdev *pdev)
142 {
143 	if (!soc || !soc->ops) {
144 		QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
145 				"%s: Invalid Instance", __func__);
146 		QDF_BUG(0);
147 		return;
148 	}
149 
150 	if (!soc->ops->host_stats_ops ||
151 	    !soc->ops->host_stats_ops->txrx_disable_enhanced_stats)
152 		return;
153 
154 	soc->ops->host_stats_ops->txrx_disable_enhanced_stats
155 			(pdev);
156 }
157 
158 /**
159  * @brief Get the desired stats from the message.
160  *
161  * @param pdev - the physical device object
162  * @param stats_base - stats buffer received from FW
163  * @param type - stats type.
164  * @return - pointer to requested stat identified by type
165  */
166 static inline uint32_t *cdp_get_stats_base
167 	(ol_txrx_soc_handle soc, struct cdp_pdev *pdev,
168 	uint32_t *stats_base, uint32_t msg_len, uint8_t type)
169 {
170 	if (!soc || !soc->ops) {
171 		QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
172 				"%s: Invalid Instance", __func__);
173 		QDF_BUG(0);
174 		return 0;
175 	}
176 
177 	if (!soc->ops->host_stats_ops ||
178 	    !soc->ops->host_stats_ops->txrx_get_stats_base)
179 		return 0;
180 
181 	return (uint32_t *)soc->ops->host_stats_ops->txrx_get_stats_base
182 			(pdev, stats_base, msg_len, type);
183 }
184 
185 static inline void
186 cdp_tx_print_tso_stats(ol_txrx_soc_handle soc,
187 	struct cdp_vdev *vdev)
188 {
189 	if (!soc || !soc->ops) {
190 		QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
191 				"%s: Invalid Instance", __func__);
192 		QDF_BUG(0);
193 		return;
194 	}
195 
196 	if (!soc->ops->host_stats_ops ||
197 	    !soc->ops->host_stats_ops->tx_print_tso_stats)
198 		return;
199 
200 	soc->ops->host_stats_ops->tx_print_tso_stats(vdev);
201 }
202 
203 static inline void
204 cdp_tx_rst_tso_stats(ol_txrx_soc_handle soc, struct cdp_vdev *vdev)
205 {
206 	if (!soc || !soc->ops) {
207 		QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
208 				"%s: Invalid Instance", __func__);
209 		QDF_BUG(0);
210 		return;
211 	}
212 
213 	if (!soc->ops->host_stats_ops ||
214 	    !soc->ops->host_stats_ops->tx_rst_tso_stats)
215 		return;
216 
217 	soc->ops->host_stats_ops->tx_rst_tso_stats(vdev);
218 }
219 
220 static inline void
221 cdp_tx_print_sg_stats(ol_txrx_soc_handle soc,
222 	struct cdp_vdev *vdev)
223 {
224 	if (!soc || !soc->ops) {
225 		QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
226 				"%s: Invalid Instance", __func__);
227 		QDF_BUG(0);
228 		return;
229 	}
230 
231 	if (!soc->ops->host_stats_ops ||
232 	    !soc->ops->host_stats_ops->tx_print_sg_stats)
233 		return;
234 
235 	soc->ops->host_stats_ops->tx_print_sg_stats(vdev);
236 }
237 
238 static inline void
239 cdp_tx_rst_sg_stats(ol_txrx_soc_handle soc, struct cdp_vdev *vdev)
240 {
241 	if (!soc || !soc->ops) {
242 		QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
243 				"%s: Invalid Instance", __func__);
244 		QDF_BUG(0);
245 		return;
246 	}
247 
248 	if (!soc->ops->host_stats_ops ||
249 	    !soc->ops->host_stats_ops->tx_rst_sg_stats)
250 		return;
251 
252 	soc->ops->host_stats_ops->tx_rst_sg_stats(vdev);
253 }
254 
255 static inline void
256 cdp_print_rx_cksum_stats(ol_txrx_soc_handle soc,
257 	struct cdp_vdev *vdev)
258 {
259 	if (!soc || !soc->ops) {
260 		QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
261 				"%s: Invalid Instance", __func__);
262 		QDF_BUG(0);
263 		return;
264 	}
265 
266 	if (!soc->ops->host_stats_ops ||
267 	    !soc->ops->host_stats_ops->print_rx_cksum_stats)
268 		return;
269 
270 	soc->ops->host_stats_ops->print_rx_cksum_stats(vdev);
271 }
272 
273 static inline void
274 cdp_rst_rx_cksum_stats(ol_txrx_soc_handle soc, struct cdp_vdev *vdev)
275 {
276 	if (!soc || !soc->ops) {
277 		QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
278 				"%s: Invalid Instance", __func__);
279 		QDF_BUG(0);
280 		return;
281 	}
282 
283 	if (!soc->ops->host_stats_ops ||
284 	    !soc->ops->host_stats_ops->rst_rx_cksum_stats)
285 		return;
286 
287 	soc->ops->host_stats_ops->rst_rx_cksum_stats(vdev);
288 }
289 
290 static inline A_STATUS
291 cdp_host_me_stats(ol_txrx_soc_handle soc, struct cdp_vdev *vdev)
292 {
293 	if (!soc || !soc->ops) {
294 		QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
295 				"%s: Invalid Instance", __func__);
296 		QDF_BUG(0);
297 		return 0;
298 	}
299 
300 	if (!soc->ops->host_stats_ops ||
301 	    !soc->ops->host_stats_ops->txrx_host_me_stats)
302 		return 0;
303 
304 	return soc->ops->host_stats_ops->txrx_host_me_stats(vdev);
305 }
306 
307 static inline void cdp_per_peer_stats
308 	(ol_txrx_soc_handle soc, struct cdp_pdev *pdev, char *addr)
309 {
310 	if (!soc || !soc->ops) {
311 		QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
312 				"%s: Invalid Instance", __func__);
313 		QDF_BUG(0);
314 		return;
315 	}
316 
317 	if (!soc->ops->host_stats_ops ||
318 	    !soc->ops->host_stats_ops->txrx_per_peer_stats)
319 		return;
320 
321 	soc->ops->host_stats_ops->txrx_per_peer_stats
322 			(pdev, addr);
323 }
324 
325 static inline int cdp_host_msdu_ttl_stats(ol_txrx_soc_handle soc,
326 	struct cdp_vdev *vdev,
327 	struct ol_txrx_stats_req *req)
328 {
329 	if (!soc || !soc->ops) {
330 		QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
331 				"%s: Invalid Instance", __func__);
332 		QDF_BUG(0);
333 		return 0;
334 	}
335 
336 	if (!soc->ops->host_stats_ops ||
337 	    !soc->ops->host_stats_ops->txrx_host_msdu_ttl_stats)
338 		return 0;
339 
340 	return soc->ops->host_stats_ops->txrx_host_msdu_ttl_stats
341 			(vdev, req);
342 }
343 
344 static inline void
345 cdp_print_lro_stats(ol_txrx_soc_handle soc, struct cdp_vdev *vdev)
346 {
347 	if (!soc || !soc->ops) {
348 		QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
349 				"%s: Invalid Instance", __func__);
350 		QDF_BUG(0);
351 		return;
352 	}
353 
354 	if (!soc->ops->host_stats_ops ||
355 	    !soc->ops->host_stats_ops->print_lro_stats)
356 		return;
357 
358 	soc->ops->host_stats_ops->print_lro_stats(vdev);
359 }
360 
361 static inline void
362 cdp_reset_lro_stats(ol_txrx_soc_handle soc, struct cdp_vdev *vdev)
363 {
364 	if (!soc || !soc->ops) {
365 		QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
366 				"%s: Invalid Instance", __func__);
367 		QDF_BUG(0);
368 		return;
369 	}
370 
371 	if (!soc->ops->host_stats_ops ||
372 	    !soc->ops->host_stats_ops->reset_lro_stats)
373 		return;
374 
375 	soc->ops->host_stats_ops->reset_lro_stats(vdev);
376 }
377 
378 static inline void cdp_get_dp_fw_peer_stats(ol_txrx_soc_handle soc,
379 		struct cdp_pdev *pdev, uint8_t *mac, uint32_t caps)
380 {
381 	if (!soc || !soc->ops) {
382 		QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
383 				"%s: Invalid Instance", __func__);
384 		QDF_BUG(0);
385 		return;
386 	}
387 
388 	if (!soc->ops->host_stats_ops ||
389 	    !soc->ops->host_stats_ops->get_fw_peer_stats)
390 		return;
391 
392 	soc->ops->host_stats_ops->get_fw_peer_stats
393 			(pdev, mac, caps);
394 }
395 
396 static inline void cdp_get_dp_htt_stats(ol_txrx_soc_handle soc,
397 					struct cdp_pdev *pdev,
398 					void *data, uint32_t data_len)
399 {
400 	if (soc && soc->ops && soc->ops->host_stats_ops &&
401 		soc->ops->host_stats_ops->get_htt_stats)
402 		return soc->ops->host_stats_ops->get_htt_stats
403 			(pdev, data, data_len);
404 	return;
405 }
406 
407 /**
408  * @brief Parse the stats header and get the payload from the message.
409  *
410  * @param pdev - the physical device object
411  * @param msg_word - stats buffer received from FW
412  * @param msg_len - length of the message
413  * @param type - place holder for parsed message type
414  * @param status - place holder for parsed message status
415  * @return - pointer to received stat payload
416  */
417 
418 #if defined(QCA_SUPPORT_SON) || defined(ENHANCED_STATS)
419 uint32_t *ol_txrx_get_en_stats_base(struct cdp_pdev *pdev, uint32_t *msg_word,
420     uint32_t msg_len, enum htt_cmn_t2h_en_stats_type *type,  enum htt_cmn_t2h_en_stats_status *status);
421 #endif
422 #endif /* _CDP_TXRX_HOST_STATS_H_ */
423