From 7c3a6d8c43114db75cb2807190ab367a2b3d51cc Mon Sep 17 00:00:00 2001 From: Ben Walker Date: Wed, 10 Aug 2016 13:12:33 -0700 Subject: [PATCH] env: Move tsc functions to env. Change-Id: Ieb1caabd76b1af9fdc7a95698ae09c86dce134bd Signed-off-by: Ben Walker --- include/spdk/env.h | 15 +++++++++++++++ lib/env/env.c | 16 ++++++++++++++++ lib/ioat/ioat_impl.h | 9 +-------- lib/nvme/nvme_impl.h | 8 ++------ 4 files changed, 34 insertions(+), 14 deletions(-) diff --git a/include/spdk/env.h b/include/spdk/env.h index f71c79eb0..729dbed77 100644 --- a/include/spdk/env.h +++ b/include/spdk/env.h @@ -61,6 +61,21 @@ spdk_zmalloc(size_t size, size_t align, uint64_t *phys_addr); void spdk_free(void *buf); +/** + * Get a monotonic timestamp counter. + */ +uint64_t spdk_get_ticks(void); + +/** + * Get the tick rate of spdk_get_ticks() per second. + */ +uint64_t spdk_get_ticks_hz(void); + +/** + * Delay the given number of microseconds + */ +void spdk_delay_us(unsigned int us); + #define SPDK_VTOPHYS_ERROR (0xFFFFFFFFFFFFFFFFULL) uint64_t spdk_vtophys(void *buf); diff --git a/lib/env/env.c b/lib/env/env.c index 834f7da69..aaef1ca75 100644 --- a/lib/env/env.c +++ b/lib/env/env.c @@ -36,6 +36,7 @@ #include #include +#include #include void * @@ -54,3 +55,18 @@ spdk_free(void *buf) { return rte_free(buf); } + +uint64_t spdk_get_ticks(void) +{ + return rte_get_timer_cycles(); +} + +uint64_t spdk_get_ticks_hz(void) +{ + return rte_get_timer_hz(); +} + +void spdk_delay_us(unsigned int us) +{ + return rte_delay_us(us); +} diff --git a/lib/ioat/ioat_impl.h b/lib/ioat/ioat_impl.h index 88e089e0d..dfceb2a9b 100644 --- a/lib/ioat/ioat_impl.h +++ b/lib/ioat/ioat_impl.h @@ -4,17 +4,10 @@ #include #include #include -#include -#include -#include -#include -#include #include "spdk/assert.h" #include "spdk/env.h" -#include - /** * \file * @@ -44,6 +37,6 @@ /** * Delay us. */ -#define ioat_delay_us(us) rte_delay_us(us) +#define ioat_delay_us spdk_delay_us #endif /* __IOAT_IMPL_H__ */ diff --git a/lib/nvme/nvme_impl.h b/lib/nvme/nvme_impl.h index ccc7a7b95..cba62c6e2 100644 --- a/lib/nvme/nvme_impl.h +++ b/lib/nvme/nvme_impl.h @@ -54,15 +54,11 @@ #include #include #include -#include -#include #include #include #include #include -#include - #include "spdk/pci_ids.h" /** @@ -193,11 +189,11 @@ nvme_mempool_put(nvme_mempool_t *mp, void *buf) /** * Get a monotonic timestamp counter (used for measuring timeouts during initialization). */ -#define nvme_get_tsc() rte_get_timer_cycles() +#define nvme_get_tsc() spdk_get_ticks() /** * Get the tick rate of nvme_get_tsc() per second. */ -#define nvme_get_tsc_hz() rte_get_timer_hz() +#define nvme_get_tsc_hz() spdk_get_ticks_hz() #endif /* __NVME_IMPL_H__ */