aboutsummaryrefslogtreecommitdiffstats
path: root/src/vppinfra/cpu.c
diff options
context:
space:
mode:
authorGabriel Ganne <gabriel.ganne@enea.com>2017-12-05 14:26:33 +0100
committerDamjan Marion <dmarion.lists@gmail.com>2017-12-05 18:19:43 +0000
commit73cb0062e30ec09aa38bc98d91cbdfc86a8fb6c0 (patch)
treeeae2d395ed3a37db5183046b9647a432f257ae77 /src/vppinfra/cpu.c
parent2aef64f04ed9a43cd0a2a9a1616069a24c14eef8 (diff)
fill "show cpu" Flag list on aarch64 platforms (VPP-1065)
use getauxval(AT_HWCAP) to get the processor capabilities. The result should be the same as calling cat /proc/cpuinfo | grep Feature | head -n1 All but one (aes) features have a different name. handle aes by adding it an arch prefix, which is skipped during print and a clib_cpu_supports_aes() custom function. Change-Id: If9830bd5a17bac1bd1b5337dacbb0ddbb8ed6b18 Signed-off-by: Gabriel Ganne <gabriel.ganne@enea.com>
Diffstat (limited to 'src/vppinfra/cpu.c')
-rw-r--r--src/vppinfra/cpu.c21
1 files changed, 19 insertions, 2 deletions
diff --git a/src/vppinfra/cpu.c b/src/vppinfra/cpu.c
index b13527a40b5..6bd19c8e7f3 100644
--- a/src/vppinfra/cpu.c
+++ b/src/vppinfra/cpu.c
@@ -126,16 +126,33 @@ format_cpu_model_name (u8 * s, va_list * args)
#endif
}
+
+static inline char const *
+flag_skip_prefix (char const *flag)
+{
+ if (memcmp (flag, "x86_", sizeof ("x86_") - 1) == 0)
+ return flag + sizeof ("x86_") - 1;
+ if (memcmp (flag, "aarch64_", sizeof ("aarch64_") - 1) == 0)
+ return flag + sizeof ("aarch64_") - 1;
+ return flag;
+}
+
u8 *
format_cpu_flags (u8 * s, va_list * args)
{
#if defined(__x86_64__)
#define _(flag, func, reg, bit) \
if (clib_cpu_supports_ ## flag()) \
- s = format (s, #flag " ");
+ s = format (s, "%s ", flag_skip_prefix(#flag));
foreach_x86_64_flags return s;
#undef _
-#else /* ! __x86_64__ */
+#elif defined(__aarch64__)
+#define _(flag, bit) \
+ if (clib_cpu_supports_ ## flag()) \
+ s = format (s, "%s ", flag_skip_prefix(#flag));
+ foreach_aarch64_flags return s;
+#undef _
+#else /* ! ! __x86_64__ && ! __aarch64__ */
return format (s, "unknown");
#endif
}