From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 5E5A2A00C5; Thu, 11 Jun 2020 14:39:59 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 560522C4F; Thu, 11 Jun 2020 14:39:59 +0200 (CEST) Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by dpdk.org (Postfix) with ESMTP id BF7322BFA for ; Thu, 11 Jun 2020 14:39:55 +0200 (CEST) IronPort-SDR: 9sffmCwy5FJrxy9QInxsyQLHLeCNXY09Y2W3BvsAqomjwHqotDy/P4cqVWLaG22zBP6F3Rp4w1 J4THrn/tVYJw== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Jun 2020 05:39:50 -0700 IronPort-SDR: 9FqrlZ5zwCFBV6ucyvzxSDg/sfbu2GDdle59pP134zVq1PoX3pe0bSy4T/bjcIRlajMT3eBmTC y0sMXOcRuvjw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,499,1583222400"; d="scan'208";a="306940870" Received: from fmsmsx107.amr.corp.intel.com ([10.18.124.205]) by fmsmga002.fm.intel.com with ESMTP; 11 Jun 2020 05:39:50 -0700 Received: from FMSMSX110.amr.corp.intel.com (10.18.116.10) by fmsmsx107.amr.corp.intel.com (10.18.124.205) with Microsoft SMTP Server (TLS) id 14.3.439.0; Thu, 11 Jun 2020 05:39:49 -0700 Received: from shsmsx104.ccr.corp.intel.com (10.239.4.70) by fmsmsx110.amr.corp.intel.com (10.18.116.10) with Microsoft SMTP Server (TLS) id 14.3.439.0; Thu, 11 Jun 2020 05:39:49 -0700 Received: from shsmsx101.ccr.corp.intel.com ([169.254.1.85]) by SHSMSX104.ccr.corp.intel.com ([10.239.4.70]) with mapi id 14.03.0439.000; Thu, 11 Jun 2020 20:39:46 +0800 From: "Tu, Lijuan" To: "Xiao, QimaiX" , "dts@dpdk.org" CC: "Xiao, QimaiX" Thread-Topic: [dts] [PATCH V1]perf_vm2vm_virtio_net_perf: add case perf_vm2vm_virtio_net_perf to dts Thread-Index: AQHWMmriNjY3V/GdTkCFRvt/y51WR6jTdexw Date: Thu, 11 Jun 2020 12:39:45 +0000 Message-ID: <8CE3E05A3F976642AAB0F4675D0AD20E0BC5BDB0@SHSMSX101.ccr.corp.intel.com> References: <1590393315-23987-1-git-send-email-qimaix.xiao@intel.com> In-Reply-To: <1590393315-23987-1-git-send-email-qimaix.xiao@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.2.0.6 dlp-reaction: no-action x-originating-ip: [10.239.127.40] Content-Type: text/plain; charset="iso-2022-jp" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dts] [PATCH V1]perf_vm2vm_virtio_net_perf: add case perf_vm2vm_virtio_net_perf to dts 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 On Behalf Of Xiao Qimai Sent: 2020=1B$BG/=1B(B5=1B$B7n=1B(B25=1B$BF|=1B(B 15:55 To: dts@dpdk.org Cc: Xiao, QimaiX Subject: [dts] [PATCH V1]perf_vm2vm_virtio_net_perf: add case perf_vm2vm_vi= rtio_net_perf to dts *. add case perf_vm2vm_virtio_net_perf Signed-off-by: Xiao Qimai --- tests/TestSuite_perf_vm2vm_virtio_net_perf.py | 365 ++++++++++++++++++++++= ++++ 1 file changed, 365 insertions(+) create mode 100644 tests/TestSuite_perf_vm2vm_virtio_net_perf.py diff --git a/tests/TestSuite_perf_vm2vm_virtio_net_perf.py b/tests/TestSuit= e_perf_vm2vm_virtio_net_perf.py new file mode 100644 index 0000000..532cdf7 --- /dev/null +++ b/tests/TestSuite_perf_vm2vm_virtio_net_perf.py @@ -0,0 +1,365 @@ +# BSD LICENSE +# +# Copyright(c) <2020> Intel Corporation. +# 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. + +vm2vm split ring and packed ring with tx offload (TSO and UFO) with non-me= rgeable path. +vm2vm split ring and packed ring with UFO about virtio-net device capabili= ty with non-mergeable path. +vm2vm split ring and packed ring vhost-user/virtio-net check the=20 +payload of large packet is valid with mergeable and non-mergeable dequeue = zero copy. +please use qemu version greater 4.1.94 which support packed feathur to tes= t this suite. +""" +import re +import os +import rst +import json +import time +import string +import random +from virt_common import VM +from test_case import TestCase +from pmd_output import PmdOutput +from settings import UPDATE_EXPECTED, load_global_setting from copy=20 +import deepcopy + + +class TestPerfVM2VMVirtioNetPerf(TestCase): + def set_up_all(self): + core_config =3D "1S/4C/1T" + self.cores_list =3D self.dut.get_core_list(core_config) + self.verify(len(self.cores_list) >=3D 4, + "There has not enough cores to test this suite %s" % + self.suite_name) + self.vm_num =3D 2 + self.virtio_ip1 =3D "1.1.1.2" + self.virtio_ip2 =3D "1.1.1.3" + self.vritio_mac1 =3D "52:54:00:00:00:01" + self.vritio_mac2 =3D "52:54:00:00:00:02" + self.base_dir =3D self.dut.base_dir.replace('~', '/root') + self.random_string =3D string.ascii_letters + string.digits + socket_num =3D len(set([int(core['socket']) for core in self.dut.c= ores])) + self.socket_mem =3D ','.join(['2048']*socket_num) + self.vhost =3D self.dut.new_session(suite=3D"vhost") + self.pmd_vhost =3D PmdOutput(self.dut, self.vhost) + self.json_obj =3D dict() + self.save_result_flag =3D True + + def set_up(self): + """ + run before each test case. + """ + self.dut.send_expect("rm -rf %s/vhost-net*" % self.base_dir, "#") + self.vm_dut =3D [] + self.vm =3D [] + self.gap =3D self.get_suite_cfg()['accepted_tolerance'] + self.test_duration =3D self.get_suite_cfg()['test_duration'] + self.test_parameter =3D self.get_suite_cfg()['test_parameters'] + self.test_result =3D {} + self.table_header =3D ['Mode', 'Type', 'TXD/RXD', 'Throughput', 'E= xpected Throughput', + 'Throughput Difference'] + + def handle_expected(self): + """ + Update expected numbers to configurate file: conf/$suite_name.cfg + """ + if load_global_setting(UPDATE_EXPECTED) =3D=3D "yes": + self.expected_throughput[self.test_parameter] =3D=20 + self.throughput + + def handle_results(self): + header =3D self.table_header + ret_data =3D {} + ret_data[header[0]] =3D 'vm2vm' + ret_data[header[1]] =3D 'iperf' + ret_data[header[2]] =3D self.test_parameter + ret_data[header[3]] =3D self.throughput + ret_data[header[4]] =3D self.expected_throughput[self.test_paramet= er] + expected =3D re.search('(.*\d)(\s?.+)', self.expected_throughput[s= elf.test_parameter]) + self.expected_data =3D float(expected.group(1)) + self.expect_unit =3D expected.group(2).strip() + self.verify(self.throughput_unit =3D=3D self.expect_unit, "data un= it not correct, expect: %s, result: %s" % (self.expect_unit, self.throughpu= t_unit)) + self.gap_data =3D round((self.throughput_data - self.expected_data= ), 3) + ret_data[header[5]] =3D str(self.gap_data) + ' ' + self.expect_uni= t + self.test_result =3D deepcopy(ret_data) + self.result_table_create(header) + self.result_table_add(list(self.test_result.values())) + # present test results to screen + self.result_table_print() + # save test results as a file + if self.save_result_flag: + self.save_result(self.test_result) + + def save_result(self, data): + ''' + Saves the test results as a separated file named with + self.nic+_perf_virtio_user_pvp.json in output folder + if self.save_result_flag is True + ''' + case_name =3D self.running_case + self.json_obj[case_name] =3D list() + status_result =3D [] + row_in =3D data + row_dict0 =3D dict() + row_dict0['performance'] =3D list() + row_dict0['parameters'] =3D list() + gap =3D self.expected_data * -float(self.gap) * 0.01 + + self.logger.info("Accept tolerance are %0.3f %s" % (gap, self.expe= ct_unit)) + self.logger.info("Throughput Difference are %0.3f %s" % (self.gap_= data, self.expect_unit)) + if self.throughput_data > self.expected_data + gap: + row_dict0['status'] =3D 'PASS' + else: + row_dict0['status'] =3D 'FAIL' + row_dict1 =3D dict(name=3D"Throughput", value=3Dself.throughput_da= ta, unit=3Dself.throughput_unit, delta=3Dself.gap_data) + row_dict2 =3D dict(name=3D"Txd/Rxd", value=3Drow_in["TXD/RXD"], un= it=3D"descriptor") + row_dict0['performance'].append(row_dict1) + row_dict0['parameters'].append(row_dict2) + self.json_obj[case_name].append(row_dict0) + status_result.append(row_dict0['status']) + with open(os.path.join(rst.path2Result, + '{0:s}_{1}.json'.format( + self.nic, self.suite_name)), 'w') as fp= : + json.dump(self.json_obj, fp) + + self.verify("FAIL" not in status_result, "Exceeded Gap") + + def start_vhost_testpmd(self, zerocopy=3DFalse): + """ + launch the testpmd with different parameters + """ + if zerocopy is True: + zerocopy_arg =3D ",dequeue-zero-copy=3D1" + else: + zerocopy_arg =3D "" + testcmd =3D self.dut.target + "/app/testpmd " + vdev1 =3D "--vdev 'net_vhost0,iface=3D%s/vhost-net0,queues=3D1%s' = " % (self.base_dir, zerocopy_arg) + vdev2 =3D "--vdev 'net_vhost1,iface=3D%s/vhost-net1,queues=3D1%s' = " % (self.base_dir, zerocopy_arg) + eal_params =3D self.dut.create_eal_parameters(cores=3Dself.cores_l= ist, prefix=3D'vhost', no_pci=3DTrue) + para =3D " -- -i --nb-cores=3D2 --txd=3D1024 --rxd=3D1024" + self.command_line =3D testcmd + eal_params + vdev1 + vdev2 + para + self.pmd_vhost.execute_cmd(self.command_line, timeout=3D30) + self.pmd_vhost.execute_cmd('start', timeout=3D30) + + def start_vms(self, mode=3D"mergeable", packed=3DFalse): + """ + start two VM, each VM has one virtio device + """ + setting_args =3D "mrg_rxbuf=3Doff,csum=3Don,guest_csum=3Don,host_t= so4=3Don,guest_tso4=3Don,guest_ecn=3Don" + if mode =3D=3D "ufo": + setting_args +=3D ",guest_ufo=3Don,host_ufo=3Don" + elif mode =3D=3D "mergeable": + setting_args =3D "mrg_rxbuf=3Don" + elif mode =3D=3D "normal": + setting_args =3D "mrg_rxbuf=3Doff" + if packed is True: + setting_args =3D "%s,packed=3Don" % setting_args + + for i in range(self.vm_num): + vm_dut =3D None + vm_info =3D VM(self.dut, 'vm%d' % i, 'vhost_sample') + vm_params =3D {} + vm_params['driver'] =3D 'vhost-user' + vm_params['opt_path'] =3D self.base_dir + '/vhost-net%d' % i + vm_params['opt_mac'] =3D "52:54:00:00:00:0%d" % (i+1) + vm_params['opt_settings'] =3D setting_args + vm_info.set_vm_device(**vm_params) + time.sleep(3) + try: + vm_dut =3D vm_info.start(set_target=3DFalse) + if vm_dut is None: + raise Exception("Set up VM ENV failed") + except Exception as e: + self.logger.error("Failure for %s" % str(e)) + raise e + vm_dut.restore_interfaces() + + self.vm_dut.append(vm_dut) + self.vm.append(vm_info) + + def config_vm_env(self): + """ + set virtio device IP and run arp protocal + """ + vm1_intf =3D self.vm_dut[0].ports_info[0]['intf'] + vm2_intf =3D self.vm_dut[1].ports_info[0]['intf'] + self.vm_dut[0].send_expect("ifconfig %s %s" % (vm1_intf, self.virt= io_ip1), "#", 10) + self.vm_dut[1].send_expect("ifconfig %s %s" % (vm2_intf, self.virt= io_ip2), "#", 10) + self.vm_dut[0].send_expect("arp -s %s %s" % (self.virtio_ip2, self= .vritio_mac2), "#", 10) + self.vm_dut[1].send_expect("arp -s %s %s" % (self.virtio_ip1,=20 + self.vritio_mac1), "#", 10) + + def prepare_test_env(self, zerocopy, path_mode, packed_mode=3DFalse): + """ + start vhost testpmd and qemu, and config the vm env + """ + self.start_vhost_testpmd(zerocopy) + self.start_vms(mode=3Dpath_mode, packed=3Dpacked_mode) + self.config_vm_env() + + def start_iperf(self, mode): + """ + run perf command between to vms + """ + # clear the port xstats before iperf + self.vhost.send_expect("clear port xstats all", "testpmd> ",=20 + 10) + + if mode =3D=3D "ufo": + iperf_server =3D "iperf -s -u -i 1" + iperf_client =3D "iperf -c 1.1.1.2 -i 1 -t %s -P 4 -u -b 1G -l= 9000" % self.test_duration + else: + iperf_server =3D "iperf -s -i 1" + iperf_client =3D "iperf -c 1.1.1.2 -i 1 -t %s" % self.test_dur= ation + self.vm_dut[0].send_expect("%s > iperf_server.log &" % iperf_serve= r, "", 10) + self.vm_dut[1].send_expect("%s > iperf_client.log &" % iperf_clien= t, "", 60) + time.sleep(int(self.test_duration)+3) + + def get_perf_result(self): + """ + get the iperf test result + """ + self.vm_dut[0].send_expect('pkill iperf', '# ') + self.vm_dut[1].session.copy_file_from("%s/iperf_client.log" % self= .dut.base_dir) + fp =3D open("./iperf_client.log") + fmsg =3D fp.read() + fp.close() + # remove the server report info from msg + index =3D fmsg.find("Server Report") + if index !=3D -1: + fmsg =3D fmsg[:index] + iperfdata =3D re.compile('\s(\d+\.\d+)\s([MG]bits/sec)').findall(f= msg) + # the last data of iperf is the ave data from 0-30 sec + self.verify(len(iperfdata) !=3D 0, "The iperf data between to vms = is 0") + self.throughput_unit =3D iperfdata[-1][1] + self.throughput_data =3D round(float(iperfdata[-1][0]), 3) + self.throughput =3D str(self.throughput_data) + ' ' + self.through= put_unit + self.logger.info("The iperf data between vms is %s" %=20 + self.throughput) + + # rm the iperf log file in vm + self.vm_dut[0].send_expect('rm iperf_server.log', '#', 10) + self.vm_dut[1].send_expect('rm iperf_client.log', '#', 10) + + def verify_xstats_info_on_vhost(self): + """ + check both 2VMs can receive and send big packets to each other + """ + out_tx =3D self.vhost.send_expect("show port xstats 0", "testpmd> = ", 20) + out_rx =3D self.vhost.send_expect("show port xstats 1", "testpmd>= =20 + ", 20) + + rx_info =3D re.search("rx_size_1523_to_max_packets:\s*(\d*)", out_= rx) + tx_info =3D re.search("tx_size_1523_to_max_packets:\s*(\d*)",=20 + out_tx) + + self.verify(int(rx_info.group(1)) > 0, + "Port 1 not receive packet greater than 1522") + self.verify(int(tx_info.group(1)) > 0, + "Port 0 not forward packet greater than 1522") + + def start_iperf_and_verify_vhost_xstats_info(self, mode): + """ + start to send packets and verify vm can received data of iperf + and verify the vhost can received big pkts in testpmd + """ + self.start_iperf(mode) + self.get_perf_result() + self.verify_xstats_info_on_vhost() + + def stop_all_apps(self): + for i in range(len(self.vm)): + self.vm[i].stop() + self.pmd_vhost.quit() + + def test_vm2vm_split_ring_iperf_with_tso(self): + """ + VM2VM split ring vhost-user/virtio-net test with tcp traffic + """ + zerocopy =3D False + path_mode =3D "tso" + self.test_target =3D "split_tso" + self.expected_throughput =3D self.get_suite_cfg()['expected_throug= hput'][self.test_target] + self.prepare_test_env(zerocopy, path_mode) + self.start_iperf_and_verify_vhost_xstats_info(mode=3D"tso") + self.handle_expected() + self.handle_results() + + def test_vm2vm_split_ring_dequeue_zero_copy_iperf_with_tso(self): + """ + VM2VM split ring vhost-user/virtio-net zero copy test with tcp tra= ffic + """ + zerocopy =3D True + path_mode =3D "tso" + self.test_target =3D "split_zero_copy_tso" + self.expected_throughput =3D self.get_suite_cfg()['expected_throug= hput'][self.test_target] + self.prepare_test_env(zerocopy, path_mode) + self.start_iperf_and_verify_vhost_xstats_info(mode=3D"tso") + self.handle_expected() + self.handle_results() + + def test_vm2vm_packed_ring_iperf_with_tso(self): + """ + VM2VM packed ring vhost-user/virtio-net test with tcp traffic + """ + zerocopy =3D False + path_mode =3D "tso" + self.test_target =3D "packed_tso" + self.expected_throughput =3D self.get_suite_cfg()['expected_throug= hput'][self.test_target] + packed_mode =3D True + self.prepare_test_env(zerocopy, path_mode, packed_mode) + self.start_iperf_and_verify_vhost_xstats_info(mode=3D"tso") + self.handle_expected() + self.handle_results() + + def test_vm2vm_packed_ring_dequeue_zero_copy_iperf_with_tso(self): + """ + VM2VM packed ring vhost-user/virtio-net zero copy test with tcp tr= affic + """ + zerocopy =3D True + path_mode =3D "tso" + packed_mode =3D True + self.test_target =3D "packed_zero_copy_tso" + self.expected_throughput =3D self.get_suite_cfg()['expected_throug= hput'][self.test_target] + self.prepare_test_env(zerocopy, path_mode, packed_mode) + self.start_iperf_and_verify_vhost_xstats_info(mode=3D"tso") + self.handle_expected() + self.handle_results() + + def tear_down(self): + """ + run after each test case. + """ + self.stop_all_apps() + self.dut.kill_all() + time.sleep(2) + + def tear_down_all(self): + """ + Run after each test suite. + + """ + if getattr(self, 'vhost', None): + self.dut.close_session(self.vhost) -- 1.8.3.1