1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2017 Intel Corporation
9 #include <rte_common.h>
11 #include "eal_private.h"
14 rte_cpu_get_model(uint32_t fam_mod_step)
16 uint32_t family, model, ext_model;
18 family = (fam_mod_step >> 8) & 0xf;
19 model = (fam_mod_step >> 4) & 0xf;
21 if (family == 6 || family == 15) {
22 ext_model = (fam_mod_step >> 16) & 0xf;
23 model += (ext_model << 4);
30 rdmsr(int msr, uint64_t *val)
32 #ifdef RTE_EXEC_ENV_LINUX
36 fd = open("/dev/cpu/0/msr", O_RDONLY);
40 ret = pread(fd, val, sizeof(uint64_t), msr);
54 check_model_wsm_nhm(uint8_t model)
73 check_model_gdm_dnv(uint8_t model)
87 get_tsc_freq_arch(void)
90 uint32_t a, b, c, d, maxleaf;
95 * Time Stamp Counter and Nominal Core Crystal Clock
98 maxleaf = __get_cpuid_max(0, NULL);
100 if (maxleaf >= 0x15) {
101 __cpuid(0x15, a, b, c, d);
103 /* EBX : TSC/Crystal ratio, ECX : Crystal Hz */
108 __cpuid(0x1, a, b, c, d);
109 model = rte_cpu_get_model(a);
111 if (check_model_wsm_nhm(model))
113 else if ((c & bit_AVX) || check_model_gdm_dnv(model))
118 ret = rdmsr(0xCE, &tsc_hz);
122 return ((tsc_hz >> 8) & 0xff) * mult * 1E6;