From a62b194f1b08bb207020a931d2f0f7e56616d14f Mon Sep 17 00:00:00 2001 From: Daniel Verkamp Date: Mon, 22 Feb 2016 16:01:36 -0700 Subject: [PATCH] nvme: add timestamp counter interface to nvme_impl Change-Id: Ic652163e4f5944c1516eaf58615f7eabcbe34a7a Signed-off-by: Daniel Verkamp --- lib/nvme/nvme_impl.h | 11 +++++++++++ test/lib/nvme/unit/nvme_impl.h | 4 ++++ 2 files changed, 15 insertions(+) diff --git a/lib/nvme/nvme_impl.h b/lib/nvme/nvme_impl.h index 1b682b3677..fc9d2b3b0c 100644 --- a/lib/nvme/nvme_impl.h +++ b/lib/nvme/nvme_impl.h @@ -39,6 +39,7 @@ #include "spdk/nvme_spec.h" #include #include +#include #include #include #include @@ -125,6 +126,16 @@ extern struct rte_mempool *request_mempool; */ #define nvme_dealloc_request(buf) rte_mempool_put(request_mempool, buf) +/** + * Get a monotonic timestamp counter (used for measuring timeouts during initialization). + */ +#define nvme_get_tsc() rte_get_timer_cycles() + +/** + * Get the tick rate of nvme_get_tsc() per second. + */ +#define nvme_get_tsc_hz() rte_get_timer_hz() + /** * */ diff --git a/test/lib/nvme/unit/nvme_impl.h b/test/lib/nvme/unit/nvme_impl.h index 02bbad12f2..bc45ca48d2 100644 --- a/test/lib/nvme/unit/nvme_impl.h +++ b/test/lib/nvme/unit/nvme_impl.h @@ -78,6 +78,10 @@ do \ #define nvme_dealloc_request(buf) free(buf) +extern uint64_t g_ut_tsc; +#define nvme_get_tsc() (g_ut_tsc) +#define nvme_get_tsc_hz() (1000000) + static inline int nvme_pci_enumerate(int (*enum_cb)(void *enum_ctx, struct spdk_pci_device *pci_dev), void *enum_ctx) {