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 490F9A0096 for ; Mon, 8 Apr 2019 08:49:00 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 3B41C2BCE; Mon, 8 Apr 2019 08:49:00 +0200 (CEST) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by dpdk.org (Postfix) with ESMTP id A981A5A for ; Mon, 8 Apr 2019 08:48:58 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 07 Apr 2019 23:48:57 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,324,1549958400"; d="scan'208";a="335868359" Received: from fmsmsx105.amr.corp.intel.com ([10.18.124.203]) by fmsmga005.fm.intel.com with ESMTP; 07 Apr 2019 23:48:57 -0700 Received: from fmsmsx153.amr.corp.intel.com (10.18.125.6) by FMSMSX105.amr.corp.intel.com (10.18.124.203) with Microsoft SMTP Server (TLS) id 14.3.408.0; Sun, 7 Apr 2019 23:48:57 -0700 Received: from shsmsx106.ccr.corp.intel.com (10.239.4.159) by FMSMSX153.amr.corp.intel.com (10.18.125.6) with Microsoft SMTP Server (TLS) id 14.3.408.0; Sun, 7 Apr 2019 23:48:57 -0700 Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.206]) by SHSMSX106.ccr.corp.intel.com ([169.254.10.21]) with mapi id 14.03.0415.000; Mon, 8 Apr 2019 14:48:55 +0800 From: "Zhao, XinfengX" To: "dts@dpdk.org" Thread-Topic: [dts][PATCH V1] tests: add test suite and conf for cryptodev virtio unit test Thread-Index: AQHU6q8M5YOszAVA3EKQSCG0KiUfZaYx2N9Q Date: Mon, 8 Apr 2019 06:48:54 +0000 Message-ID: <44051B25D8C8784BB77FFB604D6A70CA1203DAE1@shsmsx102.ccr.corp.intel.com> References: <1554358956-140640-1-git-send-email-xinfengx.zhao@intel.com> In-Reply-To: <1554358956-140640-1-git-send-email-xinfengx.zhao@intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dts] [PATCH V1] tests: add test suite and conf for cryptodev virtio unit 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" Tested-by: Zhao, XinfengX -----Original Message----- From: Zhao, XinfengX=20 Sent: Thursday, April 4, 2019 2:23 PM To: dts@dpdk.org Cc: Zhao, XinfengX Subject: [dts][PATCH V1] tests: add test suite and conf for cryptodev virti= o unit test Signed-off-by: Xinfeng Zhao --- conf/virtio_unit_cryptodev_func.cfg | 30 ++++ tests/TestSuite_virtio_unit_cryptodev_func.py | 215 ++++++++++++++++++++++= ++++ 2 files changed, 245 insertions(+) create mode 100644 conf/virtio_unit_cryptodev_func.cfg create mode 100644 tests/TestSuite_virtio_unit_cryptodev_func.py diff --git a/conf/virtio_unit_cryptodev_func.cfg b/conf/virtio_unit_cryptod= ev_func.cfg new file mode 100644 index 0000000..1ffd418 --- /dev/null +++ b/conf/virtio_unit_cryptodev_func.cfg @@ -0,0 +1,30 @@ +[suite] +# Cryptodev common options qat device id crypto_dev_id=3D"37c9" + +# PCI Pass-through +vfio_pci=3D"0000:60:00.0 0000:60:00.1" + +# Vhost-crypto option config +vdev=3D"crypto_aesni_mb_pmd_1" + +[vm0] +qemu =3D + path=3D/root/qemu-2/bin/qemu-system-x86_64; +cpu =3D + model=3Dhost,number=3D4,cpupin=3D11 12 13 14; mem =3D + size=3D5120,hugepage=3Dyes; +crypto =3D + enable=3Dyes,opt_num=3D2; +daemon =3D + enable=3Dyes; +login =3D + user=3Droot,password=3Dtester; +disk =3D + file=3D/root/VMs/virtio_crypto_test_710_1.img; +vnc =3D + displayNum=3D1; +device =3D + driver=3Dvfio-pci,opt_host=3D0000:60:00.0; + driver=3Dvfio-pci,opt_host=3D0000:60:00.1; diff --git a/tests/TestSuite_virtio_unit_cryptodev_func.py b/tests/TestSuit= e_virtio_unit_cryptodev_func.py new file mode 100644 index 0000000..4a61448 --- /dev/null +++ b/tests/TestSuite_virtio_unit_cryptodev_func.py @@ -0,0 +1,215 @@ + # BSD LICENSE +# +# Copyright(c) 2018-2019 Intel Corporation. All rights reserved. +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without #=20 +modification, are permitted provided that the following conditions #=20 +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 #=20 +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT #=20 +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR #=20 +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT #=20 +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, #=20 +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT #=20 +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, #=20 +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY #=20 +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT #=20 +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE #=20 +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 VirtioCryptodevUnitTest(TestCase): + def set_up_all(self): + self.sample_app=3D "./examples/vhost_crypto/build/vhost-crypto" + self.user_app =3D=20 +"./{target}/app/test".format(target=3Dself.dut.target) + + self.vm0, self.vm0_dut =3D None, None + self.dut.skip_setup =3D True + + self.dut_ports =3D self.dut.get_ports(self.nic) + self.verify(len(self.dut_ports) >=3D 1, 'Insufficient ports for te= st') + self.cores =3D self.dut.get_core_list("1S/3C/1T") + self.mem_channel =3D self.dut.get_memory_channels() + self.bind_script_path =3D self.dut.get_dpdk_bind_script() + + self.vfio_pci =3D self.get_suite_cfg()["vfio_pci"] + for each in self.vfio_pci.split(): + cmd =3D "echo {} > /sys/bus/pci/devices/{}/driver/unbind".form= at(each, each.replace(":", "\:")) + self.dut_execut_cmd(cmd) + + if not cc.is_build_skip(self): + self.tar_dpdk() + self.dut.skip_setup =3D False + cc.build_dpdk_with_cryptodev(self) + self.build_vhost_app() + + cc.bind_qat_device(self) + + self.launch_vhost_switch() + self.bind_vfio_pci() + + self.vm0, self.vm0_dut =3D self.launch_virtio_dut("vm0") + + def set_up(self): + pass + + def dut_execut_cmd(self, cmdline, ex=3D'#', timout=3D30): + return self.dut.send_expect(cmdline, ex, timout) + + def tar_dpdk(self): + self.dut_execut_cmd("rm -rf %s" % self.target, '#', 100) + self.dut_execut_cmd("tar -czf %s/dep/dpdk.tar.gz ../dpdk" %=20 + os.getcwd(), '#', 100) + + def build_user_dpdk(self, user_dut): + user_dut.send_expect( + "sed -i 's/CONFIG_RTE_LIBRTE_PMD_AESNI_MB=3Dn$/CONFIG_RTE_LIBR= TE_PMD_AESNI_MB=3Dy/' config/common_base", '#', 30) + out =3D user_dut.send_expect("make install T=3D%s" % self.target, = "# ", 600) + assert ("Error" not in out), "Compilation error..." + + def build_vhost_app(self): + self.dut_execut_cmd("export RTE_SDK=3D`pwd`") + self.dut_execut_cmd("export RTE_TARGET=3D%s" % self.target) + out =3D 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=3D`pwd`", '#', 30) + user_dut.send_expect("export RTE_TARGET=3D%s" % self.target, '#', = 30) + out =3D user_dut.send_expect("make -C ./%s test-build" % self.targ= et, '#', 600) + self.verify("Error" not in out, "compilation error") + + def get_vhost_eal(self): + default_eal_opts =3D { + "c": None, + "l": ','.join(self.cores), + "w": None, + "vdev": None, + "socket-mem": "2048,0", + "n": self.mem_channel, + } + opts =3D 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] =3D self.get_suite_cfg()[key] + + # Generate option string + opt_str =3D "" + for key,value in opts.items(): + if value is None: + continue + dash =3D "-" if len(key) =3D=3D 1 else "--" + opt_str =3D opt_str + "{0}{1} {2} ".format(dash, key, value) + + return opt_str + + def launch_vhost_switch(self): + eal_opt_str =3D self.get_vhost_eal() + config =3D '"(%s,0,0),(%s,0,0)"' % tuple(self.cores[-2:]) + socket_file =3D "%s,/tmp/vm0_crypto0.sock --socket-file=3D%s,/tmp/= vm0_crypto1.sock" % tuple(self.cores[-2:]) + self.vhost_switch_cmd =3D cc.get_dpdk_app_cmd_str(self.sample_app,= eal_opt_str, + '--config %s --socket-file %s' %=20 + (config, socket_file)) + + self.dut_execut_cmd(self.vhost_switch_cmd, "socket created",=20 + 30) + + def bind_vfio_pci(self): + commands.getoutput("modprobe vfio-pci") + commands.getoutput('%s -b vfio-pci %s' %=20 + (os.path.join(self.dut.base_dir, self.bind_script_path),=20 + self.vfio_pci)) + + def set_virtio_pci(self, dut): + out =3D dut.send_expect("lspci -d:1054|awk '{{print $1}}'", "# ", = 10) + virtio_list =3D out.replace("\r", "\n").replace("\n\n", "\n").spli= t("\n") + dut.send_expect('modprobe uio_pci_generic', '#', 10) + for line in virtio_list: + cmd =3D "echo 0000:{} > /sys/bus/pci/devices/0000\:{}/driver/u= nbind".format( + line, line.replace(":", "\:")) + dut.send_expect(cmd, "# ", 10) + dut.send_expect('echo "1af4 1054" >=20 + /sys/bus/pci/drivers/uio_pci_generic/new_id', "# ", 10) + + def launch_virtio_dut(self, vm_name): + # start vm + vm =3D QEMUKvm(self.dut, vm_name, 'virtio_unit_cryptodev_func') + + try: + vm_dut =3D vm.start(set_target=3DFalse) + 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_cryptodev_virtio_autotest(self): + eal_opt_str =3D cc.get_eal_opt_str(self, {"w":None, "vdev":None}) + self.__run_unit_test("cryptodev_virtio_autotest", eal_opt_str) + + def __run_unit_test(self, testsuite, eal_opt_str=3D'', timeout=3D600): + self.logger.info("STEP_TEST: " + testsuite) + self.vm0_dut.send_expect("dmesg -C", "# ", 30) + cmd_str =3D cc.get_dpdk_app_cmd_str(self.user_app, "--log-level 8"= , eal_opt_str) + info =3D self.vm0_dut.send_expect(cmd_str, "RTE>>", 30) + self.logger.info(info) + + out =3D "" + try: + out =3D self.vm0_dut.send_expect(testsuite, "RTE>>", timeout) + self.vm0_dut.send_expect("quit", "# ", 30) + except Exception as err: + self.logger.error("Cryptodev Unit Tests Exception") + dmesg =3D self.vm0_dut.alt_session.send_expect("dmesg", "# ", = 30) + self.logger.error("dmesg info:") + self.logger.error(dmesg) + + self.logger.info(out) + self.verify("Test OK" in out, "Test Failed") + self.vm0_dut.kill_all() + + def tear_down(self): + pass + + def tear_down_all(self): + if self.vm0: + self.vm0.stop() + self.dut.virt_exit() + self.vm0 =3D 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