Skip to contentSkip to conversation

crypto: add virtio poll mode driver

PATCH Superseded Jay Zhou 3 participants 26 messages Mar 25, 2018 – Mar 30, 2018

Subsystems (3)

v3 of 11 Superseded Latest is v11 →

lore
Share & tools
lore

Jay Zhou

author
#0 lore raw

v3 cover crypto: add virtio poll mode driver

This patch series introduce virtio crypto poll mode driver.

Since it is limited by the vhost crypto backend of the virtio-crypto, this patch series only supports a limited subset of crypto services. Only the following algorithms are tested:

Cipher algorithms:
- RTE_CRYPTO_CIPHER_AES_CBC (128-bit, 192-bit and 256-bit keys)

Cipher then hash algorithms:
- RTE_CRYPTO_CIPHER_AES_CBC with RTE_CRYPTO_AUTH_SHA1_HMAC

The qemu side has supported vhost crypto and the vhost user crypto server side patches had been sent to DPDK community, pls see

[PATCH v2 00/10] lib/librte_vhost: introduce new vhost user crypto backend
support
https://dpdk.org/ml/archives/dev/2018-February/091594.html

Firstly run DPDK vhost crypto sample as a server side and build QEMU with vhost crypto enabled.
QEMU can then be started using the following parameters:

qemu-system-x86_64 \
    [...] \
        -chardev socket,id=charcrypto0,path=/path/to/your/socket \
        -object cryptodev-vhost-user,id=cryptodev0,chardev=charcrypto0 \
        -device virtio-crypto-pci,id=crypto0,cryptodev=cryptodev0
    [...]

Bind the uio_generic driver for the virtio-crypto device. For example, 0000:00:04.0 is the domain, bus, device and function number of the virtio-crypto device:

    modprobe uio_pci_generic
    echo -n 0000:00:04.0 > /sys/bus/pci/drivers/virtio-pci/unbind
    echo "1af4 1054" > /sys/bus/pci/drivers/uio_pci_generic/new_id

The front-end virtio crypto PMD driver can be installed:
cd to the top-level DPDK directory
sed -i 's,\(CONFIG_RTE_LIBRTE_PMD_VIRTIO_CRYPTO\)=n,\1=y,' config/common_base make config T=x86_64-native-linuxapp-gcc
make install T=x86_64-native-linuxapp-gcc

The unit test cases can be compiled as below:
cd to the top-level DPDK directory
export RTE_TARGET=x86_64-native-linuxapp-gcc export RTE_SDK=pwd
cd to test/test
make
./test (MUST reserve enough huge pages memory) type the command "cryptodev_virtio_autotest" to test

The result should be like this:
RTE>>cryptodev_virtio_autotest
+ ------------------------------------------------------- +
+ Test Suite : Crypto VIRTIO Unit Test Suite
+ ------------------------------------------------------- +
0) TestCase AES-128-CBC Encryption PASS
1) TestCase AES-128-CBC Decryption PASS
2) TestCase AES-192-CBC Encryption PASS
3) TestCase AES-192-CBC Decryption PASS
4) TestCase AES-256-CBC Encryption PASS
5) TestCase AES-256-CBC Decryption PASS
6) TestCase AES-256-CBC OOP Encryption PASS
7) TestCase AES-256-CBC OOP Decryption PASS
8) TestCase AES-128-CTR Encryption PASS
9) TestCase AES-128-CTR Decryption PASS
10) TestCase AES-192-CTR Encryption PASS
11) TestCase AES-192-CTR Decryption PASS
12) TestCase AES-256-CTR Encryption PASS
13) TestCase AES-256-CTR Decryption PASS
+ TestCase [ 0] : test_AES_cipheronly_virtio_all succeeded
+ ------------------------------------------------------- +
+ Test Suite Summary

 + Tests Total :        1
 + Tests Skipped :      0
 + Tests Executed :     1
 + Tests Unsupported:   0
 + Tests Passed :       1
 + Tests Failed :       0

+ ------------------------------------------------------- +
Test OK

The performance can be tested as below:

reserve enough huge pages
cd to the top-level DPDK directory
export RTE_TARGET=x86_64-native-linuxapp-gcc
export RTE_SDK=pwd
cd to app/test-crypto-perf
type the command "make" to compile
run the tests with the following command:

./dpdk-test-crypto-perf -l 0,1 -- --devtype crypto_virtio \
--ptest throughput --optype cipher-then-auth --cipher-algo aes-cbc \
--cipher-op encrypt --cipher-key-sz 16 --auth-algo sha1-hmac \
--auth-op generate --auth-key-sz 64 --digest-sz 12 \
--total-ops 100000000 --burst-sz 64 --buffer-sz 2048

Please help to review, thanks!

Changes in v3:
- set up capabilities for virtio crypto PMD [Fan]
- delete AES-CTR unit test cases since vhost_user crypto backend does not support [Fan]
- fix a variable uninitialized in virtio_crypto_queue_setup() [Xin, Fan]
- fix a bug in virtqueue_dequeue_burst_rx()

Changes in v2:
- using pre-allocated mempool instead of rte_malloc to improve performance [Fan]
- split the patch into a patchset [Fan]
- using linux/virtio_crypto.h instead of creating a copy of the file [Fan]
- update doc/guides/cryptodevs for describing virtio crypto PMD [Fan]
- update copyright
- delete virtio legacy mode code since virtio-crypto conforms to virtio-1.0
- refine the function and variable names
- fix errors and warnings reported by checkpatch

Jay Zhou (7):
crypto/virtio: add virtio related fundamental functions crpyto/virtio: add crypto related session structure cryptodev/virtio: core code of crypto devices crypto/virtio: add makefile
cryptodev: add document for virtio crypto PMD
cryptodev: add function tests for virtio crypto PMD
MAINTAINERS: add myself as virtio crypto PMD maintainer

 MAINTAINERS                                        |    6 +
 config/common_base                                 |   20 +
 doc/guides/cryptodevs/features/virtio.ini          |   22 +
 doc/guides/cryptodevs/virtio.rst                   |  117 ++
 drivers/crypto/Makefile                            |    1 +
 drivers/crypto/virtio/Makefile                     |   31 +
 .../virtio/rte_pmd_virtio_crypto_version.map       |    3 +
 drivers/crypto/virtio/virtio_crypto_algs.h         |   27 +
 drivers/crypto/virtio/virtio_crypto_capabilities.h |   51 +
 drivers/crypto/virtio/virtio_cryptodev.c           | 1553 ++++++++++++++++++++
 drivers/crypto/virtio/virtio_cryptodev.h           |   66 +
 drivers/crypto/virtio/virtio_logs.h                |   47 +
 drivers/crypto/virtio/virtio_pci.c                 |  460 ++++++
 drivers/crypto/virtio/virtio_pci.h                 |  253 ++++
 drivers/crypto/virtio/virtio_ring.h                |  137 ++
 drivers/crypto/virtio/virtio_rxtx.c                |  540 +++++++
 drivers/crypto/virtio/virtqueue.c                  |   43 +
 drivers/crypto/virtio/virtqueue.h                  |  176 +++
 mk/rte.app.mk                                      |    1 +
 test/test/test_cryptodev.c                         |   49 +
 test/test/test_cryptodev.h                         |    1 +
 test/test/test_cryptodev_aes_test_vectors.h        |   24 +-
 test/test/test_cryptodev_blockcipher.c             |    9 +-
 test/test/test_cryptodev_blockcipher.h             |    1 +
 24 files changed, 3629 insertions(+), 9 deletions(-)
 create mode 100644 doc/guides/cryptodevs/features/virtio.ini
 create mode 100644 doc/guides/cryptodevs/virtio.rst
 create mode 100644 drivers/crypto/virtio/Makefile
 create mode 100644 drivers/crypto/virtio/rte_pmd_virtio_crypto_version.map
 create mode 100644 drivers/crypto/virtio/virtio_crypto_algs.h
 create mode 100644 drivers/crypto/virtio/virtio_crypto_capabilities.h
 create mode 100644 drivers/crypto/virtio/virtio_cryptodev.c
 create mode 100644 drivers/crypto/virtio/virtio_cryptodev.h
 create mode 100644 drivers/crypto/virtio/virtio_logs.h
 create mode 100644 drivers/crypto/virtio/virtio_pci.c
 create mode 100644 drivers/crypto/virtio/virtio_pci.h
 create mode 100644 drivers/crypto/virtio/virtio_ring.h
 create mode 100644 drivers/crypto/virtio/virtio_rxtx.c
 create mode 100644 drivers/crypto/virtio/virtqueue.c
 create mode 100644 drivers/crypto/virtio/virtqueue.h

--
1.8.3.1

author
#1 lore raw

PATCH v3 1/7 crypto/virtio: add virtio related fundamental functions

Since there does not have the common virtio library, we have to put these files here. They are basically the same with virtio net related files with some minor changes.

---
 config/common_base                  |  20 ++
 drivers/crypto/virtio/virtio_logs.h |  47 ++++
 drivers/crypto/virtio/virtio_pci.c  | 460 ++++++++++++++++++++++++++++++++++++
 drivers/crypto/virtio/virtio_pci.h  | 253 ++++++++++++++++++++
 drivers/crypto/virtio/virtio_ring.h | 137 +++++++++++
 drivers/crypto/virtio/virtqueue.c   |  43 ++++
 drivers/crypto/virtio/virtqueue.h   | 176 ++++++++++++++
 7 files changed, 1136 insertions(+)
 create mode 100644 drivers/crypto/virtio/virtio_logs.h
 create mode 100644 drivers/crypto/virtio/virtio_pci.c
 create mode 100644 drivers/crypto/virtio/virtio_pci.h
 create mode 100644 drivers/crypto/virtio/virtio_ring.h
 create mode 100644 drivers/crypto/virtio/virtqueue.c
 create mode 100644 drivers/crypto/virtio/virtqueue.h
config/common_base +20 -0
index ad03cf4..19d0cdd 100644
@@ -482,6 +482,26 @@ 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
+CONFIG_RTE_LIBRTE_PMD_VIRTIO_CRYPTO_DEBUG_INIT=n
+CONFIG_RTE_LIBRTE_PMD_VIRTIO_CRYPTO_DEBUG_SESSION=n
+CONFIG_RTE_LIBRTE_PMD_VIRTIO_CRYPTO_DEBUG_TX=n
+CONFIG_RTE_LIBRTE_PMD_VIRTIO_CRYPTO_DEBUG_RX=n
+CONFIG_RTE_LIBRTE_PMD_VIRTIO_CRYPTO_DEBUG_DRIVER=n
+CONFIG_RTE_LIBRTE_PMD_VIRTIO_CRYPTO_DEBUG_DUMP=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
drivers/crypto/virtio/virtio_logs.h new file +47 -0

47 lines not on this page · raw message

drivers/crypto/virtio/virtio_pci.c new file +460 -0

460 lines not on this page · raw message

drivers/crypto/virtio/virtio_pci.h new file +253 -0

253 lines not on this page · raw message

drivers/crypto/virtio/virtio_ring.h new file +137 -0

137 lines not on this page · raw message

drivers/crypto/virtio/virtqueue.c new file +43 -0

43 lines not on this page · raw message

drivers/crypto/virtio/virtqueue.h new file +176 -0

176 lines not on this page · raw message

Signature · 1 line
1.8.3.1
Reviewed-by Acked-by on v3 1/7
#2 lore raw

Re: [PATCH v3 1/7] crypto/virtio: add virtio related fundamental functions

Quoted 14 lines

-----Original Message-----
From: Jay Zhou [mailto:[email protected]]
Sent: Sunday, March 25, 2018 9:34 AM
To: [email protected]
Cc: De Lara Guarch, Pablo <[email protected]>; Zhang, Roy Fan <[email protected]>; [email protected]; [email protected]; Zeng, Xin <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]
Subject: [PATCH v3 1/7] crypto/virtio: add virtio related fundamental functions

Quoted 6 lines

Since there does not have the common virtio library, we have to put these files here. They are basically the same with virtio net related files with some minor changes.

---

#3 lore raw

Re: [PATCH v3 1/7] crypto/virtio: add virtio related fundamental functions

In reply to Jay Zhou

Hi Jay,

Quoted 43 lines

-----Original Message-----
From: Jay Zhou [mailto:[email protected]]
Sent: Sunday, March 25, 2018 9:34 AM
To: [email protected]
Cc: De Lara Guarch, Pablo <[email protected]>; Zhang, Roy Fan <[email protected]>; [email protected]; [email protected]; Zeng, Xin <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]
Subject: [PATCH v3 1/7] crypto/virtio: add virtio related fundamental functions

Since there does not have the common virtio library, we have to put these files here. They are basically the same with virtio net related files with some minor changes.

---
 config/common_base                  |  20 ++
 drivers/crypto/virtio/virtio_logs.h |  47 ++++
drivers/crypto/virtio/virtio_pci.c  | 460
++++++++++++++++++++++++++++++++++++
 drivers/crypto/virtio/virtio_pci.h  | 253 ++++++++++++++++++++
drivers/crypto/virtio/virtio_ring.h | 137 +++++++++++
 drivers/crypto/virtio/virtqueue.c   |  43 ++++
 drivers/crypto/virtio/virtqueue.h   | 176 ++++++++++++++
 7 files changed, 1136 insertions(+)
 create mode 100644 drivers/crypto/virtio/virtio_logs.h
 create mode 100644 drivers/crypto/virtio/virtio_pci.c
 create mode 100644 drivers/crypto/virtio/virtio_pci.h
 create mode 100644 drivers/crypto/virtio/virtio_ring.h
 create mode 100644 drivers/crypto/virtio/virtqueue.c  create mode

100644 drivers/crypto/virtio/virtqueue.h

config/common_base index renamed from config/common_base +0 -0

ad03cf4..19d0cdd 100644

config/common_base +0 -0
@@ -482,6 +482,26 @@

CONFIG_RTE_LIBRTE_PMD_QAT_DEBUG_DRIVER=n
CONFIG_RTE_QAT_PMD_MAX_NB_SESSIONS=2048

#

config/common_base CONFIG_RTE_LIBRTE_PMD_QAT_DEBUG_DRIVER=n · line 493

Quoted 8 lines
config/common_base +8 -0
+# Compile PMD for virtio crypto devices #
+CONFIG_RTE_LIBRTE_PMD_VIRTIO_CRYPTO=n
+CONFIG_RTE_LIBRTE_PMD_VIRTIO_CRYPTO_DEBUG_INIT=n
+CONFIG_RTE_LIBRTE_PMD_VIRTIO_CRYPTO_DEBUG_SESSION=n
+CONFIG_RTE_LIBRTE_PMD_VIRTIO_CRYPTO_DEBUG_TX=n
+CONFIG_RTE_LIBRTE_PMD_VIRTIO_CRYPTO_DEBUG_RX=n
+CONFIG_RTE_LIBRTE_PMD_VIRTIO_CRYPTO_DEBUG_DRIVER=n
+CONFIG_RTE_LIBRTE_PMD_VIRTIO_CRYPTO_DEBUG_DUMP=n

Could you remove these DEBUG options? I see that they are used only for enabling logging. For that, we are using now dynamic logging.
Take a look at the following commit, as an example:
510ac6f4f030 ("event/sw: support dynamic logging")

Pablo

#4 lore raw

Re: [PATCH v3 1/7] crypto/virtio: add virtio related fundamental functions

Hi Pablo,

Quoted 55 lines

-----Original Message-----
From: De Lara Guarch, Pablo [mailto:[email protected]]
Sent: Friday, March 30, 2018 12:07 AM
To: Zhoujian (jay) <[email protected]>; [email protected]
Cc: Zhang, Roy Fan <[email protected]>; [email protected]; Gonglei (Arei) <[email protected]>; Zeng, Xin <[email protected]>; Huangweidong (C) <[email protected]>; wangxin (U) <[email protected]>; longpeng <[email protected]>
Subject: RE: [PATCH v3 1/7] crypto/virtio: add virtio related fundamental functions

Hi Jay,

Quoted 42 lines

-----Original Message-----
From: Jay Zhou [mailto:[email protected]]
Sent: Sunday, March 25, 2018 9:34 AM
To: [email protected]
Cc: De Lara Guarch, Pablo <[email protected]>; Zhang, Roy Fan <[email protected]>; [email protected]; [email protected]; Zeng, Xin <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]
Subject: [PATCH v3 1/7] crypto/virtio: add virtio related fundamental functions

Since there does not have the common virtio library, we have to put these files here. They are basically the same with virtio net related files with some minor changes.

---
 config/common_base                  |  20 ++
 drivers/crypto/virtio/virtio_logs.h |  47 ++++
drivers/crypto/virtio/virtio_pci.c  | 460
++++++++++++++++++++++++++++++++++++
 drivers/crypto/virtio/virtio_pci.h  | 253 ++++++++++++++++++++
drivers/crypto/virtio/virtio_ring.h | 137 +++++++++++
 drivers/crypto/virtio/virtqueue.c   |  43 ++++
 drivers/crypto/virtio/virtqueue.h   | 176 ++++++++++++++
 7 files changed, 1136 insertions(+)
 create mode 100644 drivers/crypto/virtio/virtio_logs.h
 create mode 100644 drivers/crypto/virtio/virtio_pci.c
 create mode 100644 drivers/crypto/virtio/virtio_pci.h
 create mode 100644 drivers/crypto/virtio/virtio_ring.h
 create mode 100644 drivers/crypto/virtio/virtqueue.c  create mode

100644 drivers/crypto/virtio/virtqueue.h

config/common_base index renamed from config/common_base +0 -0

ad03cf4..19d0cdd 100644

config/common_base +0 -0
@@ -482,6 +482,26 @@

CONFIG_RTE_LIBRTE_PMD_QAT_DEBUG_DRIVER=n
CONFIG_RTE_QAT_PMD_MAX_NB_SESSIONS=2048

Quoted 15 lines

config/common_base CONFIG_RTE_LIBRTE_PMD_QAT_DEBUG_DRIVER=n · line 493

Quoted 9 lines

#

config/common_base +8 -0
+# Compile PMD for virtio crypto devices #
+CONFIG_RTE_LIBRTE_PMD_VIRTIO_CRYPTO=n
+CONFIG_RTE_LIBRTE_PMD_VIRTIO_CRYPTO_DEBUG_INIT=n
+CONFIG_RTE_LIBRTE_PMD_VIRTIO_CRYPTO_DEBUG_SESSION=n
+CONFIG_RTE_LIBRTE_PMD_VIRTIO_CRYPTO_DEBUG_TX=n
+CONFIG_RTE_LIBRTE_PMD_VIRTIO_CRYPTO_DEBUG_RX=n
+CONFIG_RTE_LIBRTE_PMD_VIRTIO_CRYPTO_DEBUG_DRIVER=n
+CONFIG_RTE_LIBRTE_PMD_VIRTIO_CRYPTO_DEBUG_DUMP=n

Could you remove these DEBUG options? I see that they are used only for enabling logging.
For that, we are using now dynamic logging.
Take a look at the following commit, as an example:
510ac6f4f030 ("event/sw: support dynamic logging")

Okay. Will support dynamic logging for virtio crypto pmd in the next version.

Regards,
Jay

Quoted 2 lines

Pablo

author
#5 lore raw

PATCH v3 2/7 crpyto/virtio: add crypto related session structure

In reply to Jay Zhou

This structure will be used in the following patches, especially at creating and destroying crypto sessions.

---
 drivers/crypto/virtio/virtio_crypto_algs.h | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)
 create mode 100644 drivers/crypto/virtio/virtio_crypto_algs.h
drivers/crypto/virtio/virtio_crypto_algs.h new file +27 -0
new file mode 100644
index 0000000..5f1e9df
@@ -0,0 +1,27 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2018 HUAWEI TECHNOLOGIES CO., LTD.
+ */
+
+#ifndef _VIRTIO_CRYPTO_ALGS_H_
+#define _VIRTIO_CRYPTO_ALGS_H_
+
+#include <rte_memory.h>
+#include <linux/virtio_crypto.h>
+
+struct virtio_crypto_session {
+	uint64_t session_id;
+
+	struct {
+		uint16_t offset;
+		uint16_t length;
+	} iv;
+
+	struct {
+		uint32_t length;
+		phys_addr_t phys_addr;
+	} aad;
+
+	struct virtio_crypto_op_ctrl_req ctrl;
+};
+
+#endif /* _VIRTIO_CRYPTO_ALGS_H_ */
Signature · 1 line
1.8.3.1
Reviewed-by Acked-by on v3 2/7
#6 lore raw

Re: [PATCH v3 2/7] crpyto/virtio: add crypto related session structure

Quoted 13 lines

-----Original Message-----
From: Jay Zhou [mailto:[email protected]]
Sent: Sunday, March 25, 2018 9:34 AM
To: [email protected]
Cc: De Lara Guarch, Pablo <[email protected]>; Zhang, Roy Fan <[email protected]>; [email protected]; [email protected]; Zeng, Xin <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]
Subject: [PATCH v3 2/7] crpyto/virtio: add crypto related session structure

Quoted 4 lines

This structure will be used in the following patches, especially at creating and destroying crypto sessions.

#7 lore raw

Re: [PATCH v3 2/7] crpyto/virtio: add crypto related session structure

In reply to Jay Zhou
Quoted 12 lines

-----Original Message-----
From: Jay Zhou [mailto:[email protected]]
Sent: Sunday, March 25, 2018 9:34 AM
To: [email protected]
Cc: De Lara Guarch, Pablo <[email protected]>; Zhang, Roy Fan <[email protected]>; [email protected]; [email protected]; Zeng, Xin <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]
Subject: [PATCH v3 2/7] crpyto/virtio: add crypto related session structure

Typo in title.

Quoted 20 lines

This structure will be used in the following patches, especially at creating and destroying crypto sessions.

---
 drivers/crypto/virtio/virtio_crypto_algs.h | 27
+++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)
 create mode 100644 drivers/crypto/virtio/virtio_crypto_algs.h
drivers/crypto/virtio/virtio_crypto_algs.h new file +2 -0
new file mode 100644
index 0000000..5f1e9df
@@ -0,0 +1,27 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2018 HUAWEI TECHNOLOGIES CO., LTD.

drivers/crypto/virtio/virtio_crypto_algs.h line 12

Quoted 10 lines
drivers/crypto/virtio/virtio_crypto_algs.h new file +10 -0
+ */
+
+#ifndef _VIRTIO_CRYPTO_ALGS_H_
+#define _VIRTIO_CRYPTO_ALGS_H_
+
+#include <rte_memory.h>
+#include <linux/virtio_crypto.h>
+
+struct virtio_crypto_session {
+	uint64_t session_id;

Probably a uint32_t here is enough.

#8 lore raw

Re: [PATCH v3 2/7] crpyto/virtio: add crypto related session structure

Quoted 27 lines

-----Original Message-----
From: De Lara Guarch, Pablo [mailto:[email protected]]
Sent: Friday, March 30, 2018 6:12 AM
To: Zhoujian (jay) <[email protected]>; [email protected]
Cc: Zhang, Roy Fan <[email protected]>; [email protected]; Gonglei (Arei) <[email protected]>; Zeng, Xin <[email protected]>; Huangweidong (C) <[email protected]>; wangxin (U) <[email protected]>; longpeng <[email protected]>
Subject: RE: [PATCH v3 2/7] crpyto/virtio: add crypto related session structure

Quoted 11 lines

-----Original Message-----
From: Jay Zhou [mailto:[email protected]]
Sent: Sunday, March 25, 2018 9:34 AM
To: [email protected]
Cc: De Lara Guarch, Pablo <[email protected]>; Zhang, Roy Fan <[email protected]>; [email protected]; [email protected]; Zeng, Xin <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]
Subject: [PATCH v3 2/7] crpyto/virtio: add crypto related session structure

Quoted 1 line

Typo in title.

Will fix.

Quoted 25 lines
Quoted 25 lines

This structure will be used in the following patches, especially at creating and destroying crypto sessions.

---
 drivers/crypto/virtio/virtio_crypto_algs.h | 27
+++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)
 create mode 100644 drivers/crypto/virtio/virtio_crypto_algs.h
drivers/crypto/virtio/virtio_crypto_algs.h new file +6 -0
new file mode 100644
index 0000000..5f1e9df
@@ -0,0 +1,27 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2018 HUAWEI TECHNOLOGIES CO., LTD.
+ */
+
+#ifndef _VIRTIO_CRYPTO_ALGS_H_
+#define _VIRTIO_CRYPTO_ALGS_H_
Quoted 8 lines

drivers/crypto/virtio/virtio_crypto_algs.h line 12

Quoted 6 lines
drivers/crypto/virtio/virtio_crypto_algs.h new file +6 -0
+
+#include <rte_memory.h>
+#include <linux/virtio_crypto.h>
+
+struct virtio_crypto_session {
+	uint64_t session_id;

Probably a uint32_t here is enough.

Consider the type of session_id in the struct virtio_crypto_op_header of linux kernel and QEMU side is uint64_t, could we just keep it as uint64_t for consistency?

Regards,
Jay

#9 lore raw

Re: [PATCH v3 2/7] crpyto/virtio: add crypto related session structure

Quoted 81 lines

-----Original Message-----
From: Zhoujian (jay) [mailto:[email protected]]
Sent: Friday, March 30, 2018 3:44 AM
To: De Lara Guarch, Pablo <[email protected]>; [email protected]
Cc: Zhang, Roy Fan <[email protected]>; [email protected]; Gonglei (Arei) <[email protected]>; Zeng, Xin <[email protected]>; Huangweidong (C) <[email protected]>; wangxin (U) <[email protected]>; longpeng <[email protected]>
Subject: RE: [PATCH v3 2/7] crpyto/virtio: add crypto related session structure

Quoted 26 lines

-----Original Message-----
From: De Lara Guarch, Pablo [mailto:[email protected]]
Sent: Friday, March 30, 2018 6:12 AM
To: Zhoujian (jay) <[email protected]>; [email protected]
Cc: Zhang, Roy Fan <[email protected]>; [email protected]; Gonglei
(Arei) <[email protected]>; Zeng, Xin <[email protected]>; Huangweidong (C) <[email protected]>; wangxin (U) <[email protected]>; longpeng <[email protected]>
Subject: RE: [PATCH v3 2/7] crpyto/virtio: add crypto related session structure

Quoted 11 lines

-----Original Message-----
From: Jay Zhou [mailto:[email protected]]
Sent: Sunday, March 25, 2018 9:34 AM
To: [email protected]
Cc: De Lara Guarch, Pablo <[email protected]>; Zhang, Roy Fan <[email protected]>; [email protected]; [email protected]; Zeng, Xin <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]
Subject: [PATCH v3 2/7] crpyto/virtio: add crypto related session structure

Quoted 1 line

Typo in title.

Will fix.

Quoted 25 lines
Quoted 25 lines

This structure will be used in the following patches, especially at creating and destroying crypto sessions.

---
 drivers/crypto/virtio/virtio_crypto_algs.h | 27
+++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)
 create mode 100644 drivers/crypto/virtio/virtio_crypto_algs.h
drivers/crypto/virtio/virtio_crypto_algs.h new file +6 -0
new file mode 100644
index 0000000..5f1e9df
@@ -0,0 +1,27 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2018 HUAWEI TECHNOLOGIES CO., LTD.
+ */
+
+#ifndef _VIRTIO_CRYPTO_ALGS_H_
+#define _VIRTIO_CRYPTO_ALGS_H_
Quoted 8 lines

drivers/crypto/virtio/virtio_crypto_algs.h line 12

Quoted 6 lines
drivers/crypto/virtio/virtio_crypto_algs.h new file +6 -0
+
+#include <rte_memory.h>
+#include <linux/virtio_crypto.h>
+
+struct virtio_crypto_session {
+	uint64_t session_id;

Probably a uint32_t here is enough.

Quoted 3 lines

Consider the type of session_id in the struct virtio_crypto_op_header of linux kernel and QEMU side is uint64_t, could we just keep it as uint64_t for consistency?

Fair enough.

Pablo

Quoted 3 lines

Regards,
Jay

author
#10 lore raw

PATCH v3 3/7 cryptodev/virtio: core code of crypto devices

In reply to Jay Zhou

The idea comes from QAT and virtio-net devices.

---
 drivers/crypto/virtio/virtio_crypto_capabilities.h |   51 +
 drivers/crypto/virtio/virtio_cryptodev.c           | 1553 ++++++++++++++++++++
 drivers/crypto/virtio/virtio_cryptodev.h           |   66 +
 drivers/crypto/virtio/virtio_rxtx.c                |  540 +++++++
 4 files changed, 2210 insertions(+)
 create mode 100644 drivers/crypto/virtio/virtio_crypto_capabilities.h
 create mode 100644 drivers/crypto/virtio/virtio_cryptodev.c
 create mode 100644 drivers/crypto/virtio/virtio_cryptodev.h
 create mode 100644 drivers/crypto/virtio/virtio_rxtx.c
drivers/crypto/virtio/virtio_crypto_capabilities.h new file +51 -0
new file mode 100644
index 0000000..0d8dfac
@@ -0,0 +1,51 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2018 HUAWEI TECHNOLOGIES CO., LTD.
+ */
+
+#ifndef _VIRTIO_CRYPTO_CAPABILITIES_H_
+#define _VIRTIO_CRYPTO_CAPABILITIES_H_
+
+#define VIRTIO_SYM_CAPABILITIES						\
+	{	/* SHA1 HMAC */						\
+		.op = RTE_CRYPTO_OP_TYPE_SYMMETRIC,			\
+		{.sym = {						\
+			.xform_type = RTE_CRYPTO_SYM_XFORM_AUTH,	\
+			{.auth = {					\
+				.algo = RTE_CRYPTO_AUTH_SHA1_HMAC,	\
+				.block_size = 64,			\
+				.key_size = {				\
+					.min = 1,			\
+					.max = 64,			\
+					.increment = 1			\
+				},					\
+				.digest_size = {			\
+					.min = 1,			\
+					.max = 20,			\
+					.increment = 1			\
+				},					\
+				.iv_size = { 0 }			\
+			}, }						\
+		}, }							\
+	},								\
+	{	/* AES CBC */						\
+		.op = RTE_CRYPTO_OP_TYPE_SYMMETRIC,			\
+		{.sym = {						\
+			.xform_type = RTE_CRYPTO_SYM_XFORM_CIPHER,	\
+			{.cipher = {					\
+				.algo = RTE_CRYPTO_CIPHER_AES_CBC,	\
+				.block_size = 16,			\
+				.key_size = {				\
+					.min = 16,			\
+					.max = 32,			\
+					.increment = 8			\
+				},					\
+				.iv_size = {				\
+					.min = 16,			\
+					.max = 16,			\
+					.increment = 0			\
+				}					\
+			}, }						\
+		}, }							\
+	}
+
+#endif /* _VIRTIO_CRYPTO_CAPABILITIES_H_ */
drivers/crypto/virtio/virtio_cryptodev.c new file +1553 -0

1,553 lines not on this page · raw message

drivers/crypto/virtio/virtio_cryptodev.h new file +66 -0

66 lines not on this page · raw message

drivers/crypto/virtio/virtio_rxtx.c new file +540 -0

540 lines not on this page · raw message

Signature · 1 line
1.8.3.1
Reviewed-by Acked-by on v3 3/7
#11 lore raw

Re: [PATCH v3 3/7] cryptodev/virtio: core code of crypto devices

Quoted 13 lines

-----Original Message-----
From: Jay Zhou [mailto:[email protected]]
Sent: Sunday, March 25, 2018 9:34 AM
To: [email protected]
Cc: De Lara Guarch, Pablo <[email protected]>; Zhang, Roy Fan <[email protected]>; [email protected]; [email protected]; Zeng, Xin <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]
Subject: [PATCH v3 3/7] cryptodev/virtio: core code of crypto devices

Quoted 3 lines

The idea comes from QAT and virtio-net devices.

#12 lore raw

Re: [PATCH v3 3/7] cryptodev/virtio: core code of crypto devices

In reply to Jay Zhou
Quoted 12 lines

-----Original Message-----
From: Jay Zhou [mailto:[email protected]]
Sent: Sunday, March 25, 2018 9:34 AM
To: [email protected]
Cc: De Lara Guarch, Pablo <[email protected]>; Zhang, Roy Fan <[email protected]>; [email protected]; [email protected]; Zeng, Xin <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]
Subject: [PATCH v3 3/7] cryptodev/virtio: core code of crypto devices

Use crypto/virtio: ...

Quoted 2 lines

The idea comes from QAT and virtio-net devices.

Could you elaborate a bit more here? Which idea?
Probably better to describe the patch and not compare with other devices.

Quoted 13 lines
---
 drivers/crypto/virtio/virtio_crypto_capabilities.h |   51 +
 drivers/crypto/virtio/virtio_cryptodev.c           | 1553
++++++++++++++++++++
 drivers/crypto/virtio/virtio_cryptodev.h           |   66 +
 drivers/crypto/virtio/virtio_rxtx.c                |  540 +++++++
 4 files changed, 2210 insertions(+)
 create mode 100644 drivers/crypto/virtio/virtio_crypto_capabilities.h
 create mode 100644 drivers/crypto/virtio/virtio_cryptodev.c
 create mode 100644 drivers/crypto/virtio/virtio_cryptodev.h
 create mode 100644 drivers/crypto/virtio/virtio_rxtx.c

...

drivers/crypto/virtio/virtio_cryptodev.c

Quoted 3 lines

index 0000000..8affbef

drivers/crypto/virtio/virtio_cryptodev.c new file +0 -0

...

+

drivers/crypto/virtio/virtio_cryptodev.c line 1149

Quoted 11 lines
drivers/crypto/virtio/virtio_cryptodev.c new file +11 -0
+static int virtio_crypto_sym_pad_cipher_param(
+		struct virtio_crypto_cipher_session_para *para,
+		struct rte_crypto_cipher_xform *cipher_xform)
+{
+	switch (cipher_xform->algo) {
+	case RTE_CRYPTO_CIPHER_NULL:
+		para->algo = VIRTIO_CRYPTO_NO_CIPHER;
+		break;
+	case RTE_CRYPTO_CIPHER_3DES_CBC:
+		para->algo = VIRTIO_CRYPTO_CIPHER_3DES_CBC;
+		break;

Do you support these algorithms? From capabilities, it looks like you only support AES-CBC and SHA1, but from the cover letter, you say that those are the ones that you have tested, which means that this PMD actually supports more?

Quoted 3 lines
drivers/crypto/virtio/virtio_cryptodev.c new file +3 -0
+	case RTE_CRYPTO_CIPHER_3DES_CTR:
+		para->algo = VIRTIO_CRYPTO_CIPHER_3DES_CTR;
+		break;

...

drivers/crypto/virtio/virtio_cryptodev.c line 1553

Quoted 5 lines

+RTE_PMD_REGISTER_PCI(CRYPTODEV_NAME_VIRTIO_PMD, rte_virtio_crypto_driver); +RTE_PMD_REGISTER_CRYPTO_DRIVER(virtio_crypto_drv, rte_virtio_crypto_driver,

drivers/crypto/virtio/virtio_cryptodev.c new file +1 -0
+		cryptodev_virtio_driver_id);

RTE_PMD_REGISTER_CRYPTO_DRIVER has changed. Could you rebase against dpdk-next-crypto? You need to pass rte_virtio_crypto_driver.driver as a second parameter.

#13 lore raw

Re: [PATCH v3 3/7] cryptodev/virtio: core code of crypto devices

Quoted 25 lines

-----Original Message-----
From: De Lara Guarch, Pablo [mailto:[email protected]]
Sent: Friday, March 30, 2018 6:28 AM
To: Zhoujian (jay) <[email protected]>; [email protected]
Cc: Zhang, Roy Fan <[email protected]>; [email protected]; Gonglei (Arei) <[email protected]>; Zeng, Xin <[email protected]>; Huangweidong (C) <[email protected]>; wangxin (U) <[email protected]>; longpeng <[email protected]>
Subject: RE: [PATCH v3 3/7] cryptodev/virtio: core code of crypto devices

Quoted 10 lines

-----Original Message-----
From: Jay Zhou [mailto:[email protected]]
Sent: Sunday, March 25, 2018 9:34 AM
To: [email protected]
Cc: De Lara Guarch, Pablo <[email protected]>; Zhang, Roy Fan <[email protected]>; [email protected]; [email protected]; Zeng, Xin <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]
Subject: [PATCH v3 3/7] cryptodev/virtio: core code of crypto devices

Quoted 1 line

Use crypto/virtio: ...

Okay.

Quoted 7 lines
Quoted 4 lines

The idea comes from QAT and virtio-net devices.

Could you elaborate a bit more here? Which idea?
Probably better to describe the patch and not compare with other devices.

I'll describe the patch in more details, and it will help to review the code I think.

Quoted 24 lines
Quoted 14 lines
---
 drivers/crypto/virtio/virtio_crypto_capabilities.h |   51 +
 drivers/crypto/virtio/virtio_cryptodev.c           | 1553
++++++++++++++++++++
 drivers/crypto/virtio/virtio_cryptodev.h           |   66 +
 drivers/crypto/virtio/virtio_rxtx.c                |  540 +++++++
 4 files changed, 2210 insertions(+)
 create mode 100644 drivers/crypto/virtio/virtio_crypto_capabilities.h
 create mode 100644 drivers/crypto/virtio/virtio_cryptodev.c
 create mode 100644 drivers/crypto/virtio/virtio_cryptodev.h
 create mode 100644 drivers/crypto/virtio/virtio_rxtx.c

...

drivers/crypto/virtio/virtio_cryptodev.c

Quoted 3 lines

index 0000000..8affbef

drivers/crypto/virtio/virtio_cryptodev.c new file +0 -0

...

+

Quoted 15 lines

drivers/crypto/virtio/virtio_cryptodev.c line 1149

Quoted 10 lines
drivers/crypto/virtio/virtio_cryptodev.c new file +10 -0
+static int virtio_crypto_sym_pad_cipher_param(
+		struct virtio_crypto_cipher_session_para *para,
+		struct rte_crypto_cipher_xform *cipher_xform) {
+	switch (cipher_xform->algo) {
+	case RTE_CRYPTO_CIPHER_NULL:
+		para->algo = VIRTIO_CRYPTO_NO_CIPHER;
+		break;
+	case RTE_CRYPTO_CIPHER_3DES_CBC:
+		para->algo = VIRTIO_CRYPTO_CIPHER_3DES_CBC;
+		break;

Do you support these algorithms? From capabilities, it looks like you only support AES-CBC and SHA1, but from the cover letter, you say that those are the ones that you have tested, which means that this PMD actually supports more?

Yes, this PMD actually supports more. But for now, it is limited by the virtio-crypto vhost-crypto backend which only supports AES-CBC and SHA1, so only AES-CBC and SHA1 can be tested, others are not guaranteed. I think it's better to remove other cases and algorithms, we can add them once the virtio-crypto vhost-user backend supports them.
What do you think?

Quoted 8 lines
Quoted 5 lines
drivers/crypto/virtio/virtio_cryptodev.c new file +3 -0
+	case RTE_CRYPTO_CIPHER_3DES_CTR:
+		para->algo = VIRTIO_CRYPTO_CIPHER_3DES_CTR;
+		break;

...

Quoted 10 lines

drivers/crypto/virtio/virtio_cryptodev.c line 1553

Quoted 5 lines

+RTE_PMD_REGISTER_PCI(CRYPTODEV_NAME_VIRTIO_PMD, rte_virtio_crypto_driver); +RTE_PMD_REGISTER_CRYPTO_DRIVER(virtio_crypto_drv, rte_virtio_crypto_driver,

drivers/crypto/virtio/virtio_cryptodev.c new file +1 -0
+		cryptodev_virtio_driver_id);

RTE_PMD_REGISTER_CRYPTO_DRIVER has changed. Could you rebase against dpdk- next-crypto?
You need to pass rte_virtio_crypto_driver.driver as a second parameter.

Will do.

Regards,
Jay

#14 lore raw

Re: [PATCH v3 3/7] cryptodev/virtio: core code of crypto devices

Quoted 98 lines

-----Original Message-----
From: Zhoujian (jay) [mailto:[email protected]]
Sent: Friday, March 30, 2018 4:03 AM
To: De Lara Guarch, Pablo <[email protected]>; [email protected]
Cc: Zhang, Roy Fan <[email protected]>; [email protected]; Gonglei (Arei) <[email protected]>; Zeng, Xin <[email protected]>; Huangweidong (C) <[email protected]>; wangxin (U) <[email protected]>; longpeng <[email protected]>
Subject: RE: [PATCH v3 3/7] cryptodev/virtio: core code of crypto devices

Quoted 26 lines

-----Original Message-----
From: De Lara Guarch, Pablo [mailto:[email protected]]
Sent: Friday, March 30, 2018 6:28 AM
To: Zhoujian (jay) <[email protected]>; [email protected]
Cc: Zhang, Roy Fan <[email protected]>; [email protected]; Gonglei
(Arei) <[email protected]>; Zeng, Xin <[email protected]>; Huangweidong (C) <[email protected]>; wangxin (U) <[email protected]>; longpeng <[email protected]>
Subject: RE: [PATCH v3 3/7] cryptodev/virtio: core code of crypto devices

Quoted 11 lines

-----Original Message-----
From: Jay Zhou [mailto:[email protected]]
Sent: Sunday, March 25, 2018 9:34 AM
To: [email protected]
Cc: De Lara Guarch, Pablo <[email protected]>; Zhang, Roy Fan <[email protected]>; [email protected]; [email protected]; Zeng, Xin <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]
Subject: [PATCH v3 3/7] cryptodev/virtio: core code of crypto devices

Quoted 1 line

Use crypto/virtio: ...

Okay.

Quoted 7 lines
Quoted 4 lines

The idea comes from QAT and virtio-net devices.

Could you elaborate a bit more here? Which idea? Probably better to describe the patch and not compare with other

devices.

I'll describe the patch in more details, and it will help to review the code I think.

Quoted 24 lines
Quoted 14 lines
---
 drivers/crypto/virtio/virtio_crypto_capabilities.h |   51 +
 drivers/crypto/virtio/virtio_cryptodev.c           | 1553
++++++++++++++++++++
 drivers/crypto/virtio/virtio_cryptodev.h           |   66 +
 drivers/crypto/virtio/virtio_rxtx.c                |  540 +++++++
 4 files changed, 2210 insertions(+)  create mode 100644
drivers/crypto/virtio/virtio_crypto_capabilities.h
 create mode 100644 drivers/crypto/virtio/virtio_cryptodev.c
 create mode 100644 drivers/crypto/virtio/virtio_cryptodev.h
 create mode 100644 drivers/crypto/virtio/virtio_rxtx.c

...

drivers/crypto/virtio/virtio_cryptodev.c

Quoted 3 lines

index 0000000..8affbef

drivers/crypto/virtio/virtio_cryptodev.c new file +0 -0

...

+

Quoted 15 lines

drivers/crypto/virtio/virtio_cryptodev.c line 1149

Quoted 10 lines
drivers/crypto/virtio/virtio_cryptodev.c new file +10 -0
+static int virtio_crypto_sym_pad_cipher_param(
+		struct virtio_crypto_cipher_session_para *para,
+		struct rte_crypto_cipher_xform *cipher_xform) {
+	switch (cipher_xform->algo) {
+	case RTE_CRYPTO_CIPHER_NULL:
+		para->algo = VIRTIO_CRYPTO_NO_CIPHER;
+		break;
+	case RTE_CRYPTO_CIPHER_3DES_CBC:
+		para->algo = VIRTIO_CRYPTO_CIPHER_3DES_CBC;
+		break;

Do you support these algorithms? From capabilities, it looks like you only support AES-CBC and SHA1, but from the cover letter, you say that those are the ones that you have tested, which means that this PMD actually supports more?

Quoted 6 lines

Yes, this PMD actually supports more. But for now, it is limited by the virtio-crypto vhost-crypto backend which only supports AES-CBC and SHA1, so only AES-CBC and SHA1 can be tested, others are not guaranteed. I think it's better to remove other cases and algorithms, we can add them once the virtio-crypto vhost-user backend supports them.
What do you think?

Sounds good.

Quoted 27 lines
Quoted 9 lines
Quoted 6 lines
drivers/crypto/virtio/virtio_cryptodev.c new file +3 -0
+	case RTE_CRYPTO_CIPHER_3DES_CTR:
+		para->algo = VIRTIO_CRYPTO_CIPHER_3DES_CTR;
+		break;

...

Quoted 7 lines

drivers/crypto/virtio/virtio_cryptodev.c line 1553

Quoted 5 lines

+RTE_PMD_REGISTER_PCI(CRYPTODEV_NAME_VIRTIO_PMD, rte_virtio_crypto_driver); +RTE_PMD_REGISTER_CRYPTO_DRIVER(virtio_crypto_drv, rte_virtio_crypto_driver,

drivers/crypto/virtio/virtio_cryptodev.c new file +1 -0
+		cryptodev_virtio_driver_id);

RTE_PMD_REGISTER_CRYPTO_DRIVER has changed. Could you rebase

against

Quoted 3 lines

dpdk- next-crypto?
You need to pass rte_virtio_crypto_driver.driver as a second parameter.

Will do.

Regards,
Jay

author
#15 lore raw

PATCH v3 4/7 crypto/virtio: add makefile

In reply to Jay Zhou

The virtio crypto PMD driver can be compiled now.

---
 drivers/crypto/Makefile                            |  1 +
 drivers/crypto/virtio/Makefile                     | 31 ++++++++++++++++++++++
 .../virtio/rte_pmd_virtio_crypto_version.map       |  3 +++
 mk/rte.app.mk                                      |  1 +
 4 files changed, 36 insertions(+)
 create mode 100644 drivers/crypto/virtio/Makefile
 create mode 100644 drivers/crypto/virtio/rte_pmd_virtio_crypto_version.map
drivers/crypto/Makefile +1 -0
index 26e503e..e48bbdd 100644
@@ -20,5 +20,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
drivers/crypto/virtio/Makefile new file +31 -0
new file mode 100644
index 0000000..c4727ea
@@ -0,0 +1,31 @@
+# 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) += virtqueue.c
+SRCS-$(CONFIG_RTE_LIBRTE_PMD_VIRTIO_CRYPTO) += virtio_pci.c
+SRCS-$(CONFIG_RTE_LIBRTE_PMD_VIRTIO_CRYPTO) += virtio_rxtx.c
+SRCS-$(CONFIG_RTE_LIBRTE_PMD_VIRTIO_CRYPTO) += virtio_cryptodev.c
+
+# this lib depends upon:
+DEPDIRS-$(CONFIG_RTE_LIBRTE_PMD_VIRTIO_CRYPTO) += lib/librte_eal
+DEPDIRS-$(CONFIG_RTE_LIBRTE_PMD_VIRTIO_CRYPTO) += lib/librte_mempool lib/librte_mbuf
+DEPDIRS-$(CONFIG_RTE_LIBRTE_PMD_VIRTIO_CRYPTO) += lib/librte_cryptodev
+
+include $(RTE_SDK)/mk/rte.lib.mk
drivers/crypto/virtio/rte_pmd_virtio_crypto_version.map new file +3 -0
new file mode 100644
index 0000000..de8e412
@@ -0,0 +1,3 @@
+DPDK_18.05 {
+	local: *;
+};
mk/rte.app.mk +1 -0
index 94525dc..d7ddda4 100644
@@ -204,6 +204,7 @@ _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_AESNI_GCM)   += -L$(AESNI_MULTI_BUFFER_LIB_PATH)
 _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
Signature · 1 line
1.8.3.1
Reviewed-by Acked-by on v3 4/7
#16 lore raw

Re: [PATCH v3 4/7] crypto/virtio: add makefile

Quoted 13 lines

-----Original Message-----
From: Jay Zhou [mailto:[email protected]]
Sent: Sunday, March 25, 2018 9:34 AM
To: [email protected]
Cc: De Lara Guarch, Pablo <[email protected]>; Zhang, Roy Fan <[email protected]>; [email protected]; [email protected]; Zeng, Xin <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]
Subject: [PATCH v3 4/7] crypto/virtio: add makefile

Quoted 4 lines

The virtio crypto PMD driver can be compiled now.

---

author
#17 lore raw

PATCH v3 5/7 cryptodev: add document for virtio crypto PMD

In reply to Jay Zhou
---
 doc/guides/cryptodevs/features/virtio.ini |  22 ++++++
 doc/guides/cryptodevs/virtio.rst          | 117 ++++++++++++++++++++++++++++++
 2 files changed, 139 insertions(+)
 create mode 100644 doc/guides/cryptodevs/features/virtio.ini
 create mode 100644 doc/guides/cryptodevs/virtio.rst
doc/guides/cryptodevs/features/virtio.ini new file +22 -0
new file mode 100644
index 0000000..eaac734
@@ -0,0 +1,22 @@
+; Supported features of the 'virtio' crypto driver.
+;
+; Refer to default.ini for the full list of available PMD features.
+;
+[Features]
+Symmetric crypto       = Y
+Sym operation chaining = Y
+HW Accelerated         = N
+Mbuf scatter gather    = N
+
+;
+; Supported crypto algorithms of the 'virtio' crypto driver.
+;
+[Cipher]
+AES CBC (128)  = Y
+AES CBC (192)  = Y
+AES CBC (256)  = Y
+;
+; Supported authentication algorithms of the 'virtio' crypto driver.
+;
+[Auth]
+SHA1 HMAC      = Y
doc/guides/cryptodevs/virtio.rst new file +117 -0

117 lines not on this page · raw message

Signature · 1 line
1.8.3.1
Reviewed-by Acked-by on v3 5/7
#18 lore raw

Re: [PATCH v3 5/7] cryptodev: add document for virtio crypto PMD

Quoted 13 lines

-----Original Message-----
From: Jay Zhou [mailto:[email protected]]
Sent: Sunday, March 25, 2018 9:34 AM
To: [email protected]
Cc: De Lara Guarch, Pablo <[email protected]>; Zhang, Roy Fan <[email protected]>; [email protected]; [email protected]; Zeng, Xin <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]
Subject: [PATCH v3 5/7] cryptodev: add document for virtio crypto PMD

Quoted 2 lines

---

#19 lore raw

Re: [PATCH v3 5/7] cryptodev: add document for virtio crypto PMD

In reply to Jay Zhou
Quoted 12 lines

-----Original Message-----
From: Jay Zhou [mailto:[email protected]]
Sent: Sunday, March 25, 2018 9:34 AM
To: [email protected]
Cc: De Lara Guarch, Pablo <[email protected]>; Zhang, Roy Fan <[email protected]>; [email protected]; [email protected]; Zeng, Xin <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]
Subject: [PATCH v3 5/7] cryptodev: add document for virtio crypto PMD

You should use "doc: add virtio crypto PMD guide"

Quoted 5 lines
---
 doc/guides/cryptodevs/features/virtio.ini |  22 ++++++
 doc/guides/cryptodevs/virtio.rst          | 117

I tried building the documentation and it fails:

Warning generate_overview_table(): File 'virtio.ini' has no [AEAD] secton /root/dpdk/doc/guides/cryptodevs/virtio.rst: WARNING: document isn't included in any toctree

You should also add a note about this PMD in release notes, but you should probably do it in the first patch.

#20 lore raw

Re: [PATCH v3 5/7] cryptodev: add document for virtio crypto PMD

Quoted 25 lines

-----Original Message-----
From: De Lara Guarch, Pablo [mailto:[email protected]]
Sent: Friday, March 30, 2018 6:36 AM
To: Zhoujian (jay) <[email protected]>; [email protected]
Cc: Zhang, Roy Fan <[email protected]>; [email protected]; Gonglei (Arei) <[email protected]>; Zeng, Xin <[email protected]>; Huangweidong (C) <[email protected]>; wangxin (U) <[email protected]>; longpeng <[email protected]>
Subject: RE: [PATCH v3 5/7] cryptodev: add document for virtio crypto PMD

Quoted 10 lines

-----Original Message-----
From: Jay Zhou [mailto:[email protected]]
Sent: Sunday, March 25, 2018 9:34 AM
To: [email protected]
Cc: De Lara Guarch, Pablo <[email protected]>; Zhang, Roy Fan <[email protected]>; [email protected]; [email protected]; Zeng, Xin <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]
Subject: [PATCH v3 5/7] cryptodev: add document for virtio crypto PMD

Quoted 1 line

You should use "doc: add virtio crypto PMD guide"

Okay.

Quoted 7 lines
Quoted 6 lines
---
 doc/guides/cryptodevs/features/virtio.ini |  22 ++++++
 doc/guides/cryptodevs/virtio.rst          | 117
Quoted 9 lines

I tried building the documentation and it fails:

Warning generate_overview_table(): File 'virtio.ini' has no [AEAD] secton /root/dpdk/doc/guides/cryptodevs/virtio.rst: WARNING: document isn't included in any toctree

You should also add a note about this PMD in release notes, but you should probably do it in the first patch.

Okay. Will fix all the above.

Regards,
Jay

author
#21 lore raw

PATCH v3 6/7 cryptodev: add function tests for virtio crypto PMD

In reply to Jay Zhou

Only RTE_CRYPTO_CIPHER_AES_CBC cipher
algorithms are tested as unit test, it is supported both by the cryptodev-backend-builtin and cryptodev-vhost-user of qemu side.

---
 test/test/test_cryptodev.c                  | 49 +++++++++++++++++++++++++++++
 test/test/test_cryptodev.h                  |  1 +
 test/test/test_cryptodev_aes_test_vectors.h | 24 +++++++++-----
 test/test/test_cryptodev_blockcipher.c      |  9 +++++-
 test/test/test_cryptodev_blockcipher.h      |  1 +
 5 files changed, 75 insertions(+), 9 deletions(-)
test/test/test_cryptodev.c +49 -0
index 1417482..357e1df 100644
@@ -1765,6 +1765,26 @@ struct crypto_unittest_params {
 }
 
 static int
+test_AES_cipheronly_virtio_all(void)
+{
+	struct crypto_testsuite_params *ts_params = &testsuite_params;
+	int status;
+
+	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
+		ts_params->op_mpool,
+		ts_params->session_mpool,
+		ts_params->valid_devs[0],
+		rte_cryptodev_driver_id_get(
+		RTE_STR(CRYPTODEV_NAME_VIRTIO_PMD)),
+		BLKCIPHER_AES_CIPHERONLY_TYPE);
+
+	TEST_ASSERT_EQUAL(status, 0, "Test failed");
+
+	return TEST_SUCCESS;
+}
+
+
+static int
 test_AES_chain_dpaa_sec_all(void)
 {
 	struct crypto_testsuite_params *ts_params = &testsuite_params;
@@ -8767,6 +8787,18 @@ struct test_crypto_vector {
 	}
 };
 
+static struct unit_test_suite cryptodev_virtio_testsuite  = {
+	.suite_name = "Crypto VIRTIO Unit Test Suite",
+	.setup = testsuite_setup,
+	.teardown = testsuite_teardown,
+	.unit_test_cases = {
+		TEST_CASE_ST(ut_setup, ut_teardown,
+				test_AES_cipheronly_virtio_all),
+
+		TEST_CASES_END() /**< NULL terminate unit test array */
+	}
+};
+
 static struct unit_test_suite cryptodev_aesni_mb_testsuite  = {
 	.suite_name = "Crypto Device AESNI MB Unit Test Suite",
 	.setup = testsuite_setup,
@@ -9664,6 +9696,22 @@ struct test_crypto_vector {
 }
 
 static int
+test_cryptodev_virtio(void /*argv __rte_unused, int argc __rte_unused*/)
+{
+	gbl_driver_id =	rte_cryptodev_driver_id_get(
+			RTE_STR(CRYPTODEV_NAME_VIRTIO_PMD));
+
+	if (gbl_driver_id == -1) {
+		RTE_LOG(ERR, USER1, "VIRTIO PMD must be loaded. Check if "
+				"CONFIG_RTE_LIBRTE_PMD_VIRTIO_CRYPTO is enabled "
+				"in config file to run this testsuite.\n");
+		return TEST_FAILED;
+	}
+
+	return unit_test_suite_runner(&cryptodev_virtio_testsuite);
+}
+
+static int
 test_cryptodev_aesni_mb(void /*argv __rte_unused, int argc __rte_unused*/)
 {
 	gbl_driver_id =	rte_cryptodev_driver_id_get(
@@ -9879,3 +9927,4 @@ struct test_crypto_vector {
 REGISTER_TEST_COMMAND(cryptodev_sw_mrvl_autotest, test_cryptodev_mrvl);
 REGISTER_TEST_COMMAND(cryptodev_dpaa2_sec_autotest, test_cryptodev_dpaa2_sec);
 REGISTER_TEST_COMMAND(cryptodev_dpaa_sec_autotest, test_cryptodev_dpaa_sec);
+REGISTER_TEST_COMMAND(cryptodev_virtio_autotest, test_cryptodev_virtio);
test/test/test_cryptodev.h +1 -0
index 8cdc087..c311277 100644
@@ -61,6 +61,7 @@
 #define CRYPTODEV_NAME_DPAA2_SEC_PMD	crypto_dpaa2_sec
 #define CRYPTODEV_NAME_SCHEDULER_PMD	crypto_scheduler
 #define CRYPTODEV_NAME_MRVL_PMD		crypto_mrvl
+#define CRYPTODEV_NAME_VIRTIO_PMD   crypto_virtio
 
 /**
  * Write (spread) data from buffer to mbuf data
test/test/test_cryptodev_aes_test_vectors.h +16 -8
index 3577ef4..cac7cda 100644
@@ -1526,7 +1526,8 @@
 			BLOCKCIPHER_TEST_TARGET_PMD_SCHEDULER |
 			BLOCKCIPHER_TEST_TARGET_PMD_DPAA2_SEC |
 			BLOCKCIPHER_TEST_TARGET_PMD_DPAA_SEC |
-			BLOCKCIPHER_TEST_TARGET_PMD_MRVL
+			BLOCKCIPHER_TEST_TARGET_PMD_MRVL |
+			BLOCKCIPHER_TEST_TARGET_PMD_VIRTIO
 	},
 	{
 		.test_descr = "AES-128-CBC Decryption",
@@ -1538,7 +1539,8 @@
 			BLOCKCIPHER_TEST_TARGET_PMD_SCHEDULER |
 			BLOCKCIPHER_TEST_TARGET_PMD_DPAA2_SEC |
 			BLOCKCIPHER_TEST_TARGET_PMD_DPAA_SEC |
-			BLOCKCIPHER_TEST_TARGET_PMD_MRVL
+			BLOCKCIPHER_TEST_TARGET_PMD_MRVL |
+			BLOCKCIPHER_TEST_TARGET_PMD_VIRTIO
 	},
 	{
 		.test_descr = "AES-192-CBC Encryption",
@@ -1549,7 +1551,8 @@
 			BLOCKCIPHER_TEST_TARGET_PMD_MB |
 			BLOCKCIPHER_TEST_TARGET_PMD_SCHEDULER |
 			BLOCKCIPHER_TEST_TARGET_PMD_DPAA2_SEC |
-			BLOCKCIPHER_TEST_TARGET_PMD_DPAA_SEC
+			BLOCKCIPHER_TEST_TARGET_PMD_DPAA_SEC |
+			BLOCKCIPHER_TEST_TARGET_PMD_VIRTIO
 	},
 	{
 		.test_descr = "AES-192-CBC Encryption Scater gather",
@@ -1570,7 +1573,8 @@
 			BLOCKCIPHER_TEST_TARGET_PMD_MB |
 			BLOCKCIPHER_TEST_TARGET_PMD_SCHEDULER |
 			BLOCKCIPHER_TEST_TARGET_PMD_DPAA2_SEC |
-			BLOCKCIPHER_TEST_TARGET_PMD_DPAA_SEC
+			BLOCKCIPHER_TEST_TARGET_PMD_DPAA_SEC |
+			BLOCKCIPHER_TEST_TARGET_PMD_VIRTIO
 	},
 	{
 		.test_descr = "AES-192-CBC Decryption Scatter Gather",
@@ -1590,7 +1594,8 @@
 			BLOCKCIPHER_TEST_TARGET_PMD_SCHEDULER |
 			BLOCKCIPHER_TEST_TARGET_PMD_DPAA2_SEC |
 			BLOCKCIPHER_TEST_TARGET_PMD_DPAA_SEC |
-			BLOCKCIPHER_TEST_TARGET_PMD_MRVL
+			BLOCKCIPHER_TEST_TARGET_PMD_MRVL |
+			BLOCKCIPHER_TEST_TARGET_PMD_VIRTIO
 	},
 	{
 		.test_descr = "AES-256-CBC Decryption",
@@ -1602,7 +1607,8 @@
 			BLOCKCIPHER_TEST_TARGET_PMD_SCHEDULER |
 			BLOCKCIPHER_TEST_TARGET_PMD_DPAA2_SEC |
 			BLOCKCIPHER_TEST_TARGET_PMD_DPAA_SEC |
-			BLOCKCIPHER_TEST_TARGET_PMD_MRVL
+			BLOCKCIPHER_TEST_TARGET_PMD_MRVL |
+			BLOCKCIPHER_TEST_TARGET_PMD_VIRTIO
 	},
 	{
 		.test_descr = "AES-256-CBC OOP Encryption",
@@ -1612,7 +1618,8 @@
 		.pmd_mask = BLOCKCIPHER_TEST_TARGET_PMD_OPENSSL |
 			BLOCKCIPHER_TEST_TARGET_PMD_QAT |
 			BLOCKCIPHER_TEST_TARGET_PMD_DPAA2_SEC |
-			BLOCKCIPHER_TEST_TARGET_PMD_DPAA_SEC
+			BLOCKCIPHER_TEST_TARGET_PMD_DPAA_SEC |
+			BLOCKCIPHER_TEST_TARGET_PMD_VIRTIO
 	},
 	{
 		.test_descr = "AES-256-CBC OOP Decryption",
@@ -1622,7 +1629,8 @@
 		.pmd_mask = BLOCKCIPHER_TEST_TARGET_PMD_OPENSSL |
 			BLOCKCIPHER_TEST_TARGET_PMD_QAT |
 			BLOCKCIPHER_TEST_TARGET_PMD_DPAA2_SEC |
-			BLOCKCIPHER_TEST_TARGET_PMD_DPAA_SEC
+			BLOCKCIPHER_TEST_TARGET_PMD_DPAA_SEC |
+			BLOCKCIPHER_TEST_TARGET_PMD_VIRTIO
 	},
 	{
 		.test_descr = "AES-128-CTR Encryption",
test/test/test_cryptodev_blockcipher.c +8 -1
index ed06618..9eee350 100644
@@ -68,6 +68,8 @@
 			RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD));
 	int mrvl_pmd = rte_cryptodev_driver_id_get(
 			RTE_STR(CRYPTODEV_NAME_MRVL_PMD));
+	int virtio_pmd = rte_cryptodev_driver_id_get(
+			RTE_STR(CRYPTODEV_NAME_VIRTIO_PMD));
 
 	int nb_segs = 1;
 
@@ -94,7 +96,8 @@
 			driver_id == qat_pmd ||
 			driver_id == openssl_pmd ||
 			driver_id == armv8_pmd ||
-			driver_id == mrvl_pmd) { /* Fall through */
+			driver_id == mrvl_pmd ||
+			driver_id == virtio_pmd) { /* Fall through */
 		digest_len = tdata->digest.len;
 	} else if (driver_id == aesni_mb_pmd ||
 			driver_id == scheduler_pmd) {
@@ -569,6 +572,8 @@
 			RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD));
 	int mrvl_pmd = rte_cryptodev_driver_id_get(
 			RTE_STR(CRYPTODEV_NAME_MRVL_PMD));
+	int virtio_pmd = rte_cryptodev_driver_id_get(
+			RTE_STR(CRYPTODEV_NAME_VIRTIO_PMD));
 
 	switch (test_type) {
 	case BLKCIPHER_AES_CHAIN_TYPE:
@@ -631,6 +636,8 @@
 		target_pmd_mask = BLOCKCIPHER_TEST_TARGET_PMD_DPAA_SEC;
 	else if (driver_id == mrvl_pmd)
 		target_pmd_mask = BLOCKCIPHER_TEST_TARGET_PMD_MRVL;
+	else if (driver_id == virtio_pmd)
+		target_pmd_mask = BLOCKCIPHER_TEST_TARGET_PMD_VIRTIO;
 	else
 		TEST_ASSERT(0, "Unrecognized cryptodev type");
 
test/test/test_cryptodev_blockcipher.h +1 -0
index edbdaab..49a35bd 100644
@@ -27,6 +27,7 @@
 #define BLOCKCIPHER_TEST_TARGET_PMD_DPAA2_SEC	0x0020 /* DPAA2_SEC flag */
 #define BLOCKCIPHER_TEST_TARGET_PMD_DPAA_SEC	0x0040 /* DPAA_SEC flag */
 #define BLOCKCIPHER_TEST_TARGET_PMD_MRVL	0x0080 /* Marvell flag */
+#define BLOCKCIPHER_TEST_TARGET_PMD_VIRTIO	0x0100 /* VIRTIO flag */
 
 #define BLOCKCIPHER_TEST_OP_CIPHER	(BLOCKCIPHER_TEST_OP_ENCRYPT | \
 					BLOCKCIPHER_TEST_OP_DECRYPT)
Signature · 1 line
1.8.3.1
Reviewed-by Acked-by on v3 6/7
#22 lore raw

Re: [PATCH v3 6/7] cryptodev: add function tests for virtio crypto PMD

Quoted 13 lines

-----Original Message-----
From: Jay Zhou [mailto:[email protected]]
Sent: Sunday, March 25, 2018 9:34 AM
To: [email protected]
Cc: De Lara Guarch, Pablo <[email protected]>; Zhang, Roy Fan <[email protected]>; [email protected]; [email protected]; Zeng, Xin <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]
Subject: [PATCH v3 6/7] cryptodev: add function tests for virtio crypto PMD

Quoted 5 lines

Only RTE_CRYPTO_CIPHER_AES_CBC cipher
algorithms are tested as unit test, it is supported both by the cryptodev- backend-builtin and cryptodev-vhost-user of qemu side.

#23 lore raw

Re: [PATCH v3 6/7] cryptodev: add function tests for virtio crypto PMD

In reply to Jay Zhou
Quoted 12 lines

-----Original Message-----
From: Jay Zhou [mailto:[email protected]]
Sent: Sunday, March 25, 2018 9:34 AM
To: [email protected]
Cc: De Lara Guarch, Pablo <[email protected]>; Zhang, Roy Fan <[email protected]>; [email protected]; [email protected]; Zeng, Xin <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]
Subject: [PATCH v3 6/7] cryptodev: add function tests for virtio crypto PMD

Change title to test/crypto: add...

author
#24 lore raw

PATCH v3 7/7 MAINTAINERS: add myself as virtio crypto PMD maintainer

In reply to Jay Zhou
---
 MAINTAINERS | 6 ++++++
 1 file changed, 6 insertions(+)
MAINTAINERS +6 -0
index a646ca3..be1b394 100644
@@ -719,6 +719,12 @@ F: drivers/crypto/snow3g/
 F: doc/guides/cryptodevs/snow3g.rst
 F: doc/guides/cryptodevs/features/snow3g.ini
 
+Virtio
+M: Jay Zhou <[email protected]>
+F: drivers/crypto/virtio/
+F: doc/guides/cryptodevs/virtio.rst
+F: doc/guides/cryptodevs/features/virtio.ini
+
 ZUC
 M: Pablo de Lara <[email protected]>
 F: drivers/crypto/zuc/
Signature · 1 line
1.8.3.1
Reviewed-by Acked-by on v3 7/7
#25 lore raw

Re: [PATCH v3 7/7] MAINTAINERS: add myself as virtio crypto PMD maintainer

Quoted 37 lines

-----Original Message-----
From: Jay Zhou [mailto:[email protected]]
Sent: Sunday, March 25, 2018 9:34 AM
To: [email protected]
Cc: De Lara Guarch, Pablo <[email protected]>; Zhang, Roy Fan <[email protected]>; [email protected]; [email protected]; Zeng, Xin <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]
Subject: [PATCH v3 7/7] MAINTAINERS: add myself as virtio crypto PMD maintainer

---
 MAINTAINERS | 6 ++++++
 1 file changed, 6 insertions(+)
MAINTAINERS +6 -1
index a646ca3..be1b394 100644
@@ -719,6 +719,12 @@ F: drivers/crypto/snow3g/
 F: doc/guides/cryptodevs/snow3g.rst
 F: doc/guides/cryptodevs/features/snow3g.ini
 
+Virtio
+M: Jay Zhou <[email protected]>
+F: drivers/crypto/virtio/
+F: doc/guides/cryptodevs/virtio.rst
+F: doc/guides/cryptodevs/features/virtio.ini
+
 ZUC
 M: Pablo de Lara <[email protected]>
 F: drivers/crypto/zuc/
--
Quoted 2 lines

1.8.3.1