X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;ds=sidebyside;f=src%2Fvnet%2Fmpls%2Fmpls_input.c;h=37fa1aead12fb076fbd95482ede2a6172a34c617;hb=038e1dfbd;hp=893c45111d4bf6da80bf101f385e2e207d3bdb2d;hpb=696e88da9799056036f329676213f3c0c0a1db9c;p=vpp.git diff --git a/src/vnet/mpls/mpls_input.c b/src/vnet/mpls/mpls_input.c index 893c45111d4..37fa1aead12 100644 --- a/src/vnet/mpls/mpls_input.c +++ b/src/vnet/mpls/mpls_input.c @@ -50,17 +50,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 +73,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 +107,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 +142,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 +155,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 +206,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,8 +229,7 @@ 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) { @@ -253,7 +243,6 @@ static char * mpls_error_strings[] = { }; VLIB_REGISTER_NODE (mpls_input_node) = { - .function = mpls_input, .name = "mpls-input", /* Takes a vector of packets. */ .vector_size = sizeof (u32), @@ -274,51 +263,30 @@ 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) +/* *INDENT-OFF* */ +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"), +}; +/* *INDENT-ON* */ +#endif /* CLIB_MARCH_VARIANT */