dpdk-ipsec: use single queue pair per crypto resource 84/17184/2
authorSergio Gonzalez Monroy <sgmonroy@gmail.com>
Wed, 30 Jan 2019 10:26:00 +0000 (11:26 +0100)
committerDamjan Marion <dmarion@me.com>
Thu, 31 Jan 2019 22:07:10 +0000 (22:07 +0000)
Change-Id: I2c796583087c70fbc5cf09e8afd0f2a1f389d346
Signed-off-by: Sergio Gonzalez Monroy <sgmonroy@gmail.com>
src/plugins/dpdk/ipsec/cli.c
src/plugins/dpdk/ipsec/crypto_node.c
src/plugins/dpdk/ipsec/esp_decrypt.c
src/plugins/dpdk/ipsec/esp_encrypt.c
src/plugins/dpdk/ipsec/ipsec.c
src/plugins/dpdk/ipsec/ipsec.h

index 4efa88e..b773cd2 100644 (file)
@@ -141,9 +141,9 @@ format_crypto_worker (u8 * s, va_list * args)
     {
       ind = "  ";
       res = vec_elt_at_index (dcm->resource, res_idx[0]);
-      s = format (s, "%s%-20s dev-id %2u inbound-queue %2u outbound-queue %2u\n",
+      s = format (s, "%s%-20s dev-id %2u queue-pair %2u\n",
                  ind, vec_elt_at_index (dcm->dev, res->dev_id)->name,
-                 res->dev_id, res->qp_id, res->qp_id + 1);
+                 res->dev_id, res->qp_id);
 
       ind = "    ";
       if (verbose)
@@ -226,12 +226,12 @@ show_dpdk_crypto_placement_v_fn (vlib_main_t * vm, unformat_input_t * input,
  * @cliexstart{show dpdk crypto placement}
  * vpp# show dpdk crypto placement
  * Thread 1 (vpp_wk_0):
- *   cryptodev_aesni_mb_p dev-id  0 inbound-queue  0 outbound-queue  1
- *   cryptodev_aesni_gcm_ dev-id  1 inbound-queue  0 outbound-queue  1
+ *   cryptodev_aesni_mb_p dev-id  0 queue-pair  0
+ *   cryptodev_aesni_gcm_ dev-id  1 queue-pair  0
  *
  * Thread 2 (vpp_wk_1):
- *   cryptodev_aesni_mb_p dev-id  0 inbound-queue  2 outbound-queue  3
- *   cryptodev_aesni_gcm_ dev-id  1 inbound-queue  2 outbound-queue  3
+ *   cryptodev_aesni_mb_p dev-id  0 queue-pair  1
+ *   cryptodev_aesni_gcm_ dev-id  1 queue-pair  1
  * @cliexend
 ?*/
 /* *INDENT-OFF* */
@@ -251,18 +251,18 @@ VLIB_CLI_COMMAND (show_dpdk_crypto_placement, static) = {
  * @cliexstart{show dpdk crypto placement verbose}
  * vpp# show dpdk crypto placement verbose
  * Thread 1 (vpp_wk_0):
- *   cryptodev_aesni_mb_p dev-id  0 inbound-queue  0 outbound-queue  1
+ *   cryptodev_aesni_mb_p dev-id  0 queue-pair  0
  *     Cipher: aes-cbc-128, aes-cbc-192, aes-cbc-256, aes-ctr-128, aes-ctr-192, aes-ctr-256
  *     Auth: md5-96, sha1-96, sha-256-128, sha-384-192, sha-512-256
- *     cryptodev_aesni_gcm_ dev-id  1 inbound-queue  0 outbound-queue  1
+ *     cryptodev_aesni_gcm_ dev-id  1 queue-pair  0
  *     Cipher: aes-gcm-128, aes-gcm-192, aes-gcm-256
  *     Auth:
  *
  * Thread 2 (vpp_wk_1):
- *   cryptodev_aesni_mb_p dev-id  0 inbound-queue  2 outbound-queue  3
+ *   cryptodev_aesni_mb_p dev-id  0 queue-pair  1
  *     Cipher: aes-cbc-128, aes-cbc-192, aes-cbc-256, aes-ctr-128, aes-ctr-192, aes-ctr-256
  *     Auth: md5-96, sha1-96, sha-256-128, sha-384-192, sha-512-256
- *     cryptodev_aesni_gcm_ dev-id  1 inbound-queue  2 outbound-queue  3
+ *     cryptodev_aesni_gcm_ dev-id  1 queue-pair  1
  *     Cipher: aes-gcm-128, aes-gcm-192, aes-gcm-256
  *     Auth:
  *
index 3945973..b9ed7af 100644 (file)
@@ -145,7 +145,7 @@ dpdk_crypto_input_trace (vlib_main_t * vm, vlib_node_runtime_t * node,
 
 static_always_inline u32
 dpdk_crypto_dequeue (vlib_main_t * vm, vlib_node_runtime_t * node,
-                    crypto_resource_t * res, u8 outbound)
+                    crypto_resource_t * res)
 {
   u32 thread_idx = vlib_get_thread_index ();
   u8 numa = rte_socket_id ();
@@ -164,14 +164,14 @@ dpdk_crypto_dequeue (vlib_main_t * vm, vlib_node_runtime_t * node,
   ops = cwm->ops;
 
   n_ops = n_deq = rte_cryptodev_dequeue_burst (res->dev_id,
-                                              res->qp_id + outbound,
+                                              res->qp_id,
                                               ops, VLIB_FRAME_SIZE);
 
   /* no op dequeued, do not proceed */
   if (n_deq == 0)
     return 0;
 
-  res->inflights[outbound] -= n_ops;
+  res->inflights -= n_ops;
 
   dpdk_crypto_input_trace (vm, node, ops, n_deq);
 
@@ -285,13 +285,10 @@ dpdk_crypto_input_inline (vlib_main_t * vm, vlib_node_runtime_t * node,
     {
       res = vec_elt_at_index (dcm->resource, res_idx[0]);
 
-      if (res->inflights[0])
-       n_deq += dpdk_crypto_dequeue (vm, node, res, 0);
+      if (res->inflights)
+       n_deq += dpdk_crypto_dequeue (vm, node, res);
 
-      if (res->inflights[1])
-       n_deq += dpdk_crypto_dequeue (vm, node, res, 1);
-
-      if (PREDICT_FALSE (res->remove && !(res->inflights[0] || res->inflights[1])))
+      if (PREDICT_FALSE (res->remove && !(res->inflights)))
        vec_add1 (remove, res_idx[0]);
     }
   /* *INDENT-ON* */
index d8d1d38..265877f 100644 (file)
@@ -376,7 +376,7 @@ dpdk_esp_decrypt_inline (vlib_main_t * vm,
                                   ESP_DECRYPT_ERROR_RX_PKTS,
                                   from_frame->n_vectors);
 
-      crypto_enqueue_ops (vm, cwm, 0, dpdk_esp6_decrypt_node.index,
+      crypto_enqueue_ops (vm, cwm, dpdk_esp6_decrypt_node.index,
                          ESP_DECRYPT_ERROR_ENQ_FAIL, numa);
     }
   else
@@ -385,7 +385,7 @@ dpdk_esp_decrypt_inline (vlib_main_t * vm,
                                   ESP_DECRYPT_ERROR_RX_PKTS,
                                   from_frame->n_vectors);
 
-      crypto_enqueue_ops (vm, cwm, 0, dpdk_esp4_decrypt_node.index,
+      crypto_enqueue_ops (vm, cwm, dpdk_esp4_decrypt_node.index,
                          ESP_DECRYPT_ERROR_ENQ_FAIL, numa);
     }
 
index fc12eec..279cfea 100644 (file)
@@ -548,7 +548,7 @@ dpdk_esp_encrypt_inline (vlib_main_t * vm,
                                   ESP_ENCRYPT_ERROR_RX_PKTS,
                                   from_frame->n_vectors);
 
-      crypto_enqueue_ops (vm, cwm, 1, dpdk_esp6_encrypt_node.index,
+      crypto_enqueue_ops (vm, cwm, dpdk_esp6_encrypt_node.index,
                          ESP_ENCRYPT_ERROR_ENQ_FAIL, numa);
     }
   else
@@ -557,7 +557,7 @@ dpdk_esp_encrypt_inline (vlib_main_t * vm,
                                   ESP_ENCRYPT_ERROR_RX_PKTS,
                                   from_frame->n_vectors);
 
-      crypto_enqueue_ops (vm, cwm, 1, dpdk_esp4_encrypt_node.index,
+      crypto_enqueue_ops (vm, cwm, dpdk_esp4_encrypt_node.index,
                          ESP_ENCRYPT_ERROR_ENQ_FAIL, numa);
     }
 
index dd64f6d..5207084 100644 (file)
@@ -19,6 +19,7 @@
 #include <vlib/node_funcs.h>
 
 #include <dpdk/device/dpdk.h>
+#include <dpdk/buffer.h>
 #include <dpdk/ipsec/ipsec.h>
 
 dpdk_crypto_main_t dpdk_crypto_main;
@@ -705,7 +706,7 @@ crypto_scan_devs (u32 n_mains)
          continue;
        }
 
-      max_res_idx = (dev->max_qp / 2) - 1;
+      max_res_idx = dev->max_qp - 1;
 
       vec_validate (dev->free_resources, max_res_idx);
 
@@ -714,13 +715,13 @@ crypto_scan_devs (u32 n_mains)
                                       (crypto_resource_t) EMPTY_STRUCT,
                                       CLIB_CACHE_LINE_BYTES);
 
-      for (j = 0; j <= max_res_idx; j++, res_idx++)
+      for (j = 0; j <= max_res_idx; j++)
        {
-         vec_elt (dev->free_resources, max_res_idx - j) = res_idx;
-         res = &dcm->resource[res_idx];
+         vec_elt (dev->free_resources, max_res_idx - j) = res_idx + j;
+         res = &dcm->resource[res_idx + j];
          res->dev_id = i;
          res->drv_id = drv_id;
-         res->qp_id = j * 2;
+         res->qp_id = j;
          res->numa = dev->numa;
          res->thread_idx = (u16) ~ 0;
        }
index 054fe9b..ac2b9b8 100644 (file)
@@ -114,7 +114,7 @@ typedef struct
   u8 dev_id;
   u8 numa;
   u16 qp_id;
-  u16 inflights[2];
+  u16 inflights;
   u16 n_ops;
   u16 __unused;
   struct rte_crypto_op *ops[VLIB_FRAME_SIZE];
@@ -301,7 +301,7 @@ crypto_free_ops (u8 numa, struct rte_crypto_op **ops, u32 n)
 }
 
 static_always_inline void
-crypto_enqueue_ops (vlib_main_t * vm, crypto_worker_main_t * cwm, u8 outbound,
+crypto_enqueue_ops (vlib_main_t * vm, crypto_worker_main_t * cwm,
                    u32 node_index, u32 error, u8 numa)
 {
   dpdk_crypto_main_t *dcm = &dpdk_crypto_main;
@@ -317,9 +317,9 @@ crypto_enqueue_ops (vlib_main_t * vm, crypto_worker_main_t * cwm, u8 outbound,
       if (!res->n_ops)
        continue;
 
-      enq = rte_cryptodev_enqueue_burst (res->dev_id, res->qp_id + outbound,
+      enq = rte_cryptodev_enqueue_burst (res->dev_id, res->qp_id,
                                         res->ops, res->n_ops);
-      res->inflights[outbound] += enq;
+      res->inflights += enq;
 
       if (PREDICT_FALSE (enq < res->n_ops))
        {