From: hanyingya <yingyax.han@intel.com>
To: dts@dpdk.org
Cc: hanyingya <yingyax.han@intel.com>
Subject: [dts] [PATCH V1]tests/l3fwd: l3fwd script refactoring
Date: Thu, 20 Jun 2019 14:56:21 +0000 [thread overview]
Message-ID: <20190620145621.43712-1-yingyax.han@intel.com> (raw)
Signed-off-by: hanyingya <yingyax.han@intel.com>
---
tests/TestSuite_l3fwd.py | 535 +++++++++++++++++++++------------------
1 file changed, 284 insertions(+), 251 deletions(-)
diff --git a/tests/TestSuite_l3fwd.py b/tests/TestSuite_l3fwd.py
index 78eaee7..8e4e23e 100644
--- a/tests/TestSuite_l3fwd.py
+++ b/tests/TestSuite_l3fwd.py
@@ -1,6 +1,6 @@
# BSD LICENSE
#
-# Copyright(c) 2010-2014 Intel Corporation. All rights reserved.
+# Copyright(c) 2010-2019 Intel Corporation. All rights reserved.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@@ -36,42 +36,32 @@ Layer-3 forwarding test script.
import utils
import string
+import time
import re
+import os
from test_case import TestCase
from exception import VerifyFailure
from settings import HEADER_SIZE
from etgen import IxiaPacketGenerator
-class TestL3fwd(TestCase,IxiaPacketGenerator):
- path = "./examples/l3fwd/build/"
+class TestL3fwd(TestCase, IxiaPacketGenerator):
- test_cases_2_ports = [(1,"1S/1C/1T","%s -c %s -n %d -- -P -p %s --config '(P0,0,C{1.1.0}), (P1,0,C{1.1.0})'"),
- #"1S/1C/2T": "%s -c %s -n %d -- -p %s --config '(P0,0,C{1.1.0}), (P1,0,C{1.1.1})'",
- (1,"1S/2C/1T","%s -c %s -n %d -- -P -p %s --config '(P0,0,C{1.1.0}), (P1,0,C{1.2.0})'"),
- (1,"1S/4C/1T", "%s -c %s -n %d -- -p %s --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})'"),
- #"2S/2C/1T": "%s -c %s -n %d -- -p %s --config '(P0,0,C{0.1.0}), (P1,0,C{0.2.0}),(P0,1,C{1.3.0}), (P1,1,C{1.4.0})'",
- ]
-
- test_cases_4_ports = [(1, "1S/1C/1T",
- "%s -c %s -n %d -- -P -p %s --config '(P0,0,C{1.1.0}),(P1,0,C{1.1.0}),(P2,0,C{1.1.0}),(P3,0,C{1.1.0})'"),
- #(1, "1S/2C/2T",
- # "%s -c %s -n %d -- -p %s --config '(P0,0,C{1.1.0}),(P1,0,C{1.1.1}),(P2,0,C{1.2.0}),(P3,0,C{1.2.1})'"),
- (1, "1S/4C/1T",
- "%s -c %s -n %d -- -P -p %s --config '(P0,0,C{1.1.0}),(P1,0,C{1.2.0}),(P2,0,C{1.3.0}),(P3,0,C{1.4.0})'"),
- #(2, "1S/8C/1T",
- #"%s -c %s -n %d -- -p %s --config '(P0,0,C{1.1.0}),(P0,1,C{1.2.0}),(P1,0,C{1.3.0}),(P1,1,C{1.4.0}),(P2,0,C{1.5.0}),(P2,1,C{1.6.0}),(P3,0,C{1.7.0}),(P3,1,C{1.8.0})'"),
- #(2, "2S/2C/1T",
- # "%s -c %s -n %d -- -p %s --config '(P0,0,C{1.1.0}),(P1,0,C{1.2.0}),(P2,0,C{0.3.0}),(P3,0,C{0.4.0})'"),
- ]
-
- queues_4_ports = []
-
- for case in test_cases_4_ports:
- if case[0] * 4 not in queues_4_ports:
- queues_4_ports.append(case[0] * 4)
-
- host_table = [
+ path = "./examples/l3fwd/build/"
+ cmdline_2_ports = {
+ "1S/1C/1T": "%s -c %s -n %d -- -p %s -P --config '(P0,0,C{1.1.0}), (P1,0,C{1.1.0})'",
+ "1S/1C/2T": "%s -c %s -n %d -- -p %s -P --config '(P0,0,C{1.1.0}), (P1,0,C{1.1.1})'",
+ "1S/2C/1T": "%s -c %s -n %d -- -p %s -P --config '(P0,0,C{1.1.0}), (P1,0,C{1.2.0})'",
+ "1S/4C/1T": "%s -c %s -n %d -- -p %s -P --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})'"}
+
+ cmdline_4_ports = {
+ "1S/1C/1T": "%s -c %s -n %d -- -p %s -P --config '(P0,0,C{1.1.0}), (P1,0,C{1.1.0}), (P2,0,C{1.1.0}), (P3,0,C{1.1.0})'",
+ "1S/2C/2T": "%s -c %s -n %d -- -p %s -P --config '(P0,0,C{1.1.0}), (P1,0,C{1.1.1}), (P2,0,C{1.2.0}), (P3,0,C{1.2.1})'",
+ "1S/4C/1T": "%s -c %s -n %d -- -p %s -P --config '(P0,0,C{1.1.0}), (P1,0,C{1.2.0}), (P2,1,C{1.3.0}), (P3,1,C{1.4.0})'",
+ "1S/8C/1T": "%s -c %s -n %d -- -p %s -P --config '(P0,0,C{1.1.0}), (P1,0,C{1.2.0}), (P2,0,C{1.3.0}), (P3,0,C{1,4,0}),\
+ (P0,1,C{1.5.0}), (P1,1,C{1.6.0}), (P2,1,C{1.7.0}), (P3,1,C{1,8,0})'"}
+
+ ipv4_em_table = [
"{{IPv4(10,100,0,1), IPv4(1,2,3,4), 1, 10, IPPROTO_UDP}, P0}",
"{{IPv4(10,101,0,1), IPv4(1,2,3,4), 1, 10, IPPROTO_UDP}, P0}",
"{{IPv4(11,100,0,1), IPv4(1,2,3,4), 1, 11, IPPROTO_UDP}, P1}",
@@ -82,7 +72,7 @@ class TestL3fwd(TestCase,IxiaPacketGenerator):
"{{IPv4(13,101,0,1), IPv4(1,2,3,4), 1, 13, IPPROTO_UDP}, P3}",
]
- lpm_table = [
+ ipv4_lpm_table = [
"{IPv4(10,100,0,0), 24, P0}",
"{IPv4(10,101,0,0), 24, P0}",
"{IPv4(11,100,0,0), 24, P1}",
@@ -93,125 +83,130 @@ class TestL3fwd(TestCase,IxiaPacketGenerator):
"{IPv4(13,101,0,0), 24, P3}",
]
- frame_sizes = [64, 72, 128, 256, 512, 1024, 1518, 2048] # 65, 128
-
- methods = ['lpm']#, '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
- """
-
- 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)]
+ ipv6_em_table = [
+ "{{{0xfe, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x1b, 0x21, 0xff, 0xfe, 0x91, 0x38, 0x05}, {0xfe, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x1e, 0x67, 0xff, 0xfe, 0x0d, 0xb6, 0x0a}, 1, 10, IPPROTO_UDP}, P0}",
+ "{{{0xfe, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x1b, 0x21, 0xff, 0xfe, 0x91, 0x38, 0x05}, {0xfe, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x1e, 0x67, 0xff, 0xfe, 0x0d, 0xb6, 0x0a}, 1, 10, IPPROTO_UDP}, P0}",
+ "{{{0x2a, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x1b, 0x21, 0xff, 0xfe, 0x91, 0x38, 0x05}, {0xfe, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x1e, 0x67, 0xff, 0xfe, 0x0d, 0xb6, 0x0a}, 1, 11, IPPROTO_UDP}, P1}",
+ "{{{0x2a, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x1b, 0x21, 0xff, 0xfe, 0x91, 0x38, 0x05}, {0xfe, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x1e, 0x67, 0xff, 0xfe, 0x0d, 0xb6, 0x0a}, 1, 11, IPPROTO_UDP}, P1}",
+ "{{{0x2b, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x1b, 0x21, 0xff, 0xfe, 0x91, 0x38, 0x05}, {0xfe, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x1e, 0x67, 0xff, 0xfe, 0x0d, 0xb6, 0x0a}, 1, 12, IPPROTO_UDP}, P2}",
+ "{{{0x2b, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x1b, 0x21, 0xff, 0xfe, 0x91, 0x38, 0x05}, {0xfe, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x1e, 0x67, 0xff, 0xfe, 0x0d, 0xb6, 0x0a}, 1, 12, IPPROTO_UDP}, P2}",
+ "{{{0x2c, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x1b, 0x21, 0xff, 0xfe, 0x91, 0x38, 0x05}, {0xfe, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x1e, 0x67, 0xff, 0xfe, 0x0d, 0xb6, 0x0a}, 1, 13, IPPROTO_UDP}, P3}",
+ "{{{0x2c, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x1b, 0x21, 0xff, 0xfe, 0x91, 0x38, 0x05}, {0xfe, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x1e, 0x67, 0xff, 0xfe, 0x0d, 0xb6, 0x0a}, 1, 13, IPPROTO_UDP}, P3}",
+ ]
- #
- # Test cases.
- #
+ ipv6_lpm_table = [
+ "{{0xfe, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x1b, 0x21, 0xff, 0xfe, 0x91, 0x38, 0x05}, 64,P0}",
+ "{{0xfe, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x1b, 0x21, 0xff, 0xfe, 0x91, 0x38, 0x05}, 64,P0}",
+ "{{0x2a, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x1b, 0x21, 0xff, 0xfe, 0x91, 0x38, 0x05}, 64,P1}",
+ "{{0x2a, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x1b, 0x21, 0xff, 0xfe, 0x91, 0x38, 0x05}, 64,P1}",
+ "{{0x2b, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x1b, 0x21, 0xff, 0xfe, 0x91, 0x38, 0x05}, 64,P2}",
+ "{{0x2b, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x1b, 0x21, 0xff, 0xfe, 0x91, 0x38, 0x05}, 64,P2}",
+ "{{0x2c, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x1b, 0x21, 0xff, 0xfe, 0x91, 0x38, 0x05}, 64,P3}",
+ "{{0x2c, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x1b, 0x21, 0xff, 0xfe, 0x91, 0x38, 0x05}, 64,P3}",
+ ]
def set_up_all(self):
"""
Run at the start of each test suite.
-
-
L3fwd Prerequisites
"""
+ self.tester.extend_external_packet_generator(TestL3fwd, self)
# 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.dut_ports = self.dut.get_ports(self.nic)
+ global valports
+ valports = [_ for _ in self.dut_ports if self.tester.get_local_port(_) != -1]
- self.tester.extend_external_packet_generator(TestL3fwd, 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
- if self.port_socket == -1:
- self.port_socket = 0
-
-
- # Verify that enough threads are available
- cores = self.dut.get_core_list("1S/4C/1T")
- self.verify(cores is not None, "Insufficient cores for speed testing")
+ self.verify(len(valports) == 2 or len(valports) == 4, "Port number must be 2 or 4.")
- global valports
- valports = [_ for _ in ports if self.tester.get_local_port(_) != -1]
-
- self.verify(len(valports) >= 2, "Insufficient active ports for speed testing")
+ # get socket and cores
+ self.socket = self.dut.get_numa_id(self.dut_ports[0])
+ self.cores = self.dut.get_core_list("1S/8C/1T", socket=self.socket)
+ self.verify(self.cores is not None, "Insufficient cores for speed testing")
+
+ # self.frame_sizes = [64, 128, 256, 512, 1024, 1518] # 65, 128
+ self.frame_sizes = [64, 128]
- 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_base", "#", 20)
- self.dut.send_expect("sed -i -e 's/CONFIG_RTE_PCI_EXTENDED_TAG=.*$/CONFIG_RTE_PCI_EXTENDED_TAG=\"on\"/' ./config/common_base", "#", 20)
- self.dut.send_expect("sed -i -e 's/define RTE_TEST_RX_DESC_DEFAULT.*$/define RTE_TEST_RX_DESC_DEFAULT 2048/' ./examples/l3fwd/main.c", "#", 20)
- self.dut.send_expect("sed -i -e 's/define RTE_TEST_TX_DESC_DEFAULT.*$/define RTE_TEST_TX_DESC_DEFAULT 2048/' ./examples/l3fwd/main.c", "#", 20)
- self.dut.build_install_dpdk(self.target)
-
- # Prepare long prefix match table, replace P(x) port pattern
- lpmStr = "static struct ipv4_l3fwd_lpm_route ipv4_l3fwd_lpm_route_array[] = {\\\n"
- for idx in range(len(TestL3fwd.lpm_table)):
- TestL3fwd.lpm_table[idx] = pat.sub(self.portRepl, TestL3fwd.lpm_table[idx])
- lpmStr = lpmStr + ' ' * 4 + TestL3fwd.lpm_table[idx] + ",\\\n"
- lpmStr = lpmStr + "};"
- self.logger.debug(lpmStr)
-
- # Prepare host route table, replace P(x) port pattern
- exactStr = "static struct ipv4_l3fwd_em_route ipv4_l3fwd_em_route_array[] = {\\\n"
- for idx in range(len(TestL3fwd.host_table)):
- TestL3fwd.host_table[idx] = pat.sub(self.portRepl, TestL3fwd.host_table[idx])
- exactStr = exactStr + ' ' * 4 + TestL3fwd.host_table[idx] + ",\\\n"
- exactStr = exactStr + "};"
- self.logger.debug(exactStr)
-
- # Compile l3fwd with LPM lookup.
- self.dut.send_expect(r"sed -i '/ipv4_l3fwd_lpm_route_array\[\].*{/,/^\}\;/c\\%s' examples/l3fwd/l3fwd_lpm.c" % lpmStr, "# ")
- out = self.dut.build_dpdk_apps("./examples/l3fwd", "USER_FLAGS=-DAPP_LOOKUP_METHOD=1")
- self.verify("Error" not in out, "compilation error 1")
- self.verify("No such file" not in out, "compilation error 2")
+ if self.nic in ["fortville_sprit", "fortville_eagle", "fortville_25g"]:
+ self.dut.send_expect("sed -i -e 's/CONFIG_RTE_LIBRTE_I40E_16BYTE_RX_DESC=n/CONFIG_RTE_LIBRTE_"
+ "I40E_16BYTE_RX_DESC=y/' ./config/common_base", "#", 20)
+ self.dut.build_install_dpdk(self.target)
+
+ self.logger.info("Configure RX/TX descriptor to 2048, and re-build ./examples/l3fwd")
+ self.dut.send_expect("sed -i -e 's/define RTE_TEST_RX_DESC_DEFAULT.*$/"
+ + "define RTE_TEST_RX_DESC_DEFAULT 2048/' ./examples/l3fwd/main.c", "#", 20)
+ self.dut.send_expect("sed -i -e 's/define RTE_TEST_TX_DESC_DEFAULT.*$/"
+ + "define RTE_TEST_TX_DESC_DEFAULT 2048/' ./examples/l3fwd/main.c", "#", 20)
+ self.method_table = {"ipv4_l3fwd_lpm": TestL3fwd.ipv4_lpm_table, "ipv4_l3fwd_em": TestL3fwd.ipv4_em_table,
+ "ipv6_l3fwd_lpm": TestL3fwd.ipv6_lpm_table, "ipv6_l3fwd_em": TestL3fwd.ipv6_em_table}
+
+ self.pat = re.compile("P([0123])")
+ self.test_results = {'header': [], 'data': []}
- # Backup the LPM exe and clean up the build.
- self.dut.send_expect("mv -f examples/l3fwd/build/l3fwd examples/l3fwd/build/l3fwd_lpm", "# ")
- out = self.dut.send_expect("make clean -C examples/l3fwd", "# ")
+ def set_up(self):
+ """
+ Run before each test case.
+ """
+ pass
- # Compile l3fwd with hash/exact lookup.
- self.dut.send_expect(r"sed -i -e '/ipv4_l3fwd_em_route_array\[\].*{/,/^\}\;/c\\%s' examples/l3fwd/l3fwd_em.c" % exactStr, "# ")
- out = self.dut.build_dpdk_apps("./examples/l3fwd", "USER_FLAGS=-DAPP_LOOKUP_METHOD=0")
+ def portRepl(self, match):
+ """
+ Function to replace P([0123]) pattern in tables
+ """
+ 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)]
+ def install_l3fwd_application(self, l3_proto, mode):
+ """
+ Prepare long prefix match table, replace P(x) port pattern
+ """
+ l3fwd_method = l3_proto + "_l3fwd_" + mode
+ l3fwdStr = "static struct %s_route %s_route_array[] = {\\\n" % (l3fwd_method, l3fwd_method)
+ for idx in range(len(self.method_table[l3fwd_method])):
+ self.method_table[l3fwd_method][idx] = self.pat.sub(self.portRepl, self.method_table[l3fwd_method][idx])
+ l3fwdStr = l3fwdStr + '' * 4 + self.method_table[l3fwd_method][idx] + ",\\\n"
+ l3fwdStr = l3fwdStr + "};"
+ self.dut.send_expect(r"sed -i '/%s_route_array\[\].*{/,/^\}\;/c\\%s' examples/l3fwd/l3fwd_%s.c"
+ % (l3fwd_method, l3fwdStr, mode), "# ")
+ self.dut.send_expect("make clean -C examples/l3fwd", "# ")
+ if "lpm" in l3fwd_method:
+ out = self.dut.build_dpdk_apps("./examples/l3fwd", "USER_FLAGS=-DAPP_LOOKUP_METHOD=1")
+ elif "em" in l3fwd_method:
+ out = self.dut.build_dpdk_apps("./examples/l3fwd", "USER_FLAGS=-DAPP_LOOKUP_METHOD=0")
self.verify("Error" not in out, "compilation error 1")
self.verify("No such file" not in out, "compilation error 2")
- # Backup the Hash/Exact exe.
- self.dut.send_expect("mv -f examples/l3fwd/build/l3fwd examples/l3fwd/build/l3fwd_exact", "# ")
-
- self.l3fwd_test_results = {'header': [],
- 'data': []}
+ # Backup the l3fwd exe.
+ self.dut.send_expect("mv -f examples/l3fwd/build/l3fwd examples/l3fwd/build/%s" % l3fwd_method, "# ")
def flows(self):
"""
Return a list of packets that implements the flows described in the
l3fwd test plan.
-
- """
- return [
- 'IP(src="1.2.3.4",dst="11.100.0.1")',
- 'IP(src="1.2.3.4",dst="11.101.0.1")',
- 'IP(src="1.2.3.4",dst="10.100.0.1")',
- 'IP(src="1.2.3.4",dst="10.101.0.1")',
- 'IP(src="1.2.3.4",dst="13.100.0.1")',
- 'IP(src="1.2.3.4",dst="13.101.0.1")',
- 'IP(src="1.2.3.4",dst="12.100.0.1")',
- 'IP(src="1.2.3.4",dst="12.101.0.1")']
+ """
+ return {"ipv4": ['IP(src="1.2.3.4",dst="192.18.1.0")',
+ 'IP(src="1.2.3.4",dst="192.18.1.1")',
+ 'IP(src="1.2.3.4",dst="192.18.0.0")',
+ 'IP(src="1.2.3.4",dst="192.18.0.1")',
+ 'IP(src="1.2.3.4",dst="192.18.3.0")',
+ 'IP(src="1.2.3.4",dst="192.18.3.1")',
+ 'IP(src="1.2.3.4",dst="192.18.2.0")',
+ 'IP(src="1.2.3.4",dst="192.18.2.1")'],
+ "ipv6": [
+ 'IPv6(src="fe80:0000:0000:0000:021e:67ff:fe0d:b60a",dst="fe80:0000:0000:0000:021b:21ff:fe91:3805")/UDP(sport=10,dport=1)',
+ 'IPv6(src="fe80:0000:0000:0000:021e:67ff:fe0d:b60a",dst="fe80:0000:0000:0000:031b:21ff:fe91:3805")/UDP(sport=10,dport=1)',
+ 'IPv6(src="fe80:0000:0000:0000:021e:67ff:fe0d:b60a",dst="2a80:0000:0000:0000:021b:21ff:fe91:3805")/UDP(sport=11,dport=1)',
+ 'IPv6(src="fe80:0000:0000:0000:021e:67ff:fe0d:b60a",dst="2a80:0000:0000:0000:031b:21ff:fe91:3805")/UDP(sport=11,dport=1)',
+ 'IPv6(src="fe80:0000:0000:0000:021e:67ff:fe0d:b60a",dst="2b80:0000:0000:0000:021b:21ff:fe91:3805")/UDP(sport=12,dport=1)',
+ 'IPv6(src="fe80:0000:0000:0000:021e:67ff:fe0d:b60a",dst="2b80:0000:0000:0000:031b:21ff:fe91:3805")/UDP(sport=12,dport=1)',
+ 'IPv6(src="fe80:0000:0000:0000:021e:67ff:fe0d:b60a",dst="2c80:0000:0000:0000:021b:21ff:fe91:3805")/UDP(sport=13,dport=1)',
+ 'IPv6(src="fe80:0000:0000:0000:021e:67ff:fe0d:b60a",dst="2c80:0000:0000:0000:031b:21ff:fe91:3805")/UDP(sport=13,dport=1)'
+ ]}
def repl(self, match):
pid = match.group(1)
@@ -222,141 +217,179 @@ class TestL3fwd(TestCase,IxiaPacketGenerator):
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 perpare_commandline(self, ports):
"""
- Run before each test case.
+ Generate the command line based on the number of ports
"""
- pass
-
- def test_perf_rfc2544(self):
-
- ports = self.dut.get_ports()
- ports_num = len(ports)
- header_row = ["Frame_size(byte)", "mode", "S/C/T", "zero_loss_throughput(Mpps)", " % zero_loss_rate"]# "LR_tx_pkts(1min)", "LR_rx_pkts(1min)", "LR_loss_pkts(1min)", "% zero_loss_rate", "zero_loss_throughput(Mpps)"]
- self.l3fwd_test_results['header'] = header_row
+ global corelist
+ pat = re.compile("P([0123]),([0123]),(C\{\d.\d.\d\})")
+ core_mask = {}
+ if ports == 2:
+ rtCmdLines = dict(TestL3fwd.cmdline_2_ports)
+ elif ports == 4:
+ rtCmdLines = dict(TestL3fwd.cmdline_4_ports)
+
+ for key in rtCmdLines.keys():
+ corelist = []
+ while pat.search(rtCmdLines[key]):
+ print rtCmdLines[key]
+ rtCmdLines[key] = pat.sub(self.repl, rtCmdLines[key])
+ core_mask[key] = utils.create_mask(set(corelist))
+ return rtCmdLines, core_mask
+
+ def create_pcap_file(self, frame_size, l3_proto):
+ """
+ Prepare traffic flow for packet generator
+ """
+ if l3_proto == 'ipv4':
+ payload_size = frame_size - HEADER_SIZE['eth'] - HEADER_SIZE['ip'] - HEADER_SIZE['udp']
+ else:
+ # l3_proto == 'ipv6'
+ payload_size = frame_size - HEADER_SIZE['eth'] - HEADER_SIZE['ipv6'] - HEADER_SIZE['udp']
+ if frame_size == 64:
+ payload_size = frame_size + 2 - HEADER_SIZE['eth'] - HEADER_SIZE['ipv6'] - HEADER_SIZE['udp']
+
+ for _port in valports:
+ dmac = self.dut.get_mac_address(valports[_port])
+ layer3s = self.flows()[l3_proto][_port * 2:(_port + 1) * 2]
+ for l3 in layer3s:
+ flow = ['Ether(dst="%s")/%s/UDP()/("X"*%d)' % (dmac, l3, payload_size)]
+ self.tester.scapy_append('wrpcap("dst%d.pcap", [%s])' % (valports[_port], string.join(flow, ',')))
+ self.tester.scapy_execute()
+
+ def prepare_steam(self):
+ """
+ create streams for ports, one port one stream
+ """
+ tgen_input = []
+ for rxPort in valports:
+ if rxPort % len(valports) == 0 or rxPort % len(valports) == 2:
+ txIntf = self.tester.get_local_port(valports[rxPort + 1])
+ rxIntf = self.tester.get_local_port(valports[rxPort])
+ tgen_input.append((txIntf, rxIntf, "dst%d.pcap" % valports[rxPort + 1]))
+ elif rxPort % len(valports) == 1 or rxPort % len(valports) == 3:
+ txIntf = self.tester.get_local_port(valports[rxPort - 1])
+ rxIntf = self.tester.get_local_port(valports[rxPort])
+ tgen_input.append((txIntf, rxIntf, "dst%d.pcap" % valports[rxPort - 1]))
+ return tgen_input
+
+ def create_result_table(self, ttl, ttl1, ttl2, ttl3, ttl4):
+
+ header_row = [ttl, ttl1, ttl2, ttl3, ttl4]
+ self.test_results['header'] = header_row
self.result_table_create(header_row)
- self.l3fwd_test_results['data'] = []
-
- for frame_size in TestL3fwd.frame_sizes:
-
- # Prepare traffic flow
- payload_size = frame_size - \
- HEADER_SIZE['ip'] - HEADER_SIZE['eth'] - HEADER_SIZE['tcp']
-
- for _port in range(ports_num):
- dmac = self.dut.get_mac_address(valports[_port])
- flows = ['Ether(dst="%s")/%s/TCP()/("X"*%d)' % (dmac, flow, payload_size) for flow in self.flows()[_port *2:(_port +1)*2]]
- self.tester.scapy_append('wrpcap("dst%d.pcap", [%s])' %(valports[_port],string.join(flows,',')))
- self.tester.scapy_execute()
-
- self.rst_report("Flows for %d ports, %d frame size.\n" % (ports_num, frame_size),
- annex=True)
- self.rst_report("%s" % string.join(flows, '\n'),
- frame=True, annex=True)
-
- # 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 = {}
- cmdlist = []
- if ports_num == 4:
- for i in TestL3fwd.test_cases_4_ports:
- cmdlist.append(i)
- else:
- for i in TestL3fwd.test_cases_2_ports:
- cmdlist.append(i)
- if 'eagle' in self.nic:
- del cmdlist[2]
- else:
- del cmdlist[1]
- for cmdline_pat in cmdlist:
- corelist = []
- rtCmdLines[cmdline_pat[1]] = cmdline_pat[2]
- while pat.search(rtCmdLines[cmdline_pat[1]]):
- # Change the socket to the NIC's socket
- if cmdline_pat[1].find('1S')>=0:
- rtCmdLines[cmdline_pat[1]] = pat2.sub(repl1, rtCmdLines[cmdline_pat[1]])
- rtCmdLines[cmdline_pat[1]] = pat.sub(self.repl, rtCmdLines[cmdline_pat[1]])
-
- self.logger.info("%s\n" % str(corelist))
- coreMask[cmdline_pat[1]] = utils.create_mask(set(corelist))
-
- # measure by two different mode
- for mode in TestL3fwd.methods:
-
- # start l3fwd
- index = 0
- subtitle = []
- for cores in rtCmdLines.keys():
-
- #in order to save time, only some of the cases will be run.
- if mode == "lpm" and (cores == "1S/2C/1T" or cores == "1S/4C/1T"):
- info = "Executing l3fwd using %s mode, %d ports, %s and %d frame size.\n" % (
- mode, ports_num, cores, frame_size)
-
- self.logger.info(info)
- self.rst_report(info, annex=True)
-
- subtitle.append(cores)
- cmdline = rtCmdLines[cores] % (TestL3fwd.path + "l3fwd_" + mode, coreMask[cores],
- self.dut.get_memory_channels(), utils.create_mask(valports[:ports_num]))
- if self.nic == "niantic":
- cmdline = cmdline + " --parse-ptype"
-
- if frame_size > 1518:
- cmdline = cmdline + " --enable-jumbo --max-pkt-len %d" % frame_size
- self.rst_report(cmdline + "\n", frame=True, annex=True)
-
- out = self.dut.send_expect(cmdline, "L3FWD:", 120)
-
- # Measure test
- tgenInput = []
- for rxPort in range(ports_num):
- # 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])
- if rxPort % 2 == 0:
- tgenInput.append((txIntf, rxIntf, "dst%d.pcap" %valports[rxPort+1]))
- else:
- tgenInput.append((txIntf, rxIntf, "dst%d.pcap" %valports[rxPort-1]))
-
- zero_loss_rate, tx_pkts, rx_pkts = self.tester.run_rfc2544(tgenInput, delay=60)
- loss_pkts = tx_pkts - rx_pkts
- self.dut.send_expect("^C", "#")
- linerate = self.wirespeed(self.nic, frame_size, ports_num)
- zero_loss_throughput = (linerate * zero_loss_rate) / 100
-
- tx_pkts = utils.human_read_number(tx_pkts)
- rx_pkts = utils.human_read_number(rx_pkts)
- loss_pkts = utils.human_read_number(loss_pkts)
-
-
- #data_row = [frame_size, mode, cores, tx_pkts, rx_pkts, loss_pkts, zero_loss_rate, zero_loss_throughput]
- data_row = [frame_size, mode, cores, zero_loss_throughput, zero_loss_rate]
- self.result_table_add(data_row)
- self.l3fwd_test_results['data'].append(data_row)
- else:
- pass
-
- index += 1
+ self.test_results['data'] = []
+ def measure_throughput(self, l3_proto, mode):
+ """
+ measure throughput according to Layer-3 Protocal and Lookup Mode
+ """
+ # create result table
+ self.create_result_table("Frame Size", "Mode", "S/C/T", "Mpps", "% Linerate")
+ # build application
+ self.install_l3fwd_application(l3_proto, mode)
+ # perpare commandline and core mask
+ rtCmdLines, core_mask = self.perpare_commandline(len(valports))
+
+ for cores in rtCmdLines.keys():
+ # Start L3fwd appliction
+ command_line = rtCmdLines[cores] % (TestL3fwd.path + l3_proto + "_l3fwd_" + mode, core_mask[cores],
+ self.dut.get_memory_channels(), utils.create_mask(valports))
+ self.dut.send_expect(command_line, "L3FWD:", 120)
+ for frame_size in self.frame_sizes:
+ # crete traffic flow
+ self.create_pcap_file(frame_size, l3_proto)
+ # send the traffic and Measure test
+ tgenInput = self.prepare_steam()
+ _, pps = self.tester.traffic_generator_throughput(tgenInput, rate_percent=100, delay=10)
+ self.verify(pps > 0, "No traffic detected")
+ # statistical result
+ pps /= 1000000.0
+ linerate = self.wirespeed(self.nic, frame_size, len(valports))
+ percentage = pps * 100 / linerate
+ if mode == "ipv6" and frame_size == 64:
+ frame_size += 2
+ data_row = [frame_size, mode, cores, str(pps), str(percentage)]
+ self.result_table_add(data_row)
+ self.test_results['data'].append(data_row)
+ # Stop L3fwd
+ self.dut.send_expect("^C", "#")
+ time.sleep(1)
+ # Print result
+ self.result_table_print()
+
+ def measure_rfc2544(self, l3_proto, mode):
+ """
+ measure RFC2544 according to Layer-3 Protocal and Lookup Mode
+ """
+ # create result table
+ self.create_result_table("Frame Size", "Mode", "S/C/T", "Zero Loss Throughput(Mpps)", " % Zero Loss Rate")
+ # build application
+ self.install_l3fwd_application(l3_proto, mode)
+ # perpare commandline and core mask
+ rtCmdLines, core_mask = self.perpare_commandline(len(valports))
+
+ for frame_size in self.frame_sizes:
+ for cores in rtCmdLines.keys():
+ # in order to save time, only some of the cases will be run.
+ if cores in ["1S/2C/1T", "1S/4C/1T"]:
+ # Start L3fwd appliction
+ command_line = rtCmdLines[cores] % (TestL3fwd.path + l3_proto + "_l3fwd_" + mode, core_mask[cores],
+ self.dut.get_memory_channels(), utils.create_mask(valports))
+ if self.nic == "niantic":
+ command_line += " --parse-ptype"
+ if frame_size > 1518:
+ command_line += " --enable-jumbo --max-pkt-len %d" % frame_size
+ self.dut.send_expect(command_line, "L3FWD:", 120)
+ self.logger.info("Executing l3fwd using %s mode, %d ports, %s and %d frame size"
+ % (mode, len(valports), cores, frame_size))
+ # crete traffic flow
+ self.create_pcap_file(frame_size, l3_proto)
+ # send the traffic and Measure test
+ tgenInput = self.prepare_steam()
+ zero_loss_rate, tx_pkts, rx_pkts = self.tester.run_rfc2544(tgenInput, delay=60)
+ # statistical result
+ linerate = self.wirespeed(self.nic, frame_size, len(valports))
+ zero_loss_throughput = (linerate * zero_loss_rate) / 100
+ if mode == "ipv6" and frame_size == 64:
+ frame_size += 2
+ data_row = [frame_size, mode, cores, str(zero_loss_throughput), str(zero_loss_rate)]
+ self.result_table_add(data_row)
+ self.test_results['data'].append(data_row)
+ # Stop L3fwd
+ self.dut.send_expect("^C", "#")
+ time.sleep(1)
+ # Print result
self.result_table_print()
+ def test_perf_rfc2544_ipv4_lpm(self):
+ self.measure_rfc2544(l3_proto="ipv4", mode="lpm")
+
+ def test_perf_rfc2544_ipv4_em(self):
+ self.measure_rfc2544(l3_proto="ipv4", mode="em")
+
+ def test_perf_throughput_ipv4_lpm(self):
+ self.measure_throughput(l3_proto="ipv4", mode="lpm")
+
+ def test_perf_throughput_ipv4_em(self):
+ self.measure_throughput(l3_proto="ipv4", mode="em")
+
+ def test_perf_rfc2544_ipv6_lpm(self):
+ self.measure_rfc2544(l3_proto="ipv6", mode="lpm")
+
+ def test_perf_rfc2544_ipv6_em(self):
+ self.measure_rfc2544(l3_proto="ipv6", mode="em")
+
+ def test_perf_throughput_ipv6_lpm(self):
+ self.measure_throughput(l3_proto="ipv6", mode="lpm")
+
+ def test_perf_throughput_ipv6_em(self):
+ self.measure_throughput(l3_proto="ipv6", mode="em")
+
def ip(self, port, frag, src, proto, tos, dst, chksum, len, options, version, flags, ihl, ttl, id):
self.add_tcl_cmd("protocol config -name ip")
self.add_tcl_cmd('ip config -sourceIpAddr "%s"' % src)
@@ -375,7 +408,7 @@ class TestL3fwd(TestCase,IxiaPacketGenerator):
"""
Run after each test case.
"""
- pass
+ self.dut.kill_all()
def tear_down_all(self):
"""
--
2.17.1
next reply other threads:[~2019-06-20 6:55 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-06-20 14:56 hanyingya [this message]
2019-06-26 8:27 ` Tu, Lijuan
2019-06-26 8:31 ` Han, YingyaX
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190620145621.43712-1-yingyax.han@intel.com \
--to=yingyax.han@intel.com \
--cc=dts@dpdk.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).