From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 0733BA034F; Mon, 7 Feb 2022 09:19:59 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 89F5F40DDA; Mon, 7 Feb 2022 09:19:59 +0100 (CET) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by mails.dpdk.org (Postfix) with ESMTP id 6E7984069D for ; Mon, 7 Feb 2022 09:19:58 +0100 (CET) Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.16.1.2/8.16.1.2) with ESMTP id 216NOaww004938; Mon, 7 Feb 2022 00:19:54 -0800 Received: from nam04-mw2-obe.outbound.protection.outlook.com (mail-mw2nam08lp2174.outbound.protection.outlook.com [104.47.73.174]) by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 3e1smr4u5x-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 07 Feb 2022 00:19:54 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Oy3j/2BMHhJ6GOIztrzojBn3ufBNR0EiNXQYlSvXkUPp+pKYdowxH+P9QhKpWZlGZMbdhfL8eEU9ppJVpXJzsE3rS1VTYOMEInGm1DqRqnwo7dX0xLqIPFu0pdIToqhng54/z0eZwo9FJowxJtHFPBeRnDUAigPQKMoK8dew3ZFihML1cL81JwRvp2AcCKFVTcLhdTysPvA4dPVb37jWzrk3Ut9b1uhNUNDlv9ttdESxgNF3RlPvVxwxnPPw5ZqF1s7vCCPOEHyUuDnPZVL7qaVtSJXK2NpjMQ8hNKS6z/9P8cZDhxBSomThjb94Uv4ckghygIed73DVjqf0fVV7Fg== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=AhUWhjhaz6XAwPCDzGDM1h5wODtkoPR/4SgDBMdt1KY=; b=SpcVETVxL7Gc+sTBnYywyC9hXefgWgZfeVe8Rzg48zaKYGBPSRLTfHpmTC/M7oSjabrDK+jQbT7d6f3fYVNDngcZleFC6Pk/bX7GUDDenuh8xlowCe+9X+AhsoUQW5t3tMW+aMyypKQaSVR2xRsDgLiEIhcJYIOPQnhJdVdhWA0KzH9aMS8wCc2/4peqNNpoTrFo7PFTDVj1y+Qbm707We6NXiAtcjSDTQYtu48pemNwSl9E7lsa5UXGfkKxFLXiGx7tnTQZvEje0OFFwGKoWOAENCQkZndZWb4GtiJ1Zg1tt/ttbzAULz5qC/5aAwipVemQgcukha4M5ME8js0utg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.onmicrosoft.com; s=selector1-marvell-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=AhUWhjhaz6XAwPCDzGDM1h5wODtkoPR/4SgDBMdt1KY=; b=SRFjUNycMB0yc/CayaMt9OpWj/vFKZUEOvu0uKIgu1esw4PSHAsC5kOQ0qIgEenTwwB83Xrj2caAtBmOgqmTATF46wYa6lQa3AGmJPV/XF4RpxV3ew4EKvfKvViQy4zDDss/TQehz49GiSweIfx/ig0tgOR/IGy9t/lPdXabifg= Received: from CO6PR18MB4484.namprd18.prod.outlook.com (2603:10b6:5:359::9) by BL0PR18MB2307.namprd18.prod.outlook.com (2603:10b6:207:48::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4951.18; Mon, 7 Feb 2022 08:19:50 +0000 Received: from CO6PR18MB4484.namprd18.prod.outlook.com ([fe80::9985:c3ca:2f91:7fc]) by CO6PR18MB4484.namprd18.prod.outlook.com ([fe80::9985:c3ca:2f91:7fc%5]) with mapi id 15.20.4951.019; Mon, 7 Feb 2022 08:19:50 +0000 From: Akhil Goyal To: Ciara Power , "dev@dpdk.org" CC: "roy.fan.zhang@intel.com" , Anoob Joseph , "mdr@ashroe.eu" , Declan Doherty , Ankur Dwivedi , Tejasree Kondoj , John Griffin , Fiona Trahe , Deepak Kumar Jain Subject: RE: [EXT] [PATCH v3 1/4] crypto: use single buffer for asymmetric session Thread-Topic: [EXT] [PATCH v3 1/4] crypto: use single buffer for asymmetric session Thread-Index: AQHYGRfjUMr9MtfQvki7h0wAi5FJhqyHuCQA Date: Mon, 7 Feb 2022 08:19:49 +0000 Message-ID: References: <20220203160449.1638311-1-ciara.power@intel.com> <20220203160449.1638311-2-ciara.power@intel.com> In-Reply-To: <20220203160449.1638311-2-ciara.power@intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 924b76e5-871b-4ccb-0e56-08d9ea129c43 x-ms-traffictypediagnostic: BL0PR18MB2307:EE_ x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:785; x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: SW0pH1F2M89uOjkfKWcZTuEPSm+ASP/n/Pf7iYpTWD3I58j0FOR8gLhumJW6shl6n4UkZEYH4lD4olK02HzpQvByXNJXVvCj/LXhzo/mui1lxM44/j+8k5bS01Wp20egvvX8xeCoCTPJ1DlcFl4btYA6kbGHFxo19fWhYs5hG2iCn62kSKW4gJnRru9X2G7Tvgz+fpwiy0k1dt5kE4A1F+SEKGB9Slm+3stG3PMBn80ocRpwz6TRNSdP7p2vX7Ch9jgZ3MfjEDTCzBKEEA5Rl9YZXNRGhM9RSQwXFBPpvxOJgd9nyyuGQw0iSyECFHmUhVt296hfwDR4o57014mJmJ12cTfKR0R7rWi/Bl9G1MBZ/zBo5y/o7aMolvS0ILX+HW472pIvPOQcNDCwZn+qrD7wFoGkQsVCeCOJvAS3z16OGiAk+RkJRztSm+22+Wwwbeso9N4MNbjlNwGWB8mhxCGMGQBjdMW1e65J4Zqp4ckc9ONSqwBWcfauUYw8jhuT1oqNNO6X7YqL5J6jG3+wbzIFF26/koiNuKbD75awCszIbV5nmEFt376xmvJyEkn+SW6d/ete7qqOtlEBibRJQZCjSWkR84bDVRfAUwP9W77Xfy9y3gfSMjFJn6PuxLgNCWGLfP/bOwXfHNzHvTF3yBUdij9cJwSf/+EmP3tOLgDGVmBaFx4WnCHnL+d7Y12X4ZNxEl1zPGefpDE1n8wGRA== x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:CO6PR18MB4484.namprd18.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230001)(4636009)(366004)(66946007)(66556008)(66476007)(66446008)(8676002)(64756008)(8936002)(52536014)(4326008)(76116006)(508600001)(86362001)(316002)(9686003)(7696005)(38070700005)(55236004)(6506007)(110136005)(54906003)(71200400001)(5660300002)(38100700002)(2906002)(122000001)(186003)(26005)(55016003)(33656002)(30864003)(83380400001)(559001)(579004); DIR:OUT; SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?OKZVX3uqS6GF7eMRewfzWgH56iU5st4U3A0cI2s+cdLK+ufii1oXKVq9F3Uy?= =?us-ascii?Q?Q9Qr7x7Tig76izQppHx/Q1vPQoFI6G4bCXWsiBlIjgpeQpG2L94M0IUF3uSx?= =?us-ascii?Q?CZk2Iqlmq5yIu32B80QBqdy1bt+C0MOax+RLkgblgBUXpaGvto/sX5b989fm?= =?us-ascii?Q?NZvuc0UVY6GeHZncV24MZEd3vhWFvf53RMUyGBwoxUhi4CS+RcWsbop7eiAR?= =?us-ascii?Q?ghJm+m1Bxgm61hjNmJMGvOK/sC8uSsMAnxpMPHKxdCG6I60Kpgc9NIk+vqf8?= =?us-ascii?Q?oUD230Vs+C9qC8mFEhqdinHO9oHsC+P729SyiXdGbyKqnsI8MDbrxqvnFEy4?= =?us-ascii?Q?CC0ycHEE3XbN2/JWt2VVdtwh4rPTeNK+AlqHBjGTsWQV17fIDaBvqY20D1NK?= =?us-ascii?Q?aSLd9syM6GRzvc8e1QrrreQ3dqd0mTOlNY4PAdpfnnpF4XsCC0TWwnh1G9q4?= =?us-ascii?Q?hWXv11KicNKUf1jnoYIKGWs7O3nV/wbKvXTKEYOfTRb0wdKWZ8/Ln65BSfyW?= =?us-ascii?Q?L9yGq1kpm9I484vIo68Nleuul3JGGS7w7lAMeXZdBbJN0Y25KCtlfzgJn/8u?= =?us-ascii?Q?bR/LY1S4QSmg8MATHB0ZwIO0cbW0UTJMCMVh9GdvWa4kI9oNAWVClpeuYfTa?= =?us-ascii?Q?aVLAGtOWWzESKu5XhBQdwkeVIqHcF2MFRBicEOSMGzR0Tf3CxvVaj7hxCaGN?= =?us-ascii?Q?1MLd3YeuLjIqslAH2y+tw+ME2Ltfq/jktFOAqcoRnMXtKHaHHoJ8Iw/E9qWt?= =?us-ascii?Q?c8UOT+aT8TXbFTxeBBFvBi7DwhvITOIptRf52HqlKKOCY11xwrR2Zm+slnh8?= =?us-ascii?Q?1ccfZpZ169aHXP4fG0+LrdvmCivEpERyqptI45La28FGPmnXzOVyawcVoOsu?= =?us-ascii?Q?fHgdHFtes4c9Y/QkrT3i2HtSKx3vCLrQ88miFBWyQp2GucaxGa8C7PAwufns?= =?us-ascii?Q?Rgmd4cBNrg8bxF/v7ItC8HQSVuAtVOg10jWsDq2kZ4VudFjMgDpEyJ6vSARS?= =?us-ascii?Q?ImD937wfxbtFbwlh6p0XFzhkbHV99sYPnaSKVkVah1OPip9sA3DT6GeiK+j3?= =?us-ascii?Q?OyNG5Wj29yz1LhS7AGqrmwD+5L4YQ2YlFKHlFYBWI43mfmyFkEtx5BZRifAb?= =?us-ascii?Q?GA+8C9TCGsDn30tt04C2uC/xAdVdz4zH+VQuMW3aMpY0hTGreJ8e3x1wxIIa?= =?us-ascii?Q?egG3livdwB0o27D1Kp16un+H0zjKEOIZ698h+ZqB5mZY+pP1flcUK69s8Z9d?= =?us-ascii?Q?75CNdSGRK0S8VJ+H2OxyWBh2b2RE4xDOWTYyT+uo1Zlgsc1isDpXukmO7h0N?= =?us-ascii?Q?lVBWmtFBKBfAZB9kmkClDYda+X6/m8GLcXrCzi7XpZSUoW5vQJLnMc12yvag?= =?us-ascii?Q?jcog6/gkyundFB6+/LbmYP/m7dVdilgmCWzqxoYeGK75yJXcUs8mDlRdgXNB?= =?us-ascii?Q?1uPRu5QE2yAt0tH51CJIuU9I0hr4/wrZ66QaHhkQnzjnET9OD+akEuA66w6t?= =?us-ascii?Q?7AoSw0byYv1gObNPIR09lu2jdaiYMZHzyTdkI3v+PtLNSmXaYOt/wOb5MuQK?= =?us-ascii?Q?AdHeKTYWUC+J7282Ze7v13SUMEiayvefCyV3jgSVXXuF3O0WvfVe5C1ETDJd?= =?us-ascii?Q?EKMAjuEanEAF7EQMxEmb6Ic=3D?= Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: marvell.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: CO6PR18MB4484.namprd18.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 924b76e5-871b-4ccb-0e56-08d9ea129c43 X-MS-Exchange-CrossTenant-originalarrivaltime: 07 Feb 2022 08:19:50.0024 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 70e1fb47-1155-421d-87fc-2e58f638b6e0 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: vMiuUm5Ex2B6Gy0GqGhEXxlqds55t+EkGdFoF0Y1qqYhxY17xYC+QuHQQeszcHuBglK3mJZDPfPiT8EOAB4KTw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL0PR18MB2307 X-Proofpoint-GUID: dUVvZMpm6e2uJ6F4CO7PP68bwYD3Je7g X-Proofpoint-ORIG-GUID: dUVvZMpm6e2uJ6F4CO7PP68bwYD3Je7g X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.816,Hydra:6.0.425,FMLib:17.11.62.513 definitions=2022-02-07_03,2022-02-03_01,2021-12-02_01 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org > Rather than using a session buffer that contains pointers to private > session data elsewhere, have a single session buffer. > This session is created for a driver ID, and the mempool element > contains space for the max session private data needed for any driver. This means asymmetric ops are not allowed with scheduler PMD. Also since session_create() and session_init() are merged to a single funct= ion, Why not merge session_clear() and session_free()? >=20 > Signed-off-by: Ciara Power > Acked-by: Fan Zhang >=20 > --- > v2: > - Renamed function typedef from "free" to "clear" as session private > data isn't being freed in that function. > - Moved user data API to separate patch. > - Minor fixes to comments, formatting, return values. > v3: > - Corrected formatting of struct comments. > - Increased size of max_priv_session_sz to uint16_t. > - Removed trace for asym session init function that was > previously removed. > - Added documentation. > --- > app/test-crypto-perf/cperf_ops.c | 14 +- > app/test/test_cryptodev_asym.c | 200 ++++--------------- > doc/guides/prog_guide/cryptodev_lib.rst | 55 ++--- > doc/guides/rel_notes/release_22_03.rst | 7 + > drivers/crypto/cnxk/cn10k_cryptodev_ops.c | 6 +- > drivers/crypto/cnxk/cn9k_cryptodev_ops.c | 6 +- > drivers/crypto/cnxk/cnxk_cryptodev_ops.c | 11 +- > drivers/crypto/octeontx/otx_cryptodev_ops.c | 29 +-- > drivers/crypto/openssl/rte_openssl_pmd.c | 5 +- > drivers/crypto/openssl/rte_openssl_pmd_ops.c | 23 +-- > drivers/crypto/qat/qat_asym.c | 53 ++--- > lib/cryptodev/cryptodev_pmd.h | 17 +- > lib/cryptodev/cryptodev_trace_points.c | 6 +- > lib/cryptodev/rte_cryptodev.c | 167 ++++++++++------ > lib/cryptodev/rte_cryptodev.h | 72 ++++--- > lib/cryptodev/rte_cryptodev_trace.h | 21 +- > lib/cryptodev/version.map | 5 +- > 17 files changed, 258 insertions(+), 439 deletions(-) >=20 > diff --git a/app/test-crypto-perf/cperf_ops.c b/app/test-crypto-perf/cper= f_ops.c > index d975ae1ab8..bdc5dc9544 100644 > --- a/app/test-crypto-perf/cperf_ops.c > +++ b/app/test-crypto-perf/cperf_ops.c > @@ -735,7 +735,6 @@ cperf_create_session(struct rte_mempool *sess_mp, > struct rte_crypto_sym_xform aead_xform; > struct rte_cryptodev_sym_session *sess =3D NULL; > struct rte_crypto_asym_xform xform =3D {0}; > - int rc; >=20 > if (options->op_type =3D=3D CPERF_ASYM_MODEX) { > xform.next =3D NULL; > @@ -745,19 +744,10 @@ cperf_create_session(struct rte_mempool *sess_mp, > xform.modex.exponent.data =3D perf_mod_e; > xform.modex.exponent.length =3D sizeof(perf_mod_e); >=20 > - sess =3D (void *)rte_cryptodev_asym_session_create(sess_mp); > + sess =3D (void *)rte_cryptodev_asym_session_create(sess_mp, > dev_id, &xform); > if (sess =3D=3D NULL) > return NULL; > - rc =3D rte_cryptodev_asym_session_init(dev_id, (void *)sess, > - &xform, priv_mp); > - if (rc < 0) { > - if (sess !=3D NULL) { > - rte_cryptodev_asym_session_clear(dev_id, > - (void *)sess); > - rte_cryptodev_asym_session_free((void > *)sess); > - } > - return NULL; > - } > + > return sess; > } > #ifdef RTE_LIB_SECURITY > diff --git a/app/test/test_cryptodev_asym.c b/app/test/test_cryptodev_asy= m.c > index 68f4d8e7a6..f7c2fd2588 100644 > --- a/app/test/test_cryptodev_asym.c > +++ b/app/test/test_cryptodev_asym.c > @@ -450,7 +450,8 @@ test_cryptodev_asym_op(struct > crypto_testsuite_params_asym *ts_params, > } >=20 > if (!sessionless) { > - sess =3D rte_cryptodev_asym_session_create(ts_params- > >session_mpool); > + sess =3D rte_cryptodev_asym_session_create(ts_params- > >session_mpool, > + dev_id, &xform_tc); > if (!sess) { > snprintf(test_msg, ASYM_TEST_MSG_LEN, > "line %u " > @@ -460,15 +461,6 @@ test_cryptodev_asym_op(struct > crypto_testsuite_params_asym *ts_params, > goto error_exit; > } >=20 > - if (rte_cryptodev_asym_session_init(dev_id, sess, &xform_tc, > - ts_params->session_mpool) < 0) { > - snprintf(test_msg, ASYM_TEST_MSG_LEN, > - "line %u FAILED: %s", > - __LINE__, "unabled to config sym > session"); > - status =3D TEST_FAILED; > - goto error_exit; > - } > - > rte_crypto_op_attach_asym_session(op, sess); > } else { > asym_op->xform =3D &xform_tc; > @@ -667,18 +659,11 @@ test_rsa_sign_verify(void) > return TEST_SKIPPED; > } >=20 > - sess =3D rte_cryptodev_asym_session_create(sess_mpool); > + sess =3D rte_cryptodev_asym_session_create(sess_mpool, dev_id, > &rsa_xform); >=20 > if (!sess) { > RTE_LOG(ERR, USER1, "Session creation failed for " > "sign_verify\n"); > - return TEST_FAILED; > - } > - > - if (rte_cryptodev_asym_session_init(dev_id, sess, &rsa_xform, > - sess_mpool) < 0) { > - RTE_LOG(ERR, USER1, "Unable to config asym session for " > - "sign_verify\n"); > status =3D TEST_FAILED; > goto error_exit; > } > @@ -686,7 +671,6 @@ test_rsa_sign_verify(void) > status =3D queue_ops_rsa_sign_verify(sess); >=20 > error_exit: > - > rte_cryptodev_asym_session_clear(dev_id, sess); > rte_cryptodev_asym_session_free(sess); >=20 > @@ -716,17 +700,10 @@ test_rsa_enc_dec(void) > return TEST_SKIPPED; > } >=20 > - sess =3D rte_cryptodev_asym_session_create(sess_mpool); > + sess =3D rte_cryptodev_asym_session_create(sess_mpool, dev_id, > &rsa_xform); >=20 > if (!sess) { > RTE_LOG(ERR, USER1, "Session creation failed for enc_dec\n"); > - return TEST_FAILED; > - } > - > - if (rte_cryptodev_asym_session_init(dev_id, sess, &rsa_xform, > - sess_mpool) < 0) { > - RTE_LOG(ERR, USER1, "Unable to config asym session for " > - "enc_dec\n"); > status =3D TEST_FAILED; > goto error_exit; > } > @@ -763,22 +740,15 @@ test_rsa_sign_verify_crt(void) > return TEST_SKIPPED; > } >=20 > - sess =3D rte_cryptodev_asym_session_create(sess_mpool); > + sess =3D rte_cryptodev_asym_session_create(sess_mpool, dev_id, > &rsa_xform_crt); >=20 > if (!sess) { > RTE_LOG(ERR, USER1, "Session creation failed for " > "sign_verify_crt\n"); > status =3D TEST_FAILED; > - return status; > - } > - > - if (rte_cryptodev_asym_session_init(dev_id, sess, &rsa_xform_crt, > - sess_mpool) < 0) { > - RTE_LOG(ERR, USER1, "Unable to config asym session for " > - "sign_verify_crt\n"); > - status =3D TEST_FAILED; > goto error_exit; > } > + > status =3D queue_ops_rsa_sign_verify(sess); >=20 > error_exit: > @@ -811,21 +781,15 @@ test_rsa_enc_dec_crt(void) > return TEST_SKIPPED; > } >=20 > - sess =3D rte_cryptodev_asym_session_create(sess_mpool); > + sess =3D rte_cryptodev_asym_session_create(sess_mpool, dev_id, > &rsa_xform_crt); >=20 > if (!sess) { > RTE_LOG(ERR, USER1, "Session creation failed for " > "enc_dec_crt\n"); > - return TEST_FAILED; > - } > - > - if (rte_cryptodev_asym_session_init(dev_id, sess, &rsa_xform_crt, > - sess_mpool) < 0) { > - RTE_LOG(ERR, USER1, "Unable to config asym session for " > - "enc_dec_crt\n"); > status =3D TEST_FAILED; > goto error_exit; > } > + > status =3D queue_ops_rsa_enc_dec(sess); >=20 > error_exit: > @@ -924,7 +888,6 @@ testsuite_setup(void) > /* configure qp */ > ts_params->qp_conf.nb_descriptors =3D DEFAULT_NUM_OPS_INFLIGHT; > ts_params->qp_conf.mp_session =3D ts_params->session_mpool; > - ts_params->qp_conf.mp_session_private =3D ts_params->session_mpool; > for (qp_id =3D 0; qp_id < info.max_nb_queue_pairs; qp_id++) { > TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup( > dev_id, qp_id, &ts_params->qp_conf, > @@ -933,21 +896,9 @@ testsuite_setup(void) > qp_id, dev_id); > } >=20 > - /* setup asym session pool */ > - unsigned int session_size =3D RTE_MAX( > - rte_cryptodev_asym_get_private_session_size(dev_id), > - rte_cryptodev_asym_get_header_session_size()); > - /* > - * Create mempool with TEST_NUM_SESSIONS * 2, > - * to include the session headers > - */ > - ts_params->session_mpool =3D rte_mempool_create( > - "test_asym_sess_mp", > - TEST_NUM_SESSIONS * 2, > - session_size, > - 0, 0, NULL, NULL, NULL, > - NULL, SOCKET_ID_ANY, > - 0); > + ts_params->session_mpool =3D > rte_cryptodev_asym_session_pool_create( > + "test_asym_sess_mp", TEST_NUM_SESSIONS * 2, 0, > + SOCKET_ID_ANY); >=20 > TEST_ASSERT_NOT_NULL(ts_params->session_mpool, > "session mempool allocation failed"); > @@ -1104,14 +1055,6 @@ test_dh_gen_shared_sec(struct > rte_crypto_asym_xform *xfrm) > struct rte_crypto_asym_xform xform =3D *xfrm; > uint8_t peer[] =3D > "01234567890123456789012345678901234567890123456789"; >=20 > - sess =3D rte_cryptodev_asym_session_create(sess_mpool); > - if (sess =3D=3D NULL) { > - RTE_LOG(ERR, USER1, > - "line %u FAILED: %s", __LINE__, > - "Session creation failed"); > - status =3D TEST_FAILED; > - goto error_exit; > - } > /* set up crypto op data structure */ > op =3D rte_crypto_op_alloc(op_mpool, > RTE_CRYPTO_OP_TYPE_ASYMMETRIC); > if (!op) { > @@ -1134,11 +1077,11 @@ test_dh_gen_shared_sec(struct > rte_crypto_asym_xform *xfrm) > asym_op->dh.shared_secret.data =3D output; > asym_op->dh.shared_secret.length =3D sizeof(output); >=20 > - if (rte_cryptodev_asym_session_init(dev_id, sess, &xform, > - sess_mpool) < 0) { > + sess =3D rte_cryptodev_asym_session_create(sess_mpool, dev_id, > &xform); > + if (sess =3D=3D NULL) { > RTE_LOG(ERR, USER1, > - "line %u FAILED: %s", > - __LINE__, "unabled to config sym session"); > + "line %u FAILED: %s", __LINE__, > + "Session creation failed"); > status =3D TEST_FAILED; > goto error_exit; > } > @@ -1196,14 +1139,6 @@ test_dh_gen_priv_key(struct > rte_crypto_asym_xform *xfrm) > uint8_t output[TEST_DH_MOD_LEN]; > struct rte_crypto_asym_xform xform =3D *xfrm; >=20 > - sess =3D rte_cryptodev_asym_session_create(sess_mpool); > - if (sess =3D=3D NULL) { > - RTE_LOG(ERR, USER1, > - "line %u FAILED: %s", __LINE__, > - "Session creation failed"); > - status =3D TEST_FAILED; > - goto error_exit; > - } > /* set up crypto op data structure */ > op =3D rte_crypto_op_alloc(op_mpool, > RTE_CRYPTO_OP_TYPE_ASYMMETRIC); > if (!op) { > @@ -1222,11 +1157,11 @@ test_dh_gen_priv_key(struct > rte_crypto_asym_xform *xfrm) > asym_op->dh.priv_key.data =3D output; > asym_op->dh.priv_key.length =3D sizeof(output); >=20 > - if (rte_cryptodev_asym_session_init(dev_id, sess, &xform, > - sess_mpool) < 0) { > + sess =3D rte_cryptodev_asym_session_create(sess_mpool, dev_id, > &xform); > + if (sess =3D=3D NULL) { > RTE_LOG(ERR, USER1, > - "line %u FAILED: %s", > - __LINE__, "unabled to config sym session"); > + "line %u FAILED: %s", __LINE__, > + "Session creation failed"); > status =3D TEST_FAILED; > goto error_exit; > } > @@ -1287,14 +1222,6 @@ test_dh_gen_pub_key(struct > rte_crypto_asym_xform *xfrm) > uint8_t output[TEST_DH_MOD_LEN]; > struct rte_crypto_asym_xform xform =3D *xfrm; >=20 > - sess =3D rte_cryptodev_asym_session_create(sess_mpool); > - if (sess =3D=3D NULL) { > - RTE_LOG(ERR, USER1, > - "line %u FAILED: %s", __LINE__, > - "Session creation failed"); > - status =3D TEST_FAILED; > - goto error_exit; > - } > /* set up crypto op data structure */ > op =3D rte_crypto_op_alloc(op_mpool, > RTE_CRYPTO_OP_TYPE_ASYMMETRIC); > if (!op) { > @@ -1321,11 +1248,11 @@ test_dh_gen_pub_key(struct > rte_crypto_asym_xform *xfrm) > 0); > asym_op->dh.priv_key =3D dh_test_params.priv_key; >=20 > - if (rte_cryptodev_asym_session_init(dev_id, sess, &xform, > - sess_mpool) < 0) { > + sess =3D rte_cryptodev_asym_session_create(sess_mpool, dev_id, > &xform); > + if (sess =3D=3D NULL) { > RTE_LOG(ERR, USER1, > - "line %u FAILED: %s", > - __LINE__, "unabled to config sym session"); > + "line %u FAILED: %s", __LINE__, > + "Session creation failed"); > status =3D TEST_FAILED; > goto error_exit; > } > @@ -1388,15 +1315,6 @@ test_dh_gen_kp(struct rte_crypto_asym_xform > *xfrm) > struct rte_crypto_asym_xform pub_key_xform; > struct rte_crypto_asym_xform xform =3D *xfrm; >=20 > - sess =3D rte_cryptodev_asym_session_create(sess_mpool); > - if (sess =3D=3D NULL) { > - RTE_LOG(ERR, USER1, > - "line %u FAILED: %s", __LINE__, > - "Session creation failed"); > - status =3D TEST_FAILED; > - goto error_exit; > - } > - > /* set up crypto op data structure */ > op =3D rte_crypto_op_alloc(op_mpool, > RTE_CRYPTO_OP_TYPE_ASYMMETRIC); > if (!op) { > @@ -1420,11 +1338,12 @@ test_dh_gen_kp(struct rte_crypto_asym_xform > *xfrm) > asym_op->dh.pub_key.length =3D sizeof(out_pub_key); > asym_op->dh.priv_key.data =3D out_prv_key; > asym_op->dh.priv_key.length =3D sizeof(out_prv_key); > - if (rte_cryptodev_asym_session_init(dev_id, sess, &xform, > - sess_mpool) < 0) { > + > + sess =3D rte_cryptodev_asym_session_create(sess_mpool, dev_id, > &xform); > + if (sess =3D=3D NULL) { > RTE_LOG(ERR, USER1, > - "line %u FAILED: %s", > - __LINE__, "unabled to config sym session"); > + "line %u FAILED: %s", __LINE__, > + "Session creation failed"); > status =3D TEST_FAILED; > goto error_exit; > } > @@ -1511,7 +1430,7 @@ test_mod_inv(void) > return TEST_SKIPPED; > } >=20 > - sess =3D rte_cryptodev_asym_session_create(sess_mpool); > + sess =3D rte_cryptodev_asym_session_create(sess_mpool, dev_id, > &modinv_xform); > if (!sess) { > RTE_LOG(ERR, USER1, "line %u " > "FAILED: %s", __LINE__, > @@ -1520,15 +1439,6 @@ test_mod_inv(void) > goto error_exit; > } >=20 > - if (rte_cryptodev_asym_session_init(dev_id, sess, &modinv_xform, > - sess_mpool) < 0) { > - RTE_LOG(ERR, USER1, > - "line %u FAILED: %s", > - __LINE__, "unabled to config sym session"); > - status =3D TEST_FAILED; > - goto error_exit; > - } > - > /* generate crypto op data structure */ > op =3D rte_crypto_op_alloc(op_mpool, > RTE_CRYPTO_OP_TYPE_ASYMMETRIC); > if (!op) { > @@ -1646,7 +1556,7 @@ test_mod_exp(void) > goto error_exit; > } >=20 > - sess =3D rte_cryptodev_asym_session_create(sess_mpool); > + sess =3D rte_cryptodev_asym_session_create(sess_mpool, dev_id, > &modex_xform); > if (!sess) { > RTE_LOG(ERR, USER1, > "line %u " > @@ -1656,15 +1566,6 @@ test_mod_exp(void) > goto error_exit; > } >=20 > - if (rte_cryptodev_asym_session_init(dev_id, sess, &modex_xform, > - sess_mpool) < 0) { > - RTE_LOG(ERR, USER1, > - "line %u FAILED: %s", > - __LINE__, "unabled to config sym session"); > - status =3D TEST_FAILED; > - goto error_exit; > - } > - > asym_op =3D op->asym; > memcpy(input, base, sizeof(base)); > asym_op->modex.base.data =3D input; > @@ -1768,7 +1669,7 @@ test_dsa_sign(void) > uint8_t s[TEST_DH_MOD_LEN]; > uint8_t dgst[] =3D "35d81554afaad2cf18f3a1770d5fedc4ea5be344"; >=20 > - sess =3D rte_cryptodev_asym_session_create(sess_mpool); > + sess =3D rte_cryptodev_asym_session_create(sess_mpool, dev_id, > &dsa_xform); > if (sess =3D=3D NULL) { > RTE_LOG(ERR, USER1, > "line %u FAILED: %s", __LINE__, > @@ -1797,15 +1698,6 @@ test_dsa_sign(void) > debug_hexdump(stdout, "priv_key: ", dsa_xform.dsa.x.data, > dsa_xform.dsa.x.length); >=20 > - if (rte_cryptodev_asym_session_init(dev_id, sess, &dsa_xform, > - sess_mpool) < 0) { > - RTE_LOG(ERR, USER1, > - "line %u FAILED: %s", > - __LINE__, "unabled to config sym session"); > - status =3D TEST_FAILED; > - goto error_exit; > - } > - > /* attach asymmetric crypto session to crypto operations */ > rte_crypto_op_attach_asym_session(op, sess); > asym_op->dsa.op_type =3D RTE_CRYPTO_ASYM_OP_SIGN; > @@ -1941,15 +1833,6 @@ test_ecdsa_sign_verify(enum curve curve_id) >=20 > rte_cryptodev_info_get(dev_id, &dev_info); >=20 > - sess =3D rte_cryptodev_asym_session_create(sess_mpool); > - if (sess =3D=3D NULL) { > - RTE_LOG(ERR, USER1, > - "line %u FAILED: %s", __LINE__, > - "Session creation failed\n"); > - status =3D TEST_FAILED; > - goto exit; > - } > - > /* Setup crypto op data structure */ > op =3D rte_crypto_op_alloc(op_mpool, > RTE_CRYPTO_OP_TYPE_ASYMMETRIC); > if (op =3D=3D NULL) { > @@ -1967,11 +1850,11 @@ test_ecdsa_sign_verify(enum curve curve_id) > xform.xform_type =3D RTE_CRYPTO_ASYM_XFORM_ECDSA; > xform.ec.curve_id =3D input_params.curve; >=20 > - if (rte_cryptodev_asym_session_init(dev_id, sess, &xform, > - sess_mpool) < 0) { > + sess =3D rte_cryptodev_asym_session_create(sess_mpool, dev_id, > &xform); > + if (sess =3D=3D NULL) { > RTE_LOG(ERR, USER1, > "line %u FAILED: %s", __LINE__, > - "Unable to config asym session\n"); > + "Session creation failed\n"); > status =3D TEST_FAILED; > goto exit; > } > @@ -2154,15 +2037,6 @@ test_ecpm(enum curve curve_id) >=20 > rte_cryptodev_info_get(dev_id, &dev_info); >=20 > - sess =3D rte_cryptodev_asym_session_create(sess_mpool); > - if (sess =3D=3D NULL) { > - RTE_LOG(ERR, USER1, > - "line %u FAILED: %s", __LINE__, > - "Session creation failed\n"); > - status =3D TEST_FAILED; > - goto exit; > - } > - > /* Setup crypto op data structure */ > op =3D rte_crypto_op_alloc(op_mpool, > RTE_CRYPTO_OP_TYPE_ASYMMETRIC); > if (op =3D=3D NULL) { > @@ -2180,11 +2054,11 @@ test_ecpm(enum curve curve_id) > xform.xform_type =3D RTE_CRYPTO_ASYM_XFORM_ECPM; > xform.ec.curve_id =3D input_params.curve; >=20 > - if (rte_cryptodev_asym_session_init(dev_id, sess, &xform, > - sess_mpool) < 0) { > + sess =3D rte_cryptodev_asym_session_create(sess_mpool, dev_id, > &xform); > + if (sess =3D=3D NULL) { > RTE_LOG(ERR, USER1, > "line %u FAILED: %s", __LINE__, > - "Unable to config asym session\n"); > + "Session creation failed\n"); > status =3D TEST_FAILED; > goto exit; > } > diff --git a/doc/guides/prog_guide/cryptodev_lib.rst > b/doc/guides/prog_guide/cryptodev_lib.rst > index 8766bc34a9..f8f8562f4c 100644 > --- a/doc/guides/prog_guide/cryptodev_lib.rst > +++ b/doc/guides/prog_guide/cryptodev_lib.rst > @@ -1038,20 +1038,17 @@ It is the application's responsibility to create = and > manage the session mempools > Application using both symmetric and asymmetric sessions should allocate= and > maintain > different sessions pools for each type. >=20 > -An application can use ``rte_cryptodev_get_asym_session_private_size()``= to > -get the private size of asymmetric session on a given crypto device. Thi= s > -function would allow an application to calculate the max device asymmetr= ic > -session size of all crypto devices to create a single session mempool. > -If instead an application creates multiple asymmetric session mempools, > -the Crypto device framework also provides > ``rte_cryptodev_asym_get_header_session_size()`` to get > -the size of an uninitialized session. > +An application can use ``rte_cryptodev_asym_session_pool_create()`` to c= reate > a mempool > +with a specified number of elements. The element size will allow for the > session header, > +and the max private session size. > +The max private session size is chosen based on available crypto devices= , > +the biggest private session size is used. This means any of those device= s can be > used, > +and the mempool element will have available space for its private sessio= n data. >=20 > Once the session mempools have been created, > ``rte_cryptodev_asym_session_create()`` > -is used to allocate an uninitialized asymmetric session from the given m= empool. > -The session then must be initialized using ``rte_cryptodev_asym_session_= init()`` > -for each of the required crypto devices. An asymmetric transform chain > -is used to specify the operation and its parameters. See the section bel= ow for > -details on transforms. > +is used to allocate and initialize an asymmetric session from the given > mempool. > +An asymmetric transform chain is used to specify the operation and its > parameters. > +See the section below for details on transforms. >=20 > When a session is no longer used, user must call > ``rte_cryptodev_asym_session_clear()`` > for each of the crypto devices that are using the session, to free all d= river > @@ -1162,21 +1159,14 @@ crypto operations is similar except change to > respective op and xform setup). >=20 > uint8_t cdev_id =3D rte_cryptodev_get_dev_id(crypto_name); >=20 > - /* Get private asym session data size. */ > - asym_session_size =3D rte_cryptodev_get_asym_private_session_size(cd= ev_id); > - > /* > - * Create session mempool, with two objects per session, > - * one for the session header and another one for the > - * private asym session data for the crypto device. > + * Create session mempool, this will create elements big enough > + * to hold the generic session header, > + * and the max private session size of the available devices. > */ > - asym_session_pool =3D rte_mempool_create("asym_session_pool", > - MAX_ASYM_SESSIONS * 2, > - asym_session_size, > - 0, > - 0, NULL, NULL, NULL, > - NULL, socket_id, > - 0); > + asym_session_pool =3D rte_cryptodev_asym_session_pool_create( > + "asym_session_pool", MAX_ASYM_SESSIONS, 0, 0, > + socket_id); >=20 > /* Configure the crypto device. */ > struct rte_cryptodev_config conf =3D { > @@ -1190,8 +1180,7 @@ crypto operations is similar except change to > respective op and xform setup). > if (rte_cryptodev_configure(cdev_id, &conf) < 0) > rte_exit(EXIT_FAILURE, "Failed to configure cryptodev %u", cdev_= id); >=20 > - if (rte_cryptodev_queue_pair_setup(cdev_id, 0, &qp_conf, > - socket_id, asym_session_pool) < 0) > + if (rte_cryptodev_queue_pair_setup(cdev_id, 0, &qp_conf, socket_id) = < 0) > rte_exit(EXIT_FAILURE, "Failed to setup queue pair\n"); >=20 > if (rte_cryptodev_start(cdev_id) < 0) > @@ -1226,15 +1215,11 @@ crypto operations is similar except change to > respective op and xform setup). > }; > /* Create asym crypto session and initialize it for the crypto devic= e. */ > struct rte_cryptodev_asym_session *asym_session; > - asym_session =3D rte_cryptodev_asym_session_create(asym_session_pool= ); > + asym_session =3D rte_cryptodev_asym_session_create(asym_session_pool= , > + cdev_id, &modex_xform); > if (asym_session =3D=3D NULL) > rte_exit(EXIT_FAILURE, "Session could not be created\n"); >=20 > - if (rte_cryptodev_asym_session_init(cdev_id, asym_session, > - &modex_xform, asym_session_pool) < 0) > - rte_exit(EXIT_FAILURE, "Session could not be initialized " > - "for the crypto device\n"); > - > /* Get a burst of crypto operations. */ > struct rte_crypto_op *crypto_ops[1]; > if (rte_crypto_op_bulk_alloc(crypto_op_pool, > @@ -1245,11 +1230,11 @@ crypto operations is similar except change to > respective op and xform setup). > /* Set up the crypto operations. */ > struct rte_crypto_asym_op *asym_op =3D crypto_ops[0]->asym; >=20 > - /* calculate mod exp of value 0xf8 */ > + /* calculate mod exp of value 0xf8 */ > static unsigned char base[] =3D {0xF8}; > asym_op->modex.base.data =3D base; > asym_op->modex.base.length =3D sizeof(base); > - asym_op->modex.base.iova =3D base; > + asym_op->modex.base.iova =3D base; >=20 > /* Attach the asym crypto session to the operation */ > rte_crypto_op_attach_asym_session(op, asym_session); > diff --git a/doc/guides/rel_notes/release_22_03.rst > b/doc/guides/rel_notes/release_22_03.rst > index 3bc0630c7c..de8d8ce4e9 100644 > --- a/doc/guides/rel_notes/release_22_03.rst > +++ b/doc/guides/rel_notes/release_22_03.rst > @@ -100,6 +100,13 @@ API Changes > Also, make sure to start the actual text at the margin. > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D >=20 > +* cryptodev: The asym session handling was modified to use a single buff= er. > + A ``rte_cryptodev_asym_session_pool_create`` function was added to > + create a mempool with element size to hold the generic asym session he= ader, > + along with the max size for a device private session data. > + ``rte_cryptodev_asym_session_init`` was removed as this initialisation= is > + now done by ``rte_cryptodev_asym_session_create``. > + cryptodev: The asymmetric session handling was modified to use a single mem= pool object. An API ``rte_cryptodev_asym_session_pool_create`` was added to create a mem= pool with element size big enough to hold the generic asymmetric session header and m= ax size for a device private session data. The API ``rte_cryptodev_asym_session_init`` wa= s removed as the initialization is now moved to ``rte_cryptodev_asym_session_create``. > diff --git a/lib/cryptodev/cryptodev_pmd.h b/lib/cryptodev/cryptodev_pmd.= h > index b9146f652c..474d447496 100644 > --- a/lib/cryptodev/cryptodev_pmd.h > +++ b/lib/cryptodev/cryptodev_pmd.h > @@ -340,12 +340,12 @@ typedef int > (*cryptodev_asym_configure_session_t)(struct rte_cryptodev *dev, > typedef void (*cryptodev_sym_free_session_t)(struct rte_cryptodev *dev, > struct rte_cryptodev_sym_session *sess); > /** > - * Free asymmetric session private data. > + * Clear asymmetric session private data. > * > * @param dev Crypto device pointer > * @param sess Cryptodev session structure > */ > -typedef void (*cryptodev_asym_free_session_t)(struct rte_cryptodev *dev, > +typedef void (*cryptodev_asym_clear_session_t)(struct rte_cryptodev *dev= , > struct rte_cryptodev_asym_session *sess); > /** > * Perform actual crypto processing (encrypt/digest or auth/decrypt) > @@ -429,7 +429,7 @@ struct rte_cryptodev_ops { > /**< Configure asymmetric Crypto session. */ > cryptodev_sym_free_session_t sym_session_clear; > /**< Clear a Crypto sessions private data. */ > - cryptodev_asym_free_session_t asym_session_clear; > + cryptodev_asym_clear_session_t asym_session_clear; > /**< Clear a Crypto sessions private data. */ > union { > cryptodev_sym_cpu_crypto_process_t sym_cpu_process; > @@ -628,16 +628,9 @@ set_sym_session_private_data(struct > rte_cryptodev_sym_session *sess, > } >=20 > static inline void * > -get_asym_session_private_data(const struct rte_cryptodev_asym_session > *sess, > - uint8_t driver_id) { > - return sess->sess_private_data[driver_id]; > -} > - > -static inline void > -set_asym_session_private_data(struct rte_cryptodev_asym_session *sess, > - uint8_t driver_id, void *private_data) > +get_asym_session_private_data(struct rte_cryptodev_asym_session *sess) > { > - sess->sess_private_data[driver_id] =3D private_data; > + return sess->sess_private_data; > } >=20 > #endif /* _CRYPTODEV_PMD_H_ */ > diff --git a/lib/cryptodev/cryptodev_trace_points.c > b/lib/cryptodev/cryptodev_trace_points.c > index 5d58951fd5..d23b30edd8 100644 > --- a/lib/cryptodev/cryptodev_trace_points.c > +++ b/lib/cryptodev/cryptodev_trace_points.c > @@ -24,6 +24,9 @@ > RTE_TRACE_POINT_REGISTER(rte_cryptodev_trace_queue_pair_setup, > RTE_TRACE_POINT_REGISTER(rte_cryptodev_trace_sym_session_pool_create, > lib.cryptodev.sym.pool.create) >=20 > +RTE_TRACE_POINT_REGISTER(rte_cryptodev_trace_asym_session_pool_creat > e, > + lib.cryptodev.asym.pool.create) > + > RTE_TRACE_POINT_REGISTER(rte_cryptodev_trace_sym_session_create, > lib.cryptodev.sym.create) >=20 > @@ -39,9 +42,6 @@ > RTE_TRACE_POINT_REGISTER(rte_cryptodev_trace_asym_session_free, > RTE_TRACE_POINT_REGISTER(rte_cryptodev_trace_sym_session_init, > lib.cryptodev.sym.init) >=20 > -RTE_TRACE_POINT_REGISTER(rte_cryptodev_trace_asym_session_init, > - lib.cryptodev.asym.init) > - > RTE_TRACE_POINT_REGISTER(rte_cryptodev_trace_sym_session_clear, > lib.cryptodev.sym.clear) >=20 > diff --git a/lib/cryptodev/rte_cryptodev.c b/lib/cryptodev/rte_cryptodev.= c > index a40536c5ea..d260f79bbc 100644 > --- a/lib/cryptodev/rte_cryptodev.c > +++ b/lib/cryptodev/rte_cryptodev.c > @@ -195,7 +195,7 @@ const char *rte_crypto_asym_op_strings[] =3D { > }; >=20 > /** > - * The private data structure stored in the session mempool private data= . > + * The private data structure stored in the sym session mempool private = data. > */ > struct rte_cryptodev_sym_session_pool_private_data { > uint16_t nb_drivers; > @@ -204,6 +204,14 @@ struct rte_cryptodev_sym_session_pool_private_data > { > /**< session user data will be placed after sess_data */ > }; >=20 > +/** > + * The private data structure stored in the asym session mempool private= data. > + */ > +struct rte_cryptodev_asym_session_pool_private_data { > + uint16_t max_priv_session_sz; > + /**< Size of private session data used when creating mempool */ > +}; > + > int > rte_cryptodev_get_cipher_algo_enum(enum rte_crypto_cipher_algorithm > *algo_enum, > const char *algo_string) > @@ -1751,47 +1759,6 @@ rte_cryptodev_sym_session_init(uint8_t dev_id, > return 0; > } >=20 > -int > -rte_cryptodev_asym_session_init(uint8_t dev_id, > - struct rte_cryptodev_asym_session *sess, > - struct rte_crypto_asym_xform *xforms, > - struct rte_mempool *mp) > -{ > - struct rte_cryptodev *dev; > - uint8_t index; > - int ret; > - > - if (!rte_cryptodev_is_valid_dev(dev_id)) { > - CDEV_LOG_ERR("Invalid dev_id=3D%" PRIu8, dev_id); > - return -EINVAL; > - } > - > - dev =3D rte_cryptodev_pmd_get_dev(dev_id); > - > - if (sess =3D=3D NULL || xforms =3D=3D NULL || dev =3D=3D NULL) > - return -EINVAL; > - > - index =3D dev->driver_id; > - > - RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops- > >asym_session_configure, > - -ENOTSUP); > - > - if (sess->sess_private_data[index] =3D=3D NULL) { > - ret =3D dev->dev_ops->asym_session_configure(dev, > - xforms, > - sess, mp); > - if (ret < 0) { > - CDEV_LOG_ERR( > - "dev_id %d failed to configure session details", > - dev_id); > - return ret; > - } > - } > - > - rte_cryptodev_trace_asym_session_init(dev_id, sess, xforms, mp); > - return 0; > -} > - > struct rte_mempool * > rte_cryptodev_sym_session_pool_create(const char *name, uint32_t nb_elts= , > uint32_t elt_size, uint32_t cache_size, uint16_t user_data_size, > @@ -1834,6 +1801,53 @@ rte_cryptodev_sym_session_pool_create(const char > *name, uint32_t nb_elts, > return mp; > } >=20 > +struct rte_mempool * > +rte_cryptodev_asym_session_pool_create(const char *name, uint32_t nb_elt= s, > + uint32_t cache_size, int socket_id) > +{ > + struct rte_mempool *mp; > + struct rte_cryptodev_asym_session_pool_private_data *pool_priv; > + uint32_t obj_sz, obj_sz_aligned; > + uint8_t dev_id, priv_sz, max_priv_sz =3D 0; > + > + for (dev_id =3D 0; dev_id < RTE_CRYPTO_MAX_DEVS; dev_id++) > + if (rte_cryptodev_is_valid_dev(dev_id)) { > + priv_sz =3D > rte_cryptodev_asym_get_private_session_size(dev_id); > + if (priv_sz > max_priv_sz) > + max_priv_sz =3D priv_sz; > + } > + if (max_priv_sz =3D=3D 0) { > + CDEV_LOG_INFO("Could not set max private session size\n"); > + return NULL; > + } > + > + obj_sz =3D rte_cryptodev_asym_get_header_session_size() + max_priv_sz; > + obj_sz_aligned =3D RTE_ALIGN_CEIL(obj_sz, RTE_CACHE_LINE_SIZE); > + > + mp =3D rte_mempool_create(name, nb_elts, obj_sz_aligned, cache_size, > + (uint32_t)(sizeof(*pool_priv)), > + NULL, NULL, NULL, NULL, > + socket_id, 0); > + if (mp =3D=3D NULL) { > + CDEV_LOG_ERR("%s(name=3D%s) failed, rte_errno=3D%d\n", > + __func__, name, rte_errno); > + return NULL; > + } > + > + pool_priv =3D rte_mempool_get_priv(mp); > + if (!pool_priv) { > + CDEV_LOG_ERR("%s(name=3D%s) failed to get private data\n", > + __func__, name); > + rte_mempool_free(mp); > + return NULL; > + } > + pool_priv->max_priv_session_sz =3D max_priv_sz; > + > + rte_cryptodev_trace_asym_session_pool_create(name, nb_elts, > + cache_size, mp); > + return mp; > +} > + > static unsigned int > rte_cryptodev_sym_session_data_size(struct rte_cryptodev_sym_session *se= ss) > { > @@ -1895,19 +1909,43 @@ rte_cryptodev_sym_session_create(struct > rte_mempool *mp) > } >=20 > struct rte_cryptodev_asym_session * > -rte_cryptodev_asym_session_create(struct rte_mempool *mp) > +rte_cryptodev_asym_session_create(struct rte_mempool *mp, uint8_t dev_id= , > + struct rte_crypto_asym_xform *xforms) Please rearrange the function arguments similar to other APIs. Order should be rte_cryptodev_asym_session_create(dev_id, xforms, mp) > { > struct rte_cryptodev_asym_session *sess; > - unsigned int session_size =3D > + uint32_t session_priv_data_sz; > + struct rte_cryptodev_asym_session_pool_private_data *pool_priv; > + unsigned int session_header_size =3D > rte_cryptodev_asym_get_header_session_size(); > + struct rte_cryptodev *dev; > + int ret; > + > + if (!rte_cryptodev_is_valid_dev(dev_id)) { > + CDEV_LOG_ERR("Invalid dev_id=3D%" PRIu8, dev_id); > + return NULL; > + } > + session_priv_data_sz =3D rte_cryptodev_asym_get_private_session_size( > + dev_id); > + dev =3D rte_cryptodev_pmd_get_dev(dev_id); > + > + if (dev =3D=3D NULL) > + return NULL; >=20 > if (!mp) { > CDEV_LOG_ERR("invalid mempool\n"); > return NULL; > } Above checks should be before calling rte_cryptodev_asym_get_private_sessio= n_size(dev_id) >=20 > + pool_priv =3D rte_mempool_get_priv(mp); > + > + if (pool_priv->max_priv_session_sz < session_priv_data_sz) { > + CDEV_LOG_DEBUG( > + "The private session data size used when creating the > mempool is smaller than this device's private session data."); > + return NULL; > + } > + > /* Verify if provided mempool can hold elements big enough. */ > - if (mp->elt_size < session_size) { > + if (mp->elt_size < session_header_size + session_priv_data_sz) { > CDEV_LOG_ERR( > "mempool elements too small to hold session objects"); > return NULL; > @@ -1919,10 +1957,27 @@ rte_cryptodev_asym_session_create(struct > rte_mempool *mp) > return NULL; > } >=20 > + sess->driver_id =3D dev->driver_id; > + sess->max_priv_session_sz =3D pool_priv->max_priv_session_sz; > + > /* Clear device session pointer. > * Include the flag indicating presence of private data > */ > - memset(sess, 0, session_size); > + memset(sess->sess_private_data, 0, session_priv_data_sz); > + > + RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops- > >asym_session_configure, NULL); > + > + if (sess->sess_private_data[0] =3D=3D 0) { > + ret =3D dev->dev_ops->asym_session_configure(dev, > + xforms, > + sess, mp); The mempool object is allocated in the library layer, so why is it need to be passed to PMD? PMD cannot get mempool object. Right= ? > + if (ret < 0) { > + CDEV_LOG_ERR( > + "dev_id %d failed to configure session details", > + dev_id); > + return NULL; > + } > + } >=20 > rte_cryptodev_trace_asym_session_create(mp, sess); > return sess; > @@ -2009,20 +2064,11 @@ rte_cryptodev_sym_session_free(struct > rte_cryptodev_sym_session *sess) > int > rte_cryptodev_asym_session_free(struct rte_cryptodev_asym_session *sess) > { > - uint8_t i; > - void *sess_priv; > struct rte_mempool *sess_mp; >=20 > if (sess =3D=3D NULL) > return -EINVAL; >=20 > - /* Check that all device private data has been freed */ > - for (i =3D 0; i < nb_drivers; i++) { > - sess_priv =3D get_asym_session_private_data(sess, i); > - if (sess_priv !=3D NULL) > - return -EBUSY; > - } > - > /* Return session to mempool */ > sess_mp =3D rte_mempool_from_obj(sess); > rte_mempool_put(sess_mp, sess); As commented earlier, free and clear can be squashed to a single API. > @@ -2061,12 +2107,7 @@ > rte_cryptodev_sym_get_existing_header_session_size( > unsigned int > rte_cryptodev_asym_get_header_session_size(void) > { > - /* > - * Header contains pointers to the private data > - * of all registered drivers, and a flag which > - * indicates presence of private data > - */ > - return ((sizeof(void *) * nb_drivers) + sizeof(uint8_t)); > + return sizeof(struct rte_cryptodev_asym_session); > } >=20 > unsigned int > @@ -2092,7 +2133,6 @@ unsigned int > rte_cryptodev_asym_get_private_session_size(uint8_t dev_id) > { > struct rte_cryptodev *dev; > - unsigned int header_size =3D sizeof(void *) * nb_drivers; > unsigned int priv_sess_size; >=20 > if (!rte_cryptodev_is_valid_dev(dev_id)) > @@ -2104,11 +2144,8 @@ > rte_cryptodev_asym_get_private_session_size(uint8_t dev_id) > return 0; >=20 > priv_sess_size =3D (*dev->dev_ops->asym_session_get_size)(dev); > - if (priv_sess_size < header_size) > - return header_size; >=20 > return priv_sess_size; > - > } >=20 > int > diff --git a/lib/cryptodev/rte_cryptodev.h b/lib/cryptodev/rte_cryptodev.= h > index 59ea5a54df..8bd85f1575 100644 > --- a/lib/cryptodev/rte_cryptodev.h > +++ b/lib/cryptodev/rte_cryptodev.h > @@ -919,9 +919,13 @@ struct rte_cryptodev_sym_session { > }; >=20 > /** Cryptodev asymmetric crypto session */ > -struct rte_cryptodev_asym_session { > - __extension__ void *sess_private_data[0]; > - /**< Private asymmetric session material */ > +__extension__ struct rte_cryptodev_asym_session { > + uint8_t driver_id; > + /**< Session driver ID. */ > + uint16_t max_priv_session_sz; > + /**< Size of private session data used when creating mempool */ > + uint8_t padding[5]; > + uint8_t sess_private_data[0]; > }; RTE_STD_C11 can be used instead of __extension__. Max_priv_session_sz can be renamed to max_priv_data_sz. Session word is redundant as it is inside session struct. >=20 > /** > @@ -956,6 +960,29 @@ rte_cryptodev_sym_session_pool_create(const char > *name, uint32_t nb_elts, > uint32_t elt_size, uint32_t cache_size, uint16_t priv_size, > int socket_id); >=20 > +/** > + * Create an asymmetric session mempool. > + * > + * @param name > + * The unique mempool name. > + * @param nb_elts > + * The number of elements in the mempool. > + * @param cache_size > + * The number of per-lcore cache elements > + * @param socket_id > + * The *socket_id* argument is the socket identifier in the case of > + * NUMA. The value can be *SOCKET_ID_ANY* if there is no NUMA > + * constraint for the reserved zone. > + * > + * @return > + * - On success return mempool > + * - On failure returns NULL > + */ > +__rte_experimental > +struct rte_mempool * > +rte_cryptodev_asym_session_pool_create(const char *name, uint32_t nb_elt= s, > + uint32_t cache_size, int socket_id); > + > /** > * Create symmetric crypto session header (generic with no private data) > * > @@ -973,13 +1000,17 @@ rte_cryptodev_sym_session_create(struct > rte_mempool *mempool); > * > * @param mempool mempool to allocate asymmetric session > * objects from > + * @param dev_id ID of device that we want the session to be used on > + * @param xforms Asymmetric crypto transform operations to apply on = flow > + * processed with this session Change the order of arguments as commented above. > * @return > * - On success return pointer to asym-session > * - On failure returns NULL > */ > __rte_experimental > struct rte_cryptodev_asym_session * > -rte_cryptodev_asym_session_create(struct rte_mempool *mempool); > +rte_cryptodev_asym_session_create(struct rte_mempool *mempool, > + uint8_t dev_id, struct rte_crypto_asym_xform *xforms); >=20 > /** > * Frees symmetric crypto session header, after checking that all > @@ -997,8 +1028,7 @@ int > rte_cryptodev_sym_session_free(struct rte_cryptodev_sym_session *sess); >=20 > /** > - * Frees asymmetric crypto session header, after checking that all > - * the device private data has been freed, returning it > + * Frees asymmetric crypto session header, returning it > * to its original mempool. > * > * @param sess Session header to be freed. > @@ -1006,7 +1036,6 @@ rte_cryptodev_sym_session_free(struct > rte_cryptodev_sym_session *sess); > * @return > * - 0 if successful. > * - -EINVAL if session is NULL. > - * - -EBUSY if not all device private data has been freed. > */ > __rte_experimental > int > @@ -1034,28 +1063,6 @@ rte_cryptodev_sym_session_init(uint8_t dev_id, > struct rte_crypto_sym_xform *xforms, > struct rte_mempool *mempool); >=20 > -/** > - * Initialize asymmetric session on a device with specific asymmetric xf= orm > - * > - * @param dev_id ID of device that we want the session to be used on > - * @param sess Session to be set up on a device > - * @param xforms Asymmetric crypto transform operations to apply on = flow > - * processed with this session > - * @param mempool Mempool to be used for internal allocation. > - * > - * @return > - * - On success, zero. > - * - -EINVAL if input parameters are invalid. > - * - -ENOTSUP if crypto device does not support the crypto transform. > - * - -ENOMEM if the private session could not be allocated. > - */ These error numbers should be added in the create() API. I guess your subsequent patch is doing that. > -__rte_experimental > -int > -rte_cryptodev_asym_session_init(uint8_t dev_id, > - struct rte_cryptodev_asym_session *sess, > - struct rte_crypto_asym_xform *xforms, > - struct rte_mempool *mempool); > - > /** > * Frees private data for the device id, based on its device type, > * returning it to its mempool. It is the application's responsibility > @@ -1075,11 +1082,10 @@ rte_cryptodev_sym_session_clear(uint8_t dev_id, > struct rte_cryptodev_sym_session *sess); >=20 > /** > - * Frees resources held by asymmetric session during > rte_cryptodev_session_init > + * Clear private data held by asymmetric session. > * > * @param dev_id ID of device that uses the asymmetric session. > - * @param sess Asymmetric session setup on device using > - * rte_cryptodev_session_init > + * @param sess Asymmetric session setup on device. > * @return > * - 0 if successful. > * - -EINVAL if device is invalid or session is NULL. > @@ -1116,7 +1122,7 @@ > rte_cryptodev_sym_get_existing_header_session_size( > struct rte_cryptodev_sym_session *sess); >=20 > /** > - * Get the size of the asymmetric session header, for all registered dri= vers. > + * Get the size of the asymmetric session header. > * > * @return > * Size of the asymmetric header session. > diff --git a/lib/cryptodev/rte_cryptodev_trace.h > b/lib/cryptodev/rte_cryptodev_trace.h > index d1f4f069a3..befbaf7f44 100644 > --- a/lib/cryptodev/rte_cryptodev_trace.h > +++ b/lib/cryptodev/rte_cryptodev_trace.h > @@ -83,6 +83,16 @@ RTE_TRACE_POINT( > rte_trace_point_emit_u16(sess->user_data_sz); > ) >=20 > +RTE_TRACE_POINT( > + rte_cryptodev_trace_asym_session_pool_create, > + RTE_TRACE_POINT_ARGS(const char *name, uint32_t nb_elts, > + uint32_t cache_size, void *mempool), > + rte_trace_point_emit_string(name); > + rte_trace_point_emit_u32(nb_elts); > + rte_trace_point_emit_u32(cache_size); > + rte_trace_point_emit_ptr(mempool); > +) > + > RTE_TRACE_POINT( > rte_cryptodev_trace_asym_session_create, > RTE_TRACE_POINT_ARGS(void *mempool, > @@ -117,17 +127,6 @@ RTE_TRACE_POINT( > rte_trace_point_emit_ptr(mempool); > ) >=20 > -RTE_TRACE_POINT( > - rte_cryptodev_trace_asym_session_init, > - RTE_TRACE_POINT_ARGS(uint8_t dev_id, > - struct rte_cryptodev_asym_session *sess, void *xforms, > - void *mempool), > - rte_trace_point_emit_u8(dev_id); > - rte_trace_point_emit_ptr(sess); > - rte_trace_point_emit_ptr(xforms); > - rte_trace_point_emit_ptr(mempool); > -) rte_cryptodev_trace_asym_session_create() would need an update due to these= changes. > - > RTE_TRACE_POINT( > rte_cryptodev_trace_sym_session_clear, > RTE_TRACE_POINT_ARGS(uint8_t dev_id, void *sess), > diff --git a/lib/cryptodev/version.map b/lib/cryptodev/version.map > index c50745fa8c..eaea976f21 100644 > --- a/lib/cryptodev/version.map > +++ b/lib/cryptodev/version.map > @@ -58,7 +58,6 @@ EXPERIMENTAL { > rte_cryptodev_asym_session_clear; > rte_cryptodev_asym_session_create; > rte_cryptodev_asym_session_free; > - 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; > @@ -81,7 +80,6 @@ EXPERIMENTAL { > __rte_cryptodev_trace_sym_session_free; > __rte_cryptodev_trace_asym_session_free; > __rte_cryptodev_trace_sym_session_init; > - __rte_cryptodev_trace_asym_session_init; > __rte_cryptodev_trace_sym_session_clear; > __rte_cryptodev_trace_asym_session_clear; > __rte_cryptodev_trace_dequeue_burst; > @@ -104,6 +102,9 @@ EXPERIMENTAL { > rte_cryptodev_remove_deq_callback; > rte_cryptodev_remove_enq_callback; >=20 > + # added 22.03 > + rte_cryptodev_asym_session_pool_create; > + __rte_cryptodev_trace_asym_session_pool_create; > }; >=20 > INTERNAL { > -- > 2.25.1