From patchwork Wed Oct 26 10:54:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhangfei Gao X-Patchwork-Id: 618808 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp317042pvb; Wed, 26 Oct 2022 04:01:25 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4K0cWJDyK5N99+RxA3JTSLAwl5gYJPmxsrJewtGARPcRe237XpY2eftI+7yv0k7BASFC+V X-Received: by 2002:a5d:4ac8:0:b0:236:781a:8d2d with SMTP id y8-20020a5d4ac8000000b00236781a8d2dmr8898402wrs.715.1666782085621; Wed, 26 Oct 2022 04:01:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666782085; cv=none; d=google.com; s=arc-20160816; b=u0sNKM5MBOCqcbbc0ShpEV5+5remoi9JsPelTNungg2OhceKUMK4dWJYgPKE5b/SsH O3S0F86EoW10tVlRdBBCijYUowh+19fDXmHs8x/lBxYU6y8lTBKqVrui4HEPzKRDypfD o7UqA7az3pxgw+jWYGzwYG8L0+wFPf7tLZJn75t85p3Nw78wP205Qo2Ye2/vbSVxiqmp pArHP+65O8xWi2Jm5eajaNEPKZ6+JiaOf480AB2Nwh6o8SeediGwZLQxy+OKR12BbX96 b1yvctj0CMbHvMFe6VUOjZL4qDLOrRWFlQIUzWovGHX63NdL0gQI1bGIOgdB484wKnVh 8LYg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=mA2GgYtrtLWfJ7gQUEuGSD6oUUd9ZrpUWfXaS4o+1ro=; b=PRUQMyR+iazZ223fwQgEQ1W+G5qrqOa8QwVD6XTYKThd2BSts4GZIGcmHHPuUt4Z7+ c/d3EdYOSttZgTw/efvG0ScK9BPuzfOF68Qx3khZ1rx6S02P6NFtBqlPvcw0rxI01j9e H+sArSqLeOisBo0WxcFlG6fCTSX81qMMKN/Ksg/KEPce/vH520FJGYSsx8ODF4+Teq2H XapPGQrrFjq4k8CsCbihnk3Lqc8iMOJYvTT1LbkwxnTYEW9ukbi5zrANIu+NvCxrQunP tm1lYFUhLXv7VI//VbtvCh+FAiKe6nVjRuiB1Mz5nc3JL8A0OZvrgLA+szgtjqjKio0C pNpA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=tkchKPBR; spf=pass (google.com: domain of dev-bounces@dpdk.org designates 217.70.189.124 as permitted sender) smtp.mailfrom=dev-bounces@dpdk.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mails.dpdk.org (mails.dpdk.org. [217.70.189.124]) by mx.google.com with ESMTP id iv19-20020a05600c549300b003cf42c30ec6si1563505wmb.34.2022.10.26.04.01.25; Wed, 26 Oct 2022 04:01:25 -0700 (PDT) Received-SPF: pass (google.com: domain of dev-bounces@dpdk.org designates 217.70.189.124 as permitted sender) client-ip=217.70.189.124; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=tkchKPBR; spf=pass (google.com: domain of dev-bounces@dpdk.org designates 217.70.189.124 as permitted sender) smtp.mailfrom=dev-bounces@dpdk.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 673F1427F6; Wed, 26 Oct 2022 13:01:22 +0200 (CEST) Received: from mail-wr1-f43.google.com (mail-wr1-f43.google.com [209.85.221.43]) by mails.dpdk.org (Postfix) with ESMTP id A692440041 for ; Wed, 26 Oct 2022 13:01:18 +0200 (CEST) Received: by mail-wr1-f43.google.com with SMTP id z14so12174695wrn.7 for ; Wed, 26 Oct 2022 04:01:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=mA2GgYtrtLWfJ7gQUEuGSD6oUUd9ZrpUWfXaS4o+1ro=; b=tkchKPBR+girVC1HDR3VMo/LZj75TDczCgJwD7MzVH7tYfy1P8f++xAMzxZ8m1MXol I3dYwvYVg2SqN7xyGl05fwBlyPf7uZifFK5i3XymHDvPEEqas904tASBlqgB6ninBO4x scO8zB9lau+bsWcpqt1nTxzFN9c4H7dcZvcB7crSlUYOxFen8rlJMczPDOkTcJJ3v9mX ayGOL1aFlOv394EMQXBoyqDLDL/sAiSrRqP0GEokjxzoyPfQ75TjNH4x9EzjDXEGrDhK UK6Ne7cac0k1rVtpqoLzx5E5rhgCxYKqMRT/3JAceWVdkV2NvvjVfIJsCCN8oBPtVJWZ lKzQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=mA2GgYtrtLWfJ7gQUEuGSD6oUUd9ZrpUWfXaS4o+1ro=; b=472OEja7W3inwUAsGgPLbwFjs5F4eABVJqIs78ARFde8aCXy4ivibb4NmqQr2GeKXz Mb8nilGiHhMFhjR/2fTmw16pT74rfg2Uig9RKVLv3MfyNgVBae3zQyQM0KEOTXTJFiqJ 99PFlfATZ9dYkdPHgxnmrnjgUp6bxnF5UVTPIYPRa2omP+dYyct4wSfj9QTtexz5KCoM V98oish7hDB2bJBOVeoneqwfR1JLnTcOJXuG4C28sDTgC2rkrpeJ6n8i9j+6rWWLjvmS PzbmKcUn9YnkOeSK5tyJ8+Ldz19BZ7Bmp4OD/d5urJQtaCZ9CdlJZy9zztE/7/k2YPdh +o2Q== X-Gm-Message-State: ACrzQf1RHt60LXdtOOsJKejkVdDTbAPo9EseEp+vt0712BHnFDaPSeX9 k6aQ39xHF2Zvzgo/LtOnyJAlsA== X-Received: by 2002:adf:dd4d:0:b0:236:6e72:be17 with SMTP id u13-20020adfdd4d000000b002366e72be17mr10985607wrm.460.1666782078337; Wed, 26 Oct 2022 04:01:18 -0700 (PDT) Received: from localhost.localdomain ([213.146.143.36]) by smtp.gmail.com with ESMTPSA id h14-20020a5d688e000000b0023660f6cecfsm4856094wru.80.2022.10.26.04.01.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Oct 2022 04:01:17 -0700 (PDT) From: Zhangfei Gao To: Akhil Goyal , Declan Doherty , Fan Zhang , Ashish Gupta , Ray Kinsella , "thomas@monjalon.net" Cc: dev@dpdk.org, acc@openeuler.org, Zhangfei Gao Subject: [PATCH v6 1/6] crypto/uadk: introduce uadk crypto driver Date: Wed, 26 Oct 2022 18:54:24 +0800 Message-Id: <20221026105429.1899867-2-zhangfei.gao@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221026105429.1899867-1-zhangfei.gao@linaro.org> References: <20221026105429.1899867-1-zhangfei.gao@linaro.org> MIME-Version: 1.0 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 Introduce a new crypto PMD for hardware accelerators based on UADK [1]. UADK is a framework for user applications to access hardware accelerators. UADK relies on IOMMU SVA (Shared Virtual Address) feature, which share the same page table between IOMMU and MMU. Thereby user application can directly use virtual address for device dma, which enhances the performance as well as easy usability. This patch adds the basic framework. [1] https://github.com/Linaro/uadk Signed-off-by: Zhangfei Gao --- MAINTAINERS | 6 + doc/guides/cryptodevs/features/uadk.ini | 33 ++++++ doc/guides/cryptodevs/index.rst | 1 + doc/guides/cryptodevs/uadk.rst | 72 ++++++++++++ doc/guides/rel_notes/release_22_11.rst | 6 + drivers/crypto/meson.build | 1 + drivers/crypto/uadk/meson.build | 30 +++++ drivers/crypto/uadk/uadk_crypto_pmd.c | 110 ++++++++++++++++++ drivers/crypto/uadk/uadk_crypto_pmd_private.h | 25 ++++ drivers/crypto/uadk/version.map | 3 + 10 files changed, 287 insertions(+) create mode 100644 doc/guides/cryptodevs/features/uadk.ini create mode 100644 doc/guides/cryptodevs/uadk.rst create mode 100644 drivers/crypto/uadk/meson.build create mode 100644 drivers/crypto/uadk/uadk_crypto_pmd.c create mode 100644 drivers/crypto/uadk/uadk_crypto_pmd_private.h create mode 100644 drivers/crypto/uadk/version.map diff --git a/MAINTAINERS b/MAINTAINERS index 6f56111323..bf9baa9070 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -1060,6 +1060,12 @@ M: Kai Ji F: drivers/crypto/scheduler/ F: doc/guides/cryptodevs/scheduler.rst +HiSilicon UADK crypto +M: Zhangfei Gao +F: drivers/crypto/uadk/ +F: doc/guides/cryptodevs/uadk.rst +F: doc/guides/cryptodevs/features/uadk.ini + Intel QuickAssist M: Kai Ji F: drivers/crypto/qat/ diff --git a/doc/guides/cryptodevs/features/uadk.ini b/doc/guides/cryptodevs/features/uadk.ini new file mode 100644 index 0000000000..df5ad40e3d --- /dev/null +++ b/doc/guides/cryptodevs/features/uadk.ini @@ -0,0 +1,33 @@ +; +; Supported features of the 'uadk' crypto driver. +; +; Refer to default.ini for the full list of available PMD features. +; +[Features] +HW Accelerated = Y + +; +; Supported crypto algorithms of the 'uadk' crypto driver. +; +[Cipher] + +; +; Supported authentication algorithms of the 'uadk' crypto driver. +; +[Auth] + +; +; Supported AEAD algorithms of the 'uadk' crypto driver. +; +[AEAD] + +; +; Supported Asymmetric algorithms of the 'uadk' crypto driver. +; +[Asymmetric] + +; +; Supported Operating systems of the 'uadk' crypto driver. +; +[OS] +Linux = Y diff --git a/doc/guides/cryptodevs/index.rst b/doc/guides/cryptodevs/index.rst index 39cca6dbde..cb4ce227e9 100644 --- a/doc/guides/cryptodevs/index.rst +++ b/doc/guides/cryptodevs/index.rst @@ -30,5 +30,6 @@ Crypto Device Drivers scheduler snow3g qat + uadk virtio zuc diff --git a/doc/guides/cryptodevs/uadk.rst b/doc/guides/cryptodevs/uadk.rst new file mode 100644 index 0000000000..2a0cb300e9 --- /dev/null +++ b/doc/guides/cryptodevs/uadk.rst @@ -0,0 +1,72 @@ +.. SPDX-License-Identifier: BSD-3-Clause + Copyright 2022-2023 Huawei Technologies Co.,Ltd. All rights reserved. + Copyright 2022-2023 Linaro ltd. + +UADK Crypto Poll Mode Driver +============================ + +This code provides the initial implementation of the UADK poll mode +driver. All cryptographic operations are using UADK library crypto API, +which is algorithm level API, abstracting accelerators' low level +implementations. + +UADK crypto PMD relies on UADK library [1] + +UADK is a framework for user applications to access hardware accelerators. +UADK relies on IOMMU SVA (Shared Virtual Address) feature, which share +the same page table between IOMMU and MMU. +As a result, user application can directly use virtual address for device DMA, +which enhances the performance as well as easy usability. + + +Features +-------- + +UADK crypto PMD has support for: + + +Test steps +---------- + + .. code-block:: console + + 1. Build UADK + $ git clone https://github.com/Linaro/uadk.git + $ cd uadk + $ mkdir build + $ ./autogen.sh + $ ./configure --prefix=$PWD/build + $ make + $ make install + + * Without --prefix, UADK will be installed to /usr/local/lib by default + * If get error:"cannot find -lnuma", please install the libnuma-dev + + 2. Run pkg-config libwd to ensure env is setup correctly + $ export PKG_CONFIG_PATH=$PWD/build/lib/pkgconfig + $ pkg-config libwd --cflags --libs + -I/usr/local/include -L/usr/local/lib -lwd + + * export PKG_CONFIG_PATH is required on demand, + not needed if UADK is installed to /usr/local/lib + + 3. Build DPDK + $ cd dpdk + $ mkdir build + $ meson build (--reconfigure) + $ cd build + $ ninja + $ sudo ninja install + + 4. Prepare hugepage for dpdk + $ echo 1024 > /sys/devices/system/node/node0/hugepages/hugepages-2048kB/nr_hugepages + $ echo 1024 > /sys/devices/system/node/node1/hugepages/hugepages-2048kB/nr_hugepages + $ echo 1024 > /sys/devices/system/node/node2/hugepages/hugepages-2048kB/nr_hugepages + $ echo 1024 > /sys/devices/system/node/node3/hugepages/hugepages-2048kB/nr_hugepages + $ mkdir -p /mnt/huge_2mb + $ mount -t hugetlbfs none /mnt/huge_2mb -o pagesize=2MB + + 5. Run test app + + +[1] https://github.com/Linaro/uadk diff --git a/doc/guides/rel_notes/release_22_11.rst b/doc/guides/rel_notes/release_22_11.rst index 81cd66390d..6126031d2b 100644 --- a/doc/guides/rel_notes/release_22_11.rst +++ b/doc/guides/rel_notes/release_22_11.rst @@ -197,6 +197,12 @@ New Features integrated on SPR-EE. See the :doc:`../bbdevs/acc200` BBDEV guide for more details on this new driver. +* **Added UADK crypto driver.** + + Added a new ``UADK`` crypto driver for the UADK library + See the + :doc:`../cryptodevs/uadk.rst` UADK guide for more details on this new driver. + * **Added eventdev adapter instance get API.** * Added ``rte_event_eth_rx_adapter_instance_get`` to get Rx adapter diff --git a/drivers/crypto/meson.build b/drivers/crypto/meson.build index 147b8cf633..ee5377deff 100644 --- a/drivers/crypto/meson.build +++ b/drivers/crypto/meson.build @@ -18,6 +18,7 @@ drivers = [ 'octeontx', 'openssl', 'scheduler', + 'uadk', 'virtio', ] diff --git a/drivers/crypto/uadk/meson.build b/drivers/crypto/uadk/meson.build new file mode 100644 index 0000000000..f6fae0a239 --- /dev/null +++ b/drivers/crypto/uadk/meson.build @@ -0,0 +1,30 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright 2022-2023 Huawei Technologies Co.,Ltd. All rights reserved. +# Copyright 2022-2023 Linaro ltd. + +if not is_linux + build = false + reason = 'only supported on Linux' + subdir_done() +endif + +sources = files( + 'uadk_crypto_pmd.c', +) + +deps += 'bus_vdev' +dep = dependency('libwd_crypto', required: false, method: 'pkg-config') +if not dep.found() + build = false + reason = 'missing dependency, "libwd_crypto"' +else + ext_deps += dep +endif + +dep = dependency('libwd', required: false, method: 'pkg-config') +if not dep.found() + build = false + reason = 'missing dependency, "libwd"' +else + ext_deps += dep +endif diff --git a/drivers/crypto/uadk/uadk_crypto_pmd.c b/drivers/crypto/uadk/uadk_crypto_pmd.c new file mode 100644 index 0000000000..34df3ccbb9 --- /dev/null +++ b/drivers/crypto/uadk/uadk_crypto_pmd.c @@ -0,0 +1,110 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright 2022-2023 Huawei Technologies Co.,Ltd. All rights reserved. + * Copyright 2022-2023 Linaro ltd. + */ + +#include + +#include +#include +#include + +#include +#include +#include + +#include "uadk_crypto_pmd_private.h" + +static uint8_t uadk_cryptodev_driver_id; + +static struct rte_cryptodev_ops uadk_crypto_pmd_ops = { + .dev_configure = NULL, + .dev_start = NULL, + .dev_stop = NULL, + .dev_close = NULL, + .stats_get = NULL, + .stats_reset = NULL, + .dev_infos_get = NULL, + .queue_pair_setup = NULL, + .queue_pair_release = NULL, + .sym_session_get_size = NULL, + .sym_session_configure = NULL, + .sym_session_clear = NULL, +}; + +static int +uadk_cryptodev_probe(struct rte_vdev_device *vdev) +{ + struct rte_cryptodev_pmd_init_params init_params = { + .name = "", + .private_data_size = sizeof(struct uadk_crypto_priv), + .max_nb_queue_pairs = + RTE_CRYPTODEV_PMD_DEFAULT_MAX_NB_QUEUE_PAIRS, + }; + enum uadk_crypto_version version = UADK_CRYPTO_V2; + struct uadk_crypto_priv *priv; + struct rte_cryptodev *dev; + struct uacce_dev *udev; + const char *name; + + udev = wd_get_accel_dev("cipher"); + if (!udev) + return -ENODEV; + + if (!strcmp(udev->api, "hisi_qm_v2")) + version = UADK_CRYPTO_V2; + + free(udev); + + name = rte_vdev_device_name(vdev); + if (name == NULL) + return -EINVAL; + + dev = rte_cryptodev_pmd_create(name, &vdev->device, &init_params); + if (dev == NULL) { + UADK_LOG(ERR, "driver %s: create failed", init_params.name); + return -ENODEV; + } + + dev->dev_ops = &uadk_crypto_pmd_ops; + dev->driver_id = uadk_cryptodev_driver_id; + dev->dequeue_burst = NULL; + dev->enqueue_burst = NULL; + dev->feature_flags = RTE_CRYPTODEV_FF_HW_ACCELERATED; + priv = dev->data->dev_private; + priv->version = version; + + rte_cryptodev_pmd_probing_finish(dev); + + return 0; +} + +static int +uadk_cryptodev_remove(struct rte_vdev_device *vdev) +{ + struct rte_cryptodev *cryptodev; + const char *name; + + name = rte_vdev_device_name(vdev); + if (name == NULL) + return -EINVAL; + + cryptodev = rte_cryptodev_pmd_get_named_dev(name); + if (cryptodev == NULL) + return -ENODEV; + + return rte_cryptodev_pmd_destroy(cryptodev); +} + +static struct rte_vdev_driver uadk_crypto_pmd = { + .probe = uadk_cryptodev_probe, + .remove = uadk_cryptodev_remove, +}; + +static struct cryptodev_driver uadk_crypto_drv; + +#define UADK_CRYPTO_DRIVER_NAME crypto_uadk +RTE_PMD_REGISTER_VDEV(UADK_CRYPTO_DRIVER_NAME, uadk_crypto_pmd); +RTE_PMD_REGISTER_CRYPTO_DRIVER(uadk_crypto_drv, uadk_crypto_pmd.driver, + uadk_cryptodev_driver_id); +RTE_LOG_REGISTER_DEFAULT(uadk_crypto_logtype, INFO); diff --git a/drivers/crypto/uadk/uadk_crypto_pmd_private.h b/drivers/crypto/uadk/uadk_crypto_pmd_private.h new file mode 100644 index 0000000000..c4090f6119 --- /dev/null +++ b/drivers/crypto/uadk/uadk_crypto_pmd_private.h @@ -0,0 +1,25 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright 2022-2023 Huawei Technologies Co.,Ltd. All rights reserved. + * Copyright 2022-2023 Linaro ltd. + */ + +#ifndef _UADK_CRYPTO_PMD_PRIVATE_H_ +#define _UADK_CRYPTO_PMD_PRIVATE_H_ + +enum uadk_crypto_version { + UADK_CRYPTO_V2, + UADK_CRYPTO_V3, +}; + +struct uadk_crypto_priv { + enum uadk_crypto_version version; +} __rte_cache_aligned; + +extern int uadk_crypto_logtype; + +#define UADK_LOG(level, fmt, ...) \ + rte_log(RTE_LOG_ ## level, uadk_crypto_logtype, \ + "%s() line %u: " fmt "\n", __func__, __LINE__, \ + ## __VA_ARGS__) + +#endif /* _UADK_CRYPTO_PMD_PRIVATE_H_ */ diff --git a/drivers/crypto/uadk/version.map b/drivers/crypto/uadk/version.map new file mode 100644 index 0000000000..78c3585d7c --- /dev/null +++ b/drivers/crypto/uadk/version.map @@ -0,0 +1,3 @@ +DPDK_23 { + local: *; +};