From patchwork Tue Apr 17 09:23:17 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Zhoujian (jay)" X-Patchwork-Id: 38293 X-Patchwork-Delegate: pablo.de.lara.guarch@intel.com Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 394EFAAE9; Tue, 17 Apr 2018 11:24:11 +0200 (CEST) Received: from huawei.com (szxga05-in.huawei.com [45.249.212.191]) by dpdk.org (Postfix) with ESMTP id B3511AAC9 for ; Tue, 17 Apr 2018 11:23:53 +0200 (CEST) Received: from DGGEMS402-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 3AE64EB727796; Tue, 17 Apr 2018 17:23:39 +0800 (CST) Received: from localhost (10.177.19.14) by DGGEMS402-HUB.china.huawei.com (10.3.19.202) with Microsoft SMTP Server id 14.3.361.1; Tue, 17 Apr 2018 17:23:32 +0800 From: Jay Zhou To: CC: , , , , , , , , Date: Tue, 17 Apr 2018 17:23:17 +0800 Message-ID: <9734cbd4f45b4286876647389ae80bbce3b37bda.1523955936.git.jianjay.zhou@huawei.com> X-Mailer: git-send-email 2.6.1.windows.1 In-Reply-To: References: MIME-Version: 1.0 X-Originating-IP: [10.177.19.14] X-CFilter-Loop: Reflected Subject: [dpdk-dev] [PATCH v11 01/10] crypto/virtio: add virtio crypto PMD X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 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" 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 Acked-by: Fan Zhang --- MAINTAINERS | 4 +++ config/common_base | 14 +++++++++ config/rte_config.h | 4 +++ doc/guides/rel_notes/release_18_05.rst | 4 +++ drivers/crypto/Makefile | 1 + drivers/crypto/meson.build | 2 +- drivers/crypto/virtio/Makefile | 28 +++++++++++++++++ drivers/crypto/virtio/meson.build | 6 ++++ .../virtio/rte_pmd_virtio_crypto_version.map | 3 ++ drivers/crypto/virtio/virtio_cryptodev.c | 36 ++++++++++++++++++++++ drivers/crypto/virtio/virtio_cryptodev.h | 10 ++++++ mk/rte.app.mk | 1 + 12 files changed, 112 insertions(+), 1 deletion(-) create mode 100644 drivers/crypto/virtio/Makefile create mode 100644 drivers/crypto/virtio/meson.build create mode 100644 drivers/crypto/virtio/rte_pmd_virtio_crypto_version.map create mode 100644 drivers/crypto/virtio/virtio_cryptodev.c create mode 100644 drivers/crypto/virtio/virtio_cryptodev.h diff --git a/MAINTAINERS b/MAINTAINERS index a8bf1a4..fd1f209 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 23ea29a..255c1d7 100644 --- a/config/common_base +++ b/config/common_base @@ -494,6 +494,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 # CONFIG_RTE_LIBRTE_PMD_AESNI_MB=n diff --git a/config/rte_config.h b/config/rte_config.h index ed2deb5..fcba7a6 100644 --- a/config/rte_config.h +++ b/config/rte_config.h @@ -84,6 +84,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 e66dbeb..ae9e930 100644 --- a/doc/guides/rel_notes/release_18_05.rst +++ b/doc/guides/rel_notes/release_18_05.rst @@ -127,6 +127,10 @@ New Features Linux uevent is supported as backend of this device event notification framework. +* **Added the virtio crypto PMD.** + + Added a new poll mode driver for virtio crypto devices. + API Changes ----------- diff --git a/drivers/crypto/Makefile b/drivers/crypto/Makefile index 9fbd986..e9e8b1f 100644 --- a/drivers/crypto/Makefile +++ b/drivers/crypto/Makefile @@ -21,5 +21,6 @@ ifeq ($(CONFIG_RTE_LIBRTE_DPAA_BUS),y) DIRS-$(CONFIG_RTE_LIBRTE_PMD_DPAA_SEC) += dpaa_sec endif DIRS-$(CONFIG_RTE_LIBRTE_PMD_CCP) += ccp +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 736c9f5..63649c9 100644 --- a/drivers/crypto/meson.build +++ b/drivers/crypto/meson.build @@ -2,7 +2,7 @@ # Copyright(c) 2017 Intel Corporation drivers = ['dpaa_sec', 'dpaa2_sec', - 'openssl', 'null', 'qat'] + 'openssl', 'null', '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 0000000..58f8cfb --- /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 0000000..51f5b08 --- /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 0000000..de8e412 --- /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 0000000..3e54942 --- /dev/null +++ b/drivers/crypto/virtio/virtio_cryptodev.c @@ -0,0 +1,36 @@ +/* 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 0000000..44517b8 --- /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 117dbd1..0d14675 100644 --- a/mk/rte.app.mk +++ b/mk/rte.app.mk @@ -209,6 +209,7 @@ _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_AESNI_GCM) += -lIPSec_MB _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_OPENSSL) += -lrte_pmd_openssl -lcrypto _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_NULL_CRYPTO) += -lrte_pmd_null_crypto _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_QAT) += -lrte_pmd_qat -lcrypto +_LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_VIRTIO_CRYPTO) += -lrte_pmd_virtio_crypto _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_SNOW3G) += -lrte_pmd_snow3g _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_SNOW3G) += -L$(LIBSSO_SNOW3G_PATH)/build -lsso_snow3g _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_KASUMI) += -lrte_pmd_kasumi