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 BF557A0352; Thu, 16 Jan 2020 06:26:02 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 54D541C1BE; Thu, 16 Jan 2020 06:25:52 +0100 (CET) Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) by dpdk.org (Postfix) with ESMTP id E3B741BE81 for ; Thu, 16 Jan 2020 06:25:50 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga104.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 15 Jan 2020 21:25:50 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.70,325,1574150400"; d="scan'208";a="218402418" Received: from dpdk-moyufen06.sh.intel.com ([10.67.116.222]) by orsmga008.jf.intel.com with ESMTP; 15 Jan 2020 21:25:49 -0800 From: yufengmx To: dts@dpdk.org, lijuan.tu@intel.com Cc: yufengmx Date: Thu, 16 Jan 2020 13:28:15 +0800 Message-Id: <20200116052820.21902-9-yufengx.mo@intel.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20200116052820.21902-1-yufengx.mo@intel.com> References: <20200116052820.21902-1-yufengx.mo@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dts] [PATCH V3 8/13] tests/l3fwd_em: upload automation script 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" upload l3fwd_em suite automation script. Signed-off-by: yufengmx --- tests/TestSuite_l3fwd_em.py | 258 +++++------------------------------- 1 file changed, 30 insertions(+), 228 deletions(-) diff --git a/tests/TestSuite_l3fwd_em.py b/tests/TestSuite_l3fwd_em.py index ee50fcc..c586759 100644 --- a/tests/TestSuite_l3fwd_em.py +++ b/tests/TestSuite_l3fwd_em.py @@ -1,6 +1,6 @@ # BSD LICENSE # -# Copyright(c) 2010-2019 Intel Corporation. All rights reserved. +# Copyright(c) 2010-2020 Intel Corporation. All rights reserved. # All rights reserved. # # Redistribution and use in source and binary forms, with or without @@ -31,257 +31,59 @@ """ DPDK Test suite. -Layer-3 forwarding exact-match test script. +Layer-3 forwarding test script. """ - -import os -import utils -import string -import re from test_case import TestCase -from exception import VerifyFailure -from settings import HEADER_SIZE -from utils import * -from pktgen import PacketGeneratorHelper - - -class TestL3fwdEM(TestCase): - - path = "./examples/l3fwd/build/" - - test_cases_2_ports = {"1S/1C/1T": "%s -c %s -n %d -- -p %s -E --config '(P0,0,C{1.1.0}), (P1,0,C{1.1.0})' --hash-entry-num 0x400000", - "1S/2C/1T": "%s -c %s -n %d -- -p %s -E --config '(P0,0,C{1.1.0}), (P1,0,C{1.2.0})' --hash-entry-num 0x400000", - "1S/4C/1T": "%s -c %s -n %d -- -p %s -E --config '(P0,0,C{1.1.0}), (P1,0,C{1.2.0}),(P0,1,C{1.3.0}), (P1,1,C{1.4.0})' --hash-entry-num 0x400000" - } - - frame_sizes = [64, 65, 128, 256, 512, 1518] - methods = ['exact'] - - # - # - # Utility methods and other non-test code. - # - # Insert or move non-test functions here. - def portRepl(self, match): - """ - Function to replace P([0123]) pattern in tables - """ +from l3fwd_base import L3fwdBase, LPM, EM, L3_IPV6, L3_IPV4 - portid = match.group(1) - self.verify(int(portid) in range(4), "invalid port id") - if int(portid) >= len(valports): - return '0' - else: - return '%s' % valports[int(portid)] - # - # +class TestL3fwdEm(TestCase, L3fwdBase): # # Test cases. # - def set_up_all(self): """ Run at the start of each test suite. - - L3fwd Prerequisites """ # Based on h/w type, choose how many ports to use - ports = self.dut.get_ports(socket=1) - if not ports: - ports = self.dut.get_ports(socket=0) - - self.tester.extend_external_packet_generator(TestL3fwdEM, self) - # Verify that enough ports are available - self.verify(len(ports) >= 2, "Insufficient ports for speed testing") - - netdev = self.dut.ports_info[ports[0]]['port'] - - self.port_socket = netdev.socket - - # Verify that enough threads are available - cores = self.dut.get_core_list("1S/8C/2T") + self.dut_ports = self.dut.get_ports(self.nic) + valports = [ + _ for _ in self.dut_ports if self.tester.get_local_port(_) != -1] + self.logger.debug(valports) + self.verify_ports_number(valports) + # get socket and cores + socket = self.dut.get_numa_id(self.dut_ports[0]) + cores = self.dut.get_core_list("1S/8C/1T", socket=socket) self.verify(cores is not None, "Insufficient cores for speed testing") + # init l3fwd common base class parameters + self.l3fwd_init(valports, socket) + # preset testing environment + self.l3fwd_preset_test_environment(self.get_suite_cfg()) - global valports - valports = [_ for _ in ports if self.tester.get_local_port(_) != -1] - - self.verify(len(valports) >= 2, "Insufficient active ports for speed testing") - - pat = re.compile("P([0123])") - - # Update config file and rebuild to get best perf on FVL - self.dut.send_expect("sed -i -e 's/CONFIG_RTE_PCI_CONFIG=n/CONFIG_RTE_PCI_CONFIG=y/' ./config/common_linuxapp", "#", 20) - self.dut.send_expect("sed -i -e 's/CONFIG_RTE_PCI_EXTENDED_TAG=.*$/CONFIG_RTE_PCI_EXTENDED_TAG=\"on\"/' ./config/common_linuxapp", "#", 20) - self.dut.build_install_dpdk(self.target) - - out = self.dut.build_dpdk_apps("./examples/l3fwd") - self.verify("Error" not in out, "compilation error 1") - self.verify("No such file" not in out, "compilation error 2") - - self.l3fwd_test_results = {'header': [], - 'data': []} - # get dts output path - 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() - - def repl(self, match): - pid = match.group(1) - qid = match.group(2) - self.logger.debug("%s\n" % match.group(3)) - lcid = self.dut.get_lcore_id(match.group(3)) - self.logger.debug("%s\n" % lcid) - - global corelist - corelist.append(int(lcid)) - - self.verify(int(pid) in range(4), "invalid port id") - self.verify(lcid, "invalid thread id") - - return '%s,%s,%s' % (str(valports[int(pid)]), qid, lcid) - - def set_up(self): + def tear_down_all(self): """ - Run before each test case. + Run after each test suite. """ pass - def test_perf_l3fwd_2ports(self): + def set_up(self): """ - L3fwd main 2 ports. + Run before each test case. """ - - header_row = ["Frame", "mode", "S/C/T", "Mpps", "% linerate"] - self.l3fwd_test_results['header'] = header_row - self.result_table_create(header_row) - self.l3fwd_test_results['data'] = [] - - for frame_size in TestL3fwdEM.frame_sizes: - - # Prepare traffic flow - payload_size = frame_size - \ - HEADER_SIZE['ip'] - HEADER_SIZE['eth'] - HEADER_SIZE['tcp'] - - # Traffic for port0 - dmac_port0 = self.dut.get_mac_address(valports[0]) - flow1 = '[Ether(dst="%s")/IP(src="200.20.0.1",dst="201.0.0.0")/TCP(sport=12,dport=102)/("X"*%d)]' %(dmac_port0,payload_size) - - pcaps = {} - pcap = os.sep.join([self.output_path, "dst0.pcap"]) - pcaps[0] = pcap - self.tester.scapy_append('wrpcap("{0}",{1})'.format(pcap, flow1)) - - # Traffic for port1 - dmac_port1 = self.dut.get_mac_address(valports[1]) - flow2 = '[Ether(dst="%s")/IP(src="100.10.0.1",dst="101.0.0.0")/TCP(sport=11,dport=101)/("X"*%d)]' %(dmac_port1,payload_size) - - pcap = os.sep.join([self.output_path, "dst1.pcap"]) - pcaps[1] = pcap - self.tester.scapy_append('wrpcap("{0}",{1})'.format(pcap, flow2)) - self.tester.scapy_execute() - - # Prepare the command line - global corelist - pat = re.compile("P([0123]),([0123]),(C\{\d.\d.\d\})") - - pat2 = re.compile("C\{\d") - repl1 = "C{" + str(self.port_socket) - - coreMask = {} - rtCmdLines = dict(TestL3fwdEM.test_cases_2_ports) - for key in rtCmdLines.keys(): - corelist = [] - while pat.search(rtCmdLines[key]): - # Change the socket to the NIC's socket - if key.find('1S') >= 0: - rtCmdLines[key] = pat2.sub(repl1, rtCmdLines[key]) - rtCmdLines[key] = pat.sub(self.repl, rtCmdLines[key]) - - self.logger.info("%s\n" % str(corelist)) - coreMask[key] = utils.create_mask(set(corelist)) - - # measure by two different mode - for mode in TestL3fwdEM.methods: - - # start l3fwd - index = 0 - subtitle = [] - for cores in rtCmdLines.keys(): - - info = "Executing l3fwd using %s mode, 2 ports, %s and %d frame size.\n" % ( - mode, cores, frame_size) - - self.logger.info(info) - self.rst_report(info, annex=True) - - subtitle.append(cores) - cmdline = rtCmdLines[cores] % (TestL3fwdEM.path + "l3fwd", coreMask[cores], - self.dut.get_memory_channels(), utils.create_mask(valports[:2])) - - self.rst_report(cmdline + "\n", frame=True, annex=True) - - out = self.dut.send_expect(cmdline, "L3FWD: entering main loop", 120) - - # Measure test - tgenInput = [] - for rxPort in range(2): - # No use on rx/tx limitation - if rxPort % 2 == 0: - txIntf = self.tester.get_local_port(valports[rxPort + 1]) - else: - txIntf = self.tester.get_local_port(valports[rxPort - 1]) - - rxIntf = self.tester.get_local_port(valports[rxPort]) - port_index = valports[rxPort+1] if rxPort % 2 == 0 else valports[rxPort-1] - tgenInput.append((txIntf, rxIntf, pcaps[port_index])) - - vm_config = self.set_fields() - # clear streams before add new streams - self.tester.pktgen.clear_streams() - # run packet generator - streams = self.pktgen_helper.prepare_stream_from_tginput(tgenInput, 100, - vm_config, self.tester.pktgen) - traffic_opt = {'duration': 20, } - _, pps = self.tester.pktgen.measure_throughput(stream_ids=streams, options=traffic_opt) - - self.verify(pps > 0, "No traffic detected") - pps /= 1000000.0 - linerate = self.wirespeed(self.nic, frame_size, 2) - pct = pps * 100 / linerate - index += 1 - - # Stop l3fwd - self.dut.send_expect("^C", "#") - data_row = [frame_size, mode, cores, str(pps), str(pct)] - self.result_table_add(data_row) - self.l3fwd_test_results['data'].append(data_row) - - self.result_table_print() - - def set_fields(self): - ''' set ip protocol field behavior ''' - fields_config = { - 'ip': { - 'dst': {'range': 64, 'mask': '255.240.0.0', 'action': 'inc'} - },} - - return fields_config + pass def tear_down(self): """ Run after each test case. """ - pass + self.dut.kill_all() + self.l3fwd_reset_cur_case() - def tear_down_all(self): - """ - Run after each test suite. - """ - pass + def test_perf_throughput_ipv4_em(self): + self.l3fwd_set_cur_case('test_perf_throughput_ipv4_em') + self.ms_throughput(l3_proto=L3_IPV4, mode=EM) + + def test_perf_throughput_ipv6_em(self): + self.l3fwd_set_cur_case('test_perf_throughput_ipv6_em') + self.ms_throughput(l3_proto=L3_IPV6, mode=EM) -- 2.21.0