[dpdk-dev,v10,01/10] crypto/virtio: add virtio crypto PMD
Checks
Commit Message
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 <jianjay.zhou@huawei.com>
Reviewed-by: Fan Zhang <roy.fan.zhang@intel.com>
Acked-by: Fan Zhang <roy.fan.zhang@intel.com>
---
MAINTAINERS | 4 +++
config/common_base | 14 +++++++++
doc/guides/rel_notes/release_18_05.rst | 4 +++
drivers/crypto/Makefile | 1 +
drivers/crypto/meson.build | 2 +-
drivers/crypto/virtio/Makefile | 29 +++++++++++++++++
drivers/crypto/virtio/meson.build | 11 +++++++
.../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 +
11 files changed, 114 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
Comments
Hi Jay,
> -----Original Message-----
> From: Jay Zhou [mailto:jianjay.zhou@huawei.com]
> Sent: Monday, April 16, 2018 3:21 AM
> To: dev@dpdk.org
> Cc: De Lara Guarch, Pablo <pablo.de.lara.guarch@intel.com>; Zhang, Roy Fan
> <roy.fan.zhang@intel.com>; thomas@monjalon.net;
> arei.gonglei@huawei.com; Zeng, Xin <xin.zeng@intel.com>;
> weidong.huang@huawei.com; wangxinxin.wang@huawei.com;
> longpeng2@huawei.com; jianjay.zhou@huawei.com
> Subject: [PATCH v10 01/10] 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 <jianjay.zhou@huawei.com>
> Reviewed-by: Fan Zhang <roy.fan.zhang@intel.com>
> Acked-by: Fan Zhang <roy.fan.zhang@intel.com>
...
> +++ b/drivers/crypto/virtio/meson.build
> @@ -0,0 +1,11 @@
> +# SPDX-License-Identifier: BSD-3-Clause # Copyright(c) 2018 HUAWEI
> +TECHNOLOGIES CO., LTD.
> +
> +dep = dependency('libcrypto', required: false) if not dep.found()
> + build = false
> +endif
Does this PMD have a dependency on libcrypto?
Looking at the code, I don't think it does.
Therefore, you should remove this and also LDLIBS += -lcrypto in the Makefile.
Once this is removed, and you add the path to the virtio_crypto.h file (as Ferruh suggested),
I'd say this PMD can be enabled by default.
Hi Pablo,
> -----Original Message-----
> From: De Lara Guarch, Pablo [mailto:pablo.de.lara.guarch@intel.com]
> Sent: Monday, April 16, 2018 10:16 PM
> To: Zhoujian (jay) <jianjay.zhou@huawei.com>; dev@dpdk.org
> Cc: Zhang, Roy Fan <roy.fan.zhang@intel.com>; thomas@monjalon.net; Gonglei
> (Arei) <arei.gonglei@huawei.com>; Zeng, Xin <xin.zeng@intel.com>;
> Huangweidong (C) <weidong.huang@huawei.com>; wangxin (U)
> <wangxinxin.wang@huawei.com>; longpeng <longpeng2@huawei.com>
> Subject: RE: [PATCH v10 01/10] crypto/virtio: add virtio crypto PMD
>
> Hi Jay,
>
> > -----Original Message-----
> > From: Jay Zhou [mailto:jianjay.zhou@huawei.com]
> > Sent: Monday, April 16, 2018 3:21 AM
> > To: dev@dpdk.org
> > Cc: De Lara Guarch, Pablo <pablo.de.lara.guarch@intel.com>; Zhang, Roy
> > Fan <roy.fan.zhang@intel.com>; thomas@monjalon.net;
> > arei.gonglei@huawei.com; Zeng, Xin <xin.zeng@intel.com>;
> > weidong.huang@huawei.com; wangxinxin.wang@huawei.com;
> > longpeng2@huawei.com; jianjay.zhou@huawei.com
> > Subject: [PATCH v10 01/10] 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 <jianjay.zhou@huawei.com>
> > Reviewed-by: Fan Zhang <roy.fan.zhang@intel.com>
> > Acked-by: Fan Zhang <roy.fan.zhang@intel.com>
>
> ...
>
> > +++ b/drivers/crypto/virtio/meson.build
> > @@ -0,0 +1,11 @@
> > +# SPDX-License-Identifier: BSD-3-Clause # Copyright(c) 2018 HUAWEI
> > +TECHNOLOGIES CO., LTD.
> > +
> > +dep = dependency('libcrypto', required: false) if not dep.found()
> > + build = false
> > +endif
>
> Does this PMD have a dependency on libcrypto?
> Looking at the code, I don't think it does.
> Therefore, you should remove this and also LDLIBS += -lcrypto in the Makefile.
It's compiled successfully without the dependency, so you're right. I'll remove it.
> Once this is removed, and you add the path to the virtio_crypto.h file (as
> Ferruh suggested), I'd say this PMD can be enabled by default.
I agree with you and Ferruh. If the other codes are fine for you, I'll send
the next version tomorrow with this PMD enabled by default as well as the
updated path to virtio_crypto.h file.
Regards,
Jay
@@ -758,6 +758,10 @@ F: drivers/crypto/snow3g/
F: doc/guides/cryptodevs/snow3g.rst
F: doc/guides/cryptodevs/features/snow3g.ini
+Virtio
+M: Jay Zhou <jianjay.zhou@huawei.com>
+F: drivers/crypto/virtio/
+
ZUC
M: Pablo de Lara <pablo.de.lara.guarch@intel.com>
F: drivers/crypto/zuc/
@@ -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=n
+#
+# 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
@@ -82,6 +82,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
-----------
@@ -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
@@ -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'
new file mode 100644
@@ -0,0 +1,29 @@
+# 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 += -lcrypto
+LDLIBS += -lrte_eal -lrte_mbuf -lrte_mempool
+LDLIBS += -lrte_cryptodev
+LDLIBS += -lrte_pci -lrte_bus_pci
+
+include $(RTE_SDK)/mk/rte.lib.mk
new file mode 100644
@@ -0,0 +1,11 @@
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright(c) 2018 HUAWEI TECHNOLOGIES CO., LTD.
+
+dep = dependency('libcrypto', required: false)
+if not dep.found()
+ build = false
+endif
+deps += ['bus_pci']
+sources = files('virtio_cryptodev.c')
+ext_deps += dep
+pkgconfig_extra_libs += '-lcrypto'
new file mode 100644
@@ -0,0 +1,3 @@
+DPDK_18.05 {
+ local: *;
+};
new file mode 100644
@@ -0,0 +1,36 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2018 HUAWEI TECHNOLOGIES CO., LTD.
+ */
+#include <rte_pci.h>
+#include <rte_bus_pci.h>
+#include <rte_cryptodev_pmd.h>
+#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);
new file mode 100644
@@ -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_ */
@@ -208,6 +208,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 -lcrypto
_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