From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by dpdk.org (Postfix) with ESMTP id B1F5F2BDF for ; Mon, 19 Mar 2018 09:34:19 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 19 Mar 2018 01:34:17 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.48,329,1517904000"; d="scan'208";a="25663018" Received: from fmsmsx106.amr.corp.intel.com ([10.18.124.204]) by fmsmga008.fm.intel.com with ESMTP; 19 Mar 2018 01:34:17 -0700 Received: from fmsmsx122.amr.corp.intel.com (10.18.125.37) by FMSMSX106.amr.corp.intel.com (10.18.124.204) with Microsoft SMTP Server (TLS) id 14.3.319.2; Mon, 19 Mar 2018 01:34:17 -0700 Received: from shsmsx151.ccr.corp.intel.com (10.239.6.50) by fmsmsx122.amr.corp.intel.com (10.18.125.37) with Microsoft SMTP Server (TLS) id 14.3.319.2; Mon, 19 Mar 2018 01:34:17 -0700 Received: from shsmsx103.ccr.corp.intel.com ([169.254.4.235]) by SHSMSX151.ccr.corp.intel.com ([169.254.3.108]) with mapi id 14.03.0319.002; Mon, 19 Mar 2018 16:34:15 +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: AQHTvDkZtbnGxPlsGkmjlWSpbCCpKaPXPDbQ Date: Mon, 19 Mar 2018 08:34:15 +0000 Message-ID: <86228AFD5BCD8E4EBFD2B90117B5E81E62FC5D1F@SHSMSX103.ccr.corp.intel.com> References: <1587408514-20037-1-git-send-email-lihongx.ma@intel.com> In-Reply-To: <1587408514-20037-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: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiNjk3NmI3ZjYtOWJmMS00MmUwLTk2MzMtOTZiOGJjYjZlZmJjIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjIuNS4xOCIsIlRydXN0ZWRMYWJlbEhhc2giOiI2cW96ZXdiZVh1RHJUY293WWUyendcL3NCaGZ4ajdpWFJ5SkNQZlZBWFlCQTJDdktjSTY2NE9VdWJkbGVpZFIweiJ9 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: Mon, 19 Mar 2018 08:34:20 -0000 Thanks, lihong. Some comments are inline. > -----Original Message----- > From: dts [mailto:dts-bounces@dpdk.org] On Behalf Of lihong > Sent: Tuesday, April 21, 2020 2:49 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 | 320 > ++++++++++++++++++++++++++++++ > 1 file changed, 320 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..0654842 > --- /dev/null > +++ b/tests/TestSuite_vhost_multi_queue_qemu.py > @@ -0,0 +1,320 @@ > +# 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 test_case import TestCase > +from settings import HEADER_SIZE > +from virt_common import VM > +from packet import Packet,send_packets,save_packets > + > + > +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(len(self.cores) >=3D 3, "Insufficient cores for spee= d > testing") > + > + 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.dut.send_expect(testcmd_start, "testpmd> ", 120) > + self.dut.send_expect("set fwd mac", "testpmd> ", 120) > + self.dut.send_expect("start", "testpmd> ", 120) > + > + def start_onevm(self, path=3D""): > + """ > + Start One VM with one virtio device > + """ Look like argument path is useless in this suite. Better approach for chang= ing qemu path is from configuration file. > + 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= %d' % > (2*self.queue_number + 2) > + > + 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(len(cores) >=3D 3, "Insufficient cores for speed > testing, add the cpu number in cfg file.") > + 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 > + """ Function name look strange for me, you can use name 'vhost_performance' if = you are measuring vhost performance. Look like argument tag is useless, you can just use hard-coded title for pe= rformance table. > + 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 [] > + > + pkt1 =3D Packet() > + pkt1.assign_layers(['ether', 'ipv4', 'udp', 'raw']) > + pkt1.config_layers([('ether', {'dst': '%s' % > self.virtio1_mac}), ('ipv4', {'dst': '1.1.1.1'}), > + ('udp', {'src': 4789, 'dst': 4789}), > ('raw', {'payload': ['01'] * int('%d' % payload_size)})]) > + pkt2 =3D Packet() > + pkt2.assign_layers(['ether', 'ipv4', 'udp', 'raw']) > + pkt2.config_layers([('ether', {'dst': '%s' % > self.virtio1_mac}), ('ipv4', {'dst': '1.1.1.20'}), > + ('udp', {'src': 4789, 'dst': 4789}), ('raw= ', > {'payload': ['01'] * int('%d' % payload_size)})]) > + pkt3 =3D Packet() > + pkt3.assign_layers(['ether', 'ipv4', 'udp', 'raw']) > + pkt3.config_layers([('ether', {'dst': '%s' % > self.virtio1_mac}), ('ipv4', {'dst': '1.1.1.7'}), > + ('udp', {'src': 4789, 'dst': 4789}), > ('raw', {'payload': ['01'] * int('%d' % payload_size)})]) > + pkt4 =3D Packet() > + pkt4.assign_layers(['ether', 'ipv4', 'udp', 'raw']) > + pkt4.config_layers([('ether', {'dst': '%s' % > self.virtio1_mac}), ('ipv4', {'dst': '1.1.1.8'}), > + ('udp', {'src': 4789, 'dst': 4789}), > ('raw', {'payload': ['01'] * int('%d' % payload_size)})]) > + > + pkt =3D [pkt1, pkt2, pkt3, pkt4] > + save_packets(pkt, "/root/multiqueue_2.pcap") > + > + 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)=09 > + 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)=09 > + self.verify(Mpps !=3D 0, "The recive data of frame-size: %d = is > 0" % frame_size) Typo here, recive should be "receive".=20 > + self.result_table_print() > + > + def send_scapy(self, verify_type): > + """ > + Verify the virtio-pmd can recive the data before/after change > queue size > + """ The naming of this function can't stand for what it is done. You can change= name like "send_and_verify".=20 You'd better to describe all kinds of verify_type in function description.= =20 > + for frame_size in self.frame_sizes: > + self.dut.send_expect("clear port stats all", "testpmd> ", 12= 0) > + payload_size =3D frame_size - HEADER_SIZE['eth'] - > HEADER_SIZE['ip'] - HEADER_SIZE['udp'] > + > + > + pkt1 =3D Packet() > + pkt1.assign_layers(['ether', 'ipv4', 'udp', 'raw']) > + pkt1.config_layers([('ether', {'dst': '%s' % > self.virtio1_mac}), ('ipv4', {'dst': '1.1.1.1'}), > + ('udp', {'src': 4789, 'dst': 4789}), > ('raw', {'payload': ['01'] * int('%d' % payload_size)})]) > + pkt2 =3D Packet() > + pkt2.assign_layers(['ether', 'ipv4', 'udp', 'raw']) > + pkt2.config_layers([('ether', {'dst': '%s' % > self.virtio1_mac}), ('ipv4', {'dst': '1.1.1.20'}), > + ('udp', {'src': 4789, 'dst': 4789}), ('raw= ', > {'payload': ['01'] * int('%d' % payload_size)})]) > + pkt3 =3D Packet() > + pkt3.assign_layers(['ether', 'ipv4', 'udp', 'raw']) > + pkt3.config_layers([('ether', {'dst': '%s' % > self.virtio1_mac}), ('ipv4', {'dst': '1.1.1.7'}), > + ('udp', {'src': 4789, 'dst': 4789}), > ('raw', {'payload': ['01'] * int('%d' % payload_size)})]) > + pkt4 =3D Packet() > + pkt4.assign_layers(['ether', 'ipv4', 'udp', 'raw']) > + pkt4.config_layers([('ether', {'dst': '%s' % > self.virtio1_mac}), ('ipv4', {'dst': '1.1.1.8'}), > + ('udp', {'src': 4789, 'dst': 4789}), > ('raw', {'payload': ['01'] * int('%d' % payload_size)})]) > + > + pkt =3D [pkt1, pkt2, pkt3, pkt4]*10 Need space between "*", you can check code style by pep8 command. > + send_packets(self.tx_interface, pkt) > + > + out =3D self.dut.send_expect("show port stats 0", "testpmd> = ", > 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 veri= fy_type > =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 > + Should tx and rx number be equaled?=20 > + self.verify(rx_num >=3D verify_rx_num and tx_num >=3D > verify_tx_num, > + "The rx or tx lost some packets of frame- > size:%d" % frame_size) > + > + 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.dut.send_expect("stop", "testpmd> ", 120) > + self.dut.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.dut.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.dut.send_expect("stop", "testpmd> ", 120) > + self.dut.send_expect("start", "testpmd> ", 120) > + > + self.dut.send_expect("clear port stats all", "testpmd> ", 120) > + self.send_scapy("vhost queue =3D virtio queue") > + > + self.vm_dut.kill_all() > + self.dut.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.dut.send_expect(testcmd_start, "testpmd> ", 120) > + self.dut.send_expect("set fwd mac", "testpmd> ", 120) > + self.dut.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.dut.send_expect("clear port stats all", "testpmd> ", 120) > + > + self.send_scapy("vhost queue < virtio queue") > + > + self.dut.send_expect("stop", "testpmd>", 20) > + self.dut.send_expect("port stop all", "testpmd>") > + self.dut.send_expect("port config all rxq 2", "testpmd>", 20) > + self.dut.send_expect("port config all txq 2", "testpmd>") > + self.dut.send_expect("port start all", "testpmd>", 20) > + self.dut.send_expect("start", "testpmd>") > + self.dut.send_expect("clear port stats all", "testpmd>") > + > + self.send_scapy("vhost queue =3D virtio queue") > + > + self.vm_dut.kill_all() > + self.dut.send_expect("quit", "# ", 120) > + > + def tear_down(self): > + """ > + Run after each test case. > + Clear vhost-switch and qemu to avoid blocking the following TCs > + """ > + self.vm.stop() > + time.sleep(2) > + > + def tear_down_all(self): > + """ > + Run after each test suite. > + """ > + pass > -- > 2.7.4