Skip to content

Commit

Permalink
nat: add prefetching to in2out_ed/out2in_ed
Browse files Browse the repository at this point in the history
This saves about 20 clocks/packet in both code paths.

Type: improvement
Signed-off-by: Klement Sekera <[email protected]>
Change-Id: Ib559c74bf8168e3ddd764d51b7e5bcd2a557f591
  • Loading branch information
Klement Sekera authored and mgsmith1000 committed Jul 15, 2020
1 parent a7b963d commit 4d119a6
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
14 changes: 13 additions & 1 deletion src/plugins/nat/in2out_ed.c
Original file line number Diff line number Diff line change
Expand Up @@ -943,6 +943,19 @@ nat44_ed_in2out_fast_path_node_fn_inline (vlib_main_t * vm,
ip_csum_t sum0;

b0 = *b;
b++;

/* Prefetch next iteration. */
if (PREDICT_TRUE (n_left_from >= 2))
{
vlib_buffer_t *p2;

p2 = *b;

vlib_prefetch_buffer_header (p2, LOAD);

CLIB_PREFETCH (p2->data, CLIB_CACHE_LINE_BYTES, LOAD);
}

if (is_output_feature)
{
Expand Down Expand Up @@ -1158,7 +1171,6 @@ nat44_ed_in2out_fast_path_node_fn_inline (vlib_main_t * vm,

n_left_from--;
next++;
b++;
}

vlib_buffer_enqueue_to_next (vm, node, from, (u16 *) nexts,
Expand Down
15 changes: 14 additions & 1 deletion src/plugins/nat/out2in_ed.c
Original file line number Diff line number Diff line change
Expand Up @@ -705,6 +705,20 @@ nat44_ed_out2in_fast_path_node_fn_inline (vlib_main_t * vm,
ip_csum_t sum0;

b0 = *b;
b++;

/* Prefetch next iteration. */
if (PREDICT_TRUE (n_left_from >= 2))
{
vlib_buffer_t *p2;

p2 = *b;

vlib_prefetch_buffer_header (p2, LOAD);

CLIB_PREFETCH (p2->data, CLIB_CACHE_LINE_BYTES, LOAD);
}

next[0] = vnet_buffer2 (b0)->nat.arc_next;

vnet_buffer (b0)->snat.flags = 0;
Expand Down Expand Up @@ -927,7 +941,6 @@ nat44_ed_out2in_fast_path_node_fn_inline (vlib_main_t * vm,

n_left_from--;
next++;
b++;
}

vlib_buffer_enqueue_to_next (vm, node, from, (u16 *) nexts,
Expand Down

0 comments on commit 4d119a6

Please sign in to comment.