summaryrefslogtreecommitdiffstats
path: root/src/plugins/dpdk/device/format.c
diff options
context:
space:
mode:
authorFilip Tehlar <ftehlar@cisco.com>2019-06-03 08:13:21 +0000
committerDamjan Marion <dmarion@me.com>2019-06-04 07:46:49 +0000
commitd5cf64f8c2a08d2f41327cc99dd2d96f77d82ca3 (patch)
treeb05746f3c7dbd7aa787a32781a14e614ff61fefc /src/plugins/dpdk/device/format.c
parentbbc0867b6322d63cd35dda8e7a836566d93f1f16 (diff)
dpdk: rework extended stats
Change-Id: I421192e1921d4c9c5486a6dcca745582aebf4e3e Signed-off-by: Filip Tehlar <ftehlar@cisco.com>
Diffstat (limited to 'src/plugins/dpdk/device/format.c')
-rw-r--r--src/plugins/dpdk/device/format.c41
1 files changed, 19 insertions, 22 deletions
diff --git a/src/plugins/dpdk/device/format.c b/src/plugins/dpdk/device/format.c
index b7ceda03ad6..be2349d9e9d 100644
--- a/src/plugins/dpdk/device/format.c
+++ b/src/plugins/dpdk/device/format.c
@@ -659,35 +659,32 @@ format_dpdk_device (u8 * s, va_list * args)
u8 *xs = 0;
u32 i = 0;
- struct rte_eth_xstat *xstat, *last_xstat;
+ struct rte_eth_xstat *xstat;
struct rte_eth_xstat_name *xstat_names = 0;
- int len = rte_eth_xstats_get_names (xd->port_id, NULL, 0);
+ int len = vec_len (xd->xstats);
vec_validate (xstat_names, len - 1);
- rte_eth_xstats_get_names (xd->port_id, xstat_names, len);
+ int ret = rte_eth_xstats_get_names (xd->port_id, xstat_names, len);
- ASSERT (vec_len (xd->xstats) == vec_len (xd->last_cleared_xstats));
-
- /* *INDENT-OFF* */
- vec_foreach_index(i, xd->xstats)
+ if (ret < 0 || ret > len)
{
- u64 delta = 0;
- xstat = vec_elt_at_index(xd->xstats, i);
- last_xstat = vec_elt_at_index(xd->last_cleared_xstats, i);
-
- delta = xstat->value - last_xstat->value;
- if (verbose == 2 || (verbose && delta))
+ /* *INDENT-OFF* */
+ vec_foreach_index(i, xd->xstats)
{
- /* format_c_identifier doesn't like c strings inside vector */
- u8 * name = format(0,"%s", xstat_names[i].name);
- xs = format(xs, "\n%U%-38U%16Lu",
- format_white_space, indent + 4,
- format_c_identifier, name, delta);
- vec_free(name);
+ xstat = vec_elt_at_index(xd->xstats, i);
+ if (verbose == 2 || (verbose && xstat->value))
+ {
+ /* format_c_identifier doesn't like c strings inside vector */
+ u8 * name = format(0,"%s", xstat_names[i].name);
+ xs = format(xs, "\n%U%-38U%16Lu",
+ format_white_space, indent + 4,
+ format_c_identifier, name, xstat->value);
+ vec_free(name);
+ }
}
- }
- /* *INDENT-ON* */
+ /* *INDENT-ON* */
- vec_free (xstat_names);
+ vec_free (xstat_names);
+ }
if (xs)
{