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 675A6A052A; Wed, 23 Dec 2020 09:38:36 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 33376CA4A; Wed, 23 Dec 2020 09:38:35 +0100 (CET) Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) by dpdk.org (Postfix) with ESMTP id A3B86CA37 for ; Wed, 23 Dec 2020 09:38:33 +0100 (CET) IronPort-SDR: N0XOqj4BihpEDAnv6mow7jgwv1CwsTyCKWPXhdjhL3BKAlh05uZPoDastWHj29FMwEjRpzivlo Lv7k5lXCJWjg== X-IronPort-AV: E=McAfee;i="6000,8403,9843"; a="237544410" X-IronPort-AV: E=Sophos;i="5.78,441,1599548400"; d="scan'208";a="237544410" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Dec 2020 00:38:31 -0800 IronPort-SDR: ktHfXaRSg21KEDapMBa8m9VUe2ow51sRySXUjVATc2Ae1B01PVf/Mr04c6edvu86fuoA7A+E4S nl81yBW+HaOg== X-IronPort-AV: E=Sophos;i="5.78,441,1599548400"; d="scan'208";a="373885962" Received: from unknown (HELO localhost.localdomain) ([10.240.183.222]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Dec 2020 00:38:29 -0800 From: Ling Wei To: dts@dpdk.org Cc: Ling Wei Date: Wed, 23 Dec 2020 16:33:17 +0000 Message-Id: <20201223163317.2797162-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/virtio_smoke:add new virtio smoke test suite sync with testplan 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" add new virtio smoke test suite sync with testplan Signed-off-by: Ling Wei --- tests/TestSuite_virtio_smoke.py | 205 ++++++++++++++++++++++++++++++++ 1 file changed, 205 insertions(+) create mode 100644 tests/TestSuite_virtio_smoke.py diff --git a/tests/TestSuite_virtio_smoke.py b/tests/TestSuite_virtio_smoke= .py new file mode 100644 index 00000000..a13c5479 --- /dev/null +++ b/tests/TestSuite_virtio_smoke.py @@ -0,0 +1,205 @@ +# 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 re=0D +from test_case import TestCase=0D +from packet import Packet=0D +from pktgen import PacketGeneratorHelper=0D +from pmd_output import PmdOutput=0D +=0D +=0D +class TestVirtioSmoke(TestCase):=0D +=0D +=0D + def set_up_all(self):=0D + """=0D + Run at the start of each test suite.=0D + """=0D + self.vhost_user =3D self.dut.new_session(suite=3D"vhost-user")=0D + self.virtio_user1 =3D self.dut.new_session(suite=3D"virtio-user1")= =0D + self.pmdout_vhost_user =3D PmdOutput(self.dut, self.vhost_user)=0D + self.pmdout_virtio_user1 =3D PmdOutput(self.dut, self.virtio_user1= )=0D + self.frame_sizes_list =3D [64, 1518]=0D + self.dst_mac =3D "00:01:02:03:04:05"=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_cores =3D self.cores[0:3]=0D + self.virtio1_cores =3D self.cores[3:6]=0D + # the path of pcap file=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.pktgen_helper =3D PacketGeneratorHelper()=0D + self.base_dir =3D self.dut.base_dir.replace('~', '/root')=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 +=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 launch_testpmd_as_vhost_user(self, param, cores=3D"Default", udev= =3D"", ports=3D[], no_pci=3DTrue):=0D + self.pmdout_vhost_user.start_testpmd(cores=3Dcores, param=3Dparam,= vdevs=3D[udev], ports=3Dports, prefix=3D"vhost", fixed_prefix=3DTrue, no_p= ci=3Dno_pci)=0D + self.vhost_user.send_expect('set fwd mac', 'testpmd> ', 30)=0D +=0D + def launch_testpmd_as_virtio_user1(self, param, cores=3D"Default", ude= v=3D"", no_pci=3DTrue):=0D + eal_param =3D ""=0D + if self.check_2M_env:=0D + eal_param +=3D " --single-file-segments"=0D + if 'vectorized' in self.running_case:=0D + eal_param +=3D " --force-max-simd-bitwidth=3D512"=0D + self.pmdout_virtio_user1.start_testpmd(cores=3Dcores, param=3Dpara= m, vdevs=3D[udev], ports=3D[], prefix=3D"virtio1", fixed_prefix=3DTrue, eal= _param=3Deal_param, no_pci=3Dno_pci)=0D +=0D + def verify_vhost_queue_rx_tx_pkts(self, queue_list):=0D + out =3D self.vhost_user.send_expect('stop', 'testpmd> ', 30)=0D + for queue_index in queue_list:=0D + queue =3D "Queue=3D %d" % queue_index=0D + index =3D out.find(queue)=0D + rx =3D re.search("RX-packets:\s*(\d*)", out[index:])=0D + tx =3D re.search("TX-packets:\s*(\d*)", out[index:])=0D + rx_packets =3D int(rx.group(1))=0D + tx_packets =3D int(tx.group(1))=0D + self.verify(rx_packets > 0 and tx_packets > 0,=0D + "The queue %d rx-packets or tx-packets is 0 about = " % queue_index + "rx-packets:%d, tx-packets:%d" % (rx_packets, tx_packets)= )=0D +=0D + def test_loopback_reconnect_test_with_split_ring_mergeable_path_and_se= rver_mode(self):=0D + param =3D " --nb-cores=3D{} --rxq=3D{} --txq=3D{}"=0D + other_param =3D " --tx-offloads=3D0x0 --enable-hw-vlan-strip --rss= -ip"=0D + vhost_dev =3D f"'eth_vhost0,iface=3Dvhost-net,client=3D1,queues=3D= 8'"=0D + virtio_dev =3D f"'net_virtio_user0,mac=3D{self.dst_mac},path=3D./v= host-net,server=3D1,queues=3D8,mrg_rxbuf=3D1,in_order=3D1'"=0D +=0D + self.logger.info("Launch vhost as client mode with 2 queues")=0D + nb_core =3D 2=0D + vhost_rxq_txq =3D 2=0D + virtio_rxq_txq =3D 8=0D + vhost_param =3D param.format(nb_core, vhost_rxq_txq, vhost_rxq_txq= )=0D + virtio_param =3D (other_param + param).format(nb_core, virtio_rxq_= txq, virtio_rxq_txq)=0D + self.launch_testpmd_as_vhost_user(param=3Dvhost_param, cores=3Dsel= f.vhost_cores, udev=3Dvhost_dev, no_pci=3DTrue)=0D + self.vhost_user.send_expect('start', 'testpmd> ', 30)=0D + self.logger.info("Launch virtio-user as server mode with 8 queues"= )=0D + self.launch_testpmd_as_virtio_user1(param=3Dvirtio_param, cores=3D= self.virtio1_cores, udev=3Dvirtio_dev, no_pci=3DTrue)=0D + self.virtio_user1.send_expect('set fwd mac', 'testpmd> ', 30)=0D + self.virtio_user1.send_expect('start tx_first 32', 'testpmd> ', 30= )=0D + self.verify_vhost_queue_rx_tx_pkts(queue_list=3Drange(vhost_rxq_tx= q))=0D + self.vhost_user.send_expect("quit", "# ", 20)=0D +=0D + self.logger.info("Relaunch vhost with 8 queues and send packets")= =0D + vhost_rxq_txq =3D 8=0D + vhost_param =3D param.format(nb_core, vhost_rxq_txq, vhost_rxq_txq= )=0D + self.launch_testpmd_as_vhost_user(param=3Dvhost_param, cores=3Dsel= f.cores[0:3], udev=3Dvhost_dev, no_pci=3DTrue)=0D + self.vhost_user.send_expect('start tx_first 32', 'testpmd> ', 30)= =0D + self.vhost_user.send_expect('stop', 'testpmd> ', 30)=0D + self.vhost_user.send_expect('set burst 1', 'testpmd> ', 30)=0D + self.vhost_user.send_expect('start tx_first 1', 'testpmd> ', 30)=0D + self.verify_vhost_queue_rx_tx_pkts(queue_list=3Drange(vhost_rxq_tx= q))=0D +=0D + self.virtio_user1.send_expect("quit", "# ", 20)=0D + self.vhost_user.send_expect("quit", "# ", 20)=0D +=0D + def config_stream(self, frame_size):=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 + dst_mac =3D self.dut.get_mac_address(self.dut_ports[0])=0D + pkt =3D Packet(pkt_type=3D'UDP', pkt_len=3Dframe_size)=0D + pkt.config_layer('ether', {'dst': dst_mac})=0D + pkt.save_pcapfile(self.tester, "%s/virtio_smoke.pcap" % (self.out_= path))=0D + tgen_input.append((rx_port, tx_port, "%s/virtio_smoke.pcap" % (sel= f.out_path)))=0D + return tgen_input=0D +=0D + def perf_test(self, frame_size_list, case_info):=0D + # Create test results table=0D + table_header =3D ['Frame Size(Byte)', 'Mode', 'Throughput(Mpps)']= =0D + self.result_table_create(table_header)=0D + # Begin test perf=0D + for frame_size in frame_size_list:=0D + test_result =3D {}=0D + self.logger.info("Test running at parameters: " + "framesize: = {}".format(frame_size))=0D + tgenInput =3D self.config_stream(frame_size)=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, case_info, throughput])=0D + self.result_table_print()=0D + return test_result=0D +=0D + def test_perf_pvp_test_with_virtio_packed_ring_vectorized_path(self):= =0D + param =3D " --nb-cores=3D{} --txd=3D{} --rxd=3D{}"=0D + vhost_dev =3D f"'net_vhost0,iface=3Dvhost-net,queues=3D1'"=0D + virtio_dev =3D f"'net_virtio_user0,mac=3D{self.dst_mac},path=3D./v= host-net,packed_vq=3D1,mrg_rxbuf=3D0,in_order=3D1,vectorized=3D1,queue_size= =3D1024'"=0D + self.logger.info("Launch vhost")=0D + nb_core =3D 2=0D + vhost_rxd_txd =3D 1024=0D + vhost_param =3D param.format(nb_core, vhost_rxd_txd, vhost_rxd_txd= )=0D + port =3D self.dut.ports_info[self.dut_ports[0]]['pci']=0D + self.launch_testpmd_as_vhost_user(param=3Dvhost_param, cores=3Dsel= f.vhost_cores, udev=3Dvhost_dev, ports=3D[port], no_pci=3DFalse)=0D + self.vhost_user.send_expect('start', 'testpmd> ', 30)=0D +=0D + self.logger.info("Launch virtio")=0D + nb_core =3D 1=0D + virtio_param =3D param.format(nb_core, vhost_rxd_txd, vhost_rxd_tx= d)=0D + self.launch_testpmd_as_virtio_user1(param=3Dvirtio_param, cores=3D= self.virtio1_cores, udev=3Dvirtio_dev, no_pci=3DTrue)=0D + self.virtio_user1.send_expect('set fwd mac', 'testpmd> ', 30)=0D + self.virtio_user1.send_expect('start', 'testpmd> ', 30)=0D +=0D + self.logger.info("Start perf test")=0D + self.perf_test(frame_size_list=3Dself.frame_sizes_list, case_info= =3D'virtio packed ring vectorized path')=0D +=0D + def tear_down(self):=0D + """=0D + Run after each test case.=0D + """=0D + self.dut.close_session(self.vhost_user)=0D + self.dut.close_session(self.virtio_user1)=0D +=0D + def tear_down_all(self):=0D + """=0D + Run after each test suite.=0D + """=0D + pass=0D --=20 2.25.1