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 test-pmd
and proc_info applications to use the new xstats API, and removes
deprecated code associated with the old API.
Signed-off-by: Remy Horton
---
app/proc_info/main.c | 29 +---
app/test-pmd/config.c | 54 +-
drivers/net/e1000/igb_ethdev.c | 10 +++
drivers/net/fm10k/fm10k_ethdev.c | 5 +---
drivers/net/i40e/i40e_ethdev.c | 8 ++
drivers/net/i40e/i40e_ethdev_vf.c | 5 ++--
drivers/net/ixgbe/ixgbe_ethdev.c | 11 +++-
drivers/net/virtio/virtio_ethdev.c | 6 ++---
lib/librte_ether/rte_ethdev.c | 5 +---
lib/librte_ether/rte_ethdev.h | 7 +++--
10 files changed, 85 insertions(+), 55 deletions(-)
diff --git a/app/proc_info/main.c b/app/proc_info/main.c
index 5f83092..f2063fa 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 *xstats;
+ struct rte_eth_xstat_name *xstats_names;
+ struct rte_eth_xstat *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_get_names(port_id, NULL, 0);
if (len < 0) {
printf("Cannot get xstats count\n");
return;
@@ -258,6 +260,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");
+ return;
+ }
+
printf("## NIC extended statistics for port %-2d #\n",
port_id);
printf("%s\n",
@@ -270,11 +284,18 @@ 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 (xstats_names[idx_name].id == xstats[i].id) {
+ printf("%s: %"PRIu64"\n",
+ xstats_names[idx_name].name,
+ xstats[i].value);
+ break;
+ }
printf("%s\n",
nic_stats_border);
free(xstats);
+ free(xstats_names);
}
static void
diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c
index 1c552e4..8ddec07 100644
--- a/app/test-pmd/config.c
+++ b/app/test-pmd/config.c
@@ -1,7 +1,7 @@
/*-
* BSD LICENSE
*
- * Copyright(c) 2010-2014 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
@@ -232,29 +232,57 @@ nic_stats_clear(portid_t port_id)
void
nic_xstats_display(portid_t port_id)
{
- struct rte_eth_xstats *xstats;
- int len, ret, i;
+ struct rte_eth_xstat *xstats;
+ int cnt_xstats, idx_xstat, idx_name;
+ struct rte_eth_xstat_name *xstats_names;
printf("## NIC extended statistics for port %-2d\n", port_id);
+ if (!rte_eth_dev_is_valid_port(port_id)) {
+ printf("Error: Invalid port number %i\n", port_id);
+ return;
+ }
+
+ /* Get count */
+ cnt_xstats = rte_eth_xstats_get_names(port_id, NULL, 0);
+ if (cnt_xstats < 0) {
+ printf("Error: Cannot get count of xstats\n");
+ return;
+ }
- len = rte_eth_xstats_get(port_id, NULL, 0);
- if (len < 0) {
- printf("Cannot get xstats count\n");
+ /* 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;
}
- xstats = malloc(sizeof(xstats[0]) * len);
+ if (cnt_xstats != rte_eth_xstats_get_nam