tcp: avoid fr segments less than mss if possible
[vpp.git] / src / vnet / mpls / mpls_input.c
index 893c451..0505d9a 100644 (file)
@@ -19,6 +19,7 @@
 #include <vnet/pg/pg.h>
 #include <vnet/mpls/mpls.h>
 #include <vnet/feature/feature.h>
+#include <vnet/mpls/mpls.api_enum.h>
 
 typedef struct {
   u32 next_index;
@@ -50,17 +51,16 @@ format_mpls_input_trace (u8 * s, va_list * args)
 #define _(a,b) if (t->next_index == MPLS_INPUT_NEXT_##a) next_name = b;
   foreach_mpls_input_next;
 #undef _
-  
-  s = format (s, "MPLS: next %s[%d]  label %d ttl %d", 
+
+  s = format (s, "MPLS: next %s[%d]  label %d ttl %d exp %d",
               next_name, t->next_index,
              vnet_mpls_uc_get_label(label),
-             vnet_mpls_uc_get_ttl(label));
+             vnet_mpls_uc_get_ttl(label),
+             vnet_mpls_uc_get_exp(label));
 
   return s;
 }
 
-vlib_node_registration_t mpls_input_node;
-
 typedef struct {
   u32 last_label;
   u32 last_inner_fib_index;
@@ -74,21 +74,13 @@ mpls_input_inline (vlib_main_t * vm,
                    vlib_frame_t * from_frame)
 {
   u32 n_left_from, next_index, * from, * to_next;
-  mpls_input_runtime_t * rt;
-  mpls_main_t * mm;
-  u32 cpu_index = os_get_cpu_number();
+  mpls_main_t * mm = &mpls_main;
+  u32 thread_index = vlib_get_thread_index();
   vlib_simple_counter_main_t * cm;
   vnet_main_t * vnm = vnet_get_main();
 
   from = vlib_frame_vector_args (from_frame);
   n_left_from = from_frame->n_vectors;
-  rt = vlib_node_get_runtime_data (vm, mpls_input_node.index);
-  mm = rt->mpls_main;
-  /* 
-   * Force an initial lookup every time, in case the control-plane
-   * changed the label->FIB mapping.
-   */
-  rt->last_label = ~0;
 
   next_index = node->cached_next_index;
 
@@ -116,11 +108,11 @@ mpls_input_inline (vlib_main_t * vm,
               p2 = vlib_get_buffer (vm, from[2]);
               p3 = vlib_get_buffer (vm, from[3]);
 
-              vlib_prefetch_buffer_header (p2, STORE);
-              vlib_prefetch_buffer_header (p3, STORE);
+              vlib_prefetch_buffer_header (p2, LOAD);
+              vlib_prefetch_buffer_header (p3, LOAD);
 
-              CLIB_PREFETCH (p2->data, sizeof (h0[0]), STORE);
-              CLIB_PREFETCH (p3->data, sizeof (h1[0]), STORE);
+              CLIB_PREFETCH (p2->data, sizeof (h0[0]), LOAD);
+              CLIB_PREFETCH (p3->data, sizeof (h1[0]), LOAD);
           }
 
           bi0 = to_next[0] = from[0];
@@ -151,7 +143,7 @@ mpls_input_inline (vlib_main_t * vm,
               next0 = MPLS_INPUT_NEXT_LOOKUP;
               vnet_feature_arc_start(mm->input_feature_arc_index,
                                      sw_if_index0, &next0, b0);
-              vlib_increment_simple_counter (cm, cpu_index, sw_if_index0, 1);
+              vlib_increment_simple_counter (cm, thread_index, sw_if_index0, 1);
           }
 
           if (PREDICT_FALSE(h1[3] == 0))
@@ -164,7 +156,7 @@ mpls_input_inline (vlib_main_t * vm,
               next1 = MPLS_INPUT_NEXT_LOOKUP;
               vnet_feature_arc_start(mm->input_feature_arc_index,
                                      sw_if_index1, &next1, b1);
-              vlib_increment_simple_counter (cm, cpu_index, sw_if_index1, 1);
+              vlib_increment_simple_counter (cm, thread_index, sw_if_index1, 1);
           }
 
           if (PREDICT_FALSE(b0->flags & VLIB_BUFFER_IS_TRACED))
@@ -215,12 +207,12 @@ mpls_input_inline (vlib_main_t * vm,
             {
               next0 = MPLS_INPUT_NEXT_LOOKUP;
              vnet_feature_arc_start(mm->input_feature_arc_index, sw_if_index0, &next0, b0);
-              vlib_increment_simple_counter (cm, cpu_index, sw_if_index0, 1);
+              vlib_increment_simple_counter (cm, thread_index, sw_if_index0, 1);
             }
 
-          if (PREDICT_FALSE(b0->flags & VLIB_BUFFER_IS_TRACED)) 
+          if (PREDICT_FALSE(b0->flags & VLIB_BUFFER_IS_TRACED))
             {
-              mpls_input_trace_t *tr = vlib_add_trace (vm, node, 
+              mpls_input_trace_t *tr = vlib_add_trace (vm, node,
                                                       b0, sizeof (*tr));
               tr->next_index = next0;
               tr->label_net_byte_order = *(u32*)h0;
@@ -238,22 +230,14 @@ mpls_input_inline (vlib_main_t * vm,
   return from_frame->n_vectors;
 }
 
-static uword
-mpls_input (vlib_main_t * vm,
+VLIB_NODE_FN (mpls_input_node) (vlib_main_t * vm,
             vlib_node_runtime_t * node,
             vlib_frame_t * from_frame)
 {
   return mpls_input_inline (vm, node, from_frame);
 }
 
-static char * mpls_error_strings[] = {
-#define mpls_error(n,s) s,
-#include "error.def"
-#undef mpls_error
-};
-
 VLIB_REGISTER_NODE (mpls_input_node) = {
-  .function = mpls_input,
   .name = "mpls-input",
   /* Takes a vector of packets. */
   .vector_size = sizeof (u32),
@@ -261,7 +245,7 @@ VLIB_REGISTER_NODE (mpls_input_node) = {
   .runtime_data_bytes = sizeof(mpls_input_runtime_t),
 
   .n_errors = MPLS_N_ERROR,
-  .error_strings = mpls_error_strings,
+  .error_counters = mpls_error_counters,
 
   .n_next_nodes = MPLS_INPUT_N_NEXT,
   .next_nodes = {
@@ -274,51 +258,28 @@ VLIB_REGISTER_NODE (mpls_input_node) = {
   .format_trace = format_mpls_input_trace,
 };
 
-VLIB_NODE_FUNCTION_MULTIARCH (mpls_input_node, mpls_input)
-
+#ifndef CLIB_MARCH_VARIANT
 static void
 mpls_setup_nodes (vlib_main_t * vm)
 {
-  mpls_input_runtime_t * rt;
   pg_node_t * pn;
 
   pn = pg_get_node (mpls_input_node.index);
   pn->unformat_edit = unformat_pg_mpls_header;
 
-  rt = vlib_node_get_runtime_data (vm, mpls_input_node.index);
-  rt->last_label = (u32) ~0;
-  rt->last_inner_fib_index = 0;
-  rt->last_outer_fib_index = 0;
-  rt->mpls_main = &mpls_main;
-
-  ethernet_register_input_type (vm, ETHERNET_TYPE_MPLS_UNICAST,
+  ethernet_register_input_type (vm, ETHERNET_TYPE_MPLS,
                                 mpls_input_node.index);
 }
 
 static clib_error_t * mpls_input_init (vlib_main_t * vm)
 {
-  clib_error_t * error; 
-
-  error = vlib_call_init_function (vm, mpls_init);
-  if (error)
-    clib_error_report (error);
-
   mpls_setup_nodes (vm);
 
   return 0;
 }
 
-VLIB_INIT_FUNCTION (mpls_input_init);
-
-static clib_error_t * mpls_input_worker_init (vlib_main_t * vm)
+VLIB_INIT_FUNCTION (mpls_input_init) =
 {
-  mpls_input_runtime_t * rt;
-  rt = vlib_node_get_runtime_data (vm, mpls_input_node.index);
-  rt->last_label = (u32) ~0;
-  rt->last_inner_fib_index = 0;
-  rt->last_outer_fib_index = 0;
-  rt->mpls_main = &mpls_main;
-  return 0;
-}
-
-VLIB_WORKER_INIT_FUNCTION (mpls_input_worker_init);
+  .runs_after = VLIB_INITS("mpls_init"),
+};
+#endif /* CLIB_MARCH_VARIANT */