]> git.droids-corp.org - dpdk.git/blobdiff - lib/librte_eal/arm/rte_cycles.c
eal: control max SIMD bitwidth
[dpdk.git] / lib / librte_eal / arm / rte_cycles.c
index 3500d523efde6993de12370ab06363afa0c1e148..5bd29b24b1878e67f4a875d10959ae968e2931f1 100644 (file)
@@ -3,14 +3,35 @@
  */
 
 #include "eal_private.h"
+#include "rte_cycles.h"
 
 uint64_t
 get_tsc_freq_arch(void)
 {
 #if defined RTE_ARCH_ARM64 && !defined RTE_ARM_EAL_RDTSC_USE_PMU
-       uint64_t freq;
-       asm volatile("mrs %0, cntfrq_el0" : "=r" (freq));
-       return freq;
+       return __rte_arm64_cntfrq();
+#elif defined RTE_ARCH_ARM64 && defined RTE_ARM_EAL_RDTSC_USE_PMU
+#define CYC_PER_1MHZ 1E6
+       /* Use the generic counter ticks to calculate the PMU
+        * cycle frequency.
+        */
+       uint64_t ticks;
+       uint64_t start_ticks, cur_ticks;
+       uint64_t start_pmu_cycles, end_pmu_cycles;
+
+       /* Number of ticks for 1/10 second */
+       ticks = __rte_arm64_cntfrq() / 10;
+
+       start_ticks = __rte_arm64_cntvct_precise();
+       start_pmu_cycles = rte_rdtsc_precise();
+       do {
+               cur_ticks = __rte_arm64_cntvct();
+       } while ((cur_ticks - start_ticks) < ticks);
+       end_pmu_cycles = rte_rdtsc_precise();
+
+       /* Adjust the cycles to next 1Mhz */
+       return RTE_ALIGN_MUL_CEIL(end_pmu_cycles - start_pmu_cycles,
+                       CYC_PER_1MHZ) * 10;
 #else
        return 0;
 #endif