1 /* 2 * Copyright (c) 2016-2019 The Linux Foundation. All rights reserved. 3 * 4 * Permission to use, copy, modify, and/or distribute this software for 5 * any purpose with or without fee is hereby granted, provided that the 6 * above copyright notice and this permission notice appear in all 7 * copies. 8 * 9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL 10 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED 11 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE 12 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL 13 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR 14 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER 15 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 16 * PERFORMANCE OF THIS SOFTWARE. 17 */ 18 19 /** 20 * @file cdp_txrx_host_stats.h 21 * @brief Define the host data path stats API functions 22 * called by the host control SW and the OS interface module 23 */ 24 #ifndef _CDP_TXRX_HOST_STATS_H_ 25 #define _CDP_TXRX_HOST_STATS_H_ 26 #include "cdp_txrx_handle.h" 27 /** 28 * cdp_host_stats_get: cdp call to get host stats 29 * @soc: SOC handle 30 * @req: Requirement type 31 * 32 * return: 0 for Success, Failure returns error message 33 */ 34 static inline int cdp_host_stats_get(ol_txrx_soc_handle soc, 35 struct cdp_vdev *vdev, 36 struct ol_txrx_stats_req *req) 37 { 38 if (!soc || !soc->ops) { 39 QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG, 40 "%s: Invalid Instance", __func__); 41 QDF_BUG(0); 42 return 0; 43 } 44 45 if (!soc->ops->host_stats_ops || 46 !soc->ops->host_stats_ops->txrx_host_stats_get) 47 return 0; 48 49 return soc->ops->host_stats_ops->txrx_host_stats_get(vdev, req); 50 } 51 52 /** 53 * cdp_host_stats_clr: cdp call to clear host stats 54 * @vdev: vdev handle 55 * 56 * return: void 57 */ 58 static inline void 59 cdp_host_stats_clr(ol_txrx_soc_handle soc, struct cdp_vdev *vdev) 60 { 61 if (!soc || !soc->ops) { 62 QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG, 63 "%s: Invalid Instance", __func__); 64 QDF_BUG(0); 65 return; 66 } 67 68 if (!soc->ops->host_stats_ops || 69 !soc->ops->host_stats_ops->txrx_host_stats_clr) 70 return; 71 72 soc->ops->host_stats_ops->txrx_host_stats_clr(vdev); 73 } 74 75 static inline void 76 cdp_host_ce_stats(ol_txrx_soc_handle soc, struct cdp_vdev *vdev) 77 { 78 if (!soc || !soc->ops) { 79 QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG, 80 "%s: Invalid Instance", __func__); 81 QDF_BUG(0); 82 return; 83 } 84 85 if (!soc->ops->host_stats_ops || 86 !soc->ops->host_stats_ops->txrx_host_ce_stats) 87 return; 88 89 soc->ops->host_stats_ops->txrx_host_ce_stats(vdev); 90 } 91 92 static inline int cdp_stats_publish 93 (ol_txrx_soc_handle soc, struct cdp_pdev *pdev, 94 struct ol_txrx_stats *buf) 95 { 96 if (!soc || !soc->ops) { 97 QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG, 98 "%s: Invalid Instance", __func__); 99 QDF_BUG(0); 100 return 0; 101 } 102 103 if (!soc->ops->host_stats_ops || 104 !soc->ops->host_stats_ops->txrx_stats_publish) 105 return 0; 106 107 return soc->ops->host_stats_ops->txrx_stats_publish(pdev, buf); 108 } 109 110 /** 111 * @brief Enable enhanced stats functionality. 112 * 113 * @param pdev - the physical device object 114 * @return - void 115 */ 116 static inline void 117 cdp_enable_enhanced_stats(ol_txrx_soc_handle soc, struct cdp_pdev *pdev) 118 { 119 if (!soc || !soc->ops) { 120 QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG, 121 "%s: Invalid Instance", __func__); 122 QDF_BUG(0); 123 return; 124 } 125 126 if (!soc->ops->host_stats_ops || 127 !soc->ops->host_stats_ops->txrx_enable_enhanced_stats) 128 return; 129 130 soc->ops->host_stats_ops->txrx_enable_enhanced_stats 131 (pdev); 132 } 133 134 /** 135 * @brief Disable enhanced stats functionality. 136 * 137 * @param pdev - the physical device object 138 * @return - void 139 */ 140 static inline void 141 cdp_disable_enhanced_stats(ol_txrx_soc_handle soc, struct cdp_pdev *pdev) 142 { 143 if (!soc || !soc->ops) { 144 QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG, 145 "%s: Invalid Instance", __func__); 146 QDF_BUG(0); 147 return; 148 } 149 150 if (!soc->ops->host_stats_ops || 151 !soc->ops->host_stats_ops->txrx_disable_enhanced_stats) 152 return; 153 154 soc->ops->host_stats_ops->txrx_disable_enhanced_stats 155 (pdev); 156 } 157 158 /** 159 * @brief Get the desired stats from the message. 160 * 161 * @param pdev - the physical device object 162 * @param stats_base - stats buffer received from FW 163 * @param type - stats type. 164 * @return - pointer to requested stat identified by type 165 */ 166 static inline uint32_t *cdp_get_stats_base 167 (ol_txrx_soc_handle soc, struct cdp_pdev *pdev, 168 uint32_t *stats_base, uint32_t msg_len, uint8_t type) 169 { 170 if (!soc || !soc->ops) { 171 QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG, 172 "%s: Invalid Instance", __func__); 173 QDF_BUG(0); 174 return 0; 175 } 176 177 if (!soc->ops->host_stats_ops || 178 !soc->ops->host_stats_ops->txrx_get_stats_base) 179 return 0; 180 181 return (uint32_t *)soc->ops->host_stats_ops->txrx_get_stats_base 182 (pdev, stats_base, msg_len, type); 183 } 184 185 static inline void 186 cdp_tx_print_tso_stats(ol_txrx_soc_handle soc, 187 struct cdp_vdev *vdev) 188 { 189 if (!soc || !soc->ops) { 190 QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG, 191 "%s: Invalid Instance", __func__); 192 QDF_BUG(0); 193 return; 194 } 195 196 if (!soc->ops->host_stats_ops || 197 !soc->ops->host_stats_ops->tx_print_tso_stats) 198 return; 199 200 soc->ops->host_stats_ops->tx_print_tso_stats(vdev); 201 } 202 203 static inline void 204 cdp_tx_rst_tso_stats(ol_txrx_soc_handle soc, struct cdp_vdev *vdev) 205 { 206 if (!soc || !soc->ops) { 207 QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG, 208 "%s: Invalid Instance", __func__); 209 QDF_BUG(0); 210 return; 211 } 212 213 if (!soc->ops->host_stats_ops || 214 !soc->ops->host_stats_ops->tx_rst_tso_stats) 215 return; 216 217 soc->ops->host_stats_ops->tx_rst_tso_stats(vdev); 218 } 219 220 static inline void 221 cdp_tx_print_sg_stats(ol_txrx_soc_handle soc, 222 struct cdp_vdev *vdev) 223 { 224 if (!soc || !soc->ops) { 225 QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG, 226 "%s: Invalid Instance", __func__); 227 QDF_BUG(0); 228 return; 229 } 230 231 if (!soc->ops->host_stats_ops || 232 !soc->ops->host_stats_ops->tx_print_sg_stats) 233 return; 234 235 soc->ops->host_stats_ops->tx_print_sg_stats(vdev); 236 } 237 238 static inline void 239 cdp_tx_rst_sg_stats(ol_txrx_soc_handle soc, struct cdp_vdev *vdev) 240 { 241 if (!soc || !soc->ops) { 242 QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG, 243 "%s: Invalid Instance", __func__); 244 QDF_BUG(0); 245 return; 246 } 247 248 if (!soc->ops->host_stats_ops || 249 !soc->ops->host_stats_ops->tx_rst_sg_stats) 250 return; 251 252 soc->ops->host_stats_ops->tx_rst_sg_stats(vdev); 253 } 254 255 static inline void 256 cdp_print_rx_cksum_stats(ol_txrx_soc_handle soc, 257 struct cdp_vdev *vdev) 258 { 259 if (!soc || !soc->ops) { 260 QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG, 261 "%s: Invalid Instance", __func__); 262 QDF_BUG(0); 263 return; 264 } 265 266 if (!soc->ops->host_stats_ops || 267 !soc->ops->host_stats_ops->print_rx_cksum_stats) 268 return; 269 270 soc->ops->host_stats_ops->print_rx_cksum_stats(vdev); 271 } 272 273 static inline void 274 cdp_rst_rx_cksum_stats(ol_txrx_soc_handle soc, struct cdp_vdev *vdev) 275 { 276 if (!soc || !soc->ops) { 277 QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG, 278 "%s: Invalid Instance", __func__); 279 QDF_BUG(0); 280 return; 281 } 282 283 if (!soc->ops->host_stats_ops || 284 !soc->ops->host_stats_ops->rst_rx_cksum_stats) 285 return; 286 287 soc->ops->host_stats_ops->rst_rx_cksum_stats(vdev); 288 } 289 290 static inline A_STATUS 291 cdp_host_me_stats(ol_txrx_soc_handle soc, struct cdp_vdev *vdev) 292 { 293 if (!soc || !soc->ops) { 294 QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG, 295 "%s: Invalid Instance", __func__); 296 QDF_BUG(0); 297 return 0; 298 } 299 300 if (!soc->ops->host_stats_ops || 301 !soc->ops->host_stats_ops->txrx_host_me_stats) 302 return 0; 303 304 return soc->ops->host_stats_ops->txrx_host_me_stats(vdev); 305 } 306 307 /** 308 * cdp_per_peer_stats(): function to print per peer REO Queue stats 309 * @soc: soc handle 310 * @pdev: physical device 311 * @addr: peer address 312 * 313 * return: status 314 */ 315 static inline void cdp_per_peer_stats(ol_txrx_soc_handle soc, 316 struct cdp_pdev *pdev, char *addr) 317 { 318 if (!soc || !soc->ops) { 319 QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG, 320 "%s: Invalid Instance", __func__); 321 QDF_BUG(0); 322 return; 323 } 324 325 if (!soc->ops->host_stats_ops || 326 !soc->ops->host_stats_ops->txrx_per_peer_stats) 327 return; 328 329 soc->ops->host_stats_ops->txrx_per_peer_stats(pdev, addr); 330 } 331 332 static inline int cdp_host_msdu_ttl_stats(ol_txrx_soc_handle soc, 333 struct cdp_vdev *vdev, 334 struct ol_txrx_stats_req *req) 335 { 336 if (!soc || !soc->ops) { 337 QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG, 338 "%s: Invalid Instance", __func__); 339 QDF_BUG(0); 340 return 0; 341 } 342 343 if (!soc->ops->host_stats_ops || 344 !soc->ops->host_stats_ops->txrx_host_msdu_ttl_stats) 345 return 0; 346 347 return soc->ops->host_stats_ops->txrx_host_msdu_ttl_stats 348 (vdev, req); 349 } 350 351 static inline void 352 cdp_print_lro_stats(ol_txrx_soc_handle soc, struct cdp_vdev *vdev) 353 { 354 if (!soc || !soc->ops) { 355 QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG, 356 "%s: Invalid Instance", __func__); 357 QDF_BUG(0); 358 return; 359 } 360 361 if (!soc->ops->host_stats_ops || 362 !soc->ops->host_stats_ops->print_lro_stats) 363 return; 364 365 soc->ops->host_stats_ops->print_lro_stats(vdev); 366 } 367 368 static inline void 369 cdp_reset_lro_stats(ol_txrx_soc_handle soc, struct cdp_vdev *vdev) 370 { 371 if (!soc || !soc->ops) { 372 QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG, 373 "%s: Invalid Instance", __func__); 374 QDF_BUG(0); 375 return; 376 } 377 378 if (!soc->ops->host_stats_ops || 379 !soc->ops->host_stats_ops->reset_lro_stats) 380 return; 381 382 soc->ops->host_stats_ops->reset_lro_stats(vdev); 383 } 384 385 static inline void cdp_get_dp_fw_peer_stats(ol_txrx_soc_handle soc, 386 struct cdp_pdev *pdev, uint8_t *mac, uint32_t caps, 387 uint32_t copy_stats) 388 { 389 if (!soc || !soc->ops) { 390 QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG, 391 "%s: Invalid Instance", __func__); 392 QDF_BUG(0); 393 return; 394 } 395 396 if (!soc->ops->host_stats_ops || 397 !soc->ops->host_stats_ops->get_fw_peer_stats) 398 return; 399 400 soc->ops->host_stats_ops->get_fw_peer_stats 401 (pdev, mac, caps, copy_stats); 402 } 403 404 static inline void cdp_get_dp_htt_stats(ol_txrx_soc_handle soc, 405 struct cdp_pdev *pdev, 406 void *data, uint32_t data_len) 407 { 408 if (soc && soc->ops && soc->ops->host_stats_ops && 409 soc->ops->host_stats_ops->get_htt_stats) 410 return soc->ops->host_stats_ops->get_htt_stats 411 (pdev, data, data_len); 412 return; 413 } 414 415 /** 416 * @brief Update pdev host stats received from firmware 417 * (wmi_host_pdev_stats and wmi_host_pdev_ext_stats) into dp 418 * 419 * @param pdev - the physical device object 420 * @param data - pdev stats 421 * @return - void 422 */ 423 static inline void 424 cdp_update_pdev_host_stats(ol_txrx_soc_handle soc, 425 struct cdp_pdev *pdev, 426 void *data, 427 uint16_t stats_id) 428 { 429 if (soc && soc->ops && soc->ops->host_stats_ops && 430 soc->ops->host_stats_ops->txrx_update_pdev_stats) 431 return soc->ops->host_stats_ops->txrx_update_pdev_stats 432 (pdev, data, stats_id); 433 } 434 435 /** 436 * @brief Call to get peer stats 437 * 438 * @param peer - dp peer object 439 * @return - struct cdp_peer_stats 440 */ 441 static inline struct cdp_peer_stats * 442 cdp_host_get_peer_stats(ol_txrx_soc_handle soc, struct cdp_peer *peer) 443 { 444 if (!soc || !soc->ops) { 445 QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG, 446 "%s: Invalid Instance", __func__); 447 QDF_BUG(0); 448 return NULL; 449 } 450 451 if (!soc->ops->host_stats_ops || 452 !soc->ops->host_stats_ops->txrx_get_peer_stats) 453 return NULL; 454 455 return soc->ops->host_stats_ops->txrx_get_peer_stats(peer); 456 } 457 458 /** 459 * @brief Call to reset ald stats 460 * 461 * @param peer - dp peer object 462 * @return - void 463 */ 464 static inline void 465 cdp_host_reset_peer_ald_stats(ol_txrx_soc_handle soc, 466 struct cdp_peer *peer) 467 { 468 if (!soc || !soc->ops) { 469 QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG, 470 "%s: Invalid Instance", __func__); 471 QDF_BUG(0); 472 return; 473 } 474 475 if (!soc->ops->host_stats_ops || 476 !soc->ops->host_stats_ops->txrx_reset_peer_ald_stats) 477 return; 478 479 return soc->ops->host_stats_ops->txrx_reset_peer_ald_stats(peer); 480 } 481 482 /** 483 * @brief Call to reset peer stats 484 * 485 * @param peer - dp peer object 486 * @return - void 487 */ 488 static inline void 489 cdp_host_reset_peer_stats(ol_txrx_soc_handle soc, 490 struct cdp_peer *peer) 491 { 492 if (!soc || !soc->ops) { 493 QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG, 494 "%s: Invalid Instance", __func__); 495 QDF_BUG(0); 496 return; 497 } 498 499 if (!soc->ops->host_stats_ops || 500 !soc->ops->host_stats_ops->txrx_reset_peer_stats) 501 return; 502 503 return soc->ops->host_stats_ops->txrx_reset_peer_stats(peer); 504 } 505 506 /** 507 * @brief Call to get vdev stats 508 * 509 * @param vdev - dp vdev object 510 * @param buf - buffer 511 * @return - int 512 */ 513 static inline int 514 cdp_host_get_vdev_stats(ol_txrx_soc_handle soc, 515 struct cdp_vdev *vdev, 516 struct cdp_vdev_stats *buf, 517 bool is_aggregate) 518 { 519 if (!soc || !soc->ops) { 520 QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG, 521 "%s: Invalid Instance", __func__); 522 QDF_BUG(0); 523 return 0; 524 } 525 526 if (!soc->ops->host_stats_ops || 527 !soc->ops->host_stats_ops->txrx_get_vdev_stats) 528 return 0; 529 530 return soc->ops->host_stats_ops->txrx_get_vdev_stats(vdev, 531 buf, 532 is_aggregate); 533 } 534 535 /** 536 * @brief Call to update vdev stats received from firmware 537 * (wmi_host_vdev_stats and wmi_host_vdev_extd_stats) into dp 538 * 539 * @param data - stats data to be updated 540 * @param size - size of stats data 541 * @param stats_id - stats id 542 * @return - int 543 */ 544 static inline int 545 cdp_update_host_vdev_stats(ol_txrx_soc_handle soc, 546 void *data, 547 uint32_t size, 548 uint32_t stats_id) 549 { 550 if (!soc || !soc->ops) { 551 QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG, 552 "%s: Invalid Instance", __func__); 553 QDF_BUG(0); 554 return 0; 555 } 556 557 if (!soc->ops->host_stats_ops || 558 !soc->ops->host_stats_ops->txrx_process_wmi_host_vdev_stats) 559 return 0; 560 561 return soc->ops->host_stats_ops->txrx_process_wmi_host_vdev_stats 562 (soc, 563 data, 564 size, 565 stats_id); 566 } 567 568 /** 569 * @brief Call to get vdev extd stats 570 * 571 * @param vdev - dp vdev object 572 * @param buf - buffer 573 * @return - int 574 */ 575 static inline int 576 cdp_get_vdev_extd_stats(ol_txrx_soc_handle soc, 577 struct cdp_vdev *vdev, 578 void *buf) 579 { 580 if (!soc || !soc->ops) { 581 QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG, 582 "%s: Invalid Instance", __func__); 583 QDF_BUG(0); 584 return 0; 585 } 586 587 if (!soc->ops->host_stats_ops || 588 !soc->ops->host_stats_ops->txrx_get_vdev_extd_stats) 589 return 0; 590 591 return soc->ops->host_stats_ops->txrx_get_vdev_extd_stats(vdev, buf); 592 } 593 594 /** 595 * @brief Call to get cdp_pdev_stats 596 * 597 * @param pdev - dp pdev object 598 * @return - cdp_pdev_stats 599 */ 600 static inline struct cdp_pdev_stats* 601 cdp_host_get_pdev_stats(ol_txrx_soc_handle soc, 602 struct cdp_pdev *pdev) 603 { 604 if (!soc || !soc->ops) { 605 QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG, 606 "%s: Invalid Instance", __func__); 607 QDF_BUG(0); 608 return 0; 609 } 610 611 if (!soc->ops->host_stats_ops || 612 !soc->ops->host_stats_ops->txrx_get_pdev_stats) 613 return 0; 614 615 return soc->ops->host_stats_ops->txrx_get_pdev_stats(pdev); 616 } 617 618 /** 619 * @brief Call to get radio stats 620 * 621 * @param pdev - dp pdev object 622 * @param scn_stats_user - stats buffer 623 * @return - int 624 */ 625 static inline int 626 cdp_host_get_radio_stats(ol_txrx_soc_handle soc, 627 struct cdp_pdev *pdev, 628 void *buf) 629 { 630 if (!soc || !soc->ops) { 631 QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG, 632 "%s: Invalid Instance", __func__); 633 QDF_BUG(0); 634 return 0; 635 } 636 637 if (!soc->ops->host_stats_ops || 638 !soc->ops->host_stats_ops->txrx_get_radio_stats) 639 return 0; 640 641 return soc->ops->host_stats_ops->txrx_get_radio_stats(pdev, 642 buf); 643 } 644 645 /** 646 * @brief Parse the stats header and get the payload from the message. 647 * 648 * @param pdev - the physical device object 649 * @param msg_word - stats buffer received from FW 650 * @param msg_len - length of the message 651 * @param type - place holder for parsed message type 652 * @param status - place holder for parsed message status 653 * @return - pointer to received stat payload 654 */ 655 656 #if defined(QCA_SUPPORT_SON) || defined(ENHANCED_STATS) 657 uint32_t *ol_txrx_get_en_stats_base(struct cdp_pdev *pdev, uint32_t *msg_word, 658 uint32_t msg_len, enum htt_cmn_t2h_en_stats_type *type, enum htt_cmn_t2h_en_stats_status *status); 659 #endif 660 #endif /* _CDP_TXRX_HOST_STATS_H_ */ 661