From: Eyal Bari Date: Mon, 4 Dec 2017 11:57:45 +0000 (+0200) Subject: vlib: switch when frames are different X-Git-Tag: v18.04-rc0~115 X-Git-Url: https://gerrit.fd.io/r/gitweb?a=commitdiff_plain;h=2e292c6f6489015460e3fee8ec567791c897108e;hp=c99b4cd1c3aae9ca3bda0595a5cce4ea5e6ba84f;p=vpp.git 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 Signed-off-by: Dave Barach --- 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);