1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2017 Intel Corporation
10 #include "eal_private.h"
13 rte_cpu_get_model(uint32_t fam_mod_step)
15 uint32_t family, model, ext_model;
17 family = (fam_mod_step >> 8) & 0xf;
18 model = (fam_mod_step >> 4) & 0xf;
20 if (family == 6 || family == 15) {
21 ext_model = (fam_mod_step >> 16) & 0xf;
22 model += (ext_model << 4);
29 rdmsr(int msr, uint64_t *val)
31 #ifdef RTE_EXEC_ENV_LINUX
35 fd = open("/dev/cpu/0/msr", O_RDONLY);
39 ret = pread(fd, val, sizeof(uint64_t), msr);
53 check_model_wsm_nhm(uint8_t model)
72 check_model_gdm_dnv(uint8_t model)
86 get_tsc_freq_arch(void)
89 uint32_t a, b, c, d, maxleaf;
94 * Time Stamp Counter and Nominal Core Crystal Clock
97 maxleaf = __get_cpuid_max(0, NULL);
99 if (maxleaf >= 0x15) {
100 __cpuid(0x15, a, b, c, d);
102 /* EBX : TSC/Crystal ratio, ECX : Crystal Hz */
107 __cpuid(0x1, a, b, c, d);
108 model = rte_cpu_get_model(a);
110 if (check_model_wsm_nhm(model))
112 else if ((c & bit_AVX) || check_model_gdm_dnv(model))
117 ret = rdmsr(0xCE, &tsc_hz);
121 return ((tsc_hz >> 8) & 0xff) * mult * 1E6;