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 B3781A0487 for ; Tue, 2 Jul 2019 09:23:46 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 873665B3A; Tue, 2 Jul 2019 09:23:46 +0200 (CEST) Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by dpdk.org (Postfix) with ESMTP id A29AF5B34 for ; Tue, 2 Jul 2019 09:23:42 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 02 Jul 2019 00:23:40 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.63,442,1557212400"; d="scan'208";a="157542742" Received: from fmsmsx103.amr.corp.intel.com ([10.18.124.201]) by orsmga008.jf.intel.com with ESMTP; 02 Jul 2019 00:23:38 -0700 Received: from fmsmsx151.amr.corp.intel.com (10.18.125.4) by FMSMSX103.amr.corp.intel.com (10.18.124.201) with Microsoft SMTP Server (TLS) id 14.3.439.0; Tue, 2 Jul 2019 00:23:38 -0700 Received: from shsmsx104.ccr.corp.intel.com (10.239.4.70) by FMSMSX151.amr.corp.intel.com (10.18.125.4) with Microsoft SMTP Server (TLS) id 14.3.439.0; Tue, 2 Jul 2019 00:23:30 -0700 Received: from shsmsx101.ccr.corp.intel.com ([169.254.1.134]) by SHSMSX104.ccr.corp.intel.com ([169.254.5.110]) with mapi id 14.03.0439.000; Tue, 2 Jul 2019 15:23:29 +0800 From: "Ma, LihongX" To: "Wang, Yinan" , "dts@dpdk.org" Thread-Topic: [dts][PATCH V2] tests: add testsuite pvp vhost user built in net driver Thread-Index: AQHVLLWSC+l1XKxTz0amdV4EvvYD26auo+8AgAhQqWA= Date: Tue, 2 Jul 2019 07:23:28 +0000 Message-ID: References: <1561592132-2563-1-git-send-email-lihongx.ma@intel.com> In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: 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 V2] tests: add testsuite pvp vhost user built in net driver 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" Tested-by:lihong -----Original Message----- From: Wang, Yinan=20 Sent: Thursday, June 27, 2019 4:24 PM To: Ma, LihongX ; dts@dpdk.org Subject: RE: [dts][PATCH V2] tests: add testsuite pvp vhost user built in n= et driver Acked-by: Wang, Yinan > -----Original Message----- > From: Ma, LihongX > Sent: 2019=1B$BG/=1B(B6=1B$B7n=1B(B27=1B$BF|=1B(B 7:36 > To: dts@dpdk.org > Cc: Wang, Yinan ; Ma, LihongX=20 > > Subject: [dts][PATCH V2] tests: add testsuite pvp vhost user built in=20 > net driver >=20 > Signed-off-by: lihong > --- > ...TestSuite_pvp_vhost_user_built_in_net_driver.py | 224 > +++++++++++++++++++++ > 1 file changed, 224 insertions(+) > create mode 100644=20 > tests/TestSuite_pvp_vhost_user_built_in_net_driver.py >=20 > diff --git a/tests/TestSuite_pvp_vhost_user_built_in_net_driver.py > b/tests/TestSuite_pvp_vhost_user_built_in_net_driver.py > new file mode 100644 > index 0000000..1f560ae > --- /dev/null > +++ b/tests/TestSuite_pvp_vhost_user_built_in_net_driver.py > @@ -0,0 +1,224 @@ > +# BSD LICENSE > +# > +# Copyright(c) <2019> 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 # > +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT #=20 > +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 #=20 > +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 #=20 > +(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. > +""" > + > +import utils > +import time > +import re > +from test_case import TestCase > +from settings import HEADER_SIZE > +from pktgen import PacketGeneratorHelper > + > + > +class TestPVPVhostUserBuiltInNetDriver(TestCase): > + > + def set_up_all(self): > + """ > + Run at the start of each test suite. > + """ > + self.frame_sizes =3D [64, 128, 256, 512, 1024, 1518] > + self.core_config =3D "1S/4C/1T" > + 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 4, > + "There has not enought cores to test this suite %s" = % > + self.suite_name) > + > + self.core_list =3D self.dut.get_core_list( > + self.core_config, socket=3Dself.ports_socket) > + self.core_list_virtio_user =3D self.core_list[0:2] > + self.core_list_vhost_user =3D self.core_list[2:4] > + self.core_mask_virtio_user =3D > utils.create_mask(self.core_list_virtio_user) > + self.core_mask_vhost_user =3D > utils.create_mask(self.core_list_vhost_user) > + self.mem_channels =3D self.dut.get_memory_channels() > + self.headers_size =3D HEADER_SIZE['eth'] + HEADER_SIZE['ip'] > + self.prepare_vhost_switch() > + > + self.logger.info("You can config packet_size in file %s.cfg,"=20 > + % > self.suite_name + \ > + " in region 'suite' like packet_sizes=3D[64, 128= , 256]") > + if 'packet_sizes' in self.get_suite_cfg(): > + self.frame_sizes =3D self.get_suite_cfg()['packet_sizes'] > + # 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-net*", "# ") > + self.dut.send_expect("rm -rf ./vhost.out", "# ") > + self.dut.send_expect("killall -s INT vhost", "# ") > + self.dut.send_expect("killall -s INT testpmd", "# ") > + self.vhost_switch =3D self.dut.new_session(suite=3D"vhost-switch= ") > + self.virtio_user =3D self.dut.new_session(suite=3D"virtio-user") > + # Prepare the result table > + self.virtio_mac =3D "00:11:22:33:44:10" > + self.vlan_id =3D 1000 > + self.table_header =3D ['Frame'] > + self.table_header.append("Mode") > + self.table_header.append("Mpps") > + self.table_header.append("Queue Num") > + self.table_header.append("% linerate") > + self.result_table_create(self.table_header) > + > + def prepare_vhost_switch(self): > + cmd_info =3D self.dut.send_expect("grep 'define MAX_QUEUES' %s" = % > + "./examples/vhost/main.c", "# ") > + out =3D re.search("#define MAX_QUEUES\s*(\d*)", cmd_info) > + if out is not None: > + self.default_queue =3D out.group(1) > + else: > + self.default_queue =3D 128 > + sed_cmd =3D "sed -i -e 's/#define MAX_QUEUES.*$/#define > MAX_QUEUES %d/' " + \ > + "./examples/vhost/main.c" > + if self.nic in ['niantic']: > + max_queues =3D 128 > + else: > + max_queues =3D 512 > + self.dut.send_expect(sed_cmd % max_queues, "#", 10) > + out =3D self.dut.build_dpdk_apps('./examples/vhost') > + self.verify('make: Leaving directory' in out, "Compilation faile= d") > + self.verify("Error" not in out, "compilation l3fwd-power error") > + self.verify("No such" not in out, "Compilation error") > + > + def send_and_verify(self): > + """ > + Send packet with packet generator and verify > + """ > + for frame_size in self.frame_sizes: > + payload_size =3D frame_size - self.headers_size > + 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]) > + self.tester.scapy_append( > + 'wrpcap("vhost.pcap", > [Ether(dst=3D"%s")/Dot1Q(vlan=3D%s)/IP()/("X"*%d)])' % > + (self.virtio_mac, self.vlan_id, payload_size)) > + tgen_input.append((tx_port, rx_port, "vhost.pcap")) > + > + self.tester.scapy_execute() > + self.tester.pktgen.clear_streams() > + streams =3D > self.pktgen_helper.prepare_stream_from_tginput(tgen_input, 100, > + None, self.tester.pktgen) > + _, pps =3D > self.tester.pktgen.measure_throughput(stream_ids=3Dstreams) > + Mpps =3D pps / 1000000.0 > + self.verify(Mpps > 0, "%s can not receive packets of=20 > + frame > size %d" % (self.running_case, frame_size)) > + throughput =3D Mpps * 100 / \ > + float(self.wirespeed(self.nic, frame_size, 1)) > + > + results_row =3D [frame_size] > + results_row.append("builtin-net-driver") > + results_row.append(Mpps) > + results_row.append("1") > + results_row.append(throughput) > + self.result_table_add(results_row) > + > + def launch_vhost_switch(self): > + """ > + start vhost-switch on vhost > + """ > + self.dut.send_expect("rm -rf ./vhost.out", "#") > + command_line_client =3D=20 > + "./examples/vhost/build/app/vhost-switch " + > \ > + "-c %s -n %d --socket-mem 2048,2048 -- " += \ > + "-p 0x1 --mergeable 0 --vm2vm 1 " + \ > + "--builtin-net-driver > --socket-file ./vhost-net" + \ > + "> ./vhost.out &" > + command_line_client =3D command_line_client % > (self.core_mask_vhost_user, > + self.mem_channels) > + self.vhost_switch.send_expect(command_line_client, "# ", 120) > + time.sleep(15) > + try: > + self.logger.info("Launch vhost sample:") > + self.dut.session.copy_file_from(self.dut.base_dir + "/vhost.= out") > + fp =3D open('./vhost.out', 'r') > + out =3D fp.read() > + fp.close() > + if "Error" in out: > + raise Exception("Launch vhost sample failed") > + else: > + self.logger.info("Launch vhost sample finished") > + except Exception as e: > + self.verify(0, "ERROR: Failed to launch vhost sample: %s" % > + str(e)) > + > + def start_virtio_testpmd(self): > + """ > + start testpmd on virtio > + """ > + command_line_user =3D "./%s/app/testpmd -n %d -c %s " + \ > + "--no-pci --socket-mem 2048,2048 > --file-prefix=3Dvirtio-user " + \ > + > "--vdev=3Dnet_virtio_user0,mac=3D%s,path=3D./vhost-net,queues=3D1 " + \ > + "-- -i --rxq=3D1 --txq=3D1" > + command_line_user =3D command_line_user % (self.target, > + self.mem_channels, self.core_mask_virtio_user, self.virtio_m= ac) > + self.virtio_user.send_expect(command_line_user, "testpmd> ", 120= ) > + self.virtio_user.send_expect("set fwd mac", "testpmd> ", 120) > + self.virtio_user.send_expect("start tx_first", "testpmd> ", > + 120) > + > + def close_all_apps(self): > + """ > + close testpmd and vhost-switch > + """ > + self.virtio_user.send_expect("quit", "# ", 60) > + self.vhost_switch.send_expect("killall -s INT vhost", "# ", 60) > + self.dut.close_session(self.vhost_switch) > + self.dut.close_session(self.virtio_user) > + > + def test_perf_pvp_with_built_in_net_driver(self): > + """ > + PVP test with vhost built-in net driver > + """ > + self.launch_vhost_switch() > + self.start_virtio_testpmd() > + self.send_and_verify() > + self.result_table_print() > + self.close_all_apps() > + > + def tear_down(self): > + """ > + Run after each test case. > + """ > + self.dut.send_expect("killall -s INT testpmd", "# ") > + self.dut.send_expect("killall -s INT vhost", "# ") > + > + def tear_down_all(self): > + """ > + Run after each test suite. > + """ > + sed_cmd =3D "sed -i -e 's/#define MAX_QUEUES.*$/#define > MAX_QUEUES %d/' " + \ > + "./examples/vhost/main.c" > + self.dut.send_expect(sed_cmd % int(self.default_queue), "#", 10) > + self.dut.build_dpdk_apps('./examples/vhost') > -- > 2.7.4