* [PATCH] app/eventdev: add crypto producer mode
@ 2021-12-20 19:53 Shijith Thotton
2021-12-21 8:51 ` [PATCH v2] " Shijith Thotton
0 siblings, 1 reply; 43+ messages in thread
From: Shijith Thotton @ 2021-12-20 19:53 UTC (permalink / raw)
To: dev, Jerin Jacob
Cc: Shijith Thotton, anoobj, pbhagavatula, gakhil, abhinandan.gujjar
In crypto producer mode, producer core enqueues cryptodev with software
generated crypto ops and worker core dequeues crypto completion events
from the eventdev. Event crypto metadata used for above processing is
pre-populated in each crypto session.
Parameter --prod_type_cryptodev can be used to enable crypto producer
mode. Parameter --crypto_adptr_mode can be set to select the crypto
adapter mode, 0 for OP_NEW and 1 for OP_FORWARD.
This mode can be used to measure the performance of crypto adapter.
Example:
./dpdk-test-eventdev -l 0-2 -w <EVENTDEV> -w <CRYPTODEV> -- \
--prod_type_cryptodev --crypto_adptr_mode 1 --test=perf_atq \
--stlist=a --wlcores 1 --plcores 2
Signed-off-by: Shijith Thotton <sthotton@marvell.com>
---
app/test-eventdev/evt_common.h | 3 +
app/test-eventdev/evt_main.c | 13 +-
app/test-eventdev/evt_options.c | 27 ++
app/test-eventdev/evt_options.h | 12 +
app/test-eventdev/evt_test.h | 6 +
app/test-eventdev/test_perf_atq.c | 51 ++++
app/test-eventdev/test_perf_common.c | 405 ++++++++++++++++++++++++++-
app/test-eventdev/test_perf_common.h | 16 ++
app/test-eventdev/test_perf_queue.c | 52 ++++
doc/guides/tools/testeventdev.rst | 13 +
10 files changed, 591 insertions(+), 7 deletions(-)
diff --git a/app/test-eventdev/evt_common.h b/app/test-eventdev/evt_common.h
index f466434459..2f301a7e79 100644
--- a/app/test-eventdev/evt_common.h
+++ b/app/test-eventdev/evt_common.h
@@ -7,6 +7,7 @@
#include <rte_common.h>
#include <rte_debug.h>
+#include <rte_event_crypto_adapter.h>
#include <rte_eventdev.h>
#include <rte_service.h>
@@ -39,6 +40,7 @@ enum evt_prod_type {
EVT_PROD_TYPE_SYNT, /* Producer type Synthetic i.e. CPU. */
EVT_PROD_TYPE_ETH_RX_ADPTR, /* Producer type Eth Rx Adapter. */
EVT_PROD_TYPE_EVENT_TIMER_ADPTR, /* Producer type Timer Adapter. */
+ EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR, /* Producer type Crypto Adapter. */
EVT_PROD_TYPE_MAX,
};
@@ -77,6 +79,7 @@ struct evt_options {
uint64_t timer_tick_nsec;
uint64_t optm_timer_tick_nsec;
enum evt_prod_type prod_type;
+ enum rte_event_crypto_adapter_mode crypto_adptr_mode;
};
static inline bool
diff --git a/app/test-eventdev/evt_main.c b/app/test-eventdev/evt_main.c
index 194c980c7a..cef0fb1382 100644
--- a/app/test-eventdev/evt_main.c
+++ b/app/test-eventdev/evt_main.c
@@ -161,12 +161,19 @@ main(int argc, char **argv)
goto mempool_destroy;
}
}
+ /* Test specific cryptodev setup */
+ if (test->ops.cryptodev_setup) {
+ if (test->ops.cryptodev_setup(test, &opt)) {
+ evt_err("%s: cryptodev setup failed", opt.test_name);
+ goto ethdev_destroy;
+ }
+ }
/* Test specific eventdev setup */
if (test->ops.eventdev_setup) {
if (test->ops.eventdev_setup(test, &opt)) {
evt_err("%s: eventdev setup failed", opt.test_name);
- goto ethdev_destroy;
+ goto cryptodev_destroy;
}
}
@@ -197,6 +204,10 @@ main(int argc, char **argv)
if (test->ops.eventdev_destroy)
test->ops.eventdev_destroy(test, &opt);
+cryptodev_destroy:
+ if (test->ops.cryptodev_destroy)
+ test->ops.cryptodev_destroy(test, &opt);
+
ethdev_destroy:
if (test->ops.ethdev_destroy)
test->ops.ethdev_destroy(test, &opt);
diff --git a/app/test-eventdev/evt_options.c b/app/test-eventdev/evt_options.c
index 753a7dbd7d..5ad1491020 100644
--- a/app/test-eventdev/evt_options.c
+++ b/app/test-eventdev/evt_options.c
@@ -122,6 +122,26 @@ evt_parse_timer_prod_type_burst(struct evt_options *opt,
return 0;
}
+static int
+evt_parse_crypto_prod_type(struct evt_options *opt,
+ const char *arg __rte_unused)
+{
+ opt->prod_type = EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR;
+ return 0;
+}
+
+static int
+evt_parse_crypto_adptr_mode(struct evt_options *opt, const char *arg)
+{
+ uint8_t mode;
+ int ret;
+
+ ret = parser_read_uint8(&mode, arg);
+ opt->crypto_adptr_mode = mode ? RTE_EVENT_CRYPTO_ADAPTER_OP_FORWARD :
+ RTE_EVENT_CRYPTO_ADAPTER_OP_NEW;
+ return ret;
+}
+
static int
evt_parse_test_name(struct evt_options *opt, const char *arg)
{
@@ -335,6 +355,7 @@ usage(char *program)
"\t--queue_priority : enable queue priority\n"
"\t--deq_tmo_nsec : global dequeue timeout\n"
"\t--prod_type_ethdev : use ethernet device as producer.\n"
+ "\t--prod_type_cryptodev : use crypto device as producer.\n"
"\t--prod_type_timerdev : use event timer device as producer.\n"
"\t expity_nsec would be the timeout\n"
"\t in ns.\n"
@@ -345,6 +366,8 @@ usage(char *program)
"\t--timer_tick_nsec : timer tick interval in ns.\n"
"\t--max_tmo_nsec : max timeout interval in ns.\n"
"\t--expiry_nsec : event timer expiry ns.\n"
+ "\t--crypto_adptr_mode : 0 for OP_NEW mode (default) and\n"
+ "\t 1 for OP_FORWARD mode.\n"
"\t--mbuf_sz : packet mbuf size.\n"
"\t--max_pkt_sz : max packet size.\n"
"\t--prod_enq_burst_sz : producer enqueue burst size.\n"
@@ -415,8 +438,10 @@ static struct option lgopts[] = {
{ EVT_QUEUE_PRIORITY, 0, 0, 0 },
{ EVT_DEQ_TMO_NSEC, 1, 0, 0 },
{ EVT_PROD_ETHDEV, 0, 0, 0 },
+ { EVT_PROD_CRYPTODEV, 0, 0, 0 },
{ EVT_PROD_TIMERDEV, 0, 0, 0 },
{ EVT_PROD_TIMERDEV_BURST, 0, 0, 0 },
+ { EVT_CRYPTO_ADPTR_MODE, 1, 0, 0 },
{ EVT_NB_TIMERS, 1, 0, 0 },
{ EVT_NB_TIMER_ADPTRS, 1, 0, 0 },
{ EVT_TIMER_TICK_NSEC, 1, 0, 0 },
@@ -455,8 +480,10 @@ evt_opts_parse_long(int opt_idx, struct evt_options *opt)
{ EVT_QUEUE_PRIORITY, evt_parse_queue_priority},
{ EVT_DEQ_TMO_NSEC, evt_parse_deq_tmo_nsec},
{ EVT_PROD_ETHDEV, evt_parse_eth_prod_type},
+ { EVT_PROD_CRYPTODEV, evt_parse_crypto_prod_type},
{ EVT_PROD_TIMERDEV, evt_parse_timer_prod_type},
{ EVT_PROD_TIMERDEV_BURST, evt_parse_timer_prod_type_burst},
+ { EVT_CRYPTO_ADPTR_MODE, evt_parse_crypto_adptr_mode},
{ EVT_NB_TIMERS, evt_parse_nb_timers},
{ EVT_NB_TIMER_ADPTRS, evt_parse_nb_timer_adptrs},
{ EVT_TIMER_TICK_NSEC, evt_parse_timer_tick_nsec},
diff --git a/app/test-eventdev/evt_options.h b/app/test-eventdev/evt_options.h
index 413d7092f0..2231c58801 100644
--- a/app/test-eventdev/evt_options.h
+++ b/app/test-eventdev/evt_options.h
@@ -9,6 +9,7 @@
#include <stdbool.h>
#include <rte_common.h>
+#include <rte_cryptodev.h>
#include <rte_ethdev.h>
#include <rte_eventdev.h>
#include <rte_lcore.h>
@@ -33,8 +34,10 @@
#define EVT_QUEUE_PRIORITY ("queue_priority")
#define EVT_DEQ_TMO_NSEC ("deq_tmo_nsec")
#define EVT_PROD_ETHDEV ("prod_type_ethdev")
+#define EVT_PROD_CRYPTODEV ("prod_type_cryptodev")
#define EVT_PROD_TIMERDEV ("prod_type_timerdev")
#define EVT_PROD_TIMERDEV_BURST ("prod_type_timerdev_burst")
+#define EVT_CRYPTO_ADPTR_MODE ("crypto_adptr_mode")
#define EVT_NB_TIMERS ("nb_timers")
#define EVT_NB_TIMER_ADPTRS ("nb_timer_adptrs")
#define EVT_TIMER_TICK_NSEC ("timer_tick_nsec")
@@ -249,6 +252,8 @@ evt_prod_id_to_name(enum evt_prod_type prod_type)
return "Ethdev Rx Adapter";
case EVT_PROD_TYPE_EVENT_TIMER_ADPTR:
return "Event timer adapter";
+ case EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR:
+ return "Event crypto adapter";
}
return "";
@@ -288,6 +293,13 @@ evt_dump_producer_type(struct evt_options *opt)
evt_dump("timer_tick_nsec", "%"PRIu64"",
opt->timer_tick_nsec);
break;
+ case EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR:
+ snprintf(name, EVT_PROD_MAX_NAME_LEN,
+ "Event crypto adapter producers");
+ evt_dump("crypto adapter mode", "%s",
+ opt->crypto_adptr_mode ? "OP_FORWARD" : "OP_NEW");
+ evt_dump("nb_cryptodev", "%u", rte_cryptodev_count());
+ break;
}
evt_dump("prod_type", "%s", name);
}
diff --git a/app/test-eventdev/evt_test.h b/app/test-eventdev/evt_test.h
index f07d2c3336..50fa474ec2 100644
--- a/app/test-eventdev/evt_test.h
+++ b/app/test-eventdev/evt_test.h
@@ -29,6 +29,8 @@ typedef int (*evt_test_mempool_setup_t)
(struct evt_test *test, struct evt_options *opt);
typedef int (*evt_test_ethdev_setup_t)
(struct evt_test *test, struct evt_options *opt);
+typedef int (*evt_test_cryptodev_setup_t)
+ (struct evt_test *test, struct evt_options *opt);
typedef int (*evt_test_eventdev_setup_t)
(struct evt_test *test, struct evt_options *opt);
typedef int (*evt_test_launch_lcores_t)
@@ -39,6 +41,8 @@ typedef void (*evt_test_eventdev_destroy_t)
(struct evt_test *test, struct evt_options *opt);
typedef void (*evt_test_ethdev_destroy_t)
(struct evt_test *test, struct evt_options *opt);
+typedef void (*evt_test_cryptodev_destroy_t)
+ (struct evt_test *test, struct evt_options *opt);
typedef void (*evt_test_mempool_destroy_t)
(struct evt_test *test, struct evt_options *opt);
typedef void (*evt_test_destroy_t)
@@ -52,10 +56,12 @@ struct evt_test_ops {
evt_test_mempool_setup_t mempool_setup;
evt_test_ethdev_setup_t ethdev_setup;
evt_test_eventdev_setup_t eventdev_setup;
+ evt_test_cryptodev_setup_t cryptodev_setup;
evt_test_launch_lcores_t launch_lcores;
evt_test_result_t test_result;
evt_test_eventdev_destroy_t eventdev_destroy;
evt_test_ethdev_destroy_t ethdev_destroy;
+ evt_test_cryptodev_destroy_t cryptodev_destroy;
evt_test_mempool_destroy_t mempool_destroy;
evt_test_destroy_t test_destroy;
};
diff --git a/app/test-eventdev/test_perf_atq.c b/app/test-eventdev/test_perf_atq.c
index 8fd51004ee..dbb1dc8c0c 100644
--- a/app/test-eventdev/test_perf_atq.c
+++ b/app/test-eventdev/test_perf_atq.c
@@ -48,6 +48,22 @@ perf_atq_worker(void *arg, const int enable_fwd_latency)
continue;
}
+ if (prod_crypto_type &&
+ (ev.event_type == RTE_EVENT_TYPE_CRYPTODEV)) {
+ struct rte_crypto_op *op = ev.event_ptr;
+
+ if (op->status == RTE_CRYPTO_OP_STATUS_SUCCESS) {
+ if (op->sym->m_dst == NULL)
+ ev.event_ptr = op->sym->m_src;
+ else
+ ev.event_ptr = op->sym->m_dst;
+ rte_crypto_op_free(op);
+ } else {
+ rte_crypto_op_free(op);
+ continue;
+ }
+ }
+
if (enable_fwd_latency && !prod_timer_type)
/* first stage in pipeline, mark ts to compute fwd latency */
atq_mark_fwd_latency(&ev);
@@ -87,6 +103,25 @@ perf_atq_worker_burst(void *arg, const int enable_fwd_latency)
}
for (i = 0; i < nb_rx; i++) {
+ if (prod_crypto_type &&
+ (ev[i].event_type == RTE_EVENT_TYPE_CRYPTODEV)) {
+ struct rte_crypto_op *op = ev[i].event_ptr;
+
+ if (op->status ==
+ RTE_CRYPTO_OP_STATUS_SUCCESS) {
+ if (op->sym->m_dst == NULL)
+ ev[i].event_ptr =
+ op->sym->m_src;
+ else
+ ev[i].event_ptr =
+ op->sym->m_dst;
+ rte_crypto_op_free(op);
+ } else {
+ rte_crypto_op_free(op);
+ continue;
+ }
+ }
+
if (enable_fwd_latency && !prod_timer_type) {
rte_prefetch0(ev[i+1].event_ptr);
/* first stage in pipeline.
@@ -254,6 +289,20 @@ perf_atq_eventdev_setup(struct evt_test *test, struct evt_options *opt)
return ret;
}
}
+ } else if (opt->prod_type == EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR) {
+ uint8_t cdev_id, cdev_count;
+
+ cdev_count = rte_cryptodev_count();
+ for (cdev_id = 0; cdev_id < cdev_count; cdev_id++) {
+ ret = rte_cryptodev_start(cdev_id);
+ if (ret) {
+ evt_err("Failed to start cryptodev %u",
+ cdev_id);
+ return ret;
+ }
+ }
+
+ rte_event_crypto_adapter_start(t->crypto_adptr.id);
}
return 0;
@@ -295,12 +344,14 @@ static const struct evt_test_ops perf_atq = {
.opt_dump = perf_atq_opt_dump,
.test_setup = perf_test_setup,
.ethdev_setup = perf_ethdev_setup,
+ .cryptodev_setup = perf_cryptodev_setup,
.mempool_setup = perf_mempool_setup,
.eventdev_setup = perf_atq_eventdev_setup,
.launch_lcores = perf_atq_launch_lcores,
.eventdev_destroy = perf_eventdev_destroy,
.mempool_destroy = perf_mempool_destroy,
.ethdev_destroy = perf_ethdev_destroy,
+ .cryptodev_destroy = perf_cryptodev_destroy,
.test_result = perf_test_result,
.test_destroy = perf_test_destroy,
};
diff --git a/app/test-eventdev/test_perf_common.c b/app/test-eventdev/test_perf_common.c
index 9b73874151..fe734edd7c 100644
--- a/app/test-eventdev/test_perf_common.c
+++ b/app/test-eventdev/test_perf_common.c
@@ -6,6 +6,8 @@
#include "test_perf_common.h"
+#define NB_CRYPTODEV_DESCRIPTORS 128
+
int
perf_test_result(struct evt_test *test, struct evt_options *opt)
{
@@ -272,6 +274,121 @@ perf_event_timer_producer_burst(void *arg)
return 0;
}
+static inline void
+crypto_adapter_enq_op_new(struct prod_data *p)
+{
+ struct test_perf *t = p->t;
+ const uint32_t nb_flows = t->nb_flows;
+ const uint64_t nb_pkts = t->nb_pkts;
+ struct rte_mempool *pool = t->pool;
+ struct rte_crypto_sym_op *sym_op;
+ struct evt_options *opt = t->opt;
+ uint32_t flow_counter = 0;
+ struct rte_crypto_op *op;
+ struct rte_mbuf *m;
+ uint64_t count = 0;
+ uint16_t len;
+
+ if (opt->verbose_level > 1)
+ printf("%s(): lcore %d queue %d cdev_id %u cdev_qp_id %u\n",
+ __func__, rte_lcore_id(), p->queue_id, p->cdev_id,
+ p->cdev_qp_id);
+
+ len = opt->mbuf_sz ? opt->mbuf_sz : RTE_ETHER_MIN_LEN;
+
+ while (count < nb_pkts && t->done == false) {
+ m = rte_pktmbuf_alloc(pool);
+ if (m == NULL)
+ continue;
+
+ rte_pktmbuf_append(m, len);
+ op = rte_crypto_op_alloc(t->crypto_adptr.op_pool,
+ RTE_CRYPTO_OP_TYPE_SYMMETRIC);
+ sym_op = op->sym;
+ sym_op->m_src = m;
+ sym_op->cipher.data.offset = 0;
+ sym_op->cipher.data.length = len;
+ rte_crypto_op_attach_sym_session(
+ op, p->crypto_sess[flow_counter++ % nb_flows]);
+ while (rte_cryptodev_enqueue_burst(p->cdev_id, p->cdev_qp_id,
+ &op, 1) != 1) {
+ if (t->done)
+ break;
+ rte_pause();
+ }
+ count++;
+ }
+}
+
+static inline void
+crypto_adapter_enq_op_fwd(struct prod_data *p)
+{
+ const uint8_t dev_id = p->dev_id;
+ const uint8_t port = p->port_id;
+ struct test_perf *t = p->t;
+ const uint32_t nb_flows = t->nb_flows;
+ const uint64_t nb_pkts = t->nb_pkts;
+ struct rte_mempool *pool = t->pool;
+ struct evt_options *opt = t->opt;
+ struct rte_crypto_sym_op *sym_op;
+ uint32_t flow_counter = 0;
+ struct rte_crypto_op *op;
+ struct rte_event ev;
+ struct rte_mbuf *m;
+ uint64_t count = 0;
+ uint16_t len;
+
+ if (opt->verbose_level > 1)
+ printf("%s(): lcore %d port %d queue %d cdev_id %u cdev_qp_id %u\n",
+ __func__, rte_lcore_id(), port, p->queue_id, p->cdev_id,
+ p->cdev_qp_id);
+
+ ev.event = 0;
+ ev.op = RTE_EVENT_OP_NEW;
+ ev.queue_id = p->queue_id;
+ ev.sched_type = RTE_SCHED_TYPE_ATOMIC;
+ ev.event_type = RTE_EVENT_TYPE_CPU;
+ len = opt->mbuf_sz ? opt->mbuf_sz : RTE_ETHER_MIN_LEN;
+
+ while (count < nb_pkts && t->done == false) {
+ m = rte_pktmbuf_alloc(pool);
+ if (m == NULL)
+ continue;
+
+ rte_pktmbuf_append(m, len);
+ op = rte_crypto_op_alloc(t->crypto_adptr.op_pool,
+ RTE_CRYPTO_OP_TYPE_SYMMETRIC);
+ sym_op = op->sym;
+ sym_op->m_src = m;
+ sym_op->cipher.data.offset = 0;
+ sym_op->cipher.data.length = len;
+ rte_crypto_op_attach_sym_session(
+ op, p->crypto_sess[flow_counter++ % nb_flows]);
+ ev.event_ptr = op;
+ while (rte_event_crypto_adapter_enqueue(dev_id, port, &ev, 1) !=
+ 1) {
+ if (t->done)
+ break;
+ rte_pause();
+ }
+ count++;
+ }
+}
+
+static inline int
+perf_event_crypto_producer(void *arg)
+{
+ struct prod_data *p = arg;
+ struct evt_options *opt = p->t->opt;
+
+ if (opt->crypto_adptr_mode == RTE_EVENT_CRYPTO_ADAPTER_OP_NEW)
+ crypto_adapter_enq_op_new(p);
+ else
+ crypto_adapter_enq_op_fwd(p);
+
+ return 0;
+}
+
static int
perf_producer_wrapper(void *arg)
{
@@ -298,6 +415,8 @@ perf_producer_wrapper(void *arg)
else if (t->opt->prod_type == EVT_PROD_TYPE_EVENT_TIMER_ADPTR &&
t->opt->timdev_use_burst)
return perf_event_timer_producer_burst(arg);
+ else if (t->opt->prod_type == EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR)
+ return perf_event_crypto_producer(arg);
return 0;
}
@@ -405,8 +524,10 @@ perf_launch_lcores(struct evt_test *test, struct evt_options *opt,
if (remaining <= 0) {
t->result = EVT_TEST_SUCCESS;
if (opt->prod_type == EVT_PROD_TYPE_SYNT ||
- opt->prod_type ==
- EVT_PROD_TYPE_EVENT_TIMER_ADPTR) {
+ opt->prod_type ==
+ EVT_PROD_TYPE_EVENT_TIMER_ADPTR ||
+ opt->prod_type ==
+ EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR) {
t->done = true;
break;
}
@@ -415,7 +536,8 @@ perf_launch_lcores(struct evt_test *test, struct evt_options *opt,
if (new_cycles - dead_lock_cycles > dead_lock_sample &&
(opt->prod_type == EVT_PROD_TYPE_SYNT ||
- opt->prod_type == EVT_PROD_TYPE_EVENT_TIMER_ADPTR)) {
+ opt->prod_type == EVT_PROD_TYPE_EVENT_TIMER_ADPTR ||
+ opt->prod_type == EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR)) {
remaining = t->outstand_pkts - processed_pkts(t);
if (dead_lock_remaining == remaining) {
rte_event_dev_dump(opt->dev_id, stdout);
@@ -537,6 +659,95 @@ perf_event_timer_adapter_setup(struct test_perf *t)
return 0;
}
+static int
+perf_event_crypto_adapter_setup(struct test_perf *t,
+ struct rte_event_port_conf port_conf)
+{
+ struct evt_options *opt = t->opt;
+ uint8_t cdev_id, cdev_count;
+ int ret;
+
+ t->crypto_adptr.id = 0;
+ ret = rte_event_crypto_adapter_create(t->crypto_adptr.id, opt->dev_id,
+ &port_conf, 0);
+ if (ret)
+ return ret;
+
+ cdev_count = rte_cryptodev_count();
+ for (cdev_id = 0; cdev_id < cdev_count; cdev_id++) {
+ uint32_t cap;
+
+ ret = rte_event_crypto_adapter_caps_get(opt->dev_id, cdev_id,
+ &cap);
+ if (ret) {
+ evt_err("Failed to get crypto adapter capabilities");
+ return ret;
+ }
+
+ if (((opt->crypto_adptr_mode ==
+ RTE_EVENT_CRYPTO_ADAPTER_OP_NEW) &&
+ !(cap &
+ RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_OP_NEW)) ||
+ ((opt->crypto_adptr_mode ==
+ RTE_EVENT_CRYPTO_ADAPTER_OP_FORWARD) &&
+ !(cap &
+ RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_OP_FWD))) {
+ evt_err("crypto adapter %s mode unsupported\n",
+ opt->crypto_adptr_mode ? "OP_FORWARD" :
+ "OP_NEW");
+ return -EINVAL;
+ }
+
+ if (!(cap &
+ RTE_EVENT_CRYPTO_ADAPTER_CAP_SESSION_PRIVATE_DATA)) {
+ evt_err("Storing crypto session not supported");
+ return -EINVAL;
+ }
+
+ if (cap &
+ RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_QP_EV_BIND) {
+ struct rte_event response_info = {0};
+
+ ret = rte_event_crypto_adapter_queue_pair_add(
+ t->crypto_adptr.id, cdev_id, -1,
+ &response_info);
+ } else {
+ ret = rte_event_crypto_adapter_queue_pair_add(
+ t->crypto_adptr.id, cdev_id, -1, NULL);
+ }
+ if (ret)
+ return ret;
+ }
+
+ return 0;
+}
+
+static struct rte_cryptodev_sym_session *
+cryptodev_session_create(struct prod_data *p, struct test_perf *t)
+{
+ struct rte_crypto_sym_xform cipher_xform;
+ struct rte_cryptodev_sym_session *sess;
+
+ cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
+ cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
+ cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
+ cipher_xform.next = NULL;
+
+ sess = rte_cryptodev_sym_session_create(t->crypto_adptr.sess_pool);
+ if (sess == NULL) {
+ evt_err("Failed to create sym session");
+ return NULL;
+ }
+
+ if (rte_cryptodev_sym_session_init(p->cdev_id, sess, &cipher_xform,
+ t->crypto_adptr.sess_priv_pool)) {
+ evt_err("Failed to init session");
+ return NULL;
+ }
+
+ return sess;
+}
+
int
perf_event_dev_port_setup(struct evt_test *test, struct evt_options *opt,
uint8_t stride, uint8_t nb_queues,
@@ -598,6 +809,55 @@ perf_event_dev_port_setup(struct evt_test *test, struct evt_options *opt,
ret = perf_event_timer_adapter_setup(t);
if (ret)
return ret;
+ } else if (opt->prod_type == EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR) {
+ uint8_t cdev_id = 0;
+ uint16_t qp_id = 0;
+
+ prod = 0;
+ for (; port < perf_nb_event_ports(opt); port++) {
+ struct rte_cryptodev_sym_session *crypto_sess;
+ union rte_event_crypto_metadata m_data;
+ struct prod_data *p = &t->prod[port];
+ uint32_t flow_id;
+
+ if (qp_id == rte_cryptodev_queue_pair_count(cdev_id)) {
+ cdev_id++;
+ qp_id = 0;
+ }
+
+ p->dev_id = opt->dev_id;
+ p->port_id = port;
+ p->queue_id = prod * stride;
+ p->cdev_id = cdev_id;
+ p->cdev_qp_id = qp_id;
+ p->crypto_sess = rte_zmalloc_socket(
+ NULL, sizeof(crypto_sess) * t->nb_flows,
+ RTE_CACHE_LINE_SIZE, opt->socket_id);
+
+ m_data.request_info.cdev_id = p->cdev_id;
+ m_data.request_info.queue_pair_id = p->cdev_qp_id;
+ m_data.response_info.op = RTE_EVENT_OP_NEW;
+ m_data.response_info.sched_type = RTE_SCHED_TYPE_ATOMIC;
+ m_data.response_info.event_type = RTE_EVENT_TYPE_CPU;
+ m_data.response_info.queue_id = p->queue_id;
+ for (flow_id = 0; flow_id < t->nb_flows; flow_id++) {
+ crypto_sess = cryptodev_session_create(p, t);
+ if (crypto_sess == NULL)
+ return -ENOMEM;
+
+ m_data.response_info.flow_id = flow_id;
+ rte_cryptodev_sym_session_set_user_data(
+ crypto_sess, &m_data, sizeof(m_data));
+ p->crypto_sess[flow_id] = crypto_sess;
+ }
+ p->t = t;
+ qp_id++;
+ prod++;
+ }
+
+ ret = perf_event_crypto_adapter_setup(t, *port_conf);
+ if (ret)
+ return ret;
} else {
prod = 0;
for ( ; port < perf_nb_event_ports(opt); port++) {
@@ -659,7 +919,8 @@ perf_opt_check(struct evt_options *opt, uint64_t nb_queues)
}
if (opt->prod_type == EVT_PROD_TYPE_SYNT ||
- opt->prod_type == EVT_PROD_TYPE_EVENT_TIMER_ADPTR) {
+ opt->prod_type == EVT_PROD_TYPE_EVENT_TIMER_ADPTR ||
+ opt->prod_type == EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR) {
/* Validate producer lcores */
if (evt_lcores_has_overlap(opt->plcores,
rte_get_main_lcore())) {
@@ -767,8 +1028,7 @@ perf_ethdev_setup(struct evt_test *test, struct evt_options *opt)
},
};
- if (opt->prod_type == EVT_PROD_TYPE_SYNT ||
- opt->prod_type == EVT_PROD_TYPE_EVENT_TIMER_ADPTR)
+ if (opt->prod_type != EVT_PROD_TYPE_ETH_RX_ADPTR)
return 0;
if (!rte_eth_dev_count_avail()) {
@@ -841,6 +1101,139 @@ void perf_ethdev_destroy(struct evt_test *test, struct evt_options *opt)
}
}
+int
+perf_cryptodev_setup(struct evt_test *test, struct evt_options *opt)
+{
+ uint8_t cdev_count, cdev_id, nb_plcores, nb_qps;
+ struct test_perf *t = evt_test_priv(test);
+ unsigned int max_session_size;
+ uint32_t nb_sessions;
+ int ret;
+
+ if (opt->prod_type != EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR)
+ return 0;
+
+ cdev_count = rte_cryptodev_count();
+ if (cdev_count == 0) {
+ evt_err("No crypto devices available\n");
+ return -ENODEV;
+ }
+
+ t->crypto_adptr.op_pool = rte_crypto_op_pool_create(
+ "crypto_op_pool", RTE_CRYPTO_OP_TYPE_SYMMETRIC, opt->pool_sz,
+ 128, 0, rte_socket_id());
+ if (t->crypto_adptr.op_pool == NULL) {
+ evt_err("Failed to create crypto op pool");
+ return -ENOMEM;
+ }
+
+ nb_sessions = evt_nr_active_lcores(opt->plcores) * t->nb_flows;
+ t->crypto_adptr.sess_pool = rte_cryptodev_sym_session_pool_create(
+ "ca_sess_pool", nb_sessions, 0, 0,
+ sizeof(union rte_event_crypto_metadata), SOCKET_ID_ANY);
+ if (t->crypto_adptr.sess_pool == NULL) {
+ evt_err("Failed to create sym session pool");
+ ret = -ENOMEM;
+ goto err;
+ }
+
+ max_session_size = 0;
+ for (cdev_id = 0; cdev_id < cdev_count; cdev_id++) {
+ unsigned int session_size;
+
+ session_size =
+ rte_cryptodev_sym_get_private_session_size(cdev_id);
+ if (session_size > max_session_size)
+ max_session_size = session_size;
+ }
+ max_session_size += sizeof(union rte_event_crypto_metadata);
+ t->crypto_adptr.sess_priv_pool = rte_mempool_create(
+ "ca_sess_priv_pool", nb_sessions, max_session_size, 0, 0, NULL,
+ NULL, NULL, NULL, SOCKET_ID_ANY, 0);
+ if (t->crypto_adptr.sess_priv_pool == NULL) {
+ evt_err("failed to create sym session private pool");
+ ret = -ENOMEM;
+ goto err;
+ }
+
+ nb_plcores = evt_nr_active_lcores(opt->plcores);
+ nb_qps = (nb_plcores % cdev_count) ? (nb_plcores / cdev_count) + 1 :
+ nb_plcores / cdev_count;
+ for (cdev_id = 0; cdev_id < cdev_count; cdev_id++) {
+ struct rte_cryptodev_qp_conf qp_conf;
+ struct rte_cryptodev_config conf;
+ struct rte_cryptodev_info info;
+ int qp_id;
+
+ rte_cryptodev_info_get(cdev_id, &info);
+ if (nb_qps > info.max_nb_queue_pairs) {
+ evt_err("Not enough queue pairs per cryptodev (%u)",
+ nb_qps);
+ ret = -EINVAL;
+ goto err;
+ }
+
+ conf.nb_queue_pairs = nb_qps;
+ conf.socket_id = SOCKET_ID_ANY;
+ conf.ff_disable = RTE_CRYPTODEV_FF_SECURITY;
+
+ ret = rte_cryptodev_configure(cdev_id, &conf);
+ if (ret) {
+ evt_err("Failed to configure cryptodev (%u)", cdev_id);
+ goto err;
+ }
+
+ qp_conf.nb_descriptors = NB_CRYPTODEV_DESCRIPTORS;
+ qp_conf.mp_session = t->crypto_adptr.sess_pool;
+ qp_conf.mp_session_private = t->crypto_adptr.sess_priv_pool;
+
+ for (qp_id = 0; qp_id < conf.nb_queue_pairs; qp_id++) {
+ ret = rte_cryptodev_queue_pair_setup(
+ cdev_id, qp_id, &qp_conf,
+ rte_cryptodev_socket_id(cdev_id));
+ if (ret) {
+ evt_err("Failed to setup queue pairs on cryptodev %u\n",
+ cdev_id);
+ goto err;
+ }
+ }
+ }
+
+ return 0;
+err:
+ rte_mempool_free(t->crypto_adptr.op_pool);
+ rte_mempool_free(t->crypto_adptr.sess_pool);
+ rte_mempool_free(t->crypto_adptr.sess_priv_pool);
+
+ return ret;
+}
+
+void
+perf_cryptodev_destroy(struct evt_test *test, struct evt_options *opt)
+{
+ uint8_t cdev_id, cdev_count = rte_cryptodev_count();
+ struct test_perf *t = evt_test_priv(test);
+
+ RTE_SET_USED(opt);
+
+ if (opt->prod_type != EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR)
+ return;
+
+ rte_event_crypto_adapter_stop(t->crypto_adptr.id);
+
+ for (cdev_id = 0; cdev_id < cdev_count; cdev_id++) {
+ rte_cryptodev_stop(cdev_id);
+ rte_event_crypto_adapter_queue_pair_del(t->crypto_adptr.id,
+ cdev_id, -1);
+ }
+
+ rte_event_crypto_adapter_free(t->crypto_adptr.id);
+
+ rte_mempool_free(t->crypto_adptr.op_pool);
+ rte_mempool_free(t->crypto_adptr.sess_pool);
+ rte_mempool_free(t->crypto_adptr.sess_priv_pool);
+}
+
int
perf_mempool_setup(struct evt_test *test, struct evt_options *opt)
{
diff --git a/app/test-eventdev/test_perf_common.h b/app/test-eventdev/test_perf_common.h
index 14dcf80429..d9ad3a0b0d 100644
--- a/app/test-eventdev/test_perf_common.h
+++ b/app/test-eventdev/test_perf_common.h
@@ -9,9 +9,11 @@
#include <stdbool.h>
#include <unistd.h>
+#include <rte_cryptodev.h>
#include <rte_cycles.h>
#include <rte_ethdev.h>
#include <rte_eventdev.h>
+#include <rte_event_crypto_adapter.h>
#include <rte_event_eth_rx_adapter.h>
#include <rte_event_timer_adapter.h>
#include <rte_lcore.h>
@@ -37,9 +39,18 @@ struct prod_data {
uint8_t dev_id;
uint8_t port_id;
uint8_t queue_id;
+ uint8_t cdev_id;
+ uint16_t cdev_qp_id;
+ struct rte_cryptodev_sym_session **crypto_sess;
struct test_perf *t;
} __rte_cache_aligned;
+struct crypto_adptr_data {
+ uint8_t id;
+ struct rte_mempool *op_pool;
+ struct rte_mempool *sess_pool;
+ struct rte_mempool *sess_priv_pool;
+};
struct test_perf {
/* Don't change the offset of "done". Signal handler use this memory
@@ -58,6 +69,7 @@ struct test_perf {
uint8_t sched_type_list[EVT_MAX_STAGES] __rte_cache_aligned;
struct rte_event_timer_adapter *timer_adptr[
RTE_EVENT_TIMER_ADAPTER_NUM_MAX] __rte_cache_aligned;
+ struct crypto_adptr_data crypto_adptr;
} __rte_cache_aligned;
struct perf_elt {
@@ -81,6 +93,8 @@ struct perf_elt {
const uint8_t port = w->port_id;\
const uint8_t prod_timer_type = \
opt->prod_type == EVT_PROD_TYPE_EVENT_TIMER_ADPTR;\
+ const uint8_t prod_crypto_type = \
+ opt->prod_type == EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR;\
uint8_t *const sched_type_list = &t->sched_type_list[0];\
struct rte_mempool *const pool = t->pool;\
const uint8_t nb_stages = t->opt->nb_stages;\
@@ -154,6 +168,7 @@ int perf_test_result(struct evt_test *test, struct evt_options *opt);
int perf_opt_check(struct evt_options *opt, uint64_t nb_queues);
int perf_test_setup(struct evt_test *test, struct evt_options *opt);
int perf_ethdev_setup(struct evt_test *test, struct evt_options *opt);
+int perf_cryptodev_setup(struct evt_test *test, struct evt_options *opt);
int perf_mempool_setup(struct evt_test *test, struct evt_options *opt);
int perf_event_dev_port_setup(struct evt_test *test, struct evt_options *opt,
uint8_t stride, uint8_t nb_queues,
@@ -164,6 +179,7 @@ int perf_launch_lcores(struct evt_test *test, struct evt_options *opt,
void perf_opt_dump(struct evt_options *opt, uint8_t nb_queues);
void perf_test_destroy(struct evt_test *test, struct evt_options *opt);
void perf_eventdev_destroy(struct evt_test *test, struct evt_options *opt);
+void perf_cryptodev_destroy(struct evt_test *test, struct evt_options *opt);
void perf_ethdev_destroy(struct evt_test *test, struct evt_options *opt);
void perf_mempool_destroy(struct evt_test *test, struct evt_options *opt);
diff --git a/app/test-eventdev/test_perf_queue.c b/app/test-eventdev/test_perf_queue.c
index f4ea3a795f..5657c8b3cd 100644
--- a/app/test-eventdev/test_perf_queue.c
+++ b/app/test-eventdev/test_perf_queue.c
@@ -49,6 +49,23 @@ perf_queue_worker(void *arg, const int enable_fwd_latency)
rte_pause();
continue;
}
+
+ if (prod_crypto_type &&
+ (ev.event_type == RTE_EVENT_TYPE_CRYPTODEV)) {
+ struct rte_crypto_op *op = ev.event_ptr;
+
+ if (op->status == RTE_CRYPTO_OP_STATUS_SUCCESS) {
+ if (op->sym->m_dst == NULL)
+ ev.event_ptr = op->sym->m_src;
+ else
+ ev.event_ptr = op->sym->m_dst;
+ rte_crypto_op_free(op);
+ } else {
+ rte_crypto_op_free(op);
+ continue;
+ }
+ }
+
if (enable_fwd_latency && !prod_timer_type)
/* first q in pipeline, mark timestamp to compute fwd latency */
mark_fwd_latency(&ev, nb_stages);
@@ -88,6 +105,25 @@ perf_queue_worker_burst(void *arg, const int enable_fwd_latency)
}
for (i = 0; i < nb_rx; i++) {
+ if (prod_crypto_type &&
+ (ev[i].event_type == RTE_EVENT_TYPE_CRYPTODEV)) {
+ struct rte_crypto_op *op = ev[i].event_ptr;
+
+ if (op->status ==
+ RTE_CRYPTO_OP_STATUS_SUCCESS) {
+ if (op->sym->m_dst == NULL)
+ ev[i].event_ptr =
+ op->sym->m_src;
+ else
+ ev[i].event_ptr =
+ op->sym->m_dst;
+ rte_crypto_op_free(op);
+ } else {
+ rte_crypto_op_free(op);
+ continue;
+ }
+ }
+
if (enable_fwd_latency && !prod_timer_type) {
rte_prefetch0(ev[i+1].event_ptr);
/* first queue in pipeline.
@@ -269,6 +305,20 @@ perf_queue_eventdev_setup(struct evt_test *test, struct evt_options *opt)
return ret;
}
}
+ } else if (opt->prod_type == EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR) {
+ uint8_t cdev_id, cdev_count;
+
+ cdev_count = rte_cryptodev_count();
+ for (cdev_id = 0; cdev_id < cdev_count; cdev_id++) {
+ ret = rte_cryptodev_start(cdev_id);
+ if (ret) {
+ evt_err("Failed to start cryptodev %u",
+ cdev_id);
+ return ret;
+ }
+ }
+
+ rte_event_crypto_adapter_start(t->crypto_adptr.id);
}
return 0;
@@ -311,11 +361,13 @@ static const struct evt_test_ops perf_queue = {
.test_setup = perf_test_setup,
.mempool_setup = perf_mempool_setup,
.ethdev_setup = perf_ethdev_setup,
+ .cryptodev_setup = perf_cryptodev_setup,
.eventdev_setup = perf_queue_eventdev_setup,
.launch_lcores = perf_queue_launch_lcores,
.eventdev_destroy = perf_eventdev_destroy,
.mempool_destroy = perf_mempool_destroy,
.ethdev_destroy = perf_ethdev_destroy,
+ .cryptodev_destroy = perf_cryptodev_destroy,
.test_result = perf_test_result,
.test_destroy = perf_test_destroy,
};
diff --git a/doc/guides/tools/testeventdev.rst b/doc/guides/tools/testeventdev.rst
index 48efb9ea6e..f7d813226d 100644
--- a/doc/guides/tools/testeventdev.rst
+++ b/doc/guides/tools/testeventdev.rst
@@ -120,6 +120,10 @@ The following are the application command-line options:
Use burst mode event timer adapter as producer.
+* ``--prod_type_cryptodev``
+
+ Use crypto device as producer.
+
* ``--timer_tick_nsec``
Used to dictate number of nano seconds between bucket traversal of the
@@ -148,6 +152,11 @@ The following are the application command-line options:
timeout is out of the supported range of event device it will be
adjusted to the highest/lowest supported dequeue timeout supported.
+* ``--crypto_adptr_mode``
+
+ Set crypto adapter mode. Use 0 for OP_NEW (default) and 1 for
+ OP_FORWARD mode.
+
* ``--mbuf_sz``
Set packet mbuf size. Can be used to configure Jumbo Frames. Only
@@ -420,6 +429,7 @@ Supported application command line options are following::
--prod_type_ethdev
--prod_type_timerdev_burst
--prod_type_timerdev
+ --prod_type_cryptodev
--prod_enq_burst_sz
--timer_tick_nsec
--max_tmo_nsec
@@ -427,6 +437,7 @@ Supported application command line options are following::
--nb_timers
--nb_timer_adptrs
--deq_tmo_nsec
+ --crypto_adptr_mode
Example
^^^^^^^
@@ -529,12 +540,14 @@ Supported application command line options are following::
--prod_type_ethdev
--prod_type_timerdev_burst
--prod_type_timerdev
+ --prod_type_cryptodev
--timer_tick_nsec
--max_tmo_nsec
--expiry_nsec
--nb_timers
--nb_timer_adptrs
--deq_tmo_nsec
+ --crypto_adptr_mode
Example
^^^^^^^
--
2.25.1
^ permalink raw reply [flat|nested] 43+ messages in thread
* [PATCH v2] app/eventdev: add crypto producer mode
2021-12-20 19:53 [PATCH] app/eventdev: add crypto producer mode Shijith Thotton
@ 2021-12-21 8:51 ` Shijith Thotton
2021-12-30 11:56 ` Gujjar, Abhinandan S
2022-01-04 10:30 ` [PATCH v3] " Shijith Thotton
0 siblings, 2 replies; 43+ messages in thread
From: Shijith Thotton @ 2021-12-21 8:51 UTC (permalink / raw)
To: dev, Jerin Jacob
Cc: Shijith Thotton, anoobj, pbhagavatula, gakhil, abhinandan.gujjar
In crypto producer mode, producer core enqueues cryptodev with software
generated crypto ops and worker core dequeues crypto completion events
from the eventdev. Event crypto metadata used for above processing is
pre-populated in each crypto session.
Parameter --prod_type_cryptodev can be used to enable crypto producer
mode. Parameter --crypto_adptr_mode can be set to select the crypto
adapter mode, 0 for OP_NEW and 1 for OP_FORWARD.
This mode can be used to measure the performance of crypto adapter.
Example:
./dpdk-test-eventdev -l 0-2 -w <EVENTDEV> -w <CRYPTODEV> -- \
--prod_type_cryptodev --crypto_adptr_mode 1 --test=perf_atq \
--stlist=a --wlcores 1 --plcores 2
Signed-off-by: Shijith Thotton <sthotton@marvell.com>
---
v2:
* Fix RHEL compilation warning.
app/test-eventdev/evt_common.h | 3 +
app/test-eventdev/evt_main.c | 13 +-
app/test-eventdev/evt_options.c | 27 ++
app/test-eventdev/evt_options.h | 12 +
app/test-eventdev/evt_test.h | 6 +
app/test-eventdev/test_perf_atq.c | 51 ++++
app/test-eventdev/test_perf_common.c | 406 ++++++++++++++++++++++++++-
app/test-eventdev/test_perf_common.h | 16 ++
app/test-eventdev/test_perf_queue.c | 52 ++++
doc/guides/tools/testeventdev.rst | 13 +
10 files changed, 592 insertions(+), 7 deletions(-)
diff --git a/app/test-eventdev/evt_common.h b/app/test-eventdev/evt_common.h
index f466434459..2f301a7e79 100644
--- a/app/test-eventdev/evt_common.h
+++ b/app/test-eventdev/evt_common.h
@@ -7,6 +7,7 @@
#include <rte_common.h>
#include <rte_debug.h>
+#include <rte_event_crypto_adapter.h>
#include <rte_eventdev.h>
#include <rte_service.h>
@@ -39,6 +40,7 @@ enum evt_prod_type {
EVT_PROD_TYPE_SYNT, /* Producer type Synthetic i.e. CPU. */
EVT_PROD_TYPE_ETH_RX_ADPTR, /* Producer type Eth Rx Adapter. */
EVT_PROD_TYPE_EVENT_TIMER_ADPTR, /* Producer type Timer Adapter. */
+ EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR, /* Producer type Crypto Adapter. */
EVT_PROD_TYPE_MAX,
};
@@ -77,6 +79,7 @@ struct evt_options {
uint64_t timer_tick_nsec;
uint64_t optm_timer_tick_nsec;
enum evt_prod_type prod_type;
+ enum rte_event_crypto_adapter_mode crypto_adptr_mode;
};
static inline bool
diff --git a/app/test-eventdev/evt_main.c b/app/test-eventdev/evt_main.c
index 194c980c7a..cef0fb1382 100644
--- a/app/test-eventdev/evt_main.c
+++ b/app/test-eventdev/evt_main.c
@@ -161,12 +161,19 @@ main(int argc, char **argv)
goto mempool_destroy;
}
}
+ /* Test specific cryptodev setup */
+ if (test->ops.cryptodev_setup) {
+ if (test->ops.cryptodev_setup(test, &opt)) {
+ evt_err("%s: cryptodev setup failed", opt.test_name);
+ goto ethdev_destroy;
+ }
+ }
/* Test specific eventdev setup */
if (test->ops.eventdev_setup) {
if (test->ops.eventdev_setup(test, &opt)) {
evt_err("%s: eventdev setup failed", opt.test_name);
- goto ethdev_destroy;
+ goto cryptodev_destroy;
}
}
@@ -197,6 +204,10 @@ main(int argc, char **argv)
if (test->ops.eventdev_destroy)
test->ops.eventdev_destroy(test, &opt);
+cryptodev_destroy:
+ if (test->ops.cryptodev_destroy)
+ test->ops.cryptodev_destroy(test, &opt);
+
ethdev_destroy:
if (test->ops.ethdev_destroy)
test->ops.ethdev_destroy(test, &opt);
diff --git a/app/test-eventdev/evt_options.c b/app/test-eventdev/evt_options.c
index 753a7dbd7d..5ad1491020 100644
--- a/app/test-eventdev/evt_options.c
+++ b/app/test-eventdev/evt_options.c
@@ -122,6 +122,26 @@ evt_parse_timer_prod_type_burst(struct evt_options *opt,
return 0;
}
+static int
+evt_parse_crypto_prod_type(struct evt_options *opt,
+ const char *arg __rte_unused)
+{
+ opt->prod_type = EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR;
+ return 0;
+}
+
+static int
+evt_parse_crypto_adptr_mode(struct evt_options *opt, const char *arg)
+{
+ uint8_t mode;
+ int ret;
+
+ ret = parser_read_uint8(&mode, arg);
+ opt->crypto_adptr_mode = mode ? RTE_EVENT_CRYPTO_ADAPTER_OP_FORWARD :
+ RTE_EVENT_CRYPTO_ADAPTER_OP_NEW;
+ return ret;
+}
+
static int
evt_parse_test_name(struct evt_options *opt, const char *arg)
{
@@ -335,6 +355,7 @@ usage(char *program)
"\t--queue_priority : enable queue priority\n"
"\t--deq_tmo_nsec : global dequeue timeout\n"
"\t--prod_type_ethdev : use ethernet device as producer.\n"
+ "\t--prod_type_cryptodev : use crypto device as producer.\n"
"\t--prod_type_timerdev : use event timer device as producer.\n"
"\t expity_nsec would be the timeout\n"
"\t in ns.\n"
@@ -345,6 +366,8 @@ usage(char *program)
"\t--timer_tick_nsec : timer tick interval in ns.\n"
"\t--max_tmo_nsec : max timeout interval in ns.\n"
"\t--expiry_nsec : event timer expiry ns.\n"
+ "\t--crypto_adptr_mode : 0 for OP_NEW mode (default) and\n"
+ "\t 1 for OP_FORWARD mode.\n"
"\t--mbuf_sz : packet mbuf size.\n"
"\t--max_pkt_sz : max packet size.\n"
"\t--prod_enq_burst_sz : producer enqueue burst size.\n"
@@ -415,8 +438,10 @@ static struct option lgopts[] = {
{ EVT_QUEUE_PRIORITY, 0, 0, 0 },
{ EVT_DEQ_TMO_NSEC, 1, 0, 0 },
{ EVT_PROD_ETHDEV, 0, 0, 0 },
+ { EVT_PROD_CRYPTODEV, 0, 0, 0 },
{ EVT_PROD_TIMERDEV, 0, 0, 0 },
{ EVT_PROD_TIMERDEV_BURST, 0, 0, 0 },
+ { EVT_CRYPTO_ADPTR_MODE, 1, 0, 0 },
{ EVT_NB_TIMERS, 1, 0, 0 },
{ EVT_NB_TIMER_ADPTRS, 1, 0, 0 },
{ EVT_TIMER_TICK_NSEC, 1, 0, 0 },
@@ -455,8 +480,10 @@ evt_opts_parse_long(int opt_idx, struct evt_options *opt)
{ EVT_QUEUE_PRIORITY, evt_parse_queue_priority},
{ EVT_DEQ_TMO_NSEC, evt_parse_deq_tmo_nsec},
{ EVT_PROD_ETHDEV, evt_parse_eth_prod_type},
+ { EVT_PROD_CRYPTODEV, evt_parse_crypto_prod_type},
{ EVT_PROD_TIMERDEV, evt_parse_timer_prod_type},
{ EVT_PROD_TIMERDEV_BURST, evt_parse_timer_prod_type_burst},
+ { EVT_CRYPTO_ADPTR_MODE, evt_parse_crypto_adptr_mode},
{ EVT_NB_TIMERS, evt_parse_nb_timers},
{ EVT_NB_TIMER_ADPTRS, evt_parse_nb_timer_adptrs},
{ EVT_TIMER_TICK_NSEC, evt_parse_timer_tick_nsec},
diff --git a/app/test-eventdev/evt_options.h b/app/test-eventdev/evt_options.h
index 413d7092f0..2231c58801 100644
--- a/app/test-eventdev/evt_options.h
+++ b/app/test-eventdev/evt_options.h
@@ -9,6 +9,7 @@
#include <stdbool.h>
#include <rte_common.h>
+#include <rte_cryptodev.h>
#include <rte_ethdev.h>
#include <rte_eventdev.h>
#include <rte_lcore.h>
@@ -33,8 +34,10 @@
#define EVT_QUEUE_PRIORITY ("queue_priority")
#define EVT_DEQ_TMO_NSEC ("deq_tmo_nsec")
#define EVT_PROD_ETHDEV ("prod_type_ethdev")
+#define EVT_PROD_CRYPTODEV ("prod_type_cryptodev")
#define EVT_PROD_TIMERDEV ("prod_type_timerdev")
#define EVT_PROD_TIMERDEV_BURST ("prod_type_timerdev_burst")
+#define EVT_CRYPTO_ADPTR_MODE ("crypto_adptr_mode")
#define EVT_NB_TIMERS ("nb_timers")
#define EVT_NB_TIMER_ADPTRS ("nb_timer_adptrs")
#define EVT_TIMER_TICK_NSEC ("timer_tick_nsec")
@@ -249,6 +252,8 @@ evt_prod_id_to_name(enum evt_prod_type prod_type)
return "Ethdev Rx Adapter";
case EVT_PROD_TYPE_EVENT_TIMER_ADPTR:
return "Event timer adapter";
+ case EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR:
+ return "Event crypto adapter";
}
return "";
@@ -288,6 +293,13 @@ evt_dump_producer_type(struct evt_options *opt)
evt_dump("timer_tick_nsec", "%"PRIu64"",
opt->timer_tick_nsec);
break;
+ case EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR:
+ snprintf(name, EVT_PROD_MAX_NAME_LEN,
+ "Event crypto adapter producers");
+ evt_dump("crypto adapter mode", "%s",
+ opt->crypto_adptr_mode ? "OP_FORWARD" : "OP_NEW");
+ evt_dump("nb_cryptodev", "%u", rte_cryptodev_count());
+ break;
}
evt_dump("prod_type", "%s", name);
}
diff --git a/app/test-eventdev/evt_test.h b/app/test-eventdev/evt_test.h
index f07d2c3336..50fa474ec2 100644
--- a/app/test-eventdev/evt_test.h
+++ b/app/test-eventdev/evt_test.h
@@ -29,6 +29,8 @@ typedef int (*evt_test_mempool_setup_t)
(struct evt_test *test, struct evt_options *opt);
typedef int (*evt_test_ethdev_setup_t)
(struct evt_test *test, struct evt_options *opt);
+typedef int (*evt_test_cryptodev_setup_t)
+ (struct evt_test *test, struct evt_options *opt);
typedef int (*evt_test_eventdev_setup_t)
(struct evt_test *test, struct evt_options *opt);
typedef int (*evt_test_launch_lcores_t)
@@ -39,6 +41,8 @@ typedef void (*evt_test_eventdev_destroy_t)
(struct evt_test *test, struct evt_options *opt);
typedef void (*evt_test_ethdev_destroy_t)
(struct evt_test *test, struct evt_options *opt);
+typedef void (*evt_test_cryptodev_destroy_t)
+ (struct evt_test *test, struct evt_options *opt);
typedef void (*evt_test_mempool_destroy_t)
(struct evt_test *test, struct evt_options *opt);
typedef void (*evt_test_destroy_t)
@@ -52,10 +56,12 @@ struct evt_test_ops {
evt_test_mempool_setup_t mempool_setup;
evt_test_ethdev_setup_t ethdev_setup;
evt_test_eventdev_setup_t eventdev_setup;
+ evt_test_cryptodev_setup_t cryptodev_setup;
evt_test_launch_lcores_t launch_lcores;
evt_test_result_t test_result;
evt_test_eventdev_destroy_t eventdev_destroy;
evt_test_ethdev_destroy_t ethdev_destroy;
+ evt_test_cryptodev_destroy_t cryptodev_destroy;
evt_test_mempool_destroy_t mempool_destroy;
evt_test_destroy_t test_destroy;
};
diff --git a/app/test-eventdev/test_perf_atq.c b/app/test-eventdev/test_perf_atq.c
index 8fd51004ee..dbb1dc8c0c 100644
--- a/app/test-eventdev/test_perf_atq.c
+++ b/app/test-eventdev/test_perf_atq.c
@@ -48,6 +48,22 @@ perf_atq_worker(void *arg, const int enable_fwd_latency)
continue;
}
+ if (prod_crypto_type &&
+ (ev.event_type == RTE_EVENT_TYPE_CRYPTODEV)) {
+ struct rte_crypto_op *op = ev.event_ptr;
+
+ if (op->status == RTE_CRYPTO_OP_STATUS_SUCCESS) {
+ if (op->sym->m_dst == NULL)
+ ev.event_ptr = op->sym->m_src;
+ else
+ ev.event_ptr = op->sym->m_dst;
+ rte_crypto_op_free(op);
+ } else {
+ rte_crypto_op_free(op);
+ continue;
+ }
+ }
+
if (enable_fwd_latency && !prod_timer_type)
/* first stage in pipeline, mark ts to compute fwd latency */
atq_mark_fwd_latency(&ev);
@@ -87,6 +103,25 @@ perf_atq_worker_burst(void *arg, const int enable_fwd_latency)
}
for (i = 0; i < nb_rx; i++) {
+ if (prod_crypto_type &&
+ (ev[i].event_type == RTE_EVENT_TYPE_CRYPTODEV)) {
+ struct rte_crypto_op *op = ev[i].event_ptr;
+
+ if (op->status ==
+ RTE_CRYPTO_OP_STATUS_SUCCESS) {
+ if (op->sym->m_dst == NULL)
+ ev[i].event_ptr =
+ op->sym->m_src;
+ else
+ ev[i].event_ptr =
+ op->sym->m_dst;
+ rte_crypto_op_free(op);
+ } else {
+ rte_crypto_op_free(op);
+ continue;
+ }
+ }
+
if (enable_fwd_latency && !prod_timer_type) {
rte_prefetch0(ev[i+1].event_ptr);
/* first stage in pipeline.
@@ -254,6 +289,20 @@ perf_atq_eventdev_setup(struct evt_test *test, struct evt_options *opt)
return ret;
}
}
+ } else if (opt->prod_type == EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR) {
+ uint8_t cdev_id, cdev_count;
+
+ cdev_count = rte_cryptodev_count();
+ for (cdev_id = 0; cdev_id < cdev_count; cdev_id++) {
+ ret = rte_cryptodev_start(cdev_id);
+ if (ret) {
+ evt_err("Failed to start cryptodev %u",
+ cdev_id);
+ return ret;
+ }
+ }
+
+ rte_event_crypto_adapter_start(t->crypto_adptr.id);
}
return 0;
@@ -295,12 +344,14 @@ static const struct evt_test_ops perf_atq = {
.opt_dump = perf_atq_opt_dump,
.test_setup = perf_test_setup,
.ethdev_setup = perf_ethdev_setup,
+ .cryptodev_setup = perf_cryptodev_setup,
.mempool_setup = perf_mempool_setup,
.eventdev_setup = perf_atq_eventdev_setup,
.launch_lcores = perf_atq_launch_lcores,
.eventdev_destroy = perf_eventdev_destroy,
.mempool_destroy = perf_mempool_destroy,
.ethdev_destroy = perf_ethdev_destroy,
+ .cryptodev_destroy = perf_cryptodev_destroy,
.test_result = perf_test_result,
.test_destroy = perf_test_destroy,
};
diff --git a/app/test-eventdev/test_perf_common.c b/app/test-eventdev/test_perf_common.c
index 9b73874151..7b964ab8dc 100644
--- a/app/test-eventdev/test_perf_common.c
+++ b/app/test-eventdev/test_perf_common.c
@@ -6,6 +6,8 @@
#include "test_perf_common.h"
+#define NB_CRYPTODEV_DESCRIPTORS 128
+
int
perf_test_result(struct evt_test *test, struct evt_options *opt)
{
@@ -272,6 +274,121 @@ perf_event_timer_producer_burst(void *arg)
return 0;
}
+static inline void
+crypto_adapter_enq_op_new(struct prod_data *p)
+{
+ struct test_perf *t = p->t;
+ const uint32_t nb_flows = t->nb_flows;
+ const uint64_t nb_pkts = t->nb_pkts;
+ struct rte_mempool *pool = t->pool;
+ struct rte_crypto_sym_op *sym_op;
+ struct evt_options *opt = t->opt;
+ uint32_t flow_counter = 0;
+ struct rte_crypto_op *op;
+ struct rte_mbuf *m;
+ uint64_t count = 0;
+ uint16_t len;
+
+ if (opt->verbose_level > 1)
+ printf("%s(): lcore %d queue %d cdev_id %u cdev_qp_id %u\n",
+ __func__, rte_lcore_id(), p->queue_id, p->cdev_id,
+ p->cdev_qp_id);
+
+ len = opt->mbuf_sz ? opt->mbuf_sz : RTE_ETHER_MIN_LEN;
+
+ while (count < nb_pkts && t->done == false) {
+ m = rte_pktmbuf_alloc(pool);
+ if (m == NULL)
+ continue;
+
+ rte_pktmbuf_append(m, len);
+ op = rte_crypto_op_alloc(t->crypto_adptr.op_pool,
+ RTE_CRYPTO_OP_TYPE_SYMMETRIC);
+ sym_op = op->sym;
+ sym_op->m_src = m;
+ sym_op->cipher.data.offset = 0;
+ sym_op->cipher.data.length = len;
+ rte_crypto_op_attach_sym_session(
+ op, p->crypto_sess[flow_counter++ % nb_flows]);
+ while (rte_cryptodev_enqueue_burst(p->cdev_id, p->cdev_qp_id,
+ &op, 1) != 1) {
+ if (t->done)
+ break;
+ rte_pause();
+ }
+ count++;
+ }
+}
+
+static inline void
+crypto_adapter_enq_op_fwd(struct prod_data *p)
+{
+ const uint8_t dev_id = p->dev_id;
+ const uint8_t port = p->port_id;
+ struct test_perf *t = p->t;
+ const uint32_t nb_flows = t->nb_flows;
+ const uint64_t nb_pkts = t->nb_pkts;
+ struct rte_mempool *pool = t->pool;
+ struct evt_options *opt = t->opt;
+ struct rte_crypto_sym_op *sym_op;
+ uint32_t flow_counter = 0;
+ struct rte_crypto_op *op;
+ struct rte_event ev;
+ struct rte_mbuf *m;
+ uint64_t count = 0;
+ uint16_t len;
+
+ if (opt->verbose_level > 1)
+ printf("%s(): lcore %d port %d queue %d cdev_id %u cdev_qp_id %u\n",
+ __func__, rte_lcore_id(), port, p->queue_id, p->cdev_id,
+ p->cdev_qp_id);
+
+ ev.event = 0;
+ ev.op = RTE_EVENT_OP_NEW;
+ ev.queue_id = p->queue_id;
+ ev.sched_type = RTE_SCHED_TYPE_ATOMIC;
+ ev.event_type = RTE_EVENT_TYPE_CPU;
+ len = opt->mbuf_sz ? opt->mbuf_sz : RTE_ETHER_MIN_LEN;
+
+ while (count < nb_pkts && t->done == false) {
+ m = rte_pktmbuf_alloc(pool);
+ if (m == NULL)
+ continue;
+
+ rte_pktmbuf_append(m, len);
+ op = rte_crypto_op_alloc(t->crypto_adptr.op_pool,
+ RTE_CRYPTO_OP_TYPE_SYMMETRIC);
+ sym_op = op->sym;
+ sym_op->m_src = m;
+ sym_op->cipher.data.offset = 0;
+ sym_op->cipher.data.length = len;
+ rte_crypto_op_attach_sym_session(
+ op, p->crypto_sess[flow_counter++ % nb_flows]);
+ ev.event_ptr = op;
+ while (rte_event_crypto_adapter_enqueue(dev_id, port, &ev, 1) !=
+ 1) {
+ if (t->done)
+ break;
+ rte_pause();
+ }
+ count++;
+ }
+}
+
+static inline int
+perf_event_crypto_producer(void *arg)
+{
+ struct prod_data *p = arg;
+ struct evt_options *opt = p->t->opt;
+
+ if (opt->crypto_adptr_mode == RTE_EVENT_CRYPTO_ADAPTER_OP_NEW)
+ crypto_adapter_enq_op_new(p);
+ else
+ crypto_adapter_enq_op_fwd(p);
+
+ return 0;
+}
+
static int
perf_producer_wrapper(void *arg)
{
@@ -298,6 +415,8 @@ perf_producer_wrapper(void *arg)
else if (t->opt->prod_type == EVT_PROD_TYPE_EVENT_TIMER_ADPTR &&
t->opt->timdev_use_burst)
return perf_event_timer_producer_burst(arg);
+ else if (t->opt->prod_type == EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR)
+ return perf_event_crypto_producer(arg);
return 0;
}
@@ -405,8 +524,10 @@ perf_launch_lcores(struct evt_test *test, struct evt_options *opt,
if (remaining <= 0) {
t->result = EVT_TEST_SUCCESS;
if (opt->prod_type == EVT_PROD_TYPE_SYNT ||
- opt->prod_type ==
- EVT_PROD_TYPE_EVENT_TIMER_ADPTR) {
+ opt->prod_type ==
+ EVT_PROD_TYPE_EVENT_TIMER_ADPTR ||
+ opt->prod_type ==
+ EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR) {
t->done = true;
break;
}
@@ -415,7 +536,8 @@ perf_launch_lcores(struct evt_test *test, struct evt_options *opt,
if (new_cycles - dead_lock_cycles > dead_lock_sample &&
(opt->prod_type == EVT_PROD_TYPE_SYNT ||
- opt->prod_type == EVT_PROD_TYPE_EVENT_TIMER_ADPTR)) {
+ opt->prod_type == EVT_PROD_TYPE_EVENT_TIMER_ADPTR ||
+ opt->prod_type == EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR)) {
remaining = t->outstand_pkts - processed_pkts(t);
if (dead_lock_remaining == remaining) {
rte_event_dev_dump(opt->dev_id, stdout);
@@ -537,6 +659,96 @@ perf_event_timer_adapter_setup(struct test_perf *t)
return 0;
}
+static int
+perf_event_crypto_adapter_setup(struct test_perf *t,
+ struct rte_event_port_conf port_conf)
+{
+ struct evt_options *opt = t->opt;
+ uint8_t cdev_id, cdev_count;
+ int ret;
+
+ t->crypto_adptr.id = 0;
+ ret = rte_event_crypto_adapter_create(t->crypto_adptr.id, opt->dev_id,
+ &port_conf, 0);
+ if (ret)
+ return ret;
+
+ cdev_count = rte_cryptodev_count();
+ for (cdev_id = 0; cdev_id < cdev_count; cdev_id++) {
+ uint32_t cap;
+
+ ret = rte_event_crypto_adapter_caps_get(opt->dev_id, cdev_id,
+ &cap);
+ if (ret) {
+ evt_err("Failed to get crypto adapter capabilities");
+ return ret;
+ }
+
+ if (((opt->crypto_adptr_mode ==
+ RTE_EVENT_CRYPTO_ADAPTER_OP_NEW) &&
+ !(cap &
+ RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_OP_NEW)) ||
+ ((opt->crypto_adptr_mode ==
+ RTE_EVENT_CRYPTO_ADAPTER_OP_FORWARD) &&
+ !(cap &
+ RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_OP_FWD))) {
+ evt_err("crypto adapter %s mode unsupported\n",
+ opt->crypto_adptr_mode ? "OP_FORWARD" :
+ "OP_NEW");
+ return -EINVAL;
+ }
+
+ if (!(cap &
+ RTE_EVENT_CRYPTO_ADAPTER_CAP_SESSION_PRIVATE_DATA)) {
+ evt_err("Storing crypto session not supported");
+ return -EINVAL;
+ }
+
+ if (cap &
+ RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_QP_EV_BIND) {
+ struct rte_event response_info;
+
+ response_info.event = 0;
+ ret = rte_event_crypto_adapter_queue_pair_add(
+ t->crypto_adptr.id, cdev_id, -1,
+ &response_info);
+ } else {
+ ret = rte_event_crypto_adapter_queue_pair_add(
+ t->crypto_adptr.id, cdev_id, -1, NULL);
+ }
+ if (ret)
+ return ret;
+ }
+
+ return 0;
+}
+
+static struct rte_cryptodev_sym_session *
+cryptodev_session_create(struct prod_data *p, struct test_perf *t)
+{
+ struct rte_crypto_sym_xform cipher_xform;
+ struct rte_cryptodev_sym_session *sess;
+
+ cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
+ cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
+ cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
+ cipher_xform.next = NULL;
+
+ sess = rte_cryptodev_sym_session_create(t->crypto_adptr.sess_pool);
+ if (sess == NULL) {
+ evt_err("Failed to create sym session");
+ return NULL;
+ }
+
+ if (rte_cryptodev_sym_session_init(p->cdev_id, sess, &cipher_xform,
+ t->crypto_adptr.sess_priv_pool)) {
+ evt_err("Failed to init session");
+ return NULL;
+ }
+
+ return sess;
+}
+
int
perf_event_dev_port_setup(struct evt_test *test, struct evt_options *opt,
uint8_t stride, uint8_t nb_queues,
@@ -598,6 +810,55 @@ perf_event_dev_port_setup(struct evt_test *test, struct evt_options *opt,
ret = perf_event_timer_adapter_setup(t);
if (ret)
return ret;
+ } else if (opt->prod_type == EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR) {
+ uint8_t cdev_id = 0;
+ uint16_t qp_id = 0;
+
+ prod = 0;
+ for (; port < perf_nb_event_ports(opt); port++) {
+ struct rte_cryptodev_sym_session *crypto_sess;
+ union rte_event_crypto_metadata m_data;
+ struct prod_data *p = &t->prod[port];
+ uint32_t flow_id;
+
+ if (qp_id == rte_cryptodev_queue_pair_count(cdev_id)) {
+ cdev_id++;
+ qp_id = 0;
+ }
+
+ p->dev_id = opt->dev_id;
+ p->port_id = port;
+ p->queue_id = prod * stride;
+ p->cdev_id = cdev_id;
+ p->cdev_qp_id = qp_id;
+ p->crypto_sess = rte_zmalloc_socket(
+ NULL, sizeof(crypto_sess) * t->nb_flows,
+ RTE_CACHE_LINE_SIZE, opt->socket_id);
+
+ m_data.request_info.cdev_id = p->cdev_id;
+ m_data.request_info.queue_pair_id = p->cdev_qp_id;
+ m_data.response_info.op = RTE_EVENT_OP_NEW;
+ m_data.response_info.sched_type = RTE_SCHED_TYPE_ATOMIC;
+ m_data.response_info.event_type = RTE_EVENT_TYPE_CPU;
+ m_data.response_info.queue_id = p->queue_id;
+ for (flow_id = 0; flow_id < t->nb_flows; flow_id++) {
+ crypto_sess = cryptodev_session_create(p, t);
+ if (crypto_sess == NULL)
+ return -ENOMEM;
+
+ m_data.response_info.flow_id = flow_id;
+ rte_cryptodev_sym_session_set_user_data(
+ crypto_sess, &m_data, sizeof(m_data));
+ p->crypto_sess[flow_id] = crypto_sess;
+ }
+ p->t = t;
+ qp_id++;
+ prod++;
+ }
+
+ ret = perf_event_crypto_adapter_setup(t, *port_conf);
+ if (ret)
+ return ret;
} else {
prod = 0;
for ( ; port < perf_nb_event_ports(opt); port++) {
@@ -659,7 +920,8 @@ perf_opt_check(struct evt_options *opt, uint64_t nb_queues)
}
if (opt->prod_type == EVT_PROD_TYPE_SYNT ||
- opt->prod_type == EVT_PROD_TYPE_EVENT_TIMER_ADPTR) {
+ opt->prod_type == EVT_PROD_TYPE_EVENT_TIMER_ADPTR ||
+ opt->prod_type == EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR) {
/* Validate producer lcores */
if (evt_lcores_has_overlap(opt->plcores,
rte_get_main_lcore())) {
@@ -767,8 +1029,7 @@ perf_ethdev_setup(struct evt_test *test, struct evt_options *opt)
},
};
- if (opt->prod_type == EVT_PROD_TYPE_SYNT ||
- opt->prod_type == EVT_PROD_TYPE_EVENT_TIMER_ADPTR)
+ if (opt->prod_type != EVT_PROD_TYPE_ETH_RX_ADPTR)
return 0;
if (!rte_eth_dev_count_avail()) {
@@ -841,6 +1102,139 @@ void perf_ethdev_destroy(struct evt_test *test, struct evt_options *opt)
}
}
+int
+perf_cryptodev_setup(struct evt_test *test, struct evt_options *opt)
+{
+ uint8_t cdev_count, cdev_id, nb_plcores, nb_qps;
+ struct test_perf *t = evt_test_priv(test);
+ unsigned int max_session_size;
+ uint32_t nb_sessions;
+ int ret;
+
+ if (opt->prod_type != EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR)
+ return 0;
+
+ cdev_count = rte_cryptodev_count();
+ if (cdev_count == 0) {
+ evt_err("No crypto devices available\n");
+ return -ENODEV;
+ }
+
+ t->crypto_adptr.op_pool = rte_crypto_op_pool_create(
+ "crypto_op_pool", RTE_CRYPTO_OP_TYPE_SYMMETRIC, opt->pool_sz,
+ 128, 0, rte_socket_id());
+ if (t->crypto_adptr.op_pool == NULL) {
+ evt_err("Failed to create crypto op pool");
+ return -ENOMEM;
+ }
+
+ nb_sessions = evt_nr_active_lcores(opt->plcores) * t->nb_flows;
+ t->crypto_adptr.sess_pool = rte_cryptodev_sym_session_pool_create(
+ "ca_sess_pool", nb_sessions, 0, 0,
+ sizeof(union rte_event_crypto_metadata), SOCKET_ID_ANY);
+ if (t->crypto_adptr.sess_pool == NULL) {
+ evt_err("Failed to create sym session pool");
+ ret = -ENOMEM;
+ goto err;
+ }
+
+ max_session_size = 0;
+ for (cdev_id = 0; cdev_id < cdev_count; cdev_id++) {
+ unsigned int session_size;
+
+ session_size =
+ rte_cryptodev_sym_get_private_session_size(cdev_id);
+ if (session_size > max_session_size)
+ max_session_size = session_size;
+ }
+ max_session_size += sizeof(union rte_event_crypto_metadata);
+ t->crypto_adptr.sess_priv_pool = rte_mempool_create(
+ "ca_sess_priv_pool", nb_sessions, max_session_size, 0, 0, NULL,
+ NULL, NULL, NULL, SOCKET_ID_ANY, 0);
+ if (t->crypto_adptr.sess_priv_pool == NULL) {
+ evt_err("failed to create sym session private pool");
+ ret = -ENOMEM;
+ goto err;
+ }
+
+ nb_plcores = evt_nr_active_lcores(opt->plcores);
+ nb_qps = (nb_plcores % cdev_count) ? (nb_plcores / cdev_count) + 1 :
+ nb_plcores / cdev_count;
+ for (cdev_id = 0; cdev_id < cdev_count; cdev_id++) {
+ struct rte_cryptodev_qp_conf qp_conf;
+ struct rte_cryptodev_config conf;
+ struct rte_cryptodev_info info;
+ int qp_id;
+
+ rte_cryptodev_info_get(cdev_id, &info);
+ if (nb_qps > info.max_nb_queue_pairs) {
+ evt_err("Not enough queue pairs per cryptodev (%u)",
+ nb_qps);
+ ret = -EINVAL;
+ goto err;
+ }
+
+ conf.nb_queue_pairs = nb_qps;
+ conf.socket_id = SOCKET_ID_ANY;
+ conf.ff_disable = RTE_CRYPTODEV_FF_SECURITY;
+
+ ret = rte_cryptodev_configure(cdev_id, &conf);
+ if (ret) {
+ evt_err("Failed to configure cryptodev (%u)", cdev_id);
+ goto err;
+ }
+
+ qp_conf.nb_descriptors = NB_CRYPTODEV_DESCRIPTORS;
+ qp_conf.mp_session = t->crypto_adptr.sess_pool;
+ qp_conf.mp_session_private = t->crypto_adptr.sess_priv_pool;
+
+ for (qp_id = 0; qp_id < conf.nb_queue_pairs; qp_id++) {
+ ret = rte_cryptodev_queue_pair_setup(
+ cdev_id, qp_id, &qp_conf,
+ rte_cryptodev_socket_id(cdev_id));
+ if (ret) {
+ evt_err("Failed to setup queue pairs on cryptodev %u\n",
+ cdev_id);
+ goto err;
+ }
+ }
+ }
+
+ return 0;
+err:
+ rte_mempool_free(t->crypto_adptr.op_pool);
+ rte_mempool_free(t->crypto_adptr.sess_pool);
+ rte_mempool_free(t->crypto_adptr.sess_priv_pool);
+
+ return ret;
+}
+
+void
+perf_cryptodev_destroy(struct evt_test *test, struct evt_options *opt)
+{
+ uint8_t cdev_id, cdev_count = rte_cryptodev_count();
+ struct test_perf *t = evt_test_priv(test);
+
+ RTE_SET_USED(opt);
+
+ if (opt->prod_type != EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR)
+ return;
+
+ rte_event_crypto_adapter_stop(t->crypto_adptr.id);
+
+ for (cdev_id = 0; cdev_id < cdev_count; cdev_id++) {
+ rte_cryptodev_stop(cdev_id);
+ rte_event_crypto_adapter_queue_pair_del(t->crypto_adptr.id,
+ cdev_id, -1);
+ }
+
+ rte_event_crypto_adapter_free(t->crypto_adptr.id);
+
+ rte_mempool_free(t->crypto_adptr.op_pool);
+ rte_mempool_free(t->crypto_adptr.sess_pool);
+ rte_mempool_free(t->crypto_adptr.sess_priv_pool);
+}
+
int
perf_mempool_setup(struct evt_test *test, struct evt_options *opt)
{
diff --git a/app/test-eventdev/test_perf_common.h b/app/test-eventdev/test_perf_common.h
index 14dcf80429..d9ad3a0b0d 100644
--- a/app/test-eventdev/test_perf_common.h
+++ b/app/test-eventdev/test_perf_common.h
@@ -9,9 +9,11 @@
#include <stdbool.h>
#include <unistd.h>
+#include <rte_cryptodev.h>
#include <rte_cycles.h>
#include <rte_ethdev.h>
#include <rte_eventdev.h>
+#include <rte_event_crypto_adapter.h>
#include <rte_event_eth_rx_adapter.h>
#include <rte_event_timer_adapter.h>
#include <rte_lcore.h>
@@ -37,9 +39,18 @@ struct prod_data {
uint8_t dev_id;
uint8_t port_id;
uint8_t queue_id;
+ uint8_t cdev_id;
+ uint16_t cdev_qp_id;
+ struct rte_cryptodev_sym_session **crypto_sess;
struct test_perf *t;
} __rte_cache_aligned;
+struct crypto_adptr_data {
+ uint8_t id;
+ struct rte_mempool *op_pool;
+ struct rte_mempool *sess_pool;
+ struct rte_mempool *sess_priv_pool;
+};
struct test_perf {
/* Don't change the offset of "done". Signal handler use this memory
@@ -58,6 +69,7 @@ struct test_perf {
uint8_t sched_type_list[EVT_MAX_STAGES] __rte_cache_aligned;
struct rte_event_timer_adapter *timer_adptr[
RTE_EVENT_TIMER_ADAPTER_NUM_MAX] __rte_cache_aligned;
+ struct crypto_adptr_data crypto_adptr;
} __rte_cache_aligned;
struct perf_elt {
@@ -81,6 +93,8 @@ struct perf_elt {
const uint8_t port = w->port_id;\
const uint8_t prod_timer_type = \
opt->prod_type == EVT_PROD_TYPE_EVENT_TIMER_ADPTR;\
+ const uint8_t prod_crypto_type = \
+ opt->prod_type == EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR;\
uint8_t *const sched_type_list = &t->sched_type_list[0];\
struct rte_mempool *const pool = t->pool;\
const uint8_t nb_stages = t->opt->nb_stages;\
@@ -154,6 +168,7 @@ int perf_test_result(struct evt_test *test, struct evt_options *opt);
int perf_opt_check(struct evt_options *opt, uint64_t nb_queues);
int perf_test_setup(struct evt_test *test, struct evt_options *opt);
int perf_ethdev_setup(struct evt_test *test, struct evt_options *opt);
+int perf_cryptodev_setup(struct evt_test *test, struct evt_options *opt);
int perf_mempool_setup(struct evt_test *test, struct evt_options *opt);
int perf_event_dev_port_setup(struct evt_test *test, struct evt_options *opt,
uint8_t stride, uint8_t nb_queues,
@@ -164,6 +179,7 @@ int perf_launch_lcores(struct evt_test *test, struct evt_options *opt,
void perf_opt_dump(struct evt_options *opt, uint8_t nb_queues);
void perf_test_destroy(struct evt_test *test, struct evt_options *opt);
void perf_eventdev_destroy(struct evt_test *test, struct evt_options *opt);
+void perf_cryptodev_destroy(struct evt_test *test, struct evt_options *opt);
void perf_ethdev_destroy(struct evt_test *test, struct evt_options *opt);
void perf_mempool_destroy(struct evt_test *test, struct evt_options *opt);
diff --git a/app/test-eventdev/test_perf_queue.c b/app/test-eventdev/test_perf_queue.c
index f4ea3a795f..5657c8b3cd 100644
--- a/app/test-eventdev/test_perf_queue.c
+++ b/app/test-eventdev/test_perf_queue.c
@@ -49,6 +49,23 @@ perf_queue_worker(void *arg, const int enable_fwd_latency)
rte_pause();
continue;
}
+
+ if (prod_crypto_type &&
+ (ev.event_type == RTE_EVENT_TYPE_CRYPTODEV)) {
+ struct rte_crypto_op *op = ev.event_ptr;
+
+ if (op->status == RTE_CRYPTO_OP_STATUS_SUCCESS) {
+ if (op->sym->m_dst == NULL)
+ ev.event_ptr = op->sym->m_src;
+ else
+ ev.event_ptr = op->sym->m_dst;
+ rte_crypto_op_free(op);
+ } else {
+ rte_crypto_op_free(op);
+ continue;
+ }
+ }
+
if (enable_fwd_latency && !prod_timer_type)
/* first q in pipeline, mark timestamp to compute fwd latency */
mark_fwd_latency(&ev, nb_stages);
@@ -88,6 +105,25 @@ perf_queue_worker_burst(void *arg, const int enable_fwd_latency)
}
for (i = 0; i < nb_rx; i++) {
+ if (prod_crypto_type &&
+ (ev[i].event_type == RTE_EVENT_TYPE_CRYPTODEV)) {
+ struct rte_crypto_op *op = ev[i].event_ptr;
+
+ if (op->status ==
+ RTE_CRYPTO_OP_STATUS_SUCCESS) {
+ if (op->sym->m_dst == NULL)
+ ev[i].event_ptr =
+ op->sym->m_src;
+ else
+ ev[i].event_ptr =
+ op->sym->m_dst;
+ rte_crypto_op_free(op);
+ } else {
+ rte_crypto_op_free(op);
+ continue;
+ }
+ }
+
if (enable_fwd_latency && !prod_timer_type) {
rte_prefetch0(ev[i+1].event_ptr);
/* first queue in pipeline.
@@ -269,6 +305,20 @@ perf_queue_eventdev_setup(struct evt_test *test, struct evt_options *opt)
return ret;
}
}
+ } else if (opt->prod_type == EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR) {
+ uint8_t cdev_id, cdev_count;
+
+ cdev_count = rte_cryptodev_count();
+ for (cdev_id = 0; cdev_id < cdev_count; cdev_id++) {
+ ret = rte_cryptodev_start(cdev_id);
+ if (ret) {
+ evt_err("Failed to start cryptodev %u",
+ cdev_id);
+ return ret;
+ }
+ }
+
+ rte_event_crypto_adapter_start(t->crypto_adptr.id);
}
return 0;
@@ -311,11 +361,13 @@ static const struct evt_test_ops perf_queue = {
.test_setup = perf_test_setup,
.mempool_setup = perf_mempool_setup,
.ethdev_setup = perf_ethdev_setup,
+ .cryptodev_setup = perf_cryptodev_setup,
.eventdev_setup = perf_queue_eventdev_setup,
.launch_lcores = perf_queue_launch_lcores,
.eventdev_destroy = perf_eventdev_destroy,
.mempool_destroy = perf_mempool_destroy,
.ethdev_destroy = perf_ethdev_destroy,
+ .cryptodev_destroy = perf_cryptodev_destroy,
.test_result = perf_test_result,
.test_destroy = perf_test_destroy,
};
diff --git a/doc/guides/tools/testeventdev.rst b/doc/guides/tools/testeventdev.rst
index 48efb9ea6e..f7d813226d 100644
--- a/doc/guides/tools/testeventdev.rst
+++ b/doc/guides/tools/testeventdev.rst
@@ -120,6 +120,10 @@ The following are the application command-line options:
Use burst mode event timer adapter as producer.
+* ``--prod_type_cryptodev``
+
+ Use crypto device as producer.
+
* ``--timer_tick_nsec``
Used to dictate number of nano seconds between bucket traversal of the
@@ -148,6 +152,11 @@ The following are the application command-line options:
timeout is out of the supported range of event device it will be
adjusted to the highest/lowest supported dequeue timeout supported.
+* ``--crypto_adptr_mode``
+
+ Set crypto adapter mode. Use 0 for OP_NEW (default) and 1 for
+ OP_FORWARD mode.
+
* ``--mbuf_sz``
Set packet mbuf size. Can be used to configure Jumbo Frames. Only
@@ -420,6 +429,7 @@ Supported application command line options are following::
--prod_type_ethdev
--prod_type_timerdev_burst
--prod_type_timerdev
+ --prod_type_cryptodev
--prod_enq_burst_sz
--timer_tick_nsec
--max_tmo_nsec
@@ -427,6 +437,7 @@ Supported application command line options are following::
--nb_timers
--nb_timer_adptrs
--deq_tmo_nsec
+ --crypto_adptr_mode
Example
^^^^^^^
@@ -529,12 +540,14 @@ Supported application command line options are following::
--prod_type_ethdev
--prod_type_timerdev_burst
--prod_type_timerdev
+ --prod_type_cryptodev
--timer_tick_nsec
--max_tmo_nsec
--expiry_nsec
--nb_timers
--nb_timer_adptrs
--deq_tmo_nsec
+ --crypto_adptr_mode
Example
^^^^^^^
--
2.25.1
^ permalink raw reply [flat|nested] 43+ messages in thread
* RE: [PATCH v2] app/eventdev: add crypto producer mode
2021-12-21 8:51 ` [PATCH v2] " Shijith Thotton
@ 2021-12-30 11:56 ` Gujjar, Abhinandan S
2022-01-03 6:04 ` Shijith Thotton
2022-01-04 10:30 ` [PATCH v3] " Shijith Thotton
1 sibling, 1 reply; 43+ messages in thread
From: Gujjar, Abhinandan S @ 2021-12-30 11:56 UTC (permalink / raw)
To: Shijith Thotton, dev, Jerin Jacob; +Cc: anoobj, pbhagavatula, gakhil
Hi Shijith,
> -----Original Message-----
> From: Shijith Thotton <sthotton@marvell.com>
> Sent: Tuesday, December 21, 2021 2:21 PM
> To: dev@dpdk.org; Jerin Jacob <jerinj@marvell.com>
> Cc: Shijith Thotton <sthotton@marvell.com>; anoobj@marvell.com;
> pbhagavatula@marvell.com; gakhil@marvell.com; Gujjar, Abhinandan S
> <abhinandan.gujjar@intel.com>
> Subject: [PATCH v2] app/eventdev: add crypto producer mode
>
> In crypto producer mode, producer core enqueues cryptodev with software
> generated crypto ops and worker core dequeues crypto completion events from
> the eventdev. Event crypto metadata used for above processing is pre-
> populated in each crypto session.
>
> Parameter --prod_type_cryptodev can be used to enable crypto producer mode.
> Parameter --crypto_adptr_mode can be set to select the crypto adapter mode, 0
> for OP_NEW and 1 for OP_FORWARD.
>
> This mode can be used to measure the performance of crypto adapter.
>
> Example:
> ./dpdk-test-eventdev -l 0-2 -w <EVENTDEV> -w <CRYPTODEV> -- \
> --prod_type_cryptodev --crypto_adptr_mode 1 --test=perf_atq \
> --stlist=a --wlcores 1 --plcores 2
This patch has some perf failure as shown below. Could you please look into this?
105300 --> performance testing fail
Test environment and result as below:
Ubuntu 20.04
Kernel: 4.15.0-generic
Compiler: gcc 7.4
NIC: Intel Corporation Ethernet Converged Network Adapter 82599ES 10000 Mbps
Target: x86_64-native-linuxapp-gcc
Fail/Total: 0/4
Detail performance results:
+------------+---------+----------+-------------+------------------------------+
| frame_size | txd/rxd | num_cpus | num_threads | throughput difference from |
| | | | | expected |
+============+=========+==========+=============+==============================+
| 64 | 512 | 1 | 1 | 0.3% |
+------------+---------+----------+-------------+------------------------------+
| 64 | 2048 | 1 | 1 | -0.2% |
+------------+---------+----------+-------------+------------------------------+
| 64 | 512 | 1 | 2 | 0.0% |
+------------+---------+----------+-------------+------------------------------+
| 64 | 2048 | 1 | 2 | 0.3% |
+------------+---------+----------+-------------+------------------------------+
Ubuntu 20.04
Kernel: 4.15.0-generic
Compiler: gcc 7.4
NIC: Intel Corporation Ethernet Converged Network Adapter XL710-QDA2 40000 Mbps
Target: x86_64-native-linuxapp-gcc
Fail/Total: 1/4
Detail performance results:
+------------+---------+----------+-------------+------------------------------+
| frame_size | txd/rxd | num_cpus | num_threads | throughput difference from |
| | | | | expected |
+============+=========+==========+=============+==============================+
| 64 | 512 | 1 | 1 | 0.2% |
+------------+---------+----------+-------------+------------------------------+
| 64 | 2048 | 1 | 1 | -0.7% |
+------------+---------+----------+-------------+------------------------------+
| 64 | 512 | 1 | 2 | -1.5% |
+------------+---------+----------+-------------+------------------------------+
| 64 | 2048 | 1 | 2 | -5.3% |
+------------+---------+----------+-------------+------------------------------+
Ubuntu 20.04 ARM
Kernel: 4.15.0-132-generic
Compiler: gcc 7.5
NIC: Arm Intel Corporation Ethernet Converged Network Adapter XL710-QDA2 40000 Mbps
Target: x86_64-native-linuxapp-gcc
Fail/Total: 0/2
Detail performance results:
+------------+---------+----------+-------------+------------------------------+
| frame_size | txd/rxd | num_cpus | num_threads | throughput difference from |
| | | | | expected |
+============+=========+==========+=============+==============================+
| 64 | 512 | 1 | 1 | 0.1% |
+------------+---------+----------+-------------+------------------------------+
| 64 | 2048 | 1 | 1 | -0.5% |
+------------+---------+----------+-------------+------------------------------+
To view detailed results, visit:
https://lab.dpdk.org/results/dashboard/patchsets/20534/
>
> Signed-off-by: Shijith Thotton <sthotton@marvell.com>
> ---
> v2:
> * Fix RHEL compilation warning.
>
> app/test-eventdev/evt_common.h | 3 +
> app/test-eventdev/evt_main.c | 13 +-
> app/test-eventdev/evt_options.c | 27 ++
> app/test-eventdev/evt_options.h | 12 +
> app/test-eventdev/evt_test.h | 6 +
> app/test-eventdev/test_perf_atq.c | 51 ++++
> app/test-eventdev/test_perf_common.c | 406 ++++++++++++++++++++++++++-
> app/test-eventdev/test_perf_common.h | 16 ++ app/test-
> eventdev/test_perf_queue.c | 52 ++++
> doc/guides/tools/testeventdev.rst | 13 +
> 10 files changed, 592 insertions(+), 7 deletions(-)
>
> diff --git a/app/test-eventdev/evt_common.h b/app/test-
> eventdev/evt_common.h index f466434459..2f301a7e79 100644
> --- a/app/test-eventdev/evt_common.h
> +++ b/app/test-eventdev/evt_common.h
> @@ -7,6 +7,7 @@
>
> #include <rte_common.h>
> #include <rte_debug.h>
> +#include <rte_event_crypto_adapter.h>
> #include <rte_eventdev.h>
> #include <rte_service.h>
>
> @@ -39,6 +40,7 @@ enum evt_prod_type {
> EVT_PROD_TYPE_SYNT, /* Producer type Synthetic i.e. CPU. */
> EVT_PROD_TYPE_ETH_RX_ADPTR, /* Producer type Eth Rx Adapter. */
> EVT_PROD_TYPE_EVENT_TIMER_ADPTR, /* Producer type Timer
> Adapter. */
> + EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR, /* Producer type Crypto
> Adapter. */
> EVT_PROD_TYPE_MAX,
> };
>
> @@ -77,6 +79,7 @@ struct evt_options {
> uint64_t timer_tick_nsec;
> uint64_t optm_timer_tick_nsec;
> enum evt_prod_type prod_type;
> + enum rte_event_crypto_adapter_mode crypto_adptr_mode;
> };
>
> static inline bool
> diff --git a/app/test-eventdev/evt_main.c b/app/test-eventdev/evt_main.c
> index 194c980c7a..cef0fb1382 100644
> --- a/app/test-eventdev/evt_main.c
> +++ b/app/test-eventdev/evt_main.c
> @@ -161,12 +161,19 @@ main(int argc, char **argv)
> goto mempool_destroy;
> }
> }
> + /* Test specific cryptodev setup */
> + if (test->ops.cryptodev_setup) {
> + if (test->ops.cryptodev_setup(test, &opt)) {
> + evt_err("%s: cryptodev setup failed", opt.test_name);
> + goto ethdev_destroy;
> + }
> + }
>
> /* Test specific eventdev setup */
> if (test->ops.eventdev_setup) {
> if (test->ops.eventdev_setup(test, &opt)) {
> evt_err("%s: eventdev setup failed", opt.test_name);
> - goto ethdev_destroy;
> + goto cryptodev_destroy;
> }
> }
>
> @@ -197,6 +204,10 @@ main(int argc, char **argv)
> if (test->ops.eventdev_destroy)
> test->ops.eventdev_destroy(test, &opt);
>
> +cryptodev_destroy:
> + if (test->ops.cryptodev_destroy)
> + test->ops.cryptodev_destroy(test, &opt);
> +
> ethdev_destroy:
> if (test->ops.ethdev_destroy)
> test->ops.ethdev_destroy(test, &opt); diff --git a/app/test-
> eventdev/evt_options.c b/app/test-eventdev/evt_options.c index
> 753a7dbd7d..5ad1491020 100644
> --- a/app/test-eventdev/evt_options.c
> +++ b/app/test-eventdev/evt_options.c
> @@ -122,6 +122,26 @@ evt_parse_timer_prod_type_burst(struct evt_options
> *opt,
> return 0;
> }
>
> +static int
> +evt_parse_crypto_prod_type(struct evt_options *opt,
> + const char *arg __rte_unused)
> +{
> + opt->prod_type = EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR;
> + return 0;
> +}
> +
> +static int
> +evt_parse_crypto_adptr_mode(struct evt_options *opt, const char *arg) {
> + uint8_t mode;
> + int ret;
> +
> + ret = parser_read_uint8(&mode, arg);
> + opt->crypto_adptr_mode = mode ?
> RTE_EVENT_CRYPTO_ADAPTER_OP_FORWARD :
> +
> RTE_EVENT_CRYPTO_ADAPTER_OP_NEW;
> + return ret;
> +}
> +
> static int
> evt_parse_test_name(struct evt_options *opt, const char *arg) { @@ -335,6
> +355,7 @@ usage(char *program)
> "\t--queue_priority : enable queue priority\n"
> "\t--deq_tmo_nsec : global dequeue timeout\n"
> "\t--prod_type_ethdev : use ethernet device as producer.\n"
> + "\t--prod_type_cryptodev : use crypto device as producer.\n"
> "\t--prod_type_timerdev : use event timer device as
> producer.\n"
> "\t expity_nsec would be the timeout\n"
> "\t in ns.\n"
> @@ -345,6 +366,8 @@ usage(char *program)
> "\t--timer_tick_nsec : timer tick interval in ns.\n"
> "\t--max_tmo_nsec : max timeout interval in ns.\n"
> "\t--expiry_nsec : event timer expiry ns.\n"
> + "\t--crypto_adptr_mode : 0 for OP_NEW mode (default) and\n"
> + "\t 1 for OP_FORWARD mode.\n"
> "\t--mbuf_sz : packet mbuf size.\n"
> "\t--max_pkt_sz : max packet size.\n"
> "\t--prod_enq_burst_sz : producer enqueue burst size.\n"
> @@ -415,8 +438,10 @@ static struct option lgopts[] = {
> { EVT_QUEUE_PRIORITY, 0, 0, 0 },
> { EVT_DEQ_TMO_NSEC, 1, 0, 0 },
> { EVT_PROD_ETHDEV, 0, 0, 0 },
> + { EVT_PROD_CRYPTODEV, 0, 0, 0 },
> { EVT_PROD_TIMERDEV, 0, 0, 0 },
> { EVT_PROD_TIMERDEV_BURST, 0, 0, 0 },
> + { EVT_CRYPTO_ADPTR_MODE, 1, 0, 0 },
> { EVT_NB_TIMERS, 1, 0, 0 },
> { EVT_NB_TIMER_ADPTRS, 1, 0, 0 },
> { EVT_TIMER_TICK_NSEC, 1, 0, 0 },
> @@ -455,8 +480,10 @@ evt_opts_parse_long(int opt_idx, struct evt_options
> *opt)
> { EVT_QUEUE_PRIORITY, evt_parse_queue_priority},
> { EVT_DEQ_TMO_NSEC, evt_parse_deq_tmo_nsec},
> { EVT_PROD_ETHDEV, evt_parse_eth_prod_type},
> + { EVT_PROD_CRYPTODEV, evt_parse_crypto_prod_type},
> { EVT_PROD_TIMERDEV, evt_parse_timer_prod_type},
> { EVT_PROD_TIMERDEV_BURST,
> evt_parse_timer_prod_type_burst},
> + { EVT_CRYPTO_ADPTR_MODE, evt_parse_crypto_adptr_mode},
> { EVT_NB_TIMERS, evt_parse_nb_timers},
> { EVT_NB_TIMER_ADPTRS, evt_parse_nb_timer_adptrs},
> { EVT_TIMER_TICK_NSEC, evt_parse_timer_tick_nsec}, diff --git
> a/app/test-eventdev/evt_options.h b/app/test-eventdev/evt_options.h index
> 413d7092f0..2231c58801 100644
> --- a/app/test-eventdev/evt_options.h
> +++ b/app/test-eventdev/evt_options.h
> @@ -9,6 +9,7 @@
> #include <stdbool.h>
>
> #include <rte_common.h>
> +#include <rte_cryptodev.h>
> #include <rte_ethdev.h>
> #include <rte_eventdev.h>
> #include <rte_lcore.h>
> @@ -33,8 +34,10 @@
> #define EVT_QUEUE_PRIORITY ("queue_priority")
> #define EVT_DEQ_TMO_NSEC ("deq_tmo_nsec")
> #define EVT_PROD_ETHDEV ("prod_type_ethdev")
> +#define EVT_PROD_CRYPTODEV ("prod_type_cryptodev")
> #define EVT_PROD_TIMERDEV ("prod_type_timerdev")
> #define EVT_PROD_TIMERDEV_BURST ("prod_type_timerdev_burst")
> +#define EVT_CRYPTO_ADPTR_MODE ("crypto_adptr_mode")
> #define EVT_NB_TIMERS ("nb_timers")
> #define EVT_NB_TIMER_ADPTRS ("nb_timer_adptrs")
> #define EVT_TIMER_TICK_NSEC ("timer_tick_nsec")
> @@ -249,6 +252,8 @@ evt_prod_id_to_name(enum evt_prod_type prod_type)
> return "Ethdev Rx Adapter";
> case EVT_PROD_TYPE_EVENT_TIMER_ADPTR:
> return "Event timer adapter";
> + case EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR:
> + return "Event crypto adapter";
> }
>
> return "";
> @@ -288,6 +293,13 @@ evt_dump_producer_type(struct evt_options *opt)
> evt_dump("timer_tick_nsec", "%"PRIu64"",
> opt->timer_tick_nsec);
> break;
> + case EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR:
> + snprintf(name, EVT_PROD_MAX_NAME_LEN,
> + "Event crypto adapter producers");
> + evt_dump("crypto adapter mode", "%s",
> + opt->crypto_adptr_mode ? "OP_FORWARD" :
> "OP_NEW");
> + evt_dump("nb_cryptodev", "%u", rte_cryptodev_count());
> + break;
> }
> evt_dump("prod_type", "%s", name);
> }
> diff --git a/app/test-eventdev/evt_test.h b/app/test-eventdev/evt_test.h index
> f07d2c3336..50fa474ec2 100644
> --- a/app/test-eventdev/evt_test.h
> +++ b/app/test-eventdev/evt_test.h
> @@ -29,6 +29,8 @@ typedef int (*evt_test_mempool_setup_t)
> (struct evt_test *test, struct evt_options *opt); typedef int
> (*evt_test_ethdev_setup_t)
> (struct evt_test *test, struct evt_options *opt);
> +typedef int (*evt_test_cryptodev_setup_t)
> + (struct evt_test *test, struct evt_options *opt);
> typedef int (*evt_test_eventdev_setup_t)
> (struct evt_test *test, struct evt_options *opt); typedef int
> (*evt_test_launch_lcores_t) @@ -39,6 +41,8 @@ typedef void
> (*evt_test_eventdev_destroy_t)
> (struct evt_test *test, struct evt_options *opt); typedef void
> (*evt_test_ethdev_destroy_t)
> (struct evt_test *test, struct evt_options *opt);
> +typedef void (*evt_test_cryptodev_destroy_t)
> + (struct evt_test *test, struct evt_options *opt);
> typedef void (*evt_test_mempool_destroy_t)
> (struct evt_test *test, struct evt_options *opt); typedef void
> (*evt_test_destroy_t) @@ -52,10 +56,12 @@ struct evt_test_ops {
> evt_test_mempool_setup_t mempool_setup;
> evt_test_ethdev_setup_t ethdev_setup;
> evt_test_eventdev_setup_t eventdev_setup;
> + evt_test_cryptodev_setup_t cryptodev_setup;
> evt_test_launch_lcores_t launch_lcores;
> evt_test_result_t test_result;
> evt_test_eventdev_destroy_t eventdev_destroy;
> evt_test_ethdev_destroy_t ethdev_destroy;
> + evt_test_cryptodev_destroy_t cryptodev_destroy;
> evt_test_mempool_destroy_t mempool_destroy;
> evt_test_destroy_t test_destroy;
> };
> diff --git a/app/test-eventdev/test_perf_atq.c b/app/test-
> eventdev/test_perf_atq.c
> index 8fd51004ee..dbb1dc8c0c 100644
> --- a/app/test-eventdev/test_perf_atq.c
> +++ b/app/test-eventdev/test_perf_atq.c
> @@ -48,6 +48,22 @@ perf_atq_worker(void *arg, const int
> enable_fwd_latency)
> continue;
> }
>
> + if (prod_crypto_type &&
> + (ev.event_type == RTE_EVENT_TYPE_CRYPTODEV)) {
> + struct rte_crypto_op *op = ev.event_ptr;
> +
> + if (op->status == RTE_CRYPTO_OP_STATUS_SUCCESS) {
> + if (op->sym->m_dst == NULL)
> + ev.event_ptr = op->sym->m_src;
> + else
> + ev.event_ptr = op->sym->m_dst;
> + rte_crypto_op_free(op);
> + } else {
> + rte_crypto_op_free(op);
> + continue;
> + }
> + }
> +
> if (enable_fwd_latency && !prod_timer_type)
> /* first stage in pipeline, mark ts to compute fwd latency */
> atq_mark_fwd_latency(&ev);
> @@ -87,6 +103,25 @@ perf_atq_worker_burst(void *arg, const int
> enable_fwd_latency)
> }
>
> for (i = 0; i < nb_rx; i++) {
> + if (prod_crypto_type &&
> + (ev[i].event_type == RTE_EVENT_TYPE_CRYPTODEV))
> {
> + struct rte_crypto_op *op = ev[i].event_ptr;
> +
> + if (op->status ==
> + RTE_CRYPTO_OP_STATUS_SUCCESS) {
> + if (op->sym->m_dst == NULL)
> + ev[i].event_ptr =
> + op->sym->m_src;
> + else
> + ev[i].event_ptr =
> + op->sym->m_dst;
> + rte_crypto_op_free(op);
> + } else {
> + rte_crypto_op_free(op);
> + continue;
> + }
> + }
> +
> if (enable_fwd_latency && !prod_timer_type) {
> rte_prefetch0(ev[i+1].event_ptr);
> /* first stage in pipeline.
> @@ -254,6 +289,20 @@ perf_atq_eventdev_setup(struct evt_test *test, struct
> evt_options *opt)
> return ret;
> }
> }
> + } else if (opt->prod_type == EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR) {
> + uint8_t cdev_id, cdev_count;
> +
> + cdev_count = rte_cryptodev_count();
> + for (cdev_id = 0; cdev_id < cdev_count; cdev_id++) {
> + ret = rte_cryptodev_start(cdev_id);
> + if (ret) {
> + evt_err("Failed to start cryptodev %u",
> + cdev_id);
> + return ret;
> + }
> + }
> +
> + rte_event_crypto_adapter_start(t->crypto_adptr.id);
> }
>
> return 0;
> @@ -295,12 +344,14 @@ static const struct evt_test_ops perf_atq = {
> .opt_dump = perf_atq_opt_dump,
> .test_setup = perf_test_setup,
> .ethdev_setup = perf_ethdev_setup,
> + .cryptodev_setup = perf_cryptodev_setup,
> .mempool_setup = perf_mempool_setup,
> .eventdev_setup = perf_atq_eventdev_setup,
> .launch_lcores = perf_atq_launch_lcores,
> .eventdev_destroy = perf_eventdev_destroy,
> .mempool_destroy = perf_mempool_destroy,
> .ethdev_destroy = perf_ethdev_destroy,
> + .cryptodev_destroy = perf_cryptodev_destroy,
> .test_result = perf_test_result,
> .test_destroy = perf_test_destroy,
> };
> diff --git a/app/test-eventdev/test_perf_common.c b/app/test-
> eventdev/test_perf_common.c
> index 9b73874151..7b964ab8dc 100644
> --- a/app/test-eventdev/test_perf_common.c
> +++ b/app/test-eventdev/test_perf_common.c
> @@ -6,6 +6,8 @@
>
> #include "test_perf_common.h"
>
> +#define NB_CRYPTODEV_DESCRIPTORS 128
> +
> int
> perf_test_result(struct evt_test *test, struct evt_options *opt) { @@ -272,6
> +274,121 @@ perf_event_timer_producer_burst(void *arg)
> return 0;
> }
>
> +static inline void
> +crypto_adapter_enq_op_new(struct prod_data *p) {
> + struct test_perf *t = p->t;
> + const uint32_t nb_flows = t->nb_flows;
> + const uint64_t nb_pkts = t->nb_pkts;
> + struct rte_mempool *pool = t->pool;
> + struct rte_crypto_sym_op *sym_op;
> + struct evt_options *opt = t->opt;
> + uint32_t flow_counter = 0;
> + struct rte_crypto_op *op;
> + struct rte_mbuf *m;
> + uint64_t count = 0;
> + uint16_t len;
> +
> + if (opt->verbose_level > 1)
> + printf("%s(): lcore %d queue %d cdev_id %u cdev_qp_id %u\n",
> + __func__, rte_lcore_id(), p->queue_id, p->cdev_id,
> + p->cdev_qp_id);
> +
> + len = opt->mbuf_sz ? opt->mbuf_sz : RTE_ETHER_MIN_LEN;
> +
> + while (count < nb_pkts && t->done == false) {
> + m = rte_pktmbuf_alloc(pool);
> + if (m == NULL)
> + continue;
> +
> + rte_pktmbuf_append(m, len);
> + op = rte_crypto_op_alloc(t->crypto_adptr.op_pool,
> + RTE_CRYPTO_OP_TYPE_SYMMETRIC);
> + sym_op = op->sym;
> + sym_op->m_src = m;
> + sym_op->cipher.data.offset = 0;
> + sym_op->cipher.data.length = len;
> + rte_crypto_op_attach_sym_session(
> + op, p->crypto_sess[flow_counter++ % nb_flows]);
> + while (rte_cryptodev_enqueue_burst(p->cdev_id, p-
> >cdev_qp_id,
> + &op, 1) != 1) {
> + if (t->done)
> + break;
> + rte_pause();
> + }
> + count++;
> + }
> +}
> +
> +static inline void
> +crypto_adapter_enq_op_fwd(struct prod_data *p) {
> + const uint8_t dev_id = p->dev_id;
> + const uint8_t port = p->port_id;
> + struct test_perf *t = p->t;
> + const uint32_t nb_flows = t->nb_flows;
> + const uint64_t nb_pkts = t->nb_pkts;
> + struct rte_mempool *pool = t->pool;
> + struct evt_options *opt = t->opt;
> + struct rte_crypto_sym_op *sym_op;
> + uint32_t flow_counter = 0;
> + struct rte_crypto_op *op;
> + struct rte_event ev;
> + struct rte_mbuf *m;
> + uint64_t count = 0;
> + uint16_t len;
> +
> + if (opt->verbose_level > 1)
> + printf("%s(): lcore %d port %d queue %d cdev_id %u cdev_qp_id
> %u\n",
> + __func__, rte_lcore_id(), port, p->queue_id, p->cdev_id,
> + p->cdev_qp_id);
> +
> + ev.event = 0;
> + ev.op = RTE_EVENT_OP_NEW;
> + ev.queue_id = p->queue_id;
> + ev.sched_type = RTE_SCHED_TYPE_ATOMIC;
> + ev.event_type = RTE_EVENT_TYPE_CPU;
> + len = opt->mbuf_sz ? opt->mbuf_sz : RTE_ETHER_MIN_LEN;
> +
> + while (count < nb_pkts && t->done == false) {
> + m = rte_pktmbuf_alloc(pool);
> + if (m == NULL)
> + continue;
> +
> + rte_pktmbuf_append(m, len);
> + op = rte_crypto_op_alloc(t->crypto_adptr.op_pool,
> + RTE_CRYPTO_OP_TYPE_SYMMETRIC);
> + sym_op = op->sym;
> + sym_op->m_src = m;
> + sym_op->cipher.data.offset = 0;
> + sym_op->cipher.data.length = len;
> + rte_crypto_op_attach_sym_session(
> + op, p->crypto_sess[flow_counter++ % nb_flows]);
> + ev.event_ptr = op;
> + while (rte_event_crypto_adapter_enqueue(dev_id, port, &ev, 1)
> !=
> + 1) {
> + if (t->done)
> + break;
> + rte_pause();
> + }
> + count++;
> + }
> +}
> +
> +static inline int
> +perf_event_crypto_producer(void *arg)
> +{
> + struct prod_data *p = arg;
> + struct evt_options *opt = p->t->opt;
> +
> + if (opt->crypto_adptr_mode ==
> RTE_EVENT_CRYPTO_ADAPTER_OP_NEW)
> + crypto_adapter_enq_op_new(p);
> + else
> + crypto_adapter_enq_op_fwd(p);
> +
> + return 0;
> +}
> +
> static int
> perf_producer_wrapper(void *arg)
> {
> @@ -298,6 +415,8 @@ perf_producer_wrapper(void *arg)
> else if (t->opt->prod_type == EVT_PROD_TYPE_EVENT_TIMER_ADPTR
> &&
> t->opt->timdev_use_burst)
> return perf_event_timer_producer_burst(arg);
> + else if (t->opt->prod_type == EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR)
> + return perf_event_crypto_producer(arg);
> return 0;
> }
>
> @@ -405,8 +524,10 @@ perf_launch_lcores(struct evt_test *test, struct
> evt_options *opt,
> if (remaining <= 0) {
> t->result = EVT_TEST_SUCCESS;
> if (opt->prod_type == EVT_PROD_TYPE_SYNT
> ||
> - opt->prod_type ==
> -
> EVT_PROD_TYPE_EVENT_TIMER_ADPTR) {
> + opt->prod_type ==
> +
> EVT_PROD_TYPE_EVENT_TIMER_ADPTR ||
> + opt->prod_type ==
> +
> EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR) {
> t->done = true;
> break;
> }
> @@ -415,7 +536,8 @@ perf_launch_lcores(struct evt_test *test, struct
> evt_options *opt,
>
> if (new_cycles - dead_lock_cycles > dead_lock_sample &&
> (opt->prod_type == EVT_PROD_TYPE_SYNT ||
> - opt->prod_type == EVT_PROD_TYPE_EVENT_TIMER_ADPTR))
> {
> + opt->prod_type == EVT_PROD_TYPE_EVENT_TIMER_ADPTR
> ||
> + opt->prod_type ==
> EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR)) {
> remaining = t->outstand_pkts - processed_pkts(t);
> if (dead_lock_remaining == remaining) {
> rte_event_dev_dump(opt->dev_id, stdout);
> @@ -537,6 +659,96 @@ perf_event_timer_adapter_setup(struct test_perf *t)
> return 0;
> }
>
> +static int
> +perf_event_crypto_adapter_setup(struct test_perf *t,
> + struct rte_event_port_conf port_conf) {
> + struct evt_options *opt = t->opt;
> + uint8_t cdev_id, cdev_count;
> + int ret;
> +
> + t->crypto_adptr.id = 0;
> + ret = rte_event_crypto_adapter_create(t->crypto_adptr.id, opt->dev_id,
> + &port_conf, 0);
> + if (ret)
> + return ret;
> +
> + cdev_count = rte_cryptodev_count();
> + for (cdev_id = 0; cdev_id < cdev_count; cdev_id++) {
> + uint32_t cap;
> +
> + ret = rte_event_crypto_adapter_caps_get(opt->dev_id,
> cdev_id,
> + &cap);
> + if (ret) {
> + evt_err("Failed to get crypto adapter capabilities");
> + return ret;
> + }
> +
> + if (((opt->crypto_adptr_mode ==
> + RTE_EVENT_CRYPTO_ADAPTER_OP_NEW) &&
> + !(cap &
> +
> RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_OP_NEW)) ||
> + ((opt->crypto_adptr_mode ==
> + RTE_EVENT_CRYPTO_ADAPTER_OP_FORWARD) &&
> + !(cap &
> +
> RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_OP_FWD))) {
> + evt_err("crypto adapter %s mode unsupported\n",
> + opt->crypto_adptr_mode ? "OP_FORWARD" :
> + "OP_NEW");
> + return -EINVAL;
> + }
> +
> + if (!(cap &
> +
> RTE_EVENT_CRYPTO_ADAPTER_CAP_SESSION_PRIVATE_DATA)) {
> + evt_err("Storing crypto session not supported");
> + return -EINVAL;
> + }
> +
> + if (cap &
> +
> RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_QP_EV_BIND) {
> + struct rte_event response_info;
> +
> + response_info.event = 0;
> + ret = rte_event_crypto_adapter_queue_pair_add(
> + t->crypto_adptr.id, cdev_id, -1,
> + &response_info);
> + } else {
> + ret = rte_event_crypto_adapter_queue_pair_add(
> + t->crypto_adptr.id, cdev_id, -1, NULL);
> + }
> + if (ret)
> + return ret;
> + }
> +
> + return 0;
> +}
> +
> +static struct rte_cryptodev_sym_session *
> +cryptodev_session_create(struct prod_data *p, struct test_perf *t) {
> + struct rte_crypto_sym_xform cipher_xform;
> + struct rte_cryptodev_sym_session *sess;
> +
> + cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
> + cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
> + cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
> + cipher_xform.next = NULL;
> +
> + sess = rte_cryptodev_sym_session_create(t->crypto_adptr.sess_pool);
> + if (sess == NULL) {
> + evt_err("Failed to create sym session");
> + return NULL;
> + }
> +
> + if (rte_cryptodev_sym_session_init(p->cdev_id, sess, &cipher_xform,
> + t->crypto_adptr.sess_priv_pool)) {
> + evt_err("Failed to init session");
> + return NULL;
> + }
> +
> + return sess;
> +}
> +
> int
> perf_event_dev_port_setup(struct evt_test *test, struct evt_options *opt,
> uint8_t stride, uint8_t nb_queues,
> @@ -598,6 +810,55 @@ perf_event_dev_port_setup(struct evt_test *test,
> struct evt_options *opt,
> ret = perf_event_timer_adapter_setup(t);
> if (ret)
> return ret;
> + } else if (opt->prod_type == EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR) {
> + uint8_t cdev_id = 0;
> + uint16_t qp_id = 0;
> +
> + prod = 0;
> + for (; port < perf_nb_event_ports(opt); port++) {
> + struct rte_cryptodev_sym_session *crypto_sess;
> + union rte_event_crypto_metadata m_data;
> + struct prod_data *p = &t->prod[port];
> + uint32_t flow_id;
> +
> + if (qp_id == rte_cryptodev_queue_pair_count(cdev_id))
> {
> + cdev_id++;
> + qp_id = 0;
> + }
> +
> + p->dev_id = opt->dev_id;
> + p->port_id = port;
> + p->queue_id = prod * stride;
> + p->cdev_id = cdev_id;
> + p->cdev_qp_id = qp_id;
> + p->crypto_sess = rte_zmalloc_socket(
> + NULL, sizeof(crypto_sess) * t->nb_flows,
> + RTE_CACHE_LINE_SIZE, opt->socket_id);
> +
> + m_data.request_info.cdev_id = p->cdev_id;
> + m_data.request_info.queue_pair_id = p->cdev_qp_id;
> + m_data.response_info.op = RTE_EVENT_OP_NEW;
> + m_data.response_info.sched_type =
> RTE_SCHED_TYPE_ATOMIC;
> + m_data.response_info.event_type =
> RTE_EVENT_TYPE_CPU;
> + m_data.response_info.queue_id = p->queue_id;
> + for (flow_id = 0; flow_id < t->nb_flows; flow_id++) {
> + crypto_sess = cryptodev_session_create(p, t);
> + if (crypto_sess == NULL)
> + return -ENOMEM;
> +
> + m_data.response_info.flow_id = flow_id;
> + rte_cryptodev_sym_session_set_user_data(
> + crypto_sess, &m_data,
> sizeof(m_data));
> + p->crypto_sess[flow_id] = crypto_sess;
> + }
> + p->t = t;
> + qp_id++;
> + prod++;
> + }
> +
> + ret = perf_event_crypto_adapter_setup(t, *port_conf);
> + if (ret)
> + return ret;
> } else {
> prod = 0;
> for ( ; port < perf_nb_event_ports(opt); port++) { @@ -659,7
> +920,8 @@ perf_opt_check(struct evt_options *opt, uint64_t nb_queues)
> }
>
> if (opt->prod_type == EVT_PROD_TYPE_SYNT ||
> - opt->prod_type ==
> EVT_PROD_TYPE_EVENT_TIMER_ADPTR) {
> + opt->prod_type == EVT_PROD_TYPE_EVENT_TIMER_ADPTR ||
> + opt->prod_type == EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR) {
> /* Validate producer lcores */
> if (evt_lcores_has_overlap(opt->plcores,
> rte_get_main_lcore())) {
> @@ -767,8 +1029,7 @@ perf_ethdev_setup(struct evt_test *test, struct
> evt_options *opt)
> },
> };
>
> - if (opt->prod_type == EVT_PROD_TYPE_SYNT ||
> - opt->prod_type ==
> EVT_PROD_TYPE_EVENT_TIMER_ADPTR)
> + if (opt->prod_type != EVT_PROD_TYPE_ETH_RX_ADPTR)
> return 0;
>
> if (!rte_eth_dev_count_avail()) {
> @@ -841,6 +1102,139 @@ void perf_ethdev_destroy(struct evt_test *test,
> struct evt_options *opt)
> }
> }
>
> +int
> +perf_cryptodev_setup(struct evt_test *test, struct evt_options *opt) {
> + uint8_t cdev_count, cdev_id, nb_plcores, nb_qps;
> + struct test_perf *t = evt_test_priv(test);
> + unsigned int max_session_size;
> + uint32_t nb_sessions;
> + int ret;
> +
> + if (opt->prod_type != EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR)
> + return 0;
> +
> + cdev_count = rte_cryptodev_count();
> + if (cdev_count == 0) {
> + evt_err("No crypto devices available\n");
> + return -ENODEV;
> + }
> +
> + t->crypto_adptr.op_pool = rte_crypto_op_pool_create(
> + "crypto_op_pool", RTE_CRYPTO_OP_TYPE_SYMMETRIC, opt-
> >pool_sz,
> + 128, 0, rte_socket_id());
> + if (t->crypto_adptr.op_pool == NULL) {
> + evt_err("Failed to create crypto op pool");
> + return -ENOMEM;
> + }
> +
> + nb_sessions = evt_nr_active_lcores(opt->plcores) * t->nb_flows;
> + t->crypto_adptr.sess_pool = rte_cryptodev_sym_session_pool_create(
> + "ca_sess_pool", nb_sessions, 0, 0,
> + sizeof(union rte_event_crypto_metadata), SOCKET_ID_ANY);
> + if (t->crypto_adptr.sess_pool == NULL) {
> + evt_err("Failed to create sym session pool");
> + ret = -ENOMEM;
> + goto err;
> + }
> +
> + max_session_size = 0;
> + for (cdev_id = 0; cdev_id < cdev_count; cdev_id++) {
> + unsigned int session_size;
> +
> + session_size =
> + rte_cryptodev_sym_get_private_session_size(cdev_id);
> + if (session_size > max_session_size)
> + max_session_size = session_size;
> + }
> + max_session_size += sizeof(union rte_event_crypto_metadata);
> + t->crypto_adptr.sess_priv_pool = rte_mempool_create(
> + "ca_sess_priv_pool", nb_sessions, max_session_size, 0, 0,
> NULL,
> + NULL, NULL, NULL, SOCKET_ID_ANY, 0);
> + if (t->crypto_adptr.sess_priv_pool == NULL) {
> + evt_err("failed to create sym session private pool");
> + ret = -ENOMEM;
> + goto err;
> + }
> +
> + nb_plcores = evt_nr_active_lcores(opt->plcores);
> + nb_qps = (nb_plcores % cdev_count) ? (nb_plcores / cdev_count) + 1 :
> + nb_plcores / cdev_count;
> + for (cdev_id = 0; cdev_id < cdev_count; cdev_id++) {
> + struct rte_cryptodev_qp_conf qp_conf;
> + struct rte_cryptodev_config conf;
> + struct rte_cryptodev_info info;
> + int qp_id;
> +
> + rte_cryptodev_info_get(cdev_id, &info);
> + if (nb_qps > info.max_nb_queue_pairs) {
> + evt_err("Not enough queue pairs per cryptodev (%u)",
> + nb_qps);
> + ret = -EINVAL;
> + goto err;
> + }
> +
> + conf.nb_queue_pairs = nb_qps;
> + conf.socket_id = SOCKET_ID_ANY;
> + conf.ff_disable = RTE_CRYPTODEV_FF_SECURITY;
> +
> + ret = rte_cryptodev_configure(cdev_id, &conf);
> + if (ret) {
> + evt_err("Failed to configure cryptodev (%u)", cdev_id);
> + goto err;
> + }
> +
> + qp_conf.nb_descriptors = NB_CRYPTODEV_DESCRIPTORS;
> + qp_conf.mp_session = t->crypto_adptr.sess_pool;
> + qp_conf.mp_session_private = t->crypto_adptr.sess_priv_pool;
> +
> + for (qp_id = 0; qp_id < conf.nb_queue_pairs; qp_id++) {
> + ret = rte_cryptodev_queue_pair_setup(
> + cdev_id, qp_id, &qp_conf,
> + rte_cryptodev_socket_id(cdev_id));
> + if (ret) {
> + evt_err("Failed to setup queue pairs on
> cryptodev %u\n",
> + cdev_id);
> + goto err;
> + }
> + }
> + }
> +
> + return 0;
> +err:
> + rte_mempool_free(t->crypto_adptr.op_pool);
> + rte_mempool_free(t->crypto_adptr.sess_pool);
> + rte_mempool_free(t->crypto_adptr.sess_priv_pool);
> +
> + return ret;
> +}
> +
> +void
> +perf_cryptodev_destroy(struct evt_test *test, struct evt_options *opt)
> +{
> + uint8_t cdev_id, cdev_count = rte_cryptodev_count();
> + struct test_perf *t = evt_test_priv(test);
> +
> + RTE_SET_USED(opt);
> +
> + if (opt->prod_type != EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR)
> + return;
> +
> + rte_event_crypto_adapter_stop(t->crypto_adptr.id);
> +
> + for (cdev_id = 0; cdev_id < cdev_count; cdev_id++) {
> + rte_cryptodev_stop(cdev_id);
> + rte_event_crypto_adapter_queue_pair_del(t->crypto_adptr.id,
> + cdev_id, -1);
> + }
> +
> + rte_event_crypto_adapter_free(t->crypto_adptr.id);
> +
> + rte_mempool_free(t->crypto_adptr.op_pool);
> + rte_mempool_free(t->crypto_adptr.sess_pool);
> + rte_mempool_free(t->crypto_adptr.sess_priv_pool);
> +}
> +
> int
> perf_mempool_setup(struct evt_test *test, struct evt_options *opt) { diff --git
> a/app/test-eventdev/test_perf_common.h b/app/test-
> eventdev/test_perf_common.h
> index 14dcf80429..d9ad3a0b0d 100644
> --- a/app/test-eventdev/test_perf_common.h
> +++ b/app/test-eventdev/test_perf_common.h
> @@ -9,9 +9,11 @@
> #include <stdbool.h>
> #include <unistd.h>
>
> +#include <rte_cryptodev.h>
> #include <rte_cycles.h>
> #include <rte_ethdev.h>
> #include <rte_eventdev.h>
> +#include <rte_event_crypto_adapter.h>
> #include <rte_event_eth_rx_adapter.h>
> #include <rte_event_timer_adapter.h>
> #include <rte_lcore.h>
> @@ -37,9 +39,18 @@ struct prod_data {
> uint8_t dev_id;
> uint8_t port_id;
> uint8_t queue_id;
> + uint8_t cdev_id;
> + uint16_t cdev_qp_id;
> + struct rte_cryptodev_sym_session **crypto_sess;
> struct test_perf *t;
> } __rte_cache_aligned;
>
> +struct crypto_adptr_data {
> + uint8_t id;
> + struct rte_mempool *op_pool;
> + struct rte_mempool *sess_pool;
> + struct rte_mempool *sess_priv_pool;
> +};
>
> struct test_perf {
> /* Don't change the offset of "done". Signal handler use this memory
> @@ -58,6 +69,7 @@ struct test_perf {
> uint8_t sched_type_list[EVT_MAX_STAGES] __rte_cache_aligned;
> struct rte_event_timer_adapter *timer_adptr[
> RTE_EVENT_TIMER_ADAPTER_NUM_MAX]
> __rte_cache_aligned;
> + struct crypto_adptr_data crypto_adptr;
> } __rte_cache_aligned;
>
> struct perf_elt {
> @@ -81,6 +93,8 @@ struct perf_elt {
> const uint8_t port = w->port_id;\
> const uint8_t prod_timer_type = \
> opt->prod_type == EVT_PROD_TYPE_EVENT_TIMER_ADPTR;\
> + const uint8_t prod_crypto_type = \
> + opt->prod_type == EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR;\
> uint8_t *const sched_type_list = &t->sched_type_list[0];\
> struct rte_mempool *const pool = t->pool;\
> const uint8_t nb_stages = t->opt->nb_stages;\ @@ -154,6 +168,7 @@
> int perf_test_result(struct evt_test *test, struct evt_options *opt); int
> perf_opt_check(struct evt_options *opt, uint64_t nb_queues); int
> perf_test_setup(struct evt_test *test, struct evt_options *opt); int
> perf_ethdev_setup(struct evt_test *test, struct evt_options *opt);
> +int perf_cryptodev_setup(struct evt_test *test, struct evt_options
> +*opt);
> int perf_mempool_setup(struct evt_test *test, struct evt_options *opt); int
> perf_event_dev_port_setup(struct evt_test *test, struct evt_options *opt,
> uint8_t stride, uint8_t nb_queues,
> @@ -164,6 +179,7 @@ int perf_launch_lcores(struct evt_test *test, struct
> evt_options *opt, void perf_opt_dump(struct evt_options *opt, uint8_t
> nb_queues); void perf_test_destroy(struct evt_test *test, struct evt_options
> *opt); void perf_eventdev_destroy(struct evt_test *test, struct evt_options
> *opt);
> +void perf_cryptodev_destroy(struct evt_test *test, struct evt_options
> +*opt);
> void perf_ethdev_destroy(struct evt_test *test, struct evt_options *opt); void
> perf_mempool_destroy(struct evt_test *test, struct evt_options *opt);
>
> diff --git a/app/test-eventdev/test_perf_queue.c b/app/test-
> eventdev/test_perf_queue.c
> index f4ea3a795f..5657c8b3cd 100644
> --- a/app/test-eventdev/test_perf_queue.c
> +++ b/app/test-eventdev/test_perf_queue.c
> @@ -49,6 +49,23 @@ perf_queue_worker(void *arg, const int
> enable_fwd_latency)
> rte_pause();
> continue;
> }
> +
> + if (prod_crypto_type &&
> + (ev.event_type == RTE_EVENT_TYPE_CRYPTODEV)) {
> + struct rte_crypto_op *op = ev.event_ptr;
> +
> + if (op->status == RTE_CRYPTO_OP_STATUS_SUCCESS) {
> + if (op->sym->m_dst == NULL)
> + ev.event_ptr = op->sym->m_src;
> + else
> + ev.event_ptr = op->sym->m_dst;
> + rte_crypto_op_free(op);
> + } else {
> + rte_crypto_op_free(op);
> + continue;
> + }
> + }
> +
> if (enable_fwd_latency && !prod_timer_type)
> /* first q in pipeline, mark timestamp to compute fwd latency */
> mark_fwd_latency(&ev, nb_stages);
> @@ -88,6 +105,25 @@ perf_queue_worker_burst(void *arg, const int
> enable_fwd_latency)
> }
>
> for (i = 0; i < nb_rx; i++) {
> + if (prod_crypto_type &&
> + (ev[i].event_type == RTE_EVENT_TYPE_CRYPTODEV))
> {
> + struct rte_crypto_op *op = ev[i].event_ptr;
> +
> + if (op->status ==
> + RTE_CRYPTO_OP_STATUS_SUCCESS) {
> + if (op->sym->m_dst == NULL)
> + ev[i].event_ptr =
> + op->sym->m_src;
> + else
> + ev[i].event_ptr =
> + op->sym->m_dst;
> + rte_crypto_op_free(op);
> + } else {
> + rte_crypto_op_free(op);
> + continue;
> + }
> + }
> +
> if (enable_fwd_latency && !prod_timer_type) {
> rte_prefetch0(ev[i+1].event_ptr);
> /* first queue in pipeline.
> @@ -269,6 +305,20 @@ perf_queue_eventdev_setup(struct evt_test *test,
> struct evt_options *opt)
> return ret;
> }
> }
> + } else if (opt->prod_type == EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR) {
> + uint8_t cdev_id, cdev_count;
> +
> + cdev_count = rte_cryptodev_count();
> + for (cdev_id = 0; cdev_id < cdev_count; cdev_id++) {
> + ret = rte_cryptodev_start(cdev_id);
> + if (ret) {
> + evt_err("Failed to start cryptodev %u",
> + cdev_id);
> + return ret;
> + }
> + }
> +
> + rte_event_crypto_adapter_start(t->crypto_adptr.id);
> }
>
> return 0;
> @@ -311,11 +361,13 @@ static const struct evt_test_ops perf_queue = {
> .test_setup = perf_test_setup,
> .mempool_setup = perf_mempool_setup,
> .ethdev_setup = perf_ethdev_setup,
> + .cryptodev_setup = perf_cryptodev_setup,
> .eventdev_setup = perf_queue_eventdev_setup,
> .launch_lcores = perf_queue_launch_lcores,
> .eventdev_destroy = perf_eventdev_destroy,
> .mempool_destroy = perf_mempool_destroy,
> .ethdev_destroy = perf_ethdev_destroy,
> + .cryptodev_destroy = perf_cryptodev_destroy,
> .test_result = perf_test_result,
> .test_destroy = perf_test_destroy,
> };
> diff --git a/doc/guides/tools/testeventdev.rst
> b/doc/guides/tools/testeventdev.rst
> index 48efb9ea6e..f7d813226d 100644
> --- a/doc/guides/tools/testeventdev.rst
> +++ b/doc/guides/tools/testeventdev.rst
> @@ -120,6 +120,10 @@ The following are the application command-line
> options:
>
> Use burst mode event timer adapter as producer.
>
> +* ``--prod_type_cryptodev``
> +
> + Use crypto device as producer.
> +
> * ``--timer_tick_nsec``
>
> Used to dictate number of nano seconds between bucket traversal of the
> @@ -148,6 +152,11 @@ The following are the application command-line
> options:
> timeout is out of the supported range of event device it will be
> adjusted to the highest/lowest supported dequeue timeout supported.
>
> +* ``--crypto_adptr_mode``
> +
> + Set crypto adapter mode. Use 0 for OP_NEW (default) and 1 for
> + OP_FORWARD mode.
> +
> * ``--mbuf_sz``
>
> Set packet mbuf size. Can be used to configure Jumbo Frames. Only @@ -
> 420,6 +429,7 @@ Supported application command line options are following::
> --prod_type_ethdev
> --prod_type_timerdev_burst
> --prod_type_timerdev
> + --prod_type_cryptodev
> --prod_enq_burst_sz
> --timer_tick_nsec
> --max_tmo_nsec
> @@ -427,6 +437,7 @@ Supported application command line options are
> following::
> --nb_timers
> --nb_timer_adptrs
> --deq_tmo_nsec
> + --crypto_adptr_mode
>
> Example
> ^^^^^^^
> @@ -529,12 +540,14 @@ Supported application command line options are
> following::
> --prod_type_ethdev
> --prod_type_timerdev_burst
> --prod_type_timerdev
> + --prod_type_cryptodev
> --timer_tick_nsec
> --max_tmo_nsec
> --expiry_nsec
> --nb_timers
> --nb_timer_adptrs
> --deq_tmo_nsec
> + --crypto_adptr_mode
>
> Example
> ^^^^^^^
> --
> 2.25.1
^ permalink raw reply [flat|nested] 43+ messages in thread
* RE: [PATCH v2] app/eventdev: add crypto producer mode
2021-12-30 11:56 ` Gujjar, Abhinandan S
@ 2022-01-03 6:04 ` Shijith Thotton
2022-01-03 8:46 ` Gujjar, Abhinandan S
0 siblings, 1 reply; 43+ messages in thread
From: Shijith Thotton @ 2022-01-03 6:04 UTC (permalink / raw)
To: Gujjar, Abhinandan S, dev, Jerin Jacob Kollanukkaran
Cc: Anoob Joseph, Pavan Nikhilesh Bhagavatula, Akhil Goyal
Hi Abhinandan,
>> Subject: [PATCH v2] app/eventdev: add crypto producer mode
>>
>> In crypto producer mode, producer core enqueues cryptodev with software
>> generated crypto ops and worker core dequeues crypto completion events from
>> the eventdev. Event crypto metadata used for above processing is pre-
>> populated in each crypto session.
>>
>> Parameter --prod_type_cryptodev can be used to enable crypto producer
>mode.
>> Parameter --crypto_adptr_mode can be set to select the crypto adapter mode,
>0
>> for OP_NEW and 1 for OP_FORWARD.
>>
>> This mode can be used to measure the performance of crypto adapter.
>>
>> Example:
>> ./dpdk-test-eventdev -l 0-2 -w <EVENTDEV> -w <CRYPTODEV> -- \
>> --prod_type_cryptodev --crypto_adptr_mode 1 --test=perf_atq \
>> --stlist=a --wlcores 1 --plcores 2
>
>This patch has some perf failure as shown below. Could you please look into this?
>105300 --> performance testing fail
>
>Test environment and result as below:
>
>Ubuntu 20.04
>Kernel: 4.15.0-generic
>Compiler: gcc 7.4
>NIC: Intel Corporation Ethernet Converged Network Adapter 82599ES 10000 Mbps
>Target: x86_64-native-linuxapp-gcc
>Fail/Total: 0/4
>
>Detail performance results:
>+------------+---------+----------+-------------+------------------------------+
>| frame_size | txd/rxd | num_cpus | num_threads | throughput difference from
>|
>| | | | | expected |
>+============+=========+==========+=============+=============
>=================+
>| 64 | 512 | 1 | 1 | 0.3% |
>+------------+---------+----------+-------------+------------------------------+
>| 64 | 2048 | 1 | 1 | -0.2% |
>+------------+---------+----------+-------------+------------------------------+
>| 64 | 512 | 1 | 2 | 0.0% |
>+------------+---------+----------+-------------+------------------------------+
>| 64 | 2048 | 1 | 2 | 0.3% |
>+------------+---------+----------+-------------+------------------------------+
>
>Ubuntu 20.04
>Kernel: 4.15.0-generic
>Compiler: gcc 7.4
>NIC: Intel Corporation Ethernet Converged Network Adapter XL710-QDA2 40000
>Mbps
>Target: x86_64-native-linuxapp-gcc
>Fail/Total: 1/4
>
>Detail performance results:
>+------------+---------+----------+-------------+------------------------------+
>| frame_size | txd/rxd | num_cpus | num_threads | throughput difference from
>|
>| | | | | expected |
>+============+=========+==========+=============+=============
>=================+
>| 64 | 512 | 1 | 1 | 0.2% |
>+------------+---------+----------+-------------+------------------------------+
>| 64 | 2048 | 1 | 1 | -0.7% |
>+------------+---------+----------+-------------+------------------------------+
>| 64 | 512 | 1 | 2 | -1.5% |
>+------------+---------+----------+-------------+------------------------------+
>| 64 | 2048 | 1 | 2 | -5.3% |
>+------------+---------+----------+-------------+------------------------------+
>
>Ubuntu 20.04 ARM
>Kernel: 4.15.0-132-generic
>Compiler: gcc 7.5
>NIC: Arm Intel Corporation Ethernet Converged Network Adapter XL710-QDA2
>40000 Mbps
>Target: x86_64-native-linuxapp-gcc
>Fail/Total: 0/2
>
>Detail performance results:
>+------------+---------+----------+-------------+------------------------------+
>| frame_size | txd/rxd | num_cpus | num_threads | throughput difference from
>|
>| | | | | expected |
>+============+=========+==========+=============+=============
>=================+
>| 64 | 512 | 1 | 1 | 0.1% |
>+------------+---------+----------+-------------+------------------------------+
>| 64 | 2048 | 1 | 1 | -0.5% |
>+------------+---------+----------+-------------+------------------------------+
>
>To view detailed results, visit:
>https://urldefense.proofpoint.com/v2/url?u=https-
>3A__lab.dpdk.org_results_dashboard_patchsets_20534_&d=DwIFAg&c=nKjWec2
>b6R0mOyPaz7xtfQ&r=G9w4KsPaQLACBfGCL35PtiRH996yqJDxAZwrWegU2qQ&m=
>dPDgmKiLC_KqhgjwZrodyFlBdlFPgckVr9IW0c7t2cIHpkw6u9pGqgElFqqwuU1v&s=E
>ajYUFziZY27q6LB4p5sOGuFlty3VlOjbMsLXaQ5MeI&e=
>
Performance regression is reported by nic_single_core_perf, but is using testpmd
to measure performance. As this patch does not touch testpmd, the issue could
be with DPDK CI. Is it possible to re-trigger CI ?
>>
>> Signed-off-by: Shijith Thotton <sthotton@marvell.com>
>> ---
>> v2:
>> * Fix RHEL compilation warning.
>>
>> app/test-eventdev/evt_common.h | 3 +
>> app/test-eventdev/evt_main.c | 13 +-
>> app/test-eventdev/evt_options.c | 27 ++
>> app/test-eventdev/evt_options.h | 12 +
>> app/test-eventdev/evt_test.h | 6 +
>> app/test-eventdev/test_perf_atq.c | 51 ++++
>> app/test-eventdev/test_perf_common.c | 406
>++++++++++++++++++++++++++-
>> app/test-eventdev/test_perf_common.h | 16 ++ app/test-
>> eventdev/test_perf_queue.c | 52 ++++
>> doc/guides/tools/testeventdev.rst | 13 +
>> 10 files changed, 592 insertions(+), 7 deletions(-)
>>
>> diff --git a/app/test-eventdev/evt_common.h b/app/test-
>> eventdev/evt_common.h index f466434459..2f301a7e79 100644
>> --- a/app/test-eventdev/evt_common.h
>> +++ b/app/test-eventdev/evt_common.h
>> @@ -7,6 +7,7 @@
>>
>> #include <rte_common.h>
>> #include <rte_debug.h>
>> +#include <rte_event_crypto_adapter.h>
>> #include <rte_eventdev.h>
>> #include <rte_service.h>
>>
>> @@ -39,6 +40,7 @@ enum evt_prod_type {
>> EVT_PROD_TYPE_SYNT, /* Producer type Synthetic i.e. CPU. */
>> EVT_PROD_TYPE_ETH_RX_ADPTR, /* Producer type Eth Rx Adapter. */
>> EVT_PROD_TYPE_EVENT_TIMER_ADPTR, /* Producer type Timer
>> Adapter. */
>> + EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR, /* Producer type Crypto
>> Adapter. */
>> EVT_PROD_TYPE_MAX,
>> };
>>
>> @@ -77,6 +79,7 @@ struct evt_options {
>> uint64_t timer_tick_nsec;
>> uint64_t optm_timer_tick_nsec;
>> enum evt_prod_type prod_type;
>> + enum rte_event_crypto_adapter_mode crypto_adptr_mode;
>> };
>>
>> static inline bool
>> diff --git a/app/test-eventdev/evt_main.c b/app/test-eventdev/evt_main.c
>> index 194c980c7a..cef0fb1382 100644
>> --- a/app/test-eventdev/evt_main.c
>> +++ b/app/test-eventdev/evt_main.c
>> @@ -161,12 +161,19 @@ main(int argc, char **argv)
>> goto mempool_destroy;
>> }
>> }
>> + /* Test specific cryptodev setup */
>> + if (test->ops.cryptodev_setup) {
>> + if (test->ops.cryptodev_setup(test, &opt)) {
>> + evt_err("%s: cryptodev setup failed", opt.test_name);
>> + goto ethdev_destroy;
>> + }
>> + }
>>
>> /* Test specific eventdev setup */
>> if (test->ops.eventdev_setup) {
>> if (test->ops.eventdev_setup(test, &opt)) {
>> evt_err("%s: eventdev setup failed", opt.test_name);
>> - goto ethdev_destroy;
>> + goto cryptodev_destroy;
>> }
>> }
>>
>> @@ -197,6 +204,10 @@ main(int argc, char **argv)
>> if (test->ops.eventdev_destroy)
>> test->ops.eventdev_destroy(test, &opt);
>>
>> +cryptodev_destroy:
>> + if (test->ops.cryptodev_destroy)
>> + test->ops.cryptodev_destroy(test, &opt);
>> +
>> ethdev_destroy:
>> if (test->ops.ethdev_destroy)
>> test->ops.ethdev_destroy(test, &opt); diff --git a/app/test-
>> eventdev/evt_options.c b/app/test-eventdev/evt_options.c index
>> 753a7dbd7d..5ad1491020 100644
>> --- a/app/test-eventdev/evt_options.c
>> +++ b/app/test-eventdev/evt_options.c
>> @@ -122,6 +122,26 @@ evt_parse_timer_prod_type_burst(struct evt_options
>> *opt,
>> return 0;
>> }
>>
>> +static int
>> +evt_parse_crypto_prod_type(struct evt_options *opt,
>> + const char *arg __rte_unused)
>> +{
>> + opt->prod_type = EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR;
>> + return 0;
>> +}
>> +
>> +static int
>> +evt_parse_crypto_adptr_mode(struct evt_options *opt, const char *arg) {
>> + uint8_t mode;
>> + int ret;
>> +
>> + ret = parser_read_uint8(&mode, arg);
>> + opt->crypto_adptr_mode = mode ?
>> RTE_EVENT_CRYPTO_ADAPTER_OP_FORWARD :
>> +
>> RTE_EVENT_CRYPTO_ADAPTER_OP_NEW;
>> + return ret;
>> +}
>> +
>> static int
>> evt_parse_test_name(struct evt_options *opt, const char *arg) { @@ -335,6
>> +355,7 @@ usage(char *program)
>> "\t--queue_priority : enable queue priority\n"
>> "\t--deq_tmo_nsec : global dequeue timeout\n"
>> "\t--prod_type_ethdev : use ethernet device as producer.\n"
>> + "\t--prod_type_cryptodev : use crypto device as producer.\n"
>> "\t--prod_type_timerdev : use event timer device as
>> producer.\n"
>> "\t expity_nsec would be the timeout\n"
>> "\t in ns.\n"
>> @@ -345,6 +366,8 @@ usage(char *program)
>> "\t--timer_tick_nsec : timer tick interval in ns.\n"
>> "\t--max_tmo_nsec : max timeout interval in ns.\n"
>> "\t--expiry_nsec : event timer expiry ns.\n"
>> + "\t--crypto_adptr_mode : 0 for OP_NEW mode (default) and\n"
>> + "\t 1 for OP_FORWARD mode.\n"
>> "\t--mbuf_sz : packet mbuf size.\n"
>> "\t--max_pkt_sz : max packet size.\n"
>> "\t--prod_enq_burst_sz : producer enqueue burst size.\n"
>> @@ -415,8 +438,10 @@ static struct option lgopts[] = {
>> { EVT_QUEUE_PRIORITY, 0, 0, 0 },
>> { EVT_DEQ_TMO_NSEC, 1, 0, 0 },
>> { EVT_PROD_ETHDEV, 0, 0, 0 },
>> + { EVT_PROD_CRYPTODEV, 0, 0, 0 },
>> { EVT_PROD_TIMERDEV, 0, 0, 0 },
>> { EVT_PROD_TIMERDEV_BURST, 0, 0, 0 },
>> + { EVT_CRYPTO_ADPTR_MODE, 1, 0, 0 },
>> { EVT_NB_TIMERS, 1, 0, 0 },
>> { EVT_NB_TIMER_ADPTRS, 1, 0, 0 },
>> { EVT_TIMER_TICK_NSEC, 1, 0, 0 },
>> @@ -455,8 +480,10 @@ evt_opts_parse_long(int opt_idx, struct evt_options
>> *opt)
>> { EVT_QUEUE_PRIORITY, evt_parse_queue_priority},
>> { EVT_DEQ_TMO_NSEC, evt_parse_deq_tmo_nsec},
>> { EVT_PROD_ETHDEV, evt_parse_eth_prod_type},
>> + { EVT_PROD_CRYPTODEV, evt_parse_crypto_prod_type},
>> { EVT_PROD_TIMERDEV, evt_parse_timer_prod_type},
>> { EVT_PROD_TIMERDEV_BURST,
>> evt_parse_timer_prod_type_burst},
>> + { EVT_CRYPTO_ADPTR_MODE, evt_parse_crypto_adptr_mode},
>> { EVT_NB_TIMERS, evt_parse_nb_timers},
>> { EVT_NB_TIMER_ADPTRS, evt_parse_nb_timer_adptrs},
>> { EVT_TIMER_TICK_NSEC, evt_parse_timer_tick_nsec}, diff --git
>> a/app/test-eventdev/evt_options.h b/app/test-eventdev/evt_options.h index
>> 413d7092f0..2231c58801 100644
>> --- a/app/test-eventdev/evt_options.h
>> +++ b/app/test-eventdev/evt_options.h
>> @@ -9,6 +9,7 @@
>> #include <stdbool.h>
>>
>> #include <rte_common.h>
>> +#include <rte_cryptodev.h>
>> #include <rte_ethdev.h>
>> #include <rte_eventdev.h>
>> #include <rte_lcore.h>
>> @@ -33,8 +34,10 @@
>> #define EVT_QUEUE_PRIORITY ("queue_priority")
>> #define EVT_DEQ_TMO_NSEC ("deq_tmo_nsec")
>> #define EVT_PROD_ETHDEV ("prod_type_ethdev")
>> +#define EVT_PROD_CRYPTODEV ("prod_type_cryptodev")
>> #define EVT_PROD_TIMERDEV ("prod_type_timerdev")
>> #define EVT_PROD_TIMERDEV_BURST ("prod_type_timerdev_burst")
>> +#define EVT_CRYPTO_ADPTR_MODE ("crypto_adptr_mode")
>> #define EVT_NB_TIMERS ("nb_timers")
>> #define EVT_NB_TIMER_ADPTRS ("nb_timer_adptrs")
>> #define EVT_TIMER_TICK_NSEC ("timer_tick_nsec")
>> @@ -249,6 +252,8 @@ evt_prod_id_to_name(enum evt_prod_type prod_type)
>> return "Ethdev Rx Adapter";
>> case EVT_PROD_TYPE_EVENT_TIMER_ADPTR:
>> return "Event timer adapter";
>> + case EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR:
>> + return "Event crypto adapter";
>> }
>>
>> return "";
>> @@ -288,6 +293,13 @@ evt_dump_producer_type(struct evt_options *opt)
>> evt_dump("timer_tick_nsec", "%"PRIu64"",
>> opt->timer_tick_nsec);
>> break;
>> + case EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR:
>> + snprintf(name, EVT_PROD_MAX_NAME_LEN,
>> + "Event crypto adapter producers");
>> + evt_dump("crypto adapter mode", "%s",
>> + opt->crypto_adptr_mode ? "OP_FORWARD" :
>> "OP_NEW");
>> + evt_dump("nb_cryptodev", "%u", rte_cryptodev_count());
>> + break;
>> }
>> evt_dump("prod_type", "%s", name);
>> }
>> diff --git a/app/test-eventdev/evt_test.h b/app/test-eventdev/evt_test.h
>index
>> f07d2c3336..50fa474ec2 100644
>> --- a/app/test-eventdev/evt_test.h
>> +++ b/app/test-eventdev/evt_test.h
>> @@ -29,6 +29,8 @@ typedef int (*evt_test_mempool_setup_t)
>> (struct evt_test *test, struct evt_options *opt); typedef int
>> (*evt_test_ethdev_setup_t)
>> (struct evt_test *test, struct evt_options *opt);
>> +typedef int (*evt_test_cryptodev_setup_t)
>> + (struct evt_test *test, struct evt_options *opt);
>> typedef int (*evt_test_eventdev_setup_t)
>> (struct evt_test *test, struct evt_options *opt); typedef int
>> (*evt_test_launch_lcores_t) @@ -39,6 +41,8 @@ typedef void
>> (*evt_test_eventdev_destroy_t)
>> (struct evt_test *test, struct evt_options *opt); typedef void
>> (*evt_test_ethdev_destroy_t)
>> (struct evt_test *test, struct evt_options *opt);
>> +typedef void (*evt_test_cryptodev_destroy_t)
>> + (struct evt_test *test, struct evt_options *opt);
>> typedef void (*evt_test_mempool_destroy_t)
>> (struct evt_test *test, struct evt_options *opt); typedef void
>> (*evt_test_destroy_t) @@ -52,10 +56,12 @@ struct evt_test_ops {
>> evt_test_mempool_setup_t mempool_setup;
>> evt_test_ethdev_setup_t ethdev_setup;
>> evt_test_eventdev_setup_t eventdev_setup;
>> + evt_test_cryptodev_setup_t cryptodev_setup;
>> evt_test_launch_lcores_t launch_lcores;
>> evt_test_result_t test_result;
>> evt_test_eventdev_destroy_t eventdev_destroy;
>> evt_test_ethdev_destroy_t ethdev_destroy;
>> + evt_test_cryptodev_destroy_t cryptodev_destroy;
>> evt_test_mempool_destroy_t mempool_destroy;
>> evt_test_destroy_t test_destroy;
>> };
>> diff --git a/app/test-eventdev/test_perf_atq.c b/app/test-
>> eventdev/test_perf_atq.c
>> index 8fd51004ee..dbb1dc8c0c 100644
>> --- a/app/test-eventdev/test_perf_atq.c
>> +++ b/app/test-eventdev/test_perf_atq.c
>> @@ -48,6 +48,22 @@ perf_atq_worker(void *arg, const int
>> enable_fwd_latency)
>> continue;
>> }
>>
>> + if (prod_crypto_type &&
>> + (ev.event_type == RTE_EVENT_TYPE_CRYPTODEV)) {
>> + struct rte_crypto_op *op = ev.event_ptr;
>> +
>> + if (op->status == RTE_CRYPTO_OP_STATUS_SUCCESS) {
>> + if (op->sym->m_dst == NULL)
>> + ev.event_ptr = op->sym->m_src;
>> + else
>> + ev.event_ptr = op->sym->m_dst;
>> + rte_crypto_op_free(op);
>> + } else {
>> + rte_crypto_op_free(op);
>> + continue;
>> + }
>> + }
>> +
>> if (enable_fwd_latency && !prod_timer_type)
>> /* first stage in pipeline, mark ts to compute fwd latency */
>> atq_mark_fwd_latency(&ev);
>> @@ -87,6 +103,25 @@ perf_atq_worker_burst(void *arg, const int
>> enable_fwd_latency)
>> }
>>
>> for (i = 0; i < nb_rx; i++) {
>> + if (prod_crypto_type &&
>> + (ev[i].event_type == RTE_EVENT_TYPE_CRYPTODEV))
>> {
>> + struct rte_crypto_op *op = ev[i].event_ptr;
>> +
>> + if (op->status ==
>> + RTE_CRYPTO_OP_STATUS_SUCCESS) {
>> + if (op->sym->m_dst == NULL)
>> + ev[i].event_ptr =
>> + op->sym->m_src;
>> + else
>> + ev[i].event_ptr =
>> + op->sym->m_dst;
>> + rte_crypto_op_free(op);
>> + } else {
>> + rte_crypto_op_free(op);
>> + continue;
>> + }
>> + }
>> +
>> if (enable_fwd_latency && !prod_timer_type) {
>> rte_prefetch0(ev[i+1].event_ptr);
>> /* first stage in pipeline.
>> @@ -254,6 +289,20 @@ perf_atq_eventdev_setup(struct evt_test *test, struct
>> evt_options *opt)
>> return ret;
>> }
>> }
>> + } else if (opt->prod_type == EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR) {
>> + uint8_t cdev_id, cdev_count;
>> +
>> + cdev_count = rte_cryptodev_count();
>> + for (cdev_id = 0; cdev_id < cdev_count; cdev_id++) {
>> + ret = rte_cryptodev_start(cdev_id);
>> + if (ret) {
>> + evt_err("Failed to start cryptodev %u",
>> + cdev_id);
>> + return ret;
>> + }
>> + }
>> +
>> + rte_event_crypto_adapter_start(t->crypto_adptr.id);
>> }
>>
>> return 0;
>> @@ -295,12 +344,14 @@ static const struct evt_test_ops perf_atq = {
>> .opt_dump = perf_atq_opt_dump,
>> .test_setup = perf_test_setup,
>> .ethdev_setup = perf_ethdev_setup,
>> + .cryptodev_setup = perf_cryptodev_setup,
>> .mempool_setup = perf_mempool_setup,
>> .eventdev_setup = perf_atq_eventdev_setup,
>> .launch_lcores = perf_atq_launch_lcores,
>> .eventdev_destroy = perf_eventdev_destroy,
>> .mempool_destroy = perf_mempool_destroy,
>> .ethdev_destroy = perf_ethdev_destroy,
>> + .cryptodev_destroy = perf_cryptodev_destroy,
>> .test_result = perf_test_result,
>> .test_destroy = perf_test_destroy,
>> };
>> diff --git a/app/test-eventdev/test_perf_common.c b/app/test-
>> eventdev/test_perf_common.c
>> index 9b73874151..7b964ab8dc 100644
>> --- a/app/test-eventdev/test_perf_common.c
>> +++ b/app/test-eventdev/test_perf_common.c
>> @@ -6,6 +6,8 @@
>>
>> #include "test_perf_common.h"
>>
>> +#define NB_CRYPTODEV_DESCRIPTORS 128
>> +
>> int
>> perf_test_result(struct evt_test *test, struct evt_options *opt) { @@ -272,6
>> +274,121 @@ perf_event_timer_producer_burst(void *arg)
>> return 0;
>> }
>>
>> +static inline void
>> +crypto_adapter_enq_op_new(struct prod_data *p) {
>> + struct test_perf *t = p->t;
>> + const uint32_t nb_flows = t->nb_flows;
>> + const uint64_t nb_pkts = t->nb_pkts;
>> + struct rte_mempool *pool = t->pool;
>> + struct rte_crypto_sym_op *sym_op;
>> + struct evt_options *opt = t->opt;
>> + uint32_t flow_counter = 0;
>> + struct rte_crypto_op *op;
>> + struct rte_mbuf *m;
>> + uint64_t count = 0;
>> + uint16_t len;
>> +
>> + if (opt->verbose_level > 1)
>> + printf("%s(): lcore %d queue %d cdev_id %u cdev_qp_id %u\n",
>> + __func__, rte_lcore_id(), p->queue_id, p->cdev_id,
>> + p->cdev_qp_id);
>> +
>> + len = opt->mbuf_sz ? opt->mbuf_sz : RTE_ETHER_MIN_LEN;
>> +
>> + while (count < nb_pkts && t->done == false) {
>> + m = rte_pktmbuf_alloc(pool);
>> + if (m == NULL)
>> + continue;
>> +
>> + rte_pktmbuf_append(m, len);
>> + op = rte_crypto_op_alloc(t->crypto_adptr.op_pool,
>> + RTE_CRYPTO_OP_TYPE_SYMMETRIC);
>> + sym_op = op->sym;
>> + sym_op->m_src = m;
>> + sym_op->cipher.data.offset = 0;
>> + sym_op->cipher.data.length = len;
>> + rte_crypto_op_attach_sym_session(
>> + op, p->crypto_sess[flow_counter++ % nb_flows]);
>> + while (rte_cryptodev_enqueue_burst(p->cdev_id, p-
>> >cdev_qp_id,
>> + &op, 1) != 1) {
>> + if (t->done)
>> + break;
>> + rte_pause();
>> + }
>> + count++;
>> + }
>> +}
>> +
>> +static inline void
>> +crypto_adapter_enq_op_fwd(struct prod_data *p) {
>> + const uint8_t dev_id = p->dev_id;
>> + const uint8_t port = p->port_id;
>> + struct test_perf *t = p->t;
>> + const uint32_t nb_flows = t->nb_flows;
>> + const uint64_t nb_pkts = t->nb_pkts;
>> + struct rte_mempool *pool = t->pool;
>> + struct evt_options *opt = t->opt;
>> + struct rte_crypto_sym_op *sym_op;
>> + uint32_t flow_counter = 0;
>> + struct rte_crypto_op *op;
>> + struct rte_event ev;
>> + struct rte_mbuf *m;
>> + uint64_t count = 0;
>> + uint16_t len;
>> +
>> + if (opt->verbose_level > 1)
>> + printf("%s(): lcore %d port %d queue %d cdev_id %u cdev_qp_id
>> %u\n",
>> + __func__, rte_lcore_id(), port, p->queue_id, p->cdev_id,
>> + p->cdev_qp_id);
>> +
>> + ev.event = 0;
>> + ev.op = RTE_EVENT_OP_NEW;
>> + ev.queue_id = p->queue_id;
>> + ev.sched_type = RTE_SCHED_TYPE_ATOMIC;
>> + ev.event_type = RTE_EVENT_TYPE_CPU;
>> + len = opt->mbuf_sz ? opt->mbuf_sz : RTE_ETHER_MIN_LEN;
>> +
>> + while (count < nb_pkts && t->done == false) {
>> + m = rte_pktmbuf_alloc(pool);
>> + if (m == NULL)
>> + continue;
>> +
>> + rte_pktmbuf_append(m, len);
>> + op = rte_crypto_op_alloc(t->crypto_adptr.op_pool,
>> + RTE_CRYPTO_OP_TYPE_SYMMETRIC);
>> + sym_op = op->sym;
>> + sym_op->m_src = m;
>> + sym_op->cipher.data.offset = 0;
>> + sym_op->cipher.data.length = len;
>> + rte_crypto_op_attach_sym_session(
>> + op, p->crypto_sess[flow_counter++ % nb_flows]);
>> + ev.event_ptr = op;
>> + while (rte_event_crypto_adapter_enqueue(dev_id, port, &ev, 1)
>> !=
>> + 1) {
>> + if (t->done)
>> + break;
>> + rte_pause();
>> + }
>> + count++;
>> + }
>> +}
>> +
>> +static inline int
>> +perf_event_crypto_producer(void *arg)
>> +{
>> + struct prod_data *p = arg;
>> + struct evt_options *opt = p->t->opt;
>> +
>> + if (opt->crypto_adptr_mode ==
>> RTE_EVENT_CRYPTO_ADAPTER_OP_NEW)
>> + crypto_adapter_enq_op_new(p);
>> + else
>> + crypto_adapter_enq_op_fwd(p);
>> +
>> + return 0;
>> +}
>> +
>> static int
>> perf_producer_wrapper(void *arg)
>> {
>> @@ -298,6 +415,8 @@ perf_producer_wrapper(void *arg)
>> else if (t->opt->prod_type == EVT_PROD_TYPE_EVENT_TIMER_ADPTR
>> &&
>> t->opt->timdev_use_burst)
>> return perf_event_timer_producer_burst(arg);
>> + else if (t->opt->prod_type == EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR)
>> + return perf_event_crypto_producer(arg);
>> return 0;
>> }
>>
>> @@ -405,8 +524,10 @@ perf_launch_lcores(struct evt_test *test, struct
>> evt_options *opt,
>> if (remaining <= 0) {
>> t->result = EVT_TEST_SUCCESS;
>> if (opt->prod_type == EVT_PROD_TYPE_SYNT
>> ||
>> - opt->prod_type ==
>> -
>> EVT_PROD_TYPE_EVENT_TIMER_ADPTR) {
>> + opt->prod_type ==
>> +
>> EVT_PROD_TYPE_EVENT_TIMER_ADPTR ||
>> + opt->prod_type ==
>> +
>> EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR) {
>> t->done = true;
>> break;
>> }
>> @@ -415,7 +536,8 @@ perf_launch_lcores(struct evt_test *test, struct
>> evt_options *opt,
>>
>> if (new_cycles - dead_lock_cycles > dead_lock_sample &&
>> (opt->prod_type == EVT_PROD_TYPE_SYNT ||
>> - opt->prod_type == EVT_PROD_TYPE_EVENT_TIMER_ADPTR))
>> {
>> + opt->prod_type == EVT_PROD_TYPE_EVENT_TIMER_ADPTR
>> ||
>> + opt->prod_type ==
>> EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR)) {
>> remaining = t->outstand_pkts - processed_pkts(t);
>> if (dead_lock_remaining == remaining) {
>> rte_event_dev_dump(opt->dev_id, stdout);
>> @@ -537,6 +659,96 @@ perf_event_timer_adapter_setup(struct test_perf *t)
>> return 0;
>> }
>>
>> +static int
>> +perf_event_crypto_adapter_setup(struct test_perf *t,
>> + struct rte_event_port_conf port_conf) {
>> + struct evt_options *opt = t->opt;
>> + uint8_t cdev_id, cdev_count;
>> + int ret;
>> +
>> + t->crypto_adptr.id = 0;
>> + ret = rte_event_crypto_adapter_create(t->crypto_adptr.id, opt->dev_id,
>> + &port_conf, 0);
>> + if (ret)
>> + return ret;
>> +
>> + cdev_count = rte_cryptodev_count();
>> + for (cdev_id = 0; cdev_id < cdev_count; cdev_id++) {
>> + uint32_t cap;
>> +
>> + ret = rte_event_crypto_adapter_caps_get(opt->dev_id,
>> cdev_id,
>> + &cap);
>> + if (ret) {
>> + evt_err("Failed to get crypto adapter capabilities");
>> + return ret;
>> + }
>> +
>> + if (((opt->crypto_adptr_mode ==
>> + RTE_EVENT_CRYPTO_ADAPTER_OP_NEW) &&
>> + !(cap &
>> +
>> RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_OP_NEW)) ||
>> + ((opt->crypto_adptr_mode ==
>> + RTE_EVENT_CRYPTO_ADAPTER_OP_FORWARD) &&
>> + !(cap &
>> +
>> RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_OP_FWD))) {
>> + evt_err("crypto adapter %s mode unsupported\n",
>> + opt->crypto_adptr_mode ? "OP_FORWARD" :
>> + "OP_NEW");
>> + return -EINVAL;
>> + }
>> +
>> + if (!(cap &
>> +
>> RTE_EVENT_CRYPTO_ADAPTER_CAP_SESSION_PRIVATE_DATA)) {
>> + evt_err("Storing crypto session not supported");
>> + return -EINVAL;
>> + }
>> +
>> + if (cap &
>> +
>> RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_QP_EV_BIND) {
>> + struct rte_event response_info;
>> +
>> + response_info.event = 0;
>> + ret = rte_event_crypto_adapter_queue_pair_add(
>> + t->crypto_adptr.id, cdev_id, -1,
>> + &response_info);
>> + } else {
>> + ret = rte_event_crypto_adapter_queue_pair_add(
>> + t->crypto_adptr.id, cdev_id, -1, NULL);
>> + }
>> + if (ret)
>> + return ret;
>> + }
>> +
>> + return 0;
>> +}
>> +
>> +static struct rte_cryptodev_sym_session *
>> +cryptodev_session_create(struct prod_data *p, struct test_perf *t) {
>> + struct rte_crypto_sym_xform cipher_xform;
>> + struct rte_cryptodev_sym_session *sess;
>> +
>> + cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
>> + cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
>> + cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
>> + cipher_xform.next = NULL;
>> +
>> + sess = rte_cryptodev_sym_session_create(t->crypto_adptr.sess_pool);
>> + if (sess == NULL) {
>> + evt_err("Failed to create sym session");
>> + return NULL;
>> + }
>> +
>> + if (rte_cryptodev_sym_session_init(p->cdev_id, sess, &cipher_xform,
>> + t->crypto_adptr.sess_priv_pool)) {
>> + evt_err("Failed to init session");
>> + return NULL;
>> + }
>> +
>> + return sess;
>> +}
>> +
>> int
>> perf_event_dev_port_setup(struct evt_test *test, struct evt_options *opt,
>> uint8_t stride, uint8_t nb_queues,
>> @@ -598,6 +810,55 @@ perf_event_dev_port_setup(struct evt_test *test,
>> struct evt_options *opt,
>> ret = perf_event_timer_adapter_setup(t);
>> if (ret)
>> return ret;
>> + } else if (opt->prod_type == EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR) {
>> + uint8_t cdev_id = 0;
>> + uint16_t qp_id = 0;
>> +
>> + prod = 0;
>> + for (; port < perf_nb_event_ports(opt); port++) {
>> + struct rte_cryptodev_sym_session *crypto_sess;
>> + union rte_event_crypto_metadata m_data;
>> + struct prod_data *p = &t->prod[port];
>> + uint32_t flow_id;
>> +
>> + if (qp_id == rte_cryptodev_queue_pair_count(cdev_id))
>> {
>> + cdev_id++;
>> + qp_id = 0;
>> + }
>> +
>> + p->dev_id = opt->dev_id;
>> + p->port_id = port;
>> + p->queue_id = prod * stride;
>> + p->cdev_id = cdev_id;
>> + p->cdev_qp_id = qp_id;
>> + p->crypto_sess = rte_zmalloc_socket(
>> + NULL, sizeof(crypto_sess) * t->nb_flows,
>> + RTE_CACHE_LINE_SIZE, opt->socket_id);
>> +
>> + m_data.request_info.cdev_id = p->cdev_id;
>> + m_data.request_info.queue_pair_id = p->cdev_qp_id;
>> + m_data.response_info.op = RTE_EVENT_OP_NEW;
>> + m_data.response_info.sched_type =
>> RTE_SCHED_TYPE_ATOMIC;
>> + m_data.response_info.event_type =
>> RTE_EVENT_TYPE_CPU;
>> + m_data.response_info.queue_id = p->queue_id;
>> + for (flow_id = 0; flow_id < t->nb_flows; flow_id++) {
>> + crypto_sess = cryptodev_session_create(p, t);
>> + if (crypto_sess == NULL)
>> + return -ENOMEM;
>> +
>> + m_data.response_info.flow_id = flow_id;
>> + rte_cryptodev_sym_session_set_user_data(
>> + crypto_sess, &m_data,
>> sizeof(m_data));
>> + p->crypto_sess[flow_id] = crypto_sess;
>> + }
>> + p->t = t;
>> + qp_id++;
>> + prod++;
>> + }
>> +
>> + ret = perf_event_crypto_adapter_setup(t, *port_conf);
>> + if (ret)
>> + return ret;
>> } else {
>> prod = 0;
>> for ( ; port < perf_nb_event_ports(opt); port++) { @@ -659,7
>> +920,8 @@ perf_opt_check(struct evt_options *opt, uint64_t nb_queues)
>> }
>>
>> if (opt->prod_type == EVT_PROD_TYPE_SYNT ||
>> - opt->prod_type ==
>> EVT_PROD_TYPE_EVENT_TIMER_ADPTR) {
>> + opt->prod_type == EVT_PROD_TYPE_EVENT_TIMER_ADPTR ||
>> + opt->prod_type == EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR) {
>> /* Validate producer lcores */
>> if (evt_lcores_has_overlap(opt->plcores,
>> rte_get_main_lcore())) {
>> @@ -767,8 +1029,7 @@ perf_ethdev_setup(struct evt_test *test, struct
>> evt_options *opt)
>> },
>> };
>>
>> - if (opt->prod_type == EVT_PROD_TYPE_SYNT ||
>> - opt->prod_type ==
>> EVT_PROD_TYPE_EVENT_TIMER_ADPTR)
>> + if (opt->prod_type != EVT_PROD_TYPE_ETH_RX_ADPTR)
>> return 0;
>>
>> if (!rte_eth_dev_count_avail()) {
>> @@ -841,6 +1102,139 @@ void perf_ethdev_destroy(struct evt_test *test,
>> struct evt_options *opt)
>> }
>> }
>>
>> +int
>> +perf_cryptodev_setup(struct evt_test *test, struct evt_options *opt) {
>> + uint8_t cdev_count, cdev_id, nb_plcores, nb_qps;
>> + struct test_perf *t = evt_test_priv(test);
>> + unsigned int max_session_size;
>> + uint32_t nb_sessions;
>> + int ret;
>> +
>> + if (opt->prod_type != EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR)
>> + return 0;
>> +
>> + cdev_count = rte_cryptodev_count();
>> + if (cdev_count == 0) {
>> + evt_err("No crypto devices available\n");
>> + return -ENODEV;
>> + }
>> +
>> + t->crypto_adptr.op_pool = rte_crypto_op_pool_create(
>> + "crypto_op_pool", RTE_CRYPTO_OP_TYPE_SYMMETRIC, opt-
>> >pool_sz,
>> + 128, 0, rte_socket_id());
>> + if (t->crypto_adptr.op_pool == NULL) {
>> + evt_err("Failed to create crypto op pool");
>> + return -ENOMEM;
>> + }
>> +
>> + nb_sessions = evt_nr_active_lcores(opt->plcores) * t->nb_flows;
>> + t->crypto_adptr.sess_pool = rte_cryptodev_sym_session_pool_create(
>> + "ca_sess_pool", nb_sessions, 0, 0,
>> + sizeof(union rte_event_crypto_metadata), SOCKET_ID_ANY);
>> + if (t->crypto_adptr.sess_pool == NULL) {
>> + evt_err("Failed to create sym session pool");
>> + ret = -ENOMEM;
>> + goto err;
>> + }
>> +
>> + max_session_size = 0;
>> + for (cdev_id = 0; cdev_id < cdev_count; cdev_id++) {
>> + unsigned int session_size;
>> +
>> + session_size =
>> + rte_cryptodev_sym_get_private_session_size(cdev_id);
>> + if (session_size > max_session_size)
>> + max_session_size = session_size;
>> + }
>> + max_session_size += sizeof(union rte_event_crypto_metadata);
>> + t->crypto_adptr.sess_priv_pool = rte_mempool_create(
>> + "ca_sess_priv_pool", nb_sessions, max_session_size, 0, 0,
>> NULL,
>> + NULL, NULL, NULL, SOCKET_ID_ANY, 0);
>> + if (t->crypto_adptr.sess_priv_pool == NULL) {
>> + evt_err("failed to create sym session private pool");
>> + ret = -ENOMEM;
>> + goto err;
>> + }
>> +
>> + nb_plcores = evt_nr_active_lcores(opt->plcores);
>> + nb_qps = (nb_plcores % cdev_count) ? (nb_plcores / cdev_count) + 1 :
>> + nb_plcores / cdev_count;
>> + for (cdev_id = 0; cdev_id < cdev_count; cdev_id++) {
>> + struct rte_cryptodev_qp_conf qp_conf;
>> + struct rte_cryptodev_config conf;
>> + struct rte_cryptodev_info info;
>> + int qp_id;
>> +
>> + rte_cryptodev_info_get(cdev_id, &info);
>> + if (nb_qps > info.max_nb_queue_pairs) {
>> + evt_err("Not enough queue pairs per cryptodev (%u)",
>> + nb_qps);
>> + ret = -EINVAL;
>> + goto err;
>> + }
>> +
>> + conf.nb_queue_pairs = nb_qps;
>> + conf.socket_id = SOCKET_ID_ANY;
>> + conf.ff_disable = RTE_CRYPTODEV_FF_SECURITY;
>> +
>> + ret = rte_cryptodev_configure(cdev_id, &conf);
>> + if (ret) {
>> + evt_err("Failed to configure cryptodev (%u)", cdev_id);
>> + goto err;
>> + }
>> +
>> + qp_conf.nb_descriptors = NB_CRYPTODEV_DESCRIPTORS;
>> + qp_conf.mp_session = t->crypto_adptr.sess_pool;
>> + qp_conf.mp_session_private = t->crypto_adptr.sess_priv_pool;
>> +
>> + for (qp_id = 0; qp_id < conf.nb_queue_pairs; qp_id++) {
>> + ret = rte_cryptodev_queue_pair_setup(
>> + cdev_id, qp_id, &qp_conf,
>> + rte_cryptodev_socket_id(cdev_id));
>> + if (ret) {
>> + evt_err("Failed to setup queue pairs on
>> cryptodev %u\n",
>> + cdev_id);
>> + goto err;
>> + }
>> + }
>> + }
>> +
>> + return 0;
>> +err:
>> + rte_mempool_free(t->crypto_adptr.op_pool);
>> + rte_mempool_free(t->crypto_adptr.sess_pool);
>> + rte_mempool_free(t->crypto_adptr.sess_priv_pool);
>> +
>> + return ret;
>> +}
>> +
>> +void
>> +perf_cryptodev_destroy(struct evt_test *test, struct evt_options *opt)
>> +{
>> + uint8_t cdev_id, cdev_count = rte_cryptodev_count();
>> + struct test_perf *t = evt_test_priv(test);
>> +
>> + RTE_SET_USED(opt);
>> +
>> + if (opt->prod_type != EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR)
>> + return;
>> +
>> + rte_event_crypto_adapter_stop(t->crypto_adptr.id);
>> +
>> + for (cdev_id = 0; cdev_id < cdev_count; cdev_id++) {
>> + rte_cryptodev_stop(cdev_id);
>> + rte_event_crypto_adapter_queue_pair_del(t->crypto_adptr.id,
>> + cdev_id, -1);
>> + }
>> +
>> + rte_event_crypto_adapter_free(t->crypto_adptr.id);
>> +
>> + rte_mempool_free(t->crypto_adptr.op_pool);
>> + rte_mempool_free(t->crypto_adptr.sess_pool);
>> + rte_mempool_free(t->crypto_adptr.sess_priv_pool);
>> +}
>> +
>> int
>> perf_mempool_setup(struct evt_test *test, struct evt_options *opt) { diff --git
>> a/app/test-eventdev/test_perf_common.h b/app/test-
>> eventdev/test_perf_common.h
>> index 14dcf80429..d9ad3a0b0d 100644
>> --- a/app/test-eventdev/test_perf_common.h
>> +++ b/app/test-eventdev/test_perf_common.h
>> @@ -9,9 +9,11 @@
>> #include <stdbool.h>
>> #include <unistd.h>
>>
>> +#include <rte_cryptodev.h>
>> #include <rte_cycles.h>
>> #include <rte_ethdev.h>
>> #include <rte_eventdev.h>
>> +#include <rte_event_crypto_adapter.h>
>> #include <rte_event_eth_rx_adapter.h>
>> #include <rte_event_timer_adapter.h>
>> #include <rte_lcore.h>
>> @@ -37,9 +39,18 @@ struct prod_data {
>> uint8_t dev_id;
>> uint8_t port_id;
>> uint8_t queue_id;
>> + uint8_t cdev_id;
>> + uint16_t cdev_qp_id;
>> + struct rte_cryptodev_sym_session **crypto_sess;
>> struct test_perf *t;
>> } __rte_cache_aligned;
>>
>> +struct crypto_adptr_data {
>> + uint8_t id;
>> + struct rte_mempool *op_pool;
>> + struct rte_mempool *sess_pool;
>> + struct rte_mempool *sess_priv_pool;
>> +};
>>
>> struct test_perf {
>> /* Don't change the offset of "done". Signal handler use this memory
>> @@ -58,6 +69,7 @@ struct test_perf {
>> uint8_t sched_type_list[EVT_MAX_STAGES] __rte_cache_aligned;
>> struct rte_event_timer_adapter *timer_adptr[
>> RTE_EVENT_TIMER_ADAPTER_NUM_MAX]
>> __rte_cache_aligned;
>> + struct crypto_adptr_data crypto_adptr;
>> } __rte_cache_aligned;
>>
>> struct perf_elt {
>> @@ -81,6 +93,8 @@ struct perf_elt {
>> const uint8_t port = w->port_id;\
>> const uint8_t prod_timer_type = \
>> opt->prod_type == EVT_PROD_TYPE_EVENT_TIMER_ADPTR;\
>> + const uint8_t prod_crypto_type = \
>> + opt->prod_type == EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR;\
>> uint8_t *const sched_type_list = &t->sched_type_list[0];\
>> struct rte_mempool *const pool = t->pool;\
>> const uint8_t nb_stages = t->opt->nb_stages;\ @@ -154,6 +168,7 @@
>> int perf_test_result(struct evt_test *test, struct evt_options *opt); int
>> perf_opt_check(struct evt_options *opt, uint64_t nb_queues); int
>> perf_test_setup(struct evt_test *test, struct evt_options *opt); int
>> perf_ethdev_setup(struct evt_test *test, struct evt_options *opt);
>> +int perf_cryptodev_setup(struct evt_test *test, struct evt_options
>> +*opt);
>> int perf_mempool_setup(struct evt_test *test, struct evt_options *opt); int
>> perf_event_dev_port_setup(struct evt_test *test, struct evt_options *opt,
>> uint8_t stride, uint8_t nb_queues,
>> @@ -164,6 +179,7 @@ int perf_launch_lcores(struct evt_test *test, struct
>> evt_options *opt, void perf_opt_dump(struct evt_options *opt, uint8_t
>> nb_queues); void perf_test_destroy(struct evt_test *test, struct evt_options
>> *opt); void perf_eventdev_destroy(struct evt_test *test, struct evt_options
>> *opt);
>> +void perf_cryptodev_destroy(struct evt_test *test, struct evt_options
>> +*opt);
>> void perf_ethdev_destroy(struct evt_test *test, struct evt_options *opt); void
>> perf_mempool_destroy(struct evt_test *test, struct evt_options *opt);
>>
>> diff --git a/app/test-eventdev/test_perf_queue.c b/app/test-
>> eventdev/test_perf_queue.c
>> index f4ea3a795f..5657c8b3cd 100644
>> --- a/app/test-eventdev/test_perf_queue.c
>> +++ b/app/test-eventdev/test_perf_queue.c
>> @@ -49,6 +49,23 @@ perf_queue_worker(void *arg, const int
>> enable_fwd_latency)
>> rte_pause();
>> continue;
>> }
>> +
>> + if (prod_crypto_type &&
>> + (ev.event_type == RTE_EVENT_TYPE_CRYPTODEV)) {
>> + struct rte_crypto_op *op = ev.event_ptr;
>> +
>> + if (op->status == RTE_CRYPTO_OP_STATUS_SUCCESS) {
>> + if (op->sym->m_dst == NULL)
>> + ev.event_ptr = op->sym->m_src;
>> + else
>> + ev.event_ptr = op->sym->m_dst;
>> + rte_crypto_op_free(op);
>> + } else {
>> + rte_crypto_op_free(op);
>> + continue;
>> + }
>> + }
>> +
>> if (enable_fwd_latency && !prod_timer_type)
>> /* first q in pipeline, mark timestamp to compute fwd latency */
>> mark_fwd_latency(&ev, nb_stages);
>> @@ -88,6 +105,25 @@ perf_queue_worker_burst(void *arg, const int
>> enable_fwd_latency)
>> }
>>
>> for (i = 0; i < nb_rx; i++) {
>> + if (prod_crypto_type &&
>> + (ev[i].event_type == RTE_EVENT_TYPE_CRYPTODEV))
>> {
>> + struct rte_crypto_op *op = ev[i].event_ptr;
>> +
>> + if (op->status ==
>> + RTE_CRYPTO_OP_STATUS_SUCCESS) {
>> + if (op->sym->m_dst == NULL)
>> + ev[i].event_ptr =
>> + op->sym->m_src;
>> + else
>> + ev[i].event_ptr =
>> + op->sym->m_dst;
>> + rte_crypto_op_free(op);
>> + } else {
>> + rte_crypto_op_free(op);
>> + continue;
>> + }
>> + }
>> +
>> if (enable_fwd_latency && !prod_timer_type) {
>> rte_prefetch0(ev[i+1].event_ptr);
>> /* first queue in pipeline.
>> @@ -269,6 +305,20 @@ perf_queue_eventdev_setup(struct evt_test *test,
>> struct evt_options *opt)
>> return ret;
>> }
>> }
>> + } else if (opt->prod_type == EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR) {
>> + uint8_t cdev_id, cdev_count;
>> +
>> + cdev_count = rte_cryptodev_count();
>> + for (cdev_id = 0; cdev_id < cdev_count; cdev_id++) {
>> + ret = rte_cryptodev_start(cdev_id);
>> + if (ret) {
>> + evt_err("Failed to start cryptodev %u",
>> + cdev_id);
>> + return ret;
>> + }
>> + }
>> +
>> + rte_event_crypto_adapter_start(t->crypto_adptr.id);
>> }
>>
>> return 0;
>> @@ -311,11 +361,13 @@ static const struct evt_test_ops perf_queue = {
>> .test_setup = perf_test_setup,
>> .mempool_setup = perf_mempool_setup,
>> .ethdev_setup = perf_ethdev_setup,
>> + .cryptodev_setup = perf_cryptodev_setup,
>> .eventdev_setup = perf_queue_eventdev_setup,
>> .launch_lcores = perf_queue_launch_lcores,
>> .eventdev_destroy = perf_eventdev_destroy,
>> .mempool_destroy = perf_mempool_destroy,
>> .ethdev_destroy = perf_ethdev_destroy,
>> + .cryptodev_destroy = perf_cryptodev_destroy,
>> .test_result = perf_test_result,
>> .test_destroy = perf_test_destroy,
>> };
>> diff --git a/doc/guides/tools/testeventdev.rst
>> b/doc/guides/tools/testeventdev.rst
>> index 48efb9ea6e..f7d813226d 100644
>> --- a/doc/guides/tools/testeventdev.rst
>> +++ b/doc/guides/tools/testeventdev.rst
>> @@ -120,6 +120,10 @@ The following are the application command-line
>> options:
>>
>> Use burst mode event timer adapter as producer.
>>
>> +* ``--prod_type_cryptodev``
>> +
>> + Use crypto device as producer.
>> +
>> * ``--timer_tick_nsec``
>>
>> Used to dictate number of nano seconds between bucket traversal of the
>> @@ -148,6 +152,11 @@ The following are the application command-line
>> options:
>> timeout is out of the supported range of event device it will be
>> adjusted to the highest/lowest supported dequeue timeout supported.
>>
>> +* ``--crypto_adptr_mode``
>> +
>> + Set crypto adapter mode. Use 0 for OP_NEW (default) and 1 for
>> + OP_FORWARD mode.
>> +
>> * ``--mbuf_sz``
>>
>> Set packet mbuf size. Can be used to configure Jumbo Frames. Only @@ -
>> 420,6 +429,7 @@ Supported application command line options are following::
>> --prod_type_ethdev
>> --prod_type_timerdev_burst
>> --prod_type_timerdev
>> + --prod_type_cryptodev
>> --prod_enq_burst_sz
>> --timer_tick_nsec
>> --max_tmo_nsec
>> @@ -427,6 +437,7 @@ Supported application command line options are
>> following::
>> --nb_timers
>> --nb_timer_adptrs
>> --deq_tmo_nsec
>> + --crypto_adptr_mode
>>
>> Example
>> ^^^^^^^
>> @@ -529,12 +540,14 @@ Supported application command line options are
>> following::
>> --prod_type_ethdev
>> --prod_type_timerdev_burst
>> --prod_type_timerdev
>> + --prod_type_cryptodev
>> --timer_tick_nsec
>> --max_tmo_nsec
>> --expiry_nsec
>> --nb_timers
>> --nb_timer_adptrs
>> --deq_tmo_nsec
>> + --crypto_adptr_mode
>>
>> Example
>> ^^^^^^^
>> --
>> 2.25.1
^ permalink raw reply [flat|nested] 43+ messages in thread
* RE: [PATCH v2] app/eventdev: add crypto producer mode
2022-01-03 6:04 ` Shijith Thotton
@ 2022-01-03 8:46 ` Gujjar, Abhinandan S
2022-01-03 9:14 ` Shijith Thotton
0 siblings, 1 reply; 43+ messages in thread
From: Gujjar, Abhinandan S @ 2022-01-03 8:46 UTC (permalink / raw)
To: Shijith Thotton, dev, Jerin Jacob Kollanukkaran, dpdklab, aconole
Cc: Anoob Joseph, Pavan Nikhilesh Bhagavatula, Akhil Goyal
Hi Shijith,
> -----Original Message-----
> From: Shijith Thotton <sthotton@marvell.com>
> Sent: Monday, January 3, 2022 11:34 AM
> To: Gujjar, Abhinandan S <abhinandan.gujjar@intel.com>; dev@dpdk.org; Jerin
> Jacob Kollanukkaran <jerinj@marvell.com>
> Cc: Anoob Joseph <anoobj@marvell.com>; Pavan Nikhilesh Bhagavatula
> <pbhagavatula@marvell.com>; Akhil Goyal <gakhil@marvell.com>
> Subject: RE: [PATCH v2] app/eventdev: add crypto producer mode
>
> Hi Abhinandan,
>
> >> Subject: [PATCH v2] app/eventdev: add crypto producer mode
> >>
> >> In crypto producer mode, producer core enqueues cryptodev with
> >> software generated crypto ops and worker core dequeues crypto
> >> completion events from the eventdev. Event crypto metadata used for
> >> above processing is pre- populated in each crypto session.
> >>
> >> Parameter --prod_type_cryptodev can be used to enable crypto producer
> >mode.
> >> Parameter --crypto_adptr_mode can be set to select the crypto adapter
> >> mode,
> >0
> >> for OP_NEW and 1 for OP_FORWARD.
> >>
> >> This mode can be used to measure the performance of crypto adapter.
> >>
> >> Example:
> >> ./dpdk-test-eventdev -l 0-2 -w <EVENTDEV> -w <CRYPTODEV> -- \
> >> --prod_type_cryptodev --crypto_adptr_mode 1 --test=perf_atq \
> >> --stlist=a --wlcores 1 --plcores 2
> >
> >This patch has some perf failure as shown below. Could you please look into
> this?
> >105300 --> performance testing fail
> >
> >Test environment and result as below:
> >
> >Ubuntu 20.04
> >Kernel: 4.15.0-generic
> >Compiler: gcc 7.4
> >NIC: Intel Corporation Ethernet Converged Network Adapter 82599ES 10000
> >Mbps
> >Target: x86_64-native-linuxapp-gcc
> >Fail/Total: 0/4
> >
> >Detail performance results:
> >+------------+---------+----------+-------------+------------------------------+
> >| frame_size | txd/rxd | num_cpus | num_threads | throughput
> >| difference from
> >|
> >| | | | | expected |
> >+============+=========+==========+=============+=============
> >=================+
> >| 64 | 512 | 1 | 1 | 0.3% |
> >+------------+---------+----------+-------------+------------------------------+
> >| 64 | 2048 | 1 | 1 | -0.2% |
> >+------------+---------+----------+-------------+------------------------------+
> >| 64 | 512 | 1 | 2 | 0.0% |
> >+------------+---------+----------+-------------+------------------------------+
> >| 64 | 2048 | 1 | 2 | 0.3% |
> >+------------+---------+----------+-------------+------------------------------+
> >
> >Ubuntu 20.04
> >Kernel: 4.15.0-generic
> >Compiler: gcc 7.4
> >NIC: Intel Corporation Ethernet Converged Network Adapter XL710-QDA2
> >40000 Mbps
> >Target: x86_64-native-linuxapp-gcc
> >Fail/Total: 1/4
> >
> >Detail performance results:
> >+------------+---------+----------+-------------+------------------------------+
> >| frame_size | txd/rxd | num_cpus | num_threads | throughput
> >| difference from
> >|
> >| | | | | expected |
> >+============+=========+==========+=============+=============
> >=================+
> >| 64 | 512 | 1 | 1 | 0.2% |
> >+------------+---------+----------+-------------+------------------------------+
> >| 64 | 2048 | 1 | 1 | -0.7% |
> >+------------+---------+----------+-------------+------------------------------+
> >| 64 | 512 | 1 | 2 | -1.5% |
> >+------------+---------+----------+-------------+------------------------------+
> >| 64 | 2048 | 1 | 2 | -5.3% |
> >+------------+---------+----------+-------------+------------------------------+
> >
> >Ubuntu 20.04 ARM
> >Kernel: 4.15.0-132-generic
> >Compiler: gcc 7.5
> >NIC: Arm Intel Corporation Ethernet Converged Network Adapter
> >XL710-QDA2
> >40000 Mbps
> >Target: x86_64-native-linuxapp-gcc
> >Fail/Total: 0/2
> >
> >Detail performance results:
> >+------------+---------+----------+-------------+------------------------------+
> >| frame_size | txd/rxd | num_cpus | num_threads | throughput
> >| difference from
> >|
> >| | | | | expected |
> >+============+=========+==========+=============+=============
> >=================+
> >| 64 | 512 | 1 | 1 | 0.1% |
> >+------------+---------+----------+-------------+------------------------------+
> >| 64 | 2048 | 1 | 1 | -0.5% |
> >+------------+---------+----------+-------------+------------------------------+
> >
> >To view detailed results, visit:
> >https://urldefense.proofpoint.com/v2/url?u=https-
> >3A__lab.dpdk.org_results_dashboard_patchsets_20534_&d=DwIFAg&c=nKjWe
> c2
> >b6R0mOyPaz7xtfQ&r=G9w4KsPaQLACBfGCL35PtiRH996yqJDxAZwrWegU2qQ&
> m=
> >dPDgmKiLC_KqhgjwZrodyFlBdlFPgckVr9IW0c7t2cIHpkw6u9pGqgElFqqwuU1v&s
> =E
> >ajYUFziZY27q6LB4p5sOGuFlty3VlOjbMsLXaQ5MeI&e=
> >
>
> Performance regression is reported by nic_single_core_perf, but is using
> testpmd to measure performance. As this patch does not touch testpmd, the
> issue could be with DPDK CI. Is it possible to re-trigger CI ?
I have don't have option to trigger CI from my side.
So, I have added dpdklab and Aaron to the loop.
Please check with them.
>
> >>
> >> Signed-off-by: Shijith Thotton <sthotton@marvell.com>
> >> ---
> >> v2:
> >> * Fix RHEL compilation warning.
> >>
> >> app/test-eventdev/evt_common.h | 3 +
> >> app/test-eventdev/evt_main.c | 13 +-
> >> app/test-eventdev/evt_options.c | 27 ++
> >> app/test-eventdev/evt_options.h | 12 +
> >> app/test-eventdev/evt_test.h | 6 +
> >> app/test-eventdev/test_perf_atq.c | 51 ++++
> >> app/test-eventdev/test_perf_common.c | 406
> >++++++++++++++++++++++++++-
> >> app/test-eventdev/test_perf_common.h | 16 ++ app/test-
> >> eventdev/test_perf_queue.c | 52 ++++
> >> doc/guides/tools/testeventdev.rst | 13 +
> >> 10 files changed, 592 insertions(+), 7 deletions(-)
> >>
> >> diff --git a/app/test-eventdev/evt_common.h b/app/test-
> >> eventdev/evt_common.h index f466434459..2f301a7e79 100644
> >> --- a/app/test-eventdev/evt_common.h
> >> +++ b/app/test-eventdev/evt_common.h
> >> @@ -7,6 +7,7 @@
> >>
> >> #include <rte_common.h>
> >> #include <rte_debug.h>
> >> +#include <rte_event_crypto_adapter.h>
> >> #include <rte_eventdev.h>
> >> #include <rte_service.h>
> >>
> >> @@ -39,6 +40,7 @@ enum evt_prod_type {
> >> EVT_PROD_TYPE_SYNT, /* Producer type Synthetic i.e. CPU. */
> >> EVT_PROD_TYPE_ETH_RX_ADPTR, /* Producer type Eth Rx Adapter. */
> >> EVT_PROD_TYPE_EVENT_TIMER_ADPTR, /* Producer type Timer
> Adapter.
> >> */
> >> + EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR, /* Producer type Crypto
> >> Adapter. */
> >> EVT_PROD_TYPE_MAX,
> >> };
> >>
> >> @@ -77,6 +79,7 @@ struct evt_options {
> >> uint64_t timer_tick_nsec;
> >> uint64_t optm_timer_tick_nsec;
> >> enum evt_prod_type prod_type;
> >> + enum rte_event_crypto_adapter_mode crypto_adptr_mode;
> >> };
> >>
> >> static inline bool
> >> diff --git a/app/test-eventdev/evt_main.c
> >> b/app/test-eventdev/evt_main.c index 194c980c7a..cef0fb1382 100644
> >> --- a/app/test-eventdev/evt_main.c
> >> +++ b/app/test-eventdev/evt_main.c
> >> @@ -161,12 +161,19 @@ main(int argc, char **argv)
> >> goto mempool_destroy;
> >> }
> >> }
> >> + /* Test specific cryptodev setup */
> >> + if (test->ops.cryptodev_setup) {
> >> + if (test->ops.cryptodev_setup(test, &opt)) {
> >> + evt_err("%s: cryptodev setup failed", opt.test_name);
> >> + goto ethdev_destroy;
> >> + }
> >> + }
> >>
> >> /* Test specific eventdev setup */
> >> if (test->ops.eventdev_setup) {
> >> if (test->ops.eventdev_setup(test, &opt)) {
> >> evt_err("%s: eventdev setup failed", opt.test_name);
> >> - goto ethdev_destroy;
> >> + goto cryptodev_destroy;
> >> }
> >> }
> >>
> >> @@ -197,6 +204,10 @@ main(int argc, char **argv)
> >> if (test->ops.eventdev_destroy)
> >> test->ops.eventdev_destroy(test, &opt);
> >>
> >> +cryptodev_destroy:
> >> + if (test->ops.cryptodev_destroy)
> >> + test->ops.cryptodev_destroy(test, &opt);
> >> +
> >> ethdev_destroy:
> >> if (test->ops.ethdev_destroy)
> >> test->ops.ethdev_destroy(test, &opt); diff --git a/app/test-
> >> eventdev/evt_options.c b/app/test-eventdev/evt_options.c index
> >> 753a7dbd7d..5ad1491020 100644
> >> --- a/app/test-eventdev/evt_options.c
> >> +++ b/app/test-eventdev/evt_options.c
> >> @@ -122,6 +122,26 @@ evt_parse_timer_prod_type_burst(struct
> >> evt_options *opt,
> >> return 0;
> >> }
> >>
> >> +static int
> >> +evt_parse_crypto_prod_type(struct evt_options *opt,
> >> + const char *arg __rte_unused)
> >> +{
> >> + opt->prod_type = EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR;
> >> + return 0;
> >> +}
> >> +
> >> +static int
> >> +evt_parse_crypto_adptr_mode(struct evt_options *opt, const char *arg) {
> >> + uint8_t mode;
> >> + int ret;
> >> +
> >> + ret = parser_read_uint8(&mode, arg);
> >> + opt->crypto_adptr_mode = mode ?
> >> RTE_EVENT_CRYPTO_ADAPTER_OP_FORWARD :
> >> +
> >> RTE_EVENT_CRYPTO_ADAPTER_OP_NEW;
> >> + return ret;
> >> +}
> >> +
> >> static int
> >> evt_parse_test_name(struct evt_options *opt, const char *arg) { @@
> >> -335,6
> >> +355,7 @@ usage(char *program)
> >> "\t--queue_priority : enable queue priority\n"
> >> "\t--deq_tmo_nsec : global dequeue timeout\n"
> >> "\t--prod_type_ethdev : use ethernet device as producer.\n"
> >> + "\t--prod_type_cryptodev : use crypto device as producer.\n"
> >> "\t--prod_type_timerdev : use event timer device as
> producer.\n"
> >> "\t expity_nsec would be the timeout\n"
> >> "\t in ns.\n"
> >> @@ -345,6 +366,8 @@ usage(char *program)
> >> "\t--timer_tick_nsec : timer tick interval in ns.\n"
> >> "\t--max_tmo_nsec : max timeout interval in ns.\n"
> >> "\t--expiry_nsec : event timer expiry ns.\n"
> >> + "\t--crypto_adptr_mode : 0 for OP_NEW mode (default) and\n"
> >> + "\t 1 for OP_FORWARD mode.\n"
> >> "\t--mbuf_sz : packet mbuf size.\n"
> >> "\t--max_pkt_sz : max packet size.\n"
> >> "\t--prod_enq_burst_sz : producer enqueue burst size.\n"
> >> @@ -415,8 +438,10 @@ static struct option lgopts[] = {
> >> { EVT_QUEUE_PRIORITY, 0, 0, 0 },
> >> { EVT_DEQ_TMO_NSEC, 1, 0, 0 },
> >> { EVT_PROD_ETHDEV, 0, 0, 0 },
> >> + { EVT_PROD_CRYPTODEV, 0, 0, 0 },
> >> { EVT_PROD_TIMERDEV, 0, 0, 0 },
> >> { EVT_PROD_TIMERDEV_BURST, 0, 0, 0 },
> >> + { EVT_CRYPTO_ADPTR_MODE, 1, 0, 0 },
> >> { EVT_NB_TIMERS, 1, 0, 0 },
> >> { EVT_NB_TIMER_ADPTRS, 1, 0, 0 },
> >> { EVT_TIMER_TICK_NSEC, 1, 0, 0 },
> >> @@ -455,8 +480,10 @@ evt_opts_parse_long(int opt_idx, struct
> >> evt_options
> >> *opt)
> >> { EVT_QUEUE_PRIORITY, evt_parse_queue_priority},
> >> { EVT_DEQ_TMO_NSEC, evt_parse_deq_tmo_nsec},
> >> { EVT_PROD_ETHDEV, evt_parse_eth_prod_type},
> >> + { EVT_PROD_CRYPTODEV, evt_parse_crypto_prod_type},
> >> { EVT_PROD_TIMERDEV, evt_parse_timer_prod_type},
> >> { EVT_PROD_TIMERDEV_BURST,
> >> evt_parse_timer_prod_type_burst},
> >> + { EVT_CRYPTO_ADPTR_MODE, evt_parse_crypto_adptr_mode},
> >> { EVT_NB_TIMERS, evt_parse_nb_timers},
> >> { EVT_NB_TIMER_ADPTRS, evt_parse_nb_timer_adptrs},
> >> { EVT_TIMER_TICK_NSEC, evt_parse_timer_tick_nsec}, diff --git
> >> a/app/test-eventdev/evt_options.h b/app/test-eventdev/evt_options.h
> >> index
> >> 413d7092f0..2231c58801 100644
> >> --- a/app/test-eventdev/evt_options.h
> >> +++ b/app/test-eventdev/evt_options.h
> >> @@ -9,6 +9,7 @@
> >> #include <stdbool.h>
> >>
> >> #include <rte_common.h>
> >> +#include <rte_cryptodev.h>
> >> #include <rte_ethdev.h>
> >> #include <rte_eventdev.h>
> >> #include <rte_lcore.h>
> >> @@ -33,8 +34,10 @@
> >> #define EVT_QUEUE_PRIORITY ("queue_priority")
> >> #define EVT_DEQ_TMO_NSEC ("deq_tmo_nsec")
> >> #define EVT_PROD_ETHDEV ("prod_type_ethdev")
> >> +#define EVT_PROD_CRYPTODEV ("prod_type_cryptodev")
> >> #define EVT_PROD_TIMERDEV ("prod_type_timerdev")
> >> #define EVT_PROD_TIMERDEV_BURST ("prod_type_timerdev_burst")
> >> +#define EVT_CRYPTO_ADPTR_MODE ("crypto_adptr_mode")
> >> #define EVT_NB_TIMERS ("nb_timers")
> >> #define EVT_NB_TIMER_ADPTRS ("nb_timer_adptrs")
> >> #define EVT_TIMER_TICK_NSEC ("timer_tick_nsec")
> >> @@ -249,6 +252,8 @@ evt_prod_id_to_name(enum evt_prod_type
> prod_type)
> >> return "Ethdev Rx Adapter";
> >> case EVT_PROD_TYPE_EVENT_TIMER_ADPTR:
> >> return "Event timer adapter";
> >> + case EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR:
> >> + return "Event crypto adapter";
> >> }
> >>
> >> return "";
> >> @@ -288,6 +293,13 @@ evt_dump_producer_type(struct evt_options *opt)
> >> evt_dump("timer_tick_nsec", "%"PRIu64"",
> >> opt->timer_tick_nsec);
> >> break;
> >> + case EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR:
> >> + snprintf(name, EVT_PROD_MAX_NAME_LEN,
> >> + "Event crypto adapter producers");
> >> + evt_dump("crypto adapter mode", "%s",
> >> + opt->crypto_adptr_mode ? "OP_FORWARD" :
> >> "OP_NEW");
> >> + evt_dump("nb_cryptodev", "%u", rte_cryptodev_count());
> >> + break;
> >> }
> >> evt_dump("prod_type", "%s", name);
> >> }
> >> diff --git a/app/test-eventdev/evt_test.h
> >> b/app/test-eventdev/evt_test.h
> >index
> >> f07d2c3336..50fa474ec2 100644
> >> --- a/app/test-eventdev/evt_test.h
> >> +++ b/app/test-eventdev/evt_test.h
> >> @@ -29,6 +29,8 @@ typedef int (*evt_test_mempool_setup_t)
> >> (struct evt_test *test, struct evt_options *opt); typedef int
> >> (*evt_test_ethdev_setup_t)
> >> (struct evt_test *test, struct evt_options *opt);
> >> +typedef int (*evt_test_cryptodev_setup_t)
> >> + (struct evt_test *test, struct evt_options *opt);
> >> typedef int (*evt_test_eventdev_setup_t)
> >> (struct evt_test *test, struct evt_options *opt); typedef int
> >> (*evt_test_launch_lcores_t) @@ -39,6 +41,8 @@ typedef void
> >> (*evt_test_eventdev_destroy_t)
> >> (struct evt_test *test, struct evt_options *opt); typedef void
> >> (*evt_test_ethdev_destroy_t)
> >> (struct evt_test *test, struct evt_options *opt);
> >> +typedef void (*evt_test_cryptodev_destroy_t)
> >> + (struct evt_test *test, struct evt_options *opt);
> >> typedef void (*evt_test_mempool_destroy_t)
> >> (struct evt_test *test, struct evt_options *opt); typedef void
> >> (*evt_test_destroy_t) @@ -52,10 +56,12 @@ struct evt_test_ops {
> >> evt_test_mempool_setup_t mempool_setup;
> >> evt_test_ethdev_setup_t ethdev_setup;
> >> evt_test_eventdev_setup_t eventdev_setup;
> >> + evt_test_cryptodev_setup_t cryptodev_setup;
> >> evt_test_launch_lcores_t launch_lcores;
> >> evt_test_result_t test_result;
> >> evt_test_eventdev_destroy_t eventdev_destroy;
> >> evt_test_ethdev_destroy_t ethdev_destroy;
> >> + evt_test_cryptodev_destroy_t cryptodev_destroy;
> >> evt_test_mempool_destroy_t mempool_destroy;
> >> evt_test_destroy_t test_destroy;
> >> };
> >> diff --git a/app/test-eventdev/test_perf_atq.c b/app/test-
> >> eventdev/test_perf_atq.c index 8fd51004ee..dbb1dc8c0c 100644
> >> --- a/app/test-eventdev/test_perf_atq.c
> >> +++ b/app/test-eventdev/test_perf_atq.c
> >> @@ -48,6 +48,22 @@ perf_atq_worker(void *arg, const int
> >> enable_fwd_latency)
> >> continue;
> >> }
> >>
> >> + if (prod_crypto_type &&
> >> + (ev.event_type == RTE_EVENT_TYPE_CRYPTODEV)) {
> >> + struct rte_crypto_op *op = ev.event_ptr;
> >> +
> >> + if (op->status == RTE_CRYPTO_OP_STATUS_SUCCESS) {
> >> + if (op->sym->m_dst == NULL)
> >> + ev.event_ptr = op->sym->m_src;
> >> + else
> >> + ev.event_ptr = op->sym->m_dst;
> >> + rte_crypto_op_free(op);
> >> + } else {
> >> + rte_crypto_op_free(op);
> >> + continue;
> >> + }
> >> + }
> >> +
> >> if (enable_fwd_latency && !prod_timer_type)
> >> /* first stage in pipeline, mark ts to compute fwd latency */
> >> atq_mark_fwd_latency(&ev);
> >> @@ -87,6 +103,25 @@ perf_atq_worker_burst(void *arg, const int
> >> enable_fwd_latency)
> >> }
> >>
> >> for (i = 0; i < nb_rx; i++) {
> >> + if (prod_crypto_type &&
> >> + (ev[i].event_type == RTE_EVENT_TYPE_CRYPTODEV))
> >> {
> >> + struct rte_crypto_op *op = ev[i].event_ptr;
> >> +
> >> + if (op->status ==
> >> + RTE_CRYPTO_OP_STATUS_SUCCESS) {
> >> + if (op->sym->m_dst == NULL)
> >> + ev[i].event_ptr =
> >> + op->sym->m_src;
> >> + else
> >> + ev[i].event_ptr =
> >> + op->sym->m_dst;
> >> + rte_crypto_op_free(op);
> >> + } else {
> >> + rte_crypto_op_free(op);
> >> + continue;
> >> + }
> >> + }
> >> +
> >> if (enable_fwd_latency && !prod_timer_type) {
> >> rte_prefetch0(ev[i+1].event_ptr);
> >> /* first stage in pipeline.
> >> @@ -254,6 +289,20 @@ perf_atq_eventdev_setup(struct evt_test *test,
> >> struct evt_options *opt)
> >> return ret;
> >> }
> >> }
> >> + } else if (opt->prod_type == EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR) {
> >> + uint8_t cdev_id, cdev_count;
> >> +
> >> + cdev_count = rte_cryptodev_count();
> >> + for (cdev_id = 0; cdev_id < cdev_count; cdev_id++) {
> >> + ret = rte_cryptodev_start(cdev_id);
> >> + if (ret) {
> >> + evt_err("Failed to start cryptodev %u",
> >> + cdev_id);
> >> + return ret;
> >> + }
> >> + }
> >> +
> >> + rte_event_crypto_adapter_start(t->crypto_adptr.id);
> >> }
> >>
> >> return 0;
> >> @@ -295,12 +344,14 @@ static const struct evt_test_ops perf_atq = {
> >> .opt_dump = perf_atq_opt_dump,
> >> .test_setup = perf_test_setup,
> >> .ethdev_setup = perf_ethdev_setup,
> >> + .cryptodev_setup = perf_cryptodev_setup,
> >> .mempool_setup = perf_mempool_setup,
> >> .eventdev_setup = perf_atq_eventdev_setup,
> >> .launch_lcores = perf_atq_launch_lcores,
> >> .eventdev_destroy = perf_eventdev_destroy,
> >> .mempool_destroy = perf_mempool_destroy,
> >> .ethdev_destroy = perf_ethdev_destroy,
> >> + .cryptodev_destroy = perf_cryptodev_destroy,
> >> .test_result = perf_test_result,
> >> .test_destroy = perf_test_destroy,
> >> };
> >> diff --git a/app/test-eventdev/test_perf_common.c b/app/test-
> >> eventdev/test_perf_common.c index 9b73874151..7b964ab8dc 100644
> >> --- a/app/test-eventdev/test_perf_common.c
> >> +++ b/app/test-eventdev/test_perf_common.c
> >> @@ -6,6 +6,8 @@
> >>
> >> #include "test_perf_common.h"
> >>
> >> +#define NB_CRYPTODEV_DESCRIPTORS 128
> >> +
> >> int
> >> perf_test_result(struct evt_test *test, struct evt_options *opt) {
> >> @@ -272,6
> >> +274,121 @@ perf_event_timer_producer_burst(void *arg)
> >> return 0;
> >> }
> >>
> >> +static inline void
> >> +crypto_adapter_enq_op_new(struct prod_data *p) {
> >> + struct test_perf *t = p->t;
> >> + const uint32_t nb_flows = t->nb_flows;
> >> + const uint64_t nb_pkts = t->nb_pkts;
> >> + struct rte_mempool *pool = t->pool;
> >> + struct rte_crypto_sym_op *sym_op;
> >> + struct evt_options *opt = t->opt;
> >> + uint32_t flow_counter = 0;
> >> + struct rte_crypto_op *op;
> >> + struct rte_mbuf *m;
> >> + uint64_t count = 0;
> >> + uint16_t len;
> >> +
> >> + if (opt->verbose_level > 1)
> >> + printf("%s(): lcore %d queue %d cdev_id %u cdev_qp_id %u\n",
> >> + __func__, rte_lcore_id(), p->queue_id, p->cdev_id,
> >> + p->cdev_qp_id);
> >> +
> >> + len = opt->mbuf_sz ? opt->mbuf_sz : RTE_ETHER_MIN_LEN;
> >> +
> >> + while (count < nb_pkts && t->done == false) {
> >> + m = rte_pktmbuf_alloc(pool);
> >> + if (m == NULL)
> >> + continue;
> >> +
> >> + rte_pktmbuf_append(m, len);
> >> + op = rte_crypto_op_alloc(t->crypto_adptr.op_pool,
> >> + RTE_CRYPTO_OP_TYPE_SYMMETRIC);
> >> + sym_op = op->sym;
> >> + sym_op->m_src = m;
> >> + sym_op->cipher.data.offset = 0;
> >> + sym_op->cipher.data.length = len;
> >> + rte_crypto_op_attach_sym_session(
> >> + op, p->crypto_sess[flow_counter++ % nb_flows]);
> >> + while (rte_cryptodev_enqueue_burst(p->cdev_id, p-
> >> >cdev_qp_id,
> >> + &op, 1) != 1) {
> >> + if (t->done)
> >> + break;
> >> + rte_pause();
> >> + }
> >> + count++;
> >> + }
> >> +}
> >> +
> >> +static inline void
> >> +crypto_adapter_enq_op_fwd(struct prod_data *p) {
> >> + const uint8_t dev_id = p->dev_id;
> >> + const uint8_t port = p->port_id;
> >> + struct test_perf *t = p->t;
> >> + const uint32_t nb_flows = t->nb_flows;
> >> + const uint64_t nb_pkts = t->nb_pkts;
> >> + struct rte_mempool *pool = t->pool;
> >> + struct evt_options *opt = t->opt;
> >> + struct rte_crypto_sym_op *sym_op;
> >> + uint32_t flow_counter = 0;
> >> + struct rte_crypto_op *op;
> >> + struct rte_event ev;
> >> + struct rte_mbuf *m;
> >> + uint64_t count = 0;
> >> + uint16_t len;
> >> +
> >> + if (opt->verbose_level > 1)
> >> + printf("%s(): lcore %d port %d queue %d cdev_id %u cdev_qp_id
> >> %u\n",
> >> + __func__, rte_lcore_id(), port, p->queue_id, p->cdev_id,
> >> + p->cdev_qp_id);
> >> +
> >> + ev.event = 0;
> >> + ev.op = RTE_EVENT_OP_NEW;
> >> + ev.queue_id = p->queue_id;
> >> + ev.sched_type = RTE_SCHED_TYPE_ATOMIC;
> >> + ev.event_type = RTE_EVENT_TYPE_CPU;
> >> + len = opt->mbuf_sz ? opt->mbuf_sz : RTE_ETHER_MIN_LEN;
> >> +
> >> + while (count < nb_pkts && t->done == false) {
> >> + m = rte_pktmbuf_alloc(pool);
> >> + if (m == NULL)
> >> + continue;
> >> +
> >> + rte_pktmbuf_append(m, len);
> >> + op = rte_crypto_op_alloc(t->crypto_adptr.op_pool,
> >> + RTE_CRYPTO_OP_TYPE_SYMMETRIC);
> >> + sym_op = op->sym;
> >> + sym_op->m_src = m;
> >> + sym_op->cipher.data.offset = 0;
> >> + sym_op->cipher.data.length = len;
> >> + rte_crypto_op_attach_sym_session(
> >> + op, p->crypto_sess[flow_counter++ % nb_flows]);
> >> + ev.event_ptr = op;
> >> + while (rte_event_crypto_adapter_enqueue(dev_id, port, &ev, 1)
> >> !=
> >> + 1) {
> >> + if (t->done)
> >> + break;
> >> + rte_pause();
> >> + }
> >> + count++;
> >> + }
> >> +}
> >> +
> >> +static inline int
> >> +perf_event_crypto_producer(void *arg) {
> >> + struct prod_data *p = arg;
> >> + struct evt_options *opt = p->t->opt;
> >> +
> >> + if (opt->crypto_adptr_mode ==
> >> RTE_EVENT_CRYPTO_ADAPTER_OP_NEW)
> >> + crypto_adapter_enq_op_new(p);
> >> + else
> >> + crypto_adapter_enq_op_fwd(p);
> >> +
> >> + return 0;
> >> +}
> >> +
> >> static int
> >> perf_producer_wrapper(void *arg)
> >> {
> >> @@ -298,6 +415,8 @@ perf_producer_wrapper(void *arg)
> >> else if (t->opt->prod_type == EVT_PROD_TYPE_EVENT_TIMER_ADPTR
> &&
> >> t->opt->timdev_use_burst)
> >> return perf_event_timer_producer_burst(arg);
> >> + else if (t->opt->prod_type == EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR)
> >> + return perf_event_crypto_producer(arg);
> >> return 0;
> >> }
> >>
> >> @@ -405,8 +524,10 @@ perf_launch_lcores(struct evt_test *test, struct
> >> evt_options *opt,
> >> if (remaining <= 0) {
> >> t->result = EVT_TEST_SUCCESS;
> >> if (opt->prod_type == EVT_PROD_TYPE_SYNT
> >> ||
> >> - opt->prod_type ==
> >> -
> >> EVT_PROD_TYPE_EVENT_TIMER_ADPTR) {
> >> + opt->prod_type ==
> >> +
> >> EVT_PROD_TYPE_EVENT_TIMER_ADPTR ||
> >> + opt->prod_type ==
> >> +
> >> EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR) {
> >> t->done = true;
> >> break;
> >> }
> >> @@ -415,7 +536,8 @@ perf_launch_lcores(struct evt_test *test, struct
> >> evt_options *opt,
> >>
> >> if (new_cycles - dead_lock_cycles > dead_lock_sample &&
> >> (opt->prod_type == EVT_PROD_TYPE_SYNT ||
> >> - opt->prod_type == EVT_PROD_TYPE_EVENT_TIMER_ADPTR))
> >> {
> >> + opt->prod_type == EVT_PROD_TYPE_EVENT_TIMER_ADPTR
> >> ||
> >> + opt->prod_type ==
> >> EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR)) {
> >> remaining = t->outstand_pkts - processed_pkts(t);
> >> if (dead_lock_remaining == remaining) {
> >> rte_event_dev_dump(opt->dev_id, stdout);
> @@ -537,6 +659,96 @@
> >> perf_event_timer_adapter_setup(struct test_perf *t)
> >> return 0;
> >> }
> >>
> >> +static int
> >> +perf_event_crypto_adapter_setup(struct test_perf *t,
> >> + struct rte_event_port_conf port_conf) {
> >> + struct evt_options *opt = t->opt;
> >> + uint8_t cdev_id, cdev_count;
> >> + int ret;
> >> +
> >> + t->crypto_adptr.id = 0;
> >> + ret = rte_event_crypto_adapter_create(t->crypto_adptr.id, opt->dev_id,
> >> + &port_conf, 0);
> >> + if (ret)
> >> + return ret;
> >> +
> >> + cdev_count = rte_cryptodev_count();
> >> + for (cdev_id = 0; cdev_id < cdev_count; cdev_id++) {
> >> + uint32_t cap;
> >> +
> >> + ret = rte_event_crypto_adapter_caps_get(opt->dev_id,
> >> cdev_id,
> >> + &cap);
> >> + if (ret) {
> >> + evt_err("Failed to get crypto adapter capabilities");
> >> + return ret;
> >> + }
> >> +
> >> + if (((opt->crypto_adptr_mode ==
> >> + RTE_EVENT_CRYPTO_ADAPTER_OP_NEW) &&
> >> + !(cap &
> >> +
> >> RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_OP_NEW)) ||
> >> + ((opt->crypto_adptr_mode ==
> >> + RTE_EVENT_CRYPTO_ADAPTER_OP_FORWARD) &&
> >> + !(cap &
> >> +
> >> RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_OP_FWD))) {
> >> + evt_err("crypto adapter %s mode unsupported\n",
> >> + opt->crypto_adptr_mode ? "OP_FORWARD" :
> >> + "OP_NEW");
> >> + return -EINVAL;
> >> + }
> >> +
> >> + if (!(cap &
> >> +
> >> RTE_EVENT_CRYPTO_ADAPTER_CAP_SESSION_PRIVATE_DATA)) {
> >> + evt_err("Storing crypto session not supported");
> >> + return -EINVAL;
> >> + }
> >> +
> >> + if (cap &
> >> +
> >> RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_QP_EV_BIND) {
> >> + struct rte_event response_info;
> >> +
> >> + response_info.event = 0;
> >> + ret = rte_event_crypto_adapter_queue_pair_add(
> >> + t->crypto_adptr.id, cdev_id, -1,
> >> + &response_info);
> >> + } else {
> >> + ret = rte_event_crypto_adapter_queue_pair_add(
> >> + t->crypto_adptr.id, cdev_id, -1, NULL);
> >> + }
> >> + if (ret)
> >> + return ret;
> >> + }
> >> +
> >> + return 0;
> >> +}
> >> +
> >> +static struct rte_cryptodev_sym_session *
> >> +cryptodev_session_create(struct prod_data *p, struct test_perf *t) {
> >> + struct rte_crypto_sym_xform cipher_xform;
> >> + struct rte_cryptodev_sym_session *sess;
> >> +
> >> + cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
> >> + cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
> >> + cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
> >> + cipher_xform.next = NULL;
> >> +
> >> + sess = rte_cryptodev_sym_session_create(t->crypto_adptr.sess_pool);
> >> + if (sess == NULL) {
> >> + evt_err("Failed to create sym session");
> >> + return NULL;
> >> + }
> >> +
> >> + if (rte_cryptodev_sym_session_init(p->cdev_id, sess, &cipher_xform,
> >> + t->crypto_adptr.sess_priv_pool)) {
> >> + evt_err("Failed to init session");
> >> + return NULL;
> >> + }
> >> +
> >> + return sess;
> >> +}
> >> +
> >> int
> >> perf_event_dev_port_setup(struct evt_test *test, struct evt_options *opt,
> >> uint8_t stride, uint8_t nb_queues, @@ -598,6
> +810,55 @@
> >> perf_event_dev_port_setup(struct evt_test *test, struct evt_options
> >> *opt,
> >> ret = perf_event_timer_adapter_setup(t);
> >> if (ret)
> >> return ret;
> >> + } else if (opt->prod_type == EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR) {
> >> + uint8_t cdev_id = 0;
> >> + uint16_t qp_id = 0;
> >> +
> >> + prod = 0;
> >> + for (; port < perf_nb_event_ports(opt); port++) {
> >> + struct rte_cryptodev_sym_session *crypto_sess;
> >> + union rte_event_crypto_metadata m_data;
> >> + struct prod_data *p = &t->prod[port];
> >> + uint32_t flow_id;
> >> +
> >> + if (qp_id == rte_cryptodev_queue_pair_count(cdev_id))
> >> {
> >> + cdev_id++;
> >> + qp_id = 0;
> >> + }
> >> +
> >> + p->dev_id = opt->dev_id;
> >> + p->port_id = port;
> >> + p->queue_id = prod * stride;
> >> + p->cdev_id = cdev_id;
> >> + p->cdev_qp_id = qp_id;
> >> + p->crypto_sess = rte_zmalloc_socket(
> >> + NULL, sizeof(crypto_sess) * t->nb_flows,
> >> + RTE_CACHE_LINE_SIZE, opt->socket_id);
> >> +
> >> + m_data.request_info.cdev_id = p->cdev_id;
> >> + m_data.request_info.queue_pair_id = p->cdev_qp_id;
> >> + m_data.response_info.op = RTE_EVENT_OP_NEW;
> >> + m_data.response_info.sched_type =
> >> RTE_SCHED_TYPE_ATOMIC;
> >> + m_data.response_info.event_type =
> >> RTE_EVENT_TYPE_CPU;
> >> + m_data.response_info.queue_id = p->queue_id;
> >> + for (flow_id = 0; flow_id < t->nb_flows; flow_id++) {
> >> + crypto_sess = cryptodev_session_create(p, t);
> >> + if (crypto_sess == NULL)
> >> + return -ENOMEM;
> >> +
> >> + m_data.response_info.flow_id = flow_id;
> >> + rte_cryptodev_sym_session_set_user_data(
> >> + crypto_sess, &m_data,
> >> sizeof(m_data));
> >> + p->crypto_sess[flow_id] = crypto_sess;
> >> + }
> >> + p->t = t;
> >> + qp_id++;
> >> + prod++;
> >> + }
> >> +
> >> + ret = perf_event_crypto_adapter_setup(t, *port_conf);
> >> + if (ret)
> >> + return ret;
> >> } else {
> >> prod = 0;
> >> for ( ; port < perf_nb_event_ports(opt); port++) { @@ -659,7
> >> +920,8 @@ perf_opt_check(struct evt_options *opt, uint64_t nb_queues)
> >> }
> >>
> >> if (opt->prod_type == EVT_PROD_TYPE_SYNT ||
> >> - opt->prod_type ==
> >> EVT_PROD_TYPE_EVENT_TIMER_ADPTR) {
> >> + opt->prod_type == EVT_PROD_TYPE_EVENT_TIMER_ADPTR ||
> >> + opt->prod_type == EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR) {
> >> /* Validate producer lcores */
> >> if (evt_lcores_has_overlap(opt->plcores,
> >> rte_get_main_lcore())) {
> >> @@ -767,8 +1029,7 @@ perf_ethdev_setup(struct evt_test *test, struct
> >> evt_options *opt)
> >> },
> >> };
> >>
> >> - if (opt->prod_type == EVT_PROD_TYPE_SYNT ||
> >> - opt->prod_type ==
> >> EVT_PROD_TYPE_EVENT_TIMER_ADPTR)
> >> + if (opt->prod_type != EVT_PROD_TYPE_ETH_RX_ADPTR)
> >> return 0;
> >>
> >> if (!rte_eth_dev_count_avail()) {
> >> @@ -841,6 +1102,139 @@ void perf_ethdev_destroy(struct evt_test
> >> *test, struct evt_options *opt)
> >> }
> >> }
> >>
> >> +int
> >> +perf_cryptodev_setup(struct evt_test *test, struct evt_options *opt) {
> >> + uint8_t cdev_count, cdev_id, nb_plcores, nb_qps;
> >> + struct test_perf *t = evt_test_priv(test);
> >> + unsigned int max_session_size;
> >> + uint32_t nb_sessions;
> >> + int ret;
> >> +
> >> + if (opt->prod_type != EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR)
> >> + return 0;
> >> +
> >> + cdev_count = rte_cryptodev_count();
> >> + if (cdev_count == 0) {
> >> + evt_err("No crypto devices available\n");
> >> + return -ENODEV;
> >> + }
> >> +
> >> + t->crypto_adptr.op_pool = rte_crypto_op_pool_create(
> >> + "crypto_op_pool", RTE_CRYPTO_OP_TYPE_SYMMETRIC, opt-
> >> >pool_sz,
> >> + 128, 0, rte_socket_id());
> >> + if (t->crypto_adptr.op_pool == NULL) {
> >> + evt_err("Failed to create crypto op pool");
> >> + return -ENOMEM;
> >> + }
> >> +
> >> + nb_sessions = evt_nr_active_lcores(opt->plcores) * t->nb_flows;
> >> + t->crypto_adptr.sess_pool = rte_cryptodev_sym_session_pool_create(
> >> + "ca_sess_pool", nb_sessions, 0, 0,
> >> + sizeof(union rte_event_crypto_metadata), SOCKET_ID_ANY);
> >> + if (t->crypto_adptr.sess_pool == NULL) {
> >> + evt_err("Failed to create sym session pool");
> >> + ret = -ENOMEM;
> >> + goto err;
> >> + }
> >> +
> >> + max_session_size = 0;
> >> + for (cdev_id = 0; cdev_id < cdev_count; cdev_id++) {
> >> + unsigned int session_size;
> >> +
> >> + session_size =
> >> + rte_cryptodev_sym_get_private_session_size(cdev_id);
> >> + if (session_size > max_session_size)
> >> + max_session_size = session_size;
> >> + }
> >> + max_session_size += sizeof(union rte_event_crypto_metadata);
> >> + t->crypto_adptr.sess_priv_pool = rte_mempool_create(
> >> + "ca_sess_priv_pool", nb_sessions, max_session_size, 0, 0,
> >> NULL,
> >> + NULL, NULL, NULL, SOCKET_ID_ANY, 0);
> >> + if (t->crypto_adptr.sess_priv_pool == NULL) {
> >> + evt_err("failed to create sym session private pool");
> >> + ret = -ENOMEM;
> >> + goto err;
> >> + }
> >> +
> >> + nb_plcores = evt_nr_active_lcores(opt->plcores);
> >> + nb_qps = (nb_plcores % cdev_count) ? (nb_plcores / cdev_count) + 1 :
> >> + nb_plcores / cdev_count;
> >> + for (cdev_id = 0; cdev_id < cdev_count; cdev_id++) {
> >> + struct rte_cryptodev_qp_conf qp_conf;
> >> + struct rte_cryptodev_config conf;
> >> + struct rte_cryptodev_info info;
> >> + int qp_id;
> >> +
> >> + rte_cryptodev_info_get(cdev_id, &info);
> >> + if (nb_qps > info.max_nb_queue_pairs) {
> >> + evt_err("Not enough queue pairs per cryptodev (%u)",
> >> + nb_qps);
> >> + ret = -EINVAL;
> >> + goto err;
> >> + }
> >> +
> >> + conf.nb_queue_pairs = nb_qps;
> >> + conf.socket_id = SOCKET_ID_ANY;
> >> + conf.ff_disable = RTE_CRYPTODEV_FF_SECURITY;
> >> +
> >> + ret = rte_cryptodev_configure(cdev_id, &conf);
> >> + if (ret) {
> >> + evt_err("Failed to configure cryptodev (%u)", cdev_id);
> >> + goto err;
> >> + }
> >> +
> >> + qp_conf.nb_descriptors = NB_CRYPTODEV_DESCRIPTORS;
> >> + qp_conf.mp_session = t->crypto_adptr.sess_pool;
> >> + qp_conf.mp_session_private = t->crypto_adptr.sess_priv_pool;
> >> +
> >> + for (qp_id = 0; qp_id < conf.nb_queue_pairs; qp_id++) {
> >> + ret = rte_cryptodev_queue_pair_setup(
> >> + cdev_id, qp_id, &qp_conf,
> >> + rte_cryptodev_socket_id(cdev_id));
> >> + if (ret) {
> >> + evt_err("Failed to setup queue pairs on
> >> cryptodev %u\n",
> >> + cdev_id);
> >> + goto err;
> >> + }
> >> + }
> >> + }
> >> +
> >> + return 0;
> >> +err:
> >> + rte_mempool_free(t->crypto_adptr.op_pool);
> >> + rte_mempool_free(t->crypto_adptr.sess_pool);
> >> + rte_mempool_free(t->crypto_adptr.sess_priv_pool);
> >> +
> >> + return ret;
> >> +}
> >> +
> >> +void
> >> +perf_cryptodev_destroy(struct evt_test *test, struct evt_options
> >> +*opt) {
> >> + uint8_t cdev_id, cdev_count = rte_cryptodev_count();
> >> + struct test_perf *t = evt_test_priv(test);
> >> +
> >> + RTE_SET_USED(opt);
> >> +
> >> + if (opt->prod_type != EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR)
> >> + return;
> >> +
> >> + rte_event_crypto_adapter_stop(t->crypto_adptr.id);
> >> +
> >> + for (cdev_id = 0; cdev_id < cdev_count; cdev_id++) {
> >> + rte_cryptodev_stop(cdev_id);
> >> + rte_event_crypto_adapter_queue_pair_del(t->crypto_adptr.id,
> >> + cdev_id, -1);
> >> + }
> >> +
> >> + rte_event_crypto_adapter_free(t->crypto_adptr.id);
> >> +
> >> + rte_mempool_free(t->crypto_adptr.op_pool);
> >> + rte_mempool_free(t->crypto_adptr.sess_pool);
> >> + rte_mempool_free(t->crypto_adptr.sess_priv_pool);
> >> +}
> >> +
> >> int
> >> perf_mempool_setup(struct evt_test *test, struct evt_options *opt)
> >> { diff --git a/app/test-eventdev/test_perf_common.h b/app/test-
> >> eventdev/test_perf_common.h index 14dcf80429..d9ad3a0b0d 100644
> >> --- a/app/test-eventdev/test_perf_common.h
> >> +++ b/app/test-eventdev/test_perf_common.h
> >> @@ -9,9 +9,11 @@
> >> #include <stdbool.h>
> >> #include <unistd.h>
> >>
> >> +#include <rte_cryptodev.h>
> >> #include <rte_cycles.h>
> >> #include <rte_ethdev.h>
> >> #include <rte_eventdev.h>
> >> +#include <rte_event_crypto_adapter.h>
> >> #include <rte_event_eth_rx_adapter.h> #include
> >> <rte_event_timer_adapter.h> #include <rte_lcore.h> @@ -37,9 +39,18
> >> @@ struct prod_data {
> >> uint8_t dev_id;
> >> uint8_t port_id;
> >> uint8_t queue_id;
> >> + uint8_t cdev_id;
> >> + uint16_t cdev_qp_id;
> >> + struct rte_cryptodev_sym_session **crypto_sess;
> >> struct test_perf *t;
> >> } __rte_cache_aligned;
> >>
> >> +struct crypto_adptr_data {
> >> + uint8_t id;
> >> + struct rte_mempool *op_pool;
> >> + struct rte_mempool *sess_pool;
> >> + struct rte_mempool *sess_priv_pool; };
> >>
> >> struct test_perf {
> >> /* Don't change the offset of "done". Signal handler use this
> >> memory @@ -58,6 +69,7 @@ struct test_perf {
> >> uint8_t sched_type_list[EVT_MAX_STAGES] __rte_cache_aligned;
> >> struct rte_event_timer_adapter *timer_adptr[
> >> RTE_EVENT_TIMER_ADAPTER_NUM_MAX]
> >> __rte_cache_aligned;
> >> + struct crypto_adptr_data crypto_adptr;
> >> } __rte_cache_aligned;
> >>
> >> struct perf_elt {
> >> @@ -81,6 +93,8 @@ struct perf_elt {
> >> const uint8_t port = w->port_id;\
> >> const uint8_t prod_timer_type = \
> >> opt->prod_type == EVT_PROD_TYPE_EVENT_TIMER_ADPTR;\
> >> + const uint8_t prod_crypto_type = \
> >> + opt->prod_type == EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR;\
> >> uint8_t *const sched_type_list = &t->sched_type_list[0];\
> >> struct rte_mempool *const pool = t->pool;\
> >> const uint8_t nb_stages = t->opt->nb_stages;\ @@ -154,6 +168,7 @@
> >> int perf_test_result(struct evt_test *test, struct evt_options *opt);
> >> int perf_opt_check(struct evt_options *opt, uint64_t nb_queues); int
> >> perf_test_setup(struct evt_test *test, struct evt_options *opt); int
> >> perf_ethdev_setup(struct evt_test *test, struct evt_options *opt);
> >> +int perf_cryptodev_setup(struct evt_test *test, struct evt_options
> >> +*opt);
> >> int perf_mempool_setup(struct evt_test *test, struct evt_options
> >> *opt); int perf_event_dev_port_setup(struct evt_test *test, struct
> evt_options *opt,
> >> uint8_t stride, uint8_t nb_queues, @@ -164,6
> +179,7 @@ int
> >> perf_launch_lcores(struct evt_test *test, struct evt_options *opt,
> >> void perf_opt_dump(struct evt_options *opt, uint8_t nb_queues); void
> >> perf_test_destroy(struct evt_test *test, struct evt_options *opt);
> >> void perf_eventdev_destroy(struct evt_test *test, struct evt_options
> >> *opt);
> >> +void perf_cryptodev_destroy(struct evt_test *test, struct
> >> +evt_options *opt);
> >> void perf_ethdev_destroy(struct evt_test *test, struct evt_options
> >> *opt); void perf_mempool_destroy(struct evt_test *test, struct
> >> evt_options *opt);
> >>
> >> diff --git a/app/test-eventdev/test_perf_queue.c b/app/test-
> >> eventdev/test_perf_queue.c index f4ea3a795f..5657c8b3cd 100644
> >> --- a/app/test-eventdev/test_perf_queue.c
> >> +++ b/app/test-eventdev/test_perf_queue.c
> >> @@ -49,6 +49,23 @@ perf_queue_worker(void *arg, const int
> >> enable_fwd_latency)
> >> rte_pause();
> >> continue;
> >> }
> >> +
> >> + if (prod_crypto_type &&
> >> + (ev.event_type == RTE_EVENT_TYPE_CRYPTODEV)) {
> >> + struct rte_crypto_op *op = ev.event_ptr;
> >> +
> >> + if (op->status == RTE_CRYPTO_OP_STATUS_SUCCESS) {
> >> + if (op->sym->m_dst == NULL)
> >> + ev.event_ptr = op->sym->m_src;
> >> + else
> >> + ev.event_ptr = op->sym->m_dst;
> >> + rte_crypto_op_free(op);
> >> + } else {
> >> + rte_crypto_op_free(op);
> >> + continue;
> >> + }
> >> + }
> >> +
> >> if (enable_fwd_latency && !prod_timer_type)
> >> /* first q in pipeline, mark timestamp to compute fwd latency */
> >> mark_fwd_latency(&ev, nb_stages); @@ -88,6 +105,25
> @@
> >> perf_queue_worker_burst(void *arg, const int
> >> enable_fwd_latency)
> >> }
> >>
> >> for (i = 0; i < nb_rx; i++) {
> >> + if (prod_crypto_type &&
> >> + (ev[i].event_type == RTE_EVENT_TYPE_CRYPTODEV))
> >> {
> >> + struct rte_crypto_op *op = ev[i].event_ptr;
> >> +
> >> + if (op->status ==
> >> + RTE_CRYPTO_OP_STATUS_SUCCESS) {
> >> + if (op->sym->m_dst == NULL)
> >> + ev[i].event_ptr =
> >> + op->sym->m_src;
> >> + else
> >> + ev[i].event_ptr =
> >> + op->sym->m_dst;
> >> + rte_crypto_op_free(op);
> >> + } else {
> >> + rte_crypto_op_free(op);
> >> + continue;
> >> + }
> >> + }
> >> +
> >> if (enable_fwd_latency && !prod_timer_type) {
> >> rte_prefetch0(ev[i+1].event_ptr);
> >> /* first queue in pipeline.
> >> @@ -269,6 +305,20 @@ perf_queue_eventdev_setup(struct evt_test *test,
> >> struct evt_options *opt)
> >> return ret;
> >> }
> >> }
> >> + } else if (opt->prod_type == EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR) {
> >> + uint8_t cdev_id, cdev_count;
> >> +
> >> + cdev_count = rte_cryptodev_count();
> >> + for (cdev_id = 0; cdev_id < cdev_count; cdev_id++) {
> >> + ret = rte_cryptodev_start(cdev_id);
> >> + if (ret) {
> >> + evt_err("Failed to start cryptodev %u",
> >> + cdev_id);
> >> + return ret;
> >> + }
> >> + }
> >> +
> >> + rte_event_crypto_adapter_start(t->crypto_adptr.id);
> >> }
> >>
> >> return 0;
> >> @@ -311,11 +361,13 @@ static const struct evt_test_ops perf_queue = {
> >> .test_setup = perf_test_setup,
> >> .mempool_setup = perf_mempool_setup,
> >> .ethdev_setup = perf_ethdev_setup,
> >> + .cryptodev_setup = perf_cryptodev_setup,
> >> .eventdev_setup = perf_queue_eventdev_setup,
> >> .launch_lcores = perf_queue_launch_lcores,
> >> .eventdev_destroy = perf_eventdev_destroy,
> >> .mempool_destroy = perf_mempool_destroy,
> >> .ethdev_destroy = perf_ethdev_destroy,
> >> + .cryptodev_destroy = perf_cryptodev_destroy,
> >> .test_result = perf_test_result,
> >> .test_destroy = perf_test_destroy,
> >> };
> >> diff --git a/doc/guides/tools/testeventdev.rst
> >> b/doc/guides/tools/testeventdev.rst
> >> index 48efb9ea6e..f7d813226d 100644
> >> --- a/doc/guides/tools/testeventdev.rst
> >> +++ b/doc/guides/tools/testeventdev.rst
> >> @@ -120,6 +120,10 @@ The following are the application command-line
> >> options:
> >>
> >> Use burst mode event timer adapter as producer.
> >>
> >> +* ``--prod_type_cryptodev``
> >> +
> >> + Use crypto device as producer.
> >> +
> >> * ``--timer_tick_nsec``
> >>
> >> Used to dictate number of nano seconds between bucket
> >> traversal of the @@ -148,6 +152,11 @@ The following are the
> >> application command-line
> >> options:
> >> timeout is out of the supported range of event device it will be
> >> adjusted to the highest/lowest supported dequeue timeout supported.
> >>
> >> +* ``--crypto_adptr_mode``
> >> +
> >> + Set crypto adapter mode. Use 0 for OP_NEW (default) and 1 for
> >> + OP_FORWARD mode.
> >> +
> >> * ``--mbuf_sz``
> >>
> >> Set packet mbuf size. Can be used to configure Jumbo Frames.
> >> Only @@ -
> >> 420,6 +429,7 @@ Supported application command line options are
> following::
> >> --prod_type_ethdev
> >> --prod_type_timerdev_burst
> >> --prod_type_timerdev
> >> + --prod_type_cryptodev
> >> --prod_enq_burst_sz
> >> --timer_tick_nsec
> >> --max_tmo_nsec
> >> @@ -427,6 +437,7 @@ Supported application command line options are
> >> following::
> >> --nb_timers
> >> --nb_timer_adptrs
> >> --deq_tmo_nsec
> >> + --crypto_adptr_mode
> >>
> >> Example
> >> ^^^^^^^
> >> @@ -529,12 +540,14 @@ Supported application command line options are
> >> following::
> >> --prod_type_ethdev
> >> --prod_type_timerdev_burst
> >> --prod_type_timerdev
> >> + --prod_type_cryptodev
> >> --timer_tick_nsec
> >> --max_tmo_nsec
> >> --expiry_nsec
> >> --nb_timers
> >> --nb_timer_adptrs
> >> --deq_tmo_nsec
> >> + --crypto_adptr_mode
> >>
> >> Example
> >> ^^^^^^^
> >> --
> >> 2.25.1
^ permalink raw reply [flat|nested] 43+ messages in thread
* RE: [PATCH v2] app/eventdev: add crypto producer mode
2022-01-03 8:46 ` Gujjar, Abhinandan S
@ 2022-01-03 9:14 ` Shijith Thotton
2022-01-04 15:28 ` Aaron Conole
0 siblings, 1 reply; 43+ messages in thread
From: Shijith Thotton @ 2022-01-03 9:14 UTC (permalink / raw)
To: dpdklab, aconole
Cc: Anoob Joseph, Pavan Nikhilesh Bhagavatula, Akhil Goyal, Gujjar,
Abhinandan S, Jerin Jacob Kollanukkaran, dev
>> >>
>> >> In crypto producer mode, producer core enqueues cryptodev with
>> >> software generated crypto ops and worker core dequeues crypto
>> >> completion events from the eventdev. Event crypto metadata used for
>> >> above processing is pre- populated in each crypto session.
>> >>
>> >> Parameter --prod_type_cryptodev can be used to enable crypto producer
>> >mode.
>> >> Parameter --crypto_adptr_mode can be set to select the crypto adapter
>> >> mode,
>> >0
>> >> for OP_NEW and 1 for OP_FORWARD.
>> >>
>> >> This mode can be used to measure the performance of crypto adapter.
>> >>
>> >> Example:
>> >> ./dpdk-test-eventdev -l 0-2 -w <EVENTDEV> -w <CRYPTODEV> -- \
>> >> --prod_type_cryptodev --crypto_adptr_mode 1 --test=perf_atq \
>> >> --stlist=a --wlcores 1 --plcores 2
>> >
>> >This patch has some perf failure as shown below. Could you please look into
>> this?
>> >105300 --> performance testing fail
>> >
>> >Test environment and result as below:
>> >
>> >Ubuntu 20.04
>> >Kernel: 4.15.0-generic
>> >Compiler: gcc 7.4
>> >NIC: Intel Corporation Ethernet Converged Network Adapter 82599ES 10000
>> >Mbps
>> >Target: x86_64-native-linuxapp-gcc
>> >Fail/Total: 0/4
>> >
>> >Detail performance results:
>> >+------------+---------+----------+-------------+------------------------------+
>> >| frame_size | txd/rxd | num_cpus | num_threads | throughput
>> >| difference from
>> >|
>> >| | | | | expected |
>>
>>+============+=========+==========+=============+============
>=
>> >=================+
>> >| 64 | 512 | 1 | 1 | 0.3% |
>> >+------------+---------+----------+-------------+------------------------------+
>> >| 64 | 2048 | 1 | 1 | -0.2% |
>> >+------------+---------+----------+-------------+------------------------------+
>> >| 64 | 512 | 1 | 2 | 0.0% |
>> >+------------+---------+----------+-------------+------------------------------+
>> >| 64 | 2048 | 1 | 2 | 0.3% |
>> >+------------+---------+----------+-------------+------------------------------+
>> >
>> >Ubuntu 20.04
>> >Kernel: 4.15.0-generic
>> >Compiler: gcc 7.4
>> >NIC: Intel Corporation Ethernet Converged Network Adapter XL710-QDA2
>> >40000 Mbps
>> >Target: x86_64-native-linuxapp-gcc
>> >Fail/Total: 1/4
>> >
>> >Detail performance results:
>> >+------------+---------+----------+-------------+------------------------------+
>> >| frame_size | txd/rxd | num_cpus | num_threads | throughput
>> >| difference from
>> >|
>> >| | | | | expected |
>>
>>+============+=========+==========+=============+============
>=
>> >=================+
>> >| 64 | 512 | 1 | 1 | 0.2% |
>> >+------------+---------+----------+-------------+------------------------------+
>> >| 64 | 2048 | 1 | 1 | -0.7% |
>> >+------------+---------+----------+-------------+------------------------------+
>> >| 64 | 512 | 1 | 2 | -1.5% |
>> >+------------+---------+----------+-------------+------------------------------+
>> >| 64 | 2048 | 1 | 2 | -5.3% |
>> >+------------+---------+----------+-------------+------------------------------+
>> >
>> >Ubuntu 20.04 ARM
>> >Kernel: 4.15.0-132-generic
>> >Compiler: gcc 7.5
>> >NIC: Arm Intel Corporation Ethernet Converged Network Adapter
>> >XL710-QDA2
>> >40000 Mbps
>> >Target: x86_64-native-linuxapp-gcc
>> >Fail/Total: 0/2
>> >
>> >Detail performance results:
>> >+------------+---------+----------+-------------+------------------------------+
>> >| frame_size | txd/rxd | num_cpus | num_threads | throughput
>> >| difference from
>> >|
>> >| | | | | expected |
>>
>>+============+=========+==========+=============+============
>=
>> >=================+
>> >| 64 | 512 | 1 | 1 | 0.1% |
>> >+------------+---------+----------+-------------+------------------------------+
>> >| 64 | 2048 | 1 | 1 | -0.5% |
>> >+------------+---------+----------+-------------+------------------------------+
>> >
>> >To view detailed results, visit:
>> >https://urldefense.proofpoint.com/v2/url?u=https-
>>
>>3A__lab.dpdk.org_results_dashboard_patchsets_20534_&d=DwIFAg&c=nKjWe
>> c2
>> >b6R0mOyPaz7xtfQ&r=G9w4KsPaQLACBfGCL35PtiRH996yqJDxAZwrWegU2qQ&
>> m=
>>
>>dPDgmKiLC_KqhgjwZrodyFlBdlFPgckVr9IW0c7t2cIHpkw6u9pGqgElFqqwuU1v&s
>> =E
>> >ajYUFziZY27q6LB4p5sOGuFlty3VlOjbMsLXaQ5MeI&e=
>> >
>>
>> Performance regression is reported by nic_single_core_perf, but is using
>> testpmd to measure performance. As this patch does not touch testpmd, the
>> issue could be with DPDK CI. Is it possible to re-trigger CI ?
>I have don't have option to trigger CI from my side.
>So, I have added dpdklab and Aaron to the loop.
>Please check with them.
>
Thanks Abhinandan.
Aaron,
From DTS, I only see testpmd being used for nic_single_core_perf test.
This patch is not touching testpmd, but still got failure for the perf test.
If possible, Please re-retrigger CI for this patch.
>>
>> >>
>> >> Signed-off-by: Shijith Thotton <sthotton@marvell.com>
>> >> ---
>> >> v2:
>> >> * Fix RHEL compilation warning.
>> >>
>> >> app/test-eventdev/evt_common.h | 3 +
>> >> app/test-eventdev/evt_main.c | 13 +-
>> >> app/test-eventdev/evt_options.c | 27 ++
>> >> app/test-eventdev/evt_options.h | 12 +
>> >> app/test-eventdev/evt_test.h | 6 +
>> >> app/test-eventdev/test_perf_atq.c | 51 ++++
>> >> app/test-eventdev/test_perf_common.c | 406
>> >++++++++++++++++++++++++++-
>> >> app/test-eventdev/test_perf_common.h | 16 ++ app/test-
>> >> eventdev/test_perf_queue.c | 52 ++++
>> >> doc/guides/tools/testeventdev.rst | 13 +
>> >> 10 files changed, 592 insertions(+), 7 deletions(-)
>> >>
>> >> diff --git a/app/test-eventdev/evt_common.h b/app/test-
>> >> eventdev/evt_common.h index f466434459..2f301a7e79 100644
>> >> --- a/app/test-eventdev/evt_common.h
>> >> +++ b/app/test-eventdev/evt_common.h
>> >> @@ -7,6 +7,7 @@
>> >>
>> >> #include <rte_common.h>
>> >> #include <rte_debug.h>
>> >> +#include <rte_event_crypto_adapter.h>
>> >> #include <rte_eventdev.h>
>> >> #include <rte_service.h>
>> >>
>> >> @@ -39,6 +40,7 @@ enum evt_prod_type {
>> >> EVT_PROD_TYPE_SYNT, /* Producer type Synthetic i.e. CPU. */
>> >> EVT_PROD_TYPE_ETH_RX_ADPTR, /* Producer type Eth Rx Adapter. */
>> >> EVT_PROD_TYPE_EVENT_TIMER_ADPTR, /* Producer type Timer
>> Adapter.
>> >> */
>> >> + EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR, /* Producer type Crypto
>> >> Adapter. */
>> >> EVT_PROD_TYPE_MAX,
>> >> };
>> >>
>> >> @@ -77,6 +79,7 @@ struct evt_options {
>> >> uint64_t timer_tick_nsec;
>> >> uint64_t optm_timer_tick_nsec;
>> >> enum evt_prod_type prod_type;
>> >> + enum rte_event_crypto_adapter_mode crypto_adptr_mode;
>> >> };
>> >>
>> >> static inline bool
>> >> diff --git a/app/test-eventdev/evt_main.c
>> >> b/app/test-eventdev/evt_main.c index 194c980c7a..cef0fb1382 100644
>> >> --- a/app/test-eventdev/evt_main.c
>> >> +++ b/app/test-eventdev/evt_main.c
>> >> @@ -161,12 +161,19 @@ main(int argc, char **argv)
>> >> goto mempool_destroy;
>> >> }
>> >> }
>> >> + /* Test specific cryptodev setup */
>> >> + if (test->ops.cryptodev_setup) {
>> >> + if (test->ops.cryptodev_setup(test, &opt)) {
>> >> + evt_err("%s: cryptodev setup failed", opt.test_name);
>> >> + goto ethdev_destroy;
>> >> + }
>> >> + }
>> >>
>> >> /* Test specific eventdev setup */
>> >> if (test->ops.eventdev_setup) {
>> >> if (test->ops.eventdev_setup(test, &opt)) {
>> >> evt_err("%s: eventdev setup failed", opt.test_name);
>> >> - goto ethdev_destroy;
>> >> + goto cryptodev_destroy;
>> >> }
>> >> }
>> >>
>> >> @@ -197,6 +204,10 @@ main(int argc, char **argv)
>> >> if (test->ops.eventdev_destroy)
>> >> test->ops.eventdev_destroy(test, &opt);
>> >>
>> >> +cryptodev_destroy:
>> >> + if (test->ops.cryptodev_destroy)
>> >> + test->ops.cryptodev_destroy(test, &opt);
>> >> +
>> >> ethdev_destroy:
>> >> if (test->ops.ethdev_destroy)
>> >> test->ops.ethdev_destroy(test, &opt); diff --git a/app/test-
>> >> eventdev/evt_options.c b/app/test-eventdev/evt_options.c index
>> >> 753a7dbd7d..5ad1491020 100644
>> >> --- a/app/test-eventdev/evt_options.c
>> >> +++ b/app/test-eventdev/evt_options.c
>> >> @@ -122,6 +122,26 @@ evt_parse_timer_prod_type_burst(struct
>> >> evt_options *opt,
>> >> return 0;
>> >> }
>> >>
>> >> +static int
>> >> +evt_parse_crypto_prod_type(struct evt_options *opt,
>> >> + const char *arg __rte_unused)
>> >> +{
>> >> + opt->prod_type = EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR;
>> >> + return 0;
>> >> +}
>> >> +
>> >> +static int
>> >> +evt_parse_crypto_adptr_mode(struct evt_options *opt, const char *arg) {
>> >> + uint8_t mode;
>> >> + int ret;
>> >> +
>> >> + ret = parser_read_uint8(&mode, arg);
>> >> + opt->crypto_adptr_mode = mode ?
>> >> RTE_EVENT_CRYPTO_ADAPTER_OP_FORWARD :
>> >> +
>> >> RTE_EVENT_CRYPTO_ADAPTER_OP_NEW;
>> >> + return ret;
>> >> +}
>> >> +
>> >> static int
>> >> evt_parse_test_name(struct evt_options *opt, const char *arg) { @@
>> >> -335,6
>> >> +355,7 @@ usage(char *program)
>> >> "\t--queue_priority : enable queue priority\n"
>> >> "\t--deq_tmo_nsec : global dequeue timeout\n"
>> >> "\t--prod_type_ethdev : use ethernet device as producer.\n"
>> >> + "\t--prod_type_cryptodev : use crypto device as producer.\n"
>> >> "\t--prod_type_timerdev : use event timer device as
>> producer.\n"
>> >> "\t expity_nsec would be the timeout\n"
>> >> "\t in ns.\n"
>> >> @@ -345,6 +366,8 @@ usage(char *program)
>> >> "\t--timer_tick_nsec : timer tick interval in ns.\n"
>> >> "\t--max_tmo_nsec : max timeout interval in ns.\n"
>> >> "\t--expiry_nsec : event timer expiry ns.\n"
>> >> + "\t--crypto_adptr_mode : 0 for OP_NEW mode (default) and\n"
>> >> + "\t 1 for OP_FORWARD mode.\n"
>> >> "\t--mbuf_sz : packet mbuf size.\n"
>> >> "\t--max_pkt_sz : max packet size.\n"
>> >> "\t--prod_enq_burst_sz : producer enqueue burst size.\n"
>> >> @@ -415,8 +438,10 @@ static struct option lgopts[] = {
>> >> { EVT_QUEUE_PRIORITY, 0, 0, 0 },
>> >> { EVT_DEQ_TMO_NSEC, 1, 0, 0 },
>> >> { EVT_PROD_ETHDEV, 0, 0, 0 },
>> >> + { EVT_PROD_CRYPTODEV, 0, 0, 0 },
>> >> { EVT_PROD_TIMERDEV, 0, 0, 0 },
>> >> { EVT_PROD_TIMERDEV_BURST, 0, 0, 0 },
>> >> + { EVT_CRYPTO_ADPTR_MODE, 1, 0, 0 },
>> >> { EVT_NB_TIMERS, 1, 0, 0 },
>> >> { EVT_NB_TIMER_ADPTRS, 1, 0, 0 },
>> >> { EVT_TIMER_TICK_NSEC, 1, 0, 0 },
>> >> @@ -455,8 +480,10 @@ evt_opts_parse_long(int opt_idx, struct
>> >> evt_options
>> >> *opt)
>> >> { EVT_QUEUE_PRIORITY, evt_parse_queue_priority},
>> >> { EVT_DEQ_TMO_NSEC, evt_parse_deq_tmo_nsec},
>> >> { EVT_PROD_ETHDEV, evt_parse_eth_prod_type},
>> >> + { EVT_PROD_CRYPTODEV, evt_parse_crypto_prod_type},
>> >> { EVT_PROD_TIMERDEV, evt_parse_timer_prod_type},
>> >> { EVT_PROD_TIMERDEV_BURST,
>> >> evt_parse_timer_prod_type_burst},
>> >> + { EVT_CRYPTO_ADPTR_MODE, evt_parse_crypto_adptr_mode},
>> >> { EVT_NB_TIMERS, evt_parse_nb_timers},
>> >> { EVT_NB_TIMER_ADPTRS, evt_parse_nb_timer_adptrs},
>> >> { EVT_TIMER_TICK_NSEC, evt_parse_timer_tick_nsec}, diff --git
>> >> a/app/test-eventdev/evt_options.h b/app/test-eventdev/evt_options.h
>> >> index
>> >> 413d7092f0..2231c58801 100644
>> >> --- a/app/test-eventdev/evt_options.h
>> >> +++ b/app/test-eventdev/evt_options.h
>> >> @@ -9,6 +9,7 @@
>> >> #include <stdbool.h>
>> >>
>> >> #include <rte_common.h>
>> >> +#include <rte_cryptodev.h>
>> >> #include <rte_ethdev.h>
>> >> #include <rte_eventdev.h>
>> >> #include <rte_lcore.h>
>> >> @@ -33,8 +34,10 @@
>> >> #define EVT_QUEUE_PRIORITY ("queue_priority")
>> >> #define EVT_DEQ_TMO_NSEC ("deq_tmo_nsec")
>> >> #define EVT_PROD_ETHDEV ("prod_type_ethdev")
>> >> +#define EVT_PROD_CRYPTODEV ("prod_type_cryptodev")
>> >> #define EVT_PROD_TIMERDEV ("prod_type_timerdev")
>> >> #define EVT_PROD_TIMERDEV_BURST ("prod_type_timerdev_burst")
>> >> +#define EVT_CRYPTO_ADPTR_MODE ("crypto_adptr_mode")
>> >> #define EVT_NB_TIMERS ("nb_timers")
>> >> #define EVT_NB_TIMER_ADPTRS ("nb_timer_adptrs")
>> >> #define EVT_TIMER_TICK_NSEC ("timer_tick_nsec")
>> >> @@ -249,6 +252,8 @@ evt_prod_id_to_name(enum evt_prod_type
>> prod_type)
>> >> return "Ethdev Rx Adapter";
>> >> case EVT_PROD_TYPE_EVENT_TIMER_ADPTR:
>> >> return "Event timer adapter";
>> >> + case EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR:
>> >> + return "Event crypto adapter";
>> >> }
>> >>
>> >> return "";
>> >> @@ -288,6 +293,13 @@ evt_dump_producer_type(struct evt_options *opt)
>> >> evt_dump("timer_tick_nsec", "%"PRIu64"",
>> >> opt->timer_tick_nsec);
>> >> break;
>> >> + case EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR:
>> >> + snprintf(name, EVT_PROD_MAX_NAME_LEN,
>> >> + "Event crypto adapter producers");
>> >> + evt_dump("crypto adapter mode", "%s",
>> >> + opt->crypto_adptr_mode ? "OP_FORWARD" :
>> >> "OP_NEW");
>> >> + evt_dump("nb_cryptodev", "%u", rte_cryptodev_count());
>> >> + break;
>> >> }
>> >> evt_dump("prod_type", "%s", name);
>> >> }
>> >> diff --git a/app/test-eventdev/evt_test.h
>> >> b/app/test-eventdev/evt_test.h
>> >index
>> >> f07d2c3336..50fa474ec2 100644
>> >> --- a/app/test-eventdev/evt_test.h
>> >> +++ b/app/test-eventdev/evt_test.h
>> >> @@ -29,6 +29,8 @@ typedef int (*evt_test_mempool_setup_t)
>> >> (struct evt_test *test, struct evt_options *opt); typedef int
>> >> (*evt_test_ethdev_setup_t)
>> >> (struct evt_test *test, struct evt_options *opt);
>> >> +typedef int (*evt_test_cryptodev_setup_t)
>> >> + (struct evt_test *test, struct evt_options *opt);
>> >> typedef int (*evt_test_eventdev_setup_t)
>> >> (struct evt_test *test, struct evt_options *opt); typedef int
>> >> (*evt_test_launch_lcores_t) @@ -39,6 +41,8 @@ typedef void
>> >> (*evt_test_eventdev_destroy_t)
>> >> (struct evt_test *test, struct evt_options *opt); typedef void
>> >> (*evt_test_ethdev_destroy_t)
>> >> (struct evt_test *test, struct evt_options *opt);
>> >> +typedef void (*evt_test_cryptodev_destroy_t)
>> >> + (struct evt_test *test, struct evt_options *opt);
>> >> typedef void (*evt_test_mempool_destroy_t)
>> >> (struct evt_test *test, struct evt_options *opt); typedef void
>> >> (*evt_test_destroy_t) @@ -52,10 +56,12 @@ struct evt_test_ops {
>> >> evt_test_mempool_setup_t mempool_setup;
>> >> evt_test_ethdev_setup_t ethdev_setup;
>> >> evt_test_eventdev_setup_t eventdev_setup;
>> >> + evt_test_cryptodev_setup_t cryptodev_setup;
>> >> evt_test_launch_lcores_t launch_lcores;
>> >> evt_test_result_t test_result;
>> >> evt_test_eventdev_destroy_t eventdev_destroy;
>> >> evt_test_ethdev_destroy_t ethdev_destroy;
>> >> + evt_test_cryptodev_destroy_t cryptodev_destroy;
>> >> evt_test_mempool_destroy_t mempool_destroy;
>> >> evt_test_destroy_t test_destroy;
>> >> };
>> >> diff --git a/app/test-eventdev/test_perf_atq.c b/app/test-
>> >> eventdev/test_perf_atq.c index 8fd51004ee..dbb1dc8c0c 100644
>> >> --- a/app/test-eventdev/test_perf_atq.c
>> >> +++ b/app/test-eventdev/test_perf_atq.c
>> >> @@ -48,6 +48,22 @@ perf_atq_worker(void *arg, const int
>> >> enable_fwd_latency)
>> >> continue;
>> >> }
>> >>
>> >> + if (prod_crypto_type &&
>> >> + (ev.event_type == RTE_EVENT_TYPE_CRYPTODEV)) {
>> >> + struct rte_crypto_op *op = ev.event_ptr;
>> >> +
>> >> + if (op->status == RTE_CRYPTO_OP_STATUS_SUCCESS) {
>> >> + if (op->sym->m_dst == NULL)
>> >> + ev.event_ptr = op->sym->m_src;
>> >> + else
>> >> + ev.event_ptr = op->sym->m_dst;
>> >> + rte_crypto_op_free(op);
>> >> + } else {
>> >> + rte_crypto_op_free(op);
>> >> + continue;
>> >> + }
>> >> + }
>> >> +
>> >> if (enable_fwd_latency && !prod_timer_type)
>> >> /* first stage in pipeline, mark ts to compute fwd latency */
>> >> atq_mark_fwd_latency(&ev);
>> >> @@ -87,6 +103,25 @@ perf_atq_worker_burst(void *arg, const int
>> >> enable_fwd_latency)
>> >> }
>> >>
>> >> for (i = 0; i < nb_rx; i++) {
>> >> + if (prod_crypto_type &&
>> >> + (ev[i].event_type == RTE_EVENT_TYPE_CRYPTODEV))
>> >> {
>> >> + struct rte_crypto_op *op = ev[i].event_ptr;
>> >> +
>> >> + if (op->status ==
>> >> + RTE_CRYPTO_OP_STATUS_SUCCESS) {
>> >> + if (op->sym->m_dst == NULL)
>> >> + ev[i].event_ptr =
>> >> + op->sym->m_src;
>> >> + else
>> >> + ev[i].event_ptr =
>> >> + op->sym->m_dst;
>> >> + rte_crypto_op_free(op);
>> >> + } else {
>> >> + rte_crypto_op_free(op);
>> >> + continue;
>> >> + }
>> >> + }
>> >> +
>> >> if (enable_fwd_latency && !prod_timer_type) {
>> >> rte_prefetch0(ev[i+1].event_ptr);
>> >> /* first stage in pipeline.
>> >> @@ -254,6 +289,20 @@ perf_atq_eventdev_setup(struct evt_test *test,
>> >> struct evt_options *opt)
>> >> return ret;
>> >> }
>> >> }
>> >> + } else if (opt->prod_type == EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR) {
>> >> + uint8_t cdev_id, cdev_count;
>> >> +
>> >> + cdev_count = rte_cryptodev_count();
>> >> + for (cdev_id = 0; cdev_id < cdev_count; cdev_id++) {
>> >> + ret = rte_cryptodev_start(cdev_id);
>> >> + if (ret) {
>> >> + evt_err("Failed to start cryptodev %u",
>> >> + cdev_id);
>> >> + return ret;
>> >> + }
>> >> + }
>> >> +
>> >> + rte_event_crypto_adapter_start(t->crypto_adptr.id);
>> >> }
>> >>
>> >> return 0;
>> >> @@ -295,12 +344,14 @@ static const struct evt_test_ops perf_atq = {
>> >> .opt_dump = perf_atq_opt_dump,
>> >> .test_setup = perf_test_setup,
>> >> .ethdev_setup = perf_ethdev_setup,
>> >> + .cryptodev_setup = perf_cryptodev_setup,
>> >> .mempool_setup = perf_mempool_setup,
>> >> .eventdev_setup = perf_atq_eventdev_setup,
>> >> .launch_lcores = perf_atq_launch_lcores,
>> >> .eventdev_destroy = perf_eventdev_destroy,
>> >> .mempool_destroy = perf_mempool_destroy,
>> >> .ethdev_destroy = perf_ethdev_destroy,
>> >> + .cryptodev_destroy = perf_cryptodev_destroy,
>> >> .test_result = perf_test_result,
>> >> .test_destroy = perf_test_destroy,
>> >> };
>> >> diff --git a/app/test-eventdev/test_perf_common.c b/app/test-
>> >> eventdev/test_perf_common.c index 9b73874151..7b964ab8dc 100644
>> >> --- a/app/test-eventdev/test_perf_common.c
>> >> +++ b/app/test-eventdev/test_perf_common.c
>> >> @@ -6,6 +6,8 @@
>> >>
>> >> #include "test_perf_common.h"
>> >>
>> >> +#define NB_CRYPTODEV_DESCRIPTORS 128
>> >> +
>> >> int
>> >> perf_test_result(struct evt_test *test, struct evt_options *opt) {
>> >> @@ -272,6
>> >> +274,121 @@ perf_event_timer_producer_burst(void *arg)
>> >> return 0;
>> >> }
>> >>
>> >> +static inline void
>> >> +crypto_adapter_enq_op_new(struct prod_data *p) {
>> >> + struct test_perf *t = p->t;
>> >> + const uint32_t nb_flows = t->nb_flows;
>> >> + const uint64_t nb_pkts = t->nb_pkts;
>> >> + struct rte_mempool *pool = t->pool;
>> >> + struct rte_crypto_sym_op *sym_op;
>> >> + struct evt_options *opt = t->opt;
>> >> + uint32_t flow_counter = 0;
>> >> + struct rte_crypto_op *op;
>> >> + struct rte_mbuf *m;
>> >> + uint64_t count = 0;
>> >> + uint16_t len;
>> >> +
>> >> + if (opt->verbose_level > 1)
>> >> + printf("%s(): lcore %d queue %d cdev_id %u cdev_qp_id %u\n",
>> >> + __func__, rte_lcore_id(), p->queue_id, p->cdev_id,
>> >> + p->cdev_qp_id);
>> >> +
>> >> + len = opt->mbuf_sz ? opt->mbuf_sz : RTE_ETHER_MIN_LEN;
>> >> +
>> >> + while (count < nb_pkts && t->done == false) {
>> >> + m = rte_pktmbuf_alloc(pool);
>> >> + if (m == NULL)
>> >> + continue;
>> >> +
>> >> + rte_pktmbuf_append(m, len);
>> >> + op = rte_crypto_op_alloc(t->crypto_adptr.op_pool,
>> >> + RTE_CRYPTO_OP_TYPE_SYMMETRIC);
>> >> + sym_op = op->sym;
>> >> + sym_op->m_src = m;
>> >> + sym_op->cipher.data.offset = 0;
>> >> + sym_op->cipher.data.length = len;
>> >> + rte_crypto_op_attach_sym_session(
>> >> + op, p->crypto_sess[flow_counter++ % nb_flows]);
>> >> + while (rte_cryptodev_enqueue_burst(p->cdev_id, p-
>> >> >cdev_qp_id,
>> >> + &op, 1) != 1) {
>> >> + if (t->done)
>> >> + break;
>> >> + rte_pause();
>> >> + }
>> >> + count++;
>> >> + }
>> >> +}
>> >> +
>> >> +static inline void
>> >> +crypto_adapter_enq_op_fwd(struct prod_data *p) {
>> >> + const uint8_t dev_id = p->dev_id;
>> >> + const uint8_t port = p->port_id;
>> >> + struct test_perf *t = p->t;
>> >> + const uint32_t nb_flows = t->nb_flows;
>> >> + const uint64_t nb_pkts = t->nb_pkts;
>> >> + struct rte_mempool *pool = t->pool;
>> >> + struct evt_options *opt = t->opt;
>> >> + struct rte_crypto_sym_op *sym_op;
>> >> + uint32_t flow_counter = 0;
>> >> + struct rte_crypto_op *op;
>> >> + struct rte_event ev;
>> >> + struct rte_mbuf *m;
>> >> + uint64_t count = 0;
>> >> + uint16_t len;
>> >> +
>> >> + if (opt->verbose_level > 1)
>> >> + printf("%s(): lcore %d port %d queue %d cdev_id %u cdev_qp_id
>> >> %u\n",
>> >> + __func__, rte_lcore_id(), port, p->queue_id, p->cdev_id,
>> >> + p->cdev_qp_id);
>> >> +
>> >> + ev.event = 0;
>> >> + ev.op = RTE_EVENT_OP_NEW;
>> >> + ev.queue_id = p->queue_id;
>> >> + ev.sched_type = RTE_SCHED_TYPE_ATOMIC;
>> >> + ev.event_type = RTE_EVENT_TYPE_CPU;
>> >> + len = opt->mbuf_sz ? opt->mbuf_sz : RTE_ETHER_MIN_LEN;
>> >> +
>> >> + while (count < nb_pkts && t->done == false) {
>> >> + m = rte_pktmbuf_alloc(pool);
>> >> + if (m == NULL)
>> >> + continue;
>> >> +
>> >> + rte_pktmbuf_append(m, len);
>> >> + op = rte_crypto_op_alloc(t->crypto_adptr.op_pool,
>> >> + RTE_CRYPTO_OP_TYPE_SYMMETRIC);
>> >> + sym_op = op->sym;
>> >> + sym_op->m_src = m;
>> >> + sym_op->cipher.data.offset = 0;
>> >> + sym_op->cipher.data.length = len;
>> >> + rte_crypto_op_attach_sym_session(
>> >> + op, p->crypto_sess[flow_counter++ % nb_flows]);
>> >> + ev.event_ptr = op;
>> >> + while (rte_event_crypto_adapter_enqueue(dev_id, port, &ev, 1)
>> >> !=
>> >> + 1) {
>> >> + if (t->done)
>> >> + break;
>> >> + rte_pause();
>> >> + }
>> >> + count++;
>> >> + }
>> >> +}
>> >> +
>> >> +static inline int
>> >> +perf_event_crypto_producer(void *arg) {
>> >> + struct prod_data *p = arg;
>> >> + struct evt_options *opt = p->t->opt;
>> >> +
>> >> + if (opt->crypto_adptr_mode ==
>> >> RTE_EVENT_CRYPTO_ADAPTER_OP_NEW)
>> >> + crypto_adapter_enq_op_new(p);
>> >> + else
>> >> + crypto_adapter_enq_op_fwd(p);
>> >> +
>> >> + return 0;
>> >> +}
>> >> +
>> >> static int
>> >> perf_producer_wrapper(void *arg)
>> >> {
>> >> @@ -298,6 +415,8 @@ perf_producer_wrapper(void *arg)
>> >> else if (t->opt->prod_type == EVT_PROD_TYPE_EVENT_TIMER_ADPTR
>> &&
>> >> t->opt->timdev_use_burst)
>> >> return perf_event_timer_producer_burst(arg);
>> >> + else if (t->opt->prod_type == EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR)
>> >> + return perf_event_crypto_producer(arg);
>> >> return 0;
>> >> }
>> >>
>> >> @@ -405,8 +524,10 @@ perf_launch_lcores(struct evt_test *test, struct
>> >> evt_options *opt,
>> >> if (remaining <= 0) {
>> >> t->result = EVT_TEST_SUCCESS;
>> >> if (opt->prod_type == EVT_PROD_TYPE_SYNT
>> >> ||
>> >> - opt->prod_type ==
>> >> -
>> >> EVT_PROD_TYPE_EVENT_TIMER_ADPTR) {
>> >> + opt->prod_type ==
>> >> +
>> >> EVT_PROD_TYPE_EVENT_TIMER_ADPTR ||
>> >> + opt->prod_type ==
>> >> +
>> >> EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR) {
>> >> t->done = true;
>> >> break;
>> >> }
>> >> @@ -415,7 +536,8 @@ perf_launch_lcores(struct evt_test *test, struct
>> >> evt_options *opt,
>> >>
>> >> if (new_cycles - dead_lock_cycles > dead_lock_sample &&
>> >> (opt->prod_type == EVT_PROD_TYPE_SYNT ||
>> >> - opt->prod_type == EVT_PROD_TYPE_EVENT_TIMER_ADPTR))
>> >> {
>> >> + opt->prod_type == EVT_PROD_TYPE_EVENT_TIMER_ADPTR
>> >> ||
>> >> + opt->prod_type ==
>> >> EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR)) {
>> >> remaining = t->outstand_pkts - processed_pkts(t);
>> >> if (dead_lock_remaining == remaining) {
>> >> rte_event_dev_dump(opt->dev_id, stdout);
>> @@ -537,6 +659,96 @@
>> >> perf_event_timer_adapter_setup(struct test_perf *t)
>> >> return 0;
>> >> }
>> >>
>> >> +static int
>> >> +perf_event_crypto_adapter_setup(struct test_perf *t,
>> >> + struct rte_event_port_conf port_conf) {
>> >> + struct evt_options *opt = t->opt;
>> >> + uint8_t cdev_id, cdev_count;
>> >> + int ret;
>> >> +
>> >> + t->crypto_adptr.id = 0;
>> >> + ret = rte_event_crypto_adapter_create(t->crypto_adptr.id, opt->dev_id,
>> >> + &port_conf, 0);
>> >> + if (ret)
>> >> + return ret;
>> >> +
>> >> + cdev_count = rte_cryptodev_count();
>> >> + for (cdev_id = 0; cdev_id < cdev_count; cdev_id++) {
>> >> + uint32_t cap;
>> >> +
>> >> + ret = rte_event_crypto_adapter_caps_get(opt->dev_id,
>> >> cdev_id,
>> >> + &cap);
>> >> + if (ret) {
>> >> + evt_err("Failed to get crypto adapter capabilities");
>> >> + return ret;
>> >> + }
>> >> +
>> >> + if (((opt->crypto_adptr_mode ==
>> >> + RTE_EVENT_CRYPTO_ADAPTER_OP_NEW) &&
>> >> + !(cap &
>> >> +
>> >> RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_OP_NEW)) ||
>> >> + ((opt->crypto_adptr_mode ==
>> >> + RTE_EVENT_CRYPTO_ADAPTER_OP_FORWARD) &&
>> >> + !(cap &
>> >> +
>> >> RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_OP_FWD))) {
>> >> + evt_err("crypto adapter %s mode unsupported\n",
>> >> + opt->crypto_adptr_mode ? "OP_FORWARD" :
>> >> + "OP_NEW");
>> >> + return -EINVAL;
>> >> + }
>> >> +
>> >> + if (!(cap &
>> >> +
>> >> RTE_EVENT_CRYPTO_ADAPTER_CAP_SESSION_PRIVATE_DATA)) {
>> >> + evt_err("Storing crypto session not supported");
>> >> + return -EINVAL;
>> >> + }
>> >> +
>> >> + if (cap &
>> >> +
>> >> RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_QP_EV_BIND) {
>> >> + struct rte_event response_info;
>> >> +
>> >> + response_info.event = 0;
>> >> + ret = rte_event_crypto_adapter_queue_pair_add(
>> >> + t->crypto_adptr.id, cdev_id, -1,
>> >> + &response_info);
>> >> + } else {
>> >> + ret = rte_event_crypto_adapter_queue_pair_add(
>> >> + t->crypto_adptr.id, cdev_id, -1, NULL);
>> >> + }
>> >> + if (ret)
>> >> + return ret;
>> >> + }
>> >> +
>> >> + return 0;
>> >> +}
>> >> +
>> >> +static struct rte_cryptodev_sym_session *
>> >> +cryptodev_session_create(struct prod_data *p, struct test_perf *t) {
>> >> + struct rte_crypto_sym_xform cipher_xform;
>> >> + struct rte_cryptodev_sym_session *sess;
>> >> +
>> >> + cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
>> >> + cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
>> >> + cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
>> >> + cipher_xform.next = NULL;
>> >> +
>> >> + sess = rte_cryptodev_sym_session_create(t->crypto_adptr.sess_pool);
>> >> + if (sess == NULL) {
>> >> + evt_err("Failed to create sym session");
>> >> + return NULL;
>> >> + }
>> >> +
>> >> + if (rte_cryptodev_sym_session_init(p->cdev_id, sess, &cipher_xform,
>> >> + t->crypto_adptr.sess_priv_pool)) {
>> >> + evt_err("Failed to init session");
>> >> + return NULL;
>> >> + }
>> >> +
>> >> + return sess;
>> >> +}
>> >> +
>> >> int
>> >> perf_event_dev_port_setup(struct evt_test *test, struct evt_options *opt,
>> >> uint8_t stride, uint8_t nb_queues, @@ -598,6
>> +810,55 @@
>> >> perf_event_dev_port_setup(struct evt_test *test, struct evt_options
>> >> *opt,
>> >> ret = perf_event_timer_adapter_setup(t);
>> >> if (ret)
>> >> return ret;
>> >> + } else if (opt->prod_type == EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR) {
>> >> + uint8_t cdev_id = 0;
>> >> + uint16_t qp_id = 0;
>> >> +
>> >> + prod = 0;
>> >> + for (; port < perf_nb_event_ports(opt); port++) {
>> >> + struct rte_cryptodev_sym_session *crypto_sess;
>> >> + union rte_event_crypto_metadata m_data;
>> >> + struct prod_data *p = &t->prod[port];
>> >> + uint32_t flow_id;
>> >> +
>> >> + if (qp_id == rte_cryptodev_queue_pair_count(cdev_id))
>> >> {
>> >> + cdev_id++;
>> >> + qp_id = 0;
>> >> + }
>> >> +
>> >> + p->dev_id = opt->dev_id;
>> >> + p->port_id = port;
>> >> + p->queue_id = prod * stride;
>> >> + p->cdev_id = cdev_id;
>> >> + p->cdev_qp_id = qp_id;
>> >> + p->crypto_sess = rte_zmalloc_socket(
>> >> + NULL, sizeof(crypto_sess) * t->nb_flows,
>> >> + RTE_CACHE_LINE_SIZE, opt->socket_id);
>> >> +
>> >> + m_data.request_info.cdev_id = p->cdev_id;
>> >> + m_data.request_info.queue_pair_id = p->cdev_qp_id;
>> >> + m_data.response_info.op = RTE_EVENT_OP_NEW;
>> >> + m_data.response_info.sched_type =
>> >> RTE_SCHED_TYPE_ATOMIC;
>> >> + m_data.response_info.event_type =
>> >> RTE_EVENT_TYPE_CPU;
>> >> + m_data.response_info.queue_id = p->queue_id;
>> >> + for (flow_id = 0; flow_id < t->nb_flows; flow_id++) {
>> >> + crypto_sess = cryptodev_session_create(p, t);
>> >> + if (crypto_sess == NULL)
>> >> + return -ENOMEM;
>> >> +
>> >> + m_data.response_info.flow_id = flow_id;
>> >> + rte_cryptodev_sym_session_set_user_data(
>> >> + crypto_sess, &m_data,
>> >> sizeof(m_data));
>> >> + p->crypto_sess[flow_id] = crypto_sess;
>> >> + }
>> >> + p->t = t;
>> >> + qp_id++;
>> >> + prod++;
>> >> + }
>> >> +
>> >> + ret = perf_event_crypto_adapter_setup(t, *port_conf);
>> >> + if (ret)
>> >> + return ret;
>> >> } else {
>> >> prod = 0;
>> >> for ( ; port < perf_nb_event_ports(opt); port++) { @@ -659,7
>> >> +920,8 @@ perf_opt_check(struct evt_options *opt, uint64_t nb_queues)
>> >> }
>> >>
>> >> if (opt->prod_type == EVT_PROD_TYPE_SYNT ||
>> >> - opt->prod_type ==
>> >> EVT_PROD_TYPE_EVENT_TIMER_ADPTR) {
>> >> + opt->prod_type == EVT_PROD_TYPE_EVENT_TIMER_ADPTR ||
>> >> + opt->prod_type == EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR) {
>> >> /* Validate producer lcores */
>> >> if (evt_lcores_has_overlap(opt->plcores,
>> >> rte_get_main_lcore())) {
>> >> @@ -767,8 +1029,7 @@ perf_ethdev_setup(struct evt_test *test, struct
>> >> evt_options *opt)
>> >> },
>> >> };
>> >>
>> >> - if (opt->prod_type == EVT_PROD_TYPE_SYNT ||
>> >> - opt->prod_type ==
>> >> EVT_PROD_TYPE_EVENT_TIMER_ADPTR)
>> >> + if (opt->prod_type != EVT_PROD_TYPE_ETH_RX_ADPTR)
>> >> return 0;
>> >>
>> >> if (!rte_eth_dev_count_avail()) {
>> >> @@ -841,6 +1102,139 @@ void perf_ethdev_destroy(struct evt_test
>> >> *test, struct evt_options *opt)
>> >> }
>> >> }
>> >>
>> >> +int
>> >> +perf_cryptodev_setup(struct evt_test *test, struct evt_options *opt) {
>> >> + uint8_t cdev_count, cdev_id, nb_plcores, nb_qps;
>> >> + struct test_perf *t = evt_test_priv(test);
>> >> + unsigned int max_session_size;
>> >> + uint32_t nb_sessions;
>> >> + int ret;
>> >> +
>> >> + if (opt->prod_type != EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR)
>> >> + return 0;
>> >> +
>> >> + cdev_count = rte_cryptodev_count();
>> >> + if (cdev_count == 0) {
>> >> + evt_err("No crypto devices available\n");
>> >> + return -ENODEV;
>> >> + }
>> >> +
>> >> + t->crypto_adptr.op_pool = rte_crypto_op_pool_create(
>> >> + "crypto_op_pool", RTE_CRYPTO_OP_TYPE_SYMMETRIC, opt-
>> >> >pool_sz,
>> >> + 128, 0, rte_socket_id());
>> >> + if (t->crypto_adptr.op_pool == NULL) {
>> >> + evt_err("Failed to create crypto op pool");
>> >> + return -ENOMEM;
>> >> + }
>> >> +
>> >> + nb_sessions = evt_nr_active_lcores(opt->plcores) * t->nb_flows;
>> >> + t->crypto_adptr.sess_pool = rte_cryptodev_sym_session_pool_create(
>> >> + "ca_sess_pool", nb_sessions, 0, 0,
>> >> + sizeof(union rte_event_crypto_metadata), SOCKET_ID_ANY);
>> >> + if (t->crypto_adptr.sess_pool == NULL) {
>> >> + evt_err("Failed to create sym session pool");
>> >> + ret = -ENOMEM;
>> >> + goto err;
>> >> + }
>> >> +
>> >> + max_session_size = 0;
>> >> + for (cdev_id = 0; cdev_id < cdev_count; cdev_id++) {
>> >> + unsigned int session_size;
>> >> +
>> >> + session_size =
>> >> + rte_cryptodev_sym_get_private_session_size(cdev_id);
>> >> + if (session_size > max_session_size)
>> >> + max_session_size = session_size;
>> >> + }
>> >> + max_session_size += sizeof(union rte_event_crypto_metadata);
>> >> + t->crypto_adptr.sess_priv_pool = rte_mempool_create(
>> >> + "ca_sess_priv_pool", nb_sessions, max_session_size, 0, 0,
>> >> NULL,
>> >> + NULL, NULL, NULL, SOCKET_ID_ANY, 0);
>> >> + if (t->crypto_adptr.sess_priv_pool == NULL) {
>> >> + evt_err("failed to create sym session private pool");
>> >> + ret = -ENOMEM;
>> >> + goto err;
>> >> + }
>> >> +
>> >> + nb_plcores = evt_nr_active_lcores(opt->plcores);
>> >> + nb_qps = (nb_plcores % cdev_count) ? (nb_plcores / cdev_count) + 1 :
>> >> + nb_plcores / cdev_count;
>> >> + for (cdev_id = 0; cdev_id < cdev_count; cdev_id++) {
>> >> + struct rte_cryptodev_qp_conf qp_conf;
>> >> + struct rte_cryptodev_config conf;
>> >> + struct rte_cryptodev_info info;
>> >> + int qp_id;
>> >> +
>> >> + rte_cryptodev_info_get(cdev_id, &info);
>> >> + if (nb_qps > info.max_nb_queue_pairs) {
>> >> + evt_err("Not enough queue pairs per cryptodev (%u)",
>> >> + nb_qps);
>> >> + ret = -EINVAL;
>> >> + goto err;
>> >> + }
>> >> +
>> >> + conf.nb_queue_pairs = nb_qps;
>> >> + conf.socket_id = SOCKET_ID_ANY;
>> >> + conf.ff_disable = RTE_CRYPTODEV_FF_SECURITY;
>> >> +
>> >> + ret = rte_cryptodev_configure(cdev_id, &conf);
>> >> + if (ret) {
>> >> + evt_err("Failed to configure cryptodev (%u)", cdev_id);
>> >> + goto err;
>> >> + }
>> >> +
>> >> + qp_conf.nb_descriptors = NB_CRYPTODEV_DESCRIPTORS;
>> >> + qp_conf.mp_session = t->crypto_adptr.sess_pool;
>> >> + qp_conf.mp_session_private = t->crypto_adptr.sess_priv_pool;
>> >> +
>> >> + for (qp_id = 0; qp_id < conf.nb_queue_pairs; qp_id++) {
>> >> + ret = rte_cryptodev_queue_pair_setup(
>> >> + cdev_id, qp_id, &qp_conf,
>> >> + rte_cryptodev_socket_id(cdev_id));
>> >> + if (ret) {
>> >> + evt_err("Failed to setup queue pairs on
>> >> cryptodev %u\n",
>> >> + cdev_id);
>> >> + goto err;
>> >> + }
>> >> + }
>> >> + }
>> >> +
>> >> + return 0;
>> >> +err:
>> >> + rte_mempool_free(t->crypto_adptr.op_pool);
>> >> + rte_mempool_free(t->crypto_adptr.sess_pool);
>> >> + rte_mempool_free(t->crypto_adptr.sess_priv_pool);
>> >> +
>> >> + return ret;
>> >> +}
>> >> +
>> >> +void
>> >> +perf_cryptodev_destroy(struct evt_test *test, struct evt_options
>> >> +*opt) {
>> >> + uint8_t cdev_id, cdev_count = rte_cryptodev_count();
>> >> + struct test_perf *t = evt_test_priv(test);
>> >> +
>> >> + RTE_SET_USED(opt);
>> >> +
>> >> + if (opt->prod_type != EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR)
>> >> + return;
>> >> +
>> >> + rte_event_crypto_adapter_stop(t->crypto_adptr.id);
>> >> +
>> >> + for (cdev_id = 0; cdev_id < cdev_count; cdev_id++) {
>> >> + rte_cryptodev_stop(cdev_id);
>> >> + rte_event_crypto_adapter_queue_pair_del(t->crypto_adptr.id,
>> >> + cdev_id, -1);
>> >> + }
>> >> +
>> >> + rte_event_crypto_adapter_free(t->crypto_adptr.id);
>> >> +
>> >> + rte_mempool_free(t->crypto_adptr.op_pool);
>> >> + rte_mempool_free(t->crypto_adptr.sess_pool);
>> >> + rte_mempool_free(t->crypto_adptr.sess_priv_pool);
>> >> +}
>> >> +
>> >> int
>> >> perf_mempool_setup(struct evt_test *test, struct evt_options *opt)
>> >> { diff --git a/app/test-eventdev/test_perf_common.h b/app/test-
>> >> eventdev/test_perf_common.h index 14dcf80429..d9ad3a0b0d 100644
>> >> --- a/app/test-eventdev/test_perf_common.h
>> >> +++ b/app/test-eventdev/test_perf_common.h
>> >> @@ -9,9 +9,11 @@
>> >> #include <stdbool.h>
>> >> #include <unistd.h>
>> >>
>> >> +#include <rte_cryptodev.h>
>> >> #include <rte_cycles.h>
>> >> #include <rte_ethdev.h>
>> >> #include <rte_eventdev.h>
>> >> +#include <rte_event_crypto_adapter.h>
>> >> #include <rte_event_eth_rx_adapter.h> #include
>> >> <rte_event_timer_adapter.h> #include <rte_lcore.h> @@ -37,9 +39,18
>> >> @@ struct prod_data {
>> >> uint8_t dev_id;
>> >> uint8_t port_id;
>> >> uint8_t queue_id;
>> >> + uint8_t cdev_id;
>> >> + uint16_t cdev_qp_id;
>> >> + struct rte_cryptodev_sym_session **crypto_sess;
>> >> struct test_perf *t;
>> >> } __rte_cache_aligned;
>> >>
>> >> +struct crypto_adptr_data {
>> >> + uint8_t id;
>> >> + struct rte_mempool *op_pool;
>> >> + struct rte_mempool *sess_pool;
>> >> + struct rte_mempool *sess_priv_pool; };
>> >>
>> >> struct test_perf {
>> >> /* Don't change the offset of "done". Signal handler use this
>> >> memory @@ -58,6 +69,7 @@ struct test_perf {
>> >> uint8_t sched_type_list[EVT_MAX_STAGES] __rte_cache_aligned;
>> >> struct rte_event_timer_adapter *timer_adptr[
>> >> RTE_EVENT_TIMER_ADAPTER_NUM_MAX]
>> >> __rte_cache_aligned;
>> >> + struct crypto_adptr_data crypto_adptr;
>> >> } __rte_cache_aligned;
>> >>
>> >> struct perf_elt {
>> >> @@ -81,6 +93,8 @@ struct perf_elt {
>> >> const uint8_t port = w->port_id;\
>> >> const uint8_t prod_timer_type = \
>> >> opt->prod_type == EVT_PROD_TYPE_EVENT_TIMER_ADPTR;\
>> >> + const uint8_t prod_crypto_type = \
>> >> + opt->prod_type == EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR;\
>> >> uint8_t *const sched_type_list = &t->sched_type_list[0];\
>> >> struct rte_mempool *const pool = t->pool;\
>> >> const uint8_t nb_stages = t->opt->nb_stages;\ @@ -154,6 +168,7 @@
>> >> int perf_test_result(struct evt_test *test, struct evt_options *opt);
>> >> int perf_opt_check(struct evt_options *opt, uint64_t nb_queues); int
>> >> perf_test_setup(struct evt_test *test, struct evt_options *opt); int
>> >> perf_ethdev_setup(struct evt_test *test, struct evt_options *opt);
>> >> +int perf_cryptodev_setup(struct evt_test *test, struct evt_options
>> >> +*opt);
>> >> int perf_mempool_setup(struct evt_test *test, struct evt_options
>> >> *opt); int perf_event_dev_port_setup(struct evt_test *test, struct
>> evt_options *opt,
>> >> uint8_t stride, uint8_t nb_queues, @@ -164,6
>> +179,7 @@ int
>> >> perf_launch_lcores(struct evt_test *test, struct evt_options *opt,
>> >> void perf_opt_dump(struct evt_options *opt, uint8_t nb_queues); void
>> >> perf_test_destroy(struct evt_test *test, struct evt_options *opt);
>> >> void perf_eventdev_destroy(struct evt_test *test, struct evt_options
>> >> *opt);
>> >> +void perf_cryptodev_destroy(struct evt_test *test, struct
>> >> +evt_options *opt);
>> >> void perf_ethdev_destroy(struct evt_test *test, struct evt_options
>> >> *opt); void perf_mempool_destroy(struct evt_test *test, struct
>> >> evt_options *opt);
>> >>
>> >> diff --git a/app/test-eventdev/test_perf_queue.c b/app/test-
>> >> eventdev/test_perf_queue.c index f4ea3a795f..5657c8b3cd 100644
>> >> --- a/app/test-eventdev/test_perf_queue.c
>> >> +++ b/app/test-eventdev/test_perf_queue.c
>> >> @@ -49,6 +49,23 @@ perf_queue_worker(void *arg, const int
>> >> enable_fwd_latency)
>> >> rte_pause();
>> >> continue;
>> >> }
>> >> +
>> >> + if (prod_crypto_type &&
>> >> + (ev.event_type == RTE_EVENT_TYPE_CRYPTODEV)) {
>> >> + struct rte_crypto_op *op = ev.event_ptr;
>> >> +
>> >> + if (op->status == RTE_CRYPTO_OP_STATUS_SUCCESS) {
>> >> + if (op->sym->m_dst == NULL)
>> >> + ev.event_ptr = op->sym->m_src;
>> >> + else
>> >> + ev.event_ptr = op->sym->m_dst;
>> >> + rte_crypto_op_free(op);
>> >> + } else {
>> >> + rte_crypto_op_free(op);
>> >> + continue;
>> >> + }
>> >> + }
>> >> +
>> >> if (enable_fwd_latency && !prod_timer_type)
>> >> /* first q in pipeline, mark timestamp to compute fwd latency */
>> >> mark_fwd_latency(&ev, nb_stages); @@ -88,6 +105,25
>> @@
>> >> perf_queue_worker_burst(void *arg, const int
>> >> enable_fwd_latency)
>> >> }
>> >>
>> >> for (i = 0; i < nb_rx; i++) {
>> >> + if (prod_crypto_type &&
>> >> + (ev[i].event_type == RTE_EVENT_TYPE_CRYPTODEV))
>> >> {
>> >> + struct rte_crypto_op *op = ev[i].event_ptr;
>> >> +
>> >> + if (op->status ==
>> >> + RTE_CRYPTO_OP_STATUS_SUCCESS) {
>> >> + if (op->sym->m_dst == NULL)
>> >> + ev[i].event_ptr =
>> >> + op->sym->m_src;
>> >> + else
>> >> + ev[i].event_ptr =
>> >> + op->sym->m_dst;
>> >> + rte_crypto_op_free(op);
>> >> + } else {
>> >> + rte_crypto_op_free(op);
>> >> + continue;
>> >> + }
>> >> + }
>> >> +
>> >> if (enable_fwd_latency && !prod_timer_type) {
>> >> rte_prefetch0(ev[i+1].event_ptr);
>> >> /* first queue in pipeline.
>> >> @@ -269,6 +305,20 @@ perf_queue_eventdev_setup(struct evt_test *test,
>> >> struct evt_options *opt)
>> >> return ret;
>> >> }
>> >> }
>> >> + } else if (opt->prod_type == EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR) {
>> >> + uint8_t cdev_id, cdev_count;
>> >> +
>> >> + cdev_count = rte_cryptodev_count();
>> >> + for (cdev_id = 0; cdev_id < cdev_count; cdev_id++) {
>> >> + ret = rte_cryptodev_start(cdev_id);
>> >> + if (ret) {
>> >> + evt_err("Failed to start cryptodev %u",
>> >> + cdev_id);
>> >> + return ret;
>> >> + }
>> >> + }
>> >> +
>> >> + rte_event_crypto_adapter_start(t->crypto_adptr.id);
>> >> }
>> >>
>> >> return 0;
>> >> @@ -311,11 +361,13 @@ static const struct evt_test_ops perf_queue = {
>> >> .test_setup = perf_test_setup,
>> >> .mempool_setup = perf_mempool_setup,
>> >> .ethdev_setup = perf_ethdev_setup,
>> >> + .cryptodev_setup = perf_cryptodev_setup,
>> >> .eventdev_setup = perf_queue_eventdev_setup,
>> >> .launch_lcores = perf_queue_launch_lcores,
>> >> .eventdev_destroy = perf_eventdev_destroy,
>> >> .mempool_destroy = perf_mempool_destroy,
>> >> .ethdev_destroy = perf_ethdev_destroy,
>> >> + .cryptodev_destroy = perf_cryptodev_destroy,
>> >> .test_result = perf_test_result,
>> >> .test_destroy = perf_test_destroy,
>> >> };
>> >> diff --git a/doc/guides/tools/testeventdev.rst
>> >> b/doc/guides/tools/testeventdev.rst
>> >> index 48efb9ea6e..f7d813226d 100644
>> >> --- a/doc/guides/tools/testeventdev.rst
>> >> +++ b/doc/guides/tools/testeventdev.rst
>> >> @@ -120,6 +120,10 @@ The following are the application command-line
>> >> options:
>> >>
>> >> Use burst mode event timer adapter as producer.
>> >>
>> >> +* ``--prod_type_cryptodev``
>> >> +
>> >> + Use crypto device as producer.
>> >> +
>> >> * ``--timer_tick_nsec``
>> >>
>> >> Used to dictate number of nano seconds between bucket
>> >> traversal of the @@ -148,6 +152,11 @@ The following are the
>> >> application command-line
>> >> options:
>> >> timeout is out of the supported range of event device it will be
>> >> adjusted to the highest/lowest supported dequeue timeout supported.
>> >>
>> >> +* ``--crypto_adptr_mode``
>> >> +
>> >> + Set crypto adapter mode. Use 0 for OP_NEW (default) and 1 for
>> >> + OP_FORWARD mode.
>> >> +
>> >> * ``--mbuf_sz``
>> >>
>> >> Set packet mbuf size. Can be used to configure Jumbo Frames.
>> >> Only @@ -
>> >> 420,6 +429,7 @@ Supported application command line options are
>> following::
>> >> --prod_type_ethdev
>> >> --prod_type_timerdev_burst
>> >> --prod_type_timerdev
>> >> + --prod_type_cryptodev
>> >> --prod_enq_burst_sz
>> >> --timer_tick_nsec
>> >> --max_tmo_nsec
>> >> @@ -427,6 +437,7 @@ Supported application command line options are
>> >> following::
>> >> --nb_timers
>> >> --nb_timer_adptrs
>> >> --deq_tmo_nsec
>> >> + --crypto_adptr_mode
>> >>
>> >> Example
>> >> ^^^^^^^
>> >> @@ -529,12 +540,14 @@ Supported application command line options are
>> >> following::
>> >> --prod_type_ethdev
>> >> --prod_type_timerdev_burst
>> >> --prod_type_timerdev
>> >> + --prod_type_cryptodev
>> >> --timer_tick_nsec
>> >> --max_tmo_nsec
>> >> --expiry_nsec
>> >> --nb_timers
>> >> --nb_timer_adptrs
>> >> --deq_tmo_nsec
>> >> + --crypto_adptr_mode
>> >>
>> >> Example
>> >> ^^^^^^^
>> >> --
>> >> 2.25.1
^ permalink raw reply [flat|nested] 43+ messages in thread
* [PATCH v3] app/eventdev: add crypto producer mode
2021-12-21 8:51 ` [PATCH v2] " Shijith Thotton
2021-12-30 11:56 ` Gujjar, Abhinandan S
@ 2022-01-04 10:30 ` Shijith Thotton
2022-01-21 12:25 ` Jerin Jacob
` (2 more replies)
1 sibling, 3 replies; 43+ messages in thread
From: Shijith Thotton @ 2022-01-04 10:30 UTC (permalink / raw)
To: dev, jerinj
Cc: Shijith Thotton, anoobj, pbhagavatula, gakhil, abhinandan.gujjar
In crypto producer mode, producer core enqueues cryptodev with software
generated crypto ops and worker core dequeues crypto completion events
from the eventdev. Event crypto metadata used for above processing is
pre-populated in each crypto session.
Parameter --prod_type_cryptodev can be used to enable crypto producer
mode. Parameter --crypto_adptr_mode can be set to select the crypto
adapter mode, 0 for OP_NEW and 1 for OP_FORWARD.
This mode can be used to measure the performance of crypto adapter.
Example:
./dpdk-test-eventdev -l 0-2 -w <EVENTDEV> -w <CRYPTODEV> -- \
--prod_type_cryptodev --crypto_adptr_mode 1 --test=perf_atq \
--stlist=a --wlcores 1 --plcores 2
Signed-off-by: Shijith Thotton <sthotton@marvell.com>
---
v3:
* Reduce dereference inside loop.
v2:
* Fix RHEL compilation warning.
app/test-eventdev/evt_common.h | 3 +
app/test-eventdev/evt_main.c | 13 +-
app/test-eventdev/evt_options.c | 27 ++
app/test-eventdev/evt_options.h | 12 +
app/test-eventdev/evt_test.h | 6 +
app/test-eventdev/test_perf_atq.c | 51 ++++
app/test-eventdev/test_perf_common.c | 410 ++++++++++++++++++++++++++-
app/test-eventdev/test_perf_common.h | 16 ++
app/test-eventdev/test_perf_queue.c | 52 ++++
doc/guides/tools/testeventdev.rst | 13 +
10 files changed, 596 insertions(+), 7 deletions(-)
diff --git a/app/test-eventdev/evt_common.h b/app/test-eventdev/evt_common.h
index f466434459..2f301a7e79 100644
--- a/app/test-eventdev/evt_common.h
+++ b/app/test-eventdev/evt_common.h
@@ -7,6 +7,7 @@
#include <rte_common.h>
#include <rte_debug.h>
+#include <rte_event_crypto_adapter.h>
#include <rte_eventdev.h>
#include <rte_service.h>
@@ -39,6 +40,7 @@ enum evt_prod_type {
EVT_PROD_TYPE_SYNT, /* Producer type Synthetic i.e. CPU. */
EVT_PROD_TYPE_ETH_RX_ADPTR, /* Producer type Eth Rx Adapter. */
EVT_PROD_TYPE_EVENT_TIMER_ADPTR, /* Producer type Timer Adapter. */
+ EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR, /* Producer type Crypto Adapter. */
EVT_PROD_TYPE_MAX,
};
@@ -77,6 +79,7 @@ struct evt_options {
uint64_t timer_tick_nsec;
uint64_t optm_timer_tick_nsec;
enum evt_prod_type prod_type;
+ enum rte_event_crypto_adapter_mode crypto_adptr_mode;
};
static inline bool
diff --git a/app/test-eventdev/evt_main.c b/app/test-eventdev/evt_main.c
index 194c980c7a..cef0fb1382 100644
--- a/app/test-eventdev/evt_main.c
+++ b/app/test-eventdev/evt_main.c
@@ -161,12 +161,19 @@ main(int argc, char **argv)
goto mempool_destroy;
}
}
+ /* Test specific cryptodev setup */
+ if (test->ops.cryptodev_setup) {
+ if (test->ops.cryptodev_setup(test, &opt)) {
+ evt_err("%s: cryptodev setup failed", opt.test_name);
+ goto ethdev_destroy;
+ }
+ }
/* Test specific eventdev setup */
if (test->ops.eventdev_setup) {
if (test->ops.eventdev_setup(test, &opt)) {
evt_err("%s: eventdev setup failed", opt.test_name);
- goto ethdev_destroy;
+ goto cryptodev_destroy;
}
}
@@ -197,6 +204,10 @@ main(int argc, char **argv)
if (test->ops.eventdev_destroy)
test->ops.eventdev_destroy(test, &opt);
+cryptodev_destroy:
+ if (test->ops.cryptodev_destroy)
+ test->ops.cryptodev_destroy(test, &opt);
+
ethdev_destroy:
if (test->ops.ethdev_destroy)
test->ops.ethdev_destroy(test, &opt);
diff --git a/app/test-eventdev/evt_options.c b/app/test-eventdev/evt_options.c
index 753a7dbd7d..5ad1491020 100644
--- a/app/test-eventdev/evt_options.c
+++ b/app/test-eventdev/evt_options.c
@@ -122,6 +122,26 @@ evt_parse_timer_prod_type_burst(struct evt_options *opt,
return 0;
}
+static int
+evt_parse_crypto_prod_type(struct evt_options *opt,
+ const char *arg __rte_unused)
+{
+ opt->prod_type = EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR;
+ return 0;
+}
+
+static int
+evt_parse_crypto_adptr_mode(struct evt_options *opt, const char *arg)
+{
+ uint8_t mode;
+ int ret;
+
+ ret = parser_read_uint8(&mode, arg);
+ opt->crypto_adptr_mode = mode ? RTE_EVENT_CRYPTO_ADAPTER_OP_FORWARD :
+ RTE_EVENT_CRYPTO_ADAPTER_OP_NEW;
+ return ret;
+}
+
static int
evt_parse_test_name(struct evt_options *opt, const char *arg)
{
@@ -335,6 +355,7 @@ usage(char *program)
"\t--queue_priority : enable queue priority\n"
"\t--deq_tmo_nsec : global dequeue timeout\n"
"\t--prod_type_ethdev : use ethernet device as producer.\n"
+ "\t--prod_type_cryptodev : use crypto device as producer.\n"
"\t--prod_type_timerdev : use event timer device as producer.\n"
"\t expity_nsec would be the timeout\n"
"\t in ns.\n"
@@ -345,6 +366,8 @@ usage(char *program)
"\t--timer_tick_nsec : timer tick interval in ns.\n"
"\t--max_tmo_nsec : max timeout interval in ns.\n"
"\t--expiry_nsec : event timer expiry ns.\n"
+ "\t--crypto_adptr_mode : 0 for OP_NEW mode (default) and\n"
+ "\t 1 for OP_FORWARD mode.\n"
"\t--mbuf_sz : packet mbuf size.\n"
"\t--max_pkt_sz : max packet size.\n"
"\t--prod_enq_burst_sz : producer enqueue burst size.\n"
@@ -415,8 +438,10 @@ static struct option lgopts[] = {
{ EVT_QUEUE_PRIORITY, 0, 0, 0 },
{ EVT_DEQ_TMO_NSEC, 1, 0, 0 },
{ EVT_PROD_ETHDEV, 0, 0, 0 },
+ { EVT_PROD_CRYPTODEV, 0, 0, 0 },
{ EVT_PROD_TIMERDEV, 0, 0, 0 },
{ EVT_PROD_TIMERDEV_BURST, 0, 0, 0 },
+ { EVT_CRYPTO_ADPTR_MODE, 1, 0, 0 },
{ EVT_NB_TIMERS, 1, 0, 0 },
{ EVT_NB_TIMER_ADPTRS, 1, 0, 0 },
{ EVT_TIMER_TICK_NSEC, 1, 0, 0 },
@@ -455,8 +480,10 @@ evt_opts_parse_long(int opt_idx, struct evt_options *opt)
{ EVT_QUEUE_PRIORITY, evt_parse_queue_priority},
{ EVT_DEQ_TMO_NSEC, evt_parse_deq_tmo_nsec},
{ EVT_PROD_ETHDEV, evt_parse_eth_prod_type},
+ { EVT_PROD_CRYPTODEV, evt_parse_crypto_prod_type},
{ EVT_PROD_TIMERDEV, evt_parse_timer_prod_type},
{ EVT_PROD_TIMERDEV_BURST, evt_parse_timer_prod_type_burst},
+ { EVT_CRYPTO_ADPTR_MODE, evt_parse_crypto_adptr_mode},
{ EVT_NB_TIMERS, evt_parse_nb_timers},
{ EVT_NB_TIMER_ADPTRS, evt_parse_nb_timer_adptrs},
{ EVT_TIMER_TICK_NSEC, evt_parse_timer_tick_nsec},
diff --git a/app/test-eventdev/evt_options.h b/app/test-eventdev/evt_options.h
index 413d7092f0..2231c58801 100644
--- a/app/test-eventdev/evt_options.h
+++ b/app/test-eventdev/evt_options.h
@@ -9,6 +9,7 @@
#include <stdbool.h>
#include <rte_common.h>
+#include <rte_cryptodev.h>
#include <rte_ethdev.h>
#include <rte_eventdev.h>
#include <rte_lcore.h>
@@ -33,8 +34,10 @@
#define EVT_QUEUE_PRIORITY ("queue_priority")
#define EVT_DEQ_TMO_NSEC ("deq_tmo_nsec")
#define EVT_PROD_ETHDEV ("prod_type_ethdev")
+#define EVT_PROD_CRYPTODEV ("prod_type_cryptodev")
#define EVT_PROD_TIMERDEV ("prod_type_timerdev")
#define EVT_PROD_TIMERDEV_BURST ("prod_type_timerdev_burst")
+#define EVT_CRYPTO_ADPTR_MODE ("crypto_adptr_mode")
#define EVT_NB_TIMERS ("nb_timers")
#define EVT_NB_TIMER_ADPTRS ("nb_timer_adptrs")
#define EVT_TIMER_TICK_NSEC ("timer_tick_nsec")
@@ -249,6 +252,8 @@ evt_prod_id_to_name(enum evt_prod_type prod_type)
return "Ethdev Rx Adapter";
case EVT_PROD_TYPE_EVENT_TIMER_ADPTR:
return "Event timer adapter";
+ case EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR:
+ return "Event crypto adapter";
}
return "";
@@ -288,6 +293,13 @@ evt_dump_producer_type(struct evt_options *opt)
evt_dump("timer_tick_nsec", "%"PRIu64"",
opt->timer_tick_nsec);
break;
+ case EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR:
+ snprintf(name, EVT_PROD_MAX_NAME_LEN,
+ "Event crypto adapter producers");
+ evt_dump("crypto adapter mode", "%s",
+ opt->crypto_adptr_mode ? "OP_FORWARD" : "OP_NEW");
+ evt_dump("nb_cryptodev", "%u", rte_cryptodev_count());
+ break;
}
evt_dump("prod_type", "%s", name);
}
diff --git a/app/test-eventdev/evt_test.h b/app/test-eventdev/evt_test.h
index f07d2c3336..50fa474ec2 100644
--- a/app/test-eventdev/evt_test.h
+++ b/app/test-eventdev/evt_test.h
@@ -29,6 +29,8 @@ typedef int (*evt_test_mempool_setup_t)
(struct evt_test *test, struct evt_options *opt);
typedef int (*evt_test_ethdev_setup_t)
(struct evt_test *test, struct evt_options *opt);
+typedef int (*evt_test_cryptodev_setup_t)
+ (struct evt_test *test, struct evt_options *opt);
typedef int (*evt_test_eventdev_setup_t)
(struct evt_test *test, struct evt_options *opt);
typedef int (*evt_test_launch_lcores_t)
@@ -39,6 +41,8 @@ typedef void (*evt_test_eventdev_destroy_t)
(struct evt_test *test, struct evt_options *opt);
typedef void (*evt_test_ethdev_destroy_t)
(struct evt_test *test, struct evt_options *opt);
+typedef void (*evt_test_cryptodev_destroy_t)
+ (struct evt_test *test, struct evt_options *opt);
typedef void (*evt_test_mempool_destroy_t)
(struct evt_test *test, struct evt_options *opt);
typedef void (*evt_test_destroy_t)
@@ -52,10 +56,12 @@ struct evt_test_ops {
evt_test_mempool_setup_t mempool_setup;
evt_test_ethdev_setup_t ethdev_setup;
evt_test_eventdev_setup_t eventdev_setup;
+ evt_test_cryptodev_setup_t cryptodev_setup;
evt_test_launch_lcores_t launch_lcores;
evt_test_result_t test_result;
evt_test_eventdev_destroy_t eventdev_destroy;
evt_test_ethdev_destroy_t ethdev_destroy;
+ evt_test_cryptodev_destroy_t cryptodev_destroy;
evt_test_mempool_destroy_t mempool_destroy;
evt_test_destroy_t test_destroy;
};
diff --git a/app/test-eventdev/test_perf_atq.c b/app/test-eventdev/test_perf_atq.c
index 8fd51004ee..dbb1dc8c0c 100644
--- a/app/test-eventdev/test_perf_atq.c
+++ b/app/test-eventdev/test_perf_atq.c
@@ -48,6 +48,22 @@ perf_atq_worker(void *arg, const int enable_fwd_latency)
continue;
}
+ if (prod_crypto_type &&
+ (ev.event_type == RTE_EVENT_TYPE_CRYPTODEV)) {
+ struct rte_crypto_op *op = ev.event_ptr;
+
+ if (op->status == RTE_CRYPTO_OP_STATUS_SUCCESS) {
+ if (op->sym->m_dst == NULL)
+ ev.event_ptr = op->sym->m_src;
+ else
+ ev.event_ptr = op->sym->m_dst;
+ rte_crypto_op_free(op);
+ } else {
+ rte_crypto_op_free(op);
+ continue;
+ }
+ }
+
if (enable_fwd_latency && !prod_timer_type)
/* first stage in pipeline, mark ts to compute fwd latency */
atq_mark_fwd_latency(&ev);
@@ -87,6 +103,25 @@ perf_atq_worker_burst(void *arg, const int enable_fwd_latency)
}
for (i = 0; i < nb_rx; i++) {
+ if (prod_crypto_type &&
+ (ev[i].event_type == RTE_EVENT_TYPE_CRYPTODEV)) {
+ struct rte_crypto_op *op = ev[i].event_ptr;
+
+ if (op->status ==
+ RTE_CRYPTO_OP_STATUS_SUCCESS) {
+ if (op->sym->m_dst == NULL)
+ ev[i].event_ptr =
+ op->sym->m_src;
+ else
+ ev[i].event_ptr =
+ op->sym->m_dst;
+ rte_crypto_op_free(op);
+ } else {
+ rte_crypto_op_free(op);
+ continue;
+ }
+ }
+
if (enable_fwd_latency && !prod_timer_type) {
rte_prefetch0(ev[i+1].event_ptr);
/* first stage in pipeline.
@@ -254,6 +289,20 @@ perf_atq_eventdev_setup(struct evt_test *test, struct evt_options *opt)
return ret;
}
}
+ } else if (opt->prod_type == EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR) {
+ uint8_t cdev_id, cdev_count;
+
+ cdev_count = rte_cryptodev_count();
+ for (cdev_id = 0; cdev_id < cdev_count; cdev_id++) {
+ ret = rte_cryptodev_start(cdev_id);
+ if (ret) {
+ evt_err("Failed to start cryptodev %u",
+ cdev_id);
+ return ret;
+ }
+ }
+
+ rte_event_crypto_adapter_start(t->crypto_adptr.id);
}
return 0;
@@ -295,12 +344,14 @@ static const struct evt_test_ops perf_atq = {
.opt_dump = perf_atq_opt_dump,
.test_setup = perf_test_setup,
.ethdev_setup = perf_ethdev_setup,
+ .cryptodev_setup = perf_cryptodev_setup,
.mempool_setup = perf_mempool_setup,
.eventdev_setup = perf_atq_eventdev_setup,
.launch_lcores = perf_atq_launch_lcores,
.eventdev_destroy = perf_eventdev_destroy,
.mempool_destroy = perf_mempool_destroy,
.ethdev_destroy = perf_ethdev_destroy,
+ .cryptodev_destroy = perf_cryptodev_destroy,
.test_result = perf_test_result,
.test_destroy = perf_test_destroy,
};
diff --git a/app/test-eventdev/test_perf_common.c b/app/test-eventdev/test_perf_common.c
index 9b73874151..91cb6748ee 100644
--- a/app/test-eventdev/test_perf_common.c
+++ b/app/test-eventdev/test_perf_common.c
@@ -6,6 +6,8 @@
#include "test_perf_common.h"
+#define NB_CRYPTODEV_DESCRIPTORS 128
+
int
perf_test_result(struct evt_test *test, struct evt_options *opt)
{
@@ -272,6 +274,125 @@ perf_event_timer_producer_burst(void *arg)
return 0;
}
+static inline void
+crypto_adapter_enq_op_new(struct prod_data *p)
+{
+ struct rte_cryptodev_sym_session **crypto_sess = p->crypto_sess;
+ struct test_perf *t = p->t;
+ const uint32_t nb_flows = t->nb_flows;
+ const uint64_t nb_pkts = t->nb_pkts;
+ struct rte_mempool *pool = t->pool;
+ struct rte_crypto_sym_op *sym_op;
+ struct evt_options *opt = t->opt;
+ uint16_t qp_id = p->cdev_qp_id;
+ uint8_t cdev_id = p->cdev_id;
+ uint32_t flow_counter = 0;
+ struct rte_crypto_op *op;
+ struct rte_mbuf *m;
+ uint64_t count = 0;
+ uint16_t len;
+
+ if (opt->verbose_level > 1)
+ printf("%s(): lcore %d queue %d cdev_id %u cdev_qp_id %u\n",
+ __func__, rte_lcore_id(), p->queue_id, p->cdev_id,
+ p->cdev_qp_id);
+
+ len = opt->mbuf_sz ? opt->mbuf_sz : RTE_ETHER_MIN_LEN;
+
+ while (count < nb_pkts && t->done == false) {
+ m = rte_pktmbuf_alloc(pool);
+ if (m == NULL)
+ continue;
+
+ rte_pktmbuf_append(m, len);
+ op = rte_crypto_op_alloc(t->crypto_adptr.op_pool,
+ RTE_CRYPTO_OP_TYPE_SYMMETRIC);
+ sym_op = op->sym;
+ sym_op->m_src = m;
+ sym_op->cipher.data.offset = 0;
+ sym_op->cipher.data.length = len;
+ rte_crypto_op_attach_sym_session(
+ op, crypto_sess[flow_counter++ % nb_flows]);
+ while (rte_cryptodev_enqueue_burst(cdev_id, qp_id, &op, 1) !=
+ 1) {
+ if (t->done)
+ break;
+ rte_pause();
+ }
+ count++;
+ }
+}
+
+static inline void
+crypto_adapter_enq_op_fwd(struct prod_data *p)
+{
+ struct rte_cryptodev_sym_session **crypto_sess = p->crypto_sess;
+ const uint8_t dev_id = p->dev_id;
+ const uint8_t port = p->port_id;
+ struct test_perf *t = p->t;
+ const uint32_t nb_flows = t->nb_flows;
+ const uint64_t nb_pkts = t->nb_pkts;
+ struct rte_mempool *pool = t->pool;
+ struct evt_options *opt = t->opt;
+ struct rte_crypto_sym_op *sym_op;
+ uint32_t flow_counter = 0;
+ struct rte_crypto_op *op;
+ struct rte_event ev;
+ struct rte_mbuf *m;
+ uint64_t count = 0;
+ uint16_t len;
+
+ if (opt->verbose_level > 1)
+ printf("%s(): lcore %d port %d queue %d cdev_id %u cdev_qp_id %u\n",
+ __func__, rte_lcore_id(), port, p->queue_id, p->cdev_id,
+ p->cdev_qp_id);
+
+ ev.event = 0;
+ ev.op = RTE_EVENT_OP_NEW;
+ ev.queue_id = p->queue_id;
+ ev.sched_type = RTE_SCHED_TYPE_ATOMIC;
+ ev.event_type = RTE_EVENT_TYPE_CPU;
+ len = opt->mbuf_sz ? opt->mbuf_sz : RTE_ETHER_MIN_LEN;
+
+ while (count < nb_pkts && t->done == false) {
+ m = rte_pktmbuf_alloc(pool);
+ if (m == NULL)
+ continue;
+
+ rte_pktmbuf_append(m, len);
+ op = rte_crypto_op_alloc(t->crypto_adptr.op_pool,
+ RTE_CRYPTO_OP_TYPE_SYMMETRIC);
+ sym_op = op->sym;
+ sym_op->m_src = m;
+ sym_op->cipher.data.offset = 0;
+ sym_op->cipher.data.length = len;
+ rte_crypto_op_attach_sym_session(
+ op, crypto_sess[flow_counter++ % nb_flows]);
+ ev.event_ptr = op;
+ while (rte_event_crypto_adapter_enqueue(dev_id, port, &ev, 1) !=
+ 1) {
+ if (t->done)
+ break;
+ rte_pause();
+ }
+ count++;
+ }
+}
+
+static inline int
+perf_event_crypto_producer(void *arg)
+{
+ struct prod_data *p = arg;
+ struct evt_options *opt = p->t->opt;
+
+ if (opt->crypto_adptr_mode == RTE_EVENT_CRYPTO_ADAPTER_OP_NEW)
+ crypto_adapter_enq_op_new(p);
+ else
+ crypto_adapter_enq_op_fwd(p);
+
+ return 0;
+}
+
static int
perf_producer_wrapper(void *arg)
{
@@ -298,6 +419,8 @@ perf_producer_wrapper(void *arg)
else if (t->opt->prod_type == EVT_PROD_TYPE_EVENT_TIMER_ADPTR &&
t->opt->timdev_use_burst)
return perf_event_timer_producer_burst(arg);
+ else if (t->opt->prod_type == EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR)
+ return perf_event_crypto_producer(arg);
return 0;
}
@@ -405,8 +528,10 @@ perf_launch_lcores(struct evt_test *test, struct evt_options *opt,
if (remaining <= 0) {
t->result = EVT_TEST_SUCCESS;
if (opt->prod_type == EVT_PROD_TYPE_SYNT ||
- opt->prod_type ==
- EVT_PROD_TYPE_EVENT_TIMER_ADPTR) {
+ opt->prod_type ==
+ EVT_PROD_TYPE_EVENT_TIMER_ADPTR ||
+ opt->prod_type ==
+ EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR) {
t->done = true;
break;
}
@@ -415,7 +540,8 @@ perf_launch_lcores(struct evt_test *test, struct evt_options *opt,
if (new_cycles - dead_lock_cycles > dead_lock_sample &&
(opt->prod_type == EVT_PROD_TYPE_SYNT ||
- opt->prod_type == EVT_PROD_TYPE_EVENT_TIMER_ADPTR)) {
+ opt->prod_type == EVT_PROD_TYPE_EVENT_TIMER_ADPTR ||
+ opt->prod_type == EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR)) {
remaining = t->outstand_pkts - processed_pkts(t);
if (dead_lock_remaining == remaining) {
rte_event_dev_dump(opt->dev_id, stdout);
@@ -537,6 +663,96 @@ perf_event_timer_adapter_setup(struct test_perf *t)
return 0;
}
+static int
+perf_event_crypto_adapter_setup(struct test_perf *t,
+ struct rte_event_port_conf port_conf)
+{
+ struct evt_options *opt = t->opt;
+ uint8_t cdev_id, cdev_count;
+ int ret;
+
+ t->crypto_adptr.id = 0;
+ ret = rte_event_crypto_adapter_create(t->crypto_adptr.id, opt->dev_id,
+ &port_conf, 0);
+ if (ret)
+ return ret;
+
+ cdev_count = rte_cryptodev_count();
+ for (cdev_id = 0; cdev_id < cdev_count; cdev_id++) {
+ uint32_t cap;
+
+ ret = rte_event_crypto_adapter_caps_get(opt->dev_id, cdev_id,
+ &cap);
+ if (ret) {
+ evt_err("Failed to get crypto adapter capabilities");
+ return ret;
+ }
+
+ if (((opt->crypto_adptr_mode ==
+ RTE_EVENT_CRYPTO_ADAPTER_OP_NEW) &&
+ !(cap &
+ RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_OP_NEW)) ||
+ ((opt->crypto_adptr_mode ==
+ RTE_EVENT_CRYPTO_ADAPTER_OP_FORWARD) &&
+ !(cap &
+ RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_OP_FWD))) {
+ evt_err("crypto adapter %s mode unsupported\n",
+ opt->crypto_adptr_mode ? "OP_FORWARD" :
+ "OP_NEW");
+ return -EINVAL;
+ }
+
+ if (!(cap &
+ RTE_EVENT_CRYPTO_ADAPTER_CAP_SESSION_PRIVATE_DATA)) {
+ evt_err("Storing crypto session not supported");
+ return -EINVAL;
+ }
+
+ if (cap &
+ RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_QP_EV_BIND) {
+ struct rte_event response_info;
+
+ response_info.event = 0;
+ ret = rte_event_crypto_adapter_queue_pair_add(
+ t->crypto_adptr.id, cdev_id, -1,
+ &response_info);
+ } else {
+ ret = rte_event_crypto_adapter_queue_pair_add(
+ t->crypto_adptr.id, cdev_id, -1, NULL);
+ }
+ if (ret)
+ return ret;
+ }
+
+ return 0;
+}
+
+static struct rte_cryptodev_sym_session *
+cryptodev_sym_sess_create(struct prod_data *p, struct test_perf *t)
+{
+ struct rte_crypto_sym_xform cipher_xform;
+ struct rte_cryptodev_sym_session *sess;
+
+ cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
+ cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
+ cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
+ cipher_xform.next = NULL;
+
+ sess = rte_cryptodev_sym_session_create(t->crypto_adptr.sess_pool);
+ if (sess == NULL) {
+ evt_err("Failed to create sym session");
+ return NULL;
+ }
+
+ if (rte_cryptodev_sym_session_init(p->cdev_id, sess, &cipher_xform,
+ t->crypto_adptr.sess_priv_pool)) {
+ evt_err("Failed to init session");
+ return NULL;
+ }
+
+ return sess;
+}
+
int
perf_event_dev_port_setup(struct evt_test *test, struct evt_options *opt,
uint8_t stride, uint8_t nb_queues,
@@ -598,6 +814,55 @@ perf_event_dev_port_setup(struct evt_test *test, struct evt_options *opt,
ret = perf_event_timer_adapter_setup(t);
if (ret)
return ret;
+ } else if (opt->prod_type == EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR) {
+ uint8_t cdev_id = 0;
+ uint16_t qp_id = 0;
+
+ prod = 0;
+ for (; port < perf_nb_event_ports(opt); port++) {
+ struct rte_cryptodev_sym_session *crypto_sess;
+ union rte_event_crypto_metadata m_data;
+ struct prod_data *p = &t->prod[port];
+ uint32_t flow_id;
+
+ if (qp_id == rte_cryptodev_queue_pair_count(cdev_id)) {
+ cdev_id++;
+ qp_id = 0;
+ }
+
+ p->dev_id = opt->dev_id;
+ p->port_id = port;
+ p->queue_id = prod * stride;
+ p->cdev_id = cdev_id;
+ p->cdev_qp_id = qp_id;
+ p->crypto_sess = rte_zmalloc_socket(
+ NULL, sizeof(crypto_sess) * t->nb_flows,
+ RTE_CACHE_LINE_SIZE, opt->socket_id);
+
+ m_data.request_info.cdev_id = p->cdev_id;
+ m_data.request_info.queue_pair_id = p->cdev_qp_id;
+ m_data.response_info.op = RTE_EVENT_OP_NEW;
+ m_data.response_info.sched_type = RTE_SCHED_TYPE_ATOMIC;
+ m_data.response_info.event_type = RTE_EVENT_TYPE_CPU;
+ m_data.response_info.queue_id = p->queue_id;
+ for (flow_id = 0; flow_id < t->nb_flows; flow_id++) {
+ crypto_sess = cryptodev_sym_sess_create(p, t);
+ if (crypto_sess == NULL)
+ return -ENOMEM;
+
+ m_data.response_info.flow_id = flow_id;
+ rte_cryptodev_sym_session_set_user_data(
+ crypto_sess, &m_data, sizeof(m_data));
+ p->crypto_sess[flow_id] = crypto_sess;
+ }
+ p->t = t;
+ qp_id++;
+ prod++;
+ }
+
+ ret = perf_event_crypto_adapter_setup(t, *port_conf);
+ if (ret)
+ return ret;
} else {
prod = 0;
for ( ; port < perf_nb_event_ports(opt); port++) {
@@ -659,7 +924,8 @@ perf_opt_check(struct evt_options *opt, uint64_t nb_queues)
}
if (opt->prod_type == EVT_PROD_TYPE_SYNT ||
- opt->prod_type == EVT_PROD_TYPE_EVENT_TIMER_ADPTR) {
+ opt->prod_type == EVT_PROD_TYPE_EVENT_TIMER_ADPTR ||
+ opt->prod_type == EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR) {
/* Validate producer lcores */
if (evt_lcores_has_overlap(opt->plcores,
rte_get_main_lcore())) {
@@ -767,8 +1033,7 @@ perf_ethdev_setup(struct evt_test *test, struct evt_options *opt)
},
};
- if (opt->prod_type == EVT_PROD_TYPE_SYNT ||
- opt->prod_type == EVT_PROD_TYPE_EVENT_TIMER_ADPTR)
+ if (opt->prod_type != EVT_PROD_TYPE_ETH_RX_ADPTR)
return 0;
if (!rte_eth_dev_count_avail()) {
@@ -841,6 +1106,139 @@ void perf_ethdev_destroy(struct evt_test *test, struct evt_options *opt)
}
}
+int
+perf_cryptodev_setup(struct evt_test *test, struct evt_options *opt)
+{
+ uint8_t cdev_count, cdev_id, nb_plcores, nb_qps;
+ struct test_perf *t = evt_test_priv(test);
+ unsigned int max_session_size;
+ uint32_t nb_sessions;
+ int ret;
+
+ if (opt->prod_type != EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR)
+ return 0;
+
+ cdev_count = rte_cryptodev_count();
+ if (cdev_count == 0) {
+ evt_err("No crypto devices available\n");
+ return -ENODEV;
+ }
+
+ t->crypto_adptr.op_pool = rte_crypto_op_pool_create(
+ "crypto_op_pool", RTE_CRYPTO_OP_TYPE_SYMMETRIC, opt->pool_sz,
+ 128, 0, rte_socket_id());
+ if (t->crypto_adptr.op_pool == NULL) {
+ evt_err("Failed to create crypto op pool");
+ return -ENOMEM;
+ }
+
+ nb_sessions = evt_nr_active_lcores(opt->plcores) * t->nb_flows;
+ t->crypto_adptr.sess_pool = rte_cryptodev_sym_session_pool_create(
+ "ca_sess_pool", nb_sessions, 0, 0,
+ sizeof(union rte_event_crypto_metadata), SOCKET_ID_ANY);
+ if (t->crypto_adptr.sess_pool == NULL) {
+ evt_err("Failed to create sym session pool");
+ ret = -ENOMEM;
+ goto err;
+ }
+
+ max_session_size = 0;
+ for (cdev_id = 0; cdev_id < cdev_count; cdev_id++) {
+ unsigned int session_size;
+
+ session_size =
+ rte_cryptodev_sym_get_private_session_size(cdev_id);
+ if (session_size > max_session_size)
+ max_session_size = session_size;
+ }
+ max_session_size += sizeof(union rte_event_crypto_metadata);
+ t->crypto_adptr.sess_priv_pool = rte_mempool_create(
+ "ca_sess_priv_pool", nb_sessions, max_session_size, 0, 0, NULL,
+ NULL, NULL, NULL, SOCKET_ID_ANY, 0);
+ if (t->crypto_adptr.sess_priv_pool == NULL) {
+ evt_err("failed to create sym session private pool");
+ ret = -ENOMEM;
+ goto err;
+ }
+
+ nb_plcores = evt_nr_active_lcores(opt->plcores);
+ nb_qps = (nb_plcores % cdev_count) ? (nb_plcores / cdev_count) + 1 :
+ nb_plcores / cdev_count;
+ for (cdev_id = 0; cdev_id < cdev_count; cdev_id++) {
+ struct rte_cryptodev_qp_conf qp_conf;
+ struct rte_cryptodev_config conf;
+ struct rte_cryptodev_info info;
+ int qp_id;
+
+ rte_cryptodev_info_get(cdev_id, &info);
+ if (nb_qps > info.max_nb_queue_pairs) {
+ evt_err("Not enough queue pairs per cryptodev (%u)",
+ nb_qps);
+ ret = -EINVAL;
+ goto err;
+ }
+
+ conf.nb_queue_pairs = nb_qps;
+ conf.socket_id = SOCKET_ID_ANY;
+ conf.ff_disable = RTE_CRYPTODEV_FF_SECURITY;
+
+ ret = rte_cryptodev_configure(cdev_id, &conf);
+ if (ret) {
+ evt_err("Failed to configure cryptodev (%u)", cdev_id);
+ goto err;
+ }
+
+ qp_conf.nb_descriptors = NB_CRYPTODEV_DESCRIPTORS;
+ qp_conf.mp_session = t->crypto_adptr.sess_pool;
+ qp_conf.mp_session_private = t->crypto_adptr.sess_priv_pool;
+
+ for (qp_id = 0; qp_id < conf.nb_queue_pairs; qp_id++) {
+ ret = rte_cryptodev_queue_pair_setup(
+ cdev_id, qp_id, &qp_conf,
+ rte_cryptodev_socket_id(cdev_id));
+ if (ret) {
+ evt_err("Failed to setup queue pairs on cryptodev %u\n",
+ cdev_id);
+ goto err;
+ }
+ }
+ }
+
+ return 0;
+err:
+ rte_mempool_free(t->crypto_adptr.op_pool);
+ rte_mempool_free(t->crypto_adptr.sess_pool);
+ rte_mempool_free(t->crypto_adptr.sess_priv_pool);
+
+ return ret;
+}
+
+void
+perf_cryptodev_destroy(struct evt_test *test, struct evt_options *opt)
+{
+ uint8_t cdev_id, cdev_count = rte_cryptodev_count();
+ struct test_perf *t = evt_test_priv(test);
+
+ RTE_SET_USED(opt);
+
+ if (opt->prod_type != EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR)
+ return;
+
+ rte_event_crypto_adapter_stop(t->crypto_adptr.id);
+
+ for (cdev_id = 0; cdev_id < cdev_count; cdev_id++) {
+ rte_cryptodev_stop(cdev_id);
+ rte_event_crypto_adapter_queue_pair_del(t->crypto_adptr.id,
+ cdev_id, -1);
+ }
+
+ rte_event_crypto_adapter_free(t->crypto_adptr.id);
+
+ rte_mempool_free(t->crypto_adptr.op_pool);
+ rte_mempool_free(t->crypto_adptr.sess_pool);
+ rte_mempool_free(t->crypto_adptr.sess_priv_pool);
+}
+
int
perf_mempool_setup(struct evt_test *test, struct evt_options *opt)
{
diff --git a/app/test-eventdev/test_perf_common.h b/app/test-eventdev/test_perf_common.h
index 14dcf80429..d9ad3a0b0d 100644
--- a/app/test-eventdev/test_perf_common.h
+++ b/app/test-eventdev/test_perf_common.h
@@ -9,9 +9,11 @@
#include <stdbool.h>
#include <unistd.h>
+#include <rte_cryptodev.h>
#include <rte_cycles.h>
#include <rte_ethdev.h>
#include <rte_eventdev.h>
+#include <rte_event_crypto_adapter.h>
#include <rte_event_eth_rx_adapter.h>
#include <rte_event_timer_adapter.h>
#include <rte_lcore.h>
@@ -37,9 +39,18 @@ struct prod_data {
uint8_t dev_id;
uint8_t port_id;
uint8_t queue_id;
+ uint8_t cdev_id;
+ uint16_t cdev_qp_id;
+ struct rte_cryptodev_sym_session **crypto_sess;
struct test_perf *t;
} __rte_cache_aligned;
+struct crypto_adptr_data {
+ uint8_t id;
+ struct rte_mempool *op_pool;
+ struct rte_mempool *sess_pool;
+ struct rte_mempool *sess_priv_pool;
+};
struct test_perf {
/* Don't change the offset of "done". Signal handler use this memory
@@ -58,6 +69,7 @@ struct test_perf {
uint8_t sched_type_list[EVT_MAX_STAGES] __rte_cache_aligned;
struct rte_event_timer_adapter *timer_adptr[
RTE_EVENT_TIMER_ADAPTER_NUM_MAX] __rte_cache_aligned;
+ struct crypto_adptr_data crypto_adptr;
} __rte_cache_aligned;
struct perf_elt {
@@ -81,6 +93,8 @@ struct perf_elt {
const uint8_t port = w->port_id;\
const uint8_t prod_timer_type = \
opt->prod_type == EVT_PROD_TYPE_EVENT_TIMER_ADPTR;\
+ const uint8_t prod_crypto_type = \
+ opt->prod_type == EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR;\
uint8_t *const sched_type_list = &t->sched_type_list[0];\
struct rte_mempool *const pool = t->pool;\
const uint8_t nb_stages = t->opt->nb_stages;\
@@ -154,6 +168,7 @@ int perf_test_result(struct evt_test *test, struct evt_options *opt);
int perf_opt_check(struct evt_options *opt, uint64_t nb_queues);
int perf_test_setup(struct evt_test *test, struct evt_options *opt);
int perf_ethdev_setup(struct evt_test *test, struct evt_options *opt);
+int perf_cryptodev_setup(struct evt_test *test, struct evt_options *opt);
int perf_mempool_setup(struct evt_test *test, struct evt_options *opt);
int perf_event_dev_port_setup(struct evt_test *test, struct evt_options *opt,
uint8_t stride, uint8_t nb_queues,
@@ -164,6 +179,7 @@ int perf_launch_lcores(struct evt_test *test, struct evt_options *opt,
void perf_opt_dump(struct evt_options *opt, uint8_t nb_queues);
void perf_test_destroy(struct evt_test *test, struct evt_options *opt);
void perf_eventdev_destroy(struct evt_test *test, struct evt_options *opt);
+void perf_cryptodev_destroy(struct evt_test *test, struct evt_options *opt);
void perf_ethdev_destroy(struct evt_test *test, struct evt_options *opt);
void perf_mempool_destroy(struct evt_test *test, struct evt_options *opt);
diff --git a/app/test-eventdev/test_perf_queue.c b/app/test-eventdev/test_perf_queue.c
index f4ea3a795f..5657c8b3cd 100644
--- a/app/test-eventdev/test_perf_queue.c
+++ b/app/test-eventdev/test_perf_queue.c
@@ -49,6 +49,23 @@ perf_queue_worker(void *arg, const int enable_fwd_latency)
rte_pause();
continue;
}
+
+ if (prod_crypto_type &&
+ (ev.event_type == RTE_EVENT_TYPE_CRYPTODEV)) {
+ struct rte_crypto_op *op = ev.event_ptr;
+
+ if (op->status == RTE_CRYPTO_OP_STATUS_SUCCESS) {
+ if (op->sym->m_dst == NULL)
+ ev.event_ptr = op->sym->m_src;
+ else
+ ev.event_ptr = op->sym->m_dst;
+ rte_crypto_op_free(op);
+ } else {
+ rte_crypto_op_free(op);
+ continue;
+ }
+ }
+
if (enable_fwd_latency && !prod_timer_type)
/* first q in pipeline, mark timestamp to compute fwd latency */
mark_fwd_latency(&ev, nb_stages);
@@ -88,6 +105,25 @@ perf_queue_worker_burst(void *arg, const int enable_fwd_latency)
}
for (i = 0; i < nb_rx; i++) {
+ if (prod_crypto_type &&
+ (ev[i].event_type == RTE_EVENT_TYPE_CRYPTODEV)) {
+ struct rte_crypto_op *op = ev[i].event_ptr;
+
+ if (op->status ==
+ RTE_CRYPTO_OP_STATUS_SUCCESS) {
+ if (op->sym->m_dst == NULL)
+ ev[i].event_ptr =
+ op->sym->m_src;
+ else
+ ev[i].event_ptr =
+ op->sym->m_dst;
+ rte_crypto_op_free(op);
+ } else {
+ rte_crypto_op_free(op);
+ continue;
+ }
+ }
+
if (enable_fwd_latency && !prod_timer_type) {
rte_prefetch0(ev[i+1].event_ptr);
/* first queue in pipeline.
@@ -269,6 +305,20 @@ perf_queue_eventdev_setup(struct evt_test *test, struct evt_options *opt)
return ret;
}
}
+ } else if (opt->prod_type == EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR) {
+ uint8_t cdev_id, cdev_count;
+
+ cdev_count = rte_cryptodev_count();
+ for (cdev_id = 0; cdev_id < cdev_count; cdev_id++) {
+ ret = rte_cryptodev_start(cdev_id);
+ if (ret) {
+ evt_err("Failed to start cryptodev %u",
+ cdev_id);
+ return ret;
+ }
+ }
+
+ rte_event_crypto_adapter_start(t->crypto_adptr.id);
}
return 0;
@@ -311,11 +361,13 @@ static const struct evt_test_ops perf_queue = {
.test_setup = perf_test_setup,
.mempool_setup = perf_mempool_setup,
.ethdev_setup = perf_ethdev_setup,
+ .cryptodev_setup = perf_cryptodev_setup,
.eventdev_setup = perf_queue_eventdev_setup,
.launch_lcores = perf_queue_launch_lcores,
.eventdev_destroy = perf_eventdev_destroy,
.mempool_destroy = perf_mempool_destroy,
.ethdev_destroy = perf_ethdev_destroy,
+ .cryptodev_destroy = perf_cryptodev_destroy,
.test_result = perf_test_result,
.test_destroy = perf_test_destroy,
};
diff --git a/doc/guides/tools/testeventdev.rst b/doc/guides/tools/testeventdev.rst
index 48efb9ea6e..f7d813226d 100644
--- a/doc/guides/tools/testeventdev.rst
+++ b/doc/guides/tools/testeventdev.rst
@@ -120,6 +120,10 @@ The following are the application command-line options:
Use burst mode event timer adapter as producer.
+* ``--prod_type_cryptodev``
+
+ Use crypto device as producer.
+
* ``--timer_tick_nsec``
Used to dictate number of nano seconds between bucket traversal of the
@@ -148,6 +152,11 @@ The following are the application command-line options:
timeout is out of the supported range of event device it will be
adjusted to the highest/lowest supported dequeue timeout supported.
+* ``--crypto_adptr_mode``
+
+ Set crypto adapter mode. Use 0 for OP_NEW (default) and 1 for
+ OP_FORWARD mode.
+
* ``--mbuf_sz``
Set packet mbuf size. Can be used to configure Jumbo Frames. Only
@@ -420,6 +429,7 @@ Supported application command line options are following::
--prod_type_ethdev
--prod_type_timerdev_burst
--prod_type_timerdev
+ --prod_type_cryptodev
--prod_enq_burst_sz
--timer_tick_nsec
--max_tmo_nsec
@@ -427,6 +437,7 @@ Supported application command line options are following::
--nb_timers
--nb_timer_adptrs
--deq_tmo_nsec
+ --crypto_adptr_mode
Example
^^^^^^^
@@ -529,12 +540,14 @@ Supported application command line options are following::
--prod_type_ethdev
--prod_type_timerdev_burst
--prod_type_timerdev
+ --prod_type_cryptodev
--timer_tick_nsec
--max_tmo_nsec
--expiry_nsec
--nb_timers
--nb_timer_adptrs
--deq_tmo_nsec
+ --crypto_adptr_mode
Example
^^^^^^^
--
2.25.1
^ permalink raw reply [flat|nested] 43+ messages in thread
* Re: [PATCH v2] app/eventdev: add crypto producer mode
2022-01-03 9:14 ` Shijith Thotton
@ 2022-01-04 15:28 ` Aaron Conole
2022-01-04 15:49 ` [EXT] " Shijith Thotton
0 siblings, 1 reply; 43+ messages in thread
From: Aaron Conole @ 2022-01-04 15:28 UTC (permalink / raw)
To: Shijith Thotton
Cc: dpdklab, Anoob Joseph, Pavan Nikhilesh Bhagavatula, Akhil Goyal,
Gujjar, Abhinandan S, Jerin Jacob Kollanukkaran, dev
Shijith Thotton <sthotton@marvell.com> writes:
>>> >>
>>> >> In crypto producer mode, producer core enqueues cryptodev with
>>> >> software generated crypto ops and worker core dequeues crypto
>>> >> completion events from the eventdev. Event crypto metadata used for
>>> >> above processing is pre- populated in each crypto session.
>>> >>
>>> >> Parameter --prod_type_cryptodev can be used to enable crypto producer
>>> >mode.
>>> >> Parameter --crypto_adptr_mode can be set to select the crypto adapter
>>> >> mode,
>>> >0
>>> >> for OP_NEW and 1 for OP_FORWARD.
>>> >>
>>> >> This mode can be used to measure the performance of crypto adapter.
>>> >>
>>> >> Example:
>>> >> ./dpdk-test-eventdev -l 0-2 -w <EVENTDEV> -w <CRYPTODEV> -- \
>>> >> --prod_type_cryptodev --crypto_adptr_mode 1 --test=perf_atq \
>>> >> --stlist=a --wlcores 1 --plcores 2
>>> >
>>> >This patch has some perf failure as shown below. Could you please look into
>>> this?
>>> >105300 --> performance testing fail
>>> >
>>> >Test environment and result as below:
>>> >
>>> >Ubuntu 20.04
>>> >Kernel: 4.15.0-generic
>>> >Compiler: gcc 7.4
>>> >NIC: Intel Corporation Ethernet Converged Network Adapter 82599ES 10000
>>> >Mbps
>>> >Target: x86_64-native-linuxapp-gcc
>>> >Fail/Total: 0/4
>>> >
>>> >Detail performance results:
>>> >+------------+---------+----------+-------------+------------------------------+
>>> >| frame_size | txd/rxd | num_cpus | num_threads | throughput
>>> >| difference from
>>> >|
>>> >| | | | | expected |
>>>
>>>+============+=========+==========+=============+============
>>=
>>> >=================+
>>> >| 64 | 512 | 1 | 1 | 0.3% |
>>> >+------------+---------+----------+-------------+------------------------------+
>>> >| 64 | 2048 | 1 | 1 | -0.2% |
>>> >+------------+---------+----------+-------------+------------------------------+
>>> >| 64 | 512 | 1 | 2 | 0.0% |
>>> >+------------+---------+----------+-------------+------------------------------+
>>> >| 64 | 2048 | 1 | 2 | 0.3% |
>>> >+------------+---------+----------+-------------+------------------------------+
>>> >
>>> >Ubuntu 20.04
>>> >Kernel: 4.15.0-generic
>>> >Compiler: gcc 7.4
>>> >NIC: Intel Corporation Ethernet Converged Network Adapter XL710-QDA2
>>> >40000 Mbps
>>> >Target: x86_64-native-linuxapp-gcc
>>> >Fail/Total: 1/4
>>> >
>>> >Detail performance results:
>>> >+------------+---------+----------+-------------+------------------------------+
>>> >| frame_size | txd/rxd | num_cpus | num_threads | throughput
>>> >| difference from
>>> >|
>>> >| | | | | expected |
>>>
>>>+============+=========+==========+=============+============
>>=
>>> >=================+
>>> >| 64 | 512 | 1 | 1 | 0.2% |
>>> >+------------+---------+----------+-------------+------------------------------+
>>> >| 64 | 2048 | 1 | 1 | -0.7% |
>>> >+------------+---------+----------+-------------+------------------------------+
>>> >| 64 | 512 | 1 | 2 | -1.5% |
>>> >+------------+---------+----------+-------------+------------------------------+
>>> >| 64 | 2048 | 1 | 2 | -5.3% |
>>> >+------------+---------+----------+-------------+------------------------------+
>>> >
>>> >Ubuntu 20.04 ARM
>>> >Kernel: 4.15.0-132-generic
>>> >Compiler: gcc 7.5
>>> >NIC: Arm Intel Corporation Ethernet Converged Network Adapter
>>> >XL710-QDA2
>>> >40000 Mbps
>>> >Target: x86_64-native-linuxapp-gcc
>>> >Fail/Total: 0/2
>>> >
>>> >Detail performance results:
>>> >+------------+---------+----------+-------------+------------------------------+
>>> >| frame_size | txd/rxd | num_cpus | num_threads | throughput
>>> >| difference from
>>> >|
>>> >| | | | | expected |
>>>
>>>+============+=========+==========+=============+============
>>=
>>> >=================+
>>> >| 64 | 512 | 1 | 1 | 0.1% |
>>> >+------------+---------+----------+-------------+------------------------------+
>>> >| 64 | 2048 | 1 | 1 | -0.5% |
>>> >+------------+---------+----------+-------------+------------------------------+
>>> >
>>> >To view detailed results, visit:
>>> >https://urldefense.proofpoint.com/v2/url?u=https-
>>>
>>>3A__lab.dpdk.org_results_dashboard_patchsets_20534_&d=DwIFAg&c=nKjWe
>>> c2
>>> >b6R0mOyPaz7xtfQ&r=G9w4KsPaQLACBfGCL35PtiRH996yqJDxAZwrWegU2qQ&
>>> m=
>>>
>>>dPDgmKiLC_KqhgjwZrodyFlBdlFPgckVr9IW0c7t2cIHpkw6u9pGqgElFqqwuU1v&s
>>> =E
>>> >ajYUFziZY27q6LB4p5sOGuFlty3VlOjbMsLXaQ5MeI&e=
>>> >
>>>
>>> Performance regression is reported by nic_single_core_perf, but is using
>>> testpmd to measure performance. As this patch does not touch testpmd, the
>>> issue could be with DPDK CI. Is it possible to re-trigger CI ?
>>I have don't have option to trigger CI from my side.
>>So, I have added dpdklab and Aaron to the loop.
>>Please check with them.
>>
>
> Thanks Abhinandan.
>
> Aaron,
> From DTS, I only see testpmd being used for nic_single_core_perf test.
> This patch is not touching testpmd, but still got failure for the perf test.
> If possible, Please re-retrigger CI for this patch.
Seems this was superseded - I am guessing no new test needs to be run
for this:
https://patches.dpdk.org/project/dpdk/patch/736dc424a780b9547033f76f8911342ff06d3f87.1641292088.git.sthotton@marvell.com/
Is that correct?
^ permalink raw reply [flat|nested] 43+ messages in thread
* RE: [EXT] Re: [PATCH v2] app/eventdev: add crypto producer mode
2022-01-04 15:28 ` Aaron Conole
@ 2022-01-04 15:49 ` Shijith Thotton
0 siblings, 0 replies; 43+ messages in thread
From: Shijith Thotton @ 2022-01-04 15:49 UTC (permalink / raw)
To: Aaron Conole
Cc: dpdklab, Anoob Joseph, Pavan Nikhilesh Bhagavatula, Akhil Goyal,
Gujjar, Abhinandan S, Jerin Jacob Kollanukkaran, dev
>>>> >>
>>>> >> In crypto producer mode, producer core enqueues cryptodev with
>>>> >> software generated crypto ops and worker core dequeues crypto
>>>> >> completion events from the eventdev. Event crypto metadata used for
>>>> >> above processing is pre- populated in each crypto session.
>>>> >>
>>>> >> Parameter --prod_type_cryptodev can be used to enable crypto producer
>>>> >mode.
>>>> >> Parameter --crypto_adptr_mode can be set to select the crypto adapter
>>>> >> mode,
>>>> >0
>>>> >> for OP_NEW and 1 for OP_FORWARD.
>>>> >>
>>>> >> This mode can be used to measure the performance of crypto adapter.
>>>> >>
>>>> >> Example:
>>>> >> ./dpdk-test-eventdev -l 0-2 -w <EVENTDEV> -w <CRYPTODEV> -- \
>>>> >> --prod_type_cryptodev --crypto_adptr_mode 1 --test=perf_atq \
>>>> >> --stlist=a --wlcores 1 --plcores 2
>>>> >
>>>> >This patch has some perf failure as shown below. Could you please look into
>>>> this?
>>>> >105300 --> performance testing fail
>>>> >
>>>> >Test environment and result as below:
>>>> >
>>>> >Ubuntu 20.04
>>>> >Kernel: 4.15.0-generic
>>>> >Compiler: gcc 7.4
>>>> >NIC: Intel Corporation Ethernet Converged Network Adapter 82599ES 10000
>>>> >Mbps
>>>> >Target: x86_64-native-linuxapp-gcc
>>>> >Fail/Total: 0/4
>>>> >
>>>> >Detail performance results:
>>>> >+------------+---------+----------+-------------+------------------------------+
>>>> >| frame_size | txd/rxd | num_cpus | num_threads | throughput
>>>> >| difference from
>>>> >|
>>>> >| | | | | expected |
>>>>
>>>>+============+=========+==========+=============+==========
>==
>>>=
>>>> >=================+
>>>> >| 64 | 512 | 1 | 1 | 0.3% |
>>>> >+------------+---------+----------+-------------+------------------------------+
>>>> >| 64 | 2048 | 1 | 1 | -0.2% |
>>>> >+------------+---------+----------+-------------+------------------------------+
>>>> >| 64 | 512 | 1 | 2 | 0.0% |
>>>> >+------------+---------+----------+-------------+------------------------------+
>>>> >| 64 | 2048 | 1 | 2 | 0.3% |
>>>> >+------------+---------+----------+-------------+------------------------------+
>>>> >
>>>> >Ubuntu 20.04
>>>> >Kernel: 4.15.0-generic
>>>> >Compiler: gcc 7.4
>>>> >NIC: Intel Corporation Ethernet Converged Network Adapter XL710-QDA2
>>>> >40000 Mbps
>>>> >Target: x86_64-native-linuxapp-gcc
>>>> >Fail/Total: 1/4
>>>> >
>>>> >Detail performance results:
>>>> >+------------+---------+----------+-------------+------------------------------+
>>>> >| frame_size | txd/rxd | num_cpus | num_threads | throughput
>>>> >| difference from
>>>> >|
>>>> >| | | | | expected |
>>>>
>>>>+============+=========+==========+=============+==========
>==
>>>=
>>>> >=================+
>>>> >| 64 | 512 | 1 | 1 | 0.2% |
>>>> >+------------+---------+----------+-------------+------------------------------+
>>>> >| 64 | 2048 | 1 | 1 | -0.7% |
>>>> >+------------+---------+----------+-------------+------------------------------+
>>>> >| 64 | 512 | 1 | 2 | -1.5% |
>>>> >+------------+---------+----------+-------------+------------------------------+
>>>> >| 64 | 2048 | 1 | 2 | -5.3% |
>>>> >+------------+---------+----------+-------------+------------------------------+
>>>> >
>>>> >Ubuntu 20.04 ARM
>>>> >Kernel: 4.15.0-132-generic
>>>> >Compiler: gcc 7.5
>>>> >NIC: Arm Intel Corporation Ethernet Converged Network Adapter
>>>> >XL710-QDA2
>>>> >40000 Mbps
>>>> >Target: x86_64-native-linuxapp-gcc
>>>> >Fail/Total: 0/2
>>>> >
>>>> >Detail performance results:
>>>> >+------------+---------+----------+-------------+------------------------------+
>>>> >| frame_size | txd/rxd | num_cpus | num_threads | throughput
>>>> >| difference from
>>>> >|
>>>> >| | | | | expected |
>>>>
>>>>+============+=========+==========+=============+==========
>==
>>>=
>>>> >=================+
>>>> >| 64 | 512 | 1 | 1 | 0.1% |
>>>> >+------------+---------+----------+-------------+------------------------------+
>>>> >| 64 | 2048 | 1 | 1 | -0.5% |
>>>> >+------------+---------+----------+-------------+------------------------------+
>>>> >
>>>> >To view detailed results, visit:
>>>> >https://urldefense.proofpoint.com/v2/url?u=https-
>>>>
>>>>3A__lab.dpdk.org_results_dashboard_patchsets_20534_&d=DwIFAg&c=nKj
>We
>>>> c2
>>>>
>>b6R0mOyPaz7xtfQ&r=G9w4KsPaQLACBfGCL35PtiRH996yqJDxAZwrWegU2qQ&
>>>> m=
>>>>
>>>>dPDgmKiLC_KqhgjwZrodyFlBdlFPgckVr9IW0c7t2cIHpkw6u9pGqgElFqqwuU1v&
>s
>>>> =E
>>>> >ajYUFziZY27q6LB4p5sOGuFlty3VlOjbMsLXaQ5MeI&e=
>>>> >
>>>>
>>>> Performance regression is reported by nic_single_core_perf, but is using
>>>> testpmd to measure performance. As this patch does not touch testpmd, the
>>>> issue could be with DPDK CI. Is it possible to re-trigger CI ?
>>>I have don't have option to trigger CI from my side.
>>>So, I have added dpdklab and Aaron to the loop.
>>>Please check with them.
>>>
>>
>> Thanks Abhinandan.
>>
>> Aaron,
>> From DTS, I only see testpmd being used for nic_single_core_perf test.
>> This patch is not touching testpmd, but still got failure for the perf test.
>> If possible, Please re-retrigger CI for this patch.
>
>Seems this was superseded - I am guessing no new test needs to be run
>for this:
>
>https://urldefense.proofpoint.com/v2/url?u=https-
>3A__patches.dpdk.org_project_dpdk_patch_736dc424a780b9547033f76f8911342f
>f06d3f87.1641292088.git.sthotton-
>40marvell.com_&d=DwIBAg&c=nKjWec2b6R0mOyPaz7xtfQ&r=G9w4KsPaQLACBf
>GCL35PtiRH996yqJDxAZwrWegU2qQ&m=qAw77KHlJ3Gr9aLNyRrJFhgKWJM-
>y3Rgjlf3TZlNeM4vM7hontySZ4inIBL6ehjB&s=uWo5o2-
>22qVZRfYgG3swzbFeYJYtzrjJTPxsgBZGo30&e=
>
>Is that correct?
Yes, the patch is superseded.
CI is passing for v3. nic_single_core_perf numbers may not be consistent.
^ permalink raw reply [flat|nested] 43+ messages in thread
* Re: [PATCH v3] app/eventdev: add crypto producer mode
2022-01-04 10:30 ` [PATCH v3] " Shijith Thotton
@ 2022-01-21 12:25 ` Jerin Jacob
2022-01-23 16:56 ` Gujjar, Abhinandan S
2022-01-23 18:44 ` Gujjar, Abhinandan S
2022-02-08 16:33 ` [PATCH v4] " Shijith Thotton
2 siblings, 1 reply; 43+ messages in thread
From: Jerin Jacob @ 2022-01-21 12:25 UTC (permalink / raw)
To: Shijith Thotton
Cc: dpdk-dev, Jerin Jacob, Anoob Joseph, Pavan Nikhilesh,
Akhil Goyal, Gujjar, Abhinandan S
On Tue, Jan 4, 2022 at 4:04 PM Shijith Thotton <sthotton@marvell.com> wrote:
>
> In crypto producer mode, producer core enqueues cryptodev with software
> generated crypto ops and worker core dequeues crypto completion events
> from the eventdev. Event crypto metadata used for above processing is
> pre-populated in each crypto session.
>
> Parameter --prod_type_cryptodev can be used to enable crypto producer
> mode. Parameter --crypto_adptr_mode can be set to select the crypto
> adapter mode, 0 for OP_NEW and 1 for OP_FORWARD.
>
> This mode can be used to measure the performance of crypto adapter.
>
> Example:
> ./dpdk-test-eventdev -l 0-2 -w <EVENTDEV> -w <CRYPTODEV> -- \
> --prod_type_cryptodev --crypto_adptr_mode 1 --test=perf_atq \
> --stlist=a --wlcores 1 --plcores 2
>
> Signed-off-by: Shijith Thotton <sthotton@marvell.com>
> ---
> v3:
> * Reduce dereference inside loop.
Hi @Gujjar, Abhinandan S
Do you have any comments or objections to merging this change?
>
> v2:
> * Fix RHEL compilation warning.
>
> app/test-eventdev/evt_common.h | 3 +
> app/test-eventdev/evt_main.c | 13 +-
> app/test-eventdev/evt_options.c | 27 ++
> app/test-eventdev/evt_options.h | 12 +
> app/test-eventdev/evt_test.h | 6 +
> app/test-eventdev/test_perf_atq.c | 51 ++++
> app/test-eventdev/test_perf_common.c | 410 ++++++++++++++++++++++++++-
> app/test-eventdev/test_perf_common.h | 16 ++
> app/test-eventdev/test_perf_queue.c | 52 ++++
> doc/guides/tools/testeventdev.rst | 13 +
> 10 files changed, 596 insertions(+), 7 deletions(-)
>
> diff --git a/app/test-eventdev/evt_common.h b/app/test-eventdev/evt_common.h
> index f466434459..2f301a7e79 100644
> --- a/app/test-eventdev/evt_common.h
> +++ b/app/test-eventdev/evt_common.h
> @@ -7,6 +7,7 @@
>
> #include <rte_common.h>
> #include <rte_debug.h>
> +#include <rte_event_crypto_adapter.h>
> #include <rte_eventdev.h>
> #include <rte_service.h>
>
> @@ -39,6 +40,7 @@ enum evt_prod_type {
> EVT_PROD_TYPE_SYNT, /* Producer type Synthetic i.e. CPU. */
> EVT_PROD_TYPE_ETH_RX_ADPTR, /* Producer type Eth Rx Adapter. */
> EVT_PROD_TYPE_EVENT_TIMER_ADPTR, /* Producer type Timer Adapter. */
> + EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR, /* Producer type Crypto Adapter. */
> EVT_PROD_TYPE_MAX,
> };
>
> @@ -77,6 +79,7 @@ struct evt_options {
> uint64_t timer_tick_nsec;
> uint64_t optm_timer_tick_nsec;
> enum evt_prod_type prod_type;
> + enum rte_event_crypto_adapter_mode crypto_adptr_mode;
> };
>
> static inline bool
> diff --git a/app/test-eventdev/evt_main.c b/app/test-eventdev/evt_main.c
> index 194c980c7a..cef0fb1382 100644
> --- a/app/test-eventdev/evt_main.c
> +++ b/app/test-eventdev/evt_main.c
> @@ -161,12 +161,19 @@ main(int argc, char **argv)
> goto mempool_destroy;
> }
> }
> + /* Test specific cryptodev setup */
> + if (test->ops.cryptodev_setup) {
> + if (test->ops.cryptodev_setup(test, &opt)) {
> + evt_err("%s: cryptodev setup failed", opt.test_name);
> + goto ethdev_destroy;
> + }
> + }
>
> /* Test specific eventdev setup */
> if (test->ops.eventdev_setup) {
> if (test->ops.eventdev_setup(test, &opt)) {
> evt_err("%s: eventdev setup failed", opt.test_name);
> - goto ethdev_destroy;
> + goto cryptodev_destroy;
> }
> }
>
> @@ -197,6 +204,10 @@ main(int argc, char **argv)
> if (test->ops.eventdev_destroy)
> test->ops.eventdev_destroy(test, &opt);
>
> +cryptodev_destroy:
> + if (test->ops.cryptodev_destroy)
> + test->ops.cryptodev_destroy(test, &opt);
> +
> ethdev_destroy:
> if (test->ops.ethdev_destroy)
> test->ops.ethdev_destroy(test, &opt);
> diff --git a/app/test-eventdev/evt_options.c b/app/test-eventdev/evt_options.c
> index 753a7dbd7d..5ad1491020 100644
> --- a/app/test-eventdev/evt_options.c
> +++ b/app/test-eventdev/evt_options.c
> @@ -122,6 +122,26 @@ evt_parse_timer_prod_type_burst(struct evt_options *opt,
> return 0;
> }
>
> +static int
> +evt_parse_crypto_prod_type(struct evt_options *opt,
> + const char *arg __rte_unused)
> +{
> + opt->prod_type = EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR;
> + return 0;
> +}
> +
> +static int
> +evt_parse_crypto_adptr_mode(struct evt_options *opt, const char *arg)
> +{
> + uint8_t mode;
> + int ret;
> +
> + ret = parser_read_uint8(&mode, arg);
> + opt->crypto_adptr_mode = mode ? RTE_EVENT_CRYPTO_ADAPTER_OP_FORWARD :
> + RTE_EVENT_CRYPTO_ADAPTER_OP_NEW;
> + return ret;
> +}
> +
> static int
> evt_parse_test_name(struct evt_options *opt, const char *arg)
> {
> @@ -335,6 +355,7 @@ usage(char *program)
> "\t--queue_priority : enable queue priority\n"
> "\t--deq_tmo_nsec : global dequeue timeout\n"
> "\t--prod_type_ethdev : use ethernet device as producer.\n"
> + "\t--prod_type_cryptodev : use crypto device as producer.\n"
> "\t--prod_type_timerdev : use event timer device as producer.\n"
> "\t expity_nsec would be the timeout\n"
> "\t in ns.\n"
> @@ -345,6 +366,8 @@ usage(char *program)
> "\t--timer_tick_nsec : timer tick interval in ns.\n"
> "\t--max_tmo_nsec : max timeout interval in ns.\n"
> "\t--expiry_nsec : event timer expiry ns.\n"
> + "\t--crypto_adptr_mode : 0 for OP_NEW mode (default) and\n"
> + "\t 1 for OP_FORWARD mode.\n"
> "\t--mbuf_sz : packet mbuf size.\n"
> "\t--max_pkt_sz : max packet size.\n"
> "\t--prod_enq_burst_sz : producer enqueue burst size.\n"
> @@ -415,8 +438,10 @@ static struct option lgopts[] = {
> { EVT_QUEUE_PRIORITY, 0, 0, 0 },
> { EVT_DEQ_TMO_NSEC, 1, 0, 0 },
> { EVT_PROD_ETHDEV, 0, 0, 0 },
> + { EVT_PROD_CRYPTODEV, 0, 0, 0 },
> { EVT_PROD_TIMERDEV, 0, 0, 0 },
> { EVT_PROD_TIMERDEV_BURST, 0, 0, 0 },
> + { EVT_CRYPTO_ADPTR_MODE, 1, 0, 0 },
> { EVT_NB_TIMERS, 1, 0, 0 },
> { EVT_NB_TIMER_ADPTRS, 1, 0, 0 },
> { EVT_TIMER_TICK_NSEC, 1, 0, 0 },
> @@ -455,8 +480,10 @@ evt_opts_parse_long(int opt_idx, struct evt_options *opt)
> { EVT_QUEUE_PRIORITY, evt_parse_queue_priority},
> { EVT_DEQ_TMO_NSEC, evt_parse_deq_tmo_nsec},
> { EVT_PROD_ETHDEV, evt_parse_eth_prod_type},
> + { EVT_PROD_CRYPTODEV, evt_parse_crypto_prod_type},
> { EVT_PROD_TIMERDEV, evt_parse_timer_prod_type},
> { EVT_PROD_TIMERDEV_BURST, evt_parse_timer_prod_type_burst},
> + { EVT_CRYPTO_ADPTR_MODE, evt_parse_crypto_adptr_mode},
> { EVT_NB_TIMERS, evt_parse_nb_timers},
> { EVT_NB_TIMER_ADPTRS, evt_parse_nb_timer_adptrs},
> { EVT_TIMER_TICK_NSEC, evt_parse_timer_tick_nsec},
> diff --git a/app/test-eventdev/evt_options.h b/app/test-eventdev/evt_options.h
> index 413d7092f0..2231c58801 100644
> --- a/app/test-eventdev/evt_options.h
> +++ b/app/test-eventdev/evt_options.h
> @@ -9,6 +9,7 @@
> #include <stdbool.h>
>
> #include <rte_common.h>
> +#include <rte_cryptodev.h>
> #include <rte_ethdev.h>
> #include <rte_eventdev.h>
> #include <rte_lcore.h>
> @@ -33,8 +34,10 @@
> #define EVT_QUEUE_PRIORITY ("queue_priority")
> #define EVT_DEQ_TMO_NSEC ("deq_tmo_nsec")
> #define EVT_PROD_ETHDEV ("prod_type_ethdev")
> +#define EVT_PROD_CRYPTODEV ("prod_type_cryptodev")
> #define EVT_PROD_TIMERDEV ("prod_type_timerdev")
> #define EVT_PROD_TIMERDEV_BURST ("prod_type_timerdev_burst")
> +#define EVT_CRYPTO_ADPTR_MODE ("crypto_adptr_mode")
> #define EVT_NB_TIMERS ("nb_timers")
> #define EVT_NB_TIMER_ADPTRS ("nb_timer_adptrs")
> #define EVT_TIMER_TICK_NSEC ("timer_tick_nsec")
> @@ -249,6 +252,8 @@ evt_prod_id_to_name(enum evt_prod_type prod_type)
> return "Ethdev Rx Adapter";
> case EVT_PROD_TYPE_EVENT_TIMER_ADPTR:
> return "Event timer adapter";
> + case EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR:
> + return "Event crypto adapter";
> }
>
> return "";
> @@ -288,6 +293,13 @@ evt_dump_producer_type(struct evt_options *opt)
> evt_dump("timer_tick_nsec", "%"PRIu64"",
> opt->timer_tick_nsec);
> break;
> + case EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR:
> + snprintf(name, EVT_PROD_MAX_NAME_LEN,
> + "Event crypto adapter producers");
> + evt_dump("crypto adapter mode", "%s",
> + opt->crypto_adptr_mode ? "OP_FORWARD" : "OP_NEW");
> + evt_dump("nb_cryptodev", "%u", rte_cryptodev_count());
> + break;
> }
> evt_dump("prod_type", "%s", name);
> }
> diff --git a/app/test-eventdev/evt_test.h b/app/test-eventdev/evt_test.h
> index f07d2c3336..50fa474ec2 100644
> --- a/app/test-eventdev/evt_test.h
> +++ b/app/test-eventdev/evt_test.h
> @@ -29,6 +29,8 @@ typedef int (*evt_test_mempool_setup_t)
> (struct evt_test *test, struct evt_options *opt);
> typedef int (*evt_test_ethdev_setup_t)
> (struct evt_test *test, struct evt_options *opt);
> +typedef int (*evt_test_cryptodev_setup_t)
> + (struct evt_test *test, struct evt_options *opt);
> typedef int (*evt_test_eventdev_setup_t)
> (struct evt_test *test, struct evt_options *opt);
> typedef int (*evt_test_launch_lcores_t)
> @@ -39,6 +41,8 @@ typedef void (*evt_test_eventdev_destroy_t)
> (struct evt_test *test, struct evt_options *opt);
> typedef void (*evt_test_ethdev_destroy_t)
> (struct evt_test *test, struct evt_options *opt);
> +typedef void (*evt_test_cryptodev_destroy_t)
> + (struct evt_test *test, struct evt_options *opt);
> typedef void (*evt_test_mempool_destroy_t)
> (struct evt_test *test, struct evt_options *opt);
> typedef void (*evt_test_destroy_t)
> @@ -52,10 +56,12 @@ struct evt_test_ops {
> evt_test_mempool_setup_t mempool_setup;
> evt_test_ethdev_setup_t ethdev_setup;
> evt_test_eventdev_setup_t eventdev_setup;
> + evt_test_cryptodev_setup_t cryptodev_setup;
> evt_test_launch_lcores_t launch_lcores;
> evt_test_result_t test_result;
> evt_test_eventdev_destroy_t eventdev_destroy;
> evt_test_ethdev_destroy_t ethdev_destroy;
> + evt_test_cryptodev_destroy_t cryptodev_destroy;
> evt_test_mempool_destroy_t mempool_destroy;
> evt_test_destroy_t test_destroy;
> };
> diff --git a/app/test-eventdev/test_perf_atq.c b/app/test-eventdev/test_perf_atq.c
> index 8fd51004ee..dbb1dc8c0c 100644
> --- a/app/test-eventdev/test_perf_atq.c
> +++ b/app/test-eventdev/test_perf_atq.c
> @@ -48,6 +48,22 @@ perf_atq_worker(void *arg, const int enable_fwd_latency)
> continue;
> }
>
> + if (prod_crypto_type &&
> + (ev.event_type == RTE_EVENT_TYPE_CRYPTODEV)) {
> + struct rte_crypto_op *op = ev.event_ptr;
> +
> + if (op->status == RTE_CRYPTO_OP_STATUS_SUCCESS) {
> + if (op->sym->m_dst == NULL)
> + ev.event_ptr = op->sym->m_src;
> + else
> + ev.event_ptr = op->sym->m_dst;
> + rte_crypto_op_free(op);
> + } else {
> + rte_crypto_op_free(op);
> + continue;
> + }
> + }
> +
> if (enable_fwd_latency && !prod_timer_type)
> /* first stage in pipeline, mark ts to compute fwd latency */
> atq_mark_fwd_latency(&ev);
> @@ -87,6 +103,25 @@ perf_atq_worker_burst(void *arg, const int enable_fwd_latency)
> }
>
> for (i = 0; i < nb_rx; i++) {
> + if (prod_crypto_type &&
> + (ev[i].event_type == RTE_EVENT_TYPE_CRYPTODEV)) {
> + struct rte_crypto_op *op = ev[i].event_ptr;
> +
> + if (op->status ==
> + RTE_CRYPTO_OP_STATUS_SUCCESS) {
> + if (op->sym->m_dst == NULL)
> + ev[i].event_ptr =
> + op->sym->m_src;
> + else
> + ev[i].event_ptr =
> + op->sym->m_dst;
> + rte_crypto_op_free(op);
> + } else {
> + rte_crypto_op_free(op);
> + continue;
> + }
> + }
> +
> if (enable_fwd_latency && !prod_timer_type) {
> rte_prefetch0(ev[i+1].event_ptr);
> /* first stage in pipeline.
> @@ -254,6 +289,20 @@ perf_atq_eventdev_setup(struct evt_test *test, struct evt_options *opt)
> return ret;
> }
> }
> + } else if (opt->prod_type == EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR) {
> + uint8_t cdev_id, cdev_count;
> +
> + cdev_count = rte_cryptodev_count();
> + for (cdev_id = 0; cdev_id < cdev_count; cdev_id++) {
> + ret = rte_cryptodev_start(cdev_id);
> + if (ret) {
> + evt_err("Failed to start cryptodev %u",
> + cdev_id);
> + return ret;
> + }
> + }
> +
> + rte_event_crypto_adapter_start(t->crypto_adptr.id);
> }
>
> return 0;
> @@ -295,12 +344,14 @@ static const struct evt_test_ops perf_atq = {
> .opt_dump = perf_atq_opt_dump,
> .test_setup = perf_test_setup,
> .ethdev_setup = perf_ethdev_setup,
> + .cryptodev_setup = perf_cryptodev_setup,
> .mempool_setup = perf_mempool_setup,
> .eventdev_setup = perf_atq_eventdev_setup,
> .launch_lcores = perf_atq_launch_lcores,
> .eventdev_destroy = perf_eventdev_destroy,
> .mempool_destroy = perf_mempool_destroy,
> .ethdev_destroy = perf_ethdev_destroy,
> + .cryptodev_destroy = perf_cryptodev_destroy,
> .test_result = perf_test_result,
> .test_destroy = perf_test_destroy,
> };
> diff --git a/app/test-eventdev/test_perf_common.c b/app/test-eventdev/test_perf_common.c
> index 9b73874151..91cb6748ee 100644
> --- a/app/test-eventdev/test_perf_common.c
> +++ b/app/test-eventdev/test_perf_common.c
> @@ -6,6 +6,8 @@
>
> #include "test_perf_common.h"
>
> +#define NB_CRYPTODEV_DESCRIPTORS 128
> +
> int
> perf_test_result(struct evt_test *test, struct evt_options *opt)
> {
> @@ -272,6 +274,125 @@ perf_event_timer_producer_burst(void *arg)
> return 0;
> }
>
> +static inline void
> +crypto_adapter_enq_op_new(struct prod_data *p)
> +{
> + struct rte_cryptodev_sym_session **crypto_sess = p->crypto_sess;
> + struct test_perf *t = p->t;
> + const uint32_t nb_flows = t->nb_flows;
> + const uint64_t nb_pkts = t->nb_pkts;
> + struct rte_mempool *pool = t->pool;
> + struct rte_crypto_sym_op *sym_op;
> + struct evt_options *opt = t->opt;
> + uint16_t qp_id = p->cdev_qp_id;
> + uint8_t cdev_id = p->cdev_id;
> + uint32_t flow_counter = 0;
> + struct rte_crypto_op *op;
> + struct rte_mbuf *m;
> + uint64_t count = 0;
> + uint16_t len;
> +
> + if (opt->verbose_level > 1)
> + printf("%s(): lcore %d queue %d cdev_id %u cdev_qp_id %u\n",
> + __func__, rte_lcore_id(), p->queue_id, p->cdev_id,
> + p->cdev_qp_id);
> +
> + len = opt->mbuf_sz ? opt->mbuf_sz : RTE_ETHER_MIN_LEN;
> +
> + while (count < nb_pkts && t->done == false) {
> + m = rte_pktmbuf_alloc(pool);
> + if (m == NULL)
> + continue;
> +
> + rte_pktmbuf_append(m, len);
> + op = rte_crypto_op_alloc(t->crypto_adptr.op_pool,
> + RTE_CRYPTO_OP_TYPE_SYMMETRIC);
> + sym_op = op->sym;
> + sym_op->m_src = m;
> + sym_op->cipher.data.offset = 0;
> + sym_op->cipher.data.length = len;
> + rte_crypto_op_attach_sym_session(
> + op, crypto_sess[flow_counter++ % nb_flows]);
> + while (rte_cryptodev_enqueue_burst(cdev_id, qp_id, &op, 1) !=
> + 1) {
> + if (t->done)
> + break;
> + rte_pause();
> + }
> + count++;
> + }
> +}
> +
> +static inline void
> +crypto_adapter_enq_op_fwd(struct prod_data *p)
> +{
> + struct rte_cryptodev_sym_session **crypto_sess = p->crypto_sess;
> + const uint8_t dev_id = p->dev_id;
> + const uint8_t port = p->port_id;
> + struct test_perf *t = p->t;
> + const uint32_t nb_flows = t->nb_flows;
> + const uint64_t nb_pkts = t->nb_pkts;
> + struct rte_mempool *pool = t->pool;
> + struct evt_options *opt = t->opt;
> + struct rte_crypto_sym_op *sym_op;
> + uint32_t flow_counter = 0;
> + struct rte_crypto_op *op;
> + struct rte_event ev;
> + struct rte_mbuf *m;
> + uint64_t count = 0;
> + uint16_t len;
> +
> + if (opt->verbose_level > 1)
> + printf("%s(): lcore %d port %d queue %d cdev_id %u cdev_qp_id %u\n",
> + __func__, rte_lcore_id(), port, p->queue_id, p->cdev_id,
> + p->cdev_qp_id);
> +
> + ev.event = 0;
> + ev.op = RTE_EVENT_OP_NEW;
> + ev.queue_id = p->queue_id;
> + ev.sched_type = RTE_SCHED_TYPE_ATOMIC;
> + ev.event_type = RTE_EVENT_TYPE_CPU;
> + len = opt->mbuf_sz ? opt->mbuf_sz : RTE_ETHER_MIN_LEN;
> +
> + while (count < nb_pkts && t->done == false) {
> + m = rte_pktmbuf_alloc(pool);
> + if (m == NULL)
> + continue;
> +
> + rte_pktmbuf_append(m, len);
> + op = rte_crypto_op_alloc(t->crypto_adptr.op_pool,
> + RTE_CRYPTO_OP_TYPE_SYMMETRIC);
> + sym_op = op->sym;
> + sym_op->m_src = m;
> + sym_op->cipher.data.offset = 0;
> + sym_op->cipher.data.length = len;
> + rte_crypto_op_attach_sym_session(
> + op, crypto_sess[flow_counter++ % nb_flows]);
> + ev.event_ptr = op;
> + while (rte_event_crypto_adapter_enqueue(dev_id, port, &ev, 1) !=
> + 1) {
> + if (t->done)
> + break;
> + rte_pause();
> + }
> + count++;
> + }
> +}
> +
> +static inline int
> +perf_event_crypto_producer(void *arg)
> +{
> + struct prod_data *p = arg;
> + struct evt_options *opt = p->t->opt;
> +
> + if (opt->crypto_adptr_mode == RTE_EVENT_CRYPTO_ADAPTER_OP_NEW)
> + crypto_adapter_enq_op_new(p);
> + else
> + crypto_adapter_enq_op_fwd(p);
> +
> + return 0;
> +}
> +
> static int
> perf_producer_wrapper(void *arg)
> {
> @@ -298,6 +419,8 @@ perf_producer_wrapper(void *arg)
> else if (t->opt->prod_type == EVT_PROD_TYPE_EVENT_TIMER_ADPTR &&
> t->opt->timdev_use_burst)
> return perf_event_timer_producer_burst(arg);
> + else if (t->opt->prod_type == EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR)
> + return perf_event_crypto_producer(arg);
> return 0;
> }
>
> @@ -405,8 +528,10 @@ perf_launch_lcores(struct evt_test *test, struct evt_options *opt,
> if (remaining <= 0) {
> t->result = EVT_TEST_SUCCESS;
> if (opt->prod_type == EVT_PROD_TYPE_SYNT ||
> - opt->prod_type ==
> - EVT_PROD_TYPE_EVENT_TIMER_ADPTR) {
> + opt->prod_type ==
> + EVT_PROD_TYPE_EVENT_TIMER_ADPTR ||
> + opt->prod_type ==
> + EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR) {
> t->done = true;
> break;
> }
> @@ -415,7 +540,8 @@ perf_launch_lcores(struct evt_test *test, struct evt_options *opt,
>
> if (new_cycles - dead_lock_cycles > dead_lock_sample &&
> (opt->prod_type == EVT_PROD_TYPE_SYNT ||
> - opt->prod_type == EVT_PROD_TYPE_EVENT_TIMER_ADPTR)) {
> + opt->prod_type == EVT_PROD_TYPE_EVENT_TIMER_ADPTR ||
> + opt->prod_type == EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR)) {
> remaining = t->outstand_pkts - processed_pkts(t);
> if (dead_lock_remaining == remaining) {
> rte_event_dev_dump(opt->dev_id, stdout);
> @@ -537,6 +663,96 @@ perf_event_timer_adapter_setup(struct test_perf *t)
> return 0;
> }
>
> +static int
> +perf_event_crypto_adapter_setup(struct test_perf *t,
> + struct rte_event_port_conf port_conf)
> +{
> + struct evt_options *opt = t->opt;
> + uint8_t cdev_id, cdev_count;
> + int ret;
> +
> + t->crypto_adptr.id = 0;
> + ret = rte_event_crypto_adapter_create(t->crypto_adptr.id, opt->dev_id,
> + &port_conf, 0);
> + if (ret)
> + return ret;
> +
> + cdev_count = rte_cryptodev_count();
> + for (cdev_id = 0; cdev_id < cdev_count; cdev_id++) {
> + uint32_t cap;
> +
> + ret = rte_event_crypto_adapter_caps_get(opt->dev_id, cdev_id,
> + &cap);
> + if (ret) {
> + evt_err("Failed to get crypto adapter capabilities");
> + return ret;
> + }
> +
> + if (((opt->crypto_adptr_mode ==
> + RTE_EVENT_CRYPTO_ADAPTER_OP_NEW) &&
> + !(cap &
> + RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_OP_NEW)) ||
> + ((opt->crypto_adptr_mode ==
> + RTE_EVENT_CRYPTO_ADAPTER_OP_FORWARD) &&
> + !(cap &
> + RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_OP_FWD))) {
> + evt_err("crypto adapter %s mode unsupported\n",
> + opt->crypto_adptr_mode ? "OP_FORWARD" :
> + "OP_NEW");
> + return -EINVAL;
> + }
> +
> + if (!(cap &
> + RTE_EVENT_CRYPTO_ADAPTER_CAP_SESSION_PRIVATE_DATA)) {
> + evt_err("Storing crypto session not supported");
> + return -EINVAL;
> + }
> +
> + if (cap &
> + RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_QP_EV_BIND) {
> + struct rte_event response_info;
> +
> + response_info.event = 0;
> + ret = rte_event_crypto_adapter_queue_pair_add(
> + t->crypto_adptr.id, cdev_id, -1,
> + &response_info);
> + } else {
> + ret = rte_event_crypto_adapter_queue_pair_add(
> + t->crypto_adptr.id, cdev_id, -1, NULL);
> + }
> + if (ret)
> + return ret;
> + }
> +
> + return 0;
> +}
> +
> +static struct rte_cryptodev_sym_session *
> +cryptodev_sym_sess_create(struct prod_data *p, struct test_perf *t)
> +{
> + struct rte_crypto_sym_xform cipher_xform;
> + struct rte_cryptodev_sym_session *sess;
> +
> + cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
> + cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
> + cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
> + cipher_xform.next = NULL;
> +
> + sess = rte_cryptodev_sym_session_create(t->crypto_adptr.sess_pool);
> + if (sess == NULL) {
> + evt_err("Failed to create sym session");
> + return NULL;
> + }
> +
> + if (rte_cryptodev_sym_session_init(p->cdev_id, sess, &cipher_xform,
> + t->crypto_adptr.sess_priv_pool)) {
> + evt_err("Failed to init session");
> + return NULL;
> + }
> +
> + return sess;
> +}
> +
> int
> perf_event_dev_port_setup(struct evt_test *test, struct evt_options *opt,
> uint8_t stride, uint8_t nb_queues,
> @@ -598,6 +814,55 @@ perf_event_dev_port_setup(struct evt_test *test, struct evt_options *opt,
> ret = perf_event_timer_adapter_setup(t);
> if (ret)
> return ret;
> + } else if (opt->prod_type == EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR) {
> + uint8_t cdev_id = 0;
> + uint16_t qp_id = 0;
> +
> + prod = 0;
> + for (; port < perf_nb_event_ports(opt); port++) {
> + struct rte_cryptodev_sym_session *crypto_sess;
> + union rte_event_crypto_metadata m_data;
> + struct prod_data *p = &t->prod[port];
> + uint32_t flow_id;
> +
> + if (qp_id == rte_cryptodev_queue_pair_count(cdev_id)) {
> + cdev_id++;
> + qp_id = 0;
> + }
> +
> + p->dev_id = opt->dev_id;
> + p->port_id = port;
> + p->queue_id = prod * stride;
> + p->cdev_id = cdev_id;
> + p->cdev_qp_id = qp_id;
> + p->crypto_sess = rte_zmalloc_socket(
> + NULL, sizeof(crypto_sess) * t->nb_flows,
> + RTE_CACHE_LINE_SIZE, opt->socket_id);
> +
> + m_data.request_info.cdev_id = p->cdev_id;
> + m_data.request_info.queue_pair_id = p->cdev_qp_id;
> + m_data.response_info.op = RTE_EVENT_OP_NEW;
> + m_data.response_info.sched_type = RTE_SCHED_TYPE_ATOMIC;
> + m_data.response_info.event_type = RTE_EVENT_TYPE_CPU;
> + m_data.response_info.queue_id = p->queue_id;
> + for (flow_id = 0; flow_id < t->nb_flows; flow_id++) {
> + crypto_sess = cryptodev_sym_sess_create(p, t);
> + if (crypto_sess == NULL)
> + return -ENOMEM;
> +
> + m_data.response_info.flow_id = flow_id;
> + rte_cryptodev_sym_session_set_user_data(
> + crypto_sess, &m_data, sizeof(m_data));
> + p->crypto_sess[flow_id] = crypto_sess;
> + }
> + p->t = t;
> + qp_id++;
> + prod++;
> + }
> +
> + ret = perf_event_crypto_adapter_setup(t, *port_conf);
> + if (ret)
> + return ret;
> } else {
> prod = 0;
> for ( ; port < perf_nb_event_ports(opt); port++) {
> @@ -659,7 +924,8 @@ perf_opt_check(struct evt_options *opt, uint64_t nb_queues)
> }
>
> if (opt->prod_type == EVT_PROD_TYPE_SYNT ||
> - opt->prod_type == EVT_PROD_TYPE_EVENT_TIMER_ADPTR) {
> + opt->prod_type == EVT_PROD_TYPE_EVENT_TIMER_ADPTR ||
> + opt->prod_type == EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR) {
> /* Validate producer lcores */
> if (evt_lcores_has_overlap(opt->plcores,
> rte_get_main_lcore())) {
> @@ -767,8 +1033,7 @@ perf_ethdev_setup(struct evt_test *test, struct evt_options *opt)
> },
> };
>
> - if (opt->prod_type == EVT_PROD_TYPE_SYNT ||
> - opt->prod_type == EVT_PROD_TYPE_EVENT_TIMER_ADPTR)
> + if (opt->prod_type != EVT_PROD_TYPE_ETH_RX_ADPTR)
> return 0;
>
> if (!rte_eth_dev_count_avail()) {
> @@ -841,6 +1106,139 @@ void perf_ethdev_destroy(struct evt_test *test, struct evt_options *opt)
> }
> }
>
> +int
> +perf_cryptodev_setup(struct evt_test *test, struct evt_options *opt)
> +{
> + uint8_t cdev_count, cdev_id, nb_plcores, nb_qps;
> + struct test_perf *t = evt_test_priv(test);
> + unsigned int max_session_size;
> + uint32_t nb_sessions;
> + int ret;
> +
> + if (opt->prod_type != EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR)
> + return 0;
> +
> + cdev_count = rte_cryptodev_count();
> + if (cdev_count == 0) {
> + evt_err("No crypto devices available\n");
> + return -ENODEV;
> + }
> +
> + t->crypto_adptr.op_pool = rte_crypto_op_pool_create(
> + "crypto_op_pool", RTE_CRYPTO_OP_TYPE_SYMMETRIC, opt->pool_sz,
> + 128, 0, rte_socket_id());
> + if (t->crypto_adptr.op_pool == NULL) {
> + evt_err("Failed to create crypto op pool");
> + return -ENOMEM;
> + }
> +
> + nb_sessions = evt_nr_active_lcores(opt->plcores) * t->nb_flows;
> + t->crypto_adptr.sess_pool = rte_cryptodev_sym_session_pool_create(
> + "ca_sess_pool", nb_sessions, 0, 0,
> + sizeof(union rte_event_crypto_metadata), SOCKET_ID_ANY);
> + if (t->crypto_adptr.sess_pool == NULL) {
> + evt_err("Failed to create sym session pool");
> + ret = -ENOMEM;
> + goto err;
> + }
> +
> + max_session_size = 0;
> + for (cdev_id = 0; cdev_id < cdev_count; cdev_id++) {
> + unsigned int session_size;
> +
> + session_size =
> + rte_cryptodev_sym_get_private_session_size(cdev_id);
> + if (session_size > max_session_size)
> + max_session_size = session_size;
> + }
> + max_session_size += sizeof(union rte_event_crypto_metadata);
> + t->crypto_adptr.sess_priv_pool = rte_mempool_create(
> + "ca_sess_priv_pool", nb_sessions, max_session_size, 0, 0, NULL,
> + NULL, NULL, NULL, SOCKET_ID_ANY, 0);
> + if (t->crypto_adptr.sess_priv_pool == NULL) {
> + evt_err("failed to create sym session private pool");
> + ret = -ENOMEM;
> + goto err;
> + }
> +
> + nb_plcores = evt_nr_active_lcores(opt->plcores);
> + nb_qps = (nb_plcores % cdev_count) ? (nb_plcores / cdev_count) + 1 :
> + nb_plcores / cdev_count;
> + for (cdev_id = 0; cdev_id < cdev_count; cdev_id++) {
> + struct rte_cryptodev_qp_conf qp_conf;
> + struct rte_cryptodev_config conf;
> + struct rte_cryptodev_info info;
> + int qp_id;
> +
> + rte_cryptodev_info_get(cdev_id, &info);
> + if (nb_qps > info.max_nb_queue_pairs) {
> + evt_err("Not enough queue pairs per cryptodev (%u)",
> + nb_qps);
> + ret = -EINVAL;
> + goto err;
> + }
> +
> + conf.nb_queue_pairs = nb_qps;
> + conf.socket_id = SOCKET_ID_ANY;
> + conf.ff_disable = RTE_CRYPTODEV_FF_SECURITY;
> +
> + ret = rte_cryptodev_configure(cdev_id, &conf);
> + if (ret) {
> + evt_err("Failed to configure cryptodev (%u)", cdev_id);
> + goto err;
> + }
> +
> + qp_conf.nb_descriptors = NB_CRYPTODEV_DESCRIPTORS;
> + qp_conf.mp_session = t->crypto_adptr.sess_pool;
> + qp_conf.mp_session_private = t->crypto_adptr.sess_priv_pool;
> +
> + for (qp_id = 0; qp_id < conf.nb_queue_pairs; qp_id++) {
> + ret = rte_cryptodev_queue_pair_setup(
> + cdev_id, qp_id, &qp_conf,
> + rte_cryptodev_socket_id(cdev_id));
> + if (ret) {
> + evt_err("Failed to setup queue pairs on cryptodev %u\n",
> + cdev_id);
> + goto err;
> + }
> + }
> + }
> +
> + return 0;
> +err:
> + rte_mempool_free(t->crypto_adptr.op_pool);
> + rte_mempool_free(t->crypto_adptr.sess_pool);
> + rte_mempool_free(t->crypto_adptr.sess_priv_pool);
> +
> + return ret;
> +}
> +
> +void
> +perf_cryptodev_destroy(struct evt_test *test, struct evt_options *opt)
> +{
> + uint8_t cdev_id, cdev_count = rte_cryptodev_count();
> + struct test_perf *t = evt_test_priv(test);
> +
> + RTE_SET_USED(opt);
> +
> + if (opt->prod_type != EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR)
> + return;
> +
> + rte_event_crypto_adapter_stop(t->crypto_adptr.id);
> +
> + for (cdev_id = 0; cdev_id < cdev_count; cdev_id++) {
> + rte_cryptodev_stop(cdev_id);
> + rte_event_crypto_adapter_queue_pair_del(t->crypto_adptr.id,
> + cdev_id, -1);
> + }
> +
> + rte_event_crypto_adapter_free(t->crypto_adptr.id);
> +
> + rte_mempool_free(t->crypto_adptr.op_pool);
> + rte_mempool_free(t->crypto_adptr.sess_pool);
> + rte_mempool_free(t->crypto_adptr.sess_priv_pool);
> +}
> +
> int
> perf_mempool_setup(struct evt_test *test, struct evt_options *opt)
> {
> diff --git a/app/test-eventdev/test_perf_common.h b/app/test-eventdev/test_perf_common.h
> index 14dcf80429..d9ad3a0b0d 100644
> --- a/app/test-eventdev/test_perf_common.h
> +++ b/app/test-eventdev/test_perf_common.h
> @@ -9,9 +9,11 @@
> #include <stdbool.h>
> #include <unistd.h>
>
> +#include <rte_cryptodev.h>
> #include <rte_cycles.h>
> #include <rte_ethdev.h>
> #include <rte_eventdev.h>
> +#include <rte_event_crypto_adapter.h>
> #include <rte_event_eth_rx_adapter.h>
> #include <rte_event_timer_adapter.h>
> #include <rte_lcore.h>
> @@ -37,9 +39,18 @@ struct prod_data {
> uint8_t dev_id;
> uint8_t port_id;
> uint8_t queue_id;
> + uint8_t cdev_id;
> + uint16_t cdev_qp_id;
> + struct rte_cryptodev_sym_session **crypto_sess;
> struct test_perf *t;
> } __rte_cache_aligned;
>
> +struct crypto_adptr_data {
> + uint8_t id;
> + struct rte_mempool *op_pool;
> + struct rte_mempool *sess_pool;
> + struct rte_mempool *sess_priv_pool;
> +};
>
> struct test_perf {
> /* Don't change the offset of "done". Signal handler use this memory
> @@ -58,6 +69,7 @@ struct test_perf {
> uint8_t sched_type_list[EVT_MAX_STAGES] __rte_cache_aligned;
> struct rte_event_timer_adapter *timer_adptr[
> RTE_EVENT_TIMER_ADAPTER_NUM_MAX] __rte_cache_aligned;
> + struct crypto_adptr_data crypto_adptr;
> } __rte_cache_aligned;
>
> struct perf_elt {
> @@ -81,6 +93,8 @@ struct perf_elt {
> const uint8_t port = w->port_id;\
> const uint8_t prod_timer_type = \
> opt->prod_type == EVT_PROD_TYPE_EVENT_TIMER_ADPTR;\
> + const uint8_t prod_crypto_type = \
> + opt->prod_type == EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR;\
> uint8_t *const sched_type_list = &t->sched_type_list[0];\
> struct rte_mempool *const pool = t->pool;\
> const uint8_t nb_stages = t->opt->nb_stages;\
> @@ -154,6 +168,7 @@ int perf_test_result(struct evt_test *test, struct evt_options *opt);
> int perf_opt_check(struct evt_options *opt, uint64_t nb_queues);
> int perf_test_setup(struct evt_test *test, struct evt_options *opt);
> int perf_ethdev_setup(struct evt_test *test, struct evt_options *opt);
> +int perf_cryptodev_setup(struct evt_test *test, struct evt_options *opt);
> int perf_mempool_setup(struct evt_test *test, struct evt_options *opt);
> int perf_event_dev_port_setup(struct evt_test *test, struct evt_options *opt,
> uint8_t stride, uint8_t nb_queues,
> @@ -164,6 +179,7 @@ int perf_launch_lcores(struct evt_test *test, struct evt_options *opt,
> void perf_opt_dump(struct evt_options *opt, uint8_t nb_queues);
> void perf_test_destroy(struct evt_test *test, struct evt_options *opt);
> void perf_eventdev_destroy(struct evt_test *test, struct evt_options *opt);
> +void perf_cryptodev_destroy(struct evt_test *test, struct evt_options *opt);
> void perf_ethdev_destroy(struct evt_test *test, struct evt_options *opt);
> void perf_mempool_destroy(struct evt_test *test, struct evt_options *opt);
>
> diff --git a/app/test-eventdev/test_perf_queue.c b/app/test-eventdev/test_perf_queue.c
> index f4ea3a795f..5657c8b3cd 100644
> --- a/app/test-eventdev/test_perf_queue.c
> +++ b/app/test-eventdev/test_perf_queue.c
> @@ -49,6 +49,23 @@ perf_queue_worker(void *arg, const int enable_fwd_latency)
> rte_pause();
> continue;
> }
> +
> + if (prod_crypto_type &&
> + (ev.event_type == RTE_EVENT_TYPE_CRYPTODEV)) {
> + struct rte_crypto_op *op = ev.event_ptr;
> +
> + if (op->status == RTE_CRYPTO_OP_STATUS_SUCCESS) {
> + if (op->sym->m_dst == NULL)
> + ev.event_ptr = op->sym->m_src;
> + else
> + ev.event_ptr = op->sym->m_dst;
> + rte_crypto_op_free(op);
> + } else {
> + rte_crypto_op_free(op);
> + continue;
> + }
> + }
> +
> if (enable_fwd_latency && !prod_timer_type)
> /* first q in pipeline, mark timestamp to compute fwd latency */
> mark_fwd_latency(&ev, nb_stages);
> @@ -88,6 +105,25 @@ perf_queue_worker_burst(void *arg, const int enable_fwd_latency)
> }
>
> for (i = 0; i < nb_rx; i++) {
> + if (prod_crypto_type &&
> + (ev[i].event_type == RTE_EVENT_TYPE_CRYPTODEV)) {
> + struct rte_crypto_op *op = ev[i].event_ptr;
> +
> + if (op->status ==
> + RTE_CRYPTO_OP_STATUS_SUCCESS) {
> + if (op->sym->m_dst == NULL)
> + ev[i].event_ptr =
> + op->sym->m_src;
> + else
> + ev[i].event_ptr =
> + op->sym->m_dst;
> + rte_crypto_op_free(op);
> + } else {
> + rte_crypto_op_free(op);
> + continue;
> + }
> + }
> +
> if (enable_fwd_latency && !prod_timer_type) {
> rte_prefetch0(ev[i+1].event_ptr);
> /* first queue in pipeline.
> @@ -269,6 +305,20 @@ perf_queue_eventdev_setup(struct evt_test *test, struct evt_options *opt)
> return ret;
> }
> }
> + } else if (opt->prod_type == EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR) {
> + uint8_t cdev_id, cdev_count;
> +
> + cdev_count = rte_cryptodev_count();
> + for (cdev_id = 0; cdev_id < cdev_count; cdev_id++) {
> + ret = rte_cryptodev_start(cdev_id);
> + if (ret) {
> + evt_err("Failed to start cryptodev %u",
> + cdev_id);
> + return ret;
> + }
> + }
> +
> + rte_event_crypto_adapter_start(t->crypto_adptr.id);
> }
>
> return 0;
> @@ -311,11 +361,13 @@ static const struct evt_test_ops perf_queue = {
> .test_setup = perf_test_setup,
> .mempool_setup = perf_mempool_setup,
> .ethdev_setup = perf_ethdev_setup,
> + .cryptodev_setup = perf_cryptodev_setup,
> .eventdev_setup = perf_queue_eventdev_setup,
> .launch_lcores = perf_queue_launch_lcores,
> .eventdev_destroy = perf_eventdev_destroy,
> .mempool_destroy = perf_mempool_destroy,
> .ethdev_destroy = perf_ethdev_destroy,
> + .cryptodev_destroy = perf_cryptodev_destroy,
> .test_result = perf_test_result,
> .test_destroy = perf_test_destroy,
> };
> diff --git a/doc/guides/tools/testeventdev.rst b/doc/guides/tools/testeventdev.rst
> index 48efb9ea6e..f7d813226d 100644
> --- a/doc/guides/tools/testeventdev.rst
> +++ b/doc/guides/tools/testeventdev.rst
> @@ -120,6 +120,10 @@ The following are the application command-line options:
>
> Use burst mode event timer adapter as producer.
>
> +* ``--prod_type_cryptodev``
> +
> + Use crypto device as producer.
> +
> * ``--timer_tick_nsec``
>
> Used to dictate number of nano seconds between bucket traversal of the
> @@ -148,6 +152,11 @@ The following are the application command-line options:
> timeout is out of the supported range of event device it will be
> adjusted to the highest/lowest supported dequeue timeout supported.
>
> +* ``--crypto_adptr_mode``
> +
> + Set crypto adapter mode. Use 0 for OP_NEW (default) and 1 for
> + OP_FORWARD mode.
> +
> * ``--mbuf_sz``
>
> Set packet mbuf size. Can be used to configure Jumbo Frames. Only
> @@ -420,6 +429,7 @@ Supported application command line options are following::
> --prod_type_ethdev
> --prod_type_timerdev_burst
> --prod_type_timerdev
> + --prod_type_cryptodev
> --prod_enq_burst_sz
> --timer_tick_nsec
> --max_tmo_nsec
> @@ -427,6 +437,7 @@ Supported application command line options are following::
> --nb_timers
> --nb_timer_adptrs
> --deq_tmo_nsec
> + --crypto_adptr_mode
>
> Example
> ^^^^^^^
> @@ -529,12 +540,14 @@ Supported application command line options are following::
> --prod_type_ethdev
> --prod_type_timerdev_burst
> --prod_type_timerdev
> + --prod_type_cryptodev
> --timer_tick_nsec
> --max_tmo_nsec
> --expiry_nsec
> --nb_timers
> --nb_timer_adptrs
> --deq_tmo_nsec
> + --crypto_adptr_mode
>
> Example
> ^^^^^^^
> --
> 2.25.1
>
^ permalink raw reply [flat|nested] 43+ messages in thread
* RE: [PATCH v3] app/eventdev: add crypto producer mode
2022-01-21 12:25 ` Jerin Jacob
@ 2022-01-23 16:56 ` Gujjar, Abhinandan S
0 siblings, 0 replies; 43+ messages in thread
From: Gujjar, Abhinandan S @ 2022-01-23 16:56 UTC (permalink / raw)
To: Jerin Jacob, Shijith Thotton
Cc: dpdk-dev, Jerin Jacob, Anoob Joseph, Pavan Nikhilesh, Akhil Goyal
Hi Jerin,
> -----Original Message-----
> From: Jerin Jacob <jerinjacobk@gmail.com>
> Sent: Friday, January 21, 2022 5:55 PM
> To: Shijith Thotton <sthotton@marvell.com>
> Cc: dpdk-dev <dev@dpdk.org>; Jerin Jacob <jerinj@marvell.com>; Anoob
> Joseph <anoobj@marvell.com>; Pavan Nikhilesh
> <pbhagavatula@marvell.com>; Akhil Goyal <gakhil@marvell.com>; Gujjar,
> Abhinandan S <abhinandan.gujjar@intel.com>
> Subject: Re: [PATCH v3] app/eventdev: add crypto producer mode
>
> On Tue, Jan 4, 2022 at 4:04 PM Shijith Thotton <sthotton@marvell.com>
> wrote:
> >
> > In crypto producer mode, producer core enqueues cryptodev with
> > software generated crypto ops and worker core dequeues crypto
> > completion events from the eventdev. Event crypto metadata used for
> > above processing is pre-populated in each crypto session.
> >
> > Parameter --prod_type_cryptodev can be used to enable crypto producer
> > mode. Parameter --crypto_adptr_mode can be set to select the crypto
> > adapter mode, 0 for OP_NEW and 1 for OP_FORWARD.
> >
> > This mode can be used to measure the performance of crypto adapter.
> >
> > Example:
> > ./dpdk-test-eventdev -l 0-2 -w <EVENTDEV> -w <CRYPTODEV> -- \
> > --prod_type_cryptodev --crypto_adptr_mode 1 --test=perf_atq \
> > --stlist=a --wlcores 1 --plcores 2
> >
> > Signed-off-by: Shijith Thotton <sthotton@marvell.com>
> > ---
> > v3:
> > * Reduce dereference inside loop.
>
> Hi @Gujjar, Abhinandan S
>
> Do you have any comments or objections to merging this change?
I am trying to get the app working on my sandbox. I have few comments for Shijith.
@Shijith Thotton, After trying with openssl cryptodev, I tried with cryptodev_null pmd to get the app working.
It throws an error here too:
root@abhi-VirtualBox:/XDP/DPDK_GIT/dpdk-next-eventdev/abhi# ./app/dpdk-test-eventdev -l 0-2 --vdev=event_sw0 --vdev="crypto_null" -- --prod_type_cryptodev --crypto_adptr_mode 1 --test=perf_queue --stlist=a --wlcores 1 --plcores 2
EAL: Detected CPU lcores: 4
EAL: Detected NUMA nodes: 1
EAL: Detected static linkage of DPDK
EAL: Multi-process socket /var/run/dpdk/rte/mp_socket
EAL: Selected IOVA mode 'PA'
EAL: VFIO support initialized
CRYPTODEV: Creating cryptodev crypto_null
CRYPTODEV: Initialisation parameters - name: crypto_null,socket id: 0, max queue pairs: 8
TELEMETRY: No legacy callbacks, legacy socket not created
driver : event_sw
test : perf_queue
dev : 0
verbose_level : 1
socket_id : -1
pool_sz : 16384
main lcore : 0
nb_pkts : 67108864
nb_timers : 100000000
available lcores : {0 1 2}
nb_flows : 1024
worker deq depth : 16
fwd_latency : false
nb_prod_lcores : 1
producer lcores : {2}
nb_worker_lcores : 1
worker lcores : {1}
nb_stages : 1
nb_evdev_ports : 2
nb_evdev_queues : 1
queue_priority : false
sched_type_list : {A}
crypto adapter mode : OP_FORWARD
nb_cryptodev : 1
prod_type : Event crypto adapter producers
prod_enq_burst_sz : 1
CRYPTODEV: elt_size 0 is expanded to 288
error: perf_event_crypto_adapter_setup() crypto adapter OP_FORWARD mode unsupported
error: main() perf_queue: eventdev setup failed
CRYPTODEV: rte_cryptodev_stop() line 1116: Device with dev_id=0 already stopped
With --crypto_adptr_mode 0
error: perf_event_crypto_adapter_setup() crypto adapter OP_NEW mode unsupported
Could you please provide the right commands to get this running?
Meantime, I will go through the code. Thanks!
>
>
> >
> > v2:
> > * Fix RHEL compilation warning.
> >
> > app/test-eventdev/evt_common.h | 3 +
> > app/test-eventdev/evt_main.c | 13 +-
> > app/test-eventdev/evt_options.c | 27 ++
> > app/test-eventdev/evt_options.h | 12 +
> > app/test-eventdev/evt_test.h | 6 +
> > app/test-eventdev/test_perf_atq.c | 51 ++++
> > app/test-eventdev/test_perf_common.c | 410
> > ++++++++++++++++++++++++++- app/test-
> eventdev/test_perf_common.h |
> > 16 ++ app/test-eventdev/test_perf_queue.c | 52 ++++
> > doc/guides/tools/testeventdev.rst | 13 +
> > 10 files changed, 596 insertions(+), 7 deletions(-)
> >
> > diff --git a/app/test-eventdev/evt_common.h
> > b/app/test-eventdev/evt_common.h index f466434459..2f301a7e79
> 100644
> > --- a/app/test-eventdev/evt_common.h
> > +++ b/app/test-eventdev/evt_common.h
> > @@ -7,6 +7,7 @@
> >
> > #include <rte_common.h>
> > #include <rte_debug.h>
> > +#include <rte_event_crypto_adapter.h>
> > #include <rte_eventdev.h>
> > #include <rte_service.h>
> >
> > @@ -39,6 +40,7 @@ enum evt_prod_type {
> > EVT_PROD_TYPE_SYNT, /* Producer type Synthetic i.e. CPU. */
> > EVT_PROD_TYPE_ETH_RX_ADPTR, /* Producer type Eth Rx Adapter.
> */
> > EVT_PROD_TYPE_EVENT_TIMER_ADPTR, /* Producer type Timer
> > Adapter. */
> > + EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR, /* Producer type Crypto
> > + Adapter. */
> > EVT_PROD_TYPE_MAX,
> > };
> >
> > @@ -77,6 +79,7 @@ struct evt_options {
> > uint64_t timer_tick_nsec;
> > uint64_t optm_timer_tick_nsec;
> > enum evt_prod_type prod_type;
> > + enum rte_event_crypto_adapter_mode crypto_adptr_mode;
> > };
> >
> > static inline bool
> > diff --git a/app/test-eventdev/evt_main.c
> > b/app/test-eventdev/evt_main.c index 194c980c7a..cef0fb1382 100644
> > --- a/app/test-eventdev/evt_main.c
> > +++ b/app/test-eventdev/evt_main.c
> > @@ -161,12 +161,19 @@ main(int argc, char **argv)
> > goto mempool_destroy;
> > }
> > }
> > + /* Test specific cryptodev setup */
> > + if (test->ops.cryptodev_setup) {
> > + if (test->ops.cryptodev_setup(test, &opt)) {
> > + evt_err("%s: cryptodev setup failed", opt.test_name);
> > + goto ethdev_destroy;
> > + }
> > + }
> >
> > /* Test specific eventdev setup */
> > if (test->ops.eventdev_setup) {
> > if (test->ops.eventdev_setup(test, &opt)) {
> > evt_err("%s: eventdev setup failed", opt.test_name);
> > - goto ethdev_destroy;
> > + goto cryptodev_destroy;
> > }
> > }
> >
> > @@ -197,6 +204,10 @@ main(int argc, char **argv)
> > if (test->ops.eventdev_destroy)
> > test->ops.eventdev_destroy(test, &opt);
> >
> > +cryptodev_destroy:
> > + if (test->ops.cryptodev_destroy)
> > + test->ops.cryptodev_destroy(test, &opt);
> > +
> > ethdev_destroy:
> > if (test->ops.ethdev_destroy)
> > test->ops.ethdev_destroy(test, &opt); diff --git
> > a/app/test-eventdev/evt_options.c b/app/test-eventdev/evt_options.c
> > index 753a7dbd7d..5ad1491020 100644
> > --- a/app/test-eventdev/evt_options.c
> > +++ b/app/test-eventdev/evt_options.c
> > @@ -122,6 +122,26 @@ evt_parse_timer_prod_type_burst(struct
> evt_options *opt,
> > return 0;
> > }
> >
> > +static int
> > +evt_parse_crypto_prod_type(struct evt_options *opt,
> > + const char *arg __rte_unused) {
> > + opt->prod_type = EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR;
> > + return 0;
> > +}
> > +
> > +static int
> > +evt_parse_crypto_adptr_mode(struct evt_options *opt, const char *arg)
> > +{
> > + uint8_t mode;
> > + int ret;
> > +
> > + ret = parser_read_uint8(&mode, arg);
> > + opt->crypto_adptr_mode = mode ?
> RTE_EVENT_CRYPTO_ADAPTER_OP_FORWARD :
> > + RTE_EVENT_CRYPTO_ADAPTER_OP_NEW;
> > + return ret;
> > +}
> > +
> > static int
> > evt_parse_test_name(struct evt_options *opt, const char *arg) { @@
> > -335,6 +355,7 @@ usage(char *program)
> > "\t--queue_priority : enable queue priority\n"
> > "\t--deq_tmo_nsec : global dequeue timeout\n"
> > "\t--prod_type_ethdev : use ethernet device as producer.\n"
> > + "\t--prod_type_cryptodev : use crypto device as producer.\n"
> > "\t--prod_type_timerdev : use event timer device as producer.\n"
> > "\t expity_nsec would be the timeout\n"
> > "\t in ns.\n"
> > @@ -345,6 +366,8 @@ usage(char *program)
> > "\t--timer_tick_nsec : timer tick interval in ns.\n"
> > "\t--max_tmo_nsec : max timeout interval in ns.\n"
> > "\t--expiry_nsec : event timer expiry ns.\n"
> > + "\t--crypto_adptr_mode : 0 for OP_NEW mode (default) and\n"
> > + "\t 1 for OP_FORWARD mode.\n"
> > "\t--mbuf_sz : packet mbuf size.\n"
> > "\t--max_pkt_sz : max packet size.\n"
> > "\t--prod_enq_burst_sz : producer enqueue burst size.\n"
> > @@ -415,8 +438,10 @@ static struct option lgopts[] = {
> > { EVT_QUEUE_PRIORITY, 0, 0, 0 },
> > { EVT_DEQ_TMO_NSEC, 1, 0, 0 },
> > { EVT_PROD_ETHDEV, 0, 0, 0 },
> > + { EVT_PROD_CRYPTODEV, 0, 0, 0 },
> > { EVT_PROD_TIMERDEV, 0, 0, 0 },
> > { EVT_PROD_TIMERDEV_BURST, 0, 0, 0 },
> > + { EVT_CRYPTO_ADPTR_MODE, 1, 0, 0 },
> > { EVT_NB_TIMERS, 1, 0, 0 },
> > { EVT_NB_TIMER_ADPTRS, 1, 0, 0 },
> > { EVT_TIMER_TICK_NSEC, 1, 0, 0 },
> > @@ -455,8 +480,10 @@ evt_opts_parse_long(int opt_idx, struct
> evt_options *opt)
> > { EVT_QUEUE_PRIORITY, evt_parse_queue_priority},
> > { EVT_DEQ_TMO_NSEC, evt_parse_deq_tmo_nsec},
> > { EVT_PROD_ETHDEV, evt_parse_eth_prod_type},
> > + { EVT_PROD_CRYPTODEV, evt_parse_crypto_prod_type},
> > { EVT_PROD_TIMERDEV, evt_parse_timer_prod_type},
> > { EVT_PROD_TIMERDEV_BURST,
> > evt_parse_timer_prod_type_burst},
> > + { EVT_CRYPTO_ADPTR_MODE, evt_parse_crypto_adptr_mode},
> > { EVT_NB_TIMERS, evt_parse_nb_timers},
> > { EVT_NB_TIMER_ADPTRS, evt_parse_nb_timer_adptrs},
> > { EVT_TIMER_TICK_NSEC, evt_parse_timer_tick_nsec},
> > diff --git a/app/test-eventdev/evt_options.h
> > b/app/test-eventdev/evt_options.h index 413d7092f0..2231c58801 100644
> > --- a/app/test-eventdev/evt_options.h
> > +++ b/app/test-eventdev/evt_options.h
> > @@ -9,6 +9,7 @@
> > #include <stdbool.h>
> >
> > #include <rte_common.h>
> > +#include <rte_cryptodev.h>
> > #include <rte_ethdev.h>
> > #include <rte_eventdev.h>
> > #include <rte_lcore.h>
> > @@ -33,8 +34,10 @@
> > #define EVT_QUEUE_PRIORITY ("queue_priority")
> > #define EVT_DEQ_TMO_NSEC ("deq_tmo_nsec")
> > #define EVT_PROD_ETHDEV ("prod_type_ethdev")
> > +#define EVT_PROD_CRYPTODEV ("prod_type_cryptodev")
> > #define EVT_PROD_TIMERDEV ("prod_type_timerdev")
> > #define EVT_PROD_TIMERDEV_BURST ("prod_type_timerdev_burst")
> > +#define EVT_CRYPTO_ADPTR_MODE ("crypto_adptr_mode")
> > #define EVT_NB_TIMERS ("nb_timers")
> > #define EVT_NB_TIMER_ADPTRS ("nb_timer_adptrs")
> > #define EVT_TIMER_TICK_NSEC ("timer_tick_nsec")
> > @@ -249,6 +252,8 @@ evt_prod_id_to_name(enum evt_prod_type
> prod_type)
> > return "Ethdev Rx Adapter";
> > case EVT_PROD_TYPE_EVENT_TIMER_ADPTR:
> > return "Event timer adapter";
> > + case EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR:
> > + return "Event crypto adapter";
> > }
> >
> > return "";
> > @@ -288,6 +293,13 @@ evt_dump_producer_type(struct evt_options
> *opt)
> > evt_dump("timer_tick_nsec", "%"PRIu64"",
> > opt->timer_tick_nsec);
> > break;
> > + case EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR:
> > + snprintf(name, EVT_PROD_MAX_NAME_LEN,
> > + "Event crypto adapter producers");
> > + evt_dump("crypto adapter mode", "%s",
> > + opt->crypto_adptr_mode ? "OP_FORWARD" : "OP_NEW");
> > + evt_dump("nb_cryptodev", "%u", rte_cryptodev_count());
> > + break;
> > }
> > evt_dump("prod_type", "%s", name); } diff --git
> > a/app/test-eventdev/evt_test.h b/app/test-eventdev/evt_test.h index
> > f07d2c3336..50fa474ec2 100644
> > --- a/app/test-eventdev/evt_test.h
> > +++ b/app/test-eventdev/evt_test.h
> > @@ -29,6 +29,8 @@ typedef int (*evt_test_mempool_setup_t)
> > (struct evt_test *test, struct evt_options *opt);
> > typedef int (*evt_test_ethdev_setup_t)
> > (struct evt_test *test, struct evt_options *opt);
> > +typedef int (*evt_test_cryptodev_setup_t)
> > + (struct evt_test *test, struct evt_options *opt);
> > typedef int (*evt_test_eventdev_setup_t)
> > (struct evt_test *test, struct evt_options *opt);
> > typedef int (*evt_test_launch_lcores_t) @@ -39,6 +41,8 @@ typedef void
> > (*evt_test_eventdev_destroy_t)
> > (struct evt_test *test, struct evt_options *opt);
> > typedef void (*evt_test_ethdev_destroy_t)
> > (struct evt_test *test, struct evt_options *opt);
> > +typedef void (*evt_test_cryptodev_destroy_t)
> > + (struct evt_test *test, struct evt_options *opt);
> > typedef void (*evt_test_mempool_destroy_t)
> > (struct evt_test *test, struct evt_options *opt);
> > typedef void (*evt_test_destroy_t) @@ -52,10 +56,12 @@ struct
> > evt_test_ops {
> > evt_test_mempool_setup_t mempool_setup;
> > evt_test_ethdev_setup_t ethdev_setup;
> > evt_test_eventdev_setup_t eventdev_setup;
> > + evt_test_cryptodev_setup_t cryptodev_setup;
> > evt_test_launch_lcores_t launch_lcores;
> > evt_test_result_t test_result;
> > evt_test_eventdev_destroy_t eventdev_destroy;
> > evt_test_ethdev_destroy_t ethdev_destroy;
> > + evt_test_cryptodev_destroy_t cryptodev_destroy;
> > evt_test_mempool_destroy_t mempool_destroy;
> > evt_test_destroy_t test_destroy; }; diff --git
> > a/app/test-eventdev/test_perf_atq.c
> > b/app/test-eventdev/test_perf_atq.c
> > index 8fd51004ee..dbb1dc8c0c 100644
> > --- a/app/test-eventdev/test_perf_atq.c
> > +++ b/app/test-eventdev/test_perf_atq.c
> > @@ -48,6 +48,22 @@ perf_atq_worker(void *arg, const int
> enable_fwd_latency)
> > continue;
> > }
> >
> > + if (prod_crypto_type &&
> > + (ev.event_type == RTE_EVENT_TYPE_CRYPTODEV)) {
> > + struct rte_crypto_op *op = ev.event_ptr;
> > +
> > + if (op->status == RTE_CRYPTO_OP_STATUS_SUCCESS) {
> > + if (op->sym->m_dst == NULL)
> > + ev.event_ptr = op->sym->m_src;
> > + else
> > + ev.event_ptr = op->sym->m_dst;
> > + rte_crypto_op_free(op);
> > + } else {
> > + rte_crypto_op_free(op);
> > + continue;
> > + }
> > + }
> > +
> > if (enable_fwd_latency && !prod_timer_type)
> > /* first stage in pipeline, mark ts to compute fwd latency */
> > atq_mark_fwd_latency(&ev); @@ -87,6 +103,25 @@
> > perf_atq_worker_burst(void *arg, const int enable_fwd_latency)
> > }
> >
> > for (i = 0; i < nb_rx; i++) {
> > + if (prod_crypto_type &&
> > + (ev[i].event_type == RTE_EVENT_TYPE_CRYPTODEV)) {
> > + struct rte_crypto_op *op =
> > + ev[i].event_ptr;
> > +
> > + if (op->status ==
> > + RTE_CRYPTO_OP_STATUS_SUCCESS) {
> > + if (op->sym->m_dst == NULL)
> > + ev[i].event_ptr =
> > + op->sym->m_src;
> > + else
> > + ev[i].event_ptr =
> > + op->sym->m_dst;
> > + rte_crypto_op_free(op);
> > + } else {
> > + rte_crypto_op_free(op);
> > + continue;
> > + }
> > + }
> > +
> > if (enable_fwd_latency && !prod_timer_type) {
> > rte_prefetch0(ev[i+1].event_ptr);
> > /* first stage in pipeline.
> > @@ -254,6 +289,20 @@ perf_atq_eventdev_setup(struct evt_test *test,
> struct evt_options *opt)
> > return ret;
> > }
> > }
> > + } else if (opt->prod_type ==
> EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR) {
> > + uint8_t cdev_id, cdev_count;
> > +
> > + cdev_count = rte_cryptodev_count();
> > + for (cdev_id = 0; cdev_id < cdev_count; cdev_id++) {
> > + ret = rte_cryptodev_start(cdev_id);
> > + if (ret) {
> > + evt_err("Failed to start cryptodev %u",
> > + cdev_id);
> > + return ret;
> > + }
> > + }
> > +
> > + rte_event_crypto_adapter_start(t->crypto_adptr.id);
> > }
> >
> > return 0;
> > @@ -295,12 +344,14 @@ static const struct evt_test_ops perf_atq = {
> > .opt_dump = perf_atq_opt_dump,
> > .test_setup = perf_test_setup,
> > .ethdev_setup = perf_ethdev_setup,
> > + .cryptodev_setup = perf_cryptodev_setup,
> > .mempool_setup = perf_mempool_setup,
> > .eventdev_setup = perf_atq_eventdev_setup,
> > .launch_lcores = perf_atq_launch_lcores,
> > .eventdev_destroy = perf_eventdev_destroy,
> > .mempool_destroy = perf_mempool_destroy,
> > .ethdev_destroy = perf_ethdev_destroy,
> > + .cryptodev_destroy = perf_cryptodev_destroy,
> > .test_result = perf_test_result,
> > .test_destroy = perf_test_destroy,
> > };
> > diff --git a/app/test-eventdev/test_perf_common.c
> > b/app/test-eventdev/test_perf_common.c
> > index 9b73874151..91cb6748ee 100644
> > --- a/app/test-eventdev/test_perf_common.c
> > +++ b/app/test-eventdev/test_perf_common.c
> > @@ -6,6 +6,8 @@
> >
> > #include "test_perf_common.h"
> >
> > +#define NB_CRYPTODEV_DESCRIPTORS 128
> > +
> > int
> > perf_test_result(struct evt_test *test, struct evt_options *opt) {
> > @@ -272,6 +274,125 @@ perf_event_timer_producer_burst(void *arg)
> > return 0;
> > }
> >
> > +static inline void
> > +crypto_adapter_enq_op_new(struct prod_data *p) {
> > + struct rte_cryptodev_sym_session **crypto_sess = p->crypto_sess;
> > + struct test_perf *t = p->t;
> > + const uint32_t nb_flows = t->nb_flows;
> > + const uint64_t nb_pkts = t->nb_pkts;
> > + struct rte_mempool *pool = t->pool;
> > + struct rte_crypto_sym_op *sym_op;
> > + struct evt_options *opt = t->opt;
> > + uint16_t qp_id = p->cdev_qp_id;
> > + uint8_t cdev_id = p->cdev_id;
> > + uint32_t flow_counter = 0;
> > + struct rte_crypto_op *op;
> > + struct rte_mbuf *m;
> > + uint64_t count = 0;
> > + uint16_t len;
> > +
> > + if (opt->verbose_level > 1)
> > + printf("%s(): lcore %d queue %d cdev_id %u cdev_qp_id %u\n",
> > + __func__, rte_lcore_id(), p->queue_id, p->cdev_id,
> > + p->cdev_qp_id);
> > +
> > + len = opt->mbuf_sz ? opt->mbuf_sz : RTE_ETHER_MIN_LEN;
> > +
> > + while (count < nb_pkts && t->done == false) {
> > + m = rte_pktmbuf_alloc(pool);
> > + if (m == NULL)
> > + continue;
> > +
> > + rte_pktmbuf_append(m, len);
> > + op = rte_crypto_op_alloc(t->crypto_adptr.op_pool,
> > + RTE_CRYPTO_OP_TYPE_SYMMETRIC);
> > + sym_op = op->sym;
> > + sym_op->m_src = m;
> > + sym_op->cipher.data.offset = 0;
> > + sym_op->cipher.data.length = len;
> > + rte_crypto_op_attach_sym_session(
> > + op, crypto_sess[flow_counter++ % nb_flows]);
> > + while (rte_cryptodev_enqueue_burst(cdev_id, qp_id, &op, 1) !=
> > + 1) {
> > + if (t->done)
> > + break;
> > + rte_pause();
> > + }
> > + count++;
> > + }
> > +}
> > +
> > +static inline void
> > +crypto_adapter_enq_op_fwd(struct prod_data *p) {
> > + struct rte_cryptodev_sym_session **crypto_sess = p->crypto_sess;
> > + const uint8_t dev_id = p->dev_id;
> > + const uint8_t port = p->port_id;
> > + struct test_perf *t = p->t;
> > + const uint32_t nb_flows = t->nb_flows;
> > + const uint64_t nb_pkts = t->nb_pkts;
> > + struct rte_mempool *pool = t->pool;
> > + struct evt_options *opt = t->opt;
> > + struct rte_crypto_sym_op *sym_op;
> > + uint32_t flow_counter = 0;
> > + struct rte_crypto_op *op;
> > + struct rte_event ev;
> > + struct rte_mbuf *m;
> > + uint64_t count = 0;
> > + uint16_t len;
> > +
> > + if (opt->verbose_level > 1)
> > + printf("%s(): lcore %d port %d queue %d cdev_id %u cdev_qp_id
> %u\n",
> > + __func__, rte_lcore_id(), port, p->queue_id, p->cdev_id,
> > + p->cdev_qp_id);
> > +
> > + ev.event = 0;
> > + ev.op = RTE_EVENT_OP_NEW;
> > + ev.queue_id = p->queue_id;
> > + ev.sched_type = RTE_SCHED_TYPE_ATOMIC;
> > + ev.event_type = RTE_EVENT_TYPE_CPU;
> > + len = opt->mbuf_sz ? opt->mbuf_sz : RTE_ETHER_MIN_LEN;
> > +
> > + while (count < nb_pkts && t->done == false) {
> > + m = rte_pktmbuf_alloc(pool);
> > + if (m == NULL)
> > + continue;
> > +
> > + rte_pktmbuf_append(m, len);
> > + op = rte_crypto_op_alloc(t->crypto_adptr.op_pool,
> > + RTE_CRYPTO_OP_TYPE_SYMMETRIC);
> > + sym_op = op->sym;
> > + sym_op->m_src = m;
> > + sym_op->cipher.data.offset = 0;
> > + sym_op->cipher.data.length = len;
> > + rte_crypto_op_attach_sym_session(
> > + op, crypto_sess[flow_counter++ % nb_flows]);
> > + ev.event_ptr = op;
> > + while (rte_event_crypto_adapter_enqueue(dev_id, port, &ev, 1)
> !=
> > + 1) {
> > + if (t->done)
> > + break;
> > + rte_pause();
> > + }
> > + count++;
> > + }
> > +}
> > +
> > +static inline int
> > +perf_event_crypto_producer(void *arg) {
> > + struct prod_data *p = arg;
> > + struct evt_options *opt = p->t->opt;
> > +
> > + if (opt->crypto_adptr_mode ==
> RTE_EVENT_CRYPTO_ADAPTER_OP_NEW)
> > + crypto_adapter_enq_op_new(p);
> > + else
> > + crypto_adapter_enq_op_fwd(p);
> > +
> > + return 0;
> > +}
> > +
> > static int
> > perf_producer_wrapper(void *arg)
> > {
> > @@ -298,6 +419,8 @@ perf_producer_wrapper(void *arg)
> > else if (t->opt->prod_type == EVT_PROD_TYPE_EVENT_TIMER_ADPTR
> &&
> > t->opt->timdev_use_burst)
> > return perf_event_timer_producer_burst(arg);
> > + else if (t->opt->prod_type ==
> EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR)
> > + return perf_event_crypto_producer(arg);
> > return 0;
> > }
> >
> > @@ -405,8 +528,10 @@ perf_launch_lcores(struct evt_test *test, struct
> evt_options *opt,
> > if (remaining <= 0) {
> > t->result = EVT_TEST_SUCCESS;
> > if (opt->prod_type == EVT_PROD_TYPE_SYNT ||
> > - opt->prod_type ==
> > - EVT_PROD_TYPE_EVENT_TIMER_ADPTR) {
> > + opt->prod_type ==
> > + EVT_PROD_TYPE_EVENT_TIMER_ADPTR ||
> > + opt->prod_type ==
> > +
> > + EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR) {
> > t->done = true;
> > break;
> > }
> > @@ -415,7 +540,8 @@ perf_launch_lcores(struct evt_test *test, struct
> > evt_options *opt,
> >
> > if (new_cycles - dead_lock_cycles > dead_lock_sample &&
> > (opt->prod_type == EVT_PROD_TYPE_SYNT ||
> > - opt->prod_type == EVT_PROD_TYPE_EVENT_TIMER_ADPTR)) {
> > + opt->prod_type == EVT_PROD_TYPE_EVENT_TIMER_ADPTR ||
> > + opt->prod_type ==
> > + EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR)) {
> > remaining = t->outstand_pkts - processed_pkts(t);
> > if (dead_lock_remaining == remaining) {
> > rte_event_dev_dump(opt->dev_id,
> > stdout); @@ -537,6 +663,96 @@ perf_event_timer_adapter_setup(struct
> test_perf *t)
> > return 0;
> > }
> >
> > +static int
> > +perf_event_crypto_adapter_setup(struct test_perf *t,
> > + struct rte_event_port_conf port_conf)
> > +{
> > + struct evt_options *opt = t->opt;
> > + uint8_t cdev_id, cdev_count;
> > + int ret;
> > +
> > + t->crypto_adptr.id = 0;
> > + ret = rte_event_crypto_adapter_create(t->crypto_adptr.id, opt-
> >dev_id,
> > + &port_conf, 0);
> > + if (ret)
> > + return ret;
> > +
> > + cdev_count = rte_cryptodev_count();
> > + for (cdev_id = 0; cdev_id < cdev_count; cdev_id++) {
> > + uint32_t cap;
> > +
> > + ret = rte_event_crypto_adapter_caps_get(opt->dev_id, cdev_id,
> > + &cap);
> > + if (ret) {
> > + evt_err("Failed to get crypto adapter capabilities");
> > + return ret;
> > + }
> > +
> > + if (((opt->crypto_adptr_mode ==
> > + RTE_EVENT_CRYPTO_ADAPTER_OP_NEW) &&
> > + !(cap &
> > +
> RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_OP_NEW)) ||
> > + ((opt->crypto_adptr_mode ==
> > + RTE_EVENT_CRYPTO_ADAPTER_OP_FORWARD) &&
> > + !(cap &
> > +
> RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_OP_FWD))) {
> > + evt_err("crypto adapter %s mode unsupported\n",
> > + opt->crypto_adptr_mode ? "OP_FORWARD" :
> > + "OP_NEW");
> > + return -EINVAL;
> > + }
> > +
> > + if (!(cap &
> > +
> RTE_EVENT_CRYPTO_ADAPTER_CAP_SESSION_PRIVATE_DATA)) {
> > + evt_err("Storing crypto session not supported");
> > + return -EINVAL;
> > + }
> > +
> > + if (cap &
> > +
> RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_QP_EV_BIND) {
> > + struct rte_event response_info;
> > +
> > + response_info.event = 0;
> > + ret = rte_event_crypto_adapter_queue_pair_add(
> > + t->crypto_adptr.id, cdev_id, -1,
> > + &response_info);
> > + } else {
> > + ret = rte_event_crypto_adapter_queue_pair_add(
> > + t->crypto_adptr.id, cdev_id, -1, NULL);
> > + }
> > + if (ret)
> > + return ret;
> > + }
> > +
> > + return 0;
> > +}
> > +
> > +static struct rte_cryptodev_sym_session *
> > +cryptodev_sym_sess_create(struct prod_data *p, struct test_perf *t) {
> > + struct rte_crypto_sym_xform cipher_xform;
> > + struct rte_cryptodev_sym_session *sess;
> > +
> > + cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
> > + cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
> > + cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
> > + cipher_xform.next = NULL;
> > +
> > + sess = rte_cryptodev_sym_session_create(t-
> >crypto_adptr.sess_pool);
> > + if (sess == NULL) {
> > + evt_err("Failed to create sym session");
> > + return NULL;
> > + }
> > +
> > + if (rte_cryptodev_sym_session_init(p->cdev_id, sess, &cipher_xform,
> > + t->crypto_adptr.sess_priv_pool)) {
> > + evt_err("Failed to init session");
> > + return NULL;
> > + }
> > +
> > + return sess;
> > +}
> > +
> > int
> > perf_event_dev_port_setup(struct evt_test *test, struct evt_options
> *opt,
> > uint8_t stride, uint8_t nb_queues, @@
> > -598,6 +814,55 @@ perf_event_dev_port_setup(struct evt_test *test,
> struct evt_options *opt,
> > ret = perf_event_timer_adapter_setup(t);
> > if (ret)
> > return ret;
> > + } else if (opt->prod_type ==
> EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR) {
> > + uint8_t cdev_id = 0;
> > + uint16_t qp_id = 0;
> > +
> > + prod = 0;
> > + for (; port < perf_nb_event_ports(opt); port++) {
> > + struct rte_cryptodev_sym_session *crypto_sess;
> > + union rte_event_crypto_metadata m_data;
> > + struct prod_data *p = &t->prod[port];
> > + uint32_t flow_id;
> > +
> > + if (qp_id == rte_cryptodev_queue_pair_count(cdev_id)) {
> > + cdev_id++;
> > + qp_id = 0;
> > + }
> > +
> > + p->dev_id = opt->dev_id;
> > + p->port_id = port;
> > + p->queue_id = prod * stride;
> > + p->cdev_id = cdev_id;
> > + p->cdev_qp_id = qp_id;
> > + p->crypto_sess = rte_zmalloc_socket(
> > + NULL, sizeof(crypto_sess) * t->nb_flows,
> > + RTE_CACHE_LINE_SIZE, opt->socket_id);
> > +
> > + m_data.request_info.cdev_id = p->cdev_id;
> > + m_data.request_info.queue_pair_id = p->cdev_qp_id;
> > + m_data.response_info.op = RTE_EVENT_OP_NEW;
> > + m_data.response_info.sched_type =
> RTE_SCHED_TYPE_ATOMIC;
> > + m_data.response_info.event_type = RTE_EVENT_TYPE_CPU;
> > + m_data.response_info.queue_id = p->queue_id;
> > + for (flow_id = 0; flow_id < t->nb_flows; flow_id++) {
> > + crypto_sess = cryptodev_sym_sess_create(p, t);
> > + if (crypto_sess == NULL)
> > + return -ENOMEM;
> > +
> > + m_data.response_info.flow_id = flow_id;
> > + rte_cryptodev_sym_session_set_user_data(
> > + crypto_sess, &m_data, sizeof(m_data));
> > + p->crypto_sess[flow_id] = crypto_sess;
> > + }
> > + p->t = t;
> > + qp_id++;
> > + prod++;
> > + }
> > +
> > + ret = perf_event_crypto_adapter_setup(t, *port_conf);
> > + if (ret)
> > + return ret;
> > } else {
> > prod = 0;
> > for ( ; port < perf_nb_event_ports(opt); port++) { @@
> > -659,7 +924,8 @@ perf_opt_check(struct evt_options *opt, uint64_t
> nb_queues)
> > }
> >
> > if (opt->prod_type == EVT_PROD_TYPE_SYNT ||
> > - opt->prod_type == EVT_PROD_TYPE_EVENT_TIMER_ADPTR) {
> > + opt->prod_type == EVT_PROD_TYPE_EVENT_TIMER_ADPTR ||
> > + opt->prod_type == EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR) {
> > /* Validate producer lcores */
> > if (evt_lcores_has_overlap(opt->plcores,
> > rte_get_main_lcore())) { @@
> > -767,8 +1033,7 @@ perf_ethdev_setup(struct evt_test *test, struct
> evt_options *opt)
> > },
> > };
> >
> > - if (opt->prod_type == EVT_PROD_TYPE_SYNT ||
> > - opt->prod_type == EVT_PROD_TYPE_EVENT_TIMER_ADPTR)
> > + if (opt->prod_type != EVT_PROD_TYPE_ETH_RX_ADPTR)
> > return 0;
> >
> > if (!rte_eth_dev_count_avail()) { @@ -841,6 +1106,139 @@ void
> > perf_ethdev_destroy(struct evt_test *test, struct evt_options *opt)
> > }
> > }
> >
> > +int
> > +perf_cryptodev_setup(struct evt_test *test, struct evt_options *opt)
> > +{
> > + uint8_t cdev_count, cdev_id, nb_plcores, nb_qps;
> > + struct test_perf *t = evt_test_priv(test);
> > + unsigned int max_session_size;
> > + uint32_t nb_sessions;
> > + int ret;
> > +
> > + if (opt->prod_type != EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR)
> > + return 0;
> > +
> > + cdev_count = rte_cryptodev_count();
> > + if (cdev_count == 0) {
> > + evt_err("No crypto devices available\n");
> > + return -ENODEV;
> > + }
> > +
> > + t->crypto_adptr.op_pool = rte_crypto_op_pool_create(
> > + "crypto_op_pool", RTE_CRYPTO_OP_TYPE_SYMMETRIC, opt-
> >pool_sz,
> > + 128, 0, rte_socket_id());
> > + if (t->crypto_adptr.op_pool == NULL) {
> > + evt_err("Failed to create crypto op pool");
> > + return -ENOMEM;
> > + }
> > +
> > + nb_sessions = evt_nr_active_lcores(opt->plcores) * t->nb_flows;
> > + t->crypto_adptr.sess_pool =
> rte_cryptodev_sym_session_pool_create(
> > + "ca_sess_pool", nb_sessions, 0, 0,
> > + sizeof(union rte_event_crypto_metadata), SOCKET_ID_ANY);
> > + if (t->crypto_adptr.sess_pool == NULL) {
> > + evt_err("Failed to create sym session pool");
> > + ret = -ENOMEM;
> > + goto err;
> > + }
> > +
> > + max_session_size = 0;
> > + for (cdev_id = 0; cdev_id < cdev_count; cdev_id++) {
> > + unsigned int session_size;
> > +
> > + session_size =
> > + rte_cryptodev_sym_get_private_session_size(cdev_id);
> > + if (session_size > max_session_size)
> > + max_session_size = session_size;
> > + }
> > + max_session_size += sizeof(union rte_event_crypto_metadata);
> > + t->crypto_adptr.sess_priv_pool = rte_mempool_create(
> > + "ca_sess_priv_pool", nb_sessions, max_session_size, 0, 0, NULL,
> > + NULL, NULL, NULL, SOCKET_ID_ANY, 0);
> > + if (t->crypto_adptr.sess_priv_pool == NULL) {
> > + evt_err("failed to create sym session private pool");
> > + ret = -ENOMEM;
> > + goto err;
> > + }
> > +
> > + nb_plcores = evt_nr_active_lcores(opt->plcores);
> > + nb_qps = (nb_plcores % cdev_count) ? (nb_plcores / cdev_count) + 1 :
> > + nb_plcores / cdev_count;
> > + for (cdev_id = 0; cdev_id < cdev_count; cdev_id++) {
> > + struct rte_cryptodev_qp_conf qp_conf;
> > + struct rte_cryptodev_config conf;
> > + struct rte_cryptodev_info info;
> > + int qp_id;
> > +
> > + rte_cryptodev_info_get(cdev_id, &info);
> > + if (nb_qps > info.max_nb_queue_pairs) {
> > + evt_err("Not enough queue pairs per cryptodev (%u)",
> > + nb_qps);
> > + ret = -EINVAL;
> > + goto err;
> > + }
> > +
> > + conf.nb_queue_pairs = nb_qps;
> > + conf.socket_id = SOCKET_ID_ANY;
> > + conf.ff_disable = RTE_CRYPTODEV_FF_SECURITY;
> > +
> > + ret = rte_cryptodev_configure(cdev_id, &conf);
> > + if (ret) {
> > + evt_err("Failed to configure cryptodev (%u)", cdev_id);
> > + goto err;
> > + }
> > +
> > + qp_conf.nb_descriptors = NB_CRYPTODEV_DESCRIPTORS;
> > + qp_conf.mp_session = t->crypto_adptr.sess_pool;
> > + qp_conf.mp_session_private =
> > + t->crypto_adptr.sess_priv_pool;
> > +
> > + for (qp_id = 0; qp_id < conf.nb_queue_pairs; qp_id++) {
> > + ret = rte_cryptodev_queue_pair_setup(
> > + cdev_id, qp_id, &qp_conf,
> > + rte_cryptodev_socket_id(cdev_id));
> > + if (ret) {
> > + evt_err("Failed to setup queue pairs on cryptodev %u\n",
> > + cdev_id);
> > + goto err;
> > + }
> > + }
> > + }
> > +
> > + return 0;
> > +err:
> > + rte_mempool_free(t->crypto_adptr.op_pool);
> > + rte_mempool_free(t->crypto_adptr.sess_pool);
> > + rte_mempool_free(t->crypto_adptr.sess_priv_pool);
> > +
> > + return ret;
> > +}
> > +
> > +void
> > +perf_cryptodev_destroy(struct evt_test *test, struct evt_options
> > +*opt) {
> > + uint8_t cdev_id, cdev_count = rte_cryptodev_count();
> > + struct test_perf *t = evt_test_priv(test);
> > +
> > + RTE_SET_USED(opt);
> > +
> > + if (opt->prod_type != EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR)
> > + return;
> > +
> > + rte_event_crypto_adapter_stop(t->crypto_adptr.id);
> > +
> > + for (cdev_id = 0; cdev_id < cdev_count; cdev_id++) {
> > + rte_cryptodev_stop(cdev_id);
> > + rte_event_crypto_adapter_queue_pair_del(t->crypto_adptr.id,
> > + cdev_id, -1);
> > + }
> > +
> > + rte_event_crypto_adapter_free(t->crypto_adptr.id);
> > +
> > + rte_mempool_free(t->crypto_adptr.op_pool);
> > + rte_mempool_free(t->crypto_adptr.sess_pool);
> > + rte_mempool_free(t->crypto_adptr.sess_priv_pool);
> > +}
> > +
> > int
> > perf_mempool_setup(struct evt_test *test, struct evt_options *opt) {
> > diff --git a/app/test-eventdev/test_perf_common.h
> > b/app/test-eventdev/test_perf_common.h
> > index 14dcf80429..d9ad3a0b0d 100644
> > --- a/app/test-eventdev/test_perf_common.h
> > +++ b/app/test-eventdev/test_perf_common.h
> > @@ -9,9 +9,11 @@
> > #include <stdbool.h>
> > #include <unistd.h>
> >
> > +#include <rte_cryptodev.h>
> > #include <rte_cycles.h>
> > #include <rte_ethdev.h>
> > #include <rte_eventdev.h>
> > +#include <rte_event_crypto_adapter.h>
> > #include <rte_event_eth_rx_adapter.h> #include
> > <rte_event_timer_adapter.h> #include <rte_lcore.h> @@ -37,9 +39,18
> @@
> > struct prod_data {
> > uint8_t dev_id;
> > uint8_t port_id;
> > uint8_t queue_id;
> > + uint8_t cdev_id;
> > + uint16_t cdev_qp_id;
> > + struct rte_cryptodev_sym_session **crypto_sess;
> > struct test_perf *t;
> > } __rte_cache_aligned;
> >
> > +struct crypto_adptr_data {
> > + uint8_t id;
> > + struct rte_mempool *op_pool;
> > + struct rte_mempool *sess_pool;
> > + struct rte_mempool *sess_priv_pool; };
> >
> > struct test_perf {
> > /* Don't change the offset of "done". Signal handler use this
> > memory @@ -58,6 +69,7 @@ struct test_perf {
> > uint8_t sched_type_list[EVT_MAX_STAGES] __rte_cache_aligned;
> > struct rte_event_timer_adapter *timer_adptr[
> > RTE_EVENT_TIMER_ADAPTER_NUM_MAX] __rte_cache_aligned;
> > + struct crypto_adptr_data crypto_adptr;
> > } __rte_cache_aligned;
> >
> > struct perf_elt {
> > @@ -81,6 +93,8 @@ struct perf_elt {
> > const uint8_t port = w->port_id;\
> > const uint8_t prod_timer_type = \
> > opt->prod_type == EVT_PROD_TYPE_EVENT_TIMER_ADPTR;\
> > + const uint8_t prod_crypto_type = \
> > + opt->prod_type == EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR;\
> > uint8_t *const sched_type_list = &t->sched_type_list[0];\
> > struct rte_mempool *const pool = t->pool;\
> > const uint8_t nb_stages = t->opt->nb_stages;\ @@ -154,6 +168,7
> > @@ int perf_test_result(struct evt_test *test, struct evt_options
> > *opt); int perf_opt_check(struct evt_options *opt, uint64_t
> > nb_queues); int perf_test_setup(struct evt_test *test, struct
> > evt_options *opt); int perf_ethdev_setup(struct evt_test *test,
> > struct evt_options *opt);
> > +int perf_cryptodev_setup(struct evt_test *test, struct evt_options
> > +*opt);
> > int perf_mempool_setup(struct evt_test *test, struct evt_options
> > *opt); int perf_event_dev_port_setup(struct evt_test *test, struct
> evt_options *opt,
> > uint8_t stride, uint8_t nb_queues, @@
> > -164,6 +179,7 @@ int perf_launch_lcores(struct evt_test *test, struct
> > evt_options *opt, void perf_opt_dump(struct evt_options *opt, uint8_t
> > nb_queues); void perf_test_destroy(struct evt_test *test, struct
> > evt_options *opt); void perf_eventdev_destroy(struct evt_test *test,
> > struct evt_options *opt);
> > +void perf_cryptodev_destroy(struct evt_test *test, struct evt_options
> > +*opt);
> > void perf_ethdev_destroy(struct evt_test *test, struct evt_options
> > *opt); void perf_mempool_destroy(struct evt_test *test, struct
> > evt_options *opt);
> >
> > diff --git a/app/test-eventdev/test_perf_queue.c
> > b/app/test-eventdev/test_perf_queue.c
> > index f4ea3a795f..5657c8b3cd 100644
> > --- a/app/test-eventdev/test_perf_queue.c
> > +++ b/app/test-eventdev/test_perf_queue.c
> > @@ -49,6 +49,23 @@ perf_queue_worker(void *arg, const int
> enable_fwd_latency)
> > rte_pause();
> > continue;
> > }
> > +
> > + if (prod_crypto_type &&
> > + (ev.event_type == RTE_EVENT_TYPE_CRYPTODEV)) {
> > + struct rte_crypto_op *op = ev.event_ptr;
> > +
> > + if (op->status == RTE_CRYPTO_OP_STATUS_SUCCESS) {
> > + if (op->sym->m_dst == NULL)
> > + ev.event_ptr = op->sym->m_src;
> > + else
> > + ev.event_ptr = op->sym->m_dst;
> > + rte_crypto_op_free(op);
> > + } else {
> > + rte_crypto_op_free(op);
> > + continue;
> > + }
> > + }
> > +
> > if (enable_fwd_latency && !prod_timer_type)
> > /* first q in pipeline, mark timestamp to compute fwd latency */
> > mark_fwd_latency(&ev, nb_stages); @@ -88,6
> > +105,25 @@ perf_queue_worker_burst(void *arg, const int
> enable_fwd_latency)
> > }
> >
> > for (i = 0; i < nb_rx; i++) {
> > + if (prod_crypto_type &&
> > + (ev[i].event_type == RTE_EVENT_TYPE_CRYPTODEV)) {
> > + struct rte_crypto_op *op =
> > + ev[i].event_ptr;
> > +
> > + if (op->status ==
> > + RTE_CRYPTO_OP_STATUS_SUCCESS) {
> > + if (op->sym->m_dst == NULL)
> > + ev[i].event_ptr =
> > + op->sym->m_src;
> > + else
> > + ev[i].event_ptr =
> > + op->sym->m_dst;
> > + rte_crypto_op_free(op);
> > + } else {
> > + rte_crypto_op_free(op);
> > + continue;
> > + }
> > + }
> > +
> > if (enable_fwd_latency && !prod_timer_type) {
> > rte_prefetch0(ev[i+1].event_ptr);
> > /* first queue in pipeline.
> > @@ -269,6 +305,20 @@ perf_queue_eventdev_setup(struct evt_test
> *test, struct evt_options *opt)
> > return ret;
> > }
> > }
> > + } else if (opt->prod_type ==
> EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR) {
> > + uint8_t cdev_id, cdev_count;
> > +
> > + cdev_count = rte_cryptodev_count();
> > + for (cdev_id = 0; cdev_id < cdev_count; cdev_id++) {
> > + ret = rte_cryptodev_start(cdev_id);
> > + if (ret) {
> > + evt_err("Failed to start cryptodev %u",
> > + cdev_id);
> > + return ret;
> > + }
> > + }
> > +
> > + rte_event_crypto_adapter_start(t->crypto_adptr.id);
> > }
> >
> > return 0;
> > @@ -311,11 +361,13 @@ static const struct evt_test_ops perf_queue = {
> > .test_setup = perf_test_setup,
> > .mempool_setup = perf_mempool_setup,
> > .ethdev_setup = perf_ethdev_setup,
> > + .cryptodev_setup = perf_cryptodev_setup,
> > .eventdev_setup = perf_queue_eventdev_setup,
> > .launch_lcores = perf_queue_launch_lcores,
> > .eventdev_destroy = perf_eventdev_destroy,
> > .mempool_destroy = perf_mempool_destroy,
> > .ethdev_destroy = perf_ethdev_destroy,
> > + .cryptodev_destroy = perf_cryptodev_destroy,
> > .test_result = perf_test_result,
> > .test_destroy = perf_test_destroy,
> > };
> > diff --git a/doc/guides/tools/testeventdev.rst
> > b/doc/guides/tools/testeventdev.rst
> > index 48efb9ea6e..f7d813226d 100644
> > --- a/doc/guides/tools/testeventdev.rst
> > +++ b/doc/guides/tools/testeventdev.rst
> > @@ -120,6 +120,10 @@ The following are the application command-line
> options:
> >
> > Use burst mode event timer adapter as producer.
> >
> > +* ``--prod_type_cryptodev``
> > +
> > + Use crypto device as producer.
> > +
> > * ``--timer_tick_nsec``
> >
> > Used to dictate number of nano seconds between bucket
> > traversal of the @@ -148,6 +152,11 @@ The following are the application
> command-line options:
> > timeout is out of the supported range of event device it will be
> > adjusted to the highest/lowest supported dequeue timeout
> supported.
> >
> > +* ``--crypto_adptr_mode``
> > +
> > + Set crypto adapter mode. Use 0 for OP_NEW (default) and 1 for
> > + OP_FORWARD mode.
> > +
> > * ``--mbuf_sz``
> >
> > Set packet mbuf size. Can be used to configure Jumbo Frames.
> > Only @@ -420,6 +429,7 @@ Supported application command line options
> are following::
> > --prod_type_ethdev
> > --prod_type_timerdev_burst
> > --prod_type_timerdev
> > + --prod_type_cryptodev
> > --prod_enq_burst_sz
> > --timer_tick_nsec
> > --max_tmo_nsec
> > @@ -427,6 +437,7 @@ Supported application command line options are
> following::
> > --nb_timers
> > --nb_timer_adptrs
> > --deq_tmo_nsec
> > + --crypto_adptr_mode
> >
> > Example
> > ^^^^^^^
> > @@ -529,12 +540,14 @@ Supported application command line options are
> following::
> > --prod_type_ethdev
> > --prod_type_timerdev_burst
> > --prod_type_timerdev
> > + --prod_type_cryptodev
> > --timer_tick_nsec
> > --max_tmo_nsec
> > --expiry_nsec
> > --nb_timers
> > --nb_timer_adptrs
> > --deq_tmo_nsec
> > + --crypto_adptr_mode
> >
> > Example
> > ^^^^^^^
> > --
> > 2.25.1
> >
^ permalink raw reply [flat|nested] 43+ messages in thread
* RE: [PATCH v3] app/eventdev: add crypto producer mode
2022-01-04 10:30 ` [PATCH v3] " Shijith Thotton
2022-01-21 12:25 ` Jerin Jacob
@ 2022-01-23 18:44 ` Gujjar, Abhinandan S
2022-01-24 6:09 ` Shijith Thotton
` (2 more replies)
2022-02-08 16:33 ` [PATCH v4] " Shijith Thotton
2 siblings, 3 replies; 43+ messages in thread
From: Gujjar, Abhinandan S @ 2022-01-23 18:44 UTC (permalink / raw)
To: Shijith Thotton, dev, jerinj; +Cc: anoobj, pbhagavatula, gakhil
Hi Shijith,
Please find some comments inline.
> -----Original Message-----
> From: Shijith Thotton <sthotton@marvell.com>
> Sent: Tuesday, January 4, 2022 4:01 PM
> To: dev@dpdk.org; jerinj@marvell.com
> Cc: Shijith Thotton <sthotton@marvell.com>; anoobj@marvell.com;
> pbhagavatula@marvell.com; gakhil@marvell.com; Gujjar, Abhinandan S
> <abhinandan.gujjar@intel.com>
> Subject: [PATCH v3] app/eventdev: add crypto producer mode
>
> In crypto producer mode, producer core enqueues cryptodev with software
> generated crypto ops and worker core dequeues crypto completion events
> from the eventdev. Event crypto metadata used for above processing is pre-
> populated in each crypto session.
>
> Parameter --prod_type_cryptodev can be used to enable crypto producer
> mode. Parameter --crypto_adptr_mode can be set to select the crypto
> adapter mode, 0 for OP_NEW and 1 for OP_FORWARD.
>
> This mode can be used to measure the performance of crypto adapter.
>
> Example:
> ./dpdk-test-eventdev -l 0-2 -w <EVENTDEV> -w <CRYPTODEV> -- \
> --prod_type_cryptodev --crypto_adptr_mode 1 --test=perf_atq \
> --stlist=a --wlcores 1 --plcores 2
>
> Signed-off-by: Shijith Thotton <sthotton@marvell.com>
> ---
> v3:
> * Reduce dereference inside loop.
>
> v2:
> * Fix RHEL compilation warning.
>
> app/test-eventdev/evt_common.h | 3 +
> app/test-eventdev/evt_main.c | 13 +-
> app/test-eventdev/evt_options.c | 27 ++
> app/test-eventdev/evt_options.h | 12 +
> app/test-eventdev/evt_test.h | 6 +
> app/test-eventdev/test_perf_atq.c | 51 ++++
> app/test-eventdev/test_perf_common.c | 410
> ++++++++++++++++++++++++++- app/test-
> eventdev/test_perf_common.h | 16 ++ app/test-
> eventdev/test_perf_queue.c | 52 ++++
> doc/guides/tools/testeventdev.rst | 13 +
> 10 files changed, 596 insertions(+), 7 deletions(-)
>
> diff --git a/app/test-eventdev/evt_common.h b/app/test-
> eventdev/evt_common.h index f466434459..2f301a7e79 100644
> --- a/app/test-eventdev/evt_common.h
> +++ b/app/test-eventdev/evt_common.h
> @@ -7,6 +7,7 @@
>
> #include <rte_common.h>
> #include <rte_debug.h>
> +#include <rte_event_crypto_adapter.h>
> #include <rte_eventdev.h>
> #include <rte_service.h>
>
> @@ -39,6 +40,7 @@ enum evt_prod_type {
> EVT_PROD_TYPE_SYNT, /* Producer type Synthetic i.e. CPU. */
> EVT_PROD_TYPE_ETH_RX_ADPTR, /* Producer type Eth Rx Adapter.
> */
> EVT_PROD_TYPE_EVENT_TIMER_ADPTR, /* Producer type Timer
> Adapter. */
> + EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR, /* Producer type Crypto
> Adapter. */
> EVT_PROD_TYPE_MAX,
> };
>
> @@ -77,6 +79,7 @@ struct evt_options {
> uint64_t timer_tick_nsec;
> uint64_t optm_timer_tick_nsec;
> enum evt_prod_type prod_type;
> + enum rte_event_crypto_adapter_mode crypto_adptr_mode;
> };
>
> static inline bool
> diff --git a/app/test-eventdev/evt_main.c b/app/test-eventdev/evt_main.c
> index 194c980c7a..cef0fb1382 100644
> --- a/app/test-eventdev/evt_main.c
> +++ b/app/test-eventdev/evt_main.c
> @@ -161,12 +161,19 @@ main(int argc, char **argv)
> goto mempool_destroy;
> }
> }
New line required
> + /* Test specific cryptodev setup */
> + if (test->ops.cryptodev_setup) {
> + if (test->ops.cryptodev_setup(test, &opt)) {
> + evt_err("%s: cryptodev setup failed",
> opt.test_name);
> + goto ethdev_destroy;
> + }
> + }
>
> /* Test specific eventdev setup */
> if (test->ops.eventdev_setup) {
> if (test->ops.eventdev_setup(test, &opt)) {
> evt_err("%s: eventdev setup failed",
> opt.test_name);
> - goto ethdev_destroy;
> + goto cryptodev_destroy;
> }
> }
>
> @@ -197,6 +204,10 @@ main(int argc, char **argv)
> if (test->ops.eventdev_destroy)
> test->ops.eventdev_destroy(test, &opt);
>
> +cryptodev_destroy:
> + if (test->ops.cryptodev_destroy)
> + test->ops.cryptodev_destroy(test, &opt);
> +
> ethdev_destroy:
> if (test->ops.ethdev_destroy)
> test->ops.ethdev_destroy(test, &opt); diff --git a/app/test-
> eventdev/evt_options.c b/app/test-eventdev/evt_options.c index
> 753a7dbd7d..5ad1491020 100644
> --- a/app/test-eventdev/evt_options.c
> +++ b/app/test-eventdev/evt_options.c
> @@ -122,6 +122,26 @@ evt_parse_timer_prod_type_burst(struct
> evt_options *opt,
> return 0;
> }
>
> +static int
> +evt_parse_crypto_prod_type(struct evt_options *opt,
> + const char *arg __rte_unused)
> +{
> + opt->prod_type = EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR;
> + return 0;
> +}
> +
> +static int
> +evt_parse_crypto_adptr_mode(struct evt_options *opt, const char *arg) {
> + uint8_t mode;
> + int ret;
> +
> + ret = parser_read_uint8(&mode, arg);
> + opt->crypto_adptr_mode = mode ?
> RTE_EVENT_CRYPTO_ADAPTER_OP_FORWARD :
> +
> RTE_EVENT_CRYPTO_ADAPTER_OP_NEW;
> + return ret;
> +}
> +
> static int
> evt_parse_test_name(struct evt_options *opt, const char *arg) { @@ -
> 335,6 +355,7 @@ usage(char *program)
> "\t--queue_priority : enable queue priority\n"
> "\t--deq_tmo_nsec : global dequeue timeout\n"
> "\t--prod_type_ethdev : use ethernet device as
> producer.\n"
> + "\t--prod_type_cryptodev : use crypto device as
> producer.\n"
> "\t--prod_type_timerdev : use event timer device as
> producer.\n"
> "\t expity_nsec would be the timeout\n"
> "\t in ns.\n"
> @@ -345,6 +366,8 @@ usage(char *program)
> "\t--timer_tick_nsec : timer tick interval in ns.\n"
> "\t--max_tmo_nsec : max timeout interval in ns.\n"
> "\t--expiry_nsec : event timer expiry ns.\n"
> + "\t--crypto_adptr_mode : 0 for OP_NEW mode (default)
> and\n"
> + "\t 1 for OP_FORWARD mode.\n"
> "\t--mbuf_sz : packet mbuf size.\n"
> "\t--max_pkt_sz : max packet size.\n"
> "\t--prod_enq_burst_sz : producer enqueue burst size.\n"
> @@ -415,8 +438,10 @@ static struct option lgopts[] = {
> { EVT_QUEUE_PRIORITY, 0, 0, 0 },
> { EVT_DEQ_TMO_NSEC, 1, 0, 0 },
> { EVT_PROD_ETHDEV, 0, 0, 0 },
> + { EVT_PROD_CRYPTODEV, 0, 0, 0 },
> { EVT_PROD_TIMERDEV, 0, 0, 0 },
> { EVT_PROD_TIMERDEV_BURST, 0, 0, 0 },
> + { EVT_CRYPTO_ADPTR_MODE, 1, 0, 0 },
> { EVT_NB_TIMERS, 1, 0, 0 },
> { EVT_NB_TIMER_ADPTRS, 1, 0, 0 },
> { EVT_TIMER_TICK_NSEC, 1, 0, 0 },
> @@ -455,8 +480,10 @@ evt_opts_parse_long(int opt_idx, struct evt_options
> *opt)
> { EVT_QUEUE_PRIORITY, evt_parse_queue_priority},
> { EVT_DEQ_TMO_NSEC, evt_parse_deq_tmo_nsec},
> { EVT_PROD_ETHDEV, evt_parse_eth_prod_type},
> + { EVT_PROD_CRYPTODEV, evt_parse_crypto_prod_type},
> { EVT_PROD_TIMERDEV, evt_parse_timer_prod_type},
> { EVT_PROD_TIMERDEV_BURST,
> evt_parse_timer_prod_type_burst},
> + { EVT_CRYPTO_ADPTR_MODE,
> evt_parse_crypto_adptr_mode},
> { EVT_NB_TIMERS, evt_parse_nb_timers},
> { EVT_NB_TIMER_ADPTRS, evt_parse_nb_timer_adptrs},
> { EVT_TIMER_TICK_NSEC, evt_parse_timer_tick_nsec}, diff --
> git a/app/test-eventdev/evt_options.h b/app/test-eventdev/evt_options.h
> index 413d7092f0..2231c58801 100644
> --- a/app/test-eventdev/evt_options.h
> +++ b/app/test-eventdev/evt_options.h
> @@ -9,6 +9,7 @@
> #include <stdbool.h>
>
> #include <rte_common.h>
> +#include <rte_cryptodev.h>
> #include <rte_ethdev.h>
> #include <rte_eventdev.h>
> #include <rte_lcore.h>
> @@ -33,8 +34,10 @@
> #define EVT_QUEUE_PRIORITY ("queue_priority")
> #define EVT_DEQ_TMO_NSEC ("deq_tmo_nsec")
> #define EVT_PROD_ETHDEV ("prod_type_ethdev")
> +#define EVT_PROD_CRYPTODEV ("prod_type_cryptodev")
> #define EVT_PROD_TIMERDEV ("prod_type_timerdev")
> #define EVT_PROD_TIMERDEV_BURST ("prod_type_timerdev_burst")
> +#define EVT_CRYPTO_ADPTR_MODE ("crypto_adptr_mode")
> #define EVT_NB_TIMERS ("nb_timers")
> #define EVT_NB_TIMER_ADPTRS ("nb_timer_adptrs")
> #define EVT_TIMER_TICK_NSEC ("timer_tick_nsec")
> @@ -249,6 +252,8 @@ evt_prod_id_to_name(enum evt_prod_type
> prod_type)
> return "Ethdev Rx Adapter";
> case EVT_PROD_TYPE_EVENT_TIMER_ADPTR:
> return "Event timer adapter";
> + case EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR:
> + return "Event crypto adapter";
> }
>
> return "";
> @@ -288,6 +293,13 @@ evt_dump_producer_type(struct evt_options *opt)
> evt_dump("timer_tick_nsec", "%"PRIu64"",
> opt->timer_tick_nsec);
> break;
> + case EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR:
> + snprintf(name, EVT_PROD_MAX_NAME_LEN,
> + "Event crypto adapter producers");
> + evt_dump("crypto adapter mode", "%s",
> + opt->crypto_adptr_mode ? "OP_FORWARD" :
> "OP_NEW");
> + evt_dump("nb_cryptodev", "%u", rte_cryptodev_count());
> + break;
> }
> evt_dump("prod_type", "%s", name);
> }
> diff --git a/app/test-eventdev/evt_test.h b/app/test-eventdev/evt_test.h
> index f07d2c3336..50fa474ec2 100644
> --- a/app/test-eventdev/evt_test.h
> +++ b/app/test-eventdev/evt_test.h
> @@ -29,6 +29,8 @@ typedef int (*evt_test_mempool_setup_t)
> (struct evt_test *test, struct evt_options *opt); typedef int
> (*evt_test_ethdev_setup_t)
> (struct evt_test *test, struct evt_options *opt);
> +typedef int (*evt_test_cryptodev_setup_t)
> + (struct evt_test *test, struct evt_options *opt);
> typedef int (*evt_test_eventdev_setup_t)
> (struct evt_test *test, struct evt_options *opt); typedef int
> (*evt_test_launch_lcores_t) @@ -39,6 +41,8 @@ typedef void
> (*evt_test_eventdev_destroy_t)
> (struct evt_test *test, struct evt_options *opt); typedef void
> (*evt_test_ethdev_destroy_t)
> (struct evt_test *test, struct evt_options *opt);
> +typedef void (*evt_test_cryptodev_destroy_t)
> + (struct evt_test *test, struct evt_options *opt);
> typedef void (*evt_test_mempool_destroy_t)
> (struct evt_test *test, struct evt_options *opt); typedef void
> (*evt_test_destroy_t) @@ -52,10 +56,12 @@ struct evt_test_ops {
> evt_test_mempool_setup_t mempool_setup;
> evt_test_ethdev_setup_t ethdev_setup;
> evt_test_eventdev_setup_t eventdev_setup;
> + evt_test_cryptodev_setup_t cryptodev_setup;
> evt_test_launch_lcores_t launch_lcores;
> evt_test_result_t test_result;
> evt_test_eventdev_destroy_t eventdev_destroy;
> evt_test_ethdev_destroy_t ethdev_destroy;
> + evt_test_cryptodev_destroy_t cryptodev_destroy;
> evt_test_mempool_destroy_t mempool_destroy;
> evt_test_destroy_t test_destroy;
> };
> diff --git a/app/test-eventdev/test_perf_atq.c b/app/test-
> eventdev/test_perf_atq.c
> index 8fd51004ee..dbb1dc8c0c 100644
> --- a/app/test-eventdev/test_perf_atq.c
> +++ b/app/test-eventdev/test_perf_atq.c
> @@ -48,6 +48,22 @@ perf_atq_worker(void *arg, const int
> enable_fwd_latency)
> continue;
> }
>
> + if (prod_crypto_type &&
> + (ev.event_type == RTE_EVENT_TYPE_CRYPTODEV)) {
> + struct rte_crypto_op *op = ev.event_ptr;
> +
> + if (op->status ==
> RTE_CRYPTO_OP_STATUS_SUCCESS) {
> + if (op->sym->m_dst == NULL)
> + ev.event_ptr = op->sym->m_src;
> + else
> + ev.event_ptr = op->sym->m_dst;
> + rte_crypto_op_free(op);
> + } else {
> + rte_crypto_op_free(op);
> + continue;
> + }
> + }
> +
> if (enable_fwd_latency && !prod_timer_type)
> /* first stage in pipeline, mark ts to compute fwd latency */
> atq_mark_fwd_latency(&ev);
> @@ -87,6 +103,25 @@ perf_atq_worker_burst(void *arg, const int
> enable_fwd_latency)
> }
>
> for (i = 0; i < nb_rx; i++) {
> + if (prod_crypto_type &&
> + (ev[i].event_type ==
> RTE_EVENT_TYPE_CRYPTODEV)) {
> + struct rte_crypto_op *op = ev[i].event_ptr;
> +
> + if (op->status ==
> + RTE_CRYPTO_OP_STATUS_SUCCESS) {
> + if (op->sym->m_dst == NULL)
> + ev[i].event_ptr =
> + op->sym->m_src;
> + else
> + ev[i].event_ptr =
> + op->sym->m_dst;
> + rte_crypto_op_free(op);
> + } else {
> + rte_crypto_op_free(op);
> + continue;
> + }
> + }
> +
> if (enable_fwd_latency && !prod_timer_type) {
> rte_prefetch0(ev[i+1].event_ptr);
> /* first stage in pipeline.
> @@ -254,6 +289,20 @@ perf_atq_eventdev_setup(struct evt_test *test,
> struct evt_options *opt)
> return ret;
> }
> }
> + } else if (opt->prod_type ==
> EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR) {
> + uint8_t cdev_id, cdev_count;
> +
> + cdev_count = rte_cryptodev_count();
> + for (cdev_id = 0; cdev_id < cdev_count; cdev_id++) {
> + ret = rte_cryptodev_start(cdev_id);
> + if (ret) {
> + evt_err("Failed to start cryptodev %u",
> + cdev_id);
> + return ret;
> + }
> + }
> +
> + rte_event_crypto_adapter_start(t->crypto_adptr.id);
> }
>
> return 0;
> @@ -295,12 +344,14 @@ static const struct evt_test_ops perf_atq = {
> .opt_dump = perf_atq_opt_dump,
> .test_setup = perf_test_setup,
> .ethdev_setup = perf_ethdev_setup,
> + .cryptodev_setup = perf_cryptodev_setup,
> .mempool_setup = perf_mempool_setup,
> .eventdev_setup = perf_atq_eventdev_setup,
> .launch_lcores = perf_atq_launch_lcores,
> .eventdev_destroy = perf_eventdev_destroy,
> .mempool_destroy = perf_mempool_destroy,
> .ethdev_destroy = perf_ethdev_destroy,
> + .cryptodev_destroy = perf_cryptodev_destroy,
> .test_result = perf_test_result,
> .test_destroy = perf_test_destroy,
> };
> diff --git a/app/test-eventdev/test_perf_common.c b/app/test-
> eventdev/test_perf_common.c
> index 9b73874151..91cb6748ee 100644
> --- a/app/test-eventdev/test_perf_common.c
> +++ b/app/test-eventdev/test_perf_common.c
> @@ -6,6 +6,8 @@
>
> #include "test_perf_common.h"
>
> +#define NB_CRYPTODEV_DESCRIPTORS 128
> +
> int
> perf_test_result(struct evt_test *test, struct evt_options *opt) { @@ -272,6
> +274,125 @@ perf_event_timer_producer_burst(void *arg)
> return 0;
> }
>
> +static inline void
> +crypto_adapter_enq_op_new(struct prod_data *p) {
> + struct rte_cryptodev_sym_session **crypto_sess = p->crypto_sess;
> + struct test_perf *t = p->t;
> + const uint32_t nb_flows = t->nb_flows;
> + const uint64_t nb_pkts = t->nb_pkts;
> + struct rte_mempool *pool = t->pool;
> + struct rte_crypto_sym_op *sym_op;
> + struct evt_options *opt = t->opt;
> + uint16_t qp_id = p->cdev_qp_id;
> + uint8_t cdev_id = p->cdev_id;
> + uint32_t flow_counter = 0;
> + struct rte_crypto_op *op;
> + struct rte_mbuf *m;
> + uint64_t count = 0;
> + uint16_t len;
> +
> + if (opt->verbose_level > 1)
> + printf("%s(): lcore %d queue %d cdev_id %u cdev_qp_id
> %u\n",
> + __func__, rte_lcore_id(), p->queue_id, p->cdev_id,
> + p->cdev_qp_id);
> +
> + len = opt->mbuf_sz ? opt->mbuf_sz : RTE_ETHER_MIN_LEN;
> +
> + while (count < nb_pkts && t->done == false) {
> + m = rte_pktmbuf_alloc(pool);
> + if (m == NULL)
> + continue;
> +
> + rte_pktmbuf_append(m, len);
> + op = rte_crypto_op_alloc(t->crypto_adptr.op_pool,
> +
> RTE_CRYPTO_OP_TYPE_SYMMETRIC);
> + sym_op = op->sym;
> + sym_op->m_src = m;
> + sym_op->cipher.data.offset = 0;
> + sym_op->cipher.data.length = len;
> + rte_crypto_op_attach_sym_session(
> + op, crypto_sess[flow_counter++ % nb_flows]);
> + while (rte_cryptodev_enqueue_burst(cdev_id, qp_id, &op,
> 1) !=
> + 1) {
> + if (t->done)
> + break;
> + rte_pause();
> + }
> + count++;
> + }
> +}
> +
> +static inline void
> +crypto_adapter_enq_op_fwd(struct prod_data *p) {
> + struct rte_cryptodev_sym_session **crypto_sess = p->crypto_sess;
> + const uint8_t dev_id = p->dev_id;
> + const uint8_t port = p->port_id;
> + struct test_perf *t = p->t;
> + const uint32_t nb_flows = t->nb_flows;
> + const uint64_t nb_pkts = t->nb_pkts;
> + struct rte_mempool *pool = t->pool;
> + struct evt_options *opt = t->opt;
> + struct rte_crypto_sym_op *sym_op;
> + uint32_t flow_counter = 0;
> + struct rte_crypto_op *op;
> + struct rte_event ev;
> + struct rte_mbuf *m;
> + uint64_t count = 0;
> + uint16_t len;
> +
> + if (opt->verbose_level > 1)
> + printf("%s(): lcore %d port %d queue %d cdev_id %u
> cdev_qp_id %u\n",
> + __func__, rte_lcore_id(), port, p->queue_id, p->cdev_id,
> + p->cdev_qp_id);
> +
> + ev.event = 0;
> + ev.op = RTE_EVENT_OP_NEW;
> + ev.queue_id = p->queue_id;
> + ev.sched_type = RTE_SCHED_TYPE_ATOMIC;
> + ev.event_type = RTE_EVENT_TYPE_CPU;
> + len = opt->mbuf_sz ? opt->mbuf_sz : RTE_ETHER_MIN_LEN;
> +
> + while (count < nb_pkts && t->done == false) {
> + m = rte_pktmbuf_alloc(pool);
> + if (m == NULL)
> + continue;
> +
> + rte_pktmbuf_append(m, len);
> + op = rte_crypto_op_alloc(t->crypto_adptr.op_pool,
> +
> RTE_CRYPTO_OP_TYPE_SYMMETRIC);
> + sym_op = op->sym;
> + sym_op->m_src = m;
> + sym_op->cipher.data.offset = 0;
> + sym_op->cipher.data.length = len;
> + rte_crypto_op_attach_sym_session(
> + op, crypto_sess[flow_counter++ % nb_flows]);
> + ev.event_ptr = op;
> + while (rte_event_crypto_adapter_enqueue(dev_id, port,
> &ev, 1) !=
> + 1) {
> + if (t->done)
> + break;
> + rte_pause();
> + }
> + count++;
> + }
> +}
> +
> +static inline int
> +perf_event_crypto_producer(void *arg)
> +{
> + struct prod_data *p = arg;
> + struct evt_options *opt = p->t->opt;
> +
> + if (opt->crypto_adptr_mode ==
> RTE_EVENT_CRYPTO_ADAPTER_OP_NEW)
> + crypto_adapter_enq_op_new(p);
> + else
> + crypto_adapter_enq_op_fwd(p);
> +
> + return 0;
> +}
> +
> static int
> perf_producer_wrapper(void *arg)
> {
> @@ -298,6 +419,8 @@ perf_producer_wrapper(void *arg)
> else if (t->opt->prod_type ==
> EVT_PROD_TYPE_EVENT_TIMER_ADPTR &&
> t->opt->timdev_use_burst)
> return perf_event_timer_producer_burst(arg);
> + else if (t->opt->prod_type ==
> EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR)
> + return perf_event_crypto_producer(arg);
> return 0;
> }
>
> @@ -405,8 +528,10 @@ perf_launch_lcores(struct evt_test *test, struct
> evt_options *opt,
> if (remaining <= 0) {
> t->result = EVT_TEST_SUCCESS;
> if (opt->prod_type ==
> EVT_PROD_TYPE_SYNT ||
> - opt->prod_type ==
> -
> EVT_PROD_TYPE_EVENT_TIMER_ADPTR) {
> + opt->prod_type ==
> +
> EVT_PROD_TYPE_EVENT_TIMER_ADPTR ||
> + opt->prod_type ==
> +
> EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR) {
> t->done = true;
> break;
> }
> @@ -415,7 +540,8 @@ perf_launch_lcores(struct evt_test *test, struct
> evt_options *opt,
>
> if (new_cycles - dead_lock_cycles > dead_lock_sample &&
> (opt->prod_type == EVT_PROD_TYPE_SYNT ||
> - opt->prod_type ==
> EVT_PROD_TYPE_EVENT_TIMER_ADPTR)) {
> + opt->prod_type ==
> EVT_PROD_TYPE_EVENT_TIMER_ADPTR ||
> + opt->prod_type ==
> EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR)) {
> remaining = t->outstand_pkts - processed_pkts(t);
> if (dead_lock_remaining == remaining) {
> rte_event_dev_dump(opt->dev_id, stdout);
> @@ -537,6 +663,96 @@ perf_event_timer_adapter_setup(struct test_perf
> *t)
> return 0;
> }
>
> +static int
> +perf_event_crypto_adapter_setup(struct test_perf *t,
> + struct rte_event_port_conf port_conf) {
> + struct evt_options *opt = t->opt;
> + uint8_t cdev_id, cdev_count;
> + int ret;
> +
> + t->crypto_adptr.id = 0;
> + ret = rte_event_crypto_adapter_create(t->crypto_adptr.id, opt-
> >dev_id,
> + &port_conf, 0);
> + if (ret)
> + return ret;
> +
> + cdev_count = rte_cryptodev_count();
> + for (cdev_id = 0; cdev_id < cdev_count; cdev_id++) {
> + uint32_t cap;
> +
> + ret = rte_event_crypto_adapter_caps_get(opt->dev_id,
> cdev_id,
> + &cap);
> + if (ret) {
> + evt_err("Failed to get crypto adapter capabilities");
> + return ret;
> + }
> +
> + if (((opt->crypto_adptr_mode ==
> + RTE_EVENT_CRYPTO_ADAPTER_OP_NEW) &&
> + !(cap &
> +
> RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_OP_NEW)) ||
> + ((opt->crypto_adptr_mode ==
> + RTE_EVENT_CRYPTO_ADAPTER_OP_FORWARD) &&
> + !(cap &
> +
> RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_OP_FWD))) {
> + evt_err("crypto adapter %s mode unsupported\n",
> + opt->crypto_adptr_mode ? "OP_FORWARD"
> :
> + "OP_NEW");
> + return -EINVAL;
> + }
> +
> + if (!(cap &
> +
> RTE_EVENT_CRYPTO_ADAPTER_CAP_SESSION_PRIVATE_DATA)) {
> + evt_err("Storing crypto session not supported");
> + return -EINVAL;
> + }
> +
> + if (cap &
> +
> RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_QP_EV_BIND) {
> + struct rte_event response_info;
> +
> + response_info.event = 0;
> + ret = rte_event_crypto_adapter_queue_pair_add(
> + t->crypto_adptr.id, cdev_id, -1,
> + &response_info);
> + } else {
> + ret = rte_event_crypto_adapter_queue_pair_add(
> + t->crypto_adptr.id, cdev_id, -1, NULL);
> + }
> + if (ret)
> + return ret;
> + }
> +
> + return 0;
> +}
> +
> +static struct rte_cryptodev_sym_session *
> +cryptodev_sym_sess_create(struct prod_data *p, struct test_perf *t) {
> + struct rte_crypto_sym_xform cipher_xform;
> + struct rte_cryptodev_sym_session *sess;
> +
> + cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
> + cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
> + cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
> + cipher_xform.next = NULL;
> +
> + sess = rte_cryptodev_sym_session_create(t-
> >crypto_adptr.sess_pool);
> + if (sess == NULL) {
> + evt_err("Failed to create sym session");
> + return NULL;
> + }
> +
> + if (rte_cryptodev_sym_session_init(p->cdev_id, sess,
> &cipher_xform,
> + t->crypto_adptr.sess_priv_pool)) {
> + evt_err("Failed to init session");
> + return NULL;
> + }
> +
> + return sess;
> +}
> +
> int
> perf_event_dev_port_setup(struct evt_test *test, struct evt_options *opt,
> uint8_t stride, uint8_t nb_queues,
> @@ -598,6 +814,55 @@ perf_event_dev_port_setup(struct evt_test *test,
> struct evt_options *opt,
> ret = perf_event_timer_adapter_setup(t);
> if (ret)
> return ret;
> + } else if (opt->prod_type ==
> EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR) {
> + uint8_t cdev_id = 0;
> + uint16_t qp_id = 0;
> +
> + prod = 0;
> + for (; port < perf_nb_event_ports(opt); port++) {
> + struct rte_cryptodev_sym_session *crypto_sess;
> + union rte_event_crypto_metadata m_data;
> + struct prod_data *p = &t->prod[port];
> + uint32_t flow_id;
> +
> + if (qp_id ==
> rte_cryptodev_queue_pair_count(cdev_id)) {
> + cdev_id++;
> + qp_id = 0;
> + }
> +
> + p->dev_id = opt->dev_id;
> + p->port_id = port;
> + p->queue_id = prod * stride;
> + p->cdev_id = cdev_id;
> + p->cdev_qp_id = qp_id;
> + p->crypto_sess = rte_zmalloc_socket(
> + NULL, sizeof(crypto_sess) * t->nb_flows,
> + RTE_CACHE_LINE_SIZE, opt->socket_id);
> +
> + m_data.request_info.cdev_id = p->cdev_id;
> + m_data.request_info.queue_pair_id = p-
> >cdev_qp_id;
> + m_data.response_info.op = RTE_EVENT_OP_NEW;
> + m_data.response_info.sched_type =
> RTE_SCHED_TYPE_ATOMIC;
> + m_data.response_info.event_type =
> RTE_EVENT_TYPE_CPU;
> + m_data.response_info.queue_id = p->queue_id;
> + for (flow_id = 0; flow_id < t->nb_flows; flow_id++) {
> + crypto_sess =
> cryptodev_sym_sess_create(p, t);
> + if (crypto_sess == NULL)
> + return -ENOMEM;
> +
> + m_data.response_info.flow_id = flow_id;
> + rte_cryptodev_sym_session_set_user_data(
> + crypto_sess, &m_data,
> sizeof(m_data));
> + p->crypto_sess[flow_id] = crypto_sess;
> + }
> + p->t = t;
> + qp_id++;
> + prod++;
> + }
> +
> + ret = perf_event_crypto_adapter_setup(t, *port_conf);
> + if (ret)
> + return ret;
> } else {
> prod = 0;
> for ( ; port < perf_nb_event_ports(opt); port++) { @@ -659,7
> +924,8 @@ perf_opt_check(struct evt_options *opt, uint64_t nb_queues)
> }
>
> if (opt->prod_type == EVT_PROD_TYPE_SYNT ||
> - opt->prod_type ==
> EVT_PROD_TYPE_EVENT_TIMER_ADPTR) {
> + opt->prod_type == EVT_PROD_TYPE_EVENT_TIMER_ADPTR ||
> + opt->prod_type == EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR) {
> /* Validate producer lcores */
> if (evt_lcores_has_overlap(opt->plcores,
> rte_get_main_lcore())) {
> @@ -767,8 +1033,7 @@ perf_ethdev_setup(struct evt_test *test, struct
> evt_options *opt)
> },
> };
>
> - if (opt->prod_type == EVT_PROD_TYPE_SYNT ||
> - opt->prod_type ==
> EVT_PROD_TYPE_EVENT_TIMER_ADPTR)
> + if (opt->prod_type != EVT_PROD_TYPE_ETH_RX_ADPTR)
> return 0;
>
> if (!rte_eth_dev_count_avail()) {
> @@ -841,6 +1106,139 @@ void perf_ethdev_destroy(struct evt_test *test,
> struct evt_options *opt)
> }
> }
>
> +int
> +perf_cryptodev_setup(struct evt_test *test, struct evt_options *opt) {
> + uint8_t cdev_count, cdev_id, nb_plcores, nb_qps;
> + struct test_perf *t = evt_test_priv(test);
> + unsigned int max_session_size;
> + uint32_t nb_sessions;
> + int ret;
> +
> + if (opt->prod_type != EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR)
> + return 0;
How do you differentiate between this failed case as you are returning 0 in case of success?
> +
> + cdev_count = rte_cryptodev_count();
> + if (cdev_count == 0) {
> + evt_err("No crypto devices available\n");
> + return -ENODEV;
> + }
> +
> + t->crypto_adptr.op_pool = rte_crypto_op_pool_create(
> + "crypto_op_pool", RTE_CRYPTO_OP_TYPE_SYMMETRIC, opt-
> >pool_sz,
> + 128, 0, rte_socket_id());
> + if (t->crypto_adptr.op_pool == NULL) {
> + evt_err("Failed to create crypto op pool");
> + return -ENOMEM;
> + }
> +
> + nb_sessions = evt_nr_active_lcores(opt->plcores) * t->nb_flows;
> + t->crypto_adptr.sess_pool =
> rte_cryptodev_sym_session_pool_create(
> + "ca_sess_pool", nb_sessions, 0, 0,
> + sizeof(union rte_event_crypto_metadata),
> SOCKET_ID_ANY);
> + if (t->crypto_adptr.sess_pool == NULL) {
> + evt_err("Failed to create sym session pool");
> + ret = -ENOMEM;
> + goto err;
> + }
> +
> + max_session_size = 0;
> + for (cdev_id = 0; cdev_id < cdev_count; cdev_id++) {
> + unsigned int session_size;
> +
> + session_size =
> +
> rte_cryptodev_sym_get_private_session_size(cdev_id);
> + if (session_size > max_session_size)
> + max_session_size = session_size;
> + }
New line required
> + max_session_size += sizeof(union rte_event_crypto_metadata);
> + t->crypto_adptr.sess_priv_pool = rte_mempool_create(
> + "ca_sess_priv_pool", nb_sessions, max_session_size, 0, 0,
> NULL,
> + NULL, NULL, NULL, SOCKET_ID_ANY, 0);
> + if (t->crypto_adptr.sess_priv_pool == NULL) {
> + evt_err("failed to create sym session private pool");
> + ret = -ENOMEM;
> + goto err;
> + }
> +
> + nb_plcores = evt_nr_active_lcores(opt->plcores);
> + nb_qps = (nb_plcores % cdev_count) ? (nb_plcores / cdev_count) +
> 1 :
> + nb_plcores / cdev_count;
Let's take an example:
Cdev1 -> 8 qps
Cdev2 -> 2 qps
Cdev_count = 2
nb_plcores = 7
As per above statement, nb_qps = ( 7 % 2 ) 7/2 + 1 = 4 qps
So, this fails to setup qps for cdev2 as it supports only 2 qps and test exits! Am I missing anything?
> + for (cdev_id = 0; cdev_id < cdev_count; cdev_id++) {
> + struct rte_cryptodev_qp_conf qp_conf;
> + struct rte_cryptodev_config conf;
> + struct rte_cryptodev_info info;
> + int qp_id;
> +
> + rte_cryptodev_info_get(cdev_id, &info);
> + if (nb_qps > info.max_nb_queue_pairs) {
> + evt_err("Not enough queue pairs per cryptodev
> (%u)",
> + nb_qps);
> + ret = -EINVAL;
> + goto err;
> + }
> +
> + conf.nb_queue_pairs = nb_qps;
> + conf.socket_id = SOCKET_ID_ANY;
> + conf.ff_disable = RTE_CRYPTODEV_FF_SECURITY;
> +
> + ret = rte_cryptodev_configure(cdev_id, &conf);
> + if (ret) {
> + evt_err("Failed to configure cryptodev (%u)",
> cdev_id);
> + goto err;
> + }
> +
> + qp_conf.nb_descriptors = NB_CRYPTODEV_DESCRIPTORS;
> + qp_conf.mp_session = t->crypto_adptr.sess_pool;
> + qp_conf.mp_session_private = t-
> >crypto_adptr.sess_priv_pool;
> +
> + for (qp_id = 0; qp_id < conf.nb_queue_pairs; qp_id++) {
> + ret = rte_cryptodev_queue_pair_setup(
> + cdev_id, qp_id, &qp_conf,
> + rte_cryptodev_socket_id(cdev_id));
> + if (ret) {
> + evt_err("Failed to setup queue pairs on
> cryptodev %u\n",
> + cdev_id);
> + goto err;
> + }
> + }
> + }
> +
> + return 0;
> +err:
> + rte_mempool_free(t->crypto_adptr.op_pool);
> + rte_mempool_free(t->crypto_adptr.sess_pool);
> + rte_mempool_free(t->crypto_adptr.sess_priv_pool);
> +
> + return ret;
> +}
> +
> +void
> +perf_cryptodev_destroy(struct evt_test *test, struct evt_options *opt)
> +{
> + uint8_t cdev_id, cdev_count = rte_cryptodev_count();
> + struct test_perf *t = evt_test_priv(test);
> +
> + RTE_SET_USED(opt);
> +
> + if (opt->prod_type != EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR)
> + return;
> +
> + rte_event_crypto_adapter_stop(t->crypto_adptr.id);
> +
> + for (cdev_id = 0; cdev_id < cdev_count; cdev_id++) {
> + rte_cryptodev_stop(cdev_id);
> + rte_event_crypto_adapter_queue_pair_del(t-
> >crypto_adptr.id,
> + cdev_id, -1);
Any reason for passing -1? This can not ensure to cleanup all the preconfigured qps as per API.
> + }
> +
> + rte_event_crypto_adapter_free(t->crypto_adptr.id);
> +
> + rte_mempool_free(t->crypto_adptr.op_pool);
> + rte_mempool_free(t->crypto_adptr.sess_pool);
> + rte_mempool_free(t->crypto_adptr.sess_priv_pool);
> +}
> +
> int
> perf_mempool_setup(struct evt_test *test, struct evt_options *opt) { diff -
> -git a/app/test-eventdev/test_perf_common.h b/app/test-
> eventdev/test_perf_common.h
> index 14dcf80429..d9ad3a0b0d 100644
> --- a/app/test-eventdev/test_perf_common.h
> +++ b/app/test-eventdev/test_perf_common.h
> @@ -9,9 +9,11 @@
> #include <stdbool.h>
> #include <unistd.h>
>
> +#include <rte_cryptodev.h>
> #include <rte_cycles.h>
> #include <rte_ethdev.h>
> #include <rte_eventdev.h>
> +#include <rte_event_crypto_adapter.h>
> #include <rte_event_eth_rx_adapter.h>
> #include <rte_event_timer_adapter.h>
> #include <rte_lcore.h>
> @@ -37,9 +39,18 @@ struct prod_data {
> uint8_t dev_id;
> uint8_t port_id;
> uint8_t queue_id;
> + uint8_t cdev_id;
> + uint16_t cdev_qp_id;
> + struct rte_cryptodev_sym_session **crypto_sess;
> struct test_perf *t;
> } __rte_cache_aligned;
>
> +struct crypto_adptr_data {
> + uint8_t id;
> + struct rte_mempool *op_pool;
> + struct rte_mempool *sess_pool;
> + struct rte_mempool *sess_priv_pool;
> +};
>
> struct test_perf {
> /* Don't change the offset of "done". Signal handler use this memory
> @@ -58,6 +69,7 @@ struct test_perf {
> uint8_t sched_type_list[EVT_MAX_STAGES] __rte_cache_aligned;
> struct rte_event_timer_adapter *timer_adptr[
> RTE_EVENT_TIMER_ADAPTER_NUM_MAX]
> __rte_cache_aligned;
> + struct crypto_adptr_data crypto_adptr;
> } __rte_cache_aligned;
>
> struct perf_elt {
> @@ -81,6 +93,8 @@ struct perf_elt {
> const uint8_t port = w->port_id;\
> const uint8_t prod_timer_type = \
> opt->prod_type ==
> EVT_PROD_TYPE_EVENT_TIMER_ADPTR;\
> + const uint8_t prod_crypto_type = \
> + opt->prod_type ==
> EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR;\
> uint8_t *const sched_type_list = &t->sched_type_list[0];\
> struct rte_mempool *const pool = t->pool;\
> const uint8_t nb_stages = t->opt->nb_stages;\ @@ -154,6 +168,7
> @@ int perf_test_result(struct evt_test *test, struct evt_options *opt); int
> perf_opt_check(struct evt_options *opt, uint64_t nb_queues); int
> perf_test_setup(struct evt_test *test, struct evt_options *opt); int
> perf_ethdev_setup(struct evt_test *test, struct evt_options *opt);
> +int perf_cryptodev_setup(struct evt_test *test, struct evt_options
> +*opt);
> int perf_mempool_setup(struct evt_test *test, struct evt_options *opt); int
> perf_event_dev_port_setup(struct evt_test *test, struct evt_options *opt,
> uint8_t stride, uint8_t nb_queues,
> @@ -164,6 +179,7 @@ int perf_launch_lcores(struct evt_test *test, struct
> evt_options *opt, void perf_opt_dump(struct evt_options *opt, uint8_t
> nb_queues); void perf_test_destroy(struct evt_test *test, struct
> evt_options *opt); void perf_eventdev_destroy(struct evt_test *test, struct
> evt_options *opt);
> +void perf_cryptodev_destroy(struct evt_test *test, struct evt_options
> +*opt);
> void perf_ethdev_destroy(struct evt_test *test, struct evt_options *opt);
> void perf_mempool_destroy(struct evt_test *test, struct evt_options *opt);
>
> diff --git a/app/test-eventdev/test_perf_queue.c b/app/test-
> eventdev/test_perf_queue.c
> index f4ea3a795f..5657c8b3cd 100644
> --- a/app/test-eventdev/test_perf_queue.c
> +++ b/app/test-eventdev/test_perf_queue.c
> @@ -49,6 +49,23 @@ perf_queue_worker(void *arg, const int
> enable_fwd_latency)
> rte_pause();
> continue;
> }
> +
> + if (prod_crypto_type &&
> + (ev.event_type == RTE_EVENT_TYPE_CRYPTODEV)) {
> + struct rte_crypto_op *op = ev.event_ptr;
> +
> + if (op->status ==
> RTE_CRYPTO_OP_STATUS_SUCCESS) {
> + if (op->sym->m_dst == NULL)
> + ev.event_ptr = op->sym->m_src;
> + else
> + ev.event_ptr = op->sym->m_dst;
> + rte_crypto_op_free(op);
> + } else {
> + rte_crypto_op_free(op);
> + continue;
In case of failure, ops are freed and "ev.event_ptr" won't be set to mbuf.
What would be the expected test result?
> + }
> + }
> +
> if (enable_fwd_latency && !prod_timer_type)
> /* first q in pipeline, mark timestamp to compute fwd latency
> */
> mark_fwd_latency(&ev, nb_stages);
> @@ -88,6 +105,25 @@ perf_queue_worker_burst(void *arg, const int
> enable_fwd_latency)
> }
>
> for (i = 0; i < nb_rx; i++) {
> + if (prod_crypto_type &&
> + (ev[i].event_type ==
> RTE_EVENT_TYPE_CRYPTODEV)) {
> + struct rte_crypto_op *op = ev[i].event_ptr;
> +
> + if (op->status ==
> + RTE_CRYPTO_OP_STATUS_SUCCESS) {
> + if (op->sym->m_dst == NULL)
> + ev[i].event_ptr =
> + op->sym->m_src;
> + else
> + ev[i].event_ptr =
> + op->sym->m_dst;
> + rte_crypto_op_free(op);
> + } else {
> + rte_crypto_op_free(op);
> + continue;
> + }
> + }
> +
> if (enable_fwd_latency && !prod_timer_type) {
> rte_prefetch0(ev[i+1].event_ptr);
> /* first queue in pipeline.
> @@ -269,6 +305,20 @@ perf_queue_eventdev_setup(struct evt_test *test,
> struct evt_options *opt)
> return ret;
> }
> }
> + } else if (opt->prod_type ==
> EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR) {
> + uint8_t cdev_id, cdev_count;
> +
> + cdev_count = rte_cryptodev_count();
> + for (cdev_id = 0; cdev_id < cdev_count; cdev_id++) {
> + ret = rte_cryptodev_start(cdev_id);
> + if (ret) {
> + evt_err("Failed to start cryptodev %u",
> + cdev_id);
> + return ret;
> + }
> + }
> +
> + rte_event_crypto_adapter_start(t->crypto_adptr.id);
> }
>
> return 0;
> @@ -311,11 +361,13 @@ static const struct evt_test_ops perf_queue = {
> .test_setup = perf_test_setup,
> .mempool_setup = perf_mempool_setup,
> .ethdev_setup = perf_ethdev_setup,
> + .cryptodev_setup = perf_cryptodev_setup,
> .eventdev_setup = perf_queue_eventdev_setup,
> .launch_lcores = perf_queue_launch_lcores,
> .eventdev_destroy = perf_eventdev_destroy,
> .mempool_destroy = perf_mempool_destroy,
> .ethdev_destroy = perf_ethdev_destroy,
> + .cryptodev_destroy = perf_cryptodev_destroy,
> .test_result = perf_test_result,
> .test_destroy = perf_test_destroy,
> };
> diff --git a/doc/guides/tools/testeventdev.rst
> b/doc/guides/tools/testeventdev.rst
> index 48efb9ea6e..f7d813226d 100644
> --- a/doc/guides/tools/testeventdev.rst
> +++ b/doc/guides/tools/testeventdev.rst
> @@ -120,6 +120,10 @@ The following are the application command-line
> options:
>
> Use burst mode event timer adapter as producer.
>
> +* ``--prod_type_cryptodev``
> +
> + Use crypto device as producer.
> +
> * ``--timer_tick_nsec``
>
> Used to dictate number of nano seconds between bucket traversal of
> the @@ -148,6 +152,11 @@ The following are the application command-line
> options:
> timeout is out of the supported range of event device it will be
> adjusted to the highest/lowest supported dequeue timeout supported.
>
> +* ``--crypto_adptr_mode``
> +
> + Set crypto adapter mode. Use 0 for OP_NEW (default) and 1 for
> + OP_FORWARD mode.
> +
> * ``--mbuf_sz``
>
> Set packet mbuf size. Can be used to configure Jumbo Frames. Only @@
> -420,6 +429,7 @@ Supported application command line options are
> following::
> --prod_type_ethdev
> --prod_type_timerdev_burst
> --prod_type_timerdev
> + --prod_type_cryptodev
> --prod_enq_burst_sz
> --timer_tick_nsec
> --max_tmo_nsec
> @@ -427,6 +437,7 @@ Supported application command line options are
> following::
> --nb_timers
> --nb_timer_adptrs
> --deq_tmo_nsec
> + --crypto_adptr_mode
>
> Example
> ^^^^^^^
> @@ -529,12 +540,14 @@ Supported application command line options are
> following::
> --prod_type_ethdev
> --prod_type_timerdev_burst
> --prod_type_timerdev
> + --prod_type_cryptodev
> --timer_tick_nsec
> --max_tmo_nsec
> --expiry_nsec
> --nb_timers
> --nb_timer_adptrs
> --deq_tmo_nsec
> + --crypto_adptr_mode
>
> Example
> ^^^^^^^
> --
> 2.25.1
^ permalink raw reply [flat|nested] 43+ messages in thread
* RE: [PATCH v3] app/eventdev: add crypto producer mode
2022-01-23 18:44 ` Gujjar, Abhinandan S
@ 2022-01-24 6:09 ` Shijith Thotton
2022-01-24 6:59 ` Shijith Thotton
2022-01-25 13:39 ` Gujjar, Abhinandan S
2 siblings, 0 replies; 43+ messages in thread
From: Shijith Thotton @ 2022-01-24 6:09 UTC (permalink / raw)
To: Gujjar, Abhinandan S, dev, Jerin Jacob Kollanukkaran
Cc: Anoob Joseph, Pavan Nikhilesh Bhagavatula, Akhil Goyal
Hi Abhinandan,
>>
>> In crypto producer mode, producer core enqueues cryptodev with software
>> generated crypto ops and worker core dequeues crypto completion events
>> from the eventdev. Event crypto metadata used for above processing is pre-
>> populated in each crypto session.
>>
>> Parameter --prod_type_cryptodev can be used to enable crypto producer
>> mode. Parameter --crypto_adptr_mode can be set to select the crypto
>> adapter mode, 0 for OP_NEW and 1 for OP_FORWARD.
>>
>> This mode can be used to measure the performance of crypto adapter.
>>
>> Example:
>> ./dpdk-test-eventdev -l 0-2 -w <EVENTDEV> -w <CRYPTODEV> -- \
>> --prod_type_cryptodev --crypto_adptr_mode 1 --test=perf_atq \
>> --stlist=a --wlcores 1 --plcores 2
>>
>> Signed-off-by: Shijith Thotton <sthotton@marvell.com>
>> ---
>> v3:
>> * Reduce dereference inside loop.
>>
>> v2:
>> * Fix RHEL compilation warning.
>>
>> app/test-eventdev/evt_common.h | 3 +
>> app/test-eventdev/evt_main.c | 13 +-
>> app/test-eventdev/evt_options.c | 27 ++
>> app/test-eventdev/evt_options.h | 12 +
>> app/test-eventdev/evt_test.h | 6 +
>> app/test-eventdev/test_perf_atq.c | 51 ++++
>> app/test-eventdev/test_perf_common.c | 410
>> ++++++++++++++++++++++++++- app/test-
>> eventdev/test_perf_common.h | 16 ++ app/test-
>> eventdev/test_perf_queue.c | 52 ++++
>> doc/guides/tools/testeventdev.rst | 13 +
>> 10 files changed, 596 insertions(+), 7 deletions(-)
>>
>> diff --git a/app/test-eventdev/evt_common.h b/app/test-
>> eventdev/evt_common.h index f466434459..2f301a7e79 100644
>> --- a/app/test-eventdev/evt_common.h
>> +++ b/app/test-eventdev/evt_common.h
>> @@ -7,6 +7,7 @@
>>
>> #include <rte_common.h>
>> #include <rte_debug.h>
>> +#include <rte_event_crypto_adapter.h>
>> #include <rte_eventdev.h>
>> #include <rte_service.h>
>>
>> @@ -39,6 +40,7 @@ enum evt_prod_type {
>> EVT_PROD_TYPE_SYNT, /* Producer type Synthetic i.e. CPU. */
>> EVT_PROD_TYPE_ETH_RX_ADPTR, /* Producer type Eth Rx Adapter.
>> */
>> EVT_PROD_TYPE_EVENT_TIMER_ADPTR, /* Producer type Timer
>> Adapter. */
>> + EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR, /* Producer type Crypto
>> Adapter. */
>> EVT_PROD_TYPE_MAX,
>> };
>>
>> @@ -77,6 +79,7 @@ struct evt_options {
>> uint64_t timer_tick_nsec;
>> uint64_t optm_timer_tick_nsec;
>> enum evt_prod_type prod_type;
>> + enum rte_event_crypto_adapter_mode crypto_adptr_mode;
>> };
>>
>> static inline bool
>> diff --git a/app/test-eventdev/evt_main.c b/app/test-eventdev/evt_main.c
>> index 194c980c7a..cef0fb1382 100644
>> --- a/app/test-eventdev/evt_main.c
>> +++ b/app/test-eventdev/evt_main.c
>> @@ -161,12 +161,19 @@ main(int argc, char **argv)
>> goto mempool_destroy;
>> }
>> }
>New line required
>> + /* Test specific cryptodev setup */
>> + if (test->ops.cryptodev_setup) {
>> + if (test->ops.cryptodev_setup(test, &opt)) {
>> + evt_err("%s: cryptodev setup failed",
>> opt.test_name);
>> + goto ethdev_destroy;
>> + }
>> + }
>>
>> /* Test specific eventdev setup */
>> if (test->ops.eventdev_setup) {
>> if (test->ops.eventdev_setup(test, &opt)) {
>> evt_err("%s: eventdev setup failed",
>> opt.test_name);
>> - goto ethdev_destroy;
>> + goto cryptodev_destroy;
>> }
>> }
>>
>> @@ -197,6 +204,10 @@ main(int argc, char **argv)
>> if (test->ops.eventdev_destroy)
>> test->ops.eventdev_destroy(test, &opt);
>>
>> +cryptodev_destroy:
>> + if (test->ops.cryptodev_destroy)
>> + test->ops.cryptodev_destroy(test, &opt);
>> +
>> ethdev_destroy:
>> if (test->ops.ethdev_destroy)
>> test->ops.ethdev_destroy(test, &opt); diff --git a/app/test-
>> eventdev/evt_options.c b/app/test-eventdev/evt_options.c index
>> 753a7dbd7d..5ad1491020 100644
>> --- a/app/test-eventdev/evt_options.c
>> +++ b/app/test-eventdev/evt_options.c
>> @@ -122,6 +122,26 @@ evt_parse_timer_prod_type_burst(struct
>> evt_options *opt,
>> return 0;
>> }
>>
>> +static int
>> +evt_parse_crypto_prod_type(struct evt_options *opt,
>> + const char *arg __rte_unused)
>> +{
>> + opt->prod_type = EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR;
>> + return 0;
>> +}
>> +
>> +static int
>> +evt_parse_crypto_adptr_mode(struct evt_options *opt, const char *arg) {
>> + uint8_t mode;
>> + int ret;
>> +
>> + ret = parser_read_uint8(&mode, arg);
>> + opt->crypto_adptr_mode = mode ?
>> RTE_EVENT_CRYPTO_ADAPTER_OP_FORWARD :
>> +
>> RTE_EVENT_CRYPTO_ADAPTER_OP_NEW;
>> + return ret;
>> +}
>> +
>> static int
>> evt_parse_test_name(struct evt_options *opt, const char *arg) { @@ -
>> 335,6 +355,7 @@ usage(char *program)
>> "\t--queue_priority : enable queue priority\n"
>> "\t--deq_tmo_nsec : global dequeue timeout\n"
>> "\t--prod_type_ethdev : use ethernet device as
>> producer.\n"
>> + "\t--prod_type_cryptodev : use crypto device as
>> producer.\n"
>> "\t--prod_type_timerdev : use event timer device as
>> producer.\n"
>> "\t expity_nsec would be the timeout\n"
>> "\t in ns.\n"
>> @@ -345,6 +366,8 @@ usage(char *program)
>> "\t--timer_tick_nsec : timer tick interval in ns.\n"
>> "\t--max_tmo_nsec : max timeout interval in ns.\n"
>> "\t--expiry_nsec : event timer expiry ns.\n"
>> + "\t--crypto_adptr_mode : 0 for OP_NEW mode (default)
>> and\n"
>> + "\t 1 for OP_FORWARD mode.\n"
>> "\t--mbuf_sz : packet mbuf size.\n"
>> "\t--max_pkt_sz : max packet size.\n"
>> "\t--prod_enq_burst_sz : producer enqueue burst size.\n"
>> @@ -415,8 +438,10 @@ static struct option lgopts[] = {
>> { EVT_QUEUE_PRIORITY, 0, 0, 0 },
>> { EVT_DEQ_TMO_NSEC, 1, 0, 0 },
>> { EVT_PROD_ETHDEV, 0, 0, 0 },
>> + { EVT_PROD_CRYPTODEV, 0, 0, 0 },
>> { EVT_PROD_TIMERDEV, 0, 0, 0 },
>> { EVT_PROD_TIMERDEV_BURST, 0, 0, 0 },
>> + { EVT_CRYPTO_ADPTR_MODE, 1, 0, 0 },
>> { EVT_NB_TIMERS, 1, 0, 0 },
>> { EVT_NB_TIMER_ADPTRS, 1, 0, 0 },
>> { EVT_TIMER_TICK_NSEC, 1, 0, 0 },
>> @@ -455,8 +480,10 @@ evt_opts_parse_long(int opt_idx, struct evt_options
>> *opt)
>> { EVT_QUEUE_PRIORITY, evt_parse_queue_priority},
>> { EVT_DEQ_TMO_NSEC, evt_parse_deq_tmo_nsec},
>> { EVT_PROD_ETHDEV, evt_parse_eth_prod_type},
>> + { EVT_PROD_CRYPTODEV, evt_parse_crypto_prod_type},
>> { EVT_PROD_TIMERDEV, evt_parse_timer_prod_type},
>> { EVT_PROD_TIMERDEV_BURST,
>> evt_parse_timer_prod_type_burst},
>> + { EVT_CRYPTO_ADPTR_MODE,
>> evt_parse_crypto_adptr_mode},
>> { EVT_NB_TIMERS, evt_parse_nb_timers},
>> { EVT_NB_TIMER_ADPTRS, evt_parse_nb_timer_adptrs},
>> { EVT_TIMER_TICK_NSEC, evt_parse_timer_tick_nsec}, diff --
>> git a/app/test-eventdev/evt_options.h b/app/test-eventdev/evt_options.h
>> index 413d7092f0..2231c58801 100644
>> --- a/app/test-eventdev/evt_options.h
>> +++ b/app/test-eventdev/evt_options.h
>> @@ -9,6 +9,7 @@
>> #include <stdbool.h>
>>
>> #include <rte_common.h>
>> +#include <rte_cryptodev.h>
>> #include <rte_ethdev.h>
>> #include <rte_eventdev.h>
>> #include <rte_lcore.h>
>> @@ -33,8 +34,10 @@
>> #define EVT_QUEUE_PRIORITY ("queue_priority")
>> #define EVT_DEQ_TMO_NSEC ("deq_tmo_nsec")
>> #define EVT_PROD_ETHDEV ("prod_type_ethdev")
>> +#define EVT_PROD_CRYPTODEV ("prod_type_cryptodev")
>> #define EVT_PROD_TIMERDEV ("prod_type_timerdev")
>> #define EVT_PROD_TIMERDEV_BURST ("prod_type_timerdev_burst")
>> +#define EVT_CRYPTO_ADPTR_MODE ("crypto_adptr_mode")
>> #define EVT_NB_TIMERS ("nb_timers")
>> #define EVT_NB_TIMER_ADPTRS ("nb_timer_adptrs")
>> #define EVT_TIMER_TICK_NSEC ("timer_tick_nsec")
>> @@ -249,6 +252,8 @@ evt_prod_id_to_name(enum evt_prod_type
>> prod_type)
>> return "Ethdev Rx Adapter";
>> case EVT_PROD_TYPE_EVENT_TIMER_ADPTR:
>> return "Event timer adapter";
>> + case EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR:
>> + return "Event crypto adapter";
>> }
>>
>> return "";
>> @@ -288,6 +293,13 @@ evt_dump_producer_type(struct evt_options *opt)
>> evt_dump("timer_tick_nsec", "%"PRIu64"",
>> opt->timer_tick_nsec);
>> break;
>> + case EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR:
>> + snprintf(name, EVT_PROD_MAX_NAME_LEN,
>> + "Event crypto adapter producers");
>> + evt_dump("crypto adapter mode", "%s",
>> + opt->crypto_adptr_mode ? "OP_FORWARD" :
>> "OP_NEW");
>> + evt_dump("nb_cryptodev", "%u", rte_cryptodev_count());
>> + break;
>> }
>> evt_dump("prod_type", "%s", name);
>> }
>> diff --git a/app/test-eventdev/evt_test.h b/app/test-eventdev/evt_test.h
>> index f07d2c3336..50fa474ec2 100644
>> --- a/app/test-eventdev/evt_test.h
>> +++ b/app/test-eventdev/evt_test.h
>> @@ -29,6 +29,8 @@ typedef int (*evt_test_mempool_setup_t)
>> (struct evt_test *test, struct evt_options *opt); typedef int
>> (*evt_test_ethdev_setup_t)
>> (struct evt_test *test, struct evt_options *opt);
>> +typedef int (*evt_test_cryptodev_setup_t)
>> + (struct evt_test *test, struct evt_options *opt);
>> typedef int (*evt_test_eventdev_setup_t)
>> (struct evt_test *test, struct evt_options *opt); typedef int
>> (*evt_test_launch_lcores_t) @@ -39,6 +41,8 @@ typedef void
>> (*evt_test_eventdev_destroy_t)
>> (struct evt_test *test, struct evt_options *opt); typedef void
>> (*evt_test_ethdev_destroy_t)
>> (struct evt_test *test, struct evt_options *opt);
>> +typedef void (*evt_test_cryptodev_destroy_t)
>> + (struct evt_test *test, struct evt_options *opt);
>> typedef void (*evt_test_mempool_destroy_t)
>> (struct evt_test *test, struct evt_options *opt); typedef void
>> (*evt_test_destroy_t) @@ -52,10 +56,12 @@ struct evt_test_ops {
>> evt_test_mempool_setup_t mempool_setup;
>> evt_test_ethdev_setup_t ethdev_setup;
>> evt_test_eventdev_setup_t eventdev_setup;
>> + evt_test_cryptodev_setup_t cryptodev_setup;
>> evt_test_launch_lcores_t launch_lcores;
>> evt_test_result_t test_result;
>> evt_test_eventdev_destroy_t eventdev_destroy;
>> evt_test_ethdev_destroy_t ethdev_destroy;
>> + evt_test_cryptodev_destroy_t cryptodev_destroy;
>> evt_test_mempool_destroy_t mempool_destroy;
>> evt_test_destroy_t test_destroy;
>> };
>> diff --git a/app/test-eventdev/test_perf_atq.c b/app/test-
>> eventdev/test_perf_atq.c
>> index 8fd51004ee..dbb1dc8c0c 100644
>> --- a/app/test-eventdev/test_perf_atq.c
>> +++ b/app/test-eventdev/test_perf_atq.c
>> @@ -48,6 +48,22 @@ perf_atq_worker(void *arg, const int
>> enable_fwd_latency)
>> continue;
>> }
>>
>> + if (prod_crypto_type &&
>> + (ev.event_type == RTE_EVENT_TYPE_CRYPTODEV)) {
>> + struct rte_crypto_op *op = ev.event_ptr;
>> +
>> + if (op->status ==
>> RTE_CRYPTO_OP_STATUS_SUCCESS) {
>> + if (op->sym->m_dst == NULL)
>> + ev.event_ptr = op->sym->m_src;
>> + else
>> + ev.event_ptr = op->sym->m_dst;
>> + rte_crypto_op_free(op);
>> + } else {
>> + rte_crypto_op_free(op);
>> + continue;
>> + }
>> + }
>> +
>> if (enable_fwd_latency && !prod_timer_type)
>> /* first stage in pipeline, mark ts to compute fwd latency */
>> atq_mark_fwd_latency(&ev);
>> @@ -87,6 +103,25 @@ perf_atq_worker_burst(void *arg, const int
>> enable_fwd_latency)
>> }
>>
>> for (i = 0; i < nb_rx; i++) {
>> + if (prod_crypto_type &&
>> + (ev[i].event_type ==
>> RTE_EVENT_TYPE_CRYPTODEV)) {
>> + struct rte_crypto_op *op = ev[i].event_ptr;
>> +
>> + if (op->status ==
>> + RTE_CRYPTO_OP_STATUS_SUCCESS) {
>> + if (op->sym->m_dst == NULL)
>> + ev[i].event_ptr =
>> + op->sym->m_src;
>> + else
>> + ev[i].event_ptr =
>> + op->sym->m_dst;
>> + rte_crypto_op_free(op);
>> + } else {
>> + rte_crypto_op_free(op);
>> + continue;
>> + }
>> + }
>> +
>> if (enable_fwd_latency && !prod_timer_type) {
>> rte_prefetch0(ev[i+1].event_ptr);
>> /* first stage in pipeline.
>> @@ -254,6 +289,20 @@ perf_atq_eventdev_setup(struct evt_test *test,
>> struct evt_options *opt)
>> return ret;
>> }
>> }
>> + } else if (opt->prod_type ==
>> EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR) {
>> + uint8_t cdev_id, cdev_count;
>> +
>> + cdev_count = rte_cryptodev_count();
>> + for (cdev_id = 0; cdev_id < cdev_count; cdev_id++) {
>> + ret = rte_cryptodev_start(cdev_id);
>> + if (ret) {
>> + evt_err("Failed to start cryptodev %u",
>> + cdev_id);
>> + return ret;
>> + }
>> + }
>> +
>> + rte_event_crypto_adapter_start(t->crypto_adptr.id);
>> }
>>
>> return 0;
>> @@ -295,12 +344,14 @@ static const struct evt_test_ops perf_atq = {
>> .opt_dump = perf_atq_opt_dump,
>> .test_setup = perf_test_setup,
>> .ethdev_setup = perf_ethdev_setup,
>> + .cryptodev_setup = perf_cryptodev_setup,
>> .mempool_setup = perf_mempool_setup,
>> .eventdev_setup = perf_atq_eventdev_setup,
>> .launch_lcores = perf_atq_launch_lcores,
>> .eventdev_destroy = perf_eventdev_destroy,
>> .mempool_destroy = perf_mempool_destroy,
>> .ethdev_destroy = perf_ethdev_destroy,
>> + .cryptodev_destroy = perf_cryptodev_destroy,
>> .test_result = perf_test_result,
>> .test_destroy = perf_test_destroy,
>> };
>> diff --git a/app/test-eventdev/test_perf_common.c b/app/test-
>> eventdev/test_perf_common.c
>> index 9b73874151..91cb6748ee 100644
>> --- a/app/test-eventdev/test_perf_common.c
>> +++ b/app/test-eventdev/test_perf_common.c
>> @@ -6,6 +6,8 @@
>>
>> #include "test_perf_common.h"
>>
>> +#define NB_CRYPTODEV_DESCRIPTORS 128
>> +
>> int
>> perf_test_result(struct evt_test *test, struct evt_options *opt) { @@ -272,6
>> +274,125 @@ perf_event_timer_producer_burst(void *arg)
>> return 0;
>> }
>>
>> +static inline void
>> +crypto_adapter_enq_op_new(struct prod_data *p) {
>> + struct rte_cryptodev_sym_session **crypto_sess = p->crypto_sess;
>> + struct test_perf *t = p->t;
>> + const uint32_t nb_flows = t->nb_flows;
>> + const uint64_t nb_pkts = t->nb_pkts;
>> + struct rte_mempool *pool = t->pool;
>> + struct rte_crypto_sym_op *sym_op;
>> + struct evt_options *opt = t->opt;
>> + uint16_t qp_id = p->cdev_qp_id;
>> + uint8_t cdev_id = p->cdev_id;
>> + uint32_t flow_counter = 0;
>> + struct rte_crypto_op *op;
>> + struct rte_mbuf *m;
>> + uint64_t count = 0;
>> + uint16_t len;
>> +
>> + if (opt->verbose_level > 1)
>> + printf("%s(): lcore %d queue %d cdev_id %u cdev_qp_id
>> %u\n",
>> + __func__, rte_lcore_id(), p->queue_id, p->cdev_id,
>> + p->cdev_qp_id);
>> +
>> + len = opt->mbuf_sz ? opt->mbuf_sz : RTE_ETHER_MIN_LEN;
>> +
>> + while (count < nb_pkts && t->done == false) {
>> + m = rte_pktmbuf_alloc(pool);
>> + if (m == NULL)
>> + continue;
>> +
>> + rte_pktmbuf_append(m, len);
>> + op = rte_crypto_op_alloc(t->crypto_adptr.op_pool,
>> +
>> RTE_CRYPTO_OP_TYPE_SYMMETRIC);
>> + sym_op = op->sym;
>> + sym_op->m_src = m;
>> + sym_op->cipher.data.offset = 0;
>> + sym_op->cipher.data.length = len;
>> + rte_crypto_op_attach_sym_session(
>> + op, crypto_sess[flow_counter++ % nb_flows]);
>> + while (rte_cryptodev_enqueue_burst(cdev_id, qp_id, &op,
>> 1) !=
>> + 1) {
>> + if (t->done)
>> + break;
>> + rte_pause();
>> + }
>> + count++;
>> + }
>> +}
>> +
>> +static inline void
>> +crypto_adapter_enq_op_fwd(struct prod_data *p) {
>> + struct rte_cryptodev_sym_session **crypto_sess = p->crypto_sess;
>> + const uint8_t dev_id = p->dev_id;
>> + const uint8_t port = p->port_id;
>> + struct test_perf *t = p->t;
>> + const uint32_t nb_flows = t->nb_flows;
>> + const uint64_t nb_pkts = t->nb_pkts;
>> + struct rte_mempool *pool = t->pool;
>> + struct evt_options *opt = t->opt;
>> + struct rte_crypto_sym_op *sym_op;
>> + uint32_t flow_counter = 0;
>> + struct rte_crypto_op *op;
>> + struct rte_event ev;
>> + struct rte_mbuf *m;
>> + uint64_t count = 0;
>> + uint16_t len;
>> +
>> + if (opt->verbose_level > 1)
>> + printf("%s(): lcore %d port %d queue %d cdev_id %u
>> cdev_qp_id %u\n",
>> + __func__, rte_lcore_id(), port, p->queue_id, p->cdev_id,
>> + p->cdev_qp_id);
>> +
>> + ev.event = 0;
>> + ev.op = RTE_EVENT_OP_NEW;
>> + ev.queue_id = p->queue_id;
>> + ev.sched_type = RTE_SCHED_TYPE_ATOMIC;
>> + ev.event_type = RTE_EVENT_TYPE_CPU;
>> + len = opt->mbuf_sz ? opt->mbuf_sz : RTE_ETHER_MIN_LEN;
>> +
>> + while (count < nb_pkts && t->done == false) {
>> + m = rte_pktmbuf_alloc(pool);
>> + if (m == NULL)
>> + continue;
>> +
>> + rte_pktmbuf_append(m, len);
>> + op = rte_crypto_op_alloc(t->crypto_adptr.op_pool,
>> +
>> RTE_CRYPTO_OP_TYPE_SYMMETRIC);
>> + sym_op = op->sym;
>> + sym_op->m_src = m;
>> + sym_op->cipher.data.offset = 0;
>> + sym_op->cipher.data.length = len;
>> + rte_crypto_op_attach_sym_session(
>> + op, crypto_sess[flow_counter++ % nb_flows]);
>> + ev.event_ptr = op;
>> + while (rte_event_crypto_adapter_enqueue(dev_id, port,
>> &ev, 1) !=
>> + 1) {
>> + if (t->done)
>> + break;
>> + rte_pause();
>> + }
>> + count++;
>> + }
>> +}
>> +
>> +static inline int
>> +perf_event_crypto_producer(void *arg)
>> +{
>> + struct prod_data *p = arg;
>> + struct evt_options *opt = p->t->opt;
>> +
>> + if (opt->crypto_adptr_mode ==
>> RTE_EVENT_CRYPTO_ADAPTER_OP_NEW)
>> + crypto_adapter_enq_op_new(p);
>> + else
>> + crypto_adapter_enq_op_fwd(p);
>> +
>> + return 0;
>> +}
>> +
>> static int
>> perf_producer_wrapper(void *arg)
>> {
>> @@ -298,6 +419,8 @@ perf_producer_wrapper(void *arg)
>> else if (t->opt->prod_type ==
>> EVT_PROD_TYPE_EVENT_TIMER_ADPTR &&
>> t->opt->timdev_use_burst)
>> return perf_event_timer_producer_burst(arg);
>> + else if (t->opt->prod_type ==
>> EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR)
>> + return perf_event_crypto_producer(arg);
>> return 0;
>> }
>>
>> @@ -405,8 +528,10 @@ perf_launch_lcores(struct evt_test *test, struct
>> evt_options *opt,
>> if (remaining <= 0) {
>> t->result = EVT_TEST_SUCCESS;
>> if (opt->prod_type ==
>> EVT_PROD_TYPE_SYNT ||
>> - opt->prod_type ==
>> -
>> EVT_PROD_TYPE_EVENT_TIMER_ADPTR) {
>> + opt->prod_type ==
>> +
>> EVT_PROD_TYPE_EVENT_TIMER_ADPTR ||
>> + opt->prod_type ==
>> +
>> EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR) {
>> t->done = true;
>> break;
>> }
>> @@ -415,7 +540,8 @@ perf_launch_lcores(struct evt_test *test, struct
>> evt_options *opt,
>>
>> if (new_cycles - dead_lock_cycles > dead_lock_sample &&
>> (opt->prod_type == EVT_PROD_TYPE_SYNT ||
>> - opt->prod_type ==
>> EVT_PROD_TYPE_EVENT_TIMER_ADPTR)) {
>> + opt->prod_type ==
>> EVT_PROD_TYPE_EVENT_TIMER_ADPTR ||
>> + opt->prod_type ==
>> EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR)) {
>> remaining = t->outstand_pkts - processed_pkts(t);
>> if (dead_lock_remaining == remaining) {
>> rte_event_dev_dump(opt->dev_id, stdout);
>> @@ -537,6 +663,96 @@ perf_event_timer_adapter_setup(struct test_perf
>> *t)
>> return 0;
>> }
>>
>> +static int
>> +perf_event_crypto_adapter_setup(struct test_perf *t,
>> + struct rte_event_port_conf port_conf) {
>> + struct evt_options *opt = t->opt;
>> + uint8_t cdev_id, cdev_count;
>> + int ret;
>> +
>> + t->crypto_adptr.id = 0;
>> + ret = rte_event_crypto_adapter_create(t->crypto_adptr.id, opt-
>> >dev_id,
>> + &port_conf, 0);
>> + if (ret)
>> + return ret;
>> +
>> + cdev_count = rte_cryptodev_count();
>> + for (cdev_id = 0; cdev_id < cdev_count; cdev_id++) {
>> + uint32_t cap;
>> +
>> + ret = rte_event_crypto_adapter_caps_get(opt->dev_id,
>> cdev_id,
>> + &cap);
>> + if (ret) {
>> + evt_err("Failed to get crypto adapter capabilities");
>> + return ret;
>> + }
>> +
>> + if (((opt->crypto_adptr_mode ==
>> + RTE_EVENT_CRYPTO_ADAPTER_OP_NEW) &&
>> + !(cap &
>> +
>> RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_OP_NEW)) ||
>> + ((opt->crypto_adptr_mode ==
>> + RTE_EVENT_CRYPTO_ADAPTER_OP_FORWARD) &&
>> + !(cap &
>> +
>> RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_OP_FWD))) {
>> + evt_err("crypto adapter %s mode unsupported\n",
>> + opt->crypto_adptr_mode ? "OP_FORWARD"
>> :
>> + "OP_NEW");
>> + return -EINVAL;
>> + }
>> +
>> + if (!(cap &
>> +
>> RTE_EVENT_CRYPTO_ADAPTER_CAP_SESSION_PRIVATE_DATA)) {
>> + evt_err("Storing crypto session not supported");
>> + return -EINVAL;
>> + }
>> +
>> + if (cap &
>> +
>> RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_QP_EV_BIND) {
>> + struct rte_event response_info;
>> +
>> + response_info.event = 0;
>> + ret = rte_event_crypto_adapter_queue_pair_add(
>> + t->crypto_adptr.id, cdev_id, -1,
>> + &response_info);
>> + } else {
>> + ret = rte_event_crypto_adapter_queue_pair_add(
>> + t->crypto_adptr.id, cdev_id, -1, NULL);
>> + }
>> + if (ret)
>> + return ret;
>> + }
>> +
>> + return 0;
>> +}
>> +
>> +static struct rte_cryptodev_sym_session *
>> +cryptodev_sym_sess_create(struct prod_data *p, struct test_perf *t) {
>> + struct rte_crypto_sym_xform cipher_xform;
>> + struct rte_cryptodev_sym_session *sess;
>> +
>> + cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
>> + cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
>> + cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
>> + cipher_xform.next = NULL;
>> +
>> + sess = rte_cryptodev_sym_session_create(t-
>> >crypto_adptr.sess_pool);
>> + if (sess == NULL) {
>> + evt_err("Failed to create sym session");
>> + return NULL;
>> + }
>> +
>> + if (rte_cryptodev_sym_session_init(p->cdev_id, sess,
>> &cipher_xform,
>> + t->crypto_adptr.sess_priv_pool)) {
>> + evt_err("Failed to init session");
>> + return NULL;
>> + }
>> +
>> + return sess;
>> +}
>> +
>> int
>> perf_event_dev_port_setup(struct evt_test *test, struct evt_options *opt,
>> uint8_t stride, uint8_t nb_queues,
>> @@ -598,6 +814,55 @@ perf_event_dev_port_setup(struct evt_test *test,
>> struct evt_options *opt,
>> ret = perf_event_timer_adapter_setup(t);
>> if (ret)
>> return ret;
>> + } else if (opt->prod_type ==
>> EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR) {
>> + uint8_t cdev_id = 0;
>> + uint16_t qp_id = 0;
>> +
>> + prod = 0;
>> + for (; port < perf_nb_event_ports(opt); port++) {
>> + struct rte_cryptodev_sym_session *crypto_sess;
>> + union rte_event_crypto_metadata m_data;
>> + struct prod_data *p = &t->prod[port];
>> + uint32_t flow_id;
>> +
>> + if (qp_id ==
>> rte_cryptodev_queue_pair_count(cdev_id)) {
>> + cdev_id++;
>> + qp_id = 0;
>> + }
>> +
>> + p->dev_id = opt->dev_id;
>> + p->port_id = port;
>> + p->queue_id = prod * stride;
>> + p->cdev_id = cdev_id;
>> + p->cdev_qp_id = qp_id;
>> + p->crypto_sess = rte_zmalloc_socket(
>> + NULL, sizeof(crypto_sess) * t->nb_flows,
>> + RTE_CACHE_LINE_SIZE, opt->socket_id);
>> +
>> + m_data.request_info.cdev_id = p->cdev_id;
>> + m_data.request_info.queue_pair_id = p-
>> >cdev_qp_id;
>> + m_data.response_info.op = RTE_EVENT_OP_NEW;
>> + m_data.response_info.sched_type =
>> RTE_SCHED_TYPE_ATOMIC;
>> + m_data.response_info.event_type =
>> RTE_EVENT_TYPE_CPU;
>> + m_data.response_info.queue_id = p->queue_id;
>> + for (flow_id = 0; flow_id < t->nb_flows; flow_id++) {
>> + crypto_sess =
>> cryptodev_sym_sess_create(p, t);
>> + if (crypto_sess == NULL)
>> + return -ENOMEM;
>> +
>> + m_data.response_info.flow_id = flow_id;
>> + rte_cryptodev_sym_session_set_user_data(
>> + crypto_sess, &m_data,
>> sizeof(m_data));
>> + p->crypto_sess[flow_id] = crypto_sess;
>> + }
>> + p->t = t;
>> + qp_id++;
>> + prod++;
>> + }
>> +
>> + ret = perf_event_crypto_adapter_setup(t, *port_conf);
>> + if (ret)
>> + return ret;
>> } else {
>> prod = 0;
>> for ( ; port < perf_nb_event_ports(opt); port++) { @@ -659,7
>> +924,8 @@ perf_opt_check(struct evt_options *opt, uint64_t nb_queues)
>> }
>>
>> if (opt->prod_type == EVT_PROD_TYPE_SYNT ||
>> - opt->prod_type ==
>> EVT_PROD_TYPE_EVENT_TIMER_ADPTR) {
>> + opt->prod_type == EVT_PROD_TYPE_EVENT_TIMER_ADPTR ||
>> + opt->prod_type == EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR) {
>> /* Validate producer lcores */
>> if (evt_lcores_has_overlap(opt->plcores,
>> rte_get_main_lcore())) {
>> @@ -767,8 +1033,7 @@ perf_ethdev_setup(struct evt_test *test, struct
>> evt_options *opt)
>> },
>> };
>>
>> - if (opt->prod_type == EVT_PROD_TYPE_SYNT ||
>> - opt->prod_type ==
>> EVT_PROD_TYPE_EVENT_TIMER_ADPTR)
>> + if (opt->prod_type != EVT_PROD_TYPE_ETH_RX_ADPTR)
>> return 0;
>>
>> if (!rte_eth_dev_count_avail()) {
>> @@ -841,6 +1106,139 @@ void perf_ethdev_destroy(struct evt_test *test,
>> struct evt_options *opt)
>> }
>> }
>>
>> +int
>> +perf_cryptodev_setup(struct evt_test *test, struct evt_options *opt) {
>> + uint8_t cdev_count, cdev_id, nb_plcores, nb_qps;
>> + struct test_perf *t = evt_test_priv(test);
>> + unsigned int max_session_size;
>> + uint32_t nb_sessions;
>> + int ret;
>> +
>> + if (opt->prod_type != EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR)
>> + return 0;
>How do you differentiate between this failed case as you are returning 0 in case of
>success?
>
>> +
>> + cdev_count = rte_cryptodev_count();
>> + if (cdev_count == 0) {
>> + evt_err("No crypto devices available\n");
>> + return -ENODEV;
>> + }
>> +
>> + t->crypto_adptr.op_pool = rte_crypto_op_pool_create(
>> + "crypto_op_pool", RTE_CRYPTO_OP_TYPE_SYMMETRIC, opt-
>> >pool_sz,
>> + 128, 0, rte_socket_id());
>> + if (t->crypto_adptr.op_pool == NULL) {
>> + evt_err("Failed to create crypto op pool");
>> + return -ENOMEM;
>> + }
>> +
>> + nb_sessions = evt_nr_active_lcores(opt->plcores) * t->nb_flows;
>> + t->crypto_adptr.sess_pool =
>> rte_cryptodev_sym_session_pool_create(
>> + "ca_sess_pool", nb_sessions, 0, 0,
>> + sizeof(union rte_event_crypto_metadata),
>> SOCKET_ID_ANY);
>> + if (t->crypto_adptr.sess_pool == NULL) {
>> + evt_err("Failed to create sym session pool");
>> + ret = -ENOMEM;
>> + goto err;
>> + }
>> +
>> + max_session_size = 0;
>> + for (cdev_id = 0; cdev_id < cdev_count; cdev_id++) {
>> + unsigned int session_size;
>> +
>> + session_size =
>> +
>> rte_cryptodev_sym_get_private_session_size(cdev_id);
>> + if (session_size > max_session_size)
>> + max_session_size = session_size;
>> + }
>New line required
>> + max_session_size += sizeof(union rte_event_crypto_metadata);
>> + t->crypto_adptr.sess_priv_pool = rte_mempool_create(
>> + "ca_sess_priv_pool", nb_sessions, max_session_size, 0, 0,
>> NULL,
>> + NULL, NULL, NULL, SOCKET_ID_ANY, 0);
>> + if (t->crypto_adptr.sess_priv_pool == NULL) {
>> + evt_err("failed to create sym session private pool");
>> + ret = -ENOMEM;
>> + goto err;
>> + }
>> +
>> + nb_plcores = evt_nr_active_lcores(opt->plcores);
>> + nb_qps = (nb_plcores % cdev_count) ? (nb_plcores / cdev_count) +
>> 1 :
>> + nb_plcores / cdev_count;
>Let's take an example:
>Cdev1 -> 8 qps
>Cdev2 -> 2 qps
>Cdev_count = 2
>nb_plcores = 7
>As per above statement, nb_qps = ( 7 % 2 ) 7/2 + 1 = 4 qps
>So, this fails to setup qps for cdev2 as it supports only 2 qps and test exits! Am I
>missing anything?
>
What you told is correct. But this is a simple logic to distribute qps across
multiple cdev and doesn't consider the case you mentioned. You could see
similar logic used in other apps. I will add a comment as below:
/*
* Calculate number of needed queue pairs, based on the amount
* of available number of logical cores and crypto devices.
* For instance, if there are 4 cores and 2 crypto devices,
* 2 queue pairs will be set up per device.
*/
>> + for (cdev_id = 0; cdev_id < cdev_count; cdev_id++) {
>> + struct rte_cryptodev_qp_conf qp_conf;
>> + struct rte_cryptodev_config conf;
>> + struct rte_cryptodev_info info;
>> + int qp_id;
>> +
>> + rte_cryptodev_info_get(cdev_id, &info);
>> + if (nb_qps > info.max_nb_queue_pairs) {
>> + evt_err("Not enough queue pairs per cryptodev
>> (%u)",
>> + nb_qps);
>> + ret = -EINVAL;
>> + goto err;
>> + }
>> +
>> + conf.nb_queue_pairs = nb_qps;
>> + conf.socket_id = SOCKET_ID_ANY;
>> + conf.ff_disable = RTE_CRYPTODEV_FF_SECURITY;
>> +
>> + ret = rte_cryptodev_configure(cdev_id, &conf);
>> + if (ret) {
>> + evt_err("Failed to configure cryptodev (%u)",
>> cdev_id);
>> + goto err;
>> + }
>> +
>> + qp_conf.nb_descriptors = NB_CRYPTODEV_DESCRIPTORS;
>> + qp_conf.mp_session = t->crypto_adptr.sess_pool;
>> + qp_conf.mp_session_private = t-
>> >crypto_adptr.sess_priv_pool;
>> +
>> + for (qp_id = 0; qp_id < conf.nb_queue_pairs; qp_id++) {
>> + ret = rte_cryptodev_queue_pair_setup(
>> + cdev_id, qp_id, &qp_conf,
>> + rte_cryptodev_socket_id(cdev_id));
>> + if (ret) {
>> + evt_err("Failed to setup queue pairs on
>> cryptodev %u\n",
>> + cdev_id);
>> + goto err;
>> + }
>> + }
>> + }
>> +
>> + return 0;
>> +err:
>> + rte_mempool_free(t->crypto_adptr.op_pool);
>> + rte_mempool_free(t->crypto_adptr.sess_pool);
>> + rte_mempool_free(t->crypto_adptr.sess_priv_pool);
>> +
>> + return ret;
>> +}
>> +
>> +void
>> +perf_cryptodev_destroy(struct evt_test *test, struct evt_options *opt)
>> +{
>> + uint8_t cdev_id, cdev_count = rte_cryptodev_count();
>> + struct test_perf *t = evt_test_priv(test);
>> +
>> + RTE_SET_USED(opt);
>> +
>> + if (opt->prod_type != EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR)
>> + return;
>> +
>> + rte_event_crypto_adapter_stop(t->crypto_adptr.id);
>> +
>> + for (cdev_id = 0; cdev_id < cdev_count; cdev_id++) {
>> + rte_cryptodev_stop(cdev_id);
>> + rte_event_crypto_adapter_queue_pair_del(t-
>> >crypto_adptr.id,
>> + cdev_id, -1);
>Any reason for passing -1? This can not ensure to cleanup all the preconfigured
>qps as per API.
>> + }
>> +
>> + rte_event_crypto_adapter_free(t->crypto_adptr.id);
>> +
>> + rte_mempool_free(t->crypto_adptr.op_pool);
>> + rte_mempool_free(t->crypto_adptr.sess_pool);
>> + rte_mempool_free(t->crypto_adptr.sess_priv_pool);
>> +}
>> +
>> int
>> perf_mempool_setup(struct evt_test *test, struct evt_options *opt) { diff -
>> -git a/app/test-eventdev/test_perf_common.h b/app/test-
>> eventdev/test_perf_common.h
>> index 14dcf80429..d9ad3a0b0d 100644
>> --- a/app/test-eventdev/test_perf_common.h
>> +++ b/app/test-eventdev/test_perf_common.h
>> @@ -9,9 +9,11 @@
>> #include <stdbool.h>
>> #include <unistd.h>
>>
>> +#include <rte_cryptodev.h>
>> #include <rte_cycles.h>
>> #include <rte_ethdev.h>
>> #include <rte_eventdev.h>
>> +#include <rte_event_crypto_adapter.h>
>> #include <rte_event_eth_rx_adapter.h>
>> #include <rte_event_timer_adapter.h>
>> #include <rte_lcore.h>
>> @@ -37,9 +39,18 @@ struct prod_data {
>> uint8_t dev_id;
>> uint8_t port_id;
>> uint8_t queue_id;
>> + uint8_t cdev_id;
>> + uint16_t cdev_qp_id;
>> + struct rte_cryptodev_sym_session **crypto_sess;
>> struct test_perf *t;
>> } __rte_cache_aligned;
>>
>> +struct crypto_adptr_data {
>> + uint8_t id;
>> + struct rte_mempool *op_pool;
>> + struct rte_mempool *sess_pool;
>> + struct rte_mempool *sess_priv_pool;
>> +};
>>
>> struct test_perf {
>> /* Don't change the offset of "done". Signal handler use this memory
>> @@ -58,6 +69,7 @@ struct test_perf {
>> uint8_t sched_type_list[EVT_MAX_STAGES] __rte_cache_aligned;
>> struct rte_event_timer_adapter *timer_adptr[
>> RTE_EVENT_TIMER_ADAPTER_NUM_MAX]
>> __rte_cache_aligned;
>> + struct crypto_adptr_data crypto_adptr;
>> } __rte_cache_aligned;
>>
>> struct perf_elt {
>> @@ -81,6 +93,8 @@ struct perf_elt {
>> const uint8_t port = w->port_id;\
>> const uint8_t prod_timer_type = \
>> opt->prod_type ==
>> EVT_PROD_TYPE_EVENT_TIMER_ADPTR;\
>> + const uint8_t prod_crypto_type = \
>> + opt->prod_type ==
>> EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR;\
>> uint8_t *const sched_type_list = &t->sched_type_list[0];\
>> struct rte_mempool *const pool = t->pool;\
>> const uint8_t nb_stages = t->opt->nb_stages;\ @@ -154,6 +168,7
>> @@ int perf_test_result(struct evt_test *test, struct evt_options *opt); int
>> perf_opt_check(struct evt_options *opt, uint64_t nb_queues); int
>> perf_test_setup(struct evt_test *test, struct evt_options *opt); int
>> perf_ethdev_setup(struct evt_test *test, struct evt_options *opt);
>> +int perf_cryptodev_setup(struct evt_test *test, struct evt_options
>> +*opt);
>> int perf_mempool_setup(struct evt_test *test, struct evt_options *opt); int
>> perf_event_dev_port_setup(struct evt_test *test, struct evt_options *opt,
>> uint8_t stride, uint8_t nb_queues,
>> @@ -164,6 +179,7 @@ int perf_launch_lcores(struct evt_test *test, struct
>> evt_options *opt, void perf_opt_dump(struct evt_options *opt, uint8_t
>> nb_queues); void perf_test_destroy(struct evt_test *test, struct
>> evt_options *opt); void perf_eventdev_destroy(struct evt_test *test, struct
>> evt_options *opt);
>> +void perf_cryptodev_destroy(struct evt_test *test, struct evt_options
>> +*opt);
>> void perf_ethdev_destroy(struct evt_test *test, struct evt_options *opt);
>> void perf_mempool_destroy(struct evt_test *test, struct evt_options *opt);
>>
>> diff --git a/app/test-eventdev/test_perf_queue.c b/app/test-
>> eventdev/test_perf_queue.c
>> index f4ea3a795f..5657c8b3cd 100644
>> --- a/app/test-eventdev/test_perf_queue.c
>> +++ b/app/test-eventdev/test_perf_queue.c
>> @@ -49,6 +49,23 @@ perf_queue_worker(void *arg, const int
>> enable_fwd_latency)
>> rte_pause();
>> continue;
>> }
>> +
>> + if (prod_crypto_type &&
>> + (ev.event_type == RTE_EVENT_TYPE_CRYPTODEV)) {
>> + struct rte_crypto_op *op = ev.event_ptr;
>> +
>> + if (op->status ==
>> RTE_CRYPTO_OP_STATUS_SUCCESS) {
>> + if (op->sym->m_dst == NULL)
>> + ev.event_ptr = op->sym->m_src;
>> + else
>> + ev.event_ptr = op->sym->m_dst;
>> + rte_crypto_op_free(op);
>> + } else {
>> + rte_crypto_op_free(op);
>> + continue;
>In case of failure, ops are freed and "ev.event_ptr" won't be set to mbuf.
>What would be the expected test result?
>> + }
>> + }
>> +
>> if (enable_fwd_latency && !prod_timer_type)
>> /* first q in pipeline, mark timestamp to compute fwd latency
>> */
>> mark_fwd_latency(&ev, nb_stages);
>> @@ -88,6 +105,25 @@ perf_queue_worker_burst(void *arg, const int
>> enable_fwd_latency)
>> }
>>
>> for (i = 0; i < nb_rx; i++) {
>> + if (prod_crypto_type &&
>> + (ev[i].event_type ==
>> RTE_EVENT_TYPE_CRYPTODEV)) {
>> + struct rte_crypto_op *op = ev[i].event_ptr;
>> +
>> + if (op->status ==
>> + RTE_CRYPTO_OP_STATUS_SUCCESS) {
>> + if (op->sym->m_dst == NULL)
>> + ev[i].event_ptr =
>> + op->sym->m_src;
>> + else
>> + ev[i].event_ptr =
>> + op->sym->m_dst;
>> + rte_crypto_op_free(op);
>> + } else {
>> + rte_crypto_op_free(op);
>> + continue;
>> + }
>> + }
>> +
>> if (enable_fwd_latency && !prod_timer_type) {
>> rte_prefetch0(ev[i+1].event_ptr);
>> /* first queue in pipeline.
>> @@ -269,6 +305,20 @@ perf_queue_eventdev_setup(struct evt_test *test,
>> struct evt_options *opt)
>> return ret;
>> }
>> }
>> + } else if (opt->prod_type ==
>> EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR) {
>> + uint8_t cdev_id, cdev_count;
>> +
>> + cdev_count = rte_cryptodev_count();
>> + for (cdev_id = 0; cdev_id < cdev_count; cdev_id++) {
>> + ret = rte_cryptodev_start(cdev_id);
>> + if (ret) {
>> + evt_err("Failed to start cryptodev %u",
>> + cdev_id);
>> + return ret;
>> + }
>> + }
>> +
>> + rte_event_crypto_adapter_start(t->crypto_adptr.id);
>> }
>>
>> return 0;
>> @@ -311,11 +361,13 @@ static const struct evt_test_ops perf_queue = {
>> .test_setup = perf_test_setup,
>> .mempool_setup = perf_mempool_setup,
>> .ethdev_setup = perf_ethdev_setup,
>> + .cryptodev_setup = perf_cryptodev_setup,
>> .eventdev_setup = perf_queue_eventdev_setup,
>> .launch_lcores = perf_queue_launch_lcores,
>> .eventdev_destroy = perf_eventdev_destroy,
>> .mempool_destroy = perf_mempool_destroy,
>> .ethdev_destroy = perf_ethdev_destroy,
>> + .cryptodev_destroy = perf_cryptodev_destroy,
>> .test_result = perf_test_result,
>> .test_destroy = perf_test_destroy,
>> };
>> diff --git a/doc/guides/tools/testeventdev.rst
>> b/doc/guides/tools/testeventdev.rst
>> index 48efb9ea6e..f7d813226d 100644
>> --- a/doc/guides/tools/testeventdev.rst
>> +++ b/doc/guides/tools/testeventdev.rst
>> @@ -120,6 +120,10 @@ The following are the application command-line
>> options:
>>
>> Use burst mode event timer adapter as producer.
>>
>> +* ``--prod_type_cryptodev``
>> +
>> + Use crypto device as producer.
>> +
>> * ``--timer_tick_nsec``
>>
>> Used to dictate number of nano seconds between bucket traversal of
>> the @@ -148,6 +152,11 @@ The following are the application command-line
>> options:
>> timeout is out of the supported range of event device it will be
>> adjusted to the highest/lowest supported dequeue timeout supported.
>>
>> +* ``--crypto_adptr_mode``
>> +
>> + Set crypto adapter mode. Use 0 for OP_NEW (default) and 1 for
>> + OP_FORWARD mode.
>> +
>> * ``--mbuf_sz``
>>
>> Set packet mbuf size. Can be used to configure Jumbo Frames. Only @@
>> -420,6 +429,7 @@ Supported application command line options are
>> following::
>> --prod_type_ethdev
>> --prod_type_timerdev_burst
>> --prod_type_timerdev
>> + --prod_type_cryptodev
>> --prod_enq_burst_sz
>> --timer_tick_nsec
>> --max_tmo_nsec
>> @@ -427,6 +437,7 @@ Supported application command line options are
>> following::
>> --nb_timers
>> --nb_timer_adptrs
>> --deq_tmo_nsec
>> + --crypto_adptr_mode
>>
>> Example
>> ^^^^^^^
>> @@ -529,12 +540,14 @@ Supported application command line options are
>> following::
>> --prod_type_ethdev
>> --prod_type_timerdev_burst
>> --prod_type_timerdev
>> + --prod_type_cryptodev
>> --timer_tick_nsec
>> --max_tmo_nsec
>> --expiry_nsec
>> --nb_timers
>> --nb_timer_adptrs
>> --deq_tmo_nsec
>> + --crypto_adptr_mode
>>
>> Example
>> ^^^^^^^
>> --
>> 2.25.1
^ permalink raw reply [flat|nested] 43+ messages in thread
* RE: [PATCH v3] app/eventdev: add crypto producer mode
2022-01-23 18:44 ` Gujjar, Abhinandan S
2022-01-24 6:09 ` Shijith Thotton
@ 2022-01-24 6:59 ` Shijith Thotton
2022-01-25 14:15 ` Gujjar, Abhinandan S
2022-01-25 13:39 ` Gujjar, Abhinandan S
2 siblings, 1 reply; 43+ messages in thread
From: Shijith Thotton @ 2022-01-24 6:59 UTC (permalink / raw)
To: Gujjar, Abhinandan S, dev, Jerin Jacob Kollanukkaran
Cc: Anoob Joseph, Pavan Nikhilesh Bhagavatula, Akhil Goyal
Missed some comments in last mail.
>>
>> In crypto producer mode, producer core enqueues cryptodev with software
>> generated crypto ops and worker core dequeues crypto completion events
>> from the eventdev. Event crypto metadata used for above processing is pre-
>> populated in each crypto session.
>>
>> Parameter --prod_type_cryptodev can be used to enable crypto producer
>> mode. Parameter --crypto_adptr_mode can be set to select the crypto
>> adapter mode, 0 for OP_NEW and 1 for OP_FORWARD.
>>
>> This mode can be used to measure the performance of crypto adapter.
>>
>> Example:
>> ./dpdk-test-eventdev -l 0-2 -w <EVENTDEV> -w <CRYPTODEV> -- \
>> --prod_type_cryptodev --crypto_adptr_mode 1 --test=perf_atq \
>> --stlist=a --wlcores 1 --plcores 2
>>
>> Signed-off-by: Shijith Thotton <sthotton@marvell.com>
>> ---
>> v3:
>> * Reduce dereference inside loop.
>>
>> v2:
>> * Fix RHEL compilation warning.
>>
>> app/test-eventdev/evt_common.h | 3 +
>> app/test-eventdev/evt_main.c | 13 +-
>> app/test-eventdev/evt_options.c | 27 ++
>> app/test-eventdev/evt_options.h | 12 +
>> app/test-eventdev/evt_test.h | 6 +
>> app/test-eventdev/test_perf_atq.c | 51 ++++
>> app/test-eventdev/test_perf_common.c | 410
>> ++++++++++++++++++++++++++- app/test-
>> eventdev/test_perf_common.h | 16 ++ app/test-
>> eventdev/test_perf_queue.c | 52 ++++
>> doc/guides/tools/testeventdev.rst | 13 +
>> 10 files changed, 596 insertions(+), 7 deletions(-)
>>
>> diff --git a/app/test-eventdev/evt_common.h b/app/test-
>> eventdev/evt_common.h index f466434459..2f301a7e79 100644
>> --- a/app/test-eventdev/evt_common.h
>> +++ b/app/test-eventdev/evt_common.h
>> @@ -7,6 +7,7 @@
>>
>> #include <rte_common.h>
>> #include <rte_debug.h>
>> +#include <rte_event_crypto_adapter.h>
>> #include <rte_eventdev.h>
>> #include <rte_service.h>
>>
>> @@ -39,6 +40,7 @@ enum evt_prod_type {
>> EVT_PROD_TYPE_SYNT, /* Producer type Synthetic i.e. CPU. */
>> EVT_PROD_TYPE_ETH_RX_ADPTR, /* Producer type Eth Rx Adapter.
>> */
>> EVT_PROD_TYPE_EVENT_TIMER_ADPTR, /* Producer type Timer
>> Adapter. */
>> + EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR, /* Producer type Crypto
>> Adapter. */
>> EVT_PROD_TYPE_MAX,
>> };
>>
>> @@ -77,6 +79,7 @@ struct evt_options {
>> uint64_t timer_tick_nsec;
>> uint64_t optm_timer_tick_nsec;
>> enum evt_prod_type prod_type;
>> + enum rte_event_crypto_adapter_mode crypto_adptr_mode;
>> };
>>
>> static inline bool
>> diff --git a/app/test-eventdev/evt_main.c b/app/test-eventdev/evt_main.c
>> index 194c980c7a..cef0fb1382 100644
>> --- a/app/test-eventdev/evt_main.c
>> +++ b/app/test-eventdev/evt_main.c
>> @@ -161,12 +161,19 @@ main(int argc, char **argv)
>> goto mempool_destroy;
>> }
>> }
>New line required
Will add.
>> + /* Test specific cryptodev setup */
>> + if (test->ops.cryptodev_setup) {
>> + if (test->ops.cryptodev_setup(test, &opt)) {
>> + evt_err("%s: cryptodev setup failed",
>> opt.test_name);
>> + goto ethdev_destroy;
>> + }
>> + }
>>
>> /* Test specific eventdev setup */
>> if (test->ops.eventdev_setup) {
>> if (test->ops.eventdev_setup(test, &opt)) {
>> evt_err("%s: eventdev setup failed",
>> opt.test_name);
>> - goto ethdev_destroy;
>> + goto cryptodev_destroy;
>> }
>> }
>>
>> @@ -197,6 +204,10 @@ main(int argc, char **argv)
>> if (test->ops.eventdev_destroy)
>> test->ops.eventdev_destroy(test, &opt);
>>
>> +cryptodev_destroy:
>> + if (test->ops.cryptodev_destroy)
>> + test->ops.cryptodev_destroy(test, &opt);
>> +
>> ethdev_destroy:
>> if (test->ops.ethdev_destroy)
>> test->ops.ethdev_destroy(test, &opt); diff --git a/app/test-
>> eventdev/evt_options.c b/app/test-eventdev/evt_options.c index
>> 753a7dbd7d..5ad1491020 100644
>> --- a/app/test-eventdev/evt_options.c
>> +++ b/app/test-eventdev/evt_options.c
>> @@ -122,6 +122,26 @@ evt_parse_timer_prod_type_burst(struct
>> evt_options *opt,
>> return 0;
>> }
>>
>> +static int
>> +evt_parse_crypto_prod_type(struct evt_options *opt,
>> + const char *arg __rte_unused)
>> +{
>> + opt->prod_type = EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR;
>> + return 0;
>> +}
>> +
>> +static int
>> +evt_parse_crypto_adptr_mode(struct evt_options *opt, const char *arg) {
>> + uint8_t mode;
>> + int ret;
>> +
>> + ret = parser_read_uint8(&mode, arg);
>> + opt->crypto_adptr_mode = mode ?
>> RTE_EVENT_CRYPTO_ADAPTER_OP_FORWARD :
>> +
>> RTE_EVENT_CRYPTO_ADAPTER_OP_NEW;
>> + return ret;
>> +}
>> +
>> static int
>> evt_parse_test_name(struct evt_options *opt, const char *arg) { @@ -
>> 335,6 +355,7 @@ usage(char *program)
>> "\t--queue_priority : enable queue priority\n"
>> "\t--deq_tmo_nsec : global dequeue timeout\n"
>> "\t--prod_type_ethdev : use ethernet device as
>> producer.\n"
>> + "\t--prod_type_cryptodev : use crypto device as
>> producer.\n"
>> "\t--prod_type_timerdev : use event timer device as
>> producer.\n"
>> "\t expity_nsec would be the timeout\n"
>> "\t in ns.\n"
>> @@ -345,6 +366,8 @@ usage(char *program)
>> "\t--timer_tick_nsec : timer tick interval in ns.\n"
>> "\t--max_tmo_nsec : max timeout interval in ns.\n"
>> "\t--expiry_nsec : event timer expiry ns.\n"
>> + "\t--crypto_adptr_mode : 0 for OP_NEW mode (default)
>> and\n"
>> + "\t 1 for OP_FORWARD mode.\n"
>> "\t--mbuf_sz : packet mbuf size.\n"
>> "\t--max_pkt_sz : max packet size.\n"
>> "\t--prod_enq_burst_sz : producer enqueue burst size.\n"
>> @@ -415,8 +438,10 @@ static struct option lgopts[] = {
>> { EVT_QUEUE_PRIORITY, 0, 0, 0 },
>> { EVT_DEQ_TMO_NSEC, 1, 0, 0 },
>> { EVT_PROD_ETHDEV, 0, 0, 0 },
>> + { EVT_PROD_CRYPTODEV, 0, 0, 0 },
>> { EVT_PROD_TIMERDEV, 0, 0, 0 },
>> { EVT_PROD_TIMERDEV_BURST, 0, 0, 0 },
>> + { EVT_CRYPTO_ADPTR_MODE, 1, 0, 0 },
>> { EVT_NB_TIMERS, 1, 0, 0 },
>> { EVT_NB_TIMER_ADPTRS, 1, 0, 0 },
>> { EVT_TIMER_TICK_NSEC, 1, 0, 0 },
>> @@ -455,8 +480,10 @@ evt_opts_parse_long(int opt_idx, struct evt_options
>> *opt)
>> { EVT_QUEUE_PRIORITY, evt_parse_queue_priority},
>> { EVT_DEQ_TMO_NSEC, evt_parse_deq_tmo_nsec},
>> { EVT_PROD_ETHDEV, evt_parse_eth_prod_type},
>> + { EVT_PROD_CRYPTODEV, evt_parse_crypto_prod_type},
>> { EVT_PROD_TIMERDEV, evt_parse_timer_prod_type},
>> { EVT_PROD_TIMERDEV_BURST,
>> evt_parse_timer_prod_type_burst},
>> + { EVT_CRYPTO_ADPTR_MODE,
>> evt_parse_crypto_adptr_mode},
>> { EVT_NB_TIMERS, evt_parse_nb_timers},
>> { EVT_NB_TIMER_ADPTRS, evt_parse_nb_timer_adptrs},
>> { EVT_TIMER_TICK_NSEC, evt_parse_timer_tick_nsec}, diff --
>> git a/app/test-eventdev/evt_options.h b/app/test-eventdev/evt_options.h
>> index 413d7092f0..2231c58801 100644
>> --- a/app/test-eventdev/evt_options.h
>> +++ b/app/test-eventdev/evt_options.h
>> @@ -9,6 +9,7 @@
>> #include <stdbool.h>
>>
>> #include <rte_common.h>
>> +#include <rte_cryptodev.h>
>> #include <rte_ethdev.h>
>> #include <rte_eventdev.h>
>> #include <rte_lcore.h>
>> @@ -33,8 +34,10 @@
>> #define EVT_QUEUE_PRIORITY ("queue_priority")
>> #define EVT_DEQ_TMO_NSEC ("deq_tmo_nsec")
>> #define EVT_PROD_ETHDEV ("prod_type_ethdev")
>> +#define EVT_PROD_CRYPTODEV ("prod_type_cryptodev")
>> #define EVT_PROD_TIMERDEV ("prod_type_timerdev")
>> #define EVT_PROD_TIMERDEV_BURST ("prod_type_timerdev_burst")
>> +#define EVT_CRYPTO_ADPTR_MODE ("crypto_adptr_mode")
>> #define EVT_NB_TIMERS ("nb_timers")
>> #define EVT_NB_TIMER_ADPTRS ("nb_timer_adptrs")
>> #define EVT_TIMER_TICK_NSEC ("timer_tick_nsec")
>> @@ -249,6 +252,8 @@ evt_prod_id_to_name(enum evt_prod_type
>> prod_type)
>> return "Ethdev Rx Adapter";
>> case EVT_PROD_TYPE_EVENT_TIMER_ADPTR:
>> return "Event timer adapter";
>> + case EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR:
>> + return "Event crypto adapter";
>> }
>>
>> return "";
>> @@ -288,6 +293,13 @@ evt_dump_producer_type(struct evt_options *opt)
>> evt_dump("timer_tick_nsec", "%"PRIu64"",
>> opt->timer_tick_nsec);
>> break;
>> + case EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR:
>> + snprintf(name, EVT_PROD_MAX_NAME_LEN,
>> + "Event crypto adapter producers");
>> + evt_dump("crypto adapter mode", "%s",
>> + opt->crypto_adptr_mode ? "OP_FORWARD" :
>> "OP_NEW");
>> + evt_dump("nb_cryptodev", "%u", rte_cryptodev_count());
>> + break;
>> }
>> evt_dump("prod_type", "%s", name);
>> }
>> diff --git a/app/test-eventdev/evt_test.h b/app/test-eventdev/evt_test.h
>> index f07d2c3336..50fa474ec2 100644
>> --- a/app/test-eventdev/evt_test.h
>> +++ b/app/test-eventdev/evt_test.h
>> @@ -29,6 +29,8 @@ typedef int (*evt_test_mempool_setup_t)
>> (struct evt_test *test, struct evt_options *opt); typedef int
>> (*evt_test_ethdev_setup_t)
>> (struct evt_test *test, struct evt_options *opt);
>> +typedef int (*evt_test_cryptodev_setup_t)
>> + (struct evt_test *test, struct evt_options *opt);
>> typedef int (*evt_test_eventdev_setup_t)
>> (struct evt_test *test, struct evt_options *opt); typedef int
>> (*evt_test_launch_lcores_t) @@ -39,6 +41,8 @@ typedef void
>> (*evt_test_eventdev_destroy_t)
>> (struct evt_test *test, struct evt_options *opt); typedef void
>> (*evt_test_ethdev_destroy_t)
>> (struct evt_test *test, struct evt_options *opt);
>> +typedef void (*evt_test_cryptodev_destroy_t)
>> + (struct evt_test *test, struct evt_options *opt);
>> typedef void (*evt_test_mempool_destroy_t)
>> (struct evt_test *test, struct evt_options *opt); typedef void
>> (*evt_test_destroy_t) @@ -52,10 +56,12 @@ struct evt_test_ops {
>> evt_test_mempool_setup_t mempool_setup;
>> evt_test_ethdev_setup_t ethdev_setup;
>> evt_test_eventdev_setup_t eventdev_setup;
>> + evt_test_cryptodev_setup_t cryptodev_setup;
>> evt_test_launch_lcores_t launch_lcores;
>> evt_test_result_t test_result;
>> evt_test_eventdev_destroy_t eventdev_destroy;
>> evt_test_ethdev_destroy_t ethdev_destroy;
>> + evt_test_cryptodev_destroy_t cryptodev_destroy;
>> evt_test_mempool_destroy_t mempool_destroy;
>> evt_test_destroy_t test_destroy;
>> };
>> diff --git a/app/test-eventdev/test_perf_atq.c b/app/test-
>> eventdev/test_perf_atq.c
>> index 8fd51004ee..dbb1dc8c0c 100644
>> --- a/app/test-eventdev/test_perf_atq.c
>> +++ b/app/test-eventdev/test_perf_atq.c
>> @@ -48,6 +48,22 @@ perf_atq_worker(void *arg, const int
>> enable_fwd_latency)
>> continue;
>> }
>>
>> + if (prod_crypto_type &&
>> + (ev.event_type == RTE_EVENT_TYPE_CRYPTODEV)) {
>> + struct rte_crypto_op *op = ev.event_ptr;
>> +
>> + if (op->status ==
>> RTE_CRYPTO_OP_STATUS_SUCCESS) {
>> + if (op->sym->m_dst == NULL)
>> + ev.event_ptr = op->sym->m_src;
>> + else
>> + ev.event_ptr = op->sym->m_dst;
>> + rte_crypto_op_free(op);
>> + } else {
>> + rte_crypto_op_free(op);
>> + continue;
>> + }
>> + }
>> +
>> if (enable_fwd_latency && !prod_timer_type)
>> /* first stage in pipeline, mark ts to compute fwd latency */
>> atq_mark_fwd_latency(&ev);
>> @@ -87,6 +103,25 @@ perf_atq_worker_burst(void *arg, const int
>> enable_fwd_latency)
>> }
>>
>> for (i = 0; i < nb_rx; i++) {
>> + if (prod_crypto_type &&
>> + (ev[i].event_type ==
>> RTE_EVENT_TYPE_CRYPTODEV)) {
>> + struct rte_crypto_op *op = ev[i].event_ptr;
>> +
>> + if (op->status ==
>> + RTE_CRYPTO_OP_STATUS_SUCCESS) {
>> + if (op->sym->m_dst == NULL)
>> + ev[i].event_ptr =
>> + op->sym->m_src;
>> + else
>> + ev[i].event_ptr =
>> + op->sym->m_dst;
>> + rte_crypto_op_free(op);
>> + } else {
>> + rte_crypto_op_free(op);
>> + continue;
>> + }
>> + }
>> +
>> if (enable_fwd_latency && !prod_timer_type) {
>> rte_prefetch0(ev[i+1].event_ptr);
>> /* first stage in pipeline.
>> @@ -254,6 +289,20 @@ perf_atq_eventdev_setup(struct evt_test *test,
>> struct evt_options *opt)
>> return ret;
>> }
>> }
>> + } else if (opt->prod_type ==
>> EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR) {
>> + uint8_t cdev_id, cdev_count;
>> +
>> + cdev_count = rte_cryptodev_count();
>> + for (cdev_id = 0; cdev_id < cdev_count; cdev_id++) {
>> + ret = rte_cryptodev_start(cdev_id);
>> + if (ret) {
>> + evt_err("Failed to start cryptodev %u",
>> + cdev_id);
>> + return ret;
>> + }
>> + }
>> +
>> + rte_event_crypto_adapter_start(t->crypto_adptr.id);
>> }
>>
>> return 0;
>> @@ -295,12 +344,14 @@ static const struct evt_test_ops perf_atq = {
>> .opt_dump = perf_atq_opt_dump,
>> .test_setup = perf_test_setup,
>> .ethdev_setup = perf_ethdev_setup,
>> + .cryptodev_setup = perf_cryptodev_setup,
>> .mempool_setup = perf_mempool_setup,
>> .eventdev_setup = perf_atq_eventdev_setup,
>> .launch_lcores = perf_atq_launch_lcores,
>> .eventdev_destroy = perf_eventdev_destroy,
>> .mempool_destroy = perf_mempool_destroy,
>> .ethdev_destroy = perf_ethdev_destroy,
>> + .cryptodev_destroy = perf_cryptodev_destroy,
>> .test_result = perf_test_result,
>> .test_destroy = perf_test_destroy,
>> };
>> diff --git a/app/test-eventdev/test_perf_common.c b/app/test-
>> eventdev/test_perf_common.c
>> index 9b73874151..91cb6748ee 100644
>> --- a/app/test-eventdev/test_perf_common.c
>> +++ b/app/test-eventdev/test_perf_common.c
>> @@ -6,6 +6,8 @@
>>
>> #include "test_perf_common.h"
>>
>> +#define NB_CRYPTODEV_DESCRIPTORS 128
>> +
>> int
>> perf_test_result(struct evt_test *test, struct evt_options *opt) { @@ -272,6
>> +274,125 @@ perf_event_timer_producer_burst(void *arg)
>> return 0;
>> }
>>
>> +static inline void
>> +crypto_adapter_enq_op_new(struct prod_data *p) {
>> + struct rte_cryptodev_sym_session **crypto_sess = p->crypto_sess;
>> + struct test_perf *t = p->t;
>> + const uint32_t nb_flows = t->nb_flows;
>> + const uint64_t nb_pkts = t->nb_pkts;
>> + struct rte_mempool *pool = t->pool;
>> + struct rte_crypto_sym_op *sym_op;
>> + struct evt_options *opt = t->opt;
>> + uint16_t qp_id = p->cdev_qp_id;
>> + uint8_t cdev_id = p->cdev_id;
>> + uint32_t flow_counter = 0;
>> + struct rte_crypto_op *op;
>> + struct rte_mbuf *m;
>> + uint64_t count = 0;
>> + uint16_t len;
>> +
>> + if (opt->verbose_level > 1)
>> + printf("%s(): lcore %d queue %d cdev_id %u cdev_qp_id
>> %u\n",
>> + __func__, rte_lcore_id(), p->queue_id, p->cdev_id,
>> + p->cdev_qp_id);
>> +
>> + len = opt->mbuf_sz ? opt->mbuf_sz : RTE_ETHER_MIN_LEN;
>> +
>> + while (count < nb_pkts && t->done == false) {
>> + m = rte_pktmbuf_alloc(pool);
>> + if (m == NULL)
>> + continue;
>> +
>> + rte_pktmbuf_append(m, len);
>> + op = rte_crypto_op_alloc(t->crypto_adptr.op_pool,
>> +
>> RTE_CRYPTO_OP_TYPE_SYMMETRIC);
>> + sym_op = op->sym;
>> + sym_op->m_src = m;
>> + sym_op->cipher.data.offset = 0;
>> + sym_op->cipher.data.length = len;
>> + rte_crypto_op_attach_sym_session(
>> + op, crypto_sess[flow_counter++ % nb_flows]);
>> + while (rte_cryptodev_enqueue_burst(cdev_id, qp_id, &op,
>> 1) !=
>> + 1) {
>> + if (t->done)
>> + break;
>> + rte_pause();
>> + }
>> + count++;
>> + }
>> +}
>> +
>> +static inline void
>> +crypto_adapter_enq_op_fwd(struct prod_data *p) {
>> + struct rte_cryptodev_sym_session **crypto_sess = p->crypto_sess;
>> + const uint8_t dev_id = p->dev_id;
>> + const uint8_t port = p->port_id;
>> + struct test_perf *t = p->t;
>> + const uint32_t nb_flows = t->nb_flows;
>> + const uint64_t nb_pkts = t->nb_pkts;
>> + struct rte_mempool *pool = t->pool;
>> + struct evt_options *opt = t->opt;
>> + struct rte_crypto_sym_op *sym_op;
>> + uint32_t flow_counter = 0;
>> + struct rte_crypto_op *op;
>> + struct rte_event ev;
>> + struct rte_mbuf *m;
>> + uint64_t count = 0;
>> + uint16_t len;
>> +
>> + if (opt->verbose_level > 1)
>> + printf("%s(): lcore %d port %d queue %d cdev_id %u
>> cdev_qp_id %u\n",
>> + __func__, rte_lcore_id(), port, p->queue_id, p->cdev_id,
>> + p->cdev_qp_id);
>> +
>> + ev.event = 0;
>> + ev.op = RTE_EVENT_OP_NEW;
>> + ev.queue_id = p->queue_id;
>> + ev.sched_type = RTE_SCHED_TYPE_ATOMIC;
>> + ev.event_type = RTE_EVENT_TYPE_CPU;
>> + len = opt->mbuf_sz ? opt->mbuf_sz : RTE_ETHER_MIN_LEN;
>> +
>> + while (count < nb_pkts && t->done == false) {
>> + m = rte_pktmbuf_alloc(pool);
>> + if (m == NULL)
>> + continue;
>> +
>> + rte_pktmbuf_append(m, len);
>> + op = rte_crypto_op_alloc(t->crypto_adptr.op_pool,
>> +
>> RTE_CRYPTO_OP_TYPE_SYMMETRIC);
>> + sym_op = op->sym;
>> + sym_op->m_src = m;
>> + sym_op->cipher.data.offset = 0;
>> + sym_op->cipher.data.length = len;
>> + rte_crypto_op_attach_sym_session(
>> + op, crypto_sess[flow_counter++ % nb_flows]);
>> + ev.event_ptr = op;
>> + while (rte_event_crypto_adapter_enqueue(dev_id, port,
>> &ev, 1) !=
>> + 1) {
>> + if (t->done)
>> + break;
>> + rte_pause();
>> + }
>> + count++;
>> + }
>> +}
>> +
>> +static inline int
>> +perf_event_crypto_producer(void *arg)
>> +{
>> + struct prod_data *p = arg;
>> + struct evt_options *opt = p->t->opt;
>> +
>> + if (opt->crypto_adptr_mode ==
>> RTE_EVENT_CRYPTO_ADAPTER_OP_NEW)
>> + crypto_adapter_enq_op_new(p);
>> + else
>> + crypto_adapter_enq_op_fwd(p);
>> +
>> + return 0;
>> +}
>> +
>> static int
>> perf_producer_wrapper(void *arg)
>> {
>> @@ -298,6 +419,8 @@ perf_producer_wrapper(void *arg)
>> else if (t->opt->prod_type ==
>> EVT_PROD_TYPE_EVENT_TIMER_ADPTR &&
>> t->opt->timdev_use_burst)
>> return perf_event_timer_producer_burst(arg);
>> + else if (t->opt->prod_type ==
>> EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR)
>> + return perf_event_crypto_producer(arg);
>> return 0;
>> }
>>
>> @@ -405,8 +528,10 @@ perf_launch_lcores(struct evt_test *test, struct
>> evt_options *opt,
>> if (remaining <= 0) {
>> t->result = EVT_TEST_SUCCESS;
>> if (opt->prod_type ==
>> EVT_PROD_TYPE_SYNT ||
>> - opt->prod_type ==
>> -
>> EVT_PROD_TYPE_EVENT_TIMER_ADPTR) {
>> + opt->prod_type ==
>> +
>> EVT_PROD_TYPE_EVENT_TIMER_ADPTR ||
>> + opt->prod_type ==
>> +
>> EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR) {
>> t->done = true;
>> break;
>> }
>> @@ -415,7 +540,8 @@ perf_launch_lcores(struct evt_test *test, struct
>> evt_options *opt,
>>
>> if (new_cycles - dead_lock_cycles > dead_lock_sample &&
>> (opt->prod_type == EVT_PROD_TYPE_SYNT ||
>> - opt->prod_type ==
>> EVT_PROD_TYPE_EVENT_TIMER_ADPTR)) {
>> + opt->prod_type ==
>> EVT_PROD_TYPE_EVENT_TIMER_ADPTR ||
>> + opt->prod_type ==
>> EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR)) {
>> remaining = t->outstand_pkts - processed_pkts(t);
>> if (dead_lock_remaining == remaining) {
>> rte_event_dev_dump(opt->dev_id, stdout);
>> @@ -537,6 +663,96 @@ perf_event_timer_adapter_setup(struct test_perf
>> *t)
>> return 0;
>> }
>>
>> +static int
>> +perf_event_crypto_adapter_setup(struct test_perf *t,
>> + struct rte_event_port_conf port_conf) {
>> + struct evt_options *opt = t->opt;
>> + uint8_t cdev_id, cdev_count;
>> + int ret;
>> +
>> + t->crypto_adptr.id = 0;
>> + ret = rte_event_crypto_adapter_create(t->crypto_adptr.id, opt-
>> >dev_id,
>> + &port_conf, 0);
>> + if (ret)
>> + return ret;
>> +
>> + cdev_count = rte_cryptodev_count();
>> + for (cdev_id = 0; cdev_id < cdev_count; cdev_id++) {
>> + uint32_t cap;
>> +
>> + ret = rte_event_crypto_adapter_caps_get(opt->dev_id,
>> cdev_id,
>> + &cap);
>> + if (ret) {
>> + evt_err("Failed to get crypto adapter capabilities");
>> + return ret;
>> + }
>> +
>> + if (((opt->crypto_adptr_mode ==
>> + RTE_EVENT_CRYPTO_ADAPTER_OP_NEW) &&
>> + !(cap &
>> +
>> RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_OP_NEW)) ||
>> + ((opt->crypto_adptr_mode ==
>> + RTE_EVENT_CRYPTO_ADAPTER_OP_FORWARD) &&
>> + !(cap &
>> +
>> RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_OP_FWD))) {
>> + evt_err("crypto adapter %s mode unsupported\n",
>> + opt->crypto_adptr_mode ? "OP_FORWARD"
>> :
>> + "OP_NEW");
>> + return -EINVAL;
>> + }
>> +
>> + if (!(cap &
>> +
>> RTE_EVENT_CRYPTO_ADAPTER_CAP_SESSION_PRIVATE_DATA)) {
>> + evt_err("Storing crypto session not supported");
>> + return -EINVAL;
>> + }
>> +
>> + if (cap &
>> +
>> RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_QP_EV_BIND) {
>> + struct rte_event response_info;
>> +
>> + response_info.event = 0;
>> + ret = rte_event_crypto_adapter_queue_pair_add(
>> + t->crypto_adptr.id, cdev_id, -1,
>> + &response_info);
>> + } else {
>> + ret = rte_event_crypto_adapter_queue_pair_add(
>> + t->crypto_adptr.id, cdev_id, -1, NULL);
>> + }
>> + if (ret)
>> + return ret;
>> + }
>> +
>> + return 0;
>> +}
>> +
>> +static struct rte_cryptodev_sym_session *
>> +cryptodev_sym_sess_create(struct prod_data *p, struct test_perf *t) {
>> + struct rte_crypto_sym_xform cipher_xform;
>> + struct rte_cryptodev_sym_session *sess;
>> +
>> + cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
>> + cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
>> + cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
>> + cipher_xform.next = NULL;
>> +
>> + sess = rte_cryptodev_sym_session_create(t-
>> >crypto_adptr.sess_pool);
>> + if (sess == NULL) {
>> + evt_err("Failed to create sym session");
>> + return NULL;
>> + }
>> +
>> + if (rte_cryptodev_sym_session_init(p->cdev_id, sess,
>> &cipher_xform,
>> + t->crypto_adptr.sess_priv_pool)) {
>> + evt_err("Failed to init session");
>> + return NULL;
>> + }
>> +
>> + return sess;
>> +}
>> +
>> int
>> perf_event_dev_port_setup(struct evt_test *test, struct evt_options *opt,
>> uint8_t stride, uint8_t nb_queues,
>> @@ -598,6 +814,55 @@ perf_event_dev_port_setup(struct evt_test *test,
>> struct evt_options *opt,
>> ret = perf_event_timer_adapter_setup(t);
>> if (ret)
>> return ret;
>> + } else if (opt->prod_type ==
>> EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR) {
>> + uint8_t cdev_id = 0;
>> + uint16_t qp_id = 0;
>> +
>> + prod = 0;
>> + for (; port < perf_nb_event_ports(opt); port++) {
>> + struct rte_cryptodev_sym_session *crypto_sess;
>> + union rte_event_crypto_metadata m_data;
>> + struct prod_data *p = &t->prod[port];
>> + uint32_t flow_id;
>> +
>> + if (qp_id ==
>> rte_cryptodev_queue_pair_count(cdev_id)) {
>> + cdev_id++;
>> + qp_id = 0;
>> + }
>> +
>> + p->dev_id = opt->dev_id;
>> + p->port_id = port;
>> + p->queue_id = prod * stride;
>> + p->cdev_id = cdev_id;
>> + p->cdev_qp_id = qp_id;
>> + p->crypto_sess = rte_zmalloc_socket(
>> + NULL, sizeof(crypto_sess) * t->nb_flows,
>> + RTE_CACHE_LINE_SIZE, opt->socket_id);
>> +
>> + m_data.request_info.cdev_id = p->cdev_id;
>> + m_data.request_info.queue_pair_id = p-
>> >cdev_qp_id;
>> + m_data.response_info.op = RTE_EVENT_OP_NEW;
>> + m_data.response_info.sched_type =
>> RTE_SCHED_TYPE_ATOMIC;
>> + m_data.response_info.event_type =
>> RTE_EVENT_TYPE_CPU;
>> + m_data.response_info.queue_id = p->queue_id;
>> + for (flow_id = 0; flow_id < t->nb_flows; flow_id++) {
>> + crypto_sess =
>> cryptodev_sym_sess_create(p, t);
>> + if (crypto_sess == NULL)
>> + return -ENOMEM;
>> +
>> + m_data.response_info.flow_id = flow_id;
>> + rte_cryptodev_sym_session_set_user_data(
>> + crypto_sess, &m_data,
>> sizeof(m_data));
>> + p->crypto_sess[flow_id] = crypto_sess;
>> + }
>> + p->t = t;
>> + qp_id++;
>> + prod++;
>> + }
>> +
>> + ret = perf_event_crypto_adapter_setup(t, *port_conf);
>> + if (ret)
>> + return ret;
>> } else {
>> prod = 0;
>> for ( ; port < perf_nb_event_ports(opt); port++) { @@ -659,7
>> +924,8 @@ perf_opt_check(struct evt_options *opt, uint64_t nb_queues)
>> }
>>
>> if (opt->prod_type == EVT_PROD_TYPE_SYNT ||
>> - opt->prod_type ==
>> EVT_PROD_TYPE_EVENT_TIMER_ADPTR) {
>> + opt->prod_type == EVT_PROD_TYPE_EVENT_TIMER_ADPTR ||
>> + opt->prod_type == EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR) {
>> /* Validate producer lcores */
>> if (evt_lcores_has_overlap(opt->plcores,
>> rte_get_main_lcore())) {
>> @@ -767,8 +1033,7 @@ perf_ethdev_setup(struct evt_test *test, struct
>> evt_options *opt)
>> },
>> };
>>
>> - if (opt->prod_type == EVT_PROD_TYPE_SYNT ||
>> - opt->prod_type ==
>> EVT_PROD_TYPE_EVENT_TIMER_ADPTR)
>> + if (opt->prod_type != EVT_PROD_TYPE_ETH_RX_ADPTR)
>> return 0;
>>
>> if (!rte_eth_dev_count_avail()) {
>> @@ -841,6 +1106,139 @@ void perf_ethdev_destroy(struct evt_test *test,
>> struct evt_options *opt)
>> }
>> }
>>
>> +int
>> +perf_cryptodev_setup(struct evt_test *test, struct evt_options *opt) {
>> + uint8_t cdev_count, cdev_id, nb_plcores, nb_qps;
>> + struct test_perf *t = evt_test_priv(test);
>> + unsigned int max_session_size;
>> + uint32_t nb_sessions;
>> + int ret;
>> +
>> + if (opt->prod_type != EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR)
>> + return 0;
>How do you differentiate between this failed case as you are returning 0 in case of
>success?
This is not a failed case. cryptodev setup is not needed in other modes and is ignored.
>> +
>> + cdev_count = rte_cryptodev_count();
>> + if (cdev_count == 0) {
>> + evt_err("No crypto devices available\n");
>> + return -ENODEV;
>> + }
>> +
>> + t->crypto_adptr.op_pool = rte_crypto_op_pool_create(
>> + "crypto_op_pool", RTE_CRYPTO_OP_TYPE_SYMMETRIC, opt-
>> >pool_sz,
>> + 128, 0, rte_socket_id());
>> + if (t->crypto_adptr.op_pool == NULL) {
>> + evt_err("Failed to create crypto op pool");
>> + return -ENOMEM;
>> + }
>> +
>> + nb_sessions = evt_nr_active_lcores(opt->plcores) * t->nb_flows;
>> + t->crypto_adptr.sess_pool =
>> rte_cryptodev_sym_session_pool_create(
>> + "ca_sess_pool", nb_sessions, 0, 0,
>> + sizeof(union rte_event_crypto_metadata),
>> SOCKET_ID_ANY);
>> + if (t->crypto_adptr.sess_pool == NULL) {
>> + evt_err("Failed to create sym session pool");
>> + ret = -ENOMEM;
>> + goto err;
>> + }
>> +
>> + max_session_size = 0;
>> + for (cdev_id = 0; cdev_id < cdev_count; cdev_id++) {
>> + unsigned int session_size;
>> +
>> + session_size =
>> +
>> rte_cryptodev_sym_get_private_session_size(cdev_id);
>> + if (session_size > max_session_size)
>> + max_session_size = session_size;
>> + }
>New line required
Will add.
>> + max_session_size += sizeof(union rte_event_crypto_metadata);
>> + t->crypto_adptr.sess_priv_pool = rte_mempool_create(
>> + "ca_sess_priv_pool", nb_sessions, max_session_size, 0, 0,
>> NULL,
>> + NULL, NULL, NULL, SOCKET_ID_ANY, 0);
>> + if (t->crypto_adptr.sess_priv_pool == NULL) {
>> + evt_err("failed to create sym session private pool");
>> + ret = -ENOMEM;
>> + goto err;
>> + }
>> +
>> + nb_plcores = evt_nr_active_lcores(opt->plcores);
>> + nb_qps = (nb_plcores % cdev_count) ? (nb_plcores / cdev_count) +
>> 1 :
>> + nb_plcores / cdev_count;
>Let's take an example:
>Cdev1 -> 8 qps
>Cdev2 -> 2 qps
>Cdev_count = 2
>nb_plcores = 7
>As per above statement, nb_qps = ( 7 % 2 ) 7/2 + 1 = 4 qps
>So, this fails to setup qps for cdev2 as it supports only 2 qps and test exits! Am I
>missing anything?
>
What you told is correct. But this is a simple logic to distribute qps across
multiple cdev and doesn't consider the case you mentioned. You could see
similar logic used in other apps. I will add a comment as below:
/*
* Calculate number of needed queue pairs, based on the amount
* of available number of logical cores and crypto devices.
* For instance, if there are 4 cores and 2 crypto devices,
* 2 queue pairs will be set up per device.
*/
>> + for (cdev_id = 0; cdev_id < cdev_count; cdev_id++) {
>> + struct rte_cryptodev_qp_conf qp_conf;
>> + struct rte_cryptodev_config conf;
>> + struct rte_cryptodev_info info;
>> + int qp_id;
>> +
>> + rte_cryptodev_info_get(cdev_id, &info);
>> + if (nb_qps > info.max_nb_queue_pairs) {
>> + evt_err("Not enough queue pairs per cryptodev
>> (%u)",
>> + nb_qps);
>> + ret = -EINVAL;
>> + goto err;
>> + }
>> +
>> + conf.nb_queue_pairs = nb_qps;
>> + conf.socket_id = SOCKET_ID_ANY;
>> + conf.ff_disable = RTE_CRYPTODEV_FF_SECURITY;
>> +
>> + ret = rte_cryptodev_configure(cdev_id, &conf);
>> + if (ret) {
>> + evt_err("Failed to configure cryptodev (%u)",
>> cdev_id);
>> + goto err;
>> + }
>> +
>> + qp_conf.nb_descriptors = NB_CRYPTODEV_DESCRIPTORS;
>> + qp_conf.mp_session = t->crypto_adptr.sess_pool;
>> + qp_conf.mp_session_private = t-
>> >crypto_adptr.sess_priv_pool;
>> +
>> + for (qp_id = 0; qp_id < conf.nb_queue_pairs; qp_id++) {
>> + ret = rte_cryptodev_queue_pair_setup(
>> + cdev_id, qp_id, &qp_conf,
>> + rte_cryptodev_socket_id(cdev_id));
>> + if (ret) {
>> + evt_err("Failed to setup queue pairs on
>> cryptodev %u\n",
>> + cdev_id);
>> + goto err;
>> + }
>> + }
>> + }
>> +
>> + return 0;
>> +err:
>> + rte_mempool_free(t->crypto_adptr.op_pool);
>> + rte_mempool_free(t->crypto_adptr.sess_pool);
>> + rte_mempool_free(t->crypto_adptr.sess_priv_pool);
>> +
>> + return ret;
>> +}
>> +
>> +void
>> +perf_cryptodev_destroy(struct evt_test *test, struct evt_options *opt)
>> +{
>> + uint8_t cdev_id, cdev_count = rte_cryptodev_count();
>> + struct test_perf *t = evt_test_priv(test);
>> +
>> + RTE_SET_USED(opt);
>> +
>> + if (opt->prod_type != EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR)
>> + return;
>> +
>> + rte_event_crypto_adapter_stop(t->crypto_adptr.id);
>> +
>> + for (cdev_id = 0; cdev_id < cdev_count; cdev_id++) {
>> + rte_cryptodev_stop(cdev_id);
>> + rte_event_crypto_adapter_queue_pair_del(t-
>> >crypto_adptr.id,
>> + cdev_id, -1);
>Any reason for passing -1? This can not ensure to cleanup all the preconfigured
>qps as per API.
Okay, I thought the behavior is like rte_event_crypto_adapter_queue_pair_add.
Any reason, spec desn't consider -1 for rte_event_crypto_adapter_queue_pair_del ?
>> + }
>> +
>> + rte_event_crypto_adapter_free(t->crypto_adptr.id);
>> +
>> + rte_mempool_free(t->crypto_adptr.op_pool);
>> + rte_mempool_free(t->crypto_adptr.sess_pool);
>> + rte_mempool_free(t->crypto_adptr.sess_priv_pool);
>> +}
>> +
>> int
>> perf_mempool_setup(struct evt_test *test, struct evt_options *opt) { diff -
>> -git a/app/test-eventdev/test_perf_common.h b/app/test-
>> eventdev/test_perf_common.h
>> index 14dcf80429..d9ad3a0b0d 100644
>> --- a/app/test-eventdev/test_perf_common.h
>> +++ b/app/test-eventdev/test_perf_common.h
>> @@ -9,9 +9,11 @@
>> #include <stdbool.h>
>> #include <unistd.h>
>>
>> +#include <rte_cryptodev.h>
>> #include <rte_cycles.h>
>> #include <rte_ethdev.h>
>> #include <rte_eventdev.h>
>> +#include <rte_event_crypto_adapter.h>
>> #include <rte_event_eth_rx_adapter.h>
>> #include <rte_event_timer_adapter.h>
>> #include <rte_lcore.h>
>> @@ -37,9 +39,18 @@ struct prod_data {
>> uint8_t dev_id;
>> uint8_t port_id;
>> uint8_t queue_id;
>> + uint8_t cdev_id;
>> + uint16_t cdev_qp_id;
>> + struct rte_cryptodev_sym_session **crypto_sess;
>> struct test_perf *t;
>> } __rte_cache_aligned;
>>
>> +struct crypto_adptr_data {
>> + uint8_t id;
>> + struct rte_mempool *op_pool;
>> + struct rte_mempool *sess_pool;
>> + struct rte_mempool *sess_priv_pool;
>> +};
>>
>> struct test_perf {
>> /* Don't change the offset of "done". Signal handler use this memory
>> @@ -58,6 +69,7 @@ struct test_perf {
>> uint8_t sched_type_list[EVT_MAX_STAGES] __rte_cache_aligned;
>> struct rte_event_timer_adapter *timer_adptr[
>> RTE_EVENT_TIMER_ADAPTER_NUM_MAX]
>> __rte_cache_aligned;
>> + struct crypto_adptr_data crypto_adptr;
>> } __rte_cache_aligned;
>>
>> struct perf_elt {
>> @@ -81,6 +93,8 @@ struct perf_elt {
>> const uint8_t port = w->port_id;\
>> const uint8_t prod_timer_type = \
>> opt->prod_type ==
>> EVT_PROD_TYPE_EVENT_TIMER_ADPTR;\
>> + const uint8_t prod_crypto_type = \
>> + opt->prod_type ==
>> EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR;\
>> uint8_t *const sched_type_list = &t->sched_type_list[0];\
>> struct rte_mempool *const pool = t->pool;\
>> const uint8_t nb_stages = t->opt->nb_stages;\ @@ -154,6 +168,7
>> @@ int perf_test_result(struct evt_test *test, struct evt_options *opt); int
>> perf_opt_check(struct evt_options *opt, uint64_t nb_queues); int
>> perf_test_setup(struct evt_test *test, struct evt_options *opt); int
>> perf_ethdev_setup(struct evt_test *test, struct evt_options *opt);
>> +int perf_cryptodev_setup(struct evt_test *test, struct evt_options
>> +*opt);
>> int perf_mempool_setup(struct evt_test *test, struct evt_options *opt); int
>> perf_event_dev_port_setup(struct evt_test *test, struct evt_options *opt,
>> uint8_t stride, uint8_t nb_queues,
>> @@ -164,6 +179,7 @@ int perf_launch_lcores(struct evt_test *test, struct
>> evt_options *opt, void perf_opt_dump(struct evt_options *opt, uint8_t
>> nb_queues); void perf_test_destroy(struct evt_test *test, struct
>> evt_options *opt); void perf_eventdev_destroy(struct evt_test *test, struct
>> evt_options *opt);
>> +void perf_cryptodev_destroy(struct evt_test *test, struct evt_options
>> +*opt);
>> void perf_ethdev_destroy(struct evt_test *test, struct evt_options *opt);
>> void perf_mempool_destroy(struct evt_test *test, struct evt_options *opt);
>>
>> diff --git a/app/test-eventdev/test_perf_queue.c b/app/test-
>> eventdev/test_perf_queue.c
>> index f4ea3a795f..5657c8b3cd 100644
>> --- a/app/test-eventdev/test_perf_queue.c
>> +++ b/app/test-eventdev/test_perf_queue.c
>> @@ -49,6 +49,23 @@ perf_queue_worker(void *arg, const int
>> enable_fwd_latency)
>> rte_pause();
>> continue;
>> }
>> +
>> + if (prod_crypto_type &&
>> + (ev.event_type == RTE_EVENT_TYPE_CRYPTODEV)) {
>> + struct rte_crypto_op *op = ev.event_ptr;
>> +
>> + if (op->status ==
>> RTE_CRYPTO_OP_STATUS_SUCCESS) {
>> + if (op->sym->m_dst == NULL)
>> + ev.event_ptr = op->sym->m_src;
>> + else
>> + ev.event_ptr = op->sym->m_dst;
>> + rte_crypto_op_free(op);
>> + } else {
>> + rte_crypto_op_free(op);
>> + continue;
>In case of failure, ops are freed and "ev.event_ptr" won't be set to mbuf.
>What would be the expected test result?
In case of error, processed_pkts is not updated. If all packets fails, output will be 0 PPS.
>> + }
>> + }
>> +
>> if (enable_fwd_latency && !prod_timer_type)
>> /* first q in pipeline, mark timestamp to compute fwd latency
>> */
>> mark_fwd_latency(&ev, nb_stages);
>> @@ -88,6 +105,25 @@ perf_queue_worker_burst(void *arg, const int
>> enable_fwd_latency)
>> }
>>
>> for (i = 0; i < nb_rx; i++) {
>> + if (prod_crypto_type &&
>> + (ev[i].event_type ==
>> RTE_EVENT_TYPE_CRYPTODEV)) {
>> + struct rte_crypto_op *op = ev[i].event_ptr;
>> +
>> + if (op->status ==
>> + RTE_CRYPTO_OP_STATUS_SUCCESS) {
>> + if (op->sym->m_dst == NULL)
>> + ev[i].event_ptr =
>> + op->sym->m_src;
>> + else
>> + ev[i].event_ptr =
>> + op->sym->m_dst;
>> + rte_crypto_op_free(op);
>> + } else {
>> + rte_crypto_op_free(op);
>> + continue;
>> + }
>> + }
>> +
>> if (enable_fwd_latency && !prod_timer_type) {
>> rte_prefetch0(ev[i+1].event_ptr);
>> /* first queue in pipeline.
>> @@ -269,6 +305,20 @@ perf_queue_eventdev_setup(struct evt_test *test,
>> struct evt_options *opt)
>> return ret;
>> }
>> }
>> + } else if (opt->prod_type ==
>> EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR) {
>> + uint8_t cdev_id, cdev_count;
>> +
>> + cdev_count = rte_cryptodev_count();
>> + for (cdev_id = 0; cdev_id < cdev_count; cdev_id++) {
>> + ret = rte_cryptodev_start(cdev_id);
>> + if (ret) {
>> + evt_err("Failed to start cryptodev %u",
>> + cdev_id);
>> + return ret;
>> + }
>> + }
>> +
>> + rte_event_crypto_adapter_start(t->crypto_adptr.id);
>> }
>>
>> return 0;
>> @@ -311,11 +361,13 @@ static const struct evt_test_ops perf_queue = {
>> .test_setup = perf_test_setup,
>> .mempool_setup = perf_mempool_setup,
>> .ethdev_setup = perf_ethdev_setup,
>> + .cryptodev_setup = perf_cryptodev_setup,
>> .eventdev_setup = perf_queue_eventdev_setup,
>> .launch_lcores = perf_queue_launch_lcores,
>> .eventdev_destroy = perf_eventdev_destroy,
>> .mempool_destroy = perf_mempool_destroy,
>> .ethdev_destroy = perf_ethdev_destroy,
>> + .cryptodev_destroy = perf_cryptodev_destroy,
>> .test_result = perf_test_result,
>> .test_destroy = perf_test_destroy,
>> };
>> diff --git a/doc/guides/tools/testeventdev.rst
>> b/doc/guides/tools/testeventdev.rst
>> index 48efb9ea6e..f7d813226d 100644
>> --- a/doc/guides/tools/testeventdev.rst
>> +++ b/doc/guides/tools/testeventdev.rst
>> @@ -120,6 +120,10 @@ The following are the application command-line
>> options:
>>
>> Use burst mode event timer adapter as producer.
>>
>> +* ``--prod_type_cryptodev``
>> +
>> + Use crypto device as producer.
>> +
>> * ``--timer_tick_nsec``
>>
>> Used to dictate number of nano seconds between bucket traversal of
>> the @@ -148,6 +152,11 @@ The following are the application command-line
>> options:
>> timeout is out of the supported range of event device it will be
>> adjusted to the highest/lowest supported dequeue timeout supported.
>>
>> +* ``--crypto_adptr_mode``
>> +
>> + Set crypto adapter mode. Use 0 for OP_NEW (default) and 1 for
>> + OP_FORWARD mode.
>> +
>> * ``--mbuf_sz``
>>
>> Set packet mbuf size. Can be used to configure Jumbo Frames. Only @@
>> -420,6 +429,7 @@ Supported application command line options are
>> following::
>> --prod_type_ethdev
>> --prod_type_timerdev_burst
>> --prod_type_timerdev
>> + --prod_type_cryptodev
>> --prod_enq_burst_sz
>> --timer_tick_nsec
>> --max_tmo_nsec
>> @@ -427,6 +437,7 @@ Supported application command line options are
>> following::
>> --nb_timers
>> --nb_timer_adptrs
>> --deq_tmo_nsec
>> + --crypto_adptr_mode
>>
>> Example
>> ^^^^^^^
>> @@ -529,12 +540,14 @@ Supported application command line options are
>> following::
>> --prod_type_ethdev
>> --prod_type_timerdev_burst
>> --prod_type_timerdev
>> + --prod_type_cryptodev
>> --timer_tick_nsec
>> --max_tmo_nsec
>> --expiry_nsec
>> --nb_timers
>> --nb_timer_adptrs
>> --deq_tmo_nsec
>> + --crypto_adptr_mode
>>
>> Example
>> ^^^^^^^
>> --
>> 2.25.1
^ permalink raw reply [flat|nested] 43+ messages in thread
* RE: [PATCH v3] app/eventdev: add crypto producer mode
2022-01-23 18:44 ` Gujjar, Abhinandan S
2022-01-24 6:09 ` Shijith Thotton
2022-01-24 6:59 ` Shijith Thotton
@ 2022-01-25 13:39 ` Gujjar, Abhinandan S
2022-02-08 17:00 ` Shijith Thotton
2 siblings, 1 reply; 43+ messages in thread
From: Gujjar, Abhinandan S @ 2022-01-25 13:39 UTC (permalink / raw)
To: Shijith Thotton, dev, jerinj; +Cc: anoobj, pbhagavatula, gakhil
Hi Shijith,
Some more comments.
> -----Original Message-----
> From: Gujjar, Abhinandan S
> Sent: Monday, January 24, 2022 12:14 AM
> To: Shijith Thotton <sthotton@marvell.com>; dev@dpdk.org;
> jerinj@marvell.com
> Cc: anoobj@marvell.com; pbhagavatula@marvell.com; gakhil@marvell.com
> Subject: RE: [PATCH v3] app/eventdev: add crypto producer mode
>
> Hi Shijith,
>
> Please find some comments inline.
>
> > -----Original Message-----
> > From: Shijith Thotton <sthotton@marvell.com>
> > Sent: Tuesday, January 4, 2022 4:01 PM
> > To: dev@dpdk.org; jerinj@marvell.com
> > Cc: Shijith Thotton <sthotton@marvell.com>; anoobj@marvell.com;
> > pbhagavatula@marvell.com; gakhil@marvell.com; Gujjar, Abhinandan S
> > <abhinandan.gujjar@intel.com>
> > Subject: [PATCH v3] app/eventdev: add crypto producer mode
> >
> > In crypto producer mode, producer core enqueues cryptodev with
> > software generated crypto ops and worker core dequeues crypto
> > completion events from the eventdev. Event crypto metadata used for
> > above processing is pre- populated in each crypto session.
> >
> > Parameter --prod_type_cryptodev can be used to enable crypto producer
> > mode. Parameter --crypto_adptr_mode can be set to select the crypto
> > adapter mode, 0 for OP_NEW and 1 for OP_FORWARD.
> >
> > This mode can be used to measure the performance of crypto adapter.
> >
> > Example:
> > ./dpdk-test-eventdev -l 0-2 -w <EVENTDEV> -w <CRYPTODEV> -- \
> > --prod_type_cryptodev --crypto_adptr_mode 1 --test=perf_atq \
> > --stlist=a --wlcores 1 --plcores 2
> >
> > Signed-off-by: Shijith Thotton <sthotton@marvell.com>
> > ---
> > v3:
> > * Reduce dereference inside loop.
> >
> > v2:
> > * Fix RHEL compilation warning.
> >
> > app/test-eventdev/evt_common.h | 3 +
> > app/test-eventdev/evt_main.c | 13 +-
> > app/test-eventdev/evt_options.c | 27 ++
> > app/test-eventdev/evt_options.h | 12 +
> > app/test-eventdev/evt_test.h | 6 +
> > app/test-eventdev/test_perf_atq.c | 51 ++++
> > app/test-eventdev/test_perf_common.c | 410
> > ++++++++++++++++++++++++++- app/test-
> > eventdev/test_perf_common.h | 16 ++ app/test-
> > eventdev/test_perf_queue.c | 52 ++++
> > doc/guides/tools/testeventdev.rst | 13 +
> > 10 files changed, 596 insertions(+), 7 deletions(-)
> >
> > diff --git a/app/test-eventdev/evt_common.h b/app/test-
> > eventdev/evt_common.h index f466434459..2f301a7e79 100644
> > --- a/app/test-eventdev/evt_common.h
> > +++ b/app/test-eventdev/evt_common.h
> > @@ -7,6 +7,7 @@
> >
> > #include <rte_common.h>
> > #include <rte_debug.h>
> > +#include <rte_event_crypto_adapter.h>
> > #include <rte_eventdev.h>
> > #include <rte_service.h>
> >
> > @@ -39,6 +40,7 @@ enum evt_prod_type {
> > EVT_PROD_TYPE_SYNT, /* Producer type Synthetic i.e. CPU. */
> > EVT_PROD_TYPE_ETH_RX_ADPTR, /* Producer type Eth Rx Adapter.
> > */
> > EVT_PROD_TYPE_EVENT_TIMER_ADPTR, /* Producer type Timer
> Adapter. */
> > + EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR, /* Producer type Crypto
> > Adapter. */
> > EVT_PROD_TYPE_MAX,
> > };
> >
> > @@ -77,6 +79,7 @@ struct evt_options {
> > uint64_t timer_tick_nsec;
> > uint64_t optm_timer_tick_nsec;
> > enum evt_prod_type prod_type;
> > + enum rte_event_crypto_adapter_mode crypto_adptr_mode;
> > };
> >
> > static inline bool
> > diff --git a/app/test-eventdev/evt_main.c
> > b/app/test-eventdev/evt_main.c index 194c980c7a..cef0fb1382 100644
> > --- a/app/test-eventdev/evt_main.c
> > +++ b/app/test-eventdev/evt_main.c
> > @@ -161,12 +161,19 @@ main(int argc, char **argv)
> > goto mempool_destroy;
> > }
> > }
> New line required
> > + /* Test specific cryptodev setup */
> > + if (test->ops.cryptodev_setup) {
> > + if (test->ops.cryptodev_setup(test, &opt)) {
> > + evt_err("%s: cryptodev setup failed",
> > opt.test_name);
> > + goto ethdev_destroy;
> > + }
> > + }
> >
> > /* Test specific eventdev setup */
> > if (test->ops.eventdev_setup) {
> > if (test->ops.eventdev_setup(test, &opt)) {
> > evt_err("%s: eventdev setup failed",
> opt.test_name);
> > - goto ethdev_destroy;
> > + goto cryptodev_destroy;
> > }
> > }
> >
> > @@ -197,6 +204,10 @@ main(int argc, char **argv)
> > if (test->ops.eventdev_destroy)
> > test->ops.eventdev_destroy(test, &opt);
> >
> > +cryptodev_destroy:
> > + if (test->ops.cryptodev_destroy)
> > + test->ops.cryptodev_destroy(test, &opt);
> > +
> > ethdev_destroy:
> > if (test->ops.ethdev_destroy)
> > test->ops.ethdev_destroy(test, &opt); diff --git a/app/test-
> > eventdev/evt_options.c b/app/test-eventdev/evt_options.c index
> > 753a7dbd7d..5ad1491020 100644
> > --- a/app/test-eventdev/evt_options.c
> > +++ b/app/test-eventdev/evt_options.c
> > @@ -122,6 +122,26 @@ evt_parse_timer_prod_type_burst(struct
> > evt_options *opt,
> > return 0;
> > }
> >
> > +static int
> > +evt_parse_crypto_prod_type(struct evt_options *opt,
> > + const char *arg __rte_unused)
> > +{
> > + opt->prod_type = EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR;
> > + return 0;
> > +}
> > +
> > +static int
> > +evt_parse_crypto_adptr_mode(struct evt_options *opt, const char *arg)
> {
> > + uint8_t mode;
> > + int ret;
> > +
> > + ret = parser_read_uint8(&mode, arg);
> > + opt->crypto_adptr_mode = mode ?
> > RTE_EVENT_CRYPTO_ADAPTER_OP_FORWARD :
> > +
> > RTE_EVENT_CRYPTO_ADAPTER_OP_NEW;
> > + return ret;
> > +}
> > +
> > static int
> > evt_parse_test_name(struct evt_options *opt, const char *arg) { @@ -
> > 335,6 +355,7 @@ usage(char *program)
> > "\t--queue_priority : enable queue priority\n"
> > "\t--deq_tmo_nsec : global dequeue timeout\n"
> > "\t--prod_type_ethdev : use ethernet device as
> producer.\n"
> > + "\t--prod_type_cryptodev : use crypto device as
> > producer.\n"
> > "\t--prod_type_timerdev : use event timer device as
> producer.\n"
> > "\t expity_nsec would be the timeout\n"
> > "\t in ns.\n"
> > @@ -345,6 +366,8 @@ usage(char *program)
> > "\t--timer_tick_nsec : timer tick interval in ns.\n"
> > "\t--max_tmo_nsec : max timeout interval in ns.\n"
> > "\t--expiry_nsec : event timer expiry ns.\n"
> > + "\t--crypto_adptr_mode : 0 for OP_NEW mode (default)
> > and\n"
> > + "\t 1 for OP_FORWARD mode.\n"
> > "\t--mbuf_sz : packet mbuf size.\n"
> > "\t--max_pkt_sz : max packet size.\n"
> > "\t--prod_enq_burst_sz : producer enqueue burst size.\n"
> > @@ -415,8 +438,10 @@ static struct option lgopts[] = {
> > { EVT_QUEUE_PRIORITY, 0, 0, 0 },
> > { EVT_DEQ_TMO_NSEC, 1, 0, 0 },
> > { EVT_PROD_ETHDEV, 0, 0, 0 },
> > + { EVT_PROD_CRYPTODEV, 0, 0, 0 },
> > { EVT_PROD_TIMERDEV, 0, 0, 0 },
> > { EVT_PROD_TIMERDEV_BURST, 0, 0, 0 },
> > + { EVT_CRYPTO_ADPTR_MODE, 1, 0, 0 },
> > { EVT_NB_TIMERS, 1, 0, 0 },
> > { EVT_NB_TIMER_ADPTRS, 1, 0, 0 },
> > { EVT_TIMER_TICK_NSEC, 1, 0, 0 },
> > @@ -455,8 +480,10 @@ evt_opts_parse_long(int opt_idx, struct
> > evt_options
> > *opt)
> > { EVT_QUEUE_PRIORITY, evt_parse_queue_priority},
> > { EVT_DEQ_TMO_NSEC, evt_parse_deq_tmo_nsec},
> > { EVT_PROD_ETHDEV, evt_parse_eth_prod_type},
> > + { EVT_PROD_CRYPTODEV, evt_parse_crypto_prod_type},
> > { EVT_PROD_TIMERDEV, evt_parse_timer_prod_type},
> > { EVT_PROD_TIMERDEV_BURST,
> > evt_parse_timer_prod_type_burst},
> > + { EVT_CRYPTO_ADPTR_MODE,
> > evt_parse_crypto_adptr_mode},
> > { EVT_NB_TIMERS, evt_parse_nb_timers},
> > { EVT_NB_TIMER_ADPTRS, evt_parse_nb_timer_adptrs},
> > { EVT_TIMER_TICK_NSEC, evt_parse_timer_tick_nsec}, diff --
> git
> > a/app/test-eventdev/evt_options.h b/app/test-eventdev/evt_options.h
> > index 413d7092f0..2231c58801 100644
> > --- a/app/test-eventdev/evt_options.h
> > +++ b/app/test-eventdev/evt_options.h
> > @@ -9,6 +9,7 @@
> > #include <stdbool.h>
> >
> > #include <rte_common.h>
> > +#include <rte_cryptodev.h>
> > #include <rte_ethdev.h>
> > #include <rte_eventdev.h>
> > #include <rte_lcore.h>
> > @@ -33,8 +34,10 @@
> > #define EVT_QUEUE_PRIORITY ("queue_priority")
> > #define EVT_DEQ_TMO_NSEC ("deq_tmo_nsec")
> > #define EVT_PROD_ETHDEV ("prod_type_ethdev")
> > +#define EVT_PROD_CRYPTODEV ("prod_type_cryptodev")
> > #define EVT_PROD_TIMERDEV ("prod_type_timerdev")
> > #define EVT_PROD_TIMERDEV_BURST ("prod_type_timerdev_burst")
> > +#define EVT_CRYPTO_ADPTR_MODE ("crypto_adptr_mode")
> > #define EVT_NB_TIMERS ("nb_timers")
> > #define EVT_NB_TIMER_ADPTRS ("nb_timer_adptrs")
> > #define EVT_TIMER_TICK_NSEC ("timer_tick_nsec")
> > @@ -249,6 +252,8 @@ evt_prod_id_to_name(enum evt_prod_type
> > prod_type)
> > return "Ethdev Rx Adapter";
> > case EVT_PROD_TYPE_EVENT_TIMER_ADPTR:
> > return "Event timer adapter";
> > + case EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR:
> > + return "Event crypto adapter";
> > }
> >
> > return "";
> > @@ -288,6 +293,13 @@ evt_dump_producer_type(struct evt_options
> *opt)
> > evt_dump("timer_tick_nsec", "%"PRIu64"",
> > opt->timer_tick_nsec);
> > break;
> > + case EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR:
> > + snprintf(name, EVT_PROD_MAX_NAME_LEN,
> > + "Event crypto adapter producers");
> > + evt_dump("crypto adapter mode", "%s",
> > + opt->crypto_adptr_mode ? "OP_FORWARD" :
> > "OP_NEW");
> > + evt_dump("nb_cryptodev", "%u", rte_cryptodev_count());
> > + break;
> > }
> > evt_dump("prod_type", "%s", name);
> > }
> > diff --git a/app/test-eventdev/evt_test.h
> > b/app/test-eventdev/evt_test.h index f07d2c3336..50fa474ec2 100644
> > --- a/app/test-eventdev/evt_test.h
> > +++ b/app/test-eventdev/evt_test.h
> > @@ -29,6 +29,8 @@ typedef int (*evt_test_mempool_setup_t)
> > (struct evt_test *test, struct evt_options *opt); typedef int
> > (*evt_test_ethdev_setup_t)
> > (struct evt_test *test, struct evt_options *opt);
> > +typedef int (*evt_test_cryptodev_setup_t)
> > + (struct evt_test *test, struct evt_options *opt);
> > typedef int (*evt_test_eventdev_setup_t)
> > (struct evt_test *test, struct evt_options *opt); typedef int
> > (*evt_test_launch_lcores_t) @@ -39,6 +41,8 @@ typedef void
> > (*evt_test_eventdev_destroy_t)
> > (struct evt_test *test, struct evt_options *opt); typedef void
> > (*evt_test_ethdev_destroy_t)
> > (struct evt_test *test, struct evt_options *opt);
> > +typedef void (*evt_test_cryptodev_destroy_t)
> > + (struct evt_test *test, struct evt_options *opt);
> > typedef void (*evt_test_mempool_destroy_t)
> > (struct evt_test *test, struct evt_options *opt); typedef void
> > (*evt_test_destroy_t) @@ -52,10 +56,12 @@ struct evt_test_ops {
> > evt_test_mempool_setup_t mempool_setup;
> > evt_test_ethdev_setup_t ethdev_setup;
> > evt_test_eventdev_setup_t eventdev_setup;
> > + evt_test_cryptodev_setup_t cryptodev_setup;
> > evt_test_launch_lcores_t launch_lcores;
> > evt_test_result_t test_result;
> > evt_test_eventdev_destroy_t eventdev_destroy;
> > evt_test_ethdev_destroy_t ethdev_destroy;
> > + evt_test_cryptodev_destroy_t cryptodev_destroy;
> > evt_test_mempool_destroy_t mempool_destroy;
> > evt_test_destroy_t test_destroy;
> > };
> > diff --git a/app/test-eventdev/test_perf_atq.c b/app/test-
> > eventdev/test_perf_atq.c index 8fd51004ee..dbb1dc8c0c 100644
> > --- a/app/test-eventdev/test_perf_atq.c
> > +++ b/app/test-eventdev/test_perf_atq.c
> > @@ -48,6 +48,22 @@ perf_atq_worker(void *arg, const int
> > enable_fwd_latency)
> > continue;
> > }
> >
> > + if (prod_crypto_type &&
> > + (ev.event_type == RTE_EVENT_TYPE_CRYPTODEV)) {
> > + struct rte_crypto_op *op = ev.event_ptr;
> > +
> > + if (op->status ==
> > RTE_CRYPTO_OP_STATUS_SUCCESS) {
> > + if (op->sym->m_dst == NULL)
> > + ev.event_ptr = op->sym->m_src;
> > + else
> > + ev.event_ptr = op->sym->m_dst;
> > + rte_crypto_op_free(op);
> > + } else {
> > + rte_crypto_op_free(op);
> > + continue;
> > + }
> > + }
> > +
> > if (enable_fwd_latency && !prod_timer_type)
> > /* first stage in pipeline, mark ts to compute fwd latency */
> > atq_mark_fwd_latency(&ev);
> > @@ -87,6 +103,25 @@ perf_atq_worker_burst(void *arg, const int
> > enable_fwd_latency)
> > }
> >
> > for (i = 0; i < nb_rx; i++) {
> > + if (prod_crypto_type &&
> > + (ev[i].event_type ==
> > RTE_EVENT_TYPE_CRYPTODEV)) {
> > + struct rte_crypto_op *op = ev[i].event_ptr;
> > +
> > + if (op->status ==
> > + RTE_CRYPTO_OP_STATUS_SUCCESS) {
> > + if (op->sym->m_dst == NULL)
> > + ev[i].event_ptr =
> > + op->sym->m_src;
> > + else
> > + ev[i].event_ptr =
> > + op->sym->m_dst;
> > + rte_crypto_op_free(op);
> > + } else {
> > + rte_crypto_op_free(op);
> > + continue;
> > + }
> > + }
> > +
> > if (enable_fwd_latency && !prod_timer_type) {
> > rte_prefetch0(ev[i+1].event_ptr);
> > /* first stage in pipeline.
> > @@ -254,6 +289,20 @@ perf_atq_eventdev_setup(struct evt_test *test,
> > struct evt_options *opt)
> > return ret;
> > }
> > }
> > + } else if (opt->prod_type ==
> > EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR) {
> > + uint8_t cdev_id, cdev_count;
> > +
> > + cdev_count = rte_cryptodev_count();
> > + for (cdev_id = 0; cdev_id < cdev_count; cdev_id++) {
> > + ret = rte_cryptodev_start(cdev_id);
> > + if (ret) {
> > + evt_err("Failed to start cryptodev %u",
> > + cdev_id);
> > + return ret;
> > + }
> > + }
> > +
> > + rte_event_crypto_adapter_start(t->crypto_adptr.id);
> > }
> >
> > return 0;
> > @@ -295,12 +344,14 @@ static const struct evt_test_ops perf_atq = {
> > .opt_dump = perf_atq_opt_dump,
> > .test_setup = perf_test_setup,
> > .ethdev_setup = perf_ethdev_setup,
> > + .cryptodev_setup = perf_cryptodev_setup,
> > .mempool_setup = perf_mempool_setup,
> > .eventdev_setup = perf_atq_eventdev_setup,
> > .launch_lcores = perf_atq_launch_lcores,
> > .eventdev_destroy = perf_eventdev_destroy,
> > .mempool_destroy = perf_mempool_destroy,
> > .ethdev_destroy = perf_ethdev_destroy,
> > + .cryptodev_destroy = perf_cryptodev_destroy,
> > .test_result = perf_test_result,
> > .test_destroy = perf_test_destroy,
> > };
> > diff --git a/app/test-eventdev/test_perf_common.c b/app/test-
> > eventdev/test_perf_common.c index 9b73874151..91cb6748ee 100644
> > --- a/app/test-eventdev/test_perf_common.c
> > +++ b/app/test-eventdev/test_perf_common.c
> > @@ -6,6 +6,8 @@
> >
> > #include "test_perf_common.h"
> >
> > +#define NB_CRYPTODEV_DESCRIPTORS 128
> > +
> > int
> > perf_test_result(struct evt_test *test, struct evt_options *opt) {
> > @@ -272,6
> > +274,125 @@ perf_event_timer_producer_burst(void *arg)
> > return 0;
> > }
> >
> > +static inline void
> > +crypto_adapter_enq_op_new(struct prod_data *p) {
> > + struct rte_cryptodev_sym_session **crypto_sess = p->crypto_sess;
> > + struct test_perf *t = p->t;
> > + const uint32_t nb_flows = t->nb_flows;
> > + const uint64_t nb_pkts = t->nb_pkts;
> > + struct rte_mempool *pool = t->pool;
> > + struct rte_crypto_sym_op *sym_op;
> > + struct evt_options *opt = t->opt;
> > + uint16_t qp_id = p->cdev_qp_id;
> > + uint8_t cdev_id = p->cdev_id;
> > + uint32_t flow_counter = 0;
> > + struct rte_crypto_op *op;
> > + struct rte_mbuf *m;
> > + uint64_t count = 0;
> > + uint16_t len;
> > +
> > + if (opt->verbose_level > 1)
> > + printf("%s(): lcore %d queue %d cdev_id %u cdev_qp_id
> > %u\n",
> > + __func__, rte_lcore_id(), p->queue_id, p->cdev_id,
> > + p->cdev_qp_id);
> > +
> > + len = opt->mbuf_sz ? opt->mbuf_sz : RTE_ETHER_MIN_LEN;
> > +
> > + while (count < nb_pkts && t->done == false) {
> > + m = rte_pktmbuf_alloc(pool);
> > + if (m == NULL)
> > + continue;
> > +
> > + rte_pktmbuf_append(m, len);
> > + op = rte_crypto_op_alloc(t->crypto_adptr.op_pool,
NULL check for op is missing
> > +
> > RTE_CRYPTO_OP_TYPE_SYMMETRIC);
> > + sym_op = op->sym;
> > + sym_op->m_src = m;
> > + sym_op->cipher.data.offset = 0;
> > + sym_op->cipher.data.length = len;
> > + rte_crypto_op_attach_sym_session(
> > + op, crypto_sess[flow_counter++ % nb_flows]);
> > + while (rte_cryptodev_enqueue_burst(cdev_id, qp_id, &op,
> > 1) !=
> > + 1) {
> > + if (t->done)
> > + break;
> > + rte_pause();
> > + }
> > + count++;
> > + }
> > +}
> > +
> > +static inline void
> > +crypto_adapter_enq_op_fwd(struct prod_data *p) {
> > + struct rte_cryptodev_sym_session **crypto_sess = p->crypto_sess;
> > + const uint8_t dev_id = p->dev_id;
> > + const uint8_t port = p->port_id;
> > + struct test_perf *t = p->t;
> > + const uint32_t nb_flows = t->nb_flows;
> > + const uint64_t nb_pkts = t->nb_pkts;
> > + struct rte_mempool *pool = t->pool;
> > + struct evt_options *opt = t->opt;
> > + struct rte_crypto_sym_op *sym_op;
> > + uint32_t flow_counter = 0;
> > + struct rte_crypto_op *op;
> > + struct rte_event ev;
> > + struct rte_mbuf *m;
> > + uint64_t count = 0;
> > + uint16_t len;
> > +
> > + if (opt->verbose_level > 1)
> > + printf("%s(): lcore %d port %d queue %d cdev_id %u
> > cdev_qp_id %u\n",
> > + __func__, rte_lcore_id(), port, p->queue_id, p->cdev_id,
> > + p->cdev_qp_id);
> > +
> > + ev.event = 0;
> > + ev.op = RTE_EVENT_OP_NEW;
So, this is an new event and adapter treats it as OP_FWD?
> > + ev.queue_id = p->queue_id;
> > + ev.sched_type = RTE_SCHED_TYPE_ATOMIC;
> > + ev.event_type = RTE_EVENT_TYPE_CPU;
> > + len = opt->mbuf_sz ? opt->mbuf_sz : RTE_ETHER_MIN_LEN;
> > +
> > + while (count < nb_pkts && t->done == false) {
> > + m = rte_pktmbuf_alloc(pool);
> > + if (m == NULL)
> > + continue;
> > +
> > + rte_pktmbuf_append(m, len);
> > + op = rte_crypto_op_alloc(t->crypto_adptr.op_pool,
> > +
> > RTE_CRYPTO_OP_TYPE_SYMMETRIC);
> > + sym_op = op->sym;
> > + sym_op->m_src = m;
> > + sym_op->cipher.data.offset = 0;
> > + sym_op->cipher.data.length = len;
> > + rte_crypto_op_attach_sym_session(
> > + op, crypto_sess[flow_counter++ % nb_flows]);
> > + ev.event_ptr = op;
> > + while (rte_event_crypto_adapter_enqueue(dev_id, port,
> > &ev, 1) !=
> > + 1) {
If the adapter OP_FWD is supported by rte_event_enqueue_burst(), then even that path has to be tested. Please add it.
> > + if (t->done)
> > + break;
> > + rte_pause();
> > + }
> > + count++;
> > + }
> > +}
> > +
> > +static inline int
> > +perf_event_crypto_producer(void *arg) {
> > + struct prod_data *p = arg;
> > + struct evt_options *opt = p->t->opt;
> > +
> > + if (opt->crypto_adptr_mode ==
> > RTE_EVENT_CRYPTO_ADAPTER_OP_NEW)
> > + crypto_adapter_enq_op_new(p);
> > + else
> > + crypto_adapter_enq_op_fwd(p);
> > +
> > + return 0;
> > +}
> > +
> > static int
> > perf_producer_wrapper(void *arg)
> > {
> > @@ -298,6 +419,8 @@ perf_producer_wrapper(void *arg)
> > else if (t->opt->prod_type ==
> > EVT_PROD_TYPE_EVENT_TIMER_ADPTR &&
> > t->opt->timdev_use_burst)
> > return perf_event_timer_producer_burst(arg);
> > + else if (t->opt->prod_type ==
> > EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR)
> > + return perf_event_crypto_producer(arg);
> > return 0;
> > }
> >
> > @@ -405,8 +528,10 @@ perf_launch_lcores(struct evt_test *test, struct
> > evt_options *opt,
> > if (remaining <= 0) {
> > t->result = EVT_TEST_SUCCESS;
> > if (opt->prod_type ==
> > EVT_PROD_TYPE_SYNT ||
> > - opt->prod_type ==
> > -
> > EVT_PROD_TYPE_EVENT_TIMER_ADPTR) {
> > + opt->prod_type ==
> > +
> > EVT_PROD_TYPE_EVENT_TIMER_ADPTR ||
> > + opt->prod_type ==
> > +
> > EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR) {
> > t->done = true;
> > break;
> > }
> > @@ -415,7 +540,8 @@ perf_launch_lcores(struct evt_test *test, struct
> > evt_options *opt,
> >
> > if (new_cycles - dead_lock_cycles > dead_lock_sample &&
> > (opt->prod_type == EVT_PROD_TYPE_SYNT ||
> > - opt->prod_type ==
> > EVT_PROD_TYPE_EVENT_TIMER_ADPTR)) {
> > + opt->prod_type ==
> > EVT_PROD_TYPE_EVENT_TIMER_ADPTR ||
> > + opt->prod_type ==
> > EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR)) {
> > remaining = t->outstand_pkts - processed_pkts(t);
> > if (dead_lock_remaining == remaining) {
> > rte_event_dev_dump(opt->dev_id, stdout);
> @@ -537,6 +663,96 @@
> > perf_event_timer_adapter_setup(struct test_perf
> > *t)
> > return 0;
> > }
> >
> > +static int
> > +perf_event_crypto_adapter_setup(struct test_perf *t,
> > + struct rte_event_port_conf port_conf) {
> > + struct evt_options *opt = t->opt;
> > + uint8_t cdev_id, cdev_count;
> > + int ret;
> > +
> > + t->crypto_adptr.id = 0;
> > + ret = rte_event_crypto_adapter_create(t->crypto_adptr.id, opt-
> > >dev_id,
> > + &port_conf, 0);
> > + if (ret)
> > + return ret;
> > +
> > + cdev_count = rte_cryptodev_count();
> > + for (cdev_id = 0; cdev_id < cdev_count; cdev_id++) {
> > + uint32_t cap;
> > +
> > + ret = rte_event_crypto_adapter_caps_get(opt->dev_id,
> > cdev_id,
> > + &cap);
> > + if (ret) {
> > + evt_err("Failed to get crypto adapter capabilities");
> > + return ret;
> > + }
> > +
> > + if (((opt->crypto_adptr_mode ==
> > + RTE_EVENT_CRYPTO_ADAPTER_OP_NEW) &&
> > + !(cap &
> > +
> > RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_OP_NEW)) ||
> > + ((opt->crypto_adptr_mode ==
> > + RTE_EVENT_CRYPTO_ADAPTER_OP_FORWARD) &&
> > + !(cap &
> > +
> > RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_OP_FWD))) {
> > + evt_err("crypto adapter %s mode unsupported\n",
> > + opt->crypto_adptr_mode ? "OP_FORWARD"
> > :
> > + "OP_NEW");
> > + return -EINVAL;
> > + }
> > +
> > + if (!(cap &
> > +
> > RTE_EVENT_CRYPTO_ADAPTER_CAP_SESSION_PRIVATE_DATA)) {
> > + evt_err("Storing crypto session not supported");
> > + return -EINVAL;
> > + }
> > +
> > + if (cap &
> > +
> > RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_QP_EV_BIND) {
> > + struct rte_event response_info;
> > +
> > + response_info.event = 0;
It is good that you are covering even this case. Should not you fill event with valid values?
> > + ret = rte_event_crypto_adapter_queue_pair_add(
> > + t->crypto_adptr.id, cdev_id, -1,
> > + &response_info);
> > + } else {
> > + ret = rte_event_crypto_adapter_queue_pair_add(
> > + t->crypto_adptr.id, cdev_id, -1, NULL);
> > + }
New line
> > + if (ret)
> > + return ret;
> > + }
> > +
> > + return 0;
> > +}
> > +
> > +static struct rte_cryptodev_sym_session *
> > +cryptodev_sym_sess_create(struct prod_data *p, struct test_perf *t) {
> > + struct rte_crypto_sym_xform cipher_xform;
> > + struct rte_cryptodev_sym_session *sess;
> > +
> > + cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
> > + cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
> > + cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
> > + cipher_xform.next = NULL;
> > +
> > + sess = rte_cryptodev_sym_session_create(t-
> > >crypto_adptr.sess_pool);
> > + if (sess == NULL) {
> > + evt_err("Failed to create sym session");
> > + return NULL;
> > + }
> > +
> > + if (rte_cryptodev_sym_session_init(p->cdev_id, sess,
> > &cipher_xform,
> > + t->crypto_adptr.sess_priv_pool)) {
> > + evt_err("Failed to init session");
> > + return NULL;
> > + }
> > +
> > + return sess;
> > +}
> > +
> > int
> > perf_event_dev_port_setup(struct evt_test *test, struct evt_options
> *opt,
> > uint8_t stride, uint8_t nb_queues, @@ -
> 598,6 +814,55 @@
> > perf_event_dev_port_setup(struct evt_test *test, struct evt_options
> > *opt,
> > ret = perf_event_timer_adapter_setup(t);
> > if (ret)
> > return ret;
> > + } else if (opt->prod_type ==
> > EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR) {
> > + uint8_t cdev_id = 0;
> > + uint16_t qp_id = 0;
> > +
> > + prod = 0;
> > + for (; port < perf_nb_event_ports(opt); port++) {
> > + struct rte_cryptodev_sym_session *crypto_sess;
> > + union rte_event_crypto_metadata m_data;
> > + struct prod_data *p = &t->prod[port];
> > + uint32_t flow_id;
> > +
> > + if (qp_id ==
> > rte_cryptodev_queue_pair_count(cdev_id)) {
> > + cdev_id++;
> > + qp_id = 0;
> > + }
> > +
> > + p->dev_id = opt->dev_id;
> > + p->port_id = port;
> > + p->queue_id = prod * stride;
> > + p->cdev_id = cdev_id;
> > + p->cdev_qp_id = qp_id;
> > + p->crypto_sess = rte_zmalloc_socket(
> > + NULL, sizeof(crypto_sess) * t->nb_flows,
> > + RTE_CACHE_LINE_SIZE, opt->socket_id);
> > +
> > + m_data.request_info.cdev_id = p->cdev_id;
> > + m_data.request_info.queue_pair_id = p-
> > >cdev_qp_id;
> > + m_data.response_info.op = RTE_EVENT_OP_NEW;
> > + m_data.response_info.sched_type =
> > RTE_SCHED_TYPE_ATOMIC;
> > + m_data.response_info.event_type =
> > RTE_EVENT_TYPE_CPU;
> > + m_data.response_info.queue_id = p->queue_id;
> > + for (flow_id = 0; flow_id < t->nb_flows; flow_id++) {
> > + crypto_sess =
> > cryptodev_sym_sess_create(p, t);
> > + if (crypto_sess == NULL)
> > + return -ENOMEM;
> > +
> > + m_data.response_info.flow_id = flow_id;
> > + rte_cryptodev_sym_session_set_user_data(
> > + crypto_sess, &m_data,
> > sizeof(m_data));
> > + p->crypto_sess[flow_id] = crypto_sess;
> > + }
New line
> > + p->t = t;
> > + qp_id++;
> > + prod++;
> > + }
> > +
> > + ret = perf_event_crypto_adapter_setup(t, *port_conf);
> > + if (ret)
> > + return ret;
> > } else {
> > prod = 0;
> > for ( ; port < perf_nb_event_ports(opt); port++) { @@ -659,7
> > +924,8 @@ perf_opt_check(struct evt_options *opt, uint64_t nb_queues)
> > }
> >
> > if (opt->prod_type == EVT_PROD_TYPE_SYNT ||
> > - opt->prod_type ==
> > EVT_PROD_TYPE_EVENT_TIMER_ADPTR) {
> > + opt->prod_type == EVT_PROD_TYPE_EVENT_TIMER_ADPTR ||
> > + opt->prod_type == EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR) {
> > /* Validate producer lcores */
> > if (evt_lcores_has_overlap(opt->plcores,
> > rte_get_main_lcore())) {
> > @@ -767,8 +1033,7 @@ perf_ethdev_setup(struct evt_test *test, struct
> > evt_options *opt)
> > },
> > };
> >
> > - if (opt->prod_type == EVT_PROD_TYPE_SYNT ||
> > - opt->prod_type ==
> > EVT_PROD_TYPE_EVENT_TIMER_ADPTR)
> > + if (opt->prod_type != EVT_PROD_TYPE_ETH_RX_ADPTR)
> > return 0;
> >
> > if (!rte_eth_dev_count_avail()) {
> > @@ -841,6 +1106,139 @@ void perf_ethdev_destroy(struct evt_test *test,
> > struct evt_options *opt)
> > }
> > }
> >
> > +int
> > +perf_cryptodev_setup(struct evt_test *test, struct evt_options *opt) {
> > + uint8_t cdev_count, cdev_id, nb_plcores, nb_qps;
> > + struct test_perf *t = evt_test_priv(test);
> > + unsigned int max_session_size;
> > + uint32_t nb_sessions;
> > + int ret;
> > +
> > + if (opt->prod_type != EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR)
> > + return 0;
> How do you differentiate between this failed case as you are returning 0 in
> case of success?
>
> > +
> > + cdev_count = rte_cryptodev_count();
> > + if (cdev_count == 0) {
> > + evt_err("No crypto devices available\n");
> > + return -ENODEV;
> > + }
> > +
> > + t->crypto_adptr.op_pool = rte_crypto_op_pool_create(
> > + "crypto_op_pool", RTE_CRYPTO_OP_TYPE_SYMMETRIC, opt-
> > >pool_sz,
> > + 128, 0, rte_socket_id());
> > + if (t->crypto_adptr.op_pool == NULL) {
> > + evt_err("Failed to create crypto op pool");
> > + return -ENOMEM;
> > + }
> > +
> > + nb_sessions = evt_nr_active_lcores(opt->plcores) * t->nb_flows;
> > + t->crypto_adptr.sess_pool =
> > rte_cryptodev_sym_session_pool_create(
> > + "ca_sess_pool", nb_sessions, 0, 0,
> > + sizeof(union rte_event_crypto_metadata),
> > SOCKET_ID_ANY);
> > + if (t->crypto_adptr.sess_pool == NULL) {
> > + evt_err("Failed to create sym session pool");
> > + ret = -ENOMEM;
> > + goto err;
> > + }
> > +
> > + max_session_size = 0;
> > + for (cdev_id = 0; cdev_id < cdev_count; cdev_id++) {
> > + unsigned int session_size;
> > +
> > + session_size =
> > +
> > rte_cryptodev_sym_get_private_session_size(cdev_id);
> > + if (session_size > max_session_size)
> > + max_session_size = session_size;
> > + }
> New line required
> > + max_session_size += sizeof(union rte_event_crypto_metadata);
> > + t->crypto_adptr.sess_priv_pool = rte_mempool_create(
> > + "ca_sess_priv_pool", nb_sessions, max_session_size, 0, 0,
> > NULL,
> > + NULL, NULL, NULL, SOCKET_ID_ANY, 0);
> > + if (t->crypto_adptr.sess_priv_pool == NULL) {
> > + evt_err("failed to create sym session private pool");
> > + ret = -ENOMEM;
> > + goto err;
> > + }
> > +
> > + nb_plcores = evt_nr_active_lcores(opt->plcores);
> > + nb_qps = (nb_plcores % cdev_count) ? (nb_plcores / cdev_count) +
> > 1 :
> > + nb_plcores / cdev_count;
> Let's take an example:
> Cdev1 -> 8 qps
> Cdev2 -> 2 qps
> Cdev_count = 2
> nb_plcores = 7
> As per above statement, nb_qps = ( 7 % 2 ) 7/2 + 1 = 4 qps So, this fails to
> setup qps for cdev2 as it supports only 2 qps and test exits! Am I missing
> anything?
>
> > + for (cdev_id = 0; cdev_id < cdev_count; cdev_id++) {
> > + struct rte_cryptodev_qp_conf qp_conf;
> > + struct rte_cryptodev_config conf;
> > + struct rte_cryptodev_info info;
> > + int qp_id;
> > +
> > + rte_cryptodev_info_get(cdev_id, &info);
> > + if (nb_qps > info.max_nb_queue_pairs) {
> > + evt_err("Not enough queue pairs per cryptodev
> > (%u)",
> > + nb_qps);
> > + ret = -EINVAL;
> > + goto err;
> > + }
> > +
> > + conf.nb_queue_pairs = nb_qps;
> > + conf.socket_id = SOCKET_ID_ANY;
> > + conf.ff_disable = RTE_CRYPTODEV_FF_SECURITY;
> > +
> > + ret = rte_cryptodev_configure(cdev_id, &conf);
> > + if (ret) {
> > + evt_err("Failed to configure cryptodev (%u)",
> > cdev_id);
> > + goto err;
> > + }
> > +
> > + qp_conf.nb_descriptors = NB_CRYPTODEV_DESCRIPTORS;
> > + qp_conf.mp_session = t->crypto_adptr.sess_pool;
> > + qp_conf.mp_session_private = t-
> > >crypto_adptr.sess_priv_pool;
> > +
> > + for (qp_id = 0; qp_id < conf.nb_queue_pairs; qp_id++) {
> > + ret = rte_cryptodev_queue_pair_setup(
> > + cdev_id, qp_id, &qp_conf,
> > + rte_cryptodev_socket_id(cdev_id));
> > + if (ret) {
> > + evt_err("Failed to setup queue pairs on
> > cryptodev %u\n",
> > + cdev_id);
> > + goto err;
> > + }
> > + }
> > + }
> > +
> > + return 0;
> > +err:
> > + rte_mempool_free(t->crypto_adptr.op_pool);
> > + rte_mempool_free(t->crypto_adptr.sess_pool);
> > + rte_mempool_free(t->crypto_adptr.sess_priv_pool);
> > +
> > + return ret;
> > +}
> > +
> > +void
> > +perf_cryptodev_destroy(struct evt_test *test, struct evt_options
> > +*opt) {
> > + uint8_t cdev_id, cdev_count = rte_cryptodev_count();
> > + struct test_perf *t = evt_test_priv(test);
> > +
> > + RTE_SET_USED(opt);
> > +
> > + if (opt->prod_type != EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR)
> > + return;
> > +
> > + rte_event_crypto_adapter_stop(t->crypto_adptr.id);
> > +
> > + for (cdev_id = 0; cdev_id < cdev_count; cdev_id++) {
> > + rte_cryptodev_stop(cdev_id);
> > + rte_event_crypto_adapter_queue_pair_del(t-
> > >crypto_adptr.id,
> > + cdev_id, -1);
> Any reason for passing -1? This can not ensure to cleanup all the
> preconfigured qps as per API.
> > + }
> > +
> > + rte_event_crypto_adapter_free(t->crypto_adptr.id);
> > +
> > + rte_mempool_free(t->crypto_adptr.op_pool);
> > + rte_mempool_free(t->crypto_adptr.sess_pool);
> > + rte_mempool_free(t->crypto_adptr.sess_priv_pool);
> > +}
> > +
> > int
> > perf_mempool_setup(struct evt_test *test, struct evt_options *opt) {
> > diff - -git a/app/test-eventdev/test_perf_common.h b/app/test-
> > eventdev/test_perf_common.h index 14dcf80429..d9ad3a0b0d 100644
> > --- a/app/test-eventdev/test_perf_common.h
> > +++ b/app/test-eventdev/test_perf_common.h
> > @@ -9,9 +9,11 @@
> > #include <stdbool.h>
> > #include <unistd.h>
> >
> > +#include <rte_cryptodev.h>
> > #include <rte_cycles.h>
> > #include <rte_ethdev.h>
> > #include <rte_eventdev.h>
> > +#include <rte_event_crypto_adapter.h>
> > #include <rte_event_eth_rx_adapter.h> #include
> > <rte_event_timer_adapter.h> #include <rte_lcore.h> @@ -37,9 +39,18
> @@
> > struct prod_data {
> > uint8_t dev_id;
> > uint8_t port_id;
> > uint8_t queue_id;
> > + uint8_t cdev_id;
> > + uint16_t cdev_qp_id;
> > + struct rte_cryptodev_sym_session **crypto_sess;
> > struct test_perf *t;
> > } __rte_cache_aligned;
> >
> > +struct crypto_adptr_data {
> > + uint8_t id;
> > + struct rte_mempool *op_pool;
> > + struct rte_mempool *sess_pool;
> > + struct rte_mempool *sess_priv_pool;
> > +};
> >
> > struct test_perf {
> > /* Don't change the offset of "done". Signal handler use this memory
> > @@ -58,6 +69,7 @@ struct test_perf {
> > uint8_t sched_type_list[EVT_MAX_STAGES] __rte_cache_aligned;
> > struct rte_event_timer_adapter *timer_adptr[
> > RTE_EVENT_TIMER_ADAPTER_NUM_MAX]
> > __rte_cache_aligned;
> > + struct crypto_adptr_data crypto_adptr;
> > } __rte_cache_aligned;
> >
> > struct perf_elt {
> > @@ -81,6 +93,8 @@ struct perf_elt {
> > const uint8_t port = w->port_id;\
> > const uint8_t prod_timer_type = \
> > opt->prod_type ==
> > EVT_PROD_TYPE_EVENT_TIMER_ADPTR;\
> > + const uint8_t prod_crypto_type = \
> > + opt->prod_type ==
> > EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR;\
> > uint8_t *const sched_type_list = &t->sched_type_list[0];\
> > struct rte_mempool *const pool = t->pool;\
> > const uint8_t nb_stages = t->opt->nb_stages;\ @@ -154,6 +168,7
> @@
> > int perf_test_result(struct evt_test *test, struct evt_options *opt);
> > int perf_opt_check(struct evt_options *opt, uint64_t nb_queues); int
> > perf_test_setup(struct evt_test *test, struct evt_options *opt); int
> > perf_ethdev_setup(struct evt_test *test, struct evt_options *opt);
> > +int perf_cryptodev_setup(struct evt_test *test, struct evt_options
> > +*opt);
> > int perf_mempool_setup(struct evt_test *test, struct evt_options
> > *opt); int perf_event_dev_port_setup(struct evt_test *test, struct
> evt_options *opt,
> > uint8_t stride, uint8_t nb_queues, @@ -
> 164,6 +179,7 @@ int
> > perf_launch_lcores(struct evt_test *test, struct evt_options *opt,
> > void perf_opt_dump(struct evt_options *opt, uint8_t nb_queues); void
> > perf_test_destroy(struct evt_test *test, struct evt_options *opt);
> > void perf_eventdev_destroy(struct evt_test *test, struct evt_options
> > *opt);
> > +void perf_cryptodev_destroy(struct evt_test *test, struct evt_options
> > +*opt);
> > void perf_ethdev_destroy(struct evt_test *test, struct evt_options
> > *opt); void perf_mempool_destroy(struct evt_test *test, struct
> > evt_options *opt);
> >
> > diff --git a/app/test-eventdev/test_perf_queue.c b/app/test-
> > eventdev/test_perf_queue.c index f4ea3a795f..5657c8b3cd 100644
> > --- a/app/test-eventdev/test_perf_queue.c
> > +++ b/app/test-eventdev/test_perf_queue.c
> > @@ -49,6 +49,23 @@ perf_queue_worker(void *arg, const int
> > enable_fwd_latency)
> > rte_pause();
> > continue;
> > }
> > +
> > + if (prod_crypto_type &&
> > + (ev.event_type == RTE_EVENT_TYPE_CRYPTODEV)) {
> > + struct rte_crypto_op *op = ev.event_ptr;
> > +
> > + if (op->status ==
> > RTE_CRYPTO_OP_STATUS_SUCCESS) {
> > + if (op->sym->m_dst == NULL)
> > + ev.event_ptr = op->sym->m_src;
> > + else
> > + ev.event_ptr = op->sym->m_dst;
> > + rte_crypto_op_free(op);
> > + } else {
> > + rte_crypto_op_free(op);
> > + continue;
> In case of failure, ops are freed and "ev.event_ptr" won't be set to mbuf.
> What would be the expected test result?
> > + }
> > + }
> > +
> > if (enable_fwd_latency && !prod_timer_type)
> > /* first q in pipeline, mark timestamp to compute fwd latency
> */
> > mark_fwd_latency(&ev, nb_stages);
> > @@ -88,6 +105,25 @@ perf_queue_worker_burst(void *arg, const int
> > enable_fwd_latency)
> > }
> >
> > for (i = 0; i < nb_rx; i++) {
> > + if (prod_crypto_type &&
> > + (ev[i].event_type ==
> > RTE_EVENT_TYPE_CRYPTODEV)) {
> > + struct rte_crypto_op *op = ev[i].event_ptr;
> > +
> > + if (op->status ==
> > + RTE_CRYPTO_OP_STATUS_SUCCESS) {
> > + if (op->sym->m_dst == NULL)
> > + ev[i].event_ptr =
> > + op->sym->m_src;
> > + else
> > + ev[i].event_ptr =
> > + op->sym->m_dst;
> > + rte_crypto_op_free(op);
> > + } else {
> > + rte_crypto_op_free(op);
> > + continue;
> > + }
> > + }
> > +
> > if (enable_fwd_latency && !prod_timer_type) {
> > rte_prefetch0(ev[i+1].event_ptr);
> > /* first queue in pipeline.
> > @@ -269,6 +305,20 @@ perf_queue_eventdev_setup(struct evt_test
> *test,
> > struct evt_options *opt)
> > return ret;
> > }
> > }
> > + } else if (opt->prod_type ==
> > EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR) {
> > + uint8_t cdev_id, cdev_count;
> > +
> > + cdev_count = rte_cryptodev_count();
> > + for (cdev_id = 0; cdev_id < cdev_count; cdev_id++) {
> > + ret = rte_cryptodev_start(cdev_id);
> > + if (ret) {
> > + evt_err("Failed to start cryptodev %u",
> > + cdev_id);
> > + return ret;
> > + }
> > + }
> > +
> > + rte_event_crypto_adapter_start(t->crypto_adptr.id);
> > }
> >
> > return 0;
> > @@ -311,11 +361,13 @@ static const struct evt_test_ops perf_queue = {
> > .test_setup = perf_test_setup,
> > .mempool_setup = perf_mempool_setup,
> > .ethdev_setup = perf_ethdev_setup,
> > + .cryptodev_setup = perf_cryptodev_setup,
> > .eventdev_setup = perf_queue_eventdev_setup,
> > .launch_lcores = perf_queue_launch_lcores,
> > .eventdev_destroy = perf_eventdev_destroy,
> > .mempool_destroy = perf_mempool_destroy,
> > .ethdev_destroy = perf_ethdev_destroy,
> > + .cryptodev_destroy = perf_cryptodev_destroy,
> > .test_result = perf_test_result,
> > .test_destroy = perf_test_destroy,
> > };
> > diff --git a/doc/guides/tools/testeventdev.rst
> > b/doc/guides/tools/testeventdev.rst
> > index 48efb9ea6e..f7d813226d 100644
> > --- a/doc/guides/tools/testeventdev.rst
> > +++ b/doc/guides/tools/testeventdev.rst
> > @@ -120,6 +120,10 @@ The following are the application command-line
> > options:
> >
> > Use burst mode event timer adapter as producer.
> >
> > +* ``--prod_type_cryptodev``
> > +
> > + Use crypto device as producer.
> > +
> > * ``--timer_tick_nsec``
> >
> > Used to dictate number of nano seconds between bucket
> > traversal of the @@ -148,6 +152,11 @@ The following are the
> > application command-line
> > options:
> > timeout is out of the supported range of event device it will be
> > adjusted to the highest/lowest supported dequeue timeout
> supported.
> >
> > +* ``--crypto_adptr_mode``
> > +
> > + Set crypto adapter mode. Use 0 for OP_NEW (default) and 1 for
> > + OP_FORWARD mode.
> > +
> > * ``--mbuf_sz``
> >
> > Set packet mbuf size. Can be used to configure Jumbo Frames.
> > Only @@
> > -420,6 +429,7 @@ Supported application command line options are
> > following::
> > --prod_type_ethdev
> > --prod_type_timerdev_burst
> > --prod_type_timerdev
> > + --prod_type_cryptodev
> > --prod_enq_burst_sz
> > --timer_tick_nsec
> > --max_tmo_nsec
> > @@ -427,6 +437,7 @@ Supported application command line options are
> > following::
> > --nb_timers
> > --nb_timer_adptrs
> > --deq_tmo_nsec
> > + --crypto_adptr_mode
> >
> > Example
> > ^^^^^^^
> > @@ -529,12 +540,14 @@ Supported application command line options are
> > following::
> > --prod_type_ethdev
> > --prod_type_timerdev_burst
> > --prod_type_timerdev
> > + --prod_type_cryptodev
> > --timer_tick_nsec
> > --max_tmo_nsec
> > --expiry_nsec
> > --nb_timers
> > --nb_timer_adptrs
> > --deq_tmo_nsec
> > + --crypto_adptr_mode
> >
> > Example
> > ^^^^^^^
> > --
> > 2.25.1
^ permalink raw reply [flat|nested] 43+ messages in thread
* RE: [PATCH v3] app/eventdev: add crypto producer mode
2022-01-24 6:59 ` Shijith Thotton
@ 2022-01-25 14:15 ` Gujjar, Abhinandan S
0 siblings, 0 replies; 43+ messages in thread
From: Gujjar, Abhinandan S @ 2022-01-25 14:15 UTC (permalink / raw)
To: Shijith Thotton, dev, Jerin Jacob Kollanukkaran
Cc: Anoob Joseph, Pavan Nikhilesh Bhagavatula, Akhil Goyal
> -----Original Message-----
> From: Shijith Thotton <sthotton@marvell.com>
> Sent: Monday, January 24, 2022 12:29 PM
> To: Gujjar, Abhinandan S <abhinandan.gujjar@intel.com>; dev@dpdk.org;
> Jerin Jacob Kollanukkaran <jerinj@marvell.com>
> Cc: Anoob Joseph <anoobj@marvell.com>; Pavan Nikhilesh Bhagavatula
> <pbhagavatula@marvell.com>; Akhil Goyal <gakhil@marvell.com>
> Subject: RE: [PATCH v3] app/eventdev: add crypto producer mode
>
> Missed some comments in last mail.
>
> >>
> >> In crypto producer mode, producer core enqueues cryptodev with
> >> software generated crypto ops and worker core dequeues crypto
> >> completion events from the eventdev. Event crypto metadata used for
> >> above processing is pre- populated in each crypto session.
> >>
> >> Parameter --prod_type_cryptodev can be used to enable crypto producer
> >> mode. Parameter --crypto_adptr_mode can be set to select the crypto
> >> adapter mode, 0 for OP_NEW and 1 for OP_FORWARD.
> >>
> >> This mode can be used to measure the performance of crypto adapter.
> >>
> >> Example:
> >> ./dpdk-test-eventdev -l 0-2 -w <EVENTDEV> -w <CRYPTODEV> -- \
> >> --prod_type_cryptodev --crypto_adptr_mode 1 --test=perf_atq \
> >> --stlist=a --wlcores 1 --plcores 2
> >>
> >> Signed-off-by: Shijith Thotton <sthotton@marvell.com>
> >> ---
> >> v3:
> >> * Reduce dereference inside loop.
> >>
> >> v2:
> >> * Fix RHEL compilation warning.
> >>
> >> app/test-eventdev/evt_common.h | 3 +
> >> app/test-eventdev/evt_main.c | 13 +-
> >> app/test-eventdev/evt_options.c | 27 ++
> >> app/test-eventdev/evt_options.h | 12 +
> >> app/test-eventdev/evt_test.h | 6 +
> >> app/test-eventdev/test_perf_atq.c | 51 ++++
> >> app/test-eventdev/test_perf_common.c | 410
> >> ++++++++++++++++++++++++++- app/test-
> >> eventdev/test_perf_common.h | 16 ++ app/test-
> >> eventdev/test_perf_queue.c | 52 ++++
> >> doc/guides/tools/testeventdev.rst | 13 +
> >> 10 files changed, 596 insertions(+), 7 deletions(-)
> >>
> >> diff --git a/app/test-eventdev/evt_common.h b/app/test-
> >> eventdev/evt_common.h index f466434459..2f301a7e79 100644
> >> --- a/app/test-eventdev/evt_common.h
> >> +++ b/app/test-eventdev/evt_common.h
> >> @@ -7,6 +7,7 @@
> >>
> >> #include <rte_common.h>
> >> #include <rte_debug.h>
> >> +#include <rte_event_crypto_adapter.h>
> >> #include <rte_eventdev.h>
> >> #include <rte_service.h>
> >>
> >> @@ -39,6 +40,7 @@ enum evt_prod_type {
> >> EVT_PROD_TYPE_SYNT, /* Producer type Synthetic i.e. CPU. */
> >> EVT_PROD_TYPE_ETH_RX_ADPTR, /* Producer type Eth Rx Adapter.
> >> */
> >> EVT_PROD_TYPE_EVENT_TIMER_ADPTR, /* Producer type Timer
> Adapter.
> >> */
> >> + EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR, /* Producer type Crypto
> >> Adapter. */
> >> EVT_PROD_TYPE_MAX,
> >> };
> >>
> >> @@ -77,6 +79,7 @@ struct evt_options {
> >> uint64_t timer_tick_nsec;
> >> uint64_t optm_timer_tick_nsec;
> >> enum evt_prod_type prod_type;
> >> + enum rte_event_crypto_adapter_mode crypto_adptr_mode;
> >> };
> >>
> >> static inline bool
> >> diff --git a/app/test-eventdev/evt_main.c
> >> b/app/test-eventdev/evt_main.c index 194c980c7a..cef0fb1382 100644
> >> --- a/app/test-eventdev/evt_main.c
> >> +++ b/app/test-eventdev/evt_main.c
> >> @@ -161,12 +161,19 @@ main(int argc, char **argv)
> >> goto mempool_destroy;
> >> }
> >> }
> >New line required
> Will add.
>
> >> + /* Test specific cryptodev setup */
> >> + if (test->ops.cryptodev_setup) {
> >> + if (test->ops.cryptodev_setup(test, &opt)) {
> >> + evt_err("%s: cryptodev setup failed",
> >> opt.test_name);
> >> + goto ethdev_destroy;
> >> + }
> >> + }
> >>
> >> /* Test specific eventdev setup */
> >> if (test->ops.eventdev_setup) {
> >> if (test->ops.eventdev_setup(test, &opt)) {
> >> evt_err("%s: eventdev setup failed",
> opt.test_name);
> >> - goto ethdev_destroy;
> >> + goto cryptodev_destroy;
> >> }
> >> }
> >>
> >> @@ -197,6 +204,10 @@ main(int argc, char **argv)
> >> if (test->ops.eventdev_destroy)
> >> test->ops.eventdev_destroy(test, &opt);
> >>
> >> +cryptodev_destroy:
> >> + if (test->ops.cryptodev_destroy)
> >> + test->ops.cryptodev_destroy(test, &opt);
> >> +
> >> ethdev_destroy:
> >> if (test->ops.ethdev_destroy)
> >> test->ops.ethdev_destroy(test, &opt); diff --git a/app/test-
> >> eventdev/evt_options.c b/app/test-eventdev/evt_options.c index
> >> 753a7dbd7d..5ad1491020 100644
> >> --- a/app/test-eventdev/evt_options.c
> >> +++ b/app/test-eventdev/evt_options.c
> >> @@ -122,6 +122,26 @@ evt_parse_timer_prod_type_burst(struct
> >> evt_options *opt,
> >> return 0;
> >> }
> >>
> >> +static int
> >> +evt_parse_crypto_prod_type(struct evt_options *opt,
> >> + const char *arg __rte_unused)
> >> +{
> >> + opt->prod_type = EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR;
> >> + return 0;
> >> +}
> >> +
> >> +static int
> >> +evt_parse_crypto_adptr_mode(struct evt_options *opt, const char
> *arg) {
> >> + uint8_t mode;
> >> + int ret;
> >> +
> >> + ret = parser_read_uint8(&mode, arg);
> >> + opt->crypto_adptr_mode = mode ?
> >> RTE_EVENT_CRYPTO_ADAPTER_OP_FORWARD :
> >> +
> >> RTE_EVENT_CRYPTO_ADAPTER_OP_NEW;
> >> + return ret;
> >> +}
> >> +
> >> static int
> >> evt_parse_test_name(struct evt_options *opt, const char *arg) { @@
> >> -
> >> 335,6 +355,7 @@ usage(char *program)
> >> "\t--queue_priority : enable queue priority\n"
> >> "\t--deq_tmo_nsec : global dequeue timeout\n"
> >> "\t--prod_type_ethdev : use ethernet device as
> producer.\n"
> >> + "\t--prod_type_cryptodev : use crypto device as
> >> producer.\n"
> >> "\t--prod_type_timerdev : use event timer device as
> producer.\n"
> >> "\t expity_nsec would be the timeout\n"
> >> "\t in ns.\n"
> >> @@ -345,6 +366,8 @@ usage(char *program)
> >> "\t--timer_tick_nsec : timer tick interval in ns.\n"
> >> "\t--max_tmo_nsec : max timeout interval in ns.\n"
> >> "\t--expiry_nsec : event timer expiry ns.\n"
> >> + "\t--crypto_adptr_mode : 0 for OP_NEW mode (default)
> >> and\n"
> >> + "\t 1 for OP_FORWARD mode.\n"
> >> "\t--mbuf_sz : packet mbuf size.\n"
> >> "\t--max_pkt_sz : max packet size.\n"
> >> "\t--prod_enq_burst_sz : producer enqueue burst size.\n"
> >> @@ -415,8 +438,10 @@ static struct option lgopts[] = {
> >> { EVT_QUEUE_PRIORITY, 0, 0, 0 },
> >> { EVT_DEQ_TMO_NSEC, 1, 0, 0 },
> >> { EVT_PROD_ETHDEV, 0, 0, 0 },
> >> + { EVT_PROD_CRYPTODEV, 0, 0, 0 },
> >> { EVT_PROD_TIMERDEV, 0, 0, 0 },
> >> { EVT_PROD_TIMERDEV_BURST, 0, 0, 0 },
> >> + { EVT_CRYPTO_ADPTR_MODE, 1, 0, 0 },
> >> { EVT_NB_TIMERS, 1, 0, 0 },
> >> { EVT_NB_TIMER_ADPTRS, 1, 0, 0 },
> >> { EVT_TIMER_TICK_NSEC, 1, 0, 0 },
> >> @@ -455,8 +480,10 @@ evt_opts_parse_long(int opt_idx, struct
> >> evt_options
> >> *opt)
> >> { EVT_QUEUE_PRIORITY, evt_parse_queue_priority},
> >> { EVT_DEQ_TMO_NSEC, evt_parse_deq_tmo_nsec},
> >> { EVT_PROD_ETHDEV, evt_parse_eth_prod_type},
> >> + { EVT_PROD_CRYPTODEV, evt_parse_crypto_prod_type},
> >> { EVT_PROD_TIMERDEV, evt_parse_timer_prod_type},
> >> { EVT_PROD_TIMERDEV_BURST,
> >> evt_parse_timer_prod_type_burst},
> >> + { EVT_CRYPTO_ADPTR_MODE,
> >> evt_parse_crypto_adptr_mode},
> >> { EVT_NB_TIMERS, evt_parse_nb_timers},
> >> { EVT_NB_TIMER_ADPTRS, evt_parse_nb_timer_adptrs},
> >> { EVT_TIMER_TICK_NSEC, evt_parse_timer_tick_nsec}, diff --
> git
> >> a/app/test-eventdev/evt_options.h b/app/test-eventdev/evt_options.h
> >> index 413d7092f0..2231c58801 100644
> >> --- a/app/test-eventdev/evt_options.h
> >> +++ b/app/test-eventdev/evt_options.h
> >> @@ -9,6 +9,7 @@
> >> #include <stdbool.h>
> >>
> >> #include <rte_common.h>
> >> +#include <rte_cryptodev.h>
> >> #include <rte_ethdev.h>
> >> #include <rte_eventdev.h>
> >> #include <rte_lcore.h>
> >> @@ -33,8 +34,10 @@
> >> #define EVT_QUEUE_PRIORITY ("queue_priority")
> >> #define EVT_DEQ_TMO_NSEC ("deq_tmo_nsec")
> >> #define EVT_PROD_ETHDEV ("prod_type_ethdev")
> >> +#define EVT_PROD_CRYPTODEV ("prod_type_cryptodev")
> >> #define EVT_PROD_TIMERDEV ("prod_type_timerdev")
> >> #define EVT_PROD_TIMERDEV_BURST ("prod_type_timerdev_burst")
> >> +#define EVT_CRYPTO_ADPTR_MODE ("crypto_adptr_mode")
> >> #define EVT_NB_TIMERS ("nb_timers")
> >> #define EVT_NB_TIMER_ADPTRS ("nb_timer_adptrs")
> >> #define EVT_TIMER_TICK_NSEC ("timer_tick_nsec")
> >> @@ -249,6 +252,8 @@ evt_prod_id_to_name(enum evt_prod_type
> >> prod_type)
> >> return "Ethdev Rx Adapter";
> >> case EVT_PROD_TYPE_EVENT_TIMER_ADPTR:
> >> return "Event timer adapter";
> >> + case EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR:
> >> + return "Event crypto adapter";
> >> }
> >>
> >> return "";
> >> @@ -288,6 +293,13 @@ evt_dump_producer_type(struct evt_options
> *opt)
> >> evt_dump("timer_tick_nsec", "%"PRIu64"",
> >> opt->timer_tick_nsec);
> >> break;
> >> + case EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR:
> >> + snprintf(name, EVT_PROD_MAX_NAME_LEN,
> >> + "Event crypto adapter producers");
> >> + evt_dump("crypto adapter mode", "%s",
> >> + opt->crypto_adptr_mode ? "OP_FORWARD" :
> >> "OP_NEW");
> >> + evt_dump("nb_cryptodev", "%u", rte_cryptodev_count());
> >> + break;
> >> }
> >> evt_dump("prod_type", "%s", name);
> >> }
> >> diff --git a/app/test-eventdev/evt_test.h
> >> b/app/test-eventdev/evt_test.h index f07d2c3336..50fa474ec2 100644
> >> --- a/app/test-eventdev/evt_test.h
> >> +++ b/app/test-eventdev/evt_test.h
> >> @@ -29,6 +29,8 @@ typedef int (*evt_test_mempool_setup_t)
> >> (struct evt_test *test, struct evt_options *opt); typedef int
> >> (*evt_test_ethdev_setup_t)
> >> (struct evt_test *test, struct evt_options *opt);
> >> +typedef int (*evt_test_cryptodev_setup_t)
> >> + (struct evt_test *test, struct evt_options *opt);
> >> typedef int (*evt_test_eventdev_setup_t)
> >> (struct evt_test *test, struct evt_options *opt); typedef int
> >> (*evt_test_launch_lcores_t) @@ -39,6 +41,8 @@ typedef void
> >> (*evt_test_eventdev_destroy_t)
> >> (struct evt_test *test, struct evt_options *opt); typedef void
> >> (*evt_test_ethdev_destroy_t)
> >> (struct evt_test *test, struct evt_options *opt);
> >> +typedef void (*evt_test_cryptodev_destroy_t)
> >> + (struct evt_test *test, struct evt_options *opt);
> >> typedef void (*evt_test_mempool_destroy_t)
> >> (struct evt_test *test, struct evt_options *opt); typedef void
> >> (*evt_test_destroy_t) @@ -52,10 +56,12 @@ struct evt_test_ops {
> >> evt_test_mempool_setup_t mempool_setup;
> >> evt_test_ethdev_setup_t ethdev_setup;
> >> evt_test_eventdev_setup_t eventdev_setup;
> >> + evt_test_cryptodev_setup_t cryptodev_setup;
> >> evt_test_launch_lcores_t launch_lcores;
> >> evt_test_result_t test_result;
> >> evt_test_eventdev_destroy_t eventdev_destroy;
> >> evt_test_ethdev_destroy_t ethdev_destroy;
> >> + evt_test_cryptodev_destroy_t cryptodev_destroy;
> >> evt_test_mempool_destroy_t mempool_destroy;
> >> evt_test_destroy_t test_destroy;
> >> };
> >> diff --git a/app/test-eventdev/test_perf_atq.c b/app/test-
> >> eventdev/test_perf_atq.c index 8fd51004ee..dbb1dc8c0c 100644
> >> --- a/app/test-eventdev/test_perf_atq.c
> >> +++ b/app/test-eventdev/test_perf_atq.c
> >> @@ -48,6 +48,22 @@ perf_atq_worker(void *arg, const int
> >> enable_fwd_latency)
> >> continue;
> >> }
> >>
> >> + if (prod_crypto_type &&
> >> + (ev.event_type == RTE_EVENT_TYPE_CRYPTODEV)) {
> >> + struct rte_crypto_op *op = ev.event_ptr;
> >> +
> >> + if (op->status ==
> >> RTE_CRYPTO_OP_STATUS_SUCCESS) {
> >> + if (op->sym->m_dst == NULL)
> >> + ev.event_ptr = op->sym->m_src;
> >> + else
> >> + ev.event_ptr = op->sym->m_dst;
> >> + rte_crypto_op_free(op);
> >> + } else {
> >> + rte_crypto_op_free(op);
> >> + continue;
> >> + }
> >> + }
> >> +
> >> if (enable_fwd_latency && !prod_timer_type)
> >> /* first stage in pipeline, mark ts to compute fwd latency */
> >> atq_mark_fwd_latency(&ev);
> >> @@ -87,6 +103,25 @@ perf_atq_worker_burst(void *arg, const int
> >> enable_fwd_latency)
> >> }
> >>
> >> for (i = 0; i < nb_rx; i++) {
> >> + if (prod_crypto_type &&
> >> + (ev[i].event_type ==
> >> RTE_EVENT_TYPE_CRYPTODEV)) {
> >> + struct rte_crypto_op *op = ev[i].event_ptr;
> >> +
> >> + if (op->status ==
> >> + RTE_CRYPTO_OP_STATUS_SUCCESS) {
> >> + if (op->sym->m_dst == NULL)
> >> + ev[i].event_ptr =
> >> + op->sym->m_src;
> >> + else
> >> + ev[i].event_ptr =
> >> + op->sym->m_dst;
> >> + rte_crypto_op_free(op);
> >> + } else {
> >> + rte_crypto_op_free(op);
> >> + continue;
> >> + }
> >> + }
> >> +
> >> if (enable_fwd_latency && !prod_timer_type) {
> >> rte_prefetch0(ev[i+1].event_ptr);
> >> /* first stage in pipeline.
> >> @@ -254,6 +289,20 @@ perf_atq_eventdev_setup(struct evt_test *test,
> >> struct evt_options *opt)
> >> return ret;
> >> }
> >> }
> >> + } else if (opt->prod_type ==
> >> EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR) {
> >> + uint8_t cdev_id, cdev_count;
> >> +
> >> + cdev_count = rte_cryptodev_count();
> >> + for (cdev_id = 0; cdev_id < cdev_count; cdev_id++) {
> >> + ret = rte_cryptodev_start(cdev_id);
> >> + if (ret) {
> >> + evt_err("Failed to start cryptodev %u",
> >> + cdev_id);
> >> + return ret;
> >> + }
> >> + }
> >> +
> >> + rte_event_crypto_adapter_start(t->crypto_adptr.id);
> >> }
> >>
> >> return 0;
> >> @@ -295,12 +344,14 @@ static const struct evt_test_ops perf_atq = {
> >> .opt_dump = perf_atq_opt_dump,
> >> .test_setup = perf_test_setup,
> >> .ethdev_setup = perf_ethdev_setup,
> >> + .cryptodev_setup = perf_cryptodev_setup,
> >> .mempool_setup = perf_mempool_setup,
> >> .eventdev_setup = perf_atq_eventdev_setup,
> >> .launch_lcores = perf_atq_launch_lcores,
> >> .eventdev_destroy = perf_eventdev_destroy,
> >> .mempool_destroy = perf_mempool_destroy,
> >> .ethdev_destroy = perf_ethdev_destroy,
> >> + .cryptodev_destroy = perf_cryptodev_destroy,
> >> .test_result = perf_test_result,
> >> .test_destroy = perf_test_destroy,
> >> };
> >> diff --git a/app/test-eventdev/test_perf_common.c b/app/test-
> >> eventdev/test_perf_common.c index 9b73874151..91cb6748ee 100644
> >> --- a/app/test-eventdev/test_perf_common.c
> >> +++ b/app/test-eventdev/test_perf_common.c
> >> @@ -6,6 +6,8 @@
> >>
> >> #include "test_perf_common.h"
> >>
> >> +#define NB_CRYPTODEV_DESCRIPTORS 128
> >> +
> >> int
> >> perf_test_result(struct evt_test *test, struct evt_options *opt) {
> >> @@ -272,6
> >> +274,125 @@ perf_event_timer_producer_burst(void *arg)
> >> return 0;
> >> }
> >>
> >> +static inline void
> >> +crypto_adapter_enq_op_new(struct prod_data *p) {
> >> + struct rte_cryptodev_sym_session **crypto_sess = p->crypto_sess;
> >> + struct test_perf *t = p->t;
> >> + const uint32_t nb_flows = t->nb_flows;
> >> + const uint64_t nb_pkts = t->nb_pkts;
> >> + struct rte_mempool *pool = t->pool;
> >> + struct rte_crypto_sym_op *sym_op;
> >> + struct evt_options *opt = t->opt;
> >> + uint16_t qp_id = p->cdev_qp_id;
> >> + uint8_t cdev_id = p->cdev_id;
> >> + uint32_t flow_counter = 0;
> >> + struct rte_crypto_op *op;
> >> + struct rte_mbuf *m;
> >> + uint64_t count = 0;
> >> + uint16_t len;
> >> +
> >> + if (opt->verbose_level > 1)
> >> + printf("%s(): lcore %d queue %d cdev_id %u cdev_qp_id
> >> %u\n",
> >> + __func__, rte_lcore_id(), p->queue_id, p->cdev_id,
> >> + p->cdev_qp_id);
> >> +
> >> + len = opt->mbuf_sz ? opt->mbuf_sz : RTE_ETHER_MIN_LEN;
> >> +
> >> + while (count < nb_pkts && t->done == false) {
> >> + m = rte_pktmbuf_alloc(pool);
> >> + if (m == NULL)
> >> + continue;
> >> +
> >> + rte_pktmbuf_append(m, len);
> >> + op = rte_crypto_op_alloc(t->crypto_adptr.op_pool,
> >> +
> >> RTE_CRYPTO_OP_TYPE_SYMMETRIC);
> >> + sym_op = op->sym;
> >> + sym_op->m_src = m;
> >> + sym_op->cipher.data.offset = 0;
> >> + sym_op->cipher.data.length = len;
> >> + rte_crypto_op_attach_sym_session(
> >> + op, crypto_sess[flow_counter++ % nb_flows]);
> >> + while (rte_cryptodev_enqueue_burst(cdev_id, qp_id, &op,
> >> 1) !=
> >> + 1) {
> >> + if (t->done)
> >> + break;
> >> + rte_pause();
> >> + }
> >> + count++;
> >> + }
> >> +}
> >> +
> >> +static inline void
> >> +crypto_adapter_enq_op_fwd(struct prod_data *p) {
> >> + struct rte_cryptodev_sym_session **crypto_sess = p->crypto_sess;
> >> + const uint8_t dev_id = p->dev_id;
> >> + const uint8_t port = p->port_id;
> >> + struct test_perf *t = p->t;
> >> + const uint32_t nb_flows = t->nb_flows;
> >> + const uint64_t nb_pkts = t->nb_pkts;
> >> + struct rte_mempool *pool = t->pool;
> >> + struct evt_options *opt = t->opt;
> >> + struct rte_crypto_sym_op *sym_op;
> >> + uint32_t flow_counter = 0;
> >> + struct rte_crypto_op *op;
> >> + struct rte_event ev;
> >> + struct rte_mbuf *m;
> >> + uint64_t count = 0;
> >> + uint16_t len;
> >> +
> >> + if (opt->verbose_level > 1)
> >> + printf("%s(): lcore %d port %d queue %d cdev_id %u
> >> cdev_qp_id %u\n",
> >> + __func__, rte_lcore_id(), port, p->queue_id, p->cdev_id,
> >> + p->cdev_qp_id);
> >> +
> >> + ev.event = 0;
> >> + ev.op = RTE_EVENT_OP_NEW;
> >> + ev.queue_id = p->queue_id;
> >> + ev.sched_type = RTE_SCHED_TYPE_ATOMIC;
> >> + ev.event_type = RTE_EVENT_TYPE_CPU;
> >> + len = opt->mbuf_sz ? opt->mbuf_sz : RTE_ETHER_MIN_LEN;
> >> +
> >> + while (count < nb_pkts && t->done == false) {
> >> + m = rte_pktmbuf_alloc(pool);
> >> + if (m == NULL)
> >> + continue;
> >> +
> >> + rte_pktmbuf_append(m, len);
> >> + op = rte_crypto_op_alloc(t->crypto_adptr.op_pool,
> >> +
> >> RTE_CRYPTO_OP_TYPE_SYMMETRIC);
> >> + sym_op = op->sym;
> >> + sym_op->m_src = m;
> >> + sym_op->cipher.data.offset = 0;
> >> + sym_op->cipher.data.length = len;
> >> + rte_crypto_op_attach_sym_session(
> >> + op, crypto_sess[flow_counter++ % nb_flows]);
> >> + ev.event_ptr = op;
> >> + while (rte_event_crypto_adapter_enqueue(dev_id, port,
> >> &ev, 1) !=
> >> + 1) {
> >> + if (t->done)
> >> + break;
> >> + rte_pause();
> >> + }
> >> + count++;
> >> + }
> >> +}
> >> +
> >> +static inline int
> >> +perf_event_crypto_producer(void *arg) {
> >> + struct prod_data *p = arg;
> >> + struct evt_options *opt = p->t->opt;
> >> +
> >> + if (opt->crypto_adptr_mode ==
> >> RTE_EVENT_CRYPTO_ADAPTER_OP_NEW)
> >> + crypto_adapter_enq_op_new(p);
> >> + else
> >> + crypto_adapter_enq_op_fwd(p);
> >> +
> >> + return 0;
> >> +}
> >> +
> >> static int
> >> perf_producer_wrapper(void *arg)
> >> {
> >> @@ -298,6 +419,8 @@ perf_producer_wrapper(void *arg)
> >> else if (t->opt->prod_type ==
> >> EVT_PROD_TYPE_EVENT_TIMER_ADPTR &&
> >> t->opt->timdev_use_burst)
> >> return perf_event_timer_producer_burst(arg);
> >> + else if (t->opt->prod_type ==
> >> EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR)
> >> + return perf_event_crypto_producer(arg);
> >> return 0;
> >> }
> >>
> >> @@ -405,8 +528,10 @@ perf_launch_lcores(struct evt_test *test, struct
> >> evt_options *opt,
> >> if (remaining <= 0) {
> >> t->result = EVT_TEST_SUCCESS;
> >> if (opt->prod_type ==
> >> EVT_PROD_TYPE_SYNT ||
> >> - opt->prod_type ==
> >> -
> >> EVT_PROD_TYPE_EVENT_TIMER_ADPTR) {
> >> + opt->prod_type ==
> >> +
> >> EVT_PROD_TYPE_EVENT_TIMER_ADPTR ||
> >> + opt->prod_type ==
> >> +
> >> EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR) {
> >> t->done = true;
> >> break;
> >> }
> >> @@ -415,7 +540,8 @@ perf_launch_lcores(struct evt_test *test, struct
> >> evt_options *opt,
> >>
> >> if (new_cycles - dead_lock_cycles > dead_lock_sample &&
> >> (opt->prod_type == EVT_PROD_TYPE_SYNT ||
> >> - opt->prod_type ==
> >> EVT_PROD_TYPE_EVENT_TIMER_ADPTR)) {
> >> + opt->prod_type ==
> >> EVT_PROD_TYPE_EVENT_TIMER_ADPTR ||
> >> + opt->prod_type ==
> >> EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR)) {
> >> remaining = t->outstand_pkts - processed_pkts(t);
> >> if (dead_lock_remaining == remaining) {
> >> rte_event_dev_dump(opt->dev_id, stdout);
> @@ -537,6 +663,96 @@
> >> perf_event_timer_adapter_setup(struct test_perf
> >> *t)
> >> return 0;
> >> }
> >>
> >> +static int
> >> +perf_event_crypto_adapter_setup(struct test_perf *t,
> >> + struct rte_event_port_conf port_conf) {
> >> + struct evt_options *opt = t->opt;
> >> + uint8_t cdev_id, cdev_count;
> >> + int ret;
> >> +
> >> + t->crypto_adptr.id = 0;
> >> + ret = rte_event_crypto_adapter_create(t->crypto_adptr.id, opt-
> >> >dev_id,
> >> + &port_conf, 0);
> >> + if (ret)
> >> + return ret;
> >> +
> >> + cdev_count = rte_cryptodev_count();
> >> + for (cdev_id = 0; cdev_id < cdev_count; cdev_id++) {
> >> + uint32_t cap;
> >> +
> >> + ret = rte_event_crypto_adapter_caps_get(opt->dev_id,
> >> cdev_id,
> >> + &cap);
> >> + if (ret) {
> >> + evt_err("Failed to get crypto adapter capabilities");
> >> + return ret;
> >> + }
> >> +
> >> + if (((opt->crypto_adptr_mode ==
> >> + RTE_EVENT_CRYPTO_ADAPTER_OP_NEW) &&
> >> + !(cap &
> >> +
> >> RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_OP_NEW)) ||
> >> + ((opt->crypto_adptr_mode ==
> >> + RTE_EVENT_CRYPTO_ADAPTER_OP_FORWARD) &&
> >> + !(cap &
> >> +
> >> RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_OP_FWD))) {
> >> + evt_err("crypto adapter %s mode unsupported\n",
> >> + opt->crypto_adptr_mode ? "OP_FORWARD"
> >> :
> >> + "OP_NEW");
> >> + return -EINVAL;
> >> + }
> >> +
> >> + if (!(cap &
> >> +
> >> RTE_EVENT_CRYPTO_ADAPTER_CAP_SESSION_PRIVATE_DATA)) {
> >> + evt_err("Storing crypto session not supported");
> >> + return -EINVAL;
> >> + }
> >> +
> >> + if (cap &
> >> +
> >> RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_QP_EV_BIND) {
> >> + struct rte_event response_info;
> >> +
> >> + response_info.event = 0;
> >> + ret = rte_event_crypto_adapter_queue_pair_add(
> >> + t->crypto_adptr.id, cdev_id, -1,
> >> + &response_info);
> >> + } else {
> >> + ret = rte_event_crypto_adapter_queue_pair_add(
> >> + t->crypto_adptr.id, cdev_id, -1, NULL);
> >> + }
> >> + if (ret)
> >> + return ret;
> >> + }
> >> +
> >> + return 0;
> >> +}
> >> +
> >> +static struct rte_cryptodev_sym_session *
> >> +cryptodev_sym_sess_create(struct prod_data *p, struct test_perf *t) {
> >> + struct rte_crypto_sym_xform cipher_xform;
> >> + struct rte_cryptodev_sym_session *sess;
> >> +
> >> + cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
> >> + cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
> >> + cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
> >> + cipher_xform.next = NULL;
> >> +
> >> + sess = rte_cryptodev_sym_session_create(t-
> >> >crypto_adptr.sess_pool);
> >> + if (sess == NULL) {
> >> + evt_err("Failed to create sym session");
> >> + return NULL;
> >> + }
> >> +
> >> + if (rte_cryptodev_sym_session_init(p->cdev_id, sess,
> >> &cipher_xform,
> >> + t->crypto_adptr.sess_priv_pool)) {
> >> + evt_err("Failed to init session");
> >> + return NULL;
> >> + }
> >> +
> >> + return sess;
> >> +}
> >> +
> >> int
> >> perf_event_dev_port_setup(struct evt_test *test, struct evt_options
> *opt,
> >> uint8_t stride, uint8_t nb_queues, @@ -
> 598,6 +814,55 @@
> >> perf_event_dev_port_setup(struct evt_test *test, struct evt_options
> >> *opt,
> >> ret = perf_event_timer_adapter_setup(t);
> >> if (ret)
> >> return ret;
> >> + } else if (opt->prod_type ==
> >> EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR) {
> >> + uint8_t cdev_id = 0;
> >> + uint16_t qp_id = 0;
> >> +
> >> + prod = 0;
> >> + for (; port < perf_nb_event_ports(opt); port++) {
> >> + struct rte_cryptodev_sym_session *crypto_sess;
> >> + union rte_event_crypto_metadata m_data;
> >> + struct prod_data *p = &t->prod[port];
> >> + uint32_t flow_id;
> >> +
> >> + if (qp_id ==
> >> rte_cryptodev_queue_pair_count(cdev_id)) {
> >> + cdev_id++;
> >> + qp_id = 0;
> >> + }
> >> +
> >> + p->dev_id = opt->dev_id;
> >> + p->port_id = port;
> >> + p->queue_id = prod * stride;
> >> + p->cdev_id = cdev_id;
> >> + p->cdev_qp_id = qp_id;
> >> + p->crypto_sess = rte_zmalloc_socket(
> >> + NULL, sizeof(crypto_sess) * t->nb_flows,
> >> + RTE_CACHE_LINE_SIZE, opt->socket_id);
> >> +
> >> + m_data.request_info.cdev_id = p->cdev_id;
> >> + m_data.request_info.queue_pair_id = p-
> >> >cdev_qp_id;
> >> + m_data.response_info.op = RTE_EVENT_OP_NEW;
> >> + m_data.response_info.sched_type =
> >> RTE_SCHED_TYPE_ATOMIC;
> >> + m_data.response_info.event_type =
> >> RTE_EVENT_TYPE_CPU;
> >> + m_data.response_info.queue_id = p->queue_id;
> >> + for (flow_id = 0; flow_id < t->nb_flows; flow_id++) {
> >> + crypto_sess =
> >> cryptodev_sym_sess_create(p, t);
> >> + if (crypto_sess == NULL)
> >> + return -ENOMEM;
> >> +
> >> + m_data.response_info.flow_id = flow_id;
> >> + rte_cryptodev_sym_session_set_user_data(
> >> + crypto_sess, &m_data,
> >> sizeof(m_data));
> >> + p->crypto_sess[flow_id] = crypto_sess;
> >> + }
> >> + p->t = t;
> >> + qp_id++;
> >> + prod++;
> >> + }
> >> +
> >> + ret = perf_event_crypto_adapter_setup(t, *port_conf);
> >> + if (ret)
> >> + return ret;
> >> } else {
> >> prod = 0;
> >> for ( ; port < perf_nb_event_ports(opt); port++) { @@ -659,7
> >> +924,8 @@ perf_opt_check(struct evt_options *opt, uint64_t
> nb_queues)
> >> }
> >>
> >> if (opt->prod_type == EVT_PROD_TYPE_SYNT ||
> >> - opt->prod_type ==
> >> EVT_PROD_TYPE_EVENT_TIMER_ADPTR) {
> >> + opt->prod_type == EVT_PROD_TYPE_EVENT_TIMER_ADPTR ||
> >> + opt->prod_type == EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR) {
> >> /* Validate producer lcores */
> >> if (evt_lcores_has_overlap(opt->plcores,
> >> rte_get_main_lcore())) {
> >> @@ -767,8 +1033,7 @@ perf_ethdev_setup(struct evt_test *test, struct
> >> evt_options *opt)
> >> },
> >> };
> >>
> >> - if (opt->prod_type == EVT_PROD_TYPE_SYNT ||
> >> - opt->prod_type ==
> >> EVT_PROD_TYPE_EVENT_TIMER_ADPTR)
> >> + if (opt->prod_type != EVT_PROD_TYPE_ETH_RX_ADPTR)
> >> return 0;
> >>
> >> if (!rte_eth_dev_count_avail()) {
> >> @@ -841,6 +1106,139 @@ void perf_ethdev_destroy(struct evt_test
> >> *test, struct evt_options *opt)
> >> }
> >> }
> >>
> >> +int
> >> +perf_cryptodev_setup(struct evt_test *test, struct evt_options *opt) {
> >> + uint8_t cdev_count, cdev_id, nb_plcores, nb_qps;
> >> + struct test_perf *t = evt_test_priv(test);
> >> + unsigned int max_session_size;
> >> + uint32_t nb_sessions;
> >> + int ret;
> >> +
> >> + if (opt->prod_type != EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR)
> >> + return 0;
> >How do you differentiate between this failed case as you are returning
> >0 in case of success?
>
> This is not a failed case. cryptodev setup is not needed in other modes and is
> ignored.
Ok
>
> >> +
> >> + cdev_count = rte_cryptodev_count();
> >> + if (cdev_count == 0) {
> >> + evt_err("No crypto devices available\n");
> >> + return -ENODEV;
> >> + }
> >> +
> >> + t->crypto_adptr.op_pool = rte_crypto_op_pool_create(
> >> + "crypto_op_pool", RTE_CRYPTO_OP_TYPE_SYMMETRIC, opt-
> >> >pool_sz,
> >> + 128, 0, rte_socket_id());
> >> + if (t->crypto_adptr.op_pool == NULL) {
> >> + evt_err("Failed to create crypto op pool");
> >> + return -ENOMEM;
> >> + }
> >> +
> >> + nb_sessions = evt_nr_active_lcores(opt->plcores) * t->nb_flows;
> >> + t->crypto_adptr.sess_pool =
> >> rte_cryptodev_sym_session_pool_create(
> >> + "ca_sess_pool", nb_sessions, 0, 0,
> >> + sizeof(union rte_event_crypto_metadata),
> >> SOCKET_ID_ANY);
> >> + if (t->crypto_adptr.sess_pool == NULL) {
> >> + evt_err("Failed to create sym session pool");
> >> + ret = -ENOMEM;
> >> + goto err;
> >> + }
> >> +
> >> + max_session_size = 0;
> >> + for (cdev_id = 0; cdev_id < cdev_count; cdev_id++) {
> >> + unsigned int session_size;
> >> +
> >> + session_size =
> >> +
> >> rte_cryptodev_sym_get_private_session_size(cdev_id);
> >> + if (session_size > max_session_size)
> >> + max_session_size = session_size;
> >> + }
> >New line required
> Will add.
>
> >> + max_session_size += sizeof(union rte_event_crypto_metadata);
> >> + t->crypto_adptr.sess_priv_pool = rte_mempool_create(
> >> + "ca_sess_priv_pool", nb_sessions, max_session_size, 0, 0,
> >> NULL,
> >> + NULL, NULL, NULL, SOCKET_ID_ANY, 0);
> >> + if (t->crypto_adptr.sess_priv_pool == NULL) {
> >> + evt_err("failed to create sym session private pool");
> >> + ret = -ENOMEM;
> >> + goto err;
> >> + }
> >> +
> >> + nb_plcores = evt_nr_active_lcores(opt->plcores);
> >> + nb_qps = (nb_plcores % cdev_count) ? (nb_plcores / cdev_count) +
> >> 1 :
> >> + nb_plcores / cdev_count;
> >Let's take an example:
> >Cdev1 -> 8 qps
> >Cdev2 -> 2 qps
> >Cdev_count = 2
> >nb_plcores = 7
> >As per above statement, nb_qps = ( 7 % 2 ) 7/2 + 1 = 4 qps So, this
> >fails to setup qps for cdev2 as it supports only 2 qps and test exits!
> >Am I missing anything?
> >
> What you told is correct. But this is a simple logic to distribute qps across
> multiple cdev and doesn't consider the case you mentioned. You could see
> similar logic used in other apps. I will add a comment as below:
> /*
> * Calculate number of needed queue pairs, based on the amount
> * of available number of logical cores and crypto devices.
> * For instance, if there are 4 cores and 2 crypto devices,
> * 2 queue pairs will be set up per device.
> */
Sounds good.
>
> >> + for (cdev_id = 0; cdev_id < cdev_count; cdev_id++) {
> >> + struct rte_cryptodev_qp_conf qp_conf;
> >> + struct rte_cryptodev_config conf;
> >> + struct rte_cryptodev_info info;
> >> + int qp_id;
> >> +
> >> + rte_cryptodev_info_get(cdev_id, &info);
> >> + if (nb_qps > info.max_nb_queue_pairs) {
> >> + evt_err("Not enough queue pairs per cryptodev
> >> (%u)",
> >> + nb_qps);
> >> + ret = -EINVAL;
> >> + goto err;
> >> + }
> >> +
> >> + conf.nb_queue_pairs = nb_qps;
> >> + conf.socket_id = SOCKET_ID_ANY;
> >> + conf.ff_disable = RTE_CRYPTODEV_FF_SECURITY;
> >> +
> >> + ret = rte_cryptodev_configure(cdev_id, &conf);
> >> + if (ret) {
> >> + evt_err("Failed to configure cryptodev (%u)",
> >> cdev_id);
> >> + goto err;
> >> + }
> >> +
> >> + qp_conf.nb_descriptors = NB_CRYPTODEV_DESCRIPTORS;
> >> + qp_conf.mp_session = t->crypto_adptr.sess_pool;
> >> + qp_conf.mp_session_private = t-
> >> >crypto_adptr.sess_priv_pool;
> >> +
> >> + for (qp_id = 0; qp_id < conf.nb_queue_pairs; qp_id++) {
> >> + ret = rte_cryptodev_queue_pair_setup(
> >> + cdev_id, qp_id, &qp_conf,
> >> + rte_cryptodev_socket_id(cdev_id));
> >> + if (ret) {
> >> + evt_err("Failed to setup queue pairs on
> >> cryptodev %u\n",
> >> + cdev_id);
> >> + goto err;
> >> + }
> >> + }
> >> + }
> >> +
> >> + return 0;
> >> +err:
> >> + rte_mempool_free(t->crypto_adptr.op_pool);
> >> + rte_mempool_free(t->crypto_adptr.sess_pool);
> >> + rte_mempool_free(t->crypto_adptr.sess_priv_pool);
> >> +
> >> + return ret;
> >> +}
> >> +
> >> +void
> >> +perf_cryptodev_destroy(struct evt_test *test, struct evt_options
> >> +*opt) {
> >> + uint8_t cdev_id, cdev_count = rte_cryptodev_count();
> >> + struct test_perf *t = evt_test_priv(test);
> >> +
> >> + RTE_SET_USED(opt);
> >> +
> >> + if (opt->prod_type != EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR)
> >> + return;
> >> +
> >> + rte_event_crypto_adapter_stop(t->crypto_adptr.id);
> >> +
> >> + for (cdev_id = 0; cdev_id < cdev_count; cdev_id++) {
> >> + rte_cryptodev_stop(cdev_id);
> >> + rte_event_crypto_adapter_queue_pair_del(t-
> >> >crypto_adptr.id,
> >> + cdev_id, -1);
> >Any reason for passing -1? This can not ensure to cleanup all the
> >preconfigured qps as per API.
> Okay, I thought the behavior is like
> rte_event_crypto_adapter_queue_pair_add.
> Any reason, spec desn't consider -1 for
> rte_event_crypto_adapter_queue_pair_del ?
May be, there was no ask for it.
>
<SNIPPED>
^ permalink raw reply [flat|nested] 43+ messages in thread
* [PATCH v4] app/eventdev: add crypto producer mode
2022-01-04 10:30 ` [PATCH v3] " Shijith Thotton
2022-01-21 12:25 ` Jerin Jacob
2022-01-23 18:44 ` Gujjar, Abhinandan S
@ 2022-02-08 16:33 ` Shijith Thotton
2022-02-15 6:03 ` Gujjar, Abhinandan S
2022-02-15 16:56 ` [PATCH v5] " Shijith Thotton
2 siblings, 2 replies; 43+ messages in thread
From: Shijith Thotton @ 2022-02-08 16:33 UTC (permalink / raw)
To: dev, jerinj, abhinandan.gujjar; +Cc: Shijith Thotton
In crypto producer mode, producer core enqueues cryptodev with software
generated crypto ops and worker core dequeues crypto completion events
from the eventdev. Event crypto metadata used for above processing is
pre-populated in each crypto session.
Parameter --prod_type_cryptodev can be used to enable crypto producer
mode. Parameter --crypto_adptr_mode can be set to select the crypto
adapter mode, 0 for OP_NEW and 1 for OP_FORWARD.
This mode can be used to measure the performance of crypto adapter.
Example:
./dpdk-test-eventdev -l 0-2 -w <EVENTDEV> -w <CRYPTODEV> -- \
--prod_type_cryptodev --crypto_adptr_mode 1 --test=perf_atq \
--stlist=a --wlcores 1 --plcores 2
Signed-off-by: Shijith Thotton <sthotton@marvell.com>
---
v4:
* Addressed comments on v3 and rebased.
* Added cryptodev cleanup in signal handler.
v3:
* Reduce dereference inside loop.
v2:
* Fix RHEL compilation warning.
app/test-eventdev/evt_common.h | 3 +
app/test-eventdev/evt_main.c | 17 +-
app/test-eventdev/evt_options.c | 27 ++
app/test-eventdev/evt_options.h | 12 +
app/test-eventdev/evt_test.h | 6 +
app/test-eventdev/test_perf_atq.c | 49 +++
app/test-eventdev/test_perf_common.c | 427 ++++++++++++++++++++++++++-
app/test-eventdev/test_perf_common.h | 18 +-
app/test-eventdev/test_perf_queue.c | 50 ++++
doc/guides/tools/testeventdev.rst | 13 +
10 files changed, 614 insertions(+), 8 deletions(-)
diff --git a/app/test-eventdev/evt_common.h b/app/test-eventdev/evt_common.h
index f466434459..2f301a7e79 100644
--- a/app/test-eventdev/evt_common.h
+++ b/app/test-eventdev/evt_common.h
@@ -7,6 +7,7 @@
#include <rte_common.h>
#include <rte_debug.h>
+#include <rte_event_crypto_adapter.h>
#include <rte_eventdev.h>
#include <rte_service.h>
@@ -39,6 +40,7 @@ enum evt_prod_type {
EVT_PROD_TYPE_SYNT, /* Producer type Synthetic i.e. CPU. */
EVT_PROD_TYPE_ETH_RX_ADPTR, /* Producer type Eth Rx Adapter. */
EVT_PROD_TYPE_EVENT_TIMER_ADPTR, /* Producer type Timer Adapter. */
+ EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR, /* Producer type Crypto Adapter. */
EVT_PROD_TYPE_MAX,
};
@@ -77,6 +79,7 @@ struct evt_options {
uint64_t timer_tick_nsec;
uint64_t optm_timer_tick_nsec;
enum evt_prod_type prod_type;
+ enum rte_event_crypto_adapter_mode crypto_adptr_mode;
};
static inline bool
diff --git a/app/test-eventdev/evt_main.c b/app/test-eventdev/evt_main.c
index 194c980c7a..a7d6b0c1cf 100644
--- a/app/test-eventdev/evt_main.c
+++ b/app/test-eventdev/evt_main.c
@@ -35,6 +35,9 @@ signal_handler(int signum)
if (test->ops.ethdev_destroy)
test->ops.ethdev_destroy(test, &opt);
+ if (test->ops.cryptodev_destroy)
+ test->ops.cryptodev_destroy(test, &opt);
+
rte_eal_mp_wait_lcore();
if (test->ops.test_result)
@@ -162,11 +165,19 @@ main(int argc, char **argv)
}
}
+ /* Test specific cryptodev setup */
+ if (test->ops.cryptodev_setup) {
+ if (test->ops.cryptodev_setup(test, &opt)) {
+ evt_err("%s: cryptodev setup failed", opt.test_name);
+ goto ethdev_destroy;
+ }
+ }
+
/* Test specific eventdev setup */
if (test->ops.eventdev_setup) {
if (test->ops.eventdev_setup(test, &opt)) {
evt_err("%s: eventdev setup failed", opt.test_name);
- goto ethdev_destroy;
+ goto cryptodev_destroy;
}
}
@@ -197,6 +208,10 @@ main(int argc, char **argv)
if (test->ops.eventdev_destroy)
test->ops.eventdev_destroy(test, &opt);
+cryptodev_destroy:
+ if (test->ops.cryptodev_destroy)
+ test->ops.cryptodev_destroy(test, &opt);
+
ethdev_destroy:
if (test->ops.ethdev_destroy)
test->ops.ethdev_destroy(test, &opt);
diff --git a/app/test-eventdev/evt_options.c b/app/test-eventdev/evt_options.c
index 4ae44801da..d3c704d2b3 100644
--- a/app/test-eventdev/evt_options.c
+++ b/app/test-eventdev/evt_options.c
@@ -122,6 +122,26 @@ evt_parse_timer_prod_type_burst(struct evt_options *opt,
return 0;
}
+static int
+evt_parse_crypto_prod_type(struct evt_options *opt,
+ const char *arg __rte_unused)
+{
+ opt->prod_type = EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR;
+ return 0;
+}
+
+static int
+evt_parse_crypto_adptr_mode(struct evt_options *opt, const char *arg)
+{
+ uint8_t mode;
+ int ret;
+
+ ret = parser_read_uint8(&mode, arg);
+ opt->crypto_adptr_mode = mode ? RTE_EVENT_CRYPTO_ADAPTER_OP_FORWARD :
+ RTE_EVENT_CRYPTO_ADAPTER_OP_NEW;
+ return ret;
+}
+
static int
evt_parse_test_name(struct evt_options *opt, const char *arg)
{
@@ -335,6 +355,7 @@ usage(char *program)
"\t--queue_priority : enable queue priority\n"
"\t--deq_tmo_nsec : global dequeue timeout\n"
"\t--prod_type_ethdev : use ethernet device as producer.\n"
+ "\t--prod_type_cryptodev : use crypto device as producer.\n"
"\t--prod_type_timerdev : use event timer device as producer.\n"
"\t expiry_nsec would be the timeout\n"
"\t in ns.\n"
@@ -345,6 +366,8 @@ usage(char *program)
"\t--timer_tick_nsec : timer tick interval in ns.\n"
"\t--max_tmo_nsec : max timeout interval in ns.\n"
"\t--expiry_nsec : event timer expiry ns.\n"
+ "\t--crypto_adptr_mode : 0 for OP_NEW mode (default) and\n"
+ "\t 1 for OP_FORWARD mode.\n"
"\t--mbuf_sz : packet mbuf size.\n"
"\t--max_pkt_sz : max packet size.\n"
"\t--prod_enq_burst_sz : producer enqueue burst size.\n"
@@ -415,8 +438,10 @@ static struct option lgopts[] = {
{ EVT_QUEUE_PRIORITY, 0, 0, 0 },
{ EVT_DEQ_TMO_NSEC, 1, 0, 0 },
{ EVT_PROD_ETHDEV, 0, 0, 0 },
+ { EVT_PROD_CRYPTODEV, 0, 0, 0 },
{ EVT_PROD_TIMERDEV, 0, 0, 0 },
{ EVT_PROD_TIMERDEV_BURST, 0, 0, 0 },
+ { EVT_CRYPTO_ADPTR_MODE, 1, 0, 0 },
{ EVT_NB_TIMERS, 1, 0, 0 },
{ EVT_NB_TIMER_ADPTRS, 1, 0, 0 },
{ EVT_TIMER_TICK_NSEC, 1, 0, 0 },
@@ -455,8 +480,10 @@ evt_opts_parse_long(int opt_idx, struct evt_options *opt)
{ EVT_QUEUE_PRIORITY, evt_parse_queue_priority},
{ EVT_DEQ_TMO_NSEC, evt_parse_deq_tmo_nsec},
{ EVT_PROD_ETHDEV, evt_parse_eth_prod_type},
+ { EVT_PROD_CRYPTODEV, evt_parse_crypto_prod_type},
{ EVT_PROD_TIMERDEV, evt_parse_timer_prod_type},
{ EVT_PROD_TIMERDEV_BURST, evt_parse_timer_prod_type_burst},
+ { EVT_CRYPTO_ADPTR_MODE, evt_parse_crypto_adptr_mode},
{ EVT_NB_TIMERS, evt_parse_nb_timers},
{ EVT_NB_TIMER_ADPTRS, evt_parse_nb_timer_adptrs},
{ EVT_TIMER_TICK_NSEC, evt_parse_timer_tick_nsec},
diff --git a/app/test-eventdev/evt_options.h b/app/test-eventdev/evt_options.h
index 413d7092f0..2231c58801 100644
--- a/app/test-eventdev/evt_options.h
+++ b/app/test-eventdev/evt_options.h
@@ -9,6 +9,7 @@
#include <stdbool.h>
#include <rte_common.h>
+#include <rte_cryptodev.h>
#include <rte_ethdev.h>
#include <rte_eventdev.h>
#include <rte_lcore.h>
@@ -33,8 +34,10 @@
#define EVT_QUEUE_PRIORITY ("queue_priority")
#define EVT_DEQ_TMO_NSEC ("deq_tmo_nsec")
#define EVT_PROD_ETHDEV ("prod_type_ethdev")
+#define EVT_PROD_CRYPTODEV ("prod_type_cryptodev")
#define EVT_PROD_TIMERDEV ("prod_type_timerdev")
#define EVT_PROD_TIMERDEV_BURST ("prod_type_timerdev_burst")
+#define EVT_CRYPTO_ADPTR_MODE ("crypto_adptr_mode")
#define EVT_NB_TIMERS ("nb_timers")
#define EVT_NB_TIMER_ADPTRS ("nb_timer_adptrs")
#define EVT_TIMER_TICK_NSEC ("timer_tick_nsec")
@@ -249,6 +252,8 @@ evt_prod_id_to_name(enum evt_prod_type prod_type)
return "Ethdev Rx Adapter";
case EVT_PROD_TYPE_EVENT_TIMER_ADPTR:
return "Event timer adapter";
+ case EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR:
+ return "Event crypto adapter";
}
return "";
@@ -288,6 +293,13 @@ evt_dump_producer_type(struct evt_options *opt)
evt_dump("timer_tick_nsec", "%"PRIu64"",
opt->timer_tick_nsec);
break;
+ case EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR:
+ snprintf(name, EVT_PROD_MAX_NAME_LEN,
+ "Event crypto adapter producers");
+ evt_dump("crypto adapter mode", "%s",
+ opt->crypto_adptr_mode ? "OP_FORWARD" : "OP_NEW");
+ evt_dump("nb_cryptodev", "%u", rte_cryptodev_count());
+ break;
}
evt_dump("prod_type", "%s", name);
}
diff --git a/app/test-eventdev/evt_test.h b/app/test-eventdev/evt_test.h
index f07d2c3336..50fa474ec2 100644
--- a/app/test-eventdev/evt_test.h
+++ b/app/test-eventdev/evt_test.h
@@ -29,6 +29,8 @@ typedef int (*evt_test_mempool_setup_t)
(struct evt_test *test, struct evt_options *opt);
typedef int (*evt_test_ethdev_setup_t)
(struct evt_test *test, struct evt_options *opt);
+typedef int (*evt_test_cryptodev_setup_t)
+ (struct evt_test *test, struct evt_options *opt);
typedef int (*evt_test_eventdev_setup_t)
(struct evt_test *test, struct evt_options *opt);
typedef int (*evt_test_launch_lcores_t)
@@ -39,6 +41,8 @@ typedef void (*evt_test_eventdev_destroy_t)
(struct evt_test *test, struct evt_options *opt);
typedef void (*evt_test_ethdev_destroy_t)
(struct evt_test *test, struct evt_options *opt);
+typedef void (*evt_test_cryptodev_destroy_t)
+ (struct evt_test *test, struct evt_options *opt);
typedef void (*evt_test_mempool_destroy_t)
(struct evt_test *test, struct evt_options *opt);
typedef void (*evt_test_destroy_t)
@@ -52,10 +56,12 @@ struct evt_test_ops {
evt_test_mempool_setup_t mempool_setup;
evt_test_ethdev_setup_t ethdev_setup;
evt_test_eventdev_setup_t eventdev_setup;
+ evt_test_cryptodev_setup_t cryptodev_setup;
evt_test_launch_lcores_t launch_lcores;
evt_test_result_t test_result;
evt_test_eventdev_destroy_t eventdev_destroy;
evt_test_ethdev_destroy_t ethdev_destroy;
+ evt_test_cryptodev_destroy_t cryptodev_destroy;
evt_test_mempool_destroy_t mempool_destroy;
evt_test_destroy_t test_destroy;
};
diff --git a/app/test-eventdev/test_perf_atq.c b/app/test-eventdev/test_perf_atq.c
index 8fd51004ee..67ff681666 100644
--- a/app/test-eventdev/test_perf_atq.c
+++ b/app/test-eventdev/test_perf_atq.c
@@ -48,6 +48,22 @@ perf_atq_worker(void *arg, const int enable_fwd_latency)
continue;
}
+ if (prod_crypto_type &&
+ (ev.event_type == RTE_EVENT_TYPE_CRYPTODEV)) {
+ struct rte_crypto_op *op = ev.event_ptr;
+
+ if (op->status == RTE_CRYPTO_OP_STATUS_SUCCESS) {
+ if (op->sym->m_dst == NULL)
+ ev.event_ptr = op->sym->m_src;
+ else
+ ev.event_ptr = op->sym->m_dst;
+ rte_crypto_op_free(op);
+ } else {
+ rte_crypto_op_free(op);
+ continue;
+ }
+ }
+
if (enable_fwd_latency && !prod_timer_type)
/* first stage in pipeline, mark ts to compute fwd latency */
atq_mark_fwd_latency(&ev);
@@ -87,6 +103,25 @@ perf_atq_worker_burst(void *arg, const int enable_fwd_latency)
}
for (i = 0; i < nb_rx; i++) {
+ if (prod_crypto_type &&
+ (ev[i].event_type == RTE_EVENT_TYPE_CRYPTODEV)) {
+ struct rte_crypto_op *op = ev[i].event_ptr;
+
+ if (op->status ==
+ RTE_CRYPTO_OP_STATUS_SUCCESS) {
+ if (op->sym->m_dst == NULL)
+ ev[i].event_ptr =
+ op->sym->m_src;
+ else
+ ev[i].event_ptr =
+ op->sym->m_dst;
+ rte_crypto_op_free(op);
+ } else {
+ rte_crypto_op_free(op);
+ continue;
+ }
+ }
+
if (enable_fwd_latency && !prod_timer_type) {
rte_prefetch0(ev[i+1].event_ptr);
/* first stage in pipeline.
@@ -254,6 +289,18 @@ perf_atq_eventdev_setup(struct evt_test *test, struct evt_options *opt)
return ret;
}
}
+ } else if (opt->prod_type == EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR) {
+ uint8_t cdev_id, cdev_count;
+
+ cdev_count = rte_cryptodev_count();
+ for (cdev_id = 0; cdev_id < cdev_count; cdev_id++) {
+ ret = rte_cryptodev_start(cdev_id);
+ if (ret) {
+ evt_err("Failed to start cryptodev %u",
+ cdev_id);
+ return ret;
+ }
+ }
}
return 0;
@@ -295,12 +342,14 @@ static const struct evt_test_ops perf_atq = {
.opt_dump = perf_atq_opt_dump,
.test_setup = perf_test_setup,
.ethdev_setup = perf_ethdev_setup,
+ .cryptodev_setup = perf_cryptodev_setup,
.mempool_setup = perf_mempool_setup,
.eventdev_setup = perf_atq_eventdev_setup,
.launch_lcores = perf_atq_launch_lcores,
.eventdev_destroy = perf_eventdev_destroy,
.mempool_destroy = perf_mempool_destroy,
.ethdev_destroy = perf_ethdev_destroy,
+ .cryptodev_destroy = perf_cryptodev_destroy,
.test_result = perf_test_result,
.test_destroy = perf_test_destroy,
};
diff --git a/app/test-eventdev/test_perf_common.c b/app/test-eventdev/test_perf_common.c
index 9b73874151..ca83e41555 100644
--- a/app/test-eventdev/test_perf_common.c
+++ b/app/test-eventdev/test_perf_common.c
@@ -6,6 +6,8 @@
#include "test_perf_common.h"
+#define NB_CRYPTODEV_DESCRIPTORS 128
+
int
perf_test_result(struct evt_test *test, struct evt_options *opt)
{
@@ -272,6 +274,123 @@ perf_event_timer_producer_burst(void *arg)
return 0;
}
+static inline void
+crypto_adapter_enq_op_new(struct prod_data *p)
+{
+ struct rte_cryptodev_sym_session **crypto_sess = p->ca.crypto_sess;
+ struct test_perf *t = p->t;
+ const uint32_t nb_flows = t->nb_flows;
+ const uint64_t nb_pkts = t->nb_pkts;
+ struct rte_mempool *pool = t->pool;
+ struct rte_crypto_sym_op *sym_op;
+ struct evt_options *opt = t->opt;
+ uint16_t qp_id = p->ca.cdev_qp_id;
+ uint8_t cdev_id = p->ca.cdev_id;
+ uint32_t flow_counter = 0;
+ struct rte_crypto_op *op;
+ struct rte_mbuf *m;
+ uint64_t count = 0;
+ uint16_t len;
+
+ if (opt->verbose_level > 1)
+ printf("%s(): lcore %d queue %d cdev_id %u cdev_qp_id %u\n",
+ __func__, rte_lcore_id(), p->queue_id, p->ca.cdev_id,
+ p->ca.cdev_qp_id);
+
+ len = opt->mbuf_sz ? opt->mbuf_sz : RTE_ETHER_MIN_LEN;
+
+ while (count < nb_pkts && t->done == false) {
+ m = rte_pktmbuf_alloc(pool);
+ if (m == NULL)
+ continue;
+
+ rte_pktmbuf_append(m, len);
+ op = rte_crypto_op_alloc(t->ca_op_pool,
+ RTE_CRYPTO_OP_TYPE_SYMMETRIC);
+ sym_op = op->sym;
+ sym_op->m_src = m;
+ sym_op->cipher.data.offset = 0;
+ sym_op->cipher.data.length = len;
+ rte_crypto_op_attach_sym_session(
+ op, crypto_sess[flow_counter++ % nb_flows]);
+
+ while (rte_cryptodev_enqueue_burst(cdev_id, qp_id, &op, 1) != 1 &&
+ t->done == false)
+ rte_pause();
+
+ count++;
+ }
+}
+
+static inline void
+crypto_adapter_enq_op_fwd(struct prod_data *p)
+{
+ struct rte_cryptodev_sym_session **crypto_sess = p->ca.crypto_sess;
+ const uint8_t dev_id = p->dev_id;
+ const uint8_t port = p->port_id;
+ struct test_perf *t = p->t;
+ const uint32_t nb_flows = t->nb_flows;
+ const uint64_t nb_pkts = t->nb_pkts;
+ struct rte_mempool *pool = t->pool;
+ struct evt_options *opt = t->opt;
+ struct rte_crypto_sym_op *sym_op;
+ uint32_t flow_counter = 0;
+ struct rte_crypto_op *op;
+ struct rte_event ev;
+ struct rte_mbuf *m;
+ uint64_t count = 0;
+ uint16_t len;
+
+ if (opt->verbose_level > 1)
+ printf("%s(): lcore %d port %d queue %d cdev_id %u cdev_qp_id %u\n",
+ __func__, rte_lcore_id(), port, p->queue_id,
+ p->ca.cdev_id, p->ca.cdev_qp_id);
+
+ ev.event = 0;
+ ev.op = RTE_EVENT_OP_FORWARD;
+ ev.queue_id = p->queue_id;
+ ev.sched_type = RTE_SCHED_TYPE_ATOMIC;
+ ev.event_type = RTE_EVENT_TYPE_CPU;
+ len = opt->mbuf_sz ? opt->mbuf_sz : RTE_ETHER_MIN_LEN;
+
+ while (count < nb_pkts && t->done == false) {
+ m = rte_pktmbuf_alloc(pool);
+ if (m == NULL)
+ continue;
+
+ rte_pktmbuf_append(m, len);
+ op = rte_crypto_op_alloc(t->ca_op_pool,
+ RTE_CRYPTO_OP_TYPE_SYMMETRIC);
+ sym_op = op->sym;
+ sym_op->m_src = m;
+ sym_op->cipher.data.offset = 0;
+ sym_op->cipher.data.length = len;
+ rte_crypto_op_attach_sym_session(
+ op, crypto_sess[flow_counter++ % nb_flows]);
+ ev.event_ptr = op;
+
+ while (rte_event_crypto_adapter_enqueue(dev_id, port, &ev, 1) != 1 &&
+ t->done == false)
+ rte_pause();
+
+ count++;
+ }
+}
+
+static inline int
+perf_event_crypto_producer(void *arg)
+{
+ struct prod_data *p = arg;
+ struct evt_options *opt = p->t->opt;
+
+ if (opt->crypto_adptr_mode == RTE_EVENT_CRYPTO_ADAPTER_OP_NEW)
+ crypto_adapter_enq_op_new(p);
+ else
+ crypto_adapter_enq_op_fwd(p);
+
+ return 0;
+}
+
static int
perf_producer_wrapper(void *arg)
{
@@ -298,6 +417,8 @@ perf_producer_wrapper(void *arg)
else if (t->opt->prod_type == EVT_PROD_TYPE_EVENT_TIMER_ADPTR &&
t->opt->timdev_use_burst)
return perf_event_timer_producer_burst(arg);
+ else if (t->opt->prod_type == EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR)
+ return perf_event_crypto_producer(arg);
return 0;
}
@@ -405,8 +526,10 @@ perf_launch_lcores(struct evt_test *test, struct evt_options *opt,
if (remaining <= 0) {
t->result = EVT_TEST_SUCCESS;
if (opt->prod_type == EVT_PROD_TYPE_SYNT ||
- opt->prod_type ==
- EVT_PROD_TYPE_EVENT_TIMER_ADPTR) {
+ opt->prod_type ==
+ EVT_PROD_TYPE_EVENT_TIMER_ADPTR ||
+ opt->prod_type ==
+ EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR) {
t->done = true;
break;
}
@@ -415,7 +538,8 @@ perf_launch_lcores(struct evt_test *test, struct evt_options *opt,
if (new_cycles - dead_lock_cycles > dead_lock_sample &&
(opt->prod_type == EVT_PROD_TYPE_SYNT ||
- opt->prod_type == EVT_PROD_TYPE_EVENT_TIMER_ADPTR)) {
+ opt->prod_type == EVT_PROD_TYPE_EVENT_TIMER_ADPTR ||
+ opt->prod_type == EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR)) {
remaining = t->outstand_pkts - processed_pkts(t);
if (dead_lock_remaining == remaining) {
rte_event_dev_dump(opt->dev_id, stdout);
@@ -537,6 +661,80 @@ perf_event_timer_adapter_setup(struct test_perf *t)
return 0;
}
+static int
+perf_event_crypto_adapter_setup(struct test_perf *t, struct prod_data *p)
+{
+ struct evt_options *opt = t->opt;
+ uint32_t cap;
+ int ret;
+
+ ret = rte_event_crypto_adapter_caps_get(p->dev_id, p->ca.cdev_id, &cap);
+ if (ret) {
+ evt_err("Failed to get crypto adapter capabilities");
+ return ret;
+ }
+
+ if (((opt->crypto_adptr_mode == RTE_EVENT_CRYPTO_ADAPTER_OP_NEW) &&
+ !(cap & RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_OP_NEW)) ||
+ ((opt->crypto_adptr_mode == RTE_EVENT_CRYPTO_ADAPTER_OP_FORWARD) &&
+ !(cap & RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_OP_FWD))) {
+ evt_err("crypto adapter %s mode unsupported\n",
+ opt->crypto_adptr_mode ? "OP_FORWARD" : "OP_NEW");
+ return -EINVAL;
+ } else if (!(cap & RTE_EVENT_CRYPTO_ADAPTER_CAP_SESSION_PRIVATE_DATA)) {
+ evt_err("Storing crypto session not supported");
+ return -EINVAL;
+ }
+
+ if (cap & RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_QP_EV_BIND) {
+ struct rte_event response_info;
+
+ response_info.event = 0;
+ response_info.op =
+ opt->crypto_adptr_mode ==
+ RTE_EVENT_CRYPTO_ADAPTER_OP_NEW ?
+ RTE_EVENT_OP_NEW :
+ RTE_EVENT_OP_FORWARD;
+ response_info.sched_type = RTE_SCHED_TYPE_ATOMIC;
+ response_info.event_type = RTE_EVENT_TYPE_CRYPTODEV;
+ response_info.queue_id = p->queue_id;
+ ret = rte_event_crypto_adapter_queue_pair_add(
+ TEST_PERF_CA_ID, p->ca.cdev_id, p->ca.cdev_qp_id,
+ &response_info);
+ } else {
+ ret = rte_event_crypto_adapter_queue_pair_add(
+ TEST_PERF_CA_ID, p->ca.cdev_id, p->ca.cdev_qp_id, NULL);
+ }
+
+ return ret;
+}
+
+static struct rte_cryptodev_sym_session *
+cryptodev_sym_sess_create(struct prod_data *p, struct test_perf *t)
+{
+ struct rte_crypto_sym_xform cipher_xform;
+ struct rte_cryptodev_sym_session *sess;
+
+ cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
+ cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
+ cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
+ cipher_xform.next = NULL;
+
+ sess = rte_cryptodev_sym_session_create(t->ca_sess_pool);
+ if (sess == NULL) {
+ evt_err("Failed to create sym session");
+ return NULL;
+ }
+
+ if (rte_cryptodev_sym_session_init(p->ca.cdev_id, sess, &cipher_xform,
+ t->ca_sess_priv_pool)) {
+ evt_err("Failed to init session");
+ return NULL;
+ }
+
+ return sess;
+}
+
int
perf_event_dev_port_setup(struct evt_test *test, struct evt_options *opt,
uint8_t stride, uint8_t nb_queues,
@@ -598,6 +796,80 @@ perf_event_dev_port_setup(struct evt_test *test, struct evt_options *opt,
ret = perf_event_timer_adapter_setup(t);
if (ret)
return ret;
+ } else if (opt->prod_type == EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR) {
+ struct rte_event_port_conf conf = *port_conf;
+ uint8_t cdev_id = 0;
+ uint16_t qp_id = 0;
+
+ ret = rte_event_crypto_adapter_create(TEST_PERF_CA_ID,
+ opt->dev_id, &conf, 0);
+ if (ret) {
+ evt_err("Failed to create crypto adapter");
+ return ret;
+ }
+
+ prod = 0;
+ for (; port < perf_nb_event_ports(opt); port++) {
+ struct rte_cryptodev_sym_session *crypto_sess;
+ union rte_event_crypto_metadata m_data;
+ struct prod_data *p = &t->prod[port];
+ uint32_t flow_id;
+
+ if (qp_id == rte_cryptodev_queue_pair_count(cdev_id)) {
+ cdev_id++;
+ qp_id = 0;
+ }
+
+ p->dev_id = opt->dev_id;
+ p->port_id = port;
+ p->queue_id = prod * stride;
+ p->ca.cdev_id = cdev_id;
+ p->ca.cdev_qp_id = qp_id;
+ p->ca.crypto_sess = rte_zmalloc_socket(
+ NULL, sizeof(crypto_sess) * t->nb_flows,
+ RTE_CACHE_LINE_SIZE, opt->socket_id);
+ p->t = t;
+
+ m_data.request_info.cdev_id = p->ca.cdev_id;
+ m_data.request_info.queue_pair_id = p->ca.cdev_qp_id;
+ m_data.response_info.op =
+ opt->crypto_adptr_mode ==
+ RTE_EVENT_CRYPTO_ADAPTER_OP_NEW ?
+ RTE_EVENT_OP_NEW :
+ RTE_EVENT_OP_FORWARD;
+ m_data.response_info.sched_type = RTE_SCHED_TYPE_ATOMIC;
+ m_data.response_info.event_type =
+ RTE_EVENT_TYPE_CRYPTODEV;
+ m_data.response_info.queue_id = p->queue_id;
+
+ for (flow_id = 0; flow_id < t->nb_flows; flow_id++) {
+ crypto_sess = cryptodev_sym_sess_create(p, t);
+ if (crypto_sess == NULL)
+ return -ENOMEM;
+
+ m_data.response_info.flow_id = flow_id;
+ rte_cryptodev_sym_session_set_user_data(
+ crypto_sess, &m_data, sizeof(m_data));
+ p->ca.crypto_sess[flow_id] = crypto_sess;
+ }
+
+ conf.event_port_cfg |=
+ RTE_EVENT_PORT_CFG_HINT_PRODUCER |
+ RTE_EVENT_PORT_CFG_HINT_CONSUMER;
+
+ ret = rte_event_port_setup(opt->dev_id, port, &conf);
+ if (ret) {
+ evt_err("failed to setup port %d", port);
+ return ret;
+ }
+
+ ret = perf_event_crypto_adapter_setup(t, p);
+ if (ret)
+ return ret;
+
+ qp_id++;
+ prod++;
+ }
} else {
prod = 0;
for ( ; port < perf_nb_event_ports(opt); port++) {
@@ -659,7 +931,8 @@ perf_opt_check(struct evt_options *opt, uint64_t nb_queues)
}
if (opt->prod_type == EVT_PROD_TYPE_SYNT ||
- opt->prod_type == EVT_PROD_TYPE_EVENT_TIMER_ADPTR) {
+ opt->prod_type == EVT_PROD_TYPE_EVENT_TIMER_ADPTR ||
+ opt->prod_type == EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR) {
/* Validate producer lcores */
if (evt_lcores_has_overlap(opt->plcores,
rte_get_main_lcore())) {
@@ -767,8 +1040,7 @@ perf_ethdev_setup(struct evt_test *test, struct evt_options *opt)
},
};
- if (opt->prod_type == EVT_PROD_TYPE_SYNT ||
- opt->prod_type == EVT_PROD_TYPE_EVENT_TIMER_ADPTR)
+ if (opt->prod_type != EVT_PROD_TYPE_ETH_RX_ADPTR)
return 0;
if (!rte_eth_dev_count_avail()) {
@@ -841,6 +1113,149 @@ void perf_ethdev_destroy(struct evt_test *test, struct evt_options *opt)
}
}
+int
+perf_cryptodev_setup(struct evt_test *test, struct evt_options *opt)
+{
+ uint8_t cdev_count, cdev_id, nb_plcores, nb_qps;
+ struct test_perf *t = evt_test_priv(test);
+ unsigned int max_session_size;
+ uint32_t nb_sessions;
+ int ret;
+
+ if (opt->prod_type != EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR)
+ return 0;
+
+ cdev_count = rte_cryptodev_count();
+ if (cdev_count == 0) {
+ evt_err("No crypto devices available\n");
+ return -ENODEV;
+ }
+
+ t->ca_op_pool = rte_crypto_op_pool_create(
+ "crypto_op_pool", RTE_CRYPTO_OP_TYPE_SYMMETRIC, opt->pool_sz,
+ 128, 0, rte_socket_id());
+ if (t->ca_op_pool == NULL) {
+ evt_err("Failed to create crypto op pool");
+ return -ENOMEM;
+ }
+
+ nb_sessions = evt_nr_active_lcores(opt->plcores) * t->nb_flows;
+ t->ca_sess_pool = rte_cryptodev_sym_session_pool_create(
+ "ca_sess_pool", nb_sessions, 0, 0,
+ sizeof(union rte_event_crypto_metadata), SOCKET_ID_ANY);
+ if (t->ca_sess_pool == NULL) {
+ evt_err("Failed to create sym session pool");
+ ret = -ENOMEM;
+ goto err;
+ }
+
+ max_session_size = 0;
+ for (cdev_id = 0; cdev_id < cdev_count; cdev_id++) {
+ unsigned int session_size;
+
+ session_size =
+ rte_cryptodev_sym_get_private_session_size(cdev_id);
+ if (session_size > max_session_size)
+ max_session_size = session_size;
+ }
+
+ max_session_size += sizeof(union rte_event_crypto_metadata);
+ t->ca_sess_priv_pool = rte_mempool_create(
+ "ca_sess_priv_pool", nb_sessions, max_session_size, 0, 0, NULL,
+ NULL, NULL, NULL, SOCKET_ID_ANY, 0);
+ if (t->ca_sess_priv_pool == NULL) {
+ evt_err("failed to create sym session private pool");
+ ret = -ENOMEM;
+ goto err;
+ }
+
+ /*
+ * Calculate number of needed queue pairs, based on the amount of
+ * available number of logical cores and crypto devices. For instance,
+ * if there are 4 cores and 2 crypto devices, 2 queue pairs will be set
+ * up per device.
+ */
+ nb_plcores = evt_nr_active_lcores(opt->plcores);
+ nb_qps = (nb_plcores % cdev_count) ? (nb_plcores / cdev_count) + 1 :
+ nb_plcores / cdev_count;
+ for (cdev_id = 0; cdev_id < cdev_count; cdev_id++) {
+ struct rte_cryptodev_qp_conf qp_conf;
+ struct rte_cryptodev_config conf;
+ struct rte_cryptodev_info info;
+ int qp_id;
+
+ rte_cryptodev_info_get(cdev_id, &info);
+ if (nb_qps > info.max_nb_queue_pairs) {
+ evt_err("Not enough queue pairs per cryptodev (%u)",
+ nb_qps);
+ ret = -EINVAL;
+ goto err;
+ }
+
+ conf.nb_queue_pairs = nb_qps;
+ conf.socket_id = SOCKET_ID_ANY;
+ conf.ff_disable = RTE_CRYPTODEV_FF_SECURITY;
+
+ ret = rte_cryptodev_configure(cdev_id, &conf);
+ if (ret) {
+ evt_err("Failed to configure cryptodev (%u)", cdev_id);
+ goto err;
+ }
+
+ qp_conf.nb_descriptors = NB_CRYPTODEV_DESCRIPTORS;
+ qp_conf.mp_session = t->ca_sess_pool;
+ qp_conf.mp_session_private = t->ca_sess_priv_pool;
+
+ for (qp_id = 0; qp_id < conf.nb_queue_pairs; qp_id++) {
+ ret = rte_cryptodev_queue_pair_setup(
+ cdev_id, qp_id, &qp_conf,
+ rte_cryptodev_socket_id(cdev_id));
+ if (ret) {
+ evt_err("Failed to setup queue pairs on cryptodev %u\n",
+ cdev_id);
+ goto err;
+ }
+ }
+ }
+
+ return 0;
+err:
+ rte_mempool_free(t->ca_op_pool);
+ rte_mempool_free(t->ca_sess_pool);
+ rte_mempool_free(t->ca_sess_priv_pool);
+
+ return ret;
+}
+
+void
+perf_cryptodev_destroy(struct evt_test *test, struct evt_options *opt)
+{
+ uint8_t cdev_id, cdev_count = rte_cryptodev_count();
+ struct test_perf *t = evt_test_priv(test);
+ uint16_t port;
+
+ RTE_SET_USED(opt);
+
+ if (opt->prod_type != EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR)
+ return;
+
+ for (port = t->nb_workers; port < perf_nb_event_ports(opt); port++) {
+ struct prod_data *p = &t->prod[port];
+
+ rte_event_crypto_adapter_queue_pair_del(
+ TEST_PERF_CA_ID, p->ca.cdev_id, p->ca.cdev_qp_id);
+ }
+
+ rte_event_crypto_adapter_free(TEST_PERF_CA_ID);
+
+ for (cdev_id = 0; cdev_id < cdev_count; cdev_id++)
+ rte_cryptodev_stop(cdev_id);
+
+ rte_mempool_free(t->ca_op_pool);
+ rte_mempool_free(t->ca_sess_pool);
+ rte_mempool_free(t->ca_sess_priv_pool);
+}
+
int
perf_mempool_setup(struct evt_test *test, struct evt_options *opt)
{
diff --git a/app/test-eventdev/test_perf_common.h b/app/test-eventdev/test_perf_common.h
index 14dcf80429..ea0907d61a 100644
--- a/app/test-eventdev/test_perf_common.h
+++ b/app/test-eventdev/test_perf_common.h
@@ -9,9 +9,11 @@
#include <stdbool.h>
#include <unistd.h>
+#include <rte_cryptodev.h>
#include <rte_cycles.h>
#include <rte_ethdev.h>
#include <rte_eventdev.h>
+#include <rte_event_crypto_adapter.h>
#include <rte_event_eth_rx_adapter.h>
#include <rte_event_timer_adapter.h>
#include <rte_lcore.h>
@@ -23,6 +25,8 @@
#include "evt_options.h"
#include "evt_test.h"
+#define TEST_PERF_CA_ID 0
+
struct test_perf;
struct worker_data {
@@ -33,14 +37,19 @@ struct worker_data {
struct test_perf *t;
} __rte_cache_aligned;
+struct crypto_adptr_data {
+ uint8_t cdev_id;
+ uint16_t cdev_qp_id;
+ struct rte_cryptodev_sym_session **crypto_sess;
+};
struct prod_data {
uint8_t dev_id;
uint8_t port_id;
uint8_t queue_id;
+ struct crypto_adptr_data ca;
struct test_perf *t;
} __rte_cache_aligned;
-
struct test_perf {
/* Don't change the offset of "done". Signal handler use this memory
* to terminate all lcores work.
@@ -58,6 +67,9 @@ struct test_perf {
uint8_t sched_type_list[EVT_MAX_STAGES] __rte_cache_aligned;
struct rte_event_timer_adapter *timer_adptr[
RTE_EVENT_TIMER_ADAPTER_NUM_MAX] __rte_cache_aligned;
+ struct rte_mempool *ca_op_pool;
+ struct rte_mempool *ca_sess_pool;
+ struct rte_mempool *ca_sess_priv_pool;
} __rte_cache_aligned;
struct perf_elt {
@@ -81,6 +93,8 @@ struct perf_elt {
const uint8_t port = w->port_id;\
const uint8_t prod_timer_type = \
opt->prod_type == EVT_PROD_TYPE_EVENT_TIMER_ADPTR;\
+ const uint8_t prod_crypto_type = \
+ opt->prod_type == EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR;\
uint8_t *const sched_type_list = &t->sched_type_list[0];\
struct rte_mempool *const pool = t->pool;\
const uint8_t nb_stages = t->opt->nb_stages;\
@@ -154,6 +168,7 @@ int perf_test_result(struct evt_test *test, struct evt_options *opt);
int perf_opt_check(struct evt_options *opt, uint64_t nb_queues);
int perf_test_setup(struct evt_test *test, struct evt_options *opt);
int perf_ethdev_setup(struct evt_test *test, struct evt_options *opt);
+int perf_cryptodev_setup(struct evt_test *test, struct evt_options *opt);
int perf_mempool_setup(struct evt_test *test, struct evt_options *opt);
int perf_event_dev_port_setup(struct evt_test *test, struct evt_options *opt,
uint8_t stride, uint8_t nb_queues,
@@ -164,6 +179,7 @@ int perf_launch_lcores(struct evt_test *test, struct evt_options *opt,
void perf_opt_dump(struct evt_options *opt, uint8_t nb_queues);
void perf_test_destroy(struct evt_test *test, struct evt_options *opt);
void perf_eventdev_destroy(struct evt_test *test, struct evt_options *opt);
+void perf_cryptodev_destroy(struct evt_test *test, struct evt_options *opt);
void perf_ethdev_destroy(struct evt_test *test, struct evt_options *opt);
void perf_mempool_destroy(struct evt_test *test, struct evt_options *opt);
diff --git a/app/test-eventdev/test_perf_queue.c b/app/test-eventdev/test_perf_queue.c
index f4ea3a795f..dcf6d82947 100644
--- a/app/test-eventdev/test_perf_queue.c
+++ b/app/test-eventdev/test_perf_queue.c
@@ -49,6 +49,23 @@ perf_queue_worker(void *arg, const int enable_fwd_latency)
rte_pause();
continue;
}
+
+ if (prod_crypto_type &&
+ (ev.event_type == RTE_EVENT_TYPE_CRYPTODEV)) {
+ struct rte_crypto_op *op = ev.event_ptr;
+
+ if (op->status == RTE_CRYPTO_OP_STATUS_SUCCESS) {
+ if (op->sym->m_dst == NULL)
+ ev.event_ptr = op->sym->m_src;
+ else
+ ev.event_ptr = op->sym->m_dst;
+ rte_crypto_op_free(op);
+ } else {
+ rte_crypto_op_free(op);
+ continue;
+ }
+ }
+
if (enable_fwd_latency && !prod_timer_type)
/* first q in pipeline, mark timestamp to compute fwd latency */
mark_fwd_latency(&ev, nb_stages);
@@ -88,6 +105,25 @@ perf_queue_worker_burst(void *arg, const int enable_fwd_latency)
}
for (i = 0; i < nb_rx; i++) {
+ if (prod_crypto_type &&
+ (ev[i].event_type == RTE_EVENT_TYPE_CRYPTODEV)) {
+ struct rte_crypto_op *op = ev[i].event_ptr;
+
+ if (op->status ==
+ RTE_CRYPTO_OP_STATUS_SUCCESS) {
+ if (op->sym->m_dst == NULL)
+ ev[i].event_ptr =
+ op->sym->m_src;
+ else
+ ev[i].event_ptr =
+ op->sym->m_dst;
+ rte_crypto_op_free(op);
+ } else {
+ rte_crypto_op_free(op);
+ continue;
+ }
+ }
+
if (enable_fwd_latency && !prod_timer_type) {
rte_prefetch0(ev[i+1].event_ptr);
/* first queue in pipeline.
@@ -269,6 +305,18 @@ perf_queue_eventdev_setup(struct evt_test *test, struct evt_options *opt)
return ret;
}
}
+ } else if (opt->prod_type == EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR) {
+ uint8_t cdev_id, cdev_count;
+
+ cdev_count = rte_cryptodev_count();
+ for (cdev_id = 0; cdev_id < cdev_count; cdev_id++) {
+ ret = rte_cryptodev_start(cdev_id);
+ if (ret) {
+ evt_err("Failed to start cryptodev %u",
+ cdev_id);
+ return ret;
+ }
+ }
}
return 0;
@@ -311,11 +359,13 @@ static const struct evt_test_ops perf_queue = {
.test_setup = perf_test_setup,
.mempool_setup = perf_mempool_setup,
.ethdev_setup = perf_ethdev_setup,
+ .cryptodev_setup = perf_cryptodev_setup,
.eventdev_setup = perf_queue_eventdev_setup,
.launch_lcores = perf_queue_launch_lcores,
.eventdev_destroy = perf_eventdev_destroy,
.mempool_destroy = perf_mempool_destroy,
.ethdev_destroy = perf_ethdev_destroy,
+ .cryptodev_destroy = perf_cryptodev_destroy,
.test_result = perf_test_result,
.test_destroy = perf_test_destroy,
};
diff --git a/doc/guides/tools/testeventdev.rst b/doc/guides/tools/testeventdev.rst
index 48efb9ea6e..f7d813226d 100644
--- a/doc/guides/tools/testeventdev.rst
+++ b/doc/guides/tools/testeventdev.rst
@@ -120,6 +120,10 @@ The following are the application command-line options:
Use burst mode event timer adapter as producer.
+* ``--prod_type_cryptodev``
+
+ Use crypto device as producer.
+
* ``--timer_tick_nsec``
Used to dictate number of nano seconds between bucket traversal of the
@@ -148,6 +152,11 @@ The following are the application command-line options:
timeout is out of the supported range of event device it will be
adjusted to the highest/lowest supported dequeue timeout supported.
+* ``--crypto_adptr_mode``
+
+ Set crypto adapter mode. Use 0 for OP_NEW (default) and 1 for
+ OP_FORWARD mode.
+
* ``--mbuf_sz``
Set packet mbuf size. Can be used to configure Jumbo Frames. Only
@@ -420,6 +429,7 @@ Supported application command line options are following::
--prod_type_ethdev
--prod_type_timerdev_burst
--prod_type_timerdev
+ --prod_type_cryptodev
--prod_enq_burst_sz
--timer_tick_nsec
--max_tmo_nsec
@@ -427,6 +437,7 @@ Supported application command line options are following::
--nb_timers
--nb_timer_adptrs
--deq_tmo_nsec
+ --crypto_adptr_mode
Example
^^^^^^^
@@ -529,12 +540,14 @@ Supported application command line options are following::
--prod_type_ethdev
--prod_type_timerdev_burst
--prod_type_timerdev
+ --prod_type_cryptodev
--timer_tick_nsec
--max_tmo_nsec
--expiry_nsec
--nb_timers
--nb_timer_adptrs
--deq_tmo_nsec
+ --crypto_adptr_mode
Example
^^^^^^^
--
2.25.1
^ permalink raw reply [flat|nested] 43+ messages in thread
* RE: [PATCH v3] app/eventdev: add crypto producer mode
2022-01-25 13:39 ` Gujjar, Abhinandan S
@ 2022-02-08 17:00 ` Shijith Thotton
2022-02-14 15:26 ` Jerin Jacob
0 siblings, 1 reply; 43+ messages in thread
From: Shijith Thotton @ 2022-02-08 17:00 UTC (permalink / raw)
To: Gujjar, Abhinandan S, dev, Jerin Jacob Kollanukkaran
Cc: Anoob Joseph, Pavan Nikhilesh Bhagavatula, Akhil Goyal
Hi Abhinandan,
>> > Subject: [PATCH v3] app/eventdev: add crypto producer mode
>> >
>> > In crypto producer mode, producer core enqueues cryptodev with
>> > software generated crypto ops and worker core dequeues crypto
>> > completion events from the eventdev. Event crypto metadata used for
>> > above processing is pre- populated in each crypto session.
>> >
>> > Parameter --prod_type_cryptodev can be used to enable crypto producer
>> > mode. Parameter --crypto_adptr_mode can be set to select the crypto
>> > adapter mode, 0 for OP_NEW and 1 for OP_FORWARD.
>> >
>> > This mode can be used to measure the performance of crypto adapter.
>> >
>> > Example:
>> > ./dpdk-test-eventdev -l 0-2 -w <EVENTDEV> -w <CRYPTODEV> -- \
>> > --prod_type_cryptodev --crypto_adptr_mode 1 --test=perf_atq \
>> > --stlist=a --wlcores 1 --plcores 2
>> >
>> > Signed-off-by: Shijith Thotton <sthotton@marvell.com>
>> > ---
>> > v3:
>> > * Reduce dereference inside loop.
>> >
>> > v2:
>> > * Fix RHEL compilation warning.
>> >
>> > app/test-eventdev/evt_common.h | 3 +
>> > app/test-eventdev/evt_main.c | 13 +-
>> > app/test-eventdev/evt_options.c | 27 ++
>> > app/test-eventdev/evt_options.h | 12 +
>> > app/test-eventdev/evt_test.h | 6 +
>> > app/test-eventdev/test_perf_atq.c | 51 ++++
>> > app/test-eventdev/test_perf_common.c | 410
>> > ++++++++++++++++++++++++++- app/test-
>> > eventdev/test_perf_common.h | 16 ++ app/test-
>> > eventdev/test_perf_queue.c | 52 ++++
>> > doc/guides/tools/testeventdev.rst | 13 +
>> > 10 files changed, 596 insertions(+), 7 deletions(-)
>> >
>> > diff --git a/app/test-eventdev/evt_common.h b/app/test-
>> > eventdev/evt_common.h index f466434459..2f301a7e79 100644
>> > --- a/app/test-eventdev/evt_common.h
>> > +++ b/app/test-eventdev/evt_common.h
>> > @@ -7,6 +7,7 @@
>> >
>> > #include <rte_common.h>
>> > #include <rte_debug.h>
>> > +#include <rte_event_crypto_adapter.h>
>> > #include <rte_eventdev.h>
>> > #include <rte_service.h>
<SNIP>
>> >
>> > + if (opt->verbose_level > 1)
>> > + printf("%s(): lcore %d queue %d cdev_id %u cdev_qp_id
>> > %u\n",
>> > + __func__, rte_lcore_id(), p->queue_id, p->cdev_id,
>> > + p->cdev_qp_id);
>> > +
>> > + len = opt->mbuf_sz ? opt->mbuf_sz : RTE_ETHER_MIN_LEN;
>> > +
>> > + while (count < nb_pkts && t->done == false) {
>> > + m = rte_pktmbuf_alloc(pool);
>> > + if (m == NULL)
>> > + continue;
>> > +
>> > + rte_pktmbuf_append(m, len);
>> > + op = rte_crypto_op_alloc(t->crypto_adptr.op_pool,
>NULL check for op is missing
Not added as it is fast path to avoid performance drop.
>> > +
>> > RTE_CRYPTO_OP_TYPE_SYMMETRIC);
>> > + sym_op = op->sym;
>> > + sym_op->m_src = m;
>> > + sym_op->cipher.data.offset = 0;
>> > + sym_op->cipher.data.length = len;
>> > + rte_crypto_op_attach_sym_session(
>> > + op, crypto_sess[flow_counter++ % nb_flows]);
>> > + while (rte_cryptodev_enqueue_burst(cdev_id, qp_id, &op,
>> > 1) !=
>> > + 1) {
>> > + if (t->done)
>> > + break;
>> > + rte_pause();
>> > + }
>> > + count++;
>> > + }
>> > +}
>> > +
>> > +static inline void
>> > +crypto_adapter_enq_op_fwd(struct prod_data *p) {
>> > + struct rte_cryptodev_sym_session **crypto_sess = p->crypto_sess;
>> > + const uint8_t dev_id = p->dev_id;
>> > + const uint8_t port = p->port_id;
>> > + struct test_perf *t = p->t;
>> > + const uint32_t nb_flows = t->nb_flows;
>> > + const uint64_t nb_pkts = t->nb_pkts;
>> > + struct rte_mempool *pool = t->pool;
>> > + struct evt_options *opt = t->opt;
>> > + struct rte_crypto_sym_op *sym_op;
>> > + uint32_t flow_counter = 0;
>> > + struct rte_crypto_op *op;
>> > + struct rte_event ev;
>> > + struct rte_mbuf *m;
>> > + uint64_t count = 0;
>> > + uint16_t len;
>> > +
>> > + if (opt->verbose_level > 1)
>> > + printf("%s(): lcore %d port %d queue %d cdev_id %u
>> > cdev_qp_id %u\n",
>> > + __func__, rte_lcore_id(), port, p->queue_id, p->cdev_id,
>> > + p->cdev_qp_id);
>> > +
>> > + ev.event = 0;
>> > + ev.op = RTE_EVENT_OP_NEW;
>So, this is an new event and adapter treats it as OP_FWD?
>> > + ev.queue_id = p->queue_id;
>> > + ev.sched_type = RTE_SCHED_TYPE_ATOMIC;
>> > + ev.event_type = RTE_EVENT_TYPE_CPU;
>> > + len = opt->mbuf_sz ? opt->mbuf_sz : RTE_ETHER_MIN_LEN;
>> > +
>> > + while (count < nb_pkts && t->done == false) {
>> > + m = rte_pktmbuf_alloc(pool);
>> > + if (m == NULL)
>> > + continue;
>> > +
>> > + rte_pktmbuf_append(m, len);
>> > + op = rte_crypto_op_alloc(t->crypto_adptr.op_pool,
>> > +
>> > RTE_CRYPTO_OP_TYPE_SYMMETRIC);
>> > + sym_op = op->sym;
>> > + sym_op->m_src = m;
>> > + sym_op->cipher.data.offset = 0;
>> > + sym_op->cipher.data.length = len;
>> > + rte_crypto_op_attach_sym_session(
>> > + op, crypto_sess[flow_counter++ % nb_flows]);
>> > + ev.event_ptr = op;
>> > + while (rte_event_crypto_adapter_enqueue(dev_id, port,
>> > &ev, 1) !=
>> > + 1) {
>If the adapter OP_FWD is supported by rte_event_enqueue_burst(), then even
>that path has to be tested. Please add it.
Added in patch to avoid software adapter.
>> > + if (t->done)
>> > + break;
>> > + rte_pause();
>> > + }
>> > + count++;
>> > + }
>> > +}
>> > +
>> > +static inline int
>> > +perf_event_crypto_producer(void *arg) {
>> > + struct prod_data *p = arg;
>> > + struct evt_options *opt = p->t->opt;
>> > +
>> > + if (opt->crypto_adptr_mode ==
>> > RTE_EVENT_CRYPTO_ADAPTER_OP_NEW)
>> > + crypto_adapter_enq_op_new(p);
>> > + else
>> > + crypto_adapter_enq_op_fwd(p);
>> > +
>> > + return 0;
>> > +}
>> > +
>> > static int
>> > perf_producer_wrapper(void *arg)
>> > {
>> > @@ -298,6 +419,8 @@ perf_producer_wrapper(void *arg)
>> > else if (t->opt->prod_type ==
>> > EVT_PROD_TYPE_EVENT_TIMER_ADPTR &&
>> > t->opt->timdev_use_burst)
>> > return perf_event_timer_producer_burst(arg);
>> > + else if (t->opt->prod_type ==
>> > EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR)
>> > + return perf_event_crypto_producer(arg);
>> > return 0;
>> > }
>> >
>> > @@ -405,8 +528,10 @@ perf_launch_lcores(struct evt_test *test, struct
>> > evt_options *opt,
>> > if (remaining <= 0) {
>> > t->result = EVT_TEST_SUCCESS;
>> > if (opt->prod_type ==
>> > EVT_PROD_TYPE_SYNT ||
>> > - opt->prod_type ==
>> > -
>> > EVT_PROD_TYPE_EVENT_TIMER_ADPTR) {
>> > + opt->prod_type ==
>> > +
>> > EVT_PROD_TYPE_EVENT_TIMER_ADPTR ||
>> > + opt->prod_type ==
>> > +
>> > EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR) {
>> > t->done = true;
>> > break;
>> > }
>> > @@ -415,7 +540,8 @@ perf_launch_lcores(struct evt_test *test, struct
>> > evt_options *opt,
>> >
>> > if (new_cycles - dead_lock_cycles > dead_lock_sample &&
>> > (opt->prod_type == EVT_PROD_TYPE_SYNT ||
>> > - opt->prod_type ==
>> > EVT_PROD_TYPE_EVENT_TIMER_ADPTR)) {
>> > + opt->prod_type ==
>> > EVT_PROD_TYPE_EVENT_TIMER_ADPTR ||
>> > + opt->prod_type ==
>> > EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR)) {
>> > remaining = t->outstand_pkts - processed_pkts(t);
>> > if (dead_lock_remaining == remaining) {
>> > rte_event_dev_dump(opt->dev_id, stdout);
>> @@ -537,6 +663,96 @@
>> > perf_event_timer_adapter_setup(struct test_perf
>> > *t)
>> > return 0;
>> > }
>> >
>> > +static int
>> > +perf_event_crypto_adapter_setup(struct test_perf *t,
>> > + struct rte_event_port_conf port_conf) {
>> > + struct evt_options *opt = t->opt;
>> > + uint8_t cdev_id, cdev_count;
>> > + int ret;
>> > +
>> > + t->crypto_adptr.id = 0;
>> > + ret = rte_event_crypto_adapter_create(t->crypto_adptr.id, opt-
>> > >dev_id,
>> > + &port_conf, 0);
>> > + if (ret)
>> > + return ret;
>> > +
>> > + cdev_count = rte_cryptodev_count();
>> > + for (cdev_id = 0; cdev_id < cdev_count; cdev_id++) {
>> > + uint32_t cap;
>> > +
>> > + ret = rte_event_crypto_adapter_caps_get(opt->dev_id,
>> > cdev_id,
>> > + &cap);
>> > + if (ret) {
>> > + evt_err("Failed to get crypto adapter capabilities");
>> > + return ret;
>> > + }
>> > +
>> > + if (((opt->crypto_adptr_mode ==
>> > + RTE_EVENT_CRYPTO_ADAPTER_OP_NEW) &&
>> > + !(cap &
>> > +
>> > RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_OP_NEW)) ||
>> > + ((opt->crypto_adptr_mode ==
>> > + RTE_EVENT_CRYPTO_ADAPTER_OP_FORWARD) &&
>> > + !(cap &
>> > +
>> > RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_OP_FWD))) {
>> > + evt_err("crypto adapter %s mode unsupported\n",
>> > + opt->crypto_adptr_mode ? "OP_FORWARD"
>> > :
>> > + "OP_NEW");
>> > + return -EINVAL;
>> > + }
>> > +
>> > + if (!(cap &
>> > +
>> > RTE_EVENT_CRYPTO_ADAPTER_CAP_SESSION_PRIVATE_DATA)) {
>> > + evt_err("Storing crypto session not supported");
>> > + return -EINVAL;
>> > + }
>> > +
>> > + if (cap &
>> > +
>> > RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_QP_EV_BIND) {
>> > + struct rte_event response_info;
>> > +
>> > + response_info.event = 0;
>It is good that you are covering even this case. Should not you fill event with valid
>values?
Done
>> > + ret = rte_event_crypto_adapter_queue_pair_add(
>> > + t->crypto_adptr.id, cdev_id, -1,
>> > + &response_info);
>> > + } else {
>> > + ret = rte_event_crypto_adapter_queue_pair_add(
>> > + t->crypto_adptr.id, cdev_id, -1, NULL);
>> > + }
>New line
Done
>> > + if (ret)
>> > + return ret;
>> > + }
>> > +
>> > + return 0;
>> > +}
>> > +
>> > +static struct rte_cryptodev_sym_session *
>> > +cryptodev_sym_sess_create(struct prod_data *p, struct test_perf *t) {
>> > + struct rte_crypto_sym_xform cipher_xform;
>> > + struct rte_cryptodev_sym_session *sess;
>> > +
>> > + cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
>> > + cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
>> > + cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
>> > + cipher_xform.next = NULL;
>> > +
>> > + sess = rte_cryptodev_sym_session_create(t-
>> > >crypto_adptr.sess_pool);
>> > + if (sess == NULL) {
>> > + evt_err("Failed to create sym session");
>> > + return NULL;
>> > + }
>> > +
>> > + if (rte_cryptodev_sym_session_init(p->cdev_id, sess,
>> > &cipher_xform,
>> > + t->crypto_adptr.sess_priv_pool)) {
>> > + evt_err("Failed to init session");
>> > + return NULL;
>> > + }
>> > +
>> > + return sess;
>> > +}
>> > +
>> > int
>> > perf_event_dev_port_setup(struct evt_test *test, struct evt_options
>> *opt,
>> > uint8_t stride, uint8_t nb_queues, @@ -
>> 598,6 +814,55 @@
>> > perf_event_dev_port_setup(struct evt_test *test, struct evt_options
>> > *opt,
>> > ret = perf_event_timer_adapter_setup(t);
>> > if (ret)
>> > return ret;
>> > + } else if (opt->prod_type ==
>> > EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR) {
>> > + uint8_t cdev_id = 0;
>> > + uint16_t qp_id = 0;
>> > +
>> > + prod = 0;
>> > + for (; port < perf_nb_event_ports(opt); port++) {
>> > + struct rte_cryptodev_sym_session *crypto_sess;
>> > + union rte_event_crypto_metadata m_data;
>> > + struct prod_data *p = &t->prod[port];
>> > + uint32_t flow_id;
>> > +
>> > + if (qp_id ==
>> > rte_cryptodev_queue_pair_count(cdev_id)) {
>> > + cdev_id++;
>> > + qp_id = 0;
>> > + }
>> > +
>> > + p->dev_id = opt->dev_id;
>> > + p->port_id = port;
>> > + p->queue_id = prod * stride;
>> > + p->cdev_id = cdev_id;
>> > + p->cdev_qp_id = qp_id;
>> > + p->crypto_sess = rte_zmalloc_socket(
>> > + NULL, sizeof(crypto_sess) * t->nb_flows,
>> > + RTE_CACHE_LINE_SIZE, opt->socket_id);
>> > +
>> > + m_data.request_info.cdev_id = p->cdev_id;
>> > + m_data.request_info.queue_pair_id = p-
>> > >cdev_qp_id;
>> > + m_data.response_info.op = RTE_EVENT_OP_NEW;
>> > + m_data.response_info.sched_type =
>> > RTE_SCHED_TYPE_ATOMIC;
>> > + m_data.response_info.event_type =
>> > RTE_EVENT_TYPE_CPU;
>> > + m_data.response_info.queue_id = p->queue_id;
>> > + for (flow_id = 0; flow_id < t->nb_flows; flow_id++) {
>> > + crypto_sess =
>> > cryptodev_sym_sess_create(p, t);
>> > + if (crypto_sess == NULL)
>> > + return -ENOMEM;
>> > +
>> > + m_data.response_info.flow_id = flow_id;
>> > + rte_cryptodev_sym_session_set_user_data(
>> > + crypto_sess, &m_data,
>> > sizeof(m_data));
>> > + p->crypto_sess[flow_id] = crypto_sess;
>> > + }
>New line
Done
<SNIP>
Please ack v4 if there are no more comments.
I tried adding support for software adapter implementation, but is getting a
crash in sw_event PMD after some packets. I have posted the respective changes
here: https://patchwork.dpdk.org/project/dpdk/patch/0677cbafa5145f1b9f64dd007594e033f2d9ab8a.1644337310.git.sthotton@marvell.com/
Please take it forward.
Command used to test is:
dpdk-test-eventdev -l 0-8 -s 0xf0 --vdev=event_sw0 --vdev="crypto_null" -- \
--prod_type_cryptodev --crypto_adptr_mode 1 --test=perf_queue --stlist=a \
--wlcores 1 --plcores 2
^ permalink raw reply [flat|nested] 43+ messages in thread
* Re: [PATCH v3] app/eventdev: add crypto producer mode
2022-02-08 17:00 ` Shijith Thotton
@ 2022-02-14 15:26 ` Jerin Jacob
2022-02-14 15:31 ` Gujjar, Abhinandan S
0 siblings, 1 reply; 43+ messages in thread
From: Jerin Jacob @ 2022-02-14 15:26 UTC (permalink / raw)
To: Shijith Thotton
Cc: Gujjar, Abhinandan S, dev, Jerin Jacob Kollanukkaran,
Anoob Joseph, Pavan Nikhilesh Bhagavatula, Akhil Goyal
On Tue, Feb 8, 2022 at 10:31 PM Shijith Thotton <sthotton@marvell.com> wrote:
>
> Please ack v4 if there are no more comments.
Hi @Gujjar, Abhinandan S
Any objection to merging the test application patch?
> I tried adding support for software adapter implementation, but is getting a
> crash in sw_event PMD after some packets. I have posted the respective changes
> here: https://patchwork.dpdk.org/project/dpdk/patch/0677cbafa5145f1b9f64dd007594e033f2d9ab8a.1644337310.git.sthotton@marvell.com/
> Please take it forward.
>
> Command used to test is:
> dpdk-test-eventdev -l 0-8 -s 0xf0 --vdev=event_sw0 --vdev="crypto_null" -- \
> --prod_type_cryptodev --crypto_adptr_mode 1 --test=perf_queue --stlist=a \
> --wlcores 1 --plcores 2
>
^ permalink raw reply [flat|nested] 43+ messages in thread
* RE: [PATCH v3] app/eventdev: add crypto producer mode
2022-02-14 15:26 ` Jerin Jacob
@ 2022-02-14 15:31 ` Gujjar, Abhinandan S
0 siblings, 0 replies; 43+ messages in thread
From: Gujjar, Abhinandan S @ 2022-02-14 15:31 UTC (permalink / raw)
To: Jerin Jacob, Shijith Thotton
Cc: dev, Jerin Jacob Kollanukkaran, Anoob Joseph,
Pavan Nikhilesh Bhagavatula, Akhil Goyal
Hi Jerin,
I have some issues with my sandbox after the recent upgrade.
I am trying to get it working to test the patches.
Hopefully, by 1-2 days I will give you update.
Regards
Abhinandan
> -----Original Message-----
> From: Jerin Jacob <jerinjacobk@gmail.com>
> Sent: Monday, February 14, 2022 8:57 PM
> To: Shijith Thotton <sthotton@marvell.com>
> Cc: Gujjar, Abhinandan S <abhinandan.gujjar@intel.com>; dev@dpdk.org;
> Jerin Jacob Kollanukkaran <jerinj@marvell.com>; Anoob Joseph
> <anoobj@marvell.com>; Pavan Nikhilesh Bhagavatula
> <pbhagavatula@marvell.com>; Akhil Goyal <gakhil@marvell.com>
> Subject: Re: [PATCH v3] app/eventdev: add crypto producer mode
>
> On Tue, Feb 8, 2022 at 10:31 PM Shijith Thotton <sthotton@marvell.com>
> wrote:
> >
>
> > Please ack v4 if there are no more comments.
>
> Hi @Gujjar, Abhinandan S
>
> Any objection to merging the test application patch?
>
>
>
> > I tried adding support for software adapter implementation, but is
> > getting a crash in sw_event PMD after some packets. I have posted the
> > respective changes
> > here:
> >
> https://patchwork.dpdk.org/project/dpdk/patch/0677cbafa5145f1b9f64dd0
> 0
> > 7594e033f2d9ab8a.1644337310.git.sthotton@marvell.com/
> > Please take it forward.
> >
> > Command used to test is:
> > dpdk-test-eventdev -l 0-8 -s 0xf0 --vdev=event_sw0 --vdev="crypto_null" --
> \
> > --prod_type_cryptodev --crypto_adptr_mode 1 --test=perf_queue --
> stlist=a \
> > --wlcores 1 --plcores 2
> >
^ permalink raw reply [flat|nested] 43+ messages in thread
* RE: [PATCH v4] app/eventdev: add crypto producer mode
2022-02-08 16:33 ` [PATCH v4] " Shijith Thotton
@ 2022-02-15 6:03 ` Gujjar, Abhinandan S
2022-02-15 16:08 ` Shijith Thotton
2022-02-15 16:56 ` [PATCH v5] " Shijith Thotton
1 sibling, 1 reply; 43+ messages in thread
From: Gujjar, Abhinandan S @ 2022-02-15 6:03 UTC (permalink / raw)
To: Shijith Thotton, dev, jerinj
Hi Shijith,
> -----Original Message-----
> From: Shijith Thotton <sthotton@marvell.com>
> Sent: Tuesday, February 8, 2022 10:03 PM
> To: dev@dpdk.org; jerinj@marvell.com; Gujjar, Abhinandan S
> <abhinandan.gujjar@intel.com>
> Cc: Shijith Thotton <sthotton@marvell.com>
> Subject: [PATCH v4] app/eventdev: add crypto producer mode
>
> In crypto producer mode, producer core enqueues cryptodev with software
> generated crypto ops and worker core dequeues crypto completion events
> from the eventdev. Event crypto metadata used for above processing is pre-
> populated in each crypto session.
>
> Parameter --prod_type_cryptodev can be used to enable crypto producer
> mode. Parameter --crypto_adptr_mode can be set to select the crypto
> adapter mode, 0 for OP_NEW and 1 for OP_FORWARD.
>
> This mode can be used to measure the performance of crypto adapter.
>
> Example:
> ./dpdk-test-eventdev -l 0-2 -w <EVENTDEV> -w <CRYPTODEV> -- \
> --prod_type_cryptodev --crypto_adptr_mode 1 --test=perf_atq \
> --stlist=a --wlcores 1 --plcores 2
>
> Signed-off-by: Shijith Thotton <sthotton@marvell.com>
> ---
<SNIP>
Reposting your comments from previous patch:
I tried adding support for software adapter implementation, but is getting a crash in sw_event PMD after some packets. I have posted the respective changes
here: https://patchwork.dpdk.org/project/dpdk/patch/0677cbafa5145f1b9f64dd007594e033f2d9ab8a.1644337310.git.sthotton@marvell.com/
Please take it forward.
Command used to test is:
dpdk-test-eventdev -l 0-8 -s 0xf0 --vdev=event_sw0 --vdev="crypto_null" -- \
--prod_type_cryptodev --crypto_adptr_mode 1 --test=perf_queue --stlist=a \
--wlcores 1 --plcores 2
I tried to get the above command working with your patches. As you mentioned,
I see a crash! If I change the --test to any other queue, I see a totally irrelevant
error message:
error: pipeline_opt_check() Invalid producer type 'Event crypto adapter' valid producer 'Ethdev Rx Adapter'
error: main() invalid command line argument
I think, running a test with minimal configuration like sw_event, sw adapter & null cryptodev without
any vendor specific HW is very important to acknowledge a patch. Later, this code will be a reference
for adding performance test for any specific HW.
Right now, I can't think of any other options to see a working test.
If you know any other ways to test this code, please let me.
Thanks
Abhinandan
^ permalink raw reply [flat|nested] 43+ messages in thread
* RE: [PATCH v4] app/eventdev: add crypto producer mode
2022-02-15 6:03 ` Gujjar, Abhinandan S
@ 2022-02-15 16:08 ` Shijith Thotton
2022-02-15 16:46 ` Gujjar, Abhinandan S
0 siblings, 1 reply; 43+ messages in thread
From: Shijith Thotton @ 2022-02-15 16:08 UTC (permalink / raw)
To: Gujjar, Abhinandan S, dev, Jerin Jacob Kollanukkaran
Hi Abhinandan,
>>
>> In crypto producer mode, producer core enqueues cryptodev with software
>> generated crypto ops and worker core dequeues crypto completion events
>> from the eventdev. Event crypto metadata used for above processing is pre-
>> populated in each crypto session.
>>
>> Parameter --prod_type_cryptodev can be used to enable crypto producer
>> mode. Parameter --crypto_adptr_mode can be set to select the crypto
>> adapter mode, 0 for OP_NEW and 1 for OP_FORWARD.
>>
>> This mode can be used to measure the performance of crypto adapter.
>>
>> Example:
>> ./dpdk-test-eventdev -l 0-2 -w <EVENTDEV> -w <CRYPTODEV> -- \
>> --prod_type_cryptodev --crypto_adptr_mode 1 --test=perf_atq \
>> --stlist=a --wlcores 1 --plcores 2
>>
>> Signed-off-by: Shijith Thotton <sthotton@marvell.com>
>> ---
>
><SNIP>
>Reposting your comments from previous patch:
>I tried adding support for software adapter implementation, but is getting a crash
>in sw_event PMD after some packets. I have posted the respective changes
>here: https://urldefense.proofpoint.com/v2/url?u=https-
>3A__patchwork.dpdk.org_project_dpdk_patch_0677cbafa5145f1b9f64dd007594e
>033f2d9ab8a.1644337310.git.sthotton-
>40marvell.com_&d=DwIFAg&c=nKjWec2b6R0mOyPaz7xtfQ&r=G9w4KsPaQLACBf
>GCL35PtiRH996yqJDxAZwrWegU2qQ&m=sMNIOpMhfpihE2tsEnuoFNOZNbV5fctS
>mXD33o-
>7RC1A1o2s6on3bh2npzmlCR4e&s=xitJsdeoR3OqFEkVzPdJMVrU3xbkF3Qs0x2k2Pgi
>jeE&e=
>Please take it forward.
>
>Command used to test is:
>dpdk-test-eventdev -l 0-8 -s 0xf0 --vdev=event_sw0 --vdev="crypto_null" -- \
> --prod_type_cryptodev --crypto_adptr_mode 1 --test=perf_queue --stlist=a \
> --wlcores 1 --plcores 2
>
>I tried to get the above command working with your patches. As you mentioned,
>I see a crash! If I change the --test to any other queue, I see a totally irrelevant
I have mentioned the same in my previous message. The crash is in event_sw PMD.
Thread 10 "lcore-worker-7" received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7ffff3767400 (LWP 1140492)]
0x00005555569f2c8a in sw_event_schedule ()
(gdb) bt
#0 0x00005555569f2c8a in sw_event_schedule ()
#1 0x0000555556a05e3d in sw_sched_service_func ()
#2 0x000055555632ada3 in service_runner_func ()
#3 0x0000555555749b4b in eal_thread_loop.cold ()
#4 0x00007ffff7a0f609 in start_thread (arg=<optimized out>) at pthread_create.c:477
#5 0x00007ffff7936293 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95
So requested to take it forward as I'm not well versed in SW PMD implementation.
>error message:
>error: pipeline_opt_check() Invalid producer type 'Event crypto adapter' valid
>producer 'Ethdev Rx Adapter'
>error: main() invalid command line argument
>
Looks like, the test used is pipeline (from the log). Only --prod_type_ethdev is
supported by the pipeline test. Similar error can be found for all other modes.
Refer doc/guides/tools/testeventdev.rst for the list of supported options for
each test.
>I think, running a test with minimal configuration like sw_event, sw adapter & null
>cryptodev without
>any vendor specific HW is very important to acknowledge a patch. Later, this code
>will be a reference
>for adding performance test for any specific HW.
>Right now, I can't think of any other options to see a working test.
>If you know any other ways to test this code, please let me.
>
Please let me know if any change is needed in the application side. I will take a look.
Thanks,
Shijith
^ permalink raw reply [flat|nested] 43+ messages in thread
* RE: [PATCH v4] app/eventdev: add crypto producer mode
2022-02-15 16:08 ` Shijith Thotton
@ 2022-02-15 16:46 ` Gujjar, Abhinandan S
0 siblings, 0 replies; 43+ messages in thread
From: Gujjar, Abhinandan S @ 2022-02-15 16:46 UTC (permalink / raw)
To: Shijith Thotton, dev, Jerin Jacob Kollanukkaran
Hi Shijith,
> -----Original Message-----
> From: Shijith Thotton <sthotton@marvell.com>
> Sent: Tuesday, February 15, 2022 9:39 PM
> To: Gujjar, Abhinandan S <abhinandan.gujjar@intel.com>; dev@dpdk.org;
> Jerin Jacob Kollanukkaran <jerinj@marvell.com>
> Subject: RE: [PATCH v4] app/eventdev: add crypto producer mode
>
> Hi Abhinandan,
>
> >>
> >> In crypto producer mode, producer core enqueues cryptodev with
> >> software generated crypto ops and worker core dequeues crypto
> >> completion events from the eventdev. Event crypto metadata used for
> >> above processing is pre- populated in each crypto session.
> >>
> >> Parameter --prod_type_cryptodev can be used to enable crypto producer
> >> mode. Parameter --crypto_adptr_mode can be set to select the crypto
> >> adapter mode, 0 for OP_NEW and 1 for OP_FORWARD.
> >>
> >> This mode can be used to measure the performance of crypto adapter.
> >>
> >> Example:
> >> ./dpdk-test-eventdev -l 0-2 -w <EVENTDEV> -w <CRYPTODEV> -- \
> >> --prod_type_cryptodev --crypto_adptr_mode 1 --test=perf_atq \
> >> --stlist=a --wlcores 1 --plcores 2
> >>
> >> Signed-off-by: Shijith Thotton <sthotton@marvell.com>
> >> ---
> >
> ><SNIP>
> >Reposting your comments from previous patch:
> >I tried adding support for software adapter implementation, but is
> >getting a crash in sw_event PMD after some packets. I have posted the
> >respective changes
> >here: https://urldefense.proofpoint.com/v2/url?u=https-
> >3A__patchwork.dpdk.org_project_dpdk_patch_0677cbafa5145f1b9f64dd0
> 07594e
> >033f2d9ab8a.1644337310.git.sthotton-
> >40marvell.com_&d=DwIFAg&c=nKjWec2b6R0mOyPaz7xtfQ&r=G9w4KsPaQ
> LACBf
> >GCL35PtiRH996yqJDxAZwrWegU2qQ&m=sMNIOpMhfpihE2tsEnuoFNOZNb
> V5fctS
> >mXD33o-
> >7RC1A1o2s6on3bh2npzmlCR4e&s=xitJsdeoR3OqFEkVzPdJMVrU3xbkF3Qs0
> x2k2Pgi
> >jeE&e=
> >Please take it forward.
> >
> >Command used to test is:
> >dpdk-test-eventdev -l 0-8 -s 0xf0 --vdev=event_sw0 --vdev="crypto_null" --
> \
> > --prod_type_cryptodev --crypto_adptr_mode 1 --test=perf_queue --
> stlist=a \
> > --wlcores 1 --plcores 2
> >
> >I tried to get the above command working with your patches. As you
> >mentioned, I see a crash! If I change the --test to any other queue, I
> >see a totally irrelevant
>
> I have mentioned the same in my previous message. The crash is in event_sw
> PMD.
>
> Thread 10 "lcore-worker-7" received signal SIGSEGV, Segmentation fault.
> [Switching to Thread 0x7ffff3767400 (LWP 1140492)] 0x00005555569f2c8a in
> sw_event_schedule ()
> (gdb) bt
> #0 0x00005555569f2c8a in sw_event_schedule ()
> #1 0x0000555556a05e3d in sw_sched_service_func ()
> #2 0x000055555632ada3 in service_runner_func ()
> #3 0x0000555555749b4b in eal_thread_loop.cold ()
> #4 0x00007ffff7a0f609 in start_thread (arg=<optimized out>) at
> pthread_create.c:477
> #5 0x00007ffff7936293 in clone () at
> ../sysdeps/unix/sysv/linux/x86_64/clone.S:95
>
> So requested to take it forward as I'm not well versed in SW PMD
> implementation.
I can't take it forward. Please check with PMD maintainer.
>
> >error message:
> >error: pipeline_opt_check() Invalid producer type 'Event crypto
> >adapter' valid producer 'Ethdev Rx Adapter'
> >error: main() invalid command line argument
> >
>
> Looks like, the test used is pipeline (from the log). Only --prod_type_ethdev
> is supported by the pipeline test. Similar error can be found for all other
> modes.
>
> Refer doc/guides/tools/testeventdev.rst for the list of supported options for
> each test.
>
> >I think, running a test with minimal configuration like sw_event, sw
> >adapter & null cryptodev without any vendor specific HW is very
> >important to acknowledge a patch. Later, this code will be a reference
> >for adding performance test for any specific HW.
> >Right now, I can't think of any other options to see a working test.
> >If you know any other ways to test this code, please let me.
> >
>
> Please let me know if any change is needed in the application side. I will take
> a look.
Right now, the app is not working as expected.
Please debug and fix the issue.
>
> Thanks,
> Shijith
^ permalink raw reply [flat|nested] 43+ messages in thread
* [PATCH v5] app/eventdev: add crypto producer mode
2022-02-08 16:33 ` [PATCH v4] " Shijith Thotton
2022-02-15 6:03 ` Gujjar, Abhinandan S
@ 2022-02-15 16:56 ` Shijith Thotton
2022-02-16 4:47 ` Gujjar, Abhinandan S
` (2 more replies)
1 sibling, 3 replies; 43+ messages in thread
From: Shijith Thotton @ 2022-02-15 16:56 UTC (permalink / raw)
To: dev, jerinj; +Cc: Shijith Thotton, abhinandan.gujjar
In crypto producer mode, producer core enqueues cryptodev with software
generated crypto ops and worker core dequeues crypto completion events
from the eventdev. Event crypto metadata used for above processing is
pre-populated in each crypto session.
Parameter --prod_type_cryptodev can be used to enable crypto producer
mode. Parameter --crypto_adptr_mode can be set to select the crypto
adapter mode, 0 for OP_NEW and 1 for OP_FORWARD.
This mode can be used to measure the performance of crypto adapter.
Example:
./dpdk-test-eventdev -l 0-2 -w <EVENTDEV> -w <CRYPTODEV> -- \
--prod_type_cryptodev --crypto_adptr_mode 1 --test=perf_atq \
--stlist=a --wlcores 1 --plcores 2
Signed-off-by: Shijith Thotton <sthotton@marvell.com>
---
v5:
* Rebased.
v4:
* Addressed comments on v3 and rebased.
* Added cryptodev cleanup in signal handler.
v3:
* Reduce dereference inside loop.
v2:
* Fix RHEL compilation warning.
app/test-eventdev/evt_common.h | 3 +
app/test-eventdev/evt_main.c | 17 +-
app/test-eventdev/evt_options.c | 27 ++
app/test-eventdev/evt_options.h | 12 +
app/test-eventdev/evt_test.h | 6 +
app/test-eventdev/test_perf_atq.c | 49 +++
app/test-eventdev/test_perf_common.c | 425 ++++++++++++++++++++++++++-
app/test-eventdev/test_perf_common.h | 18 +-
app/test-eventdev/test_perf_queue.c | 50 ++++
doc/guides/tools/testeventdev.rst | 13 +
10 files changed, 612 insertions(+), 8 deletions(-)
diff --git a/app/test-eventdev/evt_common.h b/app/test-eventdev/evt_common.h
index f466434459..2f301a7e79 100644
--- a/app/test-eventdev/evt_common.h
+++ b/app/test-eventdev/evt_common.h
@@ -7,6 +7,7 @@
#include <rte_common.h>
#include <rte_debug.h>
+#include <rte_event_crypto_adapter.h>
#include <rte_eventdev.h>
#include <rte_service.h>
@@ -39,6 +40,7 @@ enum evt_prod_type {
EVT_PROD_TYPE_SYNT, /* Producer type Synthetic i.e. CPU. */
EVT_PROD_TYPE_ETH_RX_ADPTR, /* Producer type Eth Rx Adapter. */
EVT_PROD_TYPE_EVENT_TIMER_ADPTR, /* Producer type Timer Adapter. */
+ EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR, /* Producer type Crypto Adapter. */
EVT_PROD_TYPE_MAX,
};
@@ -77,6 +79,7 @@ struct evt_options {
uint64_t timer_tick_nsec;
uint64_t optm_timer_tick_nsec;
enum evt_prod_type prod_type;
+ enum rte_event_crypto_adapter_mode crypto_adptr_mode;
};
static inline bool
diff --git a/app/test-eventdev/evt_main.c b/app/test-eventdev/evt_main.c
index 194c980c7a..a7d6b0c1cf 100644
--- a/app/test-eventdev/evt_main.c
+++ b/app/test-eventdev/evt_main.c
@@ -35,6 +35,9 @@ signal_handler(int signum)
if (test->ops.ethdev_destroy)
test->ops.ethdev_destroy(test, &opt);
+ if (test->ops.cryptodev_destroy)
+ test->ops.cryptodev_destroy(test, &opt);
+
rte_eal_mp_wait_lcore();
if (test->ops.test_result)
@@ -162,11 +165,19 @@ main(int argc, char **argv)
}
}
+ /* Test specific cryptodev setup */
+ if (test->ops.cryptodev_setup) {
+ if (test->ops.cryptodev_setup(test, &opt)) {
+ evt_err("%s: cryptodev setup failed", opt.test_name);
+ goto ethdev_destroy;
+ }
+ }
+
/* Test specific eventdev setup */
if (test->ops.eventdev_setup) {
if (test->ops.eventdev_setup(test, &opt)) {
evt_err("%s: eventdev setup failed", opt.test_name);
- goto ethdev_destroy;
+ goto cryptodev_destroy;
}
}
@@ -197,6 +208,10 @@ main(int argc, char **argv)
if (test->ops.eventdev_destroy)
test->ops.eventdev_destroy(test, &opt);
+cryptodev_destroy:
+ if (test->ops.cryptodev_destroy)
+ test->ops.cryptodev_destroy(test, &opt);
+
ethdev_destroy:
if (test->ops.ethdev_destroy)
test->ops.ethdev_destroy(test, &opt);
diff --git a/app/test-eventdev/evt_options.c b/app/test-eventdev/evt_options.c
index 4ae44801da..d3c704d2b3 100644
--- a/app/test-eventdev/evt_options.c
+++ b/app/test-eventdev/evt_options.c
@@ -122,6 +122,26 @@ evt_parse_timer_prod_type_burst(struct evt_options *opt,
return 0;
}
+static int
+evt_parse_crypto_prod_type(struct evt_options *opt,
+ const char *arg __rte_unused)
+{
+ opt->prod_type = EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR;
+ return 0;
+}
+
+static int
+evt_parse_crypto_adptr_mode(struct evt_options *opt, const char *arg)
+{
+ uint8_t mode;
+ int ret;
+
+ ret = parser_read_uint8(&mode, arg);
+ opt->crypto_adptr_mode = mode ? RTE_EVENT_CRYPTO_ADAPTER_OP_FORWARD :
+ RTE_EVENT_CRYPTO_ADAPTER_OP_NEW;
+ return ret;
+}
+
static int
evt_parse_test_name(struct evt_options *opt, const char *arg)
{
@@ -335,6 +355,7 @@ usage(char *program)
"\t--queue_priority : enable queue priority\n"
"\t--deq_tmo_nsec : global dequeue timeout\n"
"\t--prod_type_ethdev : use ethernet device as producer.\n"
+ "\t--prod_type_cryptodev : use crypto device as producer.\n"
"\t--prod_type_timerdev : use event timer device as producer.\n"
"\t expiry_nsec would be the timeout\n"
"\t in ns.\n"
@@ -345,6 +366,8 @@ usage(char *program)
"\t--timer_tick_nsec : timer tick interval in ns.\n"
"\t--max_tmo_nsec : max timeout interval in ns.\n"
"\t--expiry_nsec : event timer expiry ns.\n"
+ "\t--crypto_adptr_mode : 0 for OP_NEW mode (default) and\n"
+ "\t 1 for OP_FORWARD mode.\n"
"\t--mbuf_sz : packet mbuf size.\n"
"\t--max_pkt_sz : max packet size.\n"
"\t--prod_enq_burst_sz : producer enqueue burst size.\n"
@@ -415,8 +438,10 @@ static struct option lgopts[] = {
{ EVT_QUEUE_PRIORITY, 0, 0, 0 },
{ EVT_DEQ_TMO_NSEC, 1, 0, 0 },
{ EVT_PROD_ETHDEV, 0, 0, 0 },
+ { EVT_PROD_CRYPTODEV, 0, 0, 0 },
{ EVT_PROD_TIMERDEV, 0, 0, 0 },
{ EVT_PROD_TIMERDEV_BURST, 0, 0, 0 },
+ { EVT_CRYPTO_ADPTR_MODE, 1, 0, 0 },
{ EVT_NB_TIMERS, 1, 0, 0 },
{ EVT_NB_TIMER_ADPTRS, 1, 0, 0 },
{ EVT_TIMER_TICK_NSEC, 1, 0, 0 },
@@ -455,8 +480,10 @@ evt_opts_parse_long(int opt_idx, struct evt_options *opt)
{ EVT_QUEUE_PRIORITY, evt_parse_queue_priority},
{ EVT_DEQ_TMO_NSEC, evt_parse_deq_tmo_nsec},
{ EVT_PROD_ETHDEV, evt_parse_eth_prod_type},
+ { EVT_PROD_CRYPTODEV, evt_parse_crypto_prod_type},
{ EVT_PROD_TIMERDEV, evt_parse_timer_prod_type},
{ EVT_PROD_TIMERDEV_BURST, evt_parse_timer_prod_type_burst},
+ { EVT_CRYPTO_ADPTR_MODE, evt_parse_crypto_adptr_mode},
{ EVT_NB_TIMERS, evt_parse_nb_timers},
{ EVT_NB_TIMER_ADPTRS, evt_parse_nb_timer_adptrs},
{ EVT_TIMER_TICK_NSEC, evt_parse_timer_tick_nsec},
diff --git a/app/test-eventdev/evt_options.h b/app/test-eventdev/evt_options.h
index 413d7092f0..2231c58801 100644
--- a/app/test-eventdev/evt_options.h
+++ b/app/test-eventdev/evt_options.h
@@ -9,6 +9,7 @@
#include <stdbool.h>
#include <rte_common.h>
+#include <rte_cryptodev.h>
#include <rte_ethdev.h>
#include <rte_eventdev.h>
#include <rte_lcore.h>
@@ -33,8 +34,10 @@
#define EVT_QUEUE_PRIORITY ("queue_priority")
#define EVT_DEQ_TMO_NSEC ("deq_tmo_nsec")
#define EVT_PROD_ETHDEV ("prod_type_ethdev")
+#define EVT_PROD_CRYPTODEV ("prod_type_cryptodev")
#define EVT_PROD_TIMERDEV ("prod_type_timerdev")
#define EVT_PROD_TIMERDEV_BURST ("prod_type_timerdev_burst")
+#define EVT_CRYPTO_ADPTR_MODE ("crypto_adptr_mode")
#define EVT_NB_TIMERS ("nb_timers")
#define EVT_NB_TIMER_ADPTRS ("nb_timer_adptrs")
#define EVT_TIMER_TICK_NSEC ("timer_tick_nsec")
@@ -249,6 +252,8 @@ evt_prod_id_to_name(enum evt_prod_type prod_type)
return "Ethdev Rx Adapter";
case EVT_PROD_TYPE_EVENT_TIMER_ADPTR:
return "Event timer adapter";
+ case EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR:
+ return "Event crypto adapter";
}
return "";
@@ -288,6 +293,13 @@ evt_dump_producer_type(struct evt_options *opt)
evt_dump("timer_tick_nsec", "%"PRIu64"",
opt->timer_tick_nsec);
break;
+ case EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR:
+ snprintf(name, EVT_PROD_MAX_NAME_LEN,
+ "Event crypto adapter producers");
+ evt_dump("crypto adapter mode", "%s",
+ opt->crypto_adptr_mode ? "OP_FORWARD" : "OP_NEW");
+ evt_dump("nb_cryptodev", "%u", rte_cryptodev_count());
+ break;
}
evt_dump("prod_type", "%s", name);
}
diff --git a/app/test-eventdev/evt_test.h b/app/test-eventdev/evt_test.h
index f07d2c3336..50fa474ec2 100644
--- a/app/test-eventdev/evt_test.h
+++ b/app/test-eventdev/evt_test.h
@@ -29,6 +29,8 @@ typedef int (*evt_test_mempool_setup_t)
(struct evt_test *test, struct evt_options *opt);
typedef int (*evt_test_ethdev_setup_t)
(struct evt_test *test, struct evt_options *opt);
+typedef int (*evt_test_cryptodev_setup_t)
+ (struct evt_test *test, struct evt_options *opt);
typedef int (*evt_test_eventdev_setup_t)
(struct evt_test *test, struct evt_options *opt);
typedef int (*evt_test_launch_lcores_t)
@@ -39,6 +41,8 @@ typedef void (*evt_test_eventdev_destroy_t)
(struct evt_test *test, struct evt_options *opt);
typedef void (*evt_test_ethdev_destroy_t)
(struct evt_test *test, struct evt_options *opt);
+typedef void (*evt_test_cryptodev_destroy_t)
+ (struct evt_test *test, struct evt_options *opt);
typedef void (*evt_test_mempool_destroy_t)
(struct evt_test *test, struct evt_options *opt);
typedef void (*evt_test_destroy_t)
@@ -52,10 +56,12 @@ struct evt_test_ops {
evt_test_mempool_setup_t mempool_setup;
evt_test_ethdev_setup_t ethdev_setup;
evt_test_eventdev_setup_t eventdev_setup;
+ evt_test_cryptodev_setup_t cryptodev_setup;
evt_test_launch_lcores_t launch_lcores;
evt_test_result_t test_result;
evt_test_eventdev_destroy_t eventdev_destroy;
evt_test_ethdev_destroy_t ethdev_destroy;
+ evt_test_cryptodev_destroy_t cryptodev_destroy;
evt_test_mempool_destroy_t mempool_destroy;
evt_test_destroy_t test_destroy;
};
diff --git a/app/test-eventdev/test_perf_atq.c b/app/test-eventdev/test_perf_atq.c
index 8fd51004ee..67ff681666 100644
--- a/app/test-eventdev/test_perf_atq.c
+++ b/app/test-eventdev/test_perf_atq.c
@@ -48,6 +48,22 @@ perf_atq_worker(void *arg, const int enable_fwd_latency)
continue;
}
+ if (prod_crypto_type &&
+ (ev.event_type == RTE_EVENT_TYPE_CRYPTODEV)) {
+ struct rte_crypto_op *op = ev.event_ptr;
+
+ if (op->status == RTE_CRYPTO_OP_STATUS_SUCCESS) {
+ if (op->sym->m_dst == NULL)
+ ev.event_ptr = op->sym->m_src;
+ else
+ ev.event_ptr = op->sym->m_dst;
+ rte_crypto_op_free(op);
+ } else {
+ rte_crypto_op_free(op);
+ continue;
+ }
+ }
+
if (enable_fwd_latency && !prod_timer_type)
/* first stage in pipeline, mark ts to compute fwd latency */
atq_mark_fwd_latency(&ev);
@@ -87,6 +103,25 @@ perf_atq_worker_burst(void *arg, const int enable_fwd_latency)
}
for (i = 0; i < nb_rx; i++) {
+ if (prod_crypto_type &&
+ (ev[i].event_type == RTE_EVENT_TYPE_CRYPTODEV)) {
+ struct rte_crypto_op *op = ev[i].event_ptr;
+
+ if (op->status ==
+ RTE_CRYPTO_OP_STATUS_SUCCESS) {
+ if (op->sym->m_dst == NULL)
+ ev[i].event_ptr =
+ op->sym->m_src;
+ else
+ ev[i].event_ptr =
+ op->sym->m_dst;
+ rte_crypto_op_free(op);
+ } else {
+ rte_crypto_op_free(op);
+ continue;
+ }
+ }
+
if (enable_fwd_latency && !prod_timer_type) {
rte_prefetch0(ev[i+1].event_ptr);
/* first stage in pipeline.
@@ -254,6 +289,18 @@ perf_atq_eventdev_setup(struct evt_test *test, struct evt_options *opt)
return ret;
}
}
+ } else if (opt->prod_type == EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR) {
+ uint8_t cdev_id, cdev_count;
+
+ cdev_count = rte_cryptodev_count();
+ for (cdev_id = 0; cdev_id < cdev_count; cdev_id++) {
+ ret = rte_cryptodev_start(cdev_id);
+ if (ret) {
+ evt_err("Failed to start cryptodev %u",
+ cdev_id);
+ return ret;
+ }
+ }
}
return 0;
@@ -295,12 +342,14 @@ static const struct evt_test_ops perf_atq = {
.opt_dump = perf_atq_opt_dump,
.test_setup = perf_test_setup,
.ethdev_setup = perf_ethdev_setup,
+ .cryptodev_setup = perf_cryptodev_setup,
.mempool_setup = perf_mempool_setup,
.eventdev_setup = perf_atq_eventdev_setup,
.launch_lcores = perf_atq_launch_lcores,
.eventdev_destroy = perf_eventdev_destroy,
.mempool_destroy = perf_mempool_destroy,
.ethdev_destroy = perf_ethdev_destroy,
+ .cryptodev_destroy = perf_cryptodev_destroy,
.test_result = perf_test_result,
.test_destroy = perf_test_destroy,
};
diff --git a/app/test-eventdev/test_perf_common.c b/app/test-eventdev/test_perf_common.c
index 9b73874151..7d4eab9b8e 100644
--- a/app/test-eventdev/test_perf_common.c
+++ b/app/test-eventdev/test_perf_common.c
@@ -6,6 +6,8 @@
#include "test_perf_common.h"
+#define NB_CRYPTODEV_DESCRIPTORS 128
+
int
perf_test_result(struct evt_test *test, struct evt_options *opt)
{
@@ -272,6 +274,123 @@ perf_event_timer_producer_burst(void *arg)
return 0;
}
+static inline void
+crypto_adapter_enq_op_new(struct prod_data *p)
+{
+ struct rte_cryptodev_sym_session **crypto_sess = p->ca.crypto_sess;
+ struct test_perf *t = p->t;
+ const uint32_t nb_flows = t->nb_flows;
+ const uint64_t nb_pkts = t->nb_pkts;
+ struct rte_mempool *pool = t->pool;
+ struct rte_crypto_sym_op *sym_op;
+ struct evt_options *opt = t->opt;
+ uint16_t qp_id = p->ca.cdev_qp_id;
+ uint8_t cdev_id = p->ca.cdev_id;
+ uint32_t flow_counter = 0;
+ struct rte_crypto_op *op;
+ struct rte_mbuf *m;
+ uint64_t count = 0;
+ uint16_t len;
+
+ if (opt->verbose_level > 1)
+ printf("%s(): lcore %d queue %d cdev_id %u cdev_qp_id %u\n",
+ __func__, rte_lcore_id(), p->queue_id, p->ca.cdev_id,
+ p->ca.cdev_qp_id);
+
+ len = opt->mbuf_sz ? opt->mbuf_sz : RTE_ETHER_MIN_LEN;
+
+ while (count < nb_pkts && t->done == false) {
+ m = rte_pktmbuf_alloc(pool);
+ if (m == NULL)
+ continue;
+
+ rte_pktmbuf_append(m, len);
+ op = rte_crypto_op_alloc(t->ca_op_pool,
+ RTE_CRYPTO_OP_TYPE_SYMMETRIC);
+ sym_op = op->sym;
+ sym_op->m_src = m;
+ sym_op->cipher.data.offset = 0;
+ sym_op->cipher.data.length = len;
+ rte_crypto_op_attach_sym_session(
+ op, crypto_sess[flow_counter++ % nb_flows]);
+
+ while (rte_cryptodev_enqueue_burst(cdev_id, qp_id, &op, 1) != 1 &&
+ t->done == false)
+ rte_pause();
+
+ count++;
+ }
+}
+
+static inline void
+crypto_adapter_enq_op_fwd(struct prod_data *p)
+{
+ struct rte_cryptodev_sym_session **crypto_sess = p->ca.crypto_sess;
+ const uint8_t dev_id = p->dev_id;
+ const uint8_t port = p->port_id;
+ struct test_perf *t = p->t;
+ const uint32_t nb_flows = t->nb_flows;
+ const uint64_t nb_pkts = t->nb_pkts;
+ struct rte_mempool *pool = t->pool;
+ struct evt_options *opt = t->opt;
+ struct rte_crypto_sym_op *sym_op;
+ uint32_t flow_counter = 0;
+ struct rte_crypto_op *op;
+ struct rte_event ev;
+ struct rte_mbuf *m;
+ uint64_t count = 0;
+ uint16_t len;
+
+ if (opt->verbose_level > 1)
+ printf("%s(): lcore %d port %d queue %d cdev_id %u cdev_qp_id %u\n",
+ __func__, rte_lcore_id(), port, p->queue_id,
+ p->ca.cdev_id, p->ca.cdev_qp_id);
+
+ ev.event = 0;
+ ev.op = RTE_EVENT_OP_FORWARD;
+ ev.queue_id = p->queue_id;
+ ev.sched_type = RTE_SCHED_TYPE_ATOMIC;
+ ev.event_type = RTE_EVENT_TYPE_CPU;
+ len = opt->mbuf_sz ? opt->mbuf_sz : RTE_ETHER_MIN_LEN;
+
+ while (count < nb_pkts && t->done == false) {
+ m = rte_pktmbuf_alloc(pool);
+ if (m == NULL)
+ continue;
+
+ rte_pktmbuf_append(m, len);
+ op = rte_crypto_op_alloc(t->ca_op_pool,
+ RTE_CRYPTO_OP_TYPE_SYMMETRIC);
+ sym_op = op->sym;
+ sym_op->m_src = m;
+ sym_op->cipher.data.offset = 0;
+ sym_op->cipher.data.length = len;
+ rte_crypto_op_attach_sym_session(
+ op, crypto_sess[flow_counter++ % nb_flows]);
+ ev.event_ptr = op;
+
+ while (rte_event_crypto_adapter_enqueue(dev_id, port, &ev, 1) != 1 &&
+ t->done == false)
+ rte_pause();
+
+ count++;
+ }
+}
+
+static inline int
+perf_event_crypto_producer(void *arg)
+{
+ struct prod_data *p = arg;
+ struct evt_options *opt = p->t->opt;
+
+ if (opt->crypto_adptr_mode == RTE_EVENT_CRYPTO_ADAPTER_OP_NEW)
+ crypto_adapter_enq_op_new(p);
+ else
+ crypto_adapter_enq_op_fwd(p);
+
+ return 0;
+}
+
static int
perf_producer_wrapper(void *arg)
{
@@ -298,6 +417,8 @@ perf_producer_wrapper(void *arg)
else if (t->opt->prod_type == EVT_PROD_TYPE_EVENT_TIMER_ADPTR &&
t->opt->timdev_use_burst)
return perf_event_timer_producer_burst(arg);
+ else if (t->opt->prod_type == EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR)
+ return perf_event_crypto_producer(arg);
return 0;
}
@@ -405,8 +526,10 @@ perf_launch_lcores(struct evt_test *test, struct evt_options *opt,
if (remaining <= 0) {
t->result = EVT_TEST_SUCCESS;
if (opt->prod_type == EVT_PROD_TYPE_SYNT ||
- opt->prod_type ==
- EVT_PROD_TYPE_EVENT_TIMER_ADPTR) {
+ opt->prod_type ==
+ EVT_PROD_TYPE_EVENT_TIMER_ADPTR ||
+ opt->prod_type ==
+ EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR) {
t->done = true;
break;
}
@@ -415,7 +538,8 @@ perf_launch_lcores(struct evt_test *test, struct evt_options *opt,
if (new_cycles - dead_lock_cycles > dead_lock_sample &&
(opt->prod_type == EVT_PROD_TYPE_SYNT ||
- opt->prod_type == EVT_PROD_TYPE_EVENT_TIMER_ADPTR)) {
+ opt->prod_type == EVT_PROD_TYPE_EVENT_TIMER_ADPTR ||
+ opt->prod_type == EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR)) {
remaining = t->outstand_pkts - processed_pkts(t);
if (dead_lock_remaining == remaining) {
rte_event_dev_dump(opt->dev_id, stdout);
@@ -537,6 +661,80 @@ perf_event_timer_adapter_setup(struct test_perf *t)
return 0;
}
+static int
+perf_event_crypto_adapter_setup(struct test_perf *t, struct prod_data *p)
+{
+ struct evt_options *opt = t->opt;
+ uint32_t cap;
+ int ret;
+
+ ret = rte_event_crypto_adapter_caps_get(p->dev_id, p->ca.cdev_id, &cap);
+ if (ret) {
+ evt_err("Failed to get crypto adapter capabilities");
+ return ret;
+ }
+
+ if (((opt->crypto_adptr_mode == RTE_EVENT_CRYPTO_ADAPTER_OP_NEW) &&
+ !(cap & RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_OP_NEW)) ||
+ ((opt->crypto_adptr_mode == RTE_EVENT_CRYPTO_ADAPTER_OP_FORWARD) &&
+ !(cap & RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_OP_FWD))) {
+ evt_err("crypto adapter %s mode unsupported\n",
+ opt->crypto_adptr_mode ? "OP_FORWARD" : "OP_NEW");
+ return -EINVAL;
+ } else if (!(cap & RTE_EVENT_CRYPTO_ADAPTER_CAP_SESSION_PRIVATE_DATA)) {
+ evt_err("Storing crypto session not supported");
+ return -EINVAL;
+ }
+
+ if (cap & RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_QP_EV_BIND) {
+ struct rte_event response_info;
+
+ response_info.event = 0;
+ response_info.op =
+ opt->crypto_adptr_mode ==
+ RTE_EVENT_CRYPTO_ADAPTER_OP_NEW ?
+ RTE_EVENT_OP_NEW :
+ RTE_EVENT_OP_FORWARD;
+ response_info.sched_type = RTE_SCHED_TYPE_ATOMIC;
+ response_info.event_type = RTE_EVENT_TYPE_CRYPTODEV;
+ response_info.queue_id = p->queue_id;
+ ret = rte_event_crypto_adapter_queue_pair_add(
+ TEST_PERF_CA_ID, p->ca.cdev_id, p->ca.cdev_qp_id,
+ &response_info);
+ } else {
+ ret = rte_event_crypto_adapter_queue_pair_add(
+ TEST_PERF_CA_ID, p->ca.cdev_id, p->ca.cdev_qp_id, NULL);
+ }
+
+ return ret;
+}
+
+static struct rte_cryptodev_sym_session *
+cryptodev_sym_sess_create(struct prod_data *p, struct test_perf *t)
+{
+ struct rte_crypto_sym_xform cipher_xform;
+ struct rte_cryptodev_sym_session *sess;
+
+ cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
+ cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
+ cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
+ cipher_xform.next = NULL;
+
+ sess = rte_cryptodev_sym_session_create(t->ca_sess_pool);
+ if (sess == NULL) {
+ evt_err("Failed to create sym session");
+ return NULL;
+ }
+
+ if (rte_cryptodev_sym_session_init(p->ca.cdev_id, sess, &cipher_xform,
+ t->ca_sess_priv_pool)) {
+ evt_err("Failed to init session");
+ return NULL;
+ }
+
+ return sess;
+}
+
int
perf_event_dev_port_setup(struct evt_test *test, struct evt_options *opt,
uint8_t stride, uint8_t nb_queues,
@@ -598,6 +796,80 @@ perf_event_dev_port_setup(struct evt_test *test, struct evt_options *opt,
ret = perf_event_timer_adapter_setup(t);
if (ret)
return ret;
+ } else if (opt->prod_type == EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR) {
+ struct rte_event_port_conf conf = *port_conf;
+ uint8_t cdev_id = 0;
+ uint16_t qp_id = 0;
+
+ ret = rte_event_crypto_adapter_create(TEST_PERF_CA_ID,
+ opt->dev_id, &conf, 0);
+ if (ret) {
+ evt_err("Failed to create crypto adapter");
+ return ret;
+ }
+
+ prod = 0;
+ for (; port < perf_nb_event_ports(opt); port++) {
+ struct rte_cryptodev_sym_session *crypto_sess;
+ union rte_event_crypto_metadata m_data;
+ struct prod_data *p = &t->prod[port];
+ uint32_t flow_id;
+
+ if (qp_id == rte_cryptodev_queue_pair_count(cdev_id)) {
+ cdev_id++;
+ qp_id = 0;
+ }
+
+ p->dev_id = opt->dev_id;
+ p->port_id = port;
+ p->queue_id = prod * stride;
+ p->ca.cdev_id = cdev_id;
+ p->ca.cdev_qp_id = qp_id;
+ p->ca.crypto_sess = rte_zmalloc_socket(
+ NULL, sizeof(crypto_sess) * t->nb_flows,
+ RTE_CACHE_LINE_SIZE, opt->socket_id);
+ p->t = t;
+
+ m_data.request_info.cdev_id = p->ca.cdev_id;
+ m_data.request_info.queue_pair_id = p->ca.cdev_qp_id;
+ m_data.response_info.op =
+ opt->crypto_adptr_mode ==
+ RTE_EVENT_CRYPTO_ADAPTER_OP_NEW ?
+ RTE_EVENT_OP_NEW :
+ RTE_EVENT_OP_FORWARD;
+ m_data.response_info.sched_type = RTE_SCHED_TYPE_ATOMIC;
+ m_data.response_info.event_type =
+ RTE_EVENT_TYPE_CRYPTODEV;
+ m_data.response_info.queue_id = p->queue_id;
+
+ for (flow_id = 0; flow_id < t->nb_flows; flow_id++) {
+ crypto_sess = cryptodev_sym_sess_create(p, t);
+ if (crypto_sess == NULL)
+ return -ENOMEM;
+
+ m_data.response_info.flow_id = flow_id;
+ rte_cryptodev_sym_session_set_user_data(
+ crypto_sess, &m_data, sizeof(m_data));
+ p->ca.crypto_sess[flow_id] = crypto_sess;
+ }
+
+ conf.event_port_cfg |=
+ RTE_EVENT_PORT_CFG_HINT_PRODUCER |
+ RTE_EVENT_PORT_CFG_HINT_CONSUMER;
+
+ ret = rte_event_port_setup(opt->dev_id, port, &conf);
+ if (ret) {
+ evt_err("failed to setup port %d", port);
+ return ret;
+ }
+
+ ret = perf_event_crypto_adapter_setup(t, p);
+ if (ret)
+ return ret;
+
+ qp_id++;
+ prod++;
+ }
} else {
prod = 0;
for ( ; port < perf_nb_event_ports(opt); port++) {
@@ -659,7 +931,8 @@ perf_opt_check(struct evt_options *opt, uint64_t nb_queues)
}
if (opt->prod_type == EVT_PROD_TYPE_SYNT ||
- opt->prod_type == EVT_PROD_TYPE_EVENT_TIMER_ADPTR) {
+ opt->prod_type == EVT_PROD_TYPE_EVENT_TIMER_ADPTR ||
+ opt->prod_type == EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR) {
/* Validate producer lcores */
if (evt_lcores_has_overlap(opt->plcores,
rte_get_main_lcore())) {
@@ -767,8 +1040,7 @@ perf_ethdev_setup(struct evt_test *test, struct evt_options *opt)
},
};
- if (opt->prod_type == EVT_PROD_TYPE_SYNT ||
- opt->prod_type == EVT_PROD_TYPE_EVENT_TIMER_ADPTR)
+ if (opt->prod_type != EVT_PROD_TYPE_ETH_RX_ADPTR)
return 0;
if (!rte_eth_dev_count_avail()) {
@@ -841,6 +1113,147 @@ void perf_ethdev_destroy(struct evt_test *test, struct evt_options *opt)
}
}
+int
+perf_cryptodev_setup(struct evt_test *test, struct evt_options *opt)
+{
+ uint8_t cdev_count, cdev_id, nb_plcores, nb_qps;
+ struct test_perf *t = evt_test_priv(test);
+ unsigned int max_session_size;
+ uint32_t nb_sessions;
+ int ret;
+
+ if (opt->prod_type != EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR)
+ return 0;
+
+ cdev_count = rte_cryptodev_count();
+ if (cdev_count == 0) {
+ evt_err("No crypto devices available\n");
+ return -ENODEV;
+ }
+
+ t->ca_op_pool = rte_crypto_op_pool_create(
+ "crypto_op_pool", RTE_CRYPTO_OP_TYPE_SYMMETRIC, opt->pool_sz,
+ 128, 0, rte_socket_id());
+ if (t->ca_op_pool == NULL) {
+ evt_err("Failed to create crypto op pool");
+ return -ENOMEM;
+ }
+
+ nb_sessions = evt_nr_active_lcores(opt->plcores) * t->nb_flows;
+ t->ca_sess_pool = rte_cryptodev_sym_session_pool_create(
+ "ca_sess_pool", nb_sessions, 0, 0,
+ sizeof(union rte_event_crypto_metadata), SOCKET_ID_ANY);
+ if (t->ca_sess_pool == NULL) {
+ evt_err("Failed to create sym session pool");
+ ret = -ENOMEM;
+ goto err;
+ }
+
+ max_session_size = 0;
+ for (cdev_id = 0; cdev_id < cdev_count; cdev_id++) {
+ unsigned int session_size;
+
+ session_size =
+ rte_cryptodev_sym_get_private_session_size(cdev_id);
+ if (session_size > max_session_size)
+ max_session_size = session_size;
+ }
+
+ max_session_size += sizeof(union rte_event_crypto_metadata);
+ t->ca_sess_priv_pool = rte_mempool_create(
+ "ca_sess_priv_pool", nb_sessions, max_session_size, 0, 0, NULL,
+ NULL, NULL, NULL, SOCKET_ID_ANY, 0);
+ if (t->ca_sess_priv_pool == NULL) {
+ evt_err("failed to create sym session private pool");
+ ret = -ENOMEM;
+ goto err;
+ }
+
+ /*
+ * Calculate number of needed queue pairs, based on the amount of
+ * available number of logical cores and crypto devices. For instance,
+ * if there are 4 cores and 2 crypto devices, 2 queue pairs will be set
+ * up per device.
+ */
+ nb_plcores = evt_nr_active_lcores(opt->plcores);
+ nb_qps = (nb_plcores % cdev_count) ? (nb_plcores / cdev_count) + 1 :
+ nb_plcores / cdev_count;
+ for (cdev_id = 0; cdev_id < cdev_count; cdev_id++) {
+ struct rte_cryptodev_qp_conf qp_conf;
+ struct rte_cryptodev_config conf;
+ struct rte_cryptodev_info info;
+ int qp_id;
+
+ rte_cryptodev_info_get(cdev_id, &info);
+ if (nb_qps > info.max_nb_queue_pairs) {
+ evt_err("Not enough queue pairs per cryptodev (%u)",
+ nb_qps);
+ ret = -EINVAL;
+ goto err;
+ }
+
+ conf.nb_queue_pairs = nb_qps;
+ conf.socket_id = SOCKET_ID_ANY;
+ conf.ff_disable = RTE_CRYPTODEV_FF_SECURITY;
+
+ ret = rte_cryptodev_configure(cdev_id, &conf);
+ if (ret) {
+ evt_err("Failed to configure cryptodev (%u)", cdev_id);
+ goto err;
+ }
+
+ qp_conf.nb_descriptors = NB_CRYPTODEV_DESCRIPTORS;
+ qp_conf.mp_session = t->ca_sess_pool;
+ qp_conf.mp_session_private = t->ca_sess_priv_pool;
+
+ for (qp_id = 0; qp_id < conf.nb_queue_pairs; qp_id++) {
+ ret = rte_cryptodev_queue_pair_setup(
+ cdev_id, qp_id, &qp_conf,
+ rte_cryptodev_socket_id(cdev_id));
+ if (ret) {
+ evt_err("Failed to setup queue pairs on cryptodev %u\n",
+ cdev_id);
+ goto err;
+ }
+ }
+ }
+
+ return 0;
+err:
+ rte_mempool_free(t->ca_op_pool);
+ rte_mempool_free(t->ca_sess_pool);
+ rte_mempool_free(t->ca_sess_priv_pool);
+
+ return ret;
+}
+
+void
+perf_cryptodev_destroy(struct evt_test *test, struct evt_options *opt)
+{
+ uint8_t cdev_id, cdev_count = rte_cryptodev_count();
+ struct test_perf *t = evt_test_priv(test);
+ uint16_t port;
+
+ if (opt->prod_type != EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR)
+ return;
+
+ for (port = t->nb_workers; port < perf_nb_event_ports(opt); port++) {
+ struct prod_data *p = &t->prod[port];
+
+ rte_event_crypto_adapter_queue_pair_del(
+ TEST_PERF_CA_ID, p->ca.cdev_id, p->ca.cdev_qp_id);
+ }
+
+ rte_event_crypto_adapter_free(TEST_PERF_CA_ID);
+
+ for (cdev_id = 0; cdev_id < cdev_count; cdev_id++)
+ rte_cryptodev_stop(cdev_id);
+
+ rte_mempool_free(t->ca_op_pool);
+ rte_mempool_free(t->ca_sess_pool);
+ rte_mempool_free(t->ca_sess_priv_pool);
+}
+
int
perf_mempool_setup(struct evt_test *test, struct evt_options *opt)
{
diff --git a/app/test-eventdev/test_perf_common.h b/app/test-eventdev/test_perf_common.h
index 14dcf80429..ea0907d61a 100644
--- a/app/test-eventdev/test_perf_common.h
+++ b/app/test-eventdev/test_perf_common.h
@@ -9,9 +9,11 @@
#include <stdbool.h>
#include <unistd.h>
+#include <rte_cryptodev.h>
#include <rte_cycles.h>
#include <rte_ethdev.h>
#include <rte_eventdev.h>
+#include <rte_event_crypto_adapter.h>
#include <rte_event_eth_rx_adapter.h>
#include <rte_event_timer_adapter.h>
#include <rte_lcore.h>
@@ -23,6 +25,8 @@
#include "evt_options.h"
#include "evt_test.h"
+#define TEST_PERF_CA_ID 0
+
struct test_perf;
struct worker_data {
@@ -33,14 +37,19 @@ struct worker_data {
struct test_perf *t;
} __rte_cache_aligned;
+struct crypto_adptr_data {
+ uint8_t cdev_id;
+ uint16_t cdev_qp_id;
+ struct rte_cryptodev_sym_session **crypto_sess;
+};
struct prod_data {
uint8_t dev_id;
uint8_t port_id;
uint8_t queue_id;
+ struct crypto_adptr_data ca;
struct test_perf *t;
} __rte_cache_aligned;
-
struct test_perf {
/* Don't change the offset of "done". Signal handler use this memory
* to terminate all lcores work.
@@ -58,6 +67,9 @@ struct test_perf {
uint8_t sched_type_list[EVT_MAX_STAGES] __rte_cache_aligned;
struct rte_event_timer_adapter *timer_adptr[
RTE_EVENT_TIMER_ADAPTER_NUM_MAX] __rte_cache_aligned;
+ struct rte_mempool *ca_op_pool;
+ struct rte_mempool *ca_sess_pool;
+ struct rte_mempool *ca_sess_priv_pool;
} __rte_cache_aligned;
struct perf_elt {
@@ -81,6 +93,8 @@ struct perf_elt {
const uint8_t port = w->port_id;\
const uint8_t prod_timer_type = \
opt->prod_type == EVT_PROD_TYPE_EVENT_TIMER_ADPTR;\
+ const uint8_t prod_crypto_type = \
+ opt->prod_type == EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR;\
uint8_t *const sched_type_list = &t->sched_type_list[0];\
struct rte_mempool *const pool = t->pool;\
const uint8_t nb_stages = t->opt->nb_stages;\
@@ -154,6 +168,7 @@ int perf_test_result(struct evt_test *test, struct evt_options *opt);
int perf_opt_check(struct evt_options *opt, uint64_t nb_queues);
int perf_test_setup(struct evt_test *test, struct evt_options *opt);
int perf_ethdev_setup(struct evt_test *test, struct evt_options *opt);
+int perf_cryptodev_setup(struct evt_test *test, struct evt_options *opt);
int perf_mempool_setup(struct evt_test *test, struct evt_options *opt);
int perf_event_dev_port_setup(struct evt_test *test, struct evt_options *opt,
uint8_t stride, uint8_t nb_queues,
@@ -164,6 +179,7 @@ int perf_launch_lcores(struct evt_test *test, struct evt_options *opt,
void perf_opt_dump(struct evt_options *opt, uint8_t nb_queues);
void perf_test_destroy(struct evt_test *test, struct evt_options *opt);
void perf_eventdev_destroy(struct evt_test *test, struct evt_options *opt);
+void perf_cryptodev_destroy(struct evt_test *test, struct evt_options *opt);
void perf_ethdev_destroy(struct evt_test *test, struct evt_options *opt);
void perf_mempool_destroy(struct evt_test *test, struct evt_options *opt);
diff --git a/app/test-eventdev/test_perf_queue.c b/app/test-eventdev/test_perf_queue.c
index f4ea3a795f..dcf6d82947 100644
--- a/app/test-eventdev/test_perf_queue.c
+++ b/app/test-eventdev/test_perf_queue.c
@@ -49,6 +49,23 @@ perf_queue_worker(void *arg, const int enable_fwd_latency)
rte_pause();
continue;
}
+
+ if (prod_crypto_type &&
+ (ev.event_type == RTE_EVENT_TYPE_CRYPTODEV)) {
+ struct rte_crypto_op *op = ev.event_ptr;
+
+ if (op->status == RTE_CRYPTO_OP_STATUS_SUCCESS) {
+ if (op->sym->m_dst == NULL)
+ ev.event_ptr = op->sym->m_src;
+ else
+ ev.event_ptr = op->sym->m_dst;
+ rte_crypto_op_free(op);
+ } else {
+ rte_crypto_op_free(op);
+ continue;
+ }
+ }
+
if (enable_fwd_latency && !prod_timer_type)
/* first q in pipeline, mark timestamp to compute fwd latency */
mark_fwd_latency(&ev, nb_stages);
@@ -88,6 +105,25 @@ perf_queue_worker_burst(void *arg, const int enable_fwd_latency)
}
for (i = 0; i < nb_rx; i++) {
+ if (prod_crypto_type &&
+ (ev[i].event_type == RTE_EVENT_TYPE_CRYPTODEV)) {
+ struct rte_crypto_op *op = ev[i].event_ptr;
+
+ if (op->status ==
+ RTE_CRYPTO_OP_STATUS_SUCCESS) {
+ if (op->sym->m_dst == NULL)
+ ev[i].event_ptr =
+ op->sym->m_src;
+ else
+ ev[i].event_ptr =
+ op->sym->m_dst;
+ rte_crypto_op_free(op);
+ } else {
+ rte_crypto_op_free(op);
+ continue;
+ }
+ }
+
if (enable_fwd_latency && !prod_timer_type) {
rte_prefetch0(ev[i+1].event_ptr);
/* first queue in pipeline.
@@ -269,6 +305,18 @@ perf_queue_eventdev_setup(struct evt_test *test, struct evt_options *opt)
return ret;
}
}
+ } else if (opt->prod_type == EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR) {
+ uint8_t cdev_id, cdev_count;
+
+ cdev_count = rte_cryptodev_count();
+ for (cdev_id = 0; cdev_id < cdev_count; cdev_id++) {
+ ret = rte_cryptodev_start(cdev_id);
+ if (ret) {
+ evt_err("Failed to start cryptodev %u",
+ cdev_id);
+ return ret;
+ }
+ }
}
return 0;
@@ -311,11 +359,13 @@ static const struct evt_test_ops perf_queue = {
.test_setup = perf_test_setup,
.mempool_setup = perf_mempool_setup,
.ethdev_setup = perf_ethdev_setup,
+ .cryptodev_setup = perf_cryptodev_setup,
.eventdev_setup = perf_queue_eventdev_setup,
.launch_lcores = perf_queue_launch_lcores,
.eventdev_destroy = perf_eventdev_destroy,
.mempool_destroy = perf_mempool_destroy,
.ethdev_destroy = perf_ethdev_destroy,
+ .cryptodev_destroy = perf_cryptodev_destroy,
.test_result = perf_test_result,
.test_destroy = perf_test_destroy,
};
diff --git a/doc/guides/tools/testeventdev.rst b/doc/guides/tools/testeventdev.rst
index 48efb9ea6e..f7d813226d 100644
--- a/doc/guides/tools/testeventdev.rst
+++ b/doc/guides/tools/testeventdev.rst
@@ -120,6 +120,10 @@ The following are the application command-line options:
Use burst mode event timer adapter as producer.
+* ``--prod_type_cryptodev``
+
+ Use crypto device as producer.
+
* ``--timer_tick_nsec``
Used to dictate number of nano seconds between bucket traversal of the
@@ -148,6 +152,11 @@ The following are the application command-line options:
timeout is out of the supported range of event device it will be
adjusted to the highest/lowest supported dequeue timeout supported.
+* ``--crypto_adptr_mode``
+
+ Set crypto adapter mode. Use 0 for OP_NEW (default) and 1 for
+ OP_FORWARD mode.
+
* ``--mbuf_sz``
Set packet mbuf size. Can be used to configure Jumbo Frames. Only
@@ -420,6 +429,7 @@ Supported application command line options are following::
--prod_type_ethdev
--prod_type_timerdev_burst
--prod_type_timerdev
+ --prod_type_cryptodev
--prod_enq_burst_sz
--timer_tick_nsec
--max_tmo_nsec
@@ -427,6 +437,7 @@ Supported application command line options are following::
--nb_timers
--nb_timer_adptrs
--deq_tmo_nsec
+ --crypto_adptr_mode
Example
^^^^^^^
@@ -529,12 +540,14 @@ Supported application command line options are following::
--prod_type_ethdev
--prod_type_timerdev_burst
--prod_type_timerdev
+ --prod_type_cryptodev
--timer_tick_nsec
--max_tmo_nsec
--expiry_nsec
--nb_timers
--nb_timer_adptrs
--deq_tmo_nsec
+ --crypto_adptr_mode
Example
^^^^^^^
--
2.25.1
^ permalink raw reply [flat|nested] 43+ messages in thread
* RE: [PATCH v5] app/eventdev: add crypto producer mode
2022-02-15 16:56 ` [PATCH v5] " Shijith Thotton
@ 2022-02-16 4:47 ` Gujjar, Abhinandan S
2022-02-16 7:08 ` Shijith Thotton
2022-02-17 6:56 ` [EXT] " Akhil Goyal
2022-02-18 12:11 ` [PATCH v6] " Shijith Thotton
2 siblings, 1 reply; 43+ messages in thread
From: Gujjar, Abhinandan S @ 2022-02-16 4:47 UTC (permalink / raw)
To: Shijith Thotton, dev, jerinj
Hi Shijith,
> -----Original Message-----
> From: Shijith Thotton <sthotton@marvell.com>
> Sent: Tuesday, February 15, 2022 10:27 PM
> To: dev@dpdk.org; jerinj@marvell.com
> Cc: Shijith Thotton <sthotton@marvell.com>; Gujjar, Abhinandan S
> <abhinandan.gujjar@intel.com>
> Subject: [PATCH v5] app/eventdev: add crypto producer mode
>
> In crypto producer mode, producer core enqueues cryptodev with software
> generated crypto ops and worker core dequeues crypto completion events
> from the eventdev. Event crypto metadata used for above processing is pre-
> populated in each crypto session.
>
> Parameter --prod_type_cryptodev can be used to enable crypto producer
> mode. Parameter --crypto_adptr_mode can be set to select the crypto
> adapter mode, 0 for OP_NEW and 1 for OP_FORWARD.
>
> This mode can be used to measure the performance of crypto adapter.
>
> Example:
> ./dpdk-test-eventdev -l 0-2 -w <EVENTDEV> -w <CRYPTODEV> -- \
> --prod_type_cryptodev --crypto_adptr_mode 1 --test=perf_atq \
> --stlist=a --wlcores 1 --plcores 2
>
I still see error with both OP_NEW and OP_FORWARD mode. Can't run the test.
root@xdp-dev:/home/intel/abhi/dpdk-next-eventdev/abhi# ./app/dpdk-test-eventdev -l 0-8 -s 0xf0 --vdev=event_sw0 --vdev="crypto_null" -- --prod_type_cryptodev --crypto_adptr_mode 1 --test=perf_queue --stlist=a --wlcores 1 --plcores 2
EAL: Detected CPU lcores: 96
EAL: Detected NUMA nodes: 2
EAL: Detected static linkage of DPDK
EAL: Multi-process socket /var/run/dpdk/rte/mp_socket
EAL: Selected IOVA mode 'PA'
EAL: VFIO support initialized
CRYPTODEV: Creating cryptodev crypto_null
CRYPTODEV: Initialisation parameters - name: crypto_null,socket id: 0, max queue pairs: 8
TELEMETRY: No legacy callbacks, legacy socket not created
driver : event_sw
test : perf_queue
dev : 0
verbose_level : 1
socket_id : -1
pool_sz : 16384
main lcore : 0
nb_pkts : 67108864
nb_timers : 100000000
available lcores : {0 1 2 3 8}
nb_flows : 1024
worker deq depth : 16
fwd_latency : false
nb_prod_lcores : 1
producer lcores : {2}
nb_worker_lcores : 1
worker lcores : {1}
nb_stages : 1
nb_evdev_ports : 2
nb_evdev_queues : 1
queue_priority : false
sched_type_list : {A}
crypto adapter mode : OP_FORWARD
nb_cryptodev : 1
prod_type : Event crypto adapter producers
prod_enq_burst_sz : 1
CRYPTODEV: elt_size 0 is expanded to 208
error: perf_event_crypto_adapter_setup() crypto adapter OP_FORWARD mode unsupported
error: main() perf_queue: eventdev setup failed
> Signed-off-by: Shijith Thotton <sthotton@marvell.com>
> ---
> v5:
> * Rebased.
>
> v4:
> * Addressed comments on v3 and rebased.
> * Added cryptodev cleanup in signal handler.
>
> v3:
> * Reduce dereference inside loop.
>
> v2:
> * Fix RHEL compilation warning.
>
> app/test-eventdev/evt_common.h | 3 +
> app/test-eventdev/evt_main.c | 17 +-
> app/test-eventdev/evt_options.c | 27 ++
> app/test-eventdev/evt_options.h | 12 +
> app/test-eventdev/evt_test.h | 6 +
> app/test-eventdev/test_perf_atq.c | 49 +++
> app/test-eventdev/test_perf_common.c | 425
> ++++++++++++++++++++++++++- app/test-eventdev/test_perf_common.h |
> 18 +- app/test-eventdev/test_perf_queue.c | 50 ++++
> doc/guides/tools/testeventdev.rst | 13 +
> 10 files changed, 612 insertions(+), 8 deletions(-)
>
> diff --git a/app/test-eventdev/evt_common.h b/app/test-
> eventdev/evt_common.h index f466434459..2f301a7e79 100644
> --- a/app/test-eventdev/evt_common.h
> +++ b/app/test-eventdev/evt_common.h
> @@ -7,6 +7,7 @@
>
> #include <rte_common.h>
> #include <rte_debug.h>
> +#include <rte_event_crypto_adapter.h>
> #include <rte_eventdev.h>
> #include <rte_service.h>
>
> @@ -39,6 +40,7 @@ enum evt_prod_type {
> EVT_PROD_TYPE_SYNT, /* Producer type Synthetic i.e. CPU. */
> EVT_PROD_TYPE_ETH_RX_ADPTR, /* Producer type Eth Rx Adapter.
> */
> EVT_PROD_TYPE_EVENT_TIMER_ADPTR, /* Producer type Timer
> Adapter. */
> + EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR, /* Producer type Crypto
> Adapter. */
> EVT_PROD_TYPE_MAX,
> };
>
> @@ -77,6 +79,7 @@ struct evt_options {
> uint64_t timer_tick_nsec;
> uint64_t optm_timer_tick_nsec;
> enum evt_prod_type prod_type;
> + enum rte_event_crypto_adapter_mode crypto_adptr_mode;
> };
>
> static inline bool
> diff --git a/app/test-eventdev/evt_main.c b/app/test-eventdev/evt_main.c
> index 194c980c7a..a7d6b0c1cf 100644
> --- a/app/test-eventdev/evt_main.c
> +++ b/app/test-eventdev/evt_main.c
> @@ -35,6 +35,9 @@ signal_handler(int signum)
> if (test->ops.ethdev_destroy)
> test->ops.ethdev_destroy(test, &opt);
>
> + if (test->ops.cryptodev_destroy)
> + test->ops.cryptodev_destroy(test, &opt);
> +
> rte_eal_mp_wait_lcore();
>
> if (test->ops.test_result)
> @@ -162,11 +165,19 @@ main(int argc, char **argv)
> }
> }
>
> + /* Test specific cryptodev setup */
> + if (test->ops.cryptodev_setup) {
> + if (test->ops.cryptodev_setup(test, &opt)) {
> + evt_err("%s: cryptodev setup failed",
> opt.test_name);
> + goto ethdev_destroy;
> + }
> + }
> +
> /* Test specific eventdev setup */
> if (test->ops.eventdev_setup) {
> if (test->ops.eventdev_setup(test, &opt)) {
> evt_err("%s: eventdev setup failed", opt.test_name);
> - goto ethdev_destroy;
> + goto cryptodev_destroy;
> }
> }
>
> @@ -197,6 +208,10 @@ main(int argc, char **argv)
> if (test->ops.eventdev_destroy)
> test->ops.eventdev_destroy(test, &opt);
>
> +cryptodev_destroy:
> + if (test->ops.cryptodev_destroy)
> + test->ops.cryptodev_destroy(test, &opt);
> +
> ethdev_destroy:
> if (test->ops.ethdev_destroy)
> test->ops.ethdev_destroy(test, &opt); diff --git a/app/test-
> eventdev/evt_options.c b/app/test-eventdev/evt_options.c index
> 4ae44801da..d3c704d2b3 100644
> --- a/app/test-eventdev/evt_options.c
> +++ b/app/test-eventdev/evt_options.c
> @@ -122,6 +122,26 @@ evt_parse_timer_prod_type_burst(struct
> evt_options *opt,
> return 0;
> }
>
> +static int
> +evt_parse_crypto_prod_type(struct evt_options *opt,
> + const char *arg __rte_unused)
> +{
> + opt->prod_type = EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR;
> + return 0;
> +}
> +
> +static int
> +evt_parse_crypto_adptr_mode(struct evt_options *opt, const char *arg) {
> + uint8_t mode;
> + int ret;
> +
> + ret = parser_read_uint8(&mode, arg);
> + opt->crypto_adptr_mode = mode ?
> RTE_EVENT_CRYPTO_ADAPTER_OP_FORWARD :
> +
> RTE_EVENT_CRYPTO_ADAPTER_OP_NEW;
> + return ret;
> +}
> +
> static int
> evt_parse_test_name(struct evt_options *opt, const char *arg) { @@ -335,6
> +355,7 @@ usage(char *program)
> "\t--queue_priority : enable queue priority\n"
> "\t--deq_tmo_nsec : global dequeue timeout\n"
> "\t--prod_type_ethdev : use ethernet device as producer.\n"
> + "\t--prod_type_cryptodev : use crypto device as
> producer.\n"
> "\t--prod_type_timerdev : use event timer device as
> producer.\n"
> "\t expiry_nsec would be the timeout\n"
> "\t in ns.\n"
> @@ -345,6 +366,8 @@ usage(char *program)
> "\t--timer_tick_nsec : timer tick interval in ns.\n"
> "\t--max_tmo_nsec : max timeout interval in ns.\n"
> "\t--expiry_nsec : event timer expiry ns.\n"
> + "\t--crypto_adptr_mode : 0 for OP_NEW mode (default)
> and\n"
> + "\t 1 for OP_FORWARD mode.\n"
> "\t--mbuf_sz : packet mbuf size.\n"
> "\t--max_pkt_sz : max packet size.\n"
> "\t--prod_enq_burst_sz : producer enqueue burst size.\n"
> @@ -415,8 +438,10 @@ static struct option lgopts[] = {
> { EVT_QUEUE_PRIORITY, 0, 0, 0 },
> { EVT_DEQ_TMO_NSEC, 1, 0, 0 },
> { EVT_PROD_ETHDEV, 0, 0, 0 },
> + { EVT_PROD_CRYPTODEV, 0, 0, 0 },
> { EVT_PROD_TIMERDEV, 0, 0, 0 },
> { EVT_PROD_TIMERDEV_BURST, 0, 0, 0 },
> + { EVT_CRYPTO_ADPTR_MODE, 1, 0, 0 },
> { EVT_NB_TIMERS, 1, 0, 0 },
> { EVT_NB_TIMER_ADPTRS, 1, 0, 0 },
> { EVT_TIMER_TICK_NSEC, 1, 0, 0 },
> @@ -455,8 +480,10 @@ evt_opts_parse_long(int opt_idx, struct evt_options
> *opt)
> { EVT_QUEUE_PRIORITY, evt_parse_queue_priority},
> { EVT_DEQ_TMO_NSEC, evt_parse_deq_tmo_nsec},
> { EVT_PROD_ETHDEV, evt_parse_eth_prod_type},
> + { EVT_PROD_CRYPTODEV, evt_parse_crypto_prod_type},
> { EVT_PROD_TIMERDEV, evt_parse_timer_prod_type},
> { EVT_PROD_TIMERDEV_BURST,
> evt_parse_timer_prod_type_burst},
> + { EVT_CRYPTO_ADPTR_MODE,
> evt_parse_crypto_adptr_mode},
> { EVT_NB_TIMERS, evt_parse_nb_timers},
> { EVT_NB_TIMER_ADPTRS, evt_parse_nb_timer_adptrs},
> { EVT_TIMER_TICK_NSEC, evt_parse_timer_tick_nsec}, diff --
> git a/app/test-eventdev/evt_options.h b/app/test-eventdev/evt_options.h
> index 413d7092f0..2231c58801 100644
> --- a/app/test-eventdev/evt_options.h
> +++ b/app/test-eventdev/evt_options.h
> @@ -9,6 +9,7 @@
> #include <stdbool.h>
>
> #include <rte_common.h>
> +#include <rte_cryptodev.h>
> #include <rte_ethdev.h>
> #include <rte_eventdev.h>
> #include <rte_lcore.h>
> @@ -33,8 +34,10 @@
> #define EVT_QUEUE_PRIORITY ("queue_priority")
> #define EVT_DEQ_TMO_NSEC ("deq_tmo_nsec")
> #define EVT_PROD_ETHDEV ("prod_type_ethdev")
> +#define EVT_PROD_CRYPTODEV ("prod_type_cryptodev")
> #define EVT_PROD_TIMERDEV ("prod_type_timerdev")
> #define EVT_PROD_TIMERDEV_BURST ("prod_type_timerdev_burst")
> +#define EVT_CRYPTO_ADPTR_MODE ("crypto_adptr_mode")
> #define EVT_NB_TIMERS ("nb_timers")
> #define EVT_NB_TIMER_ADPTRS ("nb_timer_adptrs")
> #define EVT_TIMER_TICK_NSEC ("timer_tick_nsec")
> @@ -249,6 +252,8 @@ evt_prod_id_to_name(enum evt_prod_type
> prod_type)
> return "Ethdev Rx Adapter";
> case EVT_PROD_TYPE_EVENT_TIMER_ADPTR:
> return "Event timer adapter";
> + case EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR:
> + return "Event crypto adapter";
> }
>
> return "";
> @@ -288,6 +293,13 @@ evt_dump_producer_type(struct evt_options *opt)
> evt_dump("timer_tick_nsec", "%"PRIu64"",
> opt->timer_tick_nsec);
> break;
> + case EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR:
> + snprintf(name, EVT_PROD_MAX_NAME_LEN,
> + "Event crypto adapter producers");
> + evt_dump("crypto adapter mode", "%s",
> + opt->crypto_adptr_mode ? "OP_FORWARD" :
> "OP_NEW");
> + evt_dump("nb_cryptodev", "%u", rte_cryptodev_count());
> + break;
> }
> evt_dump("prod_type", "%s", name);
> }
> diff --git a/app/test-eventdev/evt_test.h b/app/test-eventdev/evt_test.h
> index f07d2c3336..50fa474ec2 100644
> --- a/app/test-eventdev/evt_test.h
> +++ b/app/test-eventdev/evt_test.h
> @@ -29,6 +29,8 @@ typedef int (*evt_test_mempool_setup_t)
> (struct evt_test *test, struct evt_options *opt); typedef int
> (*evt_test_ethdev_setup_t)
> (struct evt_test *test, struct evt_options *opt);
> +typedef int (*evt_test_cryptodev_setup_t)
> + (struct evt_test *test, struct evt_options *opt);
> typedef int (*evt_test_eventdev_setup_t)
> (struct evt_test *test, struct evt_options *opt); typedef int
> (*evt_test_launch_lcores_t) @@ -39,6 +41,8 @@ typedef void
> (*evt_test_eventdev_destroy_t)
> (struct evt_test *test, struct evt_options *opt); typedef void
> (*evt_test_ethdev_destroy_t)
> (struct evt_test *test, struct evt_options *opt);
> +typedef void (*evt_test_cryptodev_destroy_t)
> + (struct evt_test *test, struct evt_options *opt);
> typedef void (*evt_test_mempool_destroy_t)
> (struct evt_test *test, struct evt_options *opt); typedef void
> (*evt_test_destroy_t) @@ -52,10 +56,12 @@ struct evt_test_ops {
> evt_test_mempool_setup_t mempool_setup;
> evt_test_ethdev_setup_t ethdev_setup;
> evt_test_eventdev_setup_t eventdev_setup;
> + evt_test_cryptodev_setup_t cryptodev_setup;
> evt_test_launch_lcores_t launch_lcores;
> evt_test_result_t test_result;
> evt_test_eventdev_destroy_t eventdev_destroy;
> evt_test_ethdev_destroy_t ethdev_destroy;
> + evt_test_cryptodev_destroy_t cryptodev_destroy;
> evt_test_mempool_destroy_t mempool_destroy;
> evt_test_destroy_t test_destroy;
> };
> diff --git a/app/test-eventdev/test_perf_atq.c b/app/test-
> eventdev/test_perf_atq.c
> index 8fd51004ee..67ff681666 100644
> --- a/app/test-eventdev/test_perf_atq.c
> +++ b/app/test-eventdev/test_perf_atq.c
> @@ -48,6 +48,22 @@ perf_atq_worker(void *arg, const int
> enable_fwd_latency)
> continue;
> }
>
> + if (prod_crypto_type &&
> + (ev.event_type == RTE_EVENT_TYPE_CRYPTODEV)) {
> + struct rte_crypto_op *op = ev.event_ptr;
> +
> + if (op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
> {
> + if (op->sym->m_dst == NULL)
> + ev.event_ptr = op->sym->m_src;
> + else
> + ev.event_ptr = op->sym->m_dst;
> + rte_crypto_op_free(op);
> + } else {
> + rte_crypto_op_free(op);
> + continue;
> + }
> + }
> +
> if (enable_fwd_latency && !prod_timer_type)
> /* first stage in pipeline, mark ts to compute fwd latency */
> atq_mark_fwd_latency(&ev);
> @@ -87,6 +103,25 @@ perf_atq_worker_burst(void *arg, const int
> enable_fwd_latency)
> }
>
> for (i = 0; i < nb_rx; i++) {
> + if (prod_crypto_type &&
> + (ev[i].event_type ==
> RTE_EVENT_TYPE_CRYPTODEV)) {
> + struct rte_crypto_op *op = ev[i].event_ptr;
> +
> + if (op->status ==
> + RTE_CRYPTO_OP_STATUS_SUCCESS) {
> + if (op->sym->m_dst == NULL)
> + ev[i].event_ptr =
> + op->sym->m_src;
> + else
> + ev[i].event_ptr =
> + op->sym->m_dst;
> + rte_crypto_op_free(op);
> + } else {
> + rte_crypto_op_free(op);
> + continue;
> + }
> + }
> +
> if (enable_fwd_latency && !prod_timer_type) {
> rte_prefetch0(ev[i+1].event_ptr);
> /* first stage in pipeline.
> @@ -254,6 +289,18 @@ perf_atq_eventdev_setup(struct evt_test *test,
> struct evt_options *opt)
> return ret;
> }
> }
> + } else if (opt->prod_type ==
> EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR) {
> + uint8_t cdev_id, cdev_count;
> +
> + cdev_count = rte_cryptodev_count();
> + for (cdev_id = 0; cdev_id < cdev_count; cdev_id++) {
> + ret = rte_cryptodev_start(cdev_id);
> + if (ret) {
> + evt_err("Failed to start cryptodev %u",
> + cdev_id);
> + return ret;
> + }
> + }
> }
>
> return 0;
> @@ -295,12 +342,14 @@ static const struct evt_test_ops perf_atq = {
> .opt_dump = perf_atq_opt_dump,
> .test_setup = perf_test_setup,
> .ethdev_setup = perf_ethdev_setup,
> + .cryptodev_setup = perf_cryptodev_setup,
> .mempool_setup = perf_mempool_setup,
> .eventdev_setup = perf_atq_eventdev_setup,
> .launch_lcores = perf_atq_launch_lcores,
> .eventdev_destroy = perf_eventdev_destroy,
> .mempool_destroy = perf_mempool_destroy,
> .ethdev_destroy = perf_ethdev_destroy,
> + .cryptodev_destroy = perf_cryptodev_destroy,
> .test_result = perf_test_result,
> .test_destroy = perf_test_destroy,
> };
> diff --git a/app/test-eventdev/test_perf_common.c b/app/test-
> eventdev/test_perf_common.c
> index 9b73874151..7d4eab9b8e 100644
> --- a/app/test-eventdev/test_perf_common.c
> +++ b/app/test-eventdev/test_perf_common.c
> @@ -6,6 +6,8 @@
>
> #include "test_perf_common.h"
>
> +#define NB_CRYPTODEV_DESCRIPTORS 128
> +
> int
> perf_test_result(struct evt_test *test, struct evt_options *opt) { @@ -272,6
> +274,123 @@ perf_event_timer_producer_burst(void *arg)
> return 0;
> }
>
> +static inline void
> +crypto_adapter_enq_op_new(struct prod_data *p) {
> + struct rte_cryptodev_sym_session **crypto_sess = p-
> >ca.crypto_sess;
> + struct test_perf *t = p->t;
> + const uint32_t nb_flows = t->nb_flows;
> + const uint64_t nb_pkts = t->nb_pkts;
> + struct rte_mempool *pool = t->pool;
> + struct rte_crypto_sym_op *sym_op;
> + struct evt_options *opt = t->opt;
> + uint16_t qp_id = p->ca.cdev_qp_id;
> + uint8_t cdev_id = p->ca.cdev_id;
> + uint32_t flow_counter = 0;
> + struct rte_crypto_op *op;
> + struct rte_mbuf *m;
> + uint64_t count = 0;
> + uint16_t len;
> +
> + if (opt->verbose_level > 1)
> + printf("%s(): lcore %d queue %d cdev_id %u cdev_qp_id
> %u\n",
> + __func__, rte_lcore_id(), p->queue_id, p->ca.cdev_id,
> + p->ca.cdev_qp_id);
> +
> + len = opt->mbuf_sz ? opt->mbuf_sz : RTE_ETHER_MIN_LEN;
> +
> + while (count < nb_pkts && t->done == false) {
> + m = rte_pktmbuf_alloc(pool);
> + if (m == NULL)
> + continue;
> +
> + rte_pktmbuf_append(m, len);
> + op = rte_crypto_op_alloc(t->ca_op_pool,
> +
> RTE_CRYPTO_OP_TYPE_SYMMETRIC);
> + sym_op = op->sym;
> + sym_op->m_src = m;
> + sym_op->cipher.data.offset = 0;
> + sym_op->cipher.data.length = len;
> + rte_crypto_op_attach_sym_session(
> + op, crypto_sess[flow_counter++ % nb_flows]);
> +
> + while (rte_cryptodev_enqueue_burst(cdev_id, qp_id, &op,
> 1) != 1 &&
> + t->done == false)
> + rte_pause();
> +
> + count++;
> + }
> +}
> +
> +static inline void
> +crypto_adapter_enq_op_fwd(struct prod_data *p) {
> + struct rte_cryptodev_sym_session **crypto_sess = p-
> >ca.crypto_sess;
> + const uint8_t dev_id = p->dev_id;
> + const uint8_t port = p->port_id;
> + struct test_perf *t = p->t;
> + const uint32_t nb_flows = t->nb_flows;
> + const uint64_t nb_pkts = t->nb_pkts;
> + struct rte_mempool *pool = t->pool;
> + struct evt_options *opt = t->opt;
> + struct rte_crypto_sym_op *sym_op;
> + uint32_t flow_counter = 0;
> + struct rte_crypto_op *op;
> + struct rte_event ev;
> + struct rte_mbuf *m;
> + uint64_t count = 0;
> + uint16_t len;
> +
> + if (opt->verbose_level > 1)
> + printf("%s(): lcore %d port %d queue %d cdev_id %u
> cdev_qp_id %u\n",
> + __func__, rte_lcore_id(), port, p->queue_id,
> + p->ca.cdev_id, p->ca.cdev_qp_id);
> +
> + ev.event = 0;
> + ev.op = RTE_EVENT_OP_FORWARD;
> + ev.queue_id = p->queue_id;
> + ev.sched_type = RTE_SCHED_TYPE_ATOMIC;
> + ev.event_type = RTE_EVENT_TYPE_CPU;
> + len = opt->mbuf_sz ? opt->mbuf_sz : RTE_ETHER_MIN_LEN;
> +
> + while (count < nb_pkts && t->done == false) {
> + m = rte_pktmbuf_alloc(pool);
> + if (m == NULL)
> + continue;
> +
> + rte_pktmbuf_append(m, len);
> + op = rte_crypto_op_alloc(t->ca_op_pool,
> +
> RTE_CRYPTO_OP_TYPE_SYMMETRIC);
> + sym_op = op->sym;
> + sym_op->m_src = m;
> + sym_op->cipher.data.offset = 0;
> + sym_op->cipher.data.length = len;
> + rte_crypto_op_attach_sym_session(
> + op, crypto_sess[flow_counter++ % nb_flows]);
> + ev.event_ptr = op;
> +
> + while (rte_event_crypto_adapter_enqueue(dev_id, port,
> &ev, 1) != 1 &&
> + t->done == false)
> + rte_pause();
> +
> + count++;
> + }
> +}
> +
> +static inline int
> +perf_event_crypto_producer(void *arg)
> +{
> + struct prod_data *p = arg;
> + struct evt_options *opt = p->t->opt;
> +
> + if (opt->crypto_adptr_mode ==
> RTE_EVENT_CRYPTO_ADAPTER_OP_NEW)
> + crypto_adapter_enq_op_new(p);
> + else
> + crypto_adapter_enq_op_fwd(p);
> +
> + return 0;
> +}
> +
> static int
> perf_producer_wrapper(void *arg)
> {
> @@ -298,6 +417,8 @@ perf_producer_wrapper(void *arg)
> else if (t->opt->prod_type ==
> EVT_PROD_TYPE_EVENT_TIMER_ADPTR &&
> t->opt->timdev_use_burst)
> return perf_event_timer_producer_burst(arg);
> + else if (t->opt->prod_type ==
> EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR)
> + return perf_event_crypto_producer(arg);
> return 0;
> }
>
> @@ -405,8 +526,10 @@ perf_launch_lcores(struct evt_test *test, struct
> evt_options *opt,
> if (remaining <= 0) {
> t->result = EVT_TEST_SUCCESS;
> if (opt->prod_type == EVT_PROD_TYPE_SYNT
> ||
> - opt->prod_type ==
> -
> EVT_PROD_TYPE_EVENT_TIMER_ADPTR) {
> + opt->prod_type ==
> +
> EVT_PROD_TYPE_EVENT_TIMER_ADPTR ||
> + opt->prod_type ==
> +
> EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR) {
> t->done = true;
> break;
> }
> @@ -415,7 +538,8 @@ perf_launch_lcores(struct evt_test *test, struct
> evt_options *opt,
>
> if (new_cycles - dead_lock_cycles > dead_lock_sample &&
> (opt->prod_type == EVT_PROD_TYPE_SYNT ||
> - opt->prod_type ==
> EVT_PROD_TYPE_EVENT_TIMER_ADPTR)) {
> + opt->prod_type ==
> EVT_PROD_TYPE_EVENT_TIMER_ADPTR ||
> + opt->prod_type ==
> EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR)) {
> remaining = t->outstand_pkts - processed_pkts(t);
> if (dead_lock_remaining == remaining) {
> rte_event_dev_dump(opt->dev_id, stdout);
> @@ -537,6 +661,80 @@ perf_event_timer_adapter_setup(struct test_perf
> *t)
> return 0;
> }
>
> +static int
> +perf_event_crypto_adapter_setup(struct test_perf *t, struct prod_data
> +*p) {
> + struct evt_options *opt = t->opt;
> + uint32_t cap;
> + int ret;
> +
> + ret = rte_event_crypto_adapter_caps_get(p->dev_id, p->ca.cdev_id,
> &cap);
> + if (ret) {
> + evt_err("Failed to get crypto adapter capabilities");
> + return ret;
> + }
> +
> + if (((opt->crypto_adptr_mode ==
> RTE_EVENT_CRYPTO_ADAPTER_OP_NEW) &&
> + !(cap &
> RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_OP_NEW)) ||
> + ((opt->crypto_adptr_mode ==
> RTE_EVENT_CRYPTO_ADAPTER_OP_FORWARD) &&
> + !(cap &
> RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_OP_FWD))) {
> + evt_err("crypto adapter %s mode unsupported\n",
> + opt->crypto_adptr_mode ? "OP_FORWARD" :
> "OP_NEW");
> + return -EINVAL;
> + } else if (!(cap &
> RTE_EVENT_CRYPTO_ADAPTER_CAP_SESSION_PRIVATE_DATA)) {
> + evt_err("Storing crypto session not supported");
> + return -EINVAL;
> + }
> +
> + if (cap &
> RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_QP_EV_BIND) {
> + struct rte_event response_info;
> +
> + response_info.event = 0;
> + response_info.op =
> + opt->crypto_adptr_mode ==
> +
> RTE_EVENT_CRYPTO_ADAPTER_OP_NEW ?
> + RTE_EVENT_OP_NEW :
> + RTE_EVENT_OP_FORWARD;
> + response_info.sched_type = RTE_SCHED_TYPE_ATOMIC;
> + response_info.event_type = RTE_EVENT_TYPE_CRYPTODEV;
> + response_info.queue_id = p->queue_id;
> + ret = rte_event_crypto_adapter_queue_pair_add(
> + TEST_PERF_CA_ID, p->ca.cdev_id, p->ca.cdev_qp_id,
> + &response_info);
> + } else {
> + ret = rte_event_crypto_adapter_queue_pair_add(
> + TEST_PERF_CA_ID, p->ca.cdev_id, p->ca.cdev_qp_id,
> NULL);
> + }
> +
> + return ret;
> +}
> +
> +static struct rte_cryptodev_sym_session *
> +cryptodev_sym_sess_create(struct prod_data *p, struct test_perf *t) {
> + struct rte_crypto_sym_xform cipher_xform;
> + struct rte_cryptodev_sym_session *sess;
> +
> + cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
> + cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
> + cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
> + cipher_xform.next = NULL;
> +
> + sess = rte_cryptodev_sym_session_create(t->ca_sess_pool);
> + if (sess == NULL) {
> + evt_err("Failed to create sym session");
> + return NULL;
> + }
> +
> + if (rte_cryptodev_sym_session_init(p->ca.cdev_id, sess,
> &cipher_xform,
> + t->ca_sess_priv_pool)) {
> + evt_err("Failed to init session");
> + return NULL;
> + }
> +
> + return sess;
> +}
> +
> int
> perf_event_dev_port_setup(struct evt_test *test, struct evt_options *opt,
> uint8_t stride, uint8_t nb_queues,
> @@ -598,6 +796,80 @@ perf_event_dev_port_setup(struct evt_test *test,
> struct evt_options *opt,
> ret = perf_event_timer_adapter_setup(t);
> if (ret)
> return ret;
> + } else if (opt->prod_type ==
> EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR) {
> + struct rte_event_port_conf conf = *port_conf;
> + uint8_t cdev_id = 0;
> + uint16_t qp_id = 0;
> +
> + ret = rte_event_crypto_adapter_create(TEST_PERF_CA_ID,
> + opt->dev_id, &conf, 0);
> + if (ret) {
> + evt_err("Failed to create crypto adapter");
> + return ret;
> + }
> +
> + prod = 0;
> + for (; port < perf_nb_event_ports(opt); port++) {
> + struct rte_cryptodev_sym_session *crypto_sess;
> + union rte_event_crypto_metadata m_data;
> + struct prod_data *p = &t->prod[port];
> + uint32_t flow_id;
> +
> + if (qp_id ==
> rte_cryptodev_queue_pair_count(cdev_id)) {
> + cdev_id++;
> + qp_id = 0;
> + }
> +
> + p->dev_id = opt->dev_id;
> + p->port_id = port;
> + p->queue_id = prod * stride;
> + p->ca.cdev_id = cdev_id;
> + p->ca.cdev_qp_id = qp_id;
> + p->ca.crypto_sess = rte_zmalloc_socket(
> + NULL, sizeof(crypto_sess) * t->nb_flows,
> + RTE_CACHE_LINE_SIZE, opt->socket_id);
> + p->t = t;
> +
> + m_data.request_info.cdev_id = p->ca.cdev_id;
> + m_data.request_info.queue_pair_id = p-
> >ca.cdev_qp_id;
> + m_data.response_info.op =
> + opt->crypto_adptr_mode ==
> +
> RTE_EVENT_CRYPTO_ADAPTER_OP_NEW ?
> + RTE_EVENT_OP_NEW :
> + RTE_EVENT_OP_FORWARD;
> + m_data.response_info.sched_type =
> RTE_SCHED_TYPE_ATOMIC;
> + m_data.response_info.event_type =
> + RTE_EVENT_TYPE_CRYPTODEV;
> + m_data.response_info.queue_id = p->queue_id;
> +
> + for (flow_id = 0; flow_id < t->nb_flows; flow_id++) {
> + crypto_sess = cryptodev_sym_sess_create(p,
> t);
> + if (crypto_sess == NULL)
> + return -ENOMEM;
> +
> + m_data.response_info.flow_id = flow_id;
> + rte_cryptodev_sym_session_set_user_data(
> + crypto_sess, &m_data,
> sizeof(m_data));
> + p->ca.crypto_sess[flow_id] = crypto_sess;
> + }
> +
> + conf.event_port_cfg |=
> + RTE_EVENT_PORT_CFG_HINT_PRODUCER |
> + RTE_EVENT_PORT_CFG_HINT_CONSUMER;
> +
> + ret = rte_event_port_setup(opt->dev_id, port,
> &conf);
> + if (ret) {
> + evt_err("failed to setup port %d", port);
> + return ret;
> + }
> +
> + ret = perf_event_crypto_adapter_setup(t, p);
> + if (ret)
> + return ret;
> +
> + qp_id++;
> + prod++;
> + }
> } else {
> prod = 0;
> for ( ; port < perf_nb_event_ports(opt); port++) { @@ -659,7
> +931,8 @@ perf_opt_check(struct evt_options *opt, uint64_t nb_queues)
> }
>
> if (opt->prod_type == EVT_PROD_TYPE_SYNT ||
> - opt->prod_type ==
> EVT_PROD_TYPE_EVENT_TIMER_ADPTR) {
> + opt->prod_type == EVT_PROD_TYPE_EVENT_TIMER_ADPTR ||
> + opt->prod_type == EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR) {
> /* Validate producer lcores */
> if (evt_lcores_has_overlap(opt->plcores,
> rte_get_main_lcore())) {
> @@ -767,8 +1040,7 @@ perf_ethdev_setup(struct evt_test *test, struct
> evt_options *opt)
> },
> };
>
> - if (opt->prod_type == EVT_PROD_TYPE_SYNT ||
> - opt->prod_type ==
> EVT_PROD_TYPE_EVENT_TIMER_ADPTR)
> + if (opt->prod_type != EVT_PROD_TYPE_ETH_RX_ADPTR)
> return 0;
>
> if (!rte_eth_dev_count_avail()) {
> @@ -841,6 +1113,147 @@ void perf_ethdev_destroy(struct evt_test *test,
> struct evt_options *opt)
> }
> }
>
> +int
> +perf_cryptodev_setup(struct evt_test *test, struct evt_options *opt) {
> + uint8_t cdev_count, cdev_id, nb_plcores, nb_qps;
> + struct test_perf *t = evt_test_priv(test);
> + unsigned int max_session_size;
> + uint32_t nb_sessions;
> + int ret;
> +
> + if (opt->prod_type != EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR)
> + return 0;
> +
> + cdev_count = rte_cryptodev_count();
> + if (cdev_count == 0) {
> + evt_err("No crypto devices available\n");
> + return -ENODEV;
> + }
> +
> + t->ca_op_pool = rte_crypto_op_pool_create(
> + "crypto_op_pool", RTE_CRYPTO_OP_TYPE_SYMMETRIC,
> opt->pool_sz,
> + 128, 0, rte_socket_id());
> + if (t->ca_op_pool == NULL) {
> + evt_err("Failed to create crypto op pool");
> + return -ENOMEM;
> + }
> +
> + nb_sessions = evt_nr_active_lcores(opt->plcores) * t->nb_flows;
> + t->ca_sess_pool = rte_cryptodev_sym_session_pool_create(
> + "ca_sess_pool", nb_sessions, 0, 0,
> + sizeof(union rte_event_crypto_metadata),
> SOCKET_ID_ANY);
> + if (t->ca_sess_pool == NULL) {
> + evt_err("Failed to create sym session pool");
> + ret = -ENOMEM;
> + goto err;
> + }
> +
> + max_session_size = 0;
> + for (cdev_id = 0; cdev_id < cdev_count; cdev_id++) {
> + unsigned int session_size;
> +
> + session_size =
> +
> rte_cryptodev_sym_get_private_session_size(cdev_id);
> + if (session_size > max_session_size)
> + max_session_size = session_size;
> + }
> +
> + max_session_size += sizeof(union rte_event_crypto_metadata);
> + t->ca_sess_priv_pool = rte_mempool_create(
> + "ca_sess_priv_pool", nb_sessions, max_session_size, 0, 0,
> NULL,
> + NULL, NULL, NULL, SOCKET_ID_ANY, 0);
> + if (t->ca_sess_priv_pool == NULL) {
> + evt_err("failed to create sym session private pool");
> + ret = -ENOMEM;
> + goto err;
> + }
> +
> + /*
> + * Calculate number of needed queue pairs, based on the amount of
> + * available number of logical cores and crypto devices. For instance,
> + * if there are 4 cores and 2 crypto devices, 2 queue pairs will be set
> + * up per device.
> + */
> + nb_plcores = evt_nr_active_lcores(opt->plcores);
> + nb_qps = (nb_plcores % cdev_count) ? (nb_plcores / cdev_count) + 1
> :
> + nb_plcores / cdev_count;
> + for (cdev_id = 0; cdev_id < cdev_count; cdev_id++) {
> + struct rte_cryptodev_qp_conf qp_conf;
> + struct rte_cryptodev_config conf;
> + struct rte_cryptodev_info info;
> + int qp_id;
> +
> + rte_cryptodev_info_get(cdev_id, &info);
> + if (nb_qps > info.max_nb_queue_pairs) {
> + evt_err("Not enough queue pairs per cryptodev
> (%u)",
> + nb_qps);
> + ret = -EINVAL;
> + goto err;
> + }
> +
> + conf.nb_queue_pairs = nb_qps;
> + conf.socket_id = SOCKET_ID_ANY;
> + conf.ff_disable = RTE_CRYPTODEV_FF_SECURITY;
> +
> + ret = rte_cryptodev_configure(cdev_id, &conf);
> + if (ret) {
> + evt_err("Failed to configure cryptodev (%u)",
> cdev_id);
> + goto err;
> + }
> +
> + qp_conf.nb_descriptors = NB_CRYPTODEV_DESCRIPTORS;
> + qp_conf.mp_session = t->ca_sess_pool;
> + qp_conf.mp_session_private = t->ca_sess_priv_pool;
> +
> + for (qp_id = 0; qp_id < conf.nb_queue_pairs; qp_id++) {
> + ret = rte_cryptodev_queue_pair_setup(
> + cdev_id, qp_id, &qp_conf,
> + rte_cryptodev_socket_id(cdev_id));
> + if (ret) {
> + evt_err("Failed to setup queue pairs on
> cryptodev %u\n",
> + cdev_id);
> + goto err;
> + }
> + }
> + }
> +
> + return 0;
> +err:
> + rte_mempool_free(t->ca_op_pool);
> + rte_mempool_free(t->ca_sess_pool);
> + rte_mempool_free(t->ca_sess_priv_pool);
> +
> + return ret;
> +}
> +
> +void
> +perf_cryptodev_destroy(struct evt_test *test, struct evt_options *opt)
> +{
> + uint8_t cdev_id, cdev_count = rte_cryptodev_count();
> + struct test_perf *t = evt_test_priv(test);
> + uint16_t port;
> +
> + if (opt->prod_type != EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR)
> + return;
> +
> + for (port = t->nb_workers; port < perf_nb_event_ports(opt); port++) {
> + struct prod_data *p = &t->prod[port];
> +
> + rte_event_crypto_adapter_queue_pair_del(
> + TEST_PERF_CA_ID, p->ca.cdev_id, p-
> >ca.cdev_qp_id);
> + }
> +
> + rte_event_crypto_adapter_free(TEST_PERF_CA_ID);
> +
> + for (cdev_id = 0; cdev_id < cdev_count; cdev_id++)
> + rte_cryptodev_stop(cdev_id);
> +
> + rte_mempool_free(t->ca_op_pool);
> + rte_mempool_free(t->ca_sess_pool);
> + rte_mempool_free(t->ca_sess_priv_pool);
> +}
> +
> int
> perf_mempool_setup(struct evt_test *test, struct evt_options *opt) { diff --
> git a/app/test-eventdev/test_perf_common.h b/app/test-
> eventdev/test_perf_common.h
> index 14dcf80429..ea0907d61a 100644
> --- a/app/test-eventdev/test_perf_common.h
> +++ b/app/test-eventdev/test_perf_common.h
> @@ -9,9 +9,11 @@
> #include <stdbool.h>
> #include <unistd.h>
>
> +#include <rte_cryptodev.h>
> #include <rte_cycles.h>
> #include <rte_ethdev.h>
> #include <rte_eventdev.h>
> +#include <rte_event_crypto_adapter.h>
> #include <rte_event_eth_rx_adapter.h>
> #include <rte_event_timer_adapter.h>
> #include <rte_lcore.h>
> @@ -23,6 +25,8 @@
> #include "evt_options.h"
> #include "evt_test.h"
>
> +#define TEST_PERF_CA_ID 0
> +
> struct test_perf;
>
> struct worker_data {
> @@ -33,14 +37,19 @@ struct worker_data {
> struct test_perf *t;
> } __rte_cache_aligned;
>
> +struct crypto_adptr_data {
> + uint8_t cdev_id;
> + uint16_t cdev_qp_id;
> + struct rte_cryptodev_sym_session **crypto_sess; };
> struct prod_data {
> uint8_t dev_id;
> uint8_t port_id;
> uint8_t queue_id;
> + struct crypto_adptr_data ca;
> struct test_perf *t;
> } __rte_cache_aligned;
>
> -
> struct test_perf {
> /* Don't change the offset of "done". Signal handler use this memory
> * to terminate all lcores work.
> @@ -58,6 +67,9 @@ struct test_perf {
> uint8_t sched_type_list[EVT_MAX_STAGES] __rte_cache_aligned;
> struct rte_event_timer_adapter *timer_adptr[
> RTE_EVENT_TIMER_ADAPTER_NUM_MAX]
> __rte_cache_aligned;
> + struct rte_mempool *ca_op_pool;
> + struct rte_mempool *ca_sess_pool;
> + struct rte_mempool *ca_sess_priv_pool;
> } __rte_cache_aligned;
>
> struct perf_elt {
> @@ -81,6 +93,8 @@ struct perf_elt {
> const uint8_t port = w->port_id;\
> const uint8_t prod_timer_type = \
> opt->prod_type ==
> EVT_PROD_TYPE_EVENT_TIMER_ADPTR;\
> + const uint8_t prod_crypto_type = \
> + opt->prod_type ==
> EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR;\
> uint8_t *const sched_type_list = &t->sched_type_list[0];\
> struct rte_mempool *const pool = t->pool;\
> const uint8_t nb_stages = t->opt->nb_stages;\ @@ -154,6 +168,7
> @@ int perf_test_result(struct evt_test *test, struct evt_options *opt); int
> perf_opt_check(struct evt_options *opt, uint64_t nb_queues); int
> perf_test_setup(struct evt_test *test, struct evt_options *opt); int
> perf_ethdev_setup(struct evt_test *test, struct evt_options *opt);
> +int perf_cryptodev_setup(struct evt_test *test, struct evt_options
> +*opt);
> int perf_mempool_setup(struct evt_test *test, struct evt_options *opt); int
> perf_event_dev_port_setup(struct evt_test *test, struct evt_options *opt,
> uint8_t stride, uint8_t nb_queues,
> @@ -164,6 +179,7 @@ int perf_launch_lcores(struct evt_test *test, struct
> evt_options *opt, void perf_opt_dump(struct evt_options *opt, uint8_t
> nb_queues); void perf_test_destroy(struct evt_test *test, struct evt_options
> *opt); void perf_eventdev_destroy(struct evt_test *test, struct evt_options
> *opt);
> +void perf_cryptodev_destroy(struct evt_test *test, struct evt_options
> +*opt);
> void perf_ethdev_destroy(struct evt_test *test, struct evt_options *opt);
> void perf_mempool_destroy(struct evt_test *test, struct evt_options *opt);
>
> diff --git a/app/test-eventdev/test_perf_queue.c b/app/test-
> eventdev/test_perf_queue.c
> index f4ea3a795f..dcf6d82947 100644
> --- a/app/test-eventdev/test_perf_queue.c
> +++ b/app/test-eventdev/test_perf_queue.c
> @@ -49,6 +49,23 @@ perf_queue_worker(void *arg, const int
> enable_fwd_latency)
> rte_pause();
> continue;
> }
> +
> + if (prod_crypto_type &&
> + (ev.event_type == RTE_EVENT_TYPE_CRYPTODEV)) {
> + struct rte_crypto_op *op = ev.event_ptr;
> +
> + if (op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
> {
> + if (op->sym->m_dst == NULL)
> + ev.event_ptr = op->sym->m_src;
> + else
> + ev.event_ptr = op->sym->m_dst;
> + rte_crypto_op_free(op);
> + } else {
> + rte_crypto_op_free(op);
> + continue;
> + }
> + }
> +
> if (enable_fwd_latency && !prod_timer_type)
> /* first q in pipeline, mark timestamp to compute fwd
> latency */
> mark_fwd_latency(&ev, nb_stages);
> @@ -88,6 +105,25 @@ perf_queue_worker_burst(void *arg, const int
> enable_fwd_latency)
> }
>
> for (i = 0; i < nb_rx; i++) {
> + if (prod_crypto_type &&
> + (ev[i].event_type ==
> RTE_EVENT_TYPE_CRYPTODEV)) {
> + struct rte_crypto_op *op = ev[i].event_ptr;
> +
> + if (op->status ==
> + RTE_CRYPTO_OP_STATUS_SUCCESS) {
> + if (op->sym->m_dst == NULL)
> + ev[i].event_ptr =
> + op->sym->m_src;
> + else
> + ev[i].event_ptr =
> + op->sym->m_dst;
> + rte_crypto_op_free(op);
> + } else {
> + rte_crypto_op_free(op);
> + continue;
> + }
> + }
> +
> if (enable_fwd_latency && !prod_timer_type) {
> rte_prefetch0(ev[i+1].event_ptr);
> /* first queue in pipeline.
> @@ -269,6 +305,18 @@ perf_queue_eventdev_setup(struct evt_test *test,
> struct evt_options *opt)
> return ret;
> }
> }
> + } else if (opt->prod_type ==
> EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR) {
> + uint8_t cdev_id, cdev_count;
> +
> + cdev_count = rte_cryptodev_count();
> + for (cdev_id = 0; cdev_id < cdev_count; cdev_id++) {
> + ret = rte_cryptodev_start(cdev_id);
> + if (ret) {
> + evt_err("Failed to start cryptodev %u",
> + cdev_id);
> + return ret;
> + }
> + }
> }
>
> return 0;
> @@ -311,11 +359,13 @@ static const struct evt_test_ops perf_queue = {
> .test_setup = perf_test_setup,
> .mempool_setup = perf_mempool_setup,
> .ethdev_setup = perf_ethdev_setup,
> + .cryptodev_setup = perf_cryptodev_setup,
> .eventdev_setup = perf_queue_eventdev_setup,
> .launch_lcores = perf_queue_launch_lcores,
> .eventdev_destroy = perf_eventdev_destroy,
> .mempool_destroy = perf_mempool_destroy,
> .ethdev_destroy = perf_ethdev_destroy,
> + .cryptodev_destroy = perf_cryptodev_destroy,
> .test_result = perf_test_result,
> .test_destroy = perf_test_destroy,
> };
> diff --git a/doc/guides/tools/testeventdev.rst
> b/doc/guides/tools/testeventdev.rst
> index 48efb9ea6e..f7d813226d 100644
> --- a/doc/guides/tools/testeventdev.rst
> +++ b/doc/guides/tools/testeventdev.rst
> @@ -120,6 +120,10 @@ The following are the application command-line
> options:
>
> Use burst mode event timer adapter as producer.
>
> +* ``--prod_type_cryptodev``
> +
> + Use crypto device as producer.
> +
> * ``--timer_tick_nsec``
>
> Used to dictate number of nano seconds between bucket traversal of
> the @@ -148,6 +152,11 @@ The following are the application command-
> line options:
> timeout is out of the supported range of event device it will be
> adjusted to the highest/lowest supported dequeue timeout supported.
>
> +* ``--crypto_adptr_mode``
> +
> + Set crypto adapter mode. Use 0 for OP_NEW (default) and 1 for
> + OP_FORWARD mode.
> +
> * ``--mbuf_sz``
>
> Set packet mbuf size. Can be used to configure Jumbo Frames. Only @@
> -420,6 +429,7 @@ Supported application command line options are
> following::
> --prod_type_ethdev
> --prod_type_timerdev_burst
> --prod_type_timerdev
> + --prod_type_cryptodev
> --prod_enq_burst_sz
> --timer_tick_nsec
> --max_tmo_nsec
> @@ -427,6 +437,7 @@ Supported application command line options are
> following::
> --nb_timers
> --nb_timer_adptrs
> --deq_tmo_nsec
> + --crypto_adptr_mode
>
> Example
> ^^^^^^^
> @@ -529,12 +540,14 @@ Supported application command line options are
> following::
> --prod_type_ethdev
> --prod_type_timerdev_burst
> --prod_type_timerdev
> + --prod_type_cryptodev
> --timer_tick_nsec
> --max_tmo_nsec
> --expiry_nsec
> --nb_timers
> --nb_timer_adptrs
> --deq_tmo_nsec
> + --crypto_adptr_mode
>
> Example
> ^^^^^^^
> --
> 2.25.1
^ permalink raw reply [flat|nested] 43+ messages in thread
* RE: [PATCH v5] app/eventdev: add crypto producer mode
2022-02-16 4:47 ` Gujjar, Abhinandan S
@ 2022-02-16 7:08 ` Shijith Thotton
2022-02-16 7:49 ` Gujjar, Abhinandan S
0 siblings, 1 reply; 43+ messages in thread
From: Shijith Thotton @ 2022-02-16 7:08 UTC (permalink / raw)
To: Gujjar, Abhinandan S; +Cc: Jerin Jacob Kollanukkaran, dev
>>
>> In crypto producer mode, producer core enqueues cryptodev with software
>> generated crypto ops and worker core dequeues crypto completion events
>> from the eventdev. Event crypto metadata used for above processing is pre-
>> populated in each crypto session.
>>
>> Parameter --prod_type_cryptodev can be used to enable crypto producer
>> mode. Parameter --crypto_adptr_mode can be set to select the crypto
>> adapter mode, 0 for OP_NEW and 1 for OP_FORWARD.
>>
>> This mode can be used to measure the performance of crypto adapter.
>>
>> Example:
>> ./dpdk-test-eventdev -l 0-2 -w <EVENTDEV> -w <CRYPTODEV> -- \
>> --prod_type_cryptodev --crypto_adptr_mode 1 --test=perf_atq \
>> --stlist=a --wlcores 1 --plcores 2
>>
>I still see error with both OP_NEW and OP_FORWARD mode. Can't run the test.
>root@xdp-dev:/home/intel/abhi/dpdk-next-eventdev/abhi# ./app/dpdk-test-
>eventdev -l 0-8 -s 0xf0 --vdev=event_sw0 --vdev="crypto_null" -- --
>prod_type_cryptodev --crypto_adptr_mode 1 --test=perf_queue --stlist=a --
>wlcores 1 --plcores 2
>EAL: Detected CPU lcores: 96
>EAL: Detected NUMA nodes: 2
>EAL: Detected static linkage of DPDK
>EAL: Multi-process socket /var/run/dpdk/rte/mp_socket
>EAL: Selected IOVA mode 'PA'
>EAL: VFIO support initialized
>CRYPTODEV: Creating cryptodev crypto_null
>
>CRYPTODEV: Initialisation parameters - name: crypto_null,socket id: 0, max queue
>pairs: 8
>TELEMETRY: No legacy callbacks, legacy socket not created
> driver : event_sw
> test : perf_queue
> dev : 0
> verbose_level : 1
> socket_id : -1
> pool_sz : 16384
> main lcore : 0
> nb_pkts : 67108864
> nb_timers : 100000000
> available lcores : {0 1 2 3 8}
> nb_flows : 1024
> worker deq depth : 16
> fwd_latency : false
> nb_prod_lcores : 1
> producer lcores : {2}
> nb_worker_lcores : 1
> worker lcores : {1}
> nb_stages : 1
> nb_evdev_ports : 2
> nb_evdev_queues : 1
> queue_priority : false
> sched_type_list : {A}
> crypto adapter mode : OP_FORWARD
> nb_cryptodev : 1
> prod_type : Event crypto adapter producers
> prod_enq_burst_sz : 1
>CRYPTODEV: elt_size 0 is expanded to 208
>
>error: perf_event_crypto_adapter_setup() crypto adapter OP_FORWARD mode
>unsupported
>
>error: main() perf_queue: eventdev setup failed
>
No change from previous version.
Apply the patch "[RFC] app/eventdev: add software crypto adapter support" for using SW.
^ permalink raw reply [flat|nested] 43+ messages in thread
* RE: [PATCH v5] app/eventdev: add crypto producer mode
2022-02-16 7:08 ` Shijith Thotton
@ 2022-02-16 7:49 ` Gujjar, Abhinandan S
2022-02-16 8:44 ` Jerin Jacob
0 siblings, 1 reply; 43+ messages in thread
From: Gujjar, Abhinandan S @ 2022-02-16 7:49 UTC (permalink / raw)
To: Shijith Thotton; +Cc: Jerin Jacob Kollanukkaran, dev
Hi Shijith,
> -----Original Message-----
> From: Shijith Thotton <sthotton@marvell.com>
> Sent: Wednesday, February 16, 2022 12:39 PM
> To: Gujjar, Abhinandan S <abhinandan.gujjar@intel.com>
> Cc: Jerin Jacob Kollanukkaran <jerinj@marvell.com>; dev@dpdk.org
> Subject: RE: [PATCH v5] app/eventdev: add crypto producer mode
>
> >>
> >> In crypto producer mode, producer core enqueues cryptodev with
> >> software generated crypto ops and worker core dequeues crypto
> >> completion events from the eventdev. Event crypto metadata used for
> >> above processing is pre- populated in each crypto session.
> >>
> >> Parameter --prod_type_cryptodev can be used to enable crypto producer
> >> mode. Parameter --crypto_adptr_mode can be set to select the crypto
> >> adapter mode, 0 for OP_NEW and 1 for OP_FORWARD.
> >>
> >> This mode can be used to measure the performance of crypto adapter.
> >>
> >> Example:
> >> ./dpdk-test-eventdev -l 0-2 -w <EVENTDEV> -w <CRYPTODEV> -- \
> >> --prod_type_cryptodev --crypto_adptr_mode 1 --test=perf_atq \
> >> --stlist=a --wlcores 1 --plcores 2
> >>
> >I still see error with both OP_NEW and OP_FORWARD mode. Can't run the
> test.
> >root@xdp-dev:/home/intel/abhi/dpdk-next-eventdev/abhi# ./app/dpdk-
> test-
> >eventdev -l 0-8 -s 0xf0 --vdev=event_sw0 --vdev="crypto_null" -- --
> >prod_type_cryptodev --crypto_adptr_mode 1 --test=perf_queue --stlist=a
> >-- wlcores 1 --plcores 2
> >EAL: Detected CPU lcores: 96
> >EAL: Detected NUMA nodes: 2
> >EAL: Detected static linkage of DPDK
> >EAL: Multi-process socket /var/run/dpdk/rte/mp_socket
> >EAL: Selected IOVA mode 'PA'
> >EAL: VFIO support initialized
> >CRYPTODEV: Creating cryptodev crypto_null
> >
> >CRYPTODEV: Initialisation parameters - name: crypto_null,socket id: 0,
> >max queue
> >pairs: 8
> >TELEMETRY: No legacy callbacks, legacy socket not created
> > driver : event_sw
> > test : perf_queue
> > dev : 0
> > verbose_level : 1
> > socket_id : -1
> > pool_sz : 16384
> > main lcore : 0
> > nb_pkts : 67108864
> > nb_timers : 100000000
> > available lcores : {0 1 2 3 8}
> > nb_flows : 1024
> > worker deq depth : 16
> > fwd_latency : false
> > nb_prod_lcores : 1
> > producer lcores : {2}
> > nb_worker_lcores : 1
> > worker lcores : {1}
> > nb_stages : 1
> > nb_evdev_ports : 2
> > nb_evdev_queues : 1
> > queue_priority : false
> > sched_type_list : {A}
> > crypto adapter mode : OP_FORWARD
> > nb_cryptodev : 1
> > prod_type : Event crypto adapter producers
> > prod_enq_burst_sz : 1
> >CRYPTODEV: elt_size 0 is expanded to 208
> >
> >error: perf_event_crypto_adapter_setup() crypto adapter OP_FORWARD
> mode
> >unsupported
> >
> >error: main() perf_queue: eventdev setup failed
> >
>
> No change from previous version.
> Apply the patch "[RFC] app/eventdev: add software crypto adapter support"
> for using SW.
I see. Please send out next patchset once you have fix.
Thanks,
Abhinandan
^ permalink raw reply [flat|nested] 43+ messages in thread
* Re: [PATCH v5] app/eventdev: add crypto producer mode
2022-02-16 7:49 ` Gujjar, Abhinandan S
@ 2022-02-16 8:44 ` Jerin Jacob
2022-02-16 8:54 ` Jerin Jacob
0 siblings, 1 reply; 43+ messages in thread
From: Jerin Jacob @ 2022-02-16 8:44 UTC (permalink / raw)
To: Gujjar, Abhinandan S, Hemant Agrawal, Nipun Gupta
Cc: Shijith Thotton, Jerin Jacob Kollanukkaran, dev
On Wed, Feb 16, 2022 at 1:19 PM Gujjar, Abhinandan S
<abhinandan.gujjar@intel.com> wrote:
>
> Hi Shijith,
>
> > -----Original Message-----
> > From: Shijith Thotton <sthotton@marvell.com>
> > Sent: Wednesday, February 16, 2022 12:39 PM
> > To: Gujjar, Abhinandan S <abhinandan.gujjar@intel.com>
> > Cc: Jerin Jacob Kollanukkaran <jerinj@marvell.com>; dev@dpdk.org
> > Subject: RE: [PATCH v5] app/eventdev: add crypto producer mode
> >
> > >>
> > >> In crypto producer mode, producer core enqueues cryptodev with
> > >> software generated crypto ops and worker core dequeues crypto
> > >> completion events from the eventdev. Event crypto metadata used for
> > >> above processing is pre- populated in each crypto session.
> > >>
> > >> Parameter --prod_type_cryptodev can be used to enable crypto producer
> > >> mode. Parameter --crypto_adptr_mode can be set to select the crypto
> > >> adapter mode, 0 for OP_NEW and 1 for OP_FORWARD.
> > >>
> > >> This mode can be used to measure the performance of crypto adapter.
> > >>
> > >> Example:
> > >> ./dpdk-test-eventdev -l 0-2 -w <EVENTDEV> -w <CRYPTODEV> -- \
> > >> --prod_type_cryptodev --crypto_adptr_mode 1 --test=perf_atq \
> > >> --stlist=a --wlcores 1 --plcores 2
> > >>
> > >I still see error with both OP_NEW and OP_FORWARD mode. Can't run the
> > test.
> > >root@xdp-dev:/home/intel/abhi/dpdk-next-eventdev/abhi# ./app/dpdk-
> > test-
> > >eventdev -l 0-8 -s 0xf0 --vdev=event_sw0 --vdev="crypto_null" -- --
> > >prod_type_cryptodev --crypto_adptr_mode 1 --test=perf_queue --stlist=a
> > >-- wlcores 1 --plcores 2
> > >EAL: Detected CPU lcores: 96
> > >EAL: Detected NUMA nodes: 2
> > >EAL: Detected static linkage of DPDK
> > >EAL: Multi-process socket /var/run/dpdk/rte/mp_socket
> > >EAL: Selected IOVA mode 'PA'
> > >EAL: VFIO support initialized
> > >CRYPTODEV: Creating cryptodev crypto_null
> > >
> > >CRYPTODEV: Initialisation parameters - name: crypto_null,socket id: 0,
> > >max queue
> > >pairs: 8
> > >TELEMETRY: No legacy callbacks, legacy socket not created
> > > driver : event_sw
> > > test : perf_queue
> > > dev : 0
> > > verbose_level : 1
> > > socket_id : -1
> > > pool_sz : 16384
> > > main lcore : 0
> > > nb_pkts : 67108864
> > > nb_timers : 100000000
> > > available lcores : {0 1 2 3 8}
> > > nb_flows : 1024
> > > worker deq depth : 16
> > > fwd_latency : false
> > > nb_prod_lcores : 1
> > > producer lcores : {2}
> > > nb_worker_lcores : 1
> > > worker lcores : {1}
> > > nb_stages : 1
> > > nb_evdev_ports : 2
> > > nb_evdev_queues : 1
> > > queue_priority : false
> > > sched_type_list : {A}
> > > crypto adapter mode : OP_FORWARD
> > > nb_cryptodev : 1
> > > prod_type : Event crypto adapter producers
> > > prod_enq_burst_sz : 1
> > >CRYPTODEV: elt_size 0 is expanded to 208
> > >
> > >error: perf_event_crypto_adapter_setup() crypto adapter OP_FORWARD
> > mode
> > >unsupported
> > >
> > >error: main() perf_queue: eventdev setup failed
> > >
> >
> > No change from previous version.
> > Apply the patch "[RFC] app/eventdev: add software crypto adapter support"
> > for using SW.
> I see. Please send out next patchset once you have fix.
+ @Van Haaren, Harry (Software Eventdev PMD maintainer),
+ @Hemant Agrawal @Nipun Gupta (NXP PMD)
Summarizing the current situation to make forward progress
1) This patch adds support for crypto adapter producers to test the performance.
2) This application change is verified with cnxk PMD.
3) When testing with SW driver there is a crash is observed, SW PMD.
See [1] for more details.
Next steps:
1) Generally application changes won't wait for other all drivers to
pass if there issue with the driver.
In this case, there is a crash in SW PMD.
2) @Gujjar, Abhinandan S Please review the application code, Let me
know if there is an issue with
the application code as comments. We can wait up to rc2 time for
merging this patch.
3) Once SW PMD issue fixes based on @Van Haaren, Harry 's bandwidth
and we can merge
"[RFC] app/eventdev: add software crypto adapter support" so that
there is no crash from
testeventdev.
4) @Hemant Agrawal @Nipun Gupta Please check the NXP driver if there
is interest in this feature.
[1]
Steps to reproduce:
* Clone http://dpdk.org/git/next/dpdk-next-eventdev
* Apply [v5] app/eventdev: add crypto producer mode
git-pw --server https://patches.dpdk.org/api/1.2/ --project dpdk
patch apply 107645
* Apply [RFC] app/eventdev: add software crypto adapter support
git-pw --server https://patches.dpdk.org/api/1.2/ --project dpdk
patch apply 107029
* meson x86_build_debug -Dc_args='-g -O0' -Ddisable_drivers="*/cnxk"
* ninja -C x86_build_debug
* Command to reproduce crash
sudo ./x86_build_debug/app/dpdk-test-eventdev -l 0-8 -s 0xf0
--vdev=event_sw0 --vdev="crypto_null" -- --prod_type_cryptodev
--crypto_adptr_mode 0 --test=perf_queue --stlist=a --wlcores 1
--plcores 2
Crash log:
Thread 10 "lcore-worker-7" received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7ffff3767400 (LWP 1342606)]
0x0000555557b02b3c in iq_alloc_chunk (sw=0x10057c4c0) at
../drivers/event/sw/iq_chunk.h:35
35 sw->chunk_list_head = chunk->next;
(gdb) bt
#0 0x0000555557b02b3c in iq_alloc_chunk (sw=0x10057c4c0) at
../drivers/event/sw/iq_chunk.h:35
#1 iq_enqueue (ev=0x1005af9b0, iq=0x1009e25b8, sw=0x10057c4c0) at
../drivers/event/sw/iq_chunk.h:79
#2 __pull_port_lb (allow_reorder=0, port_id=2, sw=0x10057c4c0) at
../drivers/event/sw/sw_evdev_scheduler.c:443
#3 sw_schedule_pull_port_no_reorder (sw=0x10057c4c0, port_id=2) at
../drivers/event/sw/sw_evdev_scheduler.c:466
#4 0x0000555557b06e81 in sw_event_schedule (dev=0x5555586b3f80
<rte_event_devices>) at ../drivers/event/sw/sw_evdev_scheduler.c:538
#5 0x0000555557b2edf3 in sw_sched_service_func (args=0x5555586b3f80
<rte_event_devices>) at ../drivers/event/sw/sw_evdev.c:938
#6 0x0000555555b4f039 in service_runner_do_callback (s=0x1003fe000,
cs=0x1003eb100, service_idx=0) at ../lib/eal/common/rte_service.c:376
#7 0x0000555555b4f107 in service_run (i=0, cs=0x1003eb100,
service_mask=1, s=0x1003fe000, serialize_mt_unsafe=1) at
../lib/eal/common/rte_service.c:407
#8 0x0000555555b4f366 in service_runner_func (arg=0x0) at
../lib/eal/common/rte_service.c:475
#9 0x0000555555b6de0d in eal_thread_loop (arg=0x0) at
../lib/eal/linux/eal_thread.c:146
#10 0x00007ffff7a0f609 in start_thread (arg=<optimized out>) at
pthread_create.c:477
#11 0x00007ffff7936293 in clone () at
../sysdeps/unix/sysv/linux/x86_64/clone.S:95
(gdb) list
30
31 static __rte_always_inline struct sw_queue_chunk *
32 iq_alloc_chunk(struct sw_evdev *sw)
33 {
34 struct sw_queue_chunk *chunk = sw->chunk_list_head;
35 sw->chunk_list_head = chunk->next;
36 chunk->next = NULL;
37 return chunk;
38 }
39
(gdb) p chunk
$3 = (struct sw_queue_chunk *) 0x0
>
> Thanks,
> Abhinandan
^ permalink raw reply [flat|nested] 43+ messages in thread
* Re: [PATCH v5] app/eventdev: add crypto producer mode
2022-02-16 8:44 ` Jerin Jacob
@ 2022-02-16 8:54 ` Jerin Jacob
2022-02-17 5:33 ` Gujjar, Abhinandan S
0 siblings, 1 reply; 43+ messages in thread
From: Jerin Jacob @ 2022-02-16 8:54 UTC (permalink / raw)
To: Gujjar, Abhinandan S, Hemant Agrawal, Nipun Gupta, Van Haaren, Harry
Cc: Shijith Thotton, Jerin Jacob Kollanukkaran, dev
+ @Van Haaren, Harry
On Wed, Feb 16, 2022 at 2:14 PM Jerin Jacob <jerinjacobk@gmail.com> wrote:
>
> On Wed, Feb 16, 2022 at 1:19 PM Gujjar, Abhinandan S
> <abhinandan.gujjar@intel.com> wrote:
> >
> > Hi Shijith,
> >
> > > -----Original Message-----
> > > From: Shijith Thotton <sthotton@marvell.com>
> > > Sent: Wednesday, February 16, 2022 12:39 PM
> > > To: Gujjar, Abhinandan S <abhinandan.gujjar@intel.com>
> > > Cc: Jerin Jacob Kollanukkaran <jerinj@marvell.com>; dev@dpdk.org
> > > Subject: RE: [PATCH v5] app/eventdev: add crypto producer mode
> > >
> > > >>
> > > >> In crypto producer mode, producer core enqueues cryptodev with
> > > >> software generated crypto ops and worker core dequeues crypto
> > > >> completion events from the eventdev. Event crypto metadata used for
> > > >> above processing is pre- populated in each crypto session.
> > > >>
> > > >> Parameter --prod_type_cryptodev can be used to enable crypto producer
> > > >> mode. Parameter --crypto_adptr_mode can be set to select the crypto
> > > >> adapter mode, 0 for OP_NEW and 1 for OP_FORWARD.
> > > >>
> > > >> This mode can be used to measure the performance of crypto adapter.
> > > >>
> > > >> Example:
> > > >> ./dpdk-test-eventdev -l 0-2 -w <EVENTDEV> -w <CRYPTODEV> -- \
> > > >> --prod_type_cryptodev --crypto_adptr_mode 1 --test=perf_atq \
> > > >> --stlist=a --wlcores 1 --plcores 2
> > > >>
> > > >I still see error with both OP_NEW and OP_FORWARD mode. Can't run the
> > > test.
> > > >root@xdp-dev:/home/intel/abhi/dpdk-next-eventdev/abhi# ./app/dpdk-
> > > test-
> > > >eventdev -l 0-8 -s 0xf0 --vdev=event_sw0 --vdev="crypto_null" -- --
> > > >prod_type_cryptodev --crypto_adptr_mode 1 --test=perf_queue --stlist=a
> > > >-- wlcores 1 --plcores 2
> > > >EAL: Detected CPU lcores: 96
> > > >EAL: Detected NUMA nodes: 2
> > > >EAL: Detected static linkage of DPDK
> > > >EAL: Multi-process socket /var/run/dpdk/rte/mp_socket
> > > >EAL: Selected IOVA mode 'PA'
> > > >EAL: VFIO support initialized
> > > >CRYPTODEV: Creating cryptodev crypto_null
> > > >
> > > >CRYPTODEV: Initialisation parameters - name: crypto_null,socket id: 0,
> > > >max queue
> > > >pairs: 8
> > > >TELEMETRY: No legacy callbacks, legacy socket not created
> > > > driver : event_sw
> > > > test : perf_queue
> > > > dev : 0
> > > > verbose_level : 1
> > > > socket_id : -1
> > > > pool_sz : 16384
> > > > main lcore : 0
> > > > nb_pkts : 67108864
> > > > nb_timers : 100000000
> > > > available lcores : {0 1 2 3 8}
> > > > nb_flows : 1024
> > > > worker deq depth : 16
> > > > fwd_latency : false
> > > > nb_prod_lcores : 1
> > > > producer lcores : {2}
> > > > nb_worker_lcores : 1
> > > > worker lcores : {1}
> > > > nb_stages : 1
> > > > nb_evdev_ports : 2
> > > > nb_evdev_queues : 1
> > > > queue_priority : false
> > > > sched_type_list : {A}
> > > > crypto adapter mode : OP_FORWARD
> > > > nb_cryptodev : 1
> > > > prod_type : Event crypto adapter producers
> > > > prod_enq_burst_sz : 1
> > > >CRYPTODEV: elt_size 0 is expanded to 208
> > > >
> > > >error: perf_event_crypto_adapter_setup() crypto adapter OP_FORWARD
> > > mode
> > > >unsupported
> > > >
> > > >error: main() perf_queue: eventdev setup failed
> > > >
> > >
> > > No change from previous version.
> > > Apply the patch "[RFC] app/eventdev: add software crypto adapter support"
> > > for using SW.
> > I see. Please send out next patchset once you have fix.
>
> + @Van Haaren, Harry (Software Eventdev PMD maintainer),
> + @Hemant Agrawal @Nipun Gupta (NXP PMD)
>
> Summarizing the current situation to make forward progress
> 1) This patch adds support for crypto adapter producers to test the performance.
> 2) This application change is verified with cnxk PMD.
> 3) When testing with SW driver there is a crash is observed, SW PMD.
> See [1] for more details.
>
> Next steps:
> 1) Generally application changes won't wait for other all drivers to
> pass if there issue with the driver.
> In this case, there is a crash in SW PMD.
> 2) @Gujjar, Abhinandan S Please review the application code, Let me
> know if there is an issue with
> the application code as comments. We can wait up to rc2 time for
> merging this patch.
> 3) Once SW PMD issue fixes based on @Van Haaren, Harry 's bandwidth
> and we can merge
> "[RFC] app/eventdev: add software crypto adapter support" so that
> there is no crash from
> testeventdev.
> 4) @Hemant Agrawal @Nipun Gupta Please check the NXP driver if there
> is interest in this feature.
>
>
>
> [1]
> Steps to reproduce:
> * Clone http://dpdk.org/git/next/dpdk-next-eventdev
> * Apply [v5] app/eventdev: add crypto producer mode
> git-pw --server https://patches.dpdk.org/api/1.2/ --project dpdk
> patch apply 107645
> * Apply [RFC] app/eventdev: add software crypto adapter support
> git-pw --server https://patches.dpdk.org/api/1.2/ --project dpdk
> patch apply 107029
> * meson x86_build_debug -Dc_args='-g -O0' -Ddisable_drivers="*/cnxk"
> * ninja -C x86_build_debug
> * Command to reproduce crash
> sudo ./x86_build_debug/app/dpdk-test-eventdev -l 0-8 -s 0xf0
> --vdev=event_sw0 --vdev="crypto_null" -- --prod_type_cryptodev
> --crypto_adptr_mode 0 --test=perf_queue --stlist=a --wlcores 1
> --plcores 2
>
> Crash log:
> Thread 10 "lcore-worker-7" received signal SIGSEGV, Segmentation fault.
> [Switching to Thread 0x7ffff3767400 (LWP 1342606)]
> 0x0000555557b02b3c in iq_alloc_chunk (sw=0x10057c4c0) at
> ../drivers/event/sw/iq_chunk.h:35
> 35 sw->chunk_list_head = chunk->next;
> (gdb) bt
> #0 0x0000555557b02b3c in iq_alloc_chunk (sw=0x10057c4c0) at
> ../drivers/event/sw/iq_chunk.h:35
> #1 iq_enqueue (ev=0x1005af9b0, iq=0x1009e25b8, sw=0x10057c4c0) at
> ../drivers/event/sw/iq_chunk.h:79
> #2 __pull_port_lb (allow_reorder=0, port_id=2, sw=0x10057c4c0) at
> ../drivers/event/sw/sw_evdev_scheduler.c:443
> #3 sw_schedule_pull_port_no_reorder (sw=0x10057c4c0, port_id=2) at
> ../drivers/event/sw/sw_evdev_scheduler.c:466
> #4 0x0000555557b06e81 in sw_event_schedule (dev=0x5555586b3f80
> <rte_event_devices>) at ../drivers/event/sw/sw_evdev_scheduler.c:538
> #5 0x0000555557b2edf3 in sw_sched_service_func (args=0x5555586b3f80
> <rte_event_devices>) at ../drivers/event/sw/sw_evdev.c:938
> #6 0x0000555555b4f039 in service_runner_do_callback (s=0x1003fe000,
> cs=0x1003eb100, service_idx=0) at ../lib/eal/common/rte_service.c:376
> #7 0x0000555555b4f107 in service_run (i=0, cs=0x1003eb100,
> service_mask=1, s=0x1003fe000, serialize_mt_unsafe=1) at
> ../lib/eal/common/rte_service.c:407
> #8 0x0000555555b4f366 in service_runner_func (arg=0x0) at
> ../lib/eal/common/rte_service.c:475
> #9 0x0000555555b6de0d in eal_thread_loop (arg=0x0) at
> ../lib/eal/linux/eal_thread.c:146
> #10 0x00007ffff7a0f609 in start_thread (arg=<optimized out>) at
> pthread_create.c:477
> #11 0x00007ffff7936293 in clone () at
> ../sysdeps/unix/sysv/linux/x86_64/clone.S:95
> (gdb) list
> 30
> 31 static __rte_always_inline struct sw_queue_chunk *
> 32 iq_alloc_chunk(struct sw_evdev *sw)
> 33 {
> 34 struct sw_queue_chunk *chunk = sw->chunk_list_head;
> 35 sw->chunk_list_head = chunk->next;
> 36 chunk->next = NULL;
> 37 return chunk;
> 38 }
> 39
> (gdb) p chunk
> $3 = (struct sw_queue_chunk *) 0x0
>
>
>
> >
> > Thanks,
> > Abhinandan
^ permalink raw reply [flat|nested] 43+ messages in thread
* RE: [PATCH v5] app/eventdev: add crypto producer mode
2022-02-16 8:54 ` Jerin Jacob
@ 2022-02-17 5:33 ` Gujjar, Abhinandan S
2022-02-21 13:10 ` Van Haaren, Harry
0 siblings, 1 reply; 43+ messages in thread
From: Gujjar, Abhinandan S @ 2022-02-17 5:33 UTC (permalink / raw)
To: Jerin Jacob, Hemant Agrawal, Nipun Gupta, Van Haaren, Harry
Cc: Shijith Thotton, Jerin Jacob Kollanukkaran, dev
Hi Jerin,
> -----Original Message-----
> From: Jerin Jacob <jerinjacobk@gmail.com>
> Sent: Wednesday, February 16, 2022 2:25 PM
> To: Gujjar, Abhinandan S <abhinandan.gujjar@intel.com>; Hemant Agrawal
> <hemant.agrawal@nxp.com>; Nipun Gupta <nipun.gupta@nxp.com>; Van
> Haaren, Harry <harry.van.haaren@intel.com>
> Cc: Shijith Thotton <sthotton@marvell.com>; Jerin Jacob Kollanukkaran
> <jerinj@marvell.com>; dev@dpdk.org
> Subject: Re: [PATCH v5] app/eventdev: add crypto producer mode
>
> + @Van Haaren, Harry
>
> On Wed, Feb 16, 2022 at 2:14 PM Jerin Jacob <jerinjacobk@gmail.com>
> wrote:
> >
> > On Wed, Feb 16, 2022 at 1:19 PM Gujjar, Abhinandan S
> > <abhinandan.gujjar@intel.com> wrote:
> > >
> > > Hi Shijith,
> > >
> > > > -----Original Message-----
> > > > From: Shijith Thotton <sthotton@marvell.com>
> > > > Sent: Wednesday, February 16, 2022 12:39 PM
> > > > To: Gujjar, Abhinandan S <abhinandan.gujjar@intel.com>
> > > > Cc: Jerin Jacob Kollanukkaran <jerinj@marvell.com>; dev@dpdk.org
> > > > Subject: RE: [PATCH v5] app/eventdev: add crypto producer mode
> > > >
> > > > >>
> > > > >> In crypto producer mode, producer core enqueues cryptodev with
> > > > >> software generated crypto ops and worker core dequeues crypto
> > > > >> completion events from the eventdev. Event crypto metadata used
> > > > >> for above processing is pre- populated in each crypto session.
> > > > >>
> > > > >> Parameter --prod_type_cryptodev can be used to enable crypto
> > > > >> producer mode. Parameter --crypto_adptr_mode can be set to
> > > > >> select the crypto adapter mode, 0 for OP_NEW and 1 for
> OP_FORWARD.
> > > > >>
> > > > >> This mode can be used to measure the performance of crypto
> adapter.
> > > > >>
> > > > >> Example:
> > > > >> ./dpdk-test-eventdev -l 0-2 -w <EVENTDEV> -w <CRYPTODEV> -- \
> > > > >> --prod_type_cryptodev --crypto_adptr_mode 1 --test=perf_atq \
> > > > >> --stlist=a --wlcores 1 --plcores 2
> > > > >>
> > > > >I still see error with both OP_NEW and OP_FORWARD mode. Can't run
> > > > >the
> > > > test.
> > > > >root@xdp-dev:/home/intel/abhi/dpdk-next-eventdev/abhi#
> > > > >./app/dpdk-
> > > > test-
> > > > >eventdev -l 0-8 -s 0xf0 --vdev=event_sw0 --vdev="crypto_null" --
> > > > >-- prod_type_cryptodev --crypto_adptr_mode 1 --test=perf_queue
> > > > >--stlist=a
> > > > >-- wlcores 1 --plcores 2
> > > > >EAL: Detected CPU lcores: 96
> > > > >EAL: Detected NUMA nodes: 2
> > > > >EAL: Detected static linkage of DPDK
> > > > >EAL: Multi-process socket /var/run/dpdk/rte/mp_socket
> > > > >EAL: Selected IOVA mode 'PA'
> > > > >EAL: VFIO support initialized
> > > > >CRYPTODEV: Creating cryptodev crypto_null
> > > > >
> > > > >CRYPTODEV: Initialisation parameters - name: crypto_null,socket
> > > > >id: 0, max queue
> > > > >pairs: 8
> > > > >TELEMETRY: No legacy callbacks, legacy socket not created
> > > > > driver : event_sw
> > > > > test : perf_queue
> > > > > dev : 0
> > > > > verbose_level : 1
> > > > > socket_id : -1
> > > > > pool_sz : 16384
> > > > > main lcore : 0
> > > > > nb_pkts : 67108864
> > > > > nb_timers : 100000000
> > > > > available lcores : {0 1 2 3 8}
> > > > > nb_flows : 1024
> > > > > worker deq depth : 16
> > > > > fwd_latency : false
> > > > > nb_prod_lcores : 1
> > > > > producer lcores : {2}
> > > > > nb_worker_lcores : 1
> > > > > worker lcores : {1}
> > > > > nb_stages : 1
> > > > > nb_evdev_ports : 2
> > > > > nb_evdev_queues : 1
> > > > > queue_priority : false
> > > > > sched_type_list : {A}
> > > > > crypto adapter mode : OP_FORWARD
> > > > > nb_cryptodev : 1
> > > > > prod_type : Event crypto adapter producers
> > > > > prod_enq_burst_sz : 1
> > > > >CRYPTODEV: elt_size 0 is expanded to 208
> > > > >
> > > > >error: perf_event_crypto_adapter_setup() crypto adapter
> > > > >OP_FORWARD
> > > > mode
> > > > >unsupported
> > > > >
> > > > >error: main() perf_queue: eventdev setup failed
> > > > >
> > > >
> > > > No change from previous version.
> > > > Apply the patch "[RFC] app/eventdev: add software crypto adapter
> support"
> > > > for using SW.
> > > I see. Please send out next patchset once you have fix.
> >
> > + @Van Haaren, Harry (Software Eventdev PMD maintainer), @Hemant
> > + Agrawal @Nipun Gupta (NXP PMD)
> >
> > Summarizing the current situation to make forward progress
> > 1) This patch adds support for crypto adapter producers to test the
> performance.
> > 2) This application change is verified with cnxk PMD.
> > 3) When testing with SW driver there is a crash is observed, SW PMD.
> > See [1] for more details.
> >
> > Next steps:
> > 1) Generally application changes won't wait for other all drivers to
> > pass if there issue with the driver.
> > In this case, there is a crash in SW PMD.
> > 2) @Gujjar, Abhinandan S Please review the application code, Let me
> > know if there is an issue with the application code as comments. We
> > can wait up to rc2 time for merging this patch.
Sure. I will review it.
> > 3) Once SW PMD issue fixes based on @Van Haaren, Harry 's bandwidth
> > and we can merge "[RFC] app/eventdev: add software crypto adapter
> > support" so that there is no crash from testeventdev.
> > 4) @Hemant Agrawal @Nipun Gupta Please check the NXP driver if there
> > is interest in this feature.
Thanks for connecting all.
> >
> >
> >
> > [1]
> > Steps to reproduce:
> > * Clone http://dpdk.org/git/next/dpdk-next-eventdev
> > * Apply [v5] app/eventdev: add crypto producer mode
> > git-pw --server https://patches.dpdk.org/api/1.2/ --project dpdk
> > patch apply 107645
> > * Apply [RFC] app/eventdev: add software crypto adapter support
> > git-pw --server https://patches.dpdk.org/api/1.2/ --project dpdk
> > patch apply 107029
> > * meson x86_build_debug -Dc_args='-g -O0' -Ddisable_drivers="*/cnxk"
> > * ninja -C x86_build_debug
> > * Command to reproduce crash
> > sudo ./x86_build_debug/app/dpdk-test-eventdev -l 0-8 -s 0xf0
> > --vdev=event_sw0 --vdev="crypto_null" -- --prod_type_cryptodev
> > --crypto_adptr_mode 0 --test=perf_queue --stlist=a --wlcores 1
> > --plcores 2
> >
> > Crash log:
> > Thread 10 "lcore-worker-7" received signal SIGSEGV, Segmentation fault.
> > [Switching to Thread 0x7ffff3767400 (LWP 1342606)] 0x0000555557b02b3c
> > in iq_alloc_chunk (sw=0x10057c4c0) at
> > ../drivers/event/sw/iq_chunk.h:35
> > 35 sw->chunk_list_head = chunk->next;
> > (gdb) bt
> > #0 0x0000555557b02b3c in iq_alloc_chunk (sw=0x10057c4c0) at
> > ../drivers/event/sw/iq_chunk.h:35
> > #1 iq_enqueue (ev=0x1005af9b0, iq=0x1009e25b8, sw=0x10057c4c0) at
> > ../drivers/event/sw/iq_chunk.h:79
> > #2 __pull_port_lb (allow_reorder=0, port_id=2, sw=0x10057c4c0) at
> > ../drivers/event/sw/sw_evdev_scheduler.c:443
> > #3 sw_schedule_pull_port_no_reorder (sw=0x10057c4c0, port_id=2) at
> > ../drivers/event/sw/sw_evdev_scheduler.c:466
> > #4 0x0000555557b06e81 in sw_event_schedule (dev=0x5555586b3f80
> > <rte_event_devices>) at ../drivers/event/sw/sw_evdev_scheduler.c:538
> > #5 0x0000555557b2edf3 in sw_sched_service_func (args=0x5555586b3f80
> > <rte_event_devices>) at ../drivers/event/sw/sw_evdev.c:938
> > #6 0x0000555555b4f039 in service_runner_do_callback (s=0x1003fe000,
> > cs=0x1003eb100, service_idx=0) at ../lib/eal/common/rte_service.c:376
> > #7 0x0000555555b4f107 in service_run (i=0, cs=0x1003eb100,
> > service_mask=1, s=0x1003fe000, serialize_mt_unsafe=1) at
> > ../lib/eal/common/rte_service.c:407
> > #8 0x0000555555b4f366 in service_runner_func (arg=0x0) at
> > ../lib/eal/common/rte_service.c:475
> > #9 0x0000555555b6de0d in eal_thread_loop (arg=0x0) at
> > ../lib/eal/linux/eal_thread.c:146
> > #10 0x00007ffff7a0f609 in start_thread (arg=<optimized out>) at
> > pthread_create.c:477
> > #11 0x00007ffff7936293 in clone () at
> > ../sysdeps/unix/sysv/linux/x86_64/clone.S:95
> > (gdb) list
> > 30
> > 31 static __rte_always_inline struct sw_queue_chunk *
> > 32 iq_alloc_chunk(struct sw_evdev *sw)
> > 33 {
> > 34 struct sw_queue_chunk *chunk = sw->chunk_list_head;
> > 35 sw->chunk_list_head = chunk->next;
> > 36 chunk->next = NULL;
> > 37 return chunk;
> > 38 }
> > 39
> > (gdb) p chunk
> > $3 = (struct sw_queue_chunk *) 0x0
> >
> >
> >
> > >
> > > Thanks,
> > > Abhinandan
^ permalink raw reply [flat|nested] 43+ messages in thread
* RE: [EXT] [PATCH v5] app/eventdev: add crypto producer mode
2022-02-15 16:56 ` [PATCH v5] " Shijith Thotton
2022-02-16 4:47 ` Gujjar, Abhinandan S
@ 2022-02-17 6:56 ` Akhil Goyal
2022-02-18 12:00 ` Shijith Thotton
2022-02-18 12:11 ` [PATCH v6] " Shijith Thotton
2 siblings, 1 reply; 43+ messages in thread
From: Akhil Goyal @ 2022-02-17 6:56 UTC (permalink / raw)
To: Shijith Thotton, dev, Jerin Jacob Kollanukkaran
Cc: Shijith Thotton, abhinandan.gujjar
Hi Shijith,
Few comments inline.
With those fixed.
Acked-by: Akhil Goyal <gakhil@marvell.com>
> +static int
> +perf_event_crypto_adapter_setup(struct test_perf *t, struct prod_data *p)
> +{
> + struct evt_options *opt = t->opt;
> + uint32_t cap;
> + int ret;
> +
> + ret = rte_event_crypto_adapter_caps_get(p->dev_id, p->ca.cdev_id,
> &cap);
> + if (ret) {
> + evt_err("Failed to get crypto adapter capabilities");
> + return ret;
> + }
> +
> + if (((opt->crypto_adptr_mode ==
> RTE_EVENT_CRYPTO_ADAPTER_OP_NEW) &&
> + !(cap &
> RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_OP_NEW)) ||
> + ((opt->crypto_adptr_mode ==
> RTE_EVENT_CRYPTO_ADAPTER_OP_FORWARD) &&
> + !(cap &
> RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_OP_FWD))) {
> + evt_err("crypto adapter %s mode unsupported\n",
> + opt->crypto_adptr_mode ? "OP_FORWARD" :
> "OP_NEW");
> + return -EINVAL;
> + } else if (!(cap &
> RTE_EVENT_CRYPTO_ADAPTER_CAP_SESSION_PRIVATE_DATA)) {
> + evt_err("Storing crypto session not supported");
> + return -EINVAL;
> + }
The above errors should be -ENOTSUP. If the PMD is not capable, test should be skipped.
> +
> + if (cap &
> RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_QP_EV_BIND) {
> + struct rte_event response_info;
> +
> + response_info.event = 0;
> + response_info.op =
> + opt->crypto_adptr_mode ==
> +
> RTE_EVENT_CRYPTO_ADAPTER_OP_NEW ?
> + RTE_EVENT_OP_NEW :
> + RTE_EVENT_OP_FORWARD;
> + response_info.sched_type = RTE_SCHED_TYPE_ATOMIC;
> + response_info.event_type = RTE_EVENT_TYPE_CRYPTODEV;
> + response_info.queue_id = p->queue_id;
> + ret = rte_event_crypto_adapter_queue_pair_add(
> + TEST_PERF_CA_ID, p->ca.cdev_id, p->ca.cdev_qp_id,
> + &response_info);
> + } else {
> + ret = rte_event_crypto_adapter_queue_pair_add(
> + TEST_PERF_CA_ID, p->ca.cdev_id, p->ca.cdev_qp_id,
> NULL);
> + }
> +
> + return ret;
> +}
> +
> +static struct rte_cryptodev_sym_session *
> +cryptodev_sym_sess_create(struct prod_data *p, struct test_perf *t)
> +{
> + struct rte_crypto_sym_xform cipher_xform;
> + struct rte_cryptodev_sym_session *sess;
> +
> + cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
> + cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
> + cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
> + cipher_xform.next = NULL;
> +
> + sess = rte_cryptodev_sym_session_create(t->ca_sess_pool);
> + if (sess == NULL) {
> + evt_err("Failed to create sym session");
> + return NULL;
> + }
> +
> + if (rte_cryptodev_sym_session_init(p->ca.cdev_id, sess, &cipher_xform,
> + t->ca_sess_priv_pool)) {
> + evt_err("Failed to init session");
> + return NULL;
> + }
> +
> + return sess;
> +}
> +
> int
> perf_event_dev_port_setup(struct evt_test *test, struct evt_options *opt,
> uint8_t stride, uint8_t nb_queues,
> @@ -598,6 +796,80 @@ perf_event_dev_port_setup(struct evt_test *test,
> struct evt_options *opt,
> ret = perf_event_timer_adapter_setup(t);
> if (ret)
> return ret;
> + } else if (opt->prod_type == EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR) {
> + struct rte_event_port_conf conf = *port_conf;
> + uint8_t cdev_id = 0;
> + uint16_t qp_id = 0;
> +
> + ret = rte_event_crypto_adapter_create(TEST_PERF_CA_ID,
> + opt->dev_id, &conf, 0);
> + if (ret) {
> + evt_err("Failed to create crypto adapter");
> + return ret;
> + }
> +
> + prod = 0;
> + for (; port < perf_nb_event_ports(opt); port++) {
> + struct rte_cryptodev_sym_session *crypto_sess;
> + union rte_event_crypto_metadata m_data;
> + struct prod_data *p = &t->prod[port];
> + uint32_t flow_id;
> +
> + if (qp_id == rte_cryptodev_queue_pair_count(cdev_id))
> {
> + cdev_id++;
> + qp_id = 0;
> + }
> +
> + p->dev_id = opt->dev_id;
> + p->port_id = port;
> + p->queue_id = prod * stride;
> + p->ca.cdev_id = cdev_id;
> + p->ca.cdev_qp_id = qp_id;
> + p->ca.crypto_sess = rte_zmalloc_socket(
> + NULL, sizeof(crypto_sess) * t->nb_flows,
> + RTE_CACHE_LINE_SIZE, opt->socket_id);
> + p->t = t;
> +
> + m_data.request_info.cdev_id = p->ca.cdev_id;
> + m_data.request_info.queue_pair_id = p-
> >ca.cdev_qp_id;
> + m_data.response_info.op =
> + opt->crypto_adptr_mode ==
> +
> RTE_EVENT_CRYPTO_ADAPTER_OP_NEW ?
> + RTE_EVENT_OP_NEW :
> + RTE_EVENT_OP_FORWARD;
> + m_data.response_info.sched_type =
> RTE_SCHED_TYPE_ATOMIC;
> + m_data.response_info.event_type =
> + RTE_EVENT_TYPE_CRYPTODEV;
> + m_data.response_info.queue_id = p->queue_id;
> +
> + for (flow_id = 0; flow_id < t->nb_flows; flow_id++) {
> + crypto_sess = cryptodev_sym_sess_create(p, t);
> + if (crypto_sess == NULL)
> + return -ENOMEM;
> +
> + m_data.response_info.flow_id = flow_id;
> + rte_cryptodev_sym_session_set_user_data(
> + crypto_sess, &m_data,
> sizeof(m_data));
> + p->ca.crypto_sess[flow_id] = crypto_sess;
> + }
> +
> + conf.event_port_cfg |=
> + RTE_EVENT_PORT_CFG_HINT_PRODUCER |
> + RTE_EVENT_PORT_CFG_HINT_CONSUMER;
> +
> + ret = rte_event_port_setup(opt->dev_id, port, &conf);
> + if (ret) {
> + evt_err("failed to setup port %d", port);
> + return ret;
> + }
> +
> + ret = perf_event_crypto_adapter_setup(t, p);
> + if (ret)
> + return ret;
> +
> + qp_id++;
> + prod++;
Memory leak for p->ca.crypto_sess in failure cases.
Also check if it is getting freed when sessions are destroyed.
> + }
> } else {
> prod = 0;
> for ( ; port < perf_nb_event_ports(opt); port++) {
> @@ -659,7 +931,8 @@ perf_opt_check(struct evt_options *opt, uint64_t
> nb_queues)
> }
>
> if (opt->prod_type == EVT_PROD_TYPE_SYNT ||
> - opt->prod_type ==
> EVT_PROD_TYPE_EVENT_TIMER_ADPTR) {
> + opt->prod_type == EVT_PROD_TYPE_EVENT_TIMER_ADPTR ||
> + opt->prod_type == EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR) {
> /* Validate producer lcores */
> if (evt_lcores_has_overlap(opt->plcores,
> rte_get_main_lcore())) {
> @@ -767,8 +1040,7 @@ perf_ethdev_setup(struct evt_test *test, struct
> evt_options *opt)
> },
> };
>
> - if (opt->prod_type == EVT_PROD_TYPE_SYNT ||
> - opt->prod_type ==
> EVT_PROD_TYPE_EVENT_TIMER_ADPTR)
> + if (opt->prod_type != EVT_PROD_TYPE_ETH_RX_ADPTR)
> return 0;
>
> if (!rte_eth_dev_count_avail()) {
> @@ -841,6 +1113,147 @@ void perf_ethdev_destroy(struct evt_test *test,
> struct evt_options *opt)
> }
> }
>
> +int
> +perf_cryptodev_setup(struct evt_test *test, struct evt_options *opt)
> +{
> + uint8_t cdev_count, cdev_id, nb_plcores, nb_qps;
> + struct test_perf *t = evt_test_priv(test);
> + unsigned int max_session_size;
> + uint32_t nb_sessions;
> + int ret;
> +
> + if (opt->prod_type != EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR)
> + return 0;
> +
> + cdev_count = rte_cryptodev_count();
> + if (cdev_count == 0) {
> + evt_err("No crypto devices available\n");
> + return -ENODEV;
> + }
> +
> + t->ca_op_pool = rte_crypto_op_pool_create(
> + "crypto_op_pool", RTE_CRYPTO_OP_TYPE_SYMMETRIC, opt-
> >pool_sz,
> + 128, 0, rte_socket_id());
> + if (t->ca_op_pool == NULL) {
> + evt_err("Failed to create crypto op pool");
> + return -ENOMEM;
> + }
> +
> + nb_sessions = evt_nr_active_lcores(opt->plcores) * t->nb_flows;
> + t->ca_sess_pool = rte_cryptodev_sym_session_pool_create(
> + "ca_sess_pool", nb_sessions, 0, 0,
> + sizeof(union rte_event_crypto_metadata), SOCKET_ID_ANY);
> + if (t->ca_sess_pool == NULL) {
> + evt_err("Failed to create sym session pool");
> + ret = -ENOMEM;
> + goto err;
> + }
> +
> + max_session_size = 0;
> + for (cdev_id = 0; cdev_id < cdev_count; cdev_id++) {
> + unsigned int session_size;
> +
> + session_size =
> + rte_cryptodev_sym_get_private_session_size(cdev_id);
> + if (session_size > max_session_size)
> + max_session_size = session_size;
> + }
> +
> + max_session_size += sizeof(union rte_event_crypto_metadata);
> + t->ca_sess_priv_pool = rte_mempool_create(
> + "ca_sess_priv_pool", nb_sessions, max_session_size, 0, 0,
> NULL,
> + NULL, NULL, NULL, SOCKET_ID_ANY, 0);
> + if (t->ca_sess_priv_pool == NULL) {
> + evt_err("failed to create sym session private pool");
> + ret = -ENOMEM;
> + goto err;
> + }
> +
> + /*
> + * Calculate number of needed queue pairs, based on the amount of
> + * available number of logical cores and crypto devices. For instance,
> + * if there are 4 cores and 2 crypto devices, 2 queue pairs will be set
> + * up per device.
> + */
> + nb_plcores = evt_nr_active_lcores(opt->plcores);
> + nb_qps = (nb_plcores % cdev_count) ? (nb_plcores / cdev_count) + 1 :
> + nb_plcores / cdev_count;
> + for (cdev_id = 0; cdev_id < cdev_count; cdev_id++) {
> + struct rte_cryptodev_qp_conf qp_conf;
> + struct rte_cryptodev_config conf;
> + struct rte_cryptodev_info info;
> + int qp_id;
> +
> + rte_cryptodev_info_get(cdev_id, &info);
> + if (nb_qps > info.max_nb_queue_pairs) {
> + evt_err("Not enough queue pairs per cryptodev (%u)",
> + nb_qps);
> + ret = -EINVAL;
> + goto err;
> + }
> +
> + conf.nb_queue_pairs = nb_qps;
> + conf.socket_id = SOCKET_ID_ANY;
> + conf.ff_disable = RTE_CRYPTODEV_FF_SECURITY;
> +
> + ret = rte_cryptodev_configure(cdev_id, &conf);
> + if (ret) {
> + evt_err("Failed to configure cryptodev (%u)", cdev_id);
> + goto err;
> + }
> +
> + qp_conf.nb_descriptors = NB_CRYPTODEV_DESCRIPTORS;
> + qp_conf.mp_session = t->ca_sess_pool;
> + qp_conf.mp_session_private = t->ca_sess_priv_pool;
> +
> + for (qp_id = 0; qp_id < conf.nb_queue_pairs; qp_id++) {
> + ret = rte_cryptodev_queue_pair_setup(
> + cdev_id, qp_id, &qp_conf,
> + rte_cryptodev_socket_id(cdev_id));
> + if (ret) {
> + evt_err("Failed to setup queue pairs on
> cryptodev %u\n",
> + cdev_id);
> + goto err;
Cryptodev need to be cleared also on this error.
> + }
> + }
> + }
> +
> + return 0;
> +err:
> + rte_mempool_free(t->ca_op_pool);
> + rte_mempool_free(t->ca_sess_pool);
> + rte_mempool_free(t->ca_sess_priv_pool);
> +
> + return ret;
> +}
> +
^ permalink raw reply [flat|nested] 43+ messages in thread
* RE: [EXT] [PATCH v5] app/eventdev: add crypto producer mode
2022-02-17 6:56 ` [EXT] " Akhil Goyal
@ 2022-02-18 12:00 ` Shijith Thotton
0 siblings, 0 replies; 43+ messages in thread
From: Shijith Thotton @ 2022-02-18 12:00 UTC (permalink / raw)
To: Akhil Goyal, dev, Jerin Jacob Kollanukkaran; +Cc: abhinandan.gujjar
Hi Akhil,
>Few comments inline.
>With those fixed.
>Acked-by: Akhil Goyal <gakhil@marvell.com>
>
Thanks.
>> +static int
>> +perf_event_crypto_adapter_setup(struct test_perf *t, struct prod_data *p)
>> +{
>> + struct evt_options *opt = t->opt;
>> + uint32_t cap;
>> + int ret;
>> +
>> + ret = rte_event_crypto_adapter_caps_get(p->dev_id, p->ca.cdev_id,
>> &cap);
>> + if (ret) {
>> + evt_err("Failed to get crypto adapter capabilities");
>> + return ret;
>> + }
>> +
>> + if (((opt->crypto_adptr_mode ==
>> RTE_EVENT_CRYPTO_ADAPTER_OP_NEW) &&
>> + !(cap &
>> RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_OP_NEW)) ||
>> + ((opt->crypto_adptr_mode ==
>> RTE_EVENT_CRYPTO_ADAPTER_OP_FORWARD) &&
>> + !(cap &
>> RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_OP_FWD))) {
>> + evt_err("crypto adapter %s mode unsupported\n",
>> + opt->crypto_adptr_mode ? "OP_FORWARD" :
>> "OP_NEW");
>> + return -EINVAL;
>> + } else if (!(cap &
>> RTE_EVENT_CRYPTO_ADAPTER_CAP_SESSION_PRIVATE_DATA)) {
>> + evt_err("Storing crypto session not supported");
>> + return -EINVAL;
>> + }
>
>The above errors should be -ENOTSUP. If the PMD is not capable, test should be
>skipped.
>
Okay, will add in v6.
>> +
>> + if (cap &
>> RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_QP_EV_BIND) {
>> + struct rte_event response_info;
>> +
>> + response_info.event = 0;
>> + response_info.op =
>> + opt->crypto_adptr_mode ==
>> +
>> RTE_EVENT_CRYPTO_ADAPTER_OP_NEW ?
>> + RTE_EVENT_OP_NEW :
>> + RTE_EVENT_OP_FORWARD;
>> + response_info.sched_type = RTE_SCHED_TYPE_ATOMIC;
>> + response_info.event_type = RTE_EVENT_TYPE_CRYPTODEV;
>> + response_info.queue_id = p->queue_id;
>> + ret = rte_event_crypto_adapter_queue_pair_add(
>> + TEST_PERF_CA_ID, p->ca.cdev_id, p->ca.cdev_qp_id,
>> + &response_info);
>> + } else {
>> + ret = rte_event_crypto_adapter_queue_pair_add(
>> + TEST_PERF_CA_ID, p->ca.cdev_id, p->ca.cdev_qp_id,
>> NULL);
>> + }
>> +
>> + return ret;
>> +}
>> +
>> +static struct rte_cryptodev_sym_session *
>> +cryptodev_sym_sess_create(struct prod_data *p, struct test_perf *t)
>> +{
>> + struct rte_crypto_sym_xform cipher_xform;
>> + struct rte_cryptodev_sym_session *sess;
>> +
>> + cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
>> + cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
>> + cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
>> + cipher_xform.next = NULL;
>> +
>> + sess = rte_cryptodev_sym_session_create(t->ca_sess_pool);
>> + if (sess == NULL) {
>> + evt_err("Failed to create sym session");
>> + return NULL;
>> + }
>> +
>> + if (rte_cryptodev_sym_session_init(p->ca.cdev_id, sess, &cipher_xform,
>> + t->ca_sess_priv_pool)) {
>> + evt_err("Failed to init session");
>> + return NULL;
>> + }
>> +
>> + return sess;
>> +}
>> +
>> int
>> perf_event_dev_port_setup(struct evt_test *test, struct evt_options *opt,
>> uint8_t stride, uint8_t nb_queues,
>> @@ -598,6 +796,80 @@ perf_event_dev_port_setup(struct evt_test *test,
>> struct evt_options *opt,
>> ret = perf_event_timer_adapter_setup(t);
>> if (ret)
>> return ret;
>> + } else if (opt->prod_type == EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR) {
>> + struct rte_event_port_conf conf = *port_conf;
>> + uint8_t cdev_id = 0;
>> + uint16_t qp_id = 0;
>> +
>> + ret = rte_event_crypto_adapter_create(TEST_PERF_CA_ID,
>> + opt->dev_id, &conf, 0);
>> + if (ret) {
>> + evt_err("Failed to create crypto adapter");
>> + return ret;
>> + }
>> +
>> + prod = 0;
>> + for (; port < perf_nb_event_ports(opt); port++) {
>> + struct rte_cryptodev_sym_session *crypto_sess;
>> + union rte_event_crypto_metadata m_data;
>> + struct prod_data *p = &t->prod[port];
>> + uint32_t flow_id;
>> +
>> + if (qp_id == rte_cryptodev_queue_pair_count(cdev_id))
>> {
>> + cdev_id++;
>> + qp_id = 0;
>> + }
>> +
>> + p->dev_id = opt->dev_id;
>> + p->port_id = port;
>> + p->queue_id = prod * stride;
>> + p->ca.cdev_id = cdev_id;
>> + p->ca.cdev_qp_id = qp_id;
>> + p->ca.crypto_sess = rte_zmalloc_socket(
>> + NULL, sizeof(crypto_sess) * t->nb_flows,
>> + RTE_CACHE_LINE_SIZE, opt->socket_id);
>> + p->t = t;
>> +
>> + m_data.request_info.cdev_id = p->ca.cdev_id;
>> + m_data.request_info.queue_pair_id = p-
>> >ca.cdev_qp_id;
>> + m_data.response_info.op =
>> + opt->crypto_adptr_mode ==
>> +
>> RTE_EVENT_CRYPTO_ADAPTER_OP_NEW ?
>> + RTE_EVENT_OP_NEW :
>> + RTE_EVENT_OP_FORWARD;
>> + m_data.response_info.sched_type =
>> RTE_SCHED_TYPE_ATOMIC;
>> + m_data.response_info.event_type =
>> + RTE_EVENT_TYPE_CRYPTODEV;
>> + m_data.response_info.queue_id = p->queue_id;
>> +
>> + for (flow_id = 0; flow_id < t->nb_flows; flow_id++) {
>> + crypto_sess = cryptodev_sym_sess_create(p, t);
>> + if (crypto_sess == NULL)
>> + return -ENOMEM;
>> +
>> + m_data.response_info.flow_id = flow_id;
>> + rte_cryptodev_sym_session_set_user_data(
>> + crypto_sess, &m_data,
>> sizeof(m_data));
>> + p->ca.crypto_sess[flow_id] = crypto_sess;
>> + }
>> +
>> + conf.event_port_cfg |=
>> + RTE_EVENT_PORT_CFG_HINT_PRODUCER |
>> + RTE_EVENT_PORT_CFG_HINT_CONSUMER;
>> +
>> + ret = rte_event_port_setup(opt->dev_id, port, &conf);
>> + if (ret) {
>> + evt_err("failed to setup port %d", port);
>> + return ret;
>> + }
>> +
>> + ret = perf_event_crypto_adapter_setup(t, p);
>> + if (ret)
>> + return ret;
>> +
>> + qp_id++;
>> + prod++;
>
>Memory leak for p->ca.crypto_sess in failure cases.
>Also check if it is getting freed when sessions are destroyed.
>
Okay, will add as part of cleanup.
>> + }
>> } else {
>> prod = 0;
>> for ( ; port < perf_nb_event_ports(opt); port++) {
>> @@ -659,7 +931,8 @@ perf_opt_check(struct evt_options *opt, uint64_t
>> nb_queues)
>> }
>>
>> if (opt->prod_type == EVT_PROD_TYPE_SYNT ||
>> - opt->prod_type ==
>> EVT_PROD_TYPE_EVENT_TIMER_ADPTR) {
>> + opt->prod_type == EVT_PROD_TYPE_EVENT_TIMER_ADPTR ||
>> + opt->prod_type == EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR) {
>> /* Validate producer lcores */
>> if (evt_lcores_has_overlap(opt->plcores,
>> rte_get_main_lcore())) {
>> @@ -767,8 +1040,7 @@ perf_ethdev_setup(struct evt_test *test, struct
>> evt_options *opt)
>> },
>> };
>>
>> - if (opt->prod_type == EVT_PROD_TYPE_SYNT ||
>> - opt->prod_type ==
>> EVT_PROD_TYPE_EVENT_TIMER_ADPTR)
>> + if (opt->prod_type != EVT_PROD_TYPE_ETH_RX_ADPTR)
>> return 0;
>>
>> if (!rte_eth_dev_count_avail()) {
>> @@ -841,6 +1113,147 @@ void perf_ethdev_destroy(struct evt_test *test,
>> struct evt_options *opt)
>> }
>> }
>>
>> +int
>> +perf_cryptodev_setup(struct evt_test *test, struct evt_options *opt)
>> +{
>> + uint8_t cdev_count, cdev_id, nb_plcores, nb_qps;
>> + struct test_perf *t = evt_test_priv(test);
>> + unsigned int max_session_size;
>> + uint32_t nb_sessions;
>> + int ret;
>> +
>> + if (opt->prod_type != EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR)
>> + return 0;
>> +
>> + cdev_count = rte_cryptodev_count();
>> + if (cdev_count == 0) {
>> + evt_err("No crypto devices available\n");
>> + return -ENODEV;
>> + }
>> +
>> + t->ca_op_pool = rte_crypto_op_pool_create(
>> + "crypto_op_pool", RTE_CRYPTO_OP_TYPE_SYMMETRIC, opt-
>> >pool_sz,
>> + 128, 0, rte_socket_id());
>> + if (t->ca_op_pool == NULL) {
>> + evt_err("Failed to create crypto op pool");
>> + return -ENOMEM;
>> + }
>> +
>> + nb_sessions = evt_nr_active_lcores(opt->plcores) * t->nb_flows;
>> + t->ca_sess_pool = rte_cryptodev_sym_session_pool_create(
>> + "ca_sess_pool", nb_sessions, 0, 0,
>> + sizeof(union rte_event_crypto_metadata), SOCKET_ID_ANY);
>> + if (t->ca_sess_pool == NULL) {
>> + evt_err("Failed to create sym session pool");
>> + ret = -ENOMEM;
>> + goto err;
>> + }
>> +
>> + max_session_size = 0;
>> + for (cdev_id = 0; cdev_id < cdev_count; cdev_id++) {
>> + unsigned int session_size;
>> +
>> + session_size =
>> + rte_cryptodev_sym_get_private_session_size(cdev_id);
>> + if (session_size > max_session_size)
>> + max_session_size = session_size;
>> + }
>> +
>> + max_session_size += sizeof(union rte_event_crypto_metadata);
>> + t->ca_sess_priv_pool = rte_mempool_create(
>> + "ca_sess_priv_pool", nb_sessions, max_session_size, 0, 0,
>> NULL,
>> + NULL, NULL, NULL, SOCKET_ID_ANY, 0);
>> + if (t->ca_sess_priv_pool == NULL) {
>> + evt_err("failed to create sym session private pool");
>> + ret = -ENOMEM;
>> + goto err;
>> + }
>> +
>> + /*
>> + * Calculate number of needed queue pairs, based on the amount of
>> + * available number of logical cores and crypto devices. For instance,
>> + * if there are 4 cores and 2 crypto devices, 2 queue pairs will be set
>> + * up per device.
>> + */
>> + nb_plcores = evt_nr_active_lcores(opt->plcores);
>> + nb_qps = (nb_plcores % cdev_count) ? (nb_plcores / cdev_count) + 1 :
>> + nb_plcores / cdev_count;
>> + for (cdev_id = 0; cdev_id < cdev_count; cdev_id++) {
>> + struct rte_cryptodev_qp_conf qp_conf;
>> + struct rte_cryptodev_config conf;
>> + struct rte_cryptodev_info info;
>> + int qp_id;
>> +
>> + rte_cryptodev_info_get(cdev_id, &info);
>> + if (nb_qps > info.max_nb_queue_pairs) {
>> + evt_err("Not enough queue pairs per cryptodev (%u)",
>> + nb_qps);
>> + ret = -EINVAL;
>> + goto err;
>> + }
>> +
>> + conf.nb_queue_pairs = nb_qps;
>> + conf.socket_id = SOCKET_ID_ANY;
>> + conf.ff_disable = RTE_CRYPTODEV_FF_SECURITY;
>> +
>> + ret = rte_cryptodev_configure(cdev_id, &conf);
>> + if (ret) {
>> + evt_err("Failed to configure cryptodev (%u)", cdev_id);
>> + goto err;
>> + }
>> +
>> + qp_conf.nb_descriptors = NB_CRYPTODEV_DESCRIPTORS;
>> + qp_conf.mp_session = t->ca_sess_pool;
>> + qp_conf.mp_session_private = t->ca_sess_priv_pool;
>> +
>> + for (qp_id = 0; qp_id < conf.nb_queue_pairs; qp_id++) {
>> + ret = rte_cryptodev_queue_pair_setup(
>> + cdev_id, qp_id, &qp_conf,
>> + rte_cryptodev_socket_id(cdev_id));
>> + if (ret) {
>> + evt_err("Failed to setup queue pairs on
>> cryptodev %u\n",
>> + cdev_id);
>> + goto err;
>
>Cryptodev need to be cleared also on this error.
Okay, will add in v6.
>
>> + }
>> + }
>> + }
>> +
>> + return 0;
>> +err:
>> + rte_mempool_free(t->ca_op_pool);
>> + rte_mempool_free(t->ca_sess_pool);
>> + rte_mempool_free(t->ca_sess_priv_pool);
>> +
>> + return ret;
>> +}
>> +
^ permalink raw reply [flat|nested] 43+ messages in thread
* [PATCH v6] app/eventdev: add crypto producer mode
2022-02-15 16:56 ` [PATCH v5] " Shijith Thotton
2022-02-16 4:47 ` Gujjar, Abhinandan S
2022-02-17 6:56 ` [EXT] " Akhil Goyal
@ 2022-02-18 12:11 ` Shijith Thotton
2022-02-24 4:46 ` [PATCH v7] " Shijith Thotton
2 siblings, 1 reply; 43+ messages in thread
From: Shijith Thotton @ 2022-02-18 12:11 UTC (permalink / raw)
To: dev, jerinj, gakhil, abhinandan.gujjar; +Cc: Shijith Thotton
In crypto producer mode, producer core enqueues cryptodev with software
generated crypto ops and worker core dequeues crypto completion events
from the eventdev. Event crypto metadata used for above processing is
pre-populated in each crypto session.
Parameter --prod_type_cryptodev can be used to enable crypto producer
mode. Parameter --crypto_adptr_mode can be set to select the crypto
adapter mode, 0 for OP_NEW and 1 for OP_FORWARD.
This mode can be used to measure the performance of crypto adapter.
Example:
./dpdk-test-eventdev -l 0-2 -w <EVENTDEV> -w <CRYPTODEV> -- \
--prod_type_cryptodev --crypto_adptr_mode 1 --test=perf_atq \
--stlist=a --wlcores 1 --plcores 2
Signed-off-by: Shijith Thotton <sthotton@marvell.com>
Acked-by: Akhil Goyal <gakhil@marvell.com>
---
v6:
* Added cryptodev close.
* Fixed cleanup.
* Updated release notes.
v5:
* Rebased.
v4:
* Addressed comments on v3 and rebased.
* Added cryptodev cleanup in signal handler.
v3:
* Reduce dereference inside loop.
v2:
* Fix RHEL compilation warning.
app/test-eventdev/evt_common.h | 3 +
app/test-eventdev/evt_main.c | 17 +-
app/test-eventdev/evt_options.c | 27 ++
app/test-eventdev/evt_options.h | 12 +
app/test-eventdev/evt_test.h | 6 +
app/test-eventdev/test_perf_atq.c | 49 +++
app/test-eventdev/test_perf_common.c | 440 ++++++++++++++++++++++++-
app/test-eventdev/test_perf_common.h | 18 +-
app/test-eventdev/test_perf_queue.c | 50 +++
doc/guides/rel_notes/release_22_03.rst | 5 +
doc/guides/tools/testeventdev.rst | 13 +
11 files changed, 632 insertions(+), 8 deletions(-)
diff --git a/app/test-eventdev/evt_common.h b/app/test-eventdev/evt_common.h
index f466434459..2f301a7e79 100644
--- a/app/test-eventdev/evt_common.h
+++ b/app/test-eventdev/evt_common.h
@@ -7,6 +7,7 @@
#include <rte_common.h>
#include <rte_debug.h>
+#include <rte_event_crypto_adapter.h>
#include <rte_eventdev.h>
#include <rte_service.h>
@@ -39,6 +40,7 @@ enum evt_prod_type {
EVT_PROD_TYPE_SYNT, /* Producer type Synthetic i.e. CPU. */
EVT_PROD_TYPE_ETH_RX_ADPTR, /* Producer type Eth Rx Adapter. */
EVT_PROD_TYPE_EVENT_TIMER_ADPTR, /* Producer type Timer Adapter. */
+ EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR, /* Producer type Crypto Adapter. */
EVT_PROD_TYPE_MAX,
};
@@ -77,6 +79,7 @@ struct evt_options {
uint64_t timer_tick_nsec;
uint64_t optm_timer_tick_nsec;
enum evt_prod_type prod_type;
+ enum rte_event_crypto_adapter_mode crypto_adptr_mode;
};
static inline bool
diff --git a/app/test-eventdev/evt_main.c b/app/test-eventdev/evt_main.c
index 194c980c7a..a7d6b0c1cf 100644
--- a/app/test-eventdev/evt_main.c
+++ b/app/test-eventdev/evt_main.c
@@ -35,6 +35,9 @@ signal_handler(int signum)
if (test->ops.ethdev_destroy)
test->ops.ethdev_destroy(test, &opt);
+ if (test->ops.cryptodev_destroy)
+ test->ops.cryptodev_destroy(test, &opt);
+
rte_eal_mp_wait_lcore();
if (test->ops.test_result)
@@ -162,11 +165,19 @@ main(int argc, char **argv)
}
}
+ /* Test specific cryptodev setup */
+ if (test->ops.cryptodev_setup) {
+ if (test->ops.cryptodev_setup(test, &opt)) {
+ evt_err("%s: cryptodev setup failed", opt.test_name);
+ goto ethdev_destroy;
+ }
+ }
+
/* Test specific eventdev setup */
if (test->ops.eventdev_setup) {
if (test->ops.eventdev_setup(test, &opt)) {
evt_err("%s: eventdev setup failed", opt.test_name);
- goto ethdev_destroy;
+ goto cryptodev_destroy;
}
}
@@ -197,6 +208,10 @@ main(int argc, char **argv)
if (test->ops.eventdev_destroy)
test->ops.eventdev_destroy(test, &opt);
+cryptodev_destroy:
+ if (test->ops.cryptodev_destroy)
+ test->ops.cryptodev_destroy(test, &opt);
+
ethdev_destroy:
if (test->ops.ethdev_destroy)
test->ops.ethdev_destroy(test, &opt);
diff --git a/app/test-eventdev/evt_options.c b/app/test-eventdev/evt_options.c
index 4ae44801da..d3c704d2b3 100644
--- a/app/test-eventdev/evt_options.c
+++ b/app/test-eventdev/evt_options.c
@@ -122,6 +122,26 @@ evt_parse_timer_prod_type_burst(struct evt_options *opt,
return 0;
}
+static int
+evt_parse_crypto_prod_type(struct evt_options *opt,
+ const char *arg __rte_unused)
+{
+ opt->prod_type = EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR;
+ return 0;
+}
+
+static int
+evt_parse_crypto_adptr_mode(struct evt_options *opt, const char *arg)
+{
+ uint8_t mode;
+ int ret;
+
+ ret = parser_read_uint8(&mode, arg);
+ opt->crypto_adptr_mode = mode ? RTE_EVENT_CRYPTO_ADAPTER_OP_FORWARD :
+ RTE_EVENT_CRYPTO_ADAPTER_OP_NEW;
+ return ret;
+}
+
static int
evt_parse_test_name(struct evt_options *opt, const char *arg)
{
@@ -335,6 +355,7 @@ usage(char *program)
"\t--queue_priority : enable queue priority\n"
"\t--deq_tmo_nsec : global dequeue timeout\n"
"\t--prod_type_ethdev : use ethernet device as producer.\n"
+ "\t--prod_type_cryptodev : use crypto device as producer.\n"
"\t--prod_type_timerdev : use event timer device as producer.\n"
"\t expiry_nsec would be the timeout\n"
"\t in ns.\n"
@@ -345,6 +366,8 @@ usage(char *program)
"\t--timer_tick_nsec : timer tick interval in ns.\n"
"\t--max_tmo_nsec : max timeout interval in ns.\n"
"\t--expiry_nsec : event timer expiry ns.\n"
+ "\t--crypto_adptr_mode : 0 for OP_NEW mode (default) and\n"
+ "\t 1 for OP_FORWARD mode.\n"
"\t--mbuf_sz : packet mbuf size.\n"
"\t--max_pkt_sz : max packet size.\n"
"\t--prod_enq_burst_sz : producer enqueue burst size.\n"
@@ -415,8 +438,10 @@ static struct option lgopts[] = {
{ EVT_QUEUE_PRIORITY, 0, 0, 0 },
{ EVT_DEQ_TMO_NSEC, 1, 0, 0 },
{ EVT_PROD_ETHDEV, 0, 0, 0 },
+ { EVT_PROD_CRYPTODEV, 0, 0, 0 },
{ EVT_PROD_TIMERDEV, 0, 0, 0 },
{ EVT_PROD_TIMERDEV_BURST, 0, 0, 0 },
+ { EVT_CRYPTO_ADPTR_MODE, 1, 0, 0 },
{ EVT_NB_TIMERS, 1, 0, 0 },
{ EVT_NB_TIMER_ADPTRS, 1, 0, 0 },
{ EVT_TIMER_TICK_NSEC, 1, 0, 0 },
@@ -455,8 +480,10 @@ evt_opts_parse_long(int opt_idx, struct evt_options *opt)
{ EVT_QUEUE_PRIORITY, evt_parse_queue_priority},
{ EVT_DEQ_TMO_NSEC, evt_parse_deq_tmo_nsec},
{ EVT_PROD_ETHDEV, evt_parse_eth_prod_type},
+ { EVT_PROD_CRYPTODEV, evt_parse_crypto_prod_type},
{ EVT_PROD_TIMERDEV, evt_parse_timer_prod_type},
{ EVT_PROD_TIMERDEV_BURST, evt_parse_timer_prod_type_burst},
+ { EVT_CRYPTO_ADPTR_MODE, evt_parse_crypto_adptr_mode},
{ EVT_NB_TIMERS, evt_parse_nb_timers},
{ EVT_NB_TIMER_ADPTRS, evt_parse_nb_timer_adptrs},
{ EVT_TIMER_TICK_NSEC, evt_parse_timer_tick_nsec},
diff --git a/app/test-eventdev/evt_options.h b/app/test-eventdev/evt_options.h
index 413d7092f0..2231c58801 100644
--- a/app/test-eventdev/evt_options.h
+++ b/app/test-eventdev/evt_options.h
@@ -9,6 +9,7 @@
#include <stdbool.h>
#include <rte_common.h>
+#include <rte_cryptodev.h>
#include <rte_ethdev.h>
#include <rte_eventdev.h>
#include <rte_lcore.h>
@@ -33,8 +34,10 @@
#define EVT_QUEUE_PRIORITY ("queue_priority")
#define EVT_DEQ_TMO_NSEC ("deq_tmo_nsec")
#define EVT_PROD_ETHDEV ("prod_type_ethdev")
+#define EVT_PROD_CRYPTODEV ("prod_type_cryptodev")
#define EVT_PROD_TIMERDEV ("prod_type_timerdev")
#define EVT_PROD_TIMERDEV_BURST ("prod_type_timerdev_burst")
+#define EVT_CRYPTO_ADPTR_MODE ("crypto_adptr_mode")
#define EVT_NB_TIMERS ("nb_timers")
#define EVT_NB_TIMER_ADPTRS ("nb_timer_adptrs")
#define EVT_TIMER_TICK_NSEC ("timer_tick_nsec")
@@ -249,6 +252,8 @@ evt_prod_id_to_name(enum evt_prod_type prod_type)
return "Ethdev Rx Adapter";
case EVT_PROD_TYPE_EVENT_TIMER_ADPTR:
return "Event timer adapter";
+ case EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR:
+ return "Event crypto adapter";
}
return "";
@@ -288,6 +293,13 @@ evt_dump_producer_type(struct evt_options *opt)
evt_dump("timer_tick_nsec", "%"PRIu64"",
opt->timer_tick_nsec);
break;
+ case EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR:
+ snprintf(name, EVT_PROD_MAX_NAME_LEN,
+ "Event crypto adapter producers");
+ evt_dump("crypto adapter mode", "%s",
+ opt->crypto_adptr_mode ? "OP_FORWARD" : "OP_NEW");
+ evt_dump("nb_cryptodev", "%u", rte_cryptodev_count());
+ break;
}
evt_dump("prod_type", "%s", name);
}
diff --git a/app/test-eventdev/evt_test.h b/app/test-eventdev/evt_test.h
index f07d2c3336..50fa474ec2 100644
--- a/app/test-eventdev/evt_test.h
+++ b/app/test-eventdev/evt_test.h
@@ -29,6 +29,8 @@ typedef int (*evt_test_mempool_setup_t)
(struct evt_test *test, struct evt_options *opt);
typedef int (*evt_test_ethdev_setup_t)
(struct evt_test *test, struct evt_options *opt);
+typedef int (*evt_test_cryptodev_setup_t)
+ (struct evt_test *test, struct evt_options *opt);
typedef int (*evt_test_eventdev_setup_t)
(struct evt_test *test, struct evt_options *opt);
typedef int (*evt_test_launch_lcores_t)
@@ -39,6 +41,8 @@ typedef void (*evt_test_eventdev_destroy_t)
(struct evt_test *test, struct evt_options *opt);
typedef void (*evt_test_ethdev_destroy_t)
(struct evt_test *test, struct evt_options *opt);
+typedef void (*evt_test_cryptodev_destroy_t)
+ (struct evt_test *test, struct evt_options *opt);
typedef void (*evt_test_mempool_destroy_t)
(struct evt_test *test, struct evt_options *opt);
typedef void (*evt_test_destroy_t)
@@ -52,10 +56,12 @@ struct evt_test_ops {
evt_test_mempool_setup_t mempool_setup;
evt_test_ethdev_setup_t ethdev_setup;
evt_test_eventdev_setup_t eventdev_setup;
+ evt_test_cryptodev_setup_t cryptodev_setup;
evt_test_launch_lcores_t launch_lcores;
evt_test_result_t test_result;
evt_test_eventdev_destroy_t eventdev_destroy;
evt_test_ethdev_destroy_t ethdev_destroy;
+ evt_test_cryptodev_destroy_t cryptodev_destroy;
evt_test_mempool_destroy_t mempool_destroy;
evt_test_destroy_t test_destroy;
};
diff --git a/app/test-eventdev/test_perf_atq.c b/app/test-eventdev/test_perf_atq.c
index 8fd51004ee..67ff681666 100644
--- a/app/test-eventdev/test_perf_atq.c
+++ b/app/test-eventdev/test_perf_atq.c
@@ -48,6 +48,22 @@ perf_atq_worker(void *arg, const int enable_fwd_latency)
continue;
}
+ if (prod_crypto_type &&
+ (ev.event_type == RTE_EVENT_TYPE_CRYPTODEV)) {
+ struct rte_crypto_op *op = ev.event_ptr;
+
+ if (op->status == RTE_CRYPTO_OP_STATUS_SUCCESS) {
+ if (op->sym->m_dst == NULL)
+ ev.event_ptr = op->sym->m_src;
+ else
+ ev.event_ptr = op->sym->m_dst;
+ rte_crypto_op_free(op);
+ } else {
+ rte_crypto_op_free(op);
+ continue;
+ }
+ }
+
if (enable_fwd_latency && !prod_timer_type)
/* first stage in pipeline, mark ts to compute fwd latency */
atq_mark_fwd_latency(&ev);
@@ -87,6 +103,25 @@ perf_atq_worker_burst(void *arg, const int enable_fwd_latency)
}
for (i = 0; i < nb_rx; i++) {
+ if (prod_crypto_type &&
+ (ev[i].event_type == RTE_EVENT_TYPE_CRYPTODEV)) {
+ struct rte_crypto_op *op = ev[i].event_ptr;
+
+ if (op->status ==
+ RTE_CRYPTO_OP_STATUS_SUCCESS) {
+ if (op->sym->m_dst == NULL)
+ ev[i].event_ptr =
+ op->sym->m_src;
+ else
+ ev[i].event_ptr =
+ op->sym->m_dst;
+ rte_crypto_op_free(op);
+ } else {
+ rte_crypto_op_free(op);
+ continue;
+ }
+ }
+
if (enable_fwd_latency && !prod_timer_type) {
rte_prefetch0(ev[i+1].event_ptr);
/* first stage in pipeline.
@@ -254,6 +289,18 @@ perf_atq_eventdev_setup(struct evt_test *test, struct evt_options *opt)
return ret;
}
}
+ } else if (opt->prod_type == EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR) {
+ uint8_t cdev_id, cdev_count;
+
+ cdev_count = rte_cryptodev_count();
+ for (cdev_id = 0; cdev_id < cdev_count; cdev_id++) {
+ ret = rte_cryptodev_start(cdev_id);
+ if (ret) {
+ evt_err("Failed to start cryptodev %u",
+ cdev_id);
+ return ret;
+ }
+ }
}
return 0;
@@ -295,12 +342,14 @@ static const struct evt_test_ops perf_atq = {
.opt_dump = perf_atq_opt_dump,
.test_setup = perf_test_setup,
.ethdev_setup = perf_ethdev_setup,
+ .cryptodev_setup = perf_cryptodev_setup,
.mempool_setup = perf_mempool_setup,
.eventdev_setup = perf_atq_eventdev_setup,
.launch_lcores = perf_atq_launch_lcores,
.eventdev_destroy = perf_eventdev_destroy,
.mempool_destroy = perf_mempool_destroy,
.ethdev_destroy = perf_ethdev_destroy,
+ .cryptodev_destroy = perf_cryptodev_destroy,
.test_result = perf_test_result,
.test_destroy = perf_test_destroy,
};
diff --git a/app/test-eventdev/test_perf_common.c b/app/test-eventdev/test_perf_common.c
index 9b73874151..e82b0a4aee 100644
--- a/app/test-eventdev/test_perf_common.c
+++ b/app/test-eventdev/test_perf_common.c
@@ -6,6 +6,8 @@
#include "test_perf_common.h"
+#define NB_CRYPTODEV_DESCRIPTORS 128
+
int
perf_test_result(struct evt_test *test, struct evt_options *opt)
{
@@ -272,6 +274,123 @@ perf_event_timer_producer_burst(void *arg)
return 0;
}
+static inline void
+crypto_adapter_enq_op_new(struct prod_data *p)
+{
+ struct rte_cryptodev_sym_session **crypto_sess = p->ca.crypto_sess;
+ struct test_perf *t = p->t;
+ const uint32_t nb_flows = t->nb_flows;
+ const uint64_t nb_pkts = t->nb_pkts;
+ struct rte_mempool *pool = t->pool;
+ struct rte_crypto_sym_op *sym_op;
+ struct evt_options *opt = t->opt;
+ uint16_t qp_id = p->ca.cdev_qp_id;
+ uint8_t cdev_id = p->ca.cdev_id;
+ uint32_t flow_counter = 0;
+ struct rte_crypto_op *op;
+ struct rte_mbuf *m;
+ uint64_t count = 0;
+ uint16_t len;
+
+ if (opt->verbose_level > 1)
+ printf("%s(): lcore %d queue %d cdev_id %u cdev_qp_id %u\n",
+ __func__, rte_lcore_id(), p->queue_id, p->ca.cdev_id,
+ p->ca.cdev_qp_id);
+
+ len = opt->mbuf_sz ? opt->mbuf_sz : RTE_ETHER_MIN_LEN;
+
+ while (count < nb_pkts && t->done == false) {
+ m = rte_pktmbuf_alloc(pool);
+ if (m == NULL)
+ continue;
+
+ rte_pktmbuf_append(m, len);
+ op = rte_crypto_op_alloc(t->ca_op_pool,
+ RTE_CRYPTO_OP_TYPE_SYMMETRIC);
+ sym_op = op->sym;
+ sym_op->m_src = m;
+ sym_op->cipher.data.offset = 0;
+ sym_op->cipher.data.length = len;
+ rte_crypto_op_attach_sym_session(
+ op, crypto_sess[flow_counter++ % nb_flows]);
+
+ while (rte_cryptodev_enqueue_burst(cdev_id, qp_id, &op, 1) != 1 &&
+ t->done == false)
+ rte_pause();
+
+ count++;
+ }
+}
+
+static inline void
+crypto_adapter_enq_op_fwd(struct prod_data *p)
+{
+ struct rte_cryptodev_sym_session **crypto_sess = p->ca.crypto_sess;
+ const uint8_t dev_id = p->dev_id;
+ const uint8_t port = p->port_id;
+ struct test_perf *t = p->t;
+ const uint32_t nb_flows = t->nb_flows;
+ const uint64_t nb_pkts = t->nb_pkts;
+ struct rte_mempool *pool = t->pool;
+ struct evt_options *opt = t->opt;
+ struct rte_crypto_sym_op *sym_op;
+ uint32_t flow_counter = 0;
+ struct rte_crypto_op *op;
+ struct rte_event ev;
+ struct rte_mbuf *m;
+ uint64_t count = 0;
+ uint16_t len;
+
+ if (opt->verbose_level > 1)
+ printf("%s(): lcore %d port %d queue %d cdev_id %u cdev_qp_id %u\n",
+ __func__, rte_lcore_id(), port, p->queue_id,
+ p->ca.cdev_id, p->ca.cdev_qp_id);
+
+ ev.event = 0;
+ ev.op = RTE_EVENT_OP_FORWARD;
+ ev.queue_id = p->queue_id;
+ ev.sched_type = RTE_SCHED_TYPE_ATOMIC;
+ ev.event_type = RTE_EVENT_TYPE_CPU;
+ len = opt->mbuf_sz ? opt->mbuf_sz : RTE_ETHER_MIN_LEN;
+
+ while (count < nb_pkts && t->done == false) {
+ m = rte_pktmbuf_alloc(pool);
+ if (m == NULL)
+ continue;
+
+ rte_pktmbuf_append(m, len);
+ op = rte_crypto_op_alloc(t->ca_op_pool,
+ RTE_CRYPTO_OP_TYPE_SYMMETRIC);
+ sym_op = op->sym;
+ sym_op->m_src = m;
+ sym_op->cipher.data.offset = 0;
+ sym_op->cipher.data.length = len;
+ rte_crypto_op_attach_sym_session(
+ op, crypto_sess[flow_counter++ % nb_flows]);
+ ev.event_ptr = op;
+
+ while (rte_event_crypto_adapter_enqueue(dev_id, port, &ev, 1) != 1 &&
+ t->done == false)
+ rte_pause();
+
+ count++;
+ }
+}
+
+static inline int
+perf_event_crypto_producer(void *arg)
+{
+ struct prod_data *p = arg;
+ struct evt_options *opt = p->t->opt;
+
+ if (opt->crypto_adptr_mode == RTE_EVENT_CRYPTO_ADAPTER_OP_NEW)
+ crypto_adapter_enq_op_new(p);
+ else
+ crypto_adapter_enq_op_fwd(p);
+
+ return 0;
+}
+
static int
perf_producer_wrapper(void *arg)
{
@@ -298,6 +417,8 @@ perf_producer_wrapper(void *arg)
else if (t->opt->prod_type == EVT_PROD_TYPE_EVENT_TIMER_ADPTR &&
t->opt->timdev_use_burst)
return perf_event_timer_producer_burst(arg);
+ else if (t->opt->prod_type == EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR)
+ return perf_event_crypto_producer(arg);
return 0;
}
@@ -405,8 +526,10 @@ perf_launch_lcores(struct evt_test *test, struct evt_options *opt,
if (remaining <= 0) {
t->result = EVT_TEST_SUCCESS;
if (opt->prod_type == EVT_PROD_TYPE_SYNT ||
- opt->prod_type ==
- EVT_PROD_TYPE_EVENT_TIMER_ADPTR) {
+ opt->prod_type ==
+ EVT_PROD_TYPE_EVENT_TIMER_ADPTR ||
+ opt->prod_type ==
+ EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR) {
t->done = true;
break;
}
@@ -415,7 +538,8 @@ perf_launch_lcores(struct evt_test *test, struct evt_options *opt,
if (new_cycles - dead_lock_cycles > dead_lock_sample &&
(opt->prod_type == EVT_PROD_TYPE_SYNT ||
- opt->prod_type == EVT_PROD_TYPE_EVENT_TIMER_ADPTR)) {
+ opt->prod_type == EVT_PROD_TYPE_EVENT_TIMER_ADPTR ||
+ opt->prod_type == EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR)) {
remaining = t->outstand_pkts - processed_pkts(t);
if (dead_lock_remaining == remaining) {
rte_event_dev_dump(opt->dev_id, stdout);
@@ -537,6 +661,80 @@ perf_event_timer_adapter_setup(struct test_perf *t)
return 0;
}
+static int
+perf_event_crypto_adapter_setup(struct test_perf *t, struct prod_data *p)
+{
+ struct evt_options *opt = t->opt;
+ uint32_t cap;
+ int ret;
+
+ ret = rte_event_crypto_adapter_caps_get(p->dev_id, p->ca.cdev_id, &cap);
+ if (ret) {
+ evt_err("Failed to get crypto adapter capabilities");
+ return ret;
+ }
+
+ if (((opt->crypto_adptr_mode == RTE_EVENT_CRYPTO_ADAPTER_OP_NEW) &&
+ !(cap & RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_OP_NEW)) ||
+ ((opt->crypto_adptr_mode == RTE_EVENT_CRYPTO_ADAPTER_OP_FORWARD) &&
+ !(cap & RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_OP_FWD))) {
+ evt_err("crypto adapter %s mode unsupported\n",
+ opt->crypto_adptr_mode ? "OP_FORWARD" : "OP_NEW");
+ return -ENOTSUP;
+ } else if (!(cap & RTE_EVENT_CRYPTO_ADAPTER_CAP_SESSION_PRIVATE_DATA)) {
+ evt_err("Storing crypto session not supported");
+ return -ENOTSUP;
+ }
+
+ if (cap & RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_QP_EV_BIND) {
+ struct rte_event response_info;
+
+ response_info.event = 0;
+ response_info.op =
+ opt->crypto_adptr_mode ==
+ RTE_EVENT_CRYPTO_ADAPTER_OP_NEW ?
+ RTE_EVENT_OP_NEW :
+ RTE_EVENT_OP_FORWARD;
+ response_info.sched_type = RTE_SCHED_TYPE_ATOMIC;
+ response_info.event_type = RTE_EVENT_TYPE_CRYPTODEV;
+ response_info.queue_id = p->queue_id;
+ ret = rte_event_crypto_adapter_queue_pair_add(
+ TEST_PERF_CA_ID, p->ca.cdev_id, p->ca.cdev_qp_id,
+ &response_info);
+ } else {
+ ret = rte_event_crypto_adapter_queue_pair_add(
+ TEST_PERF_CA_ID, p->ca.cdev_id, p->ca.cdev_qp_id, NULL);
+ }
+
+ return ret;
+}
+
+static struct rte_cryptodev_sym_session *
+cryptodev_sym_sess_create(struct prod_data *p, struct test_perf *t)
+{
+ struct rte_crypto_sym_xform cipher_xform;
+ struct rte_cryptodev_sym_session *sess;
+
+ cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
+ cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
+ cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
+ cipher_xform.next = NULL;
+
+ sess = rte_cryptodev_sym_session_create(t->ca_sess_pool);
+ if (sess == NULL) {
+ evt_err("Failed to create sym session");
+ return NULL;
+ }
+
+ if (rte_cryptodev_sym_session_init(p->ca.cdev_id, sess, &cipher_xform,
+ t->ca_sess_priv_pool)) {
+ evt_err("Failed to init session");
+ return NULL;
+ }
+
+ return sess;
+}
+
int
perf_event_dev_port_setup(struct evt_test *test, struct evt_options *opt,
uint8_t stride, uint8_t nb_queues,
@@ -598,6 +796,80 @@ perf_event_dev_port_setup(struct evt_test *test, struct evt_options *opt,
ret = perf_event_timer_adapter_setup(t);
if (ret)
return ret;
+ } else if (opt->prod_type == EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR) {
+ struct rte_event_port_conf conf = *port_conf;
+ uint8_t cdev_id = 0;
+ uint16_t qp_id = 0;
+
+ ret = rte_event_crypto_adapter_create(TEST_PERF_CA_ID,
+ opt->dev_id, &conf, 0);
+ if (ret) {
+ evt_err("Failed to create crypto adapter");
+ return ret;
+ }
+
+ prod = 0;
+ for (; port < perf_nb_event_ports(opt); port++) {
+ struct rte_cryptodev_sym_session *crypto_sess;
+ union rte_event_crypto_metadata m_data;
+ struct prod_data *p = &t->prod[port];
+ uint32_t flow_id;
+
+ if (qp_id == rte_cryptodev_queue_pair_count(cdev_id)) {
+ cdev_id++;
+ qp_id = 0;
+ }
+
+ p->dev_id = opt->dev_id;
+ p->port_id = port;
+ p->queue_id = prod * stride;
+ p->ca.cdev_id = cdev_id;
+ p->ca.cdev_qp_id = qp_id;
+ p->ca.crypto_sess = rte_zmalloc_socket(
+ NULL, sizeof(crypto_sess) * t->nb_flows,
+ RTE_CACHE_LINE_SIZE, opt->socket_id);
+ p->t = t;
+
+ m_data.request_info.cdev_id = p->ca.cdev_id;
+ m_data.request_info.queue_pair_id = p->ca.cdev_qp_id;
+ m_data.response_info.op =
+ opt->crypto_adptr_mode ==
+ RTE_EVENT_CRYPTO_ADAPTER_OP_NEW ?
+ RTE_EVENT_OP_NEW :
+ RTE_EVENT_OP_FORWARD;
+ m_data.response_info.sched_type = RTE_SCHED_TYPE_ATOMIC;
+ m_data.response_info.event_type =
+ RTE_EVENT_TYPE_CRYPTODEV;
+ m_data.response_info.queue_id = p->queue_id;
+
+ for (flow_id = 0; flow_id < t->nb_flows; flow_id++) {
+ crypto_sess = cryptodev_sym_sess_create(p, t);
+ if (crypto_sess == NULL)
+ return -ENOMEM;
+
+ m_data.response_info.flow_id = flow_id;
+ rte_cryptodev_sym_session_set_user_data(
+ crypto_sess, &m_data, sizeof(m_data));
+ p->ca.crypto_sess[flow_id] = crypto_sess;
+ }
+
+ conf.event_port_cfg |=
+ RTE_EVENT_PORT_CFG_HINT_PRODUCER |
+ RTE_EVENT_PORT_CFG_HINT_CONSUMER;
+
+ ret = rte_event_port_setup(opt->dev_id, port, &conf);
+ if (ret) {
+ evt_err("failed to setup port %d", port);
+ return ret;
+ }
+
+ ret = perf_event_crypto_adapter_setup(t, p);
+ if (ret)
+ return ret;
+
+ qp_id++;
+ prod++;
+ }
} else {
prod = 0;
for ( ; port < perf_nb_event_ports(opt); port++) {
@@ -659,7 +931,8 @@ perf_opt_check(struct evt_options *opt, uint64_t nb_queues)
}
if (opt->prod_type == EVT_PROD_TYPE_SYNT ||
- opt->prod_type == EVT_PROD_TYPE_EVENT_TIMER_ADPTR) {
+ opt->prod_type == EVT_PROD_TYPE_EVENT_TIMER_ADPTR ||
+ opt->prod_type == EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR) {
/* Validate producer lcores */
if (evt_lcores_has_overlap(opt->plcores,
rte_get_main_lcore())) {
@@ -767,8 +1040,7 @@ perf_ethdev_setup(struct evt_test *test, struct evt_options *opt)
},
};
- if (opt->prod_type == EVT_PROD_TYPE_SYNT ||
- opt->prod_type == EVT_PROD_TYPE_EVENT_TIMER_ADPTR)
+ if (opt->prod_type != EVT_PROD_TYPE_ETH_RX_ADPTR)
return 0;
if (!rte_eth_dev_count_avail()) {
@@ -841,6 +1113,162 @@ void perf_ethdev_destroy(struct evt_test *test, struct evt_options *opt)
}
}
+int
+perf_cryptodev_setup(struct evt_test *test, struct evt_options *opt)
+{
+ uint8_t cdev_count, cdev_id, nb_plcores, nb_qps;
+ struct test_perf *t = evt_test_priv(test);
+ unsigned int max_session_size;
+ uint32_t nb_sessions;
+ int ret;
+
+ if (opt->prod_type != EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR)
+ return 0;
+
+ cdev_count = rte_cryptodev_count();
+ if (cdev_count == 0) {
+ evt_err("No crypto devices available\n");
+ return -ENODEV;
+ }
+
+ t->ca_op_pool = rte_crypto_op_pool_create(
+ "crypto_op_pool", RTE_CRYPTO_OP_TYPE_SYMMETRIC, opt->pool_sz,
+ 128, 0, rte_socket_id());
+ if (t->ca_op_pool == NULL) {
+ evt_err("Failed to create crypto op pool");
+ return -ENOMEM;
+ }
+
+ nb_sessions = evt_nr_active_lcores(opt->plcores) * t->nb_flows;
+ t->ca_sess_pool = rte_cryptodev_sym_session_pool_create(
+ "ca_sess_pool", nb_sessions, 0, 0,
+ sizeof(union rte_event_crypto_metadata), SOCKET_ID_ANY);
+ if (t->ca_sess_pool == NULL) {
+ evt_err("Failed to create sym session pool");
+ ret = -ENOMEM;
+ goto err;
+ }
+
+ max_session_size = 0;
+ for (cdev_id = 0; cdev_id < cdev_count; cdev_id++) {
+ unsigned int session_size;
+
+ session_size =
+ rte_cryptodev_sym_get_private_session_size(cdev_id);
+ if (session_size > max_session_size)
+ max_session_size = session_size;
+ }
+
+ max_session_size += sizeof(union rte_event_crypto_metadata);
+ t->ca_sess_priv_pool = rte_mempool_create(
+ "ca_sess_priv_pool", nb_sessions, max_session_size, 0, 0, NULL,
+ NULL, NULL, NULL, SOCKET_ID_ANY, 0);
+ if (t->ca_sess_priv_pool == NULL) {
+ evt_err("failed to create sym session private pool");
+ ret = -ENOMEM;
+ goto err;
+ }
+
+ /*
+ * Calculate number of needed queue pairs, based on the amount of
+ * available number of logical cores and crypto devices. For instance,
+ * if there are 4 cores and 2 crypto devices, 2 queue pairs will be set
+ * up per device.
+ */
+ nb_plcores = evt_nr_active_lcores(opt->plcores);
+ nb_qps = (nb_plcores % cdev_count) ? (nb_plcores / cdev_count) + 1 :
+ nb_plcores / cdev_count;
+ for (cdev_id = 0; cdev_id < cdev_count; cdev_id++) {
+ struct rte_cryptodev_qp_conf qp_conf;
+ struct rte_cryptodev_config conf;
+ struct rte_cryptodev_info info;
+ int qp_id;
+
+ rte_cryptodev_info_get(cdev_id, &info);
+ if (nb_qps > info.max_nb_queue_pairs) {
+ evt_err("Not enough queue pairs per cryptodev (%u)",
+ nb_qps);
+ ret = -EINVAL;
+ goto err;
+ }
+
+ conf.nb_queue_pairs = nb_qps;
+ conf.socket_id = SOCKET_ID_ANY;
+ conf.ff_disable = RTE_CRYPTODEV_FF_SECURITY;
+
+ ret = rte_cryptodev_configure(cdev_id, &conf);
+ if (ret) {
+ evt_err("Failed to configure cryptodev (%u)", cdev_id);
+ goto err;
+ }
+
+ qp_conf.nb_descriptors = NB_CRYPTODEV_DESCRIPTORS;
+ qp_conf.mp_session = t->ca_sess_pool;
+ qp_conf.mp_session_private = t->ca_sess_priv_pool;
+
+ for (qp_id = 0; qp_id < conf.nb_queue_pairs; qp_id++) {
+ ret = rte_cryptodev_queue_pair_setup(
+ cdev_id, qp_id, &qp_conf,
+ rte_cryptodev_socket_id(cdev_id));
+ if (ret) {
+ evt_err("Failed to setup queue pairs on cryptodev %u\n",
+ cdev_id);
+ goto err;
+ }
+ }
+ }
+
+ return 0;
+err:
+ for (cdev_id = 0; cdev_id < cdev_count; cdev_id++)
+ rte_cryptodev_close(cdev_id);
+
+ rte_mempool_free(t->ca_op_pool);
+ rte_mempool_free(t->ca_sess_pool);
+ rte_mempool_free(t->ca_sess_priv_pool);
+
+ return ret;
+}
+
+void
+perf_cryptodev_destroy(struct evt_test *test, struct evt_options *opt)
+{
+ uint8_t cdev_id, cdev_count = rte_cryptodev_count();
+ struct test_perf *t = evt_test_priv(test);
+ uint16_t port;
+
+ if (opt->prod_type != EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR)
+ return;
+
+ for (port = t->nb_workers; port < perf_nb_event_ports(opt); port++) {
+ struct rte_cryptodev_sym_session *sess;
+ struct prod_data *p = &t->prod[port];
+ uint32_t flow_id;
+ uint8_t cdev_id;
+
+ for (flow_id = 0; flow_id < t->nb_flows; flow_id++) {
+ sess = p->ca.crypto_sess[flow_id];
+ cdev_id = p->ca.cdev_id;
+ rte_cryptodev_sym_session_clear(cdev_id, sess);
+ rte_cryptodev_sym_session_free(sess);
+ }
+
+ rte_event_crypto_adapter_queue_pair_del(
+ TEST_PERF_CA_ID, p->ca.cdev_id, p->ca.cdev_qp_id);
+ }
+
+ rte_event_crypto_adapter_free(TEST_PERF_CA_ID);
+
+ for (cdev_id = 0; cdev_id < cdev_count; cdev_id++) {
+ rte_cryptodev_stop(cdev_id);
+ rte_cryptodev_close(cdev_id);
+ }
+
+ rte_mempool_free(t->ca_op_pool);
+ rte_mempool_free(t->ca_sess_pool);
+ rte_mempool_free(t->ca_sess_priv_pool);
+}
+
int
perf_mempool_setup(struct evt_test *test, struct evt_options *opt)
{
diff --git a/app/test-eventdev/test_perf_common.h b/app/test-eventdev/test_perf_common.h
index 14dcf80429..ea0907d61a 100644
--- a/app/test-eventdev/test_perf_common.h
+++ b/app/test-eventdev/test_perf_common.h
@@ -9,9 +9,11 @@
#include <stdbool.h>
#include <unistd.h>
+#include <rte_cryptodev.h>
#include <rte_cycles.h>
#include <rte_ethdev.h>
#include <rte_eventdev.h>
+#include <rte_event_crypto_adapter.h>
#include <rte_event_eth_rx_adapter.h>
#include <rte_event_timer_adapter.h>
#include <rte_lcore.h>
@@ -23,6 +25,8 @@
#include "evt_options.h"
#include "evt_test.h"
+#define TEST_PERF_CA_ID 0
+
struct test_perf;
struct worker_data {
@@ -33,14 +37,19 @@ struct worker_data {
struct test_perf *t;
} __rte_cache_aligned;
+struct crypto_adptr_data {
+ uint8_t cdev_id;
+ uint16_t cdev_qp_id;
+ struct rte_cryptodev_sym_session **crypto_sess;
+};
struct prod_data {
uint8_t dev_id;
uint8_t port_id;
uint8_t queue_id;
+ struct crypto_adptr_data ca;
struct test_perf *t;
} __rte_cache_aligned;
-
struct test_perf {
/* Don't change the offset of "done". Signal handler use this memory
* to terminate all lcores work.
@@ -58,6 +67,9 @@ struct test_perf {
uint8_t sched_type_list[EVT_MAX_STAGES] __rte_cache_aligned;
struct rte_event_timer_adapter *timer_adptr[
RTE_EVENT_TIMER_ADAPTER_NUM_MAX] __rte_cache_aligned;
+ struct rte_mempool *ca_op_pool;
+ struct rte_mempool *ca_sess_pool;
+ struct rte_mempool *ca_sess_priv_pool;
} __rte_cache_aligned;
struct perf_elt {
@@ -81,6 +93,8 @@ struct perf_elt {
const uint8_t port = w->port_id;\
const uint8_t prod_timer_type = \
opt->prod_type == EVT_PROD_TYPE_EVENT_TIMER_ADPTR;\
+ const uint8_t prod_crypto_type = \
+ opt->prod_type == EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR;\
uint8_t *const sched_type_list = &t->sched_type_list[0];\
struct rte_mempool *const pool = t->pool;\
const uint8_t nb_stages = t->opt->nb_stages;\
@@ -154,6 +168,7 @@ int perf_test_result(struct evt_test *test, struct evt_options *opt);
int perf_opt_check(struct evt_options *opt, uint64_t nb_queues);
int perf_test_setup(struct evt_test *test, struct evt_options *opt);
int perf_ethdev_setup(struct evt_test *test, struct evt_options *opt);
+int perf_cryptodev_setup(struct evt_test *test, struct evt_options *opt);
int perf_mempool_setup(struct evt_test *test, struct evt_options *opt);
int perf_event_dev_port_setup(struct evt_test *test, struct evt_options *opt,
uint8_t stride, uint8_t nb_queues,
@@ -164,6 +179,7 @@ int perf_launch_lcores(struct evt_test *test, struct evt_options *opt,
void perf_opt_dump(struct evt_options *opt, uint8_t nb_queues);
void perf_test_destroy(struct evt_test *test, struct evt_options *opt);
void perf_eventdev_destroy(struct evt_test *test, struct evt_options *opt);
+void perf_cryptodev_destroy(struct evt_test *test, struct evt_options *opt);
void perf_ethdev_destroy(struct evt_test *test, struct evt_options *opt);
void perf_mempool_destroy(struct evt_test *test, struct evt_options *opt);
diff --git a/app/test-eventdev/test_perf_queue.c b/app/test-eventdev/test_perf_queue.c
index f4ea3a795f..dcf6d82947 100644
--- a/app/test-eventdev/test_perf_queue.c
+++ b/app/test-eventdev/test_perf_queue.c
@@ -49,6 +49,23 @@ perf_queue_worker(void *arg, const int enable_fwd_latency)
rte_pause();
continue;
}
+
+ if (prod_crypto_type &&
+ (ev.event_type == RTE_EVENT_TYPE_CRYPTODEV)) {
+ struct rte_crypto_op *op = ev.event_ptr;
+
+ if (op->status == RTE_CRYPTO_OP_STATUS_SUCCESS) {
+ if (op->sym->m_dst == NULL)
+ ev.event_ptr = op->sym->m_src;
+ else
+ ev.event_ptr = op->sym->m_dst;
+ rte_crypto_op_free(op);
+ } else {
+ rte_crypto_op_free(op);
+ continue;
+ }
+ }
+
if (enable_fwd_latency && !prod_timer_type)
/* first q in pipeline, mark timestamp to compute fwd latency */
mark_fwd_latency(&ev, nb_stages);
@@ -88,6 +105,25 @@ perf_queue_worker_burst(void *arg, const int enable_fwd_latency)
}
for (i = 0; i < nb_rx; i++) {
+ if (prod_crypto_type &&
+ (ev[i].event_type == RTE_EVENT_TYPE_CRYPTODEV)) {
+ struct rte_crypto_op *op = ev[i].event_ptr;
+
+ if (op->status ==
+ RTE_CRYPTO_OP_STATUS_SUCCESS) {
+ if (op->sym->m_dst == NULL)
+ ev[i].event_ptr =
+ op->sym->m_src;
+ else
+ ev[i].event_ptr =
+ op->sym->m_dst;
+ rte_crypto_op_free(op);
+ } else {
+ rte_crypto_op_free(op);
+ continue;
+ }
+ }
+
if (enable_fwd_latency && !prod_timer_type) {
rte_prefetch0(ev[i+1].event_ptr);
/* first queue in pipeline.
@@ -269,6 +305,18 @@ perf_queue_eventdev_setup(struct evt_test *test, struct evt_options *opt)
return ret;
}
}
+ } else if (opt->prod_type == EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR) {
+ uint8_t cdev_id, cdev_count;
+
+ cdev_count = rte_cryptodev_count();
+ for (cdev_id = 0; cdev_id < cdev_count; cdev_id++) {
+ ret = rte_cryptodev_start(cdev_id);
+ if (ret) {
+ evt_err("Failed to start cryptodev %u",
+ cdev_id);
+ return ret;
+ }
+ }
}
return 0;
@@ -311,11 +359,13 @@ static const struct evt_test_ops perf_queue = {
.test_setup = perf_test_setup,
.mempool_setup = perf_mempool_setup,
.ethdev_setup = perf_ethdev_setup,
+ .cryptodev_setup = perf_cryptodev_setup,
.eventdev_setup = perf_queue_eventdev_setup,
.launch_lcores = perf_queue_launch_lcores,
.eventdev_destroy = perf_eventdev_destroy,
.mempool_destroy = perf_mempool_destroy,
.ethdev_destroy = perf_ethdev_destroy,
+ .cryptodev_destroy = perf_cryptodev_destroy,
.test_result = perf_test_result,
.test_destroy = perf_test_destroy,
};
diff --git a/doc/guides/rel_notes/release_22_03.rst b/doc/guides/rel_notes/release_22_03.rst
index ff3095d742..5da383b32e 100644
--- a/doc/guides/rel_notes/release_22_03.rst
+++ b/doc/guides/rel_notes/release_22_03.rst
@@ -149,6 +149,11 @@ New Features
* Called ``rte_ipv4/6_udptcp_cksum_mbuf()`` functions in testpmd csum mode
to support software UDP/TCP checksum over multiple segments.
+* **Added crypto producer mode in test-eventdev.**
+
+ * Crypto producer mode helps to measure performance of OP_NEW and OP_FORWARD
+ modes of event crypto adapter.
+
Removed Items
-------------
diff --git a/doc/guides/tools/testeventdev.rst b/doc/guides/tools/testeventdev.rst
index 48efb9ea6e..f7d813226d 100644
--- a/doc/guides/tools/testeventdev.rst
+++ b/doc/guides/tools/testeventdev.rst
@@ -120,6 +120,10 @@ The following are the application command-line options:
Use burst mode event timer adapter as producer.
+* ``--prod_type_cryptodev``
+
+ Use crypto device as producer.
+
* ``--timer_tick_nsec``
Used to dictate number of nano seconds between bucket traversal of the
@@ -148,6 +152,11 @@ The following are the application command-line options:
timeout is out of the supported range of event device it will be
adjusted to the highest/lowest supported dequeue timeout supported.
+* ``--crypto_adptr_mode``
+
+ Set crypto adapter mode. Use 0 for OP_NEW (default) and 1 for
+ OP_FORWARD mode.
+
* ``--mbuf_sz``
Set packet mbuf size. Can be used to configure Jumbo Frames. Only
@@ -420,6 +429,7 @@ Supported application command line options are following::
--prod_type_ethdev
--prod_type_timerdev_burst
--prod_type_timerdev
+ --prod_type_cryptodev
--prod_enq_burst_sz
--timer_tick_nsec
--max_tmo_nsec
@@ -427,6 +437,7 @@ Supported application command line options are following::
--nb_timers
--nb_timer_adptrs
--deq_tmo_nsec
+ --crypto_adptr_mode
Example
^^^^^^^
@@ -529,12 +540,14 @@ Supported application command line options are following::
--prod_type_ethdev
--prod_type_timerdev_burst
--prod_type_timerdev
+ --prod_type_cryptodev
--timer_tick_nsec
--max_tmo_nsec
--expiry_nsec
--nb_timers
--nb_timer_adptrs
--deq_tmo_nsec
+ --crypto_adptr_mode
Example
^^^^^^^
--
2.25.1
^ permalink raw reply [flat|nested] 43+ messages in thread
* RE: [PATCH v5] app/eventdev: add crypto producer mode
2022-02-17 5:33 ` Gujjar, Abhinandan S
@ 2022-02-21 13:10 ` Van Haaren, Harry
2022-02-22 7:03 ` Shijith Thotton
0 siblings, 1 reply; 43+ messages in thread
From: Van Haaren, Harry @ 2022-02-21 13:10 UTC (permalink / raw)
To: Gujjar, Abhinandan S, Jerin Jacob, Hemant Agrawal, Nipun Gupta
Cc: Shijith Thotton, Jerin Jacob Kollanukkaran, dev
<snip>
> > -----Original Message-----
> > From: Jerin Jacob <jerinjacobk@gmail.com>
> > Sent: Wednesday, February 16, 2022 2:25 PM
> > To: Gujjar, Abhinandan S <abhinandan.gujjar@intel.com>; Hemant Agrawal
> > <hemant.agrawal@nxp.com>; Nipun Gupta <nipun.gupta@nxp.com>; Van
> > Haaren, Harry <harry.van.haaren@intel.com>
> > Cc: Shijith Thotton <sthotton@marvell.com>; Jerin Jacob Kollanukkaran
> > <jerinj@marvell.com>; dev@dpdk.org
> > Subject: Re: [PATCH v5] app/eventdev: add crypto producer mode
> >
> > + @Van Haaren, Harry
Hi All,
I have been away on vacation for the last week - hence the delay in reply on this thread.
<snip discussion>
> > > [1]
> > > Steps to reproduce:
> > > * Clone http://dpdk.org/git/next/dpdk-next-eventdev
> > > * Apply [v5] app/eventdev: add crypto producer mode
> > > git-pw --server https://patches.dpdk.org/api/1.2/ --project dpdk
> > > patch apply 107645
> > > * Apply [RFC] app/eventdev: add software crypto adapter support
> > > git-pw --server https://patches.dpdk.org/api/1.2/ --project dpdk
> > > patch apply 107029
> > > * meson x86_build_debug -Dc_args='-g -O0' -Ddisable_drivers="*/cnxk"
> > > * ninja -C x86_build_debug
> > > * Command to reproduce crash
> > > sudo ./x86_build_debug/app/dpdk-test-eventdev -l 0-8 -s 0xf0
> > > --vdev=event_sw0 --vdev="crypto_null" -- --prod_type_cryptodev
> > > --crypto_adptr_mode 0 --test=perf_queue --stlist=a --wlcores 1
> > > --plcores 2
Can confirm that these steps indeed cause segfault as reported.
In debugging, it seems like there are *zero* NEW events, and large numbers of
RELEASE events are enqueued... if so, this is not compliant to the Eventdev API.
Can somebody confirm that?
The SW PMD is being told there are events to release, but there aren't any.
Eventually, this leads to a mismatch in credit allocations, which then causes
the IQ-chunks datastructure to corrupt.
All in all, I'm not convinced this is a SW PMD issue yet - initial testing
points to incorrect event OP NEW/FWD/RELEASE usage. Can we verify
that the OPs being sent are correct?
Regards, -Harry
^ permalink raw reply [flat|nested] 43+ messages in thread
* RE: [PATCH v5] app/eventdev: add crypto producer mode
2022-02-21 13:10 ` Van Haaren, Harry
@ 2022-02-22 7:03 ` Shijith Thotton
2022-02-23 9:02 ` Gujjar, Abhinandan S
0 siblings, 1 reply; 43+ messages in thread
From: Shijith Thotton @ 2022-02-22 7:03 UTC (permalink / raw)
To: Van Haaren, Harry, Gujjar, Abhinandan S, Jerin Jacob,
Hemant Agrawal, Nipun Gupta
Cc: Jerin Jacob Kollanukkaran, dev
>> >
>> > + @Van Haaren, Harry
>
>Hi All,
>
>I have been away on vacation for the last week - hence the delay in reply on this
>thread.
>
><snip discussion>
>
>> > > [1]
>> > > Steps to reproduce:
>> > > * Clone https://urldefense.proofpoint.com/v2/url?u=http-
>3A__dpdk.org_git_next_dpdk-2Dnext-
>2Deventdev&d=DwIGaQ&c=nKjWec2b6R0mOyPaz7xtfQ&r=G9w4KsPaQLACBfGCL
>35PtiRH996yqJDxAZwrWegU2qQ&m=-yaLm_cvg5cKTbBy3OoUs719W-
>E3ARETajJQmUvoE4aSAPjcEn1kulkRNxTn841D&s=lZjsn2zecck8IBBQRA7fId7BXSYKk
>U8Tjj10gNQLB6U&e=
>> > > * Apply [v5] app/eventdev: add crypto producer mode
>> > > git-pw --server https://urldefense.proofpoint.com/v2/url?u=https-
>3A__patches.dpdk.org_api_1.2_&d=DwIGaQ&c=nKjWec2b6R0mOyPaz7xtfQ&r=G
>9w4KsPaQLACBfGCL35PtiRH996yqJDxAZwrWegU2qQ&m=-
>yaLm_cvg5cKTbBy3OoUs719W-
>E3ARETajJQmUvoE4aSAPjcEn1kulkRNxTn841D&s=VBQtpQ8vwHt9BnMrPLzSneOm
>zhLdP5bfyLuY42fCnak&e= --project dpdk
>> > > patch apply 107645
>> > > * Apply [RFC] app/eventdev: add software crypto adapter support
>> > > git-pw --server https://urldefense.proofpoint.com/v2/url?u=https-
>3A__patches.dpdk.org_api_1.2_&d=DwIGaQ&c=nKjWec2b6R0mOyPaz7xtfQ&r=G
>9w4KsPaQLACBfGCL35PtiRH996yqJDxAZwrWegU2qQ&m=-
>yaLm_cvg5cKTbBy3OoUs719W-
>E3ARETajJQmUvoE4aSAPjcEn1kulkRNxTn841D&s=VBQtpQ8vwHt9BnMrPLzSneOm
>zhLdP5bfyLuY42fCnak&e= --project dpdk
>> > > patch apply 107029
>> > > * meson x86_build_debug -Dc_args='-g -O0' -Ddisable_drivers="*/cnxk"
>> > > * ninja -C x86_build_debug
>> > > * Command to reproduce crash
>> > > sudo ./x86_build_debug/app/dpdk-test-eventdev -l 0-8 -s 0xf0
>> > > --vdev=event_sw0 --vdev="crypto_null" -- --prod_type_cryptodev
>> > > --crypto_adptr_mode 0 --test=perf_queue --stlist=a --wlcores 1
>> > > --plcores 2
>
>Can confirm that these steps indeed cause segfault as reported.
>
>In debugging, it seems like there are *zero* NEW events, and large numbers of
>RELEASE events are enqueued... if so, this is not compliant to the Eventdev API.
>Can somebody confirm that?
>
>The SW PMD is being told there are events to release, but there aren't any.
>Eventually, this leads to a mismatch in credit allocations, which then causes
>the IQ-chunks datastructure to corrupt.
>
>All in all, I'm not convinced this is a SW PMD issue yet - initial testing
>points to incorrect event OP NEW/FWD/RELEASE usage. Can we verify
>that the OPs being sent are correct?
>
Looks like an issue in crypto adapter service. The service is starting with
OP_FORWARD, if RTE_EVENT_DEV_CAP_IMPLICIT_RELEASE_DISABLE is set.
Abhinandan can confirm.
^ permalink raw reply [flat|nested] 43+ messages in thread
* RE: [PATCH v5] app/eventdev: add crypto producer mode
2022-02-22 7:03 ` Shijith Thotton
@ 2022-02-23 9:02 ` Gujjar, Abhinandan S
2022-02-23 10:02 ` Shijith Thotton
0 siblings, 1 reply; 43+ messages in thread
From: Gujjar, Abhinandan S @ 2022-02-23 9:02 UTC (permalink / raw)
To: Shijith Thotton, Van Haaren, Harry, Jerin Jacob, Hemant Agrawal,
Nipun Gupta
Cc: Jerin Jacob Kollanukkaran, dev
> -----Original Message-----
> From: Shijith Thotton <sthotton@marvell.com>
> Sent: Tuesday, February 22, 2022 12:34 PM
> To: Van Haaren, Harry <harry.van.haaren@intel.com>; Gujjar, Abhinandan S
> <abhinandan.gujjar@intel.com>; Jerin Jacob <jerinjacobk@gmail.com>;
> Hemant Agrawal <hemant.agrawal@nxp.com>; Nipun Gupta
> <nipun.gupta@nxp.com>
> Cc: Jerin Jacob Kollanukkaran <jerinj@marvell.com>; dev@dpdk.org
> Subject: RE: [PATCH v5] app/eventdev: add crypto producer mode
>
> >> >
> >> > + @Van Haaren, Harry
> >
> >Hi All,
> >
> >I have been away on vacation for the last week - hence the delay in
> >reply on this thread.
> >
> ><snip discussion>
> >
> >> > > [1]
> >> > > Steps to reproduce:
> >> > > * Clone https://urldefense.proofpoint.com/v2/url?u=http-
> >3A__dpdk.org_git_next_dpdk-2Dnext-
> >2Deventdev&d=DwIGaQ&c=nKjWec2b6R0mOyPaz7xtfQ&r=G9w4KsPaQLAC
> BfGCL
> >35PtiRH996yqJDxAZwrWegU2qQ&m=-yaLm_cvg5cKTbBy3OoUs719W-
> >E3ARETajJQmUvoE4aSAPjcEn1kulkRNxTn841D&s=lZjsn2zecck8IBBQRA7fId7
> BXSYKk
> >U8Tjj10gNQLB6U&e=
> >> > > * Apply [v5] app/eventdev: add crypto producer mode
> >> > > git-pw --server
> >> > > https://urldefense.proofpoint.com/v2/url?u=https-
> >3A__patches.dpdk.org_api_1.2_&d=DwIGaQ&c=nKjWec2b6R0mOyPaz7xtf
> Q&r=G
> >9w4KsPaQLACBfGCL35PtiRH996yqJDxAZwrWegU2qQ&m=-
> >yaLm_cvg5cKTbBy3OoUs719W-
> >E3ARETajJQmUvoE4aSAPjcEn1kulkRNxTn841D&s=VBQtpQ8vwHt9BnMrPLz
> SneOm
> >zhLdP5bfyLuY42fCnak&e= --project dpdk
> >> > > patch apply 107645
> >> > > * Apply [RFC] app/eventdev: add software crypto adapter support
> >> > > git-pw --server
> >> > > https://urldefense.proofpoint.com/v2/url?u=https-
> >3A__patches.dpdk.org_api_1.2_&d=DwIGaQ&c=nKjWec2b6R0mOyPaz7xtf
> Q&r=G
> >9w4KsPaQLACBfGCL35PtiRH996yqJDxAZwrWegU2qQ&m=-
> >yaLm_cvg5cKTbBy3OoUs719W-
> >E3ARETajJQmUvoE4aSAPjcEn1kulkRNxTn841D&s=VBQtpQ8vwHt9BnMrPLz
> SneOm
> >zhLdP5bfyLuY42fCnak&e= --project dpdk
> >> > > patch apply 107029
> >> > > * meson x86_build_debug -Dc_args='-g -O0' -
> Ddisable_drivers="*/cnxk"
> >> > > * ninja -C x86_build_debug
> >> > > * Command to reproduce crash
> >> > > sudo ./x86_build_debug/app/dpdk-test-eventdev -l 0-8 -s 0xf0
> >> > > --vdev=event_sw0 --vdev="crypto_null" -- --prod_type_cryptodev
> >> > > --crypto_adptr_mode 0 --test=perf_queue --stlist=a --wlcores 1
> >> > > --plcores 2
> >
> >Can confirm that these steps indeed cause segfault as reported.
> >
> >In debugging, it seems like there are *zero* NEW events, and large
> >numbers of RELEASE events are enqueued... if so, this is not compliant to
> the Eventdev API.
> >Can somebody confirm that?
> >
> >The SW PMD is being told there are events to release, but there aren't any.
> >Eventually, this leads to a mismatch in credit allocations, which then
> >causes the IQ-chunks datastructure to corrupt.
> >
> >All in all, I'm not convinced this is a SW PMD issue yet - initial
> >testing points to incorrect event OP NEW/FWD/RELEASE usage. Can we
> >verify that the OPs being sent are correct?
> >
>
> Looks like an issue in crypto adapter service. The service is starting with
> OP_FORWARD, if RTE_EVENT_DEV_CAP_IMPLICIT_RELEASE_DISABLE is set.
> Abhinandan can confirm.
The service is started with what application is requesting for from the adapter.
The app can request either OP_NEW or FWD mode. Adapter while creating a new instance
requests for evendev caps & based on that adapter enqueues events back to evdev
in FWD or NEW mode. All events are triggered by application and adapter is
transparent here. Could you please explain me how this creating an issue?
Regards
Abhinandan
^ permalink raw reply [flat|nested] 43+ messages in thread
* RE: [PATCH v5] app/eventdev: add crypto producer mode
2022-02-23 9:02 ` Gujjar, Abhinandan S
@ 2022-02-23 10:02 ` Shijith Thotton
2022-02-23 10:13 ` Van Haaren, Harry
0 siblings, 1 reply; 43+ messages in thread
From: Shijith Thotton @ 2022-02-23 10:02 UTC (permalink / raw)
To: Gujjar, Abhinandan S, Van Haaren, Harry, Jerin Jacob,
Hemant Agrawal, Nipun Gupta
Cc: Jerin Jacob Kollanukkaran, dev
>-----Original Message-----
>From: Gujjar, Abhinandan S <abhinandan.gujjar@intel.com>
>Sent: Wednesday, February 23, 2022 2:32 PM
>To: Shijith Thotton <sthotton@marvell.com>; Van Haaren, Harry
><harry.van.haaren@intel.com>; Jerin Jacob <jerinjacobk@gmail.com>; Hemant
>Agrawal <hemant.agrawal@nxp.com>; Nipun Gupta <nipun.gupta@nxp.com>
>Cc: Jerin Jacob Kollanukkaran <jerinj@marvell.com>; dev@dpdk.org
>Subject: [EXT] RE: [PATCH v5] app/eventdev: add crypto producer mode
>
>External Email
>
>----------------------------------------------------------------------
>
>
>> -----Original Message-----
>> From: Shijith Thotton <sthotton@marvell.com>
>> Sent: Tuesday, February 22, 2022 12:34 PM
>> To: Van Haaren, Harry <harry.van.haaren@intel.com>; Gujjar, Abhinandan S
>> <abhinandan.gujjar@intel.com>; Jerin Jacob <jerinjacobk@gmail.com>;
>> Hemant Agrawal <hemant.agrawal@nxp.com>; Nipun Gupta
>> <nipun.gupta@nxp.com>
>> Cc: Jerin Jacob Kollanukkaran <jerinj@marvell.com>; dev@dpdk.org
>> Subject: RE: [PATCH v5] app/eventdev: add crypto producer mode
>>
>> >> >
>> >> > + @Van Haaren, Harry
>> >
>> >Hi All,
>> >
>> >I have been away on vacation for the last week - hence the delay in
>> >reply on this thread.
>> >
>> ><snip discussion>
>> >
>> >> > > [1]
>> >> > > Steps to reproduce:
>> >> > > * Clone https://urldefense.proofpoint.com/v2/url?u=http-
>> >3A__dpdk.org_git_next_dpdk-2Dnext-
>> >2Deventdev&d=DwIGaQ&c=nKjWec2b6R0mOyPaz7xtfQ&r=G9w4KsPaQLAC
>> BfGCL
>> >35PtiRH996yqJDxAZwrWegU2qQ&m=-yaLm_cvg5cKTbBy3OoUs719W-
>> >E3ARETajJQmUvoE4aSAPjcEn1kulkRNxTn841D&s=lZjsn2zecck8IBBQRA7fId7
>> BXSYKk
>> >U8Tjj10gNQLB6U&e=
>> >> > > * Apply [v5] app/eventdev: add crypto producer mode
>> >> > > git-pw --server
>> >> > > https://urldefense.proofpoint.com/v2/url?u=https-
>> >3A__patches.dpdk.org_api_1.2_&d=DwIGaQ&c=nKjWec2b6R0mOyPaz7xtf
>> Q&r=G
>> >9w4KsPaQLACBfGCL35PtiRH996yqJDxAZwrWegU2qQ&m=-
>> >yaLm_cvg5cKTbBy3OoUs719W-
>> >E3ARETajJQmUvoE4aSAPjcEn1kulkRNxTn841D&s=VBQtpQ8vwHt9BnMrPLz
>> SneOm
>> >zhLdP5bfyLuY42fCnak&e= --project dpdk
>> >> > > patch apply 107645
>> >> > > * Apply [RFC] app/eventdev: add software crypto adapter support
>> >> > > git-pw --server
>> >> > > https://urldefense.proofpoint.com/v2/url?u=https-
>> >3A__patches.dpdk.org_api_1.2_&d=DwIGaQ&c=nKjWec2b6R0mOyPaz7xtf
>> Q&r=G
>> >9w4KsPaQLACBfGCL35PtiRH996yqJDxAZwrWegU2qQ&m=-
>> >yaLm_cvg5cKTbBy3OoUs719W-
>> >E3ARETajJQmUvoE4aSAPjcEn1kulkRNxTn841D&s=VBQtpQ8vwHt9BnMrPLz
>> SneOm
>> >zhLdP5bfyLuY42fCnak&e= --project dpdk
>> >> > > patch apply 107029
>> >> > > * meson x86_build_debug -Dc_args='-g -O0' -
>> Ddisable_drivers="*/cnxk"
>> >> > > * ninja -C x86_build_debug
>> >> > > * Command to reproduce crash
>> >> > > sudo ./x86_build_debug/app/dpdk-test-eventdev -l 0-8 -s 0xf0
>> >> > > --vdev=event_sw0 --vdev="crypto_null" -- --prod_type_cryptodev
>> >> > > --crypto_adptr_mode 0 --test=perf_queue --stlist=a --wlcores 1
>> >> > > --plcores 2
>> >
>> >Can confirm that these steps indeed cause segfault as reported.
>> >
>> >In debugging, it seems like there are *zero* NEW events, and large
>> >numbers of RELEASE events are enqueued... if so, this is not compliant to
>> the Eventdev API.
>> >Can somebody confirm that?
>> >
>> >The SW PMD is being told there are events to release, but there aren't any.
>> >Eventually, this leads to a mismatch in credit allocations, which then
>> >causes the IQ-chunks datastructure to corrupt.
>> >
>> >All in all, I'm not convinced this is a SW PMD issue yet - initial
>> >testing points to incorrect event OP NEW/FWD/RELEASE usage. Can we
>> >verify that the OPs being sent are correct?
>> >
>>
>> Looks like an issue in crypto adapter service. The service is starting with
>> OP_FORWARD, if RTE_EVENT_DEV_CAP_IMPLICIT_RELEASE_DISABLE is set.
>> Abhinandan can confirm.
>
>The service is started with what application is requesting for from the adapter.
>The app can request either OP_NEW or FWD mode. Adapter while creating a new
>instance
>requests for evendev caps & based on that adapter enqueues events back to
>evdev
>in FWD or NEW mode. All events are triggered by application and adapter is
>transparent here. Could you please explain me how this creating an issue?
>
In lib/eventdev/rte_event_crypto_adapter.c:
...
eca_ops_enqueue_burst(struct event_crypto_adapter *adapter,
...
rte_memcpy(ev, &m_data->response_info, sizeof(*ev));
ev->event_ptr = ops[i];
ev->event_type = RTE_EVENT_TYPE_CRYPTODEV;
if (adapter->implicit_release_disabled)
ev->op = RTE_EVENT_OP_FORWARD;
else
ev->op = RTE_EVENT_OP_NEW;
...
op and event_type is set in the service. Changing FORWARD to NEW will fix the crash.
I think, we should update the spec with what all values are used in response info.
I will remove setting op/event_type field of response info in the application.
PMD/service can take care of it.
^ permalink raw reply [flat|nested] 43+ messages in thread
* RE: [PATCH v5] app/eventdev: add crypto producer mode
2022-02-23 10:02 ` Shijith Thotton
@ 2022-02-23 10:13 ` Van Haaren, Harry
2022-02-23 16:33 ` Gujjar, Abhinandan S
0 siblings, 1 reply; 43+ messages in thread
From: Van Haaren, Harry @ 2022-02-23 10:13 UTC (permalink / raw)
To: Shijith Thotton, Gujjar, Abhinandan S, Jerin Jacob,
Hemant Agrawal, Nipun Gupta
Cc: Jerin Jacob Kollanukkaran, dev
> -----Original Message-----
> From: Shijith Thotton <sthotton@marvell.com>
> Sent: Wednesday, February 23, 2022 10:02 AM
> To: Gujjar, Abhinandan S <abhinandan.gujjar@intel.com>; Van Haaren, Harry
> <harry.van.haaren@intel.com>; Jerin Jacob <jerinjacobk@gmail.com>; Hemant
> Agrawal <hemant.agrawal@nxp.com>; Nipun Gupta <nipun.gupta@nxp.com>
> Cc: Jerin Jacob Kollanukkaran <jerinj@marvell.com>; dev@dpdk.org
> Subject: RE: [PATCH v5] app/eventdev: add crypto producer mode
>
>
>
> >-----Original Message-----
> >From: Gujjar, Abhinandan S <abhinandan.gujjar@intel.com>
> >Sent: Wednesday, February 23, 2022 2:32 PM
> >To: Shijith Thotton <sthotton@marvell.com>; Van Haaren, Harry
> ><harry.van.haaren@intel.com>; Jerin Jacob <jerinjacobk@gmail.com>; Hemant
> >Agrawal <hemant.agrawal@nxp.com>; Nipun Gupta <nipun.gupta@nxp.com>
> >Cc: Jerin Jacob Kollanukkaran <jerinj@marvell.com>; dev@dpdk.org
> >Subject: [EXT] RE: [PATCH v5] app/eventdev: add crypto producer mode
> >
> >External Email
> >
> >----------------------------------------------------------------------
> >
> >
> >> -----Original Message-----
> >> From: Shijith Thotton <sthotton@marvell.com>
> >> Sent: Tuesday, February 22, 2022 12:34 PM
> >> To: Van Haaren, Harry <harry.van.haaren@intel.com>; Gujjar, Abhinandan S
> >> <abhinandan.gujjar@intel.com>; Jerin Jacob <jerinjacobk@gmail.com>;
> >> Hemant Agrawal <hemant.agrawal@nxp.com>; Nipun Gupta
> >> <nipun.gupta@nxp.com>
> >> Cc: Jerin Jacob Kollanukkaran <jerinj@marvell.com>; dev@dpdk.org
> >> Subject: RE: [PATCH v5] app/eventdev: add crypto producer mode
> >>
> >> >> >
> >> >> > + @Van Haaren, Harry
> >> >
> >> >Hi All,
> >> >
> >> >I have been away on vacation for the last week - hence the delay in
> >> >reply on this thread.
> >> >
> >> ><snip discussion>
> >> >
> >> >> > > [1]
> >> >> > > Steps to reproduce:
> >> >> > > * Clone https://urldefense.proofpoint.com/v2/url?u=http-
> >> >3A__dpdk.org_git_next_dpdk-2Dnext-
> >> >2Deventdev&d=DwIGaQ&c=nKjWec2b6R0mOyPaz7xtfQ&r=G9w4KsPaQLAC
> >> BfGCL
> >> >35PtiRH996yqJDxAZwrWegU2qQ&m=-yaLm_cvg5cKTbBy3OoUs719W-
> >> >E3ARETajJQmUvoE4aSAPjcEn1kulkRNxTn841D&s=lZjsn2zecck8IBBQRA7fId7
> >> BXSYKk
> >> >U8Tjj10gNQLB6U&e=
> >> >> > > * Apply [v5] app/eventdev: add crypto producer mode
> >> >> > > git-pw --server
> >> >> > > https://urldefense.proofpoint.com/v2/url?u=https-
> >> >3A__patches.dpdk.org_api_1.2_&d=DwIGaQ&c=nKjWec2b6R0mOyPaz7xtf
> >> Q&r=G
> >> >9w4KsPaQLACBfGCL35PtiRH996yqJDxAZwrWegU2qQ&m=-
> >> >yaLm_cvg5cKTbBy3OoUs719W-
> >> >E3ARETajJQmUvoE4aSAPjcEn1kulkRNxTn841D&s=VBQtpQ8vwHt9BnMrPLz
> >> SneOm
> >> >zhLdP5bfyLuY42fCnak&e= --project dpdk
> >> >> > > patch apply 107645
> >> >> > > * Apply [RFC] app/eventdev: add software crypto adapter support
> >> >> > > git-pw --server
> >> >> > > https://urldefense.proofpoint.com/v2/url?u=https-
> >> >3A__patches.dpdk.org_api_1.2_&d=DwIGaQ&c=nKjWec2b6R0mOyPaz7xtf
> >> Q&r=G
> >> >9w4KsPaQLACBfGCL35PtiRH996yqJDxAZwrWegU2qQ&m=-
> >> >yaLm_cvg5cKTbBy3OoUs719W-
> >> >E3ARETajJQmUvoE4aSAPjcEn1kulkRNxTn841D&s=VBQtpQ8vwHt9BnMrPLz
> >> SneOm
> >> >zhLdP5bfyLuY42fCnak&e= --project dpdk
> >> >> > > patch apply 107029
> >> >> > > * meson x86_build_debug -Dc_args='-g -O0' -
> >> Ddisable_drivers="*/cnxk"
> >> >> > > * ninja -C x86_build_debug
> >> >> > > * Command to reproduce crash
> >> >> > > sudo ./x86_build_debug/app/dpdk-test-eventdev -l 0-8 -s 0xf0
> >> >> > > --vdev=event_sw0 --vdev="crypto_null" -- --prod_type_cryptodev
> >> >> > > --crypto_adptr_mode 0 --test=perf_queue --stlist=a --wlcores 1
> >> >> > > --plcores 2
> >> >
> >> >Can confirm that these steps indeed cause segfault as reported.
> >> >
> >> >In debugging, it seems like there are *zero* NEW events, and large
> >> >numbers of RELEASE events are enqueued... if so, this is not compliant to
> >> the Eventdev API.
> >> >Can somebody confirm that?
> >> >
> >> >The SW PMD is being told there are events to release, but there aren't any.
> >> >Eventually, this leads to a mismatch in credit allocations, which then
> >> >causes the IQ-chunks datastructure to corrupt.
> >> >
> >> >All in all, I'm not convinced this is a SW PMD issue yet - initial
> >> >testing points to incorrect event OP NEW/FWD/RELEASE usage. Can we
> >> >verify that the OPs being sent are correct?
> >> >
> >>
> >> Looks like an issue in crypto adapter service. The service is starting with
> >> OP_FORWARD, if RTE_EVENT_DEV_CAP_IMPLICIT_RELEASE_DISABLE is set.
> >> Abhinandan can confirm.
> >
> >The service is started with what application is requesting for from the adapter.
> >The app can request either OP_NEW or FWD mode. Adapter while creating a
> new
> >instance
> >requests for evendev caps & based on that adapter enqueues events back to
> >evdev
> >in FWD or NEW mode. All events are triggered by application and adapter is
> >transparent here. Could you please explain me how this creating an issue?
> >
>
> In lib/eventdev/rte_event_crypto_adapter.c:
> ...
> eca_ops_enqueue_burst(struct event_crypto_adapter *adapter,
> ...
> rte_memcpy(ev, &m_data->response_info, sizeof(*ev));
> ev->event_ptr = ops[i];
> ev->event_type = RTE_EVENT_TYPE_CRYPTODEV;
> if (adapter->implicit_release_disabled)
> ev->op = RTE_EVENT_OP_FORWARD;
> else
> ev->op = RTE_EVENT_OP_NEW;
> ...
>
> op and event_type is set in the service. Changing FORWARD to NEW will fix the
> crash.
Yes, I think that is true, but lets ensure we're all understanding the reason.
The crash reported occurs when events with FORWARD are sent into the SW PMD,
and later those are RELEASED. Notice, the event was never *NEW*.
Eventdev demands that when adding "new" things (e.g. events not previously seen
by the PMD) into the Eventdev instance, the type of the event must be NEW. The NEW
op type consumes "credits" in the SW PMD, and causes tracking for the NEW events.
I think that here the events *starts* with FORWARD events (should be NEW), and hence
the crash occurs, because the NEW type was never enqueued first.
Shijith suggests changing FORWARD to NEW to fix the crash, I believe that may *fix*
the crash here, but doing so without consideration for "implicit-release" mode may break
things elsewhere.
Is the better fix to ensure that any events being enqueued into Eventdev for the first time
are of a NEW type, and once circulated, either FORWARD or NEW can be used in a valid way?
> I think, we should update the spec with what all values are used in response info.
> I will remove setting op/event_type field of response info in the application.
> PMD/service can take care of it.
I'm not familiar with how the adapter/pmd/service interact - no input from me.
^ permalink raw reply [flat|nested] 43+ messages in thread
* RE: [PATCH v5] app/eventdev: add crypto producer mode
2022-02-23 10:13 ` Van Haaren, Harry
@ 2022-02-23 16:33 ` Gujjar, Abhinandan S
2022-02-23 17:02 ` Shijith Thotton
0 siblings, 1 reply; 43+ messages in thread
From: Gujjar, Abhinandan S @ 2022-02-23 16:33 UTC (permalink / raw)
To: Van Haaren, Harry, Shijith Thotton, Jerin Jacob, Hemant Agrawal,
Nipun Gupta
Cc: Jerin Jacob Kollanukkaran, dev
> -----Original Message-----
> From: Van Haaren, Harry <harry.van.haaren@intel.com>
> Sent: Wednesday, February 23, 2022 3:43 PM
> To: Shijith Thotton <sthotton@marvell.com>; Gujjar, Abhinandan S
> <abhinandan.gujjar@intel.com>; Jerin Jacob <jerinjacobk@gmail.com>;
> Hemant Agrawal <hemant.agrawal@nxp.com>; Nipun Gupta
> <nipun.gupta@nxp.com>
> Cc: Jerin Jacob Kollanukkaran <jerinj@marvell.com>; dev@dpdk.org
> Subject: RE: [PATCH v5] app/eventdev: add crypto producer mode
>
> > -----Original Message-----
> > From: Shijith Thotton <sthotton@marvell.com>
> > Sent: Wednesday, February 23, 2022 10:02 AM
> > To: Gujjar, Abhinandan S <abhinandan.gujjar@intel.com>; Van Haaren,
> > Harry <harry.van.haaren@intel.com>; Jerin Jacob
> > <jerinjacobk@gmail.com>; Hemant Agrawal <hemant.agrawal@nxp.com>;
> > Nipun Gupta <nipun.gupta@nxp.com>
> > Cc: Jerin Jacob Kollanukkaran <jerinj@marvell.com>; dev@dpdk.org
> > Subject: RE: [PATCH v5] app/eventdev: add crypto producer mode
> >
> >
> >
> > >-----Original Message-----
> > >From: Gujjar, Abhinandan S <abhinandan.gujjar@intel.com>
> > >Sent: Wednesday, February 23, 2022 2:32 PM
> > >To: Shijith Thotton <sthotton@marvell.com>; Van Haaren, Harry
> > ><harry.van.haaren@intel.com>; Jerin Jacob <jerinjacobk@gmail.com>;
> > >Hemant Agrawal <hemant.agrawal@nxp.com>; Nipun Gupta
> > ><nipun.gupta@nxp.com>
> > >Cc: Jerin Jacob Kollanukkaran <jerinj@marvell.com>; dev@dpdk.org
> > >Subject: [EXT] RE: [PATCH v5] app/eventdev: add crypto producer mode
> > >
> > >External Email
> > >
> > >---------------------------------------------------------------------
> > >-
> > >
> > >
> > >> -----Original Message-----
> > >> From: Shijith Thotton <sthotton@marvell.com>
> > >> Sent: Tuesday, February 22, 2022 12:34 PM
> > >> To: Van Haaren, Harry <harry.van.haaren@intel.com>; Gujjar,
> > >> Abhinandan S <abhinandan.gujjar@intel.com>; Jerin Jacob
> > >> <jerinjacobk@gmail.com>; Hemant Agrawal
> <hemant.agrawal@nxp.com>;
> > >> Nipun Gupta <nipun.gupta@nxp.com>
> > >> Cc: Jerin Jacob Kollanukkaran <jerinj@marvell.com>; dev@dpdk.org
> > >> Subject: RE: [PATCH v5] app/eventdev: add crypto producer mode
> > >>
> > >> >> >
> > >> >> > + @Van Haaren, Harry
> > >> >
> > >> >Hi All,
> > >> >
> > >> >I have been away on vacation for the last week - hence the delay
> > >> >in reply on this thread.
> > >> >
> > >> ><snip discussion>
> > >> >
> > >> >> > > [1]
> > >> >> > > Steps to reproduce:
> > >> >> > > * Clone https://urldefense.proofpoint.com/v2/url?u=http-
> > >> >3A__dpdk.org_git_next_dpdk-2Dnext-
> > >>
> >2Deventdev&d=DwIGaQ&c=nKjWec2b6R0mOyPaz7xtfQ&r=G9w4KsPaQLAC
> > >> BfGCL
> > >> >35PtiRH996yqJDxAZwrWegU2qQ&m=-yaLm_cvg5cKTbBy3OoUs719W-
> > >>
> >E3ARETajJQmUvoE4aSAPjcEn1kulkRNxTn841D&s=lZjsn2zecck8IBBQRA7fId7
> > >> BXSYKk
> > >> >U8Tjj10gNQLB6U&e=
> > >> >> > > * Apply [v5] app/eventdev: add crypto producer mode
> > >> >> > > git-pw --server
> > >> >> > > https://urldefense.proofpoint.com/v2/url?u=https-
> > >>
> >3A__patches.dpdk.org_api_1.2_&d=DwIGaQ&c=nKjWec2b6R0mOyPaz7xtf
> > >> Q&r=G
> > >> >9w4KsPaQLACBfGCL35PtiRH996yqJDxAZwrWegU2qQ&m=-
> > >> >yaLm_cvg5cKTbBy3OoUs719W-
> > >>
> >E3ARETajJQmUvoE4aSAPjcEn1kulkRNxTn841D&s=VBQtpQ8vwHt9BnMrPLz
> > >> SneOm
> > >> >zhLdP5bfyLuY42fCnak&e= --project dpdk
> > >> >> > > patch apply 107645
> > >> >> > > * Apply [RFC] app/eventdev: add software crypto adapter
> support
> > >> >> > > git-pw --server
> > >> >> > > https://urldefense.proofpoint.com/v2/url?u=https-
> > >>
> >3A__patches.dpdk.org_api_1.2_&d=DwIGaQ&c=nKjWec2b6R0mOyPaz7xtf
> > >> Q&r=G
> > >> >9w4KsPaQLACBfGCL35PtiRH996yqJDxAZwrWegU2qQ&m=-
> > >> >yaLm_cvg5cKTbBy3OoUs719W-
> > >>
> >E3ARETajJQmUvoE4aSAPjcEn1kulkRNxTn841D&s=VBQtpQ8vwHt9BnMrPLz
> > >> SneOm
> > >> >zhLdP5bfyLuY42fCnak&e= --project dpdk
> > >> >> > > patch apply 107029
> > >> >> > > * meson x86_build_debug -Dc_args='-g -O0' -
> > >> Ddisable_drivers="*/cnxk"
> > >> >> > > * ninja -C x86_build_debug
> > >> >> > > * Command to reproduce crash
> > >> >> > > sudo ./x86_build_debug/app/dpdk-test-eventdev -l 0-8 -s
> > >> >> > > 0xf0
> > >> >> > > --vdev=event_sw0 --vdev="crypto_null" --
> > >> >> > > --prod_type_cryptodev --crypto_adptr_mode 0
> > >> >> > > --test=perf_queue --stlist=a --wlcores 1 --plcores 2
> > >> >
> > >> >Can confirm that these steps indeed cause segfault as reported.
> > >> >
> > >> >In debugging, it seems like there are *zero* NEW events, and large
> > >> >numbers of RELEASE events are enqueued... if so, this is not
> > >> >compliant to
> > >> the Eventdev API.
> > >> >Can somebody confirm that?
> > >> >
> > >> >The SW PMD is being told there are events to release, but there aren't
> any.
> > >> >Eventually, this leads to a mismatch in credit allocations, which
> > >> >then causes the IQ-chunks datastructure to corrupt.
> > >> >
> > >> >All in all, I'm not convinced this is a SW PMD issue yet - initial
> > >> >testing points to incorrect event OP NEW/FWD/RELEASE usage. Can we
> > >> >verify that the OPs being sent are correct?
> > >> >
> > >>
> > >> Looks like an issue in crypto adapter service. The service is
> > >> starting with OP_FORWARD, if
> RTE_EVENT_DEV_CAP_IMPLICIT_RELEASE_DISABLE is set.
> > >> Abhinandan can confirm.
> > >
> > >The service is started with what application is requesting for from the
> adapter.
> > >The app can request either OP_NEW or FWD mode. Adapter while
> creating
> > >a
> > new
> > >instance
> > >requests for evendev caps & based on that adapter enqueues events
> > >back to evdev in FWD or NEW mode. All events are triggered by
> > >application and adapter is transparent here. Could you please explain
> > >me how this creating an issue?
> > >
> >
> > In lib/eventdev/rte_event_crypto_adapter.c:
> > ...
> > eca_ops_enqueue_burst(struct event_crypto_adapter *adapter, ...
> > rte_memcpy(ev, &m_data->response_info, sizeof(*ev));
> > ev->event_ptr = ops[i];
> > ev->event_type = RTE_EVENT_TYPE_CRYPTODEV;
> > if (adapter->implicit_release_disabled)
> > ev->op = RTE_EVENT_OP_FORWARD;
> > else
> > ev->op = RTE_EVENT_OP_NEW; ...
> >
> > op and event_type is set in the service. Changing FORWARD to NEW will
> > fix the crash.
>
> Yes, I think that is true, but lets ensure we're all understanding the reason.
>
> The crash reported occurs when events with FORWARD are sent into the SW
> PMD, and later those are RELEASED. Notice, the event was never *NEW*.
>
> Eventdev demands that when adding "new" things (e.g. events not
> previously seen by the PMD) into the Eventdev instance, the type of the
> event must be NEW. The NEW op type consumes "credits" in the SW PMD,
> and causes tracking for the NEW events.
>
> I think that here the events *starts* with FORWARD events (should be NEW),
> and hence the crash occurs, because the NEW type was never enqueued
> first.
>
> Shijith suggests changing FORWARD to NEW to fix the crash, I believe that
> may *fix* the crash here, but doing so without consideration for "implicit-
> release" mode may break things elsewhere.
>
> Is the better fix to ensure that any events being enqueued into Eventdev for
> the first time are of a NEW type, and once circulated, either FORWARD or
> NEW can be used in a valid way?
>
>
> > I think, we should update the spec with what all values are used in
> response info.
> > I will remove setting op/event_type field of response info in the
> application.
> > PMD/service can take care of it.
>
> I'm not familiar with how the adapter/pmd/service interact - no input from
> me.
Harry and Shijith, Thanks for all the observations.
After debugging, I think the changes are required in both adapter and application:
1. Application/Adapter in FWD mode case: The app is forming FWD events as an event originator (it is supposed to form NEW events) which is causing the crash!
App fix:
root@dev:/home/intel/abhi/dpdk-next-eventdev#
In crypto_adapter_enq_op_fwd() -> change as below:
- ev.op = RTE_EVENT_OP_FORWARD;
+ ev.op = RTE_EVENT_OP_NEW;
ev.queue_id = p->queue_id;
ev.sched_type = RTE_SCHED_TYPE_ATOMIC;
2. Adapter in NEW mode case: The app is calls rte_cryptodev_enqueue_burst() and directly enqueue crypto ops. Adapter had no clue crypto ops were derived from events or they were directly enqueued by application.
So, below is the fix for that:
root@dev:/home/intel/abhi/dpdk-next-eventdev# git diff lib/eventdev/rte_event_crypto_adapter.c
diff --git a/lib/eventdev/rte_event_crypto_adapter.c b/lib/eventdev/rte_event_crypto_adapter.c
index 0b484f3695..a6328b853d 100644
--- a/lib/eventdev/rte_event_crypto_adapter.c
+++ b/lib/eventdev/rte_event_crypto_adapter.c
@@ -658,7 +658,9 @@ eca_ops_enqueue_burst(struct event_crypto_adapter *adapter,
rte_memcpy(ev, &m_data->response_info, sizeof(*ev));
ev->event_ptr = ops[i];
ev->event_type = RTE_EVENT_TYPE_CRYPTODEV;
- if (adapter->implicit_release_disabled)
+ if (adapter->mode == RTE_EVENT_CRYPTO_ADAPTER_OP_NEW)
+ ev->op = RTE_EVENT_OP_NEW;
+ else if (adapter->implicit_release_disabled)
ev->op = RTE_EVENT_OP_FORWARD;
else
ev->op = RTE_EVENT_OP_NEW;
With the above fix, I can run the test for both NEW and FWD mode:
root@xdp-dev:/home/intel/abhi/dpdk-next-eventdev/abhi# ./app/dpdk-test-eventdev -l 0-8 -s 0xf0 --vdev=event_sw0 --vdev="crypto_null" -- --prod_type_cryptodev --crypto_adptr_mode 0 --test=perf_queue --stlist=a --wlcores 1 --plcores 2
EAL: Detected CPU lcores: 96
EAL: Detected NUMA nodes: 2
EAL: Detected static linkage of DPDK
EAL: Multi-process socket /var/run/dpdk/rte/mp_socket
EAL: Selected IOVA mode 'PA'
EAL: VFIO support initialized
CRYPTODEV: Creating cryptodev crypto_null
CRYPTODEV: Initialisation parameters - name: crypto_null,socket id: 0, max queue pairs: 8
TELEMETRY: No legacy callbacks, legacy socket not created
driver : event_sw
test : perf_queue
dev : 0
verbose_level : 1
socket_id : -1
pool_sz : 16384
main lcore : 0
nb_pkts : 67108864
nb_timers : 100000000
available lcores : {0 1 2 3 8}
nb_flows : 1024
worker deq depth : 16
fwd_latency : false
nb_prod_lcores : 1
producer lcores : {2}
nb_worker_lcores : 1
worker lcores : {1}
nb_stages : 1
nb_evdev_ports : 2
nb_evdev_queues : 1
queue_priority : false
sched_type_list : {A}
crypto adapter mode : OP_NEW
nb_cryptodev : 1
prod_type : Event crypto adapter producers
prod_enq_burst_sz : 1
CRYPTODEV: elt_size 0 is expanded to 208
0.000 mpps avg 0.000 mppsEventDev todo-fix-name: ports 3, qids 1
rx 6080
drop 0
tx 2040
sched calls: 9064463
sched cq/qid call: 9069025
sched no IQ enq: 9063156
sched no CQ enq: 9063759
inflight 4096, credits: 0
Port 0
rx 0 drop 0 tx 2024 inflight 0
Max New: 4096 Avg cycles PP: 745 Credits: 40
Receive burst distribution:
0:100% 1-4:0.00% 5-8:0.00% 9-12:0.00% 13-16:0.00%
rx ring used: 0 free: 4096
cq ring used: 0 free: 16
Port 1
rx 0 drop 0 tx 0 inflight 0
Max New: 4096 Avg cycles PP: 0 Credits: 0
Receive burst distribution:
0:-nan%
rx ring used: 0 free: 4096
cq ring used: 0 free: 16
Port 2
rx 6080 drop 0 tx 16 inflight 16
Max New: 4096 Avg cycles PP: 0 Credits: 0
Receive burst distribution:
0:-nan%
rx ring used: 0 free: 4096
cq ring used: 16 free: 0
Queue 0 (Atomic)
rx 6080 drop 0 tx 2040
Per Port Stats:
Port 0: Pkts: 2024 Flows: 0
Port 1: Pkts: 0 Flows: 0
Port 2: Pkts: 16 Flows: 22
iq 1: Used 4040
error: perf_launch_lcores() No schedules for seconds, deadlock
Packet distribution across worker cores :
Worker 0 packets: 7e8 percentage: 100.00
Result: Failed
root@xdp-dev:/home/intel/abhi/dpdk-next-eventdev/abhi# ./app/dpdk-test-eventdev -l 0-8 -s 0xf0 --vdev=event_sw0 --vdev="crypto_null" -- --prod_type_cryptodev --crypto_adptr_mode 1 --test=perf_queue --stlist=a --wlcores 1 --plcores 2
EAL: Detected CPU lcores: 96
EAL: Detected NUMA nodes: 2
EAL: Detected static linkage of DPDK
EAL: Multi-process socket /var/run/dpdk/rte/mp_socket
EAL: Selected IOVA mode 'PA'
EAL: VFIO support initialized
CRYPTODEV: Creating cryptodev crypto_null
CRYPTODEV: Initialisation parameters - name: crypto_null,socket id: 0, max queue pairs: 8
TELEMETRY: No legacy callbacks, legacy socket not created
driver : event_sw
test : perf_queue
dev : 0
verbose_level : 1
socket_id : -1
pool_sz : 16384
main lcore : 0
nb_pkts : 67108864
nb_timers : 100000000
available lcores : {0 1 2 3 8}
nb_flows : 1024
worker deq depth : 16
fwd_latency : false
nb_prod_lcores : 1
producer lcores : {2}
nb_worker_lcores : 1
worker lcores : {1}
nb_stages : 1
nb_evdev_ports : 2
nb_evdev_queues : 1
queue_priority : false
sched_type_list : {A}
crypto adapter mode : OP_FORWARD
nb_cryptodev : 1
prod_type : Event crypto adapter producers
prod_enq_burst_sz : 1
CRYPTODEV: elt_size 0 is expanded to 208
0.000 mpps avg 0.000 mppsEventDev todo-fix-name: ports 3, qids 1
rx 4480
drop 0
tx 447
sched calls: 8438712
sched cq/qid call: 8442432
sched no IQ enq: 8438434
sched no CQ enq: 8438494
inflight 4096, credits: 0
Port 0
rx 0 drop 0 tx 431 inflight 0
Max New: 4096 Avg cycles PP: 637 Credits: 47
Receive burst distribution:
0:100% 1-4:0.00% 5-8:0.00% 13-16:0.00%
rx ring used: 0 free: 4096
cq ring used: 0 free: 16
Port 1
rx 4480 drop 0 tx 0 inflight 0
Max New: 4096 Avg cycles PP: 0 Credits: 0
Receive burst distribution:
0:-nan%
rx ring used: 0 free: 4096
cq ring used: 0 free: 16
Port 2
rx 0 drop 0 tx 16 inflight 16
Max New: 4096 Avg cycles PP: 0 Credits: 0
Receive burst distribution:
0:-nan%
rx ring used: 0 free: 4096
cq ring used: 16 free: 0
Queue 0 (Atomic)
rx 4480 drop 0 tx 447
Per Port Stats:
Port 0: Pkts: 431 Flows: 0
Port 1: Pkts: 0 Flows: 0
Port 2: Pkts: 16 Flows: 1
iq 0: Used 4033
error: perf_launch_lcores() No schedules for seconds, deadlock
Packet distribution across worker cores :
Worker 0 packets: 1af percentage: 100.00
Result: Failed
@Shijith Thotton, Any idea why the test is failing?
Meantime, I will get the rest of the app code reviewed.
I think, we can get both RFC and crypto producer patches in.
Regards
Abhinandan
^ permalink raw reply [flat|nested] 43+ messages in thread
* RE: [PATCH v5] app/eventdev: add crypto producer mode
2022-02-23 16:33 ` Gujjar, Abhinandan S
@ 2022-02-23 17:02 ` Shijith Thotton
0 siblings, 0 replies; 43+ messages in thread
From: Shijith Thotton @ 2022-02-23 17:02 UTC (permalink / raw)
To: Gujjar, Abhinandan S, Van Haaren, Harry, Jerin Jacob,
Hemant Agrawal, Nipun Gupta
Cc: Jerin Jacob Kollanukkaran, dev
>> > >> >> >
>> > >> >> > + @Van Haaren, Harry
>> > >> >
>> > >> >Hi All,
>> > >> >
>> > >> >I have been away on vacation for the last week - hence the delay
>> > >> >in reply on this thread.
>> > >> >
>> > >> ><snip discussion>
>> > >> >
>> > >> >> > > [1]
>> > >> >> > > Steps to reproduce:
>> > >> >> > > * Clone https://urldefense.proofpoint.com/v2/url?u=http-
>> > >> >3A__dpdk.org_git_next_dpdk-2Dnext-
>> > >>
>> >2Deventdev&d=DwIGaQ&c=nKjWec2b6R0mOyPaz7xtfQ&r=G9w4KsPaQLAC
>> > >> BfGCL
>> > >> >35PtiRH996yqJDxAZwrWegU2qQ&m=-yaLm_cvg5cKTbBy3OoUs719W-
>> > >>
>> >E3ARETajJQmUvoE4aSAPjcEn1kulkRNxTn841D&s=lZjsn2zecck8IBBQRA7fId7
>> > >> BXSYKk
>> > >> >U8Tjj10gNQLB6U&e=
>> > >> >> > > * Apply [v5] app/eventdev: add crypto producer mode
>> > >> >> > > git-pw --server
>> > >> >> > > https://urldefense.proofpoint.com/v2/url?u=https-
>> > >>
>> >3A__patches.dpdk.org_api_1.2_&d=DwIGaQ&c=nKjWec2b6R0mOyPaz7xtf
>> > >> Q&r=G
>> > >> >9w4KsPaQLACBfGCL35PtiRH996yqJDxAZwrWegU2qQ&m=-
>> > >> >yaLm_cvg5cKTbBy3OoUs719W-
>> > >>
>> >E3ARETajJQmUvoE4aSAPjcEn1kulkRNxTn841D&s=VBQtpQ8vwHt9BnMrPLz
>> > >> SneOm
>> > >> >zhLdP5bfyLuY42fCnak&e= --project dpdk
>> > >> >> > > patch apply 107645
>> > >> >> > > * Apply [RFC] app/eventdev: add software crypto adapter
>> support
>> > >> >> > > git-pw --server
>> > >> >> > > https://urldefense.proofpoint.com/v2/url?u=https-
>> > >>
>> >3A__patches.dpdk.org_api_1.2_&d=DwIGaQ&c=nKjWec2b6R0mOyPaz7xtf
>> > >> Q&r=G
>> > >> >9w4KsPaQLACBfGCL35PtiRH996yqJDxAZwrWegU2qQ&m=-
>> > >> >yaLm_cvg5cKTbBy3OoUs719W-
>> > >>
>> >E3ARETajJQmUvoE4aSAPjcEn1kulkRNxTn841D&s=VBQtpQ8vwHt9BnMrPLz
>> > >> SneOm
>> > >> >zhLdP5bfyLuY42fCnak&e= --project dpdk
>> > >> >> > > patch apply 107029
>> > >> >> > > * meson x86_build_debug -Dc_args='-g -O0' -
>> > >> Ddisable_drivers="*/cnxk"
>> > >> >> > > * ninja -C x86_build_debug
>> > >> >> > > * Command to reproduce crash
>> > >> >> > > sudo ./x86_build_debug/app/dpdk-test-eventdev -l 0-8 -s
>> > >> >> > > 0xf0
>> > >> >> > > --vdev=event_sw0 --vdev="crypto_null" --
>> > >> >> > > --prod_type_cryptodev --crypto_adptr_mode 0
>> > >> >> > > --test=perf_queue --stlist=a --wlcores 1 --plcores 2
>> > >> >
>> > >> >Can confirm that these steps indeed cause segfault as reported.
>> > >> >
>> > >> >In debugging, it seems like there are *zero* NEW events, and large
>> > >> >numbers of RELEASE events are enqueued... if so, this is not
>> > >> >compliant to
>> > >> the Eventdev API.
>> > >> >Can somebody confirm that?
>> > >> >
>> > >> >The SW PMD is being told there are events to release, but there aren't
>> any.
>> > >> >Eventually, this leads to a mismatch in credit allocations, which
>> > >> >then causes the IQ-chunks datastructure to corrupt.
>> > >> >
>> > >> >All in all, I'm not convinced this is a SW PMD issue yet - initial
>> > >> >testing points to incorrect event OP NEW/FWD/RELEASE usage. Can we
>> > >> >verify that the OPs being sent are correct?
>> > >> >
>> > >>
>> > >> Looks like an issue in crypto adapter service. The service is
>> > >> starting with OP_FORWARD, if
>> RTE_EVENT_DEV_CAP_IMPLICIT_RELEASE_DISABLE is set.
>> > >> Abhinandan can confirm.
>> > >
>> > >The service is started with what application is requesting for from the
>> adapter.
>> > >The app can request either OP_NEW or FWD mode. Adapter while
>> creating
>> > >a
>> > new
>> > >instance
>> > >requests for evendev caps & based on that adapter enqueues events
>> > >back to evdev in FWD or NEW mode. All events are triggered by
>> > >application and adapter is transparent here. Could you please explain
>> > >me how this creating an issue?
>> > >
>> >
>> > In lib/eventdev/rte_event_crypto_adapter.c:
>> > ...
>> > eca_ops_enqueue_burst(struct event_crypto_adapter *adapter, ...
>> > rte_memcpy(ev, &m_data->response_info, sizeof(*ev));
>> > ev->event_ptr = ops[i];
>> > ev->event_type = RTE_EVENT_TYPE_CRYPTODEV;
>> > if (adapter->implicit_release_disabled)
>> > ev->op = RTE_EVENT_OP_FORWARD;
>> > else
>> > ev->op = RTE_EVENT_OP_NEW; ...
>> >
>> > op and event_type is set in the service. Changing FORWARD to NEW will
>> > fix the crash.
>>
>> Yes, I think that is true, but lets ensure we're all understanding the reason.
>>
>> The crash reported occurs when events with FORWARD are sent into the SW
>> PMD, and later those are RELEASED. Notice, the event was never *NEW*.
>>
>> Eventdev demands that when adding "new" things (e.g. events not
>> previously seen by the PMD) into the Eventdev instance, the type of the
>> event must be NEW. The NEW op type consumes "credits" in the SW PMD,
>> and causes tracking for the NEW events.
>>
>> I think that here the events *starts* with FORWARD events (should be NEW),
>> and hence the crash occurs, because the NEW type was never enqueued
>> first.
>>
>> Shijith suggests changing FORWARD to NEW to fix the crash, I believe that
>> may *fix* the crash here, but doing so without consideration for "implicit-
>> release" mode may break things elsewhere.
>>
>> Is the better fix to ensure that any events being enqueued into Eventdev for
>> the first time are of a NEW type, and once circulated, either FORWARD or
>> NEW can be used in a valid way?
>>
>>
>> > I think, we should update the spec with what all values are used in
>> response info.
>> > I will remove setting op/event_type field of response info in the
>> application.
>> > PMD/service can take care of it.
>>
>> I'm not familiar with how the adapter/pmd/service interact - no input from
>> me.
>
>Harry and Shijith, Thanks for all the observations.
>
>After debugging, I think the changes are required in both adapter and application:
>1. Application/Adapter in FWD mode case: The app is forming FWD events as an
>event originator (it is supposed to form NEW events) which is causing the crash!
>App fix:
>root@dev:/home/intel/abhi/dpdk-next-eventdev#
>In crypto_adapter_enq_op_fwd() -> change as below:
>- ev.op = RTE_EVENT_OP_FORWARD;
>+ ev.op = RTE_EVENT_OP_NEW;
> ev.queue_id = p->queue_id;
> ev.sched_type = RTE_SCHED_TYPE_ATOMIC;
>
Will send v7 with this change + changes to not set op and event_type in application.
>2. Adapter in NEW mode case: The app is calls rte_cryptodev_enqueue_burst()
>and directly enqueue crypto ops. Adapter had no clue crypto ops were derived
>from events or they were directly enqueued by application.
>So, below is the fix for that:
>root@dev:/home/intel/abhi/dpdk-next-eventdev# git diff
>lib/eventdev/rte_event_crypto_adapter.c
>diff --git a/lib/eventdev/rte_event_crypto_adapter.c
>b/lib/eventdev/rte_event_crypto_adapter.c
>index 0b484f3695..a6328b853d 100644
>--- a/lib/eventdev/rte_event_crypto_adapter.c
>+++ b/lib/eventdev/rte_event_crypto_adapter.c
>@@ -658,7 +658,9 @@ eca_ops_enqueue_burst(struct event_crypto_adapter
>*adapter,
> rte_memcpy(ev, &m_data->response_info, sizeof(*ev));
> ev->event_ptr = ops[i];
> ev->event_type = RTE_EVENT_TYPE_CRYPTODEV;
>- if (adapter->implicit_release_disabled)
>+ if (adapter->mode == RTE_EVENT_CRYPTO_ADAPTER_OP_NEW)
>+ ev->op = RTE_EVENT_OP_NEW;
>+ else if (adapter->implicit_release_disabled)
> ev->op = RTE_EVENT_OP_FORWARD;
> else
> ev->op = RTE_EVENT_OP_NEW;
>
>
>With the above fix, I can run the test for both NEW and FWD mode:
>
>root@xdp-dev:/home/intel/abhi/dpdk-next-eventdev/abhi# ./app/dpdk-test-
>eventdev -l 0-8 -s 0xf0 --vdev=event_sw0 --vdev="crypto_null" -- --
>prod_type_cryptodev --crypto_adptr_mode 0 --test=perf_queue --stlist=a --
>wlcores 1 --plcores 2
>EAL: Detected CPU lcores: 96
>EAL: Detected NUMA nodes: 2
>EAL: Detected static linkage of DPDK
>EAL: Multi-process socket /var/run/dpdk/rte/mp_socket
>EAL: Selected IOVA mode 'PA'
>EAL: VFIO support initialized
>CRYPTODEV: Creating cryptodev crypto_null
>
>CRYPTODEV: Initialisation parameters - name: crypto_null,socket id: 0, max queue
>pairs: 8
>TELEMETRY: No legacy callbacks, legacy socket not created
> driver : event_sw
> test : perf_queue
> dev : 0
> verbose_level : 1
> socket_id : -1
> pool_sz : 16384
> main lcore : 0
> nb_pkts : 67108864
> nb_timers : 100000000
> available lcores : {0 1 2 3 8}
> nb_flows : 1024
> worker deq depth : 16
> fwd_latency : false
> nb_prod_lcores : 1
> producer lcores : {2}
> nb_worker_lcores : 1
> worker lcores : {1}
> nb_stages : 1
> nb_evdev_ports : 2
> nb_evdev_queues : 1
> queue_priority : false
> sched_type_list : {A}
> crypto adapter mode : OP_NEW
> nb_cryptodev : 1
> prod_type : Event crypto adapter producers
> prod_enq_burst_sz : 1
>CRYPTODEV: elt_size 0 is expanded to 208
>
>0.000 mpps avg 0.000 mppsEventDev todo-fix-name: ports 3, qids 1
> rx 6080
> drop 0
> tx 2040
> sched calls: 9064463
> sched cq/qid call: 9069025
> sched no IQ enq: 9063156
> sched no CQ enq: 9063759
> inflight 4096, credits: 0
> Port 0
> rx 0 drop 0 tx 2024 inflight 0
> Max New: 4096 Avg cycles PP: 745 Credits: 40
> Receive burst distribution:
> 0:100% 1-4:0.00% 5-8:0.00% 9-12:0.00% 13-16:0.00%
> rx ring used: 0 free: 4096
> cq ring used: 0 free: 16
> Port 1
> rx 0 drop 0 tx 0 inflight 0
> Max New: 4096 Avg cycles PP: 0 Credits: 0
> Receive burst distribution:
> 0:-nan%
> rx ring used: 0 free: 4096
> cq ring used: 0 free: 16
> Port 2
> rx 6080 drop 0 tx 16 inflight 16
> Max New: 4096 Avg cycles PP: 0 Credits: 0
> Receive burst distribution:
> 0:-nan%
> rx ring used: 0 free: 4096
> cq ring used: 16 free: 0
> Queue 0 (Atomic)
> rx 6080 drop 0 tx 2040
> Per Port Stats:
> Port 0: Pkts: 2024 Flows: 0
> Port 1: Pkts: 0 Flows: 0
> Port 2: Pkts: 16 Flows: 22
> iq 1: Used 4040
>error: perf_launch_lcores() No schedules for seconds, deadlock
>
>Packet distribution across worker cores :
>Worker 0 packets: 7e8 percentage: 100.00
>Result: Failed
>
>
>root@xdp-dev:/home/intel/abhi/dpdk-next-eventdev/abhi# ./app/dpdk-test-
>eventdev -l 0-8 -s 0xf0 --vdev=event_sw0 --vdev="crypto_null" -- --
>prod_type_cryptodev --crypto_adptr_mode 1 --test=perf_queue --stlist=a --
>wlcores 1 --plcores 2
>EAL: Detected CPU lcores: 96
>EAL: Detected NUMA nodes: 2
>EAL: Detected static linkage of DPDK
>EAL: Multi-process socket /var/run/dpdk/rte/mp_socket
>EAL: Selected IOVA mode 'PA'
>EAL: VFIO support initialized
>CRYPTODEV: Creating cryptodev crypto_null
>
>CRYPTODEV: Initialisation parameters - name: crypto_null,socket id: 0, max queue
>pairs: 8
>TELEMETRY: No legacy callbacks, legacy socket not created
> driver : event_sw
> test : perf_queue
> dev : 0
> verbose_level : 1
> socket_id : -1
> pool_sz : 16384
> main lcore : 0
> nb_pkts : 67108864
> nb_timers : 100000000
> available lcores : {0 1 2 3 8}
> nb_flows : 1024
> worker deq depth : 16
> fwd_latency : false
> nb_prod_lcores : 1
> producer lcores : {2}
> nb_worker_lcores : 1
> worker lcores : {1}
> nb_stages : 1
> nb_evdev_ports : 2
> nb_evdev_queues : 1
> queue_priority : false
> sched_type_list : {A}
> crypto adapter mode : OP_FORWARD
> nb_cryptodev : 1
> prod_type : Event crypto adapter producers
> prod_enq_burst_sz : 1
>CRYPTODEV: elt_size 0 is expanded to 208
>
>0.000 mpps avg 0.000 mppsEventDev todo-fix-name: ports 3, qids 1
> rx 4480
> drop 0
> tx 447
> sched calls: 8438712
> sched cq/qid call: 8442432
> sched no IQ enq: 8438434
> sched no CQ enq: 8438494
> inflight 4096, credits: 0
> Port 0
> rx 0 drop 0 tx 431 inflight 0
> Max New: 4096 Avg cycles PP: 637 Credits: 47
> Receive burst distribution:
> 0:100% 1-4:0.00% 5-8:0.00% 13-16:0.00%
> rx ring used: 0 free: 4096
> cq ring used: 0 free: 16
> Port 1
> rx 4480 drop 0 tx 0 inflight 0
> Max New: 4096 Avg cycles PP: 0 Credits: 0
> Receive burst distribution:
> 0:-nan%
> rx ring used: 0 free: 4096
> cq ring used: 0 free: 16
> Port 2
> rx 0 drop 0 tx 16 inflight 16
> Max New: 4096 Avg cycles PP: 0 Credits: 0
> Receive burst distribution:
> 0:-nan%
> rx ring used: 0 free: 4096
> cq ring used: 16 free: 0
> Queue 0 (Atomic)
> rx 4480 drop 0 tx 447
> Per Port Stats:
> Port 0: Pkts: 431 Flows: 0
> Port 1: Pkts: 0 Flows: 0
> Port 2: Pkts: 16 Flows: 1
> iq 0: Used 4033
>error: perf_launch_lcores() No schedules for seconds, deadlock
>
>Packet distribution across worker cores :
>Worker 0 packets: 1af percentage: 100.00
>Result: Failed
>
>@Shijith Thotton, Any idea why the test is failing?
I'm not sure what the issue is here.
>Meantime, I will get the rest of the app code reviewed.
>I think, we can get both RFC and crypto producer patches in.
>
Better keep both patch separate. RFC can be merged after fixing above issue.
^ permalink raw reply [flat|nested] 43+ messages in thread
* [PATCH v7] app/eventdev: add crypto producer mode
2022-02-18 12:11 ` [PATCH v6] " Shijith Thotton
@ 2022-02-24 4:46 ` Shijith Thotton
2022-02-24 6:18 ` Gujjar, Abhinandan S
0 siblings, 1 reply; 43+ messages in thread
From: Shijith Thotton @ 2022-02-24 4:46 UTC (permalink / raw)
To: dev, jerinj; +Cc: Shijith Thotton, abhinandan.gujjar, Akhil Goyal
In crypto producer mode, producer core enqueues cryptodev with software
generated crypto ops and worker core dequeues crypto completion events
from the eventdev. Event crypto metadata used for above processing is
pre-populated in each crypto session.
Parameter --prod_type_cryptodev can be used to enable crypto producer
mode. Parameter --crypto_adptr_mode can be set to select the crypto
adapter mode, 0 for OP_NEW and 1 for OP_FORWARD.
This mode can be used to measure the performance of crypto adapter.
Example:
./dpdk-test-eventdev -l 0-2 -w <EVENTDEV> -w <CRYPTODEV> -- \
--prod_type_cryptodev --crypto_adptr_mode 1 --test=perf_atq \
--stlist=a --wlcores 1 --plcores 2
Signed-off-by: Shijith Thotton <sthotton@marvell.com>
Acked-by: Akhil Goyal <gakhil@marvell.com>
---
v7:
* Removed setting op and event_type in response info.
* Fixed op type of event in FORWARD mode.
v6:
* Added cryptodev close.
* Fixed cleanup.
* Updated release notes.
v5:
* Rebased.
v4:
* Addressed comments on v3 and rebased.
* Added cryptodev cleanup in signal handler.
v3:
* Reduce dereference inside loop.
v2:
* Fix RHEL compilation warning.
app/test-eventdev/evt_common.h | 3 +
app/test-eventdev/evt_main.c | 17 +-
app/test-eventdev/evt_options.c | 27 ++
app/test-eventdev/evt_options.h | 12 +
app/test-eventdev/evt_test.h | 6 +
app/test-eventdev/test_perf_atq.c | 49 +++
app/test-eventdev/test_perf_common.c | 427 ++++++++++++++++++++++++-
app/test-eventdev/test_perf_common.h | 18 +-
app/test-eventdev/test_perf_queue.c | 50 +++
doc/guides/rel_notes/release_22_03.rst | 5 +
doc/guides/tools/testeventdev.rst | 13 +
11 files changed, 619 insertions(+), 8 deletions(-)
diff --git a/app/test-eventdev/evt_common.h b/app/test-eventdev/evt_common.h
index f466434459..2f301a7e79 100644
--- a/app/test-eventdev/evt_common.h
+++ b/app/test-eventdev/evt_common.h
@@ -7,6 +7,7 @@
#include <rte_common.h>
#include <rte_debug.h>
+#include <rte_event_crypto_adapter.h>
#include <rte_eventdev.h>
#include <rte_service.h>
@@ -39,6 +40,7 @@ enum evt_prod_type {
EVT_PROD_TYPE_SYNT, /* Producer type Synthetic i.e. CPU. */
EVT_PROD_TYPE_ETH_RX_ADPTR, /* Producer type Eth Rx Adapter. */
EVT_PROD_TYPE_EVENT_TIMER_ADPTR, /* Producer type Timer Adapter. */
+ EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR, /* Producer type Crypto Adapter. */
EVT_PROD_TYPE_MAX,
};
@@ -77,6 +79,7 @@ struct evt_options {
uint64_t timer_tick_nsec;
uint64_t optm_timer_tick_nsec;
enum evt_prod_type prod_type;
+ enum rte_event_crypto_adapter_mode crypto_adptr_mode;
};
static inline bool
diff --git a/app/test-eventdev/evt_main.c b/app/test-eventdev/evt_main.c
index 194c980c7a..a7d6b0c1cf 100644
--- a/app/test-eventdev/evt_main.c
+++ b/app/test-eventdev/evt_main.c
@@ -35,6 +35,9 @@ signal_handler(int signum)
if (test->ops.ethdev_destroy)
test->ops.ethdev_destroy(test, &opt);
+ if (test->ops.cryptodev_destroy)
+ test->ops.cryptodev_destroy(test, &opt);
+
rte_eal_mp_wait_lcore();
if (test->ops.test_result)
@@ -162,11 +165,19 @@ main(int argc, char **argv)
}
}
+ /* Test specific cryptodev setup */
+ if (test->ops.cryptodev_setup) {
+ if (test->ops.cryptodev_setup(test, &opt)) {
+ evt_err("%s: cryptodev setup failed", opt.test_name);
+ goto ethdev_destroy;
+ }
+ }
+
/* Test specific eventdev setup */
if (test->ops.eventdev_setup) {
if (test->ops.eventdev_setup(test, &opt)) {
evt_err("%s: eventdev setup failed", opt.test_name);
- goto ethdev_destroy;
+ goto cryptodev_destroy;
}
}
@@ -197,6 +208,10 @@ main(int argc, char **argv)
if (test->ops.eventdev_destroy)
test->ops.eventdev_destroy(test, &opt);
+cryptodev_destroy:
+ if (test->ops.cryptodev_destroy)
+ test->ops.cryptodev_destroy(test, &opt);
+
ethdev_destroy:
if (test->ops.ethdev_destroy)
test->ops.ethdev_destroy(test, &opt);
diff --git a/app/test-eventdev/evt_options.c b/app/test-eventdev/evt_options.c
index 4ae44801da..d3c704d2b3 100644
--- a/app/test-eventdev/evt_options.c
+++ b/app/test-eventdev/evt_options.c
@@ -122,6 +122,26 @@ evt_parse_timer_prod_type_burst(struct evt_options *opt,
return 0;
}
+static int
+evt_parse_crypto_prod_type(struct evt_options *opt,
+ const char *arg __rte_unused)
+{
+ opt->prod_type = EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR;
+ return 0;
+}
+
+static int
+evt_parse_crypto_adptr_mode(struct evt_options *opt, const char *arg)
+{
+ uint8_t mode;
+ int ret;
+
+ ret = parser_read_uint8(&mode, arg);
+ opt->crypto_adptr_mode = mode ? RTE_EVENT_CRYPTO_ADAPTER_OP_FORWARD :
+ RTE_EVENT_CRYPTO_ADAPTER_OP_NEW;
+ return ret;
+}
+
static int
evt_parse_test_name(struct evt_options *opt, const char *arg)
{
@@ -335,6 +355,7 @@ usage(char *program)
"\t--queue_priority : enable queue priority\n"
"\t--deq_tmo_nsec : global dequeue timeout\n"
"\t--prod_type_ethdev : use ethernet device as producer.\n"
+ "\t--prod_type_cryptodev : use crypto device as producer.\n"
"\t--prod_type_timerdev : use event timer device as producer.\n"
"\t expiry_nsec would be the timeout\n"
"\t in ns.\n"
@@ -345,6 +366,8 @@ usage(char *program)
"\t--timer_tick_nsec : timer tick interval in ns.\n"
"\t--max_tmo_nsec : max timeout interval in ns.\n"
"\t--expiry_nsec : event timer expiry ns.\n"
+ "\t--crypto_adptr_mode : 0 for OP_NEW mode (default) and\n"
+ "\t 1 for OP_FORWARD mode.\n"
"\t--mbuf_sz : packet mbuf size.\n"
"\t--max_pkt_sz : max packet size.\n"
"\t--prod_enq_burst_sz : producer enqueue burst size.\n"
@@ -415,8 +438,10 @@ static struct option lgopts[] = {
{ EVT_QUEUE_PRIORITY, 0, 0, 0 },
{ EVT_DEQ_TMO_NSEC, 1, 0, 0 },
{ EVT_PROD_ETHDEV, 0, 0, 0 },
+ { EVT_PROD_CRYPTODEV, 0, 0, 0 },
{ EVT_PROD_TIMERDEV, 0, 0, 0 },
{ EVT_PROD_TIMERDEV_BURST, 0, 0, 0 },
+ { EVT_CRYPTO_ADPTR_MODE, 1, 0, 0 },
{ EVT_NB_TIMERS, 1, 0, 0 },
{ EVT_NB_TIMER_ADPTRS, 1, 0, 0 },
{ EVT_TIMER_TICK_NSEC, 1, 0, 0 },
@@ -455,8 +480,10 @@ evt_opts_parse_long(int opt_idx, struct evt_options *opt)
{ EVT_QUEUE_PRIORITY, evt_parse_queue_priority},
{ EVT_DEQ_TMO_NSEC, evt_parse_deq_tmo_nsec},
{ EVT_PROD_ETHDEV, evt_parse_eth_prod_type},
+ { EVT_PROD_CRYPTODEV, evt_parse_crypto_prod_type},
{ EVT_PROD_TIMERDEV, evt_parse_timer_prod_type},
{ EVT_PROD_TIMERDEV_BURST, evt_parse_timer_prod_type_burst},
+ { EVT_CRYPTO_ADPTR_MODE, evt_parse_crypto_adptr_mode},
{ EVT_NB_TIMERS, evt_parse_nb_timers},
{ EVT_NB_TIMER_ADPTRS, evt_parse_nb_timer_adptrs},
{ EVT_TIMER_TICK_NSEC, evt_parse_timer_tick_nsec},
diff --git a/app/test-eventdev/evt_options.h b/app/test-eventdev/evt_options.h
index 413d7092f0..2231c58801 100644
--- a/app/test-eventdev/evt_options.h
+++ b/app/test-eventdev/evt_options.h
@@ -9,6 +9,7 @@
#include <stdbool.h>
#include <rte_common.h>
+#include <rte_cryptodev.h>
#include <rte_ethdev.h>
#include <rte_eventdev.h>
#include <rte_lcore.h>
@@ -33,8 +34,10 @@
#define EVT_QUEUE_PRIORITY ("queue_priority")
#define EVT_DEQ_TMO_NSEC ("deq_tmo_nsec")
#define EVT_PROD_ETHDEV ("prod_type_ethdev")
+#define EVT_PROD_CRYPTODEV ("prod_type_cryptodev")
#define EVT_PROD_TIMERDEV ("prod_type_timerdev")
#define EVT_PROD_TIMERDEV_BURST ("prod_type_timerdev_burst")
+#define EVT_CRYPTO_ADPTR_MODE ("crypto_adptr_mode")
#define EVT_NB_TIMERS ("nb_timers")
#define EVT_NB_TIMER_ADPTRS ("nb_timer_adptrs")
#define EVT_TIMER_TICK_NSEC ("timer_tick_nsec")
@@ -249,6 +252,8 @@ evt_prod_id_to_name(enum evt_prod_type prod_type)
return "Ethdev Rx Adapter";
case EVT_PROD_TYPE_EVENT_TIMER_ADPTR:
return "Event timer adapter";
+ case EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR:
+ return "Event crypto adapter";
}
return "";
@@ -288,6 +293,13 @@ evt_dump_producer_type(struct evt_options *opt)
evt_dump("timer_tick_nsec", "%"PRIu64"",
opt->timer_tick_nsec);
break;
+ case EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR:
+ snprintf(name, EVT_PROD_MAX_NAME_LEN,
+ "Event crypto adapter producers");
+ evt_dump("crypto adapter mode", "%s",
+ opt->crypto_adptr_mode ? "OP_FORWARD" : "OP_NEW");
+ evt_dump("nb_cryptodev", "%u", rte_cryptodev_count());
+ break;
}
evt_dump("prod_type", "%s", name);
}
diff --git a/app/test-eventdev/evt_test.h b/app/test-eventdev/evt_test.h
index f07d2c3336..50fa474ec2 100644
--- a/app/test-eventdev/evt_test.h
+++ b/app/test-eventdev/evt_test.h
@@ -29,6 +29,8 @@ typedef int (*evt_test_mempool_setup_t)
(struct evt_test *test, struct evt_options *opt);
typedef int (*evt_test_ethdev_setup_t)
(struct evt_test *test, struct evt_options *opt);
+typedef int (*evt_test_cryptodev_setup_t)
+ (struct evt_test *test, struct evt_options *opt);
typedef int (*evt_test_eventdev_setup_t)
(struct evt_test *test, struct evt_options *opt);
typedef int (*evt_test_launch_lcores_t)
@@ -39,6 +41,8 @@ typedef void (*evt_test_eventdev_destroy_t)
(struct evt_test *test, struct evt_options *opt);
typedef void (*evt_test_ethdev_destroy_t)
(struct evt_test *test, struct evt_options *opt);
+typedef void (*evt_test_cryptodev_destroy_t)
+ (struct evt_test *test, struct evt_options *opt);
typedef void (*evt_test_mempool_destroy_t)
(struct evt_test *test, struct evt_options *opt);
typedef void (*evt_test_destroy_t)
@@ -52,10 +56,12 @@ struct evt_test_ops {
evt_test_mempool_setup_t mempool_setup;
evt_test_ethdev_setup_t ethdev_setup;
evt_test_eventdev_setup_t eventdev_setup;
+ evt_test_cryptodev_setup_t cryptodev_setup;
evt_test_launch_lcores_t launch_lcores;
evt_test_result_t test_result;
evt_test_eventdev_destroy_t eventdev_destroy;
evt_test_ethdev_destroy_t ethdev_destroy;
+ evt_test_cryptodev_destroy_t cryptodev_destroy;
evt_test_mempool_destroy_t mempool_destroy;
evt_test_destroy_t test_destroy;
};
diff --git a/app/test-eventdev/test_perf_atq.c b/app/test-eventdev/test_perf_atq.c
index 8fd51004ee..67ff681666 100644
--- a/app/test-eventdev/test_perf_atq.c
+++ b/app/test-eventdev/test_perf_atq.c
@@ -48,6 +48,22 @@ perf_atq_worker(void *arg, const int enable_fwd_latency)
continue;
}
+ if (prod_crypto_type &&
+ (ev.event_type == RTE_EVENT_TYPE_CRYPTODEV)) {
+ struct rte_crypto_op *op = ev.event_ptr;
+
+ if (op->status == RTE_CRYPTO_OP_STATUS_SUCCESS) {
+ if (op->sym->m_dst == NULL)
+ ev.event_ptr = op->sym->m_src;
+ else
+ ev.event_ptr = op->sym->m_dst;
+ rte_crypto_op_free(op);
+ } else {
+ rte_crypto_op_free(op);
+ continue;
+ }
+ }
+
if (enable_fwd_latency && !prod_timer_type)
/* first stage in pipeline, mark ts to compute fwd latency */
atq_mark_fwd_latency(&ev);
@@ -87,6 +103,25 @@ perf_atq_worker_burst(void *arg, const int enable_fwd_latency)
}
for (i = 0; i < nb_rx; i++) {
+ if (prod_crypto_type &&
+ (ev[i].event_type == RTE_EVENT_TYPE_CRYPTODEV)) {
+ struct rte_crypto_op *op = ev[i].event_ptr;
+
+ if (op->status ==
+ RTE_CRYPTO_OP_STATUS_SUCCESS) {
+ if (op->sym->m_dst == NULL)
+ ev[i].event_ptr =
+ op->sym->m_src;
+ else
+ ev[i].event_ptr =
+ op->sym->m_dst;
+ rte_crypto_op_free(op);
+ } else {
+ rte_crypto_op_free(op);
+ continue;
+ }
+ }
+
if (enable_fwd_latency && !prod_timer_type) {
rte_prefetch0(ev[i+1].event_ptr);
/* first stage in pipeline.
@@ -254,6 +289,18 @@ perf_atq_eventdev_setup(struct evt_test *test, struct evt_options *opt)
return ret;
}
}
+ } else if (opt->prod_type == EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR) {
+ uint8_t cdev_id, cdev_count;
+
+ cdev_count = rte_cryptodev_count();
+ for (cdev_id = 0; cdev_id < cdev_count; cdev_id++) {
+ ret = rte_cryptodev_start(cdev_id);
+ if (ret) {
+ evt_err("Failed to start cryptodev %u",
+ cdev_id);
+ return ret;
+ }
+ }
}
return 0;
@@ -295,12 +342,14 @@ static const struct evt_test_ops perf_atq = {
.opt_dump = perf_atq_opt_dump,
.test_setup = perf_test_setup,
.ethdev_setup = perf_ethdev_setup,
+ .cryptodev_setup = perf_cryptodev_setup,
.mempool_setup = perf_mempool_setup,
.eventdev_setup = perf_atq_eventdev_setup,
.launch_lcores = perf_atq_launch_lcores,
.eventdev_destroy = perf_eventdev_destroy,
.mempool_destroy = perf_mempool_destroy,
.ethdev_destroy = perf_ethdev_destroy,
+ .cryptodev_destroy = perf_cryptodev_destroy,
.test_result = perf_test_result,
.test_destroy = perf_test_destroy,
};
diff --git a/app/test-eventdev/test_perf_common.c b/app/test-eventdev/test_perf_common.c
index 9b73874151..9d1f4a4567 100644
--- a/app/test-eventdev/test_perf_common.c
+++ b/app/test-eventdev/test_perf_common.c
@@ -6,6 +6,8 @@
#include "test_perf_common.h"
+#define NB_CRYPTODEV_DESCRIPTORS 128
+
int
perf_test_result(struct evt_test *test, struct evt_options *opt)
{
@@ -272,6 +274,123 @@ perf_event_timer_producer_burst(void *arg)
return 0;
}
+static inline void
+crypto_adapter_enq_op_new(struct prod_data *p)
+{
+ struct rte_cryptodev_sym_session **crypto_sess = p->ca.crypto_sess;
+ struct test_perf *t = p->t;
+ const uint32_t nb_flows = t->nb_flows;
+ const uint64_t nb_pkts = t->nb_pkts;
+ struct rte_mempool *pool = t->pool;
+ struct rte_crypto_sym_op *sym_op;
+ struct evt_options *opt = t->opt;
+ uint16_t qp_id = p->ca.cdev_qp_id;
+ uint8_t cdev_id = p->ca.cdev_id;
+ uint32_t flow_counter = 0;
+ struct rte_crypto_op *op;
+ struct rte_mbuf *m;
+ uint64_t count = 0;
+ uint16_t len;
+
+ if (opt->verbose_level > 1)
+ printf("%s(): lcore %d queue %d cdev_id %u cdev_qp_id %u\n",
+ __func__, rte_lcore_id(), p->queue_id, p->ca.cdev_id,
+ p->ca.cdev_qp_id);
+
+ len = opt->mbuf_sz ? opt->mbuf_sz : RTE_ETHER_MIN_LEN;
+
+ while (count < nb_pkts && t->done == false) {
+ m = rte_pktmbuf_alloc(pool);
+ if (m == NULL)
+ continue;
+
+ rte_pktmbuf_append(m, len);
+ op = rte_crypto_op_alloc(t->ca_op_pool,
+ RTE_CRYPTO_OP_TYPE_SYMMETRIC);
+ sym_op = op->sym;
+ sym_op->m_src = m;
+ sym_op->cipher.data.offset = 0;
+ sym_op->cipher.data.length = len;
+ rte_crypto_op_attach_sym_session(
+ op, crypto_sess[flow_counter++ % nb_flows]);
+
+ while (rte_cryptodev_enqueue_burst(cdev_id, qp_id, &op, 1) != 1 &&
+ t->done == false)
+ rte_pause();
+
+ count++;
+ }
+}
+
+static inline void
+crypto_adapter_enq_op_fwd(struct prod_data *p)
+{
+ struct rte_cryptodev_sym_session **crypto_sess = p->ca.crypto_sess;
+ const uint8_t dev_id = p->dev_id;
+ const uint8_t port = p->port_id;
+ struct test_perf *t = p->t;
+ const uint32_t nb_flows = t->nb_flows;
+ const uint64_t nb_pkts = t->nb_pkts;
+ struct rte_mempool *pool = t->pool;
+ struct evt_options *opt = t->opt;
+ struct rte_crypto_sym_op *sym_op;
+ uint32_t flow_counter = 0;
+ struct rte_crypto_op *op;
+ struct rte_event ev;
+ struct rte_mbuf *m;
+ uint64_t count = 0;
+ uint16_t len;
+
+ if (opt->verbose_level > 1)
+ printf("%s(): lcore %d port %d queue %d cdev_id %u cdev_qp_id %u\n",
+ __func__, rte_lcore_id(), port, p->queue_id,
+ p->ca.cdev_id, p->ca.cdev_qp_id);
+
+ ev.event = 0;
+ ev.op = RTE_EVENT_OP_NEW;
+ ev.queue_id = p->queue_id;
+ ev.sched_type = RTE_SCHED_TYPE_ATOMIC;
+ ev.event_type = RTE_EVENT_TYPE_CPU;
+ len = opt->mbuf_sz ? opt->mbuf_sz : RTE_ETHER_MIN_LEN;
+
+ while (count < nb_pkts && t->done == false) {
+ m = rte_pktmbuf_alloc(pool);
+ if (m == NULL)
+ continue;
+
+ rte_pktmbuf_append(m, len);
+ op = rte_crypto_op_alloc(t->ca_op_pool,
+ RTE_CRYPTO_OP_TYPE_SYMMETRIC);
+ sym_op = op->sym;
+ sym_op->m_src = m;
+ sym_op->cipher.data.offset = 0;
+ sym_op->cipher.data.length = len;
+ rte_crypto_op_attach_sym_session(
+ op, crypto_sess[flow_counter++ % nb_flows]);
+ ev.event_ptr = op;
+
+ while (rte_event_crypto_adapter_enqueue(dev_id, port, &ev, 1) != 1 &&
+ t->done == false)
+ rte_pause();
+
+ count++;
+ }
+}
+
+static inline int
+perf_event_crypto_producer(void *arg)
+{
+ struct prod_data *p = arg;
+ struct evt_options *opt = p->t->opt;
+
+ if (opt->crypto_adptr_mode == RTE_EVENT_CRYPTO_ADAPTER_OP_NEW)
+ crypto_adapter_enq_op_new(p);
+ else
+ crypto_adapter_enq_op_fwd(p);
+
+ return 0;
+}
+
static int
perf_producer_wrapper(void *arg)
{
@@ -298,6 +417,8 @@ perf_producer_wrapper(void *arg)
else if (t->opt->prod_type == EVT_PROD_TYPE_EVENT_TIMER_ADPTR &&
t->opt->timdev_use_burst)
return perf_event_timer_producer_burst(arg);
+ else if (t->opt->prod_type == EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR)
+ return perf_event_crypto_producer(arg);
return 0;
}
@@ -405,8 +526,10 @@ perf_launch_lcores(struct evt_test *test, struct evt_options *opt,
if (remaining <= 0) {
t->result = EVT_TEST_SUCCESS;
if (opt->prod_type == EVT_PROD_TYPE_SYNT ||
- opt->prod_type ==
- EVT_PROD_TYPE_EVENT_TIMER_ADPTR) {
+ opt->prod_type ==
+ EVT_PROD_TYPE_EVENT_TIMER_ADPTR ||
+ opt->prod_type ==
+ EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR) {
t->done = true;
break;
}
@@ -415,7 +538,8 @@ perf_launch_lcores(struct evt_test *test, struct evt_options *opt,
if (new_cycles - dead_lock_cycles > dead_lock_sample &&
(opt->prod_type == EVT_PROD_TYPE_SYNT ||
- opt->prod_type == EVT_PROD_TYPE_EVENT_TIMER_ADPTR)) {
+ opt->prod_type == EVT_PROD_TYPE_EVENT_TIMER_ADPTR ||
+ opt->prod_type == EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR)) {
remaining = t->outstand_pkts - processed_pkts(t);
if (dead_lock_remaining == remaining) {
rte_event_dev_dump(opt->dev_id, stdout);
@@ -537,6 +661,74 @@ perf_event_timer_adapter_setup(struct test_perf *t)
return 0;
}
+static int
+perf_event_crypto_adapter_setup(struct test_perf *t, struct prod_data *p)
+{
+ struct evt_options *opt = t->opt;
+ uint32_t cap;
+ int ret;
+
+ ret = rte_event_crypto_adapter_caps_get(p->dev_id, p->ca.cdev_id, &cap);
+ if (ret) {
+ evt_err("Failed to get crypto adapter capabilities");
+ return ret;
+ }
+
+ if (((opt->crypto_adptr_mode == RTE_EVENT_CRYPTO_ADAPTER_OP_NEW) &&
+ !(cap & RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_OP_NEW)) ||
+ ((opt->crypto_adptr_mode == RTE_EVENT_CRYPTO_ADAPTER_OP_FORWARD) &&
+ !(cap & RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_OP_FWD))) {
+ evt_err("crypto adapter %s mode unsupported\n",
+ opt->crypto_adptr_mode ? "OP_FORWARD" : "OP_NEW");
+ return -ENOTSUP;
+ } else if (!(cap & RTE_EVENT_CRYPTO_ADAPTER_CAP_SESSION_PRIVATE_DATA)) {
+ evt_err("Storing crypto session not supported");
+ return -ENOTSUP;
+ }
+
+ if (cap & RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_QP_EV_BIND) {
+ struct rte_event response_info;
+
+ response_info.event = 0;
+ response_info.sched_type = RTE_SCHED_TYPE_ATOMIC;
+ response_info.queue_id = p->queue_id;
+ ret = rte_event_crypto_adapter_queue_pair_add(
+ TEST_PERF_CA_ID, p->ca.cdev_id, p->ca.cdev_qp_id,
+ &response_info);
+ } else {
+ ret = rte_event_crypto_adapter_queue_pair_add(
+ TEST_PERF_CA_ID, p->ca.cdev_id, p->ca.cdev_qp_id, NULL);
+ }
+
+ return ret;
+}
+
+static struct rte_cryptodev_sym_session *
+cryptodev_sym_sess_create(struct prod_data *p, struct test_perf *t)
+{
+ struct rte_crypto_sym_xform cipher_xform;
+ struct rte_cryptodev_sym_session *sess;
+
+ cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
+ cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
+ cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
+ cipher_xform.next = NULL;
+
+ sess = rte_cryptodev_sym_session_create(t->ca_sess_pool);
+ if (sess == NULL) {
+ evt_err("Failed to create sym session");
+ return NULL;
+ }
+
+ if (rte_cryptodev_sym_session_init(p->ca.cdev_id, sess, &cipher_xform,
+ t->ca_sess_priv_pool)) {
+ evt_err("Failed to init session");
+ return NULL;
+ }
+
+ return sess;
+}
+
int
perf_event_dev_port_setup(struct evt_test *test, struct evt_options *opt,
uint8_t stride, uint8_t nb_queues,
@@ -598,6 +790,73 @@ perf_event_dev_port_setup(struct evt_test *test, struct evt_options *opt,
ret = perf_event_timer_adapter_setup(t);
if (ret)
return ret;
+ } else if (opt->prod_type == EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR) {
+ struct rte_event_port_conf conf = *port_conf;
+ uint8_t cdev_id = 0;
+ uint16_t qp_id = 0;
+
+ ret = rte_event_crypto_adapter_create(TEST_PERF_CA_ID,
+ opt->dev_id, &conf, 0);
+ if (ret) {
+ evt_err("Failed to create crypto adapter");
+ return ret;
+ }
+
+ prod = 0;
+ for (; port < perf_nb_event_ports(opt); port++) {
+ struct rte_cryptodev_sym_session *crypto_sess;
+ union rte_event_crypto_metadata m_data;
+ struct prod_data *p = &t->prod[port];
+ uint32_t flow_id;
+
+ if (qp_id == rte_cryptodev_queue_pair_count(cdev_id)) {
+ cdev_id++;
+ qp_id = 0;
+ }
+
+ p->dev_id = opt->dev_id;
+ p->port_id = port;
+ p->queue_id = prod * stride;
+ p->ca.cdev_id = cdev_id;
+ p->ca.cdev_qp_id = qp_id;
+ p->ca.crypto_sess = rte_zmalloc_socket(
+ NULL, sizeof(crypto_sess) * t->nb_flows,
+ RTE_CACHE_LINE_SIZE, opt->socket_id);
+ p->t = t;
+
+ m_data.request_info.cdev_id = p->ca.cdev_id;
+ m_data.request_info.queue_pair_id = p->ca.cdev_qp_id;
+ m_data.response_info.sched_type = RTE_SCHED_TYPE_ATOMIC;
+ m_data.response_info.queue_id = p->queue_id;
+
+ for (flow_id = 0; flow_id < t->nb_flows; flow_id++) {
+ crypto_sess = cryptodev_sym_sess_create(p, t);
+ if (crypto_sess == NULL)
+ return -ENOMEM;
+
+ m_data.response_info.flow_id = flow_id;
+ rte_cryptodev_sym_session_set_user_data(
+ crypto_sess, &m_data, sizeof(m_data));
+ p->ca.crypto_sess[flow_id] = crypto_sess;
+ }
+
+ conf.event_port_cfg |=
+ RTE_EVENT_PORT_CFG_HINT_PRODUCER |
+ RTE_EVENT_PORT_CFG_HINT_CONSUMER;
+
+ ret = rte_event_port_setup(opt->dev_id, port, &conf);
+ if (ret) {
+ evt_err("failed to setup port %d", port);
+ return ret;
+ }
+
+ ret = perf_event_crypto_adapter_setup(t, p);
+ if (ret)
+ return ret;
+
+ qp_id++;
+ prod++;
+ }
} else {
prod = 0;
for ( ; port < perf_nb_event_ports(opt); port++) {
@@ -659,7 +918,8 @@ perf_opt_check(struct evt_options *opt, uint64_t nb_queues)
}
if (opt->prod_type == EVT_PROD_TYPE_SYNT ||
- opt->prod_type == EVT_PROD_TYPE_EVENT_TIMER_ADPTR) {
+ opt->prod_type == EVT_PROD_TYPE_EVENT_TIMER_ADPTR ||
+ opt->prod_type == EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR) {
/* Validate producer lcores */
if (evt_lcores_has_overlap(opt->plcores,
rte_get_main_lcore())) {
@@ -767,8 +1027,7 @@ perf_ethdev_setup(struct evt_test *test, struct evt_options *opt)
},
};
- if (opt->prod_type == EVT_PROD_TYPE_SYNT ||
- opt->prod_type == EVT_PROD_TYPE_EVENT_TIMER_ADPTR)
+ if (opt->prod_type != EVT_PROD_TYPE_ETH_RX_ADPTR)
return 0;
if (!rte_eth_dev_count_avail()) {
@@ -841,6 +1100,162 @@ void perf_ethdev_destroy(struct evt_test *test, struct evt_options *opt)
}
}
+int
+perf_cryptodev_setup(struct evt_test *test, struct evt_options *opt)
+{
+ uint8_t cdev_count, cdev_id, nb_plcores, nb_qps;
+ struct test_perf *t = evt_test_priv(test);
+ unsigned int max_session_size;
+ uint32_t nb_sessions;
+ int ret;
+
+ if (opt->prod_type != EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR)
+ return 0;
+
+ cdev_count = rte_cryptodev_count();
+ if (cdev_count == 0) {
+ evt_err("No crypto devices available\n");
+ return -ENODEV;
+ }
+
+ t->ca_op_pool = rte_crypto_op_pool_create(
+ "crypto_op_pool", RTE_CRYPTO_OP_TYPE_SYMMETRIC, opt->pool_sz,
+ 128, 0, rte_socket_id());
+ if (t->ca_op_pool == NULL) {
+ evt_err("Failed to create crypto op pool");
+ return -ENOMEM;
+ }
+
+ nb_sessions = evt_nr_active_lcores(opt->plcores) * t->nb_flows;
+ t->ca_sess_pool = rte_cryptodev_sym_session_pool_create(
+ "ca_sess_pool", nb_sessions, 0, 0,
+ sizeof(union rte_event_crypto_metadata), SOCKET_ID_ANY);
+ if (t->ca_sess_pool == NULL) {
+ evt_err("Failed to create sym session pool");
+ ret = -ENOMEM;
+ goto err;
+ }
+
+ max_session_size = 0;
+ for (cdev_id = 0; cdev_id < cdev_count; cdev_id++) {
+ unsigned int session_size;
+
+ session_size =
+ rte_cryptodev_sym_get_private_session_size(cdev_id);
+ if (session_size > max_session_size)
+ max_session_size = session_size;
+ }
+
+ max_session_size += sizeof(union rte_event_crypto_metadata);
+ t->ca_sess_priv_pool = rte_mempool_create(
+ "ca_sess_priv_pool", nb_sessions, max_session_size, 0, 0, NULL,
+ NULL, NULL, NULL, SOCKET_ID_ANY, 0);
+ if (t->ca_sess_priv_pool == NULL) {
+ evt_err("failed to create sym session private pool");
+ ret = -ENOMEM;
+ goto err;
+ }
+
+ /*
+ * Calculate number of needed queue pairs, based on the amount of
+ * available number of logical cores and crypto devices. For instance,
+ * if there are 4 cores and 2 crypto devices, 2 queue pairs will be set
+ * up per device.
+ */
+ nb_plcores = evt_nr_active_lcores(opt->plcores);
+ nb_qps = (nb_plcores % cdev_count) ? (nb_plcores / cdev_count) + 1 :
+ nb_plcores / cdev_count;
+ for (cdev_id = 0; cdev_id < cdev_count; cdev_id++) {
+ struct rte_cryptodev_qp_conf qp_conf;
+ struct rte_cryptodev_config conf;
+ struct rte_cryptodev_info info;
+ int qp_id;
+
+ rte_cryptodev_info_get(cdev_id, &info);
+ if (nb_qps > info.max_nb_queue_pairs) {
+ evt_err("Not enough queue pairs per cryptodev (%u)",
+ nb_qps);
+ ret = -EINVAL;
+ goto err;
+ }
+
+ conf.nb_queue_pairs = nb_qps;
+ conf.socket_id = SOCKET_ID_ANY;
+ conf.ff_disable = RTE_CRYPTODEV_FF_SECURITY;
+
+ ret = rte_cryptodev_configure(cdev_id, &conf);
+ if (ret) {
+ evt_err("Failed to configure cryptodev (%u)", cdev_id);
+ goto err;
+ }
+
+ qp_conf.nb_descriptors = NB_CRYPTODEV_DESCRIPTORS;
+ qp_conf.mp_session = t->ca_sess_pool;
+ qp_conf.mp_session_private = t->ca_sess_priv_pool;
+
+ for (qp_id = 0; qp_id < conf.nb_queue_pairs; qp_id++) {
+ ret = rte_cryptodev_queue_pair_setup(
+ cdev_id, qp_id, &qp_conf,
+ rte_cryptodev_socket_id(cdev_id));
+ if (ret) {
+ evt_err("Failed to setup queue pairs on cryptodev %u\n",
+ cdev_id);
+ goto err;
+ }
+ }
+ }
+
+ return 0;
+err:
+ for (cdev_id = 0; cdev_id < cdev_count; cdev_id++)
+ rte_cryptodev_close(cdev_id);
+
+ rte_mempool_free(t->ca_op_pool);
+ rte_mempool_free(t->ca_sess_pool);
+ rte_mempool_free(t->ca_sess_priv_pool);
+
+ return ret;
+}
+
+void
+perf_cryptodev_destroy(struct evt_test *test, struct evt_options *opt)
+{
+ uint8_t cdev_id, cdev_count = rte_cryptodev_count();
+ struct test_perf *t = evt_test_priv(test);
+ uint16_t port;
+
+ if (opt->prod_type != EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR)
+ return;
+
+ for (port = t->nb_workers; port < perf_nb_event_ports(opt); port++) {
+ struct rte_cryptodev_sym_session *sess;
+ struct prod_data *p = &t->prod[port];
+ uint32_t flow_id;
+ uint8_t cdev_id;
+
+ for (flow_id = 0; flow_id < t->nb_flows; flow_id++) {
+ sess = p->ca.crypto_sess[flow_id];
+ cdev_id = p->ca.cdev_id;
+ rte_cryptodev_sym_session_clear(cdev_id, sess);
+ rte_cryptodev_sym_session_free(sess);
+ }
+
+ rte_event_crypto_adapter_queue_pair_del(
+ TEST_PERF_CA_ID, p->ca.cdev_id, p->ca.cdev_qp_id);
+ }
+
+ rte_event_crypto_adapter_free(TEST_PERF_CA_ID);
+
+ for (cdev_id = 0; cdev_id < cdev_count; cdev_id++) {
+ rte_cryptodev_stop(cdev_id);
+ rte_cryptodev_close(cdev_id);
+ }
+
+ rte_mempool_free(t->ca_op_pool);
+ rte_mempool_free(t->ca_sess_pool);
+ rte_mempool_free(t->ca_sess_priv_pool);
+}
+
int
perf_mempool_setup(struct evt_test *test, struct evt_options *opt)
{
diff --git a/app/test-eventdev/test_perf_common.h b/app/test-eventdev/test_perf_common.h
index 14dcf80429..ea0907d61a 100644
--- a/app/test-eventdev/test_perf_common.h
+++ b/app/test-eventdev/test_perf_common.h
@@ -9,9 +9,11 @@
#include <stdbool.h>
#include <unistd.h>
+#include <rte_cryptodev.h>
#include <rte_cycles.h>
#include <rte_ethdev.h>
#include <rte_eventdev.h>
+#include <rte_event_crypto_adapter.h>
#include <rte_event_eth_rx_adapter.h>
#include <rte_event_timer_adapter.h>
#include <rte_lcore.h>
@@ -23,6 +25,8 @@
#include "evt_options.h"
#include "evt_test.h"
+#define TEST_PERF_CA_ID 0
+
struct test_perf;
struct worker_data {
@@ -33,14 +37,19 @@ struct worker_data {
struct test_perf *t;
} __rte_cache_aligned;
+struct crypto_adptr_data {
+ uint8_t cdev_id;
+ uint16_t cdev_qp_id;
+ struct rte_cryptodev_sym_session **crypto_sess;
+};
struct prod_data {
uint8_t dev_id;
uint8_t port_id;
uint8_t queue_id;
+ struct crypto_adptr_data ca;
struct test_perf *t;
} __rte_cache_aligned;
-
struct test_perf {
/* Don't change the offset of "done". Signal handler use this memory
* to terminate all lcores work.
@@ -58,6 +67,9 @@ struct test_perf {
uint8_t sched_type_list[EVT_MAX_STAGES] __rte_cache_aligned;
struct rte_event_timer_adapter *timer_adptr[
RTE_EVENT_TIMER_ADAPTER_NUM_MAX] __rte_cache_aligned;
+ struct rte_mempool *ca_op_pool;
+ struct rte_mempool *ca_sess_pool;
+ struct rte_mempool *ca_sess_priv_pool;
} __rte_cache_aligned;
struct perf_elt {
@@ -81,6 +93,8 @@ struct perf_elt {
const uint8_t port = w->port_id;\
const uint8_t prod_timer_type = \
opt->prod_type == EVT_PROD_TYPE_EVENT_TIMER_ADPTR;\
+ const uint8_t prod_crypto_type = \
+ opt->prod_type == EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR;\
uint8_t *const sched_type_list = &t->sched_type_list[0];\
struct rte_mempool *const pool = t->pool;\
const uint8_t nb_stages = t->opt->nb_stages;\
@@ -154,6 +168,7 @@ int perf_test_result(struct evt_test *test, struct evt_options *opt);
int perf_opt_check(struct evt_options *opt, uint64_t nb_queues);
int perf_test_setup(struct evt_test *test, struct evt_options *opt);
int perf_ethdev_setup(struct evt_test *test, struct evt_options *opt);
+int perf_cryptodev_setup(struct evt_test *test, struct evt_options *opt);
int perf_mempool_setup(struct evt_test *test, struct evt_options *opt);
int perf_event_dev_port_setup(struct evt_test *test, struct evt_options *opt,
uint8_t stride, uint8_t nb_queues,
@@ -164,6 +179,7 @@ int perf_launch_lcores(struct evt_test *test, struct evt_options *opt,
void perf_opt_dump(struct evt_options *opt, uint8_t nb_queues);
void perf_test_destroy(struct evt_test *test, struct evt_options *opt);
void perf_eventdev_destroy(struct evt_test *test, struct evt_options *opt);
+void perf_cryptodev_destroy(struct evt_test *test, struct evt_options *opt);
void perf_ethdev_destroy(struct evt_test *test, struct evt_options *opt);
void perf_mempool_destroy(struct evt_test *test, struct evt_options *opt);
diff --git a/app/test-eventdev/test_perf_queue.c b/app/test-eventdev/test_perf_queue.c
index f4ea3a795f..dcf6d82947 100644
--- a/app/test-eventdev/test_perf_queue.c
+++ b/app/test-eventdev/test_perf_queue.c
@@ -49,6 +49,23 @@ perf_queue_worker(void *arg, const int enable_fwd_latency)
rte_pause();
continue;
}
+
+ if (prod_crypto_type &&
+ (ev.event_type == RTE_EVENT_TYPE_CRYPTODEV)) {
+ struct rte_crypto_op *op = ev.event_ptr;
+
+ if (op->status == RTE_CRYPTO_OP_STATUS_SUCCESS) {
+ if (op->sym->m_dst == NULL)
+ ev.event_ptr = op->sym->m_src;
+ else
+ ev.event_ptr = op->sym->m_dst;
+ rte_crypto_op_free(op);
+ } else {
+ rte_crypto_op_free(op);
+ continue;
+ }
+ }
+
if (enable_fwd_latency && !prod_timer_type)
/* first q in pipeline, mark timestamp to compute fwd latency */
mark_fwd_latency(&ev, nb_stages);
@@ -88,6 +105,25 @@ perf_queue_worker_burst(void *arg, const int enable_fwd_latency)
}
for (i = 0; i < nb_rx; i++) {
+ if (prod_crypto_type &&
+ (ev[i].event_type == RTE_EVENT_TYPE_CRYPTODEV)) {
+ struct rte_crypto_op *op = ev[i].event_ptr;
+
+ if (op->status ==
+ RTE_CRYPTO_OP_STATUS_SUCCESS) {
+ if (op->sym->m_dst == NULL)
+ ev[i].event_ptr =
+ op->sym->m_src;
+ else
+ ev[i].event_ptr =
+ op->sym->m_dst;
+ rte_crypto_op_free(op);
+ } else {
+ rte_crypto_op_free(op);
+ continue;
+ }
+ }
+
if (enable_fwd_latency && !prod_timer_type) {
rte_prefetch0(ev[i+1].event_ptr);
/* first queue in pipeline.
@@ -269,6 +305,18 @@ perf_queue_eventdev_setup(struct evt_test *test, struct evt_options *opt)
return ret;
}
}
+ } else if (opt->prod_type == EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR) {
+ uint8_t cdev_id, cdev_count;
+
+ cdev_count = rte_cryptodev_count();
+ for (cdev_id = 0; cdev_id < cdev_count; cdev_id++) {
+ ret = rte_cryptodev_start(cdev_id);
+ if (ret) {
+ evt_err("Failed to start cryptodev %u",
+ cdev_id);
+ return ret;
+ }
+ }
}
return 0;
@@ -311,11 +359,13 @@ static const struct evt_test_ops perf_queue = {
.test_setup = perf_test_setup,
.mempool_setup = perf_mempool_setup,
.ethdev_setup = perf_ethdev_setup,
+ .cryptodev_setup = perf_cryptodev_setup,
.eventdev_setup = perf_queue_eventdev_setup,
.launch_lcores = perf_queue_launch_lcores,
.eventdev_destroy = perf_eventdev_destroy,
.mempool_destroy = perf_mempool_destroy,
.ethdev_destroy = perf_ethdev_destroy,
+ .cryptodev_destroy = perf_cryptodev_destroy,
.test_result = perf_test_result,
.test_destroy = perf_test_destroy,
};
diff --git a/doc/guides/rel_notes/release_22_03.rst b/doc/guides/rel_notes/release_22_03.rst
index cbc98e798f..72052ef2dc 100644
--- a/doc/guides/rel_notes/release_22_03.rst
+++ b/doc/guides/rel_notes/release_22_03.rst
@@ -159,6 +159,11 @@ New Features
* Called ``rte_ipv4/6_udptcp_cksum_mbuf()`` functions in testpmd csum mode
to support software UDP/TCP checksum over multiple segments.
+* **Added crypto producer mode in test-eventdev.**
+
+ * Crypto producer mode helps to measure performance of OP_NEW and OP_FORWARD
+ modes of event crypto adapter.
+
Removed Items
-------------
diff --git a/doc/guides/tools/testeventdev.rst b/doc/guides/tools/testeventdev.rst
index 48efb9ea6e..f7d813226d 100644
--- a/doc/guides/tools/testeventdev.rst
+++ b/doc/guides/tools/testeventdev.rst
@@ -120,6 +120,10 @@ The following are the application command-line options:
Use burst mode event timer adapter as producer.
+* ``--prod_type_cryptodev``
+
+ Use crypto device as producer.
+
* ``--timer_tick_nsec``
Used to dictate number of nano seconds between bucket traversal of the
@@ -148,6 +152,11 @@ The following are the application command-line options:
timeout is out of the supported range of event device it will be
adjusted to the highest/lowest supported dequeue timeout supported.
+* ``--crypto_adptr_mode``
+
+ Set crypto adapter mode. Use 0 for OP_NEW (default) and 1 for
+ OP_FORWARD mode.
+
* ``--mbuf_sz``
Set packet mbuf size. Can be used to configure Jumbo Frames. Only
@@ -420,6 +429,7 @@ Supported application command line options are following::
--prod_type_ethdev
--prod_type_timerdev_burst
--prod_type_timerdev
+ --prod_type_cryptodev
--prod_enq_burst_sz
--timer_tick_nsec
--max_tmo_nsec
@@ -427,6 +437,7 @@ Supported application command line options are following::
--nb_timers
--nb_timer_adptrs
--deq_tmo_nsec
+ --crypto_adptr_mode
Example
^^^^^^^
@@ -529,12 +540,14 @@ Supported application command line options are following::
--prod_type_ethdev
--prod_type_timerdev_burst
--prod_type_timerdev
+ --prod_type_cryptodev
--timer_tick_nsec
--max_tmo_nsec
--expiry_nsec
--nb_timers
--nb_timer_adptrs
--deq_tmo_nsec
+ --crypto_adptr_mode
Example
^^^^^^^
--
2.25.1
^ permalink raw reply [flat|nested] 43+ messages in thread
* RE: [PATCH v7] app/eventdev: add crypto producer mode
2022-02-24 4:46 ` [PATCH v7] " Shijith Thotton
@ 2022-02-24 6:18 ` Gujjar, Abhinandan S
2022-02-24 7:58 ` Jerin Jacob
0 siblings, 1 reply; 43+ messages in thread
From: Gujjar, Abhinandan S @ 2022-02-24 6:18 UTC (permalink / raw)
To: Shijith Thotton, dev, jerinj; +Cc: Akhil Goyal
Acked-by: Abhinandan Gujjar <abhinandan.gujjar@intel.com>
> -----Original Message-----
> From: Shijith Thotton <sthotton@marvell.com>
> Sent: Thursday, February 24, 2022 10:16 AM
> To: dev@dpdk.org; jerinj@marvell.com
> Cc: Shijith Thotton <sthotton@marvell.com>; Gujjar, Abhinandan S
> <abhinandan.gujjar@intel.com>; Akhil Goyal <gakhil@marvell.com>
> Subject: [PATCH v7] app/eventdev: add crypto producer mode
>
> In crypto producer mode, producer core enqueues cryptodev with software
> generated crypto ops and worker core dequeues crypto completion events from
> the eventdev. Event crypto metadata used for above processing is pre-
> populated in each crypto session.
>
> Parameter --prod_type_cryptodev can be used to enable crypto producer
> mode. Parameter --crypto_adptr_mode can be set to select the crypto adapter
> mode, 0 for OP_NEW and 1 for OP_FORWARD.
>
> This mode can be used to measure the performance of crypto adapter.
>
> Example:
> ./dpdk-test-eventdev -l 0-2 -w <EVENTDEV> -w <CRYPTODEV> -- \
> --prod_type_cryptodev --crypto_adptr_mode 1 --test=perf_atq \
> --stlist=a --wlcores 1 --plcores 2
>
> Signed-off-by: Shijith Thotton <sthotton@marvell.com>
> Acked-by: Akhil Goyal <gakhil@marvell.com>
> ---
> v7:
> * Removed setting op and event_type in response info.
> * Fixed op type of event in FORWARD mode.
>
> v6:
> * Added cryptodev close.
> * Fixed cleanup.
> * Updated release notes.
>
> v5:
> * Rebased.
>
> v4:
> * Addressed comments on v3 and rebased.
> * Added cryptodev cleanup in signal handler.
>
> v3:
> * Reduce dereference inside loop.
>
> v2:
> * Fix RHEL compilation warning.
>
> app/test-eventdev/evt_common.h | 3 +
> app/test-eventdev/evt_main.c | 17 +-
> app/test-eventdev/evt_options.c | 27 ++
> app/test-eventdev/evt_options.h | 12 +
> app/test-eventdev/evt_test.h | 6 +
> app/test-eventdev/test_perf_atq.c | 49 +++
> app/test-eventdev/test_perf_common.c | 427 ++++++++++++++++++++++++-
> app/test-eventdev/test_perf_common.h | 18 +-
> app/test-eventdev/test_perf_queue.c | 50 +++
> doc/guides/rel_notes/release_22_03.rst | 5 +
> doc/guides/tools/testeventdev.rst | 13 +
> 11 files changed, 619 insertions(+), 8 deletions(-)
>
> diff --git a/app/test-eventdev/evt_common.h b/app/test-
> eventdev/evt_common.h index f466434459..2f301a7e79 100644
> --- a/app/test-eventdev/evt_common.h
> +++ b/app/test-eventdev/evt_common.h
> @@ -7,6 +7,7 @@
>
> #include <rte_common.h>
> #include <rte_debug.h>
> +#include <rte_event_crypto_adapter.h>
> #include <rte_eventdev.h>
> #include <rte_service.h>
>
> @@ -39,6 +40,7 @@ enum evt_prod_type {
> EVT_PROD_TYPE_SYNT, /* Producer type Synthetic i.e. CPU. */
> EVT_PROD_TYPE_ETH_RX_ADPTR, /* Producer type Eth Rx Adapter. */
> EVT_PROD_TYPE_EVENT_TIMER_ADPTR, /* Producer type Timer
> Adapter. */
> + EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR, /* Producer type Crypto
> Adapter. */
> EVT_PROD_TYPE_MAX,
> };
>
> @@ -77,6 +79,7 @@ struct evt_options {
> uint64_t timer_tick_nsec;
> uint64_t optm_timer_tick_nsec;
> enum evt_prod_type prod_type;
> + enum rte_event_crypto_adapter_mode crypto_adptr_mode;
> };
>
> static inline bool
> diff --git a/app/test-eventdev/evt_main.c b/app/test-eventdev/evt_main.c
> index 194c980c7a..a7d6b0c1cf 100644
> --- a/app/test-eventdev/evt_main.c
> +++ b/app/test-eventdev/evt_main.c
> @@ -35,6 +35,9 @@ signal_handler(int signum)
> if (test->ops.ethdev_destroy)
> test->ops.ethdev_destroy(test, &opt);
>
> + if (test->ops.cryptodev_destroy)
> + test->ops.cryptodev_destroy(test, &opt);
> +
> rte_eal_mp_wait_lcore();
>
> if (test->ops.test_result)
> @@ -162,11 +165,19 @@ main(int argc, char **argv)
> }
> }
>
> + /* Test specific cryptodev setup */
> + if (test->ops.cryptodev_setup) {
> + if (test->ops.cryptodev_setup(test, &opt)) {
> + evt_err("%s: cryptodev setup failed", opt.test_name);
> + goto ethdev_destroy;
> + }
> + }
> +
> /* Test specific eventdev setup */
> if (test->ops.eventdev_setup) {
> if (test->ops.eventdev_setup(test, &opt)) {
> evt_err("%s: eventdev setup failed", opt.test_name);
> - goto ethdev_destroy;
> + goto cryptodev_destroy;
> }
> }
>
> @@ -197,6 +208,10 @@ main(int argc, char **argv)
> if (test->ops.eventdev_destroy)
> test->ops.eventdev_destroy(test, &opt);
>
> +cryptodev_destroy:
> + if (test->ops.cryptodev_destroy)
> + test->ops.cryptodev_destroy(test, &opt);
> +
> ethdev_destroy:
> if (test->ops.ethdev_destroy)
> test->ops.ethdev_destroy(test, &opt); diff --git a/app/test-
> eventdev/evt_options.c b/app/test-eventdev/evt_options.c index
> 4ae44801da..d3c704d2b3 100644
> --- a/app/test-eventdev/evt_options.c
> +++ b/app/test-eventdev/evt_options.c
> @@ -122,6 +122,26 @@ evt_parse_timer_prod_type_burst(struct evt_options
> *opt,
> return 0;
> }
>
> +static int
> +evt_parse_crypto_prod_type(struct evt_options *opt,
> + const char *arg __rte_unused)
> +{
> + opt->prod_type = EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR;
> + return 0;
> +}
> +
> +static int
> +evt_parse_crypto_adptr_mode(struct evt_options *opt, const char *arg) {
> + uint8_t mode;
> + int ret;
> +
> + ret = parser_read_uint8(&mode, arg);
> + opt->crypto_adptr_mode = mode ?
> RTE_EVENT_CRYPTO_ADAPTER_OP_FORWARD :
> +
> RTE_EVENT_CRYPTO_ADAPTER_OP_NEW;
> + return ret;
> +}
> +
> static int
> evt_parse_test_name(struct evt_options *opt, const char *arg) { @@ -335,6
> +355,7 @@ usage(char *program)
> "\t--queue_priority : enable queue priority\n"
> "\t--deq_tmo_nsec : global dequeue timeout\n"
> "\t--prod_type_ethdev : use ethernet device as producer.\n"
> + "\t--prod_type_cryptodev : use crypto device as producer.\n"
> "\t--prod_type_timerdev : use event timer device as
> producer.\n"
> "\t expiry_nsec would be the timeout\n"
> "\t in ns.\n"
> @@ -345,6 +366,8 @@ usage(char *program)
> "\t--timer_tick_nsec : timer tick interval in ns.\n"
> "\t--max_tmo_nsec : max timeout interval in ns.\n"
> "\t--expiry_nsec : event timer expiry ns.\n"
> + "\t--crypto_adptr_mode : 0 for OP_NEW mode (default)
> and\n"
> + "\t 1 for OP_FORWARD mode.\n"
> "\t--mbuf_sz : packet mbuf size.\n"
> "\t--max_pkt_sz : max packet size.\n"
> "\t--prod_enq_burst_sz : producer enqueue burst size.\n"
> @@ -415,8 +438,10 @@ static struct option lgopts[] = {
> { EVT_QUEUE_PRIORITY, 0, 0, 0 },
> { EVT_DEQ_TMO_NSEC, 1, 0, 0 },
> { EVT_PROD_ETHDEV, 0, 0, 0 },
> + { EVT_PROD_CRYPTODEV, 0, 0, 0 },
> { EVT_PROD_TIMERDEV, 0, 0, 0 },
> { EVT_PROD_TIMERDEV_BURST, 0, 0, 0 },
> + { EVT_CRYPTO_ADPTR_MODE, 1, 0, 0 },
> { EVT_NB_TIMERS, 1, 0, 0 },
> { EVT_NB_TIMER_ADPTRS, 1, 0, 0 },
> { EVT_TIMER_TICK_NSEC, 1, 0, 0 },
> @@ -455,8 +480,10 @@ evt_opts_parse_long(int opt_idx, struct evt_options
> *opt)
> { EVT_QUEUE_PRIORITY, evt_parse_queue_priority},
> { EVT_DEQ_TMO_NSEC, evt_parse_deq_tmo_nsec},
> { EVT_PROD_ETHDEV, evt_parse_eth_prod_type},
> + { EVT_PROD_CRYPTODEV, evt_parse_crypto_prod_type},
> { EVT_PROD_TIMERDEV, evt_parse_timer_prod_type},
> { EVT_PROD_TIMERDEV_BURST,
> evt_parse_timer_prod_type_burst},
> + { EVT_CRYPTO_ADPTR_MODE, evt_parse_crypto_adptr_mode},
> { EVT_NB_TIMERS, evt_parse_nb_timers},
> { EVT_NB_TIMER_ADPTRS, evt_parse_nb_timer_adptrs},
> { EVT_TIMER_TICK_NSEC, evt_parse_timer_tick_nsec}, diff --git
> a/app/test-eventdev/evt_options.h b/app/test-eventdev/evt_options.h index
> 413d7092f0..2231c58801 100644
> --- a/app/test-eventdev/evt_options.h
> +++ b/app/test-eventdev/evt_options.h
> @@ -9,6 +9,7 @@
> #include <stdbool.h>
>
> #include <rte_common.h>
> +#include <rte_cryptodev.h>
> #include <rte_ethdev.h>
> #include <rte_eventdev.h>
> #include <rte_lcore.h>
> @@ -33,8 +34,10 @@
> #define EVT_QUEUE_PRIORITY ("queue_priority")
> #define EVT_DEQ_TMO_NSEC ("deq_tmo_nsec")
> #define EVT_PROD_ETHDEV ("prod_type_ethdev")
> +#define EVT_PROD_CRYPTODEV ("prod_type_cryptodev")
> #define EVT_PROD_TIMERDEV ("prod_type_timerdev")
> #define EVT_PROD_TIMERDEV_BURST ("prod_type_timerdev_burst")
> +#define EVT_CRYPTO_ADPTR_MODE ("crypto_adptr_mode")
> #define EVT_NB_TIMERS ("nb_timers")
> #define EVT_NB_TIMER_ADPTRS ("nb_timer_adptrs")
> #define EVT_TIMER_TICK_NSEC ("timer_tick_nsec")
> @@ -249,6 +252,8 @@ evt_prod_id_to_name(enum evt_prod_type
> prod_type)
> return "Ethdev Rx Adapter";
> case EVT_PROD_TYPE_EVENT_TIMER_ADPTR:
> return "Event timer adapter";
> + case EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR:
> + return "Event crypto adapter";
> }
>
> return "";
> @@ -288,6 +293,13 @@ evt_dump_producer_type(struct evt_options *opt)
> evt_dump("timer_tick_nsec", "%"PRIu64"",
> opt->timer_tick_nsec);
> break;
> + case EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR:
> + snprintf(name, EVT_PROD_MAX_NAME_LEN,
> + "Event crypto adapter producers");
> + evt_dump("crypto adapter mode", "%s",
> + opt->crypto_adptr_mode ? "OP_FORWARD" :
> "OP_NEW");
> + evt_dump("nb_cryptodev", "%u", rte_cryptodev_count());
> + break;
> }
> evt_dump("prod_type", "%s", name);
> }
> diff --git a/app/test-eventdev/evt_test.h b/app/test-eventdev/evt_test.h index
> f07d2c3336..50fa474ec2 100644
> --- a/app/test-eventdev/evt_test.h
> +++ b/app/test-eventdev/evt_test.h
> @@ -29,6 +29,8 @@ typedef int (*evt_test_mempool_setup_t)
> (struct evt_test *test, struct evt_options *opt); typedef int
> (*evt_test_ethdev_setup_t)
> (struct evt_test *test, struct evt_options *opt);
> +typedef int (*evt_test_cryptodev_setup_t)
> + (struct evt_test *test, struct evt_options *opt);
> typedef int (*evt_test_eventdev_setup_t)
> (struct evt_test *test, struct evt_options *opt); typedef int
> (*evt_test_launch_lcores_t) @@ -39,6 +41,8 @@ typedef void
> (*evt_test_eventdev_destroy_t)
> (struct evt_test *test, struct evt_options *opt); typedef void
> (*evt_test_ethdev_destroy_t)
> (struct evt_test *test, struct evt_options *opt);
> +typedef void (*evt_test_cryptodev_destroy_t)
> + (struct evt_test *test, struct evt_options *opt);
> typedef void (*evt_test_mempool_destroy_t)
> (struct evt_test *test, struct evt_options *opt); typedef void
> (*evt_test_destroy_t) @@ -52,10 +56,12 @@ struct evt_test_ops {
> evt_test_mempool_setup_t mempool_setup;
> evt_test_ethdev_setup_t ethdev_setup;
> evt_test_eventdev_setup_t eventdev_setup;
> + evt_test_cryptodev_setup_t cryptodev_setup;
> evt_test_launch_lcores_t launch_lcores;
> evt_test_result_t test_result;
> evt_test_eventdev_destroy_t eventdev_destroy;
> evt_test_ethdev_destroy_t ethdev_destroy;
> + evt_test_cryptodev_destroy_t cryptodev_destroy;
> evt_test_mempool_destroy_t mempool_destroy;
> evt_test_destroy_t test_destroy;
> };
> diff --git a/app/test-eventdev/test_perf_atq.c b/app/test-
> eventdev/test_perf_atq.c
> index 8fd51004ee..67ff681666 100644
> --- a/app/test-eventdev/test_perf_atq.c
> +++ b/app/test-eventdev/test_perf_atq.c
> @@ -48,6 +48,22 @@ perf_atq_worker(void *arg, const int
> enable_fwd_latency)
> continue;
> }
>
> + if (prod_crypto_type &&
> + (ev.event_type == RTE_EVENT_TYPE_CRYPTODEV)) {
> + struct rte_crypto_op *op = ev.event_ptr;
> +
> + if (op->status == RTE_CRYPTO_OP_STATUS_SUCCESS) {
> + if (op->sym->m_dst == NULL)
> + ev.event_ptr = op->sym->m_src;
> + else
> + ev.event_ptr = op->sym->m_dst;
> + rte_crypto_op_free(op);
> + } else {
> + rte_crypto_op_free(op);
> + continue;
> + }
> + }
> +
> if (enable_fwd_latency && !prod_timer_type)
> /* first stage in pipeline, mark ts to compute fwd latency */
> atq_mark_fwd_latency(&ev);
> @@ -87,6 +103,25 @@ perf_atq_worker_burst(void *arg, const int
> enable_fwd_latency)
> }
>
> for (i = 0; i < nb_rx; i++) {
> + if (prod_crypto_type &&
> + (ev[i].event_type == RTE_EVENT_TYPE_CRYPTODEV))
> {
> + struct rte_crypto_op *op = ev[i].event_ptr;
> +
> + if (op->status ==
> + RTE_CRYPTO_OP_STATUS_SUCCESS) {
> + if (op->sym->m_dst == NULL)
> + ev[i].event_ptr =
> + op->sym->m_src;
> + else
> + ev[i].event_ptr =
> + op->sym->m_dst;
> + rte_crypto_op_free(op);
> + } else {
> + rte_crypto_op_free(op);
> + continue;
> + }
> + }
> +
> if (enable_fwd_latency && !prod_timer_type) {
> rte_prefetch0(ev[i+1].event_ptr);
> /* first stage in pipeline.
> @@ -254,6 +289,18 @@ perf_atq_eventdev_setup(struct evt_test *test, struct
> evt_options *opt)
> return ret;
> }
> }
> + } else if (opt->prod_type == EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR) {
> + uint8_t cdev_id, cdev_count;
> +
> + cdev_count = rte_cryptodev_count();
> + for (cdev_id = 0; cdev_id < cdev_count; cdev_id++) {
> + ret = rte_cryptodev_start(cdev_id);
> + if (ret) {
> + evt_err("Failed to start cryptodev %u",
> + cdev_id);
> + return ret;
> + }
> + }
> }
>
> return 0;
> @@ -295,12 +342,14 @@ static const struct evt_test_ops perf_atq = {
> .opt_dump = perf_atq_opt_dump,
> .test_setup = perf_test_setup,
> .ethdev_setup = perf_ethdev_setup,
> + .cryptodev_setup = perf_cryptodev_setup,
> .mempool_setup = perf_mempool_setup,
> .eventdev_setup = perf_atq_eventdev_setup,
> .launch_lcores = perf_atq_launch_lcores,
> .eventdev_destroy = perf_eventdev_destroy,
> .mempool_destroy = perf_mempool_destroy,
> .ethdev_destroy = perf_ethdev_destroy,
> + .cryptodev_destroy = perf_cryptodev_destroy,
> .test_result = perf_test_result,
> .test_destroy = perf_test_destroy,
> };
> diff --git a/app/test-eventdev/test_perf_common.c b/app/test-
> eventdev/test_perf_common.c
> index 9b73874151..9d1f4a4567 100644
> --- a/app/test-eventdev/test_perf_common.c
> +++ b/app/test-eventdev/test_perf_common.c
> @@ -6,6 +6,8 @@
>
> #include "test_perf_common.h"
>
> +#define NB_CRYPTODEV_DESCRIPTORS 128
> +
> int
> perf_test_result(struct evt_test *test, struct evt_options *opt) { @@ -272,6
> +274,123 @@ perf_event_timer_producer_burst(void *arg)
> return 0;
> }
>
> +static inline void
> +crypto_adapter_enq_op_new(struct prod_data *p) {
> + struct rte_cryptodev_sym_session **crypto_sess = p->ca.crypto_sess;
> + struct test_perf *t = p->t;
> + const uint32_t nb_flows = t->nb_flows;
> + const uint64_t nb_pkts = t->nb_pkts;
> + struct rte_mempool *pool = t->pool;
> + struct rte_crypto_sym_op *sym_op;
> + struct evt_options *opt = t->opt;
> + uint16_t qp_id = p->ca.cdev_qp_id;
> + uint8_t cdev_id = p->ca.cdev_id;
> + uint32_t flow_counter = 0;
> + struct rte_crypto_op *op;
> + struct rte_mbuf *m;
> + uint64_t count = 0;
> + uint16_t len;
> +
> + if (opt->verbose_level > 1)
> + printf("%s(): lcore %d queue %d cdev_id %u cdev_qp_id %u\n",
> + __func__, rte_lcore_id(), p->queue_id, p->ca.cdev_id,
> + p->ca.cdev_qp_id);
> +
> + len = opt->mbuf_sz ? opt->mbuf_sz : RTE_ETHER_MIN_LEN;
> +
> + while (count < nb_pkts && t->done == false) {
> + m = rte_pktmbuf_alloc(pool);
> + if (m == NULL)
> + continue;
> +
> + rte_pktmbuf_append(m, len);
> + op = rte_crypto_op_alloc(t->ca_op_pool,
> + RTE_CRYPTO_OP_TYPE_SYMMETRIC);
> + sym_op = op->sym;
> + sym_op->m_src = m;
> + sym_op->cipher.data.offset = 0;
> + sym_op->cipher.data.length = len;
> + rte_crypto_op_attach_sym_session(
> + op, crypto_sess[flow_counter++ % nb_flows]);
> +
> + while (rte_cryptodev_enqueue_burst(cdev_id, qp_id, &op, 1) !=
> 1 &&
> + t->done == false)
> + rte_pause();
> +
> + count++;
> + }
> +}
> +
> +static inline void
> +crypto_adapter_enq_op_fwd(struct prod_data *p) {
> + struct rte_cryptodev_sym_session **crypto_sess = p->ca.crypto_sess;
> + const uint8_t dev_id = p->dev_id;
> + const uint8_t port = p->port_id;
> + struct test_perf *t = p->t;
> + const uint32_t nb_flows = t->nb_flows;
> + const uint64_t nb_pkts = t->nb_pkts;
> + struct rte_mempool *pool = t->pool;
> + struct evt_options *opt = t->opt;
> + struct rte_crypto_sym_op *sym_op;
> + uint32_t flow_counter = 0;
> + struct rte_crypto_op *op;
> + struct rte_event ev;
> + struct rte_mbuf *m;
> + uint64_t count = 0;
> + uint16_t len;
> +
> + if (opt->verbose_level > 1)
> + printf("%s(): lcore %d port %d queue %d cdev_id %u
> cdev_qp_id %u\n",
> + __func__, rte_lcore_id(), port, p->queue_id,
> + p->ca.cdev_id, p->ca.cdev_qp_id);
> +
> + ev.event = 0;
> + ev.op = RTE_EVENT_OP_NEW;
> + ev.queue_id = p->queue_id;
> + ev.sched_type = RTE_SCHED_TYPE_ATOMIC;
> + ev.event_type = RTE_EVENT_TYPE_CPU;
> + len = opt->mbuf_sz ? opt->mbuf_sz : RTE_ETHER_MIN_LEN;
> +
> + while (count < nb_pkts && t->done == false) {
> + m = rte_pktmbuf_alloc(pool);
> + if (m == NULL)
> + continue;
> +
> + rte_pktmbuf_append(m, len);
> + op = rte_crypto_op_alloc(t->ca_op_pool,
> + RTE_CRYPTO_OP_TYPE_SYMMETRIC);
> + sym_op = op->sym;
> + sym_op->m_src = m;
> + sym_op->cipher.data.offset = 0;
> + sym_op->cipher.data.length = len;
> + rte_crypto_op_attach_sym_session(
> + op, crypto_sess[flow_counter++ % nb_flows]);
> + ev.event_ptr = op;
> +
> + while (rte_event_crypto_adapter_enqueue(dev_id, port, &ev,
> 1) != 1 &&
> + t->done == false)
> + rte_pause();
> +
> + count++;
> + }
> +}
> +
> +static inline int
> +perf_event_crypto_producer(void *arg)
> +{
> + struct prod_data *p = arg;
> + struct evt_options *opt = p->t->opt;
> +
> + if (opt->crypto_adptr_mode ==
> RTE_EVENT_CRYPTO_ADAPTER_OP_NEW)
> + crypto_adapter_enq_op_new(p);
> + else
> + crypto_adapter_enq_op_fwd(p);
> +
> + return 0;
> +}
> +
> static int
> perf_producer_wrapper(void *arg)
> {
> @@ -298,6 +417,8 @@ perf_producer_wrapper(void *arg)
> else if (t->opt->prod_type == EVT_PROD_TYPE_EVENT_TIMER_ADPTR
> &&
> t->opt->timdev_use_burst)
> return perf_event_timer_producer_burst(arg);
> + else if (t->opt->prod_type == EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR)
> + return perf_event_crypto_producer(arg);
> return 0;
> }
>
> @@ -405,8 +526,10 @@ perf_launch_lcores(struct evt_test *test, struct
> evt_options *opt,
> if (remaining <= 0) {
> t->result = EVT_TEST_SUCCESS;
> if (opt->prod_type == EVT_PROD_TYPE_SYNT
> ||
> - opt->prod_type ==
> -
> EVT_PROD_TYPE_EVENT_TIMER_ADPTR) {
> + opt->prod_type ==
> +
> EVT_PROD_TYPE_EVENT_TIMER_ADPTR ||
> + opt->prod_type ==
> +
> EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR) {
> t->done = true;
> break;
> }
> @@ -415,7 +538,8 @@ perf_launch_lcores(struct evt_test *test, struct
> evt_options *opt,
>
> if (new_cycles - dead_lock_cycles > dead_lock_sample &&
> (opt->prod_type == EVT_PROD_TYPE_SYNT ||
> - opt->prod_type ==
> EVT_PROD_TYPE_EVENT_TIMER_ADPTR)) {
> + opt->prod_type == EVT_PROD_TYPE_EVENT_TIMER_ADPTR
> ||
> + opt->prod_type ==
> EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR)) {
> remaining = t->outstand_pkts - processed_pkts(t);
> if (dead_lock_remaining == remaining) {
> rte_event_dev_dump(opt->dev_id, stdout);
> @@ -537,6 +661,74 @@ perf_event_timer_adapter_setup(struct test_perf *t)
> return 0;
> }
>
> +static int
> +perf_event_crypto_adapter_setup(struct test_perf *t, struct prod_data
> +*p) {
> + struct evt_options *opt = t->opt;
> + uint32_t cap;
> + int ret;
> +
> + ret = rte_event_crypto_adapter_caps_get(p->dev_id, p->ca.cdev_id,
> &cap);
> + if (ret) {
> + evt_err("Failed to get crypto adapter capabilities");
> + return ret;
> + }
> +
> + if (((opt->crypto_adptr_mode ==
> RTE_EVENT_CRYPTO_ADAPTER_OP_NEW) &&
> + !(cap &
> RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_OP_NEW)) ||
> + ((opt->crypto_adptr_mode ==
> RTE_EVENT_CRYPTO_ADAPTER_OP_FORWARD) &&
> + !(cap &
> RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_OP_FWD))) {
> + evt_err("crypto adapter %s mode unsupported\n",
> + opt->crypto_adptr_mode ? "OP_FORWARD" :
> "OP_NEW");
> + return -ENOTSUP;
> + } else if (!(cap &
> RTE_EVENT_CRYPTO_ADAPTER_CAP_SESSION_PRIVATE_DATA)) {
> + evt_err("Storing crypto session not supported");
> + return -ENOTSUP;
> + }
> +
> + if (cap &
> RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_QP_EV_BIND) {
> + struct rte_event response_info;
> +
> + response_info.event = 0;
> + response_info.sched_type = RTE_SCHED_TYPE_ATOMIC;
> + response_info.queue_id = p->queue_id;
> + ret = rte_event_crypto_adapter_queue_pair_add(
> + TEST_PERF_CA_ID, p->ca.cdev_id, p->ca.cdev_qp_id,
> + &response_info);
> + } else {
> + ret = rte_event_crypto_adapter_queue_pair_add(
> + TEST_PERF_CA_ID, p->ca.cdev_id, p->ca.cdev_qp_id,
> NULL);
> + }
> +
> + return ret;
> +}
> +
> +static struct rte_cryptodev_sym_session *
> +cryptodev_sym_sess_create(struct prod_data *p, struct test_perf *t) {
> + struct rte_crypto_sym_xform cipher_xform;
> + struct rte_cryptodev_sym_session *sess;
> +
> + cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
> + cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
> + cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
> + cipher_xform.next = NULL;
> +
> + sess = rte_cryptodev_sym_session_create(t->ca_sess_pool);
> + if (sess == NULL) {
> + evt_err("Failed to create sym session");
> + return NULL;
> + }
> +
> + if (rte_cryptodev_sym_session_init(p->ca.cdev_id, sess, &cipher_xform,
> + t->ca_sess_priv_pool)) {
> + evt_err("Failed to init session");
> + return NULL;
> + }
> +
> + return sess;
> +}
> +
> int
> perf_event_dev_port_setup(struct evt_test *test, struct evt_options *opt,
> uint8_t stride, uint8_t nb_queues,
> @@ -598,6 +790,73 @@ perf_event_dev_port_setup(struct evt_test *test,
> struct evt_options *opt,
> ret = perf_event_timer_adapter_setup(t);
> if (ret)
> return ret;
> + } else if (opt->prod_type == EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR) {
> + struct rte_event_port_conf conf = *port_conf;
> + uint8_t cdev_id = 0;
> + uint16_t qp_id = 0;
> +
> + ret = rte_event_crypto_adapter_create(TEST_PERF_CA_ID,
> + opt->dev_id, &conf, 0);
> + if (ret) {
> + evt_err("Failed to create crypto adapter");
> + return ret;
> + }
> +
> + prod = 0;
> + for (; port < perf_nb_event_ports(opt); port++) {
> + struct rte_cryptodev_sym_session *crypto_sess;
> + union rte_event_crypto_metadata m_data;
> + struct prod_data *p = &t->prod[port];
> + uint32_t flow_id;
> +
> + if (qp_id == rte_cryptodev_queue_pair_count(cdev_id))
> {
> + cdev_id++;
> + qp_id = 0;
> + }
> +
> + p->dev_id = opt->dev_id;
> + p->port_id = port;
> + p->queue_id = prod * stride;
> + p->ca.cdev_id = cdev_id;
> + p->ca.cdev_qp_id = qp_id;
> + p->ca.crypto_sess = rte_zmalloc_socket(
> + NULL, sizeof(crypto_sess) * t->nb_flows,
> + RTE_CACHE_LINE_SIZE, opt->socket_id);
> + p->t = t;
> +
> + m_data.request_info.cdev_id = p->ca.cdev_id;
> + m_data.request_info.queue_pair_id = p-
> >ca.cdev_qp_id;
> + m_data.response_info.sched_type =
> RTE_SCHED_TYPE_ATOMIC;
> + m_data.response_info.queue_id = p->queue_id;
> +
> + for (flow_id = 0; flow_id < t->nb_flows; flow_id++) {
> + crypto_sess = cryptodev_sym_sess_create(p, t);
> + if (crypto_sess == NULL)
> + return -ENOMEM;
> +
> + m_data.response_info.flow_id = flow_id;
> + rte_cryptodev_sym_session_set_user_data(
> + crypto_sess, &m_data,
> sizeof(m_data));
> + p->ca.crypto_sess[flow_id] = crypto_sess;
> + }
> +
> + conf.event_port_cfg |=
> + RTE_EVENT_PORT_CFG_HINT_PRODUCER |
> + RTE_EVENT_PORT_CFG_HINT_CONSUMER;
> +
> + ret = rte_event_port_setup(opt->dev_id, port, &conf);
> + if (ret) {
> + evt_err("failed to setup port %d", port);
> + return ret;
> + }
> +
> + ret = perf_event_crypto_adapter_setup(t, p);
> + if (ret)
> + return ret;
> +
> + qp_id++;
> + prod++;
> + }
> } else {
> prod = 0;
> for ( ; port < perf_nb_event_ports(opt); port++) { @@ -659,7
> +918,8 @@ perf_opt_check(struct evt_options *opt, uint64_t nb_queues)
> }
>
> if (opt->prod_type == EVT_PROD_TYPE_SYNT ||
> - opt->prod_type ==
> EVT_PROD_TYPE_EVENT_TIMER_ADPTR) {
> + opt->prod_type == EVT_PROD_TYPE_EVENT_TIMER_ADPTR ||
> + opt->prod_type == EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR) {
> /* Validate producer lcores */
> if (evt_lcores_has_overlap(opt->plcores,
> rte_get_main_lcore())) {
> @@ -767,8 +1027,7 @@ perf_ethdev_setup(struct evt_test *test, struct
> evt_options *opt)
> },
> };
>
> - if (opt->prod_type == EVT_PROD_TYPE_SYNT ||
> - opt->prod_type ==
> EVT_PROD_TYPE_EVENT_TIMER_ADPTR)
> + if (opt->prod_type != EVT_PROD_TYPE_ETH_RX_ADPTR)
> return 0;
>
> if (!rte_eth_dev_count_avail()) {
> @@ -841,6 +1100,162 @@ void perf_ethdev_destroy(struct evt_test *test,
> struct evt_options *opt)
> }
> }
>
> +int
> +perf_cryptodev_setup(struct evt_test *test, struct evt_options *opt) {
> + uint8_t cdev_count, cdev_id, nb_plcores, nb_qps;
> + struct test_perf *t = evt_test_priv(test);
> + unsigned int max_session_size;
> + uint32_t nb_sessions;
> + int ret;
> +
> + if (opt->prod_type != EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR)
> + return 0;
> +
> + cdev_count = rte_cryptodev_count();
> + if (cdev_count == 0) {
> + evt_err("No crypto devices available\n");
> + return -ENODEV;
> + }
> +
> + t->ca_op_pool = rte_crypto_op_pool_create(
> + "crypto_op_pool", RTE_CRYPTO_OP_TYPE_SYMMETRIC, opt-
> >pool_sz,
> + 128, 0, rte_socket_id());
> + if (t->ca_op_pool == NULL) {
> + evt_err("Failed to create crypto op pool");
> + return -ENOMEM;
> + }
> +
> + nb_sessions = evt_nr_active_lcores(opt->plcores) * t->nb_flows;
> + t->ca_sess_pool = rte_cryptodev_sym_session_pool_create(
> + "ca_sess_pool", nb_sessions, 0, 0,
> + sizeof(union rte_event_crypto_metadata), SOCKET_ID_ANY);
> + if (t->ca_sess_pool == NULL) {
> + evt_err("Failed to create sym session pool");
> + ret = -ENOMEM;
> + goto err;
> + }
> +
> + max_session_size = 0;
> + for (cdev_id = 0; cdev_id < cdev_count; cdev_id++) {
> + unsigned int session_size;
> +
> + session_size =
> + rte_cryptodev_sym_get_private_session_size(cdev_id);
> + if (session_size > max_session_size)
> + max_session_size = session_size;
> + }
> +
> + max_session_size += sizeof(union rte_event_crypto_metadata);
> + t->ca_sess_priv_pool = rte_mempool_create(
> + "ca_sess_priv_pool", nb_sessions, max_session_size, 0, 0,
> NULL,
> + NULL, NULL, NULL, SOCKET_ID_ANY, 0);
> + if (t->ca_sess_priv_pool == NULL) {
> + evt_err("failed to create sym session private pool");
> + ret = -ENOMEM;
> + goto err;
> + }
> +
> + /*
> + * Calculate number of needed queue pairs, based on the amount of
> + * available number of logical cores and crypto devices. For instance,
> + * if there are 4 cores and 2 crypto devices, 2 queue pairs will be set
> + * up per device.
> + */
> + nb_plcores = evt_nr_active_lcores(opt->plcores);
> + nb_qps = (nb_plcores % cdev_count) ? (nb_plcores / cdev_count) + 1 :
> + nb_plcores / cdev_count;
> + for (cdev_id = 0; cdev_id < cdev_count; cdev_id++) {
> + struct rte_cryptodev_qp_conf qp_conf;
> + struct rte_cryptodev_config conf;
> + struct rte_cryptodev_info info;
> + int qp_id;
> +
> + rte_cryptodev_info_get(cdev_id, &info);
> + if (nb_qps > info.max_nb_queue_pairs) {
> + evt_err("Not enough queue pairs per cryptodev (%u)",
> + nb_qps);
> + ret = -EINVAL;
> + goto err;
> + }
> +
> + conf.nb_queue_pairs = nb_qps;
> + conf.socket_id = SOCKET_ID_ANY;
> + conf.ff_disable = RTE_CRYPTODEV_FF_SECURITY;
> +
> + ret = rte_cryptodev_configure(cdev_id, &conf);
> + if (ret) {
> + evt_err("Failed to configure cryptodev (%u)", cdev_id);
> + goto err;
> + }
> +
> + qp_conf.nb_descriptors = NB_CRYPTODEV_DESCRIPTORS;
> + qp_conf.mp_session = t->ca_sess_pool;
> + qp_conf.mp_session_private = t->ca_sess_priv_pool;
> +
> + for (qp_id = 0; qp_id < conf.nb_queue_pairs; qp_id++) {
> + ret = rte_cryptodev_queue_pair_setup(
> + cdev_id, qp_id, &qp_conf,
> + rte_cryptodev_socket_id(cdev_id));
> + if (ret) {
> + evt_err("Failed to setup queue pairs on
> cryptodev %u\n",
> + cdev_id);
> + goto err;
> + }
> + }
> + }
> +
> + return 0;
> +err:
> + for (cdev_id = 0; cdev_id < cdev_count; cdev_id++)
> + rte_cryptodev_close(cdev_id);
> +
> + rte_mempool_free(t->ca_op_pool);
> + rte_mempool_free(t->ca_sess_pool);
> + rte_mempool_free(t->ca_sess_priv_pool);
> +
> + return ret;
> +}
> +
> +void
> +perf_cryptodev_destroy(struct evt_test *test, struct evt_options *opt)
> +{
> + uint8_t cdev_id, cdev_count = rte_cryptodev_count();
> + struct test_perf *t = evt_test_priv(test);
> + uint16_t port;
> +
> + if (opt->prod_type != EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR)
> + return;
> +
> + for (port = t->nb_workers; port < perf_nb_event_ports(opt); port++) {
> + struct rte_cryptodev_sym_session *sess;
> + struct prod_data *p = &t->prod[port];
> + uint32_t flow_id;
> + uint8_t cdev_id;
> +
> + for (flow_id = 0; flow_id < t->nb_flows; flow_id++) {
> + sess = p->ca.crypto_sess[flow_id];
> + cdev_id = p->ca.cdev_id;
> + rte_cryptodev_sym_session_clear(cdev_id, sess);
> + rte_cryptodev_sym_session_free(sess);
> + }
> +
> + rte_event_crypto_adapter_queue_pair_del(
> + TEST_PERF_CA_ID, p->ca.cdev_id, p->ca.cdev_qp_id);
> + }
> +
> + rte_event_crypto_adapter_free(TEST_PERF_CA_ID);
> +
> + for (cdev_id = 0; cdev_id < cdev_count; cdev_id++) {
> + rte_cryptodev_stop(cdev_id);
> + rte_cryptodev_close(cdev_id);
> + }
> +
> + rte_mempool_free(t->ca_op_pool);
> + rte_mempool_free(t->ca_sess_pool);
> + rte_mempool_free(t->ca_sess_priv_pool);
> +}
> +
> int
> perf_mempool_setup(struct evt_test *test, struct evt_options *opt) { diff --git
> a/app/test-eventdev/test_perf_common.h b/app/test-
> eventdev/test_perf_common.h
> index 14dcf80429..ea0907d61a 100644
> --- a/app/test-eventdev/test_perf_common.h
> +++ b/app/test-eventdev/test_perf_common.h
> @@ -9,9 +9,11 @@
> #include <stdbool.h>
> #include <unistd.h>
>
> +#include <rte_cryptodev.h>
> #include <rte_cycles.h>
> #include <rte_ethdev.h>
> #include <rte_eventdev.h>
> +#include <rte_event_crypto_adapter.h>
> #include <rte_event_eth_rx_adapter.h>
> #include <rte_event_timer_adapter.h>
> #include <rte_lcore.h>
> @@ -23,6 +25,8 @@
> #include "evt_options.h"
> #include "evt_test.h"
>
> +#define TEST_PERF_CA_ID 0
> +
> struct test_perf;
>
> struct worker_data {
> @@ -33,14 +37,19 @@ struct worker_data {
> struct test_perf *t;
> } __rte_cache_aligned;
>
> +struct crypto_adptr_data {
> + uint8_t cdev_id;
> + uint16_t cdev_qp_id;
> + struct rte_cryptodev_sym_session **crypto_sess; };
> struct prod_data {
> uint8_t dev_id;
> uint8_t port_id;
> uint8_t queue_id;
> + struct crypto_adptr_data ca;
> struct test_perf *t;
> } __rte_cache_aligned;
>
> -
> struct test_perf {
> /* Don't change the offset of "done". Signal handler use this memory
> * to terminate all lcores work.
> @@ -58,6 +67,9 @@ struct test_perf {
> uint8_t sched_type_list[EVT_MAX_STAGES] __rte_cache_aligned;
> struct rte_event_timer_adapter *timer_adptr[
> RTE_EVENT_TIMER_ADAPTER_NUM_MAX]
> __rte_cache_aligned;
> + struct rte_mempool *ca_op_pool;
> + struct rte_mempool *ca_sess_pool;
> + struct rte_mempool *ca_sess_priv_pool;
> } __rte_cache_aligned;
>
> struct perf_elt {
> @@ -81,6 +93,8 @@ struct perf_elt {
> const uint8_t port = w->port_id;\
> const uint8_t prod_timer_type = \
> opt->prod_type == EVT_PROD_TYPE_EVENT_TIMER_ADPTR;\
> + const uint8_t prod_crypto_type = \
> + opt->prod_type == EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR;\
> uint8_t *const sched_type_list = &t->sched_type_list[0];\
> struct rte_mempool *const pool = t->pool;\
> const uint8_t nb_stages = t->opt->nb_stages;\ @@ -154,6 +168,7 @@
> int perf_test_result(struct evt_test *test, struct evt_options *opt); int
> perf_opt_check(struct evt_options *opt, uint64_t nb_queues); int
> perf_test_setup(struct evt_test *test, struct evt_options *opt); int
> perf_ethdev_setup(struct evt_test *test, struct evt_options *opt);
> +int perf_cryptodev_setup(struct evt_test *test, struct evt_options
> +*opt);
> int perf_mempool_setup(struct evt_test *test, struct evt_options *opt); int
> perf_event_dev_port_setup(struct evt_test *test, struct evt_options *opt,
> uint8_t stride, uint8_t nb_queues,
> @@ -164,6 +179,7 @@ int perf_launch_lcores(struct evt_test *test, struct
> evt_options *opt, void perf_opt_dump(struct evt_options *opt, uint8_t
> nb_queues); void perf_test_destroy(struct evt_test *test, struct evt_options
> *opt); void perf_eventdev_destroy(struct evt_test *test, struct evt_options
> *opt);
> +void perf_cryptodev_destroy(struct evt_test *test, struct evt_options
> +*opt);
> void perf_ethdev_destroy(struct evt_test *test, struct evt_options *opt); void
> perf_mempool_destroy(struct evt_test *test, struct evt_options *opt);
>
> diff --git a/app/test-eventdev/test_perf_queue.c b/app/test-
> eventdev/test_perf_queue.c
> index f4ea3a795f..dcf6d82947 100644
> --- a/app/test-eventdev/test_perf_queue.c
> +++ b/app/test-eventdev/test_perf_queue.c
> @@ -49,6 +49,23 @@ perf_queue_worker(void *arg, const int
> enable_fwd_latency)
> rte_pause();
> continue;
> }
> +
> + if (prod_crypto_type &&
> + (ev.event_type == RTE_EVENT_TYPE_CRYPTODEV)) {
> + struct rte_crypto_op *op = ev.event_ptr;
> +
> + if (op->status == RTE_CRYPTO_OP_STATUS_SUCCESS) {
> + if (op->sym->m_dst == NULL)
> + ev.event_ptr = op->sym->m_src;
> + else
> + ev.event_ptr = op->sym->m_dst;
> + rte_crypto_op_free(op);
> + } else {
> + rte_crypto_op_free(op);
> + continue;
> + }
> + }
> +
> if (enable_fwd_latency && !prod_timer_type)
> /* first q in pipeline, mark timestamp to compute fwd latency
> */
> mark_fwd_latency(&ev, nb_stages);
> @@ -88,6 +105,25 @@ perf_queue_worker_burst(void *arg, const int
> enable_fwd_latency)
> }
>
> for (i = 0; i < nb_rx; i++) {
> + if (prod_crypto_type &&
> + (ev[i].event_type == RTE_EVENT_TYPE_CRYPTODEV))
> {
> + struct rte_crypto_op *op = ev[i].event_ptr;
> +
> + if (op->status ==
> + RTE_CRYPTO_OP_STATUS_SUCCESS) {
> + if (op->sym->m_dst == NULL)
> + ev[i].event_ptr =
> + op->sym->m_src;
> + else
> + ev[i].event_ptr =
> + op->sym->m_dst;
> + rte_crypto_op_free(op);
> + } else {
> + rte_crypto_op_free(op);
> + continue;
> + }
> + }
> +
> if (enable_fwd_latency && !prod_timer_type) {
> rte_prefetch0(ev[i+1].event_ptr);
> /* first queue in pipeline.
> @@ -269,6 +305,18 @@ perf_queue_eventdev_setup(struct evt_test *test,
> struct evt_options *opt)
> return ret;
> }
> }
> + } else if (opt->prod_type == EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR) {
> + uint8_t cdev_id, cdev_count;
> +
> + cdev_count = rte_cryptodev_count();
> + for (cdev_id = 0; cdev_id < cdev_count; cdev_id++) {
> + ret = rte_cryptodev_start(cdev_id);
> + if (ret) {
> + evt_err("Failed to start cryptodev %u",
> + cdev_id);
> + return ret;
> + }
> + }
> }
>
> return 0;
> @@ -311,11 +359,13 @@ static const struct evt_test_ops perf_queue = {
> .test_setup = perf_test_setup,
> .mempool_setup = perf_mempool_setup,
> .ethdev_setup = perf_ethdev_setup,
> + .cryptodev_setup = perf_cryptodev_setup,
> .eventdev_setup = perf_queue_eventdev_setup,
> .launch_lcores = perf_queue_launch_lcores,
> .eventdev_destroy = perf_eventdev_destroy,
> .mempool_destroy = perf_mempool_destroy,
> .ethdev_destroy = perf_ethdev_destroy,
> + .cryptodev_destroy = perf_cryptodev_destroy,
> .test_result = perf_test_result,
> .test_destroy = perf_test_destroy,
> };
> diff --git a/doc/guides/rel_notes/release_22_03.rst
> b/doc/guides/rel_notes/release_22_03.rst
> index cbc98e798f..72052ef2dc 100644
> --- a/doc/guides/rel_notes/release_22_03.rst
> +++ b/doc/guides/rel_notes/release_22_03.rst
> @@ -159,6 +159,11 @@ New Features
> * Called ``rte_ipv4/6_udptcp_cksum_mbuf()`` functions in testpmd csum
> mode
> to support software UDP/TCP checksum over multiple segments.
>
> +* **Added crypto producer mode in test-eventdev.**
> +
> + * Crypto producer mode helps to measure performance of OP_NEW and
> OP_FORWARD
> + modes of event crypto adapter.
> +
>
> Removed Items
> -------------
> diff --git a/doc/guides/tools/testeventdev.rst
> b/doc/guides/tools/testeventdev.rst
> index 48efb9ea6e..f7d813226d 100644
> --- a/doc/guides/tools/testeventdev.rst
> +++ b/doc/guides/tools/testeventdev.rst
> @@ -120,6 +120,10 @@ The following are the application command-line
> options:
>
> Use burst mode event timer adapter as producer.
>
> +* ``--prod_type_cryptodev``
> +
> + Use crypto device as producer.
> +
> * ``--timer_tick_nsec``
>
> Used to dictate number of nano seconds between bucket traversal of the
> @@ -148,6 +152,11 @@ The following are the application command-line
> options:
> timeout is out of the supported range of event device it will be
> adjusted to the highest/lowest supported dequeue timeout supported.
>
> +* ``--crypto_adptr_mode``
> +
> + Set crypto adapter mode. Use 0 for OP_NEW (default) and 1 for
> + OP_FORWARD mode.
> +
> * ``--mbuf_sz``
>
> Set packet mbuf size. Can be used to configure Jumbo Frames. Only @@ -
> 420,6 +429,7 @@ Supported application command line options are following::
> --prod_type_ethdev
> --prod_type_timerdev_burst
> --prod_type_timerdev
> + --prod_type_cryptodev
> --prod_enq_burst_sz
> --timer_tick_nsec
> --max_tmo_nsec
> @@ -427,6 +437,7 @@ Supported application command line options are
> following::
> --nb_timers
> --nb_timer_adptrs
> --deq_tmo_nsec
> + --crypto_adptr_mode
>
> Example
> ^^^^^^^
> @@ -529,12 +540,14 @@ Supported application command line options are
> following::
> --prod_type_ethdev
> --prod_type_timerdev_burst
> --prod_type_timerdev
> + --prod_type_cryptodev
> --timer_tick_nsec
> --max_tmo_nsec
> --expiry_nsec
> --nb_timers
> --nb_timer_adptrs
> --deq_tmo_nsec
> + --crypto_adptr_mode
>
> Example
> ^^^^^^^
> --
> 2.25.1
^ permalink raw reply [flat|nested] 43+ messages in thread
* Re: [PATCH v7] app/eventdev: add crypto producer mode
2022-02-24 6:18 ` Gujjar, Abhinandan S
@ 2022-02-24 7:58 ` Jerin Jacob
0 siblings, 0 replies; 43+ messages in thread
From: Jerin Jacob @ 2022-02-24 7:58 UTC (permalink / raw)
To: Gujjar, Abhinandan S; +Cc: Shijith Thotton, dev, jerinj, Akhil Goyal
On Thu, Feb 24, 2022 at 11:48 AM Gujjar, Abhinandan S
<abhinandan.gujjar@intel.com> wrote:
>
> Acked-by: Abhinandan Gujjar <abhinandan.gujjar@intel.com>
Applied to dpdk-next-net-eventdev/for-main. Thanks
>
> > -----Original Message-----
> > From: Shijith Thotton <sthotton@marvell.com>
> > Sent: Thursday, February 24, 2022 10:16 AM
> > To: dev@dpdk.org; jerinj@marvell.com
> > Cc: Shijith Thotton <sthotton@marvell.com>; Gujjar, Abhinandan S
> > <abhinandan.gujjar@intel.com>; Akhil Goyal <gakhil@marvell.com>
> > Subject: [PATCH v7] app/eventdev: add crypto producer mode
> >
> > In crypto producer mode, producer core enqueues cryptodev with software
> > generated crypto ops and worker core dequeues crypto completion events from
> > the eventdev. Event crypto metadata used for above processing is pre-
> > populated in each crypto session.
> >
> > Parameter --prod_type_cryptodev can be used to enable crypto producer
> > mode. Parameter --crypto_adptr_mode can be set to select the crypto adapter
> > mode, 0 for OP_NEW and 1 for OP_FORWARD.
> >
> > This mode can be used to measure the performance of crypto adapter.
> >
> > Example:
> > ./dpdk-test-eventdev -l 0-2 -w <EVENTDEV> -w <CRYPTODEV> -- \
> > --prod_type_cryptodev --crypto_adptr_mode 1 --test=perf_atq \
> > --stlist=a --wlcores 1 --plcores 2
> >
> > Signed-off-by: Shijith Thotton <sthotton@marvell.com>
> > Acked-by: Akhil Goyal <gakhil@marvell.com>
> > ---
> > v7:
> > * Removed setting op and event_type in response info.
> > * Fixed op type of event in FORWARD mode.
> >
> > v6:
> > * Added cryptodev close.
> > * Fixed cleanup.
> > * Updated release notes.
> >
> > v5:
> > * Rebased.
> >
> > v4:
> > * Addressed comments on v3 and rebased.
> > * Added cryptodev cleanup in signal handler.
> >
> > v3:
> > * Reduce dereference inside loop.
> >
> > v2:
> > * Fix RHEL compilation warning.
> >
> > app/test-eventdev/evt_common.h | 3 +
> > app/test-eventdev/evt_main.c | 17 +-
> > app/test-eventdev/evt_options.c | 27 ++
> > app/test-eventdev/evt_options.h | 12 +
> > app/test-eventdev/evt_test.h | 6 +
> > app/test-eventdev/test_perf_atq.c | 49 +++
> > app/test-eventdev/test_perf_common.c | 427 ++++++++++++++++++++++++-
> > app/test-eventdev/test_perf_common.h | 18 +-
> > app/test-eventdev/test_perf_queue.c | 50 +++
> > doc/guides/rel_notes/release_22_03.rst | 5 +
> > doc/guides/tools/testeventdev.rst | 13 +
> > 11 files changed, 619 insertions(+), 8 deletions(-)
> >
> > diff --git a/app/test-eventdev/evt_common.h b/app/test-
> > eventdev/evt_common.h index f466434459..2f301a7e79 100644
> > --- a/app/test-eventdev/evt_common.h
> > +++ b/app/test-eventdev/evt_common.h
> > @@ -7,6 +7,7 @@
> >
> > #include <rte_common.h>
> > #include <rte_debug.h>
> > +#include <rte_event_crypto_adapter.h>
> > #include <rte_eventdev.h>
> > #include <rte_service.h>
> >
> > @@ -39,6 +40,7 @@ enum evt_prod_type {
> > EVT_PROD_TYPE_SYNT, /* Producer type Synthetic i.e. CPU. */
> > EVT_PROD_TYPE_ETH_RX_ADPTR, /* Producer type Eth Rx Adapter. */
> > EVT_PROD_TYPE_EVENT_TIMER_ADPTR, /* Producer type Timer
> > Adapter. */
> > + EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR, /* Producer type Crypto
> > Adapter. */
> > EVT_PROD_TYPE_MAX,
> > };
> >
> > @@ -77,6 +79,7 @@ struct evt_options {
> > uint64_t timer_tick_nsec;
> > uint64_t optm_timer_tick_nsec;
> > enum evt_prod_type prod_type;
> > + enum rte_event_crypto_adapter_mode crypto_adptr_mode;
> > };
> >
> > static inline bool
> > diff --git a/app/test-eventdev/evt_main.c b/app/test-eventdev/evt_main.c
> > index 194c980c7a..a7d6b0c1cf 100644
> > --- a/app/test-eventdev/evt_main.c
> > +++ b/app/test-eventdev/evt_main.c
> > @@ -35,6 +35,9 @@ signal_handler(int signum)
> > if (test->ops.ethdev_destroy)
> > test->ops.ethdev_destroy(test, &opt);
> >
> > + if (test->ops.cryptodev_destroy)
> > + test->ops.cryptodev_destroy(test, &opt);
> > +
> > rte_eal_mp_wait_lcore();
> >
> > if (test->ops.test_result)
> > @@ -162,11 +165,19 @@ main(int argc, char **argv)
> > }
> > }
> >
> > + /* Test specific cryptodev setup */
> > + if (test->ops.cryptodev_setup) {
> > + if (test->ops.cryptodev_setup(test, &opt)) {
> > + evt_err("%s: cryptodev setup failed", opt.test_name);
> > + goto ethdev_destroy;
> > + }
> > + }
> > +
> > /* Test specific eventdev setup */
> > if (test->ops.eventdev_setup) {
> > if (test->ops.eventdev_setup(test, &opt)) {
> > evt_err("%s: eventdev setup failed", opt.test_name);
> > - goto ethdev_destroy;
> > + goto cryptodev_destroy;
> > }
> > }
> >
> > @@ -197,6 +208,10 @@ main(int argc, char **argv)
> > if (test->ops.eventdev_destroy)
> > test->ops.eventdev_destroy(test, &opt);
> >
> > +cryptodev_destroy:
> > + if (test->ops.cryptodev_destroy)
> > + test->ops.cryptodev_destroy(test, &opt);
> > +
> > ethdev_destroy:
> > if (test->ops.ethdev_destroy)
> > test->ops.ethdev_destroy(test, &opt); diff --git a/app/test-
> > eventdev/evt_options.c b/app/test-eventdev/evt_options.c index
> > 4ae44801da..d3c704d2b3 100644
> > --- a/app/test-eventdev/evt_options.c
> > +++ b/app/test-eventdev/evt_options.c
> > @@ -122,6 +122,26 @@ evt_parse_timer_prod_type_burst(struct evt_options
> > *opt,
> > return 0;
> > }
> >
> > +static int
> > +evt_parse_crypto_prod_type(struct evt_options *opt,
> > + const char *arg __rte_unused)
> > +{
> > + opt->prod_type = EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR;
> > + return 0;
> > +}
> > +
> > +static int
> > +evt_parse_crypto_adptr_mode(struct evt_options *opt, const char *arg) {
> > + uint8_t mode;
> > + int ret;
> > +
> > + ret = parser_read_uint8(&mode, arg);
> > + opt->crypto_adptr_mode = mode ?
> > RTE_EVENT_CRYPTO_ADAPTER_OP_FORWARD :
> > +
> > RTE_EVENT_CRYPTO_ADAPTER_OP_NEW;
> > + return ret;
> > +}
> > +
> > static int
> > evt_parse_test_name(struct evt_options *opt, const char *arg) { @@ -335,6
> > +355,7 @@ usage(char *program)
> > "\t--queue_priority : enable queue priority\n"
> > "\t--deq_tmo_nsec : global dequeue timeout\n"
> > "\t--prod_type_ethdev : use ethernet device as producer.\n"
> > + "\t--prod_type_cryptodev : use crypto device as producer.\n"
> > "\t--prod_type_timerdev : use event timer device as
> > producer.\n"
> > "\t expiry_nsec would be the timeout\n"
> > "\t in ns.\n"
> > @@ -345,6 +366,8 @@ usage(char *program)
> > "\t--timer_tick_nsec : timer tick interval in ns.\n"
> > "\t--max_tmo_nsec : max timeout interval in ns.\n"
> > "\t--expiry_nsec : event timer expiry ns.\n"
> > + "\t--crypto_adptr_mode : 0 for OP_NEW mode (default)
> > and\n"
> > + "\t 1 for OP_FORWARD mode.\n"
> > "\t--mbuf_sz : packet mbuf size.\n"
> > "\t--max_pkt_sz : max packet size.\n"
> > "\t--prod_enq_burst_sz : producer enqueue burst size.\n"
> > @@ -415,8 +438,10 @@ static struct option lgopts[] = {
> > { EVT_QUEUE_PRIORITY, 0, 0, 0 },
> > { EVT_DEQ_TMO_NSEC, 1, 0, 0 },
> > { EVT_PROD_ETHDEV, 0, 0, 0 },
> > + { EVT_PROD_CRYPTODEV, 0, 0, 0 },
> > { EVT_PROD_TIMERDEV, 0, 0, 0 },
> > { EVT_PROD_TIMERDEV_BURST, 0, 0, 0 },
> > + { EVT_CRYPTO_ADPTR_MODE, 1, 0, 0 },
> > { EVT_NB_TIMERS, 1, 0, 0 },
> > { EVT_NB_TIMER_ADPTRS, 1, 0, 0 },
> > { EVT_TIMER_TICK_NSEC, 1, 0, 0 },
> > @@ -455,8 +480,10 @@ evt_opts_parse_long(int opt_idx, struct evt_options
> > *opt)
> > { EVT_QUEUE_PRIORITY, evt_parse_queue_priority},
> > { EVT_DEQ_TMO_NSEC, evt_parse_deq_tmo_nsec},
> > { EVT_PROD_ETHDEV, evt_parse_eth_prod_type},
> > + { EVT_PROD_CRYPTODEV, evt_parse_crypto_prod_type},
> > { EVT_PROD_TIMERDEV, evt_parse_timer_prod_type},
> > { EVT_PROD_TIMERDEV_BURST,
> > evt_parse_timer_prod_type_burst},
> > + { EVT_CRYPTO_ADPTR_MODE, evt_parse_crypto_adptr_mode},
> > { EVT_NB_TIMERS, evt_parse_nb_timers},
> > { EVT_NB_TIMER_ADPTRS, evt_parse_nb_timer_adptrs},
> > { EVT_TIMER_TICK_NSEC, evt_parse_timer_tick_nsec}, diff --git
> > a/app/test-eventdev/evt_options.h b/app/test-eventdev/evt_options.h index
> > 413d7092f0..2231c58801 100644
> > --- a/app/test-eventdev/evt_options.h
> > +++ b/app/test-eventdev/evt_options.h
> > @@ -9,6 +9,7 @@
> > #include <stdbool.h>
> >
> > #include <rte_common.h>
> > +#include <rte_cryptodev.h>
> > #include <rte_ethdev.h>
> > #include <rte_eventdev.h>
> > #include <rte_lcore.h>
> > @@ -33,8 +34,10 @@
> > #define EVT_QUEUE_PRIORITY ("queue_priority")
> > #define EVT_DEQ_TMO_NSEC ("deq_tmo_nsec")
> > #define EVT_PROD_ETHDEV ("prod_type_ethdev")
> > +#define EVT_PROD_CRYPTODEV ("prod_type_cryptodev")
> > #define EVT_PROD_TIMERDEV ("prod_type_timerdev")
> > #define EVT_PROD_TIMERDEV_BURST ("prod_type_timerdev_burst")
> > +#define EVT_CRYPTO_ADPTR_MODE ("crypto_adptr_mode")
> > #define EVT_NB_TIMERS ("nb_timers")
> > #define EVT_NB_TIMER_ADPTRS ("nb_timer_adptrs")
> > #define EVT_TIMER_TICK_NSEC ("timer_tick_nsec")
> > @@ -249,6 +252,8 @@ evt_prod_id_to_name(enum evt_prod_type
> > prod_type)
> > return "Ethdev Rx Adapter";
> > case EVT_PROD_TYPE_EVENT_TIMER_ADPTR:
> > return "Event timer adapter";
> > + case EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR:
> > + return "Event crypto adapter";
> > }
> >
> > return "";
> > @@ -288,6 +293,13 @@ evt_dump_producer_type(struct evt_options *opt)
> > evt_dump("timer_tick_nsec", "%"PRIu64"",
> > opt->timer_tick_nsec);
> > break;
> > + case EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR:
> > + snprintf(name, EVT_PROD_MAX_NAME_LEN,
> > + "Event crypto adapter producers");
> > + evt_dump("crypto adapter mode", "%s",
> > + opt->crypto_adptr_mode ? "OP_FORWARD" :
> > "OP_NEW");
> > + evt_dump("nb_cryptodev", "%u", rte_cryptodev_count());
> > + break;
> > }
> > evt_dump("prod_type", "%s", name);
> > }
> > diff --git a/app/test-eventdev/evt_test.h b/app/test-eventdev/evt_test.h index
> > f07d2c3336..50fa474ec2 100644
> > --- a/app/test-eventdev/evt_test.h
> > +++ b/app/test-eventdev/evt_test.h
> > @@ -29,6 +29,8 @@ typedef int (*evt_test_mempool_setup_t)
> > (struct evt_test *test, struct evt_options *opt); typedef int
> > (*evt_test_ethdev_setup_t)
> > (struct evt_test *test, struct evt_options *opt);
> > +typedef int (*evt_test_cryptodev_setup_t)
> > + (struct evt_test *test, struct evt_options *opt);
> > typedef int (*evt_test_eventdev_setup_t)
> > (struct evt_test *test, struct evt_options *opt); typedef int
> > (*evt_test_launch_lcores_t) @@ -39,6 +41,8 @@ typedef void
> > (*evt_test_eventdev_destroy_t)
> > (struct evt_test *test, struct evt_options *opt); typedef void
> > (*evt_test_ethdev_destroy_t)
> > (struct evt_test *test, struct evt_options *opt);
> > +typedef void (*evt_test_cryptodev_destroy_t)
> > + (struct evt_test *test, struct evt_options *opt);
> > typedef void (*evt_test_mempool_destroy_t)
> > (struct evt_test *test, struct evt_options *opt); typedef void
> > (*evt_test_destroy_t) @@ -52,10 +56,12 @@ struct evt_test_ops {
> > evt_test_mempool_setup_t mempool_setup;
> > evt_test_ethdev_setup_t ethdev_setup;
> > evt_test_eventdev_setup_t eventdev_setup;
> > + evt_test_cryptodev_setup_t cryptodev_setup;
> > evt_test_launch_lcores_t launch_lcores;
> > evt_test_result_t test_result;
> > evt_test_eventdev_destroy_t eventdev_destroy;
> > evt_test_ethdev_destroy_t ethdev_destroy;
> > + evt_test_cryptodev_destroy_t cryptodev_destroy;
> > evt_test_mempool_destroy_t mempool_destroy;
> > evt_test_destroy_t test_destroy;
> > };
> > diff --git a/app/test-eventdev/test_perf_atq.c b/app/test-
> > eventdev/test_perf_atq.c
> > index 8fd51004ee..67ff681666 100644
> > --- a/app/test-eventdev/test_perf_atq.c
> > +++ b/app/test-eventdev/test_perf_atq.c
> > @@ -48,6 +48,22 @@ perf_atq_worker(void *arg, const int
> > enable_fwd_latency)
> > continue;
> > }
> >
> > + if (prod_crypto_type &&
> > + (ev.event_type == RTE_EVENT_TYPE_CRYPTODEV)) {
> > + struct rte_crypto_op *op = ev.event_ptr;
> > +
> > + if (op->status == RTE_CRYPTO_OP_STATUS_SUCCESS) {
> > + if (op->sym->m_dst == NULL)
> > + ev.event_ptr = op->sym->m_src;
> > + else
> > + ev.event_ptr = op->sym->m_dst;
> > + rte_crypto_op_free(op);
> > + } else {
> > + rte_crypto_op_free(op);
> > + continue;
> > + }
> > + }
> > +
> > if (enable_fwd_latency && !prod_timer_type)
> > /* first stage in pipeline, mark ts to compute fwd latency */
> > atq_mark_fwd_latency(&ev);
> > @@ -87,6 +103,25 @@ perf_atq_worker_burst(void *arg, const int
> > enable_fwd_latency)
> > }
> >
> > for (i = 0; i < nb_rx; i++) {
> > + if (prod_crypto_type &&
> > + (ev[i].event_type == RTE_EVENT_TYPE_CRYPTODEV))
> > {
> > + struct rte_crypto_op *op = ev[i].event_ptr;
> > +
> > + if (op->status ==
> > + RTE_CRYPTO_OP_STATUS_SUCCESS) {
> > + if (op->sym->m_dst == NULL)
> > + ev[i].event_ptr =
> > + op->sym->m_src;
> > + else
> > + ev[i].event_ptr =
> > + op->sym->m_dst;
> > + rte_crypto_op_free(op);
> > + } else {
> > + rte_crypto_op_free(op);
> > + continue;
> > + }
> > + }
> > +
> > if (enable_fwd_latency && !prod_timer_type) {
> > rte_prefetch0(ev[i+1].event_ptr);
> > /* first stage in pipeline.
> > @@ -254,6 +289,18 @@ perf_atq_eventdev_setup(struct evt_test *test, struct
> > evt_options *opt)
> > return ret;
> > }
> > }
> > + } else if (opt->prod_type == EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR) {
> > + uint8_t cdev_id, cdev_count;
> > +
> > + cdev_count = rte_cryptodev_count();
> > + for (cdev_id = 0; cdev_id < cdev_count; cdev_id++) {
> > + ret = rte_cryptodev_start(cdev_id);
> > + if (ret) {
> > + evt_err("Failed to start cryptodev %u",
> > + cdev_id);
> > + return ret;
> > + }
> > + }
> > }
> >
> > return 0;
> > @@ -295,12 +342,14 @@ static const struct evt_test_ops perf_atq = {
> > .opt_dump = perf_atq_opt_dump,
> > .test_setup = perf_test_setup,
> > .ethdev_setup = perf_ethdev_setup,
> > + .cryptodev_setup = perf_cryptodev_setup,
> > .mempool_setup = perf_mempool_setup,
> > .eventdev_setup = perf_atq_eventdev_setup,
> > .launch_lcores = perf_atq_launch_lcores,
> > .eventdev_destroy = perf_eventdev_destroy,
> > .mempool_destroy = perf_mempool_destroy,
> > .ethdev_destroy = perf_ethdev_destroy,
> > + .cryptodev_destroy = perf_cryptodev_destroy,
> > .test_result = perf_test_result,
> > .test_destroy = perf_test_destroy,
> > };
> > diff --git a/app/test-eventdev/test_perf_common.c b/app/test-
> > eventdev/test_perf_common.c
> > index 9b73874151..9d1f4a4567 100644
> > --- a/app/test-eventdev/test_perf_common.c
> > +++ b/app/test-eventdev/test_perf_common.c
> > @@ -6,6 +6,8 @@
> >
> > #include "test_perf_common.h"
> >
> > +#define NB_CRYPTODEV_DESCRIPTORS 128
> > +
> > int
> > perf_test_result(struct evt_test *test, struct evt_options *opt) { @@ -272,6
> > +274,123 @@ perf_event_timer_producer_burst(void *arg)
> > return 0;
> > }
> >
> > +static inline void
> > +crypto_adapter_enq_op_new(struct prod_data *p) {
> > + struct rte_cryptodev_sym_session **crypto_sess = p->ca.crypto_sess;
> > + struct test_perf *t = p->t;
> > + const uint32_t nb_flows = t->nb_flows;
> > + const uint64_t nb_pkts = t->nb_pkts;
> > + struct rte_mempool *pool = t->pool;
> > + struct rte_crypto_sym_op *sym_op;
> > + struct evt_options *opt = t->opt;
> > + uint16_t qp_id = p->ca.cdev_qp_id;
> > + uint8_t cdev_id = p->ca.cdev_id;
> > + uint32_t flow_counter = 0;
> > + struct rte_crypto_op *op;
> > + struct rte_mbuf *m;
> > + uint64_t count = 0;
> > + uint16_t len;
> > +
> > + if (opt->verbose_level > 1)
> > + printf("%s(): lcore %d queue %d cdev_id %u cdev_qp_id %u\n",
> > + __func__, rte_lcore_id(), p->queue_id, p->ca.cdev_id,
> > + p->ca.cdev_qp_id);
> > +
> > + len = opt->mbuf_sz ? opt->mbuf_sz : RTE_ETHER_MIN_LEN;
> > +
> > + while (count < nb_pkts && t->done == false) {
> > + m = rte_pktmbuf_alloc(pool);
> > + if (m == NULL)
> > + continue;
> > +
> > + rte_pktmbuf_append(m, len);
> > + op = rte_crypto_op_alloc(t->ca_op_pool,
> > + RTE_CRYPTO_OP_TYPE_SYMMETRIC);
> > + sym_op = op->sym;
> > + sym_op->m_src = m;
> > + sym_op->cipher.data.offset = 0;
> > + sym_op->cipher.data.length = len;
> > + rte_crypto_op_attach_sym_session(
> > + op, crypto_sess[flow_counter++ % nb_flows]);
> > +
> > + while (rte_cryptodev_enqueue_burst(cdev_id, qp_id, &op, 1) !=
> > 1 &&
> > + t->done == false)
> > + rte_pause();
> > +
> > + count++;
> > + }
> > +}
> > +
> > +static inline void
> > +crypto_adapter_enq_op_fwd(struct prod_data *p) {
> > + struct rte_cryptodev_sym_session **crypto_sess = p->ca.crypto_sess;
> > + const uint8_t dev_id = p->dev_id;
> > + const uint8_t port = p->port_id;
> > + struct test_perf *t = p->t;
> > + const uint32_t nb_flows = t->nb_flows;
> > + const uint64_t nb_pkts = t->nb_pkts;
> > + struct rte_mempool *pool = t->pool;
> > + struct evt_options *opt = t->opt;
> > + struct rte_crypto_sym_op *sym_op;
> > + uint32_t flow_counter = 0;
> > + struct rte_crypto_op *op;
> > + struct rte_event ev;
> > + struct rte_mbuf *m;
> > + uint64_t count = 0;
> > + uint16_t len;
> > +
> > + if (opt->verbose_level > 1)
> > + printf("%s(): lcore %d port %d queue %d cdev_id %u
> > cdev_qp_id %u\n",
> > + __func__, rte_lcore_id(), port, p->queue_id,
> > + p->ca.cdev_id, p->ca.cdev_qp_id);
> > +
> > + ev.event = 0;
> > + ev.op = RTE_EVENT_OP_NEW;
> > + ev.queue_id = p->queue_id;
> > + ev.sched_type = RTE_SCHED_TYPE_ATOMIC;
> > + ev.event_type = RTE_EVENT_TYPE_CPU;
> > + len = opt->mbuf_sz ? opt->mbuf_sz : RTE_ETHER_MIN_LEN;
> > +
> > + while (count < nb_pkts && t->done == false) {
> > + m = rte_pktmbuf_alloc(pool);
> > + if (m == NULL)
> > + continue;
> > +
> > + rte_pktmbuf_append(m, len);
> > + op = rte_crypto_op_alloc(t->ca_op_pool,
> > + RTE_CRYPTO_OP_TYPE_SYMMETRIC);
> > + sym_op = op->sym;
> > + sym_op->m_src = m;
> > + sym_op->cipher.data.offset = 0;
> > + sym_op->cipher.data.length = len;
> > + rte_crypto_op_attach_sym_session(
> > + op, crypto_sess[flow_counter++ % nb_flows]);
> > + ev.event_ptr = op;
> > +
> > + while (rte_event_crypto_adapter_enqueue(dev_id, port, &ev,
> > 1) != 1 &&
> > + t->done == false)
> > + rte_pause();
> > +
> > + count++;
> > + }
> > +}
> > +
> > +static inline int
> > +perf_event_crypto_producer(void *arg)
> > +{
> > + struct prod_data *p = arg;
> > + struct evt_options *opt = p->t->opt;
> > +
> > + if (opt->crypto_adptr_mode ==
> > RTE_EVENT_CRYPTO_ADAPTER_OP_NEW)
> > + crypto_adapter_enq_op_new(p);
> > + else
> > + crypto_adapter_enq_op_fwd(p);
> > +
> > + return 0;
> > +}
> > +
> > static int
> > perf_producer_wrapper(void *arg)
> > {
> > @@ -298,6 +417,8 @@ perf_producer_wrapper(void *arg)
> > else if (t->opt->prod_type == EVT_PROD_TYPE_EVENT_TIMER_ADPTR
> > &&
> > t->opt->timdev_use_burst)
> > return perf_event_timer_producer_burst(arg);
> > + else if (t->opt->prod_type == EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR)
> > + return perf_event_crypto_producer(arg);
> > return 0;
> > }
> >
> > @@ -405,8 +526,10 @@ perf_launch_lcores(struct evt_test *test, struct
> > evt_options *opt,
> > if (remaining <= 0) {
> > t->result = EVT_TEST_SUCCESS;
> > if (opt->prod_type == EVT_PROD_TYPE_SYNT
> > ||
> > - opt->prod_type ==
> > -
> > EVT_PROD_TYPE_EVENT_TIMER_ADPTR) {
> > + opt->prod_type ==
> > +
> > EVT_PROD_TYPE_EVENT_TIMER_ADPTR ||
> > + opt->prod_type ==
> > +
> > EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR) {
> > t->done = true;
> > break;
> > }
> > @@ -415,7 +538,8 @@ perf_launch_lcores(struct evt_test *test, struct
> > evt_options *opt,
> >
> > if (new_cycles - dead_lock_cycles > dead_lock_sample &&
> > (opt->prod_type == EVT_PROD_TYPE_SYNT ||
> > - opt->prod_type ==
> > EVT_PROD_TYPE_EVENT_TIMER_ADPTR)) {
> > + opt->prod_type == EVT_PROD_TYPE_EVENT_TIMER_ADPTR
> > ||
> > + opt->prod_type ==
> > EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR)) {
> > remaining = t->outstand_pkts - processed_pkts(t);
> > if (dead_lock_remaining == remaining) {
> > rte_event_dev_dump(opt->dev_id, stdout);
> > @@ -537,6 +661,74 @@ perf_event_timer_adapter_setup(struct test_perf *t)
> > return 0;
> > }
> >
> > +static int
> > +perf_event_crypto_adapter_setup(struct test_perf *t, struct prod_data
> > +*p) {
> > + struct evt_options *opt = t->opt;
> > + uint32_t cap;
> > + int ret;
> > +
> > + ret = rte_event_crypto_adapter_caps_get(p->dev_id, p->ca.cdev_id,
> > &cap);
> > + if (ret) {
> > + evt_err("Failed to get crypto adapter capabilities");
> > + return ret;
> > + }
> > +
> > + if (((opt->crypto_adptr_mode ==
> > RTE_EVENT_CRYPTO_ADAPTER_OP_NEW) &&
> > + !(cap &
> > RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_OP_NEW)) ||
> > + ((opt->crypto_adptr_mode ==
> > RTE_EVENT_CRYPTO_ADAPTER_OP_FORWARD) &&
> > + !(cap &
> > RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_OP_FWD))) {
> > + evt_err("crypto adapter %s mode unsupported\n",
> > + opt->crypto_adptr_mode ? "OP_FORWARD" :
> > "OP_NEW");
> > + return -ENOTSUP;
> > + } else if (!(cap &
> > RTE_EVENT_CRYPTO_ADAPTER_CAP_SESSION_PRIVATE_DATA)) {
> > + evt_err("Storing crypto session not supported");
> > + return -ENOTSUP;
> > + }
> > +
> > + if (cap &
> > RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_QP_EV_BIND) {
> > + struct rte_event response_info;
> > +
> > + response_info.event = 0;
> > + response_info.sched_type = RTE_SCHED_TYPE_ATOMIC;
> > + response_info.queue_id = p->queue_id;
> > + ret = rte_event_crypto_adapter_queue_pair_add(
> > + TEST_PERF_CA_ID, p->ca.cdev_id, p->ca.cdev_qp_id,
> > + &response_info);
> > + } else {
> > + ret = rte_event_crypto_adapter_queue_pair_add(
> > + TEST_PERF_CA_ID, p->ca.cdev_id, p->ca.cdev_qp_id,
> > NULL);
> > + }
> > +
> > + return ret;
> > +}
> > +
> > +static struct rte_cryptodev_sym_session *
> > +cryptodev_sym_sess_create(struct prod_data *p, struct test_perf *t) {
> > + struct rte_crypto_sym_xform cipher_xform;
> > + struct rte_cryptodev_sym_session *sess;
> > +
> > + cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
> > + cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
> > + cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
> > + cipher_xform.next = NULL;
> > +
> > + sess = rte_cryptodev_sym_session_create(t->ca_sess_pool);
> > + if (sess == NULL) {
> > + evt_err("Failed to create sym session");
> > + return NULL;
> > + }
> > +
> > + if (rte_cryptodev_sym_session_init(p->ca.cdev_id, sess, &cipher_xform,
> > + t->ca_sess_priv_pool)) {
> > + evt_err("Failed to init session");
> > + return NULL;
> > + }
> > +
> > + return sess;
> > +}
> > +
> > int
> > perf_event_dev_port_setup(struct evt_test *test, struct evt_options *opt,
> > uint8_t stride, uint8_t nb_queues,
> > @@ -598,6 +790,73 @@ perf_event_dev_port_setup(struct evt_test *test,
> > struct evt_options *opt,
> > ret = perf_event_timer_adapter_setup(t);
> > if (ret)
> > return ret;
> > + } else if (opt->prod_type == EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR) {
> > + struct rte_event_port_conf conf = *port_conf;
> > + uint8_t cdev_id = 0;
> > + uint16_t qp_id = 0;
> > +
> > + ret = rte_event_crypto_adapter_create(TEST_PERF_CA_ID,
> > + opt->dev_id, &conf, 0);
> > + if (ret) {
> > + evt_err("Failed to create crypto adapter");
> > + return ret;
> > + }
> > +
> > + prod = 0;
> > + for (; port < perf_nb_event_ports(opt); port++) {
> > + struct rte_cryptodev_sym_session *crypto_sess;
> > + union rte_event_crypto_metadata m_data;
> > + struct prod_data *p = &t->prod[port];
> > + uint32_t flow_id;
> > +
> > + if (qp_id == rte_cryptodev_queue_pair_count(cdev_id))
> > {
> > + cdev_id++;
> > + qp_id = 0;
> > + }
> > +
> > + p->dev_id = opt->dev_id;
> > + p->port_id = port;
> > + p->queue_id = prod * stride;
> > + p->ca.cdev_id = cdev_id;
> > + p->ca.cdev_qp_id = qp_id;
> > + p->ca.crypto_sess = rte_zmalloc_socket(
> > + NULL, sizeof(crypto_sess) * t->nb_flows,
> > + RTE_CACHE_LINE_SIZE, opt->socket_id);
> > + p->t = t;
> > +
> > + m_data.request_info.cdev_id = p->ca.cdev_id;
> > + m_data.request_info.queue_pair_id = p-
> > >ca.cdev_qp_id;
> > + m_data.response_info.sched_type =
> > RTE_SCHED_TYPE_ATOMIC;
> > + m_data.response_info.queue_id = p->queue_id;
> > +
> > + for (flow_id = 0; flow_id < t->nb_flows; flow_id++) {
> > + crypto_sess = cryptodev_sym_sess_create(p, t);
> > + if (crypto_sess == NULL)
> > + return -ENOMEM;
> > +
> > + m_data.response_info.flow_id = flow_id;
> > + rte_cryptodev_sym_session_set_user_data(
> > + crypto_sess, &m_data,
> > sizeof(m_data));
> > + p->ca.crypto_sess[flow_id] = crypto_sess;
> > + }
> > +
> > + conf.event_port_cfg |=
> > + RTE_EVENT_PORT_CFG_HINT_PRODUCER |
> > + RTE_EVENT_PORT_CFG_HINT_CONSUMER;
> > +
> > + ret = rte_event_port_setup(opt->dev_id, port, &conf);
> > + if (ret) {
> > + evt_err("failed to setup port %d", port);
> > + return ret;
> > + }
> > +
> > + ret = perf_event_crypto_adapter_setup(t, p);
> > + if (ret)
> > + return ret;
> > +
> > + qp_id++;
> > + prod++;
> > + }
> > } else {
> > prod = 0;
> > for ( ; port < perf_nb_event_ports(opt); port++) { @@ -659,7
> > +918,8 @@ perf_opt_check(struct evt_options *opt, uint64_t nb_queues)
> > }
> >
> > if (opt->prod_type == EVT_PROD_TYPE_SYNT ||
> > - opt->prod_type ==
> > EVT_PROD_TYPE_EVENT_TIMER_ADPTR) {
> > + opt->prod_type == EVT_PROD_TYPE_EVENT_TIMER_ADPTR ||
> > + opt->prod_type == EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR) {
> > /* Validate producer lcores */
> > if (evt_lcores_has_overlap(opt->plcores,
> > rte_get_main_lcore())) {
> > @@ -767,8 +1027,7 @@ perf_ethdev_setup(struct evt_test *test, struct
> > evt_options *opt)
> > },
> > };
> >
> > - if (opt->prod_type == EVT_PROD_TYPE_SYNT ||
> > - opt->prod_type ==
> > EVT_PROD_TYPE_EVENT_TIMER_ADPTR)
> > + if (opt->prod_type != EVT_PROD_TYPE_ETH_RX_ADPTR)
> > return 0;
> >
> > if (!rte_eth_dev_count_avail()) {
> > @@ -841,6 +1100,162 @@ void perf_ethdev_destroy(struct evt_test *test,
> > struct evt_options *opt)
> > }
> > }
> >
> > +int
> > +perf_cryptodev_setup(struct evt_test *test, struct evt_options *opt) {
> > + uint8_t cdev_count, cdev_id, nb_plcores, nb_qps;
> > + struct test_perf *t = evt_test_priv(test);
> > + unsigned int max_session_size;
> > + uint32_t nb_sessions;
> > + int ret;
> > +
> > + if (opt->prod_type != EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR)
> > + return 0;
> > +
> > + cdev_count = rte_cryptodev_count();
> > + if (cdev_count == 0) {
> > + evt_err("No crypto devices available\n");
> > + return -ENODEV;
> > + }
> > +
> > + t->ca_op_pool = rte_crypto_op_pool_create(
> > + "crypto_op_pool", RTE_CRYPTO_OP_TYPE_SYMMETRIC, opt-
> > >pool_sz,
> > + 128, 0, rte_socket_id());
> > + if (t->ca_op_pool == NULL) {
> > + evt_err("Failed to create crypto op pool");
> > + return -ENOMEM;
> > + }
> > +
> > + nb_sessions = evt_nr_active_lcores(opt->plcores) * t->nb_flows;
> > + t->ca_sess_pool = rte_cryptodev_sym_session_pool_create(
> > + "ca_sess_pool", nb_sessions, 0, 0,
> > + sizeof(union rte_event_crypto_metadata), SOCKET_ID_ANY);
> > + if (t->ca_sess_pool == NULL) {
> > + evt_err("Failed to create sym session pool");
> > + ret = -ENOMEM;
> > + goto err;
> > + }
> > +
> > + max_session_size = 0;
> > + for (cdev_id = 0; cdev_id < cdev_count; cdev_id++) {
> > + unsigned int session_size;
> > +
> > + session_size =
> > + rte_cryptodev_sym_get_private_session_size(cdev_id);
> > + if (session_size > max_session_size)
> > + max_session_size = session_size;
> > + }
> > +
> > + max_session_size += sizeof(union rte_event_crypto_metadata);
> > + t->ca_sess_priv_pool = rte_mempool_create(
> > + "ca_sess_priv_pool", nb_sessions, max_session_size, 0, 0,
> > NULL,
> > + NULL, NULL, NULL, SOCKET_ID_ANY, 0);
> > + if (t->ca_sess_priv_pool == NULL) {
> > + evt_err("failed to create sym session private pool");
> > + ret = -ENOMEM;
> > + goto err;
> > + }
> > +
> > + /*
> > + * Calculate number of needed queue pairs, based on the amount of
> > + * available number of logical cores and crypto devices. For instance,
> > + * if there are 4 cores and 2 crypto devices, 2 queue pairs will be set
> > + * up per device.
> > + */
> > + nb_plcores = evt_nr_active_lcores(opt->plcores);
> > + nb_qps = (nb_plcores % cdev_count) ? (nb_plcores / cdev_count) + 1 :
> > + nb_plcores / cdev_count;
> > + for (cdev_id = 0; cdev_id < cdev_count; cdev_id++) {
> > + struct rte_cryptodev_qp_conf qp_conf;
> > + struct rte_cryptodev_config conf;
> > + struct rte_cryptodev_info info;
> > + int qp_id;
> > +
> > + rte_cryptodev_info_get(cdev_id, &info);
> > + if (nb_qps > info.max_nb_queue_pairs) {
> > + evt_err("Not enough queue pairs per cryptodev (%u)",
> > + nb_qps);
> > + ret = -EINVAL;
> > + goto err;
> > + }
> > +
> > + conf.nb_queue_pairs = nb_qps;
> > + conf.socket_id = SOCKET_ID_ANY;
> > + conf.ff_disable = RTE_CRYPTODEV_FF_SECURITY;
> > +
> > + ret = rte_cryptodev_configure(cdev_id, &conf);
> > + if (ret) {
> > + evt_err("Failed to configure cryptodev (%u)", cdev_id);
> > + goto err;
> > + }
> > +
> > + qp_conf.nb_descriptors = NB_CRYPTODEV_DESCRIPTORS;
> > + qp_conf.mp_session = t->ca_sess_pool;
> > + qp_conf.mp_session_private = t->ca_sess_priv_pool;
> > +
> > + for (qp_id = 0; qp_id < conf.nb_queue_pairs; qp_id++) {
> > + ret = rte_cryptodev_queue_pair_setup(
> > + cdev_id, qp_id, &qp_conf,
> > + rte_cryptodev_socket_id(cdev_id));
> > + if (ret) {
> > + evt_err("Failed to setup queue pairs on
> > cryptodev %u\n",
> > + cdev_id);
> > + goto err;
> > + }
> > + }
> > + }
> > +
> > + return 0;
> > +err:
> > + for (cdev_id = 0; cdev_id < cdev_count; cdev_id++)
> > + rte_cryptodev_close(cdev_id);
> > +
> > + rte_mempool_free(t->ca_op_pool);
> > + rte_mempool_free(t->ca_sess_pool);
> > + rte_mempool_free(t->ca_sess_priv_pool);
> > +
> > + return ret;
> > +}
> > +
> > +void
> > +perf_cryptodev_destroy(struct evt_test *test, struct evt_options *opt)
> > +{
> > + uint8_t cdev_id, cdev_count = rte_cryptodev_count();
> > + struct test_perf *t = evt_test_priv(test);
> > + uint16_t port;
> > +
> > + if (opt->prod_type != EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR)
> > + return;
> > +
> > + for (port = t->nb_workers; port < perf_nb_event_ports(opt); port++) {
> > + struct rte_cryptodev_sym_session *sess;
> > + struct prod_data *p = &t->prod[port];
> > + uint32_t flow_id;
> > + uint8_t cdev_id;
> > +
> > + for (flow_id = 0; flow_id < t->nb_flows; flow_id++) {
> > + sess = p->ca.crypto_sess[flow_id];
> > + cdev_id = p->ca.cdev_id;
> > + rte_cryptodev_sym_session_clear(cdev_id, sess);
> > + rte_cryptodev_sym_session_free(sess);
> > + }
> > +
> > + rte_event_crypto_adapter_queue_pair_del(
> > + TEST_PERF_CA_ID, p->ca.cdev_id, p->ca.cdev_qp_id);
> > + }
> > +
> > + rte_event_crypto_adapter_free(TEST_PERF_CA_ID);
> > +
> > + for (cdev_id = 0; cdev_id < cdev_count; cdev_id++) {
> > + rte_cryptodev_stop(cdev_id);
> > + rte_cryptodev_close(cdev_id);
> > + }
> > +
> > + rte_mempool_free(t->ca_op_pool);
> > + rte_mempool_free(t->ca_sess_pool);
> > + rte_mempool_free(t->ca_sess_priv_pool);
> > +}
> > +
> > int
> > perf_mempool_setup(struct evt_test *test, struct evt_options *opt) { diff --git
> > a/app/test-eventdev/test_perf_common.h b/app/test-
> > eventdev/test_perf_common.h
> > index 14dcf80429..ea0907d61a 100644
> > --- a/app/test-eventdev/test_perf_common.h
> > +++ b/app/test-eventdev/test_perf_common.h
> > @@ -9,9 +9,11 @@
> > #include <stdbool.h>
> > #include <unistd.h>
> >
> > +#include <rte_cryptodev.h>
> > #include <rte_cycles.h>
> > #include <rte_ethdev.h>
> > #include <rte_eventdev.h>
> > +#include <rte_event_crypto_adapter.h>
> > #include <rte_event_eth_rx_adapter.h>
> > #include <rte_event_timer_adapter.h>
> > #include <rte_lcore.h>
> > @@ -23,6 +25,8 @@
> > #include "evt_options.h"
> > #include "evt_test.h"
> >
> > +#define TEST_PERF_CA_ID 0
> > +
> > struct test_perf;
> >
> > struct worker_data {
> > @@ -33,14 +37,19 @@ struct worker_data {
> > struct test_perf *t;
> > } __rte_cache_aligned;
> >
> > +struct crypto_adptr_data {
> > + uint8_t cdev_id;
> > + uint16_t cdev_qp_id;
> > + struct rte_cryptodev_sym_session **crypto_sess; };
> > struct prod_data {
> > uint8_t dev_id;
> > uint8_t port_id;
> > uint8_t queue_id;
> > + struct crypto_adptr_data ca;
> > struct test_perf *t;
> > } __rte_cache_aligned;
> >
> > -
> > struct test_perf {
> > /* Don't change the offset of "done". Signal handler use this memory
> > * to terminate all lcores work.
> > @@ -58,6 +67,9 @@ struct test_perf {
> > uint8_t sched_type_list[EVT_MAX_STAGES] __rte_cache_aligned;
> > struct rte_event_timer_adapter *timer_adptr[
> > RTE_EVENT_TIMER_ADAPTER_NUM_MAX]
> > __rte_cache_aligned;
> > + struct rte_mempool *ca_op_pool;
> > + struct rte_mempool *ca_sess_pool;
> > + struct rte_mempool *ca_sess_priv_pool;
> > } __rte_cache_aligned;
> >
> > struct perf_elt {
> > @@ -81,6 +93,8 @@ struct perf_elt {
> > const uint8_t port = w->port_id;\
> > const uint8_t prod_timer_type = \
> > opt->prod_type == EVT_PROD_TYPE_EVENT_TIMER_ADPTR;\
> > + const uint8_t prod_crypto_type = \
> > + opt->prod_type == EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR;\
> > uint8_t *const sched_type_list = &t->sched_type_list[0];\
> > struct rte_mempool *const pool = t->pool;\
> > const uint8_t nb_stages = t->opt->nb_stages;\ @@ -154,6 +168,7 @@
> > int perf_test_result(struct evt_test *test, struct evt_options *opt); int
> > perf_opt_check(struct evt_options *opt, uint64_t nb_queues); int
> > perf_test_setup(struct evt_test *test, struct evt_options *opt); int
> > perf_ethdev_setup(struct evt_test *test, struct evt_options *opt);
> > +int perf_cryptodev_setup(struct evt_test *test, struct evt_options
> > +*opt);
> > int perf_mempool_setup(struct evt_test *test, struct evt_options *opt); int
> > perf_event_dev_port_setup(struct evt_test *test, struct evt_options *opt,
> > uint8_t stride, uint8_t nb_queues,
> > @@ -164,6 +179,7 @@ int perf_launch_lcores(struct evt_test *test, struct
> > evt_options *opt, void perf_opt_dump(struct evt_options *opt, uint8_t
> > nb_queues); void perf_test_destroy(struct evt_test *test, struct evt_options
> > *opt); void perf_eventdev_destroy(struct evt_test *test, struct evt_options
> > *opt);
> > +void perf_cryptodev_destroy(struct evt_test *test, struct evt_options
> > +*opt);
> > void perf_ethdev_destroy(struct evt_test *test, struct evt_options *opt); void
> > perf_mempool_destroy(struct evt_test *test, struct evt_options *opt);
> >
> > diff --git a/app/test-eventdev/test_perf_queue.c b/app/test-
> > eventdev/test_perf_queue.c
> > index f4ea3a795f..dcf6d82947 100644
> > --- a/app/test-eventdev/test_perf_queue.c
> > +++ b/app/test-eventdev/test_perf_queue.c
> > @@ -49,6 +49,23 @@ perf_queue_worker(void *arg, const int
> > enable_fwd_latency)
> > rte_pause();
> > continue;
> > }
> > +
> > + if (prod_crypto_type &&
> > + (ev.event_type == RTE_EVENT_TYPE_CRYPTODEV)) {
> > + struct rte_crypto_op *op = ev.event_ptr;
> > +
> > + if (op->status == RTE_CRYPTO_OP_STATUS_SUCCESS) {
> > + if (op->sym->m_dst == NULL)
> > + ev.event_ptr = op->sym->m_src;
> > + else
> > + ev.event_ptr = op->sym->m_dst;
> > + rte_crypto_op_free(op);
> > + } else {
> > + rte_crypto_op_free(op);
> > + continue;
> > + }
> > + }
> > +
> > if (enable_fwd_latency && !prod_timer_type)
> > /* first q in pipeline, mark timestamp to compute fwd latency
> > */
> > mark_fwd_latency(&ev, nb_stages);
> > @@ -88,6 +105,25 @@ perf_queue_worker_burst(void *arg, const int
> > enable_fwd_latency)
> > }
> >
> > for (i = 0; i < nb_rx; i++) {
> > + if (prod_crypto_type &&
> > + (ev[i].event_type == RTE_EVENT_TYPE_CRYPTODEV))
> > {
> > + struct rte_crypto_op *op = ev[i].event_ptr;
> > +
> > + if (op->status ==
> > + RTE_CRYPTO_OP_STATUS_SUCCESS) {
> > + if (op->sym->m_dst == NULL)
> > + ev[i].event_ptr =
> > + op->sym->m_src;
> > + else
> > + ev[i].event_ptr =
> > + op->sym->m_dst;
> > + rte_crypto_op_free(op);
> > + } else {
> > + rte_crypto_op_free(op);
> > + continue;
> > + }
> > + }
> > +
> > if (enable_fwd_latency && !prod_timer_type) {
> > rte_prefetch0(ev[i+1].event_ptr);
> > /* first queue in pipeline.
> > @@ -269,6 +305,18 @@ perf_queue_eventdev_setup(struct evt_test *test,
> > struct evt_options *opt)
> > return ret;
> > }
> > }
> > + } else if (opt->prod_type == EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR) {
> > + uint8_t cdev_id, cdev_count;
> > +
> > + cdev_count = rte_cryptodev_count();
> > + for (cdev_id = 0; cdev_id < cdev_count; cdev_id++) {
> > + ret = rte_cryptodev_start(cdev_id);
> > + if (ret) {
> > + evt_err("Failed to start cryptodev %u",
> > + cdev_id);
> > + return ret;
> > + }
> > + }
> > }
> >
> > return 0;
> > @@ -311,11 +359,13 @@ static const struct evt_test_ops perf_queue = {
> > .test_setup = perf_test_setup,
> > .mempool_setup = perf_mempool_setup,
> > .ethdev_setup = perf_ethdev_setup,
> > + .cryptodev_setup = perf_cryptodev_setup,
> > .eventdev_setup = perf_queue_eventdev_setup,
> > .launch_lcores = perf_queue_launch_lcores,
> > .eventdev_destroy = perf_eventdev_destroy,
> > .mempool_destroy = perf_mempool_destroy,
> > .ethdev_destroy = perf_ethdev_destroy,
> > + .cryptodev_destroy = perf_cryptodev_destroy,
> > .test_result = perf_test_result,
> > .test_destroy = perf_test_destroy,
> > };
> > diff --git a/doc/guides/rel_notes/release_22_03.rst
> > b/doc/guides/rel_notes/release_22_03.rst
> > index cbc98e798f..72052ef2dc 100644
> > --- a/doc/guides/rel_notes/release_22_03.rst
> > +++ b/doc/guides/rel_notes/release_22_03.rst
> > @@ -159,6 +159,11 @@ New Features
> > * Called ``rte_ipv4/6_udptcp_cksum_mbuf()`` functions in testpmd csum
> > mode
> > to support software UDP/TCP checksum over multiple segments.
> >
> > +* **Added crypto producer mode in test-eventdev.**
> > +
> > + * Crypto producer mode helps to measure performance of OP_NEW and
> > OP_FORWARD
> > + modes of event crypto adapter.
> > +
> >
> > Removed Items
> > -------------
> > diff --git a/doc/guides/tools/testeventdev.rst
> > b/doc/guides/tools/testeventdev.rst
> > index 48efb9ea6e..f7d813226d 100644
> > --- a/doc/guides/tools/testeventdev.rst
> > +++ b/doc/guides/tools/testeventdev.rst
> > @@ -120,6 +120,10 @@ The following are the application command-line
> > options:
> >
> > Use burst mode event timer adapter as producer.
> >
> > +* ``--prod_type_cryptodev``
> > +
> > + Use crypto device as producer.
> > +
> > * ``--timer_tick_nsec``
> >
> > Used to dictate number of nano seconds between bucket traversal of the
> > @@ -148,6 +152,11 @@ The following are the application command-line
> > options:
> > timeout is out of the supported range of event device it will be
> > adjusted to the highest/lowest supported dequeue timeout supported.
> >
> > +* ``--crypto_adptr_mode``
> > +
> > + Set crypto adapter mode. Use 0 for OP_NEW (default) and 1 for
> > + OP_FORWARD mode.
> > +
> > * ``--mbuf_sz``
> >
> > Set packet mbuf size. Can be used to configure Jumbo Frames. Only @@ -
> > 420,6 +429,7 @@ Supported application command line options are following::
> > --prod_type_ethdev
> > --prod_type_timerdev_burst
> > --prod_type_timerdev
> > + --prod_type_cryptodev
> > --prod_enq_burst_sz
> > --timer_tick_nsec
> > --max_tmo_nsec
> > @@ -427,6 +437,7 @@ Supported application command line options are
> > following::
> > --nb_timers
> > --nb_timer_adptrs
> > --deq_tmo_nsec
> > + --crypto_adptr_mode
> >
> > Example
> > ^^^^^^^
> > @@ -529,12 +540,14 @@ Supported application command line options are
> > following::
> > --prod_type_ethdev
> > --prod_type_timerdev_burst
> > --prod_type_timerdev
> > + --prod_type_cryptodev
> > --timer_tick_nsec
> > --max_tmo_nsec
> > --expiry_nsec
> > --nb_timers
> > --nb_timer_adptrs
> > --deq_tmo_nsec
> > + --crypto_adptr_mode
> >
> > Example
> > ^^^^^^^
> > --
> > 2.25.1
>
^ permalink raw reply [flat|nested] 43+ messages in thread
end of thread, other threads:[~2022-02-24 7:58 UTC | newest]
Thread overview: 43+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-20 19:53 [PATCH] app/eventdev: add crypto producer mode Shijith Thotton
2021-12-21 8:51 ` [PATCH v2] " Shijith Thotton
2021-12-30 11:56 ` Gujjar, Abhinandan S
2022-01-03 6:04 ` Shijith Thotton
2022-01-03 8:46 ` Gujjar, Abhinandan S
2022-01-03 9:14 ` Shijith Thotton
2022-01-04 15:28 ` Aaron Conole
2022-01-04 15:49 ` [EXT] " Shijith Thotton
2022-01-04 10:30 ` [PATCH v3] " Shijith Thotton
2022-01-21 12:25 ` Jerin Jacob
2022-01-23 16:56 ` Gujjar, Abhinandan S
2022-01-23 18:44 ` Gujjar, Abhinandan S
2022-01-24 6:09 ` Shijith Thotton
2022-01-24 6:59 ` Shijith Thotton
2022-01-25 14:15 ` Gujjar, Abhinandan S
2022-01-25 13:39 ` Gujjar, Abhinandan S
2022-02-08 17:00 ` Shijith Thotton
2022-02-14 15:26 ` Jerin Jacob
2022-02-14 15:31 ` Gujjar, Abhinandan S
2022-02-08 16:33 ` [PATCH v4] " Shijith Thotton
2022-02-15 6:03 ` Gujjar, Abhinandan S
2022-02-15 16:08 ` Shijith Thotton
2022-02-15 16:46 ` Gujjar, Abhinandan S
2022-02-15 16:56 ` [PATCH v5] " Shijith Thotton
2022-02-16 4:47 ` Gujjar, Abhinandan S
2022-02-16 7:08 ` Shijith Thotton
2022-02-16 7:49 ` Gujjar, Abhinandan S
2022-02-16 8:44 ` Jerin Jacob
2022-02-16 8:54 ` Jerin Jacob
2022-02-17 5:33 ` Gujjar, Abhinandan S
2022-02-21 13:10 ` Van Haaren, Harry
2022-02-22 7:03 ` Shijith Thotton
2022-02-23 9:02 ` Gujjar, Abhinandan S
2022-02-23 10:02 ` Shijith Thotton
2022-02-23 10:13 ` Van Haaren, Harry
2022-02-23 16:33 ` Gujjar, Abhinandan S
2022-02-23 17:02 ` Shijith Thotton
2022-02-17 6:56 ` [EXT] " Akhil Goyal
2022-02-18 12:00 ` Shijith Thotton
2022-02-18 12:11 ` [PATCH v6] " Shijith Thotton
2022-02-24 4:46 ` [PATCH v7] " Shijith Thotton
2022-02-24 6:18 ` Gujjar, Abhinandan S
2022-02-24 7:58 ` Jerin Jacob
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).