summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/vnet/CMakeLists.txt8
-rw-r--r--src/vnet/l2/l2_bvi.h2
-rw-r--r--src/vnet/l2/l2_flood.c3
-rw-r--r--src/vnet/l2/l2_fwd.c347
4 files changed, 159 insertions, 201 deletions
diff --git a/src/vnet/CMakeLists.txt b/src/vnet/CMakeLists.txt
index 9906a40fcc4..5f89b694afd 100644
--- a/src/vnet/CMakeLists.txt
+++ b/src/vnet/CMakeLists.txt
@@ -158,7 +158,11 @@ list(APPEND VNET_SOURCES
l2/l2_xcrw.c
)
-list(APPEND VNET_MULTIARCH_SOURCES l2/l2_output.c l2/l2_learn.c)
+list(APPEND VNET_MULTIARCH_SOURCES
+ l2/l2_fwd.c
+ l2/l2_learn.c
+ l2/l2_output.c
+)
list(APPEND VNET_HEADERS
l2/feat_bitmap.h
@@ -1374,4 +1378,4 @@ if(VPP_BUILD_SESSION_ECHO_APPS)
)
endif(VPP_BUILD_SESSION_ECHO_APPS)
-############################################################################## \ No newline at end of file
+##############################################################################
diff --git a/src/vnet/l2/l2_bvi.h b/src/vnet/l2/l2_bvi.h
index cc86072fab7..7abe462054e 100644
--- a/src/vnet/l2/l2_bvi.h
+++ b/src/vnet/l2/l2_bvi.h
@@ -38,7 +38,7 @@ static_always_inline u32
l2_to_bvi (vlib_main_t * vlib_main,
vnet_main_t * vnet_main,
vlib_buffer_t * b0,
- u32 bvi_sw_if_index, next_by_ethertype_t * l3_next, u32 * next0)
+ u32 bvi_sw_if_index, next_by_ethertype_t * l3_next, u16 * next0)
{
/* Perform L3 my-mac filter */
ethernet_header_t *e0 = vlib_buffer_get_current (b0);
diff --git a/src/vnet/l2/l2_flood.c b/src/vnet/l2/l2_flood.c
index 668301731a9..5d9873e0304 100644
--- a/src/vnet/l2/l2_flood.c
+++ b/src/vnet/l2/l2_flood.c
@@ -155,11 +155,12 @@ l2flood_node_fn (vlib_main_t * vm,
while (n_left_from > 0 && n_left_to_next > 0)
{
- u32 next0, sw_if_index0, bi0, ci0;
u16 n_clones, n_cloned, clone0;
l2_bridge_domain_t *bd_config;
+ u32 sw_if_index0, bi0, ci0;
l2_flood_member_t *member;
vlib_buffer_t *b0, *c0;
+ u16 next0;
u8 in_shg;
i32 mi;
diff --git a/src/vnet/l2/l2_fwd.c b/src/vnet/l2/l2_fwd.c
index fd7f54b41ef..7744fcdfa2f 100644
--- a/src/vnet/l2/l2_fwd.c
+++ b/src/vnet/l2/l2_fwd.c
@@ -82,7 +82,11 @@ format_l2fwd_trace (u8 * s, va_list * args)
return s;
}
+#ifndef CLIB_MARCH_VARIANT
l2fwd_main_t l2fwd_main;
+#else
+extern l2fwd_main_t l2fwd_main;
+#endif
static vlib_node_registration_t l2fwd_node;
@@ -125,7 +129,7 @@ l2fwd_process (vlib_main_t * vm,
l2fwd_main_t * msm,
vlib_error_main_t * em,
vlib_buffer_t * b0,
- u32 sw_if_index0, l2fib_entry_result_t * result0, u32 * next0)
+ u32 sw_if_index0, l2fib_entry_result_t * result0, u16 * next0)
{
int try_flood = result0->raw == ~0;
int flood_error;
@@ -227,229 +231,176 @@ static_always_inline uword
l2fwd_node_inline (vlib_main_t * vm, vlib_node_runtime_t * node,
vlib_frame_t * frame, int do_trace)
{
- u32 n_left_from, *from, *to_next;
- l2fwd_next_t next_index;
+ u32 n_left, *from;
l2fwd_main_t *msm = &l2fwd_main;
vlib_node_t *n = vlib_get_node (vm, l2fwd_node.index);
CLIB_UNUSED (u32 node_counter_base_index) = n->error_heap_index;
vlib_error_main_t *em = &vm->error_main;
l2fib_entry_key_t cached_key;
l2fib_entry_result_t cached_result;
+ vlib_buffer_t *bufs[VLIB_FRAME_SIZE], **b;
+ u16 nexts[VLIB_FRAME_SIZE], *next;
/* Clear the one-entry cache in case mac table was updated */
cached_key.raw = ~0;
cached_result.raw = ~0;
from = vlib_frame_vector_args (frame);
- n_left_from = frame->n_vectors; /* number of packets to process */
- next_index = node->cached_next_index;
+ n_left = frame->n_vectors; /* number of packets to process */
+ vlib_get_buffers (vm, from, bufs, n_left);
+ next = nexts;
+ b = bufs;
- while (n_left_from > 0)
+ while (n_left >= 8)
{
- u32 n_left_to_next;
-
- /* get space to enqueue frame to graph node "next_index" */
- vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next);
-
- while (n_left_from >= 8 && n_left_to_next >= 4)
- {
- u32 bi0, bi1, bi2, bi3;
- 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;
- l2fib_entry_key_t key0, key1, key2, key3;
- l2fib_entry_result_t result0, result1, result2, result3;
- u32 bucket0, bucket1, bucket2, bucket3;
-
- /* Prefetch next iteration. */
- {
- vlib_buffer_t *p4, *p5, *p6, *p7;
-
- p4 = vlib_get_buffer (vm, from[4]);
- p5 = vlib_get_buffer (vm, from[5]);
- p6 = vlib_get_buffer (vm, from[6]);
- p7 = vlib_get_buffer (vm, from[7]);
-
- 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);
- }
-
- /* speculatively enqueue b0 and b1 to the current next frame */
- /* bi is "buffer index", b is pointer to the buffer */
- to_next[0] = bi0 = from[0];
- to_next[1] = bi1 = from[1];
- to_next[2] = bi2 = from[2];
- to_next[3] = bi3 = from[3];
- from += 4;
- to_next += 4;
- n_left_from -= 4;
- n_left_to_next -= 4;
-
- b0 = vlib_get_buffer (vm, bi0);
- b1 = vlib_get_buffer (vm, bi1);
- b2 = vlib_get_buffer (vm, bi2);
- b3 = vlib_get_buffer (vm, bi3);
-
- /* RX interface handles */
- sw_if_index0 = vnet_buffer (b0)->sw_if_index[VLIB_RX];
- sw_if_index1 = vnet_buffer (b1)->sw_if_index[VLIB_RX];
- sw_if_index2 = vnet_buffer (b2)->sw_if_index[VLIB_RX];
- sw_if_index3 = vnet_buffer (b3)->sw_if_index[VLIB_RX];
-
- h0 = vlib_buffer_get_current (b0);
- h1 = vlib_buffer_get_current (b1);
- h2 = vlib_buffer_get_current (b2);
- h3 = vlib_buffer_get_current (b3);
-
- if (do_trace)
- {
- if (b0->flags & VLIB_BUFFER_IS_TRACED)
- {
- l2fwd_trace_t *t =
- vlib_add_trace (vm, node, b0, sizeof (*t));
- t->sw_if_index = sw_if_index0;
- t->bd_index = vnet_buffer (b0)->l2.bd_index;
- clib_memcpy (t->src, h0->src_address, 6);
- clib_memcpy (t->dst, h0->dst_address, 6);
- }
- if (b1->flags & VLIB_BUFFER_IS_TRACED)
- {
- l2fwd_trace_t *t =
- vlib_add_trace (vm, node, b1, sizeof (*t));
- t->sw_if_index = sw_if_index1;
- t->bd_index = vnet_buffer (b1)->l2.bd_index;
- clib_memcpy (t->src, h1->src_address, 6);
- clib_memcpy (t->dst, h1->dst_address, 6);
- }
- if (b2->flags & VLIB_BUFFER_IS_TRACED)
- {
- l2fwd_trace_t *t =
- vlib_add_trace (vm, node, b2, sizeof (*t));
- t->sw_if_index = sw_if_index2;
- t->bd_index = vnet_buffer (b2)->l2.bd_index;
- clib_memcpy (t->src, h2->src_address, 6);
- clib_memcpy (t->dst, h2->dst_address, 6);
- }
- if (b3->flags & VLIB_BUFFER_IS_TRACED)
- {
- l2fwd_trace_t *t =
- vlib_add_trace (vm, node, b3, sizeof (*t));
- t->sw_if_index = sw_if_index3;
- t->bd_index = vnet_buffer (b3)->l2.bd_index;
- clib_memcpy (t->src, h3->src_address, 6);
- clib_memcpy (t->dst, h3->dst_address, 6);
- }
- }
-
- /* process 2 pkts */
-#ifdef COUNTERS
- em->counters[node_counter_base_index + L2FWD_ERROR_L2FWD] += 4;
-#endif
- /* *INDENT-OFF* */
- l2fib_lookup_4 (msm->mac_table, &cached_key, &cached_result,
- h0->dst_address, h1->dst_address,
- h2->dst_address, h3->dst_address,
- vnet_buffer (b0)->l2.bd_index,
- vnet_buffer (b1)->l2.bd_index,
- vnet_buffer (b2)->l2.bd_index,
- vnet_buffer (b3)->l2.bd_index,
- &key0, /* not used */
- &key1, /* not used */
- &key2, /* not used */
- &key3, /* not used */
- &bucket0, /* not used */
- &bucket1, /* not used */
- &bucket2, /* not used */
- &bucket3, /* not used */
- &result0,
- &result1,
- &result2,
- &result3);
- /* *INDENT-ON* */
- l2fwd_process (vm, node, msm, em, b0, sw_if_index0, &result0,
- &next0);
- l2fwd_process (vm, node, msm, em, b1, sw_if_index1, &result1,
- &next1);
- l2fwd_process (vm, node, msm, em, b2, sw_if_index2, &result2,
- &next2);
- l2fwd_process (vm, node, msm, em, b3, sw_if_index3, &result3,
- &next3);
-
- /* verify speculative enqueues, maybe switch current next frame */
- /* if next0==next1==next_index then nothing special needs to be done */
- vlib_validate_buffer_enqueue_x4 (vm, node, next_index,
- to_next, n_left_to_next,
- bi0, bi1, bi2, bi3,
- next0, next1, next2, next3);
- }
-
- while (n_left_from > 0 && n_left_to_next > 0)
+ u32 sw_if_index0, sw_if_index1, sw_if_index2, sw_if_index3;
+ 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;
+
+ /* Prefetch next iteration. */
+ {
+ vlib_prefetch_buffer_header (b[4], LOAD);
+ vlib_prefetch_buffer_header (b[5], LOAD);
+ vlib_prefetch_buffer_header (b[6], LOAD);
+ vlib_prefetch_buffer_header (b[7], LOAD);
+
+ CLIB_PREFETCH (b[4]->data, CLIB_CACHE_LINE_BYTES, LOAD);
+ CLIB_PREFETCH (b[5]->data, CLIB_CACHE_LINE_BYTES, LOAD);
+ CLIB_PREFETCH (b[6]->data, CLIB_CACHE_LINE_BYTES, LOAD);
+ CLIB_PREFETCH (b[7]->data, CLIB_CACHE_LINE_BYTES, LOAD);
+ }
+
+ /* RX interface handles */
+ sw_if_index0 = vnet_buffer (b[0])->sw_if_index[VLIB_RX];
+ sw_if_index1 = vnet_buffer (b[1])->sw_if_index[VLIB_RX];
+ sw_if_index2 = vnet_buffer (b[2])->sw_if_index[VLIB_RX];
+ sw_if_index3 = vnet_buffer (b[3])->sw_if_index[VLIB_RX];
+
+ h0 = vlib_buffer_get_current (b[0]);
+ h1 = vlib_buffer_get_current (b[1]);
+ h2 = vlib_buffer_get_current (b[2]);
+ h3 = vlib_buffer_get_current (b[3]);
+
+ if (do_trace)
{
- u32 bi0;
- vlib_buffer_t *b0;
- u32 next0;
- u32 sw_if_index0;
- ethernet_header_t *h0;
- l2fib_entry_key_t key0;
- l2fib_entry_result_t result0;
- u32 bucket0;
-
- /* speculatively enqueue b0 to the current next frame */
- bi0 = from[0];
- to_next[0] = bi0;
- from += 1;
- to_next += 1;
- n_left_from -= 1;
- n_left_to_next -= 1;
-
- b0 = vlib_get_buffer (vm, bi0);
-
- sw_if_index0 = vnet_buffer (b0)->sw_if_index[VLIB_RX];
-
- h0 = vlib_buffer_get_current (b0);
-
- if (do_trace && PREDICT_FALSE (b0->flags & VLIB_BUFFER_IS_TRACED))
+ if (b[0]->flags & VLIB_BUFFER_IS_TRACED)
{
- l2fwd_trace_t *t = vlib_add_trace (vm, node, b0, sizeof (*t));
+ l2fwd_trace_t *t = vlib_add_trace (vm, node, b[0], sizeof (*t));
t->sw_if_index = sw_if_index0;
- t->bd_index = vnet_buffer (b0)->l2.bd_index;
+ t->bd_index = vnet_buffer (b[0])->l2.bd_index;
clib_memcpy (t->src, h0->src_address, 6);
clib_memcpy (t->dst, h0->dst_address, 6);
}
+ if (b[1]->flags & VLIB_BUFFER_IS_TRACED)
+ {
+ l2fwd_trace_t *t = vlib_add_trace (vm, node, b[1], sizeof (*t));
+ t->sw_if_index = sw_if_index1;
+ t->bd_index = vnet_buffer (b[1])->l2.bd_index;
+ clib_memcpy (t->src, h1->src_address, 6);
+ clib_memcpy (t->dst, h1->dst_address, 6);
+ }
+ if (b[2]->flags & VLIB_BUFFER_IS_TRACED)
+ {
+ l2fwd_trace_t *t = vlib_add_trace (vm, node, b[2], sizeof (*t));
+ t->sw_if_index = sw_if_index2;
+ t->bd_index = vnet_buffer (b[2])->l2.bd_index;
+ clib_memcpy (t->src, h2->src_address, 6);
+ clib_memcpy (t->dst, h2->dst_address, 6);
+ }
+ if (b[3]->flags & VLIB_BUFFER_IS_TRACED)
+ {
+ l2fwd_trace_t *t = vlib_add_trace (vm, node, b[3], sizeof (*t));
+ t->sw_if_index = sw_if_index3;
+ t->bd_index = vnet_buffer (b[3])->l2.bd_index;
+ clib_memcpy (t->src, h3->src_address, 6);
+ clib_memcpy (t->dst, h3->dst_address, 6);
+ }
+ }
- /* process 1 pkt */
#ifdef COUNTERS
- em->counters[node_counter_base_index + L2FWD_ERROR_L2FWD] += 1;
+ em->counters[node_counter_base_index + L2FWD_ERROR_L2FWD] += 4;
#endif
- l2fib_lookup_1 (msm->mac_table, &cached_key, &cached_result, h0->dst_address, vnet_buffer (b0)->l2.bd_index, &key0, /* not used */
- &bucket0, /* not used */
- &result0);
- l2fwd_process (vm, node, msm, em, b0, sw_if_index0, &result0,
- &next0);
-
- /* verify speculative enqueue, maybe switch current next frame */
- vlib_validate_buffer_enqueue_x1 (vm, node, next_index,
- to_next, n_left_to_next,
- bi0, next0);
+ /* *INDENT-OFF* */
+ l2fib_lookup_4 (msm->mac_table, &cached_key, &cached_result,
+ h0->dst_address, h1->dst_address,
+ h2->dst_address, h3->dst_address,
+ vnet_buffer (b[0])->l2.bd_index,
+ vnet_buffer (b[1])->l2.bd_index,
+ vnet_buffer (b[2])->l2.bd_index,
+ vnet_buffer (b[3])->l2.bd_index,
+ &key0, /* not used */
+ &key1, /* not used */
+ &key2, /* not used */
+ &key3, /* not used */
+ &bucket0, /* not used */
+ &bucket1, /* not used */
+ &bucket2, /* not used */
+ &bucket3, /* not used */
+ &result0,
+ &result1,
+ &result2,
+ &result3);
+ /* *INDENT-ON* */
+ l2fwd_process (vm, node, msm, em, b[0], sw_if_index0, &result0, next);
+ l2fwd_process (vm, node, msm, em, b[1], sw_if_index1, &result1,
+ next + 1);
+ l2fwd_process (vm, node, msm, em, b[2], sw_if_index2, &result2,
+ next + 2);
+ l2fwd_process (vm, node, msm, em, b[3], sw_if_index3, &result3,
+ next + 3);
+
+ /* verify speculative enqueues, maybe switch current next frame */
+ /* if next0==next1==next_index then nothing special needs to be done */
+ next += 4;
+ b += 4;
+ n_left -= 4;
+ }
+
+ while (n_left > 0)
+ {
+ u32 sw_if_index0;
+ ethernet_header_t *h0;
+ l2fib_entry_key_t key0;
+ l2fib_entry_result_t result0;
+ u32 bucket0;
+
+ sw_if_index0 = vnet_buffer (b[0])->sw_if_index[VLIB_RX];
+
+ h0 = vlib_buffer_get_current (b[0]);
+
+ if (do_trace && PREDICT_FALSE (b[0]->flags & VLIB_BUFFER_IS_TRACED))
+ {
+ l2fwd_trace_t *t = vlib_add_trace (vm, node, b[0], sizeof (*t));
+ t->sw_if_index = sw_if_index0;
+ t->bd_index = vnet_buffer (b[0])->l2.bd_index;
+ clib_memcpy (t->src, h0->src_address, 6);
+ clib_memcpy (t->dst, h0->dst_address, 6);
}
- vlib_put_next_frame (vm, node, next_index, n_left_to_next);
+ /* process 1 pkt */
+#ifdef COUNTERS
+ em->counters[node_counter_base_index + L2FWD_ERROR_L2FWD] += 1;
+#endif
+ l2fib_lookup_1 (msm->mac_table, &cached_key, &cached_result, h0->dst_address, vnet_buffer (b[0])->l2.bd_index, &key0, /* not used */
+ &bucket0, /* not used */
+ &result0);
+ l2fwd_process (vm, node, msm, em, b[0], sw_if_index0, &result0, next);
+
+ /* verify speculative enqueue, maybe switch current next frame */
+ next += 1;
+ b += 1;
+ n_left -= 1;
}
+ vlib_buffer_enqueue_to_next (vm, node, from, nexts, frame->n_vectors);
+
return frame->n_vectors;
}
-static uword
-l2fwd_node_fn (vlib_main_t * vm,
- vlib_node_runtime_t * node, vlib_frame_t * frame)
+VLIB_NODE_FN (l2fwd_node) (vlib_main_t * vm,
+ vlib_node_runtime_t * node, vlib_frame_t * frame)
{
if (PREDICT_FALSE ((node->flags & VLIB_NODE_FLAG_TRACE)))
return l2fwd_node_inline (vm, node, frame, 1 /* do_trace */ );
@@ -458,7 +409,6 @@ l2fwd_node_fn (vlib_main_t * vm,
/* *INDENT-OFF* */
VLIB_REGISTER_NODE (l2fwd_node,static) = {
- .function = l2fwd_node_fn,
.name = "l2-fwd",
.vector_size = sizeof (u32),
.format_trace = format_l2fwd_trace,
@@ -477,8 +427,9 @@ VLIB_REGISTER_NODE (l2fwd_node,static) = {
};
/* *INDENT-ON* */
-VLIB_NODE_FUNCTION_MULTIARCH (l2fwd_node, l2fwd_node_fn)
- clib_error_t *l2fwd_init (vlib_main_t * vm)
+#ifndef CLIB_MARCH_VARIANT
+clib_error_t *
+l2fwd_init (vlib_main_t * vm)
{
l2fwd_main_t *mp = &l2fwd_main;
@@ -577,6 +528,8 @@ VLIB_CLI_COMMAND (int_fwd_cli, static) = {
};
/* *INDENT-ON* */
+#endif
+
/*
* fd.io coding-style-patch-verification: ON
*