aboutsummaryrefslogtreecommitdiffstats
path: root/src/vnet
diff options
context:
space:
mode:
authorDamjan Marion <damarion@cisco.com>2018-05-28 21:26:47 +0200
committerFlorin Coras <florin.coras@gmail.com>2018-05-29 17:00:26 +0000
commit812b32dd8f637118bf65de2cdff0e95b421a963b (patch)
tree184d57889b841958875d57c6503d8bfb96cdaec7 /src/vnet
parent04e0bb2ff0f39dab45da01ecdbc7914035a36897 (diff)
Add VLIB_NODE_FN() macro to simplify multiversioning of node functions
Change-Id: Ibab5e27277f618ceb2d543b9d6a1a5f191e7d1db Signed-off-by: Damjan Marion <damarion@cisco.com>
Diffstat (limited to 'src/vnet')
-rw-r--r--src/vnet/bonding/node.c26
-rw-r--r--src/vnet/ip/ip4_input.c34
-rw-r--r--src/vnet/l2/l2_output.c28
3 files changed, 16 insertions, 72 deletions
diff --git a/src/vnet/bonding/node.c b/src/vnet/bonding/node.c
index df2da5c66fc..7d2acf7d0f7 100644
--- a/src/vnet/bonding/node.c
+++ b/src/vnet/bonding/node.c
@@ -36,7 +36,7 @@ typedef enum
BOND_INPUT_N_ERROR,
} bond_input_error_t;
-#ifndef CLIB_MULTIARCH_VARIANT
+#ifndef CLIB_MARCH_VARIANT
static char *bond_input_error_strings[] = {
#define _(n,s) s,
foreach_bond_input_error
@@ -172,10 +172,9 @@ bond_update_next (vlib_main_t * vm, vlib_node_runtime_t * node,
vnet_feature_next ( /* not used */ 0, next_index, b);
}
-uword CLIB_CPU_OPTIMIZED
-CLIB_MULTIARCH_FN (bond_input_fn) (vlib_main_t * vm,
- vlib_node_runtime_t * node,
- vlib_frame_t * frame)
+VLIB_NODE_FN (bond_input_node) (vlib_main_t * vm,
+ vlib_node_runtime_t * node,
+ vlib_frame_t * frame)
{
u16 thread_index = vlib_get_thread_index ();
u32 *from, n_left;
@@ -367,7 +366,7 @@ CLIB_MULTIARCH_FN (bond_input_fn) (vlib_main_t * vm,
return frame->n_vectors;
}
-#ifndef CLIB_MULTIARCH_VARIANT
+#ifndef CLIB_MARCH_VARIANT
static clib_error_t *
bond_input_init (vlib_main_t * vm)
{
@@ -376,7 +375,6 @@ bond_input_init (vlib_main_t * vm)
/* *INDENT-OFF* */
VLIB_REGISTER_NODE (bond_input_node) = {
- .function = bond_input_fn,
.name = "bond-input",
.vector_size = sizeof (u32),
.format_buffer = format_ethernet_header_with_length,
@@ -391,20 +389,6 @@ VLIB_REGISTER_NODE (bond_input_node) = {
}
};
-#if __x86_64__
-vlib_node_function_t __clib_weak bond_input_fn_avx512;
-vlib_node_function_t __clib_weak bond_input_fn_avx2;
-static void __clib_constructor
-bond_input_multiarch_select (void)
-{
- if (bond_input_fn_avx512 && clib_cpu_supports_avx512f ())
- bond_input_node.function = bond_input_fn_avx512;
- else if (bond_input_fn_avx2 && clib_cpu_supports_avx2 ())
- bond_input_node.function = bond_input_fn_avx2;
-}
-#endif
-
-
VLIB_INIT_FUNCTION (bond_input_init);
VNET_FEATURE_INIT (bond_input, static) =
diff --git a/src/vnet/ip/ip4_input.c b/src/vnet/ip/ip4_input.c
index 7af2bee187a..b476f95ab8b 100644
--- a/src/vnet/ip/ip4_input.c
+++ b/src/vnet/ip/ip4_input.c
@@ -47,7 +47,7 @@ typedef struct
u8 packet_data[64];
} ip4_input_trace_t;
-#ifndef CLIB_MULTIARCH_VARIANT
+#ifndef CLIB_MARCH_VARIANT
static u8 *
format_ip4_input_trace (u8 * s, va_list * va)
{
@@ -292,22 +292,20 @@ ip4_input_inline (vlib_main_t * vm,
<code> vnet_get_config_data (... &next0 ...); </code>
or @c error-drop
*/
-uword CLIB_CPU_OPTIMIZED
-CLIB_MULTIARCH_FN (ip4_input) (vlib_main_t * vm, vlib_node_runtime_t * node,
+VLIB_NODE_FN (ip4_input_node) (vlib_main_t * vm, vlib_node_runtime_t * node,
vlib_frame_t * frame)
{
return ip4_input_inline (vm, node, frame, /* verify_checksum */ 1);
}
-uword CLIB_CPU_OPTIMIZED
-CLIB_MULTIARCH_FN (ip4_input_no_checksum) (vlib_main_t * vm,
+VLIB_NODE_FN (ip4_input_no_checksum_node) (vlib_main_t * vm,
vlib_node_runtime_t * node,
vlib_frame_t * frame)
{
return ip4_input_inline (vm, node, frame, /* verify_checksum */ 0);
}
-#ifndef CLIB_MULTIARCH_VARIANT
+#ifndef CLIB_MARCH_VARIANT
char *ip4_error_strings[] = {
#define _(sym,string) string,
foreach_ip4_error
@@ -316,7 +314,6 @@ char *ip4_error_strings[] = {
/* *INDENT-OFF* */
VLIB_REGISTER_NODE (ip4_input_node) = {
- .function = ip4_input,
.name = "ip4-input",
.vector_size = sizeof (u32),
@@ -337,8 +334,7 @@ VLIB_REGISTER_NODE (ip4_input_node) = {
.format_trace = format_ip4_input_trace,
};
-VLIB_REGISTER_NODE (ip4_input_no_checksum_node,static) = {
- .function = ip4_input_no_checksum,
+VLIB_REGISTER_NODE (ip4_input_no_checksum_node) = {
.name = "ip4-input-no-checksum",
.vector_size = sizeof (u32),
@@ -357,26 +353,6 @@ VLIB_REGISTER_NODE (ip4_input_no_checksum_node,static) = {
};
/* *INDENT-ON* */
-#if __x86_64__
-vlib_node_function_t __clib_weak ip4_input_avx512;
-vlib_node_function_t __clib_weak ip4_input_avx2;
-vlib_node_function_t __clib_weak ip4_input_no_checksum_avx512;
-vlib_node_function_t __clib_weak ip4_input_no_checksum_avx2;
-static void __clib_constructor
-ip4_input_multiarch_select (void)
-{
- if (ip4_input_no_checksum_avx512 && clib_cpu_supports_avx512f ())
- ip4_input_no_checksum_node.function = ip4_input_no_checksum_avx512;
- else if (ip4_input_no_checksum_avx2 && clib_cpu_supports_avx2 ())
- ip4_input_no_checksum_node.function = ip4_input_no_checksum_avx2;
-
- if (ip4_input_avx512 && clib_cpu_supports_avx512f ())
- ip4_input_node.function = ip4_input_avx512;
- else if (ip4_input_avx2 && clib_cpu_supports_avx2 ())
- ip4_input_node.function = ip4_input_avx2;
-}
-#endif
-
static clib_error_t *
ip4_init (vlib_main_t * vm)
{
diff --git a/src/vnet/l2/l2_output.c b/src/vnet/l2/l2_output.c
index 306049bd0db..1fa042ffd54 100644
--- a/src/vnet/l2/l2_output.c
+++ b/src/vnet/l2/l2_output.c
@@ -27,7 +27,7 @@
#include <vnet/l2/l2_output.h>
-#ifndef CLIB_MULTIARCH_VARIANT
+#ifndef CLIB_MARCH_VARIANT
/* Feature graph node names */
static char *l2output_feat_names[] = {
#define _(sym,name) name,
@@ -76,7 +76,7 @@ typedef struct
u8 raw[12]; /* raw data */
} l2output_trace_t;
-#ifndef CLIB_MULTIARCH_VARIANT
+#ifndef CLIB_MARCH_VARIANT
/* packet trace format function */
static u8 *
format_l2output_trace (u8 * s, va_list * args)
@@ -275,10 +275,9 @@ l2output_process_batch (vlib_main_t * vm, vlib_node_runtime_t * node,
l2_efp, l2_vtr, l2_pbb, 1, 1);
}
-uword CLIB_CPU_OPTIMIZED
-CLIB_MULTIARCH_FN (l2output_node_fn) (vlib_main_t * vm,
- vlib_node_runtime_t * node,
- vlib_frame_t * frame)
+VLIB_NODE_FN (l2output_node) (vlib_main_t * vm,
+ vlib_node_runtime_t * node,
+ vlib_frame_t * frame)
{
u32 n_left, *from;
l2output_main_t *msm = &l2output_main;
@@ -431,10 +430,9 @@ CLIB_MULTIARCH_FN (l2output_node_fn) (vlib_main_t * vm,
return frame->n_vectors;
}
-#ifndef CLIB_MULTIARCH_VARIANT
+#ifndef CLIB_MARCH_VARIANT
/* *INDENT-OFF* */
VLIB_REGISTER_NODE (l2output_node) = {
- .function = l2output_node_fn,
.name = "l2-output",
.vector_size = sizeof (u32),
.format_trace = format_l2output_trace,
@@ -451,20 +449,6 @@ VLIB_REGISTER_NODE (l2output_node) = {
[L2OUTPUT_NEXT_BAD_INTF] = "l2-output-bad-intf",
},
};
-
-#if __x86_64__
-vlib_node_function_t __clib_weak l2output_node_fn_avx512;
-vlib_node_function_t __clib_weak l2output_node_fn_avx2;
-static void __clib_constructor
-l2output_multiarch_select (void)
-{
- if (l2output_node_fn_avx512 && clib_cpu_supports_avx512f ())
- l2output_node.function = l2output_node_fn_avx512;
- else if (l2output_node_fn_avx2 && clib_cpu_supports_avx2 ())
- l2output_node.function = l2output_node_fn_avx2;
-}
-#endif
-
/* *INDENT-ON* */