1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2010-2014 Intel Corporation
9 #include <rte_cpuflags.h>
10 #include <rte_debug.h>
15 /* convenience define */
16 #define CHECK_FOR_FLAG(x) \
17 result = rte_cpu_get_flag_enabled(x); \
18 printf("%s\n", cpu_flag_result(result)); \
19 if (result == -ENOENT) \
23 * Helper function to display result
25 static inline const char *
26 cpu_flag_result(int result)
44 * - Check flags from different registers with rte_cpu_get_flag_enabled()
45 * - Check if register and CPUID functions fail properly
52 printf("\nChecking for flags from different registers...\n");
54 #ifdef RTE_ARCH_PPC_64
55 printf("Check for PPC64:\t\t");
56 CHECK_FOR_FLAG(RTE_CPUFLAG_PPC64);
58 printf("Check for PPC32:\t\t");
59 CHECK_FOR_FLAG(RTE_CPUFLAG_PPC32);
61 printf("Check for VSX:\t\t");
62 CHECK_FOR_FLAG(RTE_CPUFLAG_VSX);
64 printf("Check for DFP:\t\t");
65 CHECK_FOR_FLAG(RTE_CPUFLAG_DFP);
67 printf("Check for FPU:\t\t");
68 CHECK_FOR_FLAG(RTE_CPUFLAG_FPU);
70 printf("Check for SMT:\t\t");
71 CHECK_FOR_FLAG(RTE_CPUFLAG_SMT);
73 printf("Check for MMU:\t\t");
74 CHECK_FOR_FLAG(RTE_CPUFLAG_MMU);
76 printf("Check for ALTIVEC:\t\t");
77 CHECK_FOR_FLAG(RTE_CPUFLAG_ALTIVEC);
79 printf("Check for ARCH_2_06:\t\t");
80 CHECK_FOR_FLAG(RTE_CPUFLAG_ARCH_2_06);
82 printf("Check for ARCH_2_07:\t\t");
83 CHECK_FOR_FLAG(RTE_CPUFLAG_ARCH_2_07);
85 printf("Check for ICACHE_SNOOP:\t\t");
86 CHECK_FOR_FLAG(RTE_CPUFLAG_ICACHE_SNOOP);
89 #if defined(RTE_ARCH_ARM) && defined(RTE_ARCH_32)
90 printf("Check for NEON:\t\t");
91 CHECK_FOR_FLAG(RTE_CPUFLAG_NEON);
94 #if defined(RTE_ARCH_ARM64)
95 printf("Check for FP:\t\t");
96 CHECK_FOR_FLAG(RTE_CPUFLAG_FP);
98 printf("Check for ASIMD:\t");
99 CHECK_FOR_FLAG(RTE_CPUFLAG_NEON);
101 printf("Check for EVTSTRM:\t");
102 CHECK_FOR_FLAG(RTE_CPUFLAG_EVTSTRM);
104 printf("Check for AES:\t\t");
105 CHECK_FOR_FLAG(RTE_CPUFLAG_AES);
107 printf("Check for PMULL:\t");
108 CHECK_FOR_FLAG(RTE_CPUFLAG_PMULL);
110 printf("Check for SHA1:\t\t");
111 CHECK_FOR_FLAG(RTE_CPUFLAG_SHA1);
113 printf("Check for SHA2:\t\t");
114 CHECK_FOR_FLAG(RTE_CPUFLAG_SHA2);
116 printf("Check for CRC32:\t");
117 CHECK_FOR_FLAG(RTE_CPUFLAG_CRC32);
119 printf("Check for ATOMICS:\t");
120 CHECK_FOR_FLAG(RTE_CPUFLAG_ATOMICS);
122 printf("Check for SVE:\t\t");
123 CHECK_FOR_FLAG(RTE_CPUFLAG_SVE);
125 printf("Check for SVE2:\t\t");
126 CHECK_FOR_FLAG(RTE_CPUFLAG_SVE2);
128 printf("Check for SVEAES:\t");
129 CHECK_FOR_FLAG(RTE_CPUFLAG_SVEAES);
131 printf("Check for SVEPMULL:\t");
132 CHECK_FOR_FLAG(RTE_CPUFLAG_SVEPMULL);
134 printf("Check for SVEBITPERM:\t");
135 CHECK_FOR_FLAG(RTE_CPUFLAG_SVEBITPERM);
137 printf("Check for SVESHA3:\t");
138 CHECK_FOR_FLAG(RTE_CPUFLAG_SVESHA3);
140 printf("Check for SVESM4:\t");
141 CHECK_FOR_FLAG(RTE_CPUFLAG_SVESM4);
143 printf("Check for FLAGM2:\t");
144 CHECK_FOR_FLAG(RTE_CPUFLAG_FLAGM2);
146 printf("Check for FRINT:\t");
147 CHECK_FOR_FLAG(RTE_CPUFLAG_FRINT);
149 printf("Check for SVEI8MM:\t");
150 CHECK_FOR_FLAG(RTE_CPUFLAG_SVEI8MM);
152 printf("Check for SVEF32MM:\t");
153 CHECK_FOR_FLAG(RTE_CPUFLAG_SVEF32MM);
155 printf("Check for SVEF64MM:\t");
156 CHECK_FOR_FLAG(RTE_CPUFLAG_SVEF64MM);
158 printf("Check for SVEBF16:\t");
159 CHECK_FOR_FLAG(RTE_CPUFLAG_SVEBF16);
162 #if defined(RTE_ARCH_X86_64) || defined(RTE_ARCH_I686)
163 printf("Check for SSE:\t\t");
164 CHECK_FOR_FLAG(RTE_CPUFLAG_SSE);
166 printf("Check for SSE2:\t\t");
167 CHECK_FOR_FLAG(RTE_CPUFLAG_SSE2);
169 printf("Check for SSE3:\t\t");
170 CHECK_FOR_FLAG(RTE_CPUFLAG_SSE3);
172 printf("Check for SSE4.1:\t");
173 CHECK_FOR_FLAG(RTE_CPUFLAG_SSE4_1);
175 printf("Check for SSE4.2:\t");
176 CHECK_FOR_FLAG(RTE_CPUFLAG_SSE4_2);
178 printf("Check for AVX:\t\t");
179 CHECK_FOR_FLAG(RTE_CPUFLAG_AVX);
181 printf("Check for AVX2:\t\t");
182 CHECK_FOR_FLAG(RTE_CPUFLAG_AVX2);
184 printf("Check for AVX512F:\t");
185 CHECK_FOR_FLAG(RTE_CPUFLAG_AVX512F);
187 printf("Check for TRBOBST:\t");
188 CHECK_FOR_FLAG(RTE_CPUFLAG_TRBOBST);
190 printf("Check for ENERGY_EFF:\t");
191 CHECK_FOR_FLAG(RTE_CPUFLAG_ENERGY_EFF);
193 printf("Check for LAHF_SAHF:\t");
194 CHECK_FOR_FLAG(RTE_CPUFLAG_LAHF_SAHF);
196 printf("Check for 1GB_PG:\t");
197 CHECK_FOR_FLAG(RTE_CPUFLAG_1GB_PG);
199 printf("Check for INVTSC:\t");
200 CHECK_FOR_FLAG(RTE_CPUFLAG_INVTSC);
204 * Check if invalid data is handled properly
206 printf("\nCheck for invalid flag:\t");
207 result = rte_cpu_get_flag_enabled(RTE_CPUFLAG_NUMFLAGS);
208 printf("%s\n", cpu_flag_result(result));
209 if (result != -ENOENT)
215 REGISTER_TEST_COMMAND(cpuflags_autotest, test_cpuflags);