From: Jerin Jacob <jerin.ja...@caviumnetworks.com> In ppc_64, rte_rdtsc() returns timebase register value which increments at independent timebase frequency and hence not related to lcore cpu frequency to derive TSC hz. Hence, we stick with master lcore frequency.
CC: Chao Zhu <chao...@linux.vnet.ibm.com> Signed-off-by: Jerin Jacob <jerin.ja...@caviumnetworks.com> Signed-off-by: Gowrishankar Muthukrishnan <gowrishanka...@linux.vnet.ibm.com> --- v2: * add ppc_64 specific implementation .../common/include/arch/ppc_64/rte_cycles.h | 24 ++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/lib/librte_eal/common/include/arch/ppc_64/rte_cycles.h b/lib/librte_eal/common/include/arch/ppc_64/rte_cycles.h index 8fa6fc6..1b36587 100644 --- a/lib/librte_eal/common/include/arch/ppc_64/rte_cycles.h +++ b/lib/librte_eal/common/include/arch/ppc_64/rte_cycles.h @@ -38,9 +38,13 @@ #endif #include "generic/rte_cycles.h" +#include "../../lib/librte_eal/common/eal_filesystem.h" #include <rte_byteorder.h> #include <rte_common.h> +#include <rte_lcore.h> + +static const char sys_cpu_dir[] = "/sys/devices/system/cpu"; /** * Read the time base register. @@ -79,6 +83,26 @@ return tsc.tsc_64; } +/** + * Get the number of rdtsc cycles in one second. + * + * @return + * The number of rdtsc cycles in one second. + */ +static inline uint64_t +rte_rdtsc_arch_hz(void) +{ + unsigned long cpu_hz; + char path[PATH_MAX]; + + snprintf(path, sizeof(path), "%s/cpu%d/cpufreq/cpuinfo_cur_freq", + sys_cpu_dir, rte_get_master_lcore()); + if (eal_parse_sysfs_value(path, &cpu_hz) < 0) + RTE_LOG(WARNING, EAL, "Unable to parse %s\n", path); + + return cpu_hz*1000; +} + static inline uint64_t rte_rdtsc_precise(void) { -- 1.9.1