summaryrefslogtreecommitdiffstats
path: root/src/plugins/dpdk/cryptodev/cryptodev.c
diff options
context:
space:
mode:
authorPiotr Bronowski <piotrx.bronowski@intel.com>2023-07-06 23:02:57 +0000
committerFan Zhang <fanzhang.oss@gmail.com>2023-08-18 15:20:02 +0000
commit45e8a672f02f5937d218b0b82eca28db15b76694 (patch)
treeae05a26b9fba990841c104f6da14520435bec84a /src/plugins/dpdk/cryptodev/cryptodev.c
parent03e1d559f912513e1bc2ffc615b7833471afc790 (diff)
dpdk-cryptodev: improve cryptodev cache ring implementation
Sw ring is renamed to the cache ring. This name better reflects the puropse of this ring. We've introduced push/pop functions, as well as other utility functions which remove code repetition. Error handlig is improved: previously in case of an error all frame elements were marked as bad, now only these for which errors occured have the error status set. Unnecessary stats counters have been removed. Type: improvement Signed-off-by: Piotr Bronowski <piotrx.bronowski@intel.com> Change-Id: I2fd42a529ac84ce5ad260611d6b35a861d441c79
Diffstat (limited to 'src/plugins/dpdk/cryptodev/cryptodev.c')
-rw-r--r--src/plugins/dpdk/cryptodev/cryptodev.c55
1 files changed, 42 insertions, 13 deletions
diff --git a/src/plugins/dpdk/cryptodev/cryptodev.c b/src/plugins/dpdk/cryptodev/cryptodev.c
index fa54d2bf4fc..c66e9ed9427 100644
--- a/src/plugins/dpdk/cryptodev/cryptodev.c
+++ b/src/plugins/dpdk/cryptodev/cryptodev.c
@@ -667,37 +667,66 @@ VLIB_CLI_COMMAND (show_cryptodev_assignment, static) = {
};
static clib_error_t *
-cryptodev_show_sw_rings_fn (vlib_main_t *vm, unformat_input_t *input,
- vlib_cli_command_t *cmd)
+cryptodev_show_cache_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;
+ cryptodev_cache_ring_t *ring = &cet->cache_ring;
+ u16 head = ring->head;
+ u16 tail = ring->tail;
+ u16 n_cached = ((head == tail) && (ring->frames[head].f == 0)) ?
+ 0 :
+ ((head == tail) && (ring->frames[head].f != 0)) ?
+ (CRYPTODEV_CACHE_QUEUE_MASK + 1) :
+ (head > tail) ?
+ (head - tail) :
+ (CRYPTODEV_CACHE_QUEUE_MASK - tail + head);
+
+ u16 enq_head = ring->enq_head;
+ u16 deq_tail = ring->deq_tail;
+ u16 n_frames_inflight =
+ ((enq_head == deq_tail) && (ring->frames[enq_head].f == 0)) ?
+ 0 :
+ ((enq_head == deq_tail) && (ring->frames[enq_head].f != 0)) ?
+ CRYPTODEV_CACHE_QUEUE_MASK + 1 :
+ (enq_head > deq_tail) ?
+ (enq_head - deq_tail) :
+ (CRYPTODEV_CACHE_QUEUE_MASK - deq_tail + enq_head);
+
+ u16 n_frames_processed =
+ ((tail == deq_tail) && (ring->frames[deq_tail].f == 0)) ?
+ 0 :
+ ((tail == deq_tail) && (ring->frames[deq_tail].f != 0)) ?
+ (CRYPTODEV_CACHE_QUEUE_MASK + 1) :
+ (deq_tail > tail) ? (deq_tail - tail) :
+ (CRYPTODEV_CACHE_QUEUE_MASK - tail + deq_tail);
+
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 total: %d", n_cached);
+ vlib_cli_output (vm, "Frames pending in the ring: %d",
+ n_cached - n_frames_inflight - n_frames_processed);
vlib_cli_output (vm, "Frames enqueued but not dequeued: %d",
- cet->enqueued_not_dequeueq);
+ n_frames_inflight);
vlib_cli_output (vm, "Frames dequed but not returned: %d",
- cet->deqeued_not_returned);
+ n_frames_processed);
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, "Head: %d", ring->head);
+ vlib_cli_output (vm, "Tail: %d", 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,
+ .path = "show cryptodev cache status",
+ .short_help = "show status of all cryptodev cache rings",
+ .function = cryptodev_show_cache_rings_fn,
};
static clib_error_t *