srv6-ad-flow: SRv6 Per-Flow Dynamic Proxy
[vpp.git] / src / vppinfra / cpu.h
index bef2a02..bc4ee58 100644 (file)
 #include <sys/syscall.h>
 #include <vppinfra/format.h>
 
-/*
- * multiarchitecture support. Adding new entry will produce
- * new graph node function variant optimized for specific cpu
- * microarchitecture.
- * Order is important for runtime selection, as 1st match wins...
- */
-
-#if __x86_64__ && CLIB_DEBUG == 0
-#define foreach_march_variant(macro, x) \
-  macro(avx2,  x, "arch=core-avx2")
+#if defined(__x86_64__)
+#define foreach_march_variant                                                 \
+  _ (hsw, "Intel Haswell")                                                    \
+  _ (trm, "Intel Tremont")                                                    \
+  _ (skx, "Intel Skylake (server) / Cascade Lake")                            \
+  _ (icl, "Intel Ice Lake")
+#elif defined(__aarch64__)
+#define foreach_march_variant                                                 \
+  _ (octeontx2, "Marvell Octeon TX2")                                         \
+  _ (thunderx2t99, "Marvell ThunderX2 T99")                                   \
+  _ (qdf24xx, "Qualcomm CentriqTM 2400")                                      \
+  _ (cortexa72, "ARM Cortex-A72")                                             \
+  _ (neoversen1, "ARM Neoverse N1")
 #else
-#define foreach_march_variant(macro, x)
+#define foreach_march_variant
 #endif
 
+typedef enum
+{
+  CLIB_MARCH_VARIANT_TYPE = 0,
+#define _(s, n) CLIB_MARCH_VARIANT_TYPE_##s,
+  foreach_march_variant
+#undef _
+    CLIB_MARCH_TYPE_N_VARIANTS
+} clib_march_variant_type_t;
 
 #if __GNUC__ > 4  && !__clang__ && CLIB_DEBUG == 0
 #define CLIB_CPU_OPTIMIZED __attribute__ ((optimize ("O3")))
 #define CLIB_CPU_OPTIMIZED
 #endif
 
-
-#define CLIB_MULTIARCH_ARCH_CHECK(arch, fn, tgt)                       \
-  if (clib_cpu_supports_ ## arch())                                    \
-    return & fn ## _ ##arch;
-
-/* FIXME to be removed */
-#define CLIB_MULTIARCH_SELECT_FN(fn,...)
-
 #ifdef CLIB_MARCH_VARIANT
 #define __CLIB_MULTIARCH_FN(a,b) a##_##b
 #define _CLIB_MULTIARCH_FN(a,b) __CLIB_MULTIARCH_FN(a,b)
@@ -84,29 +87,9 @@ clib_march_select_fn_ptr (clib_march_fn_registration * r)
   return rv;
 }
 
-static_always_inline void *
-clib_march_select_fn_ptr_by_name (clib_march_fn_registration * r, char *name)
-{
-  void *rv = 0;
-
-  while (r)
-    {
-      if (strncmp (name, r->name, vec_len (r->name) - 1) == 0)
-       {
-         rv = r->function;
-         break;
-       }
-      r = r->next;
-    }
-  return rv;
-}
-
 #define CLIB_MARCH_FN_POINTER(fn) \
   clib_march_select_fn_ptr (fn##_march_fn_registrations);
 
-#define CLIB_MARCH_FN_POINTER_BY_NAME(fn, name) \
-  clib_march_select_fn_ptr_by_name (fn##_march_fn_registrations, name);
-
 #define _CLIB_MARCH_FN_REGISTRATION(fn) \
 static clib_march_fn_registration \
 CLIB_MARCH_SFX(fn##_march_fn_registration) = \