From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by dpdk.org (Postfix) with ESMTP id 4FCA02A07 for ; Wed, 3 Jun 2015 09:25:48 +0200 (CEST) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga103.jf.intel.com with ESMTP; 03 Jun 2015 00:25:27 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.13,545,1427785200"; d="scan'208";a="704452005" Received: from shvmail01.sh.intel.com ([10.239.29.42]) by orsmga001.jf.intel.com with ESMTP; 03 Jun 2015 00:25:26 -0700 Received: from shecgisg003.sh.intel.com (shecgisg003.sh.intel.com [10.239.29.90]) by shvmail01.sh.intel.com with ESMTP id t537PLhC019464; Wed, 3 Jun 2015 15:25:21 +0800 Received: from shecgisg003.sh.intel.com (localhost [127.0.0.1]) by shecgisg003.sh.intel.com (8.13.6/8.13.6/SuSE Linux 0.8) with ESMTP id t537PJKE029287; Wed, 3 Jun 2015 15:25:21 +0800 Received: (from huilongx@localhost) by shecgisg003.sh.intel.com (8.13.6/8.13.6/Submit) id t537PJrU029283; Wed, 3 Jun 2015 15:25:19 +0800 From: "huilong,xu" To: dts@dpdk.org Date: Wed, 3 Jun 2015 15:25:13 +0800 Message-Id: <1433316313-29239-3-git-send-email-huilongx.xu@intel.com> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1433316313-29239-1-git-send-email-huilongx.xu@intel.com> References: <1433316313-29239-1-git-send-email-huilongx.xu@intel.com> Subject: [dts] [PATCH V1 3/3] update fdir test cmd line and test case list 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: , X-List-Received-Date: Wed, 03 Jun 2015 07:25:50 -0000 From: huilong xu Signed-off-by: huilong xu --- tests/TestSuite_fdir.py | 1086 +++++++++++++++++++++++++++++++++++++---------- 1 files changed, 857 insertions(+), 229 deletions(-) diff --git a/tests/TestSuite_fdir.py b/tests/TestSuite_fdir.py index 1c8d8f7..3db41c9 100644 --- a/tests/TestSuite_fdir.py +++ b/tests/TestSuite_fdir.py @@ -31,33 +31,62 @@ """ DPDK Test suite. -Test 82599 Flow Director Support in DPDK + +Test 82599 and fortville Flow Director Support in DPDK """ -import dts +import re import time +import string +from time import sleep +from scapy.utils import struct, socket, PcapWriter - +import dts +from etgen import IxiaPacketGenerator from test_case import TestCase +from plotting import Plotting +from settings import HEADER_SIZE from pmd_output import PmdOutput +import sys +reload(sys) +sys.setdefaultencoding('utf8') +# +# +# Test class. +# -class TestFdir(TestCase): - def set_up_all(self): - """ - Run at the start of each test suite. - """ - ports = self.dut.get_ports() - self.verify(len(ports) >= 2, "Not enough ports available") +class TestFdir(TestCase, IxiaPacketGenerator): - self.pmdout = PmdOutput(self.dut) + # + # + # Utility methods and other non-test code. + # + ########################################################################### + def plot_results(self, number_ports): - def set_up(self): - """ - Run before each test case. - """ - pass + cores_configs = [] + percent_values = [] + + # Append the percentage results for the all the cores configs + for test_cycle in self.test_cycles: + cores_configs.append(test_cycle['cores']) + config_results = [] + for frame_size in self.frame_sizes: + config_results.append(test_cycle['pct'][frame_size]) + + percent_values.append(config_results) + + image_path = self.plotting.create_bars_plot( + 'test_perf_pmd_%sports' % number_ports, + 'PMD, %d ports' % number_ports, + self.frame_sizes, + percent_values, + ylabel='% linerate', + legend=cores_configs) + + dts.results_plot_print(image_path) def send_and_verify(self, condition, packet): """ @@ -71,294 +100,893 @@ class TestFdir(TestCase): self.tester.scapy_execute() time.sleep(.5) out = self.dut.send_expect("stop", "testpmd>") - if condition: - self.verify("PKT_RX_FDIR" in out, "FDIR hash not displayed when required") - else: - self.verify("PKT_RX_FDIR" not in out, "FDIR hash displayed when not required") - def test_fdir_space(self): + if(self.nic in ["kawela", "niantic", "fortville_eagle", "fortville_spirit", "fortville_spirit_single"]): + if ("fwd" == self.fdir_type): + if condition: + self.queue = 2 + else: + self.queue = 0 + elif("drop" == self.fdir_type): + if condition: + self.queue = 0 + else: + self.queue = -1 + + result_scanner = r"port ([0-9]+)/queue ([0-9]+): received ([0-9]+) packets\s*src=[A-F\d]{2}:[A-F\d]{2}:[A-F\d]{2}:[A-F\d]{2}:[A-F\d]{2}:[A-F\d]{2} - dst=[A-F\d]{2}:[A-F\d]{2}:[A-F\d]{2}:[A-F\d]{2}:[A-F\d]{2}:[A-F\d]{2}" + scanner = re.compile(result_scanner, re.DOTALL) + m = scanner.search(out) + + print "**************Print sub-case result****************" + if m: + m.groups() + if (self.queue == int(m.group(2))): + print dts.GREEN("Pass: queue id is " + m.group(2)) + self.verify(1, "Pass") + else: + print dts.RED("Fail: queue id is " + m.group(2)) + self.verify(0, "Fail") + print out + else: + print "not match" + if (-1 == self.queue): + print dts.GREEN("Pass: fdir should not match ") + self.verify(1, "Pass") + else: + print dts.RED("Fail") + self.verify(0, "Fail") + print out + print "**************Print sub-case result****************" + + # + # + # + # Test cases. + # + def set_up_all(self): """ - Setting memory reserved for FDir filters. + Run at the start of each test suite. + + PMD prerequisites. + """ + self.tester.extend_external_packet_generator(TestFdir, self) + self.verify('bsdapp' not in self.target, "FDIR not support freebsd") + # this feature support Fortville, Niantic + self.verify(self.nic in ["kawela_2", "niantic", "bartonhills", "82545EM", + "82540EM", "springfountain", "fortville_eagle", + "fortville_spirit", "fortville_spirit_single"], + "NIC Unsupported: " + str(self.nic)) + + # Based on h/w type, choose how many ports to use + self.dut_ports = self.dut.get_ports(self.nic) + # Verify that enough ports are available + self.verify(len(self.dut_ports) >= 2, "Insufficient ports for testing") + + # Verify that enough threads are available + self.all_cores_mask = dts.create_mask(self.dut.get_core_list("all")) + self.portMask = dts.create_mask([self.dut_ports[0], self.dut_ports[1]]) + self.ports_socket = self.dut.get_numa_id(self.dut_ports[0]) + self.dut_rx_port = self.tester.get_local_port(self.dut_ports[0]) + self.dut_rx_interface = self.tester.get_interface(self.dut_rx_port) + self.dut_tx_port = self.tester.get_local_port(self.dut_ports[1]) + self.dut_tx_interface = self.tester.get_interface(self.dut_rx_port) + + self.blacklist = "" + + self.headers_size = HEADER_SIZE['eth'] + HEADER_SIZE[ + 'ip'] + HEADER_SIZE['udp'] + self.src_ip = "192.168.1.1" + self.dst_ip = "192.168.2.1" + self.default_queue = 2 + + # performance test parameter + # self.frame_sizes = [1500] + self.frame_sizes = [64, 65, 128, 256, 512, 1024, 1280, 1500] + self.rxfreet_values = [0, 8, 16, 32, 64, 128] """ + self.test_cycles = [{'cores': '1S/1C/1T', 'Mpps': {}, 'pct': {}}, + {'cores': '1S/1C/2T', 'Mpps': {}, 'pct': {}}, + {'cores': '1S/2C/1T', 'Mpps': {}, 'pct': {}}, + {'cores': '1S/2C/2T', 'Mpps': {}, 'pct': {}}, + {'cores': '1S/4C/2T', 'Mpps': {}, 'pct': {}} + ] + """ + self.test_cycles = [{'cores': '1S/4C/2T', 'Mpps': {}, 'pct': {}}] - dutPorts = self.dut.get_ports() + # Nianatic only support 2bytes payload, Fotville support 16 bytes + self.flexbytes = [{'length': 2, 'flexbytes': '0x11,0x11', 'payload': '\\x11\\x11'}, + {'length': 16, 'flexbytes': '0x11,0x11,0x22,0x22,0x33,0x33,0x44,0x44,0x55,0x55,0x66,0x66,0x77,0x77,0x88,0x88', 'payload': '\\x11\\x11\\x22\\x22\\x33\\x33\\x44\\x44\\x55\\x55\\x66\\x66\\x77\\x77\\x88\\x88'} + ] - self.pmdout.start_testpmd("all", "--rxq=2 --txq=2 --disable-rss --pkt-filter-mode=perfect --pkt-filter-size=64K") - out = self.dut.send_expect("show port fdir %s" % dutPorts[0], "testpmd>") - self.dut.send_expect("quit", "# ", 30) - self.verify("free: 2048" in out, "Free space doesn't match the expected value") + # self.test_types = ['fdir_2flexbytes'] + self.test_types = ['fdir_disable', 'fdir_enable', 'fdir_noflexbytes', 'fdir_2flexbytes', 'fdir_16flexbytes'] + """ + self.flows= [{"flows":1, "rules":1}, + {"flows":64, "rules":16}, + {"flows":64, "rules":512} + #{"flows":8192, "rules":8192} + ] + """ + self.flows = [{"flows": 8192, "rules": 8192}] + # performance report head line + self.table_header = ['Frame Size'] + for test_cycle in self.test_cycles: + self.table_header.append("%s Mpps" % test_cycle['cores']) + self.table_header.append("% linerate") - self.pmdout.start_testpmd("all", "--rxq=2 --txq=2 --disable-rss --pkt-filter-mode=perfect --pkt-filter-size=128K") - out = self.dut.send_expect("show port fdir %s" % dutPorts[0], "testpmd>") - self.dut.send_expect("quit", "# ", 30) - self.verify("free: 4096" in out, "Free space doesn't match the expected value") + self.plotting = Plotting(self.dut.crb['name'], self.target, self.nic) - self.pmdout.start_testpmd("all", "--rxq=2 --txq=2 --disable-rss --pkt-filter-mode=perfect --pkt-filter-size=256K") - out = self.dut.send_expect("show port fdir %s" % dutPorts[0], "testpmd>") - self.dut.send_expect("quit", "# ", 30) - self.verify("free: 8192" in out, "Free space doesn't match the expected value") + def set_up(self): + """ + Run before each test case. + """ + pass - def test_fdir_signatures(self): + def fdir_set_rule(self): """ - FDir signature matching mode. - There are three different reporting modes, that can be set in testpmd using the ``--pkt-filter-report-hash`` command line - argument: - --pkt-filter-report-hash=none - --pkt-filter-report-hash=match - --pkt-filter-report-hash=always - The test for each mode is following the steps below. - - Start the ``testpmd`` application by using paramter of each mode. - - Send the ``p_udp`` packet with Scapy on the traffic generator and check that FDir information is printed + Fdir Performance Benchmarking set rules """ + self.dut.send_expect("port stop %s" % self.dut_ports[0], "testpmd>") + if(self.nic in ["fortville_eagle", "fortville_spirit", "fortville_spirit_single"]): + self.dut.send_expect("flow_director_flex_payload %s l2 (0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15)" % self.dut_ports[0], "testpmd>") + self.dut.send_expect("flow_director_flex_payload %s l3 (0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15)" % self.dut_ports[0], "testpmd>") + self.dut.send_expect("flow_director_flex_payload %s l4 (0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15)" % self.dut_ports[0], "testpmd>") + self.dut.send_expect("flow_director_flex_mask %s flow all (0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff)" % self.dut_ports[0], "testpmd>") + elif (self.nic in ["niantic"]): + self.dut.send_expect("flow_director_flex_payload %s raw (12,13)" % self.dut_ports[0], "testpmd>") + self.dut.send_expect("flow_director_flex_mask %s flow raw (0xff,0xff)" % self.dut_ports[0], "testpmd>") + self.dut.send_expect("port start %s" % self.dut_ports[0], "testpmd>") + + def fdir_get_flexbytes(self): - dutPorts = self.dut.get_ports() - localPort = self.tester.get_local_port(dutPorts[0]) - itf = self.tester.get_interface(localPort) + """ + Fdir get flexbytes and payload according NIC + """ + + if(self.nic in ["fortville_eagle", "fortville_spirit", "fortville_spirit_single"]): + self.flexbytes = "0x11,0x11,0x22,0x22,0x33,0x33,0x44,0x44,0x55,0x55,0x66,0x66,0x77,0x77,0x88,0x88" + self.payload = "\\x11\\x11\\x22\\x22\\x33\\x33\\x44\\x44\\x55\\x55\\x66\\x66\\x77\\x77\\x88\\x88" + self.flexlength = 16 + elif (self.nic in ["niantic"]): + self.flexbytes = "0x00,0x00" + self.payload = "\\x11\\x11\\x22\\x22\\x33\\x33\\x44\\x44\\x55\\x55\\x66\\x66\\x77\\x77\\x88\\x88" + self.flexlength = 2 + + def test_fdir_noflexword_fwd_ipv4(self): + """ + FDir signature matching mode. + """ self.dut.kill_all() - self.pmdout.start_testpmd("all", "--portmask=%s --rxq=2 --txq=2 --disable-rss --pkt-filter-mode=perfect --pkt-filter-report-hash=none" % dts.create_mask([dutPorts[0]])) + self.dut.send_expect("./%s/app/testpmd -c %s -n 4 -- -i --portmask=%s --disable-rss --rxq=8 --txq=8 --nb-cores=16 --nb-ports=1 --pkt-filter-mode=perfect" % (self.target, self.all_cores_mask, dts.create_mask([self.dut_ports[0]])), "testpmd>", 120) self.dut.send_expect("set verbose 1", "testpmd>") self.dut.send_expect("set fwd rxonly", "testpmd>") - self.dut.send_expect("set nbcore 3", "testpmd>") - - self.send_and_verify(False, 'sendp([Ether(src=get_if_hwaddr("%s"), dst="00:1B:21:8E:B2:30")/IP(src="192.168.0.1", dst="192.168.0.2")/UDP(sport=1024,dport=1024)], iface="%s")' % (itf, itf)) - self.dut.send_expect("add_perfect_filter %s udp src 192.168.0.1 1024 dst 192.168.0.2 1024 flexbytes 0x800 vlan 0 queue 1 soft 0x14" % dutPorts[0], "testpmd>") - self.send_and_verify(False, 'sendp([Ether(src=get_if_hwaddr("%s"), dst="00:1B:21:8E:B2:30")/IP(src="192.168.0.1", dst="192.168.0.2")/UDP(sport=1024,dport=1024)], iface="%s")' % (itf, itf)) + # fwd comand testing + self.fdir_type = "fwd" + + # ipv4 ip + self.dut.send_expect("flow_director_filter %s add flow ipv4-other src 192.168.0.1 dst 192.168.0.2 vlan 0 flexbytes () fwd queue %d fd_id %d " % (self.dut_ports[0], 2, 1), "testpmd>") + self.send_and_verify(True, 'sendp([Ether(src=get_if_hwaddr("%s"), dst="00:1B:21:8E:B2:30")/IP(src="192.168.0.1", dst="192.168.0.2")], iface="%s")' % (self.dut_rx_interface, self.dut_rx_interface)) + self.dut.send_expect("flow_director_filter %s del flow ipv4-other src 192.168.0.1 dst 192.168.0.2 vlan 0 flexbytes () fwd queue %d fd_id %d " % (self.dut_ports[0], 2, 1), "testpmd>") + self.send_and_verify(False, 'sendp([Ether(src=get_if_hwaddr("%s"),dst="00:1B:21:8E:B2:30")/IP(src="192.168.0.1", dst="192.168.0.2")], iface="%s")' % (self.dut_rx_interface, self.dut_rx_interface)) + + # update command only work in niantic + if (self.nic in ["niantic"]): + self.dut.send_expect("flow_director_filter %s add flow ipv4-other src 192.168.0.1 dst 192.168.0.2 vlan 0 flexbytes () fwd queue %d fd_id %d " % (self.dut_ports[0], 1, 1), "testpmd>") + self.dut.send_expect("flow_director_filter %s update flow ipv4-other src 192.168.0.1 dst 192.168.0.2 vlan 0 flexbytes () fwd queue %d fd_id %d " % (self.dut_ports[0], 2, 1), "testpmd>") + self.send_and_verify(True, 'sendp([Ether(src=get_if_hwaddr("%s"), dst="00:1B:21:8E:B2:30")/IP(src="192.168.0.1", dst="192.168.0.2")], iface="%s")' % (self.dut_rx_interface, self.dut_rx_interface)) + self.dut.send_expect("flow_director_filter %s del flow ipv4-other src 192.168.0.1 dst 192.168.0.2 vlan 0 flexbytes () fwd queue %d fd_id %d " % (self.dut_ports[0], 2, 1), "testpmd>") + + # ipv4 udp + self.dut.send_expect("flow_director_filter %s add flow ipv4-udp src 192.168.0.1 1024 dst 192.168.0.2 1024 vlan 0 flexbytes () fwd queue %d fd_id %d " % (self.dut_ports[0], 2, 1), "testpmd>") + self.send_and_verify(True, 'sendp([Ether(src=get_if_hwaddr("%s"), dst="00:1B:21:8E:B2:30")/IP(src="192.168.0.1", dst="192.168.0.2")/UDP(sport=1024,dport=1024)], iface="%s")' % (self.dut_rx_interface, self.dut_rx_interface)) + self.dut.send_expect("flow_director_filter %s del flow ipv4-udp src 192.168.0.1 1024 dst 192.168.0.2 1024 vlan 0 flexbytes () fwd queue %d fd_id %d " % (self.dut_ports[0], 2, 1), "testpmd>") + self.send_and_verify(False, 'sendp([Ether(src=get_if_hwaddr("%s"), dst="00:1B:21:8E:B2:30")/IP(src="192.168.0.1", dst="192.168.0.2")/UDP(sport=1024,dport=1024)], iface="%s")' % (self.dut_rx_interface, self.dut_rx_interface)) + + if (self.nic in ["niantic"]): + self.dut.send_expect("flow_director_filter %s add flow ipv4-udp src 192.168.0.1 1024 dst 192.168.0.2 1024 vlan 0 flexbytes () fwd queue %d fd_id %d " % (self.dut_ports[0], 1, 1), "testpmd>") + self.dut.send_expect("flow_director_filter %s update flow ipv4-udp src 192.168.0.1 1024 dst 192.168.0.2 1024 vlan 0 flexbytes () fwd queue %d fd_id %d " % (self.dut_ports[0], 2, 1), "testpmd>") + self.send_and_verify(True, 'sendp([Ether(src=get_if_hwaddr("%s"), dst="00:1B:21:8E:B2:30")/IP(src="192.168.0.1", dst="192.168.0.2")/UDP(sport=1024,dport=1024)], iface="%s")' % (self.dut_rx_interface, self.dut_rx_interface)) + self.dut.send_expect("flow_director_filter %s del flow ipv4-udp src 192.168.0.1 1024 dst 192.168.0.2 1024 vlan 0 flexbytes () fwd queue %d fd_id %d " % (self.dut_ports[0], 2, 1), "testpmd>") + + # ipv4 tcp + self.dut.send_expect("flow_director_filter %s add flow ipv4-tcp src 192.168.0.1 32 dst 192.168.0.2 32 vlan 0 flexbytes () fwd queue %d fd_id %d " % (self.dut_ports[0], 2, 1), "testpmd>") + self.send_and_verify(True, 'sendp([Ether(src=get_if_hwaddr("%s"), dst="00:1B:21:8E:B2:30")/IP(src="192.168.0.1", dst="192.168.0.2")/TCP(sport=32,dport=32)], iface="%s")' % (self.dut_rx_interface, self.dut_rx_interface)) + self.dut.send_expect("flow_director_filter %s del flow ipv4-tcp src 192.168.0.1 32 dst 192.168.0.2 32 vlan 0 flexbytes () fwd queue %d fd_id %d " % (self.dut_ports[0], 2, 1), "testpmd>") + self.send_and_verify(False, 'sendp([Ether(src=get_if_hwaddr("%s"), dst="00:1B:21:8E:B2:30")/IP(src="192.168.0.1", dst="192.168.0.2")/TCP(sport=32,dport=32)], iface="%s")' % (self.dut_rx_interface, self.dut_rx_interface)) + if (self.nic in ["niantic"]): + self.dut.send_expect("flow_director_filter %s add flow ipv4-tcp src 192.168.0.1 32 dst 192.168.0.2 32 vlan 0 flexbytes () fwd queue %d fd_id %d " % (self.dut_ports[0], 1, 1), "testpmd>") + self.dut.send_expect("flow_director_filter %s update flow ipv4-tcp src 192.168.0.1 32 dst 192.168.0.2 32 vlan 0 flexbytes () fwd queue %d fd_id %d " % (self.dut_ports[0], 2, 1), "testpmd>") + self.send_and_verify(True, 'sendp([Ether(src=get_if_hwaddr("%s"), dst="00:1B:21:8E:B2:30")/IP(src="192.168.0.1", dst="192.168.0.2")/TCP(sport=32,dport=32)], iface="%s")' % (self.dut_rx_interface, self.dut_rx_interface)) + self.dut.send_expect("flow_director_filter %s del flow ipv4-tcp src 192.168.0.1 32 dst 192.168.0.2 32 vlan 0 flexbytes () fwd queue %d fd_id %d " % (self.dut_ports[0], 2, 1), "testpmd>") + + # ipv4 sctp + self.dut.send_expect("flow_director_filter %s add flow ipv4-sctp src 192.168.0.1 32 dst 192.168.0.2 32 verify_tag 1 vlan 0 flexbytes () fwd queue %d fd_id %d " % (self.dut_ports[0], 2, 1), "testpmd>") + self.send_and_verify(True, 'sendp([Ether(src=get_if_hwaddr("%s"), dst="00:1B:21:8E:B2:30")/IP(src="192.168.0.1", dst="192.168.0.2")/SCTP(sport=32, dport=32, tag=1)/SCTPChunkData(data="X"*46)], iface="%s")' % (self.dut_rx_interface, self.dut_rx_interface)) + self.dut.send_expect("flow_director_filter %s del flow ipv4-sctp src 192.168.0.1 32 dst 192.168.0.2 32 verify_tag 1 vlan 0 flexbytes () fwd queue %d fd_id %d " % (self.dut_ports[0], 2, 1), "testpmd>") + self.send_and_verify(False, 'sendp([Ether(src=get_if_hwaddr("%s"), dst="00:1B:21:8E:B2:30")/IP(src="192.168.0.1", dst="192.168.0.2")/SCTP(sport=32, dport=32, tag=1)/SCTPChunkData(data="X"*46)], iface="%s")' % (self.dut_rx_interface, self.dut_rx_interface)) + if (self.nic in ["niantic"]): + self.dut.send_expect("flow_director_filter %s add flow ipv4-sctp src 192.168.0.1 32 dst 192.168.0.2 32 verify_tag 1 vlan 0 flexbytes () fwd queue %d fd_id %d " % (self.dut_ports[0], 1, 1), "testpmd>") + self.dut.send_expect("flow_director_filter %s update flow ipv4-sctp src 192.168.0.1 32 dst 192.168.0.2 32 vlan 0 flexbytes () fwd queue %d fd_id %d " % (self.dut_ports[0], 2, 1), "testpmd>") + self.send_and_verify(True, 'sendp([Ether(src=get_if_hwaddr("%s"), dst="00:1B:21:8E:B2:30")/IP(src="192.168.0.1", dst="192.168.0.2")/SCTP(sport=32, dport=32, tag=1)/SCTPChunkData(data="X"*46)], iface="%s")' % (self.dut_rx_interface, self.dut_rx_interface)) + self.dut.send_expect("flow_director_filter %s del flow ipv4-sctp src 192.168.0.1 32 dst 192.168.0.2 32 verify_tag 1 vlan 0 flexbytes () fwd queue %d fd_id %d " % (self.dut_ports[0], 2, 1), "testpmd>") + + # ipv4 frag + # ip-frag only support in fortville + if (self.nic in ["fortville_eagle", "fortville_spirit", "fortville_spirit_single"]): + self.dut.send_expect("flow_director_filter %s add flow ipv4-other src 192.168.0.1 dst 192.168.0.2 vlan 0 flexbytes () fwd queue %d fd_id %d " % (self.dut_ports[0], 3, 1), "testpmd>") + self.dut.send_expect("flow_director_filter %s add flow ipv4-frag src 192.168.0.1 dst 192.168.0.2 vlan 0 flexbytes () fwd queue %d fd_id %d " % (self.dut_ports[0], 2, 1), "testpmd>") + self.send_and_verify(True, 'sendp([Ether(src=get_if_hwaddr("%s"), dst="00:1B:21:8E:B2:30")/IP(src="192.168.0.1", dst="192.168.0.2", frag=1, flags="MF")/Raw(load="X"*46)], iface="%s")' % (self.dut_rx_interface, self.dut_rx_interface)) + self.dut.send_expect("flow_director_filter %s del flow ipv4-other src 192.168.0.1 dst 192.168.0.2 vlan 0 flexbytes () fwd queue %d fd_id %d " % (self.dut_ports[0], 3, 1), "testpmd>") + self.dut.send_expect("flow_director_filter %s del flow ipv4-frag src 192.168.0.1 dst 192.168.0.2 vlan 0 flexbytes () fwd queue %d fd_id %d " % (self.dut_ports[0], 2, 1), "testpmd>") + self.send_and_verify(False, 'sendp([Ether(src=get_if_hwaddr("%s"),dst="00:1B:21:8E:B2:30")/IP(src="192.168.0.1", dst="192.168.0.2", frag=1, flags="MF")/Raw(load="X"*46)], iface="%s")' % (self.dut_rx_interface, self.dut_rx_interface)) self.dut.send_expect("quit", "# ", 30) - self.pmdout.start_testpmd("all", "--portmask=%s --rxq=2 --txq=2 --disable-rss --pkt-filter-mode=perfect --pkt-filter-report-hash=match" % dts.create_mask([dutPorts[0]])) + def test_fdir_noflexword_fwd_ipv6(self): + """ + FDir signature matching mode. + """ + + self.dut.kill_all() + if self.nic in ["niantic"]: + # Niantic ipv6 only support signature mode + self.dut.send_expect("./%s/app/testpmd -c %s -n 4 -- -i --portmask=%s --disable-rss --rxq=8 --txq=8 --nb-cores=16 --nb-ports=1 --pkt-filter-mode=signature" % (self.target, self.all_cores_mask, dts.create_mask([self.dut_ports[0]])), "testpmd>", 120) + elif self.nic in ["fortville_eagle", "fortville_spirit", "fortville_spirit_single"]: + # Fortville ipv6 support perfect mode + self.dut.send_expect("./%s/app/testpmd -c %s -n 4 -- -i --portmask=%s --disable-rss --rxq=8 --txq=8 --nb-cores=16 --nb-ports=1 --pkt-filter-mode=perfect" % (self.target, self.all_cores_mask, dts.create_mask([self.dut_ports[0]])), "testpmd>", 120) self.dut.send_expect("set verbose 1", "testpmd>") self.dut.send_expect("set fwd rxonly", "testpmd>") - self.dut.send_expect("set nbcore 3", "testpmd>") - - self.send_and_verify(False, 'sendp([Ether(src=get_if_hwaddr("%s"), dst="00:1B:21:8E:B2:30")/IP(src="192.168.0.1", dst="192.168.0.2")/UDP(sport=1024,dport=1024)], iface="%s")' % (itf, itf)) - - self.dut.send_expect("add_perfect_filter %s udp src 192.168.0.1 1024 dst 192.168.0.2 1024 flexbytes 0x800 vlan 0 queue 1 soft 0x14" % dutPorts[0], "testpmd>") - self.send_and_verify(True, 'sendp([Ether(src=get_if_hwaddr("%s"), dst="00:1B:21:8E:B2:30")/IP(src="192.168.0.1", dst="192.168.0.2")/UDP(sport=1024,dport=1024)], iface="%s")' % (itf, itf)) - - self.dut.send_expect("upd_perfect_filter %s udp src 192.168.1.1 0 dst 192.168.1.2 0 flexbytes 0x800 vlan 0 queue 1 soft 0x14" % dutPorts[0], "testpmd>") - self.send_and_verify(True, 'sendp([Ether(src=get_if_hwaddr("%s"), dst="00:1B:21:8E:B2:30")/IP(src="192.168.0.1", dst="192.168.0.2")/UDP(sport=1024,dport=1024)], iface="%s")' % (itf, itf)) + # fwd comand testing + self.fdir_type = "fwd" + + # ipv6 ip + self.dut.send_expect("flow_director_filter %s add flow ipv6-other src FE80:0:0:0:200:1FF:FE00:200 dst 3555:5555:6666:6666:7777:7777:8888:8888 vlan 0 flexbytes () fwd queue %d fd_id %d " % (self.dut_ports[0], 2, 1), "testpmd>") + self.send_and_verify(True, 'sendp([Ether(src=get_if_hwaddr("%s"), dst="00:1B:21:8E:B2:30")/IPv6(src="FE80:0:0:0:200:1FF:FE00:200", dst="3555:5555:6666:6666:7777:7777:8888:8888")], iface="%s")' % (self.dut_rx_interface, self.dut_rx_interface)) + self.dut.send_expect("flow_director_filter %s del flow ipv6-other src FE80:0:0:0:200:1FF:FE00:200 dst 3555:5555:6666:6666:7777:7777:8888:8888 vlan 0 flexbytes () fwd queue %d fd_id %d " % (self.dut_ports[0], 2, 1), "testpmd>") + self.send_and_verify(False, 'sendp([Ether(src=get_if_hwaddr("%s"), dst="00:1B:21:8E:B2:30")/IPv6(src="FE80:0:0:0:200:1FF:FE00:200", dst="3555:5555:6666:6666:7777:7777:8888:8888")], iface="%s")' % (self.dut_rx_interface, self.dut_rx_interface)) + if (self.nic in ["niantic"]): + self.dut.send_expect("flow_director_filter %s add flow ipv6-other src FE80:0:0:0:200:1FF:FE00:200 dst 3555:5555:6666:6666:7777:7777:8888:8888 vlan 0 flexbytes () fwd queue %d fd_id %d " % (self.dut_ports[0], 1, 1), "testpmd>") + self.dut.send_expect("flow_director_filter %s update flow ipv6-other src FE80:0:0:0:200:1FF:FE00:200 dst 3555:5555:6666:6666:7777:7777:8888:8888 vlan 0 flexbytes () fwd queue %d fd_id %d " % (self.dut_ports[0], 2, 1), "testpmd>") + self.send_and_verify(True, 'sendp([Ether(src=get_if_hwaddr("%s"), dst="00:1B:21:8E:B2:30")/IPv6(src="FE80:0:0:0:200:1FF:FE00:200", dst="3555:5555:6666:6666:7777:7777:8888:8888")], iface="%s")' % (self.dut_rx_interface, self.dut_rx_interface)) + self.dut.send_expect("flow_director_filter %s del flow ipv6-other src FE80:0:0:0:200:1FF:FE00:200 dst 3555:5555:6666:6666:7777:7777:8888:8888 vlan 0 flexbytes () fwd queue %d fd_id %d " % (self.dut_ports[0], 2, 1), "testpmd>") + + # ipv6 udp + self.dut.send_expect("flow_director_filter %s add flow ipv6-udp src FE80:0:0:0:200:1FF:FE00:200 1024 dst 3555:5555:6666:6666:7777:7777:8888:8888 1024 vlan 0 flexbytes () fwd queue %d fd_id %d " % (self.dut_ports[0], 2, 1), "testpmd>") + self.send_and_verify(True, 'sendp([Ether(src=get_if_hwaddr("%s"), dst="00:1B:21:8E:B2:30")/IPv6(src="FE80:0:0:0:200:1FF:FE00:200", dst="3555:5555:6666:6666:7777:7777:8888:8888")/UDP(sport=1024,dport=1024)], iface="%s")' % (self.dut_rx_interface, self.dut_rx_interface)) + self.dut.send_expect("flow_director_filter %s del flow ipv6-udp src FE80:0:0:0:200:1FF:FE00:200 1024 dst 3555:5555:6666:6666:7777:7777:8888:8888 1024 vlan 0 flexbytes () fwd queue %d fd_id %d " % (self.dut_ports[0], 2, 1), "testpmd>") + self.send_and_verify(False, 'sendp([Ether(src=get_if_hwaddr("%s"), dst="00:1B:21:8E:B2:30")/IPv6(src="FE80:0:0:0:200:1FF:FE00:200", dst="3555:5555:6666:6666:7777:7777:8888:8888")/UDP(sport=1024,dport=1024)], iface="%s")' % (self.dut_rx_interface, self.dut_rx_interface)) + if (self.nic in ["niantic"]): + self.dut.send_expect("flow_director_filter %s add flow ipv6-udp src FE80:0:0:0:200:1FF:FE00:200 1024 dst 3555:5555:6666:6666:7777:7777:8888:8888 1024 vlan 0 flexbytes () fwd queue %d fd_id %d " % (self.dut_ports[0], 1, 1), "testpmd>") + self.dut.send_expect("flow_director_filter %s update flow ipv6-udp src FE80:0:0:0:200:1FF:FE00:200 1024 dst 3555:5555:6666:6666:7777:7777:8888:8888 1024 vlan 0 flexbytes () fwd queue %d fd_id %d " % (self.dut_ports[0], 2, 1), "testpmd>") + self.send_and_verify(True, 'sendp([Ether(src=get_if_hwaddr("%s"), dst="00:1B:21:8E:B2:30")/IPv6(src="FE80:0:0:0:200:1FF:FE00:200", dst="3555:5555:6666:6666:7777:7777:8888:8888")/UDP(sport=1024,dport=1024)], iface="%s")' % (self.dut_rx_interface, self.dut_rx_interface)) + self.dut.send_expect("flow_director_filter %s del flow ipv6-udp src FE80:0:0:0:200:1FF:FE00:200 1024 dst 3555:5555:6666:6666:7777:7777:8888:8888 1024 flexbytes () fwd queue %d fd_id %d " % (self.dut_ports[0], 2, 1), "testpmd>") + + # ipv6 tcp + self.dut.send_expect("flow_director_filter %s add flow ipv6-tcp src FE80:0:0:0:200:1FF:FE00:200 32 dst 3555:5555:6666:6666:7777:7777:8888:8888 32 vlan 0 flexbytes () fwd queue %d fd_id %d " % (self.dut_ports[0], 2, 1), "testpmd>") + self.send_and_verify(True, 'sendp([Ether(src=get_if_hwaddr("%s"), dst="00:1B:21:8E:B2:30")/IPv6(src="FE80:0:0:0:200:1FF:FE00:200", dst="3555:5555:6666:6666:7777:7777:8888:8888")/TCP(sport=32,dport=32)], iface="%s")' % (self.dut_rx_interface, self.dut_rx_interface)) + self.dut.send_expect("flow_director_filter %s del flow ipv6-tcp src FE80:0:0:0:200:1FF:FE00:200 32 dst 3555:5555:6666:6666:7777:7777:8888:8888 32 vlan 0 flexbytes () fwd queue %d fd_id %d " % (self.dut_ports[0], 2, 1), "testpmd>") + self.send_and_verify(False, 'sendp([Ether(src=get_if_hwaddr("%s"), dst="00:1B:21:8E:B2:30")/IPv6(src="FE80:0:0:0:200:1FF:FE00:200", dst="3555:5555:6666:6666:7777:7777:8888:8888")/TCP(sport=32,dport=32)], iface="%s")' % (self.dut_rx_interface, self.dut_rx_interface)) + if (self.nic in ["niantic"]): + self.dut.send_expect("flow_director_filter %s add flow ipv6-tcp src FE80:0:0:0:200:1FF:FE00:200 32 dst 3555:5555:6666:6666:7777:7777:8888:8888 32 vlan 0 flexbytes () fwd queue %d fd_id %d " % (self.dut_ports[0], 1, 1), "testpmd>") + self.dut.send_expect("flow_director_filter %s update flow ipv6-tcp src FE80:0:0:0:200:1FF:FE00:200 32 dst 3555:5555:6666:6666:7777:7777:8888:8888 32 vlan 0 flexbytes () fwd queue %d fd_id %d " % (self.dut_ports[0], 2, 1), "testpmd>") + self.send_and_verify(True, 'sendp([Ether(src=get_if_hwaddr("%s"), dst="00:1B:21:8E:B2:30")/IPv6(src="FE80:0:0:0:200:1FF:FE00:200", dst="3555:5555:6666:6666:7777:7777:8888:8888")/TCP(sport=32,dport=32)], iface="%s")' % (self.dut_rx_interface, self.dut_rx_interface)) + self.dut.send_expect("flow_director_filter %s del flow ipv6-tcp src FE80:0:0:0:200:1FF:FE00:200 32 dst 3555:5555:6666:6666:7777:7777:8888:8888 32 vlan 0 flexbytes () fwd queue %d fd_id %d " % (self.dut_ports[0], 2, 1), "testpmd>") - self.send_and_verify(True, 'sendp([Ether(src=get_if_hwaddr("%s"), dst="00:1B:21:8E:B2:30")/IP(src="192.168.1.1", dst="192.168.1.2")/UDP(sport=0,dport=0)], iface="%s")' % (itf, itf)) - - self.dut.send_expect("rm_perfect_filter %s udp src 192.168.1.1 0 dst 192.168.1.2 0 flexbytes 0x800 vlan 0 soft 0x14" % dutPorts[0], "testpmd>") + """ + #ipv6 sctp + self.dut.send_expect("flow_director_filter 0 add flow ipv6-sctp src FE80:0:0:0:200:1FF:FE00:200 32 dst 3555:5555:6666:6666:7777:7777:8888:8888 32 verify_tag 1 vlan 0 flexbytes () fwd queue %d fd_id %d "%(2,1), "testpmd>") + self.send_and_verify(True, 'sendp([Ether(src=get_if_hwaddr("%s"), dst="00:1B:21:8E:B2:30")/IPv6(src="FE80:0:0:0:200:1FF:FE00:200", dst="3555:5555:6666:6666:7777:7777:8888:8888")/SCTP(sport=32, dport=32, tag=1)/SCTPChunkData(data="X"*46)], iface="%s")' % (self.dut_rx_interface, self.dut_rx_interface)) + self.dut.send_expect("flow_director_filter 0 del flow ipv6-sctp src FE80:0:0:0:200:1FF:FE00:200 32 dst 3555:5555:6666:6666:7777:7777:8888:8888 32 verify_tag 1 vlan 0 flexbytes () fwd queue %d fd_id %d "%(2,1), "testpmd>") + self.send_and_verify(False, 'sendp([Ether(src=get_if_hwaddr("%s"), dst="00:1B:21:8E:B2:30")/IPv6(src="FE80:0:0:0:200:1FF:FE00:200", dst="3555:5555:6666:6666:7777:7777:8888:8888")/SCTP(sport=32, dport=32, tag=1)/SCTPChunkData(data="X"*46)], iface="%s")' % (self.dut_rx_interface, self.dut_rx_interface)) + if (self.nic in ["niantic"]): + self.dut.send_expect("flow_director_filter 0 add flow ipv6-sctp src FE80:0:0:0:200:1FF:FE00:200 32 dst 3555:5555:6666:6666:7777:7777:8888:8888 32 verify_tag 1 vlan 0 flexbytes () fwd queue %d fd_id %d "%(1,1), "testpmd>") + self.dut.send_expect("flow_director_filter 0 update flow ipv6-sctp src FE80:0:0:0:200:1FF:FE00:200 32 dst 3555:5555:6666:6666:7777:7777:8888:8888 32 verify_tag 1 vlan 0 flexbytes () fwd queue %d fd_id %d "%(2,1), "testpmd>") + self.send_and_verify(True, 'sendp([Ether(src=get_if_hwaddr("%s"), dst="00:1B:21:8E:B2:30")/IPv6(src="FE80:0:0:0:200:1FF:FE00:200", dst="3555:5555:6666:6666:7777:7777:8888:8888")/SCTP(sport=32, dport=32, tag=1)/SCTPChunkData(data="X"*46)], iface="%s")' % (self.dut_rx_interface, self.dut_rx_interface)) + self.dut.send_expect("flow_director_filter 0 del flow ipv6-sctp src FE80:0:0:0:200:1FF:FE00:200 32 dst 3555:5555:6666:6666:7777:7777:8888:8888 32 verify_tag 1 vlan 0 flexbytes () fwd queue %d fd_id %d "%(2,1), "testpmd>") + """ - self.send_and_verify(False, 'sendp([Ether(src=get_if_hwaddr("%s"), dst="00:1B:21:8E:B2:30")/IP(src="192.168.1.1", dst="192.168.1.2")/UDP(sport=0,dport=0)], iface="%s")' % (itf, itf)) + # ipv6 frag + # ip-frag only support in fortville + if (self.nic in ["fortville_eagle", "fortville_spirit", "fortville_spirit_single"]): + self.dut.send_expect("flow_director_filter %s add flow ipv6-other src FE80:0:0:0:200:1FF:FE00:200 dst 3555:5555:6666:6666:7777:7777:8888:8888 vlan 0 flexbytes () fwd queue %d fd_id %d " % (self.dut_ports[0], 3, 1), "testpmd>") + self.dut.send_expect("flow_director_filter %s add flow ipv6-frag src FE80:0:0:0:200:1FF:FE00:200 dst 3555:5555:6666:6666:7777:7777:8888:8888 vlan 0 flexbytes () fwd queue %d fd_id %d " % (self.dut_ports[0], 2, 1), "testpmd>") + self.send_and_verify(True, 'sendp([Ether(src=get_if_hwaddr("%s"), dst="00:1B:21:8E:B2:30")/IPv6(src="FE80:0:0:0:200:1FF:FE00:200", dst="3555:5555:6666:6666:7777:7777:8888:8888", nh=44)/IPv6ExtHdrFragment()/Raw(load="X"*46)], iface="%s")' % (self.dut_rx_interface, self.dut_rx_interface)) + self.dut.send_expect("flow_director_filter %s del flow ipv6-other src FE80:0:0:0:200:1FF:FE00:200 dst 3555:5555:6666:6666:7777:7777:8888:8888 vlan 0 flexbytes () fwd queue %d fd_id %d " % (self.dut_ports[0], 3, 1), "testpmd>") + self.dut.send_expect("flow_director_filter %s del flow ipv6-frag src FE80:0:0:0:200:1FF:FE00:200 dst 3555:5555:6666:6666:7777:7777:8888:8888 vlan 0 flexbytes () fwd queue %d fd_id %d " % (self.dut_ports[0], 2, 1), "testpmd>") + self.send_and_verify(False, 'sendp([Ether(src=get_if_hwaddr("%s"), dst="00:1B:21:8E:B2:30")/IPv6(src="FE80:0:0:0:200:1FF:FE00:200", dst="3555:5555:6666:6666:7777:7777:8888:8888", nh=44)/IPv6ExtHdrFragment()/Raw(load="X"*46)], iface="%s")' % (self.dut_rx_interface, self.dut_rx_interface)) self.dut.send_expect("quit", "# ", 30) - self.pmdout.start_testpmd("all", "--portmask=%s --rxq=2 --txq=2 --disable-rss --pkt-filter-mode=perfect --pkt-filter-report-hash=always" % dts.create_mask([dutPorts[0]])) + def test_fdir_noflexword_drop_ipv4(self): + # drop command testing + self.dut.kill_all() + self.dut.send_expect("./%s/app/testpmd -c %s -n 4 -- -i --portmask=%s --disable-rss --rxq=8 --txq=8 --nb-cores=16 --nb-ports=1 --pkt-filter-mode=perfect" % (self.target, self.all_cores_mask, dts.create_mask([self.dut_ports[0]])), "testpmd>", 120) self.dut.send_expect("set verbose 1", "testpmd>") self.dut.send_expect("set fwd rxonly", "testpmd>") - self.dut.send_expect("set nbcore 3", "testpmd>") - self.send_and_verify(True, 'sendp([Ether(src=get_if_hwaddr("%s"), dst="00:1B:21:8E:B2:30")/IP(src="192.168.0.1", dst="192.168.0.2")/UDP(sport=1024,dport=1024)], iface="%s")' % (itf, itf)) - - self.dut.send_expect("add_perfect_filter %s udp src 192.168.0.1 1024 dst 192.168.0.2 1024 flexbytes 0x800 vlan 0 queue 1 soft 0x14" % dutPorts[0], "testpmd>") - self.send_and_verify(True, 'sendp([Ether(src=get_if_hwaddr("%s"), dst="00:1B:21:8E:B2:30")/IP(src="192.168.0.1", dst="192.168.0.2")/UDP(sport=1024,dport=1024)], iface="%s")' % (itf, itf)) + # fwd comand testing + self.fdir_type = "drop" + + # ipv4 ip + self.dut.send_expect("flow_director_filter %s add flow ipv4-other src 192.168.0.1 dst 192.168.0.2 vlan 0 flexbytes () drop queue %d fd_id %d " % (self.dut_ports[0], 2, 1), "testpmd>") + self.send_and_verify(False, 'sendp([Ether(src=get_if_hwaddr("%s"), dst="00:1B:21:8E:B2:30")/IP(src="192.168.0.1", dst="192.168.0.2")], iface="%s")' % (self.dut_rx_interface, self.dut_rx_interface)) + self.dut.send_expect("flow_director_filter %s del flow ipv4-other src 192.168.0.1 dst 192.168.0.2 vlan 0 flexbytes () drop queue %d fd_id %d " % (self.dut_ports[0], 2, 1), "testpmd>") + self.send_and_verify(True, 'sendp([Ether(src=get_if_hwaddr("%s"), dst="00:1B:21:8E:B2:30")/IP(src="192.168.0.1", dst="192.168.0.2")], iface="%s")' % (self.dut_rx_interface, self.dut_rx_interface)) + if (self.nic in ["niantic"]): + self.dut.send_expect("flow_director_filter %s add flow ipv4-other src 192.168.0.1 dst 192.168.0.2 vlan 0 flexbytes () drop queue %d fd_id %d " % (self.dut_ports[0], 1, 1), "testpmd>") + self.dut.send_expect("flow_director_filter %s update flow ipv4-other src 192.168.0.1 dst 192.168.0.2 vlan 0 flexbytes () drop queue %d fd_id %d " % (self.dut_ports[0], 2, 1), "testpmd>") + self.send_and_verify(False, 'sendp([Ether(src=get_if_hwaddr("%s"), dst="00:1B:21:8E:B2:30")/IP(src="192.168.0.1", dst="192.168.0.2")], iface="%s")' % (self.dut_rx_interface, self.dut_rx_interface)) + self.dut.send_expect("flow_director_filter %s del flow ipv4-other src 192.168.0.1 dst 192.168.0.2 vlan 0 flexbytes () drop queue %d fd_id %d " % (self.dut_ports[0], 2, 1), "testpmd>") + + # ipv4 udp + self.dut.send_expect("flow_director_filter %s add flow ipv4-udp src 192.168.0.1 1024 dst 192.168.0.2 1024 vlan 0 flexbytes () drop queue %d fd_id %d " % (self.dut_ports[0], 2, 1), "testpmd>") + self.send_and_verify(False, 'sendp([Ether(src=get_if_hwaddr("%s"), dst="00:1B:21:8E:B2:30")/IP(src="192.168.0.1", dst="192.168.0.2")/UDP(sport=1024,dport=1024)], iface="%s")' % (self.dut_rx_interface, self.dut_rx_interface)) + self.dut.send_expect("flow_director_filter %s del flow ipv4-udp src 192.168.0.1 1024 dst 192.168.0.2 1024 vlan 0 flexbytes () drop queue %d fd_id %d " % (self.dut_ports[0], 2, 1), "testpmd>") + self.send_and_verify(True, 'sendp([Ether(src=get_if_hwaddr("%s"), dst="00:1B:21:8E:B2:30")/IP(src="192.168.0.1", dst="192.168.0.2")/UDP(sport=1024,dport=1024)], iface="%s")' % (self.dut_rx_interface, self.dut_rx_interface)) + if (self.nic in ["niantic"]): + self.dut.send_expect("flow_director_filter %s add flow ipv4-udp src 192.168.0.1 1024 dst 192.168.0.2 1024 vlan 0 flexbytes () drop queue %d fd_id %d " % (self.dut_ports[0], 1, 1), "testpmd>") + self.dut.send_expect("flow_director_filter %s update flow ipv4-udp src 192.168.0.1 1024 dst 192.168.0.2 1024 vlan 0 flexbytes () drop queue %d fd_id %d " % (self.dut_ports[0], 2, 1), "testpmd>") + self.send_and_verify(False, 'sendp([Ether(src=get_if_hwaddr("%s"), dst="00:1B:21:8E:B2:30")/IP(src="192.168.0.1", dst="192.168.0.2")/UDP(sport=1024,dport=1024)], iface="%s")' % (self.dut_rx_interface, self.dut_rx_interface)) + self.dut.send_expect("flow_director_filter %s del flow ipv4-udp src 192.168.0.1 1024 dst 192.168.0.2 1024 vlan 0 flexbytes () drop queue %d fd_id %d " % (self.dut_ports[0], 2, 1), "testpmd>") + + # ipv4 tcp + self.dut.send_expect("flow_director_filter %s add flow ipv4-tcp src 192.168.0.1 32 dst 192.168.0.2 32 vlan 0 flexbytes () drop queue %d fd_id %d " % (self.dut_ports[0], 2, 1), "testpmd>") + self.send_and_verify(False, 'sendp([Ether(src=get_if_hwaddr("%s"), dst="00:1B:21:8E:B2:30")/IP(src="192.168.0.1", dst="192.168.0.2")/TCP(sport=32,dport=32)], iface="%s")' % (self.dut_rx_interface, self.dut_rx_interface)) + self.dut.send_expect("flow_director_filter %s del flow ipv4-tcp src 192.168.0.1 32 dst 192.168.0.2 32 vlan 0 flexbytes () drop queue %d fd_id %d " % (self.dut_ports[0], 2, 1), "testpmd>") + self.send_and_verify(True, 'sendp([Ether(src=get_if_hwaddr("%s"), dst="00:1B:21:8E:B2:30")/IP(src="192.168.0.1", dst="192.168.0.2")/TCP(sport=32,dport=32)], iface="%s")' % (self.dut_rx_interface, self.dut_rx_interface)) + if (self.nic in ["niantic"]): + self.dut.send_expect("flow_director_filter %s add flow ipv4-tcp src 192.168.0.1 32 dst 192.168.0.2 32 vlan 0 flexbytes () drop queue %d fd_id %d " % (self.dut_ports[0], 1, 1), "testpmd>") + self.dut.send_expect("flow_director_filter %s update flow ipv4-tcp src 192.168.0.1 32 dst 192.168.0.2 32 vlan 0 flexbytes () drop queue %d fd_id %d " % (self.dut_ports[0], 2, 1), "testpmd>") + self.send_and_verify(False, 'sendp([Ether(src=get_if_hwaddr("%s"), dst="00:1B:21:8E:B2:30")/IP(src="192.168.0.1", dst="192.168.0.2")/TCP(sport=32,dport=32)], iface="%s")' % (self.dut_rx_interface, self.dut_rx_interface)) + self.dut.send_expect("flow_director_filter %s del flow ipv4-tcp src 192.168.0.1 32 dst 192.168.0.2 32 vlan 0 flexbytes () drop queue %d fd_id %d " % (self.dut_ports[0], 2, 1), "testpmd>") + + # ipv4 sctp + self.dut.send_expect("flow_director_filter %s add flow ipv4-sctp src 192.168.0.1 32 dst 192.168.0.2 32 verify_tag 1 vlan 0 flexbytes () drop queue %d fd_id %d " % (self.dut_ports[0], 2, 1), "testpmd>") + self.send_and_verify(False, 'sendp([Ether(src=get_if_hwaddr("%s"), dst="00:1B:21:8E:B2:30")/IP(src="192.168.0.1", dst="192.168.0.2")/SCTP(sport=32, dport=32, tag=1)/SCTPChunkData(data="X"*46)], iface="%s")' % (self.dut_rx_interface, self.dut_rx_interface)) + self.dut.send_expect("flow_director_filter %s del flow ipv4-sctp src 192.168.0.1 32 dst 192.168.0.2 32 verify_tag 1 vlan 0 flexbytes () drop queue %d fd_id %d " % (self.dut_ports[0], 2, 1), "testpmd>") + self.send_and_verify(True, 'sendp([Ether(src=get_if_hwaddr("%s"), dst="00:1B:21:8E:B2:30")/IP(src="192.168.0.1", dst="192.168.0.2")/SCTP(sport=32, dport=32, tag=1)/SCTPChunkData(data="X"*46)], iface="%s")' % (self.dut_rx_interface, self.dut_rx_interface)) + if (self.nic in ["niantic"]): + self.dut.send_expect("flow_director_filter %s add flow ipv4-sctp src 192.168.0.1 32 dst 192.168.0.2 32 verify_tag 1 vlan 0 flexbytes () drop queue %d fd_id %d " % (self.dut_ports[0], 1, 1), "testpmd>") + self.dut.send_expect("flow_director_filter %s update flow ipv4-sctp src 192.168.0.1 32 dst 192.168.0.2 32 verify_tag 1 vlan 0 flexbytes () drop queue %d fd_id %d " % (self.dut_ports[0], 2, 1), "testpmd>") + self.send_and_verify(False, 'sendp([Ether(src=get_if_hwaddr("%s"), dst="00:1B:21:8E:B2:30")/IP(src="192.168.0.1", dst="192.168.0.2")/SCTP(sport=32, dport=32, tag=1)/SCTPChunkData(data="X"*46)], iface="%s")' % (self.dut_rx_interface, self.dut_rx_interface)) + self.dut.send_expect("flow_director_filter %s del flow ipv4-sctp src 192.168.0.1 32 dst 192.168.0.2 32 verify_tag 1 vlan 0 flexbytes () drop queue %d fd_id %d " % (self.dut_ports[0], 2, 1), "testpmd>") + + # ipv4 frag + # ip-frag only support in fortville + if (self.nic in ["fortville_eagle", "fortville_spirit", "fortville_spirit_single"]): + self.dut.send_expect("flow_director_filter %s add flow ipv4-other src 192.168.0.1 dst 192.168.0.2 vlan 0 flexbytes () drop queue %d fd_id %d " % (self.dut_ports[0], 3, 1), "testpmd>") + self.dut.send_expect("flow_director_filter %s add flow ipv4-frag src 192.168.0.1 dst 192.168.0.2 vlan 0 flexbytes () drop queue %d fd_id %d " % (self.dut_ports[0], 2, 1), "testpmd>") + self.send_and_verify(False, 'sendp([Ether(src=get_if_hwaddr("%s"), dst="00:1B:21:8E:B2:30")/IP(src="192.168.0.1", dst="192.168.0.2", frag=1, flags="MF")/Raw(load="X"*46)], iface="%s")' % (self.dut_rx_interface, self.dut_rx_interface)) + self.dut.send_expect("flow_director_filter %s del flow ipv4-other src 192.168.0.1 dst 192.168.0.2 vlan 0 flexbytes () drop queue %d fd_id %d " % (self.dut_ports[0], 3, 1), "testpmd>") + self.dut.send_expect("flow_director_filter %s del flow ipv4-frag src 192.168.0.1 dst 192.168.0.2 vlan 0 flexbytes () drop queue %d fd_id %d " % (self.dut_ports[0], 2, 1), "testpmd>") + self.send_and_verify(True, 'sendp([Ether(src=get_if_hwaddr("%s"),dst="00:1B:21:8E:B2:30")/IP(src="192.168.0.1", dst="192.168.0.2", frag=1, flags="MF")/Raw(load="X"*46)], iface="%s")' % (self.dut_rx_interface, self.dut_rx_interface)) self.dut.send_expect("quit", "# ", 30) - def test_fdir_matching(self): + def test_fdir_noflexword_drop_ipv6(self): + # drop not support signature mode, niantic only can work in signature mode with ipv6 + # Niantic is not support in drop ipv6 + if self.nic in ["fortville_eagle", "fortville_spirit", "fortville_spirit_single"]: + # drop command testing + self.dut.kill_all() + + self.dut.send_expect("./%s/app/testpmd -c %s -n 4 -- -i --portmask=%s --disable-rss --rxq=8 --txq=8 --nb-cores=16 --nb-ports=1 --pkt-filter-mode=perfect" % (self.target, self.all_cores_mask, dts.create_mask([self.dut_ports[0]])), "testpmd>", 120) + self.dut.send_expect("set verbose 1", "testpmd>") + self.dut.send_expect("set fwd rxonly", "testpmd>") + + # fwd comand testing + self.fdir_type = "drop" + + # ipv6 ip + self.dut.send_expect("flow_director_filter %s add flow ipv6-other src FE80:0:0:0:200:1FF:FE00:200 dst 3555:5555:6666:6666:7777:7777:8888:8888 vlan 0 flexbytes () drop queue %d fd_id %d " % (self.dut_ports[0], 2, 1), "testpmd>") + self.send_and_verify(False, 'sendp([Ether(src=get_if_hwaddr("%s"), dst="00:1B:21:8E:B2:30")/IPv6(src="FE80:0:0:0:200:1FF:FE00:200", dst="3555:5555:6666:6666:7777:7777:8888:8888")], iface="%s")' % (self.dut_rx_interface, self.dut_rx_interface)) + self.dut.send_expect("flow_director_filter %s del flow ipv6-other src FE80:0:0:0:200:1FF:FE00:200 dst 3555:5555:6666:6666:7777:7777:8888:8888 vlan 0 flexbytes () drop queue %d fd_id %d " % (self.dut_ports[0], 2, 1), "testpmd>") + self.send_and_verify(True, 'sendp([Ether(src=get_if_hwaddr("%s"), dst="00:1B:21:8E:B2:30")/IPv6(src="FE80:0:0:0:200:1FF:FE00:200", dst="3555:5555:6666:6666:7777:7777:8888:8888")], iface="%s")' % (self.dut_rx_interface, self.dut_rx_interface)) + + # ipv6 udp + self.dut.send_expect("flow_director_filter %s add flow ipv6-udp src FE80:0:0:0:200:1FF:FE00:200 1024 dst 3555:5555:6666:6666:7777:7777:8888:8888 1024 vlan 0 flexbytes () drop queue %d fd_id %d " % (self.dut_ports[0], 2, 1), "testpmd>") + self.send_and_verify(False, 'sendp([Ether(src=get_if_hwaddr("%s"), dst="00:1B:21:8E:B2:30")/IPv6(src="FE80:0:0:0:200:1FF:FE00:200", dst="3555:5555:6666:6666:7777:7777:8888:8888")/UDP(sport=1024,dport=1024)], iface="%s")' % (self.dut_rx_interface, self.dut_rx_interface)) + self.dut.send_expect("flow_director_filter %s del flow ipv6-udp src FE80:0:0:0:200:1FF:FE00:200 1024 dst 3555:5555:6666:6666:7777:7777:8888:8888 1024 vlan 0 flexbytes () drop queue %d fd_id %d " % (self.dut_ports[0], 2, 1), "testpmd>") + self.send_and_verify(True, 'sendp([Ether(src=get_if_hwaddr("%s"), dst="00:1B:21:8E:B2:30")/IPv6(src="FE80:0:0:0:200:1FF:FE00:200", dst="3555:5555:6666:6666:7777:7777:8888:8888")/UDP(sport=1024,dport=1024)], iface="%s")' % (self.dut_rx_interface, self.dut_rx_interface)) + + # ipv6 tcp + self.dut.send_expect("flow_director_filter %s add flow ipv6-tcp src FE80:0:0:0:200:1FF:FE00:200 32 dst 3555:5555:6666:6666:7777:7777:8888:8888 32 vlan 0 flexbytes () drop queue %d fd_id %d " % (self.dut_ports[0], 2, 1), "testpmd>") + self.send_and_verify(False, 'sendp([Ether(src=get_if_hwaddr("%s"), dst="00:1B:21:8E:B2:30")/IPv6(src="FE80:0:0:0:200:1FF:FE00:200", dst="3555:5555:6666:6666:7777:7777:8888:8888")/TCP(sport=32,dport=32)], iface="%s")' % (self.dut_rx_interface, self.dut_rx_interface)) + self.dut.send_expect("flow_director_filter %s del flow ipv6-tcp src FE80:0:0:0:200:1FF:FE00:200 32 dst 3555:5555:6666:6666:7777:7777:8888:8888 32 vlan 0 flexbytes () drop queue %d fd_id %d " % (self.dut_ports[0], 2, 1), "testpmd>") + self.send_and_verify(True, 'sendp([Ether(src=get_if_hwaddr("%s"), dst="00:1B:21:8E:B2:30")/IPv6(src="FE80:0:0:0:200:1FF:FE00:200", dst="3555:5555:6666:6666:7777:7777:8888:8888")/TCP(sport=32,dport=32)], iface="%s")' % (self.dut_rx_interface, self.dut_rx_interface)) + + # ipv6 sctp + """ + self.dut.send_expect("flow_director_filter %s add flow ipv6-sctp src FE80:0:0:0:200:1FF:FE00:200 32 dst 3555:5555:6666:6666:7777:7777:8888:8888 32 verify_tag 1 vlan 0 flexbytes () drop queue %d fd_id %d "%(self.dut_ports[0],2,1), "testpmd>") + self.send_and_verify(False, 'sendp([Ether(src=get_if_hwaddr("%s"), dst="00:1B:21:8E:B2:30")/IPv6(src="FE80:0:0:0:200:1FF:FE00:200", dst="3555:5555:6666:6666:7777:7777:8888:8888")/SCTP(sport=32, dport=32, tag=1)/SCTPChunkData(data="X"*46)], iface="%s")' % (self.dut_rx_interface, self.dut_rx_interface)) + self.dut.send_expect("flow_director_filter %s del flow ipv6-sctp src FE80:0:0:0:200:1FF:FE00:200 32 dst 3555:5555:6666:6666:7777:7777:8888:8888 32 verify_tag 1 vlan 0 flexbytes () drop queue %d fd_id %d "%(self.dut_ports[0],2,1), "testpmd>") + self.send_and_verify(True, 'sendp([Ether(src=get_if_hwaddr("%s"), dst="00:1B:21:8E:B2:30")/IPv6(src="FE80:0:0:0:200:1FF:FE00:200", dst="3555:5555:6666:6666:7777:7777:8888:8888")/SCTP(sport=32, dport=32, tag=1)/SCTPChunkData(data="X"*46)], iface="%s")' % (self.dut_rx_interface, self.dut_rx_interface)) + if (self.nic in ["niantic"]): + self.dut.send_expect("flow_director_filter %s add flow ipv6-sctp src FE80:0:0:0:200:1FF:FE00:200 32 dst 3555:5555:6666:6666:7777:7777:8888:8888 32 verify_tag 1 vlan 0 flexbytes () drop queue %d fd_id %d "%(self.dut_ports[0],1,1), "testpmd>") + self.dut.send_expect("flow_director_filter %s update flow ipv6-sctp src FE80:0:0:0:200:1FF:FE00:200 32 dst 3555:5555:6666:6666:7777:7777:8888:8888 32 verify_tag 1 vlan 0 flexbytes () drop queue %d fd_id %d "%(self.dut_ports[0],2,1), "testpmd>") + self.send_and_verify(False, 'sendp([Ether(src=get_if_hwaddr("%s"), dst="00:1B:21:8E:B2:30")/IPv6(src="FE80:0:0:0:200:1FF:FE00:200", dst="3555:5555:6666:6666:7777:7777:8888:8888")/SCTP(sport=32, dport=32, tag=1)/SCTPChunkData(data="X"*46)], iface="%s")' % (self.dut_rx_interface, self.dut_rx_interface)) + self.dut.send_expect("flow_director_filter %s del flow ipv6-sctp src FE80:0:0:0:200:1FF:FE00:200 32 dst 3555:5555:6666:6666:7777:7777:8888:8888 32 verify_tag 1 vlan 0 flexbytes () drop queue %d fd_id %d "%(self.dut_ports[0],2,1), "testpmd>") + """ + + # ipv6 frag + self.dut.send_expect("flow_director_filter %s add flow ipv6-other src FE80:0:0:0:200:1FF:FE00:200 dst 3555:5555:6666:6666:7777:7777:8888:8888 vlan 0 flexbytes () drop queue %d fd_id %d " % (self.dut_ports[0], 3, 1), "testpmd>") + self.dut.send_expect("flow_director_filter %s add flow ipv6-frag src FE80:0:0:0:200:1FF:FE00:200 dst 3555:5555:6666:6666:7777:7777:8888:8888 vlan 0 flexbytes () drop queue %d fd_id %d " % (self.dut_ports[0], 2, 1), "testpmd>") + self.send_and_verify(False, 'sendp([Ether(src=get_if_hwaddr("%s"), dst="00:1B:21:8E:B2:30")/IPv6(src="FE80:0:0:0:200:1FF:FE00:200", dst="3555:5555:6666:6666:7777:7777:8888:8888", nh=44)/IPv6ExtHdrFragment()/Raw(load="X"*46)], iface="%s")' % (self.dut_rx_interface, self.dut_rx_interface)) + self.dut.send_expect("flow_director_filter %s del flow ipv6-other src FE80:0:0:0:200:1FF:FE00:200 dst 3555:5555:6666:6666:7777:7777:8888:8888 vlan 0 flexbytes () fwd queue %d fd_id %d " % (self.dut_ports[0], 3, 1), "testpmd>") + self.dut.send_expect("flow_director_filter %s del flow ipv6-frag src FE80:0:0:0:200:1FF:FE00:200 dst 3555:5555:6666:6666:7777:7777:8888:8888 vlan 0 flexbytes () drop queue %d fd_id %d " % (self.dut_ports[0], 2, 1), "testpmd>") + self.send_and_verify(True, 'sendp([Ether(src=get_if_hwaddr("%s"), dst="00:1B:21:8E:B2:30")/IPv6(src="FE80:0:0:0:200:1FF:FE00:200", dst="3555:5555:6666:6666:7777:7777:8888:8888", nh=44)/IPv6ExtHdrFragment()/Raw(load="X"*46)], iface="%s")' % (self.dut_rx_interface, self.dut_rx_interface)) + + self.dut.send_expect("quit", "# ", 30) + + def test_fdir_flexword_fwd_ipv4(self): """ - FDir matching mode - This test adds signature filters to the hardware, and then checks - whether sent packets match those filters. - The test for each mode is following the steps below. - - Start the ``testpmd`` application - - Add filter with upd, tcp sctp, IP4 or IP6 - - Send the packet and validate the filter function. + FDir signature matching mode. """ - - dutPorts = self.dut.get_ports() - localPort = self.tester.get_local_port(dutPorts[0]) - itf = self.tester.get_interface(localPort) + # fwd comand testing + self.fdir_type = "fwd" self.dut.kill_all() - self.pmdout.start_testpmd("all", "--portmask=%s --rxq=2 --txq=2 --disable-rss --pkt-filter-mode=signature --pkt-filter-report-hash=match" % dts.create_mask([dutPorts[0]])) + # fwd testing with flexword + self.dut.send_expect("./%s/app/testpmd -c %s -n 4 -- -i --portmask=%s --disable-rss --rxq=8 --txq=8 --nb-cores=16 --nb-ports=1 --pkt-filter-mode=perfect" % (self.target, self.all_cores_mask, dts.create_mask([self.dut_ports[0]])), "testpmd>", 120) self.dut.send_expect("set verbose 1", "testpmd>") self.dut.send_expect("set fwd rxonly", "testpmd>") - self.dut.send_expect("set nbcore 3", "testpmd>") - self.send_and_verify(False, 'sendp([Ether(src=get_if_hwaddr("%s"), dst="00:1B:21:8E:B2:30")/IP(src="192.168.0.1", dst="192.168.0.2")/UDP(sport=1024,dport=1024)], iface="%s")' % (itf, itf)) - - self.dut.send_expect("add_signature_filter %s udp src 192.168.0.1 1024 dst 192.168.0.2 1024 flexbytes 0x800 vlan 0 queue 1" % dutPorts[0], "testpmd>") - self.send_and_verify(True, 'sendp([Ether(src=get_if_hwaddr("%s"), dst="00:1B:21:8E:B2:30")/IP(src="192.168.0.1", dst="192.168.0.2")/UDP(sport=1024,dport=1024)], iface="%s")' % (itf, itf)) - - self.send_and_verify(False, 'sendp([Ether(src=get_if_hwaddr("%s"), dst="00:1B:21:8E:B2:30")/IP(src="192.168.0.1", dst="192.168.0.2")/TCP(sport=1024,dport=1024)], iface="%s")' % (itf, itf)) - - self.dut.send_expect("upd_signature_filter %s udp src 192.168.1.1 0 dst 192.168.1.2 0 flexbytes 0x800 vlan 0 queue 1" % dutPorts[0], "testpmd>") - - self.send_and_verify(True, 'sendp([Ether(src=get_if_hwaddr("%s"), dst="00:1B:21:8E:B2:30")/IP(src="192.168.0.1", dst="192.168.0.2")/UDP(sport=1024,dport=1024)], iface="%s")' % (itf, itf)) - - self.send_and_verify(True, 'sendp([Ether(src=get_if_hwaddr("%s"), dst="00:1B:21:8E:B2:30")/IP(src="192.168.1.1", dst="192.168.1.2")/UDP(sport=0,dport=0)], iface="%s")' % (itf, itf)) - - self.dut.send_expect("rm_signature_filter %s udp src 192.168.1.1 0 dst 192.168.1.2 0 flexbytes 0x800 vlan 0" % dutPorts[0], "testpmd>") - - self.send_and_verify(False, 'sendp([Ether(src=get_if_hwaddr("%s"), dst="00:1B:21:8E:B2:30")/IP(src="192.168.1.1", dst="192.168.1.2")/UDP(sport=0,dport=0)], iface="%s")' % (itf, itf)) - - self.dut.send_expect("add_signature_filter %s tcp src 192.168.0.1 1024 dst 192.168.0.2 1024 flexbytes 0x800 vlan 0 queue 1" % dutPorts[0], "testpmd>") - self.send_and_verify(True, 'sendp([Ether(src=get_if_hwaddr("%s"), dst="00:1B:21:8E:B2:30")/IP(src="192.168.0.1", dst="192.168.0.2")/TCP(sport=1024,dport=1024)], iface="%s")' % (itf, itf)) - - self.send_and_verify(False, 'sendp([Ether(src=get_if_hwaddr("%s"), dst="00:1B:21:8E:B2:30")/IP(src="192.168.0.1", dst="192.168.0.2")/SCTP(sport=1024,dport=1024)], iface="%s")' % (itf, itf)) - - self.dut.send_expect("add_signature_filter %s sctp src 192.168.0.1 0 dst 192.168.0.2 0 flexbytes 0x800 vlan 0 queue 1" % dutPorts[0], "testpmd>") - self.send_and_verify(True, 'sendp([Ether(src=get_if_hwaddr("%s"), dst="00:1B:21:8E:B2:30")/IP(src="192.168.0.1", dst="192.168.0.2")/SCTP(sport=1024,dport=1024)], iface="%s")' % (itf, itf)) - - self.send_and_verify(False, 'sendp([Ether(src=get_if_hwaddr("%s"), dst="00:1B:21:8E:B2:30")/IP(src="192.168.0.1", dst="192.168.0.2")], iface="%s")' % (itf, itf)) - - self.dut.send_expect("add_signature_filter %s ip src 192.168.0.1 0 dst 192.168.0.2 0 flexbytes 0x800 vlan 0 queue 1" % dutPorts[0], "testpmd>") - self.send_and_verify(True, 'sendp([Ether(src=get_if_hwaddr("%s"), dst="00:1B:21:8E:B2:30")/IP(src="192.168.0.1", dst="192.168.0.2")], iface="%s")' % (itf, itf)) - - self.send_and_verify(False, 'sendp([Ether(src=get_if_hwaddr("%s"), dst="00:1B:21:8E:B2:30")/IPv6(src="2001:0db8:85a3:0000:0000:8a2e:0370:7000", dst="2001:0db8:85a3:0000:0000:8a2e:0370:7338")/UDP(sport=1024,dport=1024)], iface="%s")' % (itf, itf)) - - self.dut.send_expect("add_signature_filter %s udp src 2001:0db8:85a3:0000:0000:8a2e:0370:7000 1024 dst 2001:0db8:85a3:0000:0000:8a2e:0370:7338 1024 flexbytes 0x86dd vlan 0 queue 1" % dutPorts[0], "testpmd>") - self.send_and_verify(True, 'sendp([Ether(src=get_if_hwaddr("%s"), dst="00:1B:21:8E:B2:30")/IPv6(src="2001:0db8:85a3:0000:0000:8a2e:0370:7000", dst="2001:0db8:85a3:0000:0000:8a2e:0370:7338")/UDP(sport=1024,dport=1024)], iface="%s")' % (itf, itf)) + self.fdir_set_rule() + self.fdir_get_flexbytes() + + # ipv4 ip + self.dut.send_expect("flow_director_filter %s add flow ipv4-other src 192.168.0.1 dst 192.168.0.2 vlan 0 flexbytes (%s) fwd queue %d fd_id %d " % (self.dut_ports[0], self.flexbytes, 2, 1), "testpmd>") + self.send_and_verify(True, 'sendp([Ether(src=get_if_hwaddr("%s"), dst="00:1B:21:8E:B2:30")/IP(src="192.168.0.1", dst="192.168.0.2")/Raw(load="%s")], iface="%s")' % (self.dut_rx_interface, self.payload, self.dut_rx_interface)) + self.dut.send_expect("flow_director_filter %s del flow ipv4-other src 192.168.0.1 dst 192.168.0.2 vlan 0 flexbytes (%s) fwd queue %d fd_id %d " % (self.dut_ports[0], self.flexbytes, 2, 1), "testpmd>") + self.send_and_verify(False, 'sendp([Ether(src=get_if_hwaddr("%s"),dst="00:1B:21:8E:B2:30")/IP(src="192.168.0.1", dst="192.168.0.2")/Raw(load="%s")], iface="%s")' % (self.dut_rx_interface, self.payload, self.dut_rx_interface)) + if (self.nic in ["niantic"]): + self.dut.send_expect("flow_director_filter %s add flow ipv4-other src 192.168.0.1 dst 192.168.0.2 vlan 0 flexbytes (%s) fwd queue %d fd_id %d " % (self.dut_ports[0], self.flexbytes, 1, 1), "testpmd>") + self.dut.send_expect("flow_director_filter %s update flow ipv4-other src 192.168.0.1 dst 192.168.0.2 vlan 0 flexbytes (%s) fwd queue %d fd_id %d " % (self.dut_ports[0], self.flexbytes, 2, 1), "testpmd>") + self.send_and_verify(True, 'sendp([Ether(src=get_if_hwaddr("%s"), dst="00:1B:21:8E:B2:30")/IP(src="192.168.0.1", dst="192.168.0.2")/Raw(load="%s")], iface="%s")' % (self.dut_rx_interface, self.payload, self.dut_rx_interface)) + self.dut.send_expect("flow_director_filter %s del flow ipv4-other src 192.168.0.1 dst 192.168.0.2 vlan 0 flexbytes (%s) fwd queue %d fd_id %d " % (self.dut_ports[0], self.flexbytes, 2, 1), "testpmd>") + + # ipv4 udp + self.dut.send_expect("flow_director_filter %s add flow ipv4-udp src 192.168.0.1 1024 dst 192.168.0.2 1024 vlan 0 flexbytes (%s) fwd queue %d fd_id %d " % (self.dut_ports[0], self.flexbytes, 2, 1), "testpmd>") + self.send_and_verify(True, 'sendp([Ether(src=get_if_hwaddr("%s"), dst="00:1B:21:8E:B2:30")/IP(src="192.168.0.1", dst="192.168.0.2")/UDP(sport=1024,dport=1024)/Raw(load="%s")], iface="%s")' % (self.dut_rx_interface, self.payload, self.dut_rx_interface)) + self.dut.send_expect("flow_director_filter %s del flow ipv4-udp src 192.168.0.1 1024 dst 192.168.0.2 1024 vlan 0 flexbytes (%s) fwd queue %d fd_id %d " % (self.dut_ports[0], self.flexbytes, 2, 1), "testpmd>") + self.send_and_verify(False, 'sendp([Ether(src=get_if_hwaddr("%s"), dst="00:1B:21:8E:B2:30")/IP(src="192.168.0.1", dst="192.168.0.2")/UDP(sport=1024,dport=1024)/Raw(load="%s")], iface="%s")' % (self.dut_rx_interface, self.payload, self.dut_rx_interface)) + if (self.nic in ["niantic"]): + self.dut.send_expect("flow_director_filter %s add flow ipv4-udp src 192.168.0.1 1024 dst 192.168.0.2 1024 vlan 0 flexbytes (%s) fwd queue %d fd_id %d " % (self.dut_ports[0], self.flexbytes, 1, 1), "testpmd>") + self.dut.send_expect("flow_director_filter %s update flow ipv4-udp src 192.168.0.1 1024 dst 192.168.0.2 1024 vlan 0 flexbytes (%s) fwd queue %d fd_id %d " % (self.dut_ports[0], self.flexbytes, 2, 1), "testpmd>") + self.send_and_verify(True, 'sendp([Ether(src=get_if_hwaddr("%s"), dst="00:1B:21:8E:B2:30")/IP(src="192.168.0.1", dst="192.168.0.2")/UDP(sport=1024,dport=1024)/Raw(load="%s")], iface="%s")' % (self.dut_rx_interface, self.payload, self.dut_rx_interface)) + self.dut.send_expect("flow_director_filter %s del flow ipv4-udp src 192.168.0.1 1024 dst 192.168.0.2 1024 vlan 0 flexbytes (%s) fwd queue %d fd_id %d " % (self.dut_ports[0], self.flexbytes, 2, 1), "testpmd>") + + # ipv4 tcp + self.dut.send_expect("flow_director_filter %s add flow ipv4-tcp src 192.168.0.1 32 dst 192.168.0.2 32 vlan 0 flexbytes (%s) fwd queue %d fd_id %d " % (self.dut_ports[0], self.flexbytes, 2, 1), "testpmd>") + self.send_and_verify(True, 'sendp([Ether(src=get_if_hwaddr("%s"), dst="00:1B:21:8E:B2:30")/IP(src="192.168.0.1", dst="192.168.0.2")/TCP(sport=32,dport=32)/Raw(load="%s")], iface="%s")' % (self.dut_rx_interface, self.payload, self.dut_rx_interface)) + self.dut.send_expect("flow_director_filter %s del flow ipv4-tcp src 192.168.0.1 32 dst 192.168.0.2 32 vlan 0 flexbytes (%s) fwd queue %d fd_id %d " % (self.dut_ports[0], self.flexbytes, 2, 1), "testpmd>") + self.send_and_verify(False, 'sendp([Ether(src=get_if_hwaddr("%s"), dst="00:1B:21:8E:B2:30")/IP(src="192.168.0.1", dst="192.168.0.2")/TCP(sport=32,dport=32)/Raw(load="%s")], iface="%s")' % (self.dut_rx_interface, self.payload, self.dut_rx_interface)) + if (self.nic in ["niantic"]): + self.dut.send_expect("flow_director_filter %s add flow ipv4-tcp src 192.168.0.1 32 dst 192.168.0.2 32 vlan 0 flexbytes (%s) fwd queue %d fd_id %d " % (self.dut_ports[0], self.flexbytes, 1, 1), "testpmd>") + self.dut.send_expect("flow_director_filter %s update flow ipv4-tcp src 192.168.0.1 32 dst 192.168.0.2 32 vlan 0 flexbytes (%s) fwd queue %d fd_id %d " % (self.dut_ports[0], self.flexbytes, 2, 1), "testpmd>") + self.send_and_verify(True, 'sendp([Ether(src=get_if_hwaddr("%s"), dst="00:1B:21:8E:B2:30")/IP(src="192.168.0.1", dst="192.168.0.2")/TCP(sport=32,dport=32)/Raw(load="%s")], iface="%s")' % (self.dut_rx_interface, self.payload, self.dut_rx_interface)) + self.dut.send_expect("flow_director_filter %s del flow ipv4-tcp src 192.168.0.1 32 dst 192.168.0.2 32 vlan 0 flexbytes (%s) fwd queue %d fd_id %d " % (self.dut_ports[0], self.flexbytes, 2, 1), "testpmd>") + + # ipv4 frag + # ip-frag only support fortville + if (self.nic in ["fortville_eagle", "fortville_spirit", "fortville_spirit_single"]): + self.dut.send_expect("flow_director_filter %s add flow ipv4-other src 192.168.0.1 dst 192.168.0.2 vlan 0 flexbytes (%s) fwd queue %d fd_id %d " % (self.dut_ports[0], self.flexbytes, 3, 1), "testpmd>") + self.dut.send_expect("flow_director_filter %s add flow ipv4-frag src 192.168.0.1 dst 192.168.0.2 vlan 0 flexbytes (%s) fwd queue %d fd_id %d " % (self.dut_ports[0], self.flexbytes, 2, 1), "testpmd>") + self.send_and_verify(True, 'sendp([Ether(src=get_if_hwaddr("%s"), dst="00:1B:21:8E:B2:30")/IP(src="192.168.0.1", dst="192.168.0.2", frag=1, flags="MF")/Raw(load="%s")], iface="%s")' % (self.dut_rx_interface, self.payload, self.dut_rx_interface)) + self.dut.send_expect("flow_director_filter %s del flow ipv4-other src 192.168.0.1 dst 192.168.0.2 vlan 0 flexbytes (%s) fwd queue %d fd_id %d " % (self.dut_ports[0], self.flexbytes, 3, 1), "testpmd>") + self.dut.send_expect("flow_director_filter %s del flow ipv4-frag src 192.168.0.1 dst 192.168.0.2 vlan 0 flexbytes (%s) fwd queue %d fd_id %d " % (self.dut_ports[0], self.flexbytes, 2, 1), "testpmd>") + self.send_and_verify(False, 'sendp([Ether(src=get_if_hwaddr("%s"),dst="00:1B:21:8E:B2:30")/IP(src="192.168.0.1", dst="192.168.0.2", frag=1, flags="MF")/Raw(load="%s")], iface="%s")' % (self.dut_rx_interface, self.payload, self.dut_rx_interface)) + + # ipv4 sctp + """ + self.dut.send_expect("flow_director_filter %s add flow ipv4-sctp src 192.168.0.1 32 dst 192.168.0.2 32 verify_tag 1 vlan 0 flexbytes (%s) fwd queue %d fd_id %d "%(self.dut_ports[0],self.flexbytes, 2, 1), "testpmd>") + self.send_and_verify(True, 'sendp([Ether(src=get_if_hwaddr("%s"), dst="00:1B:21:8E:B2:30")/IP(src="192.168.0.1", dst="192.168.0.2")/SCTP(sport=32, dport=32, tag=1)/SCTPChunkData(data="%s")], iface="%s")' % (self.dut_rx_interface, self.payload, self.dut_rx_interface)) + self.dut.send_expect("flow_director_filter %s del flow ipv4-sctp src 192.168.0.1 32 dst 192.168.0.2 32 verify_tag 1 vlan 0 flexbytes (%s) fwd queue %d fd_id %d "%(self.dut_ports[0],self.flexbytes, 2, 1), "testpmd>") + self.send_and_verify(False, 'sendp([Ether(src=get_if_hwaddr("%s"), dst="00:1B:21:8E:B2:30")/IP(src="192.168.0.1", dst="192.168.0.2")/SCTP(sport=32, dport=32, tag=1)/SCTPChunkData(data="%s")], iface="%s")' % (self.dut_rx_interface, self.payload, self.dut_rx_interface)) + if (self.nic in ["niantic"]): + self.dut.send_expect("flow_director_filter %s add flow ipv4-sctp src 192.168.0.1 32 dst 192.168.0.2 32 verify_tag 1 vlan 0 flexbytes (%s) fwd queue %d fd_id %d "%(self.dut_ports[0],self.flexbytes, 1, 1), "testpmd>") + self.dut.send_expect("flow_director_filter %s update flow ipv4-sctp src 192.168.0.1 32 dst 192.168.0.2 32 verify_tag 1 vlan 0 flexbytes (%s) fwd queue %d fd_id %d "%(self.dut_ports[0],self.flexbytes, 2, 1), "testpmd>") + self.send_and_verify(True, 'sendp([Ether(src=get_if_hwaddr("%s"), dst="00:1B:21:8E:B2:30")/IP(src="192.168.0.1", dst="192.168.0.2")/SCTP(sport=32, dport=32, tag=1)/SCTPChunkData(data="%s")], iface="%s")' % (self.dut_rx_interface, self.payload, self.dut_rx_interface)) + self.dut.send_expect("flow_director_filter 0 del flow ipv4-sctp src 192.168.0.1 32 dst 192.168.0.2 32 verify_tag 1 vlan 0 flexbytes (%s) fwd queue %d fd_id %d "%(self.dut_ports[0],self.flexbytes, 2, 1), "testpmd>") + """ self.dut.send_expect("quit", "# ", 30) - def test_fdir_perfect_matching(self): + def test_fdir_flexword_fwd_ipv6(self): """ - FDir perfect matching mode. - This test adds perfect-match filters to the hardware, and then checks whether sent packets match those filters. - The test for each mode is following the steps below. - - Start the ``testpmd`` application with perfect match; - - Add filter with upd, tcp sctp, IP4; - - Send the packet and validate the perfect filter function. + FDir signature matching mode. """ - - dutPorts = self.dut.get_ports() - localPort = self.tester.get_local_port(dutPorts[0]) - itf = self.tester.get_interface(localPort) + # fwd comand testing + self.fdir_type = "fwd" self.dut.kill_all() - self.pmdout.start_testpmd("all", "--portmask=%s --rxq=2 --txq=2 --disable-rss --pkt-filter-mode=perfect --pkt-filter-report-hash=match" % dts.create_mask([dutPorts[0]])) + # fwd testing with flexword + if self.nic in ["niantic"]: + # Niantic ipv6 only support signature mode + self.dut.send_expect("./%s/app/testpmd -c %s -n 4 -- -i --portmask=%s --disable-rss --rxq=8 --txq=8 --nb-cores=16 --nb-ports=1 --pkt-filter-mode=signature" % (self.target, self.all_cores_mask, dts.create_mask([self.dut_ports[0]])), "testpmd>", 120) + elif self.nic in ["fortville_eagle", "fortville_spirit", "fortville_spirit_single"]: + # fortville ipv6 support perfect mode + self.dut.send_expect("./%s/app/testpmd -c %s -n 4 -- -i --portmask=%s --disable-rss --rxq=8 --txq=8 --nb-cores=16 --nb-ports=1 --pkt-filter-mode=perfect" % (self.target, self.all_cores_mask, dts.create_mask([self.dut_ports[0]])), "testpmd>", 120) self.dut.send_expect("set verbose 1", "testpmd>") self.dut.send_expect("set fwd rxonly", "testpmd>") - self.dut.send_expect("set nbcore 3", "testpmd>") - - self.dut.send_expect("add_perfect_filter %s udp src 192.168.0.1 1024 dst 192.168.0.2 1024 flexbytes 0x800 vlan 0 queue 1 soft 0x14" % dutPorts[0], "testpmd>") - self.send_and_verify(True, 'sendp([Ether(src=get_if_hwaddr("%s"), dst="00:1B:21:8E:B2:30")/IP(src="192.168.0.1", dst="192.168.0.2")/UDP(sport=1024,dport=1024)], iface="%s")' % (itf, itf)) - self.dut.send_expect("add_perfect_filter %s tcp src 192.168.0.1 1024 dst 192.168.0.2 1024 flexbytes 0x800 vlan 0 queue 1 soft 0x15" % dutPorts[0], "testpmd>") - self.send_and_verify(True, 'sendp([Ether(src=get_if_hwaddr("%s"), dst="00:1B:21:8E:B2:30")/IP(src="192.168.0.1", dst="192.168.0.2")/TCP(sport=1024,dport=1024)], iface="%s")' % (itf, itf)) - - self.dut.send_expect("add_perfect_filter %s sctp src 192.168.0.1 0 dst 192.168.0.2 0 flexbytes 0x800 vlan 0 queue 1 soft 0x16" % dutPorts[0], "testpmd>") - self.send_and_verify(True, 'sendp([Ether(src=get_if_hwaddr("%s"), dst="00:1B:21:8E:B2:30")/IP(src="192.168.0.1", dst="192.168.0.2")/SCTP(sport=1024,dport=1024)], iface="%s")' % (itf, itf)) + self.fdir_set_rule() + self.fdir_get_flexbytes() + + # ipv6 ip + self.dut.send_expect("flow_director_filter %s add flow ipv6-other src FE80:0:0:0:200:1FF:FE00:200 dst 3555:5555:6666:6666:7777:7777:8888:8888 vlan 0 flexbytes (%s) fwd queue %d fd_id %d " % (self.dut_ports[0], self.flexbytes, 2, 1), "testpmd>") + self.send_and_verify(True, 'sendp([Ether(src=get_if_hwaddr("%s"), dst="00:1B:21:8E:B2:30")/IPv6(src="FE80:0:0:0:200:1FF:FE00:200", dst="3555:5555:6666:6666:7777:7777:8888:8888")/Raw(load="%s")], iface="%s")' % (self.dut_rx_interface, self.payload, self.dut_rx_interface)) + self.dut.send_expect("flow_director_filter %s del flow ipv6-other src FE80:0:0:0:200:1FF:FE00:200 dst 3555:5555:6666:6666:7777:7777:8888:8888 vlan 0 flexbytes (%s) fwd queue %d fd_id %d " % (self.dut_ports[0], self.flexbytes, 2, 1), "testpmd>") + self.send_and_verify(False, 'sendp([Ether(src=get_if_hwaddr("%s"), dst="00:1B:21:8E:B2:30")/IPv6(src="FE80:0:0:0:200:1FF:FE00:200", dst="3555:5555:6666:6666:7777:7777:8888:8888")/Raw(load="%s")], iface="%s")' % (self.dut_rx_interface, self.payload, self.dut_rx_interface)) + if (self.nic in ["niantic"]): + self.dut.send_expect("flow_director_filter %s add flow ipv6-other src FE80:0:0:0:200:1FF:FE00:200 dst 3555:5555:6666:6666:7777:7777:8888:8888 vlan 0 flexbytes (%s) fwd queue %d fd_id %d " % (self.dut_ports[0], self.flexbytes, 1, 1), "testpmd>") + self.dut.send_expect("flow_director_filter %s update flow ipv6-other src FE80:0:0:0:200:1FF:FE00:200 dst 3555:5555:6666:6666:7777:7777:8888:8888 vlan 0 flexbytes (%s) fwd queue %d fd_id %d " % (self.dut_ports[0], self.flexbytes, 2, 1), "testpmd>") + self.send_and_verify(True, 'sendp([Ether(src=get_if_hwaddr("%s"), dst="00:1B:21:8E:B2:30")/IPv6(src="FE80:0:0:0:200:1FF:FE00:200", dst="3555:5555:6666:6666:7777:7777:8888:8888")/Raw(load="%s")], iface="%s")' % (self.dut_rx_interface, self.payload, self.dut_rx_interface)) + self.dut.send_expect("flow_director_filter %s del flow ipv6-other src FE80:0:0:0:200:1FF:FE00:200 dst 3555:5555:6666:6666:7777:7777:8888:8888 vlan 0 flexbytes (%s) fwd queue %d fd_id %d " % (self.dut_ports[0], self.flexbytes, 2, 1), "testpmd>") + + # ipv6 udp + self.dut.send_expect("flow_director_filter %s add flow ipv6-udp src FE80:0:0:0:200:1FF:FE00:200 1024 dst 3555:5555:6666:6666:7777:7777:8888:8888 1024 vlan 0 flexbytes (%s) fwd queue %d fd_id %d " % (self.dut_ports[0], self.flexbytes, 2, 1), "testpmd>") + self.send_and_verify(True, 'sendp([Ether(src=get_if_hwaddr("%s"), dst="00:1B:21:8E:B2:30")/IPv6(src="FE80:0:0:0:200:1FF:FE00:200", dst="3555:5555:6666:6666:7777:7777:8888:8888")/UDP(sport=1024,dport=1024)/Raw(load="%s")], iface="%s")' % (self.dut_rx_interface, self.payload, self.dut_rx_interface)) + self.dut.send_expect("flow_director_filter %s del flow ipv6-udp src FE80:0:0:0:200:1FF:FE00:200 1024 dst 3555:5555:6666:6666:7777:7777:8888:8888 1024 vlan 0 flexbytes (%s) fwd queue %d fd_id %d " % (self.dut_ports[0], self.flexbytes, 2, 1), "testpmd>") + self.send_and_verify(False, 'sendp([Ether(src=get_if_hwaddr("%s"), dst="00:1B:21:8E:B2:30")/IPv6(src="FE80:0:0:0:200:1FF:FE00:200", dst="3555:5555:6666:6666:7777:7777:8888:8888")/UDP(sport=1024,dport=1024)/Raw(load="%s")], iface="%s")' % (self.dut_rx_interface, self.payload, self.dut_rx_interface)) + if (self.nic in ["niantic"]): + self.dut.send_expect("flow_director_filter %s add flow ipv6-udp src FE80:0:0:0:200:1FF:FE00:200 1024 dst 3555:5555:6666:6666:7777:7777:8888:8888 1024 vlan 0 flexbytes (%s) fwd queue %d fd_id %d " % (self.dut_ports[0], self.flexbytes, 1, 1), "testpmd>") + self.dut.send_expect("flow_director_filter %s update flow ipv6-udp src FE80:0:0:0:200:1FF:FE00:200 1024 dst 3555:5555:6666:6666:7777:7777:8888:8888 1024 vlan 0 flexbytes (%s) fwd queue %d fd_id %d " % (self.dut_ports[0], self.flexbytes, 2, 1), "testpmd>") + self.send_and_verify(True, 'sendp([Ether(src=get_if_hwaddr("%s"), dst="00:1B:21:8E:B2:30")/IPv6(src="FE80:0:0:0:200:1FF:FE00:200", dst="3555:5555:6666:6666:7777:7777:8888:8888")/UDP(sport=1024,dport=1024)/Raw(load="%s")], iface="%s")' % (self.dut_rx_interface, self.payload, self.dut_rx_interface)) + self.dut.send_expect("flow_director_filter %s del flow ipv6-udp src FE80:0:0:0:200:1FF:FE00:200 1024 dst 3555:5555:6666:6666:7777:7777:8888:8888 1024 vlan 0 flexbytes (%s) fwd queue %d fd_id %d " % (self.dut_ports[0], self.flexbytes, 2, 1), "testpmd>") + + # ipv6 tcp + self.dut.send_expect("flow_director_filter %s add flow ipv6-tcp src FE80:0:0:0:200:1FF:FE00:200 32 dst 3555:5555:6666:6666:7777:7777:8888:8888 32 vlan 0 flexbytes (%s) fwd queue %d fd_id %d " % (self.dut_ports[0], self.flexbytes, 2, 1), "testpmd>") + self.send_and_verify(True, 'sendp([Ether(src=get_if_hwaddr("%s"), dst="00:1B:21:8E:B2:30")/IPv6(src="FE80:0:0:0:200:1FF:FE00:200", dst="3555:5555:6666:6666:7777:7777:8888:8888")/TCP(sport=32,dport=32)/Raw(load="%s")], iface="%s")' % (self.dut_rx_interface, self.payload, self.dut_rx_interface)) + self.dut.send_expect("flow_director_filter %s del flow ipv6-tcp src FE80:0:0:0:200:1FF:FE00:200 32 dst 3555:5555:6666:6666:7777:7777:8888:8888 32 vlan 0 flexbytes (%s) fwd queue %d fd_id %d " % (self.dut_ports[0], self.flexbytes, 2, 1), "testpmd>") + self.send_and_verify(False, 'sendp([Ether(src=get_if_hwaddr("%s"), dst="00:1B:21:8E:B2:30")/IPv6(src="FE80:0:0:0:200:1FF:FE00:200", dst="3555:5555:6666:6666:7777:7777:8888:8888")/TCP(sport=32,dport=32)/Raw(load="%s")], iface="%s")' % (self.dut_rx_interface, self.payload, self.dut_rx_interface)) + if (self.nic in ["niantic"]): + self.dut.send_expect("flow_director_filter %s add flow ipv6-tcp src FE80:0:0:0:200:1FF:FE00:200 32 dst 3555:5555:6666:6666:7777:7777:8888:8888 32 vlan 0 flexbytes (%s) fwd queue %d fd_id %d " % (self.dut_ports[0], self.flexbytes, 1, 1), "testpmd>") + self.dut.send_expect("flow_director_filter %s update flow ipv6-tcp src FE80:0:0:0:200:1FF:FE00:200 32 dst 3555:5555:6666:6666:7777:7777:8888:8888 32 vlan 0 flexbytes (%s) fwd queue %d fd_id %d " % (self.dut_ports[0], self.flexbytes, 2, 1), "testpmd>") + self.send_and_verify(True, 'sendp([Ether(src=get_if_hwaddr("%s"), dst="00:1B:21:8E:B2:30")/IPv6(src="FE80:0:0:0:200:1FF:FE00:200", dst="3555:5555:6666:6666:7777:7777:8888:8888")/TCP(sport=32,dport=32)/Raw(load="%s")], iface="%s")' % (self.dut_rx_interface, self.payload, self.dut_rx_interface)) + self.dut.send_expect("flow_director_filter %s del flow ipv6-tcp src FE80:0:0:0:200:1FF:FE00:200 32 dst 3555:5555:6666:6666:7777:7777:8888:8888 32 vlan 0 flexbytes (%s) fwd queue %d fd_id %d " % (self.dut_ports[0], self.flexbytes, 2, 1), "testpmd>") + """ + #ipv6 sctp + self.dut.send_expect("flow_director_filter %s add flow ipv6-sctp src FE80:0:0:0:200:1FF:FE00:200 32 dst 3555:5555:6666:6666:7777:7777:8888:8888 32 verify_tag 1 vlan 0 flexbytes (%s) fwd queue %d fd_id %d "%(self.dut_ports[0],self.flexbytes,2,1), "testpmd>") + self.send_and_verify(True, 'sendp([Ether(src=get_if_hwaddr("%s"), dst="00:1B:21:8E:B2:30")/IPv6(src="FE80:0:0:0:200:1FF:FE00:200", dst="3555:5555:6666:6666:7777:7777:8888:8888")/SCTP(sport=32, dport=32, tag=1)/SCTPChunkData(data="%s")], iface="%s")' % (self.dut_rx_interface, self.payload, self.dut_rx_interface)) + self.dut.send_expect("flow_director_filter %s del flow ipv6-sctp src FE80:0:0:0:200:1FF:FE00:200 32 dst 3555:5555:6666:6666:7777:7777:8888:8888 32 verify_tag 1 vlan 0 flexbytes (%s) fwd queue %d fd_id %d "%(self.dut_ports[0],self.flexbytes,2,1), "testpmd>") + self.send_and_verify(False, 'sendp([Ether(src=get_if_hwaddr("%s"), dst="00:1B:21:8E:B2:30")/IPv6(src="FE80:0:0:0:200:1FF:FE00:200", dst="3555:5555:6666:6666:7777:7777:8888:8888")/SCTP(sport=32, dport=32, tag=1)/SCTPChunkData(data="%s")], iface="%s")' % (self.dut_rx_interface, self.payload, self.dut_rx_interface)) + if (self.nic in ["niantic"]): + self.dut.send_expect("flow_director_filter %s add flow ipv6-sctp src FE80:0:0:0:200:1FF:FE00:200 32 dst 3555:5555:6666:6666:7777:7777:8888:8888 32 verify_tag 1 vlan 0 flexbytes (%s) fwd queue %d fd_id %d "%(self.dut_ports[0],self.flexbytes,1,1), "testpmd>") + self.dut.send_expect("flow_director_filter %s update flow ipv6-sctp src FE80:0:0:0:200:1FF:FE00:200 32 dst 3555:5555:6666:6666:7777:7777:8888:8888 32 verify_tag 1 vlan 0 flexbytes (%s) fwd queue %d fd_id %d "%(self.dut_ports[0],self.flexbytes,2,1), "testpmd>") + self.send_and_verify(True, 'sendp([Ether(src=get_if_hwaddr("%s"), dst="00:1B:21:8E:B2:30")/IPv6(src="FE80:0:0:0:200:1FF:FE00:200", dst="3555:5555:6666:6666:7777:7777:8888:8888")/SCTP(sport=32, dport=32, tag=1)/SCTPChunkData(data="%s")], iface="%s")' % (self.dut_rx_interface, self.payload, self.dut_rx_interface)) + self.dut.send_expect("flow_director_filter %s del flow ipv6-sctp src FE80:0:0:0:200:1FF:FE00:200 32 dst 3555:5555:6666:6666:7777:7777:8888:8888 32 verify_tag 1 vlan 0 flexbytes (%s) fwd queue %d fd_id %d "%(self.dut_ports[0],self.flexbytes,2,1), "testpmd>") + """ - self.dut.send_expect("add_perfect_filter %s ip src 192.168.0.1 0 dst 192.168.0.2 0 flexbytes 0x800 vlan 0 queue 1 soft 0x17" % dutPorts[0], "testpmd>") - self.send_and_verify(True, 'sendp([Ether(src=get_if_hwaddr("%s"), dst="00:1B:21:8E:B2:30")/IP(src="192.168.0.1", dst="192.168.0.2")], iface="%s")' % (itf, itf)) + # ipv6 frag + # ip-frag only support fortville + if (self.nic in ["fortville_eagle", "fortville_spirit", "fortville_spirit_single"]): + self.dut.send_expect("flow_director_filter %s add flow ipv6-other src FE80:0:0:0:200:1FF:FE00:200 dst 3555:5555:6666:6666:7777:7777:8888:8888 vlan 0 flexbytes (%s) fwd queue %d fd_id %d " % (self.dut_ports[0], self.flexbytes, 3, 1), "testpmd>") + self.dut.send_expect("flow_director_filter %s add flow ipv6-frag src FE80:0:0:0:200:1FF:FE00:200 dst 3555:5555:6666:6666:7777:7777:8888:8888 vlan 0 flexbytes (%s) fwd queue %d fd_id %d " % (self.dut_ports[0], self.flexbytes, 2, 1), "testpmd>") + self.send_and_verify(True, 'sendp([Ether(src=get_if_hwaddr("%s"), dst="00:1B:21:8E:B2:30")/IPv6(src="FE80:0:0:0:200:1FF:FE00:200", dst="3555:5555:6666:6666:7777:7777:8888:8888", nh=44)/IPv6ExtHdrFragment()/Raw(load="%s")], iface="%s")' % (self.dut_rx_interface, self.payload, self.dut_rx_interface)) + self.dut.send_expect("flow_director_filter %s del flow ipv6-other src FE80:0:0:0:200:1FF:FE00:200 dst 3555:5555:6666:6666:7777:7777:8888:8888 vlan 0 flexbytes (%s) fwd queue %d fd_id %d " % (self.dut_ports[0], self.flexbytes, 3, 1), "testpmd>") + self.dut.send_expect("flow_director_filter %s del flow ipv6-frag src FE80:0:0:0:200:1FF:FE00:200 dst 3555:5555:6666:6666:7777:7777:8888:8888 vlan 0 flexbytes (%s) fwd queue %d fd_id %d " % (self.dut_ports[0], self.flexbytes, 2, 1), "testpmd>") + self.send_and_verify(False, 'sendp([Ether(src=get_if_hwaddr("%s"), dst="00:1B:21:8E:B2:30")/IPv6(src="FE80:0:0:0:200:1FF:FE00:200", dst="3555:5555:6666:6666:7777:7777:8888:8888", nh=44)/IPv6ExtHdrFragment()/Raw(load="%s")], iface="%s")' % (self.dut_rx_interface, self.payload, self.dut_rx_interface)) self.dut.send_expect("quit", "# ", 30) - def test_fdir_filter_masks(self): - """ - FDir filter masks. - This tests the functionality of the setting FDir masks to to affect which - fields, or parts of fields are used in the matching process. - """ - - dutPorts = self.dut.get_ports() - localPort = self.tester.get_local_port(dutPorts[0]) - itf = self.tester.get_interface(localPort) + def test_fdir_flexword_drop_ipv4(self): - self.dut.kill_all() - self.pmdout.start_testpmd("all", "--portmask=%s --rxq=2 --txq=2 --disable-rss --pkt-filter-mode=perfect --pkt-filter-size=64K --pkt-filter-report-hash=match" % dts.create_mask([dutPorts[0]])) + # drop testing with flexword + self.dut.send_expect("./%s/app/testpmd -c %s -n 4 -- -i --portmask=%s --disable-rss --rxq=8 --txq=8 --nb-cores=16 --nb-ports=1 --pkt-filter-mode=perfect" % (self.target, self.all_cores_mask, dts.create_mask([self.dut_ports[0]])), "testpmd>", 120) self.dut.send_expect("set verbose 1", "testpmd>") self.dut.send_expect("set fwd rxonly", "testpmd>") - self.dut.send_expect("set nbcore 3", "testpmd>") - - self.dut.send_expect("set_masks_filter %s only_ip_flow 0 src_mask 0xffffff00 0xffff dst_mask 0xffffff00 0xffff flexbytes 1 vlan_id 1 vlan_prio 1" % dutPorts[0], "testpmd>") - self.dut.send_expect("add_perfect_filter %s udp src 192.168.0.0 1024 dst 192.168.0.0 1024 flexbytes 0x800 vlan 0 queue 1 soft 0x17" % dutPorts[0], "testpmd>") - self.send_and_verify(True, 'sendp([Ether(src=get_if_hwaddr("%s"), dst="00:1B:21:8E:B2:30")/IP(src="192.168.0.1", dst="192.168.0.2")/UDP(sport=1024,dport=1024)], iface="%s")' % (itf, itf)) - - self.send_and_verify(True, 'sendp([Ether(src=get_if_hwaddr("%s"), dst="00:1B:21:8E:B2:30")/IP(src="192.168.0.15", dst="192.168.0.15")/UDP(sport=1024,dport=1024)], iface="%s")' % (itf, itf)) - - self.send_and_verify(False, 'sendp([Ether(src=get_if_hwaddr("%s"), dst="00:1B:21:8E:B2:30")/IP(src="192.168.0.1", dst="192.168.1.1")/UDP(sport=1024,dport=1024)], iface="%s")' % (itf, itf)) - - self.dut.send_expect("set_masks_filter %s only_ip_flow 0 src_mask 0xffffffff 0xff00 dst_mask 0xffffffff 0xff00 flexbytes 1 vlan_id 1 vlan_prio 1" % dutPorts[0], "testpmd>") - self.dut.send_expect("add_perfect_filter %s udp src 10.11.12.1 0x4400 dst 10.11.12.2 0x4500 flexbytes 0x800 vlan 0 queue 1 soft 0x4" % dutPorts[0], "testpmd>") - self.send_and_verify(True, 'sendp([Ether(src=get_if_hwaddr("%s"), dst="00:1B:21:8E:B2:30")/IP(src="10.11.12.1", dst="10.11.12.2")/UDP(sport=0x4400,dport=0x4500)], iface="%s")' % (itf, itf)) - self.send_and_verify(True, 'sendp([Ether(src=get_if_hwaddr("%s"), dst="00:1B:21:8E:B2:30")/IP(src="10.11.12.1", dst="10.11.12.2")/UDP(sport=0x4411,dport=0x4517)], iface="%s")' % (itf, itf)) - - self.send_and_verify(False, 'sendp([Ether(src=get_if_hwaddr("%s"), dst="00:1B:21:8E:B2:30")/IP(src="10.11.12.1", dst="10.11.12.2")/UDP(sport=0x4500,dport=0x5500)], iface="%s")' % (itf, itf)) - - self.dut.send_expect("set_masks_filter %s only_ip_flow 1 src_mask 0xffffffff 0x0 dst_mask 0xffffffff 0x0 flexbytes 1 vlan_id 1 vlan_prio 1" % dutPorts[0], "testpmd>") - self.dut.send_expect("add_perfect_filter %s ip src 192.168.0.1 0 dst 192.168.0.2 0 flexbytes 0x800 vlan 0 queue 1 soft 0x42" % dutPorts[0], "testpmd>") - self.send_and_verify(True, 'sendp([Ether(src=get_if_hwaddr("%s"), dst="00:1B:21:8E:B2:30")/IP(src="192.168.0.1", dst="192.168.0.2")/UDP(sport=1024, dport=1024)], iface="%s")' % (itf, itf)) - - self.send_and_verify(True, 'sendp([Ether(src=get_if_hwaddr("%s"), dst="00:1B:21:8E:B2:30")/IP(src="192.168.0.1", dst="192.168.0.2")/TCP(sport=1024, dport=1024)], iface="%s")' % (itf, itf)) + self.fdir_set_rule() + self.fdir_get_flexbytes() + # fwd comand testing + self.fdir_type = "drop" + + # ipv4 ip + self.dut.send_expect("flow_director_filter %s add flow ipv4-other src 192.168.0.1 dst 192.168.0.2 vlan 0 flexbytes (%s) drop queue %d fd_id %d " % (self.dut_ports[0], self.flexbytes, 2, 1), "testpmd>") + self.send_and_verify(False, 'sendp([Ether(src=get_if_hwaddr("%s"), dst="00:1B:21:8E:B2:30")/IP(src="192.168.0.1", dst="192.168.0.2")/Raw(load="%s")], iface="%s")' % (self.dut_rx_interface, self.payload, self.dut_rx_interface)) + self.dut.send_expect("flow_director_filter %s del flow ipv4-other src 192.168.0.1 dst 192.168.0.2 vlan 0 flexbytes (%s) drop queue %d fd_id %d " % (self.dut_ports[0], self.flexbytes, 2, 1), "testpmd>") + self.send_and_verify(True, 'sendp([Ether(src=get_if_hwaddr("%s"), dst="00:1B:21:8E:B2:30")/IP(src="192.168.0.1", dst="192.168.0.2")/Raw(load="%s")], iface="%s")' % (self.dut_rx_interface, self.payload, self.dut_rx_interface)) + + # ipv4 udp + self.dut.send_expect("flow_director_filter %s add flow ipv4-udp src 192.168.0.1 1024 dst 192.168.0.2 1024 vlan 0 flexbytes (%s) drop queue %d fd_id %d " % (self.dut_ports[0], self.flexbytes, 2, 1), "testpmd>") + self.send_and_verify(False, 'sendp([Ether(src=get_if_hwaddr("%s"), dst="00:1B:21:8E:B2:30")/IP(src="192.168.0.1", dst="192.168.0.2")/UDP(sport=1024,dport=1024)/Raw(load="%s")], iface="%s")' % (self.dut_rx_interface, self.payload, self.dut_rx_interface)) + self.dut.send_expect("flow_director_filter %s del flow ipv4-udp src 192.168.0.1 1024 dst 192.168.0.2 1024 vlan 0 flexbytes (%s) drop queue %d fd_id %d " % (self.dut_ports[0], self.flexbytes, 2, 1), "testpmd>") + self.send_and_verify(True, 'sendp([Ether(src=get_if_hwaddr("%s"), dst="00:1B:21:8E:B2:30")/IP(src="192.168.0.1", dst="192.168.0.2")/UDP(sport=1024,dport=1024)/Raw(load="%s")], iface="%s")' % (self.dut_rx_interface, self.payload, self.dut_rx_interface)) + + # ipv4 tcp + self.dut.send_expect("flow_director_filter %s add flow ipv4-tcp src 192.168.0.1 32 dst 192.168.0.2 32 vlan 0 flexbytes (%s) drop queue %d fd_id %d " % (self.dut_ports[0], self.flexbytes, 2, 1), "testpmd>") + self.send_and_verify(False, 'sendp([Ether(src=get_if_hwaddr("%s"), dst="00:1B:21:8E:B2:30")/IP(src="192.168.0.1", dst="192.168.0.2")/TCP(sport=32,dport=32)/Raw(load="%s")], iface="%s")' % (self.dut_rx_interface, self.payload, self.dut_rx_interface)) + self.dut.send_expect("flow_director_filter %s del flow ipv4-tcp src 192.168.0.1 32 dst 192.168.0.2 32 vlan 0 flexbytes (%s) drop queue %d fd_id %d " % (self.dut_ports[0], self.flexbytes, 2, 1), "testpmd>") + self.send_and_verify(True, 'sendp([Ether(src=get_if_hwaddr("%s"), dst="00:1B:21:8E:B2:30")/IP(src="192.168.0.1", dst="192.168.0.2")/TCP(sport=32,dport=32)/Raw(load="%s")], iface="%s")' % (self.dut_rx_interface, self.payload, self.dut_rx_interface)) + + # ipv4 sctp + """ + self.dut.send_expect("flow_director_filter %s add flow ipv4-sctp src 192.168.0.1 32 dst 192.168.0.2 32 verify_tag 1 vlan 0 flexbytes (%s) drop queue %d fd_id %d "%(self.dut_ports[0],self.flexbytes, 2, 1), "testpmd>") + self.send_and_verify(False, 'sendp([Ether(src=get_if_hwaddr("%s"), dst="00:1B:21:8E:B2:30")/IP(src="192.168.0.1", dst="192.168.0.2")/SCTP(sport=32, dport=32, tag=1)/SCTPChunkData(data="%s")], iface="%s")' % (self.dut_rx_interface, self.payload, self.dut_rx_interface)) + self.dut.send_expect("flow_director_filter %s del flow ipv4-sctp src 192.168.0.1 32 dst 192.168.0.2 32 verify_tag 1 vlan 0 flexbytes (%s) drop queue %d fd_id %d "%(self.dut_ports[0],self.flexbytes, 2, 1), "testpmd>") + self.send_and_verify(True, 'sendp([Ether(src=get_if_hwaddr("%s"), dst="00:1B:21:8E:B2:30")/IP(src="192.168.0.1", dst="192.168.0.2")/SCTP(sport=32, dport=32, tag=1)/SCTPChunkData(data="%s")], iface="%s")' % (self.dut_rx_interface, self.payload, self.dut_rx_interface)) + """ - self.send_and_verify(True, 'sendp([Ether(src=get_if_hwaddr("%s"), dst="00:1B:21:8E:B2:30")/IP(src="192.168.0.1", dst="192.168.0.2")/SCTP(sport=1024, dport=1024)], iface="%s")' % (itf, itf)) + # ipv4 frag + # ip-frag only support fortville + if (self.nic in ["fortville_eagle", "fortville_spirit", "fortville_spirit_single"]): + self.dut.send_expect("flow_director_filter %s add flow ipv4-other src 192.168.0.1 dst 192.168.0.2 vlan 0 flexbytes (%s) drop queue %d fd_id %d " % (self.dut_ports[0], self.flexbytes, 3, 1), "testpmd>") + self.dut.send_expect("flow_director_filter %s add flow ipv4-frag src 192.168.0.1 dst 192.168.0.2 vlan 0 flexbytes (%s) drop queue %d fd_id %d " % (self.dut_ports[0], self.flexbytes, 2, 1), "testpmd>") + self.send_and_verify(False, 'sendp([Ether(src=get_if_hwaddr("%s"), dst="00:1B:21:8E:B2:30")/IP(src="192.168.0.1", dst="192.168.0.2", frag=1, flags="MF")/Raw(load="%s")], iface="%s")' % (self.dut_rx_interface, self.payload, self.dut_rx_interface)) + self.dut.send_expect("flow_director_filter %s del flow ipv4-other src 192.168.0.1 dst 192.168.0.2 vlan 0 flexbytes (%s) drop queue %d fd_id %d " % (self.dut_ports[0], self.flexbytes, 3, 1), "testpmd>") + self.dut.send_expect("flow_director_filter %s del flow ipv4-frag src 192.168.0.1 dst 192.168.0.2 vlan 0 flexbytes (%s) drop queue %d fd_id %d " % (self.dut_ports[0], self.flexbytes, 2, 1), "testpmd>") + self.send_and_verify(True, 'sendp([Ether(src=get_if_hwaddr("%s"),dst="00:1B:21:8E:B2:30")/IP(src="192.168.0.1", dst="192.168.0.2", frag=1, flags="MF")/Raw(load="%s")], iface="%s")' % (self.dut_rx_interface, self.payload, self.dut_rx_interface)) self.dut.send_expect("quit", "# ", 30) - def test_fdir_flexbytes_filtering(self): + def test_fdir_flexword_drop_ipv6(self): + # drop not support signature mode, niantic only can work in signature mode with ipv6 + # Niantic is not support in drop ipv6 + if (self.nic in ["fortville_eagle", "fortville_spirit", "fortville_spirit_single"]): + # drop testing with flexword + self.dut.send_expect("./%s/app/testpmd -c %s -n 4 -- -i --portmask=%s --disable-rss --rxq=8 --txq=8 --nb-cores=16 --nb-ports=1 --pkt-filter-mode=perfect" % (self.target, self.all_cores_mask, dts.create_mask([self.dut_ports[0]])), "testpmd>", 120) + self.dut.send_expect("set verbose 1", "testpmd>") + self.dut.send_expect("set fwd rxonly", "testpmd>") + + self.fdir_set_rule() + self.fdir_get_flexbytes() + # fwd comand testing + self.fdir_type = "drop" + + # ipv6 ip + self.dut.send_expect("flow_director_filter %s add flow ipv6-other src FE80:0:0:0:200:1FF:FE00:200 dst 3555:5555:6666:6666:7777:7777:8888:8888 vlan 0 flexbytes (%s) fwd queue %d fd_id %d " % (self.dut_ports[0], self.flexbytes, 2, 1), "testpmd>") + self.dut.send_expect("flow_director_filter %s add flow ipv6-other src FE80:0:0:0:200:1FF:FE00:200 dst 3555:5555:6666:6666:7777:7777:8888:8888 vlan 0 flexbytes (%s) drop queue %d fd_id %d " % (self.dut_ports[0], self.flexbytes, 2, 1), "testpmd>") + self.send_and_verify(False, 'sendp([Ether(src=get_if_hwaddr("%s"), dst="00:1B:21:8E:B2:30")/IPv6(src="FE80:0:0:0:200:1FF:FE00:200", dst="3555:5555:6666:6666:7777:7777:8888:8888")/Raw(load="%s")], iface="%s")' % (self.dut_rx_interface, self.payload, self.dut_rx_interface)) + self.dut.send_expect("flow_director_filter %s del flow ipv6-other src FE80:0:0:0:200:1FF:FE00:200 dst 3555:5555:6666:6666:7777:7777:8888:8888 vlan 0 flexbytes (%s) drop queue %d fd_id %d " % (self.dut_ports[0], self.flexbytes, 2, 1), "testpmd>") + self.send_and_verify(True, 'sendp([Ether(src=get_if_hwaddr("%s"), dst="00:1B:21:8E:B2:30")/IPv6(src="FE80:0:0:0:200:1FF:FE00:200", dst="3555:5555:6666:6666:7777:7777:8888:8888")/Raw(load="%s")], iface="%s")' % (self.dut_rx_interface, self.payload, self.dut_rx_interface)) + + # ipv6 udp + self.dut.send_expect("flow_director_filter %s add flow ipv6-udp src FE80:0:0:0:200:1FF:FE00:200 1024 dst 3555:5555:6666:6666:7777:7777:8888:8888 1024 vlan 0 flexbytes (%s) fwd queue %d fd_id %d " % (self.dut_ports[0], self.flexbytes, 2, 1), "testpmd>") + self.dut.send_expect("flow_director_filter %s add flow ipv6-udp src FE80:0:0:0:200:1FF:FE00:200 1024 dst 3555:5555:6666:6666:7777:7777:8888:8888 1024 vlan 0 flexbytes (%s) drop queue %d fd_id %d " % (self.dut_ports[0], self.flexbytes, 2, 1), "testpmd>") + self.send_and_verify(False, 'sendp([Ether(src=get_if_hwaddr("%s"), dst="00:1B:21:8E:B2:30")/IPv6(src="FE80:0:0:0:200:1FF:FE00:200", dst="3555:5555:6666:6666:7777:7777:8888:8888")/UDP(sport=1024,dport=1024)/Raw(load="%s")], iface="%s")' % (self.dut_rx_interface, self.payload, self.dut_rx_interface)) + self.dut.send_expect("flow_director_filter %s del flow ipv6-udp src FE80:0:0:0:200:1FF:FE00:200 1024 dst 3555:5555:6666:6666:7777:7777:8888:8888 1024 vlan 0 flexbytes (%s) drop queue %d fd_id %d " % (self.dut_ports[0], self.flexbytes, 2, 1), "testpmd>") + self.send_and_verify(True, 'sendp([Ether(src=get_if_hwaddr("%s"), dst="00:1B:21:8E:B2:30")/IPv6(src="FE80:0:0:0:200:1FF:FE00:200", dst="3555:5555:6666:6666:7777:7777:8888:8888")/UDP(sport=1024,dport=1024)/Raw(load="%s")], iface="%s")' % (self.dut_rx_interface, self.payload, self.dut_rx_interface)) + + # ipv6 tcp + self.dut.send_expect("flow_director_filter %s add flow ipv6-tcp src FE80:0:0:0:200:1FF:FE00:200 32 dst 3555:5555:6666:6666:7777:7777:8888:8888 32 vlan 0 flexbytes (%s) fwd queue %d fd_id %d " % (self.dut_ports[0], self.flexbytes, 2, 1), "testpmd>") + self.dut.send_expect("flow_director_filter %s add flow ipv6-tcp src FE80:0:0:0:200:1FF:FE00:200 32 dst 3555:5555:6666:6666:7777:7777:8888:8888 32 vlan 0 flexbytes (%s) drop queue %d fd_id %d " % (self.dut_ports[0], self.flexbytes, 2, 1), "testpmd>") + self.send_and_verify(False, 'sendp([Ether(src=get_if_hwaddr("%s"), dst="00:1B:21:8E:B2:30")/IPv6(src="FE80:0:0:0:200:1FF:FE00:200", dst="3555:5555:6666:6666:7777:7777:8888:8888")/TCP(sport=32,dport=32)/Raw(load="%s")], iface="%s")' % (self.dut_rx_interface, self.payload, self.dut_rx_interface)) + self.dut.send_expect("flow_director_filter %s del flow ipv6-tcp src FE80:0:0:0:200:1FF:FE00:200 32 dst 3555:5555:6666:6666:7777:7777:8888:8888 32 vlan 0 flexbytes (%s) drop queue %d fd_id %d " % (self.dut_ports[0], self.flexbytes, 2, 1), "testpmd>") + self.send_and_verify(True, 'sendp([Ether(src=get_if_hwaddr("%s"), dst="00:1B:21:8E:B2:30")/IPv6(src="FE80:0:0:0:200:1FF:FE00:200", dst="3555:5555:6666:6666:7777:7777:8888:8888")/TCP(sport=32,dport=32)/Raw(load="%s")], iface="%s")' % (self.dut_rx_interface, self.payload, self.dut_rx_interface)) + + # ipv6 frag + self.dut.send_expect("flow_director_filter %s add flow ipv6-other src FE80:0:0:0:200:1FF:FE00:200 dst 3555:5555:6666:6666:7777:7777:8888:8888 vlan 0 flexbytes (%s) drop queue %d fd_id %d " % (self.dut_ports[0], self.flexbytes, 3, 1), "testpmd>") + self.dut.send_expect("flow_director_filter %s add flow ipv6-frag src FE80:0:0:0:200:1FF:FE00:200 dst 3555:5555:6666:6666:7777:7777:8888:8888 vlan 0 flexbytes (%s) drop queue %d fd_id %d " % (self.dut_ports[0], self.flexbytes, 2, 1), "testpmd>") + self.send_and_verify(False, 'sendp([Ether(src=get_if_hwaddr("%s"), dst="00:1B:21:8E:B2:30")/IPv6(src="FE80:0:0:0:200:1FF:FE00:200", dst="3555:5555:6666:6666:7777:7777:8888:8888", nh=44)/IPv6ExtHdrFragment()/Raw(load="%s")], iface="%s")' % (self.dut_rx_interface, self.payload, self.dut_rx_interface)) + self.dut.send_expect("flow_director_filter %s del flow ipv6-other src FE80:0:0:0:200:1FF:FE00:200 dst 3555:5555:6666:6666:7777:7777:8888:8888 vlan 0 flexbytes (%s) drop queue %d fd_id %d " % (self.dut_ports[0], self.flexbytes, 3, 1), "testpmd>") + self.dut.send_expect("flow_director_filter %s del flow ipv6-frag src FE80:0:0:0:200:1FF:FE00:200 dst 3555:5555:6666:6666:7777:7777:8888:8888 vlan 0 flexbytes (%s) drop queue %d fd_id %d " % (self.dut_ports[0], self.flexbytes, 2, 1), "testpmd>") + self.send_and_verify(True, 'sendp([Ether(src=get_if_hwaddr("%s"), dst="00:1B:21:8E:B2:30")/IPv6(src="FE80:0:0:0:200:1FF:FE00:200", dst="3555:5555:6666:6666:7777:7777:8888:8888", nh=44)/IPv6ExtHdrFragment()/Raw(load="%s")], iface="%s")' % (self.dut_rx_interface, self.payload, self.dut_rx_interface)) + + self.dut.send_expect("quit", "# ", 30) + + def failed_test_fdir_flush(self): """ - FDir flexbytes filtering - The FDir feature supports setting up filters that can match on any two byte field - within the first 64 bytes of a packet. Which byte offset to use is set by passing - command line arguments to ``testpmd``. In this test a value of ``18`` corresponds - to the bytes at offset 36 and 37, as the offset is in 2-byte units + FDir flush in Fortville. """ - dutPorts = self.dut.get_ports() - localPort = self.tester.get_local_port(dutPorts[0]) - itf = self.tester.get_interface(localPort) - self.dut.kill_all() - self.pmdout.start_testpmd("all", "--portmask=%s --rxq=2 --txq=2 --disable-rss --pkt-filter-mode=perfect --pkt-filter-size=64K --pkt-filter-report-hash=match --pkt-filter-flexbytes-offset=18" % dts.create_mask([dutPorts[0]])) - self.dut.send_expect("set verbose 1", "testpmd>") - self.dut.send_expect("set fwd rxonly", "testpmd>") - self.dut.send_expect("set nbcore 3", "testpmd>") - self.dut.send_expect("add_perfect_filter %s ip src 192.168.0.1 0 dst 192.168.0.2 0 flexbytes 0x1 vlan 0 queue 1 soft 0x1" % dutPorts[0], "testpmd>") - self.send_and_verify(True, 'sendp([Ether(src=get_if_hwaddr("%s"), dst="00:1B:21:8E:B2:30")/IP(src="192.168.0.1", dst="192.168.0.2")/GRE(proto=0x1)/IP()/UDP()], iface="%s")' % (itf, itf)) + self.dut.send_expect("./%s/app/testpmd -c %s -n 4 -- -i --portmask=%s --disable-rss --rxq=8 --txq=8 --nb-cores=16 --nb-ports=2 --pkt-filter-mode=perfect" % (self.target, self.all_cores_mask, dts.create_mask([self.dut_ports[0]])), "testpmd>", 120) - self.dut.send_expect("add_perfect_filter %s ip src 192.168.0.1 0 dst 192.168.0.2 0 flexbytes 0xff vlan 0 queue 1 soft 0xff" % dutPorts[0], "testpmd>") - self.send_and_verify(True, 'sendp([Ether(src=get_if_hwaddr("%s"), dst="00:1B:21:8E:B2:30")/IP(src="192.168.0.1", dst="192.168.0.2")/GRE(proto=0xff)/IP()/UDP()], iface="%s")' % (itf, itf)) - - self.dut.send_expect("set_masks_filter %s only_ip_flow 0 src_mask 0xffffffff 0xffff dst_mask 0xffffffff 0xffff flexbytes 0 vlan_id 1 vlan_prio 1" % dutPorts[0], "testpmd>") - self.dut.send_expect("add_perfect_filter %s ip src 192.168.0.1 0 dst 192.168.0.2 0 flexbytes 0x0 vlan 0 queue 1 soft 0x42" % dutPorts[0], "testpmd>") - self.send_and_verify(True, 'sendp([Ether(src=get_if_hwaddr("%s"), dst="00:1B:21:8E:B2:30")/IP(src="192.168.0.1", dst="192.168.0.2")/GRE(proto=0x1)/IP()/UDP()], iface="%s")' % (itf, itf)) - - self.send_and_verify(True, 'sendp([Ether(src=get_if_hwaddr("%s"), dst="00:1B:21:8E:B2:30")/IP(src="192.168.0.1", dst="192.168.0.2")/GRE(proto=0xFF)/IP()/UDP()], iface="%s")' % (itf, itf)) + self.dut.send_expect("set verbose 1", "testpmd>") + self.dut.send_expect("set fwd rxonly", "testpmd>") - self.dut.send_expect("quit", "# ", 30) + # set up a fdir rule and check guarant_count + self.dut.send_expect("flow_director_filter %s add flow ipv4-other src 192.168.0.1 dst 192.168.0.2 vlan 0 flexbytes () fwd queue %d fd_id %d " % (self.dut_ports[0], 2, 1), "testpmd>") + out = self.dut.send_expect("show port fdir all", "testpmd>") + result_scanner = r"guarant_count: 1" + scanner = re.compile(result_scanner, re.DOTALL) + m = scanner.search(out) + if m: + self.verify(1, "Pass") + else: + self.verify(0, "Fail") + + # flush all fdir rule and check guarant_count + out = self.dut.send_expect("flush_flow_director %s" % self.dut_ports[0], "testpmd>") + result_scanner = r"guarant_count: 1" + scanner = re.compile(result_scanner, re.DOTALL) + m = scanner.search(out) + if m: + self.verify(0, "Fail") + else: + self.verify(1, "Pass") - def test_fdir_vlanfiltering(self): + def increment_ip_address(self, addr, val): """ - FDir VLAN field filtering + Returns the IP address from a given one, like + 192.168.1.1 ->193.168.1.1 + If disable ip hw chksum, csum routine will increase ip """ + ip2int = lambda ipstr: struct.unpack('!I', socket.inet_aton(ipstr))[0] + x = ip2int(addr) + int2ip = lambda n: socket.inet_ntoa(struct.pack('!I', n)) + return int2ip(x + 1) - dutPorts = self.dut.get_ports() - localPort = self.tester.get_local_port(dutPorts[0]) - itf = self.tester.get_interface(localPort) + def fdir_perf_set_rules(self, num_rules): - self.dut.kill_all() - self.pmdout.start_testpmd("all", "--portmask=%s --nb-cores=2 --rxq=2 --txq=2 --disable-rss --pkt-filter-mode=perfect" % dts.create_mask([dutPorts[0]])) - self.dut.send_expect("set verbose 1", "testpmd>") - self.dut.send_expect("set fwd rxonly", "testpmd>") - # "rx_vlan add all" has been removed from testpmd - self.dut.send_expect("rx_vlan add 0xFFF %s" % dutPorts[0], "testpmd>") - self.dut.send_expect("rx_vlan add 0x001 %s" % dutPorts[0], "testpmd>") - self.dut.send_expect("rx_vlan add 0x017 %s" % dutPorts[0], "testpmd>") - - self.send_and_verify(False, 'sendp([Ether(src=get_if_hwaddr("%s"), dst="00:1B:21:8E:B2:30")/Dot1Q(vlan=0x0FFF)/IP(src="192.168.0.1", dst="192.168.0.2")/UDP(sport=1024, dport=1024)], iface="%s")' % (itf, itf)) + src_ip_temp = self.src_ip + dst_ip_temp = self.dst_ip + for i in range(num_rules): + src_ip_temp = self.increment_ip_address(src_ip_temp, 1) + dst_ip_temp = self.increment_ip_address(dst_ip_temp, 1) + self.dut.send_expect("flow_director_filter %s add flow ipv4-other src %s dst %s vlan 0 flexbytes (%s) fwd queue %d fd_id %d " % (self.dut_ports[0], src_ip_temp, dst_ip_temp, self.flexbytes, i % self.queue, i), "testpmd>") - self.dut.send_expect("add_perfect_filter %s udp src 192.168.0.1 1024 dst 192.168.0.2 1024 flexbytes 0x8100 vlan 0xfff queue 1 soft 0x47" % dutPorts[0], "testpmd>") - self.send_and_verify(True, 'sendp([Ether(src=get_if_hwaddr("%s"), dst="00:1B:21:8E:B2:30")/Dot1Q(vlan=0x0FFF)/IP(src="192.168.0.1", dst="192.168.0.2")/UDP(sport=1024, dport=1024)], iface="%s")' % (itf, itf)) - - self.dut.send_expect("set_masks_filter %s only_ip_flow 0 src_mask 0xffffffff 0xffff dst_mask 0xffffffff 0xffff flexbytes 1 vlan_id 0 vlan_prio 0" % dutPorts[0], "testpmd>") - self.dut.send_expect("add_perfect_filter %s udp src 192.168.0.1 1024 dst 192.168.0.2 1024 flexbytes 0x8100 vlan 0 queue 1 soft 0x47" % dutPorts[0], "testpmd>") - self.send_and_verify(True, 'sendp([Ether(src=get_if_hwaddr("%s"), dst="00:1B:21:8E:B2:30")/Dot1Q(vlan=0x001)/IP(src="192.168.0.1", dst="192.168.0.2")/UDP(sport=1024, dport=1024)], iface="%s")' % (itf, itf)) - self.send_and_verify(True, 'sendp([Ether(src=get_if_hwaddr("%s"), dst="00:1B:21:8E:B2:30")/Dot1Q(vlan=0x0017)/IP(src="192.168.0.1", dst="192.168.0.2")/UDP(sport=1024, dport=1024)], iface="%s")' % (itf, itf)) - - self.dut.send_expect("quit", "# ", 30) + def fdir_perf_set_flows(self, num_flows, frame_size): + """ + Fdir Performance Benchmarking set Ixia flows + """ + flows = [] + src_ip_temp = self.src_ip + dst_ip_temp = self.dst_ip + print "*src_ip_temp = " + src_ip_temp + "dst_ip_temp = " + dst_ip_temp + flows.append('Ether(src="52:00:00:00:00:00", dst="00:1B:21:8E:B2:30")/IP(src="%s",dst="%s")/UDP(sport=%d,dport=%d)/Raw(load="%s" + "X"*(%d - 42 - %d))' % (src_ip_temp, dst_ip_temp, 1021, 1021, self.payload, frame_size, self.flexlength)) + self.tester.scapy_append('wrpcap("test.pcap", [%s])' % string.join(flows, ',')) + + def perf_fdir_performance_2ports(self, test_type, num_rules, num_flows): + """ + fdir Performance Benchmarking with 2 ports. + """ + # prepare traffic generator input + tgen_input = [] + + tgen_input.append((self.tester.get_local_port(self.dut_ports[0]), + self.tester.get_local_port(self.dut_ports[1]), + "test.pcap")) + tgen_input.append((self.tester.get_local_port(self.dut_ports[1]), + self.tester.get_local_port(self.dut_ports[0]), + "test.pcap")) + + print "self.ports_socket=%s" % (self.ports_socket) + # run testpmd for each core config + for test_cycle in self.test_cycles: + print "******************test cycles*********************\n" + core_config = test_cycle['cores'] + + core_list = self.dut.get_core_list(core_config, socket=self.ports_socket) + + if len(core_list) > 2: + self.queues = len(core_list) / 2 + else: + self.queues = 1 + + core_mask = dts.create_mask(core_list) + port_mask = dts.create_mask([self.dut_ports[0], self.dut_ports[1]]) + + if test_type == "fdir_disable": + command_line = "./%s/app/testpmd -c 0xff00ff -n %d -- -i --rxq=2 --txq=2 --rxd=512 --txd=512 --burst=32 --rxfreet=64 --txfreet=64 --mbcache=256 \ + --portmask=%s --nb-cores=4 --nb-ports=2 --rss-ip\ + " % (self.target, self.dut.get_memory_channels(), port_mask) + else: + command_line = "./%s/app/testpmd -c 0xff00ff -n %d -- -i --rxq=2 --txq=2 --rxd=512 --txd=512 --burst=32 --rxfreet=64 --txfreet=64 --mbcache=256 \ + --portmask=%s --nb-cores=4 --nb-ports=2 --rss-ip\ + --pkt-filter-mode=perfect" % (self.target, self.dut.get_memory_channels(), port_mask) + + info = "Executing PMD using %s\n" % test_cycle['cores'] + self.logger.info(info) + dts.report(info, annex=True) + dts.report(command_line + "\n\n", frame=True, annex=True) + + out = self.dut.send_expect(command_line, "testpmd> ", 100) + print out + + self.dut.send_expect("set verbose 1", "testpmd>") + self.fdir_get_flexbytes() + + if test_type in ["fdir_noflex", "fdir_2flex", "fdir_16flex"]: + self.fdir_set_rule() + self.fdir_perf_set_rules(num_rules) + out = self.dut.send_expect("start", "testpmd> ") + print out + for frame_size in self.frame_sizes: + print "******************frame size = %d*********************\n" % (frame_size) + wirespeed = self.wirespeed(self.nic, frame_size, 2) + # create pcap file + self.logger.info("Running with frame size %d " % frame_size) + self.fdir_perf_set_flows(num_flows, frame_size) + + self.tester.scapy_execute() + + """ + tgen_input.append([self.tester.get_local_port(self.dut_ports[0]), + self.tester.get_local_port(self.dut_ports[1]), + "test.pcap", (512.00 / wirespeed * 100.00), 1]) + tgen_input.append([self.tester.get_local_port(self.dut_ports[1]), + self.tester.get_local_port(self.dut_ports[0]), + "test.pcap", (512.00 / wirespeed * 100.00), 1]) + """ + + """ + # create pcap file + self.logger.info("Running with frame size %d " % frame_size) + self.fdir_perf_set_flows(num_flows, frame_size) + + self.tester.scapy_execute() + """ + + # run traffic generator + _, pps = self.tester.traffic_generator_throughput(tgen_input) + """ + _, pps, _ = self.throughputRate(tgen_input) + """ + + out = self.dut.send_expect("show port stats all", "testpmd> ") + print out + + pps /= 1000000.0 + test_cycle['Mpps'][frame_size] = pps + test_cycle['pct'][frame_size] = pps * 100 / wirespeed + + self.dut.send_expect("stop", "testpmd> ") + self.dut.send_expect("quit", "# ", 30) + sleep(5) + + for n in range(len(self.test_cycles)): + for frame_size in self.frame_sizes: + self.verify(self.test_cycles[n]['Mpps'][ + frame_size] > 0, "No traffic detected") + + # Print results + dts.results_table_add_header(self.table_header) + for frame_size in self.frame_sizes: + table_row = [frame_size] + for test_cycle in self.test_cycles: + table_row.append(test_cycle['Mpps'][frame_size]) + table_row.append(test_cycle['pct'][frame_size]) + + dts.results_table_add_row(table_row) + + self.plot_results(number_ports=2) + dts.results_table_print() + + def ip(self, port, frag, src, proto, tos, dst, chksum, len, version, flags, ihl, ttl, id, options=None): + """ + Configure IP protocal. + """ + self.add_tcl_cmd("protocol config -name ip") + self.add_tcl_cmd('ip config -sourceIpAddr "%s"' % src) + self.add_tcl_cmd("ip config -sourceIpAddrMode ipIncrHost") + self.add_tcl_cmd("ip config -sourceIpAddrRepeatCount 64") + self.add_tcl_cmd('ip config -destIpAddr "%s"' % dst) + self.add_tcl_cmd("ip config -destIpAddrMode ipIncrHost") + self.add_tcl_cmd("ip config -destIpAddrRepeatCount 64") + self.add_tcl_cmd("ip config -ttl %d" % ttl) + self.add_tcl_cmd("ip config -totalLength %d" % len) + self.add_tcl_cmd("ip config -fragment %d" % frag) + # self.add_tcl_cmd("ip config -ipProtocol %d" % proto) + self.add_tcl_cmd("ip config -ipProtocol ipV4ProtocolReserved255") + self.add_tcl_cmd("ip config -identifier %d" % id) + self.add_tcl_cmd("stream config -framesize %d" % (len + 18)) + self.add_tcl_cmd("ip set %d %d %d" % (self.chasId, port['card'], port['port'])) + + def test_perf_fdir_performance_2ports(self): + """ + fdir Performance Benchmarking with 2 ports. + """ + for test_type in self.test_types: + print "***************\n" + print test_type + print "***************\n" + if test_type in ["fdir_enable", "fdir_disable"]: + num_rules = 0 + num_flows = 64 + print "************%d rules/%d flows********************" % (num_rules, num_flows) + self.perf_fdir_performance_2ports(test_type, num_rules, num_flows) + elif test_type in ["fdir_noflexbytes", "fdir_2flexbytes", "fdir_16flexbytes"]: + for flows in self.flows: + num_rules = flows["rules"] + num_flows = flows["flows"] + print "************%d rules/%d flows********************" % (num_rules, num_flows) + self.perf_fdir_performance_2ports(test_type, num_rules, num_flows) def tear_down(self): """ -- 1.7.4.4