summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorZhiyong Yang <zhiyong.yang@intel.com>2019-05-05 22:52:43 +0800
committerDamjan Marion <dmarion@me.com>2019-05-06 16:33:49 +0000
commit6fec8ea700c4789462748c91983e5adf4d60a266 (patch)
treecda05d9fb97185f732f43b57df443d9119b936c7 /src
parent0549378623484cc1d3f773669de4feed99a60019 (diff)
ip4_load_balance: leverage vlib_get_buffers
vlib_get_buffers can save 1.2 clocks/pkt from 16.1 to 14.9 clocks/pkt on Skylake. Change-Id: I79d8b58b192280af5e5a5f73562b6301e1821cec Signed-off-by: Zhiyong Yang <zhiyong.yang@intel.com>
Diffstat (limited to 'src')
-rw-r--r--src/vnet/ip/ip4_forward.c24
1 files changed, 11 insertions, 13 deletions
diff --git a/src/vnet/ip/ip4_forward.c b/src/vnet/ip/ip4_forward.c
index 85e6607a963..9ed9453648b 100644
--- a/src/vnet/ip/ip4_forward.c
+++ b/src/vnet/ip/ip4_forward.c
@@ -119,16 +119,17 @@ VLIB_NODE_FN (ip4_load_balance_node) (vlib_main_t * vm,
u32 n_left_from, n_left_to_next, *from, *to_next;
ip_lookup_next_t next;
u32 thread_index = vm->thread_index;
+ vlib_buffer_t *bufs[VLIB_FRAME_SIZE], **b = bufs;
from = vlib_frame_vector_args (frame);
n_left_from = frame->n_vectors;
next = node->cached_next_index;
+ vlib_get_buffers (vm, from, bufs, n_left_from);
while (n_left_from > 0)
{
vlib_get_next_frame (vm, node, next, to_next, n_left_to_next);
-
while (n_left_from >= 4 && n_left_to_next >= 2)
{
ip_lookup_next_t next0, next1;
@@ -140,16 +141,11 @@ VLIB_NODE_FN (ip4_load_balance_node) (vlib_main_t * vm,
/* Prefetch next iteration. */
{
- vlib_buffer_t *p2, *p3;
-
- p2 = vlib_get_buffer (vm, from[2]);
- p3 = vlib_get_buffer (vm, from[3]);
+ vlib_prefetch_buffer_header (b[2], STORE);
+ vlib_prefetch_buffer_header (b[3], STORE);
- vlib_prefetch_buffer_header (p2, STORE);
- vlib_prefetch_buffer_header (p3, STORE);
-
- CLIB_PREFETCH (p2->data, sizeof (ip0[0]), STORE);
- CLIB_PREFETCH (p3->data, sizeof (ip0[0]), STORE);
+ CLIB_PREFETCH (b[2]->data, sizeof (ip0[0]), STORE);
+ CLIB_PREFETCH (b[3]->data, sizeof (ip0[0]), STORE);
}
pi0 = to_next[0] = from[0];
@@ -160,8 +156,9 @@ VLIB_NODE_FN (ip4_load_balance_node) (vlib_main_t * vm,
to_next += 2;
n_left_to_next -= 2;
- p0 = vlib_get_buffer (vm, pi0);
- p1 = vlib_get_buffer (vm, pi1);
+ p0 = b[0];
+ p1 = b[1];
+ b += 2;
ip0 = vlib_buffer_get_current (p0);
ip1 = vlib_buffer_get_current (p1);
@@ -250,7 +247,8 @@ VLIB_NODE_FN (ip4_load_balance_node) (vlib_main_t * vm,
n_left_to_next -= 1;
n_left_from -= 1;
- p0 = vlib_get_buffer (vm, pi0);
+ p0 = b[0];
+ b += 1;
ip0 = vlib_buffer_get_current (p0);
lbi0 = vnet_buffer (p0)->ip.adj_index[VLIB_TX];