From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id EE3E54590C; Thu, 5 Sep 2024 12:15:03 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id CF01240264; Thu, 5 Sep 2024 12:15:03 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by mails.dpdk.org (Postfix) with ESMTP id 1F2EF4025C for ; Thu, 5 Sep 2024 12:15:01 +0200 (CEST) Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 48586aUn015000; Thu, 5 Sep 2024 03:14:50 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h= cc:content-transfer-encoding:content-type:date:from:message-id :mime-version:subject:to; s=pfpt0220; bh=tRVvipAzkFv3ulvTOimWDlp zUJR2q2vr+/UX/Asahdw=; b=PKRaCc4Gy2GlLu95GGZ0spuoOc0JsJ8PzODqayY fofu5inyuIa1jFj3ZPEVHVtTECufEQ8ygbha2ROK78gw4a+iDWPlZJe5VnbRIpsu fRWBX1FZwLBQFlZYEPOfaWEyrL/mdRFv7Oj/DIMmBXvm+I0a6pS/2noC4ha6RFMx rAk18gMWe31jVPUpDuyS9tn0H1Rz/bvNOpcLku++ryypZJdFEZWsnQaX8DePRM1a 7jkosjNnxh1vID2tdw8p5uXuBUhfZCBgSNV5cOnA/jqKYAIFAmk1M8qO3x0hzwAN m0GJ4N8gGh42V6kSx+x8GOLrKz5qir53/JesYFUovHYE1CQ== Received: from dc6wp-exch02.marvell.com ([4.21.29.225]) by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 41f8u48dx3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 05 Sep 2024 03:14:50 -0700 (PDT) Received: from DC6WP-EXCH02.marvell.com (10.76.176.209) by DC6WP-EXCH02.marvell.com (10.76.176.209) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Thu, 5 Sep 2024 03:14:49 -0700 Received: from maili.marvell.com (10.69.176.80) by DC6WP-EXCH02.marvell.com (10.76.176.209) with Microsoft SMTP Server id 15.2.1544.4 via Frontend Transport; Thu, 5 Sep 2024 03:14:49 -0700 Received: from localhost.localdomain (unknown [10.28.36.102]) by maili.marvell.com (Postfix) with ESMTP id 98B403F70A7; Thu, 5 Sep 2024 03:14:43 -0700 (PDT) From: Akhil Goyal To: CC: , , , , , , , , , , , , , , , , , , Akhil Goyal Subject: [PATCH] [RFC] cryptodev: replace LIST_END enumerators with APIs Date: Thu, 5 Sep 2024 15:44:38 +0530 Message-ID: <20240905101438.3888274-1-gakhil@marvell.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Proofpoint-ORIG-GUID: aNo8IR7XQSA_lz6ETQUFTdR04e3xoZy4 X-Proofpoint-GUID: aNo8IR7XQSA_lz6ETQUFTdR04e3xoZy4 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.60.29 definitions=2024-09-05_05,2024-09-04_01,2024-09-02_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 Replace *_LIST_END enumerators from asymmetric crypto lib to avoid ABI breakage for every new addition in enums with inline APIs. Signed-off-by: Akhil Goyal --- This patch was discussed in ML long time back. https://patches.dpdk.org/project/dpdk/patch/20211008204516.3497060-1-gakhil@marvell.com/ Now added inline APIs for getting the list end which need to be updated for each new entry to the enum. This shall help in avoiding ABI break for adding new algo. app/test/test_cryptodev_asym.c | 2 +- lib/cryptodev/rte_crypto_asym.h | 18 ++++++++++++++---- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/app/test/test_cryptodev_asym.c b/app/test/test_cryptodev_asym.c index f0b5d38543..f1ece475b8 100644 --- a/app/test/test_cryptodev_asym.c +++ b/app/test/test_cryptodev_asym.c @@ -581,7 +581,7 @@ static inline void print_asym_capa( rte_cryptodev_asym_get_xform_string(capa->xform_type)); printf("operation supported -"); - for (i = 0; i < RTE_CRYPTO_ASYM_OP_LIST_END; i++) { + for (i = 0; i < rte_crypto_asym_op_list_end(); i++) { /* check supported operations */ if (rte_cryptodev_asym_xform_capability_check_optype(capa, i)) { if (capa->xform_type == RTE_CRYPTO_ASYM_XFORM_DH) diff --git a/lib/cryptodev/rte_crypto_asym.h b/lib/cryptodev/rte_crypto_asym.h index 39d3da3952..290b300f84 100644 --- a/lib/cryptodev/rte_crypto_asym.h +++ b/lib/cryptodev/rte_crypto_asym.h @@ -72,6 +72,7 @@ enum rte_crypto_curve_id { * Asymmetric crypto transformation types. * Each xform type maps to one asymmetric algorithm * performing specific operation + * Note: Update rte_crypto_asym_xform_type_list_end() for every new type added. */ enum rte_crypto_asym_xform_type { RTE_CRYPTO_ASYM_XFORM_UNSPECIFIED = 0, @@ -119,12 +120,17 @@ enum rte_crypto_asym_xform_type { * Performs Encrypt, Decrypt, Sign and Verify. * Refer to rte_crypto_asym_op_type. */ - RTE_CRYPTO_ASYM_XFORM_TYPE_LIST_END - /**< End of list */ }; +static inline int +rte_crypto_asym_xform_type_list_end(void) +{ + return RTE_CRYPTO_ASYM_XFORM_SM2 + 1; +} + /** * Asymmetric crypto operation type variants + * Note: Update rte_crypto_asym_op_list_end for every new type added. */ enum rte_crypto_asym_op_type { RTE_CRYPTO_ASYM_OP_ENCRYPT, @@ -135,9 +141,14 @@ enum rte_crypto_asym_op_type { /**< Signature Generation operation */ RTE_CRYPTO_ASYM_OP_VERIFY, /**< Signature Verification operation */ - RTE_CRYPTO_ASYM_OP_LIST_END }; +static inline int +rte_crypto_asym_op_list_end(void) +{ + return RTE_CRYPTO_ASYM_OP_VERIFY + 1; +} + /** * Asymmetric crypto key exchange operation type */ @@ -168,7 +179,6 @@ enum rte_crypto_rsa_padding_type { /**< RSA PKCS#1 OAEP padding scheme */ RTE_CRYPTO_RSA_PADDING_PSS, /**< RSA PKCS#1 PSS padding scheme */ - RTE_CRYPTO_RSA_PADDING_TYPE_LIST_END }; /** -- 2.25.1