From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (xvm-189-124.dc0.ghst.net [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id D74F8A09FF; Thu, 7 Jan 2021 03:42:25 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id CF91A140E6C; Thu, 7 Jan 2021 03:42:25 +0100 (CET) Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by mails.dpdk.org (Postfix) with ESMTP id 520A5140E49 for ; Thu, 7 Jan 2021 03:42:23 +0100 (CET) IronPort-SDR: OXH6YRQJ1OwJjHZE5j7YSJnyc8V8roh7PJYCJyCVDSey4OLaYPTO8a16huUMvoQt/5QaC5uXfQ NVwn1Vr02u4w== X-IronPort-AV: E=McAfee;i="6000,8403,9856"; a="164435096" X-IronPort-AV: E=Sophos;i="5.79,328,1602572400"; d="scan'208";a="164435096" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Jan 2021 18:42:21 -0800 IronPort-SDR: Nw2g24IOzNKa1gTEVwGvNMBYcraPuQe7Oh9+hLyF2m18gTewggwb15A3WH/yYV78N3jLR913cW cwgXfSPWoxyg== X-IronPort-AV: E=Sophos;i="5.79,328,1602572400"; d="scan'208";a="351097627" Received: from unknown (HELO localhost.localdomain) ([10.240.183.222]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Jan 2021 18:42:20 -0800 From: Ling Wei To: dts@dpdk.org Cc: Ling Wei Date: Thu, 7 Jan 2021 10:35:07 +0000 Message-Id: <20210107103507.3793974-1-weix.ling@intel.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Subject: [dts] [PATCH V1] tests/vswitch_sample_cbdma:add test suite sync with test plan X-BeenThere: dts@dpdk.org X-Mailman-Version: 2.1.29 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" add test suite sync with test plan Signed-off-by: Ling Wei --- tests/TestSuite_vswitch_sample_cbdma.py | 625 ++++++++++++++++++++++++ 1 file changed, 625 insertions(+) create mode 100644 tests/TestSuite_vswitch_sample_cbdma.py diff --git a/tests/TestSuite_vswitch_sample_cbdma.py b/tests/TestSuite_vswi= tch_sample_cbdma.py new file mode 100644 index 00000000..f0b8330c --- /dev/null +++ b/tests/TestSuite_vswitch_sample_cbdma.py @@ -0,0 +1,625 @@ +# BSD LICENSE=0D +#=0D +# Copyright(c) <2019> Intel Corporation. All rights reserved.=0D +# All rights reserved.=0D +#=0D +# Redistribution and use in source and binary forms, with or without=0D +# modification, are permitted provided that the following conditions=0D +# are met:=0D +#=0D +# * Redistributions of source code must retain the above copyright=0D +# notice, this list of conditions and the following disclaimer.=0D +# * Redistributions in binary form must reproduce the above copyright=0D +# notice, this list of conditions and the following disclaimer in=0D +# the documentation and/or other materials provided with the=0D +# distribution.=0D +# * Neither the name of Intel Corporation nor the names of its=0D +# contributors may be used to endorse or promote products derived=0D +# from this software without specific prior written permission.=0D +#=0D +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS=0D +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT=0D +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR=0D +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT=0D +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,=0D +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT=0D +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,=0D +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY=0D +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT=0D +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE=0D +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.=0D +=0D +"""=0D +DPDK Test suite.=0D +"""=0D +=0D +import utils=0D +import re=0D +import time=0D +import os=0D +from test_case import TestCase=0D +from packet import Packet=0D +from pktgen import PacketGeneratorHelper=0D +from pmd_output import PmdOutput=0D +from virt_common import VM=0D +=0D +=0D +class TestVswitchSampleCBDMA(TestCase):=0D +=0D + def set_up_all(self):=0D + """=0D + Run at the start of each test suite.=0D + """=0D + self.set_max_queues(512)=0D + self.dut_ports =3D self.dut.get_ports()=0D + self.verify(len(self.dut_ports) >=3D 1, "Insufficient ports for te= sting")=0D + self.tester_tx_port_num =3D 1=0D + self.ports_socket =3D self.dut.get_numa_id(self.dut_ports[0])=0D + self.dut_ports =3D self.dut.get_ports()=0D + self.socket =3D self.dut.get_numa_id(self.dut_ports[0])=0D + self.cores =3D self.dut.get_core_list("all", socket=3Dself.socket)= =0D + self.vhost_core_list =3D self.cores[0:2]=0D + self.vuser0_core_list =3D self.cores[2:4]=0D + self.vuser1_core_list =3D self.cores[4:6]=0D + self.vhost_core_mask =3D utils.create_mask(self.vhost_core_list)=0D + self.mem_channels =3D self.dut.get_memory_channels()=0D + # get cbdma device=0D + self.cbdma_dev_infos =3D []=0D + self.dmas_info =3D None=0D + self.device_str =3D None=0D + self.out_path =3D '/tmp'=0D + out =3D self.tester.send_expect('ls -d %s' % self.out_path, '# ')= =0D + if 'No such file or directory' in out:=0D + self.tester.send_expect('mkdir -p %s' % self.out_path, '# ')=0D + self.base_dir =3D self.dut.base_dir.replace('~', '/root')=0D + txport =3D self.tester.get_local_port(self.dut_ports[0])=0D + self.txItf =3D self.tester.get_interface(txport)=0D + self.virtio_dst_mac0 =3D '00:11:22:33:44:10'=0D + self.virtio_dst_mac1 =3D '00:11:22:33:44:11'=0D + self.vm_dst_mac0 =3D '52:54:00:00:00:01'=0D + self.vm_dst_mac1 =3D '52:54:00:00:00:02'=0D + self.vm_num =3D 2=0D + self.vm_dut =3D []=0D + self.vm =3D []=0D + self.app_testpmd_path =3D self.dut.apps_name['test-pmd']=0D + # create an instance to set stream field setting=0D + self.pktgen_helper =3D PacketGeneratorHelper()=0D +=0D +=0D + def set_up(self):=0D + """=0D + Run before each test case.=0D + """=0D + self.dut.send_expect("rm -rf %s/vhost-net*" % self.base_dir, "#")= =0D + self.dut.send_expect("killall -I qemu-system-x86_64", '#', 20)=0D + self.vhost_user =3D self.dut.new_session(suite=3D"vhost-user")=0D + self.virtio_user0 =3D self.dut.new_session(suite=3D"virtio-user0")= =0D + self.virtio_user1 =3D self.dut.new_session(suite=3D"virtio-user1")= =0D + self.virtio_user0_pmd =3D PmdOutput(self.dut, self.virtio_user0)=0D + self.virtio_user1_pmd =3D PmdOutput(self.dut, self.virtio_user1)=0D +=0D + def set_async_threshold(self, async_threshold=3D256):=0D + self.logger.info("Configure async_threshold to {}".format(async_th= reshold))=0D + self.dut.send_expect("sed -i -e 's/f.async_threshold =3D .*$/f.asy= nc_threshold =3D {};/' "=0D + "./examples/vhost/main.c".format(async_thresh= old), "#", 20)=0D +=0D + def set_max_queues(self, max_queues=3D512):=0D + self.logger.info("Configure MAX_QUEUES to {}".format(max_queues))= =0D + self.dut.send_expect("sed -i -e 's/#define MAX_QUEUES .*$/#define = MAX_QUEUES {}/' "=0D + "./examples/vhost/main.c".format(max_queues),= "#", 20)=0D +=0D + def build_vhost_app(self):=0D + out =3D self.dut.build_dpdk_apps('./examples/vhost')=0D + self.verify('Error' not in out, 'compilation vhost error')=0D +=0D + @property=0D + def check_2M_env(self):=0D + out =3D self.dut.send_expect("cat /proc/meminfo |grep Hugepagesize= |awk '{print($2)}'", "# ")=0D + return True if out =3D=3D '2048' else False=0D +=0D + def start_vhost_app(self, with_cbdma=3DTrue, cbdma_num=3D1, socket_num= =3D1, client_mode=3DFalse):=0D + """=0D + launch the vhost app on vhost side=0D + """=0D + self.app_path =3D self.dut.apps_name['vhost']=0D + socket_file_param =3D ''=0D + for item in range(socket_num):=0D + socket_file_param +=3D '--socket-file ./vhost-net{} '.format(i= tem)=0D + allow_pci =3D [self.dut.ports_info[0]['pci']]=0D + for item in range(cbdma_num):=0D + allow_pci.append(self.cbdma_dev_infos[item])=0D + allow_option =3D ''=0D + for item in allow_pci:=0D + allow_option +=3D ' -a {}'.format(item)=0D + if with_cbdma:=0D + if client_mode:=0D + params =3D (" -c {} -n {} {} -- -p 0x1 --mergeable 1 --vm2= vm 1 --dma-type ioat --stats 1 "=0D + + socket_file_param + "--dmas [{}] --client").fo= rmat(self.vhost_core_mask, self.mem_channels,=0D + = allow_option, self.dmas_info)=0D + else:=0D + params =3D (" -c {} -n {} {} -- -p 0x1 --mergeable 1 --vm2= vm 1 --dma-type ioat --stats 1 "=0D + + socket_file_param + "--dmas [{}]").format(self= .vhost_core_mask, self.mem_channels,=0D + allo= w_option, self.dmas_info)=0D + else:=0D + params =3D (" -c {} -n {} {} -- -p 0x1 --mergeable 1 --vm2vm 1= --stats 1 " + socket_file_param).format(=0D + self.vhost_core_mask, self.mem_channels, allow_option)=0D + self.command_line =3D self.app_path + params=0D + self.vhost_user.send_command(self.command_line)=0D + # After started dpdk-vhost app, wait 3 seconds=0D + time.sleep(3)=0D +=0D + def start_virtio_testpmd(self, pmd_session, dev_mac, dev_id, cores, pr= efix, enable_queues=3D1, server_mode=3DFalse,=0D + nb_cores=3D1, used_queues=3D1):=0D + """=0D + launch the testpmd as virtio with vhost_net0=0D + """=0D + if server_mode:=0D + eal_params =3D " --vdev=3Dnet_virtio_user0,mac=3D{},path=3D./v= host-net{},queues=3D{},server=3D1".format(dev_mac, dev_id,=0D + = enable_queues)=0D + else:=0D + eal_params =3D " --vdev=3Dnet_virtio_user0,mac=3D{},path=3D./v= host-net{},queues=3D{}".format(dev_mac, dev_id,=0D + = enable_queues)=0D + if self.check_2M_env:=0D + eal_params +=3D " --single-file-segments"=0D + params =3D "--nb-cores=3D{} --rxq=3D{} --txq=3D{} --txd=3D1024 --r= xd=3D1024".format(nb_cores, used_queues, used_queues)=0D + pmd_session.start_testpmd(cores=3Dcores, param=3Dparams, eal_param= =3Deal_params, no_pci=3DTrue, ports=3D[], prefix=3Dprefix,=0D + fixed_prefix=3DTrue)=0D +=0D + def start_vms(self, mode=3D0, mergeable=3DTrue):=0D + """=0D + start two VM, each VM has one virtio device=0D + """=0D + if mode =3D=3D 0:=0D + setting_args =3D "disable-modern=3Dtrue"=0D + elif mode =3D=3D 1:=0D + setting_args =3D "disable-modern=3Dfalse"=0D + elif mode =3D=3D 2:=0D + setting_args =3D "disable-modern=3Dfalse,packed=3Don"=0D + if mergeable is True:=0D + setting_args +=3D "," + "mrg_rxbuf=3Don"=0D + else:=0D + setting_args +=3D "," + "mrg_rxbuf=3Doff"=0D + setting_args +=3D ",csum=3Don,gso=3Don,guest_csum=3Don,host_tso4= =3Don,guest_tso4=3Don,guest_ecn=3Don"=0D +=0D + for i in range(self.vm_num):=0D + vm_dut =3D None=0D + vm_info =3D VM(self.dut, 'vm%d' % i, 'vhost_sample')=0D + vm_params =3D {}=0D + vm_params['driver'] =3D 'vhost-user'=0D + vm_params['opt_path'] =3D self.base_dir + '/vhost-net%d' % i=0D + vm_params['opt_mac'] =3D "52:54:00:00:00:0%d" % (i+1)=0D + vm_params['opt_settings'] =3D setting_args=0D + vm_info.set_vm_device(**vm_params)=0D + time.sleep(3)=0D + try:=0D + vm_dut =3D vm_info.start()=0D + if vm_dut is None:=0D + raise Exception("Set up VM ENV failed")=0D + except Exception as e:=0D + print((utils.RED("Failure for %s" % str(e))))=0D + raise e=0D + self.vm_dut.append(vm_dut)=0D + self.vm.append(vm_info)=0D +=0D + def start_vm_testpmd(self, pmd_session):=0D + """=0D + launch the testpmd in vm=0D + """=0D + self.vm_cores =3D [1,2]=0D + param =3D "--rxq=3D1 --txq=3D1 --nb-cores=3D1 --txd=3D1024 --rxd= =3D1024"=0D + pmd_session.start_testpmd(cores=3Dself.vm_cores, param=3Dparam)=0D +=0D + def repeat_bind_driver(self, dut, repeat_times=3D50):=0D + i =3D 0=0D + while i < repeat_times:=0D + dut.unbind_interfaces_linux()=0D + dut.bind_interfaces_linux(driver=3D'virtio-pci')=0D + dut.bind_interfaces_linux(driver=3D'vfio-pci')=0D + i +=3D 1=0D +=0D + def get_cbdma_ports_info_and_bind_to_dpdk(self, cbdma_num):=0D + """=0D + get all cbdma ports=0D + """=0D + str_info =3D 'Misc (rawdev) devices using kernel driver'=0D + out =3D self.dut.send_expect('./usertools/dpdk-devbind.py --status= -dev misc', '# ', 30)=0D + device_info =3D out.split('\n')=0D + for device in device_info:=0D + pci_info =3D re.search('\s*(0000:\d*:\d*.\d*)', device)=0D + if pci_info is not None:=0D + dev_info =3D pci_info.group(1)=0D + # the numa id of ioat dev, only add the device which on sa= me socket with nic dev=0D + bus =3D int(dev_info[5:7], base=3D16)=0D + if bus >=3D 128:=0D + cur_socket =3D 1=0D + else:=0D + cur_socket =3D 0=0D + if self.ports_socket =3D=3D cur_socket:=0D + self.cbdma_dev_infos.append(pci_info.group(1))=0D + self.verify(len(self.cbdma_dev_infos) >=3D cbdma_num, 'There no en= ough cbdma device to run this suite')=0D + used_cbdma =3D self.cbdma_dev_infos[0:cbdma_num]=0D + dmas_info =3D ''=0D + for dmas in used_cbdma:=0D + number =3D used_cbdma.index(dmas)=0D + dmas =3D 'txd{}@{},'.format(number, dmas.replace('0000:', ''))= =0D + dmas_info +=3D dmas=0D + self.dmas_info =3D dmas_info[:-1]=0D + self.device_str =3D ' '.join(used_cbdma)=0D + self.dut.setup_modules(self.target, "igb_uio","None")=0D + self.dut.send_expect('./usertools/dpdk-devbind.py --force --bind= =3D%s %s' % ("igb_uio", self.device_str), '# ', 60)=0D +=0D + def send_vlan_packet(self, dts_mac, pkt_size=3D64, pkt_count=3D1):=0D + """=0D + Send a vlan packet with vlan id 1000=0D + """=0D + pkt =3D Packet(pkt_type=3D'VLAN_UDP', pkt_len=3Dpkt_size)=0D + pkt.config_layer('ether', {'dst': dts_mac})=0D + pkt.config_layer('vlan', {'vlan': 1000})=0D + pkt.send_pkt(self.tester, tx_port=3Dself.txItf, count=3Dpkt_count)= =0D +=0D + def verify_receive_packet(self, pmd_session, expected_pkt_count):=0D + out =3D pmd_session.execute_cmd("show port stats all")=0D + rx_num =3D re.compile('RX-packets: (.*?)\s+?').findall(out, re.S)= =0D + self.verify((int(rx_num[0]) >=3D int(expected_pkt_count)), "Can't = receive enough packets from tester")=0D +=0D + def bind_cbdma_device_to_kernel(self):=0D + if self.device_str is not None:=0D + self.dut.send_expect('modprobe ioatdma', '# ')=0D + self.dut.send_expect('./usertools/dpdk-devbind.py -u %s' % sel= f.device_str, '# ', 30)=0D + self.dut.send_expect('./usertools/dpdk-devbind.py --force --bi= nd=3Dioatdma %s' % self.device_str, '# ', 60)=0D +=0D + def config_stream(self, frame_size, port_num, dst_mac_list):=0D + tgen_input =3D []=0D + rx_port =3D self.tester.get_local_port(self.dut_ports[0])=0D + tx_port =3D self.tester.get_local_port(self.dut_ports[0])=0D + for item in range(port_num):=0D + for dst_mac in dst_mac_list:=0D + pkt =3D Packet(pkt_type=3D'VLAN_UDP', pkt_len=3Dframe_size= )=0D + pkt.config_layer('ether', {'dst': dst_mac})=0D + pkt.config_layer('vlan', {'vlan': 1000})=0D + pcap =3D os.path.join(self.out_path, "vswitch_sample_cbdma= _%s_%s_%s.pcap" % (item, dst_mac, frame_size))=0D + pkt.save_pcapfile(None, pcap)=0D + tgen_input.append((rx_port, tx_port, pcap))=0D + return tgen_input=0D +=0D + def perf_test(self, frame_size, dst_mac_list):=0D + # Create test results table=0D + table_header =3D ['Frame Size(Byte)', 'Throughput(Mpps)']=0D + self.result_table_create(table_header)=0D + # Begin test perf=0D + test_result =3D {}=0D + for frame_size in frame_size:=0D + self.logger.info("Test running at parameters: " + "framesize: = {}".format(frame_size))=0D + tgenInput =3D self.config_stream(frame_size, self.tester_tx_po= rt_num, dst_mac_list)=0D + # clear streams before add new streams=0D + self.tester.pktgen.clear_streams()=0D + # run packet generator=0D + streams =3D self.pktgen_helper.prepare_stream_from_tginput(tge= nInput, 100, None, self.tester.pktgen)=0D + # set traffic option=0D + traffic_opt =3D {'duration': 5}=0D + _, pps =3D self.tester.pktgen.measure_throughput(stream_ids=3D= streams, options=3Dtraffic_opt)=0D + self.verify(pps > 0, "No traffic detected")=0D + throughput =3D pps / 1000000.0=0D + test_result[frame_size] =3D throughput=0D + self.result_table_add([frame_size, throughput])=0D + self.result_table_print()=0D + return test_result=0D +=0D + def pvp_test_with_cbdma(self, socket_num=3D1, with_cbdma=3DTrue, cbdma= _num=3D1):=0D + self.frame_sizes =3D [64, 512, 1024, 1518]=0D + self.start_vhost_app(with_cbdma=3Dwith_cbdma, cbdma_num=3Dcbdma_nu= m, socket_num=3Dsocket_num, client_mode=3DFalse)=0D + self.start_virtio_testpmd(pmd_session=3Dself.virtio_user0_pmd, dev= _mac=3Dself.virtio_dst_mac0, dev_id=3D0,=0D + cores=3Dself.vuser0_core_list, prefix=3D= 'testpmd0', enable_queues=3D1, server_mode=3DFalse,=0D + nb_cores=3D1, used_queues=3D1)=0D + self.virtio_user0_pmd.execute_cmd('set fwd mac')=0D + self.virtio_user0_pmd.execute_cmd('start tx_first')=0D + self.virtio_user0_pmd.execute_cmd('stop')=0D + self.virtio_user0_pmd.execute_cmd('start')=0D + dst_mac_list =3D [self.virtio_dst_mac0]=0D + perf_result =3D self.perf_test(frame_size=3Dself.frame_sizes,dst_m= ac_list=3Ddst_mac_list)=0D + return perf_result=0D +=0D + def test_perf_check_with_cbdma_channel_using_vhost_async_driver(self):= =0D + """=0D + Test Case1: PVP performance check with CBDMA channel using vhost a= sync driver=0D + """=0D + perf_result =3D []=0D + self.get_cbdma_ports_info_and_bind_to_dpdk(1)=0D +=0D + # test cbdma copy=0D + # CBDMA copy needs vhost enqueue with cbdma channel using paramete= r '-dmas'=0D + self.set_async_threshold(1518)=0D + self.build_vhost_app()=0D + cbmda_copy =3D self.pvp_test_with_cbdma(socket_num=3D1, with_cbdma= =3DTrue, cbdma_num=3D1)=0D +=0D + self.virtio_user0_pmd.execute_cmd("quit", "#")=0D + self.vhost_user.send_expect("^C", "# ", 20)=0D +=0D + # test sync copy=0D + # Sync copy needs vhost enqueue with cbdma channel, but threshold = ( can be adjusted by change value of=0D + # f.async_threshold in dpdk code) is larger than forwarding packet= length=0D + self.set_async_threshold(0)=0D + self.build_vhost_app()=0D + sync_copy =3D self.pvp_test_with_cbdma(socket_num=3D1, with_cbdma= =3DTrue, cbdma_num=3D1)=0D +=0D + self.virtio_user0_pmd.execute_cmd("quit", "#")=0D + self.vhost_user.send_expect("^C", "# ", 20)=0D +=0D + # test CPU copy=0D + # CPU copy means vhost enqueue w/o cbdma channel=0D + cpu_copy =3D self.pvp_test_with_cbdma(socket_num=3D1, with_cbdma= =3DFalse, cbdma_num=3D0)=0D +=0D + self.virtio_user0_pmd.execute_cmd("quit", "#")=0D + self.vhost_user.send_expect("^C", "# ", 20)=0D +=0D + self.table_header =3D ['Frame Size(Byte)', 'Mode', 'Throughput(Mpp= s)']=0D + self.result_table_create(self.table_header)=0D + for key in cbmda_copy.keys():=0D + perf_result.append([key, 'cbdma_copy', cbmda_copy[key]])=0D + for key in sync_copy.keys():=0D + perf_result.append([key, 'sync_copy', sync_copy[key]])=0D + for key in cpu_copy.keys():=0D + perf_result.append([key, 'cpu_copy', cpu_copy[key]])=0D + for table_row in perf_result:=0D + self.result_table_add(table_row)=0D + self.result_table_print()=0D +=0D + def pvp_test_with_multi_cbdma(self, socket_num=3D2, with_cbdma=3DTrue,= cbdma_num=3D1, launch_virtio=3DTrue, quit_vhost=3DFalse):=0D + self.frame_sizes =3D [1518]=0D + self.start_vhost_app(with_cbdma=3Dwith_cbdma, cbdma_num=3Dcbdma_nu= m, socket_num=3Dsocket_num, client_mode=3DTrue)=0D + if launch_virtio:=0D + self.start_virtio_testpmd(pmd_session=3Dself.virtio_user0_pmd,= dev_mac=3Dself.virtio_dst_mac0, dev_id=3D0,=0D + cores=3Dself.vuser0_core_list, prefi= x=3D'testpmd0', enable_queues=3D1, server_mode=3DTrue,=0D + nb_cores=3D1, used_queues=3D1)=0D + self.start_virtio_testpmd(pmd_session=3Dself.virtio_user1_pmd,= dev_mac=3Dself.virtio_dst_mac1, dev_id=3D1,=0D + cores=3Dself.vuser1_core_list, prefi= x=3D'testpmd1', enable_queues=3D1, server_mode=3DTrue,=0D + nb_cores=3D1, used_queues=3D1)=0D + self.virtio_user0_pmd.execute_cmd('set fwd mac')=0D + self.virtio_user0_pmd.execute_cmd('start tx_first')=0D + self.virtio_user0_pmd.execute_cmd('stop')=0D + self.virtio_user0_pmd.execute_cmd('start')=0D + self.virtio_user1_pmd.execute_cmd('set fwd mac')=0D + self.virtio_user1_pmd.execute_cmd('start tx_first')=0D + self.virtio_user1_pmd.execute_cmd('stop')=0D + self.virtio_user1_pmd.execute_cmd('start')=0D + else:=0D + self.virtio_user0_pmd.execute_cmd('stop', 'testpmd> ', 30)=0D + self.virtio_user0_pmd.execute_cmd('start tx_first', 'testpmd> = ', 30)=0D + self.virtio_user1_pmd.execute_cmd('stop', 'testpmd> ', 30)=0D + self.virtio_user1_pmd.execute_cmd('start tx_first', 'testpmd> = ', 30)=0D + dst_mac_list =3D [self.virtio_dst_mac0, self.virtio_dst_mac1]=0D + perf_result =3D self.perf_test(self.frame_sizes, dst_mac_list)=0D + if quit_vhost:=0D + self.vhost_user.send_expect("^C", "# ", 20)=0D + return perf_result=0D +=0D + def test_perf_check_with_multiple_cbdma_channels_using_vhost_async_dri= ver(self):=0D + """=0D + Test Case2: PVP test with multiple CBDMA channels using vhost asyn= c driver=0D + """=0D + perf_result =3D []=0D + self.get_cbdma_ports_info_and_bind_to_dpdk(2)=0D + self.set_async_threshold(256)=0D + self.build_vhost_app()=0D +=0D + self.logger.info("Launch vhost app perf test")=0D + before_relunch=3D self.pvp_test_with_multi_cbdma(socket_num=3D2, w= ith_cbdma=3DTrue, cbdma_num=3D2, launch_virtio=3DTrue, quit_vhost=3DTrue)=0D +=0D + self.logger.info("Relaunch vhost app perf test")=0D + after_relunch =3D self.pvp_test_with_multi_cbdma(socket_num=3D2, w= ith_cbdma=3DTrue, cbdma_num=3D2, launch_virtio=3DFalse, quit_vhost=3DFalse)= =0D +=0D + self.virtio_user0_pmd.execute_cmd("quit", "#")=0D + self.virtio_user1_pmd.execute_cmd("quit", "#")=0D + self.vhost_user.send_expect("^C", "# ", 20)=0D +=0D + self.table_header =3D ['Frame Size(Byte)', 'Mode', 'Throughput(Mpp= s)']=0D + self.result_table_create(self.table_header)=0D + for key in before_relunch.keys():=0D + perf_result.append([key, 'Before Re-launch vhost', before_relu= nch[key]])=0D + for key in after_relunch.keys():=0D + perf_result.append([key, 'After Re-launch vhost', after_relunc= h[key]])=0D + for table_row in perf_result:=0D + self.result_table_add(table_row)=0D + self.result_table_print()=0D +=0D + self.verify(abs(before_relunch[1518] - after_relunch[1518]) / befo= re_relunch[1518] < 0.1, "Perf is unstable, \=0D + before relaunch vhost app: %s, after relaunch vhost app: %s" % (be= fore_relunch[1518], after_relunch[1518]))=0D +=0D + def get_receive_throughput(self, pmd_session, count=3D5):=0D + i =3D 0=0D + while i < count:=0D + pmd_session.execute_cmd('show port stats all')=0D + i +=3D 1=0D + else:=0D + out =3D pmd_session.execute_cmd('show port stats all')=0D + pmd_session.execute_cmd('stop')=0D + rx_throughput =3D re.compile('Rx-pps: \s+(.*?)\s+?').findall(o= ut, re.S)=0D + return float(rx_throughput[0]) / 1000000.0=0D +=0D + def set_testpmd0_param(self, pmd_session, eth_peer_mac):=0D + pmd_session.execute_cmd('set fwd mac')=0D + pmd_session.execute_cmd('start tx_first')=0D + pmd_session.execute_cmd('stop')=0D + pmd_session.execute_cmd('set eth-peer 0 %s' % eth_peer_mac)=0D + pmd_session.execute_cmd('start')=0D +=0D + def set_testpmd1_param(self, pmd_session, eth_peer_mac):=0D + pmd_session.execute_cmd('set fwd mac')=0D + pmd_session.execute_cmd('set eth-peer 0 %s' % eth_peer_mac)=0D +=0D + def send_pkts_from_testpmd1(self, pmd_session, pkt_len):=0D + pmd_session.execute_cmd('set txpkts %s' % pkt_len)=0D + pmd_session.execute_cmd('start tx_first')=0D +=0D + def vm2vm_check_with_two_cbdma(self, with_cbdma=3DTrue, cbdma_num=3D2,= socket_num=3D2):=0D + frame_sizes =3D [256, 2000]=0D + self.start_vhost_app(with_cbdma=3Dwith_cbdma, cbdma_num=3Dcbdma_nu= m, socket_num=3Dsocket_num, client_mode=3DFalse)=0D + self.start_virtio_testpmd(pmd_session=3Dself.virtio_user0_pmd, dev= _mac=3Dself.virtio_dst_mac0, dev_id=3D0,=0D + cores=3Dself.vuser0_core_list, prefix=3D= 'testpmd0', enable_queues=3D1, server_mode=3DFalse,=0D + nb_cores=3D1, used_queues=3D1)=0D + self.start_virtio_testpmd(pmd_session=3Dself.virtio_user1_pmd, dev= _mac=3Dself.virtio_dst_mac1, dev_id=3D1,=0D + cores=3Dself.vuser1_core_list, prefix=3D= 'testpmd1', enable_queues=3D1, server_mode=3DFalse,=0D + nb_cores=3D1, used_queues=3D1)=0D + self.set_testpmd0_param(self.virtio_user0_pmd, self.virtio_dst_mac= 1)=0D + self.set_testpmd1_param(self.virtio_user1_pmd, self.virtio_dst_mac= 0)=0D +=0D + rx_throughput =3D {}=0D + for frame_size in frame_sizes:=0D + self.send_pkts_from_testpmd1(pmd_session=3Dself.virtio_user1_p= md, pkt_len=3Dframe_size)=0D + # Create test results table=0D + table_header =3D ['Frame Size(Byte)', 'Throughput(Mpps)']=0D + self.result_table_create(table_header)=0D + rx_pps =3D self.get_receive_throughput(pmd_session=3Dself.virt= io_user1_pmd)=0D + self.result_table_add([frame_size, rx_pps])=0D + rx_throughput[frame_size] =3D rx_pps=0D + self.result_table_print()=0D + return rx_throughput=0D +=0D + def test_vm2vm_check_with_two_cbdma_channels_using_vhost_async_driver(= self):=0D + """=0D + Test Case3: VM2VM performance test with two CBDMA channels using v= host async driver=0D + """=0D + perf_result =3D []=0D + self.get_cbdma_ports_info_and_bind_to_dpdk(2)=0D + self.set_async_threshold(256)=0D + self.build_vhost_app()=0D +=0D + cbdma_enable =3D self.vm2vm_check_with_two_cbdma(with_cbdma=3DTrue= , cbdma_num=3D2, socket_num=3D2)=0D +=0D + self.virtio_user0_pmd.execute_cmd("quit", "#")=0D + self.virtio_user1_pmd.execute_cmd("quit", "#")=0D + self.vhost_user.send_expect("^C", "# ", 20)=0D +=0D + cbdma_disable =3D self.vm2vm_check_with_two_cbdma(with_cbdma=3DFal= se, cbdma_num=3D2, socket_num=3D2)=0D +=0D + self.virtio_user0_pmd.execute_cmd("quit", "#")=0D + self.virtio_user1_pmd.execute_cmd("quit", "#")=0D + self.vhost_user.send_expect("^C", "# ", 20)=0D +=0D + self.table_header =3D ['Frame Size(Byte)', 'CBDMA Enable/Disable',= 'Throughput(Mpps)']=0D + self.result_table_create(self.table_header)=0D + for key in cbdma_enable.keys():=0D + perf_result.append([key, 'Enable', cbdma_enable[key]])=0D + for key in cbdma_disable.keys():=0D + perf_result.append([key, 'Disable', cbdma_disable[key]])=0D + for table_row in perf_result:=0D + self.result_table_add(table_row)=0D + self.result_table_print()=0D +=0D + for cbdma_key in cbdma_enable.keys():=0D + if cbdma_key =3D=3D '2000':=0D + self.verify(cbdma_enable[cbdma_key] > cbdma_disable[cbdma_= key],=0D + "CBDMA Enable Performance {} should better tha= n CBDMA Disable Performance {} when send 2000"=0D + " length packets".format(cbdma_enable[cbdma_ke= y], cbdma_disable[cbdma_key]))=0D + elif cbdma_key =3D=3D '256':=0D + self.verify(cbdma_disable[cbdma_key] > cbdma_enable[cbdma_= key],=0D + "CBDMA Enable Performance {} should lower tha= n CBDMA Disable Performance {} when send 256"=0D + " length packets".format(cbdma_enable[cbdma_ke= y], cbdma_disable[cbdma_key]))=0D +=0D + def vm2vm_check_with_two_vhost_device(self, with_cbdma=3DTrue, cbdma_n= um=3D2, socket_num=3D2, launch=3DTrue):=0D + frame_sizes =3D [256, 2000]=0D + if launch:=0D + self.start_vhost_app(with_cbdma=3Dwith_cbdma, cbdma_num=3Dcbdm= a_num, socket_num=3Dsocket_num, client_mode=3DFalse)=0D + self.start_vms(mode=3D0, mergeable=3DFalse)=0D + self.vm0_pmd =3D PmdOutput(self.vm_dut[0])=0D + self.vm1_pmd =3D PmdOutput(self.vm_dut[1])=0D + self.start_vm_testpmd(self.vm0_pmd)=0D + self.start_vm_testpmd(self.vm1_pmd)=0D + self.set_testpmd0_param(self.vm0_pmd, self.vm_dst_mac1)=0D + self.set_testpmd1_param(self.vm1_pmd, self.vm_dst_mac0)=0D +=0D + rx_throughput =3D {}=0D + for frame_size in frame_sizes:=0D + self.send_pkts_from_testpmd1(pmd_session=3Dself.vm1_pmd, pkt_l= en=3Dframe_size)=0D + # Create test results table=0D + table_header =3D ['Frame Size(Byte)', 'Throughput(Mpps)']=0D + self.result_table_create(table_header)=0D + rx_pps =3D self.get_receive_throughput(pmd_session=3Dself.vm1_= pmd)=0D + self.result_table_add([frame_size, rx_pps])=0D + rx_throughput[frame_size] =3D rx_pps=0D + self.result_table_print()=0D +=0D + return rx_throughput=0D +=0D + def start_vms_testpmd_and_test(self, launch, quit_vm_testpmd=3DFalse):= =0D + # start vm0 amd vm1 testpmd, send 256 and 2000 length packets from= vm1 testpmd=0D + perf_result =3D self.vm2vm_check_with_two_vhost_device(with_cbdma= =3DTrue, cbdma_num=3D2, socket_num=3D2, launch=3Dlaunch)=0D + # stop vm1 and clear vm1 stats=0D + self.vm1_pmd.execute_cmd("stop")=0D + self.vm1_pmd.execute_cmd("clear port stats all")=0D + # stop vm0 and clear vm0 stats=0D + self.vm0_pmd.execute_cmd("stop")=0D + self.vm0_pmd.execute_cmd("clear port stats all")=0D + # only start vm0 and send packets from tester, and check vm0 can r= eceive more then tester send packets' count=0D + self.vm0_pmd.execute_cmd("start")=0D + self.send_vlan_packet(dts_mac=3Dself.vm_dst_mac0, pkt_size=3D64, p= kt_count=3D100)=0D + time.sleep(3)=0D + self.verify_receive_packet(pmd_session=3Dself.vm0_pmd, expected_pk= t_count=3D100)=0D + # stop vm0=0D + self.vm0_pmd.execute_cmd("stop")=0D + # only start vm1 and send packets from tester, and check vm1 can r= eceive more then tester send packets' count=0D + self.vm1_pmd.execute_cmd("start")=0D + # clear vm1 stats after send start command=0D + self.vm1_pmd.execute_cmd("clear port stats all")=0D + self.send_vlan_packet(dts_mac=3Dself.vm_dst_mac1, pkt_size=3D64, p= kt_count=3D100)=0D + time.sleep(3)=0D + self.verify_receive_packet(pmd_session=3Dself.vm1_pmd, expected_pk= t_count=3D100)=0D + if quit_vm_testpmd:=0D + self.vm0_pmd.execute_cmd("quit", "#")=0D + self.vm1_pmd.execute_cmd("quit", "#")=0D + return perf_result=0D +=0D + def test_vm2vm_check_with_two_vhost_device_using_vhost_async_driver(se= lf):=0D + """=0D + Test Case4: VM2VM test with 2 vhost device using vhost async drive= r=0D + """=0D + perf_result =3D []=0D + self.get_cbdma_ports_info_and_bind_to_dpdk(2)=0D + self.set_async_threshold(256)=0D + self.build_vhost_app()=0D +=0D + before_rebind =3D self.start_vms_testpmd_and_test(launch=3DTrue, q= uit_vm_testpmd=3DTrue)=0D + # repeat bind 50 time from virtio-pci to vfio-pci=0D + self.repeat_bind_driver(dut=3Dself.vm_dut[0], repeat_times=3D50)=0D + self.repeat_bind_driver(dut=3Dself.vm_dut[1], repeat_times=3D50)=0D + # start vm0 and vm1 testpmd=0D + self.start_vm_testpmd(pmd_session=3Dself.vm0_pmd)=0D + self.start_vm_testpmd(pmd_session=3Dself.vm1_pmd)=0D + after_bind =3D self.start_vms_testpmd_and_test(launch=3DFalse, qui= t_vm_testpmd=3DFalse)=0D +=0D + for i in range(len(self.vm)):=0D + self.vm[i].stop()=0D + self.vhost_user.send_expect("^C", "# ", 20)=0D +=0D + self.table_header =3D ['Frame Size(Byte)', 'Before/After Bind VM D= river', 'Throughput(Mpps)']=0D + self.result_table_create(self.table_header)=0D + for key in before_rebind.keys():=0D + perf_result.append([key, 'Before rebind driver', before_rebind= [key]])=0D + for key in after_bind.keys():=0D + perf_result.append([key, 'After rebind driver', after_bind[key= ]])=0D + for table_row in perf_result:=0D + self.result_table_add(table_row)=0D + self.result_table_print()=0D +=0D + def close_all_session(self):=0D + if getattr(self, 'vhost_user', None):=0D + self.dut.close_session(self.vhost_user)=0D + if getattr(self, 'virtio-user0', None):=0D + self.dut.close_session(self.virtio_user0)=0D + if getattr(self, 'virtio-user1', None):=0D + self.dut.close_session(self.virtio_user1)=0D +=0D + def tear_down(self):=0D + """=0D + Run after each test case.=0D + """=0D + self.bind_cbdma_device_to_kernel()=0D + self.close_all_session()=0D +=0D + def tear_down_all(self):=0D + """=0D + Run after each test suite.=0D + """=0D + self.set_max_queues(128)=0D + self.set_async_threshold(256)=0D + self.dut.build_install_dpdk(self.target) \ No newline at end of file --=20 2.25.1