Replace checking input option for every asymmetric test case by
a function.
Signed-off-by: Gowrishankar Muthukrishnan <gmuthukrishn@marvell.com>
---
v2:
- cperf_is_asym_test is fixed to check only modex in this patch.
---
app/test-crypto-perf/cperf_test_common.c | 11 ++++++++++-
app/test-crypto-perf/cperf_test_common.h | 2 ++
app/test-crypto-perf/cperf_test_latency.c | 7 ++++---
app/test-crypto-perf/cperf_test_throughput.c | 2 +-
app/test-crypto-perf/cperf_test_verify.c | 2 +-
app/test-crypto-perf/main.c | 8 ++++----
6 files changed, 22 insertions(+), 10 deletions(-)
@@ -152,7 +152,7 @@ cperf_alloc_common_memory(const struct cperf_options *options,
uint16_t crypto_op_size = sizeof(struct rte_crypto_op);
uint16_t crypto_op_private_size;
- if (options->op_type == CPERF_ASYM_MODEX) {
+ if (cperf_is_asym_test(options)) {
crypto_op_size += sizeof(struct rte_crypto_asym_op);
snprintf(pool_name, RTE_MEMPOOL_NAMESIZE, "perf_asym_op_pool%u",
rte_socket_id());
@@ -301,3 +301,12 @@ cperf_mbuf_set(struct rte_mbuf *mbuf,
mbuf = mbuf->next;
}
}
+
+bool
+cperf_is_asym_test(const struct cperf_options *options)
+{
+ if (options->op_type == CPERF_ASYM_MODEX)
+ return true;
+
+ return false;
+}
@@ -26,4 +26,6 @@ cperf_mbuf_set(struct rte_mbuf *mbuf,
const struct cperf_options *options,
const struct cperf_test_vector *test_vector);
+bool
+cperf_is_asym_test(const struct cperf_options *options);
#endif /* _CPERF_TEST_COMMON_H_ */
@@ -47,7 +47,7 @@ cperf_latency_test_free(struct cperf_latency_ctx *ctx)
return;
if (ctx->sess != NULL) {
- if (ctx->options->op_type == CPERF_ASYM_MODEX)
+ if (cperf_is_asym_test(ctx->options))
rte_cryptodev_asym_session_free(ctx->dev_id, ctx->sess);
#ifdef RTE_LIB_SECURITY
else if (ctx->options->op_type == CPERF_PDCP ||
@@ -217,8 +217,9 @@ cperf_latency_test_runner(void *arg)
&imix_idx, &tsc_start);
/* Populate the mbuf with the test vector */
- for (i = 0; i < burst_size; i++)
- cperf_mbuf_set(ops[i]->sym->m_src,
+ if (!cperf_is_asym_test(ctx->options))
+ for (i = 0; i < burst_size; i++)
+ cperf_mbuf_set(ops[i]->sym->m_src,
ctx->options,
ctx->test_vector);
@@ -37,7 +37,7 @@ cperf_throughput_test_free(struct cperf_throughput_ctx *ctx)
if (!ctx)
return;
if (ctx->sess) {
- if (ctx->options->op_type == CPERF_ASYM_MODEX)
+ if (cperf_is_asym_test(ctx->options))
rte_cryptodev_asym_session_free(ctx->dev_id,
(void *)ctx->sess);
#ifdef RTE_LIB_SECURITY
@@ -42,7 +42,7 @@ cperf_verify_test_free(struct cperf_verify_ctx *ctx)
return;
if (ctx->sess != NULL) {
- if (ctx->options->op_type == CPERF_ASYM_MODEX)
+ if (cperf_is_asym_test(ctx->options))
rte_cryptodev_asym_session_free(ctx->dev_id, ctx->sess);
#ifdef RTE_LIB_SECURITY
else if (ctx->options->op_type == CPERF_PDCP ||
@@ -18,6 +18,7 @@
#include "cperf.h"
#include "cperf_options.h"
#include "cperf_test_vector_parsing.h"
+#include "cperf_test_common.h"
#include "cperf_test_throughput.h"
#include "cperf_test_latency.h"
#include "cperf_test_verify.h"
@@ -203,7 +204,7 @@ cperf_initialize_cryptodev(struct cperf_options *opts, uint8_t *enabled_cdevs)
rte_cryptodev_info_get(cdev_id, &cdev_info);
- if (opts->op_type == CPERF_ASYM_MODEX) {
+ if (cperf_is_asym_test(opts)) {
if ((cdev_info.feature_flags &
RTE_CRYPTODEV_FF_ASYMMETRIC_CRYPTO) == 0)
continue;
@@ -289,7 +290,7 @@ cperf_initialize_cryptodev(struct cperf_options *opts, uint8_t *enabled_cdevs)
return -ENOTSUP;
}
- if (opts->op_type == CPERF_ASYM_MODEX)
+ if (cperf_is_asym_test(opts))
ret = create_asym_op_pool_socket(socket_id,
sessions_needed);
else
@@ -300,9 +301,8 @@ cperf_initialize_cryptodev(struct cperf_options *opts, uint8_t *enabled_cdevs)
qp_conf.mp_session = session_pool_socket[socket_id].sess_mp;
- if (opts->op_type == CPERF_ASYM_MODEX) {
+ if (cperf_is_asym_test(opts))
qp_conf.mp_session = NULL;
- }
ret = rte_cryptodev_configure(cdev_id, &conf);
if (ret < 0) {