From patchwork Wed Jul 23 12:28:54 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Olivier Matz X-Patchwork-Id: 86 Return-Path: Received: from mail-wg0-f46.google.com (mail-wg0-f46.google.com [74.125.82.46]) by dpdk.org (Postfix) with ESMTP id B33C1594D for ; Wed, 23 Jul 2014 14:27:39 +0200 (CEST) Received: by mail-wg0-f46.google.com with SMTP id m15so1091958wgh.17 for ; Wed, 23 Jul 2014 05:29:03 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=FFfukQ1b6PPuWesVBTZojnilIFlt9MVXT1NaDS7iot8=; b=lnLkje5S50XWgxyLZ0pdG3VeWgoMWPge17a/sryzYJfhgWpDTjWoSYu3VicL/N4ovC dh1O9SfpQMy422AlzU27LWB0A+J3ybZMGcUlzDI9bOPJ8JuCzn0FUmhy/hvNkpFMoS0n LtXMSWD8Hk+dMce2+KfikhHXNe7sXt3XTXXe80DapnCBFqL7yBG192Jr0BMetKUmVBCa /Ja/4NC3FE064l9f2kYlOWCMPTBvhmbNQQB/KMftepZXSl+7I7qJ4/4wGhdquDAQMaQJ m4vxDM16X45FwrpFVXZoyo8zbdSVortTy4cBuffY2v1rNHRhSOVVTSWqy3LhcWJ1KWrh bmhA== X-Gm-Message-State: ALoCoQlrK/bLi7L17XnW+fQg6Ek+5d8SbX1scGc7k3OcXrzpAwB9PxHxs6Ie0KNFiyRSOPAG9wVT X-Received: by 10.194.174.35 with SMTP id bp3mr1280317wjc.33.1406118543104; Wed, 23 Jul 2014 05:29:03 -0700 (PDT) Received: from glumotte.dev.6wind.com (guy78-3-82-239-227-177.fbx.proxad.net. [82.239.227.177]) by mx.google.com with ESMTPSA id ch5sm5882484wjb.18.2014.07.23.05.29.01 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 23 Jul 2014 05:29:02 -0700 (PDT) From: Olivier Matz To: dev@dpdk.org Date: Wed, 23 Jul 2014 14:28:54 +0200 Message-Id: <1406118534-6169-3-git-send-email-olivier.matz@6wind.com> X-Mailer: git-send-email 2.0.1 In-Reply-To: <1406118534-6169-1-git-send-email-olivier.matz@6wind.com> References: <1406118534-6169-1-git-send-email-olivier.matz@6wind.com> Subject: [dpdk-dev] [PATCH 2/2] testpmd: add a new command to get the extended statistics of a port X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 23 Jul 2014 12:27:39 -0000 Add a new token in "show port" command to dump the extended statistics of a device. It validates the new xstats framework added in previous commit. Signed-off-by: Olivier Matz --- app/test-pmd/cmdline.c | 22 ++++++++++++++++------ app/test-pmd/config.c | 34 ++++++++++++++++++++++++++++++++++ app/test-pmd/testpmd.h | 2 ++ 3 files changed, 52 insertions(+), 6 deletions(-) diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c index 345be11..972ef8c 100644 --- a/app/test-pmd/cmdline.c +++ b/app/test-pmd/cmdline.c @@ -183,14 +183,14 @@ static void cmd_help_long_parsed(void *parsed_result, "Display:\n" "--------\n\n" - "show port (info|stats|fdir|stat_qmap) (port_id|all)\n" + "show port (info|stats|xstats|fdir|stat_qmap) (port_id|all)\n" " Display information for port_id, or all.\n\n" "show port rss-hash [key]\n" " Display the RSS hash functions and RSS hash key" " of port X\n\n" - "clear port (info|stats|fdir|stat_qmap) (port_id|all)\n" + "clear port (info|stats|xstats|fdir|stat_qmap) (port_id|all)\n" " Clear information for port_id, or all.\n\n" "show config (rxtx|cores|fwd)\n" @@ -5015,12 +5015,18 @@ static void cmd_showportall_parsed(void *parsed_result, if (!strcmp(res->what, "stats")) for (i = 0; i < nb_ports; i++) nic_stats_clear(i); + else if (!strcmp(res->what, "xstats")) + for (i = 0; i < nb_ports; i++) + nic_xstats_clear(i); } else if (!strcmp(res->what, "info")) for (i = 0; i < nb_ports; i++) port_infos_display(i); else if (!strcmp(res->what, "stats")) for (i = 0; i < nb_ports; i++) nic_stats_display(i); + else if (!strcmp(res->what, "xstats")) + for (i = 0; i < nb_ports; i++) + nic_xstats_display(i); else if (!strcmp(res->what, "fdir")) for (i = 0; i < nb_ports; i++) fdir_get_infos(i); @@ -5036,13 +5042,13 @@ cmdline_parse_token_string_t cmd_showportall_port = TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port"); cmdline_parse_token_string_t cmd_showportall_what = TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what, - "info#stats#fdir#stat_qmap"); + "info#stats#xstats#fdir#stat_qmap"); cmdline_parse_token_string_t cmd_showportall_all = TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all"); cmdline_parse_inst_t cmd_showportall = { .f = cmd_showportall_parsed, .data = NULL, - .help_str = "show|clear port info|stats|fdir|stat_qmap all", + .help_str = "show|clear port info|stats|xstats|fdir|stat_qmap all", .tokens = { (void *)&cmd_showportall_show, (void *)&cmd_showportall_port, @@ -5068,10 +5074,14 @@ static void cmd_showport_parsed(void *parsed_result, if (!strcmp(res->show, "clear")) { if (!strcmp(res->what, "stats")) nic_stats_clear(res->portnum); + else if (!strcmp(res->what, "xstats")) + nic_xstats_clear(res->portnum); } else if (!strcmp(res->what, "info")) port_infos_display(res->portnum); else if (!strcmp(res->what, "stats")) nic_stats_display(res->portnum); + else if (!strcmp(res->what, "xstats")) + nic_xstats_display(res->portnum); else if (!strcmp(res->what, "fdir")) fdir_get_infos(res->portnum); else if (!strcmp(res->what, "stat_qmap")) @@ -5085,14 +5095,14 @@ cmdline_parse_token_string_t cmd_showport_port = TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port"); cmdline_parse_token_string_t cmd_showport_what = TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what, - "info#stats#fdir#stat_qmap"); + "info#stats#xstats#fdir#stat_qmap"); cmdline_parse_token_num_t cmd_showport_portnum = TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, INT32); cmdline_parse_inst_t cmd_showport = { .f = cmd_showport_parsed, .data = NULL, - .help_str = "show|clear port info|stats|fdir|stat_qmap X (X = port number)", + .help_str = "show|clear port info|stats|xstats|fdir|stat_qmap X (X = port number)", .tokens = { (void *)&cmd_showport_show, (void *)&cmd_showport_port, diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c index c72f6ee..0a42ee9 100644 --- a/app/test-pmd/config.c +++ b/app/test-pmd/config.c @@ -199,6 +199,40 @@ nic_stats_clear(portid_t port_id) printf("\n NIC statistics for port %d cleared\n", port_id); } +void +nic_xstats_display(portid_t port_id) +{ + struct rte_eth_xstats *xstats; + int len, ret, i; + + printf("###### NIC extended statistics for port %-2d\n", port_id); + + len = rte_eth_xstats_get(port_id, NULL, 0); + if (len < 0) { + printf("Cannot get xstats count\n"); + return; + } + xstats = malloc(sizeof(xstats[0]) * len); + if (xstats == NULL) { + printf("Cannot allocate memory for xstats\n"); + return; + } + ret = rte_eth_xstats_get(port_id, xstats, len); + if (ret < 0 || ret > len) { + printf("Cannot get xstats\n"); + free(xstats); + return ; + } + for (i = 0; i < len; i++) + printf("%s: %"PRIu64"\n", xstats[i].name, xstats[i].value); + free(xstats); +} + +void +nic_xstats_clear(portid_t port_id) +{ + rte_eth_xstats_reset(port_id); +} void nic_stats_mapping_display(portid_t port_id) diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h index ac86bfe..c698c41 100644 --- a/app/test-pmd/testpmd.h +++ b/app/test-pmd/testpmd.h @@ -448,6 +448,8 @@ void launch_args_parse(int argc, char** argv); void prompt(void); void nic_stats_display(portid_t port_id); void nic_stats_clear(portid_t port_id); +void nic_xstats_display(portid_t port_id); +void nic_xstats_clear(portid_t port_id); void nic_stats_mapping_display(portid_t port_id); void port_infos_display(portid_t port_id); void fwd_lcores_config_display(void);