From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by dpdk.org (Postfix) with ESMTP id AEDDF5F65 for ; Thu, 8 Mar 2018 04:29:59 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 07 Mar 2018 19:29:57 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.47,438,1515484800"; d="scan'208";a="36387579" Received: from fmsmsx103.amr.corp.intel.com ([10.18.124.201]) by fmsmga001.fm.intel.com with ESMTP; 07 Mar 2018 19:29:56 -0800 Received: from fmsmsx119.amr.corp.intel.com (10.18.124.207) by FMSMSX103.amr.corp.intel.com (10.18.124.201) with Microsoft SMTP Server (TLS) id 14.3.319.2; Wed, 7 Mar 2018 19:29:56 -0800 Received: from shsmsx101.ccr.corp.intel.com (10.239.4.153) by FMSMSX119.amr.corp.intel.com (10.18.124.207) with Microsoft SMTP Server (TLS) id 14.3.319.2; Wed, 7 Mar 2018 19:29:56 -0800 Received: from shsmsx103.ccr.corp.intel.com ([169.254.4.116]) by SHSMSX101.ccr.corp.intel.com ([169.254.1.253]) with mapi id 14.03.0319.002; Thu, 8 Mar 2018 11:29:54 +0800 From: "Liu, Yong" To: "Ma, LihongX" , "dts@dpdk.org" CC: "Ma, LihongX" Thread-Topic: [dts] [PATCH V1] Add test suite about vhost multi queue qemu Thread-Index: AQHTtbWy42SH0MqxO0yw+xaZh/KYrKPFrItA Date: Thu, 8 Mar 2018 03:29:54 +0000 Message-ID: <86228AFD5BCD8E4EBFD2B90117B5E81E62FAB345@SHSMSX103.ccr.corp.intel.com> References: <1586692355-17207-1-git-send-email-lihongx.ma@intel.com> In-Reply-To: <1586692355-17207-1-git-send-email-lihongx.ma@intel.com> Accept-Language: zh-CN, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiZTY1YzUwZjQtN2YxMi00MzU0LWIwMjMtYjJiZTllY2MzMzEwIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjIuNS4xOCIsIlRydXN0ZWRMYWJlbEhhc2giOiJqU1lWUkNNZjErTlBGUER4d0lDNDZnZ2FWRkI0MnlITE1JdmRhbUZXK3p0ZytLOGZsTFloZytWYUNNMXFsSEdYIn0= x-ctpclassification: CTP_NT 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] Add test suite about vhost multi queue qemu 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: , X-List-Received-Date: Thu, 08 Mar 2018 03:30:00 -0000 Lihong, my comments are inline. Thanks, Marvin > -----Original Message----- > From: dts [mailto:dts-bounces@dpdk.org] On Behalf Of lihong > Sent: Sunday, April 12, 2020 7:53 PM > To: dts@dpdk.org > Cc: Ma, LihongX > Subject: [dts] [PATCH V1] Add test suite about vhost multi queue qemu >=20 > Signed-off-by: lihong > --- > tests/TestSuite_vhost_multi_queue_qemu.py | 297 > ++++++++++++++++++++++++++++++ > 1 file changed, 297 insertions(+) > create mode 100644 tests/TestSuite_vhost_multi_queue_qemu.py >=20 > diff --git a/tests/TestSuite_vhost_multi_queue_qemu.py > b/tests/TestSuite_vhost_multi_queue_qemu.py > new file mode 100644 > index 0000000..4538fd0 > --- /dev/null > +++ b/tests/TestSuite_vhost_multi_queue_qemu.py > @@ -0,0 +1,297 @@ > +# BSD LICENSE > +# > +# Copyright(c) 2010-2015 Intel Corporation. All rights reserved. > +# All rights reserved. Please update the date. > +# > +# 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. > + > +Vhost PVP performance using Qemu test suite. > +""" > +import os > +import re > +import time > +import utils > +from scapy.utils import wrpcap, rdpcap > +from test_case import TestCase > +from exception import VerifyFailure > +from settings import HEADER_SIZE > +from etgen import IxiaPacketGenerator Please remove unused import.=20 > +from qemu_kvm import QEMUKvm > + Now we have wrapper function for virtual machine object import. Please not = use QEMU object directly.=20 from virt_common import VM > + > +class TestVhostUserOneCopyOneVm(TestCase): > + > + def set_up_all(self): > + # Get and verify the ports > + self.dut_ports =3D self.dut.get_ports() > + self.verify(len(self.dut_ports) >=3D 1, "Insufficient ports for > testing") > + local_port =3D self.tester.get_local_port(self.dut_ports[0]) > + self.tx_interface =3D self.tester.get_interface(local_port) > + # Get the port's socket > + self.pf =3D self.dut_ports[0] > + netdev =3D self.dut.ports_info[self.pf]['port'] > + self.socket =3D netdev.get_nic_socket() > + self.cores =3D self.dut.get_core_list("1S/3C/1T", > socket=3Dself.socket) You may need to check whether return core is sufficient. > + > + self.queue_number =3D 2 > + > + # Using file to save the vhost sample output since in jumboframe > case, > + # there will be lots of output > + > + self.virtio1 =3D "eth1" > + self.virtio1_mac =3D "52:54:00:00:00:01" > + self.vm_dut =3D None > + > + self.number_of_ports =3D 1 > + self.header_row =3D ["FrameSize(B)", "Throughput(Mpps)", > "LineRate(%)", "Cycle"] > + self.memory_channel =3D 4 You can get dut channel by function call "self.dut.get_memory_channels()". > + if self.dut.cores[len(self.dut.cores)-1]['socket'] =3D=3D '0': > + self.socket_mem =3D '1024' > + else: > + self.socket_mem =3D '1024,1024' If socket number is required, I'd like add new function in crb object to do= that.=20 > + > + def set_up(self): > + # > + # Run before each test case. > + # > + self.dut.send_expect("rm -rf ./vhost.out", "#") > + self.dut.send_expect("rm -rf ./vhost-net*", "#") > + self.dut.send_expect("killall -s INT vhost-switch", "#") > + > + self.frame_sizes =3D [64, 128, 256, 512, 1024, 1500] > + self.vm_testpmd_vector =3D self.target + "/app/testpmd -c 0x07 -= n > 3" + \ > + " -- -i --tx-offloads=3D0x0 " + \ > + " --rxq=3D%d --txq=3D%d --rss-ip --nb- > cores=3D2" % (self.queue_number, self.queue_number) > + > + def launch_testpmd(self, queue=3D2): > + # > + # Launch the vhost sample with different parameters > + # > + self.testcmd =3D "./x86_64-native-linuxapp-gcc/app/testpmd -c %s= - > n %d --socket-mem %s" + \ > + " --vdev 'net_vhost0,iface=3Dvhost-net,queues=3D%= d' -- > -i --rxq=3D%d --txq=3D%d --nb-cores=3D2" Please use self.target for DPDK target. > + self.coremask =3D utils.create_mask(self.cores) > + self.testcmd_start =3D self.testcmd % (self.coremask, > self.memory_channel, self.socket_mem, queue, queue, queue) > + Local variable should be enough, testcmd_start won't be used in other place= s. > + self.vhost_user =3D self.dut.new_session(suite=3D"user") Please remember to close this session in tear_down function.=20 > + > + self.vhost_user.send_expect("cd /root/dpdk", "#", 120) > + self.vhost_user.send_expect(self.testcmd_start, "testpmd> ", 120= ) > + self.vhost_user.send_expect("set fwd mac", "testpmd> ", 120) > + self.vhost_user.send_expect("start", "testpmd> ", 120) > + > + def start_onevm(self, path=3D"", modem=3D0): > + # > + # Start One VM with one virtio device > + # > + self.vm =3D QEMUKvm(self.dut, 'vm0', 'vhost_sample') > + if(path !=3D ""): > + self.vm.set_qemu_emulator(path) > + vm_params =3D {} > + vm_params['driver'] =3D 'vhost-user' > + vm_params['opt_path'] =3D './vhost-net' > + vm_params['opt_mac'] =3D self.virtio1_mac > + vm_params['opt_queue'] =3D self.queue_number > + vm_params['opt_settings'] =3D 'mrg_rxbuf=3Don,mq=3Don,vectors=3D= 6' > + if(modem =3D=3D 1): > + vm_params['opt_settings'] =3D 'disable-modern=3Dfalse' > + self.vm.set_vm_device(**vm_params) > + > + try: > + self.vm_dut =3D self.vm.start() > + if self.vm_dut is None: > + raise Exception("Set up VM ENV failed") > + except Exception as e: > + self.logger.error("ERROR: Failure for %s" % str(e)) > + > + return True > + > + def vm_testpmd_start(self): > + # > + # Start testpmd in vm > + # > + if self.vm_dut is not None: > + self.vm_dut.send_expect(self.vm_testpmd_vector, "testpmd>", > 20) > + self.vm_dut.send_expect("set fwd mac", "testpmd>", 20) > + self.vm_dut.send_expect("start tx_first", "testpmd>") > + > + def send_verify(self, case, frame_sizes, tag=3D"Performance"): Look like nothing is verified in this function, you may need to change the = function name. > + self.result_table_create(self.header_row) > + for frame_size in frame_sizes: > + info =3D "Running test %s, and %d frame size." % (case, > frame_size) > + self.logger.info(info) > + payload_size =3D frame_size - HEADER_SIZE['eth'] - > HEADER_SIZE['ip'] - HEADER_SIZE['udp'] > + tgenInput =3D [] > + > + self.tester.scapy_append('a=3D > [Ether(dst=3D"%s")/IP(dst=3D"1.1.1.1")/UDP()/("X"*%d)]' % (self.virtio1_m= ac, > payload_size)) > + self.tester.scapy_append('b=3D > [Ether(dst=3D"%s")/IP(dst=3D"1.1.1.20")/UDP()/("X"*%d)]' % (self.virtio1_= mac, > payload_size)) > + self.tester.scapy_append('c=3D > [Ether(dst=3D"%s")/IP(dst=3D"1.1.1.7")/UDP()/("X"*%d)]' % (self.virtio1_m= ac, > payload_size)) > + self.tester.scapy_append('d=3D > [Ether(dst=3D"%s")/IP(dst=3D"1.1.1.8")/UDP()/("X"*%d)]' % (self.virtio1_m= ac, > payload_size)) > + self.tester.scapy_append('a=3D a + b + c + d') > + self.tester.scapy_append('wrpcap("multiqueue_2.pcap", a)') > + self.tester.scapy_execute() > + > + port =3D self.tester.get_local_port(self.pf) > + tgenInput.append((port, port, "multiqueue_2.pcap")) > + > + _, pps =3D self.tester.traffic_generator_throughput(tgenInpu= t, > delay=3D30) > + Mpps =3D pps / 1000000.0 > + pct =3D Mpps * 100 / float(self.wirespeed(self.nic, frame_si= ze, > + self.number_of_ports)) > + data_row =3D [frame_size, str(Mpps), str(pct), tag] > + self.result_table_add(data_row) > + #self.verify(Mpps !=3D 0, "The recive data of pak-size: %d i= s > 0") Please fix typo here. > + self.result_table_print() > + > + def send_scapy(self, verify_type =3D 1): Please add comment this function. Please use string for verify_type argument which is more readable. > + payload_size =3D 256 - HEADER_SIZE['eth'] - HEADER_SIZE['ip'] - > HEADER_SIZE['udp'] > + self.tester.scapy_append('pk1 =3D > [Ether(dst=3D"%s")/IP(dst=3D"1.1.1.1")/UDP()/("X"*%d)]' % (self.virtio1_m= ac, > payload_size)) > + self.tester.scapy_append('pk2 =3D > [Ether(dst=3D"%s")/IP(dst=3D"1.1.1.20")/UDP()/("X"*%d)]' % (self.virtio1_= mac, > payload_size)) > + self.tester.scapy_append('pk3 =3D > [Ether(dst=3D"%s")/IP(dst=3D"1.1.1.7")/UDP()/("X"*%d)]' % (self.virtio1_m= ac, > payload_size)) > + self.tester.scapy_append('pk4 =3D > [Ether(dst=3D"%s")/IP(dst=3D"1.1.1.8")/UDP()/("X"*%d)]' % (self.virtio1_m= ac, > payload_size)) > + self.tester.scapy_append('pk =3D pk1 + pk2 + pk3 + pk4') > + self.tester.scapy_append('sendp(pk, iface=3D"%s", count=3D10)' % > (self.tx_interface)) > + self.tester.scapy_execute() > + > + out =3D self.vhost_user.send_expect("show port stats 0", "testpm= d> > ", 120) > + print out > + rx_packet =3D re.search("RX-packets:\s*(\d*)", out) > + rx_num =3D int(rx_packet.group(1)) > + tx_packet =3D re.search("TX-packets:\s*(\d*)", out) > + tx_num =3D int(tx_packet.group(1)) > + if verify_type =3D=3D 1: > + verify_rx_num =3D 40 > + verify_tx_num =3D 40 > + else:=09 > + verify_rx_num =3D 40 > + verify_tx_num =3D 10 > + > + self.verify(rx_num >=3D verify_rx_num and tx_num >=3D verify_tx_= num, > "The vm port lost some packets") > + > + def test_perf_pvp_multiqemu_mergeable_pmd(self): > + # > + # Test the performance for mergeable path > + # > + self.launch_testpmd() > + self.start_onevm() > + self.vm_dut.send_expect(self.vm_testpmd_vector, "testpmd>", 20) > + self.vm_dut.send_expect("set fwd mac", "testpmd>", 20) > + self.vm_dut.send_expect("start", "testpmd>") > + > + self.vhost_user.send_expect("stop", "testpmd> ", 120) > + self.vhost_user.send_expect("start", "testpmd> ", 120) > + time.sleep(5) > + self.send_verify(self.running_case, self.frame_sizes, "Virtio > 0.95 Mergeable Multiqueue Performance") > + self.vm_dut.kill_all() > + > + def test_dynamic_change_virtio_queue_size(self): > + # > + # Test the performance for change vritio queue size > + # > + self.launch_testpmd() > + self.start_onevm() > + self.vm_testpmd_queue_1 =3D self.target + "/app/testpmd -c 0x07 = -n > 3" + \ > + " -- -i --tx-offloads=3D0x0 " + \ > + " --rxq=3D1 --txq=3D1 --rss-ip --nb- > cores=3D1" > + > + self.vm_dut.send_expect(self.vm_testpmd_queue_1, "testpmd>", 20) > + self.vm_dut.send_expect("set fwd mac", "testpmd>", 20) > + self.vm_dut.send_expect("start", "testpmd>") > + > + self.vhost_user.send_expect("clear port stats all", "testpmd> ", > 120) > + self.send_scapy(verify_type =3D 2) > + > + self.vm_dut.send_expect("stop", "testpmd>", 20) > + self.vm_dut.send_expect("port stop all", "testpmd>") > + self.vm_dut.send_expect("port config all rxq 2", "testpmd>", 20) > + self.vm_dut.send_expect("port config all txq 2", "testpmd>") > + self.vm_dut.send_expect("port start all", "testpmd>", 20) > + self.vm_dut.send_expect("start", "testpmd>") > + > + self.vhost_user.send_expect("stop", "testpmd> ", 120) > + self.vhost_user.send_expect("start", "testpmd> ", 120) > + > + self.vhost_user.send_expect("clear port stats all", "testpmd> ", > 120) > + self.send_scapy(verify_type =3D 1) > + > + self.vm_dut.kill_all() > + self.vhost_user.send_expect("quit", "# ", 120) > + > + def test_dynamic_change_vhost_queue_size(self): > + # > + # Test the performance for change vhost queue size > + # > + self.queue_number =3D 2 > + self.testcmd =3D "./x86_64-native-linuxapp-gcc/app/testpmd -c %s= - > n %d --socket-mem %s" + \ > + " --vdev 'net_vhost0,iface=3Dvhost-net,queues=3D2= ' -- > -i --rxq=3D1 --txq=3D1 --nb-cores=3D1" > + self.coremask =3D utils.create_mask(self.cores) > + self.testcmd_start =3D self.testcmd % (self.coremask, > self.memory_channel, self.socket_mem) > + > + self.vhost_user =3D self.dut.new_session(suite=3D"user") > + > + self.vhost_user.send_expect("cd /root/dpdk", "#", 120) > + self.vhost_user.send_expect(self.testcmd_start, "testpmd> ", 120= ) > + self.vhost_user.send_expect("set fwd mac", "testpmd> ", 120) > + self.vhost_user.send_expect("start", "testpmd> ", 120) > + > + self.start_onevm() > + > + self.vm_dut.send_expect(self.vm_testpmd_vector, "testpmd>", 20) > + self.vm_dut.send_expect("set fwd mac", "testpmd>", 20) > + self.vm_dut.send_expect("start", "testpmd>") > + self.vhost_user.send_expect("clear port stats all", "testpmd> ", > 120) > + > + self.send_scapy(verify_type =3D 1) > + > + self.vhost_user.send_expect("stop", "testpmd>", 20) > + self.vhost_user.send_expect("port stop all", "testpmd>") > + self.vhost_user.send_expect("port config all rxq 2", "testpmd>", > 20) > + self.vhost_user.send_expect("port config all txq 2", "testpmd>") > + self.vhost_user.send_expect("port start all", "testpmd>", 20) > + self.vhost_user.send_expect("start", "testpmd>") > + self.vhost_user.send_expect("clear port stats all", "testpmd>") > + > + self.send_scapy(verify_type =3D 1) > + > + self.vm_dut.kill_all() > + self.vhost_user.send_expect("quit", "# ", 120) > + > + def tear_down(self): > + # > + # Run after each test case. > + # Clear vhost-switch and qemu to avoid blocking the following TC= s > + # > + self.vm.stop() > + time.sleep(2) > + > + def tear_down_all(self): > + """ > + Run after each test suite. > + """ > + pass > -- > 2.7.4