[6/6] app/test: add asymmetric tests for virtio pmd

Message ID 20240905145612.1732-7-gmuthukrishn@marvell.com (mailing list archive)
State Changes Requested
Delegated to: akhil goyal
Headers
Series vhost: add asymmetric crypto support |

Checks

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

Commit Message

Gowrishankar Muthukrishnan Sept. 5, 2024, 2:56 p.m. UTC
Add asymmetric tests for Virtio PMD.

Signed-off-by: Gowrishankar Muthukrishnan <gmuthukrishn@marvell.com>
---
 app/test/test_cryptodev_asym.c             | 42 +++++++++++++++++++---
 app/test/test_cryptodev_rsa_test_vectors.h | 26 ++++++++++++++
 2 files changed, 64 insertions(+), 4 deletions(-)
  

Comments

Stephen Hemminger Oct. 10, 2024, 3:10 a.m. UTC | #1
On Thu, 5 Sep 2024 20:26:10 +0530
Gowrishankar Muthukrishnan <gmuthukrishn@marvell.com> wrote:

> Add asymmetric tests for Virtio PMD.
> 
> Signed-off-by: Gowrishankar Muthukrishnan <gmuthukrishn@marvell.com>

This patch set has lots of build errors. See patchwork.
For example:

*Build Failed #1:
OS: RHEL94-64
Target: x86_64-native-linuxapp-clang
FAILED: lib/librte_vhost.a.p/vhost_vhost_crypto.c.o 
clang -Ilib/librte_vhost.a.p -Ilib -I../lib -Ilib/vhost -I../lib/vhost -I. -I.. -Iconfig -I../config -Ilib/eal/include -I../lib/eal/include -Ilib/eal/linux/include -I../lib/eal/linux/include -Ilib/eal/x86/include -I../lib/eal/x86/include -Ilib/eal/common -I../lib/eal/common -Ilib/eal -I../lib/eal -Ilib/kvargs -I../lib/kvargs -Ilib/log -I../lib/log -Ilib/metrics -I../lib/metrics -Ilib/telemetry -I../lib/telemetry -Ilib/ethdev -I../lib/ethdev -Ilib/net -I../lib/net -Ilib/mbuf -I../lib/mbuf -Ilib/mempool -I../lib/mempool -Ilib/ring -I../lib/ring -Ilib/meter -I../lib/meter -Ilib/cryptodev -I../lib/cryptodev -Ilib/rcu -I../lib/rcu -Ilib/hash -I../lib/hash -Ilib/pci -I../lib/pci -Ilib/dmadev -I../lib/dmadev -fcolor-diagnostics -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -Wextra -Werror -std=c11 -O3 -include rte_config.h -Wcast-qual -Wdeprecated -Wformat -Wformat-nonliteral -Wformat-security -Wmissing-declarations -Wmissing-prototypes -Wnested-externs -Wold-style-definition -Wpointer-arith -
 Wsign-compare -Wstrict-prototypes -Wundef -Wwrite-strings -Wno-address-of-packed-member -Wno-missing-field-initializers -D_GNU_SOURCE -fPIC -march=native -mrtm -DALLOW_EXPERIMENTAL_API -DALLOW_INTERNAL_API -DVHOST_CLANG_UNROLL_PRAGMA -fno-strict-aliasing -DRTE_LOG_DEFAULT_LOGTYPE=lib.vhost -DRTE_ANNOTATE_LOCKS -Wthread-safety -MD -MQ lib/librte_vhost.a.p/vhost_vhost_crypto.c.o -MF lib/librte_vhost.a.p/vhost_vhost_crypto.c.o.d -o lib/librte_vhost.a.p/vhost_vhost_crypto.c.o -c ../lib/vhost/vhost_crypto.c
../lib/vhost/vhost_crypto.c:1426:24: error: calling function 'get_data_ptr' requires holding mutex 'vc_req->vq->iotlb_lock' [-Werror,-Wthread-safety-analysis]
 1426 |                         rsa->message.data = get_data_ptr(vc_req, desc, VHOST_ACCESS_RO);
      |                                             ^
../lib/vhost/vhost_crypto.c:1437:21: error: calling function 'get_data_ptr' requires holding mutex 'vc_req->vq->iotlb_lock' [-Werror,-Wthread-safety-analysis]
 1437 |                         rsa->sign.data = get_data_ptr(vc_req, desc, VHOST_ACCESS_RW);
      |                                          ^
../lib/vhost/vhost_crypto.c:1446:21: error: calling function 'get_data_ptr' requires holding mutex 'vc_req->vq->iotlb_lock' [-Werror,-Wthread-safety-analysis]
 1446 |                         rsa->sign.data = get_data_ptr(vc_req, desc, VHOST_ACCESS_RO);
      |                                          ^
../lib/vhost/vhost_crypto.c:1449:24: error: calling function 'get_data_ptr' requires holding mutex 'vc_req->vq->iotlb_lock' [-Werror,-Wthread-safety-analysis]
 1449 |                         rsa->message.data = get_data_ptr(vc_req, desc, VHOST_ACCESS_RO);
      |                                             ^
../lib/vhost/vhost_crypto.c:1454:24: error: calling function 'get_data_ptr' requires holding mutex 'vc_req->vq->iotlb_lock' [-Werror,-Wthread-safety-analysis]
 1454 |                         rsa->message.data = get_data_ptr(vc_req, desc, VHOST_ACCESS_RO);
      |                                             ^
../lib/vhost/vhost_crypto.c:1465:23: error: calling function 'get_data_ptr' requires holding mutex 'vc_req->vq->iotlb_lock' [-Werror,-Wthread-safety-analysis]
 1465 |                         rsa->cipher.data = get_data_ptr(vc_req, desc, VHOST_ACCESS_RW);
      |                                            ^
../lib/vhost/vhost_crypto.c:1474:23: error: calling function 'get_data_ptr' requires holding mutex 'vc_req->vq->iotlb_lock' [-Werror,-Wthread-safety-analysis]
 1474 |                         rsa->cipher.data = get_data_ptr(vc_req, desc, VHOST_ACCESS_RO);
      |                                            ^
../lib/vhost/vhost_crypto.c:1477:24: error: calling function 'get_data_ptr' requires holding mutex 'vc_req->vq->iotlb_lock' [-Werror,-Wthread-safety-analysis]
 1477 |                         rsa->message.data = get_data_ptr(vc_req, desc, VHOST_ACCESS_RO);
      |                                             ^
../lib/vhost/vhost_crypto.c:1493:18: error: calling function 'get_data_ptr' requires holding mutex 'vc_req->vq->iotlb_lock' [-Werror,-Wthread-safety-analysis]
 1493 |         vc_req->inhdr = get_data_ptr(vc_req, desc, VHOST_ACCESS_WO);
      |                         ^
9 errors generated.
[419/3000] Generating symbol file lib/librte_mldev.so.25.0.p/librte_mldev.so.25.0.symbols
[420/3000] Compiling C object lib/librte_vhost.a.p/vhost_virtio_net_ctrl.c.o
[421/3000] Compiling C object lib/librte_vhost.a.p/vhost_vhost_user.c.o
[422/3000] Compiling C object lib/librte_vhost.a.p/vhost_vhost.c.o
[423/3000] Compiling C object lib/librte_ipsec.a.p/ipsec_esp_outb.c.o
[424/3000] Compiling C object lib/librte_ipsec.a.p/ipsec_ses.c.o
[425/3000] Compiling C object lib/librte_ipsec.a.p/ipsec_sa.c.o
[426/3000] Compiling C object lib/librte_ipsec.a.p/ipsec_esp_inb.c.o
[427/3000] Compiling C object lib/librte_vhost.a.p/vhost_virtio_net.c.o
ninja: build stopped
  

Patch

diff --git a/app/test/test_cryptodev_asym.c b/app/test/test_cryptodev_asym.c
index 0928367cb0..b425643211 100644
--- a/app/test/test_cryptodev_asym.c
+++ b/app/test/test_cryptodev_asym.c
@@ -475,7 +475,7 @@  testsuite_setup(void)
 	for (qp_id = 0; qp_id < info.max_nb_queue_pairs; qp_id++) {
 		TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
 			dev_id, qp_id, &ts_params->qp_conf,
-			rte_cryptodev_socket_id(dev_id)),
+			(int8_t)rte_cryptodev_socket_id(dev_id)),
 			"Failed to setup queue pair %u on cryptodev %u ASYM",
 			qp_id, dev_id);
 	}
@@ -538,7 +538,7 @@  ut_setup_asym(void)
 		TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
 			ts_params->valid_devs[0], qp_id,
 			&ts_params->qp_conf,
-			rte_cryptodev_socket_id(ts_params->valid_devs[0])),
+			(int8_t)rte_cryptodev_socket_id(ts_params->valid_devs[0])),
 			"Failed to setup queue pair %u on cryptodev %u",
 			qp_id, ts_params->valid_devs[0]);
 	}
@@ -3319,7 +3319,6 @@  rsa_encrypt(const struct rsa_test_data_2 *vector, uint8_t *cipher_buf)
 	self->op->asym->rsa.cipher.data = cipher_buf;
 	self->op->asym->rsa.cipher.length = 0;
 	SET_RSA_PARAM(self->op->asym->rsa, vector, message);
-	self->op->asym->rsa.padding.type = vector->padding;
 
 	rte_crypto_op_attach_asym_session(self->op, self->sess);
 	TEST_ASSERT_SUCCESS(send_one(),
@@ -3343,7 +3342,6 @@  rsa_decrypt(const struct rsa_test_data_2 *vector, uint8_t *plaintext,
 	self->op->asym->rsa.message.data = plaintext;
 	self->op->asym->rsa.message.length = 0;
 	self->op->asym->rsa.op_type = RTE_CRYPTO_ASYM_OP_DECRYPT;
-	self->op->asym->rsa.padding.type = vector->padding;
 	rte_crypto_op_attach_asym_session(self->op, self->sess);
 	TEST_ASSERT_SUCCESS(send_one(),
 		"Failed to process crypto op (Decryption)");
@@ -3385,6 +3383,7 @@  kat_rsa_encrypt(const void *data)
 	SET_RSA_PARAM(xform.rsa, vector, n);
 	SET_RSA_PARAM(xform.rsa, vector, e);
 	SET_RSA_PARAM(xform.rsa, vector, d);
+	xform.rsa.padding.type = vector->padding;
 	xform.rsa.key_type = RTE_RSA_KEY_TYPE_EXP;
 	int ret = rsa_init_session(&xform);
 
@@ -3415,6 +3414,7 @@  kat_rsa_encrypt_crt(const void *data)
 	SET_RSA_PARAM_QT(xform.rsa, vector, dP);
 	SET_RSA_PARAM_QT(xform.rsa, vector, dQ);
 	SET_RSA_PARAM_QT(xform.rsa, vector, qInv);
+	xform.rsa.padding.type = vector->padding;
 	xform.rsa.key_type = RTE_RSA_KEY_TYPE_QT;
 	int ret = rsa_init_session(&xform);
 	if (ret) {
@@ -3440,6 +3440,7 @@  kat_rsa_decrypt(const void *data)
 	SET_RSA_PARAM(xform.rsa, vector, n);
 	SET_RSA_PARAM(xform.rsa, vector, e);
 	SET_RSA_PARAM(xform.rsa, vector, d);
+	xform.rsa.padding.type = vector->padding;
 	xform.rsa.key_type = RTE_RSA_KEY_TYPE_EXP;
 	int ret = rsa_init_session(&xform);
 
@@ -3470,6 +3471,7 @@  kat_rsa_decrypt_crt(const void *data)
 	SET_RSA_PARAM_QT(xform.rsa, vector, dP);
 	SET_RSA_PARAM_QT(xform.rsa, vector, dQ);
 	SET_RSA_PARAM_QT(xform.rsa, vector, qInv);
+	xform.rsa.padding.type = vector->padding;
 	xform.rsa.key_type = RTE_RSA_KEY_TYPE_QT;
 	int ret = rsa_init_session(&xform);
 	if (ret) {
@@ -3634,6 +3636,22 @@  static struct unit_test_suite cryptodev_octeontx_asym_testsuite  = {
 	}
 };
 
+static struct unit_test_suite cryptodev_virtio_asym_testsuite  = {
+	.suite_name = "Crypto Device VIRTIO ASYM Unit Test Suite",
+	.setup = testsuite_setup,
+	.teardown = testsuite_teardown,
+	.unit_test_cases = {
+		TEST_CASE_ST(ut_setup_asym, ut_teardown_asym, test_capability),
+		TEST_CASE_ST(ut_setup_asym, ut_teardown_asym,
+				test_rsa_sign_verify),
+		TEST_CASE_ST(ut_setup_asym, ut_teardown_asym,
+				test_rsa_sign_verify_crt),
+		TEST_CASE_ST(ut_setup_asym, ut_teardown_asym, test_rsa_enc_dec),
+		TEST_CASE_ST(ut_setup_asym, ut_teardown_asym, test_rsa_enc_dec_crt),
+		TEST_CASES_END() /**< NULL terminate unit test array */
+	}
+};
+
 static int
 test_cryptodev_openssl_asym(void)
 {
@@ -3702,6 +3720,22 @@  test_cryptodev_cn10k_asym(void)
 	return unit_test_suite_runner(&cryptodev_octeontx_asym_testsuite);
 }
 
+static int
+test_cryptodev_virtio_asym(void)
+{
+	gbl_driver_id = rte_cryptodev_driver_id_get(
+			RTE_STR(CRYPTODEV_NAME_VIRTIO_PMD));
+	if (gbl_driver_id == -1) {
+		RTE_LOG(ERR, USER1, "virtio PMD must be loaded.\n");
+		return TEST_FAILED;
+	}
+
+	/* Use test suite registered for crypto_virtio PMD */
+	return unit_test_suite_runner(&cryptodev_virtio_asym_testsuite);
+}
+
+REGISTER_DRIVER_TEST(cryptodev_virtio_asym_autotest, test_cryptodev_virtio_asym);
+
 REGISTER_DRIVER_TEST(cryptodev_openssl_asym_autotest, test_cryptodev_openssl_asym);
 REGISTER_DRIVER_TEST(cryptodev_qat_asym_autotest, test_cryptodev_qat_asym);
 REGISTER_DRIVER_TEST(cryptodev_octeontx_asym_autotest, test_cryptodev_octeontx_asym);
diff --git a/app/test/test_cryptodev_rsa_test_vectors.h b/app/test/test_cryptodev_rsa_test_vectors.h
index 1b7b451387..1c46a8117a 100644
--- a/app/test/test_cryptodev_rsa_test_vectors.h
+++ b/app/test/test_cryptodev_rsa_test_vectors.h
@@ -358,6 +358,28 @@  struct rte_crypto_asym_xform rsa_xform = {
 		.d = {
 			.data = rsa_d,
 			.length = sizeof(rsa_d)
+		},
+		.qt = {
+			.p = {
+				.data = rsa_p,
+				.length = sizeof(rsa_p)
+			},
+			.q = {
+				.data = rsa_q,
+				.length = sizeof(rsa_q)
+			},
+			.dP = {
+				.data = rsa_dP,
+				.length = sizeof(rsa_dP)
+			},
+			.dQ = {
+				.data = rsa_dQ,
+				.length = sizeof(rsa_dQ)
+			},
+			.qInv = {
+				.data = rsa_qInv,
+				.length = sizeof(rsa_qInv)
+			},
 		}
 	}
 };
@@ -377,6 +399,10 @@  struct rte_crypto_asym_xform rsa_xform_crt = {
 			.length = sizeof(rsa_e)
 		},
 		.key_type = RTE_RSA_KEY_TYPE_QT,
+		.d = {
+			.data = rsa_d,
+			.length = sizeof(rsa_d)
+		},
 		.qt = {
 			.p = {
 				.data = rsa_p,