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 */
cdp_host_stats_get(ol_txrx_soc_handle soc,uint8_t vdev_id,struct ol_txrx_stats_req * req)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 */
cdp_host_stats_get_ratekbps(ol_txrx_soc_handle soc,int preamb,int mcs,int htflag,int gintval)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
cdp_host_stats_clr(ol_txrx_soc_handle soc,uint8_t vdev_id)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
cdp_host_ce_stats(ol_txrx_soc_handle soc,uint8_t vdev_id)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
cdp_stats_publish(ol_txrx_soc_handle soc,uint8_t pdev_id,struct cdp_stats_extd * buf)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
cdp_enable_enhanced_stats(ol_txrx_soc_handle soc,uint8_t pdev_id)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
cdp_disable_enhanced_stats(ol_txrx_soc_handle soc,uint8_t pdev_id)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
cdp_tx_print_tso_stats(ol_txrx_soc_handle soc,uint8_t vdev_id)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
cdp_tx_rst_tso_stats(ol_txrx_soc_handle soc,uint8_t vdev_id)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
cdp_tx_print_sg_stats(ol_txrx_soc_handle soc,uint8_t vdev_id)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
cdp_tx_rst_sg_stats(ol_txrx_soc_handle soc,uint8_t vdev_id)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
cdp_print_rx_cksum_stats(ol_txrx_soc_handle soc,uint8_t vdev_id)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
cdp_rst_rx_cksum_stats(ol_txrx_soc_handle soc,uint8_t vdev_id)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
cdp_host_me_stats(ol_txrx_soc_handle soc,uint8_t vdev_id)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 */
cdp_per_peer_stats(ol_txrx_soc_handle soc,uint8_t * addr)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
cdp_host_msdu_ttl_stats(ol_txrx_soc_handle soc,uint8_t vdev_id,struct ol_txrx_stats_req * req)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
cdp_update_peer_stats(ol_txrx_soc_handle soc,uint8_t vdev_id,uint8_t * mac,void * stats,uint32_t last_tx_rate_mcs,uint32_t stats_id)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
cdp_get_dp_fw_peer_stats(ol_txrx_soc_handle soc,uint8_t pdev_id,uint8_t * mac,uint32_t caps,uint32_t copy_stats)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
cdp_get_dp_htt_stats(ol_txrx_soc_handle soc,uint8_t pdev_id,void * data,uint32_t data_len)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
cdp_update_pdev_host_stats(ol_txrx_soc_handle soc,uint8_t pdev_id,void * data,uint16_t stats_id)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 * @xmit_type: xmit type, MLO/Legacy
436 * Return: QDF_STATUS
437 */
438 static inline QDF_STATUS
cdp_update_vdev_host_stats(ol_txrx_soc_handle soc,uint8_t vdev_id,void * data,uint16_t stats_id,uint8_t xmit_type)439 cdp_update_vdev_host_stats(ol_txrx_soc_handle soc,
440 uint8_t vdev_id,
441 void *data,
442 uint16_t stats_id, uint8_t xmit_type)
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 xmit_type);
458 }
459
460 /**
461 * cdp_txrx_get_peer_stats_param() - Call to get specified peer stats
462 * @soc: soc handle
463 * @vdev_id: vdev_id of vdev object
464 * @peer_mac: mac address of the peer
465 * @type: enum of required stats
466 * @buf: buffer to hold the value
467 *
468 * Return: QDF_STATUS
469 */
470 static inline QDF_STATUS
cdp_txrx_get_peer_stats_param(ol_txrx_soc_handle soc,uint8_t vdev_id,uint8_t * peer_mac,enum cdp_peer_stats_type type,cdp_peer_stats_param_t * buf)471 cdp_txrx_get_peer_stats_param(ol_txrx_soc_handle soc, uint8_t vdev_id,
472 uint8_t *peer_mac,
473 enum cdp_peer_stats_type type,
474 cdp_peer_stats_param_t *buf)
475 {
476 if (!soc || !soc->ops) {
477 dp_cdp_debug("Invalid Instance");
478 QDF_BUG(0);
479 return QDF_STATUS_E_FAILURE;
480 }
481
482 if (!soc->ops->host_stats_ops ||
483 !soc->ops->host_stats_ops->txrx_get_peer_stats_param)
484 return QDF_STATUS_E_FAILURE;
485
486 return soc->ops->host_stats_ops->txrx_get_peer_stats_param(soc,
487 vdev_id,
488 peer_mac,
489 type,
490 buf);
491 }
492
493 /**
494 * cdp_host_get_soc_stats() - Call to get soc stats
495 * @soc: soc handle
496 * @soc_stats: buffer for cdp soc stats
497 *
498 * Return: QDF_STATUS
499 */
500 static inline QDF_STATUS
cdp_host_get_soc_stats(ol_txrx_soc_handle soc,struct cdp_soc_stats * soc_stats)501 cdp_host_get_soc_stats(ol_txrx_soc_handle soc, struct cdp_soc_stats *soc_stats)
502 {
503 if (!soc || !soc->ops) {
504 dp_cdp_debug("Invalid Instance");
505 QDF_BUG(0);
506 return QDF_STATUS_E_FAILURE;
507 }
508
509 if (!soc->ops->host_stats_ops ||
510 !soc->ops->host_stats_ops->txrx_get_soc_stats)
511 return QDF_STATUS_E_FAILURE;
512
513 return soc->ops->host_stats_ops->txrx_get_soc_stats(soc, soc_stats);
514 }
515
516 /**
517 * cdp_host_get_peer_stats() - Call to get peer stats
518 * @soc: soc handle
519 * @vdev_id: vdev_id of vdev object
520 * @peer_mac: mac address of the peer
521 * @peer_stats: destination buffer
522 *
523 * Return: QDF_STATUS
524 */
525 static inline QDF_STATUS
cdp_host_get_peer_stats(ol_txrx_soc_handle soc,uint8_t vdev_id,uint8_t * peer_mac,struct cdp_peer_stats * peer_stats)526 cdp_host_get_peer_stats(ol_txrx_soc_handle soc, uint8_t vdev_id,
527 uint8_t *peer_mac,
528 struct cdp_peer_stats *peer_stats)
529 {
530 if (!soc || !soc->ops) {
531 dp_cdp_debug("Invalid Instance");
532 QDF_BUG(0);
533 return QDF_STATUS_E_FAILURE;
534 }
535
536 if (!soc->ops->host_stats_ops ||
537 !soc->ops->host_stats_ops->txrx_get_peer_stats)
538 return QDF_STATUS_E_FAILURE;
539
540 return soc->ops->host_stats_ops->txrx_get_peer_stats(soc, vdev_id,
541 peer_mac,
542 peer_stats);
543 }
544
545
546 /**
547 * cdp_host_get_peer_stats_based_on_peer_type() - Fetch peer stats based on the
548 * peer type
549 * @soc: soc handle
550 * @vdev_id: vdev_id of vdev object
551 * @peer_mac: mac address of the peer
552 * @peer_stats: destination buffer
553 * @peer_type: type of peer
554 *
555 * Return: QDF_STATUS
556 */
557 static inline QDF_STATUS
cdp_host_get_peer_stats_based_on_peer_type(ol_txrx_soc_handle soc,uint8_t vdev_id,uint8_t * peer_mac,struct cdp_peer_stats * peer_stats,enum cdp_peer_type peer_type)558 cdp_host_get_peer_stats_based_on_peer_type(ol_txrx_soc_handle soc, uint8_t vdev_id,
559 uint8_t *peer_mac,
560 struct cdp_peer_stats *peer_stats,
561 enum cdp_peer_type peer_type)
562 {
563 if (!soc || !soc->ops) {
564 dp_cdp_debug("Invalid Instance");
565 QDF_BUG(0);
566 return QDF_STATUS_E_FAILURE;
567 }
568
569 if (!soc->ops->host_stats_ops ||
570 !soc->ops->host_stats_ops->txrx_get_peer_stats_based_on_peer_type)
571 return QDF_STATUS_E_FAILURE;
572
573 return soc->ops->host_stats_ops->txrx_get_peer_stats_based_on_peer_type(
574 soc, vdev_id,
575 peer_mac,
576 peer_stats,
577 peer_type);
578 }
579
580 /**
581 * cdp_host_get_per_link_peer_stats() - Call to get peer stats
582 * @soc: soc handle
583 * @vdev_id: vdev_id of vdev object
584 * @peer_mac: mac address of the peer
585 * @peer_stats: destination buffer
586 * @peer_type: Peer type
587 * @num_link: Number of ML links
588 *
589 * NOTE: For peer_type = CDP_MLD_PEER_TYPE peer_stats should point to
590 * buffer of size = (sizeof(*peer_stats) * num_link)
591 *
592 * Return: QDF_STATUS
593 */
594 static inline QDF_STATUS
cdp_host_get_per_link_peer_stats(ol_txrx_soc_handle soc,uint8_t vdev_id,uint8_t * peer_mac,struct cdp_peer_stats * peer_stats,enum cdp_peer_type peer_type,uint8_t num_link)595 cdp_host_get_per_link_peer_stats(ol_txrx_soc_handle soc, uint8_t vdev_id,
596 uint8_t *peer_mac,
597 struct cdp_peer_stats *peer_stats,
598 enum cdp_peer_type peer_type,
599 uint8_t num_link)
600 {
601 if (!soc || !soc->ops) {
602 dp_cdp_debug("Invalid Instance");
603 QDF_BUG(0);
604 return QDF_STATUS_E_FAILURE;
605 }
606
607 if (!soc->ops->host_stats_ops ||
608 !soc->ops->host_stats_ops->txrx_get_per_link_stats)
609 return QDF_STATUS_E_FAILURE;
610
611 return soc->ops->host_stats_ops->txrx_get_per_link_stats(soc, vdev_id,
612 peer_mac,
613 peer_stats,
614 peer_type,
615 num_link);
616 }
617
618 /**
619 * cdp_host_reset_peer_ald_stats() - Call to reset ald stats
620 * @soc: soc handle
621 * @vdev_id: vdev_id of vdev object
622 * @peer_mac: mac address of the peer
623 *
624 * Return: QDF_STATUS
625 */
626 static inline QDF_STATUS
cdp_host_reset_peer_ald_stats(ol_txrx_soc_handle soc,uint8_t vdev_id,uint8_t * peer_mac)627 cdp_host_reset_peer_ald_stats(ol_txrx_soc_handle soc, uint8_t vdev_id,
628 uint8_t *peer_mac)
629 {
630 if (!soc || !soc->ops) {
631 dp_cdp_debug("Invalid Instance");
632 QDF_BUG(0);
633 return QDF_STATUS_E_FAILURE;
634 }
635
636 if (!soc->ops->host_stats_ops ||
637 !soc->ops->host_stats_ops->txrx_reset_peer_ald_stats)
638 return QDF_STATUS_E_FAILURE;
639
640 return soc->ops->host_stats_ops->txrx_reset_peer_ald_stats(soc,
641 vdev_id,
642 peer_mac);
643 }
644
645 /**
646 * cdp_host_reset_peer_stats() - Call to reset peer stats
647 * @soc: soc handle
648 * @vdev_id: vdev_id of vdev object
649 * @peer_mac: mac address of the peer
650 *
651 * Return: QDF_STATUS
652 */
653 static inline QDF_STATUS
cdp_host_reset_peer_stats(ol_txrx_soc_handle soc,uint8_t vdev_id,uint8_t * peer_mac)654 cdp_host_reset_peer_stats(ol_txrx_soc_handle soc,
655 uint8_t vdev_id, uint8_t *peer_mac)
656 {
657 if (!soc || !soc->ops) {
658 dp_cdp_debug("Invalid Instance");
659 QDF_BUG(0);
660 return QDF_STATUS_E_FAILURE;
661 }
662
663 if (!soc->ops->host_stats_ops ||
664 !soc->ops->host_stats_ops->txrx_reset_peer_stats)
665 return QDF_STATUS_E_FAILURE;
666
667 return soc->ops->host_stats_ops->txrx_reset_peer_stats(soc,
668 vdev_id,
669 peer_mac);
670 }
671
672 /**
673 * cdp_host_get_vdev_stats() - Call to get vdev stats
674 * @soc: dp soc object
675 * @vdev_id: id of dp vdev object
676 * @buf: buffer
677 * @is_aggregate:
678 *
679 * Return: int
680 */
681 static inline int
cdp_host_get_vdev_stats(ol_txrx_soc_handle soc,uint8_t vdev_id,struct cdp_vdev_stats * buf,bool is_aggregate)682 cdp_host_get_vdev_stats(ol_txrx_soc_handle soc,
683 uint8_t vdev_id,
684 struct cdp_vdev_stats *buf,
685 bool is_aggregate)
686 {
687 if (!soc || !soc->ops) {
688 dp_cdp_debug("Invalid Instance");
689 QDF_BUG(0);
690 return 0;
691 }
692
693 if (!soc->ops->host_stats_ops ||
694 !soc->ops->host_stats_ops->txrx_get_vdev_stats)
695 return 0;
696
697 return soc->ops->host_stats_ops->txrx_get_vdev_stats(soc, vdev_id,
698 buf,
699 is_aggregate);
700 }
701
702 /**
703 * cdp_update_host_vdev_stats() - Call to update vdev stats received from
704 * firmware (wmi_host_vdev_stats and wmi_host_vdev_extd_stats) into dp
705 * @soc: soc handle
706 * @data: stats data to be updated
707 * @size: size of stats data
708 * @stats_id: stats id
709 *
710 * Return: int
711 */
712 static inline int
cdp_update_host_vdev_stats(ol_txrx_soc_handle soc,void * data,uint32_t size,uint32_t stats_id)713 cdp_update_host_vdev_stats(ol_txrx_soc_handle soc,
714 void *data,
715 uint32_t size,
716 uint32_t stats_id)
717 {
718 if (!soc || !soc->ops) {
719 dp_cdp_debug("Invalid Instance");
720 QDF_BUG(0);
721 return 0;
722 }
723
724 if (!soc->ops->host_stats_ops ||
725 !soc->ops->host_stats_ops->txrx_process_wmi_host_vdev_stats)
726 return 0;
727
728 return soc->ops->host_stats_ops->txrx_process_wmi_host_vdev_stats
729 (soc,
730 data,
731 size,
732 stats_id);
733 }
734
735 /**
736 * cdp_get_vdev_extd_stats() - Call to get vdev extd stats
737 * @soc: soc handle
738 * @vdev_id: id of dp vdev object
739 * @buf: buffer
740 *
741 * Return: int
742 */
743 static inline int
cdp_get_vdev_extd_stats(ol_txrx_soc_handle soc,uint8_t vdev_id,wmi_host_vdev_extd_stats * buf)744 cdp_get_vdev_extd_stats(ol_txrx_soc_handle soc,
745 uint8_t vdev_id,
746 wmi_host_vdev_extd_stats *buf)
747 {
748 if (!soc || !soc->ops) {
749 dp_cdp_debug("Invalid Instance");
750 QDF_BUG(0);
751 return 0;
752 }
753
754 if (!soc->ops->host_stats_ops ||
755 !soc->ops->host_stats_ops->txrx_get_vdev_extd_stats)
756 return 0;
757
758 return soc->ops->host_stats_ops->txrx_get_vdev_extd_stats(soc, vdev_id,
759 buf);
760 }
761
762 /**
763 * cdp_host_get_pdev_stats() - Call to get cdp_pdev_stats
764 * @soc: soc handle
765 * @pdev_id: id of dp pdev object
766 * @buf: buffer to hold cdp_pdev_stats
767 *
768 * Return: success/failure
769 */
770 static inline int
cdp_host_get_pdev_stats(ol_txrx_soc_handle soc,uint8_t pdev_id,struct cdp_pdev_stats * buf)771 cdp_host_get_pdev_stats(ol_txrx_soc_handle soc,
772 uint8_t pdev_id, struct cdp_pdev_stats *buf)
773 {
774 if (!soc || !soc->ops) {
775 dp_cdp_debug("Invalid Instance");
776 QDF_BUG(0);
777 return 0;
778 }
779
780 if (!soc->ops->host_stats_ops ||
781 !soc->ops->host_stats_ops->txrx_get_pdev_stats)
782 return 0;
783
784 return soc->ops->host_stats_ops->txrx_get_pdev_stats(soc, pdev_id, buf);
785 }
786
787 /**
788 * cdp_host_get_radio_stats() - Call to get radio stats
789 * @soc: soc handle
790 * @pdev_id: id of dp pdev object
791 * @buf: stats buffer
792 *
793 * Return: int
794 */
795 static inline int
cdp_host_get_radio_stats(ol_txrx_soc_handle soc,uint8_t pdev_id,void * buf)796 cdp_host_get_radio_stats(ol_txrx_soc_handle soc,
797 uint8_t pdev_id,
798 void *buf)
799 {
800 if (!soc || !soc->ops) {
801 dp_cdp_debug("Invalid Instance");
802 QDF_BUG(0);
803 return 0;
804 }
805
806 if (!soc->ops->host_stats_ops ||
807 !soc->ops->host_stats_ops->txrx_get_radio_stats)
808 return 0;
809
810 return soc->ops->host_stats_ops->txrx_get_radio_stats(soc, pdev_id,
811 buf);
812 }
813
814 #ifdef QCA_SUPPORT_SCAN_SPCL_VAP_STATS
815 static inline int
cdp_get_scan_spcl_vap_stats(ol_txrx_soc_handle soc,uint8_t vdev_id,struct cdp_scan_spcl_vap_stats * stats)816 cdp_get_scan_spcl_vap_stats(ol_txrx_soc_handle soc,
817 uint8_t vdev_id,
818 struct cdp_scan_spcl_vap_stats *stats)
819 {
820 if (!soc || !soc->ops) {
821 dp_cdp_debug("Invalid Instance");
822 QDF_BUG(0);
823 return QDF_STATUS_E_FAILURE;
824 }
825
826 if (!soc->ops->host_stats_ops ||
827 !soc->ops->host_stats_ops->txrx_get_scan_spcl_vap_stats)
828 return QDF_STATUS_E_FAILURE;
829
830 return soc->ops->host_stats_ops->txrx_get_scan_spcl_vap_stats(soc,
831 vdev_id,
832 stats);
833 }
834 #endif
835
836 /**
837 * cdp_get_peer_delay_stats() - Call to get per peer delay stats
838 * @soc: soc handle
839 * @vdev_id: id of dp_vdev handle
840 * @peer_mac: peer mac address
841 * @delay_stats: user allocated buffer for peer delay stats
842 *
843 * Return: status Success/Failure
844 */
845 static inline QDF_STATUS
cdp_get_peer_delay_stats(ol_txrx_soc_handle soc,uint8_t vdev_id,uint8_t * peer_mac,struct cdp_delay_tid_stats * delay_stats)846 cdp_get_peer_delay_stats(ol_txrx_soc_handle soc,
847 uint8_t vdev_id,
848 uint8_t *peer_mac,
849 struct cdp_delay_tid_stats *delay_stats)
850 {
851 if (!soc || !soc->ops) {
852 dp_cdp_debug("Invalid Instance");
853 QDF_BUG(0);
854 return QDF_STATUS_E_FAILURE;
855 }
856
857 if (!soc->ops->host_stats_ops ||
858 !soc->ops->host_stats_ops->txrx_get_peer_delay_stats)
859 return QDF_STATUS_E_FAILURE;
860
861 return soc->ops->host_stats_ops->txrx_get_peer_delay_stats(soc,
862 vdev_id,
863 peer_mac,
864 delay_stats);
865 }
866
867 /**
868 * cdp_get_peer_jitter_stats() - Call to get per peer jitter stats
869 * @soc: soc handle
870 * @pdev_id: id of dp_pdev handle
871 * @vdev_id: id of dp_vdev handle
872 * @peer_mac: peer mac address
873 * @tid_stats: user allocated buffer for tid_stats
874 *
875 * Return: status Success/Failure
876 */
877 static inline QDF_STATUS
cdp_get_peer_jitter_stats(ol_txrx_soc_handle soc,uint8_t pdev_id,uint8_t vdev_id,uint8_t * peer_mac,struct cdp_peer_tid_stats * tid_stats)878 cdp_get_peer_jitter_stats(ol_txrx_soc_handle soc,
879 uint8_t pdev_id,
880 uint8_t vdev_id,
881 uint8_t *peer_mac,
882 struct cdp_peer_tid_stats *tid_stats)
883 {
884 if (!soc || !soc->ops) {
885 dp_cdp_debug("Invalid Instance");
886 QDF_BUG(0);
887 return QDF_STATUS_E_FAILURE;
888 }
889
890 if (!soc->ops->host_stats_ops ||
891 !soc->ops->host_stats_ops->txrx_get_peer_jitter_stats)
892 return QDF_STATUS_E_FAILURE;
893
894 return soc->ops->host_stats_ops->txrx_get_peer_jitter_stats(soc,
895 pdev_id,
896 vdev_id,
897 peer_mac,
898 tid_stats);
899 }
900
901 /**
902 * cdp_mon_pdev_get_rx_stats() - Call to get monitor pdev rx stats
903 * @soc: soc handle
904 * @pdev_id: id of dp_pdev handle
905 * @stats: user allocated buffer for dp pdev mon stats
906 *
907 * Return: status Success/Failure
908 */
909 static inline QDF_STATUS
cdp_mon_pdev_get_rx_stats(ol_txrx_soc_handle soc,uint8_t pdev_id,struct cdp_pdev_mon_stats * stats)910 cdp_mon_pdev_get_rx_stats(ol_txrx_soc_handle soc, uint8_t pdev_id,
911 struct cdp_pdev_mon_stats *stats)
912 {
913 if (!soc || !soc->ops) {
914 dp_cdp_debug("Invalid Instance");
915 QDF_BUG(0);
916 return QDF_STATUS_E_FAILURE;
917 }
918
919 if (!soc->ops->mon_ops ||
920 !soc->ops->mon_ops->get_mon_pdev_rx_stats)
921 return QDF_STATUS_E_FAILURE;
922
923 return soc->ops->mon_ops->get_mon_pdev_rx_stats(soc, pdev_id, stats);
924 }
925
926 #ifdef WLAN_TX_PKT_CAPTURE_ENH
927 /**
928 * cdp_get_peer_tx_capture_stats() - Call to get peer tx capture stats
929 * @soc: soc handle
930 * @vdev_id: id of dp_vdev handle
931 * @peer_mac: peer mac address
932 * @stats: pointer to peer tx capture stats
933 *
934 * Return: status Success/Failure
935 */
936 static inline QDF_STATUS
cdp_get_peer_tx_capture_stats(ol_txrx_soc_handle soc,uint8_t vdev_id,uint8_t * peer_mac,struct cdp_peer_tx_capture_stats * stats)937 cdp_get_peer_tx_capture_stats(ol_txrx_soc_handle soc,
938 uint8_t vdev_id,
939 uint8_t *peer_mac,
940 struct cdp_peer_tx_capture_stats *stats)
941 {
942 if (!soc || !soc->ops) {
943 dp_cdp_debug("Invalid Instance");
944 QDF_BUG(0);
945 return QDF_STATUS_E_FAILURE;
946 }
947
948 if (!soc->ops->host_stats_ops ||
949 !soc->ops->host_stats_ops->get_peer_tx_capture_stats)
950 return QDF_STATUS_E_FAILURE;
951
952 return soc->ops->host_stats_ops->get_peer_tx_capture_stats(soc, vdev_id,
953 peer_mac,
954 stats);
955 }
956
957 /**
958 * cdp_get_pdev_tx_capture_stats() - Call to get pdev tx capture stats
959 * @soc: soc handle
960 * @pdev_id: id of dp_pdev handle
961 * @stats: pointer to pdev tx capture stats
962 *
963 * Return: status Success/Failure
964 */
965 static inline QDF_STATUS
cdp_get_pdev_tx_capture_stats(ol_txrx_soc_handle soc,uint8_t pdev_id,struct cdp_pdev_tx_capture_stats * stats)966 cdp_get_pdev_tx_capture_stats(ol_txrx_soc_handle soc, uint8_t pdev_id,
967 struct cdp_pdev_tx_capture_stats *stats)
968 {
969 if (!soc || !soc->ops) {
970 dp_cdp_debug("Invalid Instance");
971 QDF_BUG(0);
972 return QDF_STATUS_E_FAILURE;
973 }
974
975 if (!soc->ops->host_stats_ops ||
976 !soc->ops->host_stats_ops->get_pdev_tx_capture_stats)
977 return QDF_STATUS_E_FAILURE;
978
979 return soc->ops->host_stats_ops->get_pdev_tx_capture_stats(soc, pdev_id,
980 stats);
981 }
982 #endif /* WLAN_TX_PKT_CAPTURE_ENH */
983
984 #ifdef HW_TX_DELAY_STATS_ENABLE
985 /**
986 * cdp_enable_disable_vdev_tx_delay_stats() - Start/Stop tx delay stats capture
987 * @soc: soc handle
988 * @vdev_id: vdev id
989 * @value: value to be set
990 *
991 * Return: None
992 */
993 static inline void
cdp_enable_disable_vdev_tx_delay_stats(ol_txrx_soc_handle soc,uint8_t vdev_id,uint8_t value)994 cdp_enable_disable_vdev_tx_delay_stats(ol_txrx_soc_handle soc, uint8_t vdev_id,
995 uint8_t value)
996 {
997 if (!soc || !soc->ops) {
998 dp_cdp_debug("Invalid Instance");
999 return;
1000 }
1001
1002 if (!soc->ops->host_stats_ops ||
1003 !soc->ops->host_stats_ops->enable_disable_vdev_tx_delay_stats)
1004 return;
1005
1006 soc->ops->host_stats_ops->enable_disable_vdev_tx_delay_stats(soc,
1007 vdev_id,
1008 value);
1009 }
1010
1011 /**
1012 * cdp_vdev_is_tx_delay_stats_enabled() - Check if the Tx delay stats
1013 * is enabled or not for the given vdev_id
1014 * @soc: soc handle
1015 * @vdev_id: vdev_id
1016 *
1017 * Return: 1 if enabled, 0 if disabled
1018 */
1019 static inline uint8_t
cdp_vdev_is_tx_delay_stats_enabled(ol_txrx_soc_handle soc,uint8_t vdev_id)1020 cdp_vdev_is_tx_delay_stats_enabled(ol_txrx_soc_handle soc, uint8_t vdev_id)
1021 {
1022 if (!soc || !soc->ops || !soc->ops->host_stats_ops) {
1023 dp_cdp_debug("Invalid Instance:");
1024 return 0;
1025 }
1026
1027 if (soc->ops->host_stats_ops->is_tx_delay_stats_enabled)
1028 return soc->ops->host_stats_ops->is_tx_delay_stats_enabled(soc,
1029 vdev_id);
1030
1031 return 0;
1032 }
1033 #endif
1034
1035 /**
1036 * cdp_get_pdev_tid_stats() - Get pdev tid stats
1037 * @soc: soc handle
1038 * @pdev_id: Pdev id
1039 * @tid_stats: Pointer to cdp_tid_stats_intf
1040 *
1041 * Return: status Success/Failure
1042 */
1043 static inline QDF_STATUS
cdp_get_pdev_tid_stats(ol_txrx_soc_handle soc,uint8_t pdev_id,struct cdp_tid_stats_intf * tid_stats)1044 cdp_get_pdev_tid_stats(ol_txrx_soc_handle soc, uint8_t pdev_id,
1045 struct cdp_tid_stats_intf *tid_stats)
1046 {
1047 if (!soc || !soc->ops || !soc->ops->host_stats_ops) {
1048 dp_cdp_debug("Invalid Instance:");
1049 return QDF_STATUS_E_FAILURE;
1050 }
1051
1052 if (!soc->ops->host_stats_ops->txrx_get_pdev_tid_stats)
1053 return QDF_STATUS_E_FAILURE;
1054
1055 return soc->ops->host_stats_ops->txrx_get_pdev_tid_stats(soc, pdev_id,
1056 tid_stats);
1057 }
1058
1059 #ifdef WLAN_CONFIG_TELEMETRY_AGENT
1060 /**
1061 * cdp_get_pdev_telemetry_stats() - function to get pdev telemetry stats
1062 * @soc: soc handle
1063 * @pdev_id: pdev id
1064 * @stats: pointer to pdev telemetry stats
1065 *
1066 * Return: status
1067 */
cdp_get_pdev_telemetry_stats(ol_txrx_soc_handle soc,uint8_t pdev_id,struct cdp_pdev_telemetry_stats * stats)1068 static inline QDF_STATUS cdp_get_pdev_telemetry_stats(
1069 ol_txrx_soc_handle soc,
1070 uint8_t pdev_id,
1071 struct cdp_pdev_telemetry_stats *stats)
1072 {
1073 if (!soc || !soc->ops) {
1074 dp_cdp_debug("Invalid Instance");
1075 QDF_BUG(0);
1076 return QDF_STATUS_E_FAILURE;
1077 }
1078
1079 if (!soc->ops->host_stats_ops ||
1080 !soc->ops->host_stats_ops->txrx_pdev_telemetry_stats)
1081 return QDF_STATUS_E_FAILURE;
1082
1083 return soc->ops->host_stats_ops->txrx_pdev_telemetry_stats(
1084 soc, pdev_id, stats);
1085 }
1086
1087 /**
1088 * cdp_get_peer_telemetry_stats() - function to get peer telemetry stats
1089 * @soc: soc handle
1090 * @addr: peer address
1091 * @stats: pointer to peer telemetry stats
1092 *
1093 * Return: status
1094 */
cdp_get_peer_telemetry_stats(ol_txrx_soc_handle soc,uint8_t * addr,struct cdp_peer_telemetry_stats * stats)1095 static inline QDF_STATUS cdp_get_peer_telemetry_stats(
1096 ol_txrx_soc_handle soc,
1097 uint8_t *addr,
1098 struct cdp_peer_telemetry_stats *stats)
1099 {
1100 if (!soc || !soc->ops) {
1101 dp_cdp_debug("Invalid Instance");
1102 QDF_BUG(0);
1103 return QDF_STATUS_E_FAILURE;
1104 }
1105
1106 if (!soc->ops->host_stats_ops ||
1107 !soc->ops->host_stats_ops->txrx_peer_telemetry_stats)
1108 return QDF_STATUS_E_FAILURE;
1109
1110 return soc->ops->host_stats_ops->txrx_peer_telemetry_stats(
1111 soc, addr, stats);
1112 }
1113
1114 /**
1115 * cdp_get_pdev_deter_stats(): function to get pdev deterministic stats
1116 * @soc: soc handle
1117 * @pdev_id: pdev id
1118 * @stats: pointer to pdev deterministic stats
1119 *
1120 * return: status
1121 */
cdp_get_pdev_deter_stats(ol_txrx_soc_handle soc,uint8_t pdev_id,struct cdp_pdev_deter_stats * stats)1122 static inline QDF_STATUS cdp_get_pdev_deter_stats(
1123 ol_txrx_soc_handle soc,
1124 uint8_t pdev_id,
1125 struct cdp_pdev_deter_stats *stats)
1126 {
1127 if (!soc || !soc->ops) {
1128 dp_cdp_debug("Invalid Instance");
1129 QDF_BUG(0);
1130 return QDF_STATUS_E_FAILURE;
1131 }
1132
1133 if (!soc->ops->host_stats_ops ||
1134 !soc->ops->host_stats_ops->txrx_pdev_deter_stats)
1135 return QDF_STATUS_E_FAILURE;
1136
1137 return soc->ops->host_stats_ops->txrx_pdev_deter_stats(
1138 soc, pdev_id, stats);
1139 }
1140
1141 /**
1142 * cdp_get_peer_deter_stats(): function to get peer deterministic stats
1143 * @soc: soc handle
1144 * @vdev_id: id of vdev handle
1145 * @addr: peer address
1146 * @stats: pointer to peer telemetry stats
1147 *
1148 * return: status
1149 */
cdp_get_peer_deter_stats(ol_txrx_soc_handle soc,uint8_t vdev_id,uint8_t * addr,struct cdp_peer_deter_stats * stats)1150 static inline QDF_STATUS cdp_get_peer_deter_stats(
1151 ol_txrx_soc_handle soc,
1152 uint8_t vdev_id,
1153 uint8_t *addr,
1154 struct cdp_peer_deter_stats *stats)
1155 {
1156 if (!soc || !soc->ops) {
1157 dp_cdp_debug("Invalid Instance");
1158 QDF_BUG(0);
1159 return QDF_STATUS_E_FAILURE;
1160 }
1161
1162 if (!soc->ops->host_stats_ops ||
1163 !soc->ops->host_stats_ops->txrx_peer_deter_stats)
1164 return QDF_STATUS_E_FAILURE;
1165
1166 return soc->ops->host_stats_ops->txrx_peer_deter_stats(
1167 soc, vdev_id, addr, stats);
1168 }
1169
1170 /**
1171 * cdp_update_pdev_chan_util_stats(): function to update pdev channel util stats
1172 * @soc: soc handle
1173 * @pdev_id: pdev id
1174 * @ch_util: pointer to pdev ch util stats
1175 *
1176 * return: status
1177 */
cdp_update_pdev_chan_util_stats(ol_txrx_soc_handle soc,uint8_t pdev_id,struct cdp_pdev_chan_util_stats * ch_util)1178 static inline QDF_STATUS cdp_update_pdev_chan_util_stats(
1179 ol_txrx_soc_handle soc,
1180 uint8_t pdev_id,
1181 struct cdp_pdev_chan_util_stats *ch_util)
1182 {
1183 if (!soc || !soc->ops) {
1184 dp_cdp_debug("Invalid Instance");
1185 QDF_BUG(0);
1186 return QDF_STATUS_E_FAILURE;
1187 }
1188
1189 if (!soc->ops->host_stats_ops ||
1190 !soc->ops->host_stats_ops->txrx_update_pdev_chan_util_stats)
1191 return QDF_STATUS_E_FAILURE;
1192
1193 return soc->ops->host_stats_ops->txrx_update_pdev_chan_util_stats(
1194 soc, pdev_id, ch_util);
1195 }
1196 #endif
1197
1198 /**
1199 * cdp_get_peer_extd_rate_link_stats() - cdp function to get peer
1200 * extended rate and link stats
1201 * @soc: soc handle
1202 * @mac_addr: mac address
1203 *
1204 * Return: status
1205 */
cdp_get_peer_extd_rate_link_stats(ol_txrx_soc_handle soc,uint8_t * mac_addr)1206 static inline QDF_STATUS cdp_get_peer_extd_rate_link_stats(
1207 ol_txrx_soc_handle soc,
1208 uint8_t *mac_addr)
1209 {
1210 if (!soc || !soc->ops) {
1211 dp_cdp_debug("Invalid Instance");
1212 QDF_BUG(0);
1213 return QDF_STATUS_E_FAILURE;
1214 }
1215
1216 if (!soc->ops->host_stats_ops ||
1217 !soc->ops->host_stats_ops->txrx_get_peer_extd_rate_link_stats)
1218 return QDF_STATUS_E_FAILURE;
1219
1220 return soc->ops->host_stats_ops->txrx_get_peer_extd_rate_link_stats(
1221 soc, mac_addr);
1222 }
1223
1224 /**
1225 * cdp_get_pdev_obss_pd_stats() - function to get pdev obss stats
1226 * @soc: soc handle
1227 * @pdev_id: pdev id
1228 * @stats: pointer to pdev obss stats
1229 * @req: Pointer to CDP TxRx stats
1230 *
1231 * Return: status
1232 */
cdp_get_pdev_obss_pd_stats(ol_txrx_soc_handle soc,uint8_t pdev_id,struct cdp_pdev_obss_pd_stats_tlv * stats,struct cdp_txrx_stats_req * req)1233 static inline QDF_STATUS cdp_get_pdev_obss_pd_stats(
1234 ol_txrx_soc_handle soc,
1235 uint8_t pdev_id,
1236 struct cdp_pdev_obss_pd_stats_tlv *stats,
1237 struct cdp_txrx_stats_req *req)
1238 {
1239 if (!soc || !soc->ops) {
1240 dp_cdp_debug("Invalid Instance");
1241 QDF_BUG(0);
1242 return QDF_STATUS_E_FAILURE;
1243 }
1244
1245 if (!soc->ops->host_stats_ops ||
1246 !soc->ops->host_stats_ops->get_pdev_obss_stats)
1247 return QDF_STATUS_E_FAILURE;
1248
1249 return soc->ops->host_stats_ops->get_pdev_obss_stats(
1250 soc, pdev_id, stats, req);
1251 }
1252
1253 /**
1254 * cdp_clear_pdev_obss_pd_stats() - function to clear pdev obss stats
1255 * @soc: soc handle
1256 * @pdev_id: pdev id
1257 * @req: Pointer to CDP TxRx stats request. mac_id will be pre-filled
1258 * and should not be overwritten
1259 *
1260 * Return: status
1261 */
cdp_clear_pdev_obss_pd_stats(ol_txrx_soc_handle soc,uint8_t pdev_id,struct cdp_txrx_stats_req * req)1262 static inline QDF_STATUS cdp_clear_pdev_obss_pd_stats(
1263 ol_txrx_soc_handle soc,
1264 uint8_t pdev_id, struct cdp_txrx_stats_req *req)
1265 {
1266 if (!soc || !soc->ops) {
1267 dp_cdp_debug("Invalid Instance");
1268 QDF_BUG(0);
1269 return QDF_STATUS_E_FAILURE;
1270 }
1271
1272 if (!soc->ops->host_stats_ops ||
1273 !soc->ops->host_stats_ops->clear_pdev_obss_pd_stats)
1274 return QDF_STATUS_E_FAILURE;
1275
1276 return soc->ops->host_stats_ops->clear_pdev_obss_pd_stats(
1277 soc, pdev_id, req);
1278 }
1279
1280 /*
1281 * cdp_host_get_interface_stats - Get vdev stats for ath interface
1282 * @soc: soc handle
1283 * @vdev_id: vdev_id
1284 * @buf: buffer to hold vdev_stats
1285 *
1286 * return: QDF_STATUS
1287 */
1288 static inline QDF_STATUS
cdp_host_get_interface_stats(ol_txrx_soc_handle soc,uint8_t vdev_id,struct cdp_vdev_stats * buf)1289 cdp_host_get_interface_stats(ol_txrx_soc_handle soc,
1290 uint8_t vdev_id,
1291 struct cdp_vdev_stats *buf)
1292 {
1293 if (!soc || !soc->ops) {
1294 QDF_BUG(0);
1295 return QDF_STATUS_E_FAILURE;
1296 }
1297
1298 if (!soc->ops->host_stats_ops ||
1299 !soc->ops->host_stats_ops->txrx_get_interface_stats)
1300 return QDF_STATUS_E_FAILURE;
1301
1302 return soc->ops->host_stats_ops->txrx_get_interface_stats(soc,
1303 vdev_id,
1304 buf,
1305 true);
1306 }
1307
1308 #ifdef WLAN_FEATURE_TX_LATENCY_STATS
1309 /**
1310 * cdp_host_tx_latency_stats_config() - config transmit latency statistics for
1311 * specified vdev
1312 * @soc: Handle to struct dp_soc
1313 * @vdev_id: vdev id
1314 * @config: configuration for transmit latency statistics
1315 *
1316 * Return: QDF_STATUS
1317 */
1318 static inline QDF_STATUS
cdp_host_tx_latency_stats_config(ol_txrx_soc_handle soc,uint8_t vdev_id,struct cdp_tx_latency_config * config)1319 cdp_host_tx_latency_stats_config(ol_txrx_soc_handle soc,
1320 uint8_t vdev_id,
1321 struct cdp_tx_latency_config *config)
1322 {
1323 if (!soc || !soc->ops) {
1324 QDF_BUG(0);
1325 return QDF_STATUS_E_FAILURE;
1326 }
1327
1328 if (!soc->ops->host_stats_ops ||
1329 !soc->ops->host_stats_ops->tx_latency_stats_config)
1330 return QDF_STATUS_E_FAILURE;
1331
1332 return soc->ops->host_stats_ops->tx_latency_stats_config(soc,
1333 vdev_id,
1334 config);
1335 }
1336
1337 /**
1338 * cdp_host_tx_latency_stats_fetch() - fetch transmit latency statistics for
1339 * specified link mac address
1340 * @soc: Handle to struct dp_soc
1341 * @vdev_id: vdev id
1342 * @mac: link mac address of remote peer
1343 * @latency: buffer to hold per-link transmit latency statistics
1344 *
1345 * Return: QDF_STATUS
1346 */
1347 static inline QDF_STATUS
cdp_host_tx_latency_stats_fetch(ol_txrx_soc_handle soc,uint8_t vdev_id,uint8_t * mac,struct cdp_tx_latency * latency)1348 cdp_host_tx_latency_stats_fetch(ol_txrx_soc_handle soc,
1349 uint8_t vdev_id, uint8_t *mac,
1350 struct cdp_tx_latency *latency)
1351 {
1352 if (!soc || !soc->ops) {
1353 QDF_BUG(0);
1354 return QDF_STATUS_E_FAILURE;
1355 }
1356
1357 if (!soc->ops->host_stats_ops ||
1358 !soc->ops->host_stats_ops->tx_latency_stats_fetch)
1359 return QDF_STATUS_E_FAILURE;
1360
1361 return soc->ops->host_stats_ops->tx_latency_stats_fetch(soc,
1362 vdev_id,
1363 mac,
1364 latency);
1365 }
1366
1367 /**
1368 * cdp_host_tx_latency_stats_register_cb() - register transmit latency
1369 * statistics callback
1370 * @soc: Handle to struct dp_soc
1371 * @cb: callback function for transmit latency statistics
1372 *
1373 * Return: QDF_STATUS
1374 */
1375 static inline QDF_STATUS
cdp_host_tx_latency_stats_register_cb(ol_txrx_soc_handle soc,cdp_tx_latency_cb cb)1376 cdp_host_tx_latency_stats_register_cb(ol_txrx_soc_handle soc,
1377 cdp_tx_latency_cb cb)
1378 {
1379 if (!soc || !soc->ops) {
1380 QDF_BUG(0);
1381 return QDF_STATUS_E_FAILURE;
1382 }
1383
1384 if (!soc->ops->host_stats_ops ||
1385 !soc->ops->host_stats_ops->tx_latency_stats_register_cb)
1386 return QDF_STATUS_E_FAILURE;
1387
1388 return soc->ops->host_stats_ops->tx_latency_stats_register_cb(soc, cb);
1389 }
1390 #endif
1391 #endif /* _CDP_TXRX_HOST_STATS_H_ */
1392