Existing data walkthrough test creates a new session
per each test packet size. Enhance the test to use single
session instead.

Signed-off-by: Aakash Sasidharan <asasidha...@marvell.com>
---
 app/test/test_cryptodev.c                     | 49 +++++++++++++++++--
 app/test/test_cryptodev_security_tls_record.h |  1 +
 2 files changed, 45 insertions(+), 5 deletions(-)

diff --git a/app/test/test_cryptodev.c b/app/test/test_cryptodev.c
index e6ef5a13e0..75f98b6744 100644
--- a/app/test/test_cryptodev.c
+++ b/app/test/test_cryptodev.c
@@ -11968,9 +11968,12 @@ test_tls_record_proto_process(const struct 
tls_record_test_data td[],
                }
        }
 
-       /* Create security session */
-       ut_params->sec_session = rte_security_session_create(ctx, &sess_conf,
-                                       ts_params->session_mpool);
+       if (ut_params->sec_session == NULL) {
+               /* Create security session */
+               ut_params->sec_session = rte_security_session_create(ctx, 
&sess_conf,
+                               ts_params->session_mpool);
+       }
+
        if (ut_params->sec_session == NULL)
                return TEST_SKIPPED;
 
@@ -12075,9 +12078,10 @@ test_tls_record_proto_process(const struct 
tls_record_test_data td[],
        rte_pktmbuf_free(ut_params->ibuf);
        ut_params->ibuf = NULL;
 
-       if (ut_params->sec_session)
+       if (ut_params->sec_session != NULL && !flags->skip_sess_destroy) {
                rte_security_session_destroy(ctx, ut_params->sec_session);
-       ut_params->sec_session = NULL;
+               ut_params->sec_session = NULL;
+       }
 
        RTE_SET_USED(flags);
 
@@ -12121,8 +12125,11 @@ static int
 test_tls_record_proto_all(const struct tls_record_test_flags *flags)
 {
        unsigned int i, nb_pkts = 1, pass_cnt = 0, payload_len, max_payload_len;
+       struct crypto_unittest_params *ut_params = &unittest_params;
        struct tls_record_test_data td_outb[TEST_SEC_PKTS_MAX];
        struct tls_record_test_data td_inb[TEST_SEC_PKTS_MAX];
+       void *sec_session_outb = NULL;
+       void *sec_session_inb = NULL;
        int ret;
 
        switch (flags->tls_version) {
@@ -12152,10 +12159,16 @@ test_tls_record_proto_all(const struct 
tls_record_test_flags *flags)
                if (ret == TEST_SKIPPED)
                        continue;
 
+               if (flags->skip_sess_destroy)
+                       ut_params->sec_session = sec_session_outb;
+
                ret = test_tls_record_proto_process(td_outb, td_inb, nb_pkts, 
true, flags);
                if (ret == TEST_SKIPPED)
                        continue;
 
+               if (flags->skip_sess_destroy && sec_session_outb == NULL)
+                       sec_session_outb = ut_params->sec_session;
+
                if (flags->zero_len &&
                    ((flags->content_type == 
TLS_RECORD_TEST_CONTENT_TYPE_HANDSHAKE) ||
                    (flags->content_type == 
TLS_RECORD_TEST_CONTENT_TYPE_HANDSHAKE) ||
@@ -12169,10 +12182,16 @@ test_tls_record_proto_all(const struct 
tls_record_test_flags *flags)
 
                test_tls_record_td_update(td_inb, td_outb, nb_pkts, flags);
 
+               if (flags->skip_sess_destroy)
+                       ut_params->sec_session = sec_session_inb;
+
                ret = test_tls_record_proto_process(td_inb, NULL, nb_pkts, 
true, flags);
                if (ret == TEST_SKIPPED)
                        continue;
 
+               if (flags->skip_sess_destroy && sec_session_inb == NULL)
+                       sec_session_inb = ut_params->sec_session;
+
                if (flags->pkt_corruption || flags->padding_corruption) {
                        if (ret == TEST_SUCCESS)
                                return TEST_FAILED;
@@ -12188,6 +12207,22 @@ test_tls_record_proto_all(const struct 
tls_record_test_flags *flags)
                if (flags->display_alg)
                        test_sec_alg_display(sec_alg_list[i].param1, 
sec_alg_list[i].param2);
 
+               if (flags->skip_sess_destroy) {
+                       uint8_t dev_id = testsuite_params.valid_devs[0];
+                       struct rte_security_ctx *ctx;
+
+                       ctx = rte_cryptodev_get_sec_ctx(dev_id);
+                       if (sec_session_inb != NULL) {
+                               rte_security_session_destroy(ctx, 
sec_session_inb);
+                               sec_session_inb = NULL;
+                       }
+                       if (sec_session_outb != NULL) {
+                               rte_security_session_destroy(ctx, 
sec_session_outb);
+                               sec_session_outb = NULL;
+                       }
+                       ut_params->sec_session = NULL;
+               }
+
                pass_cnt++;
        }
 
@@ -12205,6 +12240,7 @@ test_tls_1_2_record_proto_data_walkthrough(void)
        memset(&flags, 0, sizeof(flags));
 
        flags.data_walkthrough = true;
+       flags.skip_sess_destroy = true;
        flags.tls_version = RTE_SECURITY_VERSION_TLS_1_2;
 
        return test_tls_record_proto_all(&flags);
@@ -12254,6 +12290,7 @@ test_tls_record_proto_sgl_data_walkthrough(enum 
rte_security_tls_version tls_ver
        struct tls_record_test_flags flags = {
                .nb_segs_in_mbuf = 5,
                .tls_version = tls_version,
+               .skip_sess_destroy = true,
                .data_walkthrough = true
        };
        struct crypto_testsuite_params *ts_params = &testsuite_params;
@@ -12430,6 +12467,7 @@ test_dtls_1_2_record_proto_data_walkthrough(void)
        memset(&flags, 0, sizeof(flags));
 
        flags.data_walkthrough = true;
+       flags.skip_sess_destroy = true;
        flags.tls_version = RTE_SECURITY_VERSION_DTLS_1_2;
 
        return test_tls_record_proto_all(&flags);
@@ -12804,6 +12842,7 @@ test_tls_1_3_record_proto_data_walkthrough(void)
        memset(&flags, 0, sizeof(flags));
 
        flags.data_walkthrough = true;
+       flags.skip_sess_destroy = true;
        flags.tls_version = RTE_SECURITY_VERSION_TLS_1_3;
 
        return test_tls_record_proto_all(&flags);
diff --git a/app/test/test_cryptodev_security_tls_record.h 
b/app/test/test_cryptodev_security_tls_record.h
index acb7f15f1c..e4a291c153 100644
--- a/app/test/test_cryptodev_security_tls_record.h
+++ b/app/test/test_cryptodev_security_tls_record.h
@@ -100,6 +100,7 @@ struct tls_record_test_flags {
        bool zero_len;
        bool padding_corruption;
        bool out_of_place;
+       bool skip_sess_destroy;
        uint8_t nb_segs_in_mbuf;
        uint8_t opt_padding;
        enum rte_security_tls_version tls_version;
-- 
2.25.1

Reply via email to