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 8999B595E for ; Wed, 20 Jan 2016 03:20:54 +0100 (CET) Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga103.jf.intel.com with ESMTP; 19 Jan 2016 18:20:53 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.22,319,1449561600"; d="scan'208";a="885189007" Received: from shvmail01.sh.intel.com ([10.239.29.42]) by fmsmga001.fm.intel.com with ESMTP; 19 Jan 2016 18:20:52 -0800 Received: from shecgisg003.sh.intel.com (shecgisg003.sh.intel.com [10.239.29.90]) by shvmail01.sh.intel.com with ESMTP id u0K2KnUF026632; Wed, 20 Jan 2016 10:20:49 +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 u0K2Klde012274; Wed, 20 Jan 2016 10:20:49 +0800 Received: (from yliu84x@localhost) by shecgisg003.sh.intel.com (8.13.6/8.13.6/Submit) id u0K2Klt6012270; Wed, 20 Jan 2016 10:20:47 +0800 From: Yong Liu To: dts@dpdk.org Date: Wed, 20 Jan 2016 10:20:46 +0800 Message-Id: <1453256446-12238-1-git-send-email-yong.liu@intel.com> X-Mailer: git-send-email 1.7.4.1 Subject: [dts] [PATCH] tests: support RRC nic 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, 20 Jan 2016 02:20:55 -0000 RRC validation enabled on checksum offload, jumboframe, mac filter, rss, queue start stop, scatter, tso and vlan. Signed-off-by: Marvin Liu diff --git a/tests/TestSuite_checksum_offload.py b/tests/TestSuite_checksum_offload.py index 7a53452..3522c80 100644 --- a/tests/TestSuite_checksum_offload.py +++ b/tests/TestSuite_checksum_offload.py @@ -68,7 +68,6 @@ class TestChecksumOffload(TestCase): (self.portMask) + "--disable-hw-vlan --enable-rx-cksum --crc-strip", socket=self.ports_socket) self.dut.send_expect("set verbose 1", "testpmd>") self.dut.send_expect("set fwd csum", "testpmd>") - self.dut.send_expect("set promisc all off", "testpmd>") def checksum_enablehw(self, port): self.dut.send_expect("csum set ip hw %d" % port, "testpmd>") @@ -89,15 +88,13 @@ class TestChecksumOffload(TestCase): tx_interface = self.tester.get_interface(self.tester.get_local_port(self.dut_ports[1])) rx_interface = self.tester.get_interface(self.tester.get_local_port(self.dut_ports[0])) - sniff_src = self.dut.get_mac_address(self.dut_ports[0]) + sniff_src = self.dut.get_mac_address(self.dut_ports[0]) checksum_pattern = re.compile("chksum.*=.*(0x[0-9a-z]+)") chksum = dict() result = dict() self.tester.send_expect("scapy", ">>> ") - self.tester.send_expect('sys.path.append("./")', ">>> ") - self.tester.send_expect('from sctp import *', ">>> ") for packet_type in packets_expected.keys(): self.tester.send_expect("p = %s" % packets_expected[packet_type], ">>>") @@ -108,9 +105,6 @@ class TestChecksumOffload(TestCase): self.tester.send_expect("exit()", "#") self.tester.scapy_background() - self.tester.scapy_append('sys.path.append("./")') - self.tester.scapy_append('import sctp') - self.tester.scapy_append('from sctp import *') self.tester.scapy_append('p = sniff(filter="ether src %s", iface="%s", count=%d)' % (sniff_src,rx_interface, len(packets_sent))) self.tester.scapy_append('nr_packets=len(p)') self.tester.scapy_append('reslist = [p[i].sprintf("%IP.chksum%;%TCP.chksum%;%UDP.chksum%;%SCTP.chksum%") for i in range(nr_packets)]') @@ -119,9 +113,6 @@ class TestChecksumOffload(TestCase): # Send packet. self.tester.scapy_foreground() - self.tester.scapy_append('sys.path.append("./")') - self.tester.scapy_append('import sctp') - self.tester.scapy_append('from sctp import *') for packet_type in packets_sent.keys(): self.tester.scapy_append('sendp([%s], iface="%s")' % (packets_sent[packet_type], tx_interface)) diff --git a/tests/TestSuite_jumboframes.py b/tests/TestSuite_jumboframes.py index 1cceba8..e4ea10a 100644 --- a/tests/TestSuite_jumboframes.py +++ b/tests/TestSuite_jumboframes.py @@ -119,6 +119,12 @@ class TestJumboframes(TestCase): self.port_mask = dts.create_mask([self.rx_port, self.tx_port]) + if self.nic == "redrockcanyou": + netobj = self.dut.ports_info[self.tx_port]['port'] + netobj.enable_jumbo(framesize = ETHER_JUMBO_FRAME_MTU) + netobj = self.dut.ports_info[self.rx_port]['port'] + netobj.enable_jumbo(framesize = ETHER_JUMBO_FRAME_MTU) + self.tester.send_expect("ifconfig %s mtu %s" % (self.tester.get_interface(self.tester.get_local_port(self.rx_port)), ETHER_JUMBO_FRAME_MTU + 200), "# ") self.tester.send_expect("ifconfig %s mtu %s" % (self.tester.get_interface(self.tester.get_local_port(self.tx_port)), ETHER_JUMBO_FRAME_MTU + 200), "# ") @@ -136,9 +142,7 @@ class TestJumboframes(TestCase): frame on testpmd app. """ self.pmdout.start_testpmd("Default", "--max-pkt-len=%d" % (ETHER_STANDARD_MTU)) - if self.nic == "redrockcanyou": - self.dut.send_expect("set promisc all off", "testpmd> ") - self.dut.send_expect("set fwd mac", "testpmd> ") + self.dut.send_expect("set fwd mac", "testpmd> ") self.dut.send_expect("start", "testpmd> ") self.jumboframes_send_packet(ETHER_STANDARD_MTU - 1) @@ -171,9 +175,7 @@ class TestJumboframes(TestCase): packet forwrding should be support correct. """ self.pmdout.start_testpmd("Default", "--max-pkt-len=%s" % (ETHER_JUMBO_FRAME_MTU)) - if self.nic == "redrockcanyou": - self.dut.send_expect("set promisc all off", "testpmd> ") - self.dut.send_expect("set fwd mac", "testpmd> ") + self.dut.send_expect("set fwd mac", "testpmd> ") self.dut.send_expect("start", "testpmd> ") self.jumboframes_send_packet(1517) @@ -188,9 +190,7 @@ class TestJumboframes(TestCase): packet can be forwarded correct. """ self.pmdout.start_testpmd("Default", "--max-pkt-len=%s" % (ETHER_JUMBO_FRAME_MTU)) - if self.nic == "redrockcanyou": - self.dut.send_expect("set promisc all off", "testpmd> ") - self.dut.send_expect("set fwd mac", "testpmd> ") + self.dut.send_expect("set fwd mac", "testpmd> ") self.dut.send_expect("start", "testpmd> ") self.jumboframes_send_packet(ETHER_STANDARD_MTU + 1) @@ -206,9 +206,7 @@ class TestJumboframes(TestCase): packet which the length bigger than MTU can not be forwarded. """ self.pmdout.start_testpmd("Default", "--max-pkt-len=%s" % (ETHER_JUMBO_FRAME_MTU)) - if self.nic == "redrockcanyou": - self.dut.send_expect("set promisc all off", "testpmd> ") - self.dut.send_expect("set fwd mac", "testpmd> ") + self.dut.send_expect("set fwd mac", "testpmd> ") self.dut.send_expect("start", "testpmd> ") """ diff --git a/tests/TestSuite_mac_filter.py b/tests/TestSuite_mac_filter.py index 3ca7387..7cae09c 100644 --- a/tests/TestSuite_mac_filter.py +++ b/tests/TestSuite_mac_filter.py @@ -38,6 +38,7 @@ import dts import time from test_case import TestCase from pmd_output import PmdOutput +from packet import Packet class TestWhitelist(TestCase): @@ -58,7 +59,7 @@ class TestWhitelist(TestCase): self.pmdout = PmdOutput(self.dut) self.pmdout.start_testpmd("Default", "--portmask=%s" % portMask) self.dut.send_expect("set verbose 1", "testpmd> ") - self.dut.send_expect("set fwd mac", "testpmd> ") + self.dut.send_expect("set fwd rxonly", "testpmd> ") self.dut.send_expect("start", "testpmd> ") # get dest address from self.target port @@ -85,11 +86,9 @@ class TestWhitelist(TestCase): Send 1 packet to portid. """ itf = self.tester.get_interface(self.tester.get_local_port(portid)) - self.tester.scapy_foreground() - self.tester.scapy_append('sendp([Ether(dst="%s", src="52:00:00:00:00:00")/Raw(load="X"*26)], iface="%s", count=%d)' % (destMac, - itf, self.frames_to_send)) - self.tester.scapy_execute() - time.sleep(5) + pkt = Packet(pkt_type='UDP') + pkt.config_layer('ether', {'src': '52:00:00:00:00:00', 'dst': destMac}) + pkt.send_pkt(tx_port=itf) def test_add_remove_mac_address(self): """ @@ -97,19 +96,20 @@ class TestWhitelist(TestCase): Remove mac address and check packet can't received """ # initialise first port without promiscuous mode - fake_mac_addr = "01:01:01:00:00:00" + fake_mac_addr = "00:01:01:00:00:00" portid = self.dutPorts[0] txportid = self.dutPorts[1] self.dut.send_expect("set promisc %d off" % portid, "testpmd> ") - out = self.dut.send_expect("show port stats %d" % txportid, "testpmd> ") - pre_rxpkt = dts.regexp(out, "TX-packets: ([0-9]+)") + self.dut.send_expect("clear port stats all", "testpmd> ") + + out = self.dut.send_expect("show port stats %d" % portid, "testpmd> ") + pre_rxpkt = dts.regexp(out, "RX-packets: ([0-9]+)") # send one packet with the portid MAC address - self.dut.send_expect("clear port stats all", "testpmd> ") self.whitelist_send_packet(portid, self.dest) - out = self.dut.send_expect("show port stats %d" % txportid, "testpmd> ") - cur_rxpkt = dts.regexp(out, "TX-packets: ([0-9]+)") + out = self.dut.send_expect("show port stats %d" % portid, "testpmd> ") + cur_rxpkt = dts.regexp(out, "RX-packets: ([0-9]+)") # check the packet increase self.verify(int(cur_rxpkt) == int(pre_rxpkt) + self.frames_to_send, "Packet has not been received on default address") @@ -118,8 +118,8 @@ class TestWhitelist(TestCase): self.whitelist_send_packet(portid, fake_mac_addr) pre_rxpkt = cur_rxpkt - out = self.dut.send_expect("show port stats %d" % txportid, "testpmd> ") - cur_rxpkt = dts.regexp(out, "TX-packets: ([0-9]+)") + out = self.dut.send_expect("show port stats %d" % portid, "testpmd> ") + cur_rxpkt = dts.regexp(out, "RX-packets: ([0-9]+)") # check the packet DO NOT increase self.verify(int(cur_rxpkt) == int(pre_rxpkt), @@ -131,8 +131,8 @@ class TestWhitelist(TestCase): self.whitelist_send_packet(portid, fake_mac_addr) pre_rxpkt = cur_rxpkt - out = self.dut.send_expect("show port stats %d" % txportid, "testpmd> ") - cur_rxpkt = dts.regexp(out, "TX-packets: ([0-9]+)") + out = self.dut.send_expect("show port stats %d" % portid, "testpmd> ") + cur_rxpkt = dts.regexp(out, "RX-packets: ([0-9]+)") # check the packet increase self.verify(int(cur_rxpkt) == int(pre_rxpkt) + self.frames_to_send, @@ -145,8 +145,8 @@ class TestWhitelist(TestCase): self.whitelist_send_packet(portid, fake_mac_addr) pre_rxpkt = cur_rxpkt - out = self.dut.send_expect("show port stats %d" % txportid, "testpmd> ") - cur_rxpkt = dts.regexp(out, "TX-packets: ([0-9]+)") + out = self.dut.send_expect("show port stats %d" % portid, "testpmd> ") + cur_rxpkt = dts.regexp(out, "RX-packets: ([0-9]+)") # check the packet increase self.verify(int(cur_rxpkt) == int(pre_rxpkt), @@ -180,7 +180,7 @@ class TestWhitelist(TestCase): # add 1 address more that max number i = 0 - base_addr = "01:00:00:00:00:" + base_addr = "00:01:00:00:00:" while i <= int(self.max_mac_addr): new_addr = base_addr + "%0.2X" % i out = self.dut.send_expect("mac_addr add %d" % portid + " %s" % new_addr, "testpmd>") diff --git a/tests/TestSuite_pmdrss_hash.py b/tests/TestSuite_pmdrss_hash.py index 7456d0a..860bfbd 100644 --- a/tests/TestSuite_pmdrss_hash.py +++ b/tests/TestSuite_pmdrss_hash.py @@ -63,44 +63,42 @@ class TestPmdrssHash(TestCase): """ global reta_lines self.tester.scapy_foreground() - self.tester.scapy_append('sys.path.append("./")') - self.tester.scapy_append('from sctp import *') self.dut.send_expect("start", "testpmd>") mac = self.dut.get_mac_address(0) # send packet with different source and dest ip if tran_type == "ipv4-other": for i in range(10): - packet = r'sendp([Ether(dst="%s")/IP(src="192.168.0.%d", dst="192.168.0.%d")], iface="%s")' % ( - mac, i + 1, i + 2, itf) + packet = r'sendp([Ether(dst="%s", src=get_if_hwaddr("%s"))/IP(src="192.168.0.%d", dst="192.168.0.%d")], iface="%s")' % ( + mac, itf, i + 1, i + 2, itf) self.tester.scapy_append(packet) self.tester.scapy_execute() time.sleep(.5) elif tran_type == "ipv4-tcp": for i in range(10): - packet = r'sendp([Ether(dst="%s")/IP(src="192.168.0.%d", dst="192.168.0.%d")/TCP(sport=1024,dport=1024)], iface="%s")' % ( - mac, i + 1, i + 2, itf) + packet = r'sendp([Ether(dst="%s", src=get_if_hwaddr("%s"))/IP(src="192.168.0.%d", dst="192.168.0.%d")/TCP(sport=1024,dport=1024)], iface="%s")' % ( + mac, itf, i + 1, i + 2, itf) self.tester.scapy_append(packet) self.tester.scapy_execute() time.sleep(.5) elif tran_type == "ipv4-udp": for i in range(10): - packet = r'sendp([Ether(dst="%s")/IP(src="192.168.0.%d", dst="192.168.0.%d")/UDP(sport=1024,dport=1024)], iface="%s")' % ( - mac, i + 1, i + 2, itf) + packet = r'sendp([Ether(dst="%s", src=get_if_hwaddr("%s"))/IP(src="192.168.0.%d", dst="192.168.0.%d")/UDP(sport=1024,dport=1024)], iface="%s")' % ( + mac, itf, i + 1, i + 2, itf) self.tester.scapy_append(packet) self.tester.scapy_execute() time.sleep(.5) elif tran_type == "ipv4-sctp": for i in range(10): - packet = r'sendp([Ether(dst="%s")/IP(src="192.168.0.%d", dst="192.168.0.%d")/SCTP(sport=1024,dport=1024,tag=1)], iface="%s")' % ( - mac, i + 1, i + 2, itf) + packet = r'sendp([Ether(dst="%s", src=get_if_hwaddr("%s"))/IP(src="192.168.0.%d", dst="192.168.0.%d")/SCTP(sport=1024,dport=1024,tag=1)], iface="%s")' % ( + mac, itf, i + 1, i + 2, itf) self.tester.scapy_append(packet) self.tester.scapy_execute() time.sleep(.5) elif tran_type == "ipv4-frag": for i in range(10): - packet = r'sendp([Ether(dst="%s")/IP(src="192.168.0.%d", dst="192.168.0.%d",frag=1,flags="MF")], iface="%s")' % ( - mac, i + 1, i + 2, itf) + packet = r'sendp([Ether(dst="%s", src=get_if_hwaddr("%s"))/IP(src="192.168.0.%d", dst="192.168.0.%d",frag=1,flags="MF")], iface="%s")' % ( + mac, itf, i + 1, i + 2, itf) self.tester.scapy_append(packet) self.tester.scapy_execute() time.sleep(.5) @@ -114,71 +112,68 @@ class TestPmdrssHash(TestCase): elif tran_type == "ipv6-other": for i in range(10): - packet = r'sendp([Ether(dst="%s")/IPv6(src="3ffe:2501:200:1fff::%d", dst="3ffe:2501:200:3::%d")], iface="%s")' % ( - mac, i + 1, i + 2, itf) + packet = r'sendp([Ether(dst="%s", src=get_if_hwaddr("%s"))/IPv6(src="3ffe:2501:200:1fff::%d", dst="3ffe:2501:200:3::%d")], iface="%s")' % ( + mac, itf, i + 1, i + 2, itf) self.tester.scapy_append(packet) self.tester.scapy_execute() time.sleep(.5) elif tran_type == "ipv6-tcp": for i in range(10): - packet = r'sendp([Ether(dst="%s")/IPv6(src="3ffe:2501:200:1fff::%d", dst="3ffe:2501:200:3::%d")/TCP(sport=1024,dport=1024)], iface="%s")' % ( - mac, i + 1, i + 2, itf) + packet = r'sendp([Ether(dst="%s", src=get_if_hwaddr("%s"))/IPv6(src="3ffe:2501:200:1fff::%d", dst="3ffe:2501:200:3::%d")/TCP(sport=1024,dport=1024)], iface="%s")' % ( + mac, itf, i + 1, i + 2, itf) self.tester.scapy_append(packet) self.tester.scapy_execute() time.sleep(.5) elif tran_type == "ipv6-udp": for i in range(10): - packet = r'sendp([Ether(dst="%s")/IPv6(src="3ffe:2501:200:1fff::%d", dst="3ffe:2501:200:3::%d")/UDP(sport=1024,dport=1024)], iface="%s")' % ( - mac, i + 1, i + 2, itf) + packet = r'sendp([Ether(dst="%s", src=get_if_hwaddr("%s"))/IPv6(src="3ffe:2501:200:1fff::%d", dst="3ffe:2501:200:3::%d")/UDP(sport=1024,dport=1024)], iface="%s")' % ( + mac, itf, i + 1, i + 2, itf) self.tester.scapy_append(packet) self.tester.scapy_execute() time.sleep(.5) elif tran_type == "ipv6-sctp": for i in range(10): - packet = r'sendp([Ether(dst="%s")/IPv6(src="3ffe:2501:200:1fff::%d", dst="3ffe:2501:200:3::%d")/SCTP(sport=1024,dport=1024,tag=1)], iface="%s")' % ( - mac, i + 1, i + 2, itf) + packet = r'sendp([Ether(dst="%s", src=get_if_hwaddr("%s"))/IPv6(src="3ffe:2501:200:1fff::%d", dst="3ffe:2501:200:3::%d")/SCTP(sport=1024,dport=1024,tag=1)], iface="%s")' % ( + mac, itf, i + 1, i + 2, itf) self.tester.scapy_append(packet) self.tester.scapy_execute() time.sleep(.5) elif tran_type == "ipv6-frag": for i in range(10): - packet = r'sendp([Ether(dst="%s")/IPv6(src="3ffe:2501:200:1fff::%d", dst="3ffe:2501:200:3::%d",nh=44)/IPv6ExtHdrFragment()], iface="%s")' % ( - mac, i + 1, i + 2, itf) + packet = r'sendp([Ether(dst="%s", src=get_if_hwaddr("%s"))/IPv6(src="3ffe:2501:200:1fff::%d", dst="3ffe:2501:200:3::%d",nh=44)/IPv6ExtHdrFragment()], iface="%s")' % ( + mac, itf, i + 1, i + 2, itf) self.tester.scapy_append(packet) self.tester.scapy_execute() time.sleep(.5) else: print "\ntran_type error!\n" - out = self.dut.send_expect("stop", "testpmd>") - print "******************************************************" - print out - print "*****************************************************" + out = self.dut.get_session_output(timeout=1) + self.dut.send_expect("stop", "testpmd>") lines = out.split("\r\n") reta_line = {} # collect the hash result and the queue id for line in lines: line = line.strip() - if len(line) != 0 and line.startswith(("src=",)): + if len(line) != 0 and line.strip().startswith("port "): + reta_line = {} + rexp = r"port (\d)/queue (\d{1,2}): received (\d) packets" + m = re.match(rexp, line.strip()) + if m: + reta_line["port"] = m.group(1) + reta_line["queue"] = m.group(2) + + elif len(line) != 0 and line.startswith(("src=",)): + if "RSS hash" not in line: + continue for item in line.split("-"): item = item.strip() - print item if(item.startswith("RSS hash")): name, value = item.split("=", 1) reta_line[name.strip()] = value.strip() reta_lines.append(reta_line) - reta_line = {} - elif len(line) != 0 and line.strip().startswith("port "): - rexp = r"port (\d)/queue (\d{1,2}): received (\d) packets" - m = re.match(rexp, line.strip()) - if m: - reta_line["port"] = m.group(1) - reta_line["queue"] = m.group(2) - elif len(line) != 0 and line.startswith("stop"): - break - else: - pass + self.verifyResult() def verifyResult(self): @@ -219,8 +214,6 @@ class TestPmdrssHash(TestCase): """ global reta_lines self.tester.scapy_foreground() - self.tester.scapy_append('sys.path.append("./")') - self.tester.scapy_append('from sctp import *') self.dut.send_expect("start", "testpmd>") mac = self.dut.get_mac_address(0) @@ -358,14 +351,21 @@ class TestPmdrssHash(TestCase): else: print "\ntran_type error!\n" - out = self.dut.send_expect("stop", "testpmd>") + out = self.dut.get_session_output(timeout=1) + self.dut.send_expect("stop", "testpmd>") lines = out.split("\r\n") - reta_line = {} # collect the hash result of five tuple and the queue id for line in lines: line = line.strip() - if len(line) != 0 and line.startswith(("src=",)): + if len(line) != 0 and line.strip().startswith("port "): + reta_line = {} + rexp = r"port (\d)/queue (\d{1,2}): received (\d) packets" + m = re.match(rexp, line.strip()) + if m: + reta_line["port"] = m.group(1) + reta_line["queue"] = m.group(2) + elif len(line) != 0 and line.startswith(("src=",)): for item in line.split("-"): item = item.strip() if(item.startswith("RSS hash")): @@ -373,17 +373,6 @@ class TestPmdrssHash(TestCase): reta_line[name.strip()] = value.strip() reta_lines.append(reta_line) - reta_line = {} - elif len(line) != 0 and line.strip().startswith("port "): - rexp = r"port (\d)/queue (\d{1,2}): received (\d) packets" - m = re.match(rexp, line.strip()) - if m: - reta_line["port"] = m.group(1) - reta_line["queue"] = m.group(2) - elif len(line) != 0 and line.startswith("stop"): - break - else: - pass self.verifyResult_symmetric() @@ -422,23 +411,21 @@ class TestPmdrssHash(TestCase): self.verify( sum(result) == 0, "the symmetric RSS hash function failed!") - # - # - # - # Test cases. - # def set_up_all(self): """ Run at the start of each test suite. """ - self.verify( - self.nic in ["fortville_eagle", "fortville_spirit", "fortville_spirit_single"], "NIC Unsupported: " + str(self.nic)) + self.verify(self.nic in ["fortville_eagle", "fortville_spirit", + "fortville_spirit_single", "redrockcanyou"], + "NIC Unsupported: " + str(self.nic)) global reta_num if self.nic in ["fortville_eagle", "fortville_spirit", "fortville_spirit_single"]: reta_num = 512 elif self.nic in ["niantic"]: reta_num = 128 + elif self.nic in ["redrockcanyou"]: + reta_num = 128 else: self.verify(False, "NIC Unsupported:%s" % str(self.nic)) ports = self.dut.get_ports(self.nic) @@ -582,15 +569,17 @@ class TestPmdrssHash(TestCase): (self.target, self.dut.get_memory_channels(), queue, queue), "testpmd> ", 120) for iptype, rsstype in iptypes.items(): - print "***********************%s rss test********************************" % iptype + self.logger.info("***********************%s rss test********************************" % iptype) self.dut.send_expect("set verbose 8", "testpmd> ") self.dut.send_expect("set fwd rxonly", "testpmd> ") self.dut.send_expect( "set nbcore %d" % (queue + 1), "testpmd> ") self.dut.send_expect("port stop all", "testpmd> ") - self.dut.send_expect( - "set_hash_global_config 0 simple_xor %s enable" % iptype, "testpmd> ") + # some nic not support change hash algorithm + if self.nic not in ["redrockcanyou"]: + self.dut.send_expect( + "set_hash_global_config 0 simple_xor %s enable" % iptype, "testpmd> ") # self.dut.send_expect("port config all rss ip", "testpmd> ") self.dut.send_expect("port start all", "testpmd> ") self.dut.send_expect( diff --git a/tests/TestSuite_queue_start_stop.py b/tests/TestSuite_queue_start_stop.py index f59333c..1d84992 100644 --- a/tests/TestSuite_queue_start_stop.py +++ b/tests/TestSuite_queue_start_stop.py @@ -141,11 +141,10 @@ class TestQueueStartStop(TestCase): """ #dpdk start try: - self.dut.send_expect("./app/test-pmd/testpmd -c 0xf -n 4 -- -i --portmask=0x3", "testpmd>", 120) + self.dut.send_expect("./app/test-pmd/testpmd -c 0xf -n 4 -- -i --portmask=0x1 --port-topology=loop", "testpmd>", 120) self.dut.send_expect("set fwd mac", "testpmd>") - self.dut.send_expect("set promisc all off", "testpmd>") self.dut.send_expect("start", "testpmd>") - self.check_forwarding([0, 1], self.nic) + self.check_forwarding([0, 0], self.nic) except Exception, e: raise IOError("dpdk start and first forward failure: %s" % e) @@ -155,15 +154,15 @@ class TestQueueStartStop(TestCase): self.dut.send_expect("stop", "testpmd>") self.dut.send_expect("port 0 rxq 0 stop", "testpmd>") self.dut.send_expect("start", "testpmd>") - self.check_forwarding([0, 1], self.nic, received=False) + self.check_forwarding([0, 0], self.nic, received=False) # start rx queue test print "test start rx queue stop tx queue" self.dut.send_expect("stop", "testpmd>") self.dut.send_expect("port 0 rxq 0 start", "testpmd>") - self.dut.send_expect("port 1 txq 0 stop", "testpmd>") + self.dut.send_expect("port 0 txq 0 stop", "testpmd>") self.dut.send_expect("start", "testpmd>") - self.check_forwarding([0, 1], self.nic, received=False) + self.check_forwarding([0, 0], self.nic, received=False) out = self.dut.get_session_output() except Exception, e: raise IOError("queue start/stop forward failure: %s" % e) @@ -174,9 +173,9 @@ class TestQueueStartStop(TestCase): # start tx queue test print "test start rx and tx queue" self.dut.send_expect("stop", "testpmd>") - self.dut.send_expect("port 1 txq 0 start", "testpmd>") + self.dut.send_expect("port 0 txq 0 start", "testpmd>") self.dut.send_expect("start", "testpmd>") - self.check_forwarding([0, 1], self.nic) + self.check_forwarding([0, 0], self.nic) except Exception, e: raise IOError("queue start/stop forward failure: %s" % e) diff --git a/tests/TestSuite_scatter.py b/tests/TestSuite_scatter.py index ea1e0ee..1953185 100644 --- a/tests/TestSuite_scatter.py +++ b/tests/TestSuite_scatter.py @@ -36,6 +36,7 @@ Test Scattered Packets. import dts from test_case import TestCase from pmd_output import PmdOutput +from packet import Packet, sniff_packets, load_sniff_packets, strip_pktload import time # # @@ -54,47 +55,31 @@ class TestScatter(TestCase): """ dutPorts = self.dut.get_ports(self.nic) # Verify that enough ports are available - self.verify(len(dutPorts) >= 2, "Insufficient ports") + self.verify(len(dutPorts) >= 1, "Insufficient ports") + self.port = dutPorts[0] self.pmdout = PmdOutput(self.dut) if self.nic in ["niantic", "sageville", "fortpark", "fortville_eagle", "fortville_spirit", "fortville_spirit_single", "redrockcanyou", "ironpond", "twinpond", "springfountain"]: self.mbsize = 2048 else: self.mbsize = 1024 - def start_tcpdump(self, tester_rx_intf): - self.tester.send_expect("rm -rf ./scatter.cap", "#") - self.tester.send_expect("tcpdump -i %s -x -w ./scatter.cap 2>/dev/null &" % tester_rx_intf, "#") - - def get_tcpdump_packet(self): - self.tester.send_expect("killall tcpdump", "#") - return self.tester.send_expect("tcpdump -nn -x -r ./scatter.cap", "#") - - def scatter_pktgen_send_packet(self, sPortid, rPortid, pktsize, num=1): + def scatter_pktgen_send_packet(self, pktsize): """ Functional test for scatter packets. """ - sport = self.tester.get_local_port(sPortid) - sintf = self.tester.get_interface(sport) - smac = self.tester.get_mac(sport) - dmac = self.dut.get_mac_address(sPortid) - rport = self.tester.get_local_port(rPortid) - rintf = self.tester.get_interface(rport) - self.tester.send_expect("ifconfig %s mtu 9000" % sintf, "#") - self.tester.send_expect("ifconfig %s mtu 9000" % rintf, "#") - - self.start_tcpdump(rintf) + tester_port = self.tester.get_local_port(self.port) + intf = self.tester.get_interface(tester_port) + dmac = self.dut.get_mac_address(self.port) + self.tester.send_expect("ifconfig %s mtu 9000" % intf, "#") - pktlen = pktsize - 18 - padding = pktlen - 20 + inst = sniff_packets(intf) + pkt = Packet(pkt_type="IP_RAW", pkt_len=pktsize) + pkt.config_layer('ether', {'dst': dmac}) + pkt.send_pkt(tx_port=intf) + sniff_pkts = load_sniff_packets(inst) - self.tester.scapy_append( - 'sendp([Ether(src="%s",dst="%s")/IP(len=%s)/Raw(load="\x50"*%s)], iface="%s")' % (smac, dmac,pktlen, padding, sintf)) - time.sleep(3) - self.tester.scapy_execute() - time.sleep(5) #wait for scapy capture subprocess exit - res = self.get_tcpdump_packet() - self.tester.send_expect("ifconfig %s mtu 1500" % sintf, "#") - self.tester.send_expect("ifconfig %s mtu 1500" % rintf, "#") + res = strip_pktload(sniff_pkts[0], layer="L4") + self.tester.send_expect("ifconfig %s mtu 1500" % intf, "#") return res def set_up(self): @@ -107,23 +92,18 @@ class TestScatter(TestCase): """ Scatter 2048 mbuf """ - cores = self.dut.get_core_list('1S/2C/2T') - coreMask = dts.create_mask(cores) - dutPorts = self.dut.get_ports(self.nic) - portMask = dts.create_mask(dutPorts[:2]) - # set the mbuf size to 1024 out = self.pmdout.start_testpmd( - "1S/2C/2T", "--mbcache=200 --mbuf-size=%d --portmask=%s --max-pkt-len=9000" % (self.mbsize, portMask)) + "1S/2C/1T", "--mbcache=200 --mbuf-size=%d --portmask=0x1 --max-pkt-len=9000 --port-topology=loop" % (self.mbsize)) + self.verify("Error" not in out, "launch error 1") self.dut.send_expect("set fwd mac", "testpmd> ", 120) self.dut.send_expect("start", "testpmd> ") for offset in [-1, 0, 1, 4, 5]: - ret = self.scatter_pktgen_send_packet( - dutPorts[0], dutPorts[1], self.mbsize + offset) - self.verify("5050 5050 5050 5050 5050 5050 5050" in ret, "packet receive error") + ret = self.scatter_pktgen_send_packet(self.mbsize + offset) + self.verify("58 58 58 58 58 58 58 58" in ret, "packet receive error") self.dut.send_expect("stop", "testpmd> ") self.dut.send_expect("quit", "# ", 30) diff --git a/tests/TestSuite_shutdown_api.py b/tests/TestSuite_shutdown_api.py index efbe934..6329649 100644 --- a/tests/TestSuite_shutdown_api.py +++ b/tests/TestSuite_shutdown_api.py @@ -166,6 +166,10 @@ class TestShutdownApi(TestCase): """ Check link status of the ports. """ + # RRC not support link speed change + if self.nic in ['redrockcanyou']: + return + for port in self.ports: out = self.tester.send_expect( "ethtool %s" % self.tester.get_interface(self.tester.get_local_port(port)), "# ") @@ -187,7 +191,6 @@ class TestShutdownApi(TestCase): self.pmdout.start_testpmd("Default", "--portmask=%s" % dts.create_mask(self.ports), socket=self.ports_socket) self.dut.send_expect("set fwd mac", "testpmd>") - self.dut.send_expect("set promisc all off", "testpmd> ") self.dut.send_expect("start", "testpmd> ") self.check_forwarding() self.dut.send_expect("stop", "testpmd> ") @@ -257,7 +260,6 @@ class TestShutdownApi(TestCase): self.dut.send_expect("port config all txq 2", "testpmd> ") self.dut.send_expect("set coremask %s" % fwdcoremask, "testpmd> ") self.dut.send_expect("set fwd mac", "testpmd>") - self.dut.send_expect("set promisc all off", "testpmd> ") self.dut.send_expect("port start all", "testpmd> ", 100) out = self.dut.send_expect("show config rxtx", "testpmd> ") self.verify("RX queues=2" in out, "RX queues not reconfigured properly") @@ -275,7 +277,6 @@ class TestShutdownApi(TestCase): self.dut.send_expect("port stop all", "testpmd> ", 100) self.dut.send_expect("port config all crc-strip on", "testpmd> ") self.dut.send_expect("set fwd mac", "testpmd>") - self.dut.send_expect("set promisc all off", "testpmd>") self.dut.send_expect("port start all", "testpmd> ", 100) out = self.dut.send_expect("show config rxtx", "testpmd> ") self.verify( @@ -383,7 +384,6 @@ class TestShutdownApi(TestCase): self.dut.send_expect("port stop all", "testpmd> ", 100) self.dut.send_expect("port config rss ip", "testpmd> ") self.dut.send_expect("set fwd mac", "testpmd>") - self.dut.send_expect("set promisc all off", "testpmd>") self.dut.send_expect("port start all", "testpmd> ", 100) self.dut.send_expect("start", "testpmd> ") self.check_forwarding() @@ -398,7 +398,6 @@ class TestShutdownApi(TestCase): self.dut.send_expect("port config all rxd 1024", "testpmd> ") self.dut.send_expect("port config all txd 1024", "testpmd> ") self.dut.send_expect("set fwd mac", "testpmd>") - self.dut.send_expect("set promisc all off", "testpmd>") self.dut.send_expect("port start all", "testpmd> ", 100) out = self.dut.send_expect("show config rxtx", "testpmd> ") self.verify( @@ -418,7 +417,6 @@ class TestShutdownApi(TestCase): self.dut.send_expect("port config all rxd 1024", "testpmd> ") self.dut.send_expect("port config all txd 1024", "testpmd> ") self.dut.send_expect("set fwd mac", "testpmd>") - self.dut.send_expect("set promisc all off", "testpmd>") self.dut.send_expect("port start all", "testpmd> ", 100) out = self.dut.send_expect("show config rxtx", "testpmd> ") self.verify( @@ -470,7 +468,6 @@ class TestShutdownApi(TestCase): self.verify("hthresh=64" in out, "TX descriptor not reconfigured properly") self.verify("wthresh=64" in out, "TX descriptor not reconfigured properly") self.dut.send_expect("set fwd mac", "testpmd>") - self.dut.send_expect("set promisc all off", "testpmd>") self.dut.send_expect("start", "testpmd> ") self.check_forwarding() @@ -490,7 +487,6 @@ class TestShutdownApi(TestCase): for _ in range(stress_iterations): self.dut.send_expect("port stop all", "testpmd> ", 100) self.dut.send_expect("set fwd mac", "testpmd>") - self.dut.send_expect("set promisc all off", "testpmd>") self.dut.send_expect("port start all", "testpmd> ", 100) self.dut.send_expect("start", "testpmd> ") self.check_forwarding() @@ -508,7 +504,6 @@ class TestShutdownApi(TestCase): self.pmdout.start_testpmd("Default", "--portmask=%s" % dts.create_mask(self.ports), socket=self.ports_socket) self.dut.send_expect("set fwd mac", "testpmd>") - self.dut.send_expect("set promisc all off", "testpmd>") self.dut.send_expect("start", "testpmd>") ports_num = len(self.ports) diff --git a/tests/TestSuite_tso.py b/tests/TestSuite_tso.py index 1f7ecd2..65b30b7 100644 --- a/tests/TestSuite_tso.py +++ b/tests/TestSuite_tso.py @@ -83,7 +83,8 @@ class TestTSO(TestCase): # this feature support Fortville, Niantic self.verify(self.nic in ["kawela_2", "niantic", "bartonhills", "82545EM", "82540EM", "springfountain", "fortville_eagle", - "fortville_spirit", "fortville_spirit_single"], + "fortville_spirit", "fortville_spirit_single", + "redrockcanyou"], "NIC Unsupported: " + str(self.nic)) # Based on h/w type, choose how many ports to use diff --git a/tests/TestSuite_vlan.py b/tests/TestSuite_vlan.py index cc23dc5..570c59e 100644 --- a/tests/TestSuite_vlan.py +++ b/tests/TestSuite_vlan.py @@ -43,6 +43,7 @@ import time from test_case import TestCase from pmd_output import PmdOutput +from packet import Packet, sniff_packets, load_sniff_packets class TestVlan(TestCase): @@ -61,37 +62,37 @@ class TestVlan(TestCase): ports = self.dut.get_ports() # Verify that enough ports are available - self.verify(len(ports) >= 2, "Insufficient ports") + self.verify(len(ports) >= 1, "Insufficient ports") valports = [_ for _ in ports if self.tester.get_local_port(_) != -1] dutRxPortId = valports[0] - dutTxPortId = valports[1] - portMask = dts.create_mask(valports[:2]) + dutTxPortId = valports[0] + portMask = dts.create_mask(valports[:1]) self.pmdout = PmdOutput(self.dut) - self.pmdout.start_testpmd("Default", "--portmask=%s" % portMask) + self.pmdout.start_testpmd("Default", "--portmask=%s --port-topology=loop" % portMask) self.dut.send_expect("set verbose 1", "testpmd> ") out = self.dut.send_expect("set fwd mac", "testpmd> ") if self.nic in ["fortville_eagle", "fortville_spirit", "fortville_spirit_single", "redrockcanyou"]: - self.dut.send_expect("set promisc all off", "testpmd> ") self.dut.send_expect("vlan set filter on %s" % dutRxPortId, "testpmd> ") self.dut.send_expect("vlan set strip off %s" % dutRxPortId, "testpmd> ") self.verify('Set mac packet forwarding mode' in out, "set fwd rxonly error") self.vlan = 51 - def start_tcpdump(self): - port = self.tester.get_local_port(dutTxPortId) - rxItf = self.tester.get_interface(port) - - self.tester.send_expect("rm -rf ./vlan_test.cap", "#") - self.tester.send_expect("tcpdump -i %s -w ./vlan_test.cap 2> /dev/null& " % rxItf, "#") + if self.nic == "redrockcanyou": + netobj = self.dut.ports_info[dutRxPortId]['port'] + netobj.add_vlan(vlan_id = self.vlan) def get_tcpdump_package(self): - self.tester.send_expect("killall tcpdump", "#") - return self.tester.send_expect("tcpdump -nn -e -v -r ./vlan_test.cap", "#") + pkts = load_sniff_packets(self.inst) + vlans = [] + for packet in pkts: + vlan = packet.strip_element_dot1q("vlan") + vlans.append(vlan) + return vlans def vlan_send_packet(self, vid, num=1): """ @@ -99,22 +100,26 @@ class TestVlan(TestCase): """ # The package stream : testTxPort->dutRxPort->dutTxport->testRxPort port = self.tester.get_local_port(dutRxPortId) - txItf = self.tester.get_interface(port) + self.txItf = self.tester.get_interface(port) self.smac = self.tester.get_mac(port) port = self.tester.get_local_port(dutTxPortId) - rxItf = self.tester.get_interface(port) + self.rxItf = self.tester.get_interface(port) # the package dect mac must is dut tx port id when the port promisc is off self.dmac = self.dut.get_mac_address(dutRxPortId) + self.inst = sniff_packets(self.rxItf) # FIXME send a burst with only num packet if vid == -1: - self.tester.scapy_append('sendp([Ether(src="%s",dst="%s")/IP(len=46)], iface="%s")' % (self.smac, self.dmac, txItf)) + pkt = Packet(pkt_type='UDP') + pkt.config_layer('ether', {'dst': self.dmac, 'src': self.smac}) else: - self.tester.scapy_append('sendp([Ether(src="%s",dst="%s")/Dot1Q(vlan=%s)/IP(len=46)], iface="%s")' % (self.smac, self.dmac, vid, txItf)) + pkt = Packet(pkt_type='VLAN_UDP') + pkt.config_layer('ether', {'dst': self.dmac, 'src': self.smac}) + pkt.config_layer('dot1q', {'vlan': vid}) - self.tester.scapy_execute() + pkt.send_pkt(tx_port=self.txItf) def set_up(self): """ @@ -135,10 +140,9 @@ class TestVlan(TestCase): self.dut.send_expect("start", "testpmd> ", 120) out = self.dut.send_expect("show port info %s" % dutRxPortId, "testpmd> ", 20) - self.start_tcpdump() self.vlan_send_packet(self.vlan) out = self.get_tcpdump_package() - self.verify("vlan %d" % self.vlan in out, "Wrong vlan:" + out) + self.verify(self.vlan in out, "Wrong vlan:" + str(out)) self.dut.send_expect("stop", "testpmd> ") @@ -149,13 +153,11 @@ class TestVlan(TestCase): self.dut.send_expect("rx_vlan rm %d %s" % (self.vlan, dutRxPortId), "testpmd> ") self.dut.send_expect("start", "testpmd> ", 120) - self.start_tcpdump() self.vlan_send_packet(self.vlan) out = self.get_tcpdump_package() - # fm10k switch will redirect package if not send to nic - if (not((self.nic == "redrockcanyou") and ("%s > %s" % (self.smac, self.dmac) in out))): - self.verify("vlan %d" % self.vlan not in out, "Wrong vlan:" + out) + self.verify(len(out) == 0, "Received unexpected packet, filter not work!!!") + self.verify(self.vlan not in out, "Wrong vlan:" + str(out)) out = self.dut.send_expect("stop", "testpmd> ") @@ -167,10 +169,10 @@ class TestVlan(TestCase): self.verify("strip on" in out, "Wrong strip:" + out) self.dut.send_expect("start", "testpmd> ", 120) - self.start_tcpdump() self.vlan_send_packet(self.vlan) out = self.get_tcpdump_package() - self.verify("vlan %d" % self.vlan not in out, "Wrong vlan:" + out) + self.verify(len(out), "Forwarded vlan packet not received!!!") + self.verify(self.vlan not in out, "Wrong vlan:" + str(out)) out = self.dut.send_expect("stop", "testpmd> ", 120) def test_vlan_strip_config_off(self): @@ -184,32 +186,39 @@ class TestVlan(TestCase): self.verify("strip off" in out, "Wrong strip:" + out) self.dut.send_expect("set nbport 2", "testpmd> ") self.dut.send_expect("start", "testpmd> ", 120) - self.start_tcpdump() self.vlan_send_packet(self.vlan) out = self.get_tcpdump_package() - self.verify("vlan %d" % self.vlan in out, "Wrong strip vlan:" + out) + self.verify(self.vlan in out, "Vlan not found:" + str(out)) out = self.dut.send_expect("stop", "testpmd> ", 120) def test_vlan_enable_vlan_insertion(self): """ Enable VLAN header insertion in transmitted packets """ + if self.nic == "redrockcanyou": + netobj = self.dut.ports_info[dutTxPortId]['port'] + netobj.add_vlan(vlan_id = self.vlan) + netobj.add_txvlan(vlan_id = self.vlan) - port = self.tester.get_local_port(dutTxPortId,) + port = self.tester.get_local_port(dutTxPortId) intf = self.tester.get_interface(port) self.dut.send_expect("set nbport 2", "testpmd> ") self.dut.send_expect("tx_vlan set %s %d" % (dutTxPortId, self.vlan), "testpmd> ") - self.start_tcpdump() self.dut.send_expect("start", "testpmd> ") self.vlan_send_packet(-1) out = self.get_tcpdump_package() - self.verify("vlan %d" % self.vlan in out, "Wrong vlan: " + out) + self.verify(self.vlan in out, "Vlan not found:" + str(out)) self.dut.send_expect("tx_vlan reset %s" % dutTxPortId, "testpmd> ", 30) self.dut.send_expect("stop", "testpmd> ", 30) + if self.nic == "redrockcanyou": + netobj = self.dut.ports_info[dutTxPortId]['port'] + # not delete vlan for self.vlan will used later + netobj.delete_txvlan(vlan_id = self.vlan) + def tear_down(self): """ Run after each test case. @@ -221,4 +230,7 @@ class TestVlan(TestCase): Run after each test suite. """ self.dut.kill_all() - pass + if self.nic == "redrockcanyou": + netobj = self.dut.ports_info[dutRxPortId]['port'] + netobj.delete_txvlan(vlan_id = self.vlan) + netobj.delete_vlan(vlan_id = self.vlan) -- 2.4.3