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 * @file cdp_txrx_host_stats.h 22 * @brief 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 * @brief Enable enhanced stats functionality. 142 * 143 * @param soc - the soc object 144 * @param pdev_id - id of the physical device object 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->host_stats_ops || 157 !soc->ops->host_stats_ops->txrx_enable_enhanced_stats) 158 return QDF_STATUS_E_FAILURE; 159 160 return soc->ops->host_stats_ops->txrx_enable_enhanced_stats 161 (soc, pdev_id); 162 } 163 164 /** 165 * @brief Disable enhanced stats functionality. 166 * 167 * @param soc - the soc object 168 * @param pdev_id - id of the physical device object 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->host_stats_ops || 181 !soc->ops->host_stats_ops->txrx_disable_enhanced_stats) 182 return QDF_STATUS_E_FAILURE; 183 184 return soc->ops->host_stats_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 * @pdev: physical device 304 * @addr: peer address 305 * 306 * return: status 307 */ 308 static inline QDF_STATUS cdp_per_peer_stats(ol_txrx_soc_handle soc, 309 uint8_t *addr) 310 { 311 if (!soc || !soc->ops) { 312 dp_cdp_debug("Invalid Instance"); 313 QDF_BUG(0); 314 return QDF_STATUS_E_FAILURE; 315 } 316 317 if (!soc->ops->host_stats_ops || 318 !soc->ops->host_stats_ops->txrx_per_peer_stats) 319 return QDF_STATUS_E_FAILURE; 320 321 return soc->ops->host_stats_ops->txrx_per_peer_stats(soc, addr); 322 } 323 324 static inline int cdp_host_msdu_ttl_stats(ol_txrx_soc_handle soc, 325 uint8_t vdev_id, 326 struct ol_txrx_stats_req *req) 327 { 328 if (!soc || !soc->ops) { 329 dp_cdp_debug("Invalid Instance"); 330 QDF_BUG(0); 331 return 0; 332 } 333 334 if (!soc->ops->host_stats_ops || 335 !soc->ops->host_stats_ops->txrx_host_msdu_ttl_stats) 336 return 0; 337 338 return soc->ops->host_stats_ops->txrx_host_msdu_ttl_stats 339 (soc, vdev_id, req); 340 } 341 342 static inline QDF_STATUS cdp_update_peer_stats(ol_txrx_soc_handle soc, 343 uint8_t vdev_id, uint8_t *mac, 344 void *stats, 345 uint32_t last_tx_rate_mcs, 346 uint32_t stats_id) 347 { 348 if (!soc || !soc->ops) { 349 dp_cdp_debug("Invalid Instance"); 350 QDF_BUG(0); 351 return QDF_STATUS_E_FAILURE; 352 } 353 354 if (!soc->ops->host_stats_ops || 355 !soc->ops->host_stats_ops->txrx_update_peer_stats) 356 return QDF_STATUS_E_FAILURE; 357 358 return soc->ops->host_stats_ops->txrx_update_peer_stats 359 (soc, vdev_id, mac, stats, last_tx_rate_mcs, stats_id); 360 } 361 362 static inline QDF_STATUS cdp_get_dp_fw_peer_stats(ol_txrx_soc_handle soc, 363 uint8_t pdev_id, 364 uint8_t *mac, uint32_t caps, 365 uint32_t copy_stats) 366 { 367 if (!soc || !soc->ops) { 368 dp_cdp_debug("Invalid Instance"); 369 QDF_BUG(0); 370 return QDF_STATUS_E_FAILURE; 371 } 372 373 if (!soc->ops->host_stats_ops || 374 !soc->ops->host_stats_ops->get_fw_peer_stats) 375 return QDF_STATUS_E_FAILURE; 376 377 return soc->ops->host_stats_ops->get_fw_peer_stats 378 (soc, pdev_id, mac, caps, copy_stats); 379 } 380 381 static inline QDF_STATUS cdp_get_dp_htt_stats(ol_txrx_soc_handle soc, 382 uint8_t pdev_id, 383 void *data, uint32_t data_len) 384 { 385 if (!soc || !soc->ops) { 386 dp_cdp_debug("Invalid Instance"); 387 QDF_BUG(0); 388 return QDF_STATUS_E_FAILURE; 389 } 390 391 if (!soc->ops->host_stats_ops || 392 !soc->ops->host_stats_ops->get_htt_stats) 393 return QDF_STATUS_E_FAILURE; 394 395 return soc->ops->host_stats_ops->get_htt_stats(soc, pdev_id, data, 396 data_len); 397 } 398 399 /** 400 * @brief Update pdev host stats received from firmware 401 * (wmi_host_pdev_stats and wmi_host_pdev_ext_stats) into dp 402 * 403 * @param soc - soc handle 404 * @param pdev_id - id of the physical device object 405 * @param data - pdev stats 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 * @brief Update vdev host stats 431 * 432 * @soc: soc handle 433 * @vdev_id: id of the virtual device object 434 * @data: pdev stats 435 * @stats_id: type of stats 436 * 437 * Return: QDF_STATUS 438 */ 439 static inline QDF_STATUS 440 cdp_update_vdev_host_stats(ol_txrx_soc_handle soc, 441 uint8_t vdev_id, 442 void *data, 443 uint16_t stats_id) 444 { 445 if (!soc || !soc->ops) { 446 dp_cdp_debug("Invalid Instance"); 447 QDF_BUG(0); 448 return QDF_STATUS_E_FAILURE; 449 } 450 451 if (!soc->ops->host_stats_ops || 452 !soc->ops->host_stats_ops->txrx_update_vdev_stats) 453 return QDF_STATUS_E_FAILURE; 454 455 return soc->ops->host_stats_ops->txrx_update_vdev_stats(soc, vdev_id, 456 data, 457 stats_id); 458 } 459 460 /** 461 * @brief Call to get specified peer stats 462 * 463 * @param soc - soc handle 464 * @param vdev_id - vdev_id of vdev object 465 * @param peer_mac - mac address of the peer 466 * @param type - enum of required stats 467 * @param buf - buffer to hold the value 468 * @return - QDF_STATUS 469 */ 470 static inline QDF_STATUS 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 * @brief Call to get soc stats 495 * 496 * @param soc - soc handle 497 * @soc_stats - buffer for cdp soc stats 498 * @return - QDF_STATUS 499 */ 500 static inline QDF_STATUS 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 * @brief Call to get peer stats 518 * 519 * @param soc - soc handle 520 * @param vdev_id - vdev_id of vdev object 521 * @param peer_mac - mac address of the peer 522 * @return - struct cdp_peer_stats 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 * @brief Call to reset ald stats 546 * 547 * @param soc - soc handle 548 * @param vdev_id - vdev_id of vdev object 549 * @param peer_mac - mac address of the peer 550 * @return - void 551 */ 552 static inline QDF_STATUS 553 cdp_host_reset_peer_ald_stats(ol_txrx_soc_handle soc, uint8_t vdev_id, 554 uint8_t *peer_mac) 555 { 556 if (!soc || !soc->ops) { 557 dp_cdp_debug("Invalid Instance"); 558 QDF_BUG(0); 559 return QDF_STATUS_E_FAILURE; 560 } 561 562 if (!soc->ops->host_stats_ops || 563 !soc->ops->host_stats_ops->txrx_reset_peer_ald_stats) 564 return QDF_STATUS_E_FAILURE; 565 566 return soc->ops->host_stats_ops->txrx_reset_peer_ald_stats(soc, 567 vdev_id, 568 peer_mac); 569 } 570 571 /** 572 * @brief Call to reset peer stats 573 * 574 * @param soc - soc handle 575 * @param vdev_id - vdev_id of vdev object 576 * @param peer_mac - mac address of the peer 577 * @return - QDF_STATUS 578 */ 579 static inline QDF_STATUS 580 cdp_host_reset_peer_stats(ol_txrx_soc_handle soc, 581 uint8_t vdev_id, uint8_t *peer_mac) 582 { 583 if (!soc || !soc->ops) { 584 dp_cdp_debug("Invalid Instance"); 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 dp_cdp_debug("Invalid Instance"); 614 QDF_BUG(0); 615 return 0; 616 } 617 618 if (!soc->ops->host_stats_ops || 619 !soc->ops->host_stats_ops->txrx_get_vdev_stats) 620 return 0; 621 622 return soc->ops->host_stats_ops->txrx_get_vdev_stats(soc, vdev_id, 623 buf, 624 is_aggregate); 625 } 626 627 /** 628 * @brief Call to update vdev stats received from firmware 629 * (wmi_host_vdev_stats and wmi_host_vdev_extd_stats) into dp 630 * 631 * @param data - stats data to be updated 632 * @param size - size of stats data 633 * @param stats_id - stats id 634 * @return - int 635 */ 636 static inline int 637 cdp_update_host_vdev_stats(ol_txrx_soc_handle soc, 638 void *data, 639 uint32_t size, 640 uint32_t stats_id) 641 { 642 if (!soc || !soc->ops) { 643 dp_cdp_debug("Invalid Instance"); 644 QDF_BUG(0); 645 return 0; 646 } 647 648 if (!soc->ops->host_stats_ops || 649 !soc->ops->host_stats_ops->txrx_process_wmi_host_vdev_stats) 650 return 0; 651 652 return soc->ops->host_stats_ops->txrx_process_wmi_host_vdev_stats 653 (soc, 654 data, 655 size, 656 stats_id); 657 } 658 659 /** 660 * @brief Call to get vdev extd stats 661 * 662 * @param soc - soc handle 663 * @param vdev_id - id of dp vdev object 664 * @param buf - buffer 665 * @return - int 666 */ 667 static inline int 668 cdp_get_vdev_extd_stats(ol_txrx_soc_handle soc, 669 uint8_t vdev_id, 670 wmi_host_vdev_extd_stats *buf) 671 { 672 if (!soc || !soc->ops) { 673 dp_cdp_debug("Invalid Instance"); 674 QDF_BUG(0); 675 return 0; 676 } 677 678 if (!soc->ops->host_stats_ops || 679 !soc->ops->host_stats_ops->txrx_get_vdev_extd_stats) 680 return 0; 681 682 return soc->ops->host_stats_ops->txrx_get_vdev_extd_stats(soc, vdev_id, 683 buf); 684 } 685 686 /** 687 * @brief Call to get cdp_pdev_stats 688 * 689 * @param soc - soc handle 690 * @param pdev_id - id of dp pdev object 691 * @param buf - buffer to hold cdp_pdev_stats 692 * @return - success/failure 693 */ 694 static inline int 695 cdp_host_get_pdev_stats(ol_txrx_soc_handle soc, 696 uint8_t pdev_id, struct cdp_pdev_stats *buf) 697 { 698 if (!soc || !soc->ops) { 699 dp_cdp_debug("Invalid Instance"); 700 QDF_BUG(0); 701 return 0; 702 } 703 704 if (!soc->ops->host_stats_ops || 705 !soc->ops->host_stats_ops->txrx_get_pdev_stats) 706 return 0; 707 708 return soc->ops->host_stats_ops->txrx_get_pdev_stats(soc, pdev_id, buf); 709 } 710 711 /** 712 * @brief Call to get radio stats 713 * 714 * @param soc - soc handle 715 * @param pdev_id - id of dp pdev object 716 * @param scn_stats_user - stats buffer 717 * @return - int 718 */ 719 static inline int 720 cdp_host_get_radio_stats(ol_txrx_soc_handle soc, 721 uint8_t pdev_id, 722 void *buf) 723 { 724 if (!soc || !soc->ops) { 725 dp_cdp_debug("Invalid Instance"); 726 QDF_BUG(0); 727 return 0; 728 } 729 730 if (!soc->ops->host_stats_ops || 731 !soc->ops->host_stats_ops->txrx_get_radio_stats) 732 return 0; 733 734 return soc->ops->host_stats_ops->txrx_get_radio_stats(soc, pdev_id, 735 buf); 736 } 737 738 #ifdef QCA_SUPPORT_SCAN_SPCL_VAP_STATS 739 static inline int 740 cdp_get_scan_spcl_vap_stats(ol_txrx_soc_handle soc, 741 uint8_t vdev_id, 742 struct cdp_scan_spcl_vap_stats *stats) 743 { 744 if (!soc || !soc->ops) { 745 dp_cdp_debug("Invalid Instance"); 746 QDF_BUG(0); 747 return QDF_STATUS_E_FAILURE; 748 } 749 750 if (!soc->ops->host_stats_ops || 751 !soc->ops->host_stats_ops->txrx_get_scan_spcl_vap_stats) 752 return QDF_STATUS_E_FAILURE; 753 754 return soc->ops->host_stats_ops->txrx_get_scan_spcl_vap_stats(soc, 755 vdev_id, 756 stats); 757 } 758 #endif 759 760 /** 761 * cdp_get_peer_delay_stats() - Call to get per peer delay stats 762 * @soc: soc handle 763 * @vdev_id: id of dp_vdev handle 764 * @peer_mac: peer mac address 765 * @delay_stats: user allocated buffer for peer delay stats 766 * 767 * return: status Success/Failure 768 */ 769 static inline QDF_STATUS 770 cdp_get_peer_delay_stats(ol_txrx_soc_handle soc, 771 uint8_t vdev_id, 772 uint8_t *peer_mac, 773 struct cdp_delay_tid_stats *delay_stats) 774 { 775 if (!soc || !soc->ops) { 776 dp_cdp_debug("Invalid Instance"); 777 QDF_BUG(0); 778 return QDF_STATUS_E_FAILURE; 779 } 780 781 if (!soc->ops->host_stats_ops || 782 !soc->ops->host_stats_ops->txrx_get_peer_delay_stats) 783 return QDF_STATUS_E_FAILURE; 784 785 return soc->ops->host_stats_ops->txrx_get_peer_delay_stats(soc, 786 vdev_id, 787 peer_mac, 788 delay_stats); 789 } 790 791 /** 792 * cdp_get_peer_jitter_stats() - Call to get per peer jitter stats 793 * @soc: soc handle 794 * @pdev_id: id of dp_pdev handle 795 * @vdev_id: id of dp_vdev handle 796 * @peer_mac: peer mac address 797 * @tid_stats: user allocated buffer for tid_stats 798 * 799 * return: status Success/Failure 800 */ 801 static inline QDF_STATUS 802 cdp_get_peer_jitter_stats(ol_txrx_soc_handle soc, 803 uint8_t pdev_id, 804 uint8_t vdev_id, 805 uint8_t *peer_mac, 806 struct cdp_peer_tid_stats *tid_stats) 807 { 808 if (!soc || !soc->ops) { 809 dp_cdp_debug("Invalid Instance"); 810 QDF_BUG(0); 811 return QDF_STATUS_E_FAILURE; 812 } 813 814 if (!soc->ops->host_stats_ops || 815 !soc->ops->host_stats_ops->txrx_get_peer_jitter_stats) 816 return QDF_STATUS_E_FAILURE; 817 818 return soc->ops->host_stats_ops->txrx_get_peer_jitter_stats(soc, 819 pdev_id, 820 vdev_id, 821 peer_mac, 822 tid_stats); 823 } 824 825 /** 826 * cdp_mon_pdev_get_rx_stats() - Call to get monitor pdev rx stats 827 * @soc: soc handle 828 * @pdev_id: id of dp_pdev handle 829 * @stats: user allocated buffer for dp pdev mon stats 830 * 831 * return: status Success/Failure 832 */ 833 static inline QDF_STATUS 834 cdp_mon_pdev_get_rx_stats(ol_txrx_soc_handle soc, uint8_t pdev_id, 835 struct cdp_pdev_mon_stats *stats) 836 { 837 if (!soc || !soc->ops) { 838 dp_cdp_debug("Invalid Instance"); 839 QDF_BUG(0); 840 return QDF_STATUS_E_FAILURE; 841 } 842 843 if (!soc->ops->mon_ops || 844 !soc->ops->mon_ops->get_mon_pdev_rx_stats) 845 return QDF_STATUS_E_FAILURE; 846 847 return soc->ops->mon_ops->get_mon_pdev_rx_stats(soc, pdev_id, stats); 848 } 849 850 #ifdef WLAN_TX_PKT_CAPTURE_ENH 851 /** 852 * cdp_get_peer_tx_capture_stats() - Call to get peer tx capture stats 853 * @soc: soc handle 854 * @vdev_id: id of dp_vdev handle 855 * @peer_mac: peer mac address 856 * @stats: pointer to peer tx capture stats 857 * 858 * return: status Success/Failure 859 */ 860 static inline QDF_STATUS 861 cdp_get_peer_tx_capture_stats(ol_txrx_soc_handle soc, 862 uint8_t vdev_id, 863 uint8_t *peer_mac, 864 struct cdp_peer_tx_capture_stats *stats) 865 { 866 if (!soc || !soc->ops) { 867 dp_cdp_debug("Invalid Instance"); 868 QDF_BUG(0); 869 return QDF_STATUS_E_FAILURE; 870 } 871 872 if (!soc->ops->host_stats_ops || 873 !soc->ops->host_stats_ops->get_peer_tx_capture_stats) 874 return QDF_STATUS_E_FAILURE; 875 876 return soc->ops->host_stats_ops->get_peer_tx_capture_stats(soc, vdev_id, 877 peer_mac, 878 stats); 879 } 880 881 /** 882 * cdp_get_pdev_tx_capture_stats() - Call to get pdev tx capture stats 883 * @soc: soc handle 884 * @pdev_id: id of dp_pdev handle 885 * @stats: pointer to pdev tx capture stats 886 * 887 * return: status Success/Failure 888 */ 889 static inline QDF_STATUS 890 cdp_get_pdev_tx_capture_stats(ol_txrx_soc_handle soc, uint8_t pdev_id, 891 struct cdp_pdev_tx_capture_stats *stats) 892 { 893 if (!soc || !soc->ops) { 894 dp_cdp_debug("Invalid Instance"); 895 QDF_BUG(0); 896 return QDF_STATUS_E_FAILURE; 897 } 898 899 if (!soc->ops->host_stats_ops || 900 !soc->ops->host_stats_ops->get_pdev_tx_capture_stats) 901 return QDF_STATUS_E_FAILURE; 902 903 return soc->ops->host_stats_ops->get_pdev_tx_capture_stats(soc, pdev_id, 904 stats); 905 } 906 #endif /* WLAN_TX_PKT_CAPTURE_ENH */ 907 908 #ifdef HW_TX_DELAY_STATS_ENABLE 909 /** 910 * cdp_enable_disable_vdev_tx_delay_stats() - Start/Stop tx delay stats capture 911 * @soc: soc handle 912 * @vdev_id: vdev id 913 * @value: value to be set 914 * 915 * Return: None 916 */ 917 static inline void 918 cdp_enable_disable_vdev_tx_delay_stats(ol_txrx_soc_handle soc, uint8_t vdev_id, 919 uint8_t value) 920 { 921 if (!soc || !soc->ops) { 922 dp_cdp_debug("Invalid Instance"); 923 return; 924 } 925 926 if (!soc->ops->host_stats_ops || 927 !soc->ops->host_stats_ops->enable_disable_vdev_tx_delay_stats) 928 return; 929 930 soc->ops->host_stats_ops->enable_disable_vdev_tx_delay_stats(soc, 931 vdev_id, 932 value); 933 } 934 935 /** 936 * cdp_vdev_is_tx_delay_stats_enabled() - Check if the Tx delay stats 937 * is enabled or not for the given vdev_id 938 * @soc: soc handle 939 * @vdev_id: vdev_id 940 * 941 * Returns: 1 if enabled, 0 if disabled 942 */ 943 static inline uint8_t 944 cdp_vdev_is_tx_delay_stats_enabled(ol_txrx_soc_handle soc, uint8_t vdev_id) 945 { 946 if (!soc || !soc->ops || !soc->ops->host_stats_ops) { 947 dp_cdp_debug("Invalid Instance:"); 948 return 0; 949 } 950 951 if (soc->ops->host_stats_ops->is_tx_delay_stats_enabled) 952 return soc->ops->host_stats_ops->is_tx_delay_stats_enabled(soc, 953 vdev_id); 954 955 return 0; 956 } 957 #endif 958 959 /** 960 * cdp_get_pdev_tid_stats() - Get pdev tid stats 961 * @soc: soc handle 962 * @pdev_id: Pdev id 963 * @tid_stats: Pointer to cdp_tid_stats_intf 964 * 965 * Return: status Success/Failure 966 */ 967 static inline QDF_STATUS 968 cdp_get_pdev_tid_stats(ol_txrx_soc_handle soc, uint8_t pdev_id, 969 struct cdp_tid_stats_intf *tid_stats) 970 { 971 if (!soc || !soc->ops || !soc->ops->host_stats_ops) { 972 dp_cdp_debug("Invalid Instance:"); 973 return QDF_STATUS_E_FAILURE; 974 } 975 976 if (!soc->ops->host_stats_ops->txrx_get_pdev_tid_stats) 977 return QDF_STATUS_E_FAILURE; 978 979 return soc->ops->host_stats_ops->txrx_get_pdev_tid_stats(soc, pdev_id, 980 tid_stats); 981 } 982 983 #ifdef WLAN_TELEMETRY_STATS_SUPPORT 984 /** 985 * cdp_get_pdev_telemetry_stats(): function to get pdev telemetry stats 986 * @soc: soc handle 987 * @pdev_id: pdev id 988 * @stats: pointer to pdev telemetry stats 989 * 990 * return: status 991 */ 992 static inline QDF_STATUS cdp_get_pdev_telemetry_stats( 993 ol_txrx_soc_handle soc, 994 uint8_t pdev_id, 995 struct cdp_pdev_telemetry_stats *stats) 996 { 997 if (!soc || !soc->ops) { 998 dp_cdp_debug("Invalid Instance"); 999 QDF_BUG(0); 1000 return QDF_STATUS_E_FAILURE; 1001 } 1002 1003 if (!soc->ops->host_stats_ops || 1004 !soc->ops->host_stats_ops->txrx_pdev_telemetry_stats) 1005 return QDF_STATUS_E_FAILURE; 1006 1007 return soc->ops->host_stats_ops->txrx_pdev_telemetry_stats( 1008 soc, pdev_id, stats); 1009 } 1010 1011 /** 1012 * cdp_get_peer_telemetry_stats(): function to get peer telemetry stats 1013 * @soc: soc handle 1014 * @addr: peer address 1015 * @stats: pointer to peer telemetry stats 1016 * 1017 * return: status 1018 */ 1019 static inline QDF_STATUS cdp_get_peer_telemetry_stats( 1020 ol_txrx_soc_handle soc, 1021 uint8_t *addr, 1022 struct cdp_peer_telemetry_stats *stats) 1023 { 1024 if (!soc || !soc->ops) { 1025 dp_cdp_debug("Invalid Instance"); 1026 QDF_BUG(0); 1027 return QDF_STATUS_E_FAILURE; 1028 } 1029 1030 if (!soc->ops->host_stats_ops || 1031 !soc->ops->host_stats_ops->txrx_peer_telemetry_stats) 1032 return QDF_STATUS_E_FAILURE; 1033 1034 return soc->ops->host_stats_ops->txrx_peer_telemetry_stats( 1035 soc, addr, stats); 1036 } 1037 1038 /** 1039 * cdp_get_pdev_deter_stats(): function to get pdev deterministic stats 1040 * @soc: soc handle 1041 * @pdev_id: pdev id 1042 * @stats: pointer to pdev deterministic stats 1043 * 1044 * return: status 1045 */ 1046 static inline QDF_STATUS cdp_get_pdev_deter_stats( 1047 ol_txrx_soc_handle soc, 1048 uint8_t pdev_id, 1049 struct cdp_pdev_deter_stats *stats) 1050 { 1051 if (!soc || !soc->ops) { 1052 dp_cdp_debug("Invalid Instance"); 1053 QDF_BUG(0); 1054 return QDF_STATUS_E_FAILURE; 1055 } 1056 1057 if (!soc->ops->host_stats_ops || 1058 !soc->ops->host_stats_ops->txrx_pdev_deter_stats) 1059 return QDF_STATUS_E_FAILURE; 1060 1061 return soc->ops->host_stats_ops->txrx_pdev_deter_stats( 1062 soc, pdev_id, stats); 1063 } 1064 1065 /** 1066 * cdp_get_peer_deter_stats(): function to get peer deterministic stats 1067 * @soc: soc handle 1068 * @vdev_id: id of vdev handle 1069 * @addr: peer address 1070 * @stats: pointer to peer telemetry stats 1071 * 1072 * return: status 1073 */ 1074 static inline QDF_STATUS cdp_get_peer_deter_stats( 1075 ol_txrx_soc_handle soc, 1076 uint8_t vdev_id, 1077 uint8_t *addr, 1078 struct cdp_peer_deter_stats *stats) 1079 { 1080 if (!soc || !soc->ops) { 1081 dp_cdp_debug("Invalid Instance"); 1082 QDF_BUG(0); 1083 return QDF_STATUS_E_FAILURE; 1084 } 1085 1086 if (!soc->ops->host_stats_ops || 1087 !soc->ops->host_stats_ops->txrx_peer_deter_stats) 1088 return QDF_STATUS_E_FAILURE; 1089 1090 return soc->ops->host_stats_ops->txrx_peer_deter_stats( 1091 soc, vdev_id, addr, stats); 1092 } 1093 1094 /** 1095 * cdp_update_pdev_chan_util_stats(): function to update pdev channel util stats 1096 * @soc: soc handle 1097 * @pdev_id: pdev id 1098 * @ch_util: pointer to pdev ch util stats 1099 * 1100 * return: status 1101 */ 1102 static inline QDF_STATUS cdp_update_pdev_chan_util_stats( 1103 ol_txrx_soc_handle soc, 1104 uint8_t pdev_id, 1105 struct cdp_pdev_chan_util_stats *ch_util) 1106 { 1107 if (!soc || !soc->ops) { 1108 dp_cdp_debug("Invalid Instance"); 1109 QDF_BUG(0); 1110 return QDF_STATUS_E_FAILURE; 1111 } 1112 1113 if (!soc->ops->host_stats_ops || 1114 !soc->ops->host_stats_ops->txrx_update_pdev_chan_util_stats) 1115 return QDF_STATUS_E_FAILURE; 1116 1117 return soc->ops->host_stats_ops->txrx_update_pdev_chan_util_stats( 1118 soc, pdev_id, ch_util); 1119 } 1120 #endif 1121 1122 /** 1123 * cdp_get_peer_extd_rate_link_stats(): cdp function to get peer 1124 * extended rate and link stats 1125 * @soc: soc handle 1126 * @addr: mac address 1127 * 1128 * return: status 1129 */ 1130 static inline QDF_STATUS cdp_get_peer_extd_rate_link_stats( 1131 ol_txrx_soc_handle soc, 1132 uint8_t *mac_addr) 1133 { 1134 if (!soc || !soc->ops) { 1135 dp_cdp_debug("Invalid Instance"); 1136 QDF_BUG(0); 1137 return QDF_STATUS_E_FAILURE; 1138 } 1139 1140 if (!soc->ops->host_stats_ops || 1141 !soc->ops->host_stats_ops->txrx_get_peer_extd_rate_link_stats) 1142 return QDF_STATUS_E_FAILURE; 1143 1144 return soc->ops->host_stats_ops->txrx_get_peer_extd_rate_link_stats( 1145 soc, mac_addr); 1146 } 1147 1148 /* 1149 * cdp_get_pdev_obss_pd_stats(): function to get pdev obss stats 1150 * @soc: soc handle 1151 * @pdev_id: pdev id 1152 * @stats: pointer to pdev obss stats 1153 * @req: Pointer to CDP TxRx stats 1154 * 1155 * return: status 1156 */ 1157 static inline QDF_STATUS cdp_get_pdev_obss_pd_stats( 1158 ol_txrx_soc_handle soc, 1159 uint8_t pdev_id, 1160 struct cdp_pdev_obss_pd_stats_tlv *stats, 1161 struct cdp_txrx_stats_req *req) 1162 { 1163 if (!soc || !soc->ops) { 1164 dp_cdp_debug("Invalid Instance"); 1165 QDF_BUG(0); 1166 return QDF_STATUS_E_FAILURE; 1167 } 1168 1169 if (!soc->ops->host_stats_ops || 1170 !soc->ops->host_stats_ops->get_pdev_obss_stats) 1171 return QDF_STATUS_E_FAILURE; 1172 1173 return soc->ops->host_stats_ops->get_pdev_obss_stats( 1174 soc, pdev_id, stats, req); 1175 } 1176 1177 /** 1178 * cdp_clear_pdev_obss_pd_stats(): function to clear pdev obss stats 1179 * @soc: soc handle 1180 * @pdev_id: pdev id 1181 * @req: Pointer to CDP TxRx stats request. mac_id will be pre-filled 1182 * and should not be overwritten 1183 * 1184 * return: status 1185 */ 1186 static inline QDF_STATUS cdp_clear_pdev_obss_pd_stats( 1187 ol_txrx_soc_handle soc, 1188 uint8_t pdev_id, struct cdp_txrx_stats_req *req) 1189 { 1190 if (!soc || !soc->ops) { 1191 dp_cdp_debug("Invalid Instance"); 1192 QDF_BUG(0); 1193 return QDF_STATUS_E_FAILURE; 1194 } 1195 1196 if (!soc->ops->host_stats_ops || 1197 !soc->ops->host_stats_ops->clear_pdev_obss_pd_stats) 1198 return QDF_STATUS_E_FAILURE; 1199 1200 return soc->ops->host_stats_ops->clear_pdev_obss_pd_stats( 1201 soc, pdev_id, req); 1202 } 1203 #endif /* _CDP_TXRX_HOST_STATS_H_ */ 1204