Add support for multiple microarchitectures in single binary
[vpp.git] / vnet / vnet / l2 / l2_output.c
index 72c3d03..f5b2211 100644 (file)
@@ -102,6 +102,8 @@ split_horizon_violation (u8 shg1, u8 shg2)
 }
 
 
+static vlib_node_registration_t l2output_node;
+
 static uword
 l2output_node_fn (vlib_main_t * vm,
                  vlib_node_runtime_t * node,
@@ -190,16 +192,16 @@ l2output_node_fn (vlib_main_t * vm,
                     l2output_trace_t *t = 
                       vlib_add_trace (vm, node, b0, sizeof (*t));
                     t->sw_if_index = sw_if_index0;
-                    memcpy(t->src, h0->src_address, 6);
-                    memcpy(t->dst, h0->dst_address, 6);
+                    clib_memcpy(t->src, h0->src_address, 6);
+                    clib_memcpy(t->dst, h0->dst_address, 6);
                   }
                 if (b1->flags & VLIB_BUFFER_IS_TRACED) 
                   {
                     l2output_trace_t *t = 
                       vlib_add_trace (vm, node, b1, sizeof (*t));
                     t->sw_if_index = sw_if_index1;
-                    memcpy(t->src, h1->src_address, 6);
-                    memcpy(t->dst, h1->dst_address, 6);
+                    clib_memcpy(t->src, h1->src_address, 6);
+                    clib_memcpy(t->dst, h1->dst_address, 6);
                   }
               }
 
@@ -327,8 +329,8 @@ l2output_node_fn (vlib_main_t * vm,
                vlib_add_trace (vm, node, b0, sizeof (*t));
             t->sw_if_index = sw_if_index0;
             h0 = vlib_buffer_get_current (b0);
-            memcpy(t->src, h0->src_address, 6);
-            memcpy(t->dst, h0->dst_address, 6);
+            clib_memcpy(t->src, h0->src_address, 6);
+            clib_memcpy(t->dst, h0->dst_address, 6);
             }
 
           em->counters[node_counter_base_index + L2OUTPUT_ERROR_L2OUTPUT] += 1;
@@ -394,7 +396,7 @@ l2output_node_fn (vlib_main_t * vm,
 }
 
 
-VLIB_REGISTER_NODE (l2output_node) = {
+VLIB_REGISTER_NODE (l2output_node,static) = {
   .function = l2output_node_fn,
   .name = "l2-output",
   .vector_size = sizeof (u32),
@@ -412,6 +414,8 @@ VLIB_REGISTER_NODE (l2output_node) = {
   },
 };
 
+VLIB_NODE_FUNCTION_MULTIARCH (l2output_node, l2output_node_fn)
+
 clib_error_t *l2output_init (vlib_main_t *vm)
 {
   l2output_main_t * mp = &l2output_main;
@@ -452,6 +456,7 @@ static void output_node_mapping_send_rpc
  u32 sw_if_index)
 {
   output_node_mapping_rpc_args_t args;
+  void vl_api_rpc_call_main_thread (void *fp, u8 * data, u32 data_length);
 
   args.node_index = node_index;
   args.sw_if_index = sw_if_index;
@@ -473,6 +478,9 @@ u32 l2output_create_output_node_mapping (
   u32                  next;  // index of next graph node
   vnet_hw_interface_t *hw0;
   u32                 *node;
+
+  hw0 = vnet_get_sup_hw_interface (vnet_main, sw_if_index);
+
 #if DPDK > 0
   uword                       cpu_number;
 
@@ -480,13 +488,19 @@ u32 l2output_create_output_node_mapping (
 
   if (cpu_number)
     {
+      u32 oldflags;
+
+      oldflags = __sync_fetch_and_or(&hw0->flags,
+                                     VNET_HW_INTERFACE_FLAG_L2OUTPUT_MAPPED);
+
+      if ((oldflags & VNET_HW_INTERFACE_FLAG_L2OUTPUT_MAPPED) )
+        return L2OUTPUT_NEXT_DROP;
+
       output_node_mapping_send_rpc (node_index, sw_if_index);
-      return 0;
+        return L2OUTPUT_NEXT_DROP;
     }
 #endif
 
-  hw0 = vnet_get_sup_hw_interface (vnet_main, sw_if_index);
-
   // dynamically create graph node arc 
   next = vlib_node_add_next (vlib_main,
                              node_index,