crypto/uadk: introduce HiSilicon UADK crypto driver

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 <zhangfei.gao@linaro.org>
Acked-by: Akhil Goyal <gakhil@marvell.com>
This commit is contained in:
Zhangfei Gao 2022-10-27 11:25:00 +08:00 committed by Akhil Goyal
parent 10d64144b0
commit 8c515d9680
9 changed files with 294 additions and 0 deletions

View File

@ -1064,6 +1064,12 @@ M: Kai Ji <kai.ji@intel.com>
F: drivers/crypto/scheduler/
F: doc/guides/cryptodevs/scheduler.rst
HiSilicon UADK crypto
M: Zhangfei Gao <zhangfei.gao@linaro.org>
F: drivers/crypto/uadk/
F: doc/guides/cryptodevs/uadk.rst
F: doc/guides/cryptodevs/features/uadk.ini
Intel QuickAssist
M: Kai Ji <kai.ji@intel.com>
F: drivers/crypto/qat/

View File

@ -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

View File

@ -30,5 +30,6 @@ Crypto Device Drivers
scheduler
snow3g
qat
uadk
virtio
zuc

View File

@ -0,0 +1,85 @@
.. 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 <https://github.com/Linaro/uadk>`_.
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
----------
#. Build UADK
.. code-block:: console
git clone https://github.com/Linaro/uadk.git
cd uadk
mkdir build
./autogen.sh
./configure --prefix=$PWD/build
make
make install
.. note::
Without ``--prefix``, UADK will be installed to ``/usr/local/lib`` by default.
.. note::
If get error: "cannot find -lnuma", please install the libnuma-dev.
#. Run pkg-config libwd to ensure env is setup correctly
.. code-block:: console
export PKG_CONFIG_PATH=$PWD/build/lib/pkgconfig
pkg-config libwd --cflags --libs -I/usr/local/include -L/usr/local/lib -lwd
.. note::
export ``PKG_CONFIG_PATH`` is required on demand,
not needed if UADK is installed to ``/usr/local/lib``.
#. Build DPDK
.. code-block:: console
cd dpdk
mkdir build
meson build (--reconfigure)
cd build
ninja
sudo ninja install
#. Prepare hugepages for DPDK (see also :doc:`../tools/hugepages`)
.. code-block:: console
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
#. Run test app

View File

@ -18,6 +18,7 @@ drivers = [
'octeontx',
'openssl',
'scheduler',
'uadk',
'virtio',
]

View File

@ -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

View File

@ -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 <stdlib.h>
#include <bus_vdev_driver.h>
#include <cryptodev_pmd.h>
#include <rte_bus_vdev.h>
#include <uadk/wd_cipher.h>
#include <uadk/wd_digest.h>
#include <uadk/wd_sched.h>
#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);

View File

@ -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_ */

View File

@ -0,0 +1,3 @@
DPDK_23 {
local: *;
};