From: Franck Lenormand Date: Mon, 12 Oct 2020 14:10:05 +0000 (+0530) Subject: test/crypto: rework PDCP function X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=1ba59ffebe1cd4b9d073a608fbf0c261da9fb806;p=dpdk.git test/crypto: rework PDCP function 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 --- diff --git a/app/test/test_cryptodev.c b/app/test/test_cryptodev.c index c7975ed01c..09244d8d68 100644 --- a/app/test/test_cryptodev.c +++ b/app/test/test_cryptodev.c @@ -7653,14 +7653,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; @@ -7675,7 +7679,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; @@ -7701,24 +7705,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 { @@ -7729,22 +7731,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 }; @@ -7773,7 +7775,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); @@ -8114,74 +8116,97 @@ on_err: 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