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 21630A0C51; Fri, 16 Jul 2021 21:26:23 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 986514067B; Fri, 16 Jul 2021 21:26:22 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by mails.dpdk.org (Postfix) with ESMTP id 091F240151 for ; Fri, 16 Jul 2021 21:26:20 +0200 (CEST) Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 16GJPwbf003191; Fri, 16 Jul 2021 12:26:20 -0700 Received: from nam10-mw2-obe.outbound.protection.outlook.com (mail-mw2nam10lp2108.outbound.protection.outlook.com [104.47.55.108]) by mx0a-0016f401.pphosted.com with ESMTP id 39tw30m0xa-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 16 Jul 2021 12:26:19 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BSPBT6+Du6G4Gr+HcNsMI2enpsK90J8TBATDDhtUgRb2NjsMnl1dzJClMlcwXNbkcp0o4aIhv+bpaoU0S9tW+RLzeKwIMQwdscX/tYG8JyJW89WyHlExFzPBKUMmHgh5N6gPfPMJikjWstDJMOqzi4Uu7iz3NW1I7JNuitTmoEKClK/68EGao7MOr/o8yNoVeQjuLaMK+VJtwupQIrwvgsv7QnffGmv9+iZ4OGP3pp6bpY+c4fJwV/Eu2hGR66MYjGdaQMKiUTjNfLLdV44TLJOis3pzpmxX7fz2lFda79x5dGAB3xJRGTX7XHuVT2+R73zuP5SDDt6+q4DoqwqIOQ== 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=BXV7qoMbA3GVDLOlJC3+9lHlvtos0vkPDSXsOCJl+uI=; b=Z6zOdIgYZrb+z5Vq6FmHDCHJiq5rK2jBpspzOENdZxgdQS7714A3hhNWPrTQp/WaqdkZZ+A4rggwTkFQHpApGhENHkjgB+lwx8K9oGgmPPu98eLg7GhF3mF/JOrho54rjQHZ9qbwzgTw3FUhN0+rHxGLadlhTdQviZi34ZxoU0FrL7Du6mpEadJBpBMYgm1HhD8Skjuph0LMLsAeKp7egi8kcyfxxSxH1k8NWgOp1NkHdHUz4ZV+J6mpomf2NmwAHfCptrZ3LauIZcptncdF5D5twD6jn/WLWBx4WzFe3k8cv802xeGuN399ghDibcuiwCbwK2p+PLi86LbaYtwejg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=marvell.com; dmarc=pass action=none header.from=marvell.com; dkim=pass header.d=marvell.com; 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=BXV7qoMbA3GVDLOlJC3+9lHlvtos0vkPDSXsOCJl+uI=; b=ZqCzGMhyBDhzj7DNVdyBGl0+KLT3iL+rSbXSYTLwbQPqd9Xl9bXxGdqsR9S16LKV53ndXizmSRScCsrxLARa6TNZiCqlRbTpDOKGMNw8tT4HVZq3MJnhIaoSucf+KyK+Kj/0NlIvFdemPWqDXOiJbVb5i1jrLjMjfTQBJAESvZg= Received: from CO6PR18MB4484.namprd18.prod.outlook.com (2603:10b6:5:359::9) by CO1PR18MB4745.namprd18.prod.outlook.com (2603:10b6:303:e8::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4331.23; Fri, 16 Jul 2021 19:26:17 +0000 Received: from CO6PR18MB4484.namprd18.prod.outlook.com ([fe80::1455:9a67:a6e7:e557]) by CO6PR18MB4484.namprd18.prod.outlook.com ([fe80::1455:9a67:a6e7:e557%6]) with mapi id 15.20.4331.028; Fri, 16 Jul 2021 19:26:16 +0000 From: Akhil Goyal To: Shiri Kuzin , "dev@dpdk.org" CC: "matan@nvidia.com" , "suanmingm@nvidia.com" , "david.marchand@redhat.com" Thread-Topic: [EXT] [PATCH v8 02/16] crypto/mlx5: add DEK object management Thread-Index: AQHXeZhaMdCELImi8ki1pN4sYTFFgKtF/HPQ Date: Fri, 16 Jul 2021 19:26:16 +0000 Message-ID: References: <20210715150817.51485-1-shirik@nvidia.com> <20210715164126.54073-1-shirik@nvidia.com> <20210715164126.54073-3-shirik@nvidia.com> In-Reply-To: <20210715164126.54073-3-shirik@nvidia.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: nvidia.com; dkim=none (message not signed) header.d=none;nvidia.com; dmarc=none action=none header.from=marvell.com; x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 331d6b67-d858-4b90-b724-08d9488f952c x-ms-traffictypediagnostic: CO1PR18MB4745: x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:4303; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: pzZzZ6n+ie7duOlWe9St1Wl4BE9t65FluxRIu4MfYY5InQCFL0iE6WzpVe8QLoubQ3TYhdhueudpQ0+bQXe8Mu2xZvBCXHCCKh55QKd9W1hCPk8t/8DGkEq9u96mnnZNleQXw8Y9n+ZpHjWCwnJo0SXJVSDIhlqCcplenl9ek1IfGhcRNRzZ1n9wncCisgKCezLgSTsIZH5ahc4GcrbMM4dmMsf+0d2eXFVVhfxGAczUY1Om+XYuIy1G78JLzPrMveB8oj00buTerDirQqQu+hDna6eCAJ0+XLCDYt6ZFchLp8z55pouhfNxKLL2pEgO5v5RAPEkJp7ojqW0oSM5JjUmii52WtKwypULEdE7o+vjr6qpaNXO23B2x0+Fdi6LVfotVnqpyOpxDKSW4CH+ZAoeSxcIx694yYVHpps+YS1JKZgJBIWqjbghBzXEqIpeLGBtFMKszv/azOeRNRHql+0XH4aLMGqm6Xl3Qi7ZmbNeV2N0URpk6vsuSJDD8svYj8t5jzeWOWj6gkYhMILO0Tqx19VBMG3870Ck7hsxdsjslF9kfyGxHibZhTgBW4Fl3qWgjyb6dwOxE/kH/Grz9diSZTK+Yq6nqp0dI2xWS2aoWJ5drSnPFpLkr/P2eObKL5ZrSStovXHO7uUDgOBL5oWOSSjufFbQFWiDPxCsguIrqfyHd92vzhD88yV6gLtyY+n71YjR1k9dpHlH4YwRNA== 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:(4636009)(366004)(136003)(396003)(376002)(346002)(39860400002)(7696005)(122000001)(478600001)(86362001)(33656002)(26005)(5660300002)(71200400001)(54906003)(38100700002)(55016002)(6506007)(186003)(8676002)(316002)(110136005)(52536014)(9686003)(66446008)(66556008)(66476007)(64756008)(8936002)(4326008)(66946007)(2906002)(30864003)(83380400001)(76116006)(38070700004); DIR:OUT; SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?9ND+6/VTP0nX3WcuZwotig7pekqzl/AJBauFVfgUszNJOy+iVDnzOBrerEgy?= =?us-ascii?Q?TM7ANWR6ek/+Rw0/KJvsQsWwOwgjpYtQ3P9QHhosjXJQW48jfUDJSi4cWOZi?= =?us-ascii?Q?j8HBOuwvDp79G4bHurbdfNh438fNjOtMNduj42h5xW+eqerc2fSSO3nRMovz?= =?us-ascii?Q?cIgUNKh2wVC7TVsXMUI5wKBy3LELQ/Oo8ZXKiZZ/biQgNXPCH4qbWRM84b28?= =?us-ascii?Q?1ur97seJlROUywXK/iw/AMau0N1Nt8y6gHNw5kH+9SjNMiXubBOHk1WKkrQM?= =?us-ascii?Q?bfYxUxvAn6+yJygirywNZdlW485a0kNToLsQr//SHa0GGV0uakg0NfVBhVuG?= =?us-ascii?Q?b609a5APyy99tawT4w7CWJjz4EAOI9uNXQPm/2P2LalXE8O1X6W9iPinlt7E?= =?us-ascii?Q?Y9y3y1dqKGH3u0lQQvJP99prFRPV5Lp4+KR1EoCyeH2FRw8RCOPnWMeWYvfl?= =?us-ascii?Q?Cr2H7Pi1vLWLOvcSj9AkLYZwWjuWLnpvLSShKlgH8cmBo4VqtMv3pDF2WQM4?= =?us-ascii?Q?Fl8/UVbW32UOUWcNW2qOyc4HDOZOFQCGiD7RNxFKOIx2zqXA7VjWbVQum2ob?= =?us-ascii?Q?q8qRb++TlgNMFTsXxfwSnmw+TDGKkkxoMZ2GUAvmdOiYgKKGz/9L5AZ6NVpJ?= =?us-ascii?Q?bnsUHUJnuqsvLaUaC78hdeuHlIK+1lM9ysIKo1epzmAi2oyV3EcnPFtGmgfl?= =?us-ascii?Q?+jN5bAQpgF6UMsVjIXnLugQX1nIkT+OS7MlWkiMZOlHNLFb1lWzDeN8pIrwo?= =?us-ascii?Q?i2nCIEoiyqEOqMZ6yOWGBkFpiVyP6TpaWM3xIkJxHc1cKAuOnfZC09oI/1lJ?= =?us-ascii?Q?yzt1gXRbTq5ZiazgjtW6tDni4UIUbksaBdv4IG38SPA5kFqxk5EL7Zw4FPIs?= =?us-ascii?Q?9ghrvHiK1pWdGZMdfK60iIyGTeWmf3usMsX6mf+hlno51d25hnVb5JEPg64V?= =?us-ascii?Q?YvVQ+M9WbKLKvxsNe8EIODDwYR9oHugJM4gyRhDbqE7ZahKQLXCnUiMUs5mT?= =?us-ascii?Q?hwklwAR7UStf5uY3zVWCWiQk5F+x3jKL3pqGdayD186wE4EAol5nbKjYBijb?= =?us-ascii?Q?y9d50VxxPr0/viAJW1B7nG6fW45Z1WGmtBLCokgr8qnnPxpbiFqJ5HoPkTVc?= =?us-ascii?Q?uTWQHPDghGYpnWUh6m5pXwMzXjF7w1R/A1SATGHeT0Nq74AbtpOhiNLNsnzD?= =?us-ascii?Q?UNa19ehhaESGIusCFkfKFXvH1yDXgrGlHAitEkSF5LYkqFOm11Y7ofab06MT?= =?us-ascii?Q?yzqdRyhOVSrJUYgov/IMa3rcx60dV9h0Z0BrZpklXJPI+8HZ5OcJB85T2HRJ?= =?us-ascii?Q?PLQ=3D?= x-ms-exchange-transport-forked: True 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: 331d6b67-d858-4b90-b724-08d9488f952c X-MS-Exchange-CrossTenant-originalarrivaltime: 16 Jul 2021 19:26:16.9008 (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: PoA9fhcNqtlEd//BmIr9nl3DtUJH5Rca1TpGT7/dv/g2OiG8aRlJ44BlCQnWZPHdfp2+YYbi7U0+anzy97HM2A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO1PR18MB4745 X-Proofpoint-ORIG-GUID: pdY3jnA-xPUeBVkYDD8b4_5vnOKqgY_J X-Proofpoint-GUID: pdY3jnA-xPUeBVkYDD8b4_5vnOKqgY_J X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.391, 18.0.790 definitions=2021-07-16_09:2021-07-16, 2021-07-16 signatures=0 Subject: Re: [dpdk-dev] [EXT] [PATCH v8 02/16] crypto/mlx5: add DEK object management 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 Sender: "dev" > A DEK(Data encryption Key) is an mlx5 HW object which represents the > cipher algorithm key. > The DEKs are used during data encryption/decryption operations. >=20 > In symmetric algorithms like AES-STS, we use the same DEK for both > encryption and decryption. >=20 > Use the mlx5 hash-list tool to manage the DEK objects in the PMD. >=20 > Provide the compare, create and destroy functions to manage DEKs in > hash-list and introduce an internal API to setup and unset the DEK > management and to prepare and destroy specific DEK object. >=20 > The DEK hash-list will be created in dev_configure routine and > destroyed in dev_close routine. >=20 > Signed-off-by: Shiri Kuzin > Acked-by: Matan Azrad > --- > drivers/crypto/mlx5/meson.build | 1 + > drivers/crypto/mlx5/mlx5_crypto.c | 42 ++++--- > drivers/crypto/mlx5/mlx5_crypto.h | 51 ++++++++ > drivers/crypto/mlx5/mlx5_crypto_dek.c | 161 > ++++++++++++++++++++++++++ > 4 files changed, 239 insertions(+), 16 deletions(-) > create mode 100644 drivers/crypto/mlx5/mlx5_crypto.h > create mode 100644 drivers/crypto/mlx5/mlx5_crypto_dek.c >=20 > diff --git a/drivers/crypto/mlx5/meson.build > b/drivers/crypto/mlx5/meson.build > index 6fd70bc477..d55cdbfe6f 100644 > --- a/drivers/crypto/mlx5/meson.build > +++ b/drivers/crypto/mlx5/meson.build > @@ -11,6 +11,7 @@ fmt_name =3D 'mlx5_crypto' > deps +=3D ['common_mlx5', 'eal', 'cryptodev'] > sources =3D files( > 'mlx5_crypto.c', > + 'mlx5_crypto_dek.c', > ) > cflags_options =3D [ > '-std=3Dc11', > diff --git a/drivers/crypto/mlx5/mlx5_crypto.c > b/drivers/crypto/mlx5/mlx5_crypto.c > index fbe3c21aae..d2d82c7b15 100644 > --- a/drivers/crypto/mlx5/mlx5_crypto.c > +++ b/drivers/crypto/mlx5/mlx5_crypto.c > @@ -3,12 +3,9 @@ > */ >=20 > #include > -#include > #include > +#include > #include > -#include > -#include > -#include There is some issue in the splitting of the patches, The above headers are added in first patch and moved to a header file in th= is patch. Take reference of the cnxk crypto driver which got merged recently. >=20 > #include > #include > @@ -17,6 +14,7 @@ > #include >=20 > #include "mlx5_crypto_utils.h" > +#include "mlx5_crypto.h" >=20 > #define MLX5_CRYPTO_DRIVER_NAME mlx5_crypto > #define MLX5_CRYPTO_LOG_NAME pmd.crypto.mlx5 > @@ -24,16 +22,6 @@ > #define MLX5_CRYPTO_FEATURE_FLAGS \ > RTE_CRYPTODEV_FF_HW_ACCELERATED >=20 > -struct mlx5_crypto_priv { > - TAILQ_ENTRY(mlx5_crypto_priv) next; > - struct ibv_context *ctx; /* Device context. */ > - struct rte_pci_device *pci_dev; > - struct rte_cryptodev *crypto_dev; > - void *uar; /* User Access Region. */ > - uint32_t pdn; /* Protection Domain number. */ > - struct ibv_pd *pd; > -}; > - > TAILQ_HEAD(mlx5_crypto_privs, mlx5_crypto_priv) mlx5_crypto_priv_list = =3D >=20 > TAILQ_HEAD_INITIALIZER(mlx5_crypto_priv_list); > static pthread_mutex_t priv_list_lock =3D PTHREAD_MUTEX_INITIALIZER; > @@ -51,11 +39,33 @@ static const struct rte_driver mlx5_drv =3D { >=20 > static struct cryptodev_driver mlx5_cryptodev_driver; >=20 > +static int > +mlx5_crypto_dev_configure(struct rte_cryptodev *dev, > + struct rte_cryptodev_config *config __rte_unused) > +{ > + struct mlx5_crypto_priv *priv =3D dev->data->dev_private; > + > + if (mlx5_crypto_dek_setup(priv) !=3D 0) { > + DRV_LOG(ERR, "Dek hash list creation has failed."); > + return -ENOMEM; > + } > + return 0; > +} > + > +static int > +mlx5_crypto_dev_close(struct rte_cryptodev *dev) > +{ > + struct mlx5_crypto_priv *priv =3D dev->data->dev_private; > + > + mlx5_crypto_dek_unset(priv); > + return 0; > +} > + > static struct rte_cryptodev_ops mlx5_crypto_ops =3D { > - .dev_configure =3D NULL, > + .dev_configure =3D mlx5_crypto_dev_configure, > .dev_start =3D NULL, > .dev_stop =3D NULL, > - .dev_close =3D NULL, > + .dev_close =3D mlx5_crypto_dev_close, > .dev_infos_get =3D NULL, > .stats_get =3D NULL, > .stats_reset =3D NULL, > diff --git a/drivers/crypto/mlx5/mlx5_crypto.h > b/drivers/crypto/mlx5/mlx5_crypto.h > new file mode 100644 > index 0000000000..167e9e57ad > --- /dev/null > +++ b/drivers/crypto/mlx5/mlx5_crypto.h > @@ -0,0 +1,51 @@ > +/* SPDX-License-Identifier: BSD-3-Clause > + * Copyright (c) 2021 NVIDIA Corporation & Affiliates > + */ > + > +#ifndef MLX5_CRYPTO_H_ > +#define MLX5_CRYPTO_H_ > + > +#include > + > +#include > +#include > + > +#include > + > +#define MLX5_CRYPTO_DEK_HTABLE_SZ (1 << 11) > +#define MLX5_CRYPTO_KEY_LENGTH 80 > + > +struct mlx5_crypto_priv { > + TAILQ_ENTRY(mlx5_crypto_priv) next; > + struct ibv_context *ctx; /* Device context. */ > + struct rte_pci_device *pci_dev; > + struct rte_cryptodev *crypto_dev; > + void *uar; /* User Access Region. */ > + uint32_t pdn; /* Protection Domain number. */ > + struct ibv_pd *pd; > + struct mlx5_hlist *dek_hlist; /* Dek hash list. */ > +}; > + > +struct mlx5_crypto_dek { > + struct mlx5_list_entry entry; /* Pointer to DEK hash list entry. */ > + struct mlx5_devx_obj *obj; /* Pointer to DEK DevX object. */ > + uint8_t data[MLX5_CRYPTO_KEY_LENGTH]; /* DEK key data. */ > + bool size_is_48; /* Whether the key\data size is 48 bytes or not. */ > +} __rte_cache_aligned; > + > +int > +mlx5_crypto_dek_destroy(struct mlx5_crypto_priv *priv, > + struct mlx5_crypto_dek *dek); > + > +struct mlx5_crypto_dek * > +mlx5_crypto_dek_prepare(struct mlx5_crypto_priv *priv, > + struct rte_crypto_cipher_xform *cipher); > + > +int > +mlx5_crypto_dek_setup(struct mlx5_crypto_priv *priv); > + > +void > +mlx5_crypto_dek_unset(struct mlx5_crypto_priv *priv); > + > +#endif /* MLX5_CRYPTO_H_ */ > + > diff --git a/drivers/crypto/mlx5/mlx5_crypto_dek.c > b/drivers/crypto/mlx5/mlx5_crypto_dek.c > new file mode 100644 > index 0000000000..43d1bcc9f8 > --- /dev/null > +++ b/drivers/crypto/mlx5/mlx5_crypto_dek.c > @@ -0,0 +1,161 @@ > +/* SPDX-License-Identifier: BSD-3-Clause > + * Copyright (c) 2021 NVIDIA Corporation & Affiliates > + */ > + > +#include > +#include > +#include > +#include > + > +#include > +#include > + > +#include "mlx5_crypto_utils.h" > +#include "mlx5_crypto.h" > + > +struct mlx5_crypto_dek_ctx { > + struct rte_crypto_cipher_xform *cipher; > + struct mlx5_crypto_priv *priv; > +}; > + > +int > +mlx5_crypto_dek_destroy(struct mlx5_crypto_priv *priv, > + struct mlx5_crypto_dek *dek) > +{ > + return mlx5_hlist_unregister(priv->dek_hlist, &dek->entry); > +} > + > +struct mlx5_crypto_dek * > +mlx5_crypto_dek_prepare(struct mlx5_crypto_priv *priv, > + struct rte_crypto_cipher_xform *cipher) > +{ > + struct mlx5_hlist *dek_hlist =3D priv->dek_hlist; > + struct mlx5_crypto_dek_ctx dek_ctx =3D { > + .cipher =3D cipher, > + .priv =3D priv, > + }; > + struct rte_crypto_cipher_xform *cipher_ctx =3D cipher; > + uint64_t key64 =3D __rte_raw_cksum(cipher_ctx->key.data, > + cipher_ctx->key.length, 0); > + struct mlx5_list_entry *entry =3D mlx5_hlist_register(dek_hlist, > + key64, &dek_ctx); > + > + return entry =3D=3D NULL ? NULL : > + container_of(entry, struct mlx5_crypto_dek, > entry); > +} > + > +static struct mlx5_list_entry * > +mlx5_crypto_dek_clone_cb(void *tool_ctx __rte_unused, > + struct mlx5_list_entry *oentry, > + void *cb_ctx __rte_unused) > +{ > + struct mlx5_crypto_dek *entry =3D rte_zmalloc(__func__, > sizeof(*entry), > + RTE_CACHE_LINE_SIZE); > + > + if (!entry) { > + DRV_LOG(ERR, "Cannot allocate dek resource memory."); > + rte_errno =3D ENOMEM; > + return NULL; > + } > + memcpy(entry, oentry, sizeof(*entry)); > + return &entry->entry; > +} > + > +static void > +mlx5_crypto_dek_clone_free_cb(void *tool_ctx __rte_unused, > + struct mlx5_list_entry *entry) > +{ > + struct mlx5_crypto_dek *dek =3D container_of(entry, > + struct mlx5_crypto_dek, > entry); > + > + rte_free(dek); > +} > + > +static int > +mlx5_crypto_dek_match_cb(void *tool_ctx __rte_unused, > + struct mlx5_list_entry *entry, void *cb_ctx) > +{ > + struct mlx5_crypto_dek_ctx *ctx =3D cb_ctx; > + struct rte_crypto_cipher_xform *cipher_ctx =3D ctx->cipher; > + struct mlx5_crypto_dek *dek =3D > + container_of(entry, typeof(*dek), entry); > + uint32_t key_len =3D dek->size_is_48 ? 48 : 80; > + > + if (key_len !=3D cipher_ctx->key.length) > + return -1; > + return memcmp(cipher_ctx->key.data, dek->data, key_len); > +} > + > +static struct mlx5_list_entry * > +mlx5_crypto_dek_create_cb(void *tool_ctx __rte_unused, void *cb_ctx) > +{ > + struct mlx5_crypto_dek_ctx *ctx =3D cb_ctx; > + struct rte_crypto_cipher_xform *cipher_ctx =3D ctx->cipher; > + struct mlx5_crypto_dek *dek =3D rte_zmalloc(__func__, sizeof(*dek), > + RTE_CACHE_LINE_SIZE); > + struct mlx5_devx_dek_attr dek_attr =3D { > + .pd =3D ctx->priv->pdn, > + .key_purpose =3D MLX5_CRYPTO_KEY_PURPOSE_AES_XTS, > + .has_keytag =3D 1, > + }; > + > + if (dek =3D=3D NULL) { > + DRV_LOG(ERR, "Failed to allocate dek memory."); > + return NULL; > + } > + switch (cipher_ctx->key.length) { > + case 48: > + dek->size_is_48 =3D true; > + dek_attr.key_size =3D MLX5_CRYPTO_KEY_SIZE_128b; > + break; > + case 80: > + dek->size_is_48 =3D false; > + dek_attr.key_size =3D MLX5_CRYPTO_KEY_SIZE_256b; > + break; > + default: > + DRV_LOG(ERR, "Key size not supported."); > + return NULL; > + } > + memcpy(&dek_attr.key, cipher_ctx->key.data, cipher_ctx- > >key.length); > + dek->obj =3D mlx5_devx_cmd_create_dek_obj(ctx->priv->ctx, > &dek_attr); > + if (dek->obj =3D=3D NULL) { > + rte_free(dek); > + return NULL; > + } > + memcpy(&dek->data, cipher_ctx->key.data, cipher_ctx->key.length); > + return &dek->entry; > +} > + > +static void > +mlx5_crypto_dek_remove_cb(void *tool_ctx __rte_unused, > + struct mlx5_list_entry *entry) > +{ > + struct mlx5_crypto_dek *dek =3D > + container_of(entry, typeof(*dek), entry); > + > + claim_zero(mlx5_devx_cmd_destroy(dek->obj)); > + rte_free(dek); > +} > + > + Extra line... > +int > +mlx5_crypto_dek_setup(struct mlx5_crypto_priv *priv) > +{ > + priv->dek_hlist =3D mlx5_hlist_create("dek_hlist", > + MLX5_CRYPTO_DEK_HTABLE_SZ, > + 0, 1, NULL, mlx5_crypto_dek_create_cb, > + mlx5_crypto_dek_match_cb, > + mlx5_crypto_dek_remove_cb, > + mlx5_crypto_dek_clone_cb, > + mlx5_crypto_dek_clone_free_cb); > + if (priv->dek_hlist =3D=3D NULL) > + return -1; > + return 0; > +} > + > +void > +mlx5_crypto_dek_unset(struct mlx5_crypto_priv *priv) > +{ > + mlx5_hlist_destroy(priv->dek_hlist); > + priv->dek_hlist =3D NULL; > +} > -- > 2.27.0