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 E505BA0513; Thu, 16 Jan 2020 00:20:43 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 484E81C026; Thu, 16 Jan 2020 00:20:43 +0100 (CET) Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) by dpdk.org (Postfix) with ESMTP id CDB641C024 for ; Thu, 16 Jan 2020 00:20:41 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga104.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 15 Jan 2020 15:20:40 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.70,323,1574150400"; d="scan'208";a="213871253" Received: from fmsmsx103.amr.corp.intel.com ([10.18.124.201]) by orsmga007.jf.intel.com with ESMTP; 15 Jan 2020 15:20:40 -0800 Received: from fmsmsx603.amr.corp.intel.com (10.18.126.83) by FMSMSX103.amr.corp.intel.com (10.18.124.201) with Microsoft SMTP Server (TLS) id 14.3.439.0; Wed, 15 Jan 2020 15:20:40 -0800 Received: from fmsmsx603.amr.corp.intel.com (10.18.126.83) by fmsmsx603.amr.corp.intel.com (10.18.126.83) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Wed, 15 Jan 2020 15:20:39 -0800 Received: from FMSEDG002.ED.cps.intel.com (10.1.192.134) by fmsmsx603.amr.corp.intel.com (10.18.126.83) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.1713.5 via Frontend Transport; Wed, 15 Jan 2020 15:20:39 -0800 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (104.47.58.105) by edgegateway.intel.com (192.55.55.69) with Microsoft SMTP Server (TLS) id 14.3.439.0; Wed, 15 Jan 2020 15:20:39 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZtiSarg2Tynq8OeTL38h4iVXJ56bB5q7/fRXXnMQWDWcsKTrVsQ+UAwm0+SpF9KsUSIqzsHIpw8eFokeW0uEqBvAgJkYlzpKUhmJ04D2Umw3DTmTbvG7TTh/vmaj80FDHcVVaMb+fzdURGn/Bh6iCU83V6JsgvnInCEY2c+0co76TK27f/5hd+A7VBPqLBNDKpjQlLiCb9wSsARDsm+6+V7qESTpWfZSTWJjlhqnLwO/mCBojh53pw9ixXdjT0A8ZyD6gZ9Kd0oTbNpSMLRW8C7TJiG6BhBakpB+CAjuLnroFBdf2VyQKQiNseAjc0FnpYUJrSW2W30hmbVuTeprrw== 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=qF82+9gJORKTMML22kCUy6Wj1XciNu8Qc0w87l3zdYI=; b=PX2mAkuDT1UEo8f4FABOywoaKmhJSh9MYFkyJNpij8BcLUzTGBNYZHIk7vwXK1fi5cE8TK0It/CD8rzVYI1rr5SA0ErhUeWPeyRV6F9jc8su05UfjNKqsp8c1pP6UrbbgO0zXYqJpDEjqzWXRY8fcTha6KRCKkoK3LaCultOLKCmN+41ObpZeqgQ5mjZZBqK3ljLAyVCkUrpyo+MTcAihKacFH0x8ZeXYIRqD9rnLEHTsGkSGVzSBse6G8Xa1xDU3oDfWS66eHiXVs/06q42l14HTBkx3gZhX/xTpZD16sehVi1SoIN29FIqB1JhsFZloETZ++VblCFoaBZ/Vz84RQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.onmicrosoft.com; s=selector2-intel-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=qF82+9gJORKTMML22kCUy6Wj1XciNu8Qc0w87l3zdYI=; b=W1DJrrRXHPWzVaNaCNXHmr6vZTJgsJVlSzWU9jzZO+tluXPcvUOL9ZQeY/cDhAIW5cB3tzRkKLA0lcpNYYxuVT2/fuZJxX8nmEvxHoqCZwrDpsAKVw5bIQVbkOr2HODxrFZxNHkJC7XP29hdNvDUzEjYIHDMBAUGFC9eaojTsnU= Received: from SN6PR11MB2558.namprd11.prod.outlook.com (52.135.94.19) by SN6PR11MB3104.namprd11.prod.outlook.com (52.135.124.21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2623.11; Wed, 15 Jan 2020 23:20:35 +0000 Received: from SN6PR11MB2558.namprd11.prod.outlook.com ([fe80::4d86:362a:13c3:8386]) by SN6PR11MB2558.namprd11.prod.outlook.com ([fe80::4d86:362a:13c3:8386%7]) with mapi id 15.20.2644.015; Wed, 15 Jan 2020 23:20:35 +0000 From: "Ananyev, Konstantin" To: "Smoczynski, MarcinX" , "akhil.goyal@nxp.com" , "Zhang, Roy Fan" , "Doherty, Declan" , "Nicolau, Radu" CC: "dev@dpdk.org" Thread-Topic: [PATCH v3 1/6] cryptodev: introduce cpu crypto support API Thread-Index: AQHVy9H3OXdDrx6nmUCOrx84WCRkhafsXG/w Date: Wed, 15 Jan 2020 23:20:35 +0000 Message-ID: References: <20200115182832.17012-1-marcinx.smoczynski@intel.com> <20200115182832.17012-2-marcinx.smoczynski@intel.com> In-Reply-To: <20200115182832.17012-2-marcinx.smoczynski@intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiYTNmZmY5OTUtNWMyOC00ZDU1LTg2NDctNjBiMGQzMmEzODg0IiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoickNCS0FYWHVMK1wvaEFFYWl1ejhmYmdmTG1HQ0Q2XC9cL0dWZElwVWhcLytPd3dDaWlEN1krWjZYMGkrZEsrU1FuUjAifQ== dlp-product: dlpe-windows dlp-reaction: no-action dlp-version: 11.2.0.6 x-ctpclassification: CTP_NT authentication-results: spf=none (sender IP is ) smtp.mailfrom=konstantin.ananyev@intel.com; x-originating-ip: [192.198.151.179] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 3cac034d-eaa1-462c-e49a-08d79a118673 x-ms-traffictypediagnostic: SN6PR11MB3104: x-ld-processed: 46c98d88-e344-4ed4-8496-4ed7712e255d,ExtAddr x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:3631; x-forefront-prvs: 02830F0362 x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(396003)(346002)(376002)(366004)(39860400002)(136003)(199004)(189003)(81166006)(8676002)(2906002)(71200400001)(26005)(81156014)(66476007)(6636002)(86362001)(110136005)(478600001)(186003)(66946007)(76116006)(66556008)(33656002)(6506007)(316002)(55016002)(4326008)(52536014)(9686003)(8936002)(64756008)(66446008)(7696005)(5660300002); DIR:OUT; SFP:1102; SCL:1; SRVR:SN6PR11MB3104; H:SN6PR11MB2558.namprd11.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: ILw8bP3NWgY1+JYjuanzfi7HMKGEwWLR/9ECiZ/qb0shz76YOj3GZnNRFS2f092bk6p6sdOU9zaE1P/gwk5tqCs/534KEoIMgajjm0iwG3OWsDpyUnyxhRCdy+WpDmHEmy+MGVCtTBxqoJLjVHHtV8Jj52Tn03tiFIF7bQsKnQvkN9eAzwYsWeXKP/aof05TnOsryst9iZkghQSuK3d3oZJsPeC5RpfwQazfIAm/eNKm7xjhWnVAvJrXrFR6V5sUD/aCJZaF89g4NezyMSjClIGAMS6f3Ish8SDGGXwhvBdN1oE+wLdxaYdlPE/CBIM0NMP6VcWxc7gjGqNIfXhy/DJyIfyNNyCcqdaF0vaQuWV1sm7GQL2uZ2yrEbW/v9f9uuOLvMItQtNLAEyW8HetFYLBLzp/ak6PhfdFSe9y3/J5I33qRpP8E31U6WeMmnLC Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Exchange-CrossTenant-Network-Message-Id: 3cac034d-eaa1-462c-e49a-08d79a118673 X-MS-Exchange-CrossTenant-originalarrivaltime: 15 Jan 2020 23:20:35.4689 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: luagF0dGZjCYUgb77k+tue6tVwKACO5xdHqIAfZB58YzSkUtRD+YNxdwGPZeA+TYdFC09RdjTKRFOGvJbrEPV6dk59aCD0jzuW1ruwz4WLk= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR11MB3104 X-OriginatorOrg: intel.com Subject: Re: [dpdk-dev] [PATCH v3 1/6] cryptodev: introduce cpu crypto support 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 Marcin, =20 > Add new API allowing to process crypto operations in a synchronous > manner. Operations are performed on a set of SG arrays. >=20 > Sync mode is selected by setting appropriate flag in an xform > type number. Cryptodevs which allows CPU crypto operation mode have to > use RTE_CRYPTODEV_FF_SYM_CPU_CRYPTO capability. >=20 > Signed-off-by: Konstantin Ananyev > Signed-off-by: Marcin Smoczynski > --- > lib/librte_cryptodev/rte_crypto_sym.h | 62 ++++++++++++++++++- > lib/librte_cryptodev/rte_cryptodev.c | 30 +++++++++ > lib/librte_cryptodev/rte_cryptodev.h | 20 ++++++ > lib/librte_cryptodev/rte_cryptodev_pmd.h | 19 ++++++ > .../rte_cryptodev_version.map | 1 + > 5 files changed, 131 insertions(+), 1 deletion(-) >=20 > diff --git a/lib/librte_cryptodev/rte_crypto_sym.h b/lib/librte_cryptodev= /rte_crypto_sym.h > index ffa038dc4..f5dd05ab0 100644 > --- a/lib/librte_cryptodev/rte_crypto_sym.h > +++ b/lib/librte_cryptodev/rte_crypto_sym.h > @@ -25,6 +25,59 @@ extern "C" { > #include > #include >=20 > +/** > + * Crypto IO Vector (in analogy with struct iovec) > + * Supposed be used to pass input/output data buffers for crypto data-pa= th > + * functions. > + */ > +struct rte_crypto_vec { > + /** virtual address of the data buffer */ > + void *base; > + /** IOVA of the data buffer */ > + rte_iova_t *iova; > + /** length of the data buffer */ > + uint32_t len; > +}; > + > +struct rte_crypto_sgl { > + /** start of an array of vectors */ > + struct rte_crypto_vec *vec; > + /** size of an array of vectors */ > + uint32_t num; > +}; > + > +struct rte_crypto_sym_vec { > + /** array of SGL vectors */ > + struct rte_crypto_sgl *sgl; > + /** array of pointers to IV */ > + void **iv; > + /** array of pointers to AAD */ > + void **aad; > + /** array of pointers to digest */ > + void **digest; > + /** > + * array of statuses for each operation: > + * - 0 on success > + * - errno on error > + */ > + int32_t *status; > + /** number of operations to perform */ > + uint32_t num; > +}; > + > +/** > + * used for cpu_crypto_process_bulk() to specify head/tail offsets > + * for auth/cipher processing. > + */ > +union rte_crypto_sym_ofs { > + uint64_t raw; > + struct { > + struct { > + uint16_t head; > + uint16_t tail; > + } auth, cipher; > + } ofs; > +}; >=20 > /** Symmetric Cipher Algorithms */ > enum rte_crypto_cipher_algorithm { > @@ -425,7 +478,14 @@ 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_XFORM_TYPE_MASK =3D 0xFFFF, > + /**< xform type mask value */ > + RTE_CRYPTO_SYM_XFORM_FLAG_MASK =3D 0xFFFF0000, > + /**< xform flag mask value */ > + RTE_CRYPTO_SYM_CPU_CRYPTO =3D 0x80000000, > + /**< xform flag for cpu-crypto */ We probably can avoid that. Instead just expect each PMD that does provide FF_SYM_CPU_CRYPTO capability to always create session that is capable to work in both modes (sync/async)= . Apart from that - LGTM. Konstantin > }; >=20 > /** > diff --git a/lib/librte_cryptodev/rte_cryptodev.c b/lib/librte_cryptodev/= rte_cryptodev.c > index 89aa2ed3e..157fda890 100644 > --- a/lib/librte_cryptodev/rte_cryptodev.c > +++ b/lib/librte_cryptodev/rte_cryptodev.c > @@ -1616,6 +1616,36 @@ rte_cryptodev_sym_session_get_user_data( > return (void *)(sess->sess_data + sess->nb_drivers); > } >=20 > +static inline void > +sym_crypto_fill_status(struct rte_crypto_sym_vec *vec, int32_t errnum) > +{ > + uint32_t i; > + for (i =3D 0; i < vec->num; i++) > + vec->status[i] =3D errnum; > +} > + > +uint32_t > +rte_cryptodev_sym_cpu_crypto_process(uint8_t dev_id, > + struct rte_cryptodev_sym_session *sess, union rte_crypto_sym_ofs ofs, > + struct rte_crypto_sym_vec *vec) > +{ > + struct rte_cryptodev *dev; > + > + if (!rte_cryptodev_pmd_is_valid_dev(dev_id)) { > + sym_crypto_fill_status(vec, EINVAL); > + return 0; > + } > + > + dev =3D rte_cryptodev_pmd_get_dev(dev_id); > + > + if (*dev->dev_ops->sym_cpu_process =3D=3D NULL) { > + sym_crypto_fill_status(vec, ENOTSUP); > + return 0; > + } > + > + return dev->dev_ops->sym_cpu_process(dev, sess, ofs, vec); > +} > + > /** 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..8786dfb90 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_asy= m_xform_type *xform_enum, > /**< Support encrypted-digest operations where digest is appended to dat= a */ > #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 */ >=20 >=20 > /** > @@ -1274,6 +1276,24 @@ void * > rte_cryptodev_sym_session_get_user_data( > struct rte_cryptodev_sym_session *sess); >=20 > +/** > + * 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 ofs Start and stop offsets for auth and cipher operations > + * @param vec Vectorized operation descriptor > + * > + * @return > + * - Returns number of successfully processed packets. > + */ > +__rte_experimental > +uint32_t > +rte_cryptodev_sym_cpu_crypto_process(uint8_t dev_id, > + struct rte_cryptodev_sym_session *sess, union rte_crypto_sym_ofs ofs, > + struct rte_crypto_sym_vec *vec); > + > #ifdef __cplusplus > } > #endif > diff --git a/lib/librte_cryptodev/rte_cryptodev_pmd.h b/lib/librte_crypto= dev/rte_cryptodev_pmd.h > index fba14f2fa..5d9ee5fef 100644 > --- a/lib/librte_cryptodev/rte_cryptodev_pmd.h > +++ b/lib/librte_cryptodev/rte_cryptodev_pmd.h > @@ -308,6 +308,23 @@ typedef void (*cryptodev_sym_free_session_t)(struct = rte_cryptodev *dev, > */ > typedef void (*cryptodev_asym_free_session_t)(struct rte_cryptodev *dev, > 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 ofs Start and stop offsets for auth and cipher operations > + * @param vec Vectorized operation descriptor > + * > + * @return > + * - Returns number of successfully processed packets. > + * > + */ > +typedef uint32_t (*cryptodev_sym_cpu_crypto_process_t) > + (struct rte_cryptodev *dev, struct rte_cryptodev_sym_session *sess, > + union rte_crypto_sym_ofs ofs, struct rte_crypto_sym_vec *vec); > + >=20 > /** Crypto device operations function pointer table */ > struct rte_cryptodev_ops { > @@ -342,6 +359,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). */ > }; >=20 >=20 > diff --git a/lib/librte_cryptodev/rte_cryptodev_version.map b/lib/librte_= cryptodev/rte_cryptodev_version.map > index 1dd1e259a..6e41b4be5 100644 > --- a/lib/librte_cryptodev/rte_cryptodev_version.map > +++ b/lib/librte_cryptodev/rte_cryptodev_version.map > @@ -71,6 +71,7 @@ EXPERIMENTAL { > rte_cryptodev_asym_session_init; > rte_cryptodev_asym_xform_capability_check_modlen; > rte_cryptodev_asym_xform_capability_check_optype; > + rte_cryptodev_sym_cpu_crypto_process; > rte_cryptodev_sym_get_existing_header_session_size; > rte_cryptodev_sym_session_get_user_data; > rte_cryptodev_sym_session_pool_create; > -- > 2.17.1