From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by dpdk.org (Postfix) with ESMTP id 064395F13 for ; Fri, 9 Mar 2018 09:51:08 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 09 Mar 2018 00:51:07 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.47,444,1515484800"; d="scan'208";a="26558443" Received: from fmsmsx107.amr.corp.intel.com ([10.18.124.205]) by fmsmga002.fm.intel.com with ESMTP; 09 Mar 2018 00:51:07 -0800 Received: from fmsmsx122.amr.corp.intel.com (10.18.125.37) by fmsmsx107.amr.corp.intel.com (10.18.124.205) with Microsoft SMTP Server (TLS) id 14.3.319.2; Fri, 9 Mar 2018 00:51:07 -0800 Received: from shsmsx101.ccr.corp.intel.com (10.239.4.153) by fmsmsx122.amr.corp.intel.com (10.18.125.37) with Microsoft SMTP Server (TLS) id 14.3.319.2; Fri, 9 Mar 2018 00:51:07 -0800 Received: from shsmsx103.ccr.corp.intel.com ([169.254.4.235]) by SHSMSX101.ccr.corp.intel.com ([169.254.1.166]) with mapi id 14.03.0319.002; Fri, 9 Mar 2018 16:51:05 +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: AQHTt3hNRk1sumJMdE2egmPxR1IlsaPHkDIg Date: Fri, 9 Mar 2018 08:51:04 +0000 Message-ID: <86228AFD5BCD8E4EBFD2B90117B5E81E62FBB550@SHSMSX103.ccr.corp.intel.com> References: <1586885923-11991-1-git-send-email-lihongx.ma@intel.com> In-Reply-To: <1586885923-11991-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: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiY2I5ZTM4MDgtMzcxZC00NjE4LWFlNGUtMjBhNGY0OWZiNDhkIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjIuNS4xOCIsIlRydXN0ZWRMYWJlbEhhc2giOiJVTXM4S2lcLzJMQUptdDg2ak1HMVlEMjBDQ0xzUUQrS1pIUXBocVVuclE4K093UzlMYmJPeWU5ajhSbVpmYW5jVCJ9 x-ctpclassification: CTP_NT dlp-product: dlpe-windows dlp-version: 11.0.0.116 dlp-reaction: no-action 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: Fri, 09 Mar 2018 08:51:10 -0000 Lihong,=20 Some comments are inline. Thanks, Marvin > -----Original Message----- > From: dts [mailto:dts-bounces@dpdk.org] On Behalf Of lihong > Sent: Wednesday, April 15, 2020 1:39 AM > 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 | 300 > ++++++++++++++++++++++++++++++ > 1 file changed, 300 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..80a02bd > --- /dev/null > +++ b/tests/TestSuite_vhost_multi_queue_qemu.py > @@ -0,0 +1,300 @@ > +# BSD LICENSE > +# > +# Copyright(c) 2010-2018 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. > + > +Vhost PVP performance using Qemu test suite. > +""" > +import re > +import time > +import utils > +from scapy.utils import wrpcap > +from test_case import TestCase > +from settings import HEADER_SIZE > +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) > + self.verify(self.cores is not None, "Insufficient cores for spee= d > testing") Function get_core_list won't return None if allocated cores are insufficien= t. You can do same kind of function by check length of self.cores. > + > + 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 self.dut.get_memory_channels() > + > + 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 %s -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 > + # > + testcmd =3D self.target + "/app/testpmd -c %s -n %d --socket-mem > 1024,1024" + \ > + " --vdev 'net_vhost0,iface=3Dvhost-net,queues=3D%= d' -- > -i --rxq=3D%d --txq=3D%d --nb-cores=3D2" > + self.coremask =3D utils.create_mask(self.cores) > + testcmd_start =3D testcmd % (self.coremask, self.memory_channel, > queue, queue, queue) > + > + self.vhost_user =3D self.dut.new_session(suite=3D"user") > + > + self.vhost_user.send_expect("cd /root/dpdk", "#", 120) DPDK folder is saved in self.dut.base_dir. I'm not sure why need additional= session for starting testpmd. Look like you haven't use host default session in this suite. > + self.vhost_user.send_expect(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""): > + # > + # Start One VM with one virtio device > + # Please use """ as separator for function description.=20 > + self.vm =3D VM(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' Vectors should be calculated?=20 > + > + 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 get_vm_coremask(self): > + # > + # Get the vm coremask > + # > + cores =3D self.vm_dut.get_core_list("1S/3C/1T") > + self.verify(cores is not None, "Insufficient cores for speed > testing, add the cpu number in cfg file.") Same comment as previous. > + self.vm_coremask =3D utils.create_mask(cores) > + > + def send_performance(self, case, frame_sizes, tag=3D"Performance"): > + # > + # Verify the testpmd can recive and forward the data > + # > + 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 frame-size: %d = is > 0" % frame_size) > + self.result_table_print() > + > + def send_scapy(self, verify_type): > + # > + # Verify the virtio-pmd can recive the data before/after change > queue size > + # > + 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() Please use those functions in packet module for packet transmission. > + > + 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 "vhost queue =3D virtio queue" or verify_t= ype =3D=3D > "vhost queue < virtio queue" : > + verify_rx_num =3D 40 > + verify_tx_num =3D 40 > + elif verify_type =3D=3D "vhost queue > virtio queue": > + 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.get_vm_coremask() > + > + self.vm_dut.send_expect(self.vm_testpmd_vector % self.vm_coremas= k, > "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_performance(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 %s -n= 3" > + \ > + " -- -i --tx-offloads=3D0x0 " + \ > + " --rxq=3D1 --txq=3D1 --rss-ip --nb- > cores=3D1" > + self.get_vm_coremask() > + self.vm_dut.send_expect(self.vm_testpmd_queue_1 % > self.vm_coremask, "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("vhost queue > virtio queue") > + > + 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("vhost queue =3D virtio queue") > + > + 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 > + testcmd =3D self.target + "/app/testpmd -c %s -n %d --socket-mem > 1024,1024" + \ > + " --vdev 'net_vhost0,iface=3Dvhost-net,queues=3D2= ' -- > -i --rxq=3D1 --txq=3D1 --nb-cores=3D1" > + self.coremask =3D utils.create_mask(self.cores) > + testcmd_start =3D testcmd % (self.coremask, self.memory_channel) > + > + 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(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.get_vm_coremask() > + self.vm_dut.send_expect(self.vm_testpmd_vector % self.vm_coremas= k, > "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("vhost queue < virtio queue") > + > + 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("vhost queue =3D virtio queue") > + > + 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 > + # > + if getattr(self, 'vhost_user', None): > + self.dut.close_session(self.vhost_user) > + self.vm.stop() > + time.sleep(2) > + > + def tear_down_all(self): > + """ > + Run after each test suite. > + """ > + pass > -- > 2.7.4