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 57806A04AB; Mon, 31 Aug 2020 08:24:24 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 4232E1515; Mon, 31 Aug 2020 08:24:23 +0200 (CEST) Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by dpdk.org (Postfix) with ESMTP id A5991DE0 for ; Mon, 31 Aug 2020 08:24:20 +0200 (CEST) IronPort-SDR: cI/fAxlssWKMPgwDnmA9oXUGPjKCzeLqPMhhMTiFi15TPlDR4vjYZL45CNrbNHFyOVXt3uLJvo t8I2a7+Cmo0A== X-IronPort-AV: E=McAfee;i="6000,8403,9729"; a="156920500" X-IronPort-AV: E=Sophos;i="5.76,374,1592895600"; d="scan'208";a="156920500" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Aug 2020 23:24:19 -0700 IronPort-SDR: k9E1KK6mYyIE6RPsU+sqBAuI3imobXwi2eQb0YRnOAuzAZz2hEd5k5TyB/dbAvd1BQfcVzavu/ QNLv+Ljn0Epg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.76,374,1592895600"; d="scan'208";a="314248128" Received: from fmsmsx604.amr.corp.intel.com ([10.18.126.84]) by orsmga002.jf.intel.com with ESMTP; 30 Aug 2020 23:24:19 -0700 Received: from fmsmsx604.amr.corp.intel.com (10.18.126.84) by fmsmsx604.amr.corp.intel.com (10.18.126.84) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Sun, 30 Aug 2020 23:24:00 -0700 Received: from fmsedg601.ED.cps.intel.com (10.1.192.135) by fmsmsx604.amr.corp.intel.com (10.18.126.84) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5 via Frontend Transport; Sun, 30 Aug 2020 23:24:00 -0700 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (104.47.58.169) by edgegateway.intel.com (192.55.55.70) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.1713.5; Sun, 30 Aug 2020 23:23:53 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=DXG0jwp5Dl07r7cFJ5xKmEgzUrqFk+0MtTzETcquCXrFo/QDYYIUriF7jelC5EacR/yxHSIfzwn5D2W7BB675dRbliC88OCPk/9wCqHJZdON4J/pP8FaqLAvvN+0sSLi33Awhz1jnt3ZSbqHZni9ST3F7jYYeHWPbUpsUXLwmu+/eJRhw40vQ+eB7td7kn1GSEVuhb4uV7u6M6o/vvxRXw0oVYgtZhULhMu729LtnBWOvPzo7vF9nNXIZQLgLLsOImLrXltiX4TL+PRiTjNeeveMko4FpLLJTMPvTmtRiBabyLXdshSODintLA2RVck07Sqvs1XBwEGrb08C8mhtaw== 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=oVNw3vg6LqvQCt7BaI91QOy/2Ptj3IL5weS/kBJv+gM=; b=DSbaF+f2OMQXPUzIw2+k7brJYEjnjesAUI4tcGE51kTsL8NXLW7dWMrYfzNrm20IEA2M+h8acvu+L7pKKkhDkQ2cz6To80Ji6YPXrIDCujWys/Q8oPHIwm+/aAoGG3w1r73C5h5ccLWW3E61wLGGwiQWRO+1Fg2GA2dPkfjSoyIQczanaEKTrHGRoiIGTNtt5wzDUpE/0Q9dPjrop3ajZsiVMB4Zwq43JDw+SrA9pOYJQxeaJX8hjoU0RVF3RghaYTRGSxv6r312uaTGp8rKMWpaESUGjwh7qzalMDKZ91IQZnjgsbcxftaf6rz4r6vKELLc066yipULqgVtvyh6Zw== 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=oVNw3vg6LqvQCt7BaI91QOy/2Ptj3IL5weS/kBJv+gM=; b=bimcSPp/OAWfskyM32TnssTx9BZT+1zE6Q0IBpq4tg4JzWft8/q3St5ua8f5sKnbr42BWBELnpuWw/8SJAMdI9omFidVM8qHkn91GBMKX3S54CjI8beEvcu+l/vrHIhLcecvYsTpDLfZqJEAp0hrjWIXGbRBZTE3s/5WK+4CD1A= Received: from CY4PR11MB1830.namprd11.prod.outlook.com (2603:10b6:903:125::21) by CY4PR1101MB2102.namprd11.prod.outlook.com (2603:10b6:910:1e::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3326.23; Mon, 31 Aug 2020 06:23:51 +0000 Received: from CY4PR11MB1830.namprd11.prod.outlook.com ([fe80::20a7:37c7:9ba7:94d]) by CY4PR11MB1830.namprd11.prod.outlook.com ([fe80::20a7:37c7:9ba7:94d%12]) with mapi id 15.20.3326.025; Mon, 31 Aug 2020 06:23:51 +0000 From: "Kusztal, ArkadiuszX" To: "Zhang, Roy Fan" , "dev@dpdk.org" CC: "akhil.goyal@nxp.com" , "Trahe, Fiona" , "Dybkowski, AdamX" , "Bronowski, PiotrX" Thread-Topic: [dpdk-dev v7 1/4] cryptodev: add crypto data-path service APIs Thread-Index: AQHWfTrsegAUCLA8IEewn0mKwDuAbKlRs/Hg Date: Mon, 31 Aug 2020 06:23:51 +0000 Message-ID: References: <20200818162833.20219-1-roy.fan.zhang@intel.com> <20200828125815.21614-1-roy.fan.zhang@intel.com> <20200828125815.21614-2-roy.fan.zhang@intel.com> In-Reply-To: <20200828125815.21614-2-roy.fan.zhang@intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-reaction: no-action dlp-version: 11.5.1.3 dlp-product: dlpe-windows x-ctpclassification: CTP_NT x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiMmEzNTQzMDItM2E5Yi00ZTMxLThmYjQtNDdhYjk2NDU5ZmY5IiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoiU2l0bEJ4NUppcnd3ZEpQRVRoQ0J0S0ViYlFkTnRxempLRXg0MEJFRU1lQklXQ3JRWHRKOGM5VXIzZk5XQWp5MSJ9 authentication-results: intel.com; dkim=none (message not signed) header.d=none;intel.com; dmarc=none action=none header.from=intel.com; x-originating-ip: [192.198.151.43] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: cf16955f-1e3e-43c0-b379-08d84d766df7 x-ms-traffictypediagnostic: CY4PR1101MB2102: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:8273; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: YzAKqlsl3A7QQM4bfIC6W/SEGPST50eNpVcDoh8kTANfrmwYDx68Z+2EnaWBoGi2gz1VCZGh9KHxnv2rlaUqrq+ivr5H6xnSiN5o5fm26oZD4PaERlA6vm8sLXU9sGw+7i31LosZfmGw126HscDMi0SscBBwy+4RmMsG5DCNfZ31PrJwJL5hrePuC/cHTQypzbb1gB7aJC+miHGS04mhJgrdFTwk8b/OjQZGAse0GXpdaCfN+sb/1VmOFSI0AtAUg4r6RyuHJ3TY26VpeT1GEVhKj7qI05r5w/xdHnnuego/tNZ3cV+KQ7pV/duwOkaELcl1Mq6Sd6zuH/Rs3d7RKg== x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:CY4PR11MB1830.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(39860400002)(346002)(366004)(136003)(376002)(396003)(26005)(8936002)(107886003)(110136005)(83380400001)(33656002)(52536014)(5660300002)(53546011)(478600001)(66574015)(7696005)(54906003)(6506007)(66946007)(9686003)(4326008)(30864003)(55016002)(71200400001)(76116006)(66556008)(2906002)(316002)(66476007)(186003)(8676002)(66446008)(64756008)(86362001)(579004); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata: LM8yobl6R7yeVU9InDiZqoDtnAhkPTxBJ98xypJBHekrCOIIr8RE06ZDQHUFnDalk3aXD5brdn2p72/17Twgw5BTkpfH2V+VCiYLhQQ7W+UADp71a4mUj3FZ/T2NF6Ocpg5bTJfm0XWeluj0hyF0X6reGvm7/cirVDuxXBQtnEYVhY5E/pW3wWvD6fINdHqMQwK6d3cneWFjqJz42zsTbIN2TqoRs1/NZ+SFwHoNZsGxAo3pWPWqXeWoLQDrCXQxbb7tu+ty4ctTQ4xh+Yp1D5OyP3icfRJXKop/YkVS5YmLyj3eksHZYbSyYIWLPQOOa/QTZeCR/XrAmu1g9avWUXytAea6TAl8cToYWsVQcK02+7gnPF23QwEClU7DHyVRNhGCC6jDZZfLmCOqaDABhENEmxeZpYUbFqUb9U6yX5KJANCFjdD4pwSaeBYtWGwIw66DhHa0odF60i4EVcyKm5mLkXbLKmemfLMnfJ5SCTKALRn57Gf7Jof7DPhJpvuJ7o5pDzJuZ7Vx5HSRryvGhN4Jnw2GhyWMr4IqWghZvGsgd3SKhvzCTsWMv5CYJiE3mEX+GhUsBQlxWuI9Rjr0MBOp7s1UhD0+Dd1lCsC/qO9/LgXXfkxRevOQ4Qh7pBUEe3Ws51IvzWH5SG0q4hMZoQ== Content-Type: text/plain; charset="iso-8859-2" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: CY4PR11MB1830.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: cf16955f-1e3e-43c0-b379-08d84d766df7 X-MS-Exchange-CrossTenant-originalarrivaltime: 31 Aug 2020 06:23:51.8575 (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: jiSW8QDzfdS35CSlysCIJFs0Dho3PgWCBnu9m0FEZPz02vURdjyfdGeLvgMGreTKxC4l16gCuXW2D1UCu1VyYrPn31ZQC+v3coK0/2DMpyg= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR1101MB2102 X-OriginatorOrg: intel.com Subject: Re: [dpdk-dev] [dpdk-dev v7 1/4] cryptodev: add crypto data-path service APIs 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 Fan, Piotrek, -----Original Message----- From: Zhang, Roy Fan =20 Sent: pi=B1tek, 28 sierpnia 2020 14:58 To: dev@dpdk.org Cc: akhil.goyal@nxp.com; Trahe, Fiona ; Kusztal, Ark= adiuszX ; Dybkowski, AdamX ; Zhang, Roy Fan ; Bronowski, PiotrX Subject: [dpdk-dev v7 1/4] cryptodev: add crypto data-path service APIs This patch adds data-path service APIs for enqueue and dequeue operations t= o cryptodev. The APIs support flexible user-define enqueue and dequeue beha= viors and operation mode. Signed-off-by: Fan Zhang Signed-off-by: Piotr Bronowski --- lib/librte_cryptodev/rte_crypto.h | 9 + lib/librte_cryptodev/rte_crypto_sym.h | 44 ++- lib/librte_cryptodev/rte_cryptodev.c | 45 +++ lib/librte_cryptodev/rte_cryptodev.h | 335 +++++++++++++++++- lib/librte_cryptodev/rte_cryptodev_pmd.h | 47 ++- .../rte_cryptodev_version.map | 10 + 6 files changed, 481 insertions(+), 9 deletions(-) diff --git a/lib/librte_cryptodev/rte_crypto.h b/lib/librte_cryptodev/rte_c= rypto.h index fd5ef3a87..f009be9af 100644 --- a/lib/librte_cryptodev/rte_crypto.h +++ b/lib/librte_cryptodev/rte_crypto.h @@ -438,6 +438,15 @@ rte_crypto_op_attach_asym_session(struct rte_crypto_op= *op, return 0; } =20 +/** Crypto data-path service types */ +enum rte_crypto_dp_service { + RTE_CRYPTO_DP_SYM_CIPHER_ONLY =3D 0, + RTE_CRYPTO_DP_SYM_AUTH_ONLY, + RTE_CRYPTO_DP_SYM_CHAIN, [Arek] - if it is auth-cipher/cipher-auth will be decided thanks to sym_ses= sion/xform? + RTE_CRYPTO_DP_SYM_AEAD, + RTE_CRYPTO_DP_N_SERVICE +}; + #ifdef __cplusplus } #endif diff --git a/lib/librte_cryptodev/rte_crypto_sym.h b/lib/librte_cryptodev/r= te_crypto_sym.h index f29c98051..518e4111b 100644 --- a/lib/librte_cryptodev/rte_crypto_sym.h +++ b/lib/librte_cryptodev/rte_crypto_sym.h @@ -50,6 +50,18 @@ struct rte_crypto_sgl { uint32_t num; }; =20 +/** + * Crypto IO Data without length info. + * Supposed to be used to pass input/output data buffers with lengths + * defined when creating crypto session. + */ +struct rte_crypto_data { + /** virtual address of the data buffer */ + void *base; + /** IOVA of the data buffer */ + rte_iova_t iova; +}; + /** * Synchronous operation descriptor. * Supposed to be used with CPU crypto API call. @@ -57,12 +69,32 @@ struct rte_crypto_sgl { 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; + + union { + + /* Supposed to be used with CPU crypto API call. */ + struct { + /** array of pointers to IV */ + void **iv; + /** array of pointers to AAD */ + void **aad; + /** array of pointers to digest */ + void **digest; + }; + + /* Supposed to be used with rte_cryptodev_dp_sym_submit_vec() + * call. + */ + struct { + /** vector to IV */ + struct rte_crypto_data *iv_vec; + /** vecor to AAD */ + struct rte_crypto_data *aad_vec; + /** vector to Digest */ + struct rte_crypto_data *digest_vec; + }; + }; + /** * array of statuses for each operation: * - 0 on success diff --git a/lib/librte_cryptodev/rte_cryptodev.c b/lib/librte_cryptodev/rt= e_cryptodev.c index 1dd795bcb..8a28511f9 100644 --- a/lib/librte_cryptodev/rte_cryptodev.c +++ b/lib/librte_cryptodev/rte_cryptodev.c @@ -1914,6 +1914,51 @@ rte_cryptodev_sym_cpu_crypto_process(uint8_t dev_id, return dev->dev_ops->sym_cpu_process(dev, sess, ofs, vec); } =20 +int +rte_cryptodev_get_dp_service_ctx_data_size(uint8_t dev_id) { + struct rte_cryptodev *dev; + int32_t size =3D sizeof(struct rte_crypto_dp_service_ctx); + int32_t priv_size; + + if (!rte_cryptodev_pmd_is_valid_dev(dev_id)) + return -1; + + dev =3D rte_cryptodev_pmd_get_dev(dev_id); + + if (*dev->dev_ops->get_drv_ctx_size =3D=3D NULL || + !(dev->feature_flags & RTE_CRYPTODEV_FF_DATA_PLANE_SERVICE)) { + return -1; + } + + priv_size =3D (*dev->dev_ops->get_drv_ctx_size)(dev); + if (priv_size < 0) + return -1; + + return RTE_ALIGN_CEIL((size + priv_size), 8); } + +int +rte_cryptodev_dp_configure_service(uint8_t dev_id, uint16_t qp_id, + enum rte_crypto_dp_service service_type, + enum rte_crypto_op_sess_type sess_type, + union rte_cryptodev_session_ctx session_ctx, + struct rte_crypto_dp_service_ctx *ctx, uint8_t is_update) { + struct rte_cryptodev *dev; + + if (!rte_cryptodev_get_qp_status(dev_id, qp_id)) + return -1; + + dev =3D rte_cryptodev_pmd_get_dev(dev_id); + if (!(dev->feature_flags & RTE_CRYPTODEV_FF_DATA_PLANE_SERVICE) + || dev->dev_ops->configure_service =3D=3D NULL) + return -1; + [Arek] - Why to change order of arguments between rte_cryptodev_dp_configur= e_service and configure_service pointer? Except of dev and dev_id they all = are the same. + return (*dev->dev_ops->configure_service)(dev, qp_id, ctx, + service_type, sess_type, session_ctx, is_update); } + /** Initialise rte_crypto_op mempool element */ static void rte_crypto_o= p_init(struct rte_mempool *mempool, diff --git a/lib/librte_cryptodev/rte_c= ryptodev.h b/lib/librte_cryptodev/rte_cryptodev.h index 7b3ebc20f..9c97846f3 100644 --- a/lib/librte_cryptodev/rte_cryptodev.h +++ b/lib/librte_cryptodev/rte_cryptodev.h @@ -466,7 +466,8 @@ rte_cryptodev_asym_get_xform_enum(enum rte_crypto_asym_= xform_type *xform_enum, /**< Support symmetric session-less operations */ #define RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA (1ULL << 23) /**< Support operations on data which is not byte aligned */ - +#define RTE_CRYPTODEV_FF_DATA_PLANE_SERVICE (1ULL << 24) +/**< Support accelerated specific raw data as input */ =20 /** * Get the name of a crypto device feature flag @@ -1351,6 +1352,338 @@ rt= e_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); =20 +/** + * Get the size of the data-path service context for all registered driver= s. + * + * @param dev_id The device identifier. + * + * @return + * - If the device supports data-path service, return the context size. + * - If the device does not support the data-plane service, return -1. + */ +__rte_experimental +int +rte_cryptodev_get_dp_service_ctx_data_size(uint8_t dev_id); + +/** + * Union of different crypto session types, including session-less=20 +xform + * pointer. + */ +union rte_cryptodev_session_ctx { + struct rte_cryptodev_sym_session *crypto_sess; + struct rte_crypto_sym_xform *xform; + struct rte_security_session *sec_sess; }; + +/** + * Submit a data vector into device queue but the driver will not start + * processing until rte_cryptodev_dp_sym_submit_vec() is called. [Arek] " until ``rte_cryptodev_dp_submit_done`` function is called " ? + * + * @param qp Driver specific queue pair data. + * @param service_data Driver specific service data. + * @param vec The array of job vectors. + * @param ofs Start and stop offsets for auth and cipher + * operations. + * @param opaque The array of opaque data for dequeue. + * @return + * - The number of jobs successfully submitted. + */ +typedef uint32_t (*cryptodev_dp_sym_submit_vec_t)( + void *qp, uint8_t *service_data, struct rte_crypto_sym_vec *vec, + union rte_crypto_sym_ofs ofs, void **opaque); + +/** + * Submit single job into device queue but the driver will not start + * processing until rte_cryptodev_dp_sym_submit_vec() is called. [Arek] until ``rte_cryptodev_dp_submit_done`` function is called " as above= . + * + * @param qp Driver specific queue pair data. + * @param service_data Driver specific service data. + * @param data The buffer vector. + * @param n_data_vecs Number of buffer vectors. + * @param ofs Start and stop offsets for auth and cipher + * operations. + * @param iv IV data. + * @param digest Digest data. + * @param aad AAD data. + * @param opaque The opaque data for dequeue. + * @return + * - On success return 0. + * - On failure return negative integer. [Arek] How can we distinguish between malformed packet and full queue? + */ +typedef int (*cryptodev_dp_submit_single_job_t)( + void *qp, uint8_t *service_data, struct rte_crypto_vec *data, + uint16_t n_data_vecs, union rte_crypto_sym_ofs ofs, + struct rte_crypto_data *iv, struct rte_crypto_data *digest, + struct rte_crypto_data *aad, void *opaque); + +/** + * Inform the queue pair to start processing or finish dequeuing all + * submitted/dequeued jobs. + * + * @param qp Driver specific queue pair data. + * @param service_data Driver specific service data. + * @param n The total number of submitted jobs. + */ +typedef void (*cryptodev_dp_sym_operation_done_t)(void *qp, + uint8_t *service_data, uint32_t n); + +/** + * Typedef that the user provided for the driver to get the dequeue count. + * The function may return a fixed number or the number parsed from the=20 +opaque + * data stored in the first processed job. + * + * @param opaque Dequeued opaque data. + **/ +typedef uint32_t (*rte_cryptodev_get_dequeue_count_t)(void *opaque); + +/** + * Typedef that the user provided to deal with post dequeue operation,=20 +such + * as filling status. + * + * @param opaque Dequeued opaque data. In case + * RTE_CRYPTO_HW_DP_FF_GET_OPAQUE_ARRAY bit is + * set, this value will be the opaque data stored + * in the specific processed jobs referenced by + * index, otherwise it will be the opaque data + * stored in the first processed job in the burst. + * @param index Index number of the processed job. + * @param is_op_success Driver filled operation status. + **/ +typedef void (*rte_cryptodev_post_dequeue_t)(void *opaque, uint32_t index, + uint8_t is_op_success); + +/** + * Dequeue symmetric crypto processing of user provided data. + * + * @param qp Driver specific queue pair data. + * @param service_data Driver specific service data. + * @param get_dequeue_count User provided callback function to + * obtain dequeue count. + * @param post_dequeue User provided callback function to + * post-process a dequeued operation. + * @param out_opaque Opaque pointer array to be retrieve from + * device queue. In case of + * *is_opaque_array* is set there should + * be enough room to store all opaque data. + * @param is_opaque_array Set 1 if every dequeued job will be + * written the opaque data into + * *out_opaque* array. + * @param n_success_jobs Driver written value to specific the + * total successful operations count. + * + * @return + * - Returns number of dequeued packets. + */ +typedef uint32_t (*cryptodev_dp_sym_dequeue_t)(void *qp, uint8_t *service_= data, + rte_cryptodev_get_dequeue_count_t get_dequeue_count, + rte_cryptodev_post_dequeue_t post_dequeue, + void **out_opaque, uint8_t is_opaque_array, + uint32_t *n_success_jobs); + +/** + * Dequeue symmetric crypto processing of user provided data. + * + * @param qp Driver specific queue pair data. + * @param service_data Driver specific service data. + * @param out_opaque Opaque pointer to be retrieve from + * device queue. + * + * @return + * - 1 if the job is dequeued and the operation is a success. + * - 0 if the job is dequeued but the operation is failed. + * - -1 if no job is dequeued. + */ +typedef int (*cryptodev_dp_sym_dequeue_single_job_t)( + void *qp, uint8_t *service_data, void **out_opaque); + +/** + * Context data for asynchronous crypto process. + */ +struct rte_crypto_dp_service_ctx { + void *qp_data; + + union { [Arek] - Why union? It will be extended by other structs in future? [Arek] - unnamed union and struct, C11 extension. + /* Supposed to be used for symmetric crypto service */ + struct { + cryptodev_dp_submit_single_job_t submit_single_job; + cryptodev_dp_sym_submit_vec_t submit_vec; + cryptodev_dp_sym_operation_done_t submit_done; + cryptodev_dp_sym_dequeue_t dequeue_opaque; + cryptodev_dp_sym_dequeue_single_job_t dequeue_single; + cryptodev_dp_sym_operation_done_t dequeue_done; + }; + }; + + /* Driver specific service data */ + uint8_t drv_service_data[]; [Arek] - flexible array, C99 so again extension +}; + +/** + * Configure one DP service context data. Calling this function for the=20 +first + * time the user should unset the *is_update* parameter and the driver=20 +will + * fill necessary operation data into ctx buffer. Only when + * rte_cryptodev_dp_submit_done() is called the data stored in the ctx=20 +buffer + * will not be effective. + * + * @param dev_id The device identifier. + * @param qp_id The index of the queue pair from which to + * retrieve processed packets. The value must be + * in the range [0, nb_queue_pair - 1] previously + * supplied to rte_cryptodev_configure(). + * @param service_type Type of the service requested. + * @param sess_type session type. + * @param session_ctx Session context data. + * @param ctx The data-path service context data. + * @param is_update Set 1 if ctx is pre-initialized but need + * update to different service type or session, + * but the rest driver data remains the same. [Arek] - if user will call it only once with is_update =3D=3D 1 will there = be any error shown about ctx not set when started processing or is it undef= ined behavior? + * @return + * - On success return 0. + * - On failure return negative integer. + */ +__rte_experimental +int +rte_cryptodev_dp_configure_service(uint8_t dev_id, uint16_t qp_id, + enum rte_crypto_dp_service service_type, + enum rte_crypto_op_sess_type sess_type, + union rte_cryptodev_session_ctx session_ctx, + struct rte_crypto_dp_service_ctx *ctx, uint8_t is_update); + +/** + * Submit single job into device queue but the driver will not start + * processing until rte_cryptodev_dp_sym_submit_vec() is called. + * + * @param ctx The initialized data-path service context data. + * @param data The buffer vector. + * @param n_data_vecs Number of buffer vectors. + * @param ofs Start and stop offsets for auth and cipher + * operations. + * @param iv IV data. + * @param digest Digest data. + * @param aad AAD data. + * @param opaque The array of opaque data for dequeue. + * @return + * - On success return 0. + * - On failure return negative integer. + */ +__rte_experimental +static __rte_always_inline int +rte_cryptodev_dp_submit_single_job(struct rte_crypto_dp_service_ctx *ctx, + struct rte_crypto_vec *data, uint16_t n_data_vecs, + union rte_crypto_sym_ofs ofs, + struct rte_crypto_data *iv, struct rte_crypto_data *digest, + struct rte_crypto_data *aad, void *opaque) { + return (*ctx->submit_single_job)(ctx->qp_data, ctx->drv_service_data, + data, n_data_vecs, ofs, iv, digest, aad, opaque); } + +/** + * Submit a data vector into device queue but the driver will not start + * processing until rte_cryptodev_dp_sym_submit_vec() is called. + * + * @param ctx The initialized data-path service context data. + * @param vec The array of job vectors. + * @param ofs Start and stop offsets for auth and cipher operations. + * @param opaque The array of opaque data for dequeue. + * @return + * - The number of jobs successfully submitted. + */ +__rte_experimental +static __rte_always_inline uint32_t +rte_cryptodev_dp_sym_submit_vec(struct rte_crypto_dp_service_ctx *ctx, + struct rte_crypto_sym_vec *vec, union rte_crypto_sym_ofs ofs, + void **opaque) +{ + return (*ctx->submit_vec)(ctx->qp_data, ctx->drv_service_data, vec, + ofs, opaque); +} + +/** + * Command the queue pair to start processing all submitted jobs from=20 +last + * rte_cryptodev_init_dp_service() call. + * + * @param ctx The initialized data-path service context data. + * @param n The total number of submitted jobs. + */ +__rte_experimental +static __rte_always_inline void +rte_cryptodev_dp_submit_done(struct rte_crypto_dp_service_ctx *ctx,=20 +uint32_t n) { + (*ctx->submit_done)(ctx->qp_data, ctx->drv_service_data, n); } + +/** + * Dequeue symmetric crypto processing of user provided data. + * + * @param ctx The initialized data-path service + * context data. + * @param get_dequeue_count User provided callback function to + * obtain dequeue count. + * @param post_dequeue User provided callback function to + * post-process a dequeued operation. + * @param out_opaque Opaque pointer array to be retrieve from + * device queue. In case of + * *is_opaque_array* is set there should + * be enough room to store all opaque data. + * @param is_opaque_array Set 1 if every dequeued job will be + * written the opaque data into + * *out_opaque* array. + * @param n_success_jobs Driver written value to specific the + * total successful operations count. + * + * @return + * - Returns number of dequeued packets. + */ +__rte_experimental +static __rte_always_inline uint32_t +rte_cryptodev_dp_sym_dequeue(struct rte_crypto_dp_service_ctx *ctx, + rte_cryptodev_get_dequeue_count_t get_dequeue_count, + rte_cryptodev_post_dequeue_t post_dequeue, + void **out_opaque, uint8_t is_opaque_array, + uint32_t *n_success_jobs) +{ + return (*ctx->dequeue_opaque)(ctx->qp_data, ctx->drv_service_data, + get_dequeue_count, post_dequeue, out_opaque, is_opaque_array, + n_success_jobs); +} + +/** + * Dequeue Single symmetric crypto processing of user provided data. + * + * @param ctx The initialized data-path service + * context data. + * @param out_opaque Opaque pointer to be retrieve from + * device queue. The driver shall support + * NULL input of this parameter. + * + * @return + * - 1 if the job is dequeued and the operation is a success. + * - 0 if the job is dequeued but the operation is failed. + * - -1 if no job is dequeued. + */ +__rte_experimental +static __rte_always_inline int +rte_cryptodev_dp_sym_dequeue_single_job(struct rte_crypto_dp_service_ctx *= ctx, + void **out_opaque) +{ + return (*ctx->dequeue_single)(ctx->qp_data, ctx->drv_service_data, + out_opaque); +} + +/** + * Inform the queue pair dequeue jobs finished. + * + * @param ctx The initialized data-path service context data. + * @param n The total number of jobs already dequeued. + */ +__rte_experimental +static __rte_always_inline void +rte_cryptodev_dp_dequeue_done(struct rte_crypto_dp_service_ctx *ctx,=20 +uint32_t n) { + (*ctx->dequeue_done)(ctx->qp_data, ctx->drv_service_data, n); } + #ifdef __cplusplus } #endif diff --git a/lib/librte_cryptodev/rte_cryptodev_pmd.h b/lib/librte_cryptode= v/rte_cryptodev_pmd.h index 81975d72b..bf0260c87 100644 --- a/lib/librte_cryptodev/rte_cryptodev_pmd.h +++ b/lib/librte_cryptodev/rte_cryptodev_pmd.h @@ -316,6 +316,41 @@ 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 +/** + * Typedef that the driver provided to get service context private date si= ze. + * + * @param dev Crypto device pointer. + * + * @return + * - On success return the size of the device's service context private = data. + * - On failure return negative integer. + */ +typedef int (*cryptodev_dp_get_service_ctx_size_t)( + struct rte_cryptodev *dev); + +/** + * Typedef that the driver provided to configure data-path service. + * + * @param dev Crypto device pointer. + * @param qp_id Crypto device queue pair index. + * @param ctx The data-path service context data. + * @param service_type Type of the service requested. + * @param sess_type session type. + * @param session_ctx Session context data. + * @param is_update Set 1 if ctx is pre-initialized but need + * update to different service type or session, + * but the rest driver data remains the same. + * buffer will always be one. + * @return + * - On success return 0. + * - On failure return negative integer. + */ +typedef int (*cryptodev_dp_configure_service_t)( + struct rte_cryptodev *dev, uint16_t qp_id, + struct rte_crypto_dp_service_ctx *ctx, + enum rte_crypto_dp_service service_type, + enum rte_crypto_op_sess_type sess_type, + union rte_cryptodev_session_ctx session_ctx, uint8_t is_update); =20 /** Crypto device operations function pointer table */ struct rte_cryptod= ev_ops { @@ -348,8 +383,16 @@ 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). */ + union { + cryptodev_sym_cpu_crypto_process_t sym_cpu_process; + /**< process input data synchronously (cpu-crypto). */ + struct { + cryptodev_dp_get_service_ctx_size_t get_drv_ctx_size; + /**< Get data path service context data size. */ + cryptodev_dp_configure_service_t configure_service; + /**< Initialize crypto service ctx data. */ + }; + }; }; =20 =20 diff --git a/lib/librte_cryptodev/rte_cryptodev_version.map b/lib/librte_cr= yptodev/rte_cryptodev_version.map index 02f6dcf72..d384382d3 100644 --- a/lib/librte_cryptodev/rte_cryptodev_version.map +++ b/lib/librte_cryptodev/rte_cryptodev_version.map @@ -105,4 +105,14 @@ EXPERIMENTAL { =20 # added in 20.08 rte_cryptodev_get_qp_status; + + # added in 20.11 + rte_cryptodev_dp_configure_service; + rte_cryptodev_get_dp_service_ctx_data_size; [Arek] - I know its experimental but following 6 functions are not only sta= tic but __always_inline__ too, I doubt there will be any symbol generated, = should they be placed inside map file then? [Arek] - Another thing since symbol is not created these funcs are outside = of abidifftool scope of interest either I think. + rte_cryptodev_dp_submit_single_job; + rte_cryptodev_dp_sym_submit_vec; + rte_cryptodev_dp_submit_done; + rte_cryptodev_dp_sym_dequeue; + rte_cryptodev_dp_sym_dequeue_single_job; + rte_cryptodev_dp_dequeue_done; }; [Arek] - Two small things: - rte_crypto_data - there is many thing in asymmetric/symmetric crypto tha= t can be called like that, and this is basically symmetric encrypted/authen= ticated data pointer, maybe some more specific name could be better. - can iv, digest, aad be grouped into one? All share the same features, an= d there would less arguments to functions. -- 2.20.1