#include <stddef.h>
#include <stdint.h>
#include <string.h>
+#include <time.h>
#include <math.h>
#ifdef DPDK_NETDEV
enum pmd_stat_type {
PMD_STAT_EXACT_HIT, /* Packets that had an exact match (emc). */
+ PMD_STAT_SMC_HIT, /* Packets that had a sig match hit (SMC). */
PMD_STAT_MASKED_HIT, /* Packets that matched in the flow table. */
PMD_STAT_MISS, /* Packets that did not match and upcall was ok. */
PMD_STAT_LOST, /* Packets that did not match and upcall failed. */
char *log_reason;
};
+#ifdef __linux__
+static inline uint64_t
+rdtsc_syscall(struct pmd_perf_stats *s)
+{
+ struct timespec val;
+ uint64_t v;
+
+ if (clock_gettime(CLOCK_MONOTONIC_RAW, &val) != 0) {
+ return s->last_tsc;
+ }
+
+ v = val.tv_sec * UINT64_C(1000000000) + val.tv_nsec;
+ return s->last_tsc = v;
+}
+#endif
+
/* Support for accurate timing of PMD execution on TSC clock cycle level.
* These functions are intended to be invoked in the context of pmd threads. */
{
#ifdef DPDK_NETDEV
return s->last_tsc = rte_get_tsc_cycles();
+#elif !defined(_MSC_VER) && defined(__x86_64__)
+ uint32_t h, l;
+ asm volatile("rdtsc" : "=a" (l), "=d" (h));
+
+ return s->last_tsc = ((uint64_t) h << 32) | l;
+#elif !defined(_MSC_VER) && defined(__aarch64__)
+ asm volatile("mrs %0, cntvct_el0" : "=r" (s->last_tsc));
+
+ return s->last_tsc;
+#elif defined(__linux__)
+ return rdtsc_syscall(s);
#else
return s->last_tsc = 0;
#endif
return s->last_tsc;
}
+void pmd_perf_estimate_tsc_frequency(void);
+
/* A nestable timer for measuring execution time in TSC cycles.
*
* Usage: