From 123b5ebb9816e520d3029146ee233826f4e974bc Mon Sep 17 00:00:00 2001 From: Neale Ranns Date: Fri, 16 Oct 2020 14:03:55 +0000 Subject: ipsec: Layout and prefetching of SA struct Type: improvement - collect all DP used variables onto 1st or 2nd cache line - prefetch the 2nd cache line - in encrypt prefetch the likely location of the trailer. Signed-off-by: Neale Ranns Change-Id: I44d58f8d2d469ff71a4f4a71578e7cc1acaeba43 --- src/vnet/ipsec/esp_encrypt.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/vnet/ipsec/esp_encrypt.c') diff --git a/src/vnet/ipsec/esp_encrypt.c b/src/vnet/ipsec/esp_encrypt.c index c0773e2963f..591ec260699 100644 --- a/src/vnet/ipsec/esp_encrypt.c +++ b/src/vnet/ipsec/esp_encrypt.c @@ -624,6 +624,9 @@ esp_encrypt_inline (vlib_main_t * vm, vlib_node_runtime_t * node, CLIB_PREFETCH (p, CLIB_CACHE_LINE_BYTES, LOAD); p -= CLIB_CACHE_LINE_BYTES; CLIB_PREFETCH (p, CLIB_CACHE_LINE_BYTES, LOAD); + /* speculate that the trailer goes in the first buffer */ + CLIB_PREFETCH (vlib_buffer_get_tail (b[1]), + CLIB_CACHE_LINE_BYTES, LOAD); } if (is_tun) @@ -646,6 +649,10 @@ esp_encrypt_inline (vlib_main_t * vm, vlib_node_runtime_t * node, current_sa_packets = current_sa_bytes = 0; sa0 = pool_elt_at_index (im->sad, sa_index0); + + /* fetch the second cacheline ASAP */ + CLIB_PREFETCH (sa0->cacheline1, CLIB_CACHE_LINE_BYTES, LOAD); + current_sa_index = sa_index0; spi = clib_net_to_host_u32 (sa0->spi); esp_align = sa0->esp_block_align; -- cgit 1.2.3-korg