Skip to contentSkip to conversation

test/crypto: update CN20K and sessionless coverage

PATCH New Tejasree Kondoj 1 participant 5 messages Jun 16

lore
Share & tools
lore
#0 lore raw

cover test/crypto: update CN20K and sessionless coverage

Add CN20K sym/asym autotests, asymmetric sessionless test and Rx-inject multi-segment unit test.

Vidya Sagar Velumuri (4):
test/crypto: add asymmetric sessionless test case test/crypto: add asym autotest support for cn20k test/crypto: add autotest support for cn20k test/crypto: add unit test for Rx inject multi seg

 app/test/test.h                |   4 ++
 app/test/test_cryptodev.c      |  42 +++++++++++-
 app/test/test_cryptodev.h      |   1 +
 app/test/test_cryptodev_asym.c | 113 +++++++++++++++++++++++++++++++--
 4 files changed, 160 insertions(+), 31 deletions(-)
Signature · 1 line
2.34.1
#1 lore raw

PATCH 1/4 test/crypto: add asymmetric sessionless test case

From: Vidya Sagar Velumuri <[email protected]>

Add test for sessionless asymmetric operation

---
 app/test/test_cryptodev_asym.c | 106 +++++++++++++++++++++++++++++++--
 1 file changed, 100 insertions(+), 6 deletions(-)
app/test/test_cryptodev_asym.c +100 -6
index bf1a1fc417..e7cc5a79e2 100644
@@ -558,6 +558,13 @@ testsuite_setup(void)
 			"Failed to configure cryptodev %u with %u qps",
 			dev_id, ts_params->conf.nb_queue_pairs);
 
+	ts_params->session_mpool = rte_cryptodev_asym_session_pool_create(
+			"test_asym_sess_mp", TEST_NUM_SESSIONS, 0, 0,
+			SOCKET_ID_ANY);
+
+	TEST_ASSERT_NOT_NULL(ts_params->session_mpool,
+			"session mempool allocation failed");
+
 	/* configure qp */
 	ts_params->qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT;
 	ts_params->qp_conf.mp_session = ts_params->session_mpool;
@@ -569,12 +576,6 @@ testsuite_setup(void)
 			qp_id, dev_id);
 	}
 
-	ts_params->session_mpool = rte_cryptodev_asym_session_pool_create(
-			"test_asym_sess_mp", TEST_NUM_SESSIONS, 0, 0,
-			SOCKET_ID_ANY);
-
-	TEST_ASSERT_NOT_NULL(ts_params->session_mpool,
-			"session mempool allocation failed");
 	/* >8 End of device, op pool and session configuration for asymmetric crypto section. */
 	return TEST_SUCCESS;
 }
@@ -1181,6 +1182,98 @@ test_mod_inv(void)
 	return status;
 }
 
+static int
+test_mod_exp_sessionless(void)
+{
+	struct crypto_testsuite_params_asym *ts_params = &testsuite_params;
+	const struct rte_cryptodev_asymmetric_xform_capability *capability;
+	struct rte_mempool *op_mpool = ts_params->op_mpool;
+	struct rte_crypto_op *op = NULL, *result_op = NULL;
+	struct rte_cryptodev_asym_capability_idx cap_idx;
+	uint8_t dev_id = ts_params->valid_devs[0];
+	struct rte_crypto_asym_op *asym_op = NULL;
+	uint8_t result[sizeof(mod_p)] = { 0 };
+	uint8_t input[TEST_DATA_SIZE] = {0};
+	struct rte_cryptodev_info info;
+	int status = TEST_SUCCESS;
+	int ret = 0;
+
+	rte_cryptodev_info_get(dev_id, &info);
+	if (!(info.feature_flags & RTE_CRYPTODEV_FF_ASYM_SESSIONLESS))
+		return TEST_SKIPPED;
+
+	if (rte_cryptodev_asym_get_xform_enum(&modex_xform.xform_type, "modexp") < 0) {
+		RTE_LOG(ERR, USER1, "Invalid ASYM algorithm specified\n");
+		return -1;
+	}
+
+	/* check for modlen capability */
+	cap_idx.type = modex_xform.xform_type;
+	capability = rte_cryptodev_asym_capability_get(dev_id, &cap_idx);
+
+	if (capability == NULL) {
+		RTE_LOG(INFO, USER1, "Device doesn't support MOD EXP. Test Skipped\n");
+		return TEST_SKIPPED;
+	}
+
+	if (rte_cryptodev_asym_xform_capability_check_modlen(capability,
+							     modex_xform.modex.modulus.length)) {
+		RTE_LOG(ERR, USER1, "Unsupported MODULUS length specified\n");
+		return TEST_SKIPPED;
+	}
+
+	/* Create op and process packets. */
+	op = rte_crypto_op_alloc(op_mpool, RTE_CRYPTO_OP_TYPE_ASYMMETRIC);
+	if (!op) {
+		RTE_LOG(ERR, USER1, "line %u FAILED: %s", __LINE__,
+			"Failed to allocate asymmetric crypto operation struct");
+		return TEST_FAILED;
+	}
+
+	asym_op = op->asym;
+	memcpy(input, base, sizeof(base));
+	asym_op->modex.base.data = input;
+	asym_op->modex.base.length = sizeof(base);
+	asym_op->modex.result.data = result;
+	asym_op->modex.result.length = sizeof(result);
+	asym_op->xform = &modex_xform;
+	op->sess_type = RTE_CRYPTO_OP_SESSIONLESS;
+
+	RTE_LOG(DEBUG, USER1, "Process ASYM operation");
+	/* Process crypto operation */
+	if (rte_cryptodev_enqueue_burst(dev_id, 0, &op, 1) != 1) {
+		RTE_LOG(ERR, USER1,
+				"line %u FAILED: %s",
+				__LINE__, "Error sending packet for operation");
+		status = TEST_FAILED;
+		goto error_exit;
+	}
+
+	while (rte_cryptodev_dequeue_burst(dev_id, 0, &result_op, 1) == 0)
+		rte_pause();
+
+	if (result_op == NULL) {
+		RTE_LOG(ERR, USER1,
+				"line %u FAILED: %s",
+				__LINE__, "Failed to process asym crypto op");
+		status = TEST_FAILED;
+		goto error_exit;
+	}
+
+	ret = verify_modexp(mod_exp, result_op);
+	if (ret) {
+		RTE_LOG(ERR, USER1,  "operation verification failed\n");
+		status = TEST_FAILED;
+	}
+
+error_exit:
+	rte_crypto_op_free(op);
+
+	TEST_ASSERT_EQUAL(status, 0, "Test failed");
+
+	return status;
+}
+
 static int
 test_mod_exp(void)
 {
@@ -5309,6 +5402,7 @@ static struct unit_test_suite cryptodev_asym_mod_ex_testsuite = {
 			"Modular Exponentiation (mod=128, base=20, exp=3, res=128)",
 			ut_setup_asym, ut_teardown_asym,
 			modular_exponentiation, &modex_test_case_m128_b20_e3),
+		TEST_CASE_ST(ut_setup_asym, ut_teardown_asym, test_mod_exp_sessionless),
 		TEST_CASES_END()
 	}
 };
Signature · 1 line
2.34.1
#2 lore raw

PATCH 2/4 test/crypto: add asym autotest support for cn20k

In reply to Tejasree Kondoj

From: Vidya Sagar Velumuri <[email protected]>

Add crypto asym autotest support for cn20k

---
 app/test/test_cryptodev_asym.c | 7 +++++++
 1 file changed, 7 insertions(+)
app/test/test_cryptodev_asym.c +7 -0
index e7cc5a79e2..48637ef247 100644
@@ -5583,6 +5583,12 @@ test_cryptodev_cn10k_asym(void)
 	return run_cryptodev_asym_testsuite(RTE_STR(CRYPTODEV_NAME_CN10K_PMD));
 }
 
+static int
+test_cryptodev_cn20k_asym(void)
+{
+	return run_cryptodev_asym_testsuite(RTE_STR(CRYPTODEV_NAME_CN20K_PMD));
+}
+
 static int
 test_cryptodev_virtio_asym(void)
 {
@@ -5600,5 +5606,6 @@ REGISTER_DRIVER_TEST(cryptodev_qat_asym_autotest, test_cryptodev_qat_asym);
 REGISTER_DRIVER_TEST(cryptodev_octeontx_asym_autotest, test_cryptodev_octeontx_asym);
 REGISTER_DRIVER_TEST(cryptodev_cn9k_asym_autotest, test_cryptodev_cn9k_asym);
 REGISTER_DRIVER_TEST(cryptodev_cn10k_asym_autotest, test_cryptodev_cn10k_asym);
+REGISTER_DRIVER_TEST(cryptodev_cn20k_asym_autotest, test_cryptodev_cn20k_asym);
 REGISTER_DRIVER_TEST(cryptodev_virtio_asym_autotest, test_cryptodev_virtio_asym);
 REGISTER_DRIVER_TEST(cryptodev_virtio_user_asym_autotest, test_cryptodev_virtio_user_asym);
Signature · 1 line
2.34.1
#3 lore raw

PATCH 3/4 test/crypto: add autotest support for cn20k

In reply to Tejasree Kondoj

From: Vidya Sagar Velumuri <[email protected]>

Add crypto autotest support for cn20k

---
 app/test/test_cryptodev.c | 15 +++++++++++++++
 app/test/test_cryptodev.h |  1 +
 2 files changed, 16 insertions(+)
app/test/test_cryptodev.c +15 -0
index a60983c6b7..bd726ddcf9 100644
@@ -20880,6 +20880,18 @@ test_cryptodev_cn10k_raw_api(void)
 	return run_cryptodev_raw_testsuite(RTE_STR(CRYPTODEV_NAME_CN10K_PMD));
 }
 
+static int
+test_cryptodev_cn20k(void)
+{
+	return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_CN20K_PMD));
+}
+
+static int
+test_cryptodev_cn20k_raw_api(void)
+{
+	return run_cryptodev_raw_testsuite(RTE_STR(CRYPTODEV_NAME_CN20K_PMD));
+}
+
 static int
 test_cryptodev_dpaa2_sec_raw_api(void)
 {
@@ -20935,4 +20947,7 @@ REGISTER_DRIVER_TEST(cryptodev_nitrox_autotest, test_cryptodev_nitrox);
 REGISTER_DRIVER_TEST(cryptodev_bcmfs_autotest, test_cryptodev_bcmfs);
 REGISTER_DRIVER_TEST(cryptodev_cn9k_autotest, test_cryptodev_cn9k);
 REGISTER_DRIVER_TEST(cryptodev_cn10k_autotest, test_cryptodev_cn10k);
+REGISTER_DRIVER_TEST(cryptodev_cn20k_autotest, test_cryptodev_cn20k);
+REGISTER_DRIVER_TEST(cryptodev_cn20k_raw_api_autotest,
+		test_cryptodev_cn20k_raw_api);
 REGISTER_DRIVER_TEST(cryptodev_zsda_autotest, test_cryptodev_zsda);
app/test/test_cryptodev.h +1 -0
index 23d12ec961..f4d8f9be0a 100644
@@ -76,6 +76,7 @@
 #define CRYPTODEV_NAME_BCMFS_PMD	crypto_bcmfs
 #define CRYPTODEV_NAME_CN9K_PMD		crypto_cn9k
 #define CRYPTODEV_NAME_CN10K_PMD	crypto_cn10k
+#define CRYPTODEV_NAME_CN20K_PMD	crypto_cn20k
 #define CRYPTODEV_NAME_MLX5_PMD		crypto_mlx5
 #define CRYPTODEV_NAME_UADK_PMD		crypto_uadk
 #define CRYPTODEV_NAME_ZSDA_SYM_PMD	crypto_zsda
Signature · 1 line
2.34.1
#4 lore raw

PATCH 4/4 test/crypto: add unit test for Rx inject multi seg

In reply to Tejasree Kondoj

From: Vidya Sagar Velumuri <[email protected]>

Add unit test to verify the multi segment support in RX Inject

---
 app/test/test_cryptodev.c | 27 ++++++++++++++++++++++++++-
 1 file changed, 26 insertions(+), 1 deletion(-)
app/test/test_cryptodev.c +26 -1
index bd726ddcf9..a11bc00963 100644
@@ -1564,7 +1564,8 @@ ut_setup_security_rx_inject(void)
 	struct rte_eth_conf port_conf = {
 		.rxmode = {
 			.offloads = RTE_ETH_RX_OFFLOAD_CHECKSUM |
-				    RTE_ETH_RX_OFFLOAD_SECURITY,
+				    RTE_ETH_RX_OFFLOAD_SECURITY |
+					RTE_ETH_RX_OFFLOAD_SCATTER,
 		},
 		.txmode = {
 			.offloads = RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE,
@@ -10781,6 +10782,25 @@ test_ipsec_proto_known_vec_inb_rx_inject(const void *test_data)
 	return test_ipsec_proto_process(&td_inb, NULL, 1, false, &flags);
 }
 
+static int
+test_ipsec_proto_known_vec_inb_rx_inject_multi_seg(const void *test_data)
+{
+	const struct ipsec_test_data *td = test_data;
+	struct ipsec_test_flags flags;
+	struct ipsec_test_data td_inb;
+
+	memset(&flags, 0, sizeof(flags));
+	flags.rx_inject = true;
+	flags.nb_segs_in_mbuf = 4;
+
+	if (td->ipsec_xform.direction == RTE_SECURITY_IPSEC_SA_DIR_EGRESS)
+		test_ipsec_td_in_from_out(td, &td_inb);
+	else
+		memcpy(&td_inb, td, sizeof(td_inb));
+
+	return test_ipsec_proto_process(&td_inb, NULL, 1, false, &flags);
+}
+
 static int
 test_ipsec_proto_all(const struct ipsec_test_flags *flags)
 {
@@ -18389,6 +18409,11 @@ static struct unit_test_suite ipsec_proto_testsuite  = {
 			"Inbound known vector (ESP tunnel mode IPv4 AES-GCM 128) Rx inject",
 			ut_setup_security_rx_inject, ut_teardown_rx_inject,
 			test_ipsec_proto_known_vec_inb_rx_inject, &pkt_aes_128_gcm),
+		TEST_CASE_NAMED_WITH_DATA(
+			"Inbound known vector (ESP tunnel mode IPv4 AES-GCM 128) Rx inject multi seg",
+			ut_setup_security_rx_inject, ut_teardown_rx_inject,
+			test_ipsec_proto_known_vec_inb_rx_inject_multi_seg, &pkt_aes_128_gcm),
+
 		TEST_CASES_END() /**< NULL terminate unit test array */
 	}
 };
Signature · 1 line
2.34.1