avoid using thread local storage for thread index
[vpp.git] / src / vnet / bonding / node.c
index df2da5c..7abd7b0 100644 (file)
@@ -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
@@ -67,7 +67,7 @@ typedef enum
 {
   BOND_INPUT_NEXT_DROP,
   BOND_INPUT_N_NEXT,
-} l2output_next_t;
+} bond_output_next_t;
 
 static_always_inline u8
 packet_is_cdp (ethernet_header_t * eth)
@@ -138,7 +138,7 @@ bond_update_next (vlib_main_t * vm, vlib_node_runtime_t * node,
                  u32 * bond_sw_if_index, vlib_buffer_t * b,
                  u32 * next_index, vlib_error_t * error)
 {
-  u16 thread_index = vlib_get_thread_index ();
+  u16 thread_index = vm->thread_index;
   slave_if_t *sif;
   bond_if_t *bif;
 
@@ -172,12 +172,11 @@ 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 ();
+  u16 thread_index = vm->thread_index;
   u32 *from, n_left;
   vlib_buffer_t *bufs[VLIB_FRAME_SIZE], **b;
   u32 sw_if_indices[VLIB_FRAME_SIZE], *sw_if_index;
@@ -330,17 +329,12 @@ CLIB_MULTIARCH_FN (bond_input_fn) (vlib_main_t * vm,
       n_left = frame->n_vectors;       /* number of packets to process */
       b = bufs;
       sw_if_index = sw_if_indices;
-      next = nexts;
       bond_packet_trace_t *t0;
-      uword n_trace = vlib_get_trace_count (vm, node);
 
-      while (n_left && n_trace)
+      while (n_left)
        {
          if (PREDICT_FALSE (b[0]->flags & VLIB_BUFFER_IS_TRACED))
            {
-             vlib_trace_buffer (vm, node, next[0], b[0],
-                                0 /* follow_chain */ );
-             vlib_set_trace_count (vm, node, --n_trace);
              t0 = vlib_add_trace (vm, node, b[0], sizeof (*t0));
              t0->sw_if_index = sw_if_index[0];
              clib_memcpy (&t0->ethernet, vlib_buffer_get_current (b[0]),
@@ -351,7 +345,6 @@ CLIB_MULTIARCH_FN (bond_input_fn) (vlib_main_t * vm,
          n_left--;
          b++;
          sw_if_index++;
-         next++;
        }
     }
 
@@ -367,7 +360,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 +369,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 +383,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) =