aboutsummaryrefslogtreecommitdiff
path: root/platform/linux-dpdk/include/odp
diff options
context:
space:
mode:
authorMatias Elo <matias.elo@nokia.com>2018-07-10 16:55:49 +0300
committerMatias Elo <matias.elo@nokia.com>2018-07-13 09:33:08 +0300
commit8617ec5d3d7294849fd3565f81b61b371b666dda (patch)
tree428a4e4101ddb30f8585a014e35aeb89a8ba22c2 /platform/linux-dpdk/include/odp
parentbe6f67ec3a769346cf2168c957942ce110e96a32 (diff)
Port c6cc6d3a "linux-gen: time: inline arch cpu time on x86"
Signed-off-by: Matias Elo <matias.elo@nokia.com>
Diffstat (limited to 'platform/linux-dpdk/include/odp')
-rw-r--r--platform/linux-dpdk/include/odp/api/plat/time_inlines.h84
1 files changed, 84 insertions, 0 deletions
diff --git a/platform/linux-dpdk/include/odp/api/plat/time_inlines.h b/platform/linux-dpdk/include/odp/api/plat/time_inlines.h
new file mode 100644
index 000000000..6c14d6c40
--- /dev/null
+++ b/platform/linux-dpdk/include/odp/api/plat/time_inlines.h
@@ -0,0 +1,84 @@
+/* Copyright (c) 2018, Linaro Limited
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#ifndef ODP_PLAT_TIME_INLINES_H_
+#define ODP_PLAT_TIME_INLINES_H_
+
+#include <stdint.h>
+
+#include <odp/api/align.h>
+
+#include <odp/api/abi/cpu_time.h>
+
+/** @cond _ODP_HIDE_FROM_DOXYGEN_ */
+
+#define _ODP_TIMESPEC_SIZE 16
+
+typedef odp_time_t (*time_cur_fn)(void);
+typedef uint64_t (*time_res_fn)(void);
+
+typedef struct time_handler_ {
+ time_cur_fn time_cur;
+ time_res_fn time_res;
+
+} time_handler_t;
+
+typedef struct _odp_time_global_t {
+ /* Storage space for struct timespec. Posix headers are not included
+ * here to avoid application exposure. */
+ uint8_t ODP_ALIGNED(_ODP_TIMESPEC_SIZE) timespec[_ODP_TIMESPEC_SIZE];
+
+ int use_hw;
+ uint64_t hw_start;
+ uint64_t hw_freq_hz;
+ /* DPDK specific */
+ time_handler_t handler;
+
+} _odp_time_global_t;
+
+extern _odp_time_global_t _odp_time_glob;
+
+odp_time_t _odp_timespec_cur(void);
+
+static inline odp_time_t _odp_time_cur_gen(void)
+{
+ if (_odp_time_glob.use_hw) {
+ odp_time_t time;
+
+ time.count = _odp_cpu_global_time() - _odp_time_glob.hw_start;
+ return time;
+ }
+
+ return _odp_timespec_cur();
+}
+
+static inline odp_time_t _odp_time_cur(void)
+{
+ return _odp_time_glob.handler.time_cur();
+}
+
+#ifndef _ODP_NO_INLINE
+ /* Inline functions by default */
+ #define _ODP_INLINE static inline
+ #define odp_time_local __odp_time_local
+ #define odp_time_global __odp_time_global
+#else
+ #define _ODP_INLINE
+#endif
+
+_ODP_INLINE odp_time_t odp_time_local(void)
+{
+ return _odp_time_cur();
+}
+
+_ODP_INLINE odp_time_t odp_time_global(void)
+{
+ return _odp_time_cur();
+}
+
+/** @endcond */
+
+#endif