ipsec: IPSec protection for multi-point tunnel interfaces
[vpp.git] / src / vnet / l2 / l2_input_classify.c
index 497df19..ffd1078 100644 (file)
@@ -67,10 +67,12 @@ format_l2_input_classify_trace (u8 * s, va_list * args)
   return s;
 }
 
+extern l2_input_classify_main_t l2_input_classify_main;
+
+#ifndef CLIB_MARCH_VARIANT
 /** l2 input classifier main data structure. */
 l2_input_classify_main_t l2_input_classify_main;
-
-vlib_node_registration_t l2_input_classify_node;
+#endif /* CLIB_MARCH_VARIANT */
 
 #define foreach_l2_input_classify_error               \
 _(MISS, "Classify misses")                      \
@@ -142,9 +144,9 @@ static char *l2_input_classify_error_strings[] = {
  *   Classifier hits in other than the first table
  */
 
-static uword
-l2_input_classify_node_fn (vlib_main_t * vm,
-                          vlib_node_runtime_t * node, vlib_frame_t * frame)
+VLIB_NODE_FN (l2_input_classify_node) (vlib_main_t * vm,
+                                      vlib_node_runtime_t * node,
+                                      vlib_frame_t * frame)
 {
   u32 n_left_from, *from, *to_next;
   l2_input_classify_next_t next_index;
@@ -152,7 +154,6 @@ l2_input_classify_node_fn (vlib_main_t * vm,
   vnet_classify_main_t *vcm = cm->vnet_classify_main;
   l2_input_classify_runtime_t *rt =
     (l2_input_classify_runtime_t *) node->runtime_data;
-  u32 feature_bitmap;
   u32 hits = 0;
   u32 misses = 0;
   u32 chain_hits = 0;
@@ -168,7 +169,7 @@ l2_input_classify_node_fn (vlib_main_t * vm,
 
   /* First pass: compute hash */
 
-  while (n_left_from > 2)
+  while (n_left_from >= 4)
     {
       vlib_buffer_t *b0, *b1;
       u32 bi0, bi1;
@@ -183,15 +184,15 @@ l2_input_classify_node_fn (vlib_main_t * vm,
 
       /* prefetch next iteration */
       {
-       vlib_buffer_t *p1, *p2;
+       vlib_buffer_t *p2, *p3;
 
-       p1 = vlib_get_buffer (vm, from[1]);
        p2 = vlib_get_buffer (vm, from[2]);
+       p3 = vlib_get_buffer (vm, from[3]);
 
-       vlib_prefetch_buffer_header (p1, STORE);
-       CLIB_PREFETCH (p1->data, CLIB_CACHE_LINE_BYTES, STORE);
        vlib_prefetch_buffer_header (p2, STORE);
        CLIB_PREFETCH (p2->data, CLIB_CACHE_LINE_BYTES, STORE);
+       vlib_prefetch_buffer_header (p3, STORE);
+       CLIB_PREFETCH (p3->data, CLIB_CACHE_LINE_BYTES, STORE);
       }
 
       bi0 = from[0];
@@ -354,13 +355,6 @@ l2_input_classify_node_fn (vlib_main_t * vm,
          e0 = 0;
          vnet_buffer (b0)->l2_classify.opaque_index = ~0;
 
-         /* Remove ourself from the feature bitmap */
-         feature_bitmap = vnet_buffer (b0)->l2.feature_bitmap
-           & ~L2INPUT_FEAT_INPUT_CLASSIFY;
-
-         /* save for next feature graph nodes */
-         vnet_buffer (b0)->l2.feature_bitmap = feature_bitmap;
-
          if (PREDICT_TRUE (table_index0 != ~0))
            {
              hash0 = vnet_buffer (b0)->l2_classify.hash;
@@ -412,13 +406,13 @@ l2_input_classify_node_fn (vlib_main_t * vm,
          if (PREDICT_FALSE (next0 == 0))
            b0->error = node->errors[L2_INPUT_CLASSIFY_ERROR_DROP];
 
+         /* Determine the next node and remove ourself from bitmap */
          if (PREDICT_TRUE (next0 == ~0))
-           {
-             // Determine the next node
-             next0 =
-               feat_bitmap_get_next_node_index (cm->feat_next_node_index,
-                                                feature_bitmap);
-           }
+           next0 = vnet_l2_feature_next (b0, cm->l2_inp_feat_next,
+                                         L2INPUT_FEAT_INPUT_CLASSIFY);
+         else
+           vnet_buffer (b0)->l2.feature_bitmap &=
+             ~L2INPUT_FEAT_INPUT_CLASSIFY;
 
          if (PREDICT_FALSE ((node->flags & VLIB_NODE_FLAG_TRACE)
                             && (b0->flags & VLIB_BUFFER_IS_TRACED)))
@@ -451,7 +445,6 @@ l2_input_classify_node_fn (vlib_main_t * vm,
 
 /* *INDENT-OFF* */
 VLIB_REGISTER_NODE (l2_input_classify_node) = {
-  .function = l2_input_classify_node_fn,
   .name = "l2-input-classify",
   .vector_size = sizeof (u32),
   .format_trace = format_l2_input_classify_trace,
@@ -475,9 +468,7 @@ VLIB_REGISTER_NODE (l2_input_classify_node) = {
 };
 /* *INDENT-ON* */
 
-VLIB_NODE_FUNCTION_MULTIARCH (l2_input_classify_node,
-                             l2_input_classify_node_fn);
-
+#ifndef CLIB_MARCH_VARIANT
 /** l2 input classsifier feature initialization. */
 clib_error_t *
 l2_input_classify_init (vlib_main_t * vm)
@@ -496,7 +487,7 @@ l2_input_classify_init (vlib_main_t * vm)
                               l2_input_classify_node.index,
                               L2INPUT_N_FEAT,
                               l2input_get_feat_names (),
-                              cm->feat_next_node_index);
+                              cm->l2_inp_feat_next);
   rt->l2cm = cm;
   rt->vcm = cm->vnet_classify_main;
 
@@ -505,6 +496,21 @@ l2_input_classify_init (vlib_main_t * vm)
 
 VLIB_INIT_FUNCTION (l2_input_classify_init);
 
+clib_error_t *
+l2_input_classify_worker_init (vlib_main_t * vm)
+{
+  l2_input_classify_main_t *cm = &l2_input_classify_main;
+  l2_input_classify_runtime_t *rt;
+
+  rt = vlib_node_get_runtime_data (vm, l2_input_classify_node.index);
+
+  rt->l2cm = cm;
+  rt->vcm = cm->vnet_classify_main;
+
+  return 0;
+}
+
+VLIB_WORKER_INIT_FUNCTION (l2_input_classify_worker_init);
 
 /** Enable/disable l2 input classification on a specific interface. */
 void
@@ -570,6 +576,7 @@ vnet_l2_input_classify_set_tables (u32 sw_if_index,
 
   return 0;
 }
+#endif /* CLIB_MARCH_VARIANT */
 
 static clib_error_t *
 int_l2_input_classify_command_fn (vlib_main_t * vm,