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 3BC05A2F6B for ; Wed, 9 Oct 2019 09:20:23 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 026D61C132; Wed, 9 Oct 2019 09:20:23 +0200 (CEST) Received: from EUR02-VE1-obe.outbound.protection.outlook.com (mail-eopbgr20081.outbound.protection.outlook.com [40.107.2.81]) by dpdk.org (Postfix) with ESMTP id 43AF91C115 for ; Wed, 9 Oct 2019 09:20:21 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Mwu73jTxUs2Dh71GV4nQ2NHbxeV/eE8Mjuc8CmXtxLH1U1VUcuPlMP4c1n8nHsMu2+5exQFW/5N5rQH6NWt1GBNufMN9VAHF0fwuGpOkYqTuRvaKP6LgdDdgDhiVhNAtjmjnRR1Rkja+cMbqceE1+jCvIz5MtxOrw6gA/zcyvuLHjkEFz+eRA/2zX5bx3bmcG9Y+6dkgvmCkSlTQNeRwLq7Vf+y77btZVTcifplTW333+8cMflHv0VVlfkpOM+//EKDxLEcB8O8mvVhOa8oYGHr2EmQ8Z9Sh7refIFpYRT4/GW8tg63cstqWQ1zQ1S+t8fliKRBb/p9ZMK/BbETsKQ== 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=nOvHs1i89fO7t1zt6lqTKdIWAZMBJ92ZS4iSAclXtxo=; b=eOuem+RJfVE1nTWw47g0uV1xu9Y4HpBC8o1SonW8bGd49yj/NAcW1K0M8+TDFa+ecb3qw2pk3uoAfoAPU3l46pkkhGE17vgRyZOju01uhCOIZSomD8GYZT0t22m8R4st/QPWjiFKprhNy9ZO6j/mulJd9Ccwn5vjb8svAF+N+puJJ1SJPnZfMWj/AC1sEyI5ZfoHZzeVC687otPMdGAq9mKIvIN/426HUMvJkWs+SOxkKCWHnwhxPNdwaLBOWlfP3Q6Vi3Tw+55kenJ7fkHOOR/A5wZNsFg+sNiX9jlJiZQCAis0Pp5IGbbsKFYojTjfK79OH34uGtxr/V8y948Xrg== 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=nOvHs1i89fO7t1zt6lqTKdIWAZMBJ92ZS4iSAclXtxo=; b=N0bJrii+xKwbD01xFSjTRD09VhXj/laJO7SzsEEbBRdPIaUgBLCb77SV6qALf1YwqA0c+sdDfObuUdXpPm5B5pmfHFnpS00MmC/3YtSxO3acR70RKHZyca78bF4e+/sxdv/dAM5hYeVTrUhHIrtvKTVBeZhPxU/pRffzwqMb0QA= Received: from VE1PR04MB6639.eurprd04.prod.outlook.com (10.255.118.11) by VE1PR04MB6349.eurprd04.prod.outlook.com (20.179.235.90) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2327.24; Wed, 9 Oct 2019 07:20:20 +0000 Received: from VE1PR04MB6639.eurprd04.prod.outlook.com ([fe80::c045:5df2:ba1f:c3ee]) by VE1PR04MB6639.eurprd04.prod.outlook.com ([fe80::c045:5df2:ba1f:c3ee%5]) with mapi id 15.20.2327.026; Wed, 9 Oct 2019 07:20:20 +0000 From: Akhil Goyal To: "Ananyev, Konstantin" , "'dev@dpdk.org'" , "De Lara Guarch, Pablo" , 'Thomas Monjalon' , "Zhang, Roy Fan" CC: "Doherty, Declan" , 'Anoob Joseph' Thread-Topic: [RFC PATCH 1/9] security: introduce CPU Crypto action type and API Thread-Index: AQHVYm4LqyJkewM9NkuUWAfAmrqx1acbUiZggAAsN4CAAtsIgIAAT02AgAYXC5CAAbSDgIABbRGggAaWxgCAAPjG4IABs/OAgAuzNYCAAoY34IAE8G8AgAAH4mCAAbN9gIADA/pwgAZJhgCAAr+oMA== Date: Wed, 9 Oct 2019 07:20:19 +0000 Message-ID: References: <20190903154046.55992-1-roy.fan.zhang@intel.com> <20190903154046.55992-2-roy.fan.zhang@intel.com> <9F7182E3F746AB4EA17801C148F3C6043369D686@IRSMSX101.ger.corp.intel.com> <2601191342CEEE43887BDE71AB9772580191926A17@irsmsx105.ger.corp.intel.com> <2601191342CEEE43887BDE71AB9772580191962CD5@irsmsx105.ger.corp.intel.com> <2601191342CEEE43887BDE71AB9772580191966116@irsmsx105.ger.corp.intel.com> <2601191342CEEE43887BDE71AB9772580191966C23@irsmsx105.ger.corp.intel.com> <2601191342CEEE43887BDE71AB977258019196A767@irsmsx105.ger.corp.intel.com> <2601191342CEEE43887BDE71AB977258019196D53D@irsmsx105.ger.corp.intel.com> <2601191342CEEE43887BDE71AB977258019196F386@irsmsx105.ger.corp.intel.com> <2601191342CEEE43887BDE71AB977258019197206C@irsmsx105.ger.corp.intel.com> In-Reply-To: <2601191342CEEE43887BDE71AB977258019197206C@irsmsx105.ger.corp.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: [92.120.1.65] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: f20476a3-3829-4069-3fd8-08d74c892469 x-ms-office365-filtering-ht: Tenant x-ms-traffictypediagnostic: VE1PR04MB6349: x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:5797; x-forefront-prvs: 018577E36E x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(4636009)(366004)(396003)(346002)(39860400002)(376002)(136003)(199004)(189003)(52314003)(51444003)(2906002)(6436002)(4326008)(8676002)(446003)(74316002)(305945005)(55016002)(7736002)(44832011)(478600001)(9686003)(476003)(52536014)(71200400001)(6246003)(99286004)(8936002)(6116002)(3846002)(256004)(71190400001)(14444005)(81166006)(81156014)(15650500001)(229853002)(486006)(11346002)(86362001)(5660300002)(30864003)(7696005)(110136005)(14454004)(6506007)(102836004)(561944003)(76116006)(25786009)(316002)(33656002)(26005)(54906003)(64756008)(66446008)(66476007)(186003)(76176011)(66066001)(66556008)(66946007)(21314003)(491001)(579004)(559001)(569006); DIR:OUT; SFP:1101; SCL:1; SRVR:VE1PR04MB6349; H:VE1PR04MB6639.eurprd04.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; 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: Zs6KyBMhTXPuamDgWI8KQhOV/MZmL5WPRohNGv+2a0bQgjgD5dy4c+krkoLV/7fVjUOwKBUyFC156jQW3EPr3RBf9tuKrTZdNe3qP0N1wZ6X6p/+rkeR9K7fw6TiNrF2FOhfRHi1gB1QoJTGwu0CRM7waU44RIkj71ZZibtuQVmTJvuJqi0bFmTnotoBA5rm0CdK7gCnnBTwHcXcA2k2d3L3PBAE1Mh9kUJz7ylj43CDbK/sbMi5MvNeJwTDQ8n6qMSdAxpt5hIGagE2Q/pnlF+tPWJIfdMhMfVGlzf4/j+LfCvFYl7cDM36f+nd7C7vqq74EIJX422q1zLpUgt2ANISnU86sMsm/7oOUQ4WPaEU2oDUz6qvvGc4TOK+oEaNvZjNr5BkXkZlEp4kaO5P1DhyqQrj9fgWpJRfho0BFk8= 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: f20476a3-3829-4069-3fd8-08d74c892469 X-MS-Exchange-CrossTenant-originalarrivaltime: 09 Oct 2019 07:20:19.9153 (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: 7gagOz0GAJrP7n2552vHa2jwYvo69YE+G7o4udIMTHq6KU/VwStEKdbl3Q7e2AiXrYfiRAuvNqlz+5VOesev6Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR04MB6349 Subject: Re: [dpdk-dev] [RFC PATCH 1/9] security: introduce CPU Crypto action type and 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 Konstantin, >=20 >=20 > Hi Akhil, >=20 > > > > > > > > > > > > > > > > This action type allows the burst of symmet= ric crypto > > > > > workload > > > > > > > using > > > > > > > > > > the > > > > > > > > > > > > > > same > > > > > > > > > > > > > > > > algorithm, key, and direction being process= ed by CPU > > > cycles > > > > > > > > > > > > synchronously. > > > > > > > > > > > > > > > > This flexible action type does not require = external > > > hardware > > > > > > > > > > involvement, > > > > > > > > > > > > > > > > having the crypto workload processed synchr= onously, > > > and is > > > > > > > more > > > > > > > > > > > > > > performant > > > > > > > > > > > > > > > > than Cryptodev SW PMD due to the saved cycl= es on > > > removed > > > > > > > "async > > > > > > > > > > > > mode > > > > > > > > > > > > > > > > simulation" as well as 3 cacheline access o= f the > crypto > > > ops. > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > Does that mean application will not call the > > > > > > > cryptodev_enqueue_burst > > > > > > > > > > and > > > > > > > > > > > > > > corresponding dequeue burst. > > > > > > > > > > > > > > > > > > > > > > > > > > > > Yes, instead it just call > > > rte_security_process_cpu_crypto_bulk(...) > > > > > > > > > > > > > > > > > > > > > > > > > > > > > It would be a new API something like process_= packets > and > > > it > > > > > will > > > > > > > have > > > > > > > > > > the > > > > > > > > > > > > > > crypto processed packets while returning from t= he API? > > > > > > > > > > > > > > > > > > > > > > > > > > > > Yes, though the plan is that API will operate o= n raw data > > > buffers, > > > > > > > not > > > > > > > > > > mbufs. > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > I still do not understand why we cannot do wi= th the > > > > > conventional > > > > > > > > > > crypto lib > > > > > > > > > > > > > > only. > > > > > > > > > > > > > > > As far as I can understand, you are not doing= any > protocol > > > > > > > processing > > > > > > > > > > or > > > > > > > > > > > > any > > > > > > > > > > > > > > value add > > > > > > > > > > > > > > > To the crypto processing. IMO, you just need = a > > > synchronous > > > > > > > crypto > > > > > > > > > > > > processing > > > > > > > > > > > > > > API which > > > > > > > > > > > > > > > Can be defined in cryptodev, you don't need t= o re- > create a > > > > > crypto > > > > > > > > > > session > > > > > > > > > > > > in > > > > > > > > > > > > > > the name of > > > > > > > > > > > > > > > Security session in the driver just to do a s= ynchronous > > > > > processing. > > > > > > > > > > > > > > > > > > > > > > > > > > > > I suppose your question is why not to have > > > > > > > > > > > > > > rte_crypot_process_cpu_crypto_bulk(...) instead= ? > > > > > > > > > > > > > > The main reason is that would require disruptiv= e changes > in > > > > > existing > > > > > > > > > > > > cryptodev > > > > > > > > > > > > > > API > > > > > > > > > > > > > > (would cause ABI/API breakage). > > > > > > > > > > > > > > Session for RTE_SECURITY_ACTION_TYPE_CPU_CRYPT= O > > > need > > > > > > > some > > > > > > > > > > extra > > > > > > > > > > > > > > information > > > > > > > > > > > > > > that normal crypto_sym_xform doesn't contain > > > > > > > > > > > > > > (cipher offset from the start of the buffer, mi= ght be > > > something > > > > > extra > > > > > > > in > > > > > > > > > > > > future). > > > > > > > > > > > > > > > > > > > > > > > > > > Cipher offset will be part of rte_crypto_op. > > > > > > > > > > > > > > > > > > > > > > > > fill/read (+ alloc/free) is one of the main things = that > slowdown > > > > > current > > > > > > > > > > crypto-op > > > > > > > > > > > > approach. > > > > > > > > > > > > That's why the general idea - have all data that wo= uldn't > change > > > > > from > > > > > > > packet > > > > > > > > > > to > > > > > > > > > > > > packet > > > > > > > > > > > > included into the session and setup it once at sess= ion_init(). > > > > > > > > > > > > > > > > > > > > > > I agree that you cannot use crypto-op. > > > > > > > > > > > You can have the new API in crypto. > > > > > > > > > > > As per the current patch, you only need cipher_offset= which > you > > > can > > > > > have > > > > > > > it as > > > > > > > > > > a parameter until > > > > > > > > > > > You get it approved in the crypto xform. I believe it= will be > > > beneficial > > > > > in > > > > > > > case of > > > > > > > > > > other crypto cases as well. > > > > > > > > > > > We can have cipher offset at both places(crypto-op an= d > > > > > cipher_xform). It > > > > > > > will > > > > > > > > > > give flexibility to the user to > > > > > > > > > > > override it. > > > > > > > > > > > > > > > > > > > > After having another thought on your proposal: > > > > > > > > > > Probably we can introduce new rte_crypto_sym_xform_type= s > for > > > CPU > > > > > > > related > > > > > > > > > > stuff here? > > > > > > > > > > > > > > > > > > I also thought of adding new xforms, but that wont serve = the > purpose > > > for > > > > > > > may be all the cases. > > > > > > > > > You would be needing all information currently available = in the > > > current > > > > > > > xforms. > > > > > > > > > So if you are adding new fields in the new xform, the siz= e will be > more > > > > > than > > > > > > > that of the union of xforms. > > > > > > > > > ABI breakage would still be there. > > > > > > > > > > > > > > > > > > If you think a valid compression of the AEAD xform can be= done, > then > > > > > that > > > > > > > can be done for each of the > > > > > > > > > Xforms and we can have a solution to this issue. > > > > > > > > > > > > > > > > I think that we can re-use iv.offset for our purposes (for = crypto > offset). > > > > > > > > So for now we can make that path work without any ABI break= age. > > > > > > > > Fan, please feel free to correct me here, if I missed somet= hing. > > > > > > > > If in future we would need to add some extra information it= might > > > > > > > > require ABI breakage, though by now I don't envision anythi= ng > > > particular to > > > > > > > add. > > > > > > > > Anyway, if there is no objection to go that way, we can try= to make > > > > > > > > these changes for v2. > > > > > > > > > > > > > > > > > > > > > > Actually, after looking at it more deeply it appears not that= easy as I > > > thought > > > > > it > > > > > > > would be :) > > > > > > > Below is a very draft version of proposed API additions. > > > > > > > I think it avoids ABI breakages right now and provides enough > flexibility > > > for > > > > > > > future extensions (if any). > > > > > > > For now, it doesn't address your comments about naming > conventions > > > > > (_CPU_ > > > > > > > vs _SYNC_) , etc. > > > > > > > but I suppose is comprehensive enough to provide a main idea > beyond it. > > > > > > > Akhil and other interested parties, please try to review and = provide > > > feedback > > > > > > > ASAP, > > > > > > > as related changes would take some time and we still like to = hit 19.11 > > > > > deadline. > > > > > > > Konstantin > > > > > > > > > > > > > > diff --git a/lib/librte_cryptodev/rte_crypto_sym.h > > > > > > > b/lib/librte_cryptodev/rte_crypto_sym.h > > > > > > > index bc8da2466..c03069e23 100644 > > > > > > > --- a/lib/librte_cryptodev/rte_crypto_sym.h > > > > > > > +++ b/lib/librte_cryptodev/rte_crypto_sym.h > > > > > > > @@ -103,6 +103,9 @@ rte_crypto_cipher_operation_strings[]; > > > > > > > * > > > > > > > * This structure contains data relating to Cipher (Encrypti= on and > > > Decryption) > > > > > > > * use to create a session. > > > > > > > + * Actually I was wrong saying that we don't have free space= inside > > > xforms. > > > > > > > + * Making key struct packed (see below) allow us to regain 6= B that > could > > > be > > > > > > > + * used for future extensions. > > > > > > > */ > > > > > > > struct rte_crypto_cipher_xform { > > > > > > > enum rte_crypto_cipher_operation op; > > > > > > > @@ -116,7 +119,25 @@ struct rte_crypto_cipher_xform { > > > > > > > struct { > > > > > > > const uint8_t *data; /**< pointer to key d= ata */ > > > > > > > uint16_t length; /**< key length in by= tes */ > > > > > > > - } key; > > > > > > > + } __attribute__((__packed__)) key; > > > > > > > + > > > > > > > + /** > > > > > > > + * offset for cipher to start within user provided d= ata buffer. > > > > > > > + * Fan suggested another (and less space consuming wa= y) - > > > > > > > + * reuse iv.offset space below, by changing: > > > > > > > + * struct {uint16_t offset, length;} iv; > > > > > > > + * to uunamed union: > > > > > > > + * union { > > > > > > > + * struct {uint16_t offset, length;} iv; > > > > > > > + * struct {uint16_t iv_len, crypto_offset} cpu_c= rypto_param; > > > > > > > + * }; > > > > > > > + * Both approaches seems ok to me in general. > > > > > > > > > > > > No strong opinions here. OK with this one. > > > > > > > > > > > > > + * Comments/suggestions are welcome. > > > > > > > + */ > > > > > > > + uint16_t offset; > > > > > > > > > > After another thought - it is probably a bit better to have offse= t as a > separate > > > > > field. > > > > > In that case we can use the same xforms to create both type of se= ssions. > > > > ok > > > > > > > > > > > > + > > > > > > > + uint8_t reserved1[4]; > > > > > > > + > > > > > > > /**< Cipher key > > > > > > > * > > > > > > > * For the RTE_CRYPTO_CIPHER_AES_F8 mode of operation= , > > > key.data > > > > > will > > > > > > > @@ -284,7 +305,7 @@ struct rte_crypto_auth_xform { > > > > > > > struct { > > > > > > > const uint8_t *data; /**< pointer to key d= ata */ > > > > > > > uint16_t length; /**< key length in by= tes */ > > > > > > > - } key; > > > > > > > + } __attribute__((__packed__)) key; > > > > > > > /**< Authentication key data. > > > > > > > * The authentication key length MUST be less than or= equal to > the > > > > > > > * block size of the algorithm. It is the callers res= ponsibility to > > > > > > > @@ -292,6 +313,8 @@ struct rte_crypto_auth_xform { > > > > > > > * (for example RFC 2104, FIPS 198a). > > > > > > > */ > > > > > > > > > > > > > > + uint8_t reserved1[6]; > > > > > > > + > > > > > > > struct { > > > > > > > uint16_t offset; > > > > > > > /**< Starting point for Initialisation Vector= or Counter, > > > > > > > @@ -376,7 +399,12 @@ struct rte_crypto_aead_xform { > > > > > > > struct { > > > > > > > const uint8_t *data; /**< pointer to key d= ata */ > > > > > > > uint16_t length; /**< key length in by= tes */ > > > > > > > - } key; > > > > > > > + } __attribute__((__packed__)) key; > > > > > > > + > > > > > > > + /** offset for cipher to start within data buffer */ > > > > > > > + uint16_t cipher_offset; > > > > > > > + > > > > > > > + uint8_t reserved1[4]; > > > > > > > > > > > > > > struct { > > > > > > > uint16_t offset; > > > > > > > diff --git a/lib/librte_cryptodev/rte_cryptodev.h > > > > > > > b/lib/librte_cryptodev/rte_cryptodev.h > > > > > > > index e175b838c..c0c7bfed7 100644 > > > > > > > --- a/lib/librte_cryptodev/rte_cryptodev.h > > > > > > > +++ b/lib/librte_cryptodev/rte_cryptodev.h > > > > > > > @@ -1272,6 +1272,101 @@ void * > > > > > > > rte_cryptodev_sym_session_get_user_data( > > > > > > > struct rte_cryptodev_= sym_session *sess); > > > > > > > > > > > > > > +/* > > > > > > > + * After several thoughts decided not to try to squeeze CPU_= CRYPTO > > > > > > > + * into existing rte_crypto_sym_session structure/API, but i= nstead > > > > > > > + * introduce an extentsion to it via new fully opaque > > > > > > > + * struct rte_crypto_cpu_sym_session and additional related = API. > > > > > > > > > > > > > > > > > > What all things do we need to squeeze? > > > > > > In this proposal I do not see the new struct cpu_sym_session d= efined > here. > > > > > > > > > > The plan is to have it totally opaque to the user, i.e. just: > > > > > struct rte_crypto_cpu_sym_session; > > > > > in public header files. > > > > > > > > > > > I believe you will have same lib API/struct for cpu_sym_session= and > > > > > sym_session. > > > > > > > > > > I thought about such way, but there are few things that looks clu= msy to > me: > > > > > 1. Right now there is no 'type' (or so) field inside > rte_cryptodev_sym_session, > > > > > so it is not possible to easy distinguish what session do you hav= e: > lksd_sym or > > > > > cpu_sym. > > > > > In theory, there is a hole of 4B inside rte_cryptodev_sym_session= , so we > can > > > add > > > > > some extra field > > > > > here, but in that case we wouldn't be able to use the same xform= for > both > > > > > lksd_sym or cpu_sym > > > > > (which seems really plausible thing for me). > > > > > 2. Majority of rte_cryptodev_sym_session fields I think are unne= cessary > for > > > > > rte_crypto_cpu_sym_session: > > > > > sess_data[], opaque_data, user_data, nb_drivers. > > > > > All that consumes space, that could be used somewhere else instea= d. > > > > > 3. I am a bit reluctant to touch existing rte_cryptodev API - to = avoid any > > > > > breakages I can't foresee right now. > > > > > From other side - if we'll add new functions/structs for cpu_sym_= session > we > > > can > > > > > mark it > > > > > and keep it for some time as experimental, so further changes (if= needed) > > > would > > > > > still be possible. > > > > > > > > > > > > > OK let us assume that you have a separate structure. But I have a f= ew > queries: > > > > 1. how can multiple drivers use a same session > > > > > > As a short answer: they can't. > > > It is pretty much the same approach as with rte_security - each devic= e needs > to > > > create/init its own session. > > > So upper layer would need to maintain its own array (or so) for such = case. > > > Though the question is why would you like to have same session over > multiple > > > SW backed devices? > > > As it would be anyway just a synchronous function call that will be e= xecuted > on > > > the same cpu. > > > > I may have single FAT tunnel which may be distributed over multiple > > Cores, and each core is affined to a different SW device. >=20 > If it is pure SW, then we don't need multiple devices for such scenario. > Device in that case is pure abstraction that we can skip. Yes agreed, but that liberty is given to the application whether it need mu= ltiple devices with single queue or a single device with multiple queues. I think that independence should not be broken in this new API. >=20 > > So a single session may be accessed by multiple devices. > > > > One more example would be depending on packet sizes, I may switch betwe= en > > HW/SW PMDs with the same session. >=20 > Sure, but then we'll have multiple sessions. No, the session will be same and it will have multiple private data for eac= h of the PMD. > BTW, we have same thing now - these private session pointers are just sto= red > inside the same rte_crypto_sym_session. > And if user wants to support this model, he would also need to store queue_id> > pair for each HW device anyway. Yes agreed, but how is that thing happening in your new struct, you cannot = support that. >=20 > > > > > > > > > 2. Can somebody use the scheduler pmd for scheduling the different = type > of > > > payloads for the same session? > > > > > > In theory yes. > > > Though for that scheduler pmd should have inside it's > > > rte_crypto_cpu_sym_session an array of pointers to > > > the underlying devices sessions. > > > > > > > > > > > With your proposal the APIs would be very specific to your use case= only. > > > > > > Yes in some way. > > > I consider that API specific for SW backed crypto PMDs. > > > I can hardly see how any 'real HW' PMDs (lksd-none, lksd-proto) will = benefit > > > from it. > > > Current crypto-op API is very much HW oriented. > > > Which is ok, that's for it was intended for, but I think we also need= one that > > > would be designed > > > for SW backed implementation in mind. > > > > We may re-use your API for HW PMDs as well which do not have requiremen= t > of > > Crypto-op/mbuf etc. > > The return type of your new process API may have a status which say > 'processed' > > Or can be say 'enqueued'. So if it is 'enqueued', we may have a new AP= I for > raw > > Bufs dequeue as well. > > > > This requirement can be for any hardware PMDs like QAT as well. >=20 > I don't think it is a good idea to extend this API for async (lookaside) = devices. > You'll need to: > - provide dev_id and queue_id for each process(enqueue) and dequeuer > operation. > - provide IOVA for all buffers passing to that function (data buffers, d= igest, IV, > aad). > - On dequeue provide some way to associate dequed data and digest buffer= s > with > crypto-session that was used (and probably with mbuf). > So most likely we'll end up with another just version of our current cry= pto-op > structure. > If you'd like to get rid of mbufs dependency within current crypto-op API= that > understandable, > but I don't think we should have same API for both sync (CPU) and async > (lookaside) cases. > It doesn't seem feasible at all and voids whole purpose of that patch. At this moment we are not much concerned about the dequeue API and about th= e HW PMD support. It is just that the new API should be generic enough to be = used in some future scenarios as well. I am just highlighting the possible usecases= which can=20 be there in future. What is the issue that you face in making a dev-op for this new API. Do you= see any performance impact with that? >=20 > > That is why a dev-ops would be a better option. > > > > > > > > > When you would add more functionality to this sync API/struct, it w= ill end > up > > > being the same API/struct. > > > > > > > > Let us see how close/ far we are from the existing APIs when the a= ctual > > > implementation is done. > > > > > > > > > > I am not sure if that would be needed. > > > > > > It would be internal to the driver that if synchronous processi= ng is > > > > > supported(from feature flag) and > > > > > > Have relevant fields in xform(the newly added ones which are pa= cked > as > > > per > > > > > your suggestions) set, > > > > > > It will create that type of session. > > > > > > > > > > > > > > > > > > > + * Main points: > > > > > > > + * - Current crypto-dev API is reasonably mature and it is d= esirable > > > > > > > + * to keep it unchanged (API/ABI stability). From other si= de, this > > > > > > > + * new sync API is new one and probably would require extr= a > changes. > > > > > > > + * Having it as a new one allows to mark it as experimenta= l, without > > > > > > > + * affecting existing one. > > > > > > > + * - Fully opaque cpu_sym_session structure gives more flexi= bility > > > > > > > + * to the PMD writers and again allows to avoid ABI breaka= ges in > future. > > > > > > > + * - process() function per set of xforms > > > > > > > + * allows to expose different process() functions for diff= erent > > > > > > > + * xform combinations. PMD writer can decide, does he want= s to > > > > > > > + * push all supported algorithms into one process() functi= on, > > > > > > > + * or spread it across several ones. > > > > > > > + * I.E. More flexibility for PMD writer. > > > > > > > > > > > > Which process function should be chosen is internal to PMD, how > would > > > that > > > > > info > > > > > > be visible to the application or the library. These will get st= ored in the > > > session > > > > > private > > > > > > data. It would be upto the PMD writer, to store the per session= process > > > > > function in > > > > > > the session private data. > > > > > > > > > > > > Process function would be a dev ops just like enc/deq operation= s and it > > > should > > > > > call > > > > > > The respective process API stored in the session private data. > > > > > > > > > > That model (via devops) is possible, but has several drawbacks fr= om my > > > > > perspective: > > > > > > > > > > 1. It means we'll need to pass dev_id as a parameter to process()= function. > > > > > Though in fact dev_id is not a relevant information for us here > > > > > (all we need is pointer to the session and pointer to the fuction= to call) > > > > > and I tried to avoid using it in data-path functions for that API= . > > > > > > > > You have a single vdev, but someone may have multiple vdevs for eac= h > thread, > > > or may > > > > Have same dev with multiple queues for each core. > > > > > > That's fine. As I said above it is a SW backed implementation. > > > Each session has to be a separate entity that contains all necessary > information > > > (keys, alg/mode info, etc.) to process input buffers. > > > Plus we need the actual function pointer to call. > > > I just don't see what for we need a dev_id in that situation. > > > > To iterate the session private data in the session. > > > > > Again, here we don't need care about queues and their pinning to core= s. > > > If let say someone would like to process buffers from the same IPsec = SA on 2 > > > different cores in parallel, he can just create 2 sessions for the sa= me xform, > > > give one to thread #1 and second to thread #2. > > > After that both threads are free to call process(this_thread_ses, ...= ) at will. > > > > Say you have a 16core device to handle 100G of traffic on a single tunn= el. > > Will we make 16 sessions with same parameters? >=20 > Absolutely same question we can ask for current crypto-op API. > You have lookaside crypto-dev with 16 HW queues, each queue is serviced b= y > different CPU. > For the same SA, do you need a separate session per queue, or is it ok to= reuse > current one? > AFAIK, right now this is a grey area not clearly defined. > For crypto-devs I am aware - user can reuse the same session (as PMD uses= it > read-only). > But again, right now I think it is not clearly defined and is implementat= ion > specific. User can use the same session, that is what I am also insisting, but it may= have separate Session private data. Cryptodev session create API provide that functionali= ty and we can Leverage that. BTW, I can see a v2 to this RFC which is still based on security library. W= hen do you plan To submit the patches for crypto based APIs. We have RC1 merge deadline for= this patchset on 21st Oct. As per my understanding you only need a new dev-op for sync support. Sessio= n APIs Will remain the same and you will have some extra fields packed in xform st= ructs. The PMD will need to maintain a pointer to the per session process function= while creating Session and will be used by the dev-op API at runtime without any extra che= ck at runtime. >=20 > > > > > > > > > > > > > > 2. As you pointed in that case it will be just one process() func= tion per > device. > > > > > So if PMD would like to have several process() functions for diff= erent type > of > > > > > sessions > > > > > (let say one per alg) first thing it has to do inside it's proces= s() - read > session > > > data > > > > > and > > > > > based on that, do a jump/call to particular internal sub-routine. > > > > > Something like: > > > > > driver_id =3D get_pmd_driver_id(); > > > > > priv_ses =3D ses->sess_data[driver_id]; > > > > > Then either: > > > > > switch(priv_sess->alg) {case XXX: process_XXX(priv_sess, ...);bre= ak;...} > > > > > OR > > > > > priv_ses->process(priv_sess, ...); > > > > > > > > > > to select and call the proper function. > > > > > Looks like totally unnecessary overhead to me. > > > > > Though if we'll have ability to query/extract some sort session_o= ps based > on > > > the > > > > > xform - > > > > > we can avoid this extra de-refererence+jump/call thing. > > > > > > > > What is the issue in the priv_ses->process(); approach? > > > > > > Nothing at all. > > > What I am saying that schema with dev_ops > > > dev[dev_id]->dev_ops.process(ses->priv_ses[driver_id], ...) > > > | > > > |-> priv_ses->process(...) > > > > > > Has bigger overhead then just: > > > process(ses,...); > > > > > > So what for to introduce extra-level of indirection here? > > > > Explained above. > > > > > > > > > I don't understand what are you saving by not doing this. > > > > In any case you would need to identify which session correspond to = which > > > process(). > > > > > > Yes, sure, but I think we can make user to store information that rel= ationship, > > > in a way he likes: store process() pointer for each session, or group= sessions > > > that share the same process() somehow, or... > > > > So whatever relationship that user will make and store will make its li= fe > complicated. > > If we can hide that information in the driver, then what is the issue i= n that and > user > > Will not need to worry. He would just call the process() and driver wil= l choose > which > > Process need to be called. >=20 > Driver can do that at config/init time. > Then at run-time we can avoid that choice at all and call already chosen = function. >=20 > > > > I think we should have a POC around this and see the difference in the = cycle > count. > > IMO it would be negligible and we would end up making a generic API set > which > > can be used by others as well. > > > > > > > > > For that you would be doing it somewhere in your data path. > > > > > > Why at data-path? > > > Only once at session creation/initialization time. > > > Or might be even once per group of sessions. > > > > > > > > > > > > > > > > > > > > > > > > I am not sure if you would need a new session init API for this= as > nothing > > > would > > > > > be visible to > > > > > > the app or lib. > > > > > > > > > > > > > + * - Not storing process() pointer inside the session - > > > > > > > + * Allows user to choose does he want to store a process()= pointer > > > > > > > + * per session, or per group of sessions for that device t= hat share > > > > > > > + * the same input xforms. I.E. extra flexibility for the u= ser, > > > > > > > + * plus allows us to keep cpu_sym_session totally opaque, = see > above. > > > > > > > > > > > > If multiple sessions need to be processed via the same process = function, > > > > > > PMD would save the same process in all the sessions, I don't th= ink there > > > would > > > > > > be any perf overhead with that. > > > > > > > > > > I think it would, see above. > > > > > > > > > > > > > > > > > > + * Sketched usage model: > > > > > > > + * .... > > > > > > > + * /* control path, alloc/init session */ > > > > > > > + * int32_t sz =3D rte_crypto_cpu_sym_session_size(dev_id, &x= form); > > > > > > > + * struct rte_crypto_cpu_sym_session *ses =3D user_alloc(...= , sz); > > > > > > > + * rte_crypto_cpu_sym_process_t process =3D > > > > > > > + * rte_crypto_cpu_sym_session_func(dev_id, &xform); > > > > > > > + * rte_crypto_cpu_sym_session_init(dev_id, ses, &xform); > > > > > > > + * ... > > > > > > > + * /* data-path*/ > > > > > > > + * process(ses, ....); > > > > > > > + * .... > > > > > > > + * /* control path, termiante/free session */ > > > > > > > + * rte_crypto_cpu_sym_session_fini(dev_id, ses); > > > > > > > + */ > > > > > > > + > > > > > > > +/** > > > > > > > + * vector structure, contains pointer to vector array and th= e length > > > > > > > + * of the array > > > > > > > + */ > > > > > > > +struct rte_crypto_vec { > > > > > > > + struct iovec *vec; > > > > > > > + uint32_t num; > > > > > > > +}; > > > > > > > + > > > > > > > +/* > > > > > > > + * Data-path bulk process crypto function. > > > > > > > + */ > > > > > > > +typedef void (*rte_crypto_cpu_sym_process_t)( > > > > > > > + struct rte_crypto_cpu_sym_session *sess, > > > > > > > + struct rte_crypto_vec buf[], void *iv[], void= *aad[], > > > > > > > + void *digest[], int status[], uint32_t num); > > > > > > > +/* > > > > > > > + * for given device return process function specific to inpu= t xforms > > > > > > > + * on error - return NULL and set rte_errno value. > > > > > > > + * Note that for same input xfroms for the same device shoul= d > return > > > > > > > + * the same process function. > > > > > > > + */ > > > > > > > +__rte_experimental > > > > > > > +rte_crypto_cpu_sym_process_t > > > > > > > +rte_crypto_cpu_sym_session_func(uint8_t dev_id, > > > > > > > + const struct rte_crypto_sym_xform *xf= orms); > > > > > > > + > > > > > > > +/* > > > > > > > + * Return required session size in bytes for given set of xf= orms. > > > > > > > + * if xforms =3D=3D NULL, then return the max possible sessi= on size, > > > > > > > + * that would fit session for any supported by the device al= gorithm. > > > > > > > + * if CPU mode is not supported at all, or requeted in xform > > > > > > > + * algorithm is not supported, then return -ENOTSUP. > > > > > > > + */ > > > > > > > +__rte_experimental > > > > > > > +int > > > > > > > +rte_crypto_cpu_sym_session_size(uint8_t dev_id, > > > > > > > + const struct rte_crypto_sym_xform *xf= orms); > > > > > > > + > > > > > > > +/* > > > > > > > + * Initialize session. > > > > > > > + * It is caller responsibility to allocate enough space for = it. > > > > > > > + * See rte_crypto_cpu_sym_session_size above. > > > > > > > + */ > > > > > > > +__rte_experimental > > > > > > > +int rte_crypto_cpu_sym_session_init(uint8_t dev_id, > > > > > > > + struct rte_crypto_cpu_sym_session *se= ss, > > > > > > > + const struct rte_crypto_sym_xform *xf= orms); > > > > > > > + > > > > > > > +__rte_experimental > > > > > > > +void > > > > > > > +rte_crypto_cpu_sym_session_fini(uint8_t dev_id, > > > > > > > + struct rte_crypto_cpu_sym_session *se= ss); > > > > > > > + > > > > > > > + > > > > > > > #ifdef __cplusplus > > > > > > > } > > > > > > > #endif > > > > > > > diff --git a/lib/librte_cryptodev/rte_cryptodev_pmd.h > > > > > > > b/lib/librte_cryptodev/rte_cryptodev_pmd.h > > > > > > > index defe05ea0..ed7e63fab 100644 > > > > > > > --- a/lib/librte_cryptodev/rte_cryptodev_pmd.h > > > > > > > +++ b/lib/librte_cryptodev/rte_cryptodev_pmd.h > > > > > > > @@ -310,6 +310,20 @@ typedef void > > > > > (*cryptodev_sym_free_session_t)(struct > > > > > > > rte_cryptodev *dev, > > > > > > > typedef void (*cryptodev_asym_free_session_t)(struct rte_cry= ptodev > > > *dev, > > > > > > > struct rte_cryptodev_asym_session *sess); > > > > > > > > > > > > > > +typedef int (*cryptodev_cpu_sym_session_size_t) (struct > rte_cryptodev > > > > > *dev, > > > > > > > + const struct rte_crypto_sym_xform *xf= orms); > > > > > > > + > > > > > > > +typedef int (*cryptodev_cpu_sym_session_init_t) (struct > rte_cryptodev > > > > > *dev, > > > > > > > + struct rte_crypto_cpu_sym_session *se= ss, > > > > > > > + const struct rte_crypto_sym_xform *xf= orms); > > > > > > > + > > > > > > > +typedef void (*cryptodev_cpu_sym_session_fini_t) (struct > rte_cryptodev > > > > > *dev, > > > > > > > + struct rte_crypto_cpu_sym_session *se= ss); > > > > > > > + > > > > > > > +typedef rte_crypto_cpu_sym_process_t > > > > > (*cryptodev_cpu_sym_session_func_t) > > > > > > > ( > > > > > > > + struct rte_cryptodev *dev, > > > > > > > + const struct rte_crypto_sym_xform *xf= orms); > > > > > > > + > > > > > > > /** Crypto device operations function pointer table */ > > > > > > > struct rte_cryptodev_ops { > > > > > > > cryptodev_configure_t dev_configure; /**< Configur= e device. > */ > > > > > > > @@ -343,6 +357,11 @@ 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_cpu_sym_session_size_t sym_cpu_session_get_= size; > > > > > > > + cryptodev_cpu_sym_session_func_t sym_cpu_session_get_= func; > > > > > > > + cryptodev_cpu_sym_session_init_t sym_cpu_session_init= ; > > > > > > > + cryptodev_cpu_sym_session_fini_t sym_cpu_session_fini= ; > > > > > > > }; > > > > > > > > > > > > > > > > > > > > >