X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=src%2Fvnet%2Fl2%2Fl2_efp_filter.c;h=3d152ad1f11d55f559a7962d4f395fd1d3012b95;hb=282872127;hp=2db4dc69c9c1b4e4c3ac6194e500ee1267ac9d84;hpb=7cd468a3d7dee7d6c92f69a0bb7061ae208ec727;p=vpp.git diff --git a/src/vnet/l2/l2_efp_filter.c b/src/vnet/l2/l2_efp_filter.c index 2db4dc69c9c..3d152ad1f11 100644 --- a/src/vnet/l2/l2_efp_filter.c +++ b/src/vnet/l2/l2_efp_filter.c @@ -22,6 +22,7 @@ #include #include #include +#include #include #include @@ -43,9 +44,8 @@ */ typedef struct { - - /* Next nodes for features and output interfaces */ - l2_output_next_nodes_st next_nodes; + /* Next nodes for L2 output features */ + u32 l2_out_feat_next[32]; /* convenience variables */ vlib_main_t *vlib_main; @@ -81,9 +81,11 @@ format_l2_efp_filter_trace (u8 * s, va_list * args) return s; } -l2_efp_filter_main_t l2_efp_filter_main; +extern l2_efp_filter_main_t l2_efp_filter_main; -static vlib_node_registration_t l2_efp_filter_node; +#ifndef CLIB_MARCH_VARIANT +l2_efp_filter_main_t l2_efp_filter_main; +#endif /* CLIB_MARCH_VARIANT */ #define foreach_l2_efp_filter_error \ _(L2_EFP_FILTER, "L2 EFP filter packets") \ @@ -170,9 +172,9 @@ extract_keys (vnet_main_t * vnet_main, * The post-rewrite check is performed here. */ -static uword -l2_efp_filter_node_fn (vlib_main_t * vm, - vlib_node_runtime_t * node, vlib_frame_t * frame) +VLIB_NODE_FN (l2_efp_filter_node) (vlib_main_t * vm, + vlib_node_runtime_t * node, + vlib_frame_t * frame) { u32 n_left_from, *from, *to_next; l2_efp_filter_next_t next_index; @@ -180,11 +182,6 @@ l2_efp_filter_node_fn (vlib_main_t * vm, vlib_node_t *n = vlib_get_node (vm, l2_efp_filter_node.index); u32 node_counter_base_index = n->error_heap_index; vlib_error_main_t *em = &vm->error_main; - u32 cached_sw_if_index = ~0; - u32 cached_next_index = ~0; - - /* invalidate cache to begin with */ - cached_sw_if_index = ~0; from = vlib_frame_vector_args (frame); n_left_from = frame->n_vectors; /* number of packets to process */ @@ -203,7 +200,6 @@ l2_efp_filter_node_fn (vlib_main_t * vm, vlib_buffer_t *b0, *b1; u32 next0, next1; u32 sw_if_index0, sw_if_index1; - u32 feature_bitmap0, feature_bitmap1; u16 first_ethertype0, first_ethertype1; u16 outer_id0, inner_id0, outer_id1, inner_id1; u32 match_flags0, match_flags1; @@ -267,29 +263,11 @@ l2_efp_filter_node_fn (vlib_main_t * vm, em->counters[node_counter_base_index + L2_EFP_FILTER_ERROR_L2_EFP_FILTER] += 2; - /* Remove ourself from the feature bitmap */ - feature_bitmap0 = - vnet_buffer (b0)->l2.feature_bitmap & ~L2OUTPUT_FEAT_EFP_FILTER; - feature_bitmap1 = - vnet_buffer (b1)->l2.feature_bitmap & ~L2OUTPUT_FEAT_EFP_FILTER; - /* Determine next node */ - l2_output_dispatch (msm->vlib_main, - msm->vnet_main, - node, - l2_efp_filter_node.index, - &cached_sw_if_index, - &cached_next_index, - &msm->next_nodes, - b0, sw_if_index0, feature_bitmap0, &next0); - l2_output_dispatch (msm->vlib_main, - msm->vnet_main, - node, - l2_efp_filter_node.index, - &cached_sw_if_index, - &cached_next_index, - &msm->next_nodes, - b1, sw_if_index1, feature_bitmap1, &next1); + next0 = vnet_l2_feature_next (b0, msm->l2_out_feat_next, + L2OUTPUT_FEAT_EFP_FILTER); + next1 = vnet_l2_feature_next (b1, msm->l2_out_feat_next, + L2OUTPUT_FEAT_EFP_FILTER); /* perform the efp filter check on two packets */ @@ -326,7 +304,6 @@ l2_efp_filter_node_fn (vlib_main_t * vm, &main_intf1, &vlan_intf1, &qinq_intf1); matched0 = eth_identify_subint (hi0, - b0, match_flags0, main_intf0, vlan_intf0, @@ -335,7 +312,6 @@ l2_efp_filter_node_fn (vlib_main_t * vm, &error0, &is_l20); matched1 = eth_identify_subint (hi1, - b1, match_flags1, main_intf1, vlan_intf1, @@ -365,9 +341,9 @@ l2_efp_filter_node_fn (vlib_main_t * vm, l2_efp_filter_trace_t *t = vlib_add_trace (vm, node, b0, sizeof (*t)); t->sw_if_index = sw_if_index0; - clib_memcpy (t->src, h0->src_address, 6); - clib_memcpy (t->dst, h0->dst_address, 6); - clib_memcpy (t->raw, &h0->type, sizeof (t->raw)); + clib_memcpy_fast (t->src, h0->src_address, 6); + clib_memcpy_fast (t->dst, h0->dst_address, 6); + clib_memcpy_fast (t->raw, &h0->type, sizeof (t->raw)); } if (b1->flags & VLIB_BUFFER_IS_TRACED) { @@ -375,9 +351,9 @@ l2_efp_filter_node_fn (vlib_main_t * vm, l2_efp_filter_trace_t *t = vlib_add_trace (vm, node, b1, sizeof (*t)); t->sw_if_index = sw_if_index1; - clib_memcpy (t->src, h1->src_address, 6); - clib_memcpy (t->dst, h1->dst_address, 6); - clib_memcpy (t->raw, &h1->type, sizeof (t->raw)); + clib_memcpy_fast (t->src, h1->src_address, 6); + clib_memcpy_fast (t->dst, h1->dst_address, 6); + clib_memcpy_fast (t->raw, &h1->type, sizeof (t->raw)); } } @@ -394,7 +370,6 @@ l2_efp_filter_node_fn (vlib_main_t * vm, vlib_buffer_t *b0; u32 next0; u32 sw_if_index0; - u32 feature_bitmap0; u16 first_ethertype0; u16 outer_id0, inner_id0; u32 match_flags0; @@ -422,19 +397,9 @@ l2_efp_filter_node_fn (vlib_main_t * vm, em->counters[node_counter_base_index + L2_EFP_FILTER_ERROR_L2_EFP_FILTER] += 1; - /* Remove ourself from the feature bitmap */ - feature_bitmap0 = - vnet_buffer (b0)->l2.feature_bitmap & ~L2OUTPUT_FEAT_EFP_FILTER; - /* Determine next node */ - l2_output_dispatch (msm->vlib_main, - msm->vnet_main, - node, - l2_efp_filter_node.index, - &cached_sw_if_index, - &cached_next_index, - &msm->next_nodes, - b0, sw_if_index0, feature_bitmap0, &next0); + next0 = vnet_l2_feature_next (b0, msm->l2_out_feat_next, + L2OUTPUT_FEAT_EFP_FILTER); /* perform the efp filter check on one packet */ @@ -455,7 +420,6 @@ l2_efp_filter_node_fn (vlib_main_t * vm, &main_intf0, &vlan_intf0, &qinq_intf0); matched0 = eth_identify_subint (hi0, - b0, match_flags0, main_intf0, vlan_intf0, @@ -477,9 +441,9 @@ l2_efp_filter_node_fn (vlib_main_t * vm, l2_efp_filter_trace_t *t = vlib_add_trace (vm, node, b0, sizeof (*t)); t->sw_if_index = sw_if_index0; - clib_memcpy (t->src, h0->src_address, 6); - clib_memcpy (t->dst, h0->dst_address, 6); - clib_memcpy (t->raw, &h0->type, sizeof (t->raw)); + clib_memcpy_fast (t->src, h0->src_address, 6); + clib_memcpy_fast (t->dst, h0->dst_address, 6); + clib_memcpy_fast (t->raw, &h0->type, sizeof (t->raw)); } /* verify speculative enqueue, maybe switch current next frame */ @@ -496,8 +460,7 @@ l2_efp_filter_node_fn (vlib_main_t * vm, /* *INDENT-OFF* */ -VLIB_REGISTER_NODE (l2_efp_filter_node,static) = { - .function = l2_efp_filter_node_fn, +VLIB_REGISTER_NODE (l2_efp_filter_node) = { .name = "l2-efp-filter", .vector_size = sizeof (u32), .format_trace = format_l2_efp_filter_trace, @@ -515,8 +478,9 @@ VLIB_REGISTER_NODE (l2_efp_filter_node,static) = { }; /* *INDENT-ON* */ -VLIB_NODE_FUNCTION_MULTIARCH (l2_efp_filter_node, l2_efp_filter_node_fn) - clib_error_t *l2_efp_filter_init (vlib_main_t * vm) +#ifndef CLIB_MARCH_VARIANT +clib_error_t * +l2_efp_filter_init (vlib_main_t * vm) { l2_efp_filter_main_t *mp = &l2_efp_filter_main; @@ -528,10 +492,7 @@ VLIB_NODE_FUNCTION_MULTIARCH (l2_efp_filter_node, l2_efp_filter_node_fn) l2_efp_filter_node.index, L2OUTPUT_N_FEAT, l2output_get_feat_names (), - mp->next_nodes.feat_next_node_index); - - /* Initialize the output node mapping table */ - l2output_init_output_node_vec (&mp->next_nodes.output_node_index_vec); + mp->l2_out_feat_next); return 0; } @@ -541,7 +502,7 @@ VLIB_INIT_FUNCTION (l2_efp_filter_init); /** Enable/disable the EFP Filter check on the subinterface. */ void -l2_efp_filter_configure (vnet_main_t * vnet_main, u32 sw_if_index, u32 enable) +l2_efp_filter_configure (vnet_main_t * vnet_main, u32 sw_if_index, u8 enable) { /* set the interface flag */ l2output_intf_bitmap_enable (sw_if_index, L2OUTPUT_FEAT_EFP_FILTER, enable); @@ -604,6 +565,7 @@ VLIB_CLI_COMMAND (int_l2_efp_filter_cli, static) = { }; /* *INDENT-ON* */ +#endif /* CLIB_MARCH_VARIANT */ /* * fd.io coding-style-patch-verification: ON