DPDK patches and discussions
 help / color / mirror / Atom feed
From: akhil.goyal@nxp.com
To: dev@dpdk.org
Cc: hemant.agrawal@nxp.com, anoobj@marvell.com,
	declan.doherty@intel.com, david.coyle@intel.com,
	Franck LENORMAND <franck.lenormand@nxp.com>
Subject: [dpdk-dev] [PATCH 6/7] test/crypto: Modify test_pdcp_proto to take parameters
Date: Thu,  3 Sep 2020 21:36:51 +0530	[thread overview]
Message-ID: <20200903160652.31654-7-akhil.goyal@nxp.com> (raw)
In-Reply-To: <20200903160652.31654-1-akhil.goyal@nxp.com>

From: Franck LENORMAND <franck.lenormand@nxp.com>

The function test_pdcp_proto was relying to heavily on the structure
of test vectors for PDCP making it difficult to be reusable.

The function is changed to take all the test parameters as input and
does not need access to the tests vectors anymore.

Signed-off-by: Franck LENORMAND <franck.lenormand@nxp.com>
---
 app/test/test_cryptodev.c | 183 ++++++++++++++++++++++----------------
 1 file changed, 104 insertions(+), 79 deletions(-)

diff --git a/app/test/test_cryptodev.c b/app/test/test_cryptodev.c
index 70bf6fe2c..d6bc07696 100644
--- a/app/test/test_cryptodev.c
+++ b/app/test/test_cryptodev.c
@@ -7121,14 +7121,18 @@ security_proto_supported(enum rte_security_session_action_type action,
  * on input_vec. Checks the output of the crypto operation against
  * output_vec.
  */
-static int
-test_pdcp_proto(int i, int oop,
-	enum rte_crypto_cipher_operation opc,
-	enum rte_crypto_auth_operation opa,
-	uint8_t *input_vec,
-	unsigned int input_vec_len,
-	uint8_t *output_vec,
-	unsigned int output_vec_len)
+static int test_pdcp_proto(int i, int oop, enum rte_crypto_cipher_operation opc,
+			   enum rte_crypto_auth_operation opa,
+			   const uint8_t *input_vec, unsigned int input_vec_len,
+			   const uint8_t *output_vec,
+			   unsigned int output_vec_len,
+			   enum rte_crypto_cipher_algorithm cipher_alg,
+			   const uint8_t *cipher_key, uint32_t cipher_key_len,
+			   enum rte_crypto_auth_algorithm auth_alg,
+			   const uint8_t *auth_key, uint32_t auth_key_len,
+			   uint8_t bearer, enum rte_security_pdcp_domain domain,
+			   uint8_t packet_direction, uint8_t sn_size,
+			   uint32_t hfn, uint32_t hfn_threshold, uint8_t sdap)
 {
 	struct crypto_testsuite_params *ts_params = &testsuite_params;
 	struct crypto_unittest_params *ut_params = &unittest_params;
@@ -7143,7 +7147,7 @@ test_pdcp_proto(int i, int oop,
 
 	sec_cap_idx.action = ut_params->type;
 	sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_PDCP;
-	sec_cap_idx.pdcp.domain = pdcp_test_params[i].domain;
+	sec_cap_idx.pdcp.domain = domain;
 	if (rte_security_capability_get(ctx, &sec_cap_idx) == NULL)
 		return -ENOTSUP;
 
@@ -7169,24 +7173,22 @@ test_pdcp_proto(int i, int oop,
 
 	/* Setup Cipher Parameters */
 	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
-	ut_params->cipher_xform.cipher.algo = pdcp_test_params[i].cipher_alg;
+	ut_params->cipher_xform.cipher.algo = cipher_alg;
 	ut_params->cipher_xform.cipher.op = opc;
-	ut_params->cipher_xform.cipher.key.data = pdcp_test_crypto_key[i];
-	ut_params->cipher_xform.cipher.key.length =
-					pdcp_test_params[i].cipher_key_len;
+	ut_params->cipher_xform.cipher.key.data = cipher_key;
+	ut_params->cipher_xform.cipher.key.length = cipher_key_len;
 	ut_params->cipher_xform.cipher.iv.length =
-				pdcp_test_packet_direction[i] ? 4 : 0;
+				packet_direction ? 4 : 0;
 	ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
 
 	/* Setup HMAC Parameters if ICV header is required */
-	if (pdcp_test_params[i].auth_alg != 0) {
+	if (auth_alg != 0) {
 		ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
 		ut_params->auth_xform.next = NULL;
-		ut_params->auth_xform.auth.algo = pdcp_test_params[i].auth_alg;
+		ut_params->auth_xform.auth.algo = auth_alg;
 		ut_params->auth_xform.auth.op = opa;
-		ut_params->auth_xform.auth.key.data = pdcp_test_auth_key[i];
-		ut_params->auth_xform.auth.key.length =
-					pdcp_test_params[i].auth_key_len;
+		ut_params->auth_xform.auth.key.data = auth_key;
+		ut_params->auth_xform.auth.key.length = auth_key_len;
 
 		ut_params->cipher_xform.next = &ut_params->auth_xform;
 	} else {
@@ -7197,22 +7199,22 @@ test_pdcp_proto(int i, int oop,
 		.action_type = ut_params->type,
 		.protocol = RTE_SECURITY_PROTOCOL_PDCP,
 		{.pdcp = {
-			.bearer = pdcp_test_bearer[i],
-			.domain = pdcp_test_params[i].domain,
-			.pkt_dir = pdcp_test_packet_direction[i],
-			.sn_size = pdcp_test_data_sn_size[i],
-			.hfn = pdcp_test_packet_direction[i] ?
-				0 : pdcp_test_hfn[i],
-				/**
-				 * hfn can be set as pdcp_test_hfn[i]
-				 * if hfn_ovrd is not set. Here, PDCP
-				 * packet direction is just used to
-				 * run half of the cases with session
-				 * HFN and other half with per packet
-				 * HFN.
-				 */
-			.hfn_threshold = pdcp_test_hfn_threshold[i],
-			.hfn_ovrd = pdcp_test_packet_direction[i] ? 1 : 0,
+			.bearer = bearer,
+			.domain = domain,
+			.pkt_dir = packet_direction,
+			.sn_size = sn_size,
+			.hfn = packet_direction ? 0 : hfn,
+			/**
+			 * hfn can be set as pdcp_test_hfn[i]
+			 * if hfn_ovrd is not set. Here, PDCP
+			 * packet direction is just used to
+			 * run half of the cases with session
+			 * HFN and other half with per packet
+			 * HFN.
+			 */
+			.hfn_threshold = hfn_threshold,
+			.hfn_ovrd = packet_direction ? 1 : 0,
+			.sdap_enabled = sdap,
 		} },
 		.crypto_xform = &ut_params->cipher_xform
 	};
@@ -7241,7 +7243,7 @@ test_pdcp_proto(int i, int oop,
 
 	uint32_t *per_pkt_hfn = rte_crypto_op_ctod_offset(ut_params->op,
 					uint32_t *, IV_OFFSET);
-	*per_pkt_hfn = pdcp_test_packet_direction[i] ? pdcp_test_hfn[i] : 0;
+	*per_pkt_hfn = packet_direction ? hfn : 0;
 
 	rte_security_attach_session(ut_params->op, ut_params->sec_session);
 
@@ -7582,74 +7584,97 @@ test_pdcp_proto_SGL(int i, int oop,
 int
 test_pdcp_proto_cplane_encap(int i)
 {
-	return test_pdcp_proto(i, 0,
-		RTE_CRYPTO_CIPHER_OP_ENCRYPT,
-		RTE_CRYPTO_AUTH_OP_GENERATE,
-		pdcp_test_data_in[i],
-		pdcp_test_data_in_len[i],
-		pdcp_test_data_out[i],
-		pdcp_test_data_in_len[i]+4);
+	return test_pdcp_proto(
+		i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT, RTE_CRYPTO_AUTH_OP_GENERATE,
+		pdcp_test_data_in[i], pdcp_test_data_in_len[i],
+		pdcp_test_data_out[i], pdcp_test_data_in_len[i] + 4,
+		pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
+		pdcp_test_params[i].cipher_key_len,
+		pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
+		pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
+		pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
+		pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
+		pdcp_test_hfn_threshold[i], SDAP_DISABLED);
 }
 
 int
 test_pdcp_proto_uplane_encap(int i)
 {
-	return test_pdcp_proto(i, 0,
-		RTE_CRYPTO_CIPHER_OP_ENCRYPT,
-		RTE_CRYPTO_AUTH_OP_GENERATE,
-		pdcp_test_data_in[i],
-		pdcp_test_data_in_len[i],
-		pdcp_test_data_out[i],
-		pdcp_test_data_in_len[i]);
-
+	return test_pdcp_proto(
+		i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT, RTE_CRYPTO_AUTH_OP_GENERATE,
+		pdcp_test_data_in[i], pdcp_test_data_in_len[i],
+		pdcp_test_data_out[i], pdcp_test_data_in_len[i],
+		pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
+		pdcp_test_params[i].cipher_key_len,
+		pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
+		pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
+		pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
+		pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
+		pdcp_test_hfn_threshold[i], SDAP_DISABLED);
 }
 
 int
 test_pdcp_proto_uplane_encap_with_int(int i)
 {
-	return test_pdcp_proto(i, 0,
-		RTE_CRYPTO_CIPHER_OP_ENCRYPT,
-		RTE_CRYPTO_AUTH_OP_GENERATE,
-		pdcp_test_data_in[i],
-		pdcp_test_data_in_len[i],
-		pdcp_test_data_out[i],
-		pdcp_test_data_in_len[i] + 4);
+	return test_pdcp_proto(
+		i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT, RTE_CRYPTO_AUTH_OP_GENERATE,
+		pdcp_test_data_in[i], pdcp_test_data_in_len[i],
+		pdcp_test_data_out[i], pdcp_test_data_in_len[i] + 4,
+		pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
+		pdcp_test_params[i].cipher_key_len,
+		pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
+		pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
+		pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
+		pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
+		pdcp_test_hfn_threshold[i], SDAP_DISABLED);
 }
 
 int
 test_pdcp_proto_cplane_decap(int i)
 {
-	return test_pdcp_proto(i, 0,
-		RTE_CRYPTO_CIPHER_OP_DECRYPT,
-		RTE_CRYPTO_AUTH_OP_VERIFY,
-		pdcp_test_data_out[i],
-		pdcp_test_data_in_len[i] + 4,
-		pdcp_test_data_in[i],
-		pdcp_test_data_in_len[i]);
+	return test_pdcp_proto(
+		i, 0, RTE_CRYPTO_CIPHER_OP_DECRYPT, RTE_CRYPTO_AUTH_OP_VERIFY,
+		pdcp_test_data_out[i], pdcp_test_data_in_len[i] + 4,
+		pdcp_test_data_in[i], pdcp_test_data_in_len[i],
+		pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
+		pdcp_test_params[i].cipher_key_len,
+		pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
+		pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
+		pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
+		pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
+		pdcp_test_hfn_threshold[i], SDAP_DISABLED);
 }
 
 int
 test_pdcp_proto_uplane_decap(int i)
 {
-	return test_pdcp_proto(i, 0,
-		RTE_CRYPTO_CIPHER_OP_DECRYPT,
-		RTE_CRYPTO_AUTH_OP_VERIFY,
-		pdcp_test_data_out[i],
-		pdcp_test_data_in_len[i],
-		pdcp_test_data_in[i],
-		pdcp_test_data_in_len[i]);
+	return test_pdcp_proto(
+		i, 0, RTE_CRYPTO_CIPHER_OP_DECRYPT, RTE_CRYPTO_AUTH_OP_VERIFY,
+		pdcp_test_data_out[i], pdcp_test_data_in_len[i],
+		pdcp_test_data_in[i], pdcp_test_data_in_len[i],
+		pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
+		pdcp_test_params[i].cipher_key_len,
+		pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
+		pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
+		pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
+		pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
+		pdcp_test_hfn_threshold[i], SDAP_DISABLED);
 }
 
 int
 test_pdcp_proto_uplane_decap_with_int(int i)
 {
-	return test_pdcp_proto(i, 0,
-		RTE_CRYPTO_CIPHER_OP_DECRYPT,
-		RTE_CRYPTO_AUTH_OP_VERIFY,
-		pdcp_test_data_out[i],
-		pdcp_test_data_in_len[i] + 4,
-		pdcp_test_data_in[i],
-		pdcp_test_data_in_len[i]);
+	return test_pdcp_proto(
+		i, 0, RTE_CRYPTO_CIPHER_OP_DECRYPT, RTE_CRYPTO_AUTH_OP_VERIFY,
+		pdcp_test_data_out[i], pdcp_test_data_in_len[i] + 4,
+		pdcp_test_data_in[i], pdcp_test_data_in_len[i],
+		pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
+		pdcp_test_params[i].cipher_key_len,
+		pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
+		pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
+		pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
+		pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
+		pdcp_test_hfn_threshold[i], SDAP_DISABLED);
 }
 
 static int
-- 
2.17.1


  parent reply	other threads:[~2020-09-03 16:08 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-03 16:06 [dpdk-dev] [PATCH 0/7] support PDCP-SDAP for dpaa2_sec akhil.goyal
2020-09-03 16:06 ` [dpdk-dev] [PATCH 1/7] common/dpaax/caamflib: Support PDCP-SDAP akhil.goyal
2020-09-03 16:06 ` [dpdk-dev] [PATCH 2/7] security: modify PDCP xform to support SDAP akhil.goyal
2020-10-05 18:04   ` Coyle, David
2020-10-08  9:01     ` Akhil Goyal
2020-09-03 16:06 ` [dpdk-dev] [PATCH 3/7] crypto/dpaa2_sec: enable PDCP-SDAP sessions akhil.goyal
2020-09-03 16:06 ` [dpdk-dev] [PATCH 4/7] crypto/dpaa_sec: " akhil.goyal
2020-09-03 16:06 ` [dpdk-dev] [PATCH 5/7] test/crypto: Add test vectors for PDCP-SDAP akhil.goyal
2020-09-03 16:06 ` akhil.goyal [this message]
2020-09-03 16:06 ` [dpdk-dev] [PATCH 7/7] test/crypto: Add PDCP-SDAP cases akhil.goyal
2020-10-11 21:33 ` [dpdk-dev] [PATCH v2 0/8] support PDCP-SDAP for dpaa2_sec Akhil Goyal
2020-10-11 21:33   ` [dpdk-dev] [PATCH v2 1/8] common/dpaax/caamflib: Support PDCP-SDAP Akhil Goyal
2020-10-11 21:33   ` [dpdk-dev] [PATCH v2 2/8] security: modify PDCP xform to support SDAP Akhil Goyal
2020-10-11 21:33   ` [dpdk-dev] [PATCH v2 3/8] doc: remove unnecessary API code from security guide Akhil Goyal
2020-10-11 21:33   ` [dpdk-dev] [PATCH v2 4/8] crypto/dpaa2_sec: enable PDCP-SDAP sessions Akhil Goyal
2020-10-11 21:34   ` [dpdk-dev] [PATCH v2 5/8] crypto/dpaa_sec: " Akhil Goyal
2020-10-11 21:34   ` [dpdk-dev] [PATCH v2 6/8] test/crypto: Add test vectors for PDCP-SDAP Akhil Goyal
2020-10-11 21:49     ` Thomas Monjalon
2020-10-12 14:01       ` Akhil Goyal
2020-10-11 21:34   ` [dpdk-dev] [PATCH v2 7/8] test/crypto: Modify test_pdcp_proto to take parameters Akhil Goyal
2020-10-11 21:34   ` [dpdk-dev] [PATCH v2 8/8] test/crypto: Add PDCP-SDAP cases Akhil Goyal
2020-10-12 14:09   ` [dpdk-dev] [PATCH v3 0/8] support PDCP-SDAP for dpaa2_sec Akhil Goyal
2020-10-12 14:09     ` [dpdk-dev] [PATCH v3 1/8] common/dpaax/caamflib: Support PDCP-SDAP Akhil Goyal
2020-10-12 14:10     ` [dpdk-dev] [PATCH v3 2/8] security: modify PDCP xform to support SDAP Akhil Goyal
2020-10-14  7:46       ` Thomas Monjalon
2020-10-14 20:26         ` Akhil Goyal
2020-10-12 14:10     ` [dpdk-dev] [PATCH v3 3/8] doc: remove unnecessary API code from security guide Akhil Goyal
2020-10-12 14:10     ` [dpdk-dev] [PATCH v3 4/8] crypto/dpaa2_sec: enable PDCP-SDAP sessions Akhil Goyal
2020-10-12 14:10     ` [dpdk-dev] [PATCH v3 5/8] crypto/dpaa_sec: " Akhil Goyal
2020-10-12 14:10     ` [dpdk-dev] [PATCH v3 6/8] test/crypto: Add test vectors for PDCP-SDAP Akhil Goyal
2020-10-12 14:10     ` [dpdk-dev] [PATCH v3 7/8] test/crypto: Modify test_pdcp_proto to take parameters Akhil Goyal
2020-10-12 14:10     ` [dpdk-dev] [PATCH v3 8/8] test/crypto: Add PDCP-SDAP cases Akhil Goyal

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200903160652.31654-7-akhil.goyal@nxp.com \
    --to=akhil.goyal@nxp.com \
    --cc=anoobj@marvell.com \
    --cc=david.coyle@intel.com \
    --cc=declan.doherty@intel.com \
    --cc=dev@dpdk.org \
    --cc=franck.lenormand@nxp.com \
    --cc=hemant.agrawal@nxp.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).