| 571 | } |
| 572 | |
| 573 | static void |
| 574 | print_stats(struct stats_lcore_params *stats_lcore) |
| 575 | { |
| 576 | unsigned int l_id; |
| 577 | unsigned int bbdev_id = stats_lcore->app_params->bbdev_id; |
| 578 | unsigned int port_id = stats_lcore->app_params->port_id; |
| 579 | int len, ret, i; |
| 580 | |
| 581 | struct rte_eth_xstat *xstats; |
| 582 | struct rte_eth_xstat_name *xstats_names; |
| 583 | struct rte_bbdev_stats bbstats; |
| 584 | static const char *stats_border = "_______"; |
| 585 | |
| 586 | const char clr[] = { 27, '[', '2', 'J', '\0' }; |
| 587 | const char topLeft[] = { 27, '[', '1', ';', '1', 'H', '\0' }; |
| 588 | |
| 589 | /* Clear screen and move to top left */ |
| 590 | printf("%s%s", clr, topLeft); |
| 591 | |
| 592 | printf("PORT STATISTICS:\n================\n"); |
| 593 | len = rte_eth_xstats_get(port_id, NULL, 0); |
| 594 | if (len < 0) |
| 595 | rte_exit(EXIT_FAILURE, |
| 596 | "rte_eth_xstats_get(%u) failed: %d", port_id, |
| 597 | len); |
| 598 | |
| 599 | xstats = calloc(len, sizeof(*xstats)); |
| 600 | if (xstats == NULL) |
| 601 | rte_exit(EXIT_FAILURE, |
| 602 | "Failed to calloc memory for xstats"); |
| 603 | |
| 604 | ret = rte_eth_xstats_get(port_id, xstats, len); |
| 605 | if (ret < 0 || ret > len) { |
| 606 | free(xstats); |
| 607 | rte_exit(EXIT_FAILURE, |
| 608 | "rte_eth_xstats_get(%u) len%i failed: %d", |
| 609 | port_id, len, ret); |
| 610 | } |
| 611 | |
| 612 | xstats_names = calloc(len, sizeof(*xstats_names)); |
| 613 | if (xstats_names == NULL) { |
| 614 | free(xstats); |
| 615 | rte_exit(EXIT_FAILURE, |
| 616 | "Failed to calloc memory for xstats_names"); |
| 617 | } |
| 618 | |
| 619 | ret = rte_eth_xstats_get_names(port_id, xstats_names, len); |
| 620 | if (ret < 0 || ret > len) { |
| 621 | free(xstats); |
| 622 | free(xstats_names); |
| 623 | rte_exit(EXIT_FAILURE, |
| 624 | "rte_eth_xstats_get_names(%u) len%i failed: %d", |
| 625 | port_id, len, ret); |
| 626 | } |
| 627 | |
| 628 | for (i = 0; i < len; i++) { |
| 629 | if (xstats[i].value > 0) |
| 630 | printf("Port %u: %s %s:\t\t%"PRIu64"\n", |
no test coverage detected