xref: /wlan-dirver/qca-wifi-host-cmn/dp/inc/cdp_txrx_host_stats.h (revision f28396d060cff5c6519f883cb28ae0116ce479f1)
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
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 #include <wmi_unified_api.h>
28 /**
29  * cdp_host_stats_get: cdp call to get host stats
30  * @soc: SOC handle
31  * @vdev_id: vdev id of vdev
32  * @req: Requirement type
33  *
34  * return: 0 for Success, Failure returns error message
35  */
36 static inline int cdp_host_stats_get(ol_txrx_soc_handle soc,
37 		uint8_t vdev_id,
38 		struct ol_txrx_stats_req *req)
39 {
40 	if (!soc || !soc->ops) {
41 		QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
42 				"%s: Invalid Instance", __func__);
43 		QDF_BUG(0);
44 		return 0;
45 	}
46 
47 	if (!soc->ops->host_stats_ops ||
48 	    !soc->ops->host_stats_ops->txrx_host_stats_get)
49 		return 0;
50 
51 	return soc->ops->host_stats_ops->txrx_host_stats_get(soc, vdev_id, req);
52 }
53 
54 /**
55  * cdp_host_stats_get_ratekbps: cdp call to get rate in kbps
56  * @soc: SOC handle
57  * @preamb: Preamble
58  * @mcs: Modulation and Coding scheme index
59  * @htflag: Flag to identify HT or VHT
60  * @gintval: Gaurd Interval value
61  *
62  * return: 0 for Failure, Returns rate on Success
63  */
64 static inline int cdp_host_stats_get_ratekbps(ol_txrx_soc_handle soc,
65 					      int preamb, int mcs,
66 					      int htflag, int gintval)
67 {
68 	if (!soc || !soc->ops) {
69 		QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
70 			  "%s: Invalid Instance", __func__);
71 		QDF_BUG(0);
72 		return 0;
73 	}
74 
75 	if (!soc->ops->host_stats_ops ||
76 	    !soc->ops->host_stats_ops->txrx_get_ratekbps)
77 		return 0;
78 
79 	return soc->ops->host_stats_ops->txrx_get_ratekbps(preamb,
80 							   mcs, htflag,
81 							   gintval);
82 }
83 
84 /**
85  * cdp_host_stats_clr: cdp call to clear host stats
86  * @soc: soc handle
87  * @vdev_id: vdev handle id
88  *
89  * return: QDF_STATUS
90  */
91 static inline QDF_STATUS
92 cdp_host_stats_clr(ol_txrx_soc_handle soc, uint8_t vdev_id)
93 {
94 	if (!soc || !soc->ops) {
95 		QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
96 				"%s: Invalid Instance", __func__);
97 		QDF_BUG(0);
98 		return QDF_STATUS_E_FAILURE;
99 	}
100 
101 	if (!soc->ops->host_stats_ops ||
102 	    !soc->ops->host_stats_ops->txrx_host_stats_clr)
103 		return QDF_STATUS_E_FAILURE;
104 
105 	return soc->ops->host_stats_ops->txrx_host_stats_clr(soc, vdev_id);
106 }
107 
108 static inline QDF_STATUS
109 cdp_host_ce_stats(ol_txrx_soc_handle soc, uint8_t vdev_id)
110 {
111 	if (!soc || !soc->ops) {
112 		QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
113 				"%s: Invalid Instance", __func__);
114 		QDF_BUG(0);
115 		return QDF_STATUS_E_FAILURE;
116 	}
117 
118 	if (!soc->ops->host_stats_ops ||
119 	    !soc->ops->host_stats_ops->txrx_host_ce_stats)
120 		return QDF_STATUS_E_FAILURE;
121 
122 	return soc->ops->host_stats_ops->txrx_host_ce_stats(soc, vdev_id);
123 }
124 
125 static inline int cdp_stats_publish
126 	(ol_txrx_soc_handle soc, uint8_t pdev_id,
127 	struct cdp_stats_extd *buf)
128 {
129 	if (!soc || !soc->ops) {
130 		QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
131 				"%s: Invalid Instance", __func__);
132 		QDF_BUG(0);
133 		return 0;
134 	}
135 
136 	if (!soc->ops->host_stats_ops ||
137 	    !soc->ops->host_stats_ops->txrx_stats_publish)
138 		return 0;
139 
140 	return soc->ops->host_stats_ops->txrx_stats_publish(soc, pdev_id, buf);
141 }
142 
143 /**
144  * @brief Enable enhanced stats functionality.
145  *
146  * @param soc - the soc object
147  * @param pdev_id - id of the physical device object
148  * @return - QDF_STATUS
149  */
150 static inline QDF_STATUS
151 cdp_enable_enhanced_stats(ol_txrx_soc_handle soc, uint8_t pdev_id)
152 {
153 	if (!soc || !soc->ops) {
154 		QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
155 				"%s: Invalid Instance", __func__);
156 		QDF_BUG(0);
157 		return QDF_STATUS_E_FAILURE;
158 	}
159 
160 	if (!soc->ops->host_stats_ops ||
161 	    !soc->ops->host_stats_ops->txrx_enable_enhanced_stats)
162 		return QDF_STATUS_E_FAILURE;
163 
164 	return soc->ops->host_stats_ops->txrx_enable_enhanced_stats
165 			(soc, pdev_id);
166 }
167 
168 /**
169  * @brief Disable enhanced stats functionality.
170  *
171  * @param soc - the soc object
172  * @param pdev_id - id of the physical device object
173  * @return - QDF_STATUS
174  */
175 static inline QDF_STATUS
176 cdp_disable_enhanced_stats(ol_txrx_soc_handle soc, uint8_t pdev_id)
177 {
178 	if (!soc || !soc->ops) {
179 		QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
180 				"%s: Invalid Instance", __func__);
181 		QDF_BUG(0);
182 		return QDF_STATUS_E_FAILURE;
183 	}
184 
185 	if (!soc->ops->host_stats_ops ||
186 	    !soc->ops->host_stats_ops->txrx_disable_enhanced_stats)
187 		return QDF_STATUS_E_FAILURE;
188 
189 	return soc->ops->host_stats_ops->txrx_disable_enhanced_stats
190 			(soc, pdev_id);
191 }
192 
193 static inline QDF_STATUS
194 cdp_tx_print_tso_stats(ol_txrx_soc_handle soc, uint8_t vdev_id)
195 {
196 	if (!soc || !soc->ops) {
197 		QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
198 				"%s: Invalid Instance", __func__);
199 		QDF_BUG(0);
200 		return QDF_STATUS_E_FAILURE;
201 	}
202 
203 	if (!soc->ops->host_stats_ops ||
204 	    !soc->ops->host_stats_ops->tx_print_tso_stats)
205 		return QDF_STATUS_E_FAILURE;
206 
207 	return soc->ops->host_stats_ops->tx_print_tso_stats(soc, vdev_id);
208 }
209 
210 static inline QDF_STATUS
211 cdp_tx_rst_tso_stats(ol_txrx_soc_handle soc, uint8_t vdev_id)
212 {
213 	if (!soc || !soc->ops) {
214 		QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
215 				"%s: Invalid Instance", __func__);
216 		QDF_BUG(0);
217 		return QDF_STATUS_E_FAILURE;
218 	}
219 
220 	if (!soc->ops->host_stats_ops ||
221 	    !soc->ops->host_stats_ops->tx_rst_tso_stats)
222 		return QDF_STATUS_E_FAILURE;
223 
224 	return soc->ops->host_stats_ops->tx_rst_tso_stats(soc, vdev_id);
225 }
226 
227 static inline QDF_STATUS
228 cdp_tx_print_sg_stats(ol_txrx_soc_handle soc, uint8_t vdev_id)
229 {
230 	if (!soc || !soc->ops) {
231 		QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
232 				"%s: Invalid Instance", __func__);
233 		QDF_BUG(0);
234 		return QDF_STATUS_E_FAILURE;
235 	}
236 
237 	if (!soc->ops->host_stats_ops ||
238 	    !soc->ops->host_stats_ops->tx_print_sg_stats)
239 		return QDF_STATUS_E_FAILURE;
240 
241 	return soc->ops->host_stats_ops->tx_print_sg_stats(soc, vdev_id);
242 }
243 
244 static inline QDF_STATUS
245 cdp_tx_rst_sg_stats(ol_txrx_soc_handle soc, uint8_t vdev_id)
246 {
247 	if (!soc || !soc->ops) {
248 		QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
249 				"%s: Invalid Instance", __func__);
250 		QDF_BUG(0);
251 		return QDF_STATUS_E_FAILURE;
252 	}
253 
254 	if (!soc->ops->host_stats_ops ||
255 	    !soc->ops->host_stats_ops->tx_rst_sg_stats)
256 		return QDF_STATUS_E_FAILURE;
257 
258 	return soc->ops->host_stats_ops->tx_rst_sg_stats(soc, vdev_id);
259 }
260 
261 static inline QDF_STATUS
262 cdp_print_rx_cksum_stats(ol_txrx_soc_handle soc, uint8_t vdev_id)
263 {
264 	if (!soc || !soc->ops) {
265 		QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
266 				"%s: Invalid Instance", __func__);
267 		QDF_BUG(0);
268 		return QDF_STATUS_E_FAILURE;
269 	}
270 
271 	if (!soc->ops->host_stats_ops ||
272 	    !soc->ops->host_stats_ops->print_rx_cksum_stats)
273 		return QDF_STATUS_E_FAILURE;
274 
275 	return soc->ops->host_stats_ops->print_rx_cksum_stats(soc, vdev_id);
276 }
277 
278 static inline QDF_STATUS
279 cdp_rst_rx_cksum_stats(ol_txrx_soc_handle soc, uint8_t vdev_id)
280 {
281 	if (!soc || !soc->ops) {
282 		QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
283 				"%s: Invalid Instance", __func__);
284 		QDF_BUG(0);
285 		return QDF_STATUS_E_FAILURE;
286 	}
287 
288 	if (!soc->ops->host_stats_ops ||
289 	    !soc->ops->host_stats_ops->rst_rx_cksum_stats)
290 		return QDF_STATUS_E_FAILURE;
291 
292 	return soc->ops->host_stats_ops->rst_rx_cksum_stats(soc, vdev_id);
293 }
294 
295 static inline QDF_STATUS
296 cdp_host_me_stats(ol_txrx_soc_handle soc, uint8_t vdev_id)
297 {
298 	if (!soc || !soc->ops) {
299 		QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
300 				"%s: Invalid Instance", __func__);
301 		QDF_BUG(0);
302 		return QDF_STATUS_E_FAILURE;
303 	}
304 
305 	if (!soc->ops->host_stats_ops ||
306 	    !soc->ops->host_stats_ops->txrx_host_me_stats)
307 		return QDF_STATUS_E_FAILURE;
308 
309 	return soc->ops->host_stats_ops->txrx_host_me_stats(soc, vdev_id);
310 }
311 
312 /**
313  * cdp_per_peer_stats(): function to print per peer REO Queue stats
314  * @soc: soc handle
315  * @pdev: physical device
316  * @addr: peer address
317  *
318  * return: status
319  */
320 static inline QDF_STATUS cdp_per_peer_stats(ol_txrx_soc_handle soc,
321 					    uint8_t *addr)
322 {
323 	if (!soc || !soc->ops) {
324 		QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
325 			  "%s: Invalid Instance", __func__);
326 		QDF_BUG(0);
327 		return QDF_STATUS_E_FAILURE;
328 	}
329 
330 	if (!soc->ops->host_stats_ops ||
331 	    !soc->ops->host_stats_ops->txrx_per_peer_stats)
332 		return QDF_STATUS_E_FAILURE;
333 
334 	return soc->ops->host_stats_ops->txrx_per_peer_stats(soc, addr);
335 }
336 
337 static inline int cdp_host_msdu_ttl_stats(ol_txrx_soc_handle soc,
338 	uint8_t vdev_id,
339 	struct ol_txrx_stats_req *req)
340 {
341 	if (!soc || !soc->ops) {
342 		QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
343 				"%s: Invalid Instance", __func__);
344 		QDF_BUG(0);
345 		return 0;
346 	}
347 
348 	if (!soc->ops->host_stats_ops ||
349 	    !soc->ops->host_stats_ops->txrx_host_msdu_ttl_stats)
350 		return 0;
351 
352 	return soc->ops->host_stats_ops->txrx_host_msdu_ttl_stats
353 			(soc, vdev_id, req);
354 }
355 
356 static inline QDF_STATUS cdp_update_peer_stats(ol_txrx_soc_handle soc,
357 					       uint8_t vdev_id, uint8_t *mac,
358 					       void *stats,
359 					       uint32_t last_tx_rate_mcs,
360 					       uint32_t stats_id)
361 {
362 	if (!soc || !soc->ops) {
363 		QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
364 				"%s: Invalid Instance", __func__);
365 		QDF_BUG(0);
366 		return QDF_STATUS_E_FAILURE;
367 	}
368 
369 	if (!soc->ops->host_stats_ops ||
370 	    !soc->ops->host_stats_ops->txrx_update_peer_stats)
371 		return QDF_STATUS_E_FAILURE;
372 
373 	return soc->ops->host_stats_ops->txrx_update_peer_stats
374 			(soc, vdev_id, mac, stats, last_tx_rate_mcs, stats_id);
375 }
376 
377 static inline QDF_STATUS cdp_get_dp_fw_peer_stats(ol_txrx_soc_handle soc,
378 						  uint8_t pdev_id,
379 						  uint8_t *mac, uint32_t caps,
380 						  uint32_t copy_stats)
381 {
382 	if (!soc || !soc->ops) {
383 		QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
384 				"%s: Invalid Instance", __func__);
385 		QDF_BUG(0);
386 		return QDF_STATUS_E_FAILURE;
387 	}
388 
389 	if (!soc->ops->host_stats_ops ||
390 	    !soc->ops->host_stats_ops->get_fw_peer_stats)
391 		return QDF_STATUS_E_FAILURE;
392 
393 	return soc->ops->host_stats_ops->get_fw_peer_stats
394 			(soc, pdev_id, mac, caps, copy_stats);
395 }
396 
397 static inline QDF_STATUS cdp_get_dp_htt_stats(ol_txrx_soc_handle soc,
398 					      uint8_t pdev_id,
399 					      void *data, uint32_t data_len)
400 {
401 	if (!soc || !soc->ops) {
402 		QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
403 			  "%s: Invalid Instance", __func__);
404 		QDF_BUG(0);
405 		return QDF_STATUS_E_FAILURE;
406 	}
407 
408 	if (!soc->ops->host_stats_ops ||
409 	    !soc->ops->host_stats_ops->get_htt_stats)
410 		return QDF_STATUS_E_FAILURE;
411 
412 	return soc->ops->host_stats_ops->get_htt_stats(soc, pdev_id, data,
413 						       data_len);
414 }
415 
416 /**
417  * @brief Update pdev host stats received from firmware
418  * (wmi_host_pdev_stats and wmi_host_pdev_ext_stats) into dp
419  *
420  * @param soc - soc handle
421  * @param pdev_id - id of the physical device object
422  * @param data - pdev stats
423  * @return - QDF_STATUS
424  */
425 static inline QDF_STATUS
426 cdp_update_pdev_host_stats(ol_txrx_soc_handle soc,
427 			   uint8_t pdev_id,
428 			   void *data,
429 			   uint16_t stats_id)
430 {
431 	if (!soc || !soc->ops) {
432 		QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
433 			  "%s: Invalid Instance", __func__);
434 		QDF_BUG(0);
435 		return QDF_STATUS_E_FAILURE;
436 	}
437 
438 	if (!soc->ops->host_stats_ops ||
439 	    !soc->ops->host_stats_ops->txrx_update_pdev_stats)
440 		return QDF_STATUS_E_FAILURE;
441 
442 	return soc->ops->host_stats_ops->txrx_update_pdev_stats(soc, pdev_id,
443 								data,
444 								stats_id);
445 }
446 
447 /**
448  * @brief Update vdev host stats
449  *
450  * @soc: soc handle
451  * @vdev_id: id of the virtual device object
452  * @data: pdev stats
453  * @stats_id: type of stats
454  *
455  * Return: QDF_STATUS
456  */
457 static inline QDF_STATUS
458 cdp_update_vdev_host_stats(ol_txrx_soc_handle soc,
459 			   uint8_t vdev_id,
460 			   void *data,
461 			   uint16_t stats_id)
462 {
463 	if (!soc || !soc->ops) {
464 		QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
465 			  "%s: Invalid Instance", __func__);
466 		QDF_BUG(0);
467 		return QDF_STATUS_E_FAILURE;
468 	}
469 
470 	if (!soc->ops->host_stats_ops ||
471 	    !soc->ops->host_stats_ops->txrx_update_vdev_stats)
472 		return QDF_STATUS_E_FAILURE;
473 
474 	return soc->ops->host_stats_ops->txrx_update_vdev_stats(soc, vdev_id,
475 								data,
476 								stats_id);
477 }
478 
479 /**
480  * @brief Call to get specified peer stats
481  *
482  * @param soc - soc handle
483  * @param vdev_id - vdev_id of vdev object
484  * @param peer_mac - mac address of the peer
485  * @param type - enum of required stats
486  * @param buf - buffer to hold the value
487  * @return - QDF_STATUS
488  */
489 static inline QDF_STATUS
490 cdp_txrx_get_peer_stats_param(ol_txrx_soc_handle soc, uint8_t vdev_id,
491 			      uint8_t *peer_mac,
492 			      enum cdp_peer_stats_type type,
493 			      cdp_peer_stats_param_t *buf)
494 {
495 	if (!soc || !soc->ops) {
496 		QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
497 			  "%s: Invalid Instance", __func__);
498 		QDF_BUG(0);
499 		return QDF_STATUS_E_FAILURE;
500 	}
501 
502 	if (!soc->ops->host_stats_ops ||
503 	    !soc->ops->host_stats_ops->txrx_get_peer_stats_param)
504 		return QDF_STATUS_E_FAILURE;
505 
506 	return soc->ops->host_stats_ops->txrx_get_peer_stats_param(soc,
507 								   vdev_id,
508 								   peer_mac,
509 								   type,
510 								   buf);
511 }
512 
513 /**
514  * @brief Call to get peer stats
515  *
516  * @param soc - soc handle
517  * @param vdev_id - vdev_id of vdev object
518  * @param peer_mac - mac address of the peer
519  * @return - struct cdp_peer_stats
520  */
521 static inline QDF_STATUS
522 cdp_host_get_peer_stats(ol_txrx_soc_handle soc, uint8_t vdev_id,
523 			uint8_t *peer_mac,
524 			struct cdp_peer_stats *peer_stats)
525 {
526 	if (!soc || !soc->ops) {
527 		QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
528 			  "%s: Invalid Instance", __func__);
529 		QDF_BUG(0);
530 		return QDF_STATUS_E_FAILURE;
531 	}
532 
533 	if (!soc->ops->host_stats_ops ||
534 	    !soc->ops->host_stats_ops->txrx_get_peer_stats)
535 		return QDF_STATUS_E_FAILURE;
536 
537 	return soc->ops->host_stats_ops->txrx_get_peer_stats(soc, vdev_id,
538 							     peer_mac,
539 							     peer_stats);
540 }
541 
542 /**
543  * @brief Call to reset ald stats
544  *
545  * @param soc - soc handle
546  * @param vdev_id - vdev_id of vdev object
547  * @param peer_mac - mac address of the peer
548  * @return - void
549  */
550 static inline QDF_STATUS
551 cdp_host_reset_peer_ald_stats(ol_txrx_soc_handle soc, uint8_t vdev_id,
552 			      uint8_t *peer_mac)
553 {
554 	if (!soc || !soc->ops) {
555 		QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
556 			  "%s: Invalid Instance", __func__);
557 		QDF_BUG(0);
558 		return QDF_STATUS_E_FAILURE;
559 	}
560 
561 	if (!soc->ops->host_stats_ops ||
562 	    !soc->ops->host_stats_ops->txrx_reset_peer_ald_stats)
563 		return QDF_STATUS_E_FAILURE;
564 
565 	return soc->ops->host_stats_ops->txrx_reset_peer_ald_stats(soc,
566 							    vdev_id,
567 							    peer_mac);
568 }
569 
570 /**
571  * @brief Call to reset peer stats
572  *
573  * @param soc - soc handle
574  * @param vdev_id - vdev_id of vdev object
575  * @param peer_mac - mac address of the peer
576  * @return - QDF_STATUS
577  */
578 static inline QDF_STATUS
579 cdp_host_reset_peer_stats(ol_txrx_soc_handle soc,
580 			  uint8_t vdev_id, uint8_t *peer_mac)
581 {
582 	if (!soc || !soc->ops) {
583 		QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
584 			  "%s: Invalid Instance", __func__);
585 		QDF_BUG(0);
586 		return QDF_STATUS_E_FAILURE;
587 	}
588 
589 	if (!soc->ops->host_stats_ops ||
590 	    !soc->ops->host_stats_ops->txrx_reset_peer_stats)
591 		return QDF_STATUS_E_FAILURE;
592 
593 	return soc->ops->host_stats_ops->txrx_reset_peer_stats(soc,
594 							vdev_id,
595 							peer_mac);
596 }
597 
598 /**
599  * @brief Call to get vdev stats
600  *
601  * @param soc - dp soc object
602  * @param vdev_id - id of dp vdev object
603  * @param buf - buffer
604  * @return - int
605  */
606 static inline int
607 cdp_host_get_vdev_stats(ol_txrx_soc_handle soc,
608 			uint8_t vdev_id,
609 			struct cdp_vdev_stats *buf,
610 			bool is_aggregate)
611 {
612 	if (!soc || !soc->ops) {
613 		QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
614 			  "%s: Invalid Instance", __func__);
615 		QDF_BUG(0);
616 		return 0;
617 	}
618 
619 	if (!soc->ops->host_stats_ops ||
620 	    !soc->ops->host_stats_ops->txrx_get_vdev_stats)
621 		return 0;
622 
623 	return soc->ops->host_stats_ops->txrx_get_vdev_stats(soc, vdev_id,
624 							     buf,
625 							     is_aggregate);
626 }
627 
628 /**
629  * @brief Call to update vdev stats received from firmware
630  * (wmi_host_vdev_stats and wmi_host_vdev_extd_stats) into dp
631  *
632  * @param data - stats data to be updated
633  * @param size - size of stats data
634  * @param stats_id - stats id
635  * @return - int
636  */
637 static inline int
638 cdp_update_host_vdev_stats(ol_txrx_soc_handle soc,
639 			   void *data,
640 			   uint32_t size,
641 			   uint32_t stats_id)
642 {
643 	if (!soc || !soc->ops) {
644 		QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
645 			  "%s: Invalid Instance", __func__);
646 		QDF_BUG(0);
647 		return 0;
648 	}
649 
650 	if (!soc->ops->host_stats_ops ||
651 	    !soc->ops->host_stats_ops->txrx_process_wmi_host_vdev_stats)
652 		return 0;
653 
654 	return soc->ops->host_stats_ops->txrx_process_wmi_host_vdev_stats
655 								(soc,
656 								 data,
657 								 size,
658 								 stats_id);
659 }
660 
661 /**
662  * @brief Call to get vdev extd stats
663  *
664  * @param soc - soc handle
665  * @param vdev_id - id of dp vdev object
666  * @param buf - buffer
667  * @return - int
668  */
669 static inline int
670 cdp_get_vdev_extd_stats(ol_txrx_soc_handle soc,
671 			uint8_t vdev_id,
672 			wmi_host_vdev_extd_stats *buf)
673 {
674 	if (!soc || !soc->ops) {
675 		QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
676 			  "%s: Invalid Instance", __func__);
677 		QDF_BUG(0);
678 		return 0;
679 	}
680 
681 	if (!soc->ops->host_stats_ops ||
682 	    !soc->ops->host_stats_ops->txrx_get_vdev_extd_stats)
683 		return 0;
684 
685 	return soc->ops->host_stats_ops->txrx_get_vdev_extd_stats(soc, vdev_id,
686 								  buf);
687 }
688 
689 /**
690  * @brief Call to get cdp_pdev_stats
691  *
692  * @param soc - soc handle
693  * @param pdev_id - id of dp pdev object
694  * @param buf - buffer to hold cdp_pdev_stats
695  * @return - success/failure
696  */
697 static inline int
698 cdp_host_get_pdev_stats(ol_txrx_soc_handle soc,
699 			uint8_t pdev_id, struct cdp_pdev_stats *buf)
700 {
701 	if (!soc || !soc->ops) {
702 		QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
703 			  "%s: Invalid Instance", __func__);
704 		QDF_BUG(0);
705 		return 0;
706 	}
707 
708 	if (!soc->ops->host_stats_ops ||
709 	    !soc->ops->host_stats_ops->txrx_get_pdev_stats)
710 		return 0;
711 
712 	return soc->ops->host_stats_ops->txrx_get_pdev_stats(soc, pdev_id, buf);
713 }
714 
715 /**
716  * @brief Call to get radio stats
717  *
718  * @param soc - soc handle
719  * @param pdev_id - id of dp pdev object
720  * @param scn_stats_user - stats buffer
721  * @return - int
722  */
723 static inline int
724 cdp_host_get_radio_stats(ol_txrx_soc_handle soc,
725 			 uint8_t pdev_id,
726 			 void *buf)
727 {
728 	if (!soc || !soc->ops) {
729 		QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
730 			  "%s: Invalid Instance", __func__);
731 		QDF_BUG(0);
732 		return 0;
733 	}
734 
735 	if (!soc->ops->host_stats_ops ||
736 	    !soc->ops->host_stats_ops->txrx_get_radio_stats)
737 		return 0;
738 
739 	return soc->ops->host_stats_ops->txrx_get_radio_stats(soc, pdev_id,
740 							      buf);
741 }
742 #endif /* _CDP_TXRX_HOST_STATS_H_ */
743