#include <rte_flow.h>
#include <rte_flow_driver.h>
+#include <rte_cycles.h>
#include "failsafe_private.h"
/* 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));
+ if (err) {
+ uint64_t timestamp = sdev->stats_snapshot.timestamp;
+
+ WARN("Could not access latest statistics from sub-device %d.\n",
+ SUB_ID(sdev));
+ if (timestamp != 0)
+ WARN("Using latest snapshot taken before %"PRIu64" seconds.\n",
+ (rte_rdtsc() - timestamp) / rte_get_tsc_hz());
+ }
failsafe_stats_increment(&PRIV(sdev->fs_dev)->stats_accumulator,
- err ? &sdev->stats_snapshot : &stats);
- memset(&sdev->stats_snapshot, 0, sizeof(struct rte_eth_stats));
+ err ? &sdev->stats_snapshot.stats : &stats);
+ memset(&sdev->stats_snapshot, 0, sizeof(sdev->stats_snapshot));
}
static inline int
#include <rte_ethdev.h>
#include <rte_malloc.h>
#include <rte_flow.h>
+#include <rte_cycles.h>
#include "failsafe_private.h"
rte_memcpy(stats, &PRIV(dev)->stats_accumulator, sizeof(*stats));
FOREACH_SUBDEV_STATE(sdev, i, dev, DEV_ACTIVE) {
- ret = rte_eth_stats_get(PORT_ID(sdev), &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;
}
- failsafe_stats_increment(stats, &sdev->stats_snapshot);
+ *timestamp = rte_rdtsc();
+ failsafe_stats_increment(stats, snapshot);
}
return 0;
}
DEV_STARTED,
};
+struct fs_stats {
+ struct rte_eth_stats stats;
+ uint64_t timestamp;
+};
+
struct sub_device {
/* Exhaustive DPDK device description */
struct rte_devargs devargs;
/* Device state machine */
enum dev_state state;
/* Last stats snapshot passed to user */
- struct rte_eth_stats stats_snapshot;
+ struct fs_stats stats_snapshot;
/* Some device are defined as a command line */
char *cmdline;
/* fail-safe device backreference */