From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by dpdk.org (Postfix) with ESMTP id 69D866945 for ; Mon, 30 May 2016 12:48:24 +0200 (CEST) Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga104.fm.intel.com with ESMTP; 30 May 2016 03:48:24 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.26,389,1459839600"; d="scan'208";a="817650951" Received: from rhorton-mobl.ger.corp.intel.com (HELO VM.ir.intel.com) ([163.33.228.212]) by orsmga003.jf.intel.com with ESMTP; 30 May 2016 03:48:23 -0700 From: Remy Horton To: dev@dpdk.org, Maryam Tahhan Date: Mon, 30 May 2016 11:48:10 +0100 Message-Id: <1464605292-4599-9-git-send-email-remy.horton@intel.com> X-Mailer: git-send-email 2.5.5 In-Reply-To: <1464605292-4599-1-git-send-email-remy.horton@intel.com> References: <1464605292-4599-1-git-send-email-remy.horton@intel.com> Subject: [dpdk-dev] [PATCH v3 08/10] app/proc_info: change xstats to use integer ids 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: Mon, 30 May 2016 10:48:25 -0000 The current extended ethernet statistics fetching involve doing several string operations, which causes performance issues if there are lots of statistics and/or network interfaces. This patch changes the proc_info application to use the new API that seperates name string and value queries. Signed-off-by: Remy Horton --- app/proc_info/main.c | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/app/proc_info/main.c b/app/proc_info/main.c index 5f83092..ef71fcf 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 @@ -243,11 +243,13 @@ nic_stats_clear(uint8_t port_id) static void nic_xstats_display(uint8_t port_id) { + struct rte_eth_xstats_name *ptr_names; struct rte_eth_xstats *xstats; int len, ret, i; + int idx_name; static const char *nic_stats_border = "########################"; - len = rte_eth_xstats_get(port_id, NULL, 0); + len = rte_eth_xstats_count(port_id); if (len < 0) { printf("Cannot get xstats count\n"); return; @@ -258,6 +260,18 @@ nic_xstats_display(uint8_t port_id) return; } + ptr_names = malloc(sizeof(struct rte_eth_xstats_name) * len); + if (ptr_names == NULL) { + printf("Cannot allocate memory for xstat names\n"); + free(xstats); + return; + } + if (len != rte_eth_xstats_names( + port_id, ptr_names, len)) { + printf("Cannot get xstat names\n"); + return; + } + printf("###### NIC extended statistics for port %-2d #########\n", port_id); printf("%s############################\n", @@ -270,11 +284,17 @@ nic_xstats_display(uint8_t port_id) } for (i = 0; i < len; i++) - printf("%s: %"PRIu64"\n", xstats[i].name, xstats[i].value); + for (idx_name = 0; idx_name < len; idx_name++) + if (ptr_names[idx_name].id == xstats[i].id) { + printf("%s: %lu\n", ptr_names[idx_name].name, + xstats[i].value); + break; + } printf("%s############################\n", nic_stats_border); free(xstats); + free(ptr_names); } static void -- 2.5.5