summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/plugins/memif.am31
-rw-r--r--src/plugins/memif/device.c42
-rw-r--r--src/plugins/memif/node.c28
3 files changed, 82 insertions, 19 deletions
diff --git a/src/plugins/memif.am b/src/plugins/memif.am
index 15147e77621..6e9aa779155 100644
--- a/src/plugins/memif.am
+++ b/src/plugins/memif.am
@@ -14,6 +14,7 @@
vppplugins_LTLIBRARIES += memif_plugin.la
vppapitestplugins_LTLIBRARIES += memif_test_plugin.la
+memif_plugin_la_LIBADD =
memif_plugin_la_SOURCES = memif/memif.c \
memif/memif_api.c \
memif/cli.c \
@@ -34,4 +35,34 @@ nobase_apiinclude_HEADERS += \
API_FILES += memif/memif.api
+if CPU_X86_64
+memif_multiversioning_files = \
+ memif/node.c \
+ memif/device.c
+
+if CC_SUPPORTS_AVX2
+###############################################################
+# AVX2
+###############################################################
+libmemif_plugin_avx2_la_SOURCES = $(memif_multiversioning_files)
+libmemif_plugin_avx2_la_CFLAGS = \
+ $(AM_CFLAGS) @CPU_AVX2_FLAGS@ \
+ -DCLIB_MULTIARCH_VARIANT=avx2
+noinst_LTLIBRARIES += libmemif_plugin_avx2.la
+memif_plugin_la_LIBADD += libmemif_plugin_avx2.la
+endif
+
+if CC_SUPPORTS_AVX512
+###############################################################
+# AVX512
+###############################################################
+libmemif_plugin_avx512_la_SOURCES = $(memif_multiversioning_files)
+libmemif_plugin_avx512_la_CFLAGS = \
+ $(AM_CFLAGS) @CPU_AVX512_FLAGS@ \
+ -DCLIB_MULTIARCH_VARIANT=avx512
+noinst_LTLIBRARIES += libmemif_plugin_avx512.la
+memif_plugin_la_LIBADD += libmemif_plugin_avx512.la
+endif
+endif
+
# vi:syntax=automake
diff --git a/src/plugins/memif/device.c b/src/plugins/memif/device.c
index 012c75327f1..fa3a4eda40d 100644
--- a/src/plugins/memif/device.c
+++ b/src/plugins/memif/device.c
@@ -42,12 +42,13 @@ typedef enum
MEMIF_TX_N_ERROR,
} memif_tx_func_error_t;
-static char *memif_tx_func_error_strings[] = {
+static __clib_unused char *memif_tx_func_error_strings[] = {
#define _(n,s) s,
foreach_memif_tx_func_error
#undef _
};
+#ifndef CLIB_MULTIARCH_VARIANT
u8 *
format_memif_device_name (u8 * s, va_list * args)
{
@@ -58,8 +59,9 @@ format_memif_device_name (u8 * s, va_list * args)
s = format (s, "memif%lu/%lu", mif->socket_file_index, mif->id);
return s;
}
+#endif
-static u8 *
+static __clib_unused u8 *
format_memif_device (u8 * s, va_list * args)
{
u32 dev_instance = va_arg (*args, u32);
@@ -75,7 +77,7 @@ format_memif_device (u8 * s, va_list * args)
return s;
}
-static u8 *
+static __clib_unused u8 *
format_memif_tx_trace (u8 * s, va_list * args)
{
s = format (s, "Unimplemented...");
@@ -256,9 +258,10 @@ error:
return frame->n_vectors;
}
-static uword
-memif_interface_tx (vlib_main_t * vm,
- vlib_node_runtime_t * node, vlib_frame_t * frame)
+uword
+CLIB_MULTIARCH_FN (memif_interface_tx) (vlib_main_t * vm,
+ vlib_node_runtime_t * node,
+ vlib_frame_t * frame)
{
memif_main_t *nm = &memif_main;
vnet_interface_output_runtime_t *rund = (void *) node->runtime_data;
@@ -270,7 +273,7 @@ memif_interface_tx (vlib_main_t * vm,
return memif_interface_tx_inline (vm, node, frame, mif, MEMIF_RING_M2S);
}
-static void
+static __clib_unused void
memif_set_interface_next_node (vnet_main_t * vnm, u32 hw_if_index,
u32 node_index)
{
@@ -289,13 +292,13 @@ memif_set_interface_next_node (vnet_main_t * vnm, u32 hw_if_index,
vlib_node_add_next (vlib_get_main (), memif_input_node.index, node_index);
}
-static void
+static __clib_unused void
memif_clear_hw_interface_counters (u32 instance)
{
/* Nothing for now */
}
-static clib_error_t *
+static __clib_unused clib_error_t *
memif_interface_rx_mode_change (vnet_main_t * vnm, u32 hw_if_index, u32 qid,
vnet_hw_interface_rx_mode mode)
{
@@ -312,7 +315,7 @@ memif_interface_rx_mode_change (vnet_main_t * vnm, u32 hw_if_index, u32 qid,
return 0;
}
-static clib_error_t *
+static __clib_unused clib_error_t *
memif_interface_admin_up_down (vnet_main_t * vnm, u32 hw_if_index, u32 flags)
{
memif_main_t *mm = &memif_main;
@@ -328,7 +331,7 @@ memif_interface_admin_up_down (vnet_main_t * vnm, u32 hw_if_index, u32 flags)
return error;
}
-static clib_error_t *
+static __clib_unused clib_error_t *
memif_subif_add_del_function (vnet_main_t * vnm,
u32 hw_if_index,
struct vnet_sw_interface_t *st, int is_add)
@@ -337,6 +340,7 @@ memif_subif_add_del_function (vnet_main_t * vnm,
return 0;
}
+#ifndef CLIB_MULTIARCH_VARIANT
/* *INDENT-OFF* */
VNET_DEVICE_CLASS (memif_device_class) = {
.name = "memif",
@@ -353,8 +357,20 @@ VNET_DEVICE_CLASS (memif_device_class) = {
.rx_mode_change_function = memif_interface_rx_mode_change,
};
-VLIB_DEVICE_TX_FUNCTION_MULTIARCH(memif_device_class,
- memif_interface_tx)
+#if __x86_64__
+vlib_node_function_t __clib_weak memif_interface_tx_avx512;
+vlib_node_function_t __clib_weak memif_interface_tx_avx2;
+static void __clib_constructor
+dpdk_interface_tx_multiarch_select (void)
+{
+ if (memif_interface_tx_avx512 && clib_cpu_supports_avx512f ())
+ memif_device_class.tx_function = memif_interface_tx_avx512;
+ else if (memif_interface_tx_avx2 && clib_cpu_supports_avx2 ())
+ memif_device_class.tx_function = memif_interface_tx_avx2;
+}
+#endif
+#endif
+
/* *INDENT-ON* */
/*
diff --git a/src/plugins/memif/node.c b/src/plugins/memif/node.c
index 74b238931ac..1c34922d331 100644
--- a/src/plugins/memif/node.c
+++ b/src/plugins/memif/node.c
@@ -41,7 +41,7 @@ typedef enum
MEMIF_INPUT_N_ERROR,
} memif_input_error_t;
-static char *memif_input_error_strings[] = {
+static __clib_unused char *memif_input_error_strings[] = {
#define _(n,s) s,
foreach_memif_input_error
#undef _
@@ -54,7 +54,7 @@ typedef struct
u16 ring;
} memif_input_trace_t;
-static u8 *
+static __clib_unused u8 *
format_memif_input_trace (u8 * s, va_list * args)
{
CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *);
@@ -447,9 +447,10 @@ memif_device_input_inline (vlib_main_t * vm, vlib_node_runtime_t * node,
return n_rx_packets;
}
-static uword
-memif_input_fn (vlib_main_t * vm, vlib_node_runtime_t * node,
- vlib_frame_t * frame)
+uword
+CLIB_MULTIARCH_FN (memif_input_fn) (vlib_main_t * vm,
+ vlib_node_runtime_t * node,
+ vlib_frame_t * frame)
{
u32 n_rx = 0;
memif_main_t *nm = &memif_main;
@@ -491,6 +492,7 @@ memif_input_fn (vlib_main_t * vm, vlib_node_runtime_t * node,
return n_rx;
}
+#ifndef CLIB_MULTIARCH_VARIANT
/* *INDENT-OFF* */
VLIB_REGISTER_NODE (memif_input_node) = {
.function = memif_input_fn,
@@ -503,7 +505,21 @@ VLIB_REGISTER_NODE (memif_input_node) = {
.error_strings = memif_input_error_strings,
};
-VLIB_NODE_FUNCTION_MULTIARCH (memif_input_node, memif_input_fn)
+vlib_node_function_t __clib_weak memif_input_avx512;
+vlib_node_function_t __clib_weak memif_input_avx2;
+
+#if __x86_64__
+static void __clib_constructor
+memif_input_multiarch_select (void)
+{
+ if (memif_input_avx512 && clib_cpu_supports_avx512f ())
+ memif_input_node.function = memif_input_avx512;
+ else if (memif_input_avx2 && clib_cpu_supports_avx2 ())
+ memif_input_node.function = memif_input_avx2;
+}
+#endif
+#endif
+
/* *INDENT-ON* */