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 A4414A054E; Sat, 15 Feb 2020 11:22:25 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id D788E49E0; Sat, 15 Feb 2020 11:22:24 +0100 (CET) Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by dpdk.org (Postfix) with ESMTP id A39E6DE3 for ; Sat, 15 Feb 2020 11:22:22 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga106.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 15 Feb 2020 02:22:22 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.70,444,1574150400"; d="scan'208";a="282072966" Received: from fmsmsx103.amr.corp.intel.com ([10.18.124.201]) by FMSMGA003.fm.intel.com with ESMTP; 15 Feb 2020 02:22:22 -0800 Received: from fmsmsx114.amr.corp.intel.com (10.18.116.8) by FMSMSX103.amr.corp.intel.com (10.18.124.201) with Microsoft SMTP Server (TLS) id 14.3.439.0; Sat, 15 Feb 2020 02:22:21 -0800 Received: from shsmsx105.ccr.corp.intel.com (10.239.4.158) by FMSMSX114.amr.corp.intel.com (10.18.116.8) with Microsoft SMTP Server (TLS) id 14.3.439.0; Sat, 15 Feb 2020 02:22:21 -0800 Received: from shsmsx101.ccr.corp.intel.com ([169.254.1.222]) by SHSMSX105.ccr.corp.intel.com ([169.254.11.138]) with mapi id 14.03.0439.000; Sat, 15 Feb 2020 18:22:19 +0800 From: "Tu, Lijuan" To: "dts@dpdk.org" Thread-Topic: [dts] [PATCH] tests: add test script for example vmdq_dcb Thread-Index: AQHV4yNznsCyVrDkWk67CS0ZqiKCIqgcDVBg Date: Sat, 15 Feb 2020 10:22:18 +0000 Message-ID: <8CE3E05A3F976642AAB0F4675D0AD20E0BBC8576@SHSMSX101.ccr.corp.intel.com> References: <1581706271-163689-1-git-send-email-lijuan.tu@intel.com> In-Reply-To: <1581706271-163689-1-git-send-email-lijuan.tu@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="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dts] [PATCH] tests: add test script for example vmdq_dcb 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: Tu, Lijuan > Sent: Saturday, February 15, 2020 2:51 AM > To: dts@dpdk.org > Cc: Tu, Lijuan > Subject: [dts] [PATCH] tests: add test script for example vmdq_dcb >=20 > Signed-off-by: Lijuan Tu > --- > tests/TestSuite_vmdq_dcb.py | 211 > ++++++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 211 insertions(+) > create mode 100644 tests/TestSuite_vmdq_dcb.py >=20 > diff --git a/tests/TestSuite_vmdq_dcb.py b/tests/TestSuite_vmdq_dcb.py > new file mode 100644 index 0000000..8641c7c > --- /dev/null > +++ b/tests/TestSuite_vmdq_dcb.py > @@ -0,0 +1,211 @@ > +# BSD LICENSE > +# > +# Copyright(c) 2020 Intel Corporation. All rights reserved. > +# 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. > + > +Test example vmdq_dcb. > + > +""" > +import utils > +import os > +import re > +import random > +from test_case import TestCase > +from settings import HEADER_SIZE > +from pktgen import PacketGeneratorHelper > + > + > +class TestVmdqDcb(TestCase): > + > + def set_up_all(self): > + """ > + Run at the start of each test suite. > + """ > + self.tester.extend_external_packet_generator(TestVmdqDcb, self) > + self.dut_ports =3D self.dut.get_ports(self.nic) > + self.verify(len(self.dut_ports) >=3D 2, "Insufficient ports") > + self.socket =3D self.dut.get_numa_id(self.dut_ports[0]) > + self.frame_size =3D 64 > + self.destmac_port =3D "52:54:00:12:00:00" > + > + # get dts output path to place pcap files > + if self.logger.log_path.startswith(os.sep): > + self.output_path =3D self.logger.log_path > + else: > + cur_path =3D os.path.dirname( > + os.path.dirname(os.path.realpath(__file_= _))) > + self.output_path =3D os.sep.join([cur_path, > + self.logger.log_path]) > + > + # create an instance to set stream field setting > + self.pktgen_helper =3D PacketGeneratorHelper() > + > + self.prios =3D range(8) > + self.create_pcaps(self.prios) > + > + def set_up(self): > + """ > + Run before each test case. > + """ > + if self.running_case =3D=3D "test_perf_16pools_8tcs": > + self.rebuild_dpdk(8) > + else: > + self.rebuild_dpdk(4) > + self.build_app() > + > + def build_app(self): > + """ > + Build example "Vmdq_dcb". > + """ > + out =3D self.dut.send_expect("make -C examples/vmdq_dcb", "#", 1= 0) > + self.verify("Error" not in out, "Compilation error") > + > + def rebuild_dpdk(self, nb_queue_per_vm=3D4): > + """ > + Rebuild dpdk > + """ > + self.dut.send_expect("sed -i -e > 's/CONFIG_RTE_LIBRTE_I40E_QUEUE_NUM_PER_VM=3D?/" > + > "CONFIG_RTE_LIBRTE_I40E_QUEUE_NUM_PER_VM=3D%s/' ./config/common_ > base" % nb_queue_per_vm, "#", 20) > + self.dut.build_install_dpdk(self.target) > + > + def start_application(self, npools, ntcs): > + """ > + Prepare the commandline and start vmdq_dcb app > + """ > + core_list =3D self.dut.get_core_list("1S/%dC/1T" % ntcs, socket= =3Dself.socket) > + self.verify(core_list is not None, "Requested %d cores failed" %= ntcs) > + core_mask =3D utils.create_mask(core_list) > + port_mask =3D utils.create_mask(self.dut_ports) > + # Run the application > + self.dut.send_expect("./examples/vmdq_dcb/build/vmdq_dcb_app - > c %s -n 4 -- -p %s --nb-pools %s --nb-tcs %s " > + "--enable-rss" % (core_mask, port_mask, > + str(npools), str(ntcs)), "reading queues", 120) > + > + def create_pcaps(self, prios): > + """ > + create traffic flows to pcap files > + """ > + payload =3D self.frame_size - HEADER_SIZE['ip'] - HEADER_SIZE['e= th'] > + for prio in prios: > + self.tester.scapy_append( > + 'flows =3D [Ether(dst=3D"%s")/Dot1Q(vlan=3D0,prio=3D%d)/= IP(src=3D"1.2.3.4", > dst=3D"1.1.1.1")/("X"*%d)]' > + % (self.destmac_port, prio, payload)) > + pcap =3D os.sep.join([self.output_path, "%s%d.pcap" % > (self.suite_name, prio)]) > + self.tester.scapy_append('wrpcap("%s", flows)' % pcap) > + self.tester.scapy_execute() > + > + def get_tgen_input(self, prios): > + tx_port =3D self.tester.get_local_port(self.dut_ports[0]) > + rx_port =3D self.tester.get_local_port(self.dut_ports[1]) > + tgen_input =3D [] > + for prio in prios: > + pcap =3D os.sep.join([self.output_path, "%s%d.pcap" % > (self.suite_name, prio)]) > + tgen_input.append((tx_port, rx_port, "%s" % pcap)) > + return tgen_input > + > + > + def set_fields(self, vid_range, dmac_range): > + """ > + set ip protocol field behavior > + """ > + > + fields_config =3D { > + 'vlan': { > + 0: {'range': vid_range, 'action': 'inc'}}, > + 'mac': { > + 'dst': {'range': dmac_range, 'action': 'inc'}}, > + 'ip': { 'src': {'action': 'random'}}, > + } > + > + return fields_config > + > + def get_vmdq_stats(self): > + vmdq_dcb_session =3D self.dut.new_session() > + vmdq_dcb_session.send_expect("kill -s SIGHUP `pgrep -fl > vmdq_dcb_app | awk '{print $1}'`", "#", 20) > + out =3D self.dut.get_session_output() > + self.logger.info(out) > + return out > + > + def verify_all_vmdq_stats(self): > + """ > + Every RX queue should have received approximately (+/-15%) the s= ame > number of incoming packets. > + """ > + out =3D self.get_vmdq_stats() > + lines_list =3D out.split("\r\n") > + nb_packets =3D [] > + for pool_info in lines_list: > + if pool_info.startswith('Pool'): > + nb_packets +=3D pool_info.split()[2:] > + nb_packets =3D list(map(int, nb_packets)) > + self.verify(min(nb_packets) > 0, "Some queues don't get any pack= et!") > + self.verify(float((max(nb_packets) - > + min(nb_packets))/max(nb_packets)) <=3D 0.15, "Too wide variation in > + queue stats") > + > + def vmdq_dcb_test(self, npools, ntcs): > + """ > + vmdq_dcb test according to pools, tcs. > + """ > + self.start_application(npools, ntcs) > + > + # Transmit traffic > + tgen_input =3D self.get_tgen_input(self.prios) > + vm_config =3D self.set_fields(npools, npools) > + self.tester.pktgen.clear_streams() > + # Start traffic transmission using approx 10% of line rate. > + ratePercent =3D 50 > + # run packet generator > + streams =3D > self.pktgen_helper.prepare_stream_from_tginput(tgen_input, ratePercent, > vm_config, self.tester.pktgen) > + # set traffic option > + options =3D {'duration': 15} > + loss =3D self.tester.pktgen.measure_loss(stream_ids=3Dstreams, > options=3Doptions) > + self.logger.info("loss is [loss rate, SendNumbers, > ReceNumbers]{}!".format(loss)) > + # Verify there is no packet loss > + self.verify(loss[1] =3D=3D loss[2], "Packet Loss! Send: %d, but = only > Receive: %d!".format(loss[1], loss[2])) > + self.verify_all_vmdq_stats() > + > + def test_perf_32pools_4tcs(self): > + > + self.vmdq_dcb_test(32, 4) > + > + def test_perf_16pools_8tcs(self): > + > + self.vmdq_dcb_test(16, 8) > + > + def tear_down(self): > + """ > + Run after each test case. > + """ > + self.dut.kill_all() > + > + def tear_down_all(self): > + """ > + Run after each test suite. > + """ > + self.rebuild_dpdk(4) > -- > 1.8.3.1