ipsec: re-enable DPDK IPSec for tunnel decap/encap (VPP-1823)
[vpp.git] / src / plugins / dpdk / ipsec / ipsec.c
index 2415422..8837756 100644 (file)
@@ -252,13 +252,13 @@ crypto_set_aead_xform (struct rte_crypto_sym_xform *xform,
 
   xform->type = RTE_CRYPTO_SYM_XFORM_AEAD;
   xform->aead.algo = c->alg;
-  xform->aead.key.data = sa->crypto_key;
+  xform->aead.key.data = sa->crypto_key.data;
   xform->aead.key.length = c->key_len;
   xform->aead.iv.offset =
     crypto_op_get_priv_offset () + offsetof (dpdk_op_priv_t, cb);
   xform->aead.iv.length = 12;
   xform->aead.digest_length = c->trunc_size;
-  xform->aead.aad_length = sa->use_esn ? 12 : 8;
+  xform->aead.aad_length = ipsec_sa_is_set_USE_ESN (sa) ? 12 : 8;
   xform->next = NULL;
 
   if (is_outbound)
@@ -280,7 +280,7 @@ crypto_set_cipher_xform (struct rte_crypto_sym_xform *xform,
 
   xform->type = RTE_CRYPTO_SYM_XFORM_CIPHER;
   xform->cipher.algo = c->alg;
-  xform->cipher.key.data = sa->crypto_key;
+  xform->cipher.key.data = sa->crypto_key.data;
   xform->cipher.key.length = c->key_len;
   xform->cipher.iv.offset =
     crypto_op_get_priv_offset () + offsetof (dpdk_op_priv_t, cb);
@@ -306,7 +306,7 @@ crypto_set_auth_xform (struct rte_crypto_sym_xform *xform,
 
   xform->type = RTE_CRYPTO_SYM_XFORM_AUTH;
   xform->auth.algo = a->alg;
-  xform->auth.key.data = sa->integ_key;
+  xform->auth.key.data = sa->integ_key.data;
   xform->auth.key.length = a->key_len;
   xform->auth.digest_length = a->trunc_size;
   xform->next = NULL;
@@ -494,7 +494,6 @@ dpdk_crypto_session_disposal (crypto_session_disposal_t * v, u64 ts)
 static clib_error_t *
 add_del_sa_session (u32 sa_index, u8 is_add)
 {
-  ipsec_main_t *im = &ipsec_main;
   dpdk_crypto_main_t *dcm = &dpdk_crypto_main;
   crypto_data_t *data;
   struct rte_cryptodev_sym_session *s;
@@ -502,24 +501,7 @@ add_del_sa_session (u32 sa_index, u8 is_add)
   u32 drv_id;
 
   if (is_add)
-    {
-#if 1
-      ipsec_sa_t *sa = pool_elt_at_index (im->sad, sa_index);
-      u32 seed;
-      switch (sa->crypto_alg)
-       {
-       case IPSEC_CRYPTO_ALG_AES_GCM_128:
-       case IPSEC_CRYPTO_ALG_AES_GCM_192:
-       case IPSEC_CRYPTO_ALG_AES_GCM_256:
-         clib_memcpy (&sa->salt, &sa->crypto_key[sa->crypto_key_len - 4], 4);
-         break;
-       default:
-         seed = (u32) clib_cpu_time_now ();
-         sa->salt = random_u32 (&seed);
-       }
-#endif
-      return 0;
-    }
+    return 0;
 
   /* *INDENT-OFF* */
   vec_foreach (data, dcm->data)
@@ -638,9 +620,6 @@ crypto_parse_capabilities (crypto_dev_t * dev,
     }
 }
 
-#define DPDK_CRYPTO_N_QUEUE_DESC  2048
-#define DPDK_CRYPTO_NB_SESS_OBJS  20000
-
 static clib_error_t *
 crypto_dev_conf (u8 dev, u16 n_qp, u8 numa)
 {
@@ -1068,8 +1047,12 @@ dpdk_ipsec_process (vlib_main_t * vm, vlib_node_runtime_t * rt,
 
   u32 idx = ipsec_register_esp_backend (vm, im, "dpdk backend",
                                        "dpdk-esp4-encrypt",
+                                       "dpdk-esp4-encrypt-tun",
+                                       "dpdk-esp4-decrypt",
                                        "dpdk-esp4-decrypt",
                                        "dpdk-esp6-encrypt",
+                                       "dpdk-esp6-encrypt-tun",
+                                       "dpdk-esp6-decrypt",
                                        "dpdk-esp6-decrypt",
                                        dpdk_ipsec_check_support,
                                        add_del_sa_session);