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
@@ -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,6 +181,7 @@ 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*/ \
@@ -191,6 +192,7 @@ do { \
vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next); \
} \
} \
+ } \
} while(0);
/** \brief Finish enqueueing one buffer forward in the graph.
