summaryrefslogtreecommitdiffstats
path: root/src/vlib/time.h
diff options
context:
space:
mode:
authorBenoît Ganne <bganne@cisco.com>2021-08-20 09:18:31 +0200
committerDamjan Marion <dmarion@me.com>2021-11-22 16:44:26 +0000
commit56eccdbaa982a6aff16fbc2a651fd024ecc589a8 (patch)
tree9ad2dfae55bf356d6c03b328744d690c64f8e0ef /src/vlib/time.h
parentf33979ba88111be3b7935ea90172422e4d4a114b (diff)
vlib: add virtual time support
Type: feature Change-Id: Iabd76558e9c72ed8286cfeeb1fbaa4fde4832a90 Signed-off-by: Benoît Ganne <bganne@cisco.com>
Diffstat (limited to 'src/vlib/time.h')
-rw-r--r--src/vlib/time.h26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/vlib/time.h b/src/vlib/time.h
new file mode 100644
index 00000000000..61873bb2ef3
--- /dev/null
+++ b/src/vlib/time.h
@@ -0,0 +1,26 @@
+/*
+ * SPDX-License-Identifier: Apache-2.0
+ * Copyright(c) 2021 Cisco Systems, Inc.
+ */
+
+#ifndef included_vlib_time_h
+#define included_vlib_time_h
+
+#include <vlib/vlib.h>
+#include <vppinfra/tw_timer_1t_3w_1024sl_ov.h>
+
+static inline f64
+vlib_time_get_next_timer (vlib_main_t *vm)
+{
+ vlib_node_main_t *nm = &vm->node_main;
+ TWT (tw_timer_wheel) *wheel = nm->timing_wheel;
+ return TW (tw_timer_first_expires_in_ticks) (wheel) * wheel->timer_interval;
+}
+
+static inline void
+vlib_time_adjust (vlib_main_t *vm, f64 offset)
+{
+ vm->time_offset += offset;
+}
+
+#endif /* included_vlib_time_h */