From patchwork Thu Sep 29 03:27:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhangfei Gao X-Patchwork-Id: 610565 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp647621pvb; Wed, 28 Sep 2022 20:28:07 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6CjjEWx79mUC1Px1RVw5L7rH2ldp7x7sQp8+wlZdiI3NogKDH1HnaUJiyfsmM888TmuPL1 X-Received: by 2002:a05:600c:3781:b0:3b4:63c8:554b with SMTP id o1-20020a05600c378100b003b463c8554bmr8995760wmr.25.1664422087036; Wed, 28 Sep 2022 20:28:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664422087; cv=none; d=google.com; s=arc-20160816; b=lcmxR+fflWBhh7hRrYefee27w9sl+248FDSRIZWqFhXoWLBtJ93LCiVj7zk5xTY76r F1x7vT3QiBA/01DEQR91dAU0LPWJlmP3n8XMS23ds65Le3nHAaAtp9zbhzmm5Ls5wgZD kblNoxE/hvEcFwcx2dDPDVy98gXMM7uzrX+l2HV71TrX7VrnD/rXPZ9JcbC5DldZiFPj YEJibQkYRMU5lYNlS7TOUHFXb9qKCqWZBji3lXcdSlIYdx0ScxcmJaCvFPEFaTsSkwsI D5TC67a6JcY5NnEInLV0BqaSIWkLUyn4vGyasqEx+IEP20fEBQ/NmzzrdTOzGWrzBT3b iANw== 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=7h0KGp7+IzEAdbyoCzq7fzvVoXxOS0I/bFJW9sxkg4A=; b=gN3fq3dSKO/kOp39Wf2YzxrkBuTc+YJ+owaPVfYkMBDTeiTPd5UsxYglIADe36o4Tc nEpDmJjQPQL+EcnN65teTa8lMsHmQ/dK1Il7ecYP/nzsMSwzO6++fzXRuj+/a3SjMRod nGjVFb5PibWawWuzLiOLoWFaHJDvog3HpIVoQSaESrgy7JXinxeFaVPYf1syjlDO7/jB 1EpgdSx29ioV414RfaSq6XYkPekzNFuqiIyjcELW9AnR0xXJMnSUENLB2c4pyd5UENBv cX8A65KOzRou0VnES4ozf14G1b4S7ErYw+vtIgrZjQmW2mlOHpYa7uYW6dIcd9ZrEVEp mbgg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=BC4YUJj1; 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 h3-20020adfaa83000000b00228dd3d93a8si3498941wrc.300.2022.09.28.20.28.06; Wed, 28 Sep 2022 20:28:07 -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=BC4YUJj1; 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 BA18C41140; Thu, 29 Sep 2022 05:28:06 +0200 (CEST) Received: from mail-pj1-f53.google.com (mail-pj1-f53.google.com [209.85.216.53]) by mails.dpdk.org (Postfix) with ESMTP id DA2C040DDC for ; Thu, 29 Sep 2022 05:28:05 +0200 (CEST) Received: by mail-pj1-f53.google.com with SMTP id q35-20020a17090a752600b002038d8a68fbso4719563pjk.0 for ; Wed, 28 Sep 2022 20:28:05 -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; bh=7h0KGp7+IzEAdbyoCzq7fzvVoXxOS0I/bFJW9sxkg4A=; b=BC4YUJj1QHvvWOLt/KgrdGY0BI42rScu+GRuIF7uYyl0L4wFlyKPOFRDyo9CMY+GrY nLEqHL3Uv2Lwj93bZyxWVYCsW3GMZzkobmX4hR7JfttFbMDmsygD9+/dqo4Jmi9WXPGc dTMfKiV4MommQTnZ6FWcG+aI1tP7T+byiQQ2Z1ZEkIKtDQ/v6XSsWWvQbqmy0TBa+zQ7 r2ERyJC6jlRxKL+R0VD3gB4iBBECW9sNswuOJB0JzlGBOpwTXA0muno0RiB8nC3mwUUh 2Vbv+aOwjPqO5I533jhi2H2GQD5qehj+eRgXmNEvk246Th70k4IH6O1GEShTXYEqfNSh ZKpw== 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; bh=7h0KGp7+IzEAdbyoCzq7fzvVoXxOS0I/bFJW9sxkg4A=; b=ADSH509wa2RKEY0GMDIacjL8QOorOUIJBq5ekeKzyduL2drDJoRfQg+QcvZ+anYA5Z cvZcL32oBebxMPiZCEkMUwFSbnMkUn6i7twsE5mjVA0UWpCrI+uiMLSXzdy60cLCmp8F aN0kOZFN4uwgJofnu/VCIy+2iWpAozarkBkMpVzufEUy5wrjba9U61g4i8hEqoDMlCsI v8IMIAz97ZLoCkCkOy6sXCIbvTeUFGAb3/sH83/WGrG4iiialf7peuOC4J16y2mCwFyR CqUEbO6O309DHEzl29Wf+lQ+YvXfvZKtsJE/lD6IPKtts79TcyMKA2kt2ACZ+9AuQBOx YR/Q== X-Gm-Message-State: ACrzQf1HP6pRqcooQPHtNIcG4pbYTaFTJP+Um1k6igv0K9pm9E7UrIy9 pbt+DNhSM1xAVbB3tz+9SCE1Ow== X-Received: by 2002:a17:902:8ec5:b0:179:ffdc:ee4d with SMTP id x5-20020a1709028ec500b00179ffdcee4dmr1358201plo.124.1664422085036; Wed, 28 Sep 2022 20:28:05 -0700 (PDT) Received: from localhost.localdomain ([45.128.198.71]) by smtp.gmail.com with ESMTPSA id gn4-20020a17090ac78400b001fd66d5c42csm2304271pjb.49.2022.09.28.20.28.00 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 28 Sep 2022 20:28:04 -0700 (PDT) From: Zhangfei Gao To: Akhil Goyal , Declan Doherty , Fan Zhang , Ashish Gupta , Ray Kinsella Cc: dev@dpdk.org, acc@openeuler.org, Zhangfei Gao Subject: [PATCH v3 1/6] crypto/uadk: introduce uadk crypto driver Date: Thu, 29 Sep 2022 11:27:41 +0800 Message-Id: <20220929032746.10659-2-zhangfei.gao@linaro.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220929032746.10659-1-zhangfei.gao@linaro.org> References: <20220929032746.10659-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 | 53 +++++++++++ drivers/crypto/meson.build | 1 + drivers/crypto/uadk/meson.build | 36 +++++++ drivers/crypto/uadk/uadk_crypto_pmd.c | 120 ++++++++++++++++++++++++ drivers/crypto/uadk/version.map | 3 + 8 files changed, 253 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/version.map diff --git a/MAINTAINERS b/MAINTAINERS index 32ffdd1a61..f485cec2ed 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -1061,6 +1061,12 @@ M: Fan Zhang 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: Fan Zhang 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..a170224cac --- /dev/null +++ b/doc/guides/cryptodevs/uadk.rst @@ -0,0 +1,53 @@ +.. 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 +======================================================= + +UADK crypto PMD provides poll mode driver +All cryptographic operations are using UADK crypto API. +Hardware accelerators using UADK are supposed to be supported. + + +Features +-------- + +UADK crypto PMD has support for: + + +Test steps +----------- + + .. code-block:: console + + 1. Build + cd dpdk + mkdir build + meson build (--reconfigure) + cd build + ninja + sudo ninja install + + 2. Prepare + 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 + + 3. Run test app + +Dependency +------------ + +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. + +[1] https://github.com/Linaro/uadk 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..dda6c6b257 --- /dev/null +++ b/drivers/crypto/uadk/meson.build @@ -0,0 +1,36 @@ +# 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 + +if arch_subdir != 'arm' or not dpdk_conf.get('RTE_ARCH_64') + build = false + reason = 'only supported on aarch64' + subdir_done() +endif + +sources = files( + 'uadk_crypto_pmd.c', +) + +deps += 'bus_vdev' +dep = cc.find_library('libwd_crypto', required: false) +if not dep.found() + build = false + reason = 'missing dependency, "libwd_crypto"' +else + ext_deps += dep +endif + +dep = cc.find_library('libwd', required: false) +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..5c2e6d8f40 --- /dev/null +++ b/drivers/crypto/uadk/uadk_crypto_pmd.c @@ -0,0 +1,120 @@ +/* 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 + +enum uadk_crypto_version { + UADK_CRYPTO_V2, + UADK_CRYPTO_V3, +}; + +struct uadk_crypto_priv { + enum uadk_crypto_version version; +} __rte_cache_aligned; + +static uint8_t uadk_cryptodev_driver_id; + +RTE_LOG_REGISTER_DEFAULT(uadk_crypto_logtype, INFO); + +#define UADK_LOG(level, fmt, ...) \ + rte_log(RTE_LOG_ ## level, uadk_crypto_logtype, \ + "%s() line %u: " fmt "\n", __func__, __LINE__, \ + ## __VA_ARGS__) + +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); diff --git a/drivers/crypto/uadk/version.map b/drivers/crypto/uadk/version.map new file mode 100644 index 0000000000..c2e0723b4c --- /dev/null +++ b/drivers/crypto/uadk/version.map @@ -0,0 +1,3 @@ +DPDK_22 { + local: *; +};