xref: /wlan-dirver/qca-wifi-host-cmn/dp/inc/cdp_txrx_host_stats.h (revision 3b082b0bf8d2e31f3268608a8140a8dfa0215204)
1 /*
2  * Copyright (c) 2016-2021 The Linux Foundation. All rights reserved.
3  * Copyright (c) 2021-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: cdp_txrx_host_stats.h
22  * Define the host data path stats API functions
23  * called by the host control SW and the OS interface module
24  */
25 #ifndef _CDP_TXRX_HOST_STATS_H_
26 #define _CDP_TXRX_HOST_STATS_H_
27 #include "cdp_txrx_handle.h"
28 #include <cdp_txrx_cmn.h>
29 #include <wmi_unified_api.h>
30 /**
31  * cdp_host_stats_get() - cdp call to get host stats
32  * @soc: SOC handle
33  * @vdev_id: vdev id of vdev
34  * @req: Requirement type
35  *
36  * Return: 0 for Success, Failure returns error message
37  */
38 static inline int cdp_host_stats_get(ol_txrx_soc_handle soc,
39 		uint8_t vdev_id,
40 		struct ol_txrx_stats_req *req)
41 {
42 	if (!soc || !soc->ops) {
43 		dp_cdp_debug("Invalid Instance");
44 		QDF_BUG(0);
45 		return 0;
46 	}
47 
48 	if (!soc->ops->host_stats_ops ||
49 	    !soc->ops->host_stats_ops->txrx_host_stats_get)
50 		return 0;
51 
52 	return soc->ops->host_stats_ops->txrx_host_stats_get(soc, vdev_id, req);
53 }
54 
55 /**
56  * cdp_host_stats_get_ratekbps() - cdp call to get rate in kbps
57  * @soc: SOC handle
58  * @preamb: Preamble
59  * @mcs: Modulation and Coding scheme index
60  * @htflag: Flag to identify HT or VHT
61  * @gintval: Guard Interval value
62  *
63  * Return: 0 for Failure, Returns rate on Success
64  */
65 static inline int cdp_host_stats_get_ratekbps(ol_txrx_soc_handle soc,
66 					      int preamb, int mcs,
67 					      int htflag, int gintval)
68 {
69 	if (!soc || !soc->ops) {
70 		dp_cdp_debug("Invalid Instance");
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 		dp_cdp_debug("Invalid Instance");
96 		QDF_BUG(0);
97 		return QDF_STATUS_E_FAILURE;
98 	}
99 
100 	if (!soc->ops->host_stats_ops ||
101 	    !soc->ops->host_stats_ops->txrx_host_stats_clr)
102 		return QDF_STATUS_E_FAILURE;
103 
104 	return soc->ops->host_stats_ops->txrx_host_stats_clr(soc, vdev_id);
105 }
106 
107 static inline QDF_STATUS
108 cdp_host_ce_stats(ol_txrx_soc_handle soc, uint8_t vdev_id)
109 {
110 	if (!soc || !soc->ops) {
111 		dp_cdp_debug("Invalid Instance");
112 		QDF_BUG(0);
113 		return QDF_STATUS_E_FAILURE;
114 	}
115 
116 	if (!soc->ops->host_stats_ops ||
117 	    !soc->ops->host_stats_ops->txrx_host_ce_stats)
118 		return QDF_STATUS_E_FAILURE;
119 
120 	return soc->ops->host_stats_ops->txrx_host_ce_stats(soc, vdev_id);
121 }
122 
123 static inline int cdp_stats_publish
124 	(ol_txrx_soc_handle soc, uint8_t pdev_id,
125 	struct cdp_stats_extd *buf)
126 {
127 	if (!soc || !soc->ops) {
128 		dp_cdp_debug("Invalid Instance");
129 		QDF_BUG(0);
130 		return 0;
131 	}
132 
133 	if (!soc->ops->host_stats_ops ||
134 	    !soc->ops->host_stats_ops->txrx_stats_publish)
135 		return 0;
136 
137 	return soc->ops->host_stats_ops->txrx_stats_publish(soc, pdev_id, buf);
138 }
139 
140 /**
141  * cdp_enable_enhanced_stats() - Enable enhanced stats functionality.
142  * @soc: the soc object
143  * @pdev_id: id of the physical device object
144  *
145  * Return: QDF_STATUS
146  */
147 static inline QDF_STATUS
148 cdp_enable_enhanced_stats(ol_txrx_soc_handle soc, uint8_t pdev_id)
149 {
150 	if (!soc || !soc->ops) {
151 		dp_cdp_debug("Invalid Instance");
152 		QDF_BUG(0);
153 		return QDF_STATUS_E_FAILURE;
154 	}
155 
156 	if (!soc->ops->mon_ops ||
157 	    !soc->ops->mon_ops->txrx_enable_enhanced_stats)
158 		return QDF_STATUS_E_FAILURE;
159 
160 	return soc->ops->mon_ops->txrx_enable_enhanced_stats
161 			(soc, pdev_id);
162 }
163 
164 /**
165  * cdp_disable_enhanced_stats() - Disable enhanced stats functionality.
166  * @soc: the soc object
167  * @pdev_id: id of the physical device object
168  *
169  * Return: QDF_STATUS
170  */
171 static inline QDF_STATUS
172 cdp_disable_enhanced_stats(ol_txrx_soc_handle soc, uint8_t pdev_id)
173 {
174 	if (!soc || !soc->ops) {
175 		dp_cdp_debug("Invalid Instance");
176 		QDF_BUG(0);
177 		return QDF_STATUS_E_FAILURE;
178 	}
179 
180 	if (!soc->ops->mon_ops ||
181 	    !soc->ops->mon_ops->txrx_disable_enhanced_stats)
182 		return QDF_STATUS_E_FAILURE;
183 
184 	return soc->ops->mon_ops->txrx_disable_enhanced_stats
185 			(soc, pdev_id);
186 }
187 
188 static inline QDF_STATUS
189 cdp_tx_print_tso_stats(ol_txrx_soc_handle soc, uint8_t vdev_id)
190 {
191 	if (!soc || !soc->ops) {
192 		dp_cdp_debug("Invalid Instance");
193 		QDF_BUG(0);
194 		return QDF_STATUS_E_FAILURE;
195 	}
196 
197 	if (!soc->ops->host_stats_ops ||
198 	    !soc->ops->host_stats_ops->tx_print_tso_stats)
199 		return QDF_STATUS_E_FAILURE;
200 
201 	return soc->ops->host_stats_ops->tx_print_tso_stats(soc, vdev_id);
202 }
203 
204 static inline QDF_STATUS
205 cdp_tx_rst_tso_stats(ol_txrx_soc_handle soc, uint8_t vdev_id)
206 {
207 	if (!soc || !soc->ops) {
208 		dp_cdp_debug("Invalid Instance");
209 		QDF_BUG(0);
210 		return QDF_STATUS_E_FAILURE;
211 	}
212 
213 	if (!soc->ops->host_stats_ops ||
214 	    !soc->ops->host_stats_ops->tx_rst_tso_stats)
215 		return QDF_STATUS_E_FAILURE;
216 
217 	return soc->ops->host_stats_ops->tx_rst_tso_stats(soc, vdev_id);
218 }
219 
220 static inline QDF_STATUS
221 cdp_tx_print_sg_stats(ol_txrx_soc_handle soc, uint8_t vdev_id)
222 {
223 	if (!soc || !soc->ops) {
224 		dp_cdp_debug("Invalid Instance");
225 		QDF_BUG(0);
226 		return QDF_STATUS_E_FAILURE;
227 	}
228 
229 	if (!soc->ops->host_stats_ops ||
230 	    !soc->ops->host_stats_ops->tx_print_sg_stats)
231 		return QDF_STATUS_E_FAILURE;
232 
233 	return soc->ops->host_stats_ops->tx_print_sg_stats(soc, vdev_id);
234 }
235 
236 static inline QDF_STATUS
237 cdp_tx_rst_sg_stats(ol_txrx_soc_handle soc, uint8_t vdev_id)
238 {
239 	if (!soc || !soc->ops) {
240 		dp_cdp_debug("Invalid Instance");
241 		QDF_BUG(0);
242 		return QDF_STATUS_E_FAILURE;
243 	}
244 
245 	if (!soc->ops->host_stats_ops ||
246 	    !soc->ops->host_stats_ops->tx_rst_sg_stats)
247 		return QDF_STATUS_E_FAILURE;
248 
249 	return soc->ops->host_stats_ops->tx_rst_sg_stats(soc, vdev_id);
250 }
251 
252 static inline QDF_STATUS
253 cdp_print_rx_cksum_stats(ol_txrx_soc_handle soc, uint8_t vdev_id)
254 {
255 	if (!soc || !soc->ops) {
256 		dp_cdp_debug("Invalid Instance");
257 		QDF_BUG(0);
258 		return QDF_STATUS_E_FAILURE;
259 	}
260 
261 	if (!soc->ops->host_stats_ops ||
262 	    !soc->ops->host_stats_ops->print_rx_cksum_stats)
263 		return QDF_STATUS_E_FAILURE;
264 
265 	return soc->ops->host_stats_ops->print_rx_cksum_stats(soc, vdev_id);
266 }
267 
268 static inline QDF_STATUS
269 cdp_rst_rx_cksum_stats(ol_txrx_soc_handle soc, uint8_t vdev_id)
270 {
271 	if (!soc || !soc->ops) {
272 		dp_cdp_debug("Invalid Instance");
273 		QDF_BUG(0);
274 		return QDF_STATUS_E_FAILURE;
275 	}
276 
277 	if (!soc->ops->host_stats_ops ||
278 	    !soc->ops->host_stats_ops->rst_rx_cksum_stats)
279 		return QDF_STATUS_E_FAILURE;
280 
281 	return soc->ops->host_stats_ops->rst_rx_cksum_stats(soc, vdev_id);
282 }
283 
284 static inline QDF_STATUS
285 cdp_host_me_stats(ol_txrx_soc_handle soc, uint8_t vdev_id)
286 {
287 	if (!soc || !soc->ops) {
288 		dp_cdp_debug("Invalid Instance");
289 		QDF_BUG(0);
290 		return QDF_STATUS_E_FAILURE;
291 	}
292 
293 	if (!soc->ops->host_stats_ops ||
294 	    !soc->ops->host_stats_ops->txrx_host_me_stats)
295 		return QDF_STATUS_E_FAILURE;
296 
297 	return soc->ops->host_stats_ops->txrx_host_me_stats(soc, vdev_id);
298 }
299 
300 /**
301  * cdp_per_peer_stats() - function to print per peer REO Queue stats
302  * @soc: soc handle
303  * @addr: peer address
304  *
305  * Return: status
306  */
307 static inline QDF_STATUS cdp_per_peer_stats(ol_txrx_soc_handle soc,
308 					    uint8_t *addr)
309 {
310 	if (!soc || !soc->ops) {
311 		dp_cdp_debug("Invalid Instance");
312 		QDF_BUG(0);
313 		return QDF_STATUS_E_FAILURE;
314 	}
315 
316 	if (!soc->ops->host_stats_ops ||
317 	    !soc->ops->host_stats_ops->txrx_per_peer_stats)
318 		return QDF_STATUS_E_FAILURE;
319 
320 	return soc->ops->host_stats_ops->txrx_per_peer_stats(soc, addr);
321 }
322 
323 static inline int cdp_host_msdu_ttl_stats(ol_txrx_soc_handle soc,
324 	uint8_t vdev_id,
325 	struct ol_txrx_stats_req *req)
326 {
327 	if (!soc || !soc->ops) {
328 		dp_cdp_debug("Invalid Instance");
329 		QDF_BUG(0);
330 		return 0;
331 	}
332 
333 	if (!soc->ops->host_stats_ops ||
334 	    !soc->ops->host_stats_ops->txrx_host_msdu_ttl_stats)
335 		return 0;
336 
337 	return soc->ops->host_stats_ops->txrx_host_msdu_ttl_stats
338 			(soc, vdev_id, req);
339 }
340 
341 static inline QDF_STATUS cdp_update_peer_stats(ol_txrx_soc_handle soc,
342 					       uint8_t vdev_id, uint8_t *mac,
343 					       void *stats,
344 					       uint32_t last_tx_rate_mcs,
345 					       uint32_t stats_id)
346 {
347 	if (!soc || !soc->ops) {
348 		dp_cdp_debug("Invalid Instance");
349 		QDF_BUG(0);
350 		return QDF_STATUS_E_FAILURE;
351 	}
352 
353 	if (!soc->ops->host_stats_ops ||
354 	    !soc->ops->host_stats_ops->txrx_update_peer_stats)
355 		return QDF_STATUS_E_FAILURE;
356 
357 	return soc->ops->host_stats_ops->txrx_update_peer_stats
358 			(soc, vdev_id, mac, stats, last_tx_rate_mcs, stats_id);
359 }
360 
361 static inline QDF_STATUS cdp_get_dp_fw_peer_stats(ol_txrx_soc_handle soc,
362 						  uint8_t pdev_id,
363 						  uint8_t *mac, uint32_t caps,
364 						  uint32_t copy_stats)
365 {
366 	if (!soc || !soc->ops) {
367 		dp_cdp_debug("Invalid Instance");
368 		QDF_BUG(0);
369 		return QDF_STATUS_E_FAILURE;
370 	}
371 
372 	if (!soc->ops->host_stats_ops ||
373 	    !soc->ops->host_stats_ops->get_fw_peer_stats)
374 		return QDF_STATUS_E_FAILURE;
375 
376 	return soc->ops->host_stats_ops->get_fw_peer_stats
377 			(soc, pdev_id, mac, caps, copy_stats);
378 }
379 
380 static inline QDF_STATUS cdp_get_dp_htt_stats(ol_txrx_soc_handle soc,
381 					      uint8_t pdev_id,
382 					      void *data, uint32_t data_len)
383 {
384 	if (!soc || !soc->ops) {
385 		dp_cdp_debug("Invalid Instance");
386 		QDF_BUG(0);
387 		return QDF_STATUS_E_FAILURE;
388 	}
389 
390 	if (!soc->ops->host_stats_ops ||
391 	    !soc->ops->host_stats_ops->get_htt_stats)
392 		return QDF_STATUS_E_FAILURE;
393 
394 	return soc->ops->host_stats_ops->get_htt_stats(soc, pdev_id, data,
395 						       data_len);
396 }
397 
398 /**
399  * cdp_update_pdev_host_stats() - Update pdev host stats received from firmware
400  * (wmi_host_pdev_stats and wmi_host_pdev_ext_stats) into dp
401  * @soc: soc handle
402  * @pdev_id: id of the physical device object
403  * @data: pdev stats
404  * @stats_id: statistics to be updated
405  *
406  * Return: QDF_STATUS
407  */
408 static inline QDF_STATUS
409 cdp_update_pdev_host_stats(ol_txrx_soc_handle soc,
410 			   uint8_t pdev_id,
411 			   void *data,
412 			   uint16_t stats_id)
413 {
414 	if (!soc || !soc->ops) {
415 		dp_cdp_debug("Invalid Instance");
416 		QDF_BUG(0);
417 		return QDF_STATUS_E_FAILURE;
418 	}
419 
420 	if (!soc->ops->host_stats_ops ||
421 	    !soc->ops->host_stats_ops->txrx_update_pdev_stats)
422 		return QDF_STATUS_E_FAILURE;
423 
424 	return soc->ops->host_stats_ops->txrx_update_pdev_stats(soc, pdev_id,
425 								data,
426 								stats_id);
427 }
428 
429 /**
430  * cdp_update_vdev_host_stats() - Update vdev host stats
431  * @soc: soc handle
432  * @vdev_id: id of the virtual device object
433  * @data: pdev stats
434  * @stats_id: type of stats
435  *
436  * Return: QDF_STATUS
437  */
438 static inline QDF_STATUS
439 cdp_update_vdev_host_stats(ol_txrx_soc_handle soc,
440 			   uint8_t vdev_id,
441 			   void *data,
442 			   uint16_t stats_id)
443 {
444 	if (!soc || !soc->ops) {
445 		dp_cdp_debug("Invalid Instance");
446 		QDF_BUG(0);
447 		return QDF_STATUS_E_FAILURE;
448 	}
449 
450 	if (!soc->ops->host_stats_ops ||
451 	    !soc->ops->host_stats_ops->txrx_update_vdev_stats)
452 		return QDF_STATUS_E_FAILURE;
453 
454 	return soc->ops->host_stats_ops->txrx_update_vdev_stats(soc, vdev_id,
455 								data,
456 								stats_id);
457 }
458 
459 /**
460  * cdp_txrx_get_peer_stats_param() - Call to get specified peer stats
461  * @soc: soc handle
462  * @vdev_id: vdev_id of vdev object
463  * @peer_mac: mac address of the peer
464  * @type: enum of required stats
465  * @buf: buffer to hold the value
466  *
467  * Return: QDF_STATUS
468  */
469 static inline QDF_STATUS
470 cdp_txrx_get_peer_stats_param(ol_txrx_soc_handle soc, uint8_t vdev_id,
471 			      uint8_t *peer_mac,
472 			      enum cdp_peer_stats_type type,
473 			      cdp_peer_stats_param_t *buf)
474 {
475 	if (!soc || !soc->ops) {
476 		dp_cdp_debug("Invalid Instance");
477 		QDF_BUG(0);
478 		return QDF_STATUS_E_FAILURE;
479 	}
480 
481 	if (!soc->ops->host_stats_ops ||
482 	    !soc->ops->host_stats_ops->txrx_get_peer_stats_param)
483 		return QDF_STATUS_E_FAILURE;
484 
485 	return soc->ops->host_stats_ops->txrx_get_peer_stats_param(soc,
486 								   vdev_id,
487 								   peer_mac,
488 								   type,
489 								   buf);
490 }
491 
492 /**
493  * cdp_host_get_soc_stats() - Call to get soc stats
494  * @soc: soc handle
495  * @soc_stats: buffer for cdp soc stats
496  *
497  * Return: QDF_STATUS
498  */
499 static inline QDF_STATUS
500 cdp_host_get_soc_stats(ol_txrx_soc_handle soc, struct cdp_soc_stats *soc_stats)
501 {
502 	if (!soc || !soc->ops) {
503 		dp_cdp_debug("Invalid Instance");
504 		QDF_BUG(0);
505 		return QDF_STATUS_E_FAILURE;
506 	}
507 
508 	if (!soc->ops->host_stats_ops ||
509 	    !soc->ops->host_stats_ops->txrx_get_soc_stats)
510 		return QDF_STATUS_E_FAILURE;
511 
512 	return soc->ops->host_stats_ops->txrx_get_soc_stats(soc, soc_stats);
513 }
514 
515 /**
516  * cdp_host_get_peer_stats() - Call to get peer stats
517  * @soc: soc handle
518  * @vdev_id: vdev_id of vdev object
519  * @peer_mac: mac address of the peer
520  * @peer_stats: destination buffer
521  *
522  * Return: QDF_STATUS
523  */
524 static inline QDF_STATUS
525 cdp_host_get_peer_stats(ol_txrx_soc_handle soc, uint8_t vdev_id,
526 			uint8_t *peer_mac,
527 			struct cdp_peer_stats *peer_stats)
528 {
529 	if (!soc || !soc->ops) {
530 		dp_cdp_debug("Invalid Instance");
531 		QDF_BUG(0);
532 		return QDF_STATUS_E_FAILURE;
533 	}
534 
535 	if (!soc->ops->host_stats_ops ||
536 	    !soc->ops->host_stats_ops->txrx_get_peer_stats)
537 		return QDF_STATUS_E_FAILURE;
538 
539 	return soc->ops->host_stats_ops->txrx_get_peer_stats(soc, vdev_id,
540 							     peer_mac,
541 							     peer_stats);
542 }
543 
544 /**
545  * cdp_host_get_per_link_peer_stats() - Call to get peer stats
546  * @soc: soc handle
547  * @vdev_id: vdev_id of vdev object
548  * @peer_mac: mac address of the peer
549  * @peer_stats: destination buffer
550  * @peer_type: Peer type
551  * @num_link: Number of ML links
552  *
553  * NOTE: For peer_type = CDP_MLD_PEER_TYPE peer_stats should point to
554  *       buffer of size = (sizeof(*peer_stats) * num_link)
555  *
556  * Return: QDF_STATUS
557  */
558 static inline QDF_STATUS
559 cdp_host_get_per_link_peer_stats(ol_txrx_soc_handle soc, uint8_t vdev_id,
560 				 uint8_t *peer_mac,
561 				 struct cdp_peer_stats *peer_stats,
562 				 enum cdp_peer_type peer_type,
563 				 uint8_t num_link)
564 {
565 	if (!soc || !soc->ops) {
566 		dp_cdp_debug("Invalid Instance");
567 		QDF_BUG(0);
568 		return QDF_STATUS_E_FAILURE;
569 	}
570 
571 	if (!soc->ops->host_stats_ops ||
572 	    !soc->ops->host_stats_ops->txrx_get_per_link_stats)
573 		return QDF_STATUS_E_FAILURE;
574 
575 	return soc->ops->host_stats_ops->txrx_get_per_link_stats(soc, vdev_id,
576 								 peer_mac,
577 								 peer_stats,
578 								 peer_type,
579 								 num_link);
580 }
581 
582 /**
583  * cdp_host_reset_peer_ald_stats() - Call to reset ald stats
584  * @soc: soc handle
585  * @vdev_id: vdev_id of vdev object
586  * @peer_mac: mac address of the peer
587  *
588  * Return: QDF_STATUS
589  */
590 static inline QDF_STATUS
591 cdp_host_reset_peer_ald_stats(ol_txrx_soc_handle soc, uint8_t vdev_id,
592 			      uint8_t *peer_mac)
593 {
594 	if (!soc || !soc->ops) {
595 		dp_cdp_debug("Invalid Instance");
596 		QDF_BUG(0);
597 		return QDF_STATUS_E_FAILURE;
598 	}
599 
600 	if (!soc->ops->host_stats_ops ||
601 	    !soc->ops->host_stats_ops->txrx_reset_peer_ald_stats)
602 		return QDF_STATUS_E_FAILURE;
603 
604 	return soc->ops->host_stats_ops->txrx_reset_peer_ald_stats(soc,
605 							    vdev_id,
606 							    peer_mac);
607 }
608 
609 /**
610  * cdp_host_reset_peer_stats() - Call to reset peer stats
611  * @soc: soc handle
612  * @vdev_id: vdev_id of vdev object
613  * @peer_mac: mac address of the peer
614  *
615  * Return: QDF_STATUS
616  */
617 static inline QDF_STATUS
618 cdp_host_reset_peer_stats(ol_txrx_soc_handle soc,
619 			  uint8_t vdev_id, uint8_t *peer_mac)
620 {
621 	if (!soc || !soc->ops) {
622 		dp_cdp_debug("Invalid Instance");
623 		QDF_BUG(0);
624 		return QDF_STATUS_E_FAILURE;
625 	}
626 
627 	if (!soc->ops->host_stats_ops ||
628 	    !soc->ops->host_stats_ops->txrx_reset_peer_stats)
629 		return QDF_STATUS_E_FAILURE;
630 
631 	return soc->ops->host_stats_ops->txrx_reset_peer_stats(soc,
632 							vdev_id,
633 							peer_mac);
634 }
635 
636 /**
637  * cdp_host_get_vdev_stats() - Call to get vdev stats
638  * @soc: dp soc object
639  * @vdev_id: id of dp vdev object
640  * @buf: buffer
641  * @is_aggregate:
642  *
643  * Return: int
644  */
645 static inline int
646 cdp_host_get_vdev_stats(ol_txrx_soc_handle soc,
647 			uint8_t vdev_id,
648 			struct cdp_vdev_stats *buf,
649 			bool is_aggregate)
650 {
651 	if (!soc || !soc->ops) {
652 		dp_cdp_debug("Invalid Instance");
653 		QDF_BUG(0);
654 		return 0;
655 	}
656 
657 	if (!soc->ops->host_stats_ops ||
658 	    !soc->ops->host_stats_ops->txrx_get_vdev_stats)
659 		return 0;
660 
661 	return soc->ops->host_stats_ops->txrx_get_vdev_stats(soc, vdev_id,
662 							     buf,
663 							     is_aggregate);
664 }
665 
666 /**
667  * cdp_update_host_vdev_stats() - Call to update vdev stats received from
668  * firmware (wmi_host_vdev_stats and wmi_host_vdev_extd_stats) into dp
669  * @soc: soc handle
670  * @data: stats data to be updated
671  * @size: size of stats data
672  * @stats_id: stats id
673  *
674  * Return: int
675  */
676 static inline int
677 cdp_update_host_vdev_stats(ol_txrx_soc_handle soc,
678 			   void *data,
679 			   uint32_t size,
680 			   uint32_t stats_id)
681 {
682 	if (!soc || !soc->ops) {
683 		dp_cdp_debug("Invalid Instance");
684 		QDF_BUG(0);
685 		return 0;
686 	}
687 
688 	if (!soc->ops->host_stats_ops ||
689 	    !soc->ops->host_stats_ops->txrx_process_wmi_host_vdev_stats)
690 		return 0;
691 
692 	return soc->ops->host_stats_ops->txrx_process_wmi_host_vdev_stats
693 								(soc,
694 								 data,
695 								 size,
696 								 stats_id);
697 }
698 
699 /**
700  * cdp_get_vdev_extd_stats() - Call to get vdev extd stats
701  * @soc: soc handle
702  * @vdev_id: id of dp vdev object
703  * @buf: buffer
704  *
705  * Return: int
706  */
707 static inline int
708 cdp_get_vdev_extd_stats(ol_txrx_soc_handle soc,
709 			uint8_t vdev_id,
710 			wmi_host_vdev_extd_stats *buf)
711 {
712 	if (!soc || !soc->ops) {
713 		dp_cdp_debug("Invalid Instance");
714 		QDF_BUG(0);
715 		return 0;
716 	}
717 
718 	if (!soc->ops->host_stats_ops ||
719 	    !soc->ops->host_stats_ops->txrx_get_vdev_extd_stats)
720 		return 0;
721 
722 	return soc->ops->host_stats_ops->txrx_get_vdev_extd_stats(soc, vdev_id,
723 								  buf);
724 }
725 
726 /**
727  * cdp_host_get_pdev_stats() - Call to get cdp_pdev_stats
728  * @soc: soc handle
729  * @pdev_id: id of dp pdev object
730  * @buf: buffer to hold cdp_pdev_stats
731  *
732  * Return: success/failure
733  */
734 static inline int
735 cdp_host_get_pdev_stats(ol_txrx_soc_handle soc,
736 			uint8_t pdev_id, struct cdp_pdev_stats *buf)
737 {
738 	if (!soc || !soc->ops) {
739 		dp_cdp_debug("Invalid Instance");
740 		QDF_BUG(0);
741 		return 0;
742 	}
743 
744 	if (!soc->ops->host_stats_ops ||
745 	    !soc->ops->host_stats_ops->txrx_get_pdev_stats)
746 		return 0;
747 
748 	return soc->ops->host_stats_ops->txrx_get_pdev_stats(soc, pdev_id, buf);
749 }
750 
751 /**
752  * cdp_host_get_radio_stats() - Call to get radio stats
753  * @soc: soc handle
754  * @pdev_id: id of dp pdev object
755  * @buf: stats buffer
756  *
757  * Return: int
758  */
759 static inline int
760 cdp_host_get_radio_stats(ol_txrx_soc_handle soc,
761 			 uint8_t pdev_id,
762 			 void *buf)
763 {
764 	if (!soc || !soc->ops) {
765 		dp_cdp_debug("Invalid Instance");
766 		QDF_BUG(0);
767 		return 0;
768 	}
769 
770 	if (!soc->ops->host_stats_ops ||
771 	    !soc->ops->host_stats_ops->txrx_get_radio_stats)
772 		return 0;
773 
774 	return soc->ops->host_stats_ops->txrx_get_radio_stats(soc, pdev_id,
775 							      buf);
776 }
777 
778 #ifdef QCA_SUPPORT_SCAN_SPCL_VAP_STATS
779 static inline int
780 cdp_get_scan_spcl_vap_stats(ol_txrx_soc_handle soc,
781 			    uint8_t vdev_id,
782 			    struct cdp_scan_spcl_vap_stats *stats)
783 {
784 	if (!soc || !soc->ops) {
785 		dp_cdp_debug("Invalid Instance");
786 		QDF_BUG(0);
787 		return QDF_STATUS_E_FAILURE;
788 	}
789 
790 	if (!soc->ops->host_stats_ops ||
791 	    !soc->ops->host_stats_ops->txrx_get_scan_spcl_vap_stats)
792 		return QDF_STATUS_E_FAILURE;
793 
794 	return soc->ops->host_stats_ops->txrx_get_scan_spcl_vap_stats(soc,
795 								      vdev_id,
796 								      stats);
797 }
798 #endif
799 
800 /**
801  * cdp_get_peer_delay_stats() - Call to get per peer delay stats
802  * @soc: soc handle
803  * @vdev_id: id of dp_vdev handle
804  * @peer_mac: peer mac address
805  * @delay_stats: user allocated buffer for peer delay stats
806  *
807  * Return: status Success/Failure
808  */
809 static inline QDF_STATUS
810 cdp_get_peer_delay_stats(ol_txrx_soc_handle soc,
811 			 uint8_t vdev_id,
812 			 uint8_t *peer_mac,
813 			 struct cdp_delay_tid_stats *delay_stats)
814 {
815 	if (!soc || !soc->ops) {
816 		dp_cdp_debug("Invalid Instance");
817 		QDF_BUG(0);
818 		return QDF_STATUS_E_FAILURE;
819 	}
820 
821 	if (!soc->ops->host_stats_ops ||
822 	    !soc->ops->host_stats_ops->txrx_get_peer_delay_stats)
823 		return QDF_STATUS_E_FAILURE;
824 
825 	return soc->ops->host_stats_ops->txrx_get_peer_delay_stats(soc,
826 								   vdev_id,
827 								   peer_mac,
828 								   delay_stats);
829 }
830 
831 /**
832  * cdp_get_peer_jitter_stats() - Call to get per peer jitter stats
833  * @soc: soc handle
834  * @pdev_id: id of dp_pdev handle
835  * @vdev_id: id of dp_vdev handle
836  * @peer_mac: peer mac address
837  * @tid_stats: user allocated buffer for tid_stats
838  *
839  * Return: status Success/Failure
840  */
841 static inline QDF_STATUS
842 cdp_get_peer_jitter_stats(ol_txrx_soc_handle soc,
843 			  uint8_t pdev_id,
844 			  uint8_t vdev_id,
845 			  uint8_t *peer_mac,
846 			  struct cdp_peer_tid_stats *tid_stats)
847 {
848 	if (!soc || !soc->ops) {
849 		dp_cdp_debug("Invalid Instance");
850 		QDF_BUG(0);
851 		return QDF_STATUS_E_FAILURE;
852 	}
853 
854 	if (!soc->ops->host_stats_ops ||
855 	    !soc->ops->host_stats_ops->txrx_get_peer_jitter_stats)
856 		return QDF_STATUS_E_FAILURE;
857 
858 	return soc->ops->host_stats_ops->txrx_get_peer_jitter_stats(soc,
859 								    pdev_id,
860 								    vdev_id,
861 								    peer_mac,
862 								    tid_stats);
863 }
864 
865 /**
866  * cdp_mon_pdev_get_rx_stats() - Call to get monitor pdev rx stats
867  * @soc: soc handle
868  * @pdev_id: id of dp_pdev handle
869  * @stats: user allocated buffer for dp pdev mon stats
870  *
871  * Return: status Success/Failure
872  */
873 static inline QDF_STATUS
874 cdp_mon_pdev_get_rx_stats(ol_txrx_soc_handle soc, uint8_t pdev_id,
875 			  struct cdp_pdev_mon_stats *stats)
876 {
877 	if (!soc || !soc->ops) {
878 		dp_cdp_debug("Invalid Instance");
879 		QDF_BUG(0);
880 		return QDF_STATUS_E_FAILURE;
881 	}
882 
883 	if (!soc->ops->mon_ops ||
884 	    !soc->ops->mon_ops->get_mon_pdev_rx_stats)
885 		return QDF_STATUS_E_FAILURE;
886 
887 	return soc->ops->mon_ops->get_mon_pdev_rx_stats(soc, pdev_id, stats);
888 }
889 
890 #ifdef WLAN_TX_PKT_CAPTURE_ENH
891 /**
892  * cdp_get_peer_tx_capture_stats() - Call to get peer tx capture stats
893  * @soc: soc handle
894  * @vdev_id: id of dp_vdev handle
895  * @peer_mac: peer mac address
896  * @stats: pointer to peer tx capture stats
897  *
898  * Return: status Success/Failure
899  */
900 static inline QDF_STATUS
901 cdp_get_peer_tx_capture_stats(ol_txrx_soc_handle soc,
902 			      uint8_t vdev_id,
903 			      uint8_t *peer_mac,
904 			      struct cdp_peer_tx_capture_stats *stats)
905 {
906 	if (!soc || !soc->ops) {
907 		dp_cdp_debug("Invalid Instance");
908 		QDF_BUG(0);
909 		return QDF_STATUS_E_FAILURE;
910 	}
911 
912 	if (!soc->ops->host_stats_ops ||
913 	    !soc->ops->host_stats_ops->get_peer_tx_capture_stats)
914 		return QDF_STATUS_E_FAILURE;
915 
916 	return soc->ops->host_stats_ops->get_peer_tx_capture_stats(soc, vdev_id,
917 								   peer_mac,
918 								   stats);
919 }
920 
921 /**
922  * cdp_get_pdev_tx_capture_stats() - Call to get pdev tx capture stats
923  * @soc: soc handle
924  * @pdev_id: id of dp_pdev handle
925  * @stats: pointer to pdev tx capture stats
926  *
927  * Return: status Success/Failure
928  */
929 static inline QDF_STATUS
930 cdp_get_pdev_tx_capture_stats(ol_txrx_soc_handle soc, uint8_t pdev_id,
931 			      struct cdp_pdev_tx_capture_stats *stats)
932 {
933 	if (!soc || !soc->ops) {
934 		dp_cdp_debug("Invalid Instance");
935 		QDF_BUG(0);
936 		return QDF_STATUS_E_FAILURE;
937 	}
938 
939 	if (!soc->ops->host_stats_ops ||
940 	    !soc->ops->host_stats_ops->get_pdev_tx_capture_stats)
941 		return QDF_STATUS_E_FAILURE;
942 
943 	return soc->ops->host_stats_ops->get_pdev_tx_capture_stats(soc, pdev_id,
944 								   stats);
945 }
946 #endif /* WLAN_TX_PKT_CAPTURE_ENH */
947 
948 #ifdef HW_TX_DELAY_STATS_ENABLE
949 /**
950  * cdp_enable_disable_vdev_tx_delay_stats() - Start/Stop tx delay stats capture
951  * @soc: soc handle
952  * @vdev_id: vdev id
953  * @value: value to be set
954  *
955  * Return: None
956  */
957 static inline void
958 cdp_enable_disable_vdev_tx_delay_stats(ol_txrx_soc_handle soc, uint8_t vdev_id,
959 				       uint8_t value)
960 {
961 	if (!soc || !soc->ops) {
962 		dp_cdp_debug("Invalid Instance");
963 		return;
964 	}
965 
966 	if (!soc->ops->host_stats_ops ||
967 	    !soc->ops->host_stats_ops->enable_disable_vdev_tx_delay_stats)
968 		return;
969 
970 	soc->ops->host_stats_ops->enable_disable_vdev_tx_delay_stats(soc,
971 								     vdev_id,
972 								     value);
973 }
974 
975 /**
976  * cdp_vdev_is_tx_delay_stats_enabled() - Check if the Tx delay stats
977  *  is enabled or not for the given vdev_id
978  * @soc: soc handle
979  * @vdev_id: vdev_id
980  *
981  * Return: 1 if enabled, 0 if disabled
982  */
983 static inline uint8_t
984 cdp_vdev_is_tx_delay_stats_enabled(ol_txrx_soc_handle soc, uint8_t vdev_id)
985 {
986 	if (!soc || !soc->ops || !soc->ops->host_stats_ops) {
987 		dp_cdp_debug("Invalid Instance:");
988 		return 0;
989 	}
990 
991 	if (soc->ops->host_stats_ops->is_tx_delay_stats_enabled)
992 		return soc->ops->host_stats_ops->is_tx_delay_stats_enabled(soc,
993 								     vdev_id);
994 
995 	return 0;
996 }
997 #endif
998 
999 /**
1000  * cdp_get_pdev_tid_stats() - Get pdev tid stats
1001  * @soc: soc handle
1002  * @pdev_id: Pdev id
1003  * @tid_stats: Pointer to cdp_tid_stats_intf
1004  *
1005  * Return: status Success/Failure
1006  */
1007 static inline QDF_STATUS
1008 cdp_get_pdev_tid_stats(ol_txrx_soc_handle soc, uint8_t pdev_id,
1009 		       struct cdp_tid_stats_intf *tid_stats)
1010 {
1011 	if (!soc || !soc->ops || !soc->ops->host_stats_ops) {
1012 		dp_cdp_debug("Invalid Instance:");
1013 		return QDF_STATUS_E_FAILURE;
1014 	}
1015 
1016 	if (!soc->ops->host_stats_ops->txrx_get_pdev_tid_stats)
1017 		return QDF_STATUS_E_FAILURE;
1018 
1019 	return soc->ops->host_stats_ops->txrx_get_pdev_tid_stats(soc, pdev_id,
1020 								 tid_stats);
1021 }
1022 
1023 #ifdef WLAN_CONFIG_TELEMETRY_AGENT
1024 /**
1025  * cdp_get_pdev_telemetry_stats() - function to get pdev telemetry stats
1026  * @soc: soc handle
1027  * @pdev_id: pdev id
1028  * @stats: pointer to pdev telemetry stats
1029  *
1030  * Return: status
1031  */
1032 static inline QDF_STATUS cdp_get_pdev_telemetry_stats(
1033 				ol_txrx_soc_handle soc,
1034 				uint8_t pdev_id,
1035 				struct cdp_pdev_telemetry_stats *stats)
1036 {
1037 	if (!soc || !soc->ops) {
1038 		dp_cdp_debug("Invalid Instance");
1039 		QDF_BUG(0);
1040 		return QDF_STATUS_E_FAILURE;
1041 	}
1042 
1043 	if (!soc->ops->host_stats_ops ||
1044 	    !soc->ops->host_stats_ops->txrx_pdev_telemetry_stats)
1045 		return QDF_STATUS_E_FAILURE;
1046 
1047 	return soc->ops->host_stats_ops->txrx_pdev_telemetry_stats(
1048 					soc, pdev_id, stats);
1049 }
1050 
1051 /**
1052  * cdp_get_peer_telemetry_stats() - function to get peer telemetry stats
1053  * @soc: soc handle
1054  * @addr: peer address
1055  * @stats: pointer to peer telemetry stats
1056  *
1057  * Return: status
1058  */
1059 static inline QDF_STATUS cdp_get_peer_telemetry_stats(
1060 				ol_txrx_soc_handle soc,
1061 				uint8_t *addr,
1062 				struct cdp_peer_telemetry_stats *stats)
1063 {
1064 	if (!soc || !soc->ops) {
1065 		dp_cdp_debug("Invalid Instance");
1066 		QDF_BUG(0);
1067 		return QDF_STATUS_E_FAILURE;
1068 	}
1069 
1070 	if (!soc->ops->host_stats_ops ||
1071 	    !soc->ops->host_stats_ops->txrx_peer_telemetry_stats)
1072 		return QDF_STATUS_E_FAILURE;
1073 
1074 	return soc->ops->host_stats_ops->txrx_peer_telemetry_stats(
1075 					soc, addr, stats);
1076 }
1077 
1078 /**
1079  * cdp_get_pdev_deter_stats(): function to get pdev deterministic stats
1080  * @soc: soc handle
1081  * @pdev_id: pdev id
1082  * @stats: pointer to pdev deterministic stats
1083  *
1084  * return: status
1085  */
1086 static inline QDF_STATUS cdp_get_pdev_deter_stats(
1087 				ol_txrx_soc_handle soc,
1088 				uint8_t pdev_id,
1089 				struct cdp_pdev_deter_stats *stats)
1090 {
1091 	if (!soc || !soc->ops) {
1092 		dp_cdp_debug("Invalid Instance");
1093 		QDF_BUG(0);
1094 		return QDF_STATUS_E_FAILURE;
1095 	}
1096 
1097 	if (!soc->ops->host_stats_ops ||
1098 	    !soc->ops->host_stats_ops->txrx_pdev_deter_stats)
1099 		return QDF_STATUS_E_FAILURE;
1100 
1101 	return soc->ops->host_stats_ops->txrx_pdev_deter_stats(
1102 					soc, pdev_id, stats);
1103 }
1104 
1105 /**
1106  * cdp_get_peer_deter_stats(): function to get peer deterministic stats
1107  * @soc: soc handle
1108  * @vdev_id: id of vdev handle
1109  * @addr: peer address
1110  * @stats: pointer to peer telemetry stats
1111  *
1112  * return: status
1113  */
1114 static inline QDF_STATUS cdp_get_peer_deter_stats(
1115 				ol_txrx_soc_handle soc,
1116 				uint8_t vdev_id,
1117 				uint8_t *addr,
1118 				struct cdp_peer_deter_stats *stats)
1119 {
1120 	if (!soc || !soc->ops) {
1121 		dp_cdp_debug("Invalid Instance");
1122 		QDF_BUG(0);
1123 		return QDF_STATUS_E_FAILURE;
1124 	}
1125 
1126 	if (!soc->ops->host_stats_ops ||
1127 	    !soc->ops->host_stats_ops->txrx_peer_deter_stats)
1128 		return QDF_STATUS_E_FAILURE;
1129 
1130 	return soc->ops->host_stats_ops->txrx_peer_deter_stats(
1131 					soc, vdev_id, addr, stats);
1132 }
1133 
1134 /**
1135  * cdp_update_pdev_chan_util_stats(): function to update pdev channel util stats
1136  * @soc: soc handle
1137  * @pdev_id: pdev id
1138  * @ch_util: pointer to pdev ch util stats
1139  *
1140  * return: status
1141  */
1142 static inline QDF_STATUS cdp_update_pdev_chan_util_stats(
1143 				ol_txrx_soc_handle soc,
1144 				uint8_t pdev_id,
1145 				struct cdp_pdev_chan_util_stats *ch_util)
1146 {
1147 	if (!soc || !soc->ops) {
1148 		dp_cdp_debug("Invalid Instance");
1149 		QDF_BUG(0);
1150 		return QDF_STATUS_E_FAILURE;
1151 	}
1152 
1153 	if (!soc->ops->host_stats_ops ||
1154 	    !soc->ops->host_stats_ops->txrx_update_pdev_chan_util_stats)
1155 		return QDF_STATUS_E_FAILURE;
1156 
1157 	return soc->ops->host_stats_ops->txrx_update_pdev_chan_util_stats(
1158 					soc, pdev_id, ch_util);
1159 }
1160 #endif
1161 
1162 /**
1163  * cdp_get_peer_extd_rate_link_stats() - cdp function to get peer
1164  *				extended rate and link stats
1165  * @soc: soc handle
1166  * @mac_addr: mac address
1167  *
1168  * Return: status
1169  */
1170 static inline QDF_STATUS cdp_get_peer_extd_rate_link_stats(
1171 					ol_txrx_soc_handle soc,
1172 					uint8_t *mac_addr)
1173 {
1174 	if (!soc || !soc->ops) {
1175 		dp_cdp_debug("Invalid Instance");
1176 		QDF_BUG(0);
1177 		return QDF_STATUS_E_FAILURE;
1178 	}
1179 
1180 	if (!soc->ops->host_stats_ops ||
1181 	    !soc->ops->host_stats_ops->txrx_get_peer_extd_rate_link_stats)
1182 		return QDF_STATUS_E_FAILURE;
1183 
1184 	return soc->ops->host_stats_ops->txrx_get_peer_extd_rate_link_stats(
1185 								soc, mac_addr);
1186 }
1187 
1188 /**
1189  * cdp_get_pdev_obss_pd_stats() - function to get pdev obss stats
1190  * @soc: soc handle
1191  * @pdev_id: pdev id
1192  * @stats: pointer to pdev obss stats
1193  * @req: Pointer to CDP TxRx stats
1194  *
1195  * Return: status
1196  */
1197 static inline QDF_STATUS cdp_get_pdev_obss_pd_stats(
1198 				ol_txrx_soc_handle soc,
1199 				uint8_t pdev_id,
1200 				struct cdp_pdev_obss_pd_stats_tlv *stats,
1201 				struct cdp_txrx_stats_req *req)
1202 {
1203 	if (!soc || !soc->ops) {
1204 		dp_cdp_debug("Invalid Instance");
1205 		QDF_BUG(0);
1206 		return QDF_STATUS_E_FAILURE;
1207 	}
1208 
1209 	if (!soc->ops->host_stats_ops ||
1210 	    !soc->ops->host_stats_ops->get_pdev_obss_stats)
1211 		return QDF_STATUS_E_FAILURE;
1212 
1213 	return soc->ops->host_stats_ops->get_pdev_obss_stats(
1214 				     soc, pdev_id, stats, req);
1215 }
1216 
1217 /**
1218  * cdp_clear_pdev_obss_pd_stats() - function to clear pdev obss stats
1219  * @soc: soc handle
1220  * @pdev_id: pdev id
1221  * @req: Pointer to CDP TxRx stats request. mac_id will be pre-filled
1222  *	 and should not be overwritten
1223  *
1224  * Return: status
1225  */
1226 static inline QDF_STATUS cdp_clear_pdev_obss_pd_stats(
1227 				ol_txrx_soc_handle soc,
1228 				uint8_t pdev_id, struct cdp_txrx_stats_req *req)
1229 {
1230 	if (!soc || !soc->ops) {
1231 		dp_cdp_debug("Invalid Instance");
1232 		QDF_BUG(0);
1233 		return QDF_STATUS_E_FAILURE;
1234 	}
1235 
1236 	if (!soc->ops->host_stats_ops ||
1237 	    !soc->ops->host_stats_ops->clear_pdev_obss_pd_stats)
1238 		return QDF_STATUS_E_FAILURE;
1239 
1240 	return soc->ops->host_stats_ops->clear_pdev_obss_pd_stats(
1241 					soc, pdev_id, req);
1242 }
1243 #endif /* _CDP_TXRX_HOST_STATS_H_ */
1244