[dpdk-dev,v2,2/5] eal/ppc64: define architecture specific rdtsc hz
Checks
Commit Message
From: Jerin Jacob <jerin.jacob@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 <chaozhu@linux.vnet.ibm.com>
Signed-off-by: Jerin Jacob <jerin.jacob@caviumnetworks.com>
Signed-off-by: Gowrishankar Muthukrishnan <gowrishankar.m@linux.vnet.ibm.com>
---
v2:
* add ppc_64 specific implementation
.../common/include/arch/ppc_64/rte_cycles.h | 24 ++++++++++++++++++++++
1 file changed, 24 insertions(+)
Comments
22/09/2017 10:25, Gowrishankar:
> From: Jerin Jacob <jerin.jacob@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 <chaozhu@linux.vnet.ibm.com>
> Signed-off-by: Jerin Jacob <jerin.jacob@caviumnetworks.com>
> Signed-off-by: Gowrishankar Muthukrishnan <gowrishankar.m@linux.vnet.ibm.com>
[...]
> --- 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"
rte_cycles.h is an installed header.
eal_filesystem.h is not exported.
It cannot work.
@@ -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)
{