From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by dpdk.space (Postfix) with ESMTP id 1CF40A0679 for ; Thu, 4 Apr 2019 08:53:23 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id F1CF45323; Thu, 4 Apr 2019 08:53:22 +0200 (CEST) Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by dpdk.org (Postfix) with ESMTP id F364A4F91 for ; Thu, 4 Apr 2019 08:53:20 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 03 Apr 2019 23:53:20 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,306,1549958400"; d="scan'208";a="131346682" Received: from purley-s2600stq.sh.intel.com ([10.67.110.242]) by orsmga008.jf.intel.com with ESMTP; 03 Apr 2019 23:53:18 -0700 From: Xinfeng Zhao To: dts@dpdk.org Cc: Xinfeng Zhao Date: Thu, 4 Apr 2019 14:51:53 +0800 Message-Id: <1554360713-150164-1-git-send-email-xinfengx.zhao@intel.com> X-Mailer: git-send-email 2.7.4 Subject: [dts] [PATCH V1] tests: add test suite and conf for cryptodev virtio perf test X-BeenThere: dts@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: test suite reviews and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dts-bounces@dpdk.org Sender: "dts" Signed-off-by: Xinfeng Zhao --- conf/virtio_perf_cryptodev_func.cfg | 64 +++++++ tests/TestSuite_virtio_perf_cryptodev_func.py | 252 ++++++++++++++++++++++++++ 2 files changed, 316 insertions(+) create mode 100644 conf/virtio_perf_cryptodev_func.cfg create mode 100644 tests/TestSuite_virtio_perf_cryptodev_func.py diff --git a/conf/virtio_perf_cryptodev_func.cfg b/conf/virtio_perf_cryptodev_func.cfg new file mode 100644 index 0000000..5a9b2cb --- /dev/null +++ b/conf/virtio_perf_cryptodev_func.cfg @@ -0,0 +1,64 @@ +[suite] +# Cryptodev common options qat device id +crypto_dev_id="37c9" + +# PCI Pass-through +vfio_pci="0000:60:00.0 0000:60:00.1" + +# Vhost-crypto option config +vdev="crypto_aesni_mb_pmd_1" + +[test_aesni_mb_aes_cbc_sha1_hmac] +buffer-sz="64,128,256,512,1024,2048" +l="0,1" +socket-mem="512,0" +vdev="crypto_aesni_mb_pmd_1" +optype="cipher-then-auth" +devtype="crypto_aesni_mb" +cipher-algo="aes-cbc" +cipher-op="encrypt" +cipher-key-sz=16 +cipher-iv-sz=16 +auth-algo="sha1-hmac" +auth-op="generate" +auth-key-sz=64 +digest-sz=12 +total-ops=100000 + +[test_virtio_aes_cbc_sha1_hmac] +buffer-sz="64,128,256,512,1024,2048" +l="0,1" +socket-mem="512,0" +w="00:05.0" +optype="cipher-then-auth" +devtype="crypto_virtio" +cipher-algo="aes-cbc" +cipher-op="encrypt" +cipher-key-sz=16 +cipher-iv-sz=16 +auth-algo="sha1-hmac" +auth-op="generate" +auth-key-sz=64 +digest-sz=12 +total-ops=100000 + +[vm0] +qemu = + path=/root/qemu-2/bin/qemu-system-x86_64; +cpu = + model=host,number=4,cpupin=11 12 13 14; +mem = + size=5120,hugepage=yes; +crypto = + enable=yes,opt_num=2; +daemon = + enable=yes; +login = + user=root,password=tester; +disk = + file=/root/VMs/virtio_crypto_test_710_1.img; +vnc = + displayNum=1; +device = + driver=vfio-pci,opt_host=0000:60:00.0; + driver=vfio-pci,opt_host=0000:60:00.1; diff --git a/tests/TestSuite_virtio_perf_cryptodev_func.py b/tests/TestSuite_virtio_perf_cryptodev_func.py new file mode 100644 index 0000000..1f23363 --- /dev/null +++ b/tests/TestSuite_virtio_perf_cryptodev_func.py @@ -0,0 +1,252 @@ +# BSD LICENSE +# +# Copyright(c) 2018-201 Intel Corporation. All rights reserved. +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# * Neither the name of Intel Corporation nor the names of its +# contributors may be used to endorse or promote products derived +# from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +""" +DPDK Test suite +Test DPDK vhost + virtio scenarios +""" +import os +import utils +import commands +from test_case import TestCase +from qemu_kvm import QEMUKvm +import cryptodev_common as cc + +class VirtioCryptodevPerfTest(TestCase): + def set_up_all(self): + self.sample_app = "./examples/vhost_crypto/build/vhost-crypto" + self.user_app = "./{target}/build/app/test-crypto-perf/dpdk-test-crypto-perf".format(target=self.dut.target) + self._default_crypto_perf_opts = { + "ptest": "throughput", + "silent": "", + "pool-sz": None, + "total-ops": "1000000", + "burst-sz": "32", + "buffer-sz": "64", + "devtype": None, + "segments-nb": None, + "optype": "cipher-then-auth", + "sessionless": None, + "out-of-place": None, + "test-file": None, + "test-name": None, + "cipher-algo": None, + "cipher-op": None, + "cipher-key-sz": None, + "cipher-iv-sz": None, + "auth-algo": None, + "auth-op": None, + "auth-key-sz": None, + "auth-iv-sz": None, + "aead-algo": None, + "aead-op": None, + "aead-key-sz": None, + "aead-iv-sz": None, + "aead-aad-sz": None, + "digest-sz": None, + "csv-friendly": None + } + + self.vm0, self.vm0_dut = None, None + self.dut.skip_setup = True + + self.dut_ports = self.dut.get_ports(self.nic) + self.verify(len(self.dut_ports) >= 1, 'Insufficient ports for test') + self.cores = self.dut.get_core_list("1S/3C/1T") + self.mem_channel = self.dut.get_memory_channels() + + self.bind_script_path = self.dut.get_dpdk_bind_script() + + self.vfio_pci = self.get_suite_cfg()["vfio_pci"] + for each in self.vfio_pci.split(): + cmd = "echo {} > /sys/bus/pci/devices/{}/driver/unbind".format(each, each.replace(":", "\:")) + self.dut_execut_cmd(cmd) + + if not cc.is_build_skip(self): + self.tar_dpdk() + self.dut.skip_setup = False + cc.build_dpdk_with_cryptodev(self) + self.build_vhost_app() + cc.bind_qat_device(self, "vfio-pci") + + self.launch_vhost_switch() + self.bind_vfio_pci() + + self.vm0, self.vm0_dut = self.launch_virtio_dut("vm0") + + def set_up(self): + pass + + def dut_execut_cmd(self, cmdline, ex='#', timout=30): + return self.dut.send_expect(cmdline, ex, timout) + + def tar_dpdk(self): + self.dut_execut_cmd("tar -czf %s/dep/dpdk.tar.gz ../dpdk" % os.getcwd(), '#', 100) + + def build_user_dpdk(self, user_dut): + user_dut.send_expect( + "sed -i 's/CONFIG_RTE_LIBRTE_PMD_AESNI_MB=n$/CONFIG_RTE_LIBRTE_PMD_AESNI_MB=y/' config/common_base", '#', 30) + + out = user_dut.send_expect("make install T=%s" % self.target, "# ", 600) + assert ("Error" not in out), "Compilation error..." + + def build_vhost_app(self): + self.dut_execut_cmd("export RTE_SDK=`pwd`") + self.dut_execut_cmd("export RTE_TARGET=%s" % self.target) + out = self.dut_execut_cmd("make -C ./examples/vhost_crypto") + self.verify("Error" not in out, "compilation error") + + def build_user_app(self, user_dut): + user_dut.send_expect("export RTE_SDK=`pwd`", '#', 30) + user_dut.send_expect("export RTE_TARGET=%s" % self.target, '#', 30) + out = user_dut.send_expect("make -C ./%s test-build" % self.target, '#', 600) + self.verify("Error" not in out, "compilation error") + + def get_vhost_eal(self): + default_eal_opts = { + "c": None, + "l": ','.join(self.cores), + "w": None, + "vdev": None, + "socket-mem": "2048,0", + "n": self.mem_channel + } + opts = default_eal_opts.copy() + + # Update options with test suite/case config file + for key in opts.keys(): + if key in self.get_suite_cfg(): + opts[key] = self.get_suite_cfg()[key] + + # Generate option string + opt_str = "" + for key,value in opts.items(): + if value is None: + continue + dash = "-" if len(key) == 1 else "--" + opt_str = opt_str + "{0}{1} {2} ".format(dash, key, value) + + return opt_str + + def launch_vhost_switch(self): + eal_opt_str = self.get_vhost_eal() + config = '"(%s,0,0),(%s,0,0)"' % tuple(self.cores[-2:]) + socket_file = "%s,/tmp/vm0_crypto0.sock --socket-file=%s,/tmp/vm0_crypto1.sock" % tuple(self.cores[-2:]) + self.vhost_switch_cmd = cc.get_dpdk_app_cmd_str(self.sample_app, eal_opt_str, + '--config %s --socket-file %s' % (config, socket_file)) + + self.dut_execut_cmd(self.vhost_switch_cmd, "socket created", 30) + + def bind_vfio_pci(self): + commands.getoutput("modprobe vfio-pci") + commands.getoutput('%s -b vfio-pci %s' % (os.path.join(self.dut.base_dir, self.bind_script_path), self.vfio_pci)) + + def set_virtio_pci(self, dut): + out = dut.send_expect("lspci -d:1054|awk '{{print $1}}'", "# ", 10) + virtio_list = out.replace("\r", "\n").replace("\n\n", "\n").split("\n") + dut.send_expect('modprobe uio_pci_generic', '#', 10) + for line in virtio_list: + cmd = "echo 0000:{} > /sys/bus/pci/devices/0000\:{}/driver/unbind".format( + line, line.replace(":", "\:")) + dut.send_expect(cmd, "# ", 10) + dut.send_expect('echo "1af4 1054" > /sys/bus/pci/drivers/uio_pci_generic/new_id', "# ", 10) + + def launch_virtio_dut(self, vm_name): + # start vm + vm = QEMUKvm(self.dut, vm_name, 'virtio_perf_cryptodev_func') + + try: + vm_dut = vm.start(set_target=False) + if vm_dut is None: + print('{} start failed'.format(vm_name)) + except Exception as err: + raise err + + vm_dut.restore_interfaces() + + if not self.dut.skip_setup: + self.build_user_dpdk(vm_dut) + self.build_user_app(vm_dut) + + vm_dut.setup_modules(self.target, "igb_uio", None) + vm_dut.bind_interfaces_linux('igb_uio') + self.set_virtio_pci(vm_dut) + + return vm, vm_dut + + def test_aesni_mb_aes_cbc_sha1_hmac(self): + if cc.is_test_skip(self): + return + + eal_opt_str = cc.get_eal_opt_str(self, {"w":None}) + crypto_perf_opt_str = cc.get_opt_str(self, self._default_crypto_perf_opts) + out = self._run_crypto_perf(eal_opt_str, crypto_perf_opt_str) + self.logger.info(out) + self.verify("Failed" not in out, "Test fail") + self.verify("Error" not in out, "Test fail") + + def test_virtio_aes_cbc_sha1_hmac(self): + if cc.is_test_skip(self): + return + + eal_opt_str = cc.get_eal_opt_str(self, {"vdev":None}) + crypto_perf_opt_str = cc.get_opt_str(self, self._default_crypto_perf_opts) + out = self._run_crypto_perf(eal_opt_str, crypto_perf_opt_str) + self.logger.info(out) + self.verify("Failed" not in out, "Test fail") + self.verify("Error" not in out, "Test fail") + + def _run_crypto_perf(self, eal_opt_str, crypto_perf_opt_str): + cmd_str = cc.get_dpdk_app_cmd_str(self.user_app, + eal_opt_str, + crypto_perf_opt_str) + self.logger.info(cmd_str) + try: + out = self.vm0_dut.send_expect(cmd_str, "#", 600) + except Exception as ex: + self.logger.error(ex) + raise ex + + return out + + def tear_down(self): + pass + + def tear_down_all(self): + if self.vm0: + self.vm0.stop() + self.dut.virt_exit() + self.vm0 = None + + self.dut_execut_cmd("^C", "# ") + self.dut_execut_cmd("killall -s INT vhost-crypto") + self.dut_execut_cmd("killall -s INT qemu-system-x86_64") + self.dut_execut_cmd("rm -r /tmp/*") + cc.clear_dpdk_config(self) -- 2.7.4