From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) by dpdk.org (Postfix) with ESMTP id 86B7E1B480 for ; Fri, 15 Feb 2019 07:24:31 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga104.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 14 Feb 2019 22:24:30 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.58,371,1544515200"; d="scan'208";a="118115391" Received: from fmsmsx104.amr.corp.intel.com ([10.18.124.202]) by orsmga008.jf.intel.com with ESMTP; 14 Feb 2019 22:24:30 -0800 Received: from fmsmsx163.amr.corp.intel.com (10.18.125.72) by fmsmsx104.amr.corp.intel.com (10.18.124.202) with Microsoft SMTP Server (TLS) id 14.3.408.0; Thu, 14 Feb 2019 22:24:30 -0800 Received: from shsmsx108.ccr.corp.intel.com (10.239.4.97) by fmsmsx163.amr.corp.intel.com (10.18.125.72) with Microsoft SMTP Server (TLS) id 14.3.408.0; Thu, 14 Feb 2019 22:24:28 -0800 Received: from shsmsx101.ccr.corp.intel.com ([169.254.1.110]) by SHSMSX108.ccr.corp.intel.com ([169.254.8.36]) with mapi id 14.03.0415.000; Fri, 15 Feb 2019 14:24:27 +0800 From: "Wu, ChangqingX" To: "Peng, Yuan" , "dts@dpdk.org" CC: "Peng, Yuan" Thread-Topic: [dts] [PATCH]tests: add TestSuite_rxtx_offload.py Thread-Index: AQHUu4HiASz84kk0/kOikuG5F1YgOKXgdyAw Date: Fri, 15 Feb 2019 06:24:27 +0000 Message-ID: <7F81DD3887C58F49A6B2EFEC3C28E22E0B6A1F9F@SHSMSX101.ccr.corp.intel.com> References: <1549172161-53810-1-git-send-email-yuan.peng@intel.com> In-Reply-To: <1549172161-53810-1-git-send-email-yuan.peng@intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dts] [PATCH]tests: add TestSuite_rxtx_offload.py 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: Fri, 15 Feb 2019 06:24:32 -0000 Tested-by: Wu, ChangqingX -----Original Message----- From: dts [mailto:dts-bounces@dpdk.org] On Behalf Of Peng Yuan Sent: Sunday, February 3, 2019 1:36 PM To: dts@dpdk.org Cc: Peng, Yuan Subject: [dts] [PATCH]tests: add TestSuite_rxtx_offload.py Add TestSuite_rxtx_offload.py to tests Signed-off-by: Peng Yuan diff --git a/tests/TestSuite_rxtx_offload.py b/tests/TestSuite_rxtx_offload= .py new file mode 100644 index 0000000..53f7cf9 --- /dev/null +++ b/tests/TestSuite_rxtx_offload.py @@ -0,0 +1,603 @@ +# 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 #=20 +modification, are permitted provided that the following conditions #=20 +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 #=20 +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT #=20 +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR #=20 +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT #=20 +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, #=20 +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT #=20 +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, #=20 +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY #=20 +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT #=20 +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE #=20 +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +""" +DPDK Test suite. + +New RX/TX offload APIs. + +""" + +import utils +import time +import re + +from test_case import TestCase +from settings import HEADER_SIZE +from pmd_output import PmdOutput +from settings import DRIVERS + +from project_dpdk import DPDKdut +from dut import Dut +from packet import Packet + +ETHER_STANDARD_MTU =3D 1518 +ETHER_JUMBO_FRAME_MTU =3D 9000 + +offloads =3D {'mbuf_fast_free': 'MBUF_FAST_FREE', + 'vlan_insert': 'VLAN_INSERT', + 'ipv4_cksum': 'IPV4_CKSUM', + 'udp_cksum': 'UDP_CKSUM', + 'tcp_cksum': 'TCP_CKSUM', + 'sctp_cksum': 'SCTP_CKSUM', + 'outer_ipv4_cksum': 'OUTER_IPV4_CKSUM', + 'tcp_tso': 'TCP_TSO', + 'qinq_insert': 'QINQ_INSERT', + 'vxlan_tnl_tso': 'VXLAN_TNL_TSO', + 'gre_tnl_tso': 'GRE_TNL_TSO', + 'ipip_tnl_tso': 'IPIP_TNL_TSO', + 'geneve_tnl_tso': 'GENEVE_TNL_TSO', + 'multi_segs': 'MULTI_SEGS', + 'macsec_insert': 'MACSEC_INSERT', + 'security': 'SECURITY', + 'vlan_strip': 'VLAN_STRIP', + 'tcp_lro': 'TCP_LRO', + 'qinq_strip': 'QINQ_STRIP', + 'vlan_filter': 'VLAN_FILTER', + 'vlan_extend': 'VLAN_EXTEND', + 'jumboframe': 'JUMBO_FRAME', + 'scatter': 'SCATTER', + 'keep_crc': 'KEEP_CRC', + 'macsec_strip': 'MACSEC_STRIP' + } + + +class TestRxTx_Offload(TestCase): + + def set_up_all(self): + """ + Run at the start of each test suite. + New rx tx offload API Prerequisites + """ + self.verify(self.nic in ["fortville_eagle", "fortville_spirit", + "fortville_spirit_single", "niantic"], "N= IC Unsupported: " + str(self.nic)) + # Based on h/w type, choose how many ports to use + self.dut_ports =3D self.dut.get_ports(self.nic) + # Verify that enough ports are available + self.verify(len(self.dut_ports) >=3D 2, "Insufficient ports") + + localPort0 =3D self.tester.get_local_port(self.dut_ports[0]) + localPort1 =3D self.tester.get_local_port(self.dut_ports[1]) + self.tester_itf0 =3D self.tester.get_interface(localPort0) + self.tester_itf1 =3D self.tester.get_interface(localPort1) + + self.tester_mac0 =3D self.tester.get_mac(localPort0) + self.pf_interface =3D self.dut.ports_info[self.dut_ports[0]]['intf= '] + self.pf_mac =3D self.dut.get_mac_address(0) + self.pf_pci =3D self.dut.ports_info[self.dut_ports[0]]['pci'] + self.pmdout =3D PmdOutput(self.dut) + self.cores =3D "1S/4C/1T" + self.jumbo_pkt1 =3D r'sendp([Ether(dst=3D"%s")/IP(dst=3D"192.168.0= .1",src=3D"192.168.0.2", len=3D8981)/Raw(load=3D"P"*8961)], iface=3D"%s")' = % (self.pf_mac, self.tester_itf0) + self.jumbo_pkt2 =3D r'sendp([Ether(dst=3D"%s")/IP(dst=3D"192.168.0= .1",src=3D"192.168.0.3", len=3D8981)/Raw(load=3D"P"*8961)], iface=3D"%s")' = % (self.pf_mac, self.tester_itf0) + self.vlan_pkt1 =3D r'sendp([Ether(dst=3D"%s")/Dot1Q(vlan=3D1)/IP(s= rc=3D"192.168.0.1",dst=3D"192.168.0.3")/UDP(sport=3D33, dport=3D34)/Raw("x"= *20)], iface=3D"%s")' % (self.pf_mac, self.tester_itf0) + self.vlan_pkt2 =3D=20 + r'sendp([Ether(dst=3D"%s")/Dot1Q(vlan=3D1)/IP(src=3D"192.168.0.2",dst=3D"= 192.1 + 68.0.3")/UDP(sport=3D33, dport=3D34)/Raw("x"*20)], iface=3D"%s")' %=20 + (self.pf_mac, self.tester_itf0) + + def set_up(self): + """ + Run before each test case. + """ + pass + + def check_port_capability(self, rxtx): + """ + Check capabilities. + """ + global offloads + offload_keys =3D [] + if rxtx =3D=3D "rx": + outstring =3D self.dut.send_expect("show port 0 rx_offload cap= abilities", "testpmd> ") + elif rxtx =3D=3D "tx": + outstring =3D self.dut.send_expect("show port 0 tx_offload=20 + capabilities", "testpmd> ") + + # get capability by port + result_scanner =3D r"Per Port : (.*?)\n" + scanner =3D re.compile(result_scanner, re.DOTALL) + m =3D scanner.search(outstring) + i =3D 0 + offload_value =3D m.group(1).split() + for key, value in offloads.items(): + if value in offload_value: + offload_keys.insert(i, key) + i =3D i + 1 + return offload_keys + + def check_port_config(self, rxtx, offload): + """ + Check configuration per port. + """ + global offloads + + result_config =3D self.dut.send_expect("port start 0", "testpmd> "= ) + self.verify("Fail" not in result_config, "Fail to configure=20 + port") + + if rxtx =3D=3D "rx": + outstring =3D self.dut.send_expect("show port 0 rx_offload con= figuration", "testpmd> ") + elif rxtx =3D=3D "tx": + outstring =3D self.dut.send_expect("show port 0 tx_offload=20 + configuration", "testpmd> ") + + result_scanner =3D r"Port : (.*?)\n" + scanner =3D re.compile(result_scanner, re.DOTALL) + m =3D scanner.search(outstring) + if offload =3D=3D "NULL": + self.verify(m =3D=3D None, "The offload failed to be disabled.= ") + else: + exp_offload =3D m.group(1).split() + self.verify(exp_offload !=3D None, "There is no offload config= ured.") + for each_offload in offload: + self.verify(each_offload in offloads.keys(), "Offload type= error!") + self.verify(offloads[each_offload] in exp_offload,=20 + "There is wrong offload configured.") + + def check_queue_config(self, rxtx, offload): + """ + Check configuration per queue. + """ + global offloads + + result_config =3D self.dut.send_expect("port start 0", "testpmd> "= ) + self.verify("Fail" not in result_config, "Fail to configure=20 + port") + + acl_offloads =3D [] + if rxtx =3D=3D "rx": + outstring =3D self.dut.send_expect("show port 0 rx_offload con= figuration", "testpmd> ") + elif rxtx =3D=3D "tx": + outstring =3D self.dut.send_expect("show port 0 tx_offload=20 + configuration", "testpmd> ") + + lines =3D outstring.split("\r\n") + result_scanner =3D r"Queue[ \d] : (.*?)" + scanner =3D re.compile(result_scanner, re.DOTALL) + queue_line =3D [] + i =3D 0 + for line in lines: + if len(line) !=3D 0 and line.strip().startswith("Queue"): + queue_line.insert(i, line) + i =3D i + 1 + i =3D 0 + for i in range(0, 4): + if offload[i] =3D=3D "NULL": + m =3D scanner.search(queue_line[i]) + self.verify(m =3D=3D None, "Fail to configure offload by q= ueue.") + else: + acl_offload =3D offloads[offload[i]] + self.verify(acl_offload in queue_line[i], "Fail to configu= re offload by queue.") + i =3D i + 1 +=20 + def get_queue_number(self, packet): + """ + Send packet and get the queue which packet enter. + """ + self.dut.send_expect("start", "testpmd> ") + self.tester.scapy_foreground() + self.tester.scapy_append(packet) + self.tester.scapy_execute() + outstring =3D self.dut.send_expect("stop", "testpmd> ") + self.verify("Queue" in outstring, "the packet is not received.") + result_scanner =3D r"Forward Stats for RX Port=3D %s/Queue=3D\s?([= 0-9]+)" % self.dut_ports[0] + scanner =3D re.compile(result_scanner, re.DOTALL) + m =3D scanner.search(outstring) + queue_id =3D m.group(1) + print "queue is %s" % queue_id + return queue_id + + def check_flag(self, packet, queue): + """ + Sends packets and check the flag. + """ + self.dut.send_expect("start", "testpmd>") + self.tester.scapy_foreground() + self.tester.scapy_append(packet) + self.tester.scapy_execute() + time.sleep(2) + outstring =3D self.dut.get_session_output(timeout=3D1) + # get queue ID + result_scanner =3D r"RSS queue=3D0x([0-9]+)" + scanner =3D re.compile(result_scanner, re.DOTALL) + m =3D scanner.search(outstring) + queue_id =3D m.group(1) + if int(queue_id) in queue: + self.verify("PKT_RX_VLAN_STRIPPED" in outstring, "Fail to conf= igure offload by queue.") + else: + self.verify("PKT_RX_VLAN_STRIPPED" not in outstring, "Fail to = configure offload by queue.") + self.dut.send_expect("stop", "testpmd>") + + def verify_result(self, packet, expect_rxpkts, expect_queue): + """ + verify if the packet is to the expected queue + """ + result_config =3D self.dut.send_expect("port start 0", "testpmd> "= ) + self.verify("Fail" not in result_config, "Fail to configure=20 + port") + + self.dut.send_expect("start", "testpmd> ") + self.tester.scapy_foreground() + self.tester.scapy_append(packet) + self.tester.scapy_execute() + time.sleep(2) + + outstring =3D self.dut.send_expect("stop", "testpmd> ", 120) + time.sleep(2) + if expect_rxpkts =3D=3D 0: + self.verify("Queue" not in outstring, "the packet is still rec= eived.") + else: + result_scanner =3D r"Forward Stats for RX Port=3D %s/Queue=3D\= s?([0-9]+)" % self.dut_ports[0] + scanner =3D re.compile(result_scanner, re.DOTALL) + m =3D scanner.search(outstring) + queue_id =3D m.group(1) + self.verify(int(expect_queue) =3D=3D int(queue_id), "the=20 + offload setting doesn't take effect.") + + def start_tcpdump(self, rxItf): + + self.tester.send_expect("rm -rf ./getPackageByTcpdump.cap", "#") + self.tester.send_expect("tcpdump -i %s -w=20 + ./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=20 + ./getPackageByTcpdump.cap", "#", 120) + + def test_rxoffload_port(self): + """ + Set Rx offload by port. + """ + self.pmdout.start_testpmd("%s" % self.cores, "--rxq=3D4 --txq=3D4 = --max-pkt-len=3D9000") + self.dut.send_expect("set fwd rxonly", "testpmd> ") + self.dut.send_expect("set verbose 1", "testpmd> ") + offload =3D ['jumboframe'] + self.check_port_config("rx", offload) + self.tester.send_expect("ifconfig %s mtu %s" % (self.tester_itf0, = ETHER_JUMBO_FRAME_MTU), "# ") + self.tester.send_expect("ifconfig %s mtu %s" %=20 + (self.tester_itf1, ETHER_JUMBO_FRAME_MTU), "# ") + + pkt1_queue =3D self.get_queue_number(self.jumbo_pkt1) + pkt2_queue =3D self.get_queue_number(self.jumbo_pkt2) + + # Failed to disable jumboframe per_queue + self.dut.send_expect("port stop 0", "testpmd> ") + self.dut.send_expect("port 0 rxq %s rx_offload jumbo_frame off" % = pkt1_queue, "testpmd> ") + self.verify_result(self.jumbo_pkt1, 1, pkt1_queue) + + # Succeed to disable jumboframe per_port + self.dut.send_expect("port stop 0", "testpmd> ") + self.dut.send_expect("port config 0 rx_offload jumbo_frame off", "= testpmd> ") + self.check_port_config("rx", "NULL") + self.verify_result(self.jumbo_pkt1, 0, pkt1_queue) + self.verify_result(self.jumbo_pkt2, 0, pkt2_queue) + + # Failed to enable jumboframe per_queue + self.dut.send_expect("port stop 0", "testpmd> ") + self.dut.send_expect("port 0 rxq %s rx_offload jumbo_frame on" % p= kt1_queue, "testpmd> ") + outstring =3D self.dut.send_expect("port start 0", "testpmd> ") + self.verify("Fail" in outstring, "jumboframe can be set by=20 + queue.") + + # Succeed to enable jumboframe per_port + self.dut.send_expect("port stop 0", "testpmd> ") + self.dut.send_expect("port config 0 rx_offload jumbo_frame on", "t= estpmd> ") + self.check_port_config("rx", offload) + self.verify_result(self.jumbo_pkt1, 1, pkt1_queue) + self.verify_result(self.jumbo_pkt2, 1, pkt2_queue) + + self.tester.send_expect("ifconfig %s mtu %s" % (self.tester_itf0, = ETHER_STANDARD_MTU), "# ") + self.tester.send_expect("ifconfig %s mtu %s" %=20 + (self.tester_itf1, ETHER_STANDARD_MTU), "# ") + + def test_rxoffload_port_cmdline(self): + """ + Set Rx offload by port in cmdline. + """ + self.pmdout.start_testpmd("%s" % self.cores, "--rxq=3D4 --txq=3D4 = --enable-rx-cksum") + offload =3D ['ipv4_cksum', 'udp_cksum', 'tcp_cksum'] + self.check_port_config("rx", offload) + + # Disable the rx cksum per_port + self.dut.send_expect("port stop 0", "testpmd> ") + self.dut.send_expect("port config 0 rx_offload udp_cksum off", "te= stpmd> ") + offload =3D ['ipv4_cksum', 'tcp_cksum'] + self.check_port_config("rx", offload) + self.dut.send_expect("port stop 0", "testpmd> ") + self.dut.send_expect("port config 0 rx_offload ipv4_cksum off", "t= estpmd> ") + offload =3D ['tcp_cksum'] + self.check_port_config("rx", offload) + self.dut.send_expect("port stop 0", "testpmd> ") + self.dut.send_expect("port config 0 rx_offload tcp_cksum off", "te= stpmd> ") + self.check_port_config("rx", "NULL") + + # Enable the rx cksum per_port + self.dut.send_expect("port stop 0", "testpmd> ") + self.dut.send_expect("port config 0 rx_offload ipv4_cksum on", "te= stpmd> ") + offload =3D ['ipv4_cksum'] + self.check_port_config("rx", offload) + self.dut.send_expect("port stop 0", "testpmd> ") + self.dut.send_expect("port config 0 rx_offload tcp_cksum on", "tes= tpmd> ") + offload =3D ['ipv4_cksum', 'tcp_cksum'] + self.check_port_config("rx", offload) + self.dut.send_expect("port stop 0", "testpmd> ") + self.dut.send_expect("port config 0 rx_offload udp_cksum on", "tes= tpmd> ") + offload =3D ['ipv4_cksum', 'tcp_cksum', 'udp_cksum'] + self.check_port_config("rx", offload) + + def test_rxoffload_port_all(self): + """ + Set all Rx offload capabilities by port. + """ + self.pmdout.start_testpmd("%s" % self.cores, "--rxq=3D4 --txq=3D4"= ) + capabilities =3D self.check_port_capability("rx") + for capability in capabilities: + if capability !=3D "jumboframe": + self.dut.send_expect("port stop 0", "testpmd> ") + self.dut.send_expect("port config 0 rx_offload %s on" % ca= pability, "testpmd> ") + offload =3D [capability] + self.check_port_config("rx", offload) + self.dut.send_expect("port stop 0", "testpmd> ") + self.dut.send_expect("port config 0 rx_offload %s off" % c= apability, "testpmd> ") + self.check_port_config("rx", "NULL") + + def test_rxoffload_queue(self): + """ + Set Rx offload by queue. + """ + # Only support NNT + self.verify(self.nic in ["niantic"], "%s nic not support rx=20 + offload setting by queue." % self.nic) + + self.pmdout.start_testpmd("%s" % self.cores, "--rxq=3D4 --txq=3D4"= ) + self.dut.send_expect("set fwd rxonly", "testpmd> ") + self.dut.send_expect("set verbose 1", "testpmd> ") + offload =3D ["NULL", "NULL", "NULL", "NULL"] + self.check_queue_config("rx", offload) + + # Enable vlan_strip per_queue. + self.dut.send_expect("port stop 0", "testpmd> ") + self.dut.send_expect("port 0 rxq 0 rx_offload vlan_strip on", "tes= tpmd> ") + self.dut.send_expect("port 0 rxq 2 rx_offload vlan_strip on", "tes= tpmd> ") + self.dut.send_expect("port start 0", "testpmd> ") + queue =3D [0, 2] + self.check_flag(self.vlan_pkt1, queue) + self.check_flag(self.vlan_pkt2, queue) + offload =3D ["vlan_strip", "NULL", "vlan_strip", "NULL"] + self.check_queue_config("rx", offload) + + # Disable vlan_strip per_queue + self.dut.send_expect("port stop 0", "testpmd> ") + self.dut.send_expect("port 0 rxq 3 rx_offload vlan_strip on", "tes= tpmd> ") + self.dut.send_expect("port 0 rxq 2 rx_offload vlan_strip off", "te= stpmd> ") + self.dut.send_expect("port start 0", "testpmd> ") + queue =3D [0, 3] + self.check_flag(self.vlan_pkt1, queue) + self.check_flag(self.vlan_pkt2, queue) + offload =3D ["vlan_strip", "NULL", "NULL", "vlan_strip"] + self.check_queue_config("rx", offload) + + # Enable vlan_strip per_port + self.dut.send_expect("port stop 0", "testpmd> ") + self.dut.send_expect("port config 0 rx_offload vlan_strip on", "te= stpmd> ") + offload =3D ["vlan_strip"] + self.check_port_config("rx", offload) + queue =3D [0, 1, 2, 3] + self.check_flag(self.vlan_pkt1, queue) + self.check_flag(self.vlan_pkt2, queue) + + # Disable vlan_strip per_port + self.dut.send_expect("port stop 0", "testpmd> ") + self.dut.send_expect("port config 0 rx_offload vlan_strip off", "t= estpmd> ") + self.check_port_config("rx", "NULL") + queue =3D [] + self.check_flag(self.vlan_pkt1, queue) + self.check_flag(self.vlan_pkt2, queue) + + def test_txoffload_port(self): + """ + Set Tx offload by port. + """ + self.pmdout.start_testpmd("%s" % self.cores, "--rxq=3D4 --txq=3D4 = --port-topology=3Dloop") + self.dut.send_expect("set fwd txonly", "testpmd> ") + self.dut.send_expect("set verbose 1", "testpmd> ") + if (self.nic in ["fortville_eagle", "fortville_spirit", + "fortville_spirit_single"]): + self.dut.send_expect("port stop 0", "testpmd> ") + self.dut.send_expect("port config 0 tx_offload mbuf_fast_free = off", "testpmd> ") + #self.dut.send_expect("port start 0", "testpmd> ") + self.check_port_config("tx", "NULL") + self.start_tcpdump(self.tester_itf0) + self.dut.send_expect("start", "testpmd> ") + self.dut.send_expect("stop", "testpmd> ") + out =3D self.get_tcpdump_package() + self.verify("vlan" not in out, "There is vlan insert.") + + # Enable vlan_insert per_port + self.dut.send_expect("port stop 0", "testpmd> ") + self.dut.send_expect("port config 0 tx_offload vlan_insert on", "t= estpmd> ") + self.dut.send_expect("tx_vlan set 0 1", "testpmd> ") + offload =3D ["vlan_insert"] + self.check_port_config("tx", offload) + self.start_tcpdump(self.tester_itf0) + self.dut.send_expect("start", "testpmd> ") + self.dut.send_expect("stop", "testpmd> ") + out =3D self.get_tcpdump_package() + self.verify("vlan 1" in out, "There is no vlan insert.") + + # Disable vlan_insert per_port + self.dut.send_expect("port stop 0", "testpmd> ") + self.dut.send_expect("port config 0 tx_offload vlan_insert off", "= testpmd> ") + self.check_port_config("tx", "NULL") + self.start_tcpdump(self.tester_itf0) + self.dut.send_expect("start", "testpmd> ") + self.dut.send_expect("stop", "testpmd> ") + out =3D self.get_tcpdump_package() + self.verify("vlan" not in out, "There is vlan insert.") + + def test_txoffload_port_cmdline(self): + """ + Set Tx offload by port in cmdline. + """ + self.pmdout.start_testpmd("%s" % self.cores, "--rxq=3D4 --txq=3D4 = --port-topology=3Dloop --tx-offloads=3D0x0001") + self.dut.send_expect("set fwd txonly", "testpmd> ") + self.dut.send_expect("set verbose 1", "testpmd> ") + if (self.nic in ["fortville_eagle", "fortville_spirit", + "fortville_spirit_single", "fortpark_TLV"]): + self.dut.send_expect("port stop 0", "testpmd> ") + self.dut.send_expect("port config 0 tx_offload mbuf_fast_free = off", "testpmd> ") + self.dut.send_expect("port start 0", "testpmd> ") + offload =3D ["vlan_insert"] + self.check_port_config("tx", offload) + self.dut.send_expect("port stop 0", "testpmd> ") + self.dut.send_expect("tx_vlan set 0 1", "testpmd> ") + self.dut.send_expect("port start 0", "testpmd> ") + self.start_tcpdump(self.tester_itf0) + self.dut.send_expect("start", "testpmd> ") + self.dut.send_expect("stop", "testpmd> ") + out =3D self.get_tcpdump_package() + self.verify("vlan 1" in out, "There is no vlan insert.") + + # Disable vlan_insert per_queue + self.dut.send_expect("port stop 0", "testpmd> ") + self.dut.send_expect("port 0 txq 0 tx_offload vlan_insert off", "t= estpmd> ") + self.dut.send_expect("port 0 txq 1 tx_offload vlan_insert off", "t= estpmd> ") + self.dut.send_expect("port 0 txq 2 tx_offload vlan_insert off", "t= estpmd> ") + self.dut.send_expect("port 0 txq 3 tx_offload vlan_insert off", "t= estpmd> ") + offload =3D ["vlan_insert"] + self.check_port_config("tx", offload) + self.start_tcpdump(self.tester_itf0) + self.dut.send_expect("start", "testpmd> ") + self.dut.send_expect("stop", "testpmd> ") + out =3D self.get_tcpdump_package() + self.verify("vlan 1" in out, "There is no vlan insert.") + + # Disable vlan_insert per_port + self.dut.send_expect("port stop 0", "testpmd> ") + self.dut.send_expect("port config 0 tx_offload vlan_insert off", "= testpmd> ") + self.check_port_config("tx", "NULL") + self.start_tcpdump(self.tester_itf0) + self.dut.send_expect("start", "testpmd> ") + self.dut.send_expect("stop", "testpmd> ") + out =3D self.get_tcpdump_package() + self.verify("vlan" not in out, "There is vlan insert.") + + # Enable vlan_insert per_queue + self.dut.send_expect("port stop 0", "testpmd> ") + self.dut.send_expect("port 0 txq 0 tx_offload vlan_insert on", "te= stpmd> ") + self.dut.send_expect("port 0 txq 1 tx_offload vlan_insert on", "te= stpmd> ") + self.dut.send_expect("port 0 txq 2 tx_offload vlan_insert on", "te= stpmd> ") + self.dut.send_expect("port 0 txq 3 tx_offload vlan_insert on", "te= stpmd> ") + outstring =3D self.dut.send_expect("port start 0", "testpmd> ") + self.verify("Fail" in outstring, "vlan_insert can be set by=20 + queue.") + + # Enable vlan_insert per_port + self.dut.send_expect("port stop 0", "testpmd> ") + self.dut.send_expect("port config 0 tx_offload vlan_insert on", "t= estpmd> ") + offload =3D ["vlan_insert"] + self.check_port_config("tx", offload) + self.start_tcpdump(self.tester_itf0) + self.dut.send_expect("start", "testpmd> ") + self.dut.send_expect("stop", "testpmd> ") + out =3D self.get_tcpdump_package() + self.verify("vlan 1" in out, "There is no vlan insert.") + + def test_txoffload_port_all(self): + """ + Set all Tx offload capabilities by port. + """ + self.pmdout.start_testpmd("%s" % self.cores, "--rxq=3D4 --txq=3D4"= ) + capabilities =3D self.check_port_capability("tx") + # Disable per queue capability first, if it is FVL. + if (self.nic in ["fortville_eagle", "fortville_spirit", + "fortville_spirit_single", "fortpark_TLV"]): + self.dut.send_expect("port stop 0", "testpmd> ") + self.dut.send_expect("port config 0 tx_offload mbuf_fast_free = off", "testpmd> ") + self.dut.send_expect("port start 0", "testpmd> ") + for capability in capabilities: + self.dut.send_expect("port stop 0", "testpmd> ") + self.dut.send_expect("port config 0 tx_offload %s on" % capabi= lity, "testpmd> ") + offload =3D [capability] + self.check_port_config("tx", offload) + self.dut.send_expect("port stop 0", "testpmd> ") + self.dut.send_expect("port config 0 tx_offload %s off" % capab= ility, "testpmd> ") + self.check_port_config("tx", "NULL") + + def test_txoffload_queue(self): + """ + Set Rx offload by queue. + """ + # Only support FVL + self.verify(self.nic in ["fortville_eagle", "fortville_spirit", + "fortville_spirit_single",], "%s nic not = support rx offload setting by queue." % self.nic) + # Check offload configuration by port and by queue. + self.pmdout.start_testpmd("%s" % self.cores, "--rxq=3D4 --txq=3D4"= ) + offload =3D ["mbuf_fast_free"] + self.check_port_config("tx", offload) + offload =3D ["NULL", "NULL", "NULL", "NULL"] + self.check_queue_config("tx", offload) + + # Disable mbuf_fast_free per_port. + self.dut.send_expect("port stop 0", "testpmd> ") + self.dut.send_expect("port config 0 tx_offload mbuf_fast_free off"= , "testpmd> ") + self.check_port_config("tx", "NULL") + + # Enable mbuf_fast_free per_queue. + self.dut.send_expect("port stop 0", "testpmd> ") + self.dut.send_expect("port 0 txq 0 tx_offload mbuf_fast_free on", = "testpmd> ") + self.dut.send_expect("port 0 txq 1 tx_offload mbuf_fast_free on", = "testpmd> ") + self.dut.send_expect("port 0 txq 2 tx_offload mbuf_fast_free on", = "testpmd> ") + self.dut.send_expect("port 0 txq 3 tx_offload mbuf_fast_free on", = "testpmd> ") + offload =3D ["mbuf_fast_free", "mbuf_fast_free", "mbuf_fast_free",= "mbuf_fast_free"] + self.check_queue_config("tx", offload) + + # Disable mbuf_fast_free per_queue. + self.dut.send_expect("port stop 0", "testpmd> ") + self.dut.send_expect("port 0 txq 0 tx_offload mbuf_fast_free off",= "testpmd> ") + self.dut.send_expect("port 0 txq 1 tx_offload mbuf_fast_free off",= "testpmd> ") + self.dut.send_expect("port 0 txq 2 tx_offload mbuf_fast_free off",= "testpmd> ") + self.dut.send_expect("port 0 txq 3 tx_offload mbuf_fast_free off",= "testpmd> ") + offload =3D ["NULL", "NULL", "NULL", "NULL"] + self.check_queue_config("tx", offload) + + # Enable mbuf_fast_free per_port. + self.dut.send_expect("port stop 0", "testpmd> ") + self.dut.send_expect("port config 0 tx_offload mbuf_fast_free on",= "testpmd> ") + offload =3D ["mbuf_fast_free"] + self.check_port_config("tx", offload) + + def tear_down(self): + """ + Run after each test case. + """ + self.dut.send_expect("quit", "# ") + + def tear_down_all(self): + """ + Run after each test suite. + """ + time.sleep(2) + self.dut.kill_all() -- 2.5.0