From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by dpdk.org (Postfix) with ESMTP id 794855F36 for ; Mon, 26 Mar 2018 11:54:34 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 26 Mar 2018 02:54:33 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.48,364,1517904000"; d="scan'208";a="27031155" Received: from silpixa00398673.ir.intel.com (HELO silpixa00398673.ger.corp.intel.com) ([10.237.223.54]) by fmsmga007.fm.intel.com with ESMTP; 26 Mar 2018 02:54:32 -0700 From: Fan Zhang To: dev@dpdk.org Cc: maxime.coquelin@redhat.com, jianjay.zhou@huawei.com Date: Mon, 26 Mar 2018 10:51:04 +0100 Message-Id: <20180326095114.11605-1-roy.fan.zhang@intel.com> X-Mailer: git-send-email 2.13.6 Subject: [dpdk-dev] [PATCH v3 00/10] lib/librte_vhost: introduce new vhost user crypto backend support 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: , X-List-Received-Date: Mon, 26 Mar 2018 09:54:35 -0000 This patchset adds crypto backend suppport to vhost_user library, including a proof-of-concept sample application. The implementation follows the virtio-crypto specification and have been tested with qemu 2.11.50 (with several patches applied, detailed later) with Fedora 24 running in the frontend. The vhost_crypto library acts as a "bridge" method that translate the virtio-crypto crypto requests to DPDK crypto operations, so it is purely software implementation. However it does require the user to provide the DPDK Cryptodev ID so it knows how to handle the virtio-crypto session creation and deletion mesages. Currently the implementation supports AES-CBC-128 and HMAC-SHA1 cipher only/chaining modes and does not support sessionless mode yet. The guest can use standard virtio-crypto driver to set up session and sends encryption/decryption requests to backend. The vhost-crypto sample application provided in this patchset will do the actual crypto work. To make this patchset working, a few tweaks need to be done: In the host: 1. Download the qemu source code. 2. Configure and compile your qemu with vhost-crypto option enabled. 3. Apply this patchset to latest DPDK code and recompile DPDK. 4. Compile and run vhost-crypto sample application. ./examples/vhost_crypto/build/vhost-crypto -l 11,12,13 -w 0000:86:01.0 \ --socket-mem 2048,2048 Where 0000:86:01.0 is the QAT PCI address. You may use AES-NI-MB if it is not available. The sample application requires 2 lcores: 1 master and 1 worker. The application will create a UNIX socket file /tmp/vhost_crypto1.socket. It is possible to use other flags like --zero-copy and --guest-polling. 5. Start your qemu application. Here is my command: qemu/x86_64-softmmu/qemu-system-x86_64 -machine accel=kvm -cpu host \ -smp 2 -m 1G -hda ~/path-to-your/image.qcow \ -object memory-backend-file,id=mem,size=1G,mem-path=/dev/hugepages,share=on \ -mem-prealloc -numa node,memdev=mem -chardev \ socket,id=charcrypto0,path=/tmp/vhost_crypto1.socket \ -object cryptodev-vhost-user,id=cryptodev0,chardev=charcrypto0 \ -device virtio-crypto-pci,id=crypto0,cryptodev=cryptodev0 6. Once guest is booted. The Linux virtio_crypto kernel module is loaded by default. You shall see the following logs in your demsg: [ 17.611044] virtio_crypto: loading out-of-tree module taints kernel. [ 17.611083] virtio_crypto: module verification failed: signature and/or ... [ 17.611723] virtio_crypto virtio0: max_queues: 1, max_cipher_key_len: ... [ 17.612156] virtio_crypto virtio0: will run requests pump with realtime ... [ 18.376100] virtio_crypto virtio0: Accelerator is ready The virtio_crypto driver in the guest is now up and running. 7. The rest steps can be as same as the Testing section in https://wiki.qemu.org/Features/VirtioCrypto 8. It is possible to use DPDK Virtio Crypto PMD (https://dpdk.org/dev/patchwork/patch/36471/) in the guest to work with this patchset to achieve optimal performance. v3: - Changed external vhost backend private data and message handling - Added experimental tag to rte_vhost_crypto_set_zero_copy() v2: - Moved vhost_crypto_data_req data from crypto op to source mbuf. - Removed ZERO-COPY flag from config option and make it run-timely changeable. - Guest-polling mode possible. - Simplified vring descriptor access procedure. - Work with both LKCF and DPDK Virtio-Crypto PMD guest drivers. Fan Zhang (10): lib/librte_vhost: add external backend support lib/librte_vhost: add virtio-crypto user message structure lib/librte_vhost: add session message handler lib/librte_vhost: add request handler lib/librte_vhost: add head file lib/librte_vhost: add public function implementation lib/librte_vhost: update version map lib/librte_vhost: update makefile examples/vhost_crypto: add vhost crypto sample application doc: update prog guide and sample app guide doc/guides/prog_guide/vhost_lib.rst | 21 + doc/guides/sample_app_ug/index.rst | 1 + doc/guides/sample_app_ug/vhost_crypto.rst | 84 ++ examples/vhost_crypto/Makefile | 32 + examples/vhost_crypto/main.c | 598 ++++++++++++++ lib/librte_vhost/Makefile | 6 +- lib/librte_vhost/meson.build | 8 +- lib/librte_vhost/rte_vhost.h | 45 +- lib/librte_vhost/rte_vhost_crypto.h | 125 +++ lib/librte_vhost/rte_vhost_version.map | 11 + lib/librte_vhost/vhost.c | 23 +- lib/librte_vhost/vhost.h | 8 +- lib/librte_vhost/vhost_crypto.c | 1269 +++++++++++++++++++++++++++++ lib/librte_vhost/vhost_user.c | 29 +- lib/librte_vhost/vhost_user.h | 36 +- 15 files changed, 2279 insertions(+), 17 deletions(-) create mode 100644 doc/guides/sample_app_ug/vhost_crypto.rst create mode 100644 examples/vhost_crypto/Makefile create mode 100644 examples/vhost_crypto/main.c create mode 100644 lib/librte_vhost/rte_vhost_crypto.h create mode 100644 lib/librte_vhost/vhost_crypto.c -- 2.7.4