From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 1B7BEA0561; Mon, 20 Apr 2020 16:22:38 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id F09BB1C2F0; Mon, 20 Apr 2020 16:22:37 +0200 (CEST) Received: from EUR01-HE1-obe.outbound.protection.outlook.com (mail-eopbgr130081.outbound.protection.outlook.com [40.107.13.81]) by dpdk.org (Postfix) with ESMTP id 988E71C2E1 for ; Mon, 20 Apr 2020 16:22:36 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=j8lf5o1HuNiFBAUwlR85hoF6fC78ROiRDpxMumYULuULjZr5gY4ffu8RXZNH2KDvfoZfrfvzWIFgyx4J/xzavUf5K3Ybk7b5jpFjsT0vcCFg3OrRSOqDkTQ4FhxlWR6355jNzDOec6Fl8Rs04fv7leSK2nUCSnZ/uOyxPkgJRZX/Gwdzre5f34WwVtyimkCLH+zoubglX6eUQY9UrXaf+45Y4oM0xg3+7Nwf4XKQQqvIilbQvs6iljOR83Esja40Gc5CnP9/sFcLSaArcTMGR5aHFixVddTZswKoKEW2wcL0G9AIk3pgxhF8Rl64X6KbTSNYdiweNjKD0DXIsS1wWw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=8e65jUDllmJ7h9Er0wEyeWC7+wcvk9ConmS747MhlZ8=; b=VOdFJpP5R+W1er872AfqbaT6qb6ILsnVKgwcbSt5552iLA+jUQQ5lXeh2jT7KtTIWOEG1bDUu0NowBCDEkAbYnRWxh3P2EOSJCIpa402U6yoL0rCqp1d6wwwe5Ytsr/ZFnitAyDaeVJYJwCXMdVOa+oBVvSuYBu5juvqfrT+oTtRYGJKRAGSfo9BkrsezdXf2vVPJHAXRiaCUiRrfQa5ZwdVF5WCLBtBsvrHqRmeoIHAM9zCxaXbO4tc2oZy1KLZEZkoY8Z0LWeX7PHVAICDChiug2BQcekNj2A/izdZiY+vtzcrk8lg7TRFtK1836Pz45HzZeW1oCsh52dDQNJ9Ow== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=8e65jUDllmJ7h9Er0wEyeWC7+wcvk9ConmS747MhlZ8=; b=RCyeXg2sNma3AvoSrD0r89CcGj8yeMGfqcM9cQc/EeHLmxxf0PbfHwIIev8xqaEOWrWg9BSAepDO6WLSOsqJg4aED4Se+39FUF98+vYExsLjEQUfEUNSb6zMsXU7kNwqp5ruPghB4XoFYL389wmgXPcFVq96RwJhyQXIK+OEftQ= Received: from VI1PR04MB3168.eurprd04.prod.outlook.com (2603:10a6:802:6::10) by VI1PR04MB4430.eurprd04.prod.outlook.com (2603:10a6:803:65::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2921.29; Mon, 20 Apr 2020 14:22:34 +0000 Received: from VI1PR04MB3168.eurprd04.prod.outlook.com ([fe80::8c03:2f5:3b48:ba74]) by VI1PR04MB3168.eurprd04.prod.outlook.com ([fe80::8c03:2f5:3b48:ba74%7]) with mapi id 15.20.2921.027; Mon, 20 Apr 2020 14:22:34 +0000 From: Akhil Goyal To: Arek Kusztal , "dev@dpdk.org" , Ray Kinsella CC: "fiona.trahe@intel.com" , Thomas Monjalon Thread-Topic: [PATCH v3] cryptodev: version cryptodev info get function Thread-Index: AQHWFMjcB0wk1LfvoUytWfMXMHTAWaiCED9Q Date: Mon, 20 Apr 2020 14:22:34 +0000 Message-ID: References: <20200417145924.2052-1-arkadiuszx.kusztal@intel.com> In-Reply-To: <20200417145924.2052-1-arkadiuszx.kusztal@intel.com> Accept-Language: en-IN, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=akhil.goyal@nxp.com; x-originating-ip: [45.118.167.83] x-ms-publictraffictype: Email x-ms-office365-filtering-ht: Tenant x-ms-office365-filtering-correlation-id: 1179b440-1cdd-4b6c-2f1f-08d7e5364528 x-ms-traffictypediagnostic: VI1PR04MB4430: x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:10000; x-forefront-prvs: 03793408BA x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:VI1PR04MB3168.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFTY:; SFS:(10009020)(4636009)(376002)(39860400002)(396003)(366004)(136003)(346002)(5660300002)(26005)(55016002)(478600001)(316002)(30864003)(9686003)(54906003)(52536014)(110136005)(45080400002)(86362001)(33656002)(4326008)(81156014)(8936002)(66946007)(2906002)(71200400001)(44832011)(7696005)(6506007)(8676002)(66556008)(76116006)(66446008)(64756008)(66476007)(186003); DIR:OUT; SFP:1101; received-spf: None (protection.outlook.com: nxp.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: 0QaCT98WwdG19g3YBhYBsioM6rC+1uOa31rq+Y3IFnFWd7mm8E37Y9QxQkDHSb93UjFq4rszp2lP8Cb+4VQKtRK0d/pNfsNGdRAYyK39tjuVX9QJX4jO98b42onlTQWof15Cs9cTuNPDbXWY1XY1fUMI5OzOMF370T0lBYofjlynYQYihdr2rqLJEXCd3UEwHSfMstFB2YQWTBxuo7ID7Hh9bXkGjdpBSbZ4jVL+h97I6QrIGF5/OWzkghXFL41bb8ea4VuoUF4r65FFlhBI4PUW0rhdJmuOFfHWjILXzPyLEcNJDNmqhNcspd9FCfq2lY7ZMGLs5BQA/RTfMxj6lgNxw5T2PAQDCWCddAQgXyv9HZZ7Ro5kjWySCNDn+9Ijw6nq8AS7SxZrtALFOqG0lzALHUAuLLM+Y5NlD+wIp2k4YpVZPz2uyAb5UuOG10nwgXu3LPXoULyQ/xlRVef/z/D76cxgcrJvfD7Oier5i5g= x-ms-exchange-antispam-messagedata: qDEcm9MDMB+VLjFjdq2wsbaARFGd+uOu9rZ5Pt19HYqoBxIB0YHPnchDLNrlZY41orEFfL/31qlB2SKLHC9zkZIwpapRFIOYSSFr9++SCJPIlymL5qFOdqXJKOkz96t/N3OVOroXJuizhfDReyfxSA== x-ms-exchange-transport-forked: True Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1179b440-1cdd-4b6c-2f1f-08d7e5364528 X-MS-Exchange-CrossTenant-originalarrivaltime: 20 Apr 2020 14:22:34.6111 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: r+xxO3cT4QYiOSTw7CTV9eSbFbXLGXJnKebbLQHGFfeIBnfX+GErd2tcLDEQhLxnccrjL+YKjBLhYX0wRcpweA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB4430 Subject: Re: [dpdk-dev] [PATCH v3] cryptodev: version cryptodev info get function X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" >=20 > This patch adds versioned function rte_cryptodev_info_get() > to prevent some issues with ABI policy. > Node v21 works in same way as before, returning driver capabilities > directly to the API caller. These capabilities may include new elements > not part of the v20 ABI. > Node v20 function maintains compatibility with v20 ABI releases > by stripping out elements not supported in v20 ABI. Because > rte_cryptodev_info_get is called by other API functions, > rte_cryptodev_sym_capability_get function is versioned the same way. >=20 > Signed-off-by: Arek Kusztal > --- > v2: > - changed version numbers of symbols to 20.0.2 > v3: > - added v2/v3 informations > - changed version numbers of symbols to 21 > - fixed checkpatch issues >=20 > This patch depends on following patches: >=20 > [1] - "[v3] cryptodev: add chacha20-poly1305 aead algorithm" > (https://eur01.safelinks.protection.outlook.com/?url=3Dhttp%3A%2F%2Fpatch= wor > k.dpdk.org%2Fpatch%2F64549%2F&data=3D02%7C01%7Cakhil.goyal%40nxp. > com%7Ce6789fd42a5946c128e508d7e2dffe2f%7C686ea1d3bc2b4c6fa92cd99c > 5c301635%7C0%7C0%7C637227323980059545&sdata=3D50eQJE7WHTME6d > qA7Nfk%2B50PVAyJrpKlMw%2BoGtA1%2FTc%3D&reserved=3D0) Please include the dependent patches in a single series in your next versio= n. >=20 > lib/librte_cryptodev/rte_cryptodev.c | 143 +++++++++++++++++++= +++++- > lib/librte_cryptodev/rte_cryptodev.h | 39 ++++++- > lib/librte_cryptodev/rte_cryptodev_version.map | 7 ++ > 3 files changed, 186 insertions(+), 3 deletions(-) >=20 > diff --git a/lib/librte_cryptodev/rte_cryptodev.c > b/lib/librte_cryptodev/rte_cryptodev.c > index 6d1d0e9..b061447 100644 > --- a/lib/librte_cryptodev/rte_cryptodev.c > +++ b/lib/librte_cryptodev/rte_cryptodev.c > @@ -41,6 +41,9 @@ > #include "rte_cryptodev.h" > #include "rte_cryptodev_pmd.h" >=20 > +#include > +#include > + > static uint8_t nb_drivers; >=20 > static struct rte_cryptodev rte_crypto_devices[RTE_CRYPTO_MAX_DEVS]; > @@ -56,6 +59,14 @@ static struct rte_cryptodev_global cryptodev_globals = =3D { > /* spinlock for crypto device callbacks */ > static rte_spinlock_t rte_cryptodev_cb_lock =3D RTE_SPINLOCK_INITIALIZER= ; >=20 > +static const struct rte_cryptodev_capabilities > + cryptodev_undefined_capabilities[] =3D { > + RTE_CRYPTODEV_END_OF_CAPABILITIES_LIST() > +}; > + > +static struct rte_cryptodev_capabilities > + *capability_copies[RTE_CRYPTO_MAX_DEVS]; Capabilities_copy is a better name as it is copy of many capabilities. > +static uint8_t is_capability_checked[RTE_CRYPTO_MAX_DEVS]; >=20 > /** > * The user application callback description. > @@ -280,7 +291,43 @@ rte_crypto_auth_operation_strings[] =3D { > }; >=20 > const struct rte_cryptodev_symmetric_capability * > -rte_cryptodev_sym_capability_get(uint8_t dev_id, > +rte_cryptodev_sym_capability_get_v20(uint8_t dev_id, __vsym Annotation to be used in a declaration of the internal symbol to signal that it is being used as an implementation of a particular version of symbol. > + const struct rte_cryptodev_sym_capability_idx *idx) > +{ > + const struct rte_cryptodev_capabilities *capability; > + struct rte_cryptodev_info dev_info; > + int i =3D 0; > + > + rte_cryptodev_info_get_v20(dev_id, &dev_info); > + > + while ((capability =3D &dev_info.capabilities[i++])->op !=3D > + RTE_CRYPTO_OP_TYPE_UNDEFINED) { > + if (capability->op !=3D RTE_CRYPTO_OP_TYPE_SYMMETRIC) > + continue; > + > + if (capability->sym.xform_type !=3D idx->type) > + continue; > + > + if (idx->type =3D=3D RTE_CRYPTO_SYM_XFORM_AUTH && > + capability->sym.auth.algo =3D=3D idx->algo.auth) > + return &capability->sym; > + > + if (idx->type =3D=3D RTE_CRYPTO_SYM_XFORM_CIPHER && > + capability->sym.cipher.algo =3D=3D idx->algo.cipher) > + return &capability->sym; > + > + if (idx->type =3D=3D RTE_CRYPTO_SYM_XFORM_AEAD && > + capability->sym.aead.algo =3D=3D idx->algo.aead) > + return &capability->sym; > + } > + > + return NULL; > + Extra line > +} > +VERSION_SYMBOL(rte_cryptodev_sym_capability_get, _v20, 20.0); > + > +const struct rte_cryptodev_symmetric_capability * __vsym annotation > +rte_cryptodev_sym_capability_get_v21(uint8_t dev_id, > const struct rte_cryptodev_sym_capability_idx *idx) > { > const struct rte_cryptodev_capabilities *capability; > @@ -313,6 +360,10 @@ rte_cryptodev_sym_capability_get(uint8_t dev_id, > return NULL; >=20 > } > +MAP_STATIC_SYMBOL(const struct rte_cryptodev_symmetric_capability * > + rte_cryptodev_sym_capability_get(uint8_t dev_id, > + const struct rte_cryptodev_sym_capability_idx *idx), > + rte_cryptodev_sym_capability_get_v21); >=20 > static int > param_range_check(uint16_t size, const struct rte_crypto_param_range *ra= nge) > @@ -999,6 +1050,13 @@ rte_cryptodev_close(uint8_t dev_id) > RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->dev_close, -ENOTSUP); > retval =3D (*dev->dev_ops->dev_close)(dev); >=20 > + > + if (capability_copies[dev_id]) { > + free(capability_copies[dev_id]); > + capability_copies[dev_id] =3D NULL; > + } > + is_capability_checked[dev_id] =3D 0; > + > if (retval < 0) > return retval; >=20 > @@ -1111,9 +1169,61 @@ rte_cryptodev_stats_reset(uint8_t dev_id) > (*dev->dev_ops->stats_reset)(dev); > } >=20 > +static void > +get_v20_capabilities(uint8_t dev_id, struct rte_cryptodev_info *dev_info= ) > +{ > + const struct rte_cryptodev_capabilities *capability; > + uint8_t found_invalid_capa =3D 0; > + uint8_t counter =3D 0; > + > + for (capability =3D dev_info->capabilities; > + capability->op !=3D RTE_CRYPTO_OP_TYPE_UNDEFINED; > + ++capability, ++counter) { > + if (capability->op =3D=3D RTE_CRYPTO_OP_TYPE_SYMMETRIC && > + capability->sym.xform_type =3D=3D > + RTE_CRYPTO_SYM_XFORM_AEAD > + && capability->sym.aead.algo >=3D > + RTE_CRYPTO_AEAD_CHACHA20_POLY1305) { > + found_invalid_capa =3D 1; > + counter--; > + } > + } > + is_capability_checked[dev_id] =3D 1; > + if (found_invalid_capa) { Code becomes unreadable due to indentation which can be avoided. if (!found_invalid_capa) return; capability_copies[dev_id] =3D malloc(counter * sizeof(struct rte_cryptodev_= capabilities)); if (capability_copies[dev_id] =3D=3D NULL) { dev_info->capabilities =3D cryptodev_undefined_capabilities; is_capability_checked[dev_id] =3D 0; return; } counter =3D 0; for(...) { ... } > + capability_copies[dev_id] =3D malloc(counter * > + sizeof(struct rte_cryptodev_capabilities)); > + if (capability_copies[dev_id] =3D=3D NULL) { > + /* > + * error case - no memory to store the trimmed > + * list, so have to return an empty list > + */ > + dev_info->capabilities =3D > + cryptodev_undefined_capabilities; > + is_capability_checked[dev_id] =3D 0; > + } else { > + counter =3D 0; > + for (capability =3D dev_info->capabilities; > + capability->op !=3D > + RTE_CRYPTO_OP_TYPE_UNDEFINED; > + capability++) { > + if (!(capability->op =3D=3D > + RTE_CRYPTO_OP_TYPE_SYMMETRIC > + && capability->sym.xform_type =3D=3D > + RTE_CRYPTO_SYM_XFORM_AEAD > + && capability->sym.aead.algo >=3D > + > RTE_CRYPTO_AEAD_CHACHA20_POLY1305)) { > + capability_copies[dev_id][counter++] =3D > + *capability; > + } > + } > + dev_info->capabilities =3D > + capability_copies[dev_id]; > + } > + } > +} >=20 > void > -rte_cryptodev_info_get(uint8_t dev_id, struct rte_cryptodev_info *dev_in= fo) > +rte_cryptodev_info_get_v20(uint8_t dev_id, struct rte_cryptodev_info > *dev_info) > { > struct rte_cryptodev *dev; >=20 > @@ -1129,10 +1239,39 @@ rte_cryptodev_info_get(uint8_t dev_id, struct > rte_cryptodev_info *dev_info) > RTE_FUNC_PTR_OR_RET(*dev->dev_ops->dev_infos_get); > (*dev->dev_ops->dev_infos_get)(dev, dev_info); >=20 > + if (capability_copies[dev_id] =3D=3D NULL) { > + if (!is_capability_checked[dev_id]) > + get_v20_capabilities(dev_id, dev_info); > + } else > + dev_info->capabilities =3D capability_copies[dev_id]; > + > dev_info->driver_name =3D dev->device->driver->name; > dev_info->device =3D dev->device; > } > +VERSION_SYMBOL(rte_cryptodev_info_get, _v20, 20.0); > + > +void > +rte_cryptodev_info_get_v21(uint8_t dev_id, struct rte_cryptodev_info > *dev_info) > +{ > + struct rte_cryptodev *dev; > + > + if (!rte_cryptodev_pmd_is_valid_dev(dev_id)) { > + CDEV_LOG_ERR("Invalid dev_id=3D%d", dev_id); > + return; > + } > + > + dev =3D &rte_crypto_devices[dev_id]; >=20 > + memset(dev_info, 0, sizeof(struct rte_cryptodev_info)); > + > + RTE_FUNC_PTR_OR_RET(*dev->dev_ops->dev_infos_get); > + (*dev->dev_ops->dev_infos_get)(dev, dev_info); > + > + dev_info->driver_name =3D dev->device->driver->name; > + dev_info->device =3D dev->device; > +} > +MAP_STATIC_SYMBOL(void rte_cryptodev_info_get(uint8_t dev_id, > + struct rte_cryptodev_info *dev_info), rte_cryptodev_info_get_v21); >=20 > int > rte_cryptodev_callback_register(uint8_t dev_id, > diff --git a/lib/librte_cryptodev/rte_cryptodev.h > b/lib/librte_cryptodev/rte_cryptodev.h > index 437b8a9..7f1bc90 100644 > --- a/lib/librte_cryptodev/rte_cryptodev.h > +++ b/lib/librte_cryptodev/rte_cryptodev.h > @@ -24,6 +24,9 @@ extern "C" { > #include > #include >=20 > +#include > +#include > + > extern const char **rte_cyptodev_names; >=20 > /* Logging Macros */ > @@ -217,6 +220,15 @@ struct rte_cryptodev_asym_capability_idx { > * - Return NULL if the capability not exist. > */ > const struct rte_cryptodev_symmetric_capability * > +rte_cryptodev_sym_capability_get_v20(uint8_t dev_id, > + const struct rte_cryptodev_sym_capability_idx *idx); > + > +const struct rte_cryptodev_symmetric_capability * > +rte_cryptodev_sym_capability_get_v21(uint8_t dev_id, > + const struct rte_cryptodev_sym_capability_idx *idx); > +BIND_DEFAULT_SYMBOL(rte_cryptodev_sym_capability_get, _v21, 21); > + > +const struct rte_cryptodev_symmetric_capability * > rte_cryptodev_sym_capability_get(uint8_t dev_id, > const struct rte_cryptodev_sym_capability_idx *idx); >=20 > @@ -758,9 +770,34 @@ rte_cryptodev_stats_reset(uint8_t dev_id); > * the last valid element has it's op field set to > * RTE_CRYPTO_OP_TYPE_UNDEFINED. > */ > -extern void > + > +void > rte_cryptodev_info_get(uint8_t dev_id, struct rte_cryptodev_info *dev_in= fo); >=20 > +/* An extra element RTE_CRYPTO_AEAD_CHACHA20_POLY1305 is added > + * to enum rte_crypto_aead_algorithm, also changing the value of > + * RTE_CRYPTO_AEAD_LIST_END. To maintain ABI compatibility with > applications > + * which linked against earlier versions, preventing them, for example, = from > + * picking up the new value and using it to index into an array sized to= o small > + * for it, it is necessary to have two versions of rte_cryptodev_info_ge= t() > + * The latest version just returns directly the capabilities retrieved f= rom > + * the device. The compatible version inspects the capabilities retrieve= d > + * from the device, but only returns them directly if the new value > + * is not included. If the new value is included, it allocates space > + * for a copy of the device capabilities, trims the new value from this > + * and returns this copy. It only needs to do this once per device. > + * For the corner case of a corner case when the alloc may fail, > + * an empty capability list is returned, as there is no mechanism to ret= urn > + * an error and adding such a mechanism would itself be an ABI breakage. > + * The compatible version can be removed after the next major ABI releas= e. > + */ > + > +void > +rte_cryptodev_info_get_v20(uint8_t dev_id, struct rte_cryptodev_info > *dev_info); > + > +void > +rte_cryptodev_info_get_v21(uint8_t dev_id, struct rte_cryptodev_info > *dev_info); > +BIND_DEFAULT_SYMBOL(rte_cryptodev_info_get, _v21, 21); I am not sure if we need to bind for _v20 also BIND_DEFAULT_SYMBOL(rte_cryptodev_info_get, _v20, 20); Ray, can you please suggest if it required or not? And what all we need to = check? The patch is still showing Incompatibilities NOTICE: ABI may be incompatible, check reports/logs for details. NOTICE: Incompatible list: librte_cryptodev.so >=20 > /** > * Register a callback function for specific device id. > diff --git a/lib/librte_cryptodev/rte_cryptodev_version.map > b/lib/librte_cryptodev/rte_cryptodev_version.map > index 6e41b4b..512a4a7 100644 > --- a/lib/librte_cryptodev/rte_cryptodev_version.map > +++ b/lib/librte_cryptodev/rte_cryptodev_version.map > @@ -58,6 +58,13 @@ DPDK_20.0 { > local: *; > }; >=20 > +DPDK_21 { > + global: > + rte_cryptodev_info_get; > + rte_cryptodev_sym_capability_get; > +} DPDK_20.0; > + > + > EXPERIMENTAL { > global: >=20 > -- > 2.1.0