From 321809bb8c61066f4ec790f4ac17b3c5e0c67178 Mon Sep 17 00:00:00 2001 From: Matan Azrad Date: Sat, 21 Oct 2017 20:54:45 +0000 Subject: [PATCH] net/failsafe: improve stats accuracy The stats_get API was changed to signal a potential failure to read stats. Furthermore, some PMDs are able to provide statistics even after a removal event occurred. Considering this, the fail-safe can try to access the latest statistics of a PMD to improve statistics accuracy. Attempt an ultimate statistics read on removal time; if that fails, use the latest recorded snapshot. Signed-off-by: Matan Azrad Acked-by: Gaetan Rivet --- drivers/net/failsafe/failsafe_ether.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/drivers/net/failsafe/failsafe_ether.c b/drivers/net/failsafe/failsafe_ether.c index f4db423e78..0282891a63 100644 --- a/drivers/net/failsafe/failsafe_ether.c +++ b/drivers/net/failsafe/failsafe_ether.c @@ -312,8 +312,16 @@ fs_dev_remove(struct sub_device *sdev) static void fs_dev_stats_save(struct sub_device *sdev) { + struct rte_eth_stats stats; + int err; + + /* Attempt to read current stats. */ + err = rte_eth_stats_get(PORT_ID(sdev), &stats); + if (err) + WARN("Could not access latest statistics from sub-device %d," + " using latest snapshot.\n", SUB_ID(sdev)); failsafe_stats_increment(&PRIV(sdev->fs_dev)->stats_accumulator, - &sdev->stats_snapshot); + err ? &sdev->stats_snapshot : &stats); memset(&sdev->stats_snapshot, 0, sizeof(struct rte_eth_stats)); } -- 2.20.1