20 #define foreach_x86_cpu_uarch \ 21 _(0x06, 0x9e, "Kaby Lake", "Kaby Lake DT/H/S/X") \ 22 _(0x06, 0x8e, "Kaby Lake", "Kaby Lake Y/U") \ 23 _(0x06, 0x85, "Knights Mill", "Knights Mill") \ 24 _(0x06, 0x5f, "Goldmont", "Denverton") \ 25 _(0x06, 0x5e, "Skylake", "Skylake DT/H/S") \ 26 _(0x06, 0x5c, "Goldmont", "Apollo Lake") \ 27 _(0x06, 0x5a, "Silvermont", "Moorefield") \ 28 _(0x06, 0x57, "Knights Landing", "Knights Landing") \ 29 _(0x06, 0x56, "Broadwell", "Broadwell DE") \ 30 _(0x06, 0x55, "Skylake", "Skylake X/SP") \ 31 _(0x06, 0x4f, "Broadwell", "Broadwell EP/EX") \ 32 _(0x06, 0x4e, "Skylake", "Skylake Y/U") \ 33 _(0x06, 0x4d, "Silvermont", "Rangeley") \ 34 _(0x06, 0x4c, "Airmont", "Braswell") \ 35 _(0x06, 0x47, "Broadwell", "Broadwell H") \ 36 _(0x06, 0x46, "Haswell", "Crystalwell") \ 37 _(0x06, 0x45, "Haswell", "Haswell ULT") \ 38 _(0x06, 0x3f, "Haswell", "Haswell E") \ 39 _(0x06, 0x3e, "Ivy Bridge", "Ivy Bridge E/EN/EP") \ 40 _(0x06, 0x3d, "Broadwell", "Broadwell U") \ 41 _(0x06, 0x3c, "Haswell", "Haswell") \ 42 _(0x06, 0x3a, "Ivy Bridge", "IvyBridge") \ 43 _(0x06, 0x37, "Silvermont", "BayTrail") \ 44 _(0x06, 0x36, "Saltwell", "Cedarview,Centerton") \ 45 _(0x06, 0x35, "Saltwell", "Cloverview") \ 46 _(0x06, 0x2f, "Westmere", "Westmere EX") \ 47 _(0x06, 0x2e, "Nehalem", "Nehalem EX") \ 48 _(0x06, 0x2d, "Sandy Bridge", "SandyBridge E/EN/EP") \ 49 _(0x06, 0x2c, "Westmere", "Westmere EP/EX,Gulftown") \ 50 _(0x06, 0x2a, "Sandy Bridge", "Sandy Bridge") \ 51 _(0x06, 0x27, "Saltwell", "Medfield") \ 52 _(0x06, 0x26, "Bonnell", "Tunnel Creek") \ 53 _(0x06, 0x25, "Westmere", "Arrandale,Clarksdale") \ 54 _(0x06, 0x1e, "Nehalem", "Clarksfield,Lynnfield,Jasper Forest") \ 55 _(0x06, 0x1d, "Penryn", "Dunnington") \ 56 _(0x06, 0x1c, "Bonnell", "Pineview,Silverthorne") \ 57 _(0x06, 0x1a, "Nehalem", "Nehalem EP,Bloomfield)") \ 58 _(0x06, 0x17, "Penryn", "Yorkfield,Wolfdale,Penryn,Harpertown") 61 #define foreach_aarch64_cpu_uarch \ 62 _(0x41, 0xd03, "ARM", "Cortex-A53", 0) \ 63 _(0x41, 0xd07, "ARM", "Cortex-A57", 0) \ 64 _(0x41, 0xd08, "ARM", "Cortex-A72", 0) \ 65 _(0x41, 0xd09, "ARM", "Cortex-A73", 0) \ 66 _(0x43, 0x0a1, "Marvell", "THUNDERX CN88XX", 0) \ 67 _(0x43, 0x0a2, "Marvell", "OCTEON TX CN81XX", 0) \ 68 _(0x43, 0x0a3, "Marvell", "OCTEON TX CN83XX", 0) \ 69 _(0x43, 0x0af, "Marvell", "THUNDERX2 CN99XX", 1) \ 70 _(0x43, 0x0b1, "Marvell", "OCTEON TX2 CN98XX", 1) \ 71 _(0x43, 0x0b2, "Marvell", "OCTEON TX2 CN96XX", 1) 77 u32 __attribute__ ((unused)) eax, ebx, ecx, edx;
78 u8 model, family, stepping;
80 if (__get_cpuid (1, &eax, &ebx, &ecx, &edx) == 0)
81 return format (s,
"unknown (missing cpuid)");
83 model = ((eax >> 4) & 0x0f) | ((eax >> 12) & 0xf0);
84 family = (eax >> 8) & 0x0f;
85 stepping = eax & 0x0f;
87 #define _(f,m,a,c) if ((model == m) && (family == f)) return \ 88 format(s, "[0x%x] %s ([0x%02x] %s) stepping 0x%x", f, a, m, c, stepping); 91 return format (s,
"unknown (family 0x%02x model 0x%02x)", family, model);
96 u32 implementer, primary_part_number, variant, revision;
98 fd = open (
"/proc/cpuinfo", 0);
100 return format (s,
"unknown");
105 if (
unformat (&input,
"CPU implementer%_: 0x%x", &implementer))
107 else if (
unformat (&input,
"CPU part%_: 0x%x", &primary_part_number))
109 else if (
unformat (&input,
"CPU variant%_: 0x%x", &variant))
111 else if (
unformat (&input,
"CPU revision%_: %u", &revision))
119 #define _(i,p,a,c,_format) if ((implementer == i) && (primary_part_number == p)){ \ 121 return format(s, "%s (%s PASS %c%u)", a, c, 'A'+variant, revision);\ 123 if (implementer == 0x43)\ 125 return format (s, "%s (%s PASS %u.%u)", a, c, variant, revision);}} 129 return format (s,
"unknown (implementer 0x%02x part 0x%03x PASS %u.%u)",
130 implementer, primary_part_number, variant, revision);
133 return format (s,
"unknown");
141 u32 __attribute__ ((unused)) eax, ebx, ecx, edx;
145 if (__get_cpuid (1, &eax, &ebx, &ecx, &edx) == 0)
146 return format (s,
"unknown (missing cpuid)");
148 __get_cpuid (0x80000000, &eax, &ebx, &ecx, &edx);
149 if (eax < 0x80000004)
150 return format (s,
"unknown (missing ext feature)");
153 name_u32 = (
u32 *) name;
155 __get_cpuid (0x80000002, &eax, &ebx, &ecx, &edx);
161 __get_cpuid (0x80000003, &eax, &ebx, &ecx, &edx);
167 __get_cpuid (0x80000004, &eax, &ebx, &ecx, &edx);
173 s =
format (s,
"%s", name);
177 #elif defined(__aarch64__) 178 return format (s,
"armv8");
180 return format (s,
"unknown");
185 static inline char const *
188 if (0 == strncmp (flag, pfx, len - 1))
189 return flag + len - 1;
196 #if defined(__x86_64__) 197 #define _(flag, func, reg, bit) \ 198 if (clib_cpu_supports_ ## flag()) \ 199 s = format (s, "%s ", flag_skip_prefix(#flag, "x86_", sizeof("x86_"))); 202 #elif defined(__aarch64__) 203 #define _(flag, bit) \ 204 if (clib_cpu_supports_ ## flag()) \ 205 s = format (s, "%s ", flag_skip_prefix(#flag, "aarch64_", sizeof("aarch64_"))); 209 return format (s,
"unknown");
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment) ...
u8 * format_cpu_uarch(u8 *s, va_list *args)
#define foreach_aarch64_flags
#define foreach_aarch64_cpu_uarch
u8 * format_cpu_model_name(u8 *s, va_list *args)
static char const * flag_skip_prefix(char const *flag, const char *pfx, int len)
#define vec_free(V)
Free vector's memory (no header).
u8 * format_cpu_flags(u8 *s, va_list *args)
#define foreach_x86_64_flags
#define foreach_x86_cpu_uarch