From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by dpdk.org (Postfix) with ESMTP id 1A19D27D for ; Mon, 25 Feb 2019 11:04:21 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 25 Feb 2019 02:04:20 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.58,411,1544515200"; d="scan'208";a="117569446" Received: from fmsmsx108.amr.corp.intel.com ([10.18.124.206]) by orsmga007.jf.intel.com with ESMTP; 25 Feb 2019 02:04:20 -0800 Received: from fmsmsx120.amr.corp.intel.com (10.18.124.208) by FMSMSX108.amr.corp.intel.com (10.18.124.206) with Microsoft SMTP Server (TLS) id 14.3.408.0; Mon, 25 Feb 2019 02:04:20 -0800 Received: from shsmsx152.ccr.corp.intel.com (10.239.6.52) by fmsmsx120.amr.corp.intel.com (10.18.124.208) with Microsoft SMTP Server (TLS) id 14.3.408.0; Mon, 25 Feb 2019 02:04:19 -0800 Received: from shsmsx101.ccr.corp.intel.com ([169.254.1.110]) by SHSMSX152.ccr.corp.intel.com ([169.254.6.109]) with mapi id 14.03.0415.000; Mon, 25 Feb 2019 18:04:18 +0800 From: "Tu, Lijuan" To: "Peng, Yuan" , "dts@dpdk.org" CC: "Peng, Yuan" Thread-Topic: [dts] [PATCH]tests: add TestSuite_rxtx_offload.py Thread-Index: AQHUu4Hicqd57XOK30WES9DRWzrtxKXwa+LQ Date: Mon, 25 Feb 2019 10:04:17 +0000 Message-ID: <8CE3E05A3F976642AAB0F4675D0AD20E0BA26C79@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: zh-CN, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-product: dlpe-windows dlp-version: 11.0.400.15 dlp-reaction: no-action x-ctpclassification: CTP_NT x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiMzljOGQ1YzEtMTYxMC00YzNjLTk4OGEtODNkODdmZThiNGVlIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoiRnQ5TGt0cmllTFBiVDFJYUl4djV1aHVGWmt3TEpEbisrYlZkV3VaWlJQclZ0S0dlU3ZBK3BXTlFvRlZHV1wvZ1gifQ== 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: Mon, 25 Feb 2019 10:04:22 -0000 Applied, thanks > -----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 >=20 > Add TestSuite_rxtx_offload.py to tests >=20 > Signed-off-by: Peng Yuan >=20 > diff --git a/tests/TestSuite_rxtx_offload.py b/tests/TestSuite_rxtx_offlo= ad.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 # > +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. > + > +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"], = "NIC 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]]['in= tf'] > + 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.te= ster_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.te= ster_itf0) > + self.vlan_pkt1 =3D > r'sendp([Ether(dst=3D"%s")/Dot1Q(vlan=3D1)/IP(src=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 > + 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")' % > + (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 c= apabilities", > "testpmd> ") > + elif rxtx =3D=3D "tx": > + outstring =3D self.dut.send_expect("show port 0 tx_offload > + 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 > + port") > + > + if rxtx =3D=3D "rx": > + outstring =3D self.dut.send_expect("show port 0 rx_offload c= onfiguration", > "testpmd> ") > + elif rxtx =3D=3D "tx": > + outstring =3D self.dut.send_expect("show port 0 tx_offload > + 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 disable= d.") > + else: > + exp_offload =3D m.group(1).split() > + self.verify(exp_offload !=3D None, "There is no offload conf= igured.") > + for each_offload in offload: > + self.verify(each_offload in offloads.keys(), "Offload ty= pe error!") > + self.verify(offloads[each_offload] in exp_offload, > + "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 > + port") > + > + acl_offloads =3D [] > + if rxtx =3D=3D "rx": > + outstring =3D self.dut.send_expect("show port 0 rx_offload c= onfiguration", > "testpmd> ") > + elif rxtx =3D=3D "tx": > + outstring =3D self.dut.send_expect("show port 0 tx_offload > + 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= queue.") > + else: > + acl_offload =3D offloads[offload[i]] > + self.verify(acl_offload in queue_line[i], "Fail to confi= gure offload by > queue.") > + i =3D i + 1 > + > + 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 co= nfigure > offload by queue.") > + else: > + self.verify("PKT_RX_VLAN_STRIPPED" not in outstring, "Fail t= o 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 > + 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 r= eceived.") > + 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 > + 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 > + ./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", "#", 120) > + > + def test_rxoffload_port(self): > + """ > + Set Rx offload by port. > + """ > + self.pmdout.start_testpmd("%s" % self.cores, "--rxq=3D4 --txq=3D= 4 --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" % > + (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" % > pkt1_queue, "testpmd> ") > + outstring =3D self.dut.send_expect("port start 0", "testpmd> ") > + self.verify("Fail" in outstring, "jumboframe can be set by > + 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", > "testpmd> ") > + 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" % > + (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=3D= 4 --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", "= testpmd> > ") > + 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", = "testpmd> > ") > + 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", "= testpmd> > ") > + 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", "= testpmd> > ") > + 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", "t= estpmd> ") > + 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", "t= estpmd> > ") > + 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=3D= 4") > + 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" % = capability, > "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" %= capability, > "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 > + offload setting by queue." % self.nic) > + > + self.pmdout.start_testpmd("%s" % self.cores, "--rxq=3D4 --txq=3D= 4") > + 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", "t= estpmd> ") > + self.dut.send_expect("port 0 rxq 2 rx_offload vlan_strip on", "t= estpmd> ") > + 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", "t= estpmd> ") > + self.dut.send_expect("port 0 rxq 2 rx_offload vlan_strip off", "= testpmd> ") > + 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", "= testpmd> ") > + 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", = "testpmd> ") > + 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=3D= 4 --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_fre= e 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", = "testpmd> > ") > + 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=3D= 4 --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_fre= e 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", = "testpmd> ") > + self.dut.send_expect("port 0 txq 1 tx_offload vlan_insert off", = "testpmd> ") > + self.dut.send_expect("port 0 txq 2 tx_offload vlan_insert off", = "testpmd> ") > + self.dut.send_expect("port 0 txq 3 tx_offload vlan_insert off", = "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.") > + > + # 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", "= testpmd> ") > + self.dut.send_expect("port 0 txq 1 tx_offload vlan_insert on", "= testpmd> ") > + self.dut.send_expect("port 0 txq 2 tx_offload vlan_insert on", "= testpmd> ") > + self.dut.send_expect("port 0 txq 3 tx_offload vlan_insert on", "= testpmd> ") > + outstring =3D self.dut.send_expect("port start 0", "testpmd> ") > + self.verify("Fail" in outstring, "vlan_insert can be set by > + 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", = "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.") > + > + def test_txoffload_port_all(self): > + """ > + Set all Tx offload capabilities by port. > + """ > + self.pmdout.start_testpmd("%s" % self.cores, "--rxq=3D4 --txq=3D= 4") > + 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_fre= e 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" % capa= bility, > "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" % cap= ability, > "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 no= t 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=3D= 4") > + 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 of= f", > "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