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)
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);
123 #if defined(RTE_ARCH_X86_64) || defined(RTE_ARCH_I686)
124 printf("Check for SSE:\t\t");
125 CHECK_FOR_FLAG(RTE_CPUFLAG_SSE);
127 printf("Check for SSE2:\t\t");
128 CHECK_FOR_FLAG(RTE_CPUFLAG_SSE2);
130 printf("Check for SSE3:\t\t");
131 CHECK_FOR_FLAG(RTE_CPUFLAG_SSE3);
133 printf("Check for SSE4.1:\t");
134 CHECK_FOR_FLAG(RTE_CPUFLAG_SSE4_1);
136 printf("Check for SSE4.2:\t");
137 CHECK_FOR_FLAG(RTE_CPUFLAG_SSE4_2);
139 printf("Check for AVX:\t\t");
140 CHECK_FOR_FLAG(RTE_CPUFLAG_AVX);
142 printf("Check for AVX2:\t\t");
143 CHECK_FOR_FLAG(RTE_CPUFLAG_AVX2);
145 printf("Check for AVX512F:\t");
146 CHECK_FOR_FLAG(RTE_CPUFLAG_AVX512F);
148 printf("Check for TRBOBST:\t");
149 CHECK_FOR_FLAG(RTE_CPUFLAG_TRBOBST);
151 printf("Check for ENERGY_EFF:\t");
152 CHECK_FOR_FLAG(RTE_CPUFLAG_ENERGY_EFF);
154 printf("Check for LAHF_SAHF:\t");
155 CHECK_FOR_FLAG(RTE_CPUFLAG_LAHF_SAHF);
157 printf("Check for 1GB_PG:\t");
158 CHECK_FOR_FLAG(RTE_CPUFLAG_1GB_PG);
160 printf("Check for INVTSC:\t");
161 CHECK_FOR_FLAG(RTE_CPUFLAG_INVTSC);
165 * Check if invalid data is handled properly
167 printf("\nCheck for invalid flag:\t");
168 result = rte_cpu_get_flag_enabled(RTE_CPUFLAG_NUMFLAGS);
169 printf("%s\n", cpu_flag_result(result));
170 if (result != -ENOENT)
176 REGISTER_TEST_COMMAND(cpuflags_autotest, test_cpuflags);