diff mbox series

[RFC] app/eventdev: add software crypto adapter support

Message ID 0677cbafa5145f1b9f64dd007594e033f2d9ab8a.1644337310.git.sthotton@marvell.com (mailing list archive)
State RFC
Delegated to: Jerin Jacob
Headers show
Series [RFC] app/eventdev: add software crypto adapter support | expand

Checks

Context Check Description
ci/Intel-compilation warning apply issues
ci/checkpatch success coding style OK

Commit Message

Shijith Thotton Feb. 8, 2022, 4:33 p.m. UTC
Added addition crypto adapter API calls and enabled services to use
software implementation of crypto adapter.

Signed-off-by: Shijith Thotton <sthotton@marvell.com>
---
 app/test-eventdev/test_perf_atq.c    | 16 +++++++++-
 app/test-eventdev/test_perf_common.c | 48 ++++++++++++++++++++++++----
 app/test-eventdev/test_perf_common.h |  1 +
 app/test-eventdev/test_perf_queue.c  | 16 +++++++++-
 4 files changed, 72 insertions(+), 9 deletions(-)
diff mbox series

Patch

diff --git a/app/test-eventdev/test_perf_atq.c b/app/test-eventdev/test_perf_atq.c
index 67ff681666..b9c22effd6 100644
--- a/app/test-eventdev/test_perf_atq.c
+++ b/app/test-eventdev/test_perf_atq.c
@@ -301,9 +301,23 @@  perf_atq_eventdev_setup(struct evt_test *test, struct evt_options *opt)
 				return ret;
 			}
 		}
+
+		if (t->ca_sw_cap) {
+			uint32_t service_id;
+
+			rte_event_crypto_adapter_service_id_get(TEST_PERF_CA_ID,
+								&service_id);
+			ret = evt_service_setup(service_id);
+			if (ret) {
+				evt_err("Failed to setup crypto adapter service");
+				return ret;
+			}
+
+			ret = rte_event_crypto_adapter_start(TEST_PERF_CA_ID);
+		}
 	}
 
-	return 0;
+	return ret;
 }
 
 static void
diff --git a/app/test-eventdev/test_perf_common.c b/app/test-eventdev/test_perf_common.c
index ca83e41555..dc644692eb 100644
--- a/app/test-eventdev/test_perf_common.c
+++ b/app/test-eventdev/test_perf_common.c
@@ -4,6 +4,8 @@ 
 
 #include <math.h>
 
+#include <eventdev_pmd.h>
+
 #include "test_perf_common.h"
 
 #define NB_CRYPTODEV_DESCRIPTORS 128
@@ -336,10 +338,10 @@  crypto_adapter_enq_op_fwd(struct prod_data *p)
 	struct rte_crypto_sym_op *sym_op;
 	uint32_t flow_counter = 0;
 	struct rte_crypto_op *op;
+	uint16_t len, nb_events;
 	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",
@@ -369,9 +371,16 @@  crypto_adapter_enq_op_fwd(struct prod_data *p)
 			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)
+		do {
+			if (t->ca_sw_cap)
+				nb_events = rte_event_enqueue_burst(
+					dev_id, port, &ev, 1);
+			else
+				nb_events = rte_event_crypto_adapter_enqueue(
+					dev_id, port, &ev, 1);
+
 			rte_pause();
+		} while (nb_events != 1 && t->done == false);
 
 		count++;
 	}
@@ -674,10 +683,16 @@  perf_event_crypto_adapter_setup(struct test_perf *t, struct prod_data *p)
 		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))) {
+	if (cap == RTE_EVENT_CRYPTO_ADAPTER_SW_CAP) {
+		t->ca_sw_cap = 1;
+	} else 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;
@@ -706,6 +721,22 @@  perf_event_crypto_adapter_setup(struct test_perf *t, struct prod_data *p)
 			TEST_PERF_CA_ID, p->ca.cdev_id, p->ca.cdev_qp_id, NULL);
 	}
 
+	if (ret)
+		return ret;
+
+	if (t->ca_sw_cap) {
+		uint8_t sw_event_port;
+		uint32_t service_id;
+
+		rte_event_crypto_adapter_event_port_get(TEST_PERF_CA_ID,
+							&sw_event_port);
+		rte_event_port_link(p->dev_id, sw_event_port, &p->queue_id,
+				    NULL, 1);
+
+		rte_event_dev_service_id_get(p->dev_id, &service_id);
+		ret = evt_service_setup(service_id);
+	}
+
 	return ret;
 }
 
@@ -1239,6 +1270,9 @@  perf_cryptodev_destroy(struct evt_test *test, struct evt_options *opt)
 	if (opt->prod_type != EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR)
 		return;
 
+	if (t->ca_sw_cap)
+		rte_event_crypto_adapter_stop(TEST_PERF_CA_ID);
+
 	for (port = t->nb_workers; port < perf_nb_event_ports(opt); port++) {
 		struct prod_data *p = &t->prod[port];
 
diff --git a/app/test-eventdev/test_perf_common.h b/app/test-eventdev/test_perf_common.h
index ea0907d61a..c3402696fc 100644
--- a/app/test-eventdev/test_perf_common.h
+++ b/app/test-eventdev/test_perf_common.h
@@ -67,6 +67,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;
+	uint8_t ca_sw_cap;
 	struct rte_mempool *ca_op_pool;
 	struct rte_mempool *ca_sess_pool;
 	struct rte_mempool *ca_sess_priv_pool;
diff --git a/app/test-eventdev/test_perf_queue.c b/app/test-eventdev/test_perf_queue.c
index dcf6d82947..a2158c65da 100644
--- a/app/test-eventdev/test_perf_queue.c
+++ b/app/test-eventdev/test_perf_queue.c
@@ -317,9 +317,23 @@  perf_queue_eventdev_setup(struct evt_test *test, struct evt_options *opt)
 				return ret;
 			}
 		}
+
+		if (t->ca_sw_cap) {
+			uint32_t service_id;
+
+			rte_event_crypto_adapter_service_id_get(TEST_PERF_CA_ID,
+								&service_id);
+			ret = evt_service_setup(service_id);
+			if (ret) {
+				evt_err("Failed to setup crypto adapter service");
+				return ret;
+			}
+
+			ret = rte_event_crypto_adapter_start(TEST_PERF_CA_ID);
+		}
 	}
 
-	return 0;
+	return ret;
 }
 
 static void