net/failsafe: add timestamp to stats snapshot
[dpdk.git] / drivers / net / failsafe / failsafe_ops.c
index e0f1b0b..f460551 100644 (file)
@@ -38,6 +38,7 @@
 #include <rte_ethdev.h>
 #include <rte_malloc.h>
 #include <rte_flow.h>
+#include <rte_cycles.h>
 
 #include "failsafe_private.h"
 
@@ -582,18 +583,30 @@ fs_link_update(struct rte_eth_dev *dev,
        return -1;
 }
 
-static void
+static int
 fs_stats_get(struct rte_eth_dev *dev,
             struct rte_eth_stats *stats)
 {
        struct sub_device *sdev;
        uint8_t i;
+       int ret;
 
        rte_memcpy(stats, &PRIV(dev)->stats_accumulator, sizeof(*stats));
        FOREACH_SUBDEV_STATE(sdev, i, dev, DEV_ACTIVE) {
-               rte_eth_stats_get(PORT_ID(sdev), &sdev->stats_snapshot);
-               failsafe_stats_increment(stats, &sdev->stats_snapshot);
+               struct rte_eth_stats *snapshot = &sdev->stats_snapshot.stats;
+               uint64_t *timestamp = &sdev->stats_snapshot.timestamp;
+
+               ret = rte_eth_stats_get(PORT_ID(sdev), snapshot);
+               if (ret) {
+                       ERROR("Operation rte_eth_stats_get failed for sub_device %d with error %d",
+                                 i, ret);
+                       *timestamp = 0;
+                       return ret;
+               }
+               *timestamp = rte_rdtsc();
+               failsafe_stats_increment(stats, snapshot);
        }
+       return 0;
 }
 
 static void