dpdk-cryptodev: introduce sw_ring 18/39018/2
authorPiotr Bronowski <piotrx.bronowski@intel.com>
Fri, 9 Jun 2023 14:22:40 +0000 (14:22 +0000)
committerDamjan Marion <dmarion@0xa5.net>
Tue, 13 Jun 2023 12:08:54 +0000 (12:08 +0000)
This patch introduces sw_ring. This ring is used in next set of patchas
and plays role of a buffer for QAT, allowing collecting frame elements
in case QAT queue is fully utilized, and assembling frame
from QAT dequeued elements.

Type: improvement
Signed-off-by: Piotr Bronowski <piotrx.bronowski@intel.com>
Signed-off-by: Dastin Wilski <dastin.wilski@gmail.com>
Change-Id: I20718e200986ab4dba5cbc31c05a904072a6981a

src/plugins/dpdk/cryptodev/cryptodev.c
src/plugins/dpdk/cryptodev/cryptodev.h

index 84a307d..8750ffd 100644 (file)
@@ -666,6 +666,40 @@ VLIB_CLI_COMMAND (show_cryptodev_assignment, static) = {
     .function = cryptodev_show_assignment_fn,
 };
 
+static clib_error_t *
+cryptodev_show_sw_rings_fn (vlib_main_t *vm, unformat_input_t *input,
+                           vlib_cli_command_t *cmd)
+{
+  cryptodev_main_t *cmt = &cryptodev_main;
+  u32 thread_index = 0;
+  vec_foreach_index (thread_index, cmt->per_thread_data)
+    {
+      cryptodev_engine_thread_t *cet = cmt->per_thread_data + thread_index;
+      if (vlib_num_workers () > 0 && thread_index == 0)
+       continue;
+      vlib_cli_output (vm, "\n\n");
+      vlib_cli_output (vm, "Frames total: %d", cet->frames_on_ring);
+      vlib_cli_output (vm, "Frames pending in a ring: %d",
+                      cet->frames_on_ring - cet->enqueued_not_dequeueq -
+                        cet->deqeued_not_returned);
+      vlib_cli_output (vm, "Frames enqueued but not dequeued: %d",
+                      cet->enqueued_not_dequeueq);
+      vlib_cli_output (vm, "Frames dequed but not returned: %d",
+                      cet->deqeued_not_returned);
+      vlib_cli_output (vm, "inflight: %d", cet->inflight);
+      vlib_cli_output (vm, "Head: %d", cet->frame_ring.head);
+      vlib_cli_output (vm, "Tail: %d", cet->frame_ring.tail);
+      vlib_cli_output (vm, "\n\n");
+    }
+  return 0;
+}
+
+VLIB_CLI_COMMAND (show_cryptodev_sw_rings, static) = {
+  .path = "show cryptodev sw-ring status",
+  .short_help = "show status of all cryptodev software rings",
+  .function = cryptodev_show_sw_rings_fn,
+};
+
 static clib_error_t *
 cryptodev_set_assignment_fn (vlib_main_t * vm, unformat_input_t * input,
                             vlib_cli_command_t * cmd)
index cf68e1d..58c2397 100644 (file)
@@ -26,6 +26,8 @@
 #define CRYPTODEV_CACHE_QUEUE_MASK (VNET_CRYPTO_FRAME_POOL_SIZE - 1)
 #define CRYPTODEV_MAX_INFLIGHT    (CRYPTODEV_NB_CRYPTO_OPS - 1)
 #define CRYPTODEV_AAD_MASK        (CRYPTODEV_NB_CRYPTO_OPS - 1)
+#define CRYPTODE_ENQ_MAX          64
+#define CRYPTODE_DEQ_MAX          64
 #define CRYPTODEV_DEQ_CACHE_SZ    32
 #define CRYPTODEV_NB_SESSION      4096
 #define CRYPTODEV_MAX_IV_SIZE     16
@@ -152,6 +154,30 @@ typedef struct
   u32 n_elts;
 } cryptodev_op_t;
 
+typedef struct
+{
+  vnet_crypto_async_frame_t *f;
+
+  u8 enqueued;
+  u8 dequeued;
+  u8 deq_state;
+  u8 frame_inflight;
+
+  u8 op_type;
+  u8 aad_len;
+  u8 n_elts;
+  u8 reserved;
+} cryptodev_async_ring_elt;
+
+typedef struct
+{
+  cryptodev_async_ring_elt frames[VNET_CRYPTO_FRAME_POOL_SIZE];
+  uint16_t head;
+  uint16_t tail;
+  uint16_t enq; /*record the frame currently being enqueued */
+  uint16_t deq; /*record the frame currently being dequeued */
+} cryptodev_async_frame_sw_ring;
+
 typedef struct
 {
   CLIB_CACHE_LINE_ALIGN_MARK (cacheline0);
@@ -174,8 +200,14 @@ typedef struct
       cryptodev_session_t *reset_sess;
     };
   };
+
+  cryptodev_async_frame_sw_ring frame_ring;
   u16 cryptodev_id;
   u16 cryptodev_q;
+  u16 frames_on_ring;
+  u16 enqueued_not_dequeueq;
+  u16 deqeued_not_returned;
+  u16 pending_to_qat;
   u16 inflight;
 } cryptodev_engine_thread_t;