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 5EA52A0613 for ; Tue, 30 Jul 2019 14:18:38 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 549B81C112; Tue, 30 Jul 2019 14:18:38 +0200 (CEST) Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by dpdk.org (Postfix) with ESMTP id 7E0031C10A for ; Tue, 30 Jul 2019 14:18:36 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 30 Jul 2019 05:18:35 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,326,1559545200"; d="scan'208";a="162561232" Received: from fmsmsx108.amr.corp.intel.com ([10.18.124.206]) by orsmga007.jf.intel.com with ESMTP; 30 Jul 2019 05:18:35 -0700 Received: from fmsmsx158.amr.corp.intel.com (10.18.116.75) by FMSMSX108.amr.corp.intel.com (10.18.124.206) with Microsoft SMTP Server (TLS) id 14.3.439.0; Tue, 30 Jul 2019 05:18:35 -0700 Received: from shsmsx101.ccr.corp.intel.com (10.239.4.153) by fmsmsx158.amr.corp.intel.com (10.18.116.75) with Microsoft SMTP Server (TLS) id 14.3.439.0; Tue, 30 Jul 2019 05:18:34 -0700 Received: from shsmsx104.ccr.corp.intel.com ([169.254.5.112]) by SHSMSX101.ccr.corp.intel.com ([169.254.1.80]) with mapi id 14.03.0439.000; Tue, 30 Jul 2019 20:18:32 +0800 From: "Wang, Yinan" To: "Ma, LihongX" , "dts@dpdk.org" CC: "Ma, LihongX" Thread-Topic: [dts] [PATCH V1] tests: add testsuite pvp virtio bonding Thread-Index: AQHVRpT8F7OS0G46eUeiyqiyLDqkN6bjFJ6w Date: Tue, 30 Jul 2019 12:18:32 +0000 Message-ID: References: <1564436781-8462-1-git-send-email-lihongx.ma@intel.com> In-Reply-To: <1564436781-8462-1-git-send-email-lihongx.ma@intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiM2IzYTk0MTYtYzc4Mi00NTRkLWI0MWQtYmZkYzQ3OTUxNGJkIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoiMnNaUWZvVThvR0hyanRUWHR5VW13SmlTUDhPS29xbExqeE4ydmtHcWRxWHVUSGRYU3J1bW5DNnZxM0xxK3AxYyJ9 x-ctpclassification: CTP_NT dlp-product: dlpe-windows dlp-version: 11.0.600.7 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] tests: add testsuite pvp virtio bonding 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" Acked-by: Wang, Yinan > -----Original Message----- > From: dts [mailto:dts-bounces@dpdk.org] On Behalf Of lihong > Sent: 2019=1B$BG/=1B(B7=1B$B7n=1B(B30=1B$BF|=1B(B 5:46 > To: dts@dpdk.org > Cc: Ma, LihongX > Subject: [dts] [PATCH V1] tests: add testsuite pvp virtio bonding >=20 > Signed-off-by: lihong > --- > tests/TestSuite_pvp_virtio_bonding.py | 249 > ++++++++++++++++++++++++++++++++++ > 1 file changed, 249 insertions(+) > create mode 100644 tests/TestSuite_pvp_virtio_bonding.py >=20 > diff --git a/tests/TestSuite_pvp_virtio_bonding.py > b/tests/TestSuite_pvp_virtio_bonding.py > new file mode 100644 > index 0000000..bcfbfd4 > --- /dev/null > +++ b/tests/TestSuite_pvp_virtio_bonding.py > @@ -0,0 +1,249 @@ > +# 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. > +The Link Bonding functions make it possible to dynamically create and > +manage link bonding devices from within testpmd interactive prompt. > +""" > +import re > +import time > +import utils > +from test_case import TestCase > +from virt_common import VM > +from pmd_output import PmdOutput > +from packet import Packet, save_packets from pktgen import > +PacketGeneratorHelper > + > + > +class TestPVPVirtIOBonding(TestCase): > + > + def set_up_all(self): > + # Get and verify the ports > + self.core_config =3D "1S/5C/1T" > + self.queues =3D 4 > + self.dut_ports =3D self.dut.get_ports() > + 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.verify(len(self.dut_ports) >=3D 1, "Insufficient ports for = testing") > + self.verify(self.cores_num >=3D 5, > + "There has not enought cores to test this suite %s" = % > + self.suite_name) > + cores =3D self.dut.get_core_list(self.core_config, > socket=3Dself.ports_socket) > + self.coremask =3D utils.create_mask(cores) > + self.memory_channel =3D self.dut.get_memory_channels() > + self.dst_mac =3D self.dut.get_mac_address(self.dut_ports[0]) > + > + self.out_path =3D '/tmp/%s' % self.suite_name > + out =3D self.tester.send_expect('ls -d %s' % self.out_path, '# '= ) > + if 'No such file or directory' in out: > + self.tester.send_expect('mkdir -p %s' % self.out_path, '# ') > + # create an instance to set stream field setting > + self.pktgen_helper =3D PacketGeneratorHelper() > + > + def set_up(self): > + """ > + run before each test case. > + """ > + self.dut.send_expect("rm -rf ./vhost.out", "#") > + self.dut.send_expect("killall -s INT testpmd", "#") > + self.dut.send_expect("killall -s INT qemu-system-x86_64", "#") > + self.start_testpmd_on_vhost() > + self.start_one_vm() > + > + def start_testpmd_on_vhost(self): > + """ > + launch vhost testpmd > + """ > + vdev_info =3D "" > + for i in range(self.queues): > + vdev_info +=3D "--vdev > 'net_vhost%d,iface=3Dvhost-net%d,client=3D1,queues=3D1' " % (i, i) > + params =3D "--port-topology=3Dchained --nb-cores=3D4 --txd=3D102= 4 > --rxd=3D1024" > + eal_param =3D "--socket-mem 2048,2048 --legacy-mem > --file-prefix=3Dvhost %s " % vdev_info > + self.vhost_testpmd =3D PmdOutput(self.dut) > + self.vhost_testpmd.start_testpmd(self.core_config, params, > eal_param=3Deal_param) > + self.vhost_testpmd.execute_cmd('set fwd mac') > + self.vhost_testpmd.execute_cmd('start') > + > + def start_testpmd_on_vm(self): > + """ > + launch testpmd in VM > + """ > + self.vm_testpmd =3D PmdOutput(self.vm_dut) > + self.vm_testpmd.start_testpmd("all", "--port-topology=3Dchained > + --nb-cores=3D5") > + > + def create_bonded_device_in_vm(self, mode): > + """ > + create one bonded device on socket 0 > + """ > + self.vm_testpmd.execute_cmd('create bonded device %s 0' % mode) > + self.vm_testpmd.execute_cmd('add bonding slave 0 4') > + self.vm_testpmd.execute_cmd('add bonding slave 1 4') > + self.vm_testpmd.execute_cmd('add bonding slave 2 4') > + out =3D self.vm_testpmd.execute_cmd('port start 4') > + self.verify("Invalid port" not in out, "Port start failed for %s= " % out) > + out =3D self.vm_testpmd.execute_cmd('show bonding config 4') > + self.logger.info(out) > + self.vm_testpmd.execute_cmd('set portlist 3,4') > + self.vm_testpmd.execute_cmd('set fwd mac') > + self.vm_testpmd.execute_cmd('start') > + > + def get_port_stats(self, out, port): > + log =3D "Forward statistics for port %d" % port > + index =3D out.find(log) > + self.verify(index >=3D 0, "not have stats info for port %d" % po= rt) > + xstats_info =3D out[index:] > + stats_rx =3D re.search("RX-packets:\s*(\d*)", xstats_info) > + stats_tx =3D re.search("TX-packets:\s*(\d*)", xstats_info) > + result_rx =3D int(stats_rx.group(1)) > + result_tx =3D int(stats_tx.group(1)) > + return result_rx/1000000, result_tx/1000000 > + > + def check_port_stats_on_vhost(self): > + """ > + check port stats at vhost side: > + port 0 and port 4 can rx packets,while port 0 and port 1 can tx = packets > + """ > + out =3D self.vhost_testpmd.execute_cmd('stop') > + self.vhost_testpmd.execute_cmd('start') > + print out > + rx, tx =3D self.get_port_stats(out, 0) > + self.verify(rx > 0 and tx > 0, "vhost port 0 can not receive or > + fwd data") > + > + rx, tx =3D self.get_port_stats(out, 4) > + self.verify(rx > 0, "vhost port 4 can not receive data") > + > + rx, tx =3D self.get_port_stats(out, 1) > + self.verify(tx > 0, "vhost port 4 can not fwd data") > + > + def check_port_stats_on_vm(self): > + """ > + check port stats at VM side: > + port 4 can rx packets,while port 3 tx packets > + """ > + out =3D self.vm_testpmd.execute_cmd('stop') > + print out > + rx, tx =3D self.get_port_stats(out, 4) > + self.verify(rx > 0, "vm port 4 can not receive data") > + > + rx, tx =3D self.get_port_stats(out, 3) > + self.verify(tx > 0, "vm port 3 can not fwd data") > + > + def send_packets(self): > + """ > + start traffic and verify data stats on vhost and vm > + """ > + tgen_input =3D [] > + rx_port =3D self.tester.get_local_port(self.dut_ports[0]) > + tx_port =3D self.tester.get_local_port(self.dut_ports[0]) > + pkt =3D Packet(pkt_type=3D'UDP') > + pkt.config_layer('ether', {'dst': '%s' % self.dst_mac}) > + save_packets([pkt], "%s/bonding.pcap" % self.out_path) > + tgen_input.append((tx_port, rx_port, "%s/bonding.pcap" % > self.out_path)) > + self.tester.pktgen.clear_streams() > + streams =3D > self.pktgen_helper.prepare_stream_from_tginput(tgen_input, 100, None, > self.tester.pktgen) > + # set traffic option > + traffic_opt =3D {'delay': 10} > + _, _ =3D > + self.tester.pktgen.measure_throughput(stream_ids=3Dstreams, > + options=3Dtraffic_opt) > + > + def set_vm_vcpu(self): > + """ > + set the vcpu number of vm > + """ > + params_number =3D len(self.vm.params) > + for i in range(params_number): > + if self.vm.params[i].keys()[0] =3D=3D 'cpu': > + self.vm.params[i]['cpu'][0]['number'] =3D 6 > + > + def start_one_vm(self): > + """ > + bootup one vm with four virtio-net devices > + """ > + virtio_mac =3D "52:54:00:00:00:0" > + self.vm =3D VM(self.dut, 'vm0', 'vhost_sample') > + self.vm.load_config() > + vm_params =3D {} > + for i in range(self.queues): > + vm_params['opt_server'] =3D 'server' > + vm_params['driver'] =3D 'vhost-user' > + vm_params['opt_path'] =3D './vhost-net%d' % i > + vm_params['opt_mac'] =3D "%s%d" % (virtio_mac, i+1) > + 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 stop_testpmd_and_vm(self): > + """ > + quit testpmd on vhost and stop vm > + """ > + self.vhost_testpmd.quit() > + self.vm.stop() > + > + def test_perf_vhost_virtio_bonding_mode_from_0_to_6(self): > + """ > + test the pvp performance for vector path > + """ > + # start testpmd on VM > + mode =3D ["0", "1", "2", "3", "4", "5", "6"] > + for i in mode: > + self.start_testpmd_on_vm() > + self.create_bonded_device_in_vm(i) > + # about the mode 4, just verify it can bonded ok > + if i =3D=3D "4": > + self.vm_testpmd.quit() > + continue > + self.send_packets() > + self.check_port_stats_on_vhost() > + self.check_port_stats_on_vm() > + self.vm_testpmd.quit() > + > + def tear_down(self): > + """ > + Run after each test case. > + """ > + self.stop_testpmd_and_vm() > + 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. > + """ > + pass > -- > 2.7.4