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 5FC33A0546; Fri, 14 Feb 2020 11:42:25 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 0979C100C; Fri, 14 Feb 2020 11:42:25 +0100 (CET) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by dpdk.org (Postfix) with ESMTP id CA3043B5 for ; Fri, 14 Feb 2020 11:42:23 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 14 Feb 2020 02:42:22 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.70,440,1574150400"; d="scan'208";a="227358535" Received: from unknown (HELO dpdk-lijuan.sh.intel.com) ([10.67.119.192]) by fmsmga007.fm.intel.com with ESMTP; 14 Feb 2020 02:42:22 -0800 From: Lijuan Tu To: dts@dpdk.org Cc: Lijuan Tu Date: Sat, 15 Feb 2020 02:51:11 +0800 Message-Id: <1581706271-163689-1-git-send-email-lijuan.tu@intel.com> X-Mailer: git-send-email 1.8.3.1 Subject: [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" Signed-off-by: Lijuan Tu --- tests/TestSuite_vmdq_dcb.py | 211 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 211 insertions(+) create mode 100644 tests/TestSuite_vmdq_dcb.py 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 = self.dut.get_ports(self.nic) + self.verify(len(self.dut_ports) >= 2, "Insufficient ports") + self.socket = self.dut.get_numa_id(self.dut_ports[0]) + self.frame_size = 64 + self.destmac_port = "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 = self.logger.log_path + else: + cur_path = os.path.dirname( + os.path.dirname(os.path.realpath(__file__))) + self.output_path = os.sep.join([cur_path, self.logger.log_path]) + + # create an instance to set stream field setting + self.pktgen_helper = PacketGeneratorHelper() + + self.prios = range(8) + self.create_pcaps(self.prios) + + def set_up(self): + """ + Run before each test case. + """ + if self.running_case == "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 = self.dut.send_expect("make -C examples/vmdq_dcb", "#", 10) + self.verify("Error" not in out, "Compilation error") + + def rebuild_dpdk(self, nb_queue_per_vm=4): + """ + Rebuild dpdk + """ + self.dut.send_expect("sed -i -e 's/CONFIG_RTE_LIBRTE_I40E_QUEUE_NUM_PER_VM=?/" + "CONFIG_RTE_LIBRTE_I40E_QUEUE_NUM_PER_VM=%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 = self.dut.get_core_list("1S/%dC/1T" % ntcs, socket=self.socket) + self.verify(core_list is not None, "Requested %d cores failed" % ntcs) + core_mask = utils.create_mask(core_list) + port_mask = 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 = self.frame_size - HEADER_SIZE['ip'] - HEADER_SIZE['eth'] + for prio in prios: + self.tester.scapy_append( + 'flows = [Ether(dst="%s")/Dot1Q(vlan=0,prio=%d)/IP(src="1.2.3.4", dst="1.1.1.1")/("X"*%d)]' + % (self.destmac_port, prio, payload)) + pcap = 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 = self.tester.get_local_port(self.dut_ports[0]) + rx_port = self.tester.get_local_port(self.dut_ports[1]) + tgen_input = [] + for prio in prios: + pcap = 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 = { + '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 = self.dut.new_session() + vmdq_dcb_session.send_expect("kill -s SIGHUP `pgrep -fl vmdq_dcb_app | awk '{print $1}'`", "#", 20) + out = 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 same number of incoming packets. + """ + out = self.get_vmdq_stats() + lines_list = out.split("\r\n") + nb_packets = [] + for pool_info in lines_list: + if pool_info.startswith('Pool'): + nb_packets += pool_info.split()[2:] + nb_packets = list(map(int, nb_packets)) + self.verify(min(nb_packets) > 0, "Some queues don't get any packet!") + self.verify(float((max(nb_packets) - min(nb_packets))/max(nb_packets)) <= 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 = self.get_tgen_input(self.prios) + vm_config = self.set_fields(npools, npools) + self.tester.pktgen.clear_streams() + # Start traffic transmission using approx 10% of line rate. + ratePercent = 50 + # run packet generator + streams = self.pktgen_helper.prepare_stream_from_tginput(tgen_input, ratePercent, vm_config, self.tester.pktgen) + # set traffic option + options = {'duration': 15} + loss = self.tester.pktgen.measure_loss(stream_ids=streams, options=options) + self.logger.info("loss is [loss rate, SendNumbers, ReceNumbers]{}!".format(loss)) + # Verify there is no packet loss + self.verify(loss[1] == 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