aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/avf
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/avf')
-rw-r--r--src/plugins/avf/avf.h1
-rw-r--r--src/plugins/avf/device.c10
-rw-r--r--src/plugins/avf/format.c5
3 files changed, 14 insertions, 2 deletions
diff --git a/src/plugins/avf/avf.h b/src/plugins/avf/avf.h
index 62fa9a6ecd9..b907e3ff2b6 100644
--- a/src/plugins/avf/avf.h
+++ b/src/plugins/avf/avf.h
@@ -164,6 +164,7 @@ typedef struct
/* stats */
virtchnl_eth_stats_t eth_stats;
+ virtchnl_eth_stats_t last_cleared_eth_stats;
/* error */
clib_error_t *error;
diff --git a/src/plugins/avf/device.c b/src/plugins/avf/device.c
index 2a86bed4a7a..5fd1d6cd8db 100644
--- a/src/plugins/avf/device.c
+++ b/src/plugins/avf/device.c
@@ -1416,10 +1416,20 @@ static char *avf_tx_func_error_strings[] = {
#undef _
};
+static void
+avf_clear_hw_interface_counters (u32 instance)
+{
+ avf_main_t *am = &avf_main;
+ avf_device_t *ad = vec_elt_at_index (am->devices, instance);
+ clib_memcpy_fast (&ad->last_cleared_eth_stats,
+ &ad->eth_stats, sizeof (ad->eth_stats));
+}
+
/* *INDENT-OFF* */
VNET_DEVICE_CLASS (avf_device_class,) =
{
.name = "Adaptive Virtual Function (AVF) interface",
+ .clear_counters = avf_clear_hw_interface_counters,
.format_device = format_avf_device,
.format_device_name = format_avf_device_name,
.admin_up_down_function = avf_interface_admin_up_down,
diff --git a/src/plugins/avf/format.c b/src/plugins/avf/format.c
index 4c391a80760..4def8b5ea32 100644
--- a/src/plugins/avf/format.c
+++ b/src/plugins/avf/format.c
@@ -107,9 +107,10 @@ format_avf_device (u8 * s, va_list * args)
s = format (s, "\n%Uerror %U", format_white_space, indent,
format_clib_error, ad->error);
-#define _(c) if (ad->eth_stats.c) \
+#define _(c) if (ad->eth_stats.c - ad->last_cleared_eth_stats.c) \
a = format (a, "\n%U%-20U %u", format_white_space, indent + 2, \
- format_c_identifier, #c, ad->eth_stats.c);
+ format_c_identifier, #c, \
+ ad->eth_stats.c - ad->last_cleared_eth_stats.c);
foreach_virtchnl_eth_stats;
#undef _
if (a)