summaryrefslogtreecommitdiffstats
path: root/src/vlib/buffer_node.h
diff options
context:
space:
mode:
authorEyal Bari <ebari@cisco.com>2017-12-04 13:57:45 +0200
committerDamjan Marion <dmarion.lists@gmail.com>2017-12-04 17:13:38 +0000
commit2e292c6f6489015460e3fee8ec567791c897108e (patch)
tree610d115f8cd34c4c193955e52142b1ef793c402f /src/vlib/buffer_node.h
parentc99b4cd1c3aae9ca3bda0595a5cce4ea5e6ba84f (diff)
vlib: switch when frames are different
[ebari] no need to switch if next2, next3 are equal to next_index [dbarach] change fix_speculation calculaton to a branch-free xor/or tree Change-Id: I0131dc4499218363d5b0ce8f6440ce74e0b22bb9 Signed-off-by: Eyal Bari <ebari@cisco.com> Signed-off-by: Dave Barach <dave@barachs.net>
Diffstat (limited to 'src/vlib/buffer_node.h')
-rw-r--r--src/vlib/buffer_node.h22
1 files changed, 12 insertions, 10 deletions
diff --git a/src/vlib/buffer_node.h b/src/vlib/buffer_node.h
index 8a779049625..f9e8b3fa4fe 100644
--- a/src/vlib/buffer_node.h
+++ b/src/vlib/buffer_node.h
@@ -138,8 +138,8 @@ do { \
#define vlib_validate_buffer_enqueue_x4(vm,node,next_index,to_next,n_left_to_next,bi0,bi1,bi2,bi3,next0,next1,next2,next3) \
do { \
/* After the fact: check the [speculative] enqueue to "next" */ \
- u32 fix_speculation = next_index != next0 || next_index != next1 \
- || next_index != next2 || next_index != next3; \
+ u32 fix_speculation = (next_index ^ next0) | (next_index ^ next1) \
+ | (next_index ^ next2) | (next_index ^ next3); \
if (PREDICT_FALSE(fix_speculation)) \
{ \
/* rewind... */ \
@@ -181,15 +181,17 @@ do { \
n_left_to_next --; \
} \
else \
- vlib_set_next_frame_buffer (vm, node, next3, bi3); \
- \
- /* Change speculation: last 2 packets went to the same node */ \
- if (next2 == next3) \
{ \
- vlib_put_next_frame (vm, node, next_index, n_left_to_next); \
- next_index = next3; \
- vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next); \
- } \
+ vlib_set_next_frame_buffer (vm, node, next3, bi3); \
+ \
+ /* Change speculation: last 2 packets went to the same node*/ \
+ if (next2 == next3) \
+ { \
+ vlib_put_next_frame (vm, node, next_index, n_left_to_next); \
+ next_index = next3; \
+ vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next); \
+ } \
+ } \
} \
} while(0);