ipsec: one thread index per-SA

Type: improvement

AN SA is uni-drectional therefore it can be used only for encrypt or
decrypt, not both. So it only needs one thread ID. free up some space on
the 1st cacheline.

Signed-off-by: Neale Ranns <neale@graphiant.com>
Change-Id: I21cb7cff70a763cbe2bffead860b574bc80b3136
diff --git a/src/vnet/ipsec/ipsec_handoff.c b/src/vnet/ipsec/ipsec_handoff.c
index 87eb801..8bd6d22 100644
--- a/src/vnet/ipsec/ipsec_handoff.c
+++ b/src/vnet/ipsec/ipsec_handoff.c
@@ -54,9 +54,8 @@
 
 /* do worker handoff based on thread_index in NAT HA protcol header */
 static_always_inline uword
-ipsec_handoff (vlib_main_t * vm,
-	       vlib_node_runtime_t * node,
-	       vlib_frame_t * frame, u32 fq_index, bool is_enc)
+ipsec_handoff (vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame,
+	       u32 fq_index)
 {
   vlib_buffer_t *bufs[VLIB_FRAME_SIZE], **b;
   u16 thread_indices[VLIB_FRAME_SIZE], *ti;
@@ -99,20 +98,10 @@
       sa2 = pool_elt_at_index (im->sad, sai2);
       sa3 = pool_elt_at_index (im->sad, sai3);
 
-      if (is_enc)
-	{
-	  ti[0] = sa0->encrypt_thread_index;
-	  ti[1] = sa1->encrypt_thread_index;
-	  ti[2] = sa2->encrypt_thread_index;
-	  ti[3] = sa3->encrypt_thread_index;
-	}
-      else
-	{
-	  ti[0] = sa0->decrypt_thread_index;
-	  ti[1] = sa1->decrypt_thread_index;
-	  ti[2] = sa2->decrypt_thread_index;
-	  ti[3] = sa3->decrypt_thread_index;
-	}
+      ti[0] = sa0->thread_index;
+      ti[1] = sa1->thread_index;
+      ti[2] = sa2->thread_index;
+      ti[3] = sa3->thread_index;
 
       if (node->flags & VLIB_NODE_FLAG_TRACE)
 	{
@@ -154,10 +143,7 @@
       sai0 = vnet_buffer (b[0])->ipsec.sad_index;
       sa0 = pool_elt_at_index (im->sad, sai0);
 
-      if (is_enc)
-	ti[0] = sa0->encrypt_thread_index;
-      else
-	ti[0] = sa0->decrypt_thread_index;
+      ti[0] = sa0->thread_index;
 
       if (PREDICT_FALSE (b[0]->flags & VLIB_BUFFER_IS_TRACED))
 	{
@@ -188,7 +174,7 @@
 {
   ipsec_main_t *im = &ipsec_main;
 
-  return ipsec_handoff (vm, node, from_frame, im->esp4_enc_fq_index, true);
+  return ipsec_handoff (vm, node, from_frame, im->esp4_enc_fq_index);
 }
 
 VLIB_NODE_FN (esp6_encrypt_handoff) (vlib_main_t * vm,
@@ -197,7 +183,7 @@
 {
   ipsec_main_t *im = &ipsec_main;
 
-  return ipsec_handoff (vm, node, from_frame, im->esp6_enc_fq_index, true);
+  return ipsec_handoff (vm, node, from_frame, im->esp6_enc_fq_index);
 }
 
 VLIB_NODE_FN (esp4_encrypt_tun_handoff) (vlib_main_t * vm,
@@ -206,8 +192,7 @@
 {
   ipsec_main_t *im = &ipsec_main;
 
-  return ipsec_handoff (vm, node, from_frame, im->esp4_enc_tun_fq_index,
-			true);
+  return ipsec_handoff (vm, node, from_frame, im->esp4_enc_tun_fq_index);
 }
 
 VLIB_NODE_FN (esp6_encrypt_tun_handoff) (vlib_main_t * vm,
@@ -216,8 +201,7 @@
 {
   ipsec_main_t *im = &ipsec_main;
 
-  return ipsec_handoff (vm, node, from_frame, im->esp6_enc_tun_fq_index,
-			true);
+  return ipsec_handoff (vm, node, from_frame, im->esp6_enc_tun_fq_index);
 }
 
 VLIB_NODE_FN (esp_mpls_encrypt_tun_handoff)
@@ -225,8 +209,7 @@
 {
   ipsec_main_t *im = &ipsec_main;
 
-  return ipsec_handoff (vm, node, from_frame, im->esp_mpls_enc_tun_fq_index,
-			true);
+  return ipsec_handoff (vm, node, from_frame, im->esp_mpls_enc_tun_fq_index);
 }
 
 VLIB_NODE_FN (esp4_decrypt_handoff) (vlib_main_t * vm,
@@ -235,7 +218,7 @@
 {
   ipsec_main_t *im = &ipsec_main;
 
-  return ipsec_handoff (vm, node, from_frame, im->esp4_dec_fq_index, false);
+  return ipsec_handoff (vm, node, from_frame, im->esp4_dec_fq_index);
 }
 
 VLIB_NODE_FN (esp6_decrypt_handoff) (vlib_main_t * vm,
@@ -244,7 +227,7 @@
 {
   ipsec_main_t *im = &ipsec_main;
 
-  return ipsec_handoff (vm, node, from_frame, im->esp6_dec_fq_index, false);
+  return ipsec_handoff (vm, node, from_frame, im->esp6_dec_fq_index);
 }
 
 VLIB_NODE_FN (esp4_decrypt_tun_handoff) (vlib_main_t * vm,
@@ -253,8 +236,7 @@
 {
   ipsec_main_t *im = &ipsec_main;
 
-  return ipsec_handoff (vm, node, from_frame, im->esp4_dec_tun_fq_index,
-			false);
+  return ipsec_handoff (vm, node, from_frame, im->esp4_dec_tun_fq_index);
 }
 
 VLIB_NODE_FN (esp6_decrypt_tun_handoff) (vlib_main_t * vm,
@@ -263,8 +245,7 @@
 {
   ipsec_main_t *im = &ipsec_main;
 
-  return ipsec_handoff (vm, node, from_frame, im->esp6_dec_tun_fq_index,
-			false);
+  return ipsec_handoff (vm, node, from_frame, im->esp6_dec_tun_fq_index);
 }
 
 VLIB_NODE_FN (ah4_encrypt_handoff) (vlib_main_t * vm,
@@ -273,7 +254,7 @@
 {
   ipsec_main_t *im = &ipsec_main;
 
-  return ipsec_handoff (vm, node, from_frame, im->ah4_enc_fq_index, true);
+  return ipsec_handoff (vm, node, from_frame, im->ah4_enc_fq_index);
 }
 
 VLIB_NODE_FN (ah6_encrypt_handoff) (vlib_main_t * vm,
@@ -282,7 +263,7 @@
 {
   ipsec_main_t *im = &ipsec_main;
 
-  return ipsec_handoff (vm, node, from_frame, im->ah6_enc_fq_index, true);
+  return ipsec_handoff (vm, node, from_frame, im->ah6_enc_fq_index);
 }
 
 VLIB_NODE_FN (ah4_decrypt_handoff) (vlib_main_t * vm,
@@ -291,7 +272,7 @@
 {
   ipsec_main_t *im = &ipsec_main;
 
-  return ipsec_handoff (vm, node, from_frame, im->ah4_dec_fq_index, false);
+  return ipsec_handoff (vm, node, from_frame, im->ah4_dec_fq_index);
 }
 
 VLIB_NODE_FN (ah6_decrypt_handoff) (vlib_main_t * vm,
@@ -300,7 +281,7 @@
 {
   ipsec_main_t *im = &ipsec_main;
 
-  return ipsec_handoff (vm, node, from_frame, im->ah6_dec_fq_index, false);
+  return ipsec_handoff (vm, node, from_frame, im->ah6_dec_fq_index);
 }
 
 /* *INDENT-OFF* */