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 860DA4590E; Thu, 5 Sep 2024 17:09:06 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 712A342E61; Thu, 5 Sep 2024 17:09:06 +0200 (CEST) Received: from dkmailrelay1.smartsharesystems.com (smartserver.smartsharesystems.com [77.243.40.215]) by mails.dpdk.org (Postfix) with ESMTP id 61FF242E5F for ; Thu, 5 Sep 2024 17:09:04 +0200 (CEST) Received: from smartserver.smartsharesystems.com (smartserver.smartsharesys.local [192.168.4.10]) by dkmailrelay1.smartsharesystems.com (Postfix) with ESMTP id 349D220E92; Thu, 5 Sep 2024 17:09:04 +0200 (CEST) Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Subject: RE: [PATCH] [RFC] cryptodev: replace LIST_END enumerators with APIs Date: Thu, 5 Sep 2024 17:09:00 +0200 X-MimeOLE: Produced By Microsoft Exchange V6.5 Message-ID: <98CBD80474FA8B44BF855DF32C47DC35E9F6A8@smartserver.smartshare.dk> In-Reply-To: <20240905101438.3888274-1-gakhil@marvell.com> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: [PATCH] [RFC] cryptodev: replace LIST_END enumerators with APIs Thread-Index: Adr/fHxcuIWWjRn4Sg6xO/Iih6HtkAAJmGvw References: <20240905101438.3888274-1-gakhil@marvell.com> From: =?iso-8859-1?Q?Morten_Br=F8rup?= To: "Akhil Goyal" , Cc: , , , , , , , , , , , , , , , , , 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 > +++ 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 -"); >=20 > - for (i =3D 0; i < RTE_CRYPTO_ASYM_OP_LIST_END; i++) { > + for (i =3D 0; i < rte_crypto_asym_op_list_end(); i++) { > +++ b/lib/cryptodev/rte_crypto_asym.h > +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; > +} I like the concept of replacing an "last enum value" with a "last enum = function" for API/ABI compatibility purposes. Here's an idea... We can introduce a generic design pattern where we keep the _LIST_END = enum value at the end, somehow marking it private (and not part of the = API/ABI), and move the _list_end() function inside the C file, so it = uses the _LIST_END enum value that the library was built with. E.g. like = this: In the header file: enum rte_crypto_asym_op_type { RTE_CRYPTO_ASYM_OP_VERIFY, /**< Signature Verification operation */ #if RTE_BUILDING_INTERNAL __RTE_CRYPTO_ASYM_OP_LIST_END /* internal */ #endif } int rte_crypto_asym_op_list_end(void); And in the associated library code file, when including = rte_crypto_asym.h: #define RTE_BUILDING_INTERNAL #include int rte_crypto_asym_op_list_end(void) { return __RTE_CRYPTO_ASYM_OP_LIST_END; }