X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=app%2Fproc_info%2Fmain.c;h=2c56d10667a53a72c7ec7f9e3f45ded622e326d6;hb=69ed52dddc0fc64f5cec7e7384197874f92ff393;hp=6448d7be6949d3e20d501026987b71cd0eb5c6df;hpb=22561383ea1776cecb454a98242a3bcec82ca4e2;p=dpdk.git diff --git a/app/proc_info/main.c b/app/proc_info/main.c index 6448d7be69..2c56d10667 100644 --- a/app/proc_info/main.c +++ b/app/proc_info/main.c @@ -1,7 +1,7 @@ /* * BSD LICENSE * - * Copyright(c) 2010-2015 Intel Corporation. All rights reserved. + * Copyright(c) 2010-2016 Intel Corporation. All rights reserved. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -42,7 +42,6 @@ #include #include -#include #include #include #include @@ -244,11 +243,12 @@ nic_stats_clear(uint8_t port_id) static void nic_xstats_display(uint8_t port_id) { - struct rte_eth_xstats *xstats; + struct rte_eth_xstat_name *xstats_names; + struct rte_eth_xstat *xstats; int len, ret, i; static const char *nic_stats_border = "########################"; - len = rte_eth_xstats_get(port_id, NULL, 0); + len = rte_eth_xstats_get_names(port_id, NULL, 0); if (len < 0) { printf("Cannot get xstats count\n"); return; @@ -259,6 +259,18 @@ nic_xstats_display(uint8_t port_id) return; } + xstats_names = malloc(sizeof(struct rte_eth_xstat_name) * len); + if (xstats_names == NULL) { + printf("Cannot allocate memory for xstat names\n"); + free(xstats); + return; + } + if (len != rte_eth_xstats_get_names( + port_id, xstats_names, len)) { + printf("Cannot get xstat names\n"); + goto err; + } + printf("###### NIC extended statistics for port %-2d #########\n", port_id); printf("%s############################\n", @@ -266,16 +278,19 @@ nic_xstats_display(uint8_t port_id) ret = rte_eth_xstats_get(port_id, xstats, len); if (ret < 0 || ret > len) { printf("Cannot get xstats\n"); - free(xstats); - return; + goto err; } for (i = 0; i < len; i++) - printf("%s: %"PRIu64"\n", xstats[i].name, xstats[i].value); + printf("%s: %"PRIu64"\n", + xstats_names[i].name, + xstats[i].value); printf("%s############################\n", nic_stats_border); +err: free(xstats); + free(xstats_names); } static void @@ -314,6 +329,9 @@ main(int argc, char **argv) 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) @@ -328,10 +346,6 @@ main(int argc, char **argv) if (nb_ports == 0) rte_exit(EXIT_FAILURE, "No Ethernet ports - bye\n"); - - if (nb_ports > RTE_MAX_ETHPORTS) - nb_ports = RTE_MAX_ETHPORTS; - /* If no port mask was specified*/ if (enabled_port_mask == 0) enabled_port_mask = 0xffff;