]> git.proxmox.com Git - mirror_ovs.git/blobdiff - lib/dpif-netdev-perf.h
tunnel: Bareudp Tunnel Support.
[mirror_ovs.git] / lib / dpif-netdev-perf.h
index b8aa4e34483ddad040c14dfba0681d372184bf28..72645b6b3c92487a1e95b214709f8e735bc59713 100644 (file)
@@ -21,6 +21,7 @@
 #include <stddef.h>
 #include <stdint.h>
 #include <string.h>
+#include <time.h>
 #include <math.h>
 
 #ifdef DPDK_NETDEV
@@ -56,6 +57,7 @@ extern "C" {
 
 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. */
@@ -185,6 +187,22 @@ struct pmd_perf_stats {
     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. */
 
@@ -197,6 +215,17 @@ cycles_counter_update(struct pmd_perf_stats *s)
 {
 #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
@@ -208,6 +237,8 @@ cycles_counter_get(struct pmd_perf_stats *s)
     return s->last_tsc;
 }
 
+void pmd_perf_estimate_tsc_frequency(void);
+
 /* A nestable timer for measuring execution time in TSC cycles.
  *
  * Usage: