From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by dpdk.org (Postfix) with ESMTP id C372B2C23 for ; Tue, 28 Feb 2017 06:24:11 +0100 (CET) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 27 Feb 2017 21:24:10 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.35,217,1484035200"; d="scan'208";a="1135834076" Received: from stv-crb-08.sh.intel.com (HELO dpdk-test60.sh.intel.com) ([10.239.128.48]) by fmsmga002.fm.intel.com with ESMTP; 27 Feb 2017 21:24:10 -0800 From: Xueqin Lin To: dts@dpdk.org Cc: Xueqin Lin Date: Mon, 27 Feb 2017 18:20:22 -0500 Message-Id: <1488237622-6313-1-git-send-email-xueqin.lin@intel.com> X-Mailer: git-send-email 2.5.5 Subject: [dts] [dst][PATCH v3] test suite: add tx preparation test suite 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: Tue, 28 Feb 2017 05:24:12 -0000 --- tests/TestSuite_tx_preparation.py | 198 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 198 insertions(+) create mode 100644 tests/TestSuite_tx_preparation.py diff --git a/tests/TestSuite_tx_preparation.py b/tests/TestSuite_tx_preparation.py new file mode 100644 index 0000000..36411f9 --- /dev/null +++ b/tests/TestSuite_tx_preparation.py @@ -0,0 +1,198 @@ +# BSD LICENSE +# +# Copyright(c) 2010-2017 Intel Corporation. All rights reserved. +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# * Neither the name of Intel Corporation nor the names of its +# contributors may be used to endorse or promote products derived +# from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + + +""" +DPDK Test suite. + +Test tx preparation feature + +""" + +import os +import time +import dut +from config import PortConf +from test_case import TestCase +from pmd_output import PmdOutput +from settings import FOLDERS +from packet import Packet +import random +# +# +# Test class. +# + +Normal_mtu = 1500 +Max_mtu = 9000 +TSO_value = 1460 + + +class TestTX_preparation(TestCase): + # + # Test cases. + # + + def set_up_all(self): + """ + Run at the start of each test suite. + """ + self.ports = self.dut.get_ports(self.nic) + self.verify(len(self.ports) >= 1, "Insufficient number of ports.") + self.used_dut_port = self.ports[0] + tester_port = self.tester.get_local_port(self.used_dut_port) + self.tester_intf = self.tester.get_interface(tester_port) + out = self.tester.send_expect("ethtool -K %s rx off tx off tso off gso\ + off gro off lro off" %self.tester_intf, "#") + if "Cannot change large-receive-offload" in out: + self.tester.send_expect("ethtool -K %s rx off tx off tso off gso\ + off gro off" %self.tester_intf, "#") + self.tester.send_expect("ifconfig %s mtu %s" + %(self.tester_intf, Max_mtu), "#") + + + def set_up(self): + """ + Run before each test case. + """ + self.dut_testpmd = PmdOutput(self.dut) + self.dut_testpmd.start_testpmd( + "Default", "--port-topology=chained --max-pkt-len=%s" %Max_mtu) + self.dmac = self.dut_testpmd.get_port_mac(0) + self.dut_testpmd.execute_cmd('set fwd csum') + self.dut_testpmd.execute_cmd('set verbose 1') + #enable ip/udp/tcp hardware checksum + self.dut_testpmd.execute_cmd('csum set ip hw 0') + self.dut_testpmd.execute_cmd('csum set tcp hw 0') + self.dut_testpmd.execute_cmd('csum set udp hw 0') + + def start_tcpdump(self, rxItf): + + self.tester.send_expect("rm -rf ./getPackageByTcpdump.cap", "#") + self.tester.send_expect("tcpdump -Q in -i %s -n -e -vv -w\ + ./getPackageByTcpdump.cap 2> /dev/null& " % rxItf, "#") + + def get_tcpdump_package(self): + self.tester.send_expect("killall tcpdump", "#") + return self.tester.send_expect( + "tcpdump -nn -e -v -r ./getPackageByTcpdump.cap", "#") + + def send_packet_verify(self, tsoflag = 0): + """ + Send packet to portid and output + """ + LrgLength = random.randint(Normal_mtu, Max_mtu-100) + pkts = {'IPv4/cksum TCP': 'Ether(dst="%s")/IP()/TCP(flags=0x10)\ + /Raw(RandString(50))' % self.dmac, + 'IPv4/bad IP cksum': 'Ether(dst="%s")/IP(chksum=0x1234)\ + /TCP(flags=0x10)/Raw(RandString(50))' %self.dmac, + 'IPv4/bad TCP cksum': 'Ether(dst="%s")/IP()/TCP(flags=0x10,\ + chksum=0x1234)/Raw(RandString(50))' %self.dmac, + 'IPv4/large pkt': 'Ether(dst="%s")/IP()/TCP(flags=0x10)\ + /Raw(RandString(%s))' %(self.dmac, LrgLength), + 'IPv4/bad cksum/large pkt': 'Ether(dst="%s")/IP(chksum=0x1234)\ + /TCP(flags=0x10,chksum=0x1234)/Raw(RandString(%s))' + %(self.dmac, LrgLength), + 'IPv6/cksum TCP': 'Ether(dst="%s")/IPv6()/TCP(flags=0x10)\ + /Raw(RandString(50))' %self.dmac, + 'IPv6/cksum UDP': 'Ether(dst="%s")/IPv6()/UDP()\ + /Raw(RandString(50))' %self.dmac, + 'IPv6/bad TCP cksum': 'Ether(dst="%s")/IPv6()/TCP(flags=0x10,\ + chksum=0x1234)/Raw(RandString(50))' %self.dmac, + 'IPv6/large pkt': 'Ether(dst="%s")/IPv6()/TCP(flags=0x10)\ + /Raw(RandString(%s))' %(self.dmac, LrgLength) } + + for packet_type in pkts.keys(): + self.start_tcpdump(self.tester_intf) + self.tester.scapy_append( + 'sendp([%s], iface="%s")' % (pkts[packet_type], self.tester_intf)) + self.tester.scapy_execute() + out = self.get_tcpdump_package() + if packet_type == 'IPv6/cksum UDP': + self.verify("udp sum ok" in out, + "Failed to check UDP checksum correctness!!!") + else : + self.verify("cksum" in out, "Failed to check IP/TCP checksum!!!") + self.verify("correct" in out and "incorrect" not in out, + "Failed to check IP/TCP/UDP checksum correctness!!!") + + if tsoflag == 1: + if packet_type in\ + ['IPv4/large pkt', 'IPv6/large pkt', 'IPv4/bad cksum/large pkt']: + segnum = LrgLength / TSO_value + LastLength = LrgLength % TSO_value + num = out.count('length %s' %TSO_value) + self.verify("length %s" %TSO_value in out and num == segnum, + "Failed to verify TSO correctness for large packets!!!") + if LastLength != 0 : + num = out.count('length %s' %LastLength) + self.verify("length %s" %LastLength in out and num == 1 , + "Failed to verify TSO correctness for large packets!!!") + + + def test_tx_preparation_NonTSO(self): + """ + ftag functional test + """ + self.dut_testpmd.execute_cmd('tso set 0 0') + self.dut_testpmd.execute_cmd('start') + + self.send_packet_verify() + self.dut_testpmd.execute_cmd('stop') + self.dut_testpmd.quit() + + def test_tx_preparation_TSO(self): + """ + ftag functional test + """ + self.dut_testpmd.execute_cmd('tso set %s 0' %TSO_value) + self.dut_testpmd.execute_cmd('start') + + self.send_packet_verify(1) + self.dut_testpmd.execute_cmd('stop') + self.dut_testpmd.quit() + + + def tear_down(self): + """ + Run after each test case. + """ + pass + + + def tear_down_all(self): + """ + Run after each test suite. + """ + self.tester.send_expect("ifconfig %s mtu %s" + %(self.tester_intf, Normal_mtu), "#") + self.dut.kill_all() -- 2.5.5