X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=src%2Fvnet%2Fl2%2Fl2_learn.c;h=732a1fc5d8534fa764c984b46299e1a564029eb4;hb=eb1525f1060569cc3dc03aca7696ce05e1401a09;hp=6ece1a3c7f25ddefdc59fa7513b2abd9ff293d58;hpb=71612d61930e57e7c8ebf9e5647b15a4b23720b2;p=vpp.git diff --git a/src/vnet/l2/l2_learn.c b/src/vnet/l2/l2_learn.c index 6ece1a3c7f2..732a1fc5d85 100644 --- a/src/vnet/l2/l2_learn.c +++ b/src/vnet/l2/l2_learn.c @@ -29,7 +29,9 @@ #include #include +#ifndef CLIB_MARCH_VARIANT l2learn_main_t l2learn_main; +#endif /** * @file @@ -132,7 +134,7 @@ l2learn_process (vlib_node_runtime_t * node, if (PREDICT_TRUE (check == 0)) return; /* MAC entry up to date */ - if (result0->fields.age_not) + if (l2fib_entry_result_is_set_AGE_NOT (result0)) return; /* Static MAC always age_not */ if (msm->global_learn_count > msm->global_learn_limit) return; /* Above learn limit - do not update */ @@ -171,12 +173,15 @@ l2learn_process (vlib_node_runtime_t * node, msm->global_learn_count++; result0->raw = 0; /* clear all fields */ result0->fields.sw_if_index = sw_if_index0; - result0->fields.lrn_evt = (msm->client_pid != 0); + if (msm->client_pid != 0) + l2fib_entry_result_set_LRN_EVT (result0); + else + l2fib_entry_result_clear_LRN_EVT (result0); } else { /* Entry in L2FIB with different sw_if_index - mac move or filter */ - if (result0->fields.filter) + if (l2fib_entry_result_is_set_FILTER (result0)) { ASSERT (result0->fields.sw_if_index == ~0); /* drop packet because lookup matched a filter mac entry */ @@ -185,7 +190,7 @@ l2learn_process (vlib_node_runtime_t * node, return; } - if (result0->fields.static_mac) + if (l2fib_entry_result_is_set_STATIC (result0)) { /* * Don't overwrite a static mac @@ -201,12 +206,20 @@ l2learn_process (vlib_node_runtime_t * node, * TODO: check global/bridge domain/interface learn limits */ result0->fields.sw_if_index = sw_if_index0; - if (result0->fields.age_not) /* The mac was provisioned */ + if (l2fib_entry_result_is_set_AGE_NOT (result0)) { + /* The mac was provisioned */ msm->global_learn_count++; - result0->fields.age_not = 0; + l2fib_entry_result_clear_AGE_NOT (result0); } - result0->fields.lrn_evt = (msm->client_pid != 0); + if (msm->client_pid != 0) + l2fib_entry_result_set_bits (result0, + (L2FIB_ENTRY_RESULT_FLAG_LRN_EVT | + L2FIB_ENTRY_RESULT_FLAG_LRN_MOV)); + else + l2fib_entry_result_clear_bits (result0, + (L2FIB_ENTRY_RESULT_FLAG_LRN_EVT | + L2FIB_ENTRY_RESULT_FLAG_LRN_MOV)); counter_base[L2LEARN_ERROR_MAC_MOVE] += 1; } @@ -260,7 +273,7 @@ l2learn_node_inline (vlib_main_t * vm, vlib_node_runtime_t * node, vlib_buffer_t *b0, *b1, *b2, *b3; u32 next0, next1, next2, next3; u32 sw_if_index0, sw_if_index1, sw_if_index2, sw_if_index3; - ethernet_header_t *h0, *h1, *h2, *h3; + const ethernet_header_t *h0, *h1, *h2, *h3; l2fib_entry_key_t key0, key1, key2, key3; l2fib_entry_result_t result0, result1, result2, result3; u32 bucket0, bucket1, bucket2, bucket3; @@ -274,15 +287,17 @@ l2learn_node_inline (vlib_main_t * vm, vlib_node_runtime_t * node, p6 = vlib_get_buffer (vm, from[6]); p7 = vlib_get_buffer (vm, from[7]); + /* buffer header is read and written, so use LOAD + * prefetch */ vlib_prefetch_buffer_header (p4, LOAD); vlib_prefetch_buffer_header (p5, LOAD); vlib_prefetch_buffer_header (p6, LOAD); vlib_prefetch_buffer_header (p7, LOAD); - CLIB_PREFETCH (p4->data, CLIB_CACHE_LINE_BYTES, STORE); - CLIB_PREFETCH (p5->data, CLIB_CACHE_LINE_BYTES, STORE); - CLIB_PREFETCH (p6->data, CLIB_CACHE_LINE_BYTES, STORE); - CLIB_PREFETCH (p7->data, CLIB_CACHE_LINE_BYTES, STORE); + CLIB_PREFETCH (p4->data, CLIB_CACHE_LINE_BYTES, LOAD); + CLIB_PREFETCH (p5->data, CLIB_CACHE_LINE_BYTES, LOAD); + CLIB_PREFETCH (p6->data, CLIB_CACHE_LINE_BYTES, LOAD); + CLIB_PREFETCH (p7->data, CLIB_CACHE_LINE_BYTES, LOAD); } /* speculatively enqueue b0 and b1 to the current next frame */ @@ -454,9 +469,8 @@ l2learn_node_inline (vlib_main_t * vm, vlib_node_runtime_t * node, return frame->n_vectors; } -static uword -l2learn_node_fn (vlib_main_t * vm, - vlib_node_runtime_t * node, vlib_frame_t * frame) +VLIB_NODE_FN (l2learn_node) (vlib_main_t * vm, + vlib_node_runtime_t * node, vlib_frame_t * frame) { if (PREDICT_FALSE ((node->flags & VLIB_NODE_FLAG_TRACE))) return l2learn_node_inline (vm, node, frame, 1 /* do_trace */ ); @@ -465,7 +479,6 @@ l2learn_node_fn (vlib_main_t * vm, /* *INDENT-OFF* */ VLIB_REGISTER_NODE (l2learn_node,static) = { - .function = l2learn_node_fn, .name = "l2-learn", .vector_size = sizeof (u32), .format_trace = format_l2learn_trace, @@ -484,8 +497,9 @@ VLIB_REGISTER_NODE (l2learn_node,static) = { }; /* *INDENT-ON* */ -VLIB_NODE_FUNCTION_MULTIARCH (l2learn_node, l2learn_node_fn) - clib_error_t *l2learn_init (vlib_main_t * vm) +#ifndef CLIB_MARCH_VARIANT +clib_error_t * +l2learn_init (vlib_main_t * vm) { l2learn_main_t *mp = &l2learn_main; @@ -588,6 +602,8 @@ l2learn_config (vlib_main_t * vm, unformat_input_t * input) VLIB_CONFIG_FUNCTION (l2learn_config, "l2learn"); +#endif + /* * fd.io coding-style-patch-verification: ON