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 4400CA0096 for ; Wed, 5 Jun 2019 04:17:03 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 26F901B94F; Wed, 5 Jun 2019 04:17:03 +0200 (CEST) Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by dpdk.org (Postfix) with ESMTP id C31EF2A6A for ; Wed, 5 Jun 2019 04:17:00 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 04 Jun 2019 19:16:59 -0700 X-ExtLoop1: 1 Received: from fmsmsx104.amr.corp.intel.com ([10.18.124.202]) by orsmga001.jf.intel.com with ESMTP; 04 Jun 2019 19:16:59 -0700 Received: from fmsmsx116.amr.corp.intel.com (10.18.116.20) by fmsmsx104.amr.corp.intel.com (10.18.124.202) with Microsoft SMTP Server (TLS) id 14.3.408.0; Tue, 4 Jun 2019 19:16:59 -0700 Received: from shsmsx103.ccr.corp.intel.com (10.239.4.69) by fmsmsx116.amr.corp.intel.com (10.18.116.20) with Microsoft SMTP Server (TLS) id 14.3.408.0; Tue, 4 Jun 2019 19:16:58 -0700 Received: from shsmsx101.ccr.corp.intel.com ([169.254.1.10]) by SHSMSX103.ccr.corp.intel.com ([169.254.4.120]) with mapi id 14.03.0415.000; Wed, 5 Jun 2019 10:16:57 +0800 From: "Tu, Lijuan" To: "Ma, LihongX" , "dts@dpdk.org" CC: "Wang, Yinan" , "Ma, LihongX" Thread-Topic: [dts] [PATCH V1] tests: add testsuite vhost dequeue zero copy Thread-Index: AQHVFr8FhlMLJAIMp02avUyY1QUHJqaMW/xQ Date: Wed, 5 Jun 2019 02:16:56 +0000 Message-ID: <8CE3E05A3F976642AAB0F4675D0AD20E0BAA0586@SHSMSX101.ccr.corp.intel.com> References: <1559177256-17148-1-git-send-email-lihongx.ma@intel.com> In-Reply-To: <1559177256-17148-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: dlp-product: dlpe-windows dlp-version: 11.0.600.7 dlp-reaction: no-action x-ctpclassification: CTP_NT x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiMjE1MzgzMmEtYjc4Yi00OWU2LWFjOTEtN2Y4YWJjNjg1ODNiIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoibDBsMEcwdFE3N3ZnYzBLbWpsWDUxaE1CVkxhWFY5a0NzZFBjMjZWQklMd3EyWE9WQkdYQjZKeGQ2S2lzbTVNayJ9 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 testsuite vhost dequeue zero copy 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" Applied, thanks > -----Original Message----- > From: dts [mailto:dts-bounces@dpdk.org] On Behalf Of lihong > Sent: Thursday, May 30, 2019 8:48 AM > To: dts@dpdk.org > Cc: Wang, Yinan ; Ma, LihongX > > Subject: [dts] [PATCH V1] tests: add testsuite vhost dequeue zero copy >=20 > Signed-off-by: lihong > --- > tests/TestSuite_vhost_dequeue_zero_copy.py | 375 > +++++++++++++++++++++++++++++ > 1 file changed, 375 insertions(+) > create mode 100644 tests/TestSuite_vhost_dequeue_zero_copy.py >=20 > diff --git a/tests/TestSuite_vhost_dequeue_zero_copy.py > b/tests/TestSuite_vhost_dequeue_zero_copy.py > new file mode 100644 > index 0000000..596a23a > --- /dev/null > +++ b/tests/TestSuite_vhost_dequeue_zero_copy.py > @@ -0,0 +1,375 @@ > +# > +# BSD LICENSE > +# > +# Copyright(c) <2019> Intel Corporation. > +# 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 the performance of dequeue zero-copy. > +There are three topology test (PVP/VM2VM/VM2NIC) for this feature. > +And this testsuite implement the topology of PVP. > +Testsuite vm2vm_net_perf implement the topology VM2VM Testsuite gso > +implement the topology VM2NIC """ > +import utils > +import time > +import re > +from settings import HEADER_SIZE > +from virt_common import VM > +from test_case import TestCase > +from etgen import IxiaPacketGenerator > + > + > +class TestPVPQemuZeroCopy(TestCase, IxiaPacketGenerator): > + > + def set_up_all(self): > + """ > + Run at the start of each test suite. > + """ > + self.tester.extend_external_packet_generator(TestPVPQemuZeroCopy= , > self) > + self.frame_sizes =3D [64, 128, 256, 512, 1024, 1518] > + self.queue_number =3D 1 > + self.nb_cores =3D 1 > + self.dut_ports =3D self.dut.get_ports() > + self.verify(len(self.dut_ports) >=3D 1, "Insufficient ports for = testing") > + self.ports_socket =3D self.dut.get_numa_id(self.dut_ports[0]) > + self.cores_num =3D len([n for n in self.dut.cores if int(n['sock= et']) > + =3D=3D self.ports_socket]) > + self.mem_channels =3D self.dut.get_memory_channels() > + self.dst_mac =3D self.dut.get_mac_address(self.dut_ports[0]) > + self.vm_dut =3D None > + self.virtio1_mac =3D "52:54:00:00:00:01" > + > + self.logger.info("you can config packet_size in file %s.cfg," % > self.suite_name + \ > + "in region 'suite' like packet_sizes=3D[64, 128, 256= ]") > + # get the frame_sizes from cfg file > + if 'packet_sizes' in self.get_suite_cfg(): > + self.frame_sizes =3D self.get_suite_cfg()['packet_sizes'] > + > + def set_up(self): > + """ > + Run before each test case. > + """ > + # Clean the execution ENV > + self.dut.send_expect("killall -s INT testpmd", "#") > + self.dut.send_expect("killall -s INT qemu-system-x86_64", "#") > + self.dut.send_expect("rm -rf ./vhost-net*", "#") > + # Prepare the result table > + self.table_header =3D ["FrameSize(B)", "Throughput(Mpps)", > + "% linerate", "Queue number", "Cycle"] > + self.result_table_create(self.table_header) > + > + self.vhost =3D self.dut.new_session(suite=3D"vhost-user") > + > + def ip(self, port, frag, src, proto, tos, dst, chksum, len, > + options, version, flags, ihl, ttl, id): > + """ > + Configure IP protocol. > + """ > + self.add_tcl_cmd("protocol config -name ip") > + self.add_tcl_cmd('ip config -sourceIpAddr "%s"' % src) > + self.add_tcl_cmd('ip config -destIpAddrMode ipRandom') > + self.add_tcl_cmd("ip config -ttl %d" % ttl) > + self.add_tcl_cmd("ip config -totalLength %d" % len) > + self.add_tcl_cmd("ip config -fragment %d" % frag) > + self.add_tcl_cmd("ip config -ipProtocol %d" % proto) > + self.add_tcl_cmd("ip config -identifier %d" % id) > + self.add_tcl_cmd("stream config -framesize %d" % (len + 18)) > + self.add_tcl_cmd("ip set %d %d %d" % ( > + self.chasId, port['card'], port['port'])) > + > + def get_core_mask(self): > + """ > + check whether the server has enough cores to run case > + """ > + core_config =3D "1S/%dC/1T" % (self.nb_cores + 1) > + self.verify(self.cores_num >=3D (self.nb_cores + 1), > + "There has not enought cores to test this case %s" % > self.running_case) > + core_list =3D self.dut.get_core_list( > + core_config, socket=3Dself.ports_socket) > + self.core_mask =3D utils.create_mask(core_list) > + > + def launch_testpmd_on_vhost(self, txfreet): > + """ > + launch testpmd on vhost > + """ > + self.get_core_mask() > + > + if txfreet =3D=3D "normal": > + txfreet_args =3D "--txfreet=3D992" > + elif txfreet =3D=3D "maximum": > + txfreet_args =3D "--txfreet=3D1020 --txrs=3D4" > + command_client =3D self.dut.target + "/app/testpmd " + \ > + " -n %d -c %s --socket-mem 1024,1024 " + \ > + " --legacy-mem --file-prefix=3Dvhost " + \ > + " --vdev 'eth_vhost0,iface=3Dvhost-net,queues= =3D%d,dequeue- > zero-copy=3D1' " + \ > + " -- -i --nb-cores=3D%d --rxq=3D%d --txq=3D%d "= + \ > + "--txd=3D1024 --rxd=3D1024 %s" > + command_line_client =3D command_client % ( > + self.mem_channels, self.core_mask, > + self.queue_number, self.nb_cores, > + self.queue_number, self.queue_number, txfreet_args) > + self.vhost.send_expect(command_line_client, "testpmd> ", 120) > + self.vhost.send_expect("set fwd mac", "testpmd> ", 120) > + > + def launch_testpmd_on_vm(self): > + """ > + start testpmd in vm depend on different path > + """ > + command =3D self.dut.target + "/app/testpmd " + \ > + "-c 0x1f -n 3 -- -i " + \ > + "--nb-cores=3D%d --rxq=3D%d --txq=3D%d " + \ > + "--txd=3D1024 --rxd=3D1024" > + command_line =3D command % (self.nb_cores, > + self.queue_number, self.queue_number) > + self.vm_dut.send_expect(command_line, "testpmd> ", 30) > + > + def relaunch_testpmd_on_vm(self): > + self.vm_dut.send_expect("quit", "# ", 30) > + self.launch_testpmd_on_vm() > + self.vm_dut.send_expect("set fwd mac", "testpmd> ", 30) > + self.vm_dut.send_expect("start", "testpmd> ", 30) > + > + def set_vm_vcpu(self): > + """ > + config the vcpu numbers > + remove the cpupin param from vm_params > + when the cores in cpupin is the isolcpus, it will reduce the > + performance of dequeue zero copy > + And if we not use the cpupin params(taskset -c xxx), it will use > + the cpu which not set in isolcpus, and it number equal to the vc= pus > + """ > + params_number =3D len(self.vm.params) > + for i in range(params_number): > + if self.vm.params[i].keys()[0] =3D=3D 'cpu': > + if 'number' in self.vm.params[i]['cpu'][0].keys(): > + self.vm.params[i]['cpu'][0]['number'] =3D 5 > + if 'cpupin' in self.vm.params[i]['cpu'][0].keys(): > + self.vm.params[i]['cpu'][0].pop('cpupin') > + > + def start_one_vm(self): > + """ > + start qemu > + """ > + self.vm =3D VM(self.dut, 'vm0', 'vhost_sample') > + self.vm.load_config() > + vm_params =3D {} > + vm_params['driver'] =3D 'vhost-user' > + vm_params['opt_path'] =3D './vhost-net' > + vm_params['opt_mac'] =3D self.virtio1_mac > + opt_args =3D "mrg_rxbuf=3Don,rx_queue_size=3D1024,tx_queue_size= =3D1024" > + if self.queue_number > 1: > + vm_params['opt_queue'] =3D self.queue_number > + opt_args +=3D ",mq=3Don,vectors=3D%d" % (2*self.queue_number= + 2) > + vm_params['opt_settings'] =3D opt_args > + self.vm.set_vm_device(**vm_params) > + self.set_vm_vcpu() > + try: > + # Due to we have change the params info before, > + # so need to start vm with load_config=3DFalse > + self.vm_dut =3D self.vm.start(load_config=3DFalse) > + 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)) > + > + def update_table_info(self, frame_size, Mpps, throughtput, cycle): > + results_row =3D [frame_size] > + results_row.append(Mpps) > + results_row.append(throughtput) > + results_row.append(self.queue_number) > + results_row.append(cycle) > + self.result_table_add(results_row) > + > + def calculate_avg_throughput(self, frame_size, loopback): > + """ > + start to send packet and get the throughput > + """ > + payload =3D frame_size - HEADER_SIZE['eth'] - HEADER_SIZE['ip'] = - > HEADER_SIZE['udp'] > + flow =3D > '[Ether(dst=3D"%s")/IP(src=3D"192.168.4.1",proto=3D255)/UDP()/("X"*%d)]' = % ( > + self.dst_mac, payload) > + self.tester.scapy_append('wrpcap("zero_copy.pcap", %s)' % flow) > + self.tester.scapy_execute() > + > + tgenInput =3D [] > + port =3D self.tester.get_local_port(self.dut_ports[0]) > + tgenInput.append((port, port, "zero_copy.pcap")) > + _, pps =3D self.tester.traffic_generator_throughput(tgenInput, d= elay=3D30) > + Mpps =3D pps / 1000000.0 > + # when the fwd mode is rxonly, we can not receive data, so shoul= d not > verify it > + if loopback !=3D "rxonly": > + self.verify(Mpps > 0, "can not receive packets of frame size= %d" % > (frame_size)) > + throughput =3D Mpps * 100 / \ > + float(self.wirespeed(self.nic, frame_size, 1)) > + return Mpps, throughput > + > + def check_packets_of_each_queue(self, frame_size, loopback): > + """ > + check each queue has receive packets > + """ > + if loopback =3D=3D "rxonly": > + verify_port =3D 1 > + else: > + verify_port =3D 2 > + out =3D self.vhost.send_expect("stop", "testpmd> ", 60) > + for port_index in range(0, verify_port): > + for queue_index in range(0, self.queue_number): > + queue_info =3D re.findall("RX\s*Port=3D\s*%d/Queue=3D\s*= %d" % > + (port_index, queue_index), out) > + queue =3D queue_info[0] > + index =3D out.find(queue) > + rx =3D re.search("RX-packets:\s*(\d*)", out[index:]) > + tx =3D re.search("TX-packets:\s*(\d*)", out[index:]) > + rx_packets =3D int(rx.group(1)) > + tx_packets =3D int(tx.group(1)) > + self.verify(rx_packets > 0 and tx_packets > 0, > + "The queue %d rx-packets or tx-packets is 0 about = " % > + queue_index + \ > + "frame_size:%d, rx-packets:%d, tx-packets:%d" % > + (frame_size, rx_packets, tx_packets)) > + > + self.vhost.send_expect("start", "testpmd> ", 60) > + > + def send_and_verify(self, cycle=3D"", loopback=3D""): > + """ > + start to send packets and verify it > + """ > + for frame_size in self.frame_sizes: > + info =3D "Running test %s, and %d frame size." % (self.runni= ng_case, > frame_size) > + self.logger.info(info) > + > + Mpps, throughput =3D self.calculate_avg_throughput(frame_siz= e, > loopback) > + if loopback !=3D "rxonly": > + self.update_table_info(frame_size, Mpps, throughput, cyc= le) > + # when multi queues, check each queue can receive packets > + if self.queue_number > 1: > + self.check_packets_of_each_queue(frame_size, loopback) > + > + def close_all_testpmd_and_vm(self): > + """ > + close testpmd about vhost-user and vm_testpmd > + """ > + self.vhost.send_expect("quit", "#", 60) > + self.vm_dut.send_expect("quit", "#", 60) > + self.dut.close_session(self.vhost) > + self.vm.stop() > + > + def test_perf_pvp_dequeue_zero_copy(self): > + """ > + performance of pvp zero-copy with [frame_sizes] > + """ > + self.nb_cores =3D 1 > + self.queue_number =3D 1 > + self.launch_testpmd_on_vhost(txfreet=3D"normal") > + self.start_one_vm() > + self.launch_testpmd_on_vm() > + # set fwd mode on vm > + self.vm_dut.send_expect("set fwd mac", "testpmd> ", 30) > + self.vm_dut.send_expect("start", "testpmd> ", 30) > + # start testpmd at host side after VM and virtio-pmd launched > + self.vhost.send_expect("start", "testpmd> ", 120) > + self.send_and_verify() > + self.close_all_testpmd_and_vm() > + self.result_table_print() > + > + def test_perf_pvp_dequeue_zero_copy_with_2_queue(self): > + """ > + pvp dequeue zero-copy test with 2 queues > + """ > + self.nb_cores =3D 2 > + self.queue_number =3D 2 > + self.launch_testpmd_on_vhost(txfreet=3D"normal") > + self.start_one_vm() > + self.launch_testpmd_on_vm() > + # set fwd mode on vm > + self.vm_dut.send_expect("set fwd mac", "testpmd> ", 30) > + self.vm_dut.send_expect("start", "testpmd> ", 30) > + # start testpmd at host side after VM and virtio-pmd launched > + self.vhost.send_expect("start", "testpmd> ", 120) > + # when multi queues, the function will check each queue can rece= ive > packets > + self.send_and_verify() > + self.close_all_testpmd_and_vm() > + self.result_table_print() > + > + def test_perf_pvp_dequeue_zero_copy_with_driver_unload(self): > + """ > + pvp dequeue zero-copy test with driver unload test > + """ > + self.nb_cores =3D 4 > + self.queue_number =3D 16 > + self.launch_testpmd_on_vhost(txfreet=3D"normal") > + self.start_one_vm() > + self.launch_testpmd_on_vm() > + # set fwd mode on vm > + self.vm_dut.send_expect("set fwd rxonly", "testpmd> ", 30) > + self.vm_dut.send_expect("start", "testpmd> ", 30) > + # start testpmd at host side after VM and virtio-pmd launched > + self.vhost.send_expect("start", "testpmd> ", 120) > + # when multi queues, the function will check each queue can rece= ive > packets > + self.send_and_verify(cycle=3D"befor relaunch", loopback=3D"rxonl= y") > + > + # relaunch testpmd at virtio side in VM for driver reloading > + self.relaunch_testpmd_on_vm() > + self.send_and_verify(cycle=3D"after relaunch") > + self.close_all_testpmd_and_vm() > + self.result_table_print() > + > + def test_perf_pvp_dequeue_zero_copy_with_maximum_txfreet(self): > + """ > + pvp dequeue zero-copy test with maximum txfreet > + """ > + self.nb_cores =3D 4 > + self.queue_number =3D 16 > + self.launch_testpmd_on_vhost(txfreet=3D"maximum") > + self.start_one_vm() > + self.launch_testpmd_on_vm() > + # set fwd mode on vm > + self.vm_dut.send_expect("set fwd mac", "testpmd> ", 30) > + self.vm_dut.send_expect("start", "testpmd> ", 30) > + # start testpmd at host side after VM and virtio-pmd launched > + self.vhost.send_expect("start", "testpmd> ", 120) > + # when multi queues, the function will check each queue can rece= ive > packets > + self.send_and_verify() > + self.close_all_testpmd_and_vm() > + self.result_table_print() > + > + def tear_down(self): > + """ > + Run after each test case. > + """ > + self.dut.send_expect("killall -s INT testpmd", "#") > + self.dut.send_expect("killall -s INT qemu-system-x86_64", "#") > + time.sleep(2) > + > + def tear_down_all(self): > + """ > + Run after each test suite. > + """ > -- > 2.7.4