From: Kuba Kozak <kubax.kozak@intel.com>
To: dev@dpdk.org
Cc: Jacek Piasecki <jacekx.piasecki@intel.com>,
Kuba Kozak <kubax.kozak@intel.com>
Subject: [dpdk-dev] [PATCH 4/4] app/proc_info: add support for xstats-name and xstats-group
Date: Fri, 3 Mar 2017 13:54:32 +0100 [thread overview]
Message-ID: <1488545672-5208-5-git-send-email-kubax.kozak@intel.com> (raw)
In-Reply-To: <1488545672-5208-1-git-send-email-kubax.kozak@intel.com>
From: Jacek Piasecki <jacekx.piasecki@intel.com>
This patch provides support for proc_info application
to allow printing single xstat value specified by its
name and printing xstats values specified by its group name.
New proc_info arguments:
--xstats-name NAME: to display single xstat value by NAME
--xstats-group GROUPNAME: to display group of xstats by GROUPNAME
Signed-off-by: Jacek Piasecki <jacekx.piasecki@intel.com>
Signed-off-by: Kuba Kozak <kubax.kozak@intel.com>
---
app/proc_info/main.c | 112 ++++++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 111 insertions(+), 1 deletion(-)
diff --git a/app/proc_info/main.c b/app/proc_info/main.c
index 2c56d10..8826090 100644
--- a/app/proc_info/main.c
+++ b/app/proc_info/main.c
@@ -74,6 +74,11 @@
static uint32_t reset_xstats;
/**< Enable memory info. */
static uint32_t mem_info;
+/**< Enable displaying xstat name. */
+static uint32_t enable_xstats_name;
+static char *xstats_name;
+/**< Enable displaying xstat group name. */
+static uint64_t enable_xstats_group;
/**< display usage */
static void
@@ -85,6 +90,8 @@
" --stats: to display port statistics, enabled by default\n"
" --xstats: to display extended port statistics, disabled by "
"default\n"
+ " --xstats-name NAME: to display single xstat value by NAME\n"
+ " --xstats-group GROUPNAME: to display group of xstats by GROUPNAME\n"
" --stats-reset: to reset port statistics\n"
" --xstats-reset: to reset port extended statistics\n",
prgname);
@@ -128,6 +135,8 @@
{"stats-reset", 0, NULL, 0},
{"xstats", 0, NULL, 0},
{"xstats-reset", 0, NULL, 0},
+ {"xstats-name", required_argument, NULL, 1},
+ {"xstats-group", required_argument, NULL, 1},
{NULL, 0, 0, 0}
};
@@ -168,7 +177,27 @@
MAX_LONG_OPT_SZ))
reset_xstats = 1;
break;
-
+ case 1:
+ /* Print xstat single value given by name*/
+ if (!strncmp(long_option[option_index].name,
+ "xstats-name",
+ MAX_LONG_OPT_SZ)) {
+ enable_xstats_name = 1;
+ xstats_name = optarg;
+ printf("name:%s:%s\n",
+ long_option[option_index].name,
+ optarg);
+ }
+ /* Print xstat group values given by group name*/
+ else if (!strncmp(long_option[option_index].name,
+ "xstats-group",
+ MAX_LONG_OPT_SZ)) {
+ enable_xstats_group = atoi(optarg);
+ printf("name:%s:%s\n",
+ long_option[option_index].name,
+ optarg);
+ }
+ break;
default:
proc_info_usage(prgname);
return -1;
@@ -241,6 +270,82 @@
}
static void
+nic_xstats_by_name_display(__rte_unused uint8_t port_id,
+ __rte_unused char *name)
+{
+ struct rte_eth_xstat xstat;
+
+ printf("###### NIC statistics for port %-2d, statistic name '%s':\n",
+ port_id, name);
+
+ if (rte_eth_xstats_get_by_name(port_id, &xstat, name) == 0)
+ printf("%s: %"PRIu64"\n", name, xstat.value);
+ else
+ printf("Statistic not found...\n");
+
+}
+
+static void
+nic_xstats_by_group_display(__rte_unused uint8_t port_id,
+ __rte_unused uint64_t group_mask)
+{
+ struct rte_eth_xstat *xstats;
+ int cnt_xstats, idx_xstat;
+ struct rte_eth_xstat_name *xstats_names;
+
+ printf("###### NIC extended statistics for port %-2d,"
+ " group %-2lu #########\n",
+ port_id, group_mask);
+
+ /* Get count */
+ cnt_xstats = rte_eth_xstats_get_names_by_group(port_id, NULL, 0,
+ group_mask);
+ if (cnt_xstats < 0) {
+ printf("Error: Cannot get count of xstats\n");
+ return;
+ }
+
+ /* Get id-name lookup table */
+ xstats_names = malloc(sizeof(struct rte_eth_xstat_name) * cnt_xstats);
+ if (xstats_names == NULL) {
+ printf("Cannot allocate memory for xstats lookup\n");
+ return;
+ }
+
+ if (cnt_xstats != rte_eth_xstats_get_names_by_group(
+ port_id, xstats_names, cnt_xstats, group_mask)) {
+ printf("Error: Cannot get xstats lookup\n");
+ free(xstats_names);
+ return;
+ }
+
+ /* Get stats themselves */
+ xstats = malloc(sizeof(struct rte_eth_xstat) * cnt_xstats);
+ if (xstats == NULL) {
+ printf("Cannot allocate memory for xstats\n");
+ free(xstats_names);
+ return;
+ }
+
+ if (cnt_xstats != rte_eth_xstats_get_by_group(port_id, xstats,
+ cnt_xstats, group_mask)) {
+ printf("Error: Unable to get xstats\n");
+ free(xstats_names);
+ free(xstats);
+ return;
+ }
+
+ /* Display xstats */
+ for (idx_xstat = 0; idx_xstat < cnt_xstats; idx_xstat++)
+ printf("%s: %"PRIu64"\n",
+ xstats_names[idx_xstat].name,
+ xstats[idx_xstat].value);
+ free(xstats_names);
+ free(xstats);
+
+}
+
+static void
nic_xstats_display(uint8_t port_id)
{
struct rte_eth_xstat_name *xstats_names;
@@ -360,6 +465,11 @@
nic_stats_clear(i);
else if (reset_xstats)
nic_xstats_clear(i);
+ else if (enable_xstats_group)
+ nic_xstats_by_group_display(i,
+ enable_xstats_group);
+ else if (enable_xstats_name)
+ nic_xstats_by_name_display(i, xstats_name);
}
}
--
1.9.1
prev parent reply other threads:[~2017-03-03 11:24 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-03 12:54 [dpdk-dev] [PATCH 0/4] extend API to retriving xstats by group and xstats by name Kuba Kozak
2017-03-03 12:54 ` [dpdk-dev] [PATCH 1/4] ethdev: add retrieving " Kuba Kozak
2017-03-06 10:17 ` Thomas Monjalon
2017-03-03 12:54 ` [dpdk-dev] [PATCH 2/4] net/e1000: add grouping of xstats for e1000 driver Kuba Kozak
2017-03-06 2:05 ` Lu, Wenzhuo
2017-03-03 12:54 ` [dpdk-dev] [PATCH 3/4] net/ixgbe: add grouping of xstats for ixgbe driver Kuba Kozak
2017-03-03 12:54 ` Kuba Kozak [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1488545672-5208-5-git-send-email-kubax.kozak@intel.com \
--to=kubax.kozak@intel.com \
--cc=dev@dpdk.org \
--cc=jacekx.piasecki@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).