From cbf3888ca80c0abaeec22b43c6ae08081b73c5f9 Mon Sep 17 00:00:00 2001 From: Ole Troan Date: Wed, 19 Jun 2024 21:07:37 +0200 Subject: dpdk: xstats vecor stuck at 0 elements Fixes: dd6fb60f1794fc08ec40598a67dc70f942c200d1 Type: fix Change-Id: I2429715a954361ceea969191493c15bef21e2040 Signed-off-by: Ole Troan --- src/plugins/dpdk/device/dpdk_priv.h | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) (limited to 'src/plugins/dpdk') diff --git a/src/plugins/dpdk/device/dpdk_priv.h b/src/plugins/dpdk/device/dpdk_priv.h index 0af435767d2..e5b5a35df80 100644 --- a/src/plugins/dpdk/device/dpdk_priv.h +++ b/src/plugins/dpdk/device/dpdk_priv.h @@ -54,14 +54,19 @@ dpdk_get_xstats (dpdk_device_t *xd, u32 thread_index) { int ret; int i; - int len = vec_len (xd->xstats); + int len; if (!(xd->flags & DPDK_DEVICE_FLAG_ADMIN_UP)) return; if (xd->driver == 0) return; + len = rte_eth_xstats_get (xd->port_id, NULL, 0); + if (len < 0) + return; + + vec_validate (xd->xstats, len - 1); ret = rte_eth_xstats_get (xd->port_id, xd->xstats, len); - if (ret < 0 || ret > len || len != vec_len (xd->driver->xstats_counters)) + if (ret < 0 || ret > len) { /* Failed, expand vector and try again on next time around the track. */ vec_validate (xd->xstats, ret - 1); @@ -69,13 +74,20 @@ dpdk_get_xstats (dpdk_device_t *xd, u32 thread_index) dpdk_log_warn ("rte_eth_xstats_get(%d) failed: %d", xd->port_id, ret); return; } - vec_foreach_index (i, xd->xstats) + if (len == vec_len (xd->driver->xstats_counters)) { - vlib_set_simple_counter (&xd->driver->xstats_counters[i], thread_index, - xd->sw_if_index, xd->xstats[i].value); + vec_foreach_index (i, xd->xstats) + { + vlib_set_simple_counter (&xd->driver->xstats_counters[i], + thread_index, xd->sw_if_index, + xd->xstats[i].value); + } + } + else + { + dpdk_log_warn ("rte_eth_xstats_get vector size mismatch (%d/%d", len, + vec_len (xd->driver->xstats_counters)); } - - vec_set_len (xd->xstats, ret); } #define DPDK_UPDATE_COUNTER(vnm, tidx, xd, stat, cnt) \ -- cgit 1.2.3-korg