Replace checking input option for every asymmetric test case by
a function.

Signed-off-by: Gowrishankar Muthukrishnan <gmuthukri...@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(-)

diff --git a/app/test-crypto-perf/cperf_test_common.c 
b/app/test-crypto-perf/cperf_test_common.c
index 6b8ab65731..0f1f0b72c1 100644
--- a/app/test-crypto-perf/cperf_test_common.c
+++ b/app/test-crypto-perf/cperf_test_common.c
@@ -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;
+}
diff --git a/app/test-crypto-perf/cperf_test_common.h 
b/app/test-crypto-perf/cperf_test_common.h
index a603a607d5..2d1f69aaa2 100644
--- a/app/test-crypto-perf/cperf_test_common.h
+++ b/app/test-crypto-perf/cperf_test_common.h
@@ -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_ */
diff --git a/app/test-crypto-perf/cperf_test_latency.c 
b/app/test-crypto-perf/cperf_test_latency.c
index 376847e761..201815b469 100644
--- a/app/test-crypto-perf/cperf_test_latency.c
+++ b/app/test-crypto-perf/cperf_test_latency.c
@@ -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);
 
diff --git a/app/test-crypto-perf/cperf_test_throughput.c 
b/app/test-crypto-perf/cperf_test_throughput.c
index c0891e7c99..7112b95529 100644
--- a/app/test-crypto-perf/cperf_test_throughput.c
+++ b/app/test-crypto-perf/cperf_test_throughput.c
@@ -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
diff --git a/app/test-crypto-perf/cperf_test_verify.c 
b/app/test-crypto-perf/cperf_test_verify.c
index 222c7a1cd8..91429841ca 100644
--- a/app/test-crypto-perf/cperf_test_verify.c
+++ b/app/test-crypto-perf/cperf_test_verify.c
@@ -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 ||
diff --git a/app/test-crypto-perf/main.c b/app/test-crypto-perf/main.c
index 40c0b4b54f..780f22f399 100644
--- a/app/test-crypto-perf/main.c
+++ b/app/test-crypto-perf/main.c
@@ -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) {
-- 
2.25.1

Reply via email to