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 2413DA04AB; Wed, 6 Nov 2019 15:50:04 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id C87F01C20F; Wed, 6 Nov 2019 15:50:03 +0100 (CET) Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by dpdk.org (Postfix) with ESMTP id 0E5592B87; Wed, 6 Nov 2019 15:50:01 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 06 Nov 2019 06:50:00 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.68,275,1569308400"; d="scan'208";a="403751079" Received: from irsmsx105.ger.corp.intel.com ([163.33.3.28]) by fmsmga006.fm.intel.com with ESMTP; 06 Nov 2019 06:49:59 -0800 Received: from irsmsx104.ger.corp.intel.com ([169.254.5.252]) by irsmsx105.ger.corp.intel.com ([169.254.7.210]) with mapi id 14.03.0439.000; Wed, 6 Nov 2019 14:49:59 +0000 From: "Ananyev, Konstantin" To: Akhil Goyal , "dev@dpdk.org" , "techboard@dpdk.org" CC: "Zhang, Roy Fan" , "Doherty, Declan" Thread-Topic: [RFC 3/4] cryptodev: introduce cpu-crypto API Thread-Index: AQHVlAjLfH+qseESAUSA6Wc+tyrMCKd9G4+AgAEdezA= Date: Wed, 6 Nov 2019 14:49:58 +0000 Message-ID: <2601191342CEEE43887BDE71AB97725801A8C812CC@IRSMSX104.ger.corp.intel.com> References: <20191105184122.15172-1-konstantin.ananyev@intel.com> <20191105184122.15172-4-konstantin.ananyev@intel.com> In-Reply-To: Accept-Language: en-IE, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiNjRkODEyMzEtN2MyZC00MWRlLWI1ODAtMmY3YTExMzQ4OThlIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoiRmJBZDZadFwvMFlIcHlEdDdYUkxvY294VHJ1MzZySHJoT0t0RlRibVQ3dkFreGpNVUFnOTRob0JocVdiT2VIdXYifQ== x-ctpclassification: CTP_NT dlp-product: dlpe-windows dlp-version: 11.2.0.6 dlp-reaction: no-action x-originating-ip: [163.33.239.180] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dpdk-dev] [RFC 3/4] cryptodev: introduce cpu-crypto API 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" Hi Akhil, > > This patch extends rte_cryptodev API with CPU-CRYPTO mode. > > This is done by reusing existing rte_crypto_sym_session structure itsel= f > > and related control-path cryptodev API (init/clear/get_size/etc.) > > For data-path new sym_cpu_ process() function is added into > > rte_cryptodev dev_ops. > > > > Crypto PMD that wants to support that functionality would need to: > > 1. claim RTE_CRYPTODEV_FF_SYM_CPU_CRYPTO capability supported. > > 2. change at least the following functions inside rte_cryptodev_ops: > > . sym_session_get_size, > > . sym_session_configure, > > . sym_session_clear > > to accommodate support for both sync and async modes, > > 3. implement new function inside rte_cryptodev_ops: > > sym_cpu_process > > > > For data-path processing consumer of that API would have to maintain: > > struct rte_cryptodev_sym_session *sess, > > list of dev ids for which this session was properly initialized > > > > As an advantage of this approach - reuse of existing API > > and minimal visible changes for crypto PMDs. > > > > Signed-off-by: Konstantin Ananyev > > --- > > lib/librte_cryptodev/rte_crypto_sym.h | 11 ++++++++++- > > lib/librte_cryptodev/rte_cryptodev.c | 14 ++++++++++++++ > > lib/librte_cryptodev/rte_cryptodev.h | 24 ++++++++++++++++++++++++ > > lib/librte_cryptodev/rte_cryptodev_pmd.h | 22 ++++++++++++++++++++++ > > 4 files changed, 70 insertions(+), 1 deletion(-) > > > > diff --git a/lib/librte_cryptodev/rte_crypto_sym.h > > b/lib/librte_cryptodev/rte_crypto_sym.h > > index d8d9e9514..790c77524 100644 > > --- a/lib/librte_cryptodev/rte_crypto_sym.h > > +++ b/lib/librte_cryptodev/rte_crypto_sym.h > > @@ -166,6 +166,10 @@ struct rte_crypto_cipher_xform { > > * - Both keys must have the same size. > > **/ > > > > + /** > > + * CPU-CRYPTO specific data, should be set properly when > > + * (xform->type & RTE_CRYPTO_SYM_CPU_CRYPTO) !=3D 0, otherwise > > ignored. > > + */ > > struct { > > /** > > * offset for cipher to start within user provided data buffer. >=20 > Earlier I was ok to have this offset but on another thought, why do you n= eed this? > User can give the exact pointer in the process() API from where he wants = to do ciphering. > You will be adding this offset in the driver if you keep this in xform/se= ssion. So I think there is > no difference whether you add in the driver or the application. Am I miss= ing something? At least for ipsec this value is always constant for session (usually ESP h= eader + IV).=20 So seems better to set it once inside session, instead of passing an array of same constant values for each process() call. >=20 > > @@ -415,6 +419,10 @@ struct rte_crypto_aead_xform { > > uint16_t length; /**< key length in bytes */ > > } __attribute__((__packed__)) key; > > > > + /** > > + * CPU-CRYPTO specific data, should be set properly when > > + * (xform->type & RTE_CRYPTO_SYM_CPU_CRYPTO) !=3D 0, otherwise > > ignored. > > + */ > > struct { > > /** > > * offset for cipher to start within user provided data buffer. > > @@ -471,7 +479,8 @@ enum rte_crypto_sym_xform_type { > > RTE_CRYPTO_SYM_XFORM_NOT_SPECIFIED =3D 0, /**< No xform > > specified */ > > RTE_CRYPTO_SYM_XFORM_AUTH, /**< Authentication > > xform */ > > RTE_CRYPTO_SYM_XFORM_CIPHER, /**< Cipher xform */ > > - RTE_CRYPTO_SYM_XFORM_AEAD /**< AEAD xform */ > > + RTE_CRYPTO_SYM_XFORM_AEAD, /**< AEAD xform */ > > + RTE_CRYPTO_SYM_CPU_CRYPTO =3D INT32_MIN, /**< xform for cpu- > > crypto */ >=20 > This is not a correct place to have this. All types of xforms CIPHER/AUTH= /AEAD > can be used in SYNC mode The intention is to use it as a flag. For async mode only we just do let say .type =3D RTE_CRYPTO_SYM_XFORM_AEAD; (as we do now) For async+sync modes: .type =3D RTE_CRYPTO_SYM_XFORM_AEAD | RTE_CRYPTO_SYM_CPU_CRYPTO; >=20 > > }; > > > > /** > > diff --git a/lib/librte_cryptodev/rte_cryptodev.c > > b/lib/librte_cryptodev/rte_cryptodev.c > > index 89aa2ed3e..b1dbaf4c1 100644 > > --- a/lib/librte_cryptodev/rte_cryptodev.c > > +++ b/lib/librte_cryptodev/rte_cryptodev.c > > @@ -1616,6 +1616,20 @@ rte_cryptodev_sym_session_get_user_data( > > return (void *)(sess->sess_data + sess->nb_drivers); > > } > > > > +__rte_experimental > > +int > > +rte_cryptodev_sym_cpu_crypto_process(uint8_t dev_id, > > + struct rte_cryptodev_sym_session *sess, struct rte_crypto_sym_vec > > *vec, > > + int32_t status[], uint32_t num) > > +{ > > + struct rte_cryptodev *dev; > > + > > + dev =3D rte_cryptodev_pmd_get_dev(dev_id); > > + RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->sym_cpu_process,- > > ENOTSUP); > > + > > + return dev->dev_ops->sym_cpu_process(dev, sess, vec, status, num); > > +} > > + > > /** Initialise rte_crypto_op mempool element */ > > static void > > rte_crypto_op_init(struct rte_mempool *mempool, > > diff --git a/lib/librte_cryptodev/rte_cryptodev.h > > b/lib/librte_cryptodev/rte_cryptodev.h > > index c6ffa3b35..24877006c 100644 > > --- a/lib/librte_cryptodev/rte_cryptodev.h > > +++ b/lib/librte_cryptodev/rte_cryptodev.h > > @@ -450,6 +450,8 @@ rte_cryptodev_asym_get_xform_enum(enum > > rte_crypto_asym_xform_type *xform_enum, > > /**< Support encrypted-digest operations where digest is appended to d= ata */ > > #define RTE_CRYPTODEV_FF_ASYM_SESSIONLESS (1ULL << 20) > > /**< Support asymmetric session-less operations */ > > +#define RTE_CRYPTODEV_FF_SYM_CPU_CRYPTO > > (1ULL << 21) > > +/**< Support symmeteric cpu-crypto processing */ > > > > > > /** > > @@ -1274,6 +1276,28 @@ void * > > rte_cryptodev_sym_session_get_user_data( > > struct rte_cryptodev_sym_session > > *sess); > > > > +/** > > + * Perform actual crypto processing (encrypt/digest or auth/decrypt) > > + * on user provided data. > > + * > > + * @param dev_id The device identifier. > > + * @param sess Cryptodev session structure > > + * @param vec Array of vectors for input data > > + * @param status Array of status values (one per vec) > > + * (RTE_CRYPTO_OP_STATUS_* values) > > + * @param num Number of elems in vec and status arrays. > > + * > > + * @return > > + * - Returns negative errno value on error, or non-negative number > > + * of successfully processed input vectors. > > + * > > +*/ > > +__rte_experimental > > +int > > +rte_cryptodev_sym_cpu_crypto_process(uint8_t dev_id, > > + struct rte_cryptodev_sym_session *sess, struct rte_crypto_sym_vec > > *vec, > > + int32_t status[], uint32_t num); > > + > > #ifdef __cplusplus > > } > > #endif > > diff --git a/lib/librte_cryptodev/rte_cryptodev_pmd.h > > b/lib/librte_cryptodev/rte_cryptodev_pmd.h > > index fba14f2fa..02e7a19ae 100644 > > --- a/lib/librte_cryptodev/rte_cryptodev_pmd.h > > +++ b/lib/librte_cryptodev/rte_cryptodev_pmd.h > > @@ -308,6 +308,26 @@ typedef void (*cryptodev_sym_free_session_t)(struc= t > > rte_cryptodev *dev, > > */ > > typedef void (*cryptodev_asym_free_session_t)(struct rte_cryptodev *de= v, > > struct rte_cryptodev_asym_session *sess); > > +/** > > + * Perform actual crypto processing (encrypt/digest or auth/decrypt) > > + * on user provided data. > > + * > > + * @param dev Crypto device pointer > > + * @param sess Cryptodev session structure > > + * @param vec Array of vectors for input data > > + * @param status Array of status values (one per vec) > > + * (RTE_CRYPTO_OP_STATUS_* values) > > + * @param num Number of elems in vec and status arrays. > > + * > > + * @return > > + * - Returns negative errno value on error, or non-negative number > > + * of successfully processed input vectors. > > + * > > +*/ > > +typedef int (*cryptodev_sym_cpu_crypto_process_t)(struct rte_cryptodev= *dev, > > + struct rte_cryptodev_sym_session *sess, struct rte_crypto_sym_vec > > *vec, > > + int32_t status[], uint32_t num); > > + > > > > /** Crypto device operations function pointer table */ > > struct rte_cryptodev_ops { > > @@ -342,6 +362,8 @@ struct rte_cryptodev_ops { > > /**< Clear a Crypto sessions private data. */ > > cryptodev_asym_free_session_t asym_session_clear; > > /**< Clear a Crypto sessions private data. */ > > + cryptodev_sym_cpu_crypto_process_t sym_cpu_process; > > + /**< process input data synchronously (cpu-crypto). */ > > }; > > > > > > -- > > 2.17.1