[dpdk-dev] [PATCH v2 4/5] eal/armv8: define architecture specific rdtsc hz

Gowrishankar gowrishankar.m at linux.vnet.ibm.com
Fri Sep 22 10:25:36 CEST 2017


From: Jerin Jacob <jerin.jacob at caviumnetworks.com>

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 <jianbo.liu at linaro.org>
Signed-off-by: Jerin Jacob <jerin.jacob at caviumnetworks.com>
Acked-by: Jianbo Liu <jianbo.liu at linaro.org>
---
 .../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 1545769..5b95cb6 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 @@
 	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 @@
 	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
-- 
1.9.1



More information about the dev mailing list