From: Jay Zhou Date: Tue, 17 Apr 2018 09:23:17 +0000 (+0800) Subject: crypto/virtio: add virtio crypto PMD X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=8769079ae09569fdfb8125c2dfe1ae83381928fb;p=dpdk.git crypto/virtio: add virtio crypto PMD The virtio crypto device is a virtual cryptography device as well as a kind of virtual hardware accelerator for virtual machines. The linux kernel virtio-crypto driver has been merged, and this patch introduces virtio crypto PMD to achieve better performance. Signed-off-by: Jay Zhou Reviewed-by: Fan Zhang --- diff --git a/MAINTAINERS b/MAINTAINERS index 7f7d97d264..70c77c18eb 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -772,6 +772,10 @@ F: drivers/crypto/snow3g/ F: doc/guides/cryptodevs/snow3g.rst F: doc/guides/cryptodevs/features/snow3g.ini +Virtio +M: Jay Zhou +F: drivers/crypto/virtio/ + ZUC M: Pablo de Lara F: drivers/crypto/zuc/ diff --git a/config/common_base b/config/common_base index dc30247538..e57fe3ab74 100644 --- a/config/common_base +++ b/config/common_base @@ -493,6 +493,20 @@ CONFIG_RTE_LIBRTE_PMD_QAT_DEBUG_DRIVER=n # CONFIG_RTE_QAT_PMD_MAX_NB_SESSIONS=2048 +# +# Compile PMD for virtio crypto devices +# +CONFIG_RTE_LIBRTE_PMD_VIRTIO_CRYPTO=y +# +# Number of maximum virtio crypto devices +# +CONFIG_RTE_MAX_VIRTIO_CRYPTO=32 +# +# Number of sessions to create in the session memory pool +# on a single virtio crypto device. +# +CONFIG_RTE_VIRTIO_CRYPTO_PMD_MAX_NB_SESSIONS=1024 + # # Compile PMD for AESNI backed device # diff --git a/config/rte_config.h b/config/rte_config.h index 0d61b84c17..b1c0b3920a 100644 --- a/config/rte_config.h +++ b/config/rte_config.h @@ -87,6 +87,10 @@ /* QuickAssist device */ #define RTE_QAT_PMD_MAX_NB_SESSIONS 2048 +/* virtio crypto defines */ +#define RTE_VIRTIO_CRYPTO_PMD_MAX_NB_SESSIONS 1024 +#define RTE_MAX_VIRTIO_CRYPTO 32 + /* DPAA2_SEC */ #define RTE_DPAA2_SEC_PMD_MAX_NB_SESSIONS 2048 diff --git a/doc/guides/rel_notes/release_18_05.rst b/doc/guides/rel_notes/release_18_05.rst index ffb4cc339d..f23286f2bf 100644 --- a/doc/guides/rel_notes/release_18_05.rst +++ b/doc/guides/rel_notes/release_18_05.rst @@ -96,6 +96,10 @@ New Features including session creation/deletion handling and translating virtio-crypto request into DPDK crypto operations. A sample application is also introduced. +* **Added virtio crypto PMD.** + + Added a new poll mode driver for virtio crypto devices. + * **Added AMD CCP Crypto PMD.** Added the new ``ccp`` crypto driver for AMD CCP devices. See the diff --git a/drivers/crypto/Makefile b/drivers/crypto/Makefile index d5e0974521..28157ac050 100644 --- a/drivers/crypto/Makefile +++ b/drivers/crypto/Makefile @@ -21,5 +21,6 @@ endif ifeq ($(CONFIG_RTE_LIBRTE_DPAA_BUS),y) DIRS-$(CONFIG_RTE_LIBRTE_PMD_DPAA_SEC) += dpaa_sec endif +DIRS-$(CONFIG_RTE_LIBRTE_PMD_VIRTIO_CRYPTO) += virtio include $(RTE_SDK)/mk/rte.subdir.mk diff --git a/drivers/crypto/meson.build b/drivers/crypto/meson.build index 1295743f5e..fbe190d873 100644 --- a/drivers/crypto/meson.build +++ b/drivers/crypto/meson.build @@ -1,8 +1,8 @@ # SPDX-License-Identifier: BSD-3-Clause # Copyright(c) 2017 Intel Corporation -drivers = ['dpaa_sec', 'dpaa2_sec', - 'openssl', 'mrvl', 'null', 'qat'] +drivers = ['dpaa_sec', 'dpaa2_sec', 'mrvl', + 'null', 'openssl', 'qat', 'virtio'] std_deps = ['cryptodev'] # cryptodev pulls in all other needed deps config_flag_fmt = 'RTE_LIBRTE_@0@_PMD' diff --git a/drivers/crypto/virtio/Makefile b/drivers/crypto/virtio/Makefile new file mode 100644 index 0000000000..58f8cfb199 --- /dev/null +++ b/drivers/crypto/virtio/Makefile @@ -0,0 +1,28 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2018 HUAWEI TECHNOLOGIES CO., LTD. + +include $(RTE_SDK)/mk/rte.vars.mk + +# +# library name +# +LIB = librte_pmd_virtio_crypto.a + +CFLAGS += -O3 +CFLAGS += $(WERROR_FLAGS) + +EXPORT_MAP := rte_pmd_virtio_crypto_version.map + +LIBABIVER := 1 + +# +# all source are stored in SRCS-y +# +SRCS-$(CONFIG_RTE_LIBRTE_PMD_VIRTIO_CRYPTO) += virtio_cryptodev.c + +# this lib depends upon: +LDLIBS += -lrte_eal -lrte_mbuf -lrte_mempool +LDLIBS += -lrte_cryptodev +LDLIBS += -lrte_pci -lrte_bus_pci + +include $(RTE_SDK)/mk/rte.lib.mk diff --git a/drivers/crypto/virtio/meson.build b/drivers/crypto/virtio/meson.build new file mode 100644 index 0000000000..51f5b085a2 --- /dev/null +++ b/drivers/crypto/virtio/meson.build @@ -0,0 +1,6 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2018 HUAWEI TECHNOLOGIES CO., LTD. + +deps += 'bus_pci' +name = 'virtio_crypto' +sources = files('virtio_cryptodev.c') diff --git a/drivers/crypto/virtio/rte_pmd_virtio_crypto_version.map b/drivers/crypto/virtio/rte_pmd_virtio_crypto_version.map new file mode 100644 index 0000000000..de8e412ff1 --- /dev/null +++ b/drivers/crypto/virtio/rte_pmd_virtio_crypto_version.map @@ -0,0 +1,3 @@ +DPDK_18.05 { + local: *; +}; diff --git a/drivers/crypto/virtio/virtio_cryptodev.c b/drivers/crypto/virtio/virtio_cryptodev.c new file mode 100644 index 0000000000..24295d89aa --- /dev/null +++ b/drivers/crypto/virtio/virtio_cryptodev.c @@ -0,0 +1,37 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2018 HUAWEI TECHNOLOGIES CO., LTD. + */ +#include +#include +#include + +#include "virtio_cryptodev.h" + +uint8_t cryptodev_virtio_driver_id; + +static int +crypto_virtio_pci_probe( + struct rte_pci_driver *pci_drv __rte_unused, + struct rte_pci_device *pci_dev __rte_unused) +{ + return 0; +} + +static int +crypto_virtio_pci_remove( + struct rte_pci_device *pci_dev __rte_unused) +{ + return 0; +} + +static struct rte_pci_driver rte_virtio_crypto_driver = { + .probe = crypto_virtio_pci_probe, + .remove = crypto_virtio_pci_remove +}; + +static struct cryptodev_driver virtio_crypto_drv; + +RTE_PMD_REGISTER_PCI(CRYPTODEV_NAME_VIRTIO_PMD, rte_virtio_crypto_driver); +RTE_PMD_REGISTER_CRYPTO_DRIVER(virtio_crypto_drv, + rte_virtio_crypto_driver.driver, + cryptodev_virtio_driver_id); diff --git a/drivers/crypto/virtio/virtio_cryptodev.h b/drivers/crypto/virtio/virtio_cryptodev.h new file mode 100644 index 0000000000..44517b82ae --- /dev/null +++ b/drivers/crypto/virtio/virtio_cryptodev.h @@ -0,0 +1,10 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2018 HUAWEI TECHNOLOGIES CO., LTD. + */ + +#ifndef _VIRTIO_CRYPTODEV_H_ +#define _VIRTIO_CRYPTODEV_H_ + +#define CRYPTODEV_NAME_VIRTIO_PMD crypto_virtio + +#endif /* _VIRTIO_CRYPTODEV_H_ */ diff --git a/mk/rte.app.mk b/mk/rte.app.mk index eb18e05bbb..a14579140b 100644 --- a/mk/rte.app.mk +++ b/mk/rte.app.mk @@ -226,6 +226,7 @@ endif # CONFIG_RTE_LIBRTE_FSLMC_BUS ifeq ($(CONFIG_RTE_LIBRTE_DPAA_BUS),y) _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_DPAA_SEC) += -lrte_pmd_dpaa_sec endif # CONFIG_RTE_LIBRTE_DPAA_BUS +_LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_VIRTIO_CRYPTO) += -lrte_pmd_virtio_crypto endif # CONFIG_RTE_LIBRTE_CRYPTODEV ifeq ($(CONFIG_RTE_LIBRTE_EVENTDEV),y)