static __attribute__((noreturn)) void lcore_stats(void) { uint8_t port = 0; while (1) { sleep(30); nic_stats_display(port); nic_xstats_display(port); printf("\n$$$$$$$$$$$$$$reset the stats$$$$$$$$$$$$$\n"); nic_stats_clear(port); nic_xstats_clear(port); } }
static void cmd_showport_parsed(void *parsed_result, struct cmdline *cl, void *data) { struct cmd_showport_result *res = parsed_result; if (!strcmp(res->show, "clear")) { if (!strcmp(res->what, "stats")) nic_stats_clear(cl, res->portnum); else if (!strcmp(res->what, "xstats")) nic_xstats_clear(cl, res->portnum); } else if (!strcmp(res->what, "info")) port_infos_display(cl, res->portnum); else if (!strcmp(res->what, "stats")) nic_stats_display(cl, res->portnum, (intptr_t)data); else if (!strcmp(res->what, "xstats")) nic_xstats_display(cl, res->portnum, (intptr_t)data); }
int main(int argc, char **argv) { int ret; int i; char c_flag[] = "-c1"; char n_flag[] = "-n4"; char mp_flag[] = "--proc-type=secondary"; char *argp[argc + 3]; uint8_t nb_ports; /* preparse app arguments */ ret = proc_info_preparse_args(argc, argv); if (ret < 0) { printf("Failed to parse arguments\n"); return -1; } argp[0] = argv[0]; argp[1] = c_flag; argp[2] = n_flag; argp[3] = mp_flag; for (i = 1; i < argc; i++) argp[i + 3] = argv[i]; argc += 3; ret = rte_eal_init(argc, argp); if (ret < 0) rte_panic("Cannot init EAL\n"); argc -= ret; argv += (ret - 3); if (!rte_eal_primary_proc_alive(NULL)) rte_exit(EXIT_FAILURE, "No primary DPDK process is running.\n"); /* parse app arguments */ ret = proc_info_parse_args(argc, argv); if (ret < 0) rte_exit(EXIT_FAILURE, "Invalid argument\n"); if (mem_info) { meminfo_display(); return 0; } nb_ports = rte_eth_dev_count(); if (nb_ports == 0) rte_exit(EXIT_FAILURE, "No Ethernet ports - bye\n"); /* If no port mask was specified*/ if (enabled_port_mask == 0) enabled_port_mask = 0xffff; for (i = 0; i < nb_ports; i++) { if (enabled_port_mask & (1 << i)) { if (enable_stats) nic_stats_display(i); else if (enable_xstats) nic_xstats_display(i); else if (reset_stats) nic_stats_clear(i); else if (reset_xstats) nic_xstats_clear(i); else if (enable_xstats_name) nic_xstats_by_name_display(i, xstats_name); else if (nb_xstats_ids > 0) nic_xstats_by_ids_display(i, xstats_ids, nb_xstats_ids); else if (enable_metrics) metrics_display(i); } } /* print port independent stats */ if (enable_metrics) metrics_display(RTE_METRICS_GLOBAL); return 0; }