aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/nat
diff options
context:
space:
mode:
authorKlement Sekera <ksekera@cisco.com>2020-07-13 13:59:33 +0000
committerMatthew Smith <mgsmith@netgate.com>2020-07-15 16:27:29 +0000
commit4d119a6f15333e107bd9766112410eaf4ce1a57f (patch)
treebc4d880bcbf4de552a694dc6673ec672f294d678 /src/plugins/nat
parenta7b963df2758d7c25de366db1999ca1024e12d30 (diff)
nat: add prefetching to in2out_ed/out2in_ed
This saves about 20 clocks/packet in both code paths. Type: improvement Signed-off-by: Klement Sekera <ksekera@cisco.com> Change-Id: Ib559c74bf8168e3ddd764d51b7e5bcd2a557f591
Diffstat (limited to 'src/plugins/nat')
-rw-r--r--src/plugins/nat/in2out_ed.c14
-rw-r--r--src/plugins/nat/out2in_ed.c15
2 files changed, 27 insertions, 2 deletions
diff --git a/src/plugins/nat/in2out_ed.c b/src/plugins/nat/in2out_ed.c
index c59c2d4536c..080f37e7c15 100644
--- a/src/plugins/nat/in2out_ed.c
+++ b/src/plugins/nat/in2out_ed.c
@@ -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)
{
@@ -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,
diff --git a/src/plugins/nat/out2in_ed.c b/src/plugins/nat/out2in_ed.c
index 8286e66ffda..05fc75fac71 100644
--- a/src/plugins/nat/out2in_ed.c
+++ b/src/plugins/nat/out2in_ed.c
@@ -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;
@@ -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,