[PATCH 4/5] eal/armv8: define architecture specific rdtsc hz
From: Jerin Jacob <hidden>
Date: 2017-08-13 07:04:47
Subsystem:
library code, the rest · Maintainers:
Andrew Morton, Linus Torvalds
Use cntvct_el0 system register to get the system counter frequency. If the system is configured with RTE_ARM_EAL_RDTSC_USE_PMU then return 0(let the common code calibrate the tsc frequency). CC: Jianbo Liu <redacted> Signed-off-by: Jerin Jacob <redacted> --- .../common/include/arch/arm/rte_cycles_64.h | 30 ++++++++++++++++++++++ 1 file changed, 30 insertions(+)
diff --git a/lib/librte_eal/common/include/arch/arm/rte_cycles_64.h b/lib/librte_eal/common/include/arch/arm/rte_cycles_64.h
index 154576910..5b95cb67d 100644
--- a/lib/librte_eal/common/include/arch/arm/rte_cycles_64.h
+++ b/lib/librte_eal/common/include/arch/arm/rte_cycles_64.h@@ -58,6 +58,23 @@ rte_rdtsc(void) asm volatile("mrs %0, cntvct_el0" : "=r" (tsc)); return tsc; } + +/** + * Get the number of rdtsc cycles in one second if the architecture supports. + * + * @return + * The number of rdtsc cycles in one second. Return zero if the architecture + * support is not available. + */ +static inline uint64_t +rte_rdtsc_arch_hz(void) +{ + uint64_t freq; + + asm volatile("mrs %0, cntfrq_el0" : "=r" (freq)); + return freq; +} + #else /** * This is an alternative method to enable rte_rdtsc() with high resolution
@@ -85,6 +102,19 @@ rte_rdtsc(void) asm volatile("mrs %0, pmccntr_el0" : "=r"(tsc)); return tsc; } + +/** + * Get the number of rdtsc cycles in one second if the architecture supports. + * + * @return + * The number of rdtsc cycles in one second. Return zero if the architecture + * support is not available. + */ +static inline uint64_t +rte_rdtsc_arch_hz(void) +{ + return 0; +} #endif static inline uint64_t
--
2.14.0