From patchwork Mon Dec 12 15:10:23 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akhil Goyal X-Patchwork-Id: 120774 X-Patchwork-Delegate: gakhil@marvell.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 758BFA034C; Mon, 12 Dec 2022 16:10:40 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 16AEC40687; Mon, 12 Dec 2022 16:10:40 +0100 (CET) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by mails.dpdk.org (Postfix) with ESMTP id 7020E40684 for ; Mon, 12 Dec 2022 16:10:38 +0100 (CET) Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 2BCCKfhI023523; Mon, 12 Dec 2022 07:10:35 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : mime-version : content-transfer-encoding : content-type; s=pfpt0220; bh=hYR4KovJpL+maCQ1BnhrjUn5u4gOkTUImn+S+uxjsjU=; b=KYpVDJFSuS1XVzMHvkj0rTB5ovlnIpNgY92c4qu3JamvDcLW3Xcz/pcyBhs1PmcZiR+J LzQ0+kPzb7oThUykOVjKy3JRjXGkMg6Lq6JqJh5DgouduWw0UnMinXpdnyUYnFIo9hUz LpTD460IreqcK5LW7ISd/MhpLr1PviCpBIITTTV+r1fzO0c8CMrTZN5v+xBJEVMt6YQF W0Zh2tTfsjVotPyVBO/iq5uZtFRpqcHHXzn/CFiQLMmOw2+LkgPNL/VLdifhg/t9BSzo mzKXlOmOa+EqYmCJW0nf21tRIDxlKgJBuTBf1pHFubz5cjo940KrBfvLuWFqfPc4nDUQ +w== Received: from dc5-exch02.marvell.com ([199.233.59.182]) by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 3mctgse0e1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Mon, 12 Dec 2022 07:10:34 -0800 Received: from DC5-EXCH01.marvell.com (10.69.176.38) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server (TLS) id 15.0.1497.42; Mon, 12 Dec 2022 07:10:32 -0800 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server id 15.0.1497.42 via Frontend Transport; Mon, 12 Dec 2022 07:10:32 -0800 Received: from localhost.localdomain (unknown [10.28.36.102]) by maili.marvell.com (Postfix) with ESMTP id A7C825B6924; Mon, 12 Dec 2022 07:10:27 -0800 (PST) From: Akhil Goyal To: CC: , , , , , , , , , , , , , , Akhil Goyal Subject: [PATCH] cryptodev: add algo enums to string conversion APIs Date: Mon, 12 Dec 2022 20:40:23 +0530 Message-ID: <20221212151023.3308146-1-gakhil@marvell.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-Proofpoint-GUID: EHNlAqQNWcAStiOdEjaKUG2A8ayorLUO X-Proofpoint-ORIG-GUID: EHNlAqQNWcAStiOdEjaKUG2A8ayorLUO X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.923,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-12-12_02,2022-12-12_01,2022-06-22_01 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Symmetric/Asymmetric algorithm strings are accessed by application using arrays in cryptodev lib, which hampers new algorithms addition in the array due to ABI breakage. These arrays are now deprecated and will be removed in next ABI break release. New APIs are added for getting the algorithm strings based on enum values. Signed-off-by: Akhil Goyal Reviewed-by: Ruifeng Wang Acked-by: Anoob Joseph Acked-by: Ciara Power Acked-by: Fan Zhang --- app/test-crypto-perf/cperf_options_parsing.c | 6 +- app/test/test_cryptodev_asym.c | 2 +- app/test/test_cryptodev_security_ipsec.c | 8 +- doc/guides/rel_notes/deprecation.rst | 7 + drivers/crypto/openssl/rte_openssl_pmd_ops.c | 2 +- drivers/crypto/qat/qat_sym_session.c | 7 +- examples/l2fwd-crypto/main.c | 12 +- lib/cryptodev/cryptodev_trace_points.c | 12 ++ lib/cryptodev/rte_crypto_asym.h | 1 + lib/cryptodev/rte_crypto_sym.h | 3 + lib/cryptodev/rte_cryptodev.c | 182 ++++++++++++++++++- lib/cryptodev/rte_cryptodev.h | 52 ++++++ lib/cryptodev/rte_cryptodev_trace.h | 32 ++++ lib/cryptodev/version.map | 10 + 14 files changed, 309 insertions(+), 27 deletions(-) diff --git a/app/test-crypto-perf/cperf_options_parsing.c b/app/test-crypto-perf/cperf_options_parsing.c index bc5e312c81..f8ddb6ac56 100644 --- a/app/test-crypto-perf/cperf_options_parsing.c +++ b/app/test-crypto-perf/cperf_options_parsing.c @@ -1373,7 +1373,7 @@ cperf_options_dump(struct cperf_options *opts) opts->op_type == CPERF_CIPHER_THEN_AUTH || opts->op_type == CPERF_AUTH_THEN_CIPHER) { printf("# auth algorithm: %s\n", - rte_crypto_auth_algorithm_strings[opts->auth_algo]); + rte_cryptodev_get_auth_algo_string(opts->auth_algo)); printf("# auth operation: %s\n", rte_crypto_auth_operation_strings[opts->auth_op]); printf("# auth key size: %u\n", opts->auth_key_sz); @@ -1386,7 +1386,7 @@ cperf_options_dump(struct cperf_options *opts) opts->op_type == CPERF_CIPHER_THEN_AUTH || opts->op_type == CPERF_AUTH_THEN_CIPHER) { printf("# cipher algorithm: %s\n", - rte_crypto_cipher_algorithm_strings[opts->cipher_algo]); + rte_cryptodev_get_cipher_algo_string(opts->cipher_algo)); printf("# cipher operation: %s\n", rte_crypto_cipher_operation_strings[opts->cipher_op]); printf("# cipher key size: %u\n", opts->cipher_key_sz); @@ -1396,7 +1396,7 @@ cperf_options_dump(struct cperf_options *opts) if (opts->op_type == CPERF_AEAD) { printf("# aead algorithm: %s\n", - rte_crypto_aead_algorithm_strings[opts->aead_algo]); + rte_cryptodev_get_aead_algo_string(opts->aead_algo)); printf("# aead operation: %s\n", rte_crypto_aead_operation_strings[opts->aead_op]); printf("# aead key size: %u\n", opts->aead_key_sz); diff --git a/app/test/test_cryptodev_asym.c b/app/test/test_cryptodev_asym.c index c58c7f488b..5b16dcab56 100644 --- a/app/test/test_cryptodev_asym.c +++ b/app/test/test_cryptodev_asym.c @@ -974,7 +974,7 @@ static inline void print_asym_capa( int i = 0; printf("\nxform type: %s\n===================\n", - rte_crypto_asym_xform_strings[capa->xform_type]); + rte_cryptodev_asym_get_xform_string(capa->xform_type)); printf("operation supported -"); for (i = 0; i < RTE_CRYPTO_ASYM_OP_LIST_END; i++) { diff --git a/app/test/test_cryptodev_security_ipsec.c b/app/test/test_cryptodev_security_ipsec.c index 833be94c09..417ff10a1b 100644 --- a/app/test/test_cryptodev_security_ipsec.c +++ b/app/test/test_cryptodev_security_ipsec.c @@ -625,20 +625,20 @@ test_ipsec_display_alg(const struct crypto_param *param1, { if (param1->type == RTE_CRYPTO_SYM_XFORM_AEAD) { printf("\t%s [%d]", - rte_crypto_aead_algorithm_strings[param1->alg.aead], + rte_cryptodev_get_aead_algo_string(param1->alg.aead), param1->key_length * 8); } else if (param1->type == RTE_CRYPTO_SYM_XFORM_AUTH) { printf("\t%s", - rte_crypto_auth_algorithm_strings[param1->alg.auth]); + rte_cryptodev_get_auth_algo_string(param1->alg.auth)); if (param1->alg.auth != RTE_CRYPTO_AUTH_NULL) printf(" [%dB ICV]", param1->digest_length); } else { printf("\t%s", - rte_crypto_cipher_algorithm_strings[param1->alg.cipher]); + rte_cryptodev_get_cipher_algo_string(param1->alg.cipher)); if (param1->alg.cipher != RTE_CRYPTO_CIPHER_NULL) printf(" [%d]", param1->key_length * 8); printf(" %s", - rte_crypto_auth_algorithm_strings[param2->alg.auth]); + rte_cryptodev_get_auth_algo_string(param2->alg.auth)); if (param2->alg.auth != RTE_CRYPTO_AUTH_NULL) printf(" [%dB ICV]", param2->digest_length); } diff --git a/doc/guides/rel_notes/deprecation.rst b/doc/guides/rel_notes/deprecation.rst index b9b02dcef0..e18ac344ef 100644 --- a/doc/guides/rel_notes/deprecation.rst +++ b/doc/guides/rel_notes/deprecation.rst @@ -114,6 +114,13 @@ Deprecation Notices which got error interrupt to the application, so that application can reset that particular queue pair. +* cryptodev: The arrays of algorithm strings ``rte_crypto_cipher_algorithm_strings``, + ``rte_crypto_auth_algorithm_strings``, ``rte_crypto_aead_algorithm_strings`` and + ``rte_crypto_asym_xform_strings`` are deprecated and will be removed in DPDK 23.11. + Application can use the new APIs ``rte_cryptodev_get_cipher_algo_string``, + ``rte_cryptodev_get_auth_algo_string``, ``rte_cryptodev_get_aead_algo_string`` and + ``rte_cryptodev_asym_get_xform_string`` respectively. + * flow_classify: The flow_classify library and example have no maintainer. The library is experimental and, as such, it could be removed from DPDK. Its removal has been postponed to let potential users report interest diff --git a/drivers/crypto/openssl/rte_openssl_pmd_ops.c b/drivers/crypto/openssl/rte_openssl_pmd_ops.c index defed4429e..29ad1b9505 100644 --- a/drivers/crypto/openssl/rte_openssl_pmd_ops.c +++ b/drivers/crypto/openssl/rte_openssl_pmd_ops.c @@ -823,7 +823,7 @@ static int openssl_set_asym_session_parameters( if ((xform->xform_type != RTE_CRYPTO_ASYM_XFORM_DH) && (xform->next != NULL)) { OPENSSL_LOG(ERR, "chained xfrms are not supported on %s", - rte_crypto_asym_xform_strings[xform->xform_type]); + rte_cryptodev_asym_get_xform_string(xform->xform_type)); return ret; } diff --git a/drivers/crypto/qat/qat_sym_session.c b/drivers/crypto/qat/qat_sym_session.c index 0ebc66f89e..714002dce3 100644 --- a/drivers/crypto/qat/qat_sym_session.c +++ b/drivers/crypto/qat/qat_sym_session.c @@ -436,8 +436,8 @@ qat_sym_session_configure_cipher(struct rte_cryptodev *dev, if (!qat_is_cipher_alg_supported( cipher_xform->algo, internals)) { QAT_LOG(ERR, "%s not supported on this device", - rte_crypto_cipher_algorithm_strings - [cipher_xform->algo]); + rte_cryptodev_get_cipher_algo_string( + cipher_xform->algo)); ret = -ENOTSUP; goto error_out; } @@ -772,8 +772,7 @@ qat_sym_session_configure_auth(struct rte_cryptodev *dev, case RTE_CRYPTO_AUTH_ZUC_EIA3: if (!qat_is_auth_alg_supported(auth_xform->algo, internals)) { QAT_LOG(ERR, "%s not supported on this device", - rte_crypto_auth_algorithm_strings - [auth_xform->algo]); + rte_cryptodev_get_auth_algo_string(auth_xform->algo)); return -ENOTSUP; } session->qat_hash_alg = ICP_QAT_HW_AUTH_ALGO_ZUC_3G_128_EIA3; diff --git a/examples/l2fwd-crypto/main.c b/examples/l2fwd-crypto/main.c index b13e5c526e..efe7eea2a7 100644 --- a/examples/l2fwd-crypto/main.c +++ b/examples/l2fwd-crypto/main.c @@ -1536,7 +1536,7 @@ display_cipher_info(struct l2fwd_crypto_options *options) { printf("\n---- Cipher information ---\n"); printf("Algorithm: %s\n", - rte_crypto_cipher_algorithm_strings[options->cipher_xform.cipher.algo]); + rte_cryptodev_get_cipher_algo_string(options->cipher_xform.cipher.algo)); rte_hexdump(stdout, "Cipher key:", options->cipher_xform.cipher.key.data, options->cipher_xform.cipher.key.length); @@ -1548,7 +1548,7 @@ display_auth_info(struct l2fwd_crypto_options *options) { printf("\n---- Authentication information ---\n"); printf("Algorithm: %s\n", - rte_crypto_auth_algorithm_strings[options->auth_xform.auth.algo]); + rte_cryptodev_get_auth_algo_string(options->auth_xform.auth.algo)); rte_hexdump(stdout, "Auth key:", options->auth_xform.auth.key.data, options->auth_xform.auth.key.length); @@ -1560,7 +1560,7 @@ display_aead_info(struct l2fwd_crypto_options *options) { printf("\n---- AEAD information ---\n"); printf("Algorithm: %s\n", - rte_crypto_aead_algorithm_strings[options->aead_xform.aead.algo]); + rte_cryptodev_get_aead_algo_string(options->aead_xform.aead.algo)); rte_hexdump(stdout, "AEAD key:", options->aead_xform.aead.key.data, options->aead_xform.aead.key.length); @@ -1864,7 +1864,7 @@ check_device_support_cipher_algo(const struct l2fwd_crypto_options *options, if (cap->op == RTE_CRYPTO_OP_TYPE_UNDEFINED) { printf("Algorithm %s not supported by cryptodev %u" " or device not of preferred type (%s)\n", - rte_crypto_cipher_algorithm_strings[opt_cipher_algo], + rte_cryptodev_get_cipher_algo_string(opt_cipher_algo), cdev_id, options->string_type); return NULL; @@ -1898,7 +1898,7 @@ check_device_support_auth_algo(const struct l2fwd_crypto_options *options, if (cap->op == RTE_CRYPTO_OP_TYPE_UNDEFINED) { printf("Algorithm %s not supported by cryptodev %u" " or device not of preferred type (%s)\n", - rte_crypto_auth_algorithm_strings[opt_auth_algo], + rte_cryptodev_get_auth_algo_string(opt_auth_algo), cdev_id, options->string_type); return NULL; @@ -1932,7 +1932,7 @@ check_device_support_aead_algo(const struct l2fwd_crypto_options *options, if (cap->op == RTE_CRYPTO_OP_TYPE_UNDEFINED) { printf("Algorithm %s not supported by cryptodev %u" " or device not of preferred type (%s)\n", - rte_crypto_aead_algorithm_strings[opt_aead_algo], + rte_cryptodev_get_aead_algo_string(opt_aead_algo), cdev_id, options->string_type); return NULL; diff --git a/lib/cryptodev/cryptodev_trace_points.c b/lib/cryptodev/cryptodev_trace_points.c index 63a81511a9..4980bcc9be 100644 --- a/lib/cryptodev/cryptodev_trace_points.c +++ b/lib/cryptodev/cryptodev_trace_points.c @@ -72,6 +72,15 @@ RTE_TRACE_POINT_REGISTER(rte_cryptodev_trace_get_auth_algo_enum, RTE_TRACE_POINT_REGISTER(rte_cryptodev_trace_get_cipher_algo_enum, lib.cryptodev.get.cipher.algo.enum) +RTE_TRACE_POINT_REGISTER(rte_cryptodev_trace_get_aead_algo_string, + lib.cryptodev.get.aead.algo.string) + +RTE_TRACE_POINT_REGISTER(rte_cryptodev_trace_get_auth_algo_string, + lib.cryptodev.get.auth.algo.string) + +RTE_TRACE_POINT_REGISTER(rte_cryptodev_trace_get_cipher_algo_string, + lib.cryptodev.get.cipher.algo.string) + RTE_TRACE_POINT_REGISTER(rte_cryptodev_trace_get_dev_id, lib.cryptodev.get.dev.id) @@ -126,6 +135,9 @@ RTE_TRACE_POINT_REGISTER(rte_cryptodev_trace_asym_get_private_session_size, RTE_TRACE_POINT_REGISTER(rte_cryptodev_trace_asym_get_xform_enum, lib.cryptodev.asym.get.xform.enum) +RTE_TRACE_POINT_REGISTER(rte_cryptodev_trace_asym_get_xform_string, + lib.cryptodev.asym.get.xform.string) + RTE_TRACE_POINT_REGISTER(rte_cryptodev_trace_asym_xform_capability_check_modlen, lib.cryptodev.asym.xform.capability.check.modlen) diff --git a/lib/cryptodev/rte_crypto_asym.h b/lib/cryptodev/rte_crypto_asym.h index 38c8b60779..989f38323f 100644 --- a/lib/cryptodev/rte_crypto_asym.h +++ b/lib/cryptodev/rte_crypto_asym.h @@ -30,6 +30,7 @@ extern "C" { struct rte_cryptodev_asym_session; /** asym xform type name strings */ +__rte_deprecated extern const char * rte_crypto_asym_xform_strings[]; diff --git a/lib/cryptodev/rte_crypto_sym.h b/lib/cryptodev/rte_crypto_sym.h index 33b4966e16..dc847da7b8 100644 --- a/lib/cryptodev/rte_crypto_sym.h +++ b/lib/cryptodev/rte_crypto_sym.h @@ -177,6 +177,7 @@ enum rte_crypto_cipher_algorithm { }; /** Cipher algorithm name strings */ +__rte_deprecated extern const char * rte_crypto_cipher_algorithm_strings[]; @@ -378,6 +379,7 @@ enum rte_crypto_auth_algorithm { }; /** Authentication algorithm name strings */ +__rte_deprecated extern const char * rte_crypto_auth_algorithm_strings[]; @@ -482,6 +484,7 @@ enum rte_crypto_aead_algorithm { }; /** AEAD algorithm name strings */ +__rte_deprecated extern const char * rte_crypto_aead_algorithm_strings[]; diff --git a/lib/cryptodev/rte_cryptodev.c b/lib/cryptodev/rte_cryptodev.c index 2165a0688c..1e98f13dac 100644 --- a/lib/cryptodev/rte_cryptodev.c +++ b/lib/cryptodev/rte_cryptodev.c @@ -64,9 +64,11 @@ struct rte_cryptodev_callback { }; /** + * @deprecated * The crypto cipher algorithm strings identifiers. * It could be used in application command line. */ +__rte_deprecated const char * rte_crypto_cipher_algorithm_strings[] = { [RTE_CRYPTO_CIPHER_3DES_CBC] = "3des-cbc", @@ -95,6 +97,39 @@ rte_crypto_cipher_algorithm_strings[] = { [RTE_CRYPTO_CIPHER_SM4_CTR] = "sm4-ctr" }; +/** + * The crypto cipher algorithm strings identifiers. + * Not to be used in application directly. + * Application can use rte_cryptodev_get_cipher_algo_string(). + */ +static const char * +crypto_cipher_algorithm_strings[] = { + [RTE_CRYPTO_CIPHER_3DES_CBC] = "3des-cbc", + [RTE_CRYPTO_CIPHER_3DES_ECB] = "3des-ecb", + [RTE_CRYPTO_CIPHER_3DES_CTR] = "3des-ctr", + + [RTE_CRYPTO_CIPHER_AES_CBC] = "aes-cbc", + [RTE_CRYPTO_CIPHER_AES_CTR] = "aes-ctr", + [RTE_CRYPTO_CIPHER_AES_DOCSISBPI] = "aes-docsisbpi", + [RTE_CRYPTO_CIPHER_AES_ECB] = "aes-ecb", + [RTE_CRYPTO_CIPHER_AES_F8] = "aes-f8", + [RTE_CRYPTO_CIPHER_AES_XTS] = "aes-xts", + + [RTE_CRYPTO_CIPHER_ARC4] = "arc4", + + [RTE_CRYPTO_CIPHER_DES_CBC] = "des-cbc", + [RTE_CRYPTO_CIPHER_DES_DOCSISBPI] = "des-docsisbpi", + + [RTE_CRYPTO_CIPHER_NULL] = "null", + + [RTE_CRYPTO_CIPHER_KASUMI_F8] = "kasumi-f8", + [RTE_CRYPTO_CIPHER_SNOW3G_UEA2] = "snow3g-uea2", + [RTE_CRYPTO_CIPHER_ZUC_EEA3] = "zuc-eea3", + [RTE_CRYPTO_CIPHER_SM4_ECB] = "sm4-ecb", + [RTE_CRYPTO_CIPHER_SM4_CBC] = "sm4-cbc", + [RTE_CRYPTO_CIPHER_SM4_CTR] = "sm4-ctr" +}; + /** * The crypto cipher operation strings identifiers. * It could be used in application command line. @@ -106,9 +141,11 @@ rte_crypto_cipher_operation_strings[] = { }; /** + * @deprecated * The crypto auth algorithm strings identifiers. * It could be used in application command line. */ +__rte_deprecated const char * rte_crypto_auth_algorithm_strings[] = { [RTE_CRYPTO_AUTH_AES_CBC_MAC] = "aes-cbc-mac", @@ -149,9 +186,55 @@ rte_crypto_auth_algorithm_strings[] = { }; /** + * The crypto auth algorithm strings identifiers. + * Not to be used in application directly. + * Application can use rte_cryptodev_get_auth_algo_string(). + */ +static const char * +crypto_auth_algorithm_strings[] = { + [RTE_CRYPTO_AUTH_AES_CBC_MAC] = "aes-cbc-mac", + [RTE_CRYPTO_AUTH_AES_CMAC] = "aes-cmac", + [RTE_CRYPTO_AUTH_AES_GMAC] = "aes-gmac", + [RTE_CRYPTO_AUTH_AES_XCBC_MAC] = "aes-xcbc-mac", + + [RTE_CRYPTO_AUTH_MD5] = "md5", + [RTE_CRYPTO_AUTH_MD5_HMAC] = "md5-hmac", + + [RTE_CRYPTO_AUTH_NULL] = "null", + + [RTE_CRYPTO_AUTH_SHA1] = "sha1", + [RTE_CRYPTO_AUTH_SHA1_HMAC] = "sha1-hmac", + + [RTE_CRYPTO_AUTH_SHA224] = "sha2-224", + [RTE_CRYPTO_AUTH_SHA224_HMAC] = "sha2-224-hmac", + [RTE_CRYPTO_AUTH_SHA256] = "sha2-256", + [RTE_CRYPTO_AUTH_SHA256_HMAC] = "sha2-256-hmac", + [RTE_CRYPTO_AUTH_SHA384] = "sha2-384", + [RTE_CRYPTO_AUTH_SHA384_HMAC] = "sha2-384-hmac", + [RTE_CRYPTO_AUTH_SHA512] = "sha2-512", + [RTE_CRYPTO_AUTH_SHA512_HMAC] = "sha2-512-hmac", + + [RTE_CRYPTO_AUTH_SHA3_224] = "sha3-224", + [RTE_CRYPTO_AUTH_SHA3_224_HMAC] = "sha3-224-hmac", + [RTE_CRYPTO_AUTH_SHA3_256] = "sha3-256", + [RTE_CRYPTO_AUTH_SHA3_256_HMAC] = "sha3-256-hmac", + [RTE_CRYPTO_AUTH_SHA3_384] = "sha3-384", + [RTE_CRYPTO_AUTH_SHA3_384_HMAC] = "sha3-384-hmac", + [RTE_CRYPTO_AUTH_SHA3_512] = "sha3-512", + [RTE_CRYPTO_AUTH_SHA3_512_HMAC] = "sha3-512-hmac", + + [RTE_CRYPTO_AUTH_KASUMI_F9] = "kasumi-f9", + [RTE_CRYPTO_AUTH_SNOW3G_UIA2] = "snow3g-uia2", + [RTE_CRYPTO_AUTH_ZUC_EIA3] = "zuc-eia3", + [RTE_CRYPTO_AUTH_SM3] = "sm3" +}; + +/** + * @deprecated * The crypto AEAD algorithm strings identifiers. * It could be used in application command line. */ +__rte_deprecated const char * rte_crypto_aead_algorithm_strings[] = { [RTE_CRYPTO_AEAD_AES_CCM] = "aes-ccm", @@ -159,6 +242,19 @@ rte_crypto_aead_algorithm_strings[] = { [RTE_CRYPTO_AEAD_CHACHA20_POLY1305] = "chacha20-poly1305" }; +/** + * The crypto AEAD algorithm strings identifiers. + * Not to be used in application directly. + * Application can use rte_cryptodev_get_aead_algo_string(). + */ +static const char * +crypto_aead_algorithm_strings[] = { + [RTE_CRYPTO_AEAD_AES_CCM] = "aes-ccm", + [RTE_CRYPTO_AEAD_AES_GCM] = "aes-gcm", + [RTE_CRYPTO_AEAD_CHACHA20_POLY1305] = "chacha20-poly1305" +}; + + /** * The crypto AEAD operation strings identifiers. * It could be used in application command line. @@ -170,8 +266,10 @@ rte_crypto_aead_operation_strings[] = { }; /** + * @deprecated * Asymmetric crypto transform operation strings identifiers. */ +__rte_deprecated const char *rte_crypto_asym_xform_strings[] = { [RTE_CRYPTO_ASYM_XFORM_NONE] = "none", [RTE_CRYPTO_ASYM_XFORM_RSA] = "rsa", @@ -183,6 +281,22 @@ const char *rte_crypto_asym_xform_strings[] = { [RTE_CRYPTO_ASYM_XFORM_ECPM] = "ecpm", }; +/** + * Asymmetric crypto transform operation strings identifiers. + * Not to be used in application directly. + * Application can use rte_cryptodev_asym_get_xform_string(). + */ +static const char *crypto_asym_xform_strings[] = { + [RTE_CRYPTO_ASYM_XFORM_NONE] = "none", + [RTE_CRYPTO_ASYM_XFORM_RSA] = "rsa", + [RTE_CRYPTO_ASYM_XFORM_MODEX] = "modexp", + [RTE_CRYPTO_ASYM_XFORM_MODINV] = "modinv", + [RTE_CRYPTO_ASYM_XFORM_DH] = "dh", + [RTE_CRYPTO_ASYM_XFORM_DSA] = "dsa", + [RTE_CRYPTO_ASYM_XFORM_ECDSA] = "ecdsa", + [RTE_CRYPTO_ASYM_XFORM_ECPM] = "ecpm", +}; + /** * Asymmetric crypto operation strings identifiers. */ @@ -227,8 +341,8 @@ rte_cryptodev_get_cipher_algo_enum(enum rte_crypto_cipher_algorithm *algo_enum, unsigned int i; int ret = -1; /* Invalid string */ - for (i = 1; i < RTE_DIM(rte_crypto_cipher_algorithm_strings); i++) { - if (strcmp(algo_string, rte_crypto_cipher_algorithm_strings[i]) == 0) { + for (i = 1; i < RTE_DIM(crypto_cipher_algorithm_strings); i++) { + if (strcmp(algo_string, crypto_cipher_algorithm_strings[i]) == 0) { *algo_enum = (enum rte_crypto_cipher_algorithm) i; ret = 0; break; @@ -247,8 +361,8 @@ rte_cryptodev_get_auth_algo_enum(enum rte_crypto_auth_algorithm *algo_enum, unsigned int i; int ret = -1; /* Invalid string */ - for (i = 1; i < RTE_DIM(rte_crypto_auth_algorithm_strings); i++) { - if (strcmp(algo_string, rte_crypto_auth_algorithm_strings[i]) == 0) { + for (i = 1; i < RTE_DIM(crypto_auth_algorithm_strings); i++) { + if (strcmp(algo_string, crypto_auth_algorithm_strings[i]) == 0) { *algo_enum = (enum rte_crypto_auth_algorithm) i; ret = 0; break; @@ -267,8 +381,8 @@ rte_cryptodev_get_aead_algo_enum(enum rte_crypto_aead_algorithm *algo_enum, unsigned int i; int ret = -1; /* Invalid string */ - for (i = 1; i < RTE_DIM(rte_crypto_aead_algorithm_strings); i++) { - if (strcmp(algo_string, rte_crypto_aead_algorithm_strings[i]) == 0) { + for (i = 1; i < RTE_DIM(crypto_aead_algorithm_strings); i++) { + if (strcmp(algo_string, crypto_aead_algorithm_strings[i]) == 0) { *algo_enum = (enum rte_crypto_aead_algorithm) i; ret = 0; break; @@ -287,9 +401,9 @@ rte_cryptodev_asym_get_xform_enum(enum rte_crypto_asym_xform_type *xform_enum, unsigned int i; int ret = -1; /* Invalid string */ - for (i = 1; i < RTE_DIM(rte_crypto_asym_xform_strings); i++) { + for (i = 1; i < RTE_DIM(crypto_asym_xform_strings); i++) { if (strcmp(xform_string, - rte_crypto_asym_xform_strings[i]) == 0) { + crypto_asym_xform_strings[i]) == 0) { *xform_enum = (enum rte_crypto_asym_xform_type) i; ret = 0; break; @@ -301,6 +415,58 @@ rte_cryptodev_asym_get_xform_enum(enum rte_crypto_asym_xform_type *xform_enum, return ret; } +const char * +rte_cryptodev_get_cipher_algo_string(enum rte_crypto_cipher_algorithm algo_enum) +{ + const char *alg_str = NULL; + + if (algo_enum < RTE_DIM(crypto_cipher_algorithm_strings)) + alg_str = crypto_cipher_algorithm_strings[algo_enum]; + + rte_cryptodev_trace_get_cipher_algo_string(algo_enum, alg_str); + + return alg_str; +} + +const char * +rte_cryptodev_get_auth_algo_string(enum rte_crypto_auth_algorithm algo_enum) +{ + const char *alg_str = NULL; + + if (algo_enum < RTE_DIM(crypto_auth_algorithm_strings)) + alg_str = crypto_auth_algorithm_strings[algo_enum]; + + rte_cryptodev_trace_get_auth_algo_string(algo_enum, alg_str); + + return alg_str; +} + +const char * +rte_cryptodev_get_aead_algo_string(enum rte_crypto_aead_algorithm algo_enum) +{ + const char *alg_str = NULL; + + if (algo_enum < RTE_DIM(crypto_aead_algorithm_strings)) + alg_str = crypto_aead_algorithm_strings[algo_enum]; + + rte_cryptodev_trace_get_aead_algo_string(algo_enum, alg_str); + + return alg_str; +} + +const char * +rte_cryptodev_asym_get_xform_string(enum rte_crypto_asym_xform_type xform_enum) +{ + const char *xform_str = NULL; + + if (xform_enum < RTE_DIM(crypto_asym_xform_strings)) + xform_str = crypto_asym_xform_strings[xform_enum]; + + rte_cryptodev_trace_asym_get_xform_string(xform_enum, xform_str); + + return xform_str; +} + /** * The crypto auth operation strings identifiers. * It could be used in application command line. diff --git a/lib/cryptodev/rte_cryptodev.h b/lib/cryptodev/rte_cryptodev.h index 86d792e2e7..8f41a009e3 100644 --- a/lib/cryptodev/rte_cryptodev.h +++ b/lib/cryptodev/rte_cryptodev.h @@ -406,6 +406,58 @@ int rte_cryptodev_asym_get_xform_enum(enum rte_crypto_asym_xform_type *xform_enum, const char *xform_string); +/** + * Provide the cipher algorithm string, given an algorithm enum. + * + * @param algo_enum cipher algorithm enum + * + * @return + * - Return NULL if enum is not valid + * - Return algo_string corresponding to enum + */ +__rte_experimental +const char * +rte_cryptodev_get_cipher_algo_string(enum rte_crypto_cipher_algorithm algo_enum); + +/** + * Provide the authentication algorithm string, given an algorithm enum. + * + * @param algo_enum auth algorithm enum + * + * @return + * - Return NULL if enum is not valid + * - Return algo_string corresponding to enum + */ +__rte_experimental +const char * +rte_cryptodev_get_auth_algo_string(enum rte_crypto_auth_algorithm algo_enum); + +/** + * Provide the AEAD algorithm string, given an algorithm enum. + * + * @param algo_enum AEAD algorithm enum + * + * @return + * - Return NULL if enum is not valid + * - Return algo_string corresponding to enum + */ +__rte_experimental +const char * +rte_cryptodev_get_aead_algo_string(enum rte_crypto_aead_algorithm algo_enum); + +/** + * Provide the Asymmetric xform string, given an xform enum. + * + * @param xform_enum xform type enum + * + * @return + * - Return NULL, if enum is not valid. + * - Return xform string, for valid enum. + */ +__rte_experimental +const char * +rte_cryptodev_asym_get_xform_string(enum rte_crypto_asym_xform_type xform_enum); + /** Macro used at end of crypto PMD list */ #define RTE_CRYPTODEV_END_OF_CAPABILITIES_LIST() \ diff --git a/lib/cryptodev/rte_cryptodev_trace.h b/lib/cryptodev/rte_cryptodev_trace.h index 6c214ce6ea..5e694379b1 100644 --- a/lib/cryptodev/rte_cryptodev_trace.h +++ b/lib/cryptodev/rte_cryptodev_trace.h @@ -189,6 +189,30 @@ RTE_TRACE_POINT( rte_trace_point_emit_int(ret); ) +RTE_TRACE_POINT( + rte_cryptodev_trace_get_aead_algo_string, + RTE_TRACE_POINT_ARGS(enum rte_crypto_aead_algorithm algo_enum, + const char *algo_string), + rte_trace_point_emit_int(algo_enum); + rte_trace_point_emit_string(algo_string); +) + +RTE_TRACE_POINT( + rte_cryptodev_trace_get_auth_algo_string, + RTE_TRACE_POINT_ARGS(enum rte_crypto_auth_algorithm algo_enum, + const char *algo_string), + rte_trace_point_emit_int(algo_enum); + rte_trace_point_emit_string(algo_string); +) + +RTE_TRACE_POINT( + rte_cryptodev_trace_get_cipher_algo_string, + RTE_TRACE_POINT_ARGS(enum rte_crypto_cipher_algorithm algo_enum, + const char *algo_string), + rte_trace_point_emit_int(algo_enum); + rte_trace_point_emit_string(algo_string); +) + RTE_TRACE_POINT( rte_cryptodev_trace_get_dev_id, RTE_TRACE_POINT_ARGS(const char *name, int ret), @@ -351,6 +375,14 @@ RTE_TRACE_POINT( rte_trace_point_emit_int(ret); ) +RTE_TRACE_POINT( + rte_cryptodev_trace_asym_get_xform_string, + RTE_TRACE_POINT_ARGS(enum rte_crypto_asym_xform_type xform_enum, + const char *xform_string), + rte_trace_point_emit_int(xform_enum); + rte_trace_point_emit_string(xform_string); +) + RTE_TRACE_POINT( rte_cryptodev_trace_asym_xform_capability_check_modlen, RTE_TRACE_POINT_ARGS(const void *capability, uint16_t modlen, int ret), diff --git a/lib/cryptodev/version.map b/lib/cryptodev/version.map index 00c99fb45c..372d042931 100644 --- a/lib/cryptodev/version.map +++ b/lib/cryptodev/version.map @@ -150,11 +150,21 @@ EXPERIMENTAL { __rte_cryptodev_trace_sym_session_get_user_data; __rte_cryptodev_trace_sym_session_set_user_data; __rte_cryptodev_trace_count; + + # added 23.03 + rte_cryptodev_asym_get_xform_string; + rte_cryptodev_get_aead_algo_string; + rte_cryptodev_get_auth_algo_string; + rte_cryptodev_get_cipher_algo_string; }; INTERNAL { global: + __rte_cryptodev_trace_asym_get_xform_string; + __rte_cryptodev_trace_get_aead_algo_string; + __rte_cryptodev_trace_get_auth_algo_string; + __rte_cryptodev_trace_get_cipher_algo_string; cryptodev_fp_ops_reset; cryptodev_fp_ops_set; rte_cryptodev_allocate_driver;