diff options
author | Filip Tehlar <ftehlar@cisco.com> | 2019-06-03 08:13:21 +0000 |
---|---|---|
committer | Damjan Marion <dmarion@me.com> | 2019-06-04 07:46:49 +0000 |
commit | d5cf64f8c2a08d2f41327cc99dd2d96f77d82ca3 (patch) | |
tree | b05746f3c7dbd7aa787a32781a14e614ff61fefc /src/plugins | |
parent | bbc0867b6322d63cd35dda8e7a836566d93f1f16 (diff) |
dpdk: rework extended stats
Change-Id: I421192e1921d4c9c5486a6dcca745582aebf4e3e
Signed-off-by: Filip Tehlar <ftehlar@cisco.com>
Diffstat (limited to 'src/plugins')
-rw-r--r-- | src/plugins/dpdk/device/device.c | 12 | ||||
-rw-r--r-- | src/plugins/dpdk/device/dpdk.h | 1 | ||||
-rw-r--r-- | src/plugins/dpdk/device/dpdk_priv.h | 26 | ||||
-rw-r--r-- | src/plugins/dpdk/device/format.c | 41 |
4 files changed, 33 insertions, 47 deletions
diff --git a/src/plugins/dpdk/device/device.c b/src/plugins/dpdk/device/device.c index e4a92f0f0e2..836357f1c9e 100644 --- a/src/plugins/dpdk/device/device.c +++ b/src/plugins/dpdk/device/device.c @@ -397,17 +397,7 @@ dpdk_clear_hw_interface_counters (u32 instance) dpdk_main_t *dm = &dpdk_main; dpdk_device_t *xd = vec_elt_at_index (dm->devices, instance); - /* - * Set the "last_cleared_stats" to the current stats, so that - * things appear to clear from a display perspective. - */ - dpdk_update_counters (xd, vlib_time_now (dm->vlib_main)); - - clib_memcpy_fast (&xd->last_cleared_stats, &xd->stats, sizeof (xd->stats)); - clib_memcpy_fast (xd->last_cleared_xstats, xd->xstats, - vec_len (xd->last_cleared_xstats) * - sizeof (xd->last_cleared_xstats[0])); - + rte_eth_xstats_reset (xd->port_id); } static clib_error_t * diff --git a/src/plugins/dpdk/device/dpdk.h b/src/plugins/dpdk/device/dpdk.h index eadf35d5ef6..a1c522490ab 100644 --- a/src/plugins/dpdk/device/dpdk.h +++ b/src/plugins/dpdk/device/dpdk.h @@ -248,7 +248,6 @@ typedef struct struct rte_eth_stats last_stats; struct rte_eth_stats last_cleared_stats; struct rte_eth_xstat *xstats; - struct rte_eth_xstat *last_cleared_xstats; f64 time_last_stats_update; dpdk_port_type_t port_type; diff --git a/src/plugins/dpdk/device/dpdk_priv.h b/src/plugins/dpdk/device/dpdk_priv.h index e0e06826935..0b1fe92bf72 100644 --- a/src/plugins/dpdk/device/dpdk_priv.h +++ b/src/plugins/dpdk/device/dpdk_priv.h @@ -52,26 +52,26 @@ _(log-level) static inline void dpdk_get_xstats (dpdk_device_t * xd) { + int len, ret; + if (!(xd->flags & DPDK_DEVICE_FLAG_ADMIN_UP)) return; - int len; - if ((len = rte_eth_xstats_get (xd->port_id, NULL, 0)) > 0) - { - vec_validate (xd->xstats, len - 1); - vec_validate (xd->last_cleared_xstats, len - 1); - len = - rte_eth_xstats_get (xd->port_id, xd->xstats, vec_len (xd->xstats)); - - ASSERT (vec_len (xd->xstats) == len); - ASSERT (vec_len (xd->last_cleared_xstats) == len); + len = rte_eth_xstats_get (xd->port_id, NULL, 0); + if (len < 0) + return; - _vec_len (xd->xstats) = len; - _vec_len (xd->last_cleared_xstats) = len; + vec_validate (xd->xstats, len - 1); + ret = rte_eth_xstats_get (xd->port_id, xd->xstats, len); + if (ret < 0 || ret > len) + { + _vec_len (xd->xstats) = 0; + return; } -} + _vec_len (xd->xstats) = len; +} static inline void dpdk_update_counters (dpdk_device_t * xd, f64 now) 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) { |