1 /* 2 * Copyright (c) 2016-2018 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 { 388 if (!soc || !soc->ops) { 389 QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG, 390 "%s: Invalid Instance", __func__); 391 QDF_BUG(0); 392 return; 393 } 394 395 if (!soc->ops->host_stats_ops || 396 !soc->ops->host_stats_ops->get_fw_peer_stats) 397 return; 398 399 soc->ops->host_stats_ops->get_fw_peer_stats 400 (pdev, mac, caps); 401 } 402 403 static inline void cdp_get_dp_htt_stats(ol_txrx_soc_handle soc, 404 struct cdp_pdev *pdev, 405 void *data, uint32_t data_len) 406 { 407 if (soc && soc->ops && soc->ops->host_stats_ops && 408 soc->ops->host_stats_ops->get_htt_stats) 409 return soc->ops->host_stats_ops->get_htt_stats 410 (pdev, data, data_len); 411 return; 412 } 413 414 /** 415 * @brief Update pdev host stats received from firmware 416 * (wmi_host_pdev_stats and wmi_host_pdev_ext_stats) into dp 417 * 418 * @param pdev - the physical device object 419 * @param data - pdev stats 420 * @return - void 421 */ 422 static inline void 423 cdp_update_pdev_host_stats(ol_txrx_soc_handle soc, 424 struct cdp_pdev *pdev, 425 void *data, 426 uint16_t stats_id) 427 { 428 if (soc && soc->ops && soc->ops->host_stats_ops && 429 soc->ops->host_stats_ops->txrx_update_pdev_stats) 430 return soc->ops->host_stats_ops->txrx_update_pdev_stats 431 (pdev, data, stats_id); 432 } 433 434 /** 435 * @brief Call to get peer stats 436 * 437 * @param peer - dp peer object 438 * @return - struct cdp_peer_stats 439 */ 440 static inline struct cdp_peer_stats * 441 cdp_host_get_peer_stats(ol_txrx_soc_handle soc, struct cdp_peer *peer) 442 { 443 if (!soc || !soc->ops) { 444 QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG, 445 "%s: Invalid Instance", __func__); 446 QDF_BUG(0); 447 return NULL; 448 } 449 450 if (!soc->ops->host_stats_ops || 451 !soc->ops->host_stats_ops->txrx_get_peer_stats) 452 return NULL; 453 454 return soc->ops->host_stats_ops->txrx_get_peer_stats(peer); 455 } 456 457 /** 458 * @brief Call to reset ald stats 459 * 460 * @param peer - dp peer object 461 * @return - void 462 */ 463 static inline void 464 cdp_host_reset_peer_ald_stats(ol_txrx_soc_handle soc, 465 struct cdp_peer *peer) 466 { 467 if (!soc || !soc->ops) { 468 QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG, 469 "%s: Invalid Instance", __func__); 470 QDF_BUG(0); 471 return; 472 } 473 474 if (!soc->ops->host_stats_ops || 475 !soc->ops->host_stats_ops->txrx_reset_peer_ald_stats) 476 return; 477 478 return soc->ops->host_stats_ops->txrx_reset_peer_ald_stats(peer); 479 } 480 481 /** 482 * @brief Call to reset peer stats 483 * 484 * @param peer - dp peer object 485 * @return - void 486 */ 487 static inline void 488 cdp_host_reset_peer_stats(ol_txrx_soc_handle soc, 489 struct cdp_peer *peer) 490 { 491 if (!soc || !soc->ops) { 492 QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG, 493 "%s: Invalid Instance", __func__); 494 QDF_BUG(0); 495 return; 496 } 497 498 if (!soc->ops->host_stats_ops || 499 !soc->ops->host_stats_ops->txrx_reset_peer_stats) 500 return; 501 502 return soc->ops->host_stats_ops->txrx_reset_peer_stats(peer); 503 } 504 505 /** 506 * @brief Call to get vdev stats 507 * 508 * @param vdev - dp vdev object 509 * @param buf - buffer 510 * @return - int 511 */ 512 static inline int 513 cdp_host_get_vdev_stats(ol_txrx_soc_handle soc, 514 struct cdp_vdev *vdev, 515 struct cdp_vdev_stats *buf, 516 bool is_aggregate) 517 { 518 if (!soc || !soc->ops) { 519 QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG, 520 "%s: Invalid Instance", __func__); 521 QDF_BUG(0); 522 return 0; 523 } 524 525 if (!soc->ops->host_stats_ops || 526 !soc->ops->host_stats_ops->txrx_get_vdev_stats) 527 return 0; 528 529 return soc->ops->host_stats_ops->txrx_get_vdev_stats(vdev, 530 buf, 531 is_aggregate); 532 } 533 534 /** 535 * @brief Call to update vdev stats received from firmware 536 * (wmi_host_vdev_stats and wmi_host_vdev_extd_stats) into dp 537 * 538 * @param data - stats data to be updated 539 * @param size - size of stats data 540 * @param stats_id - stats id 541 * @return - int 542 */ 543 static inline int 544 cdp_update_host_vdev_stats(ol_txrx_soc_handle soc, 545 void *data, 546 uint32_t size, 547 uint32_t stats_id) 548 { 549 if (!soc || !soc->ops) { 550 QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG, 551 "%s: Invalid Instance", __func__); 552 QDF_BUG(0); 553 return 0; 554 } 555 556 if (!soc->ops->host_stats_ops || 557 !soc->ops->host_stats_ops->txrx_process_wmi_host_vdev_stats) 558 return 0; 559 560 return soc->ops->host_stats_ops->txrx_process_wmi_host_vdev_stats 561 (soc, 562 data, 563 size, 564 stats_id); 565 } 566 567 /** 568 * @brief Call to get vdev extd stats 569 * 570 * @param vdev - dp vdev object 571 * @param buf - buffer 572 * @return - int 573 */ 574 static inline int 575 cdp_get_vdev_extd_stats(ol_txrx_soc_handle soc, 576 struct cdp_vdev *vdev, 577 void *buf) 578 { 579 if (!soc || !soc->ops) { 580 QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG, 581 "%s: Invalid Instance", __func__); 582 QDF_BUG(0); 583 return 0; 584 } 585 586 if (!soc->ops->host_stats_ops || 587 !soc->ops->host_stats_ops->txrx_get_vdev_extd_stats) 588 return 0; 589 590 return soc->ops->host_stats_ops->txrx_get_vdev_extd_stats(vdev, buf); 591 } 592 593 /** 594 * @brief Call to get cdp_pdev_stats 595 * 596 * @param pdev - dp pdev object 597 * @return - cdp_pdev_stats 598 */ 599 static inline struct cdp_pdev_stats* 600 cdp_host_get_pdev_stats(ol_txrx_soc_handle soc, 601 struct cdp_pdev *pdev) 602 { 603 if (!soc || !soc->ops) { 604 QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG, 605 "%s: Invalid Instance", __func__); 606 QDF_BUG(0); 607 return 0; 608 } 609 610 if (!soc->ops->host_stats_ops || 611 !soc->ops->host_stats_ops->txrx_get_pdev_stats) 612 return 0; 613 614 return soc->ops->host_stats_ops->txrx_get_pdev_stats(pdev); 615 } 616 617 /** 618 * @brief Call to get radio stats 619 * 620 * @param pdev - dp pdev object 621 * @param scn_stats_user - stats buffer 622 * @return - int 623 */ 624 static inline int 625 cdp_host_get_radio_stats(ol_txrx_soc_handle soc, 626 struct cdp_pdev *pdev, 627 void *buf) 628 { 629 if (!soc || !soc->ops) { 630 QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG, 631 "%s: Invalid Instance", __func__); 632 QDF_BUG(0); 633 return 0; 634 } 635 636 if (!soc->ops->host_stats_ops || 637 !soc->ops->host_stats_ops->txrx_get_radio_stats) 638 return 0; 639 640 return soc->ops->host_stats_ops->txrx_get_radio_stats(pdev, 641 buf); 642 } 643 644 /** 645 * @brief Parse the stats header and get the payload from the message. 646 * 647 * @param pdev - the physical device object 648 * @param msg_word - stats buffer received from FW 649 * @param msg_len - length of the message 650 * @param type - place holder for parsed message type 651 * @param status - place holder for parsed message status 652 * @return - pointer to received stat payload 653 */ 654 655 #if defined(QCA_SUPPORT_SON) || defined(ENHANCED_STATS) 656 uint32_t *ol_txrx_get_en_stats_base(struct cdp_pdev *pdev, uint32_t *msg_word, 657 uint32_t msg_len, enum htt_cmn_t2h_en_stats_type *type, enum htt_cmn_t2h_en_stats_status *status); 658 #endif 659 #endif /* _CDP_TXRX_HOST_STATS_H_ */ 660