[21/21] test/security: add out of place sgl test case for TLS 1.2

Message ID 20240305072213.283205-22-asasidharan@marvell.com (mailing list archive)
State Superseded, archived
Delegated to: akhil goyal
Headers
Series Improvements and new test cases |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/loongarch-compilation success Compilation OK
ci/loongarch-unit-testing success Unit Testing PASS
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS
ci/intel-Functional success Functional PASS
ci/github-robot: build success github build: passed
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-abi-testing success Testing PASS
ci/iol-compile-amd64-testing success Testing PASS
ci/iol-compile-arm64-testing success Testing PASS
ci/iol-unit-arm64-testing warning Testing issues
ci/iol-unit-amd64-testing success Testing PASS
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-broadcom-Functional success Functional Testing PASS
ci/iol-sample-apps-testing success Testing PASS

Commit Message

Aakash Sasidharan March 5, 2024, 7:22 a.m. UTC
  Add TLS 1.2 out-of-place multi-segmented packet test.

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

Comments

Akhil Goyal March 8, 2024, 1:35 p.m. UTC | #1
Recheck-request: iol-unit-arm64-testing

> Subject: [PATCH 21/21] test/security: add out of place sgl test case for TLS 1.2
> 
> Add TLS 1.2 out-of-place multi-segmented packet test.
> 
> Signed-off-by: Aakash Sasidharan <asasidharan@marvell.com>
  

Patch

diff --git a/app/test/test_cryptodev.c b/app/test/test_cryptodev.c
index 2e564489e9..92500f59ca 100644
--- a/app/test/test_cryptodev.c
+++ b/app/test/test_cryptodev.c
@@ -11873,6 +11873,11 @@  test_tls_record_proto_process(const struct tls_record_test_data td[],
 		ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool, td[i].input_text.len,
 				nb_segs, 0);
 		pktmbuf_write(ut_params->ibuf, 0, td[i].input_text.len, td[i].input_text.data);
+		if (flags->out_of_place)
+			ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
+					td[i].output_text.len, nb_segs, 0);
+		else
+			ut_params->obuf = NULL;
 
 		/* Generate crypto op data structure */
 		ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
@@ -11888,7 +11893,7 @@  test_tls_record_proto_process(const struct tls_record_test_data td[],
 
 		/* Set crypto operation mbufs */
 		ut_params->op->sym->m_src = ut_params->ibuf;
-		ut_params->op->sym->m_dst = NULL;
+		ut_params->op->sym->m_dst = ut_params->obuf;
 		ut_params->op->param1.tls_record.content_type = td[i].app_type;
 
 		if (flags->opt_padding)
@@ -11920,7 +11925,10 @@  test_tls_record_proto_process(const struct tls_record_test_data td[],
 			res_d_tmp = &res_d[i];
 
 		if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS) {
-			ret = test_tls_record_post_process(ut_params->ibuf, &td[i], res_d_tmp,
+			struct rte_mbuf *buf = flags->out_of_place ? ut_params->obuf :
+						ut_params->ibuf;
+
+			ret = test_tls_record_post_process(buf, &td[i], res_d_tmp,
 							   silent, flags);
 			if (ret != TEST_SUCCESS)
 				goto crypto_op_free;
@@ -11929,6 +11937,11 @@  test_tls_record_proto_process(const struct tls_record_test_data td[],
 		rte_crypto_op_free(ut_params->op);
 		ut_params->op = NULL;
 
+		if (flags->out_of_place) {
+			rte_pktmbuf_free(ut_params->obuf);
+			ut_params->obuf = NULL;
+		}
+
 		rte_pktmbuf_free(ut_params->ibuf);
 		ut_params->ibuf = NULL;
 	}
@@ -11937,6 +11950,11 @@  test_tls_record_proto_process(const struct tls_record_test_data td[],
 	rte_crypto_op_free(ut_params->op);
 	ut_params->op = NULL;
 
+	if (flags->out_of_place) {
+		rte_pktmbuf_free(ut_params->obuf);
+		ut_params->obuf = NULL;
+	}
+
 	rte_pktmbuf_free(ut_params->ibuf);
 	ut_params->ibuf = NULL;
 
@@ -12127,6 +12145,32 @@  test_tls_record_proto_sgl_data_walkthrough(enum rte_security_tls_version tls_ver
 	return test_tls_record_proto_all(&flags);
 }
 
+static int
+test_tls_record_proto_sgl_oop(enum rte_security_tls_version tls_version)
+{
+	struct tls_record_test_flags flags = {
+		.nb_segs_in_mbuf = 5,
+		.out_of_place = true,
+		.tls_version = tls_version
+	};
+	struct crypto_testsuite_params *ts_params = &testsuite_params;
+	struct rte_cryptodev_info dev_info;
+
+	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
+	if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
+		printf("Device doesn't support in-place scatter-gather. Test Skipped.\n");
+		return TEST_SKIPPED;
+	}
+
+	return test_tls_record_proto_all(&flags);
+}
+
+static int
+test_tls_1_2_record_proto_sgl_oop(void)
+{
+	return test_tls_record_proto_sgl_oop(RTE_SECURITY_VERSION_TLS_1_2);
+}
+
 static int
 test_tls_1_2_record_proto_sgl_data_walkthrough(void)
 {
@@ -17657,6 +17701,10 @@  static struct unit_test_suite tls12_record_proto_testsuite  = {
 			"Multi-segmented mode data walkthrough",
 			ut_setup_security, ut_teardown,
 			test_tls_1_2_record_proto_sgl_data_walkthrough),
+		TEST_CASE_NAMED_ST(
+			"Multi-segmented mode out of place",
+			ut_setup_security, ut_teardown,
+			test_tls_1_2_record_proto_sgl_oop),
 		TEST_CASE_NAMED_ST(
 			"TLS packet header corruption",
 			ut_setup_security, ut_teardown,
diff --git a/app/test/test_cryptodev_security_tls_record.h b/app/test/test_cryptodev_security_tls_record.h
index 385064157a..076568dbf2 100644
--- a/app/test/test_cryptodev_security_tls_record.h
+++ b/app/test/test_cryptodev_security_tls_record.h
@@ -98,6 +98,7 @@  struct tls_record_test_flags {
 	bool pkt_corruption;
 	bool zero_len;
 	bool padding_corruption;
+	bool out_of_place;
 	uint8_t nb_segs_in_mbuf;
 	uint8_t opt_padding;
 	enum rte_security_tls_version tls_version;