From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 8E169A00C5; Thu, 11 Jun 2020 14:26:05 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 63ABD2BAB; Thu, 11 Jun 2020 14:26:05 +0200 (CEST) Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by dpdk.org (Postfix) with ESMTP id 149B32BAA for ; Thu, 11 Jun 2020 14:26:02 +0200 (CEST) IronPort-SDR: hZ4z+dJeRmzy6+qaz1ndQ5OriJTLx90rcODjlFCfyrAneTUUF2pYW4PinC8WO10AIxA70ILEyl 0nfwp3eO7w0w== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Jun 2020 05:26:02 -0700 IronPort-SDR: O38wWOLYXZwBrnTf1OaQxGGIrsgUicbfwjl28zuD3xIXeezXNTfSZgdCOzLSG2PNQNm/juSvCT 1ILzvKPYIpjA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,499,1583222400"; d="scan'208";a="275316117" Received: from fmsmsx103.amr.corp.intel.com ([10.18.124.201]) by orsmga006.jf.intel.com with ESMTP; 11 Jun 2020 05:26:01 -0700 Received: from fmsmsx113.amr.corp.intel.com (10.18.116.7) by FMSMSX103.amr.corp.intel.com (10.18.124.201) with Microsoft SMTP Server (TLS) id 14.3.439.0; Thu, 11 Jun 2020 05:26:01 -0700 Received: from shsmsx102.ccr.corp.intel.com (10.239.4.154) by FMSMSX113.amr.corp.intel.com (10.18.116.7) with Microsoft SMTP Server (TLS) id 14.3.439.0; Thu, 11 Jun 2020 05:26:00 -0700 Received: from shsmsx101.ccr.corp.intel.com ([169.254.1.85]) by shsmsx102.ccr.corp.intel.com ([169.254.2.36]) with mapi id 14.03.0439.000; Thu, 11 Jun 2020 20:25:57 +0800 From: "Tu, Lijuan" To: "Fu, Qi" , "dts@dpdk.org" CC: "Fu, Qi" Thread-Topic: [dts] [PATCH V1]tests/TestSuite_l2tp_esp_coverage: add l2tp and esp coverage testsuite Thread-Index: AQHWOt7V2Ro3SSX0L0KbwA6u90KYXqjTYSWw Date: Thu, 11 Jun 2020 12:25:56 +0000 Message-ID: <8CE3E05A3F976642AAB0F4675D0AD20E0BC5BCB6@SHSMSX101.ccr.corp.intel.com> References: <20200605110413.9595-1-qi.fu@intel.com> In-Reply-To: <20200605110413.9595-1-qi.fu@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.2.0.6 dlp-reaction: no-action x-originating-ip: [10.239.127.40] Content-Type: text/plain; charset="iso-2022-jp" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dts] [PATCH V1]tests/TestSuite_l2tp_esp_coverage: add l2tp and esp coverage testsuite 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: , Errors-To: dts-bounces@dpdk.org Sender: "dts" Applied, thanks -----Original Message----- From: dts On Behalf Of Fu Qi Sent: 2020=1B$BG/=1B(B6=1B$B7n=1B(B5=1B$BF|=1B(B 19:04 To: dts@dpdk.org Cc: Fu, Qi Subject: [dts] [PATCH V1]tests/TestSuite_l2tp_esp_coverage: add l2tp and es= p coverage testsuite Add l2tpv3 and esp coverage testsuite. Signed-off-by: Fu Qi --- tests/TestSuite_l2tp_esp_coverage.py | 585 +++++++++++++++++++++++++++ 1 file changed, 585 insertions(+) create mode 100644 tests/TestSuite_l2tp_esp_coverage.py diff --git a/tests/TestSuite_l2tp_esp_coverage.py b/tests/TestSuite_l2tp_es= p_coverage.py new file mode 100644 index 0000000..9be2015 --- /dev/null +++ b/tests/TestSuite_l2tp_esp_coverage.py @@ -0,0 +1,585 @@ +# BSD LICENSE +# +# Copyright(c) 2020 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. + +import re +import time +from packet import Packet +from pmd_output import PmdOutput +from test_case import TestCase +import rte_flow_common as rfc + +vf0_mac =3D "00:11:22:33:44:55" + +tv_MAC_IPV4_L2TPv3_chksum =3D {'good_checksum': "Ether(dst=3D'%s')/IP(src= =3D'192.168.0.3', proto=3D115)/L2TP('\\x00\\x00\\x00\\x11')/Raw('X'*480)" %= vf0_mac, + 'bad_checksum':=20 +"Ether(dst=3D'%s')/IP(src=3D'192.168.0.3', proto=3D115, chksum=3D0x1234)/L= 2TP('\\x00\\x00\\x00\\x11')/Raw('X'*480)" % vf0_mac} tv_MAC_IPV4_ESP_chksum= =3D {'good_checksum': 'Ether(dst=3D"%s")/IP(src=3D"192.168.0.3", proto=3D5= 0)/ESP(spi=3D11)/Raw("X"*480)' % vf0_mac, + 'bad_checksum':=20 +'Ether(dst=3D"%s")/IP(src=3D"192.168.0.3", proto=3D50, chksum=3D0x1234)/ES= P(spi=3D11)/Raw("X"*480)' % vf0_mac} tv_MAC_IPV4_AH_chksum =3D {'good_check= sum': 'Ether(dst=3D"%s")/IP(src=3D"192.168.0.3", proto=3D50)/AH(spi=3D11)/R= aw("X"*480)' % vf0_mac, + 'bad_checksum':=20 +'Ether(dst=3D"%s")/IP(src=3D"192.168.0.3", proto=3D50, chksum=3D0x1234)/AH= (spi=3D11)/Raw("X"*480)' % vf0_mac} tv_MAC_IPV4_NAT_T_ESP_chksum =3D {'good= _ip_udp_checksum': 'Ether(dst=3D"%s")/IP(src=3D"192.168.0.20")/UDP(dport=3D= 4500)/ESP(spi=3D2)/Raw("x"*480)' % vf0_mac, + 'bad_ip_good_udp_checksum': 'Ether(dst=3D"%s")/IP(= src=3D"192.168.0.20", chksum=3D0x1234)/UDP(dport=3D4500)/ESP(spi=3D2)/Raw("= x"*480)' % vf0_mac, + 'bad_ip_udp_checksum': 'Ether(dst=3D"%s")/IP(src=3D= "192.168.0.20", chksum=3D0x1234)/UDP(dport=3D4500,chksum=3D0x1234)/ESP(spi= =3D2)/Raw("x"*480)' % vf0_mac, + =20 +'bad_udp_good_ip_checksum':'Ether(dst=3D"%s")/IP(src=3D"192.168.0.20")/UDP= (dport=3D4500,chksum=3D0x1234)/ESP(spi=3D2)/Raw("x"*480)' % vf0_mac} tv_MAC= _IPV6_NAT_T_ESP_chksum =3D {'good_udp_checksum': 'Ether(dst=3D"%s")/IPv6(sr= c=3D"1111:2222:3333:4444:5555:6666:7777:8888")/UDP(dport=3D4500)/ESP(spi=3D= 2)/Raw("x"*480)' % vf0_mac, + 'bad_udp_checksum':=20 +'Ether(dst=3D"%s")/IPv6(src=3D"1111:2222:3333:4444:5555:6666:7777:8888")/U= D +P(dport=3D4500,chksum=3D0x1234)/ESP(spi=3D2)/Raw("x"*480)' % vf0_mac} + +tv_MAC_IPV4_L2TPv3_vlan =3D {'matched vlan': "Ether(dst=3D'%s')/Dot1Q(vlan= =3D1)/IP(proto=3D115)/L2TP('\\x00\\x00\\x00\\x11')/Raw('x'*480)" % vf0_mac, + 'dismatched vlan': "Ether(dst=3D'%s')/Dot1Q(vl= an=3D2)/IP(proto=3D115)/L2TP('\\x00\\x00\\x00\\x11')/Raw('x'*480)" % vf0_ma= c, + 'no vlan':=20 +"Ether(dst=3D'%s')/IP(proto=3D115)/L2TP('\\x00\\x00\\x00\\x11')/Raw('x'*48= 0)" % vf0_mac} tv_MAC_IPV6_L2TPv3_vlan =3D {'matched vlan': "Ether(dst=3D'%= s')/Dot1Q(vlan=3D1)/IPv6(nh=3D115)/L2TP('\\x00\\x00\\x00\\x11')/Raw('x'*480= )" % vf0_mac, + 'dismatched vlan': "Ether(dst=3D'%s')/Dot1Q(vl= an=3D2)/IPv6(nh=3D115)/L2TP('\\x00\\x00\\x00\\x11')/Raw('x'*480)" % vf0_mac= , + 'no vlan':=20 +"Ether(dst=3D'%s')/IPv6(nh=3D115)/L2TP('\\x00\\x00\\x00\\x11')/Raw('x'*480= )" % vf0_mac} tv_MAC_IPV4_ESP_vlan =3D {'matched vlan': "Ether(dst=3D'%s')/= Dot1Q(vlan=3D1)/IP(proto=3D50)/ESP(spi=3D1)/Raw('x'*480)" % vf0_mac, + 'dismatched vlan': "Ether(dst=3D'%s')/Dot1Q(vl= an=3D2)/IP(proto=3D50)/ESP(spi=3D1)/Raw('x'*480)" % vf0_mac, + 'no vlan':=20 +"Ether(dst=3D'%s')/IP(proto=3D50)/ESP(spi=3D1)/Raw('x'*480)" % vf0_mac} tv= _MAC_IPV6_ESP_vlan =3D {'matched vlan': "Ether(dst=3D'%s')/Dot1Q(vlan=3D1)/= IPv6(nh=3D50)/ESP(spi=3D1)/Raw('x'*480)" % vf0_mac, + 'dismatched vlan': "Ether(dst=3D'%s')/Dot1Q(vl= an=3D2)/IPv6(nh=3D50)/ESP(spi=3D1)/Raw('x'*480)" % vf0_mac, + 'no vlan':=20 +"Ether(dst=3D'%s')/IPv6(nh=3D50)/ESP(spi=3D1)/Raw('x'*480)" % vf0_mac} tv_= MAC_IPV4_AH_vlan =3D {'matched vlan': "Ether(dst=3D'%s')/Dot1Q(vlan=3D1)/IP= (proto=3D51)/AH(spi=3D1)/Raw('x'*480)" % vf0_mac, + 'dismatched vlan': "Ether(dst=3D'%s')/Dot1Q(vl= an=3D2)/IP(proto=3D51)/AH(spi=3D1)/Raw('x'*480)" % vf0_mac, + 'no vlan':=20 +"Ether(dst=3D'%s')/IP(proto=3D51)/AH(spi=3D1)/Raw('x'*480)" % vf0_mac} tv_= MAC_IPV6_AH_vlan =3D {'matched vlan': "Ether(dst=3D'%s')/Dot1Q(vlan=3D1)/IP= v6(nh=3D51)/AH(spi=3D1)/Raw('x'*480)" % vf0_mac, + 'dismatched vlan': "Ether(dst=3D'%s')/Dot1Q(vl= an=3D2)/IPv6(nh=3D51)/AH(spi=3D1)/Raw('x'*480)" % vf0_mac, + 'no vlan':=20 +"Ether(dst=3D'%s')/IPv6(nh=3D51)/AH(spi=3D1)/Raw('x'*480)" % vf0_mac} tv_M= AC_IPV4_NAT_T_ESP_vlan =3D {'matched vlan': "Ether(dst=3D'%s')/Dot1Q(vlan= =3D1)/IP()/UDP(dport=3D4500)/ESP(spi=3D1)/Raw('x'*480)" % vf0_mac, + 'dismatched vlan': "Ether(dst=3D'%s')/Dot1Q(vl= an=3D2)/IP()/UDP(dport=3D4500)/ESP(spi=3D1)/Raw('x'*480)" % vf0_mac, + 'no vlan':=20 +"Ether(dst=3D'%s')/IP()/UDP(dport=3D4500)/ESP(spi=3D1)/Raw('x'*480)" % vf0= _mac} tv_MAC_IPV6_NAT_T_ESP_vlan =3D {'matched vlan': "Ether(dst=3D'%s')/Do= t1Q(vlan=3D1)/IPv6()/UDP(dport=3D4500)/ESP(spi=3D1)/Raw('x'*480)" % vf0_mac= , + 'dismatched vlan': "Ether(dst=3D'%s')/Dot1Q(vl= an=3D2)/IPv6()/UDP(dport=3D4500)/ESP(spi=3D1)/Raw('x'*480)" % vf0_mac, + 'no vlan':=20 +"Ether(dst=3D'%s')/IPv6()/UDP(dport=3D4500)/ESP(spi=3D1)/Raw('x'*480)" %=20 +vf0_mac} + + +class L2tpEspCoverage(TestCase): + + def set_up_all(self): + """ + Run at the start of each test suite. + Generic filter Prerequistites + """ + self.dut_ports =3D self.dut.get_ports(self.nic) + # Verify that enough ports are available + self.verify(len(self.dut_ports) >=3D 1, "Insufficient ports") + self.pmd_output =3D PmdOutput(self.dut) + localPort =3D self.tester.get_local_port(self.dut_ports[0]) + self.used_dut_port =3D self.dut_ports[0] + self.ports_socket =3D self.dut.get_numa_id(self.dut_ports[0]) + self.tx_iface =3D self.tester.get_interface(localPort) + 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.verify(self.nic in ["columbiaville_25g", "columbiaville_100g"= ], "%s nic not support ethertype filter" % self.nic) + self.vf_flag =3D False + self.create_iavf() + self.pkt =3D Packet() + + def set_up(self): + """ + Run before each test case. + """ + self.dut.kill_all() + + def tear_down(self): + """ + Run after each test case. + """ + self.dut.kill_all() + + def tear_down_all(self): + """ + Run after each test suite. + """ + self.dut.kill_all() + self.destroy_iavf() + + def create_iavf(self): + + if self.vf_flag is False: + self.dut.bind_interfaces_linux('ice') + self.dut.generate_sriov_vfs_by_port(self.used_dut_port, 1) + self.sriov_vfs_port =3D self.dut.ports_info[self.used_dut_port= ]['vfs_port'] + self.vf_flag =3D True + + try: + for port in self.sriov_vfs_port: + port.bind_driver(self.drivername) + + self.vf0_prop =3D {'opt_host': self.sriov_vfs_port[0].pci} + self.dut.send_expect("ip link set %s vf 0 mac %s" % (self.= pf_interface, vf0_mac), "# ") + except Exception as e: + self.destroy_iavf() + raise Exception(e) + + def destroy_iavf(self): + if self.vf_flag is True: + self.dut.destroy_sriov_vfs_by_port(self.used_dut_port) + self.vf_flag =3D False + + def create_testpmd_command(self, port_info, rx_checksum=3D0): + """ + Create testpmd command for non-pipeline mode + """ + =20 + port_pci =3D port_info['opt_host'] + if rx_checksum=3D=3D1: + param_str =3D " --rxq=3D16 --txq=3D16 --port-topology=3Dloop -= -enable-rx-cksum " + else: + param_str =3D " --rxq=3D16 --txq=3D16 --port-topology=3Dloop " + self.pmd_output.start_testpmd(cores=3D"1S/8C/1T", param=3Dparam_st= r, eal_param=3D"-w %s" % port_pci) + self.dut.send_expect("set fwd rxonly", "testpmd> ", 15) + self.dut.send_expect("set verbose 1", "testpmd> ", 15) + + def enable_hw_checksum(self): + self.dut.send_expect("stop","testpmd> ") + self.dut.send_expect("port stop all","testpmd> ") + self.dut.send_expect("csum set ip hw 0","testpmd> ") + self.dut.send_expect("csum set udp hw 0","testpmd> ") + self.dut.send_expect("port start all","testpmd> ") + self.dut.send_expect("set fwd csum","testpmd> ") + self.dut.send_expect("set verbose 1","testpmd> ") + self.dut.send_expect("start","testpmd> ") + =20 + def enable_sw_checksum(self): + self.dut.send_expect("stop","testpmd> ") + self.dut.send_expect("port stop all","testpmd> ") + self.dut.send_expect("csum set ip sw 0","testpmd> ") + self.dut.send_expect("csum set udp sw 0","testpmd> ") + self.dut.send_expect("port start all","testpmd> ") + self.dut.send_expect("set fwd csum","testpmd> ") + self.dut.send_expect("set verbose 1","testpmd> ") + self.dut.send_expect("start","testpmd> ") + =20 + def checksum_verify(self, packets_sent): + # Send packet. + self.tester.scapy_foreground() + + for packet_type in list(packets_sent.keys()): + self.tester.scapy_append('sendp([%s], iface=3D"%s")' % (packet= s_sent[packet_type], self.tx_iface)) + self.tester.scapy_execute() + time.sleep(1) + out =3D self.pmd_output.execute_cmd("stop") + bad_ipcsum =3D self.pmd_output.get_pmd_value("Bad-ipcsum:", ou= t) + bad_l4csum =3D self.pmd_output.get_pmd_value("Bad-l4csum:",=20 + out) + =20 + if packet_type =3D=3D 'good_checksum': + # verify good ip checksum + self.verify(bad_ipcsum =3D=3D 0, "good ip csum check error= ") + elif packet_type =3D=3D 'bad_checksum': + # verify bad ip checksum + self.verify(bad_ipcsum =3D=3D 1, "bad ip csum check error"= ) + elif packet_type =3D=3D 'bad_udp_checksum': + # verify bad udp checksum + self.verify(bad_l4csum =3D=3D 1, "bad udp csum check error= ") + elif packet_type =3D=3D 'good_udp_checksum': + # verify good udp checksum + self.verify(bad_l4csum =3D=3D 0, "good udp csum check erro= r") + elif packet_type =3D=3D 'good_ip_udp_checksum': + # verify good ip + udp checksum + self.verify(bad_ipcsum =3D=3D 0, "good ip csum check error= ") + self.verify(bad_l4csum =3D=3D 0, "good udp csum check erro= r") + elif packet_type =3D=3D 'bad_ip_udp_checksum': + # verify bad ip + udp checksum + self.verify(bad_ipcsum =3D=3D 1, "bad ip csum check error"= ) + self.verify(bad_l4csum =3D=3D 1, "bad udp csum check error= ") + elif packet_type =3D=3D 'bad_ip_good_udp_checksum': + # verify bad ip + good udp checksum + self.verify(bad_ipcsum =3D=3D 1, "bad ip csum check error"= ) + self.verify(bad_l4csum =3D=3D 0, "good udp csum check erro= r") + else: + # verify good ip + bad udp checksum + self.verify(bad_ipcsum =3D=3D 0, "good ip csum check error= ") + self.verify(bad_l4csum =3D=3D 1, "bad udp csum check=20 + error") + + self.pmd_output.execute_cmd("start") + =20 + def test_MAC_IPV4_L2TPv3_HW_checksum(self): + self.create_testpmd_command(self.vf0_prop,rx_checksum=3D1) + self.enable_hw_checksum() + self.checksum_verify(tv_MAC_IPV4_L2TPv3_chksum) + =20 + def test_MAC_IPV4_ESP_HW_checksum(self): + self.create_testpmd_command(self.vf0_prop,rx_checksum=3D1) + self.enable_hw_checksum() + self.checksum_verify(tv_MAC_IPV4_ESP_chksum) + =20 + def test_MAC_IPV4_AH_HW_checksum(self): + self.create_testpmd_command(self.vf0_prop,rx_checksum=3D1) + self.enable_hw_checksum() + self.checksum_verify(tv_MAC_IPV4_AH_chksum) + =20 + def test_MAC_IPV4_NAT_T_ESP_HW_checksum(self): + self.create_testpmd_command(self.vf0_prop,rx_checksum=3D1) + self.enable_hw_checksum() + self.checksum_verify(tv_MAC_IPV4_NAT_T_ESP_chksum) + =20 + def test_MAC_IPV6_NAT_T_ESP_HW_checksum(self): + self.create_testpmd_command(self.vf0_prop,rx_checksum=3D1) + self.enable_hw_checksum() + self.checksum_verify(tv_MAC_IPV6_NAT_T_ESP_chksum) + =20 + =20 + def start_tcpdump(self, rxItf): + self.tester.send_expect("rm -rf getPackageByTcpdump.cap", "#") + self.tester.send_expect("tcpdump -A -nn -e -vv -w getPackageByTcpd= ump.cap -i %s 2> /dev/null& " % rxItf, "#") + time.sleep(2) + + def get_tcpdump_package(self): + time.sleep(1) + self.tester.send_expect("killall tcpdump", "#") + return self.tester.send_expect("tcpdump -A -nn -e -vv -r=20 + getPackageByTcpdump.cap", "#") + =20 + def vlan_strip_insertion_verify(self,packets_sent): + + # disabel vlan strip, tester will receive the pkt with vlan id + self.dut.send_expect("vlan set filter on 0","testpmd> ") + self.dut.send_expect("vlan set strip off 0","testpmd> ") + self.dut.send_expect("rx_vlan add 1 0","testpmd> ") + self.dut.send_expect("set fwd mac","testpmd> ") + self.dut.send_expect("set verbose 1","testpmd> ") + self.dut.send_expect("start","testpmd> ") + self.start_tcpdump(self.tx_iface) + self.tester.scapy_append('sendp([%s], iface=3D"%s")' % (packets_se= nt['matched vlan'], self.tx_iface)) + self.tester.scapy_execute() + time.sleep(1) + out =3D self.pmd_output.execute_cmd("stop") + tcpdump_out =3D self.get_tcpdump_package() + receive_pkt =3D re.findall('vlan 1', tcpdump_out) + self.verify(len(receive_pkt) =3D=3D 2, 'vlan id strip off failed') + self.dut.send_expect("start","testpmd> ") + self.tester.scapy_append('sendp([%s], iface=3D"%s")' % (packets_se= nt['dismatched vlan'], self.tx_iface)) + self.tester.scapy_execute() + time.sleep(1) + out =3D self.pmd_output.execute_cmd("stop") + pkts=3D rfc.get_port_rx_packets_number(out,0) + self.verify(pkts=3D=3D0, "vlan id filter failed") + + # enable vlan strip, tester will receive the pkt without vlan id + self.dut.send_expect("vlan set strip on 0","testpmd> ") + self.start_tcpdump(self.tx_iface) + self.tester.scapy_append('sendp([%s], iface=3D"%s")' % (packets_se= nt['matched vlan'], self.tx_iface)) + self.tester.scapy_execute() + time.sleep(1) + out =3D self.pmd_output.execute_cmd("stop") + tcpdump_out =3D self.get_tcpdump_package() + receive_pkt =3D re.findall('vlan 1', tcpdump_out) + self.verify(len(receive_pkt) =3D=3D 1, 'vlan id strip on failed') + + # vlan insertion + self.dut.send_expect("vlan set strip off 0","testpmd> ") + self.dut.send_expect("port stop all","testpmd> ") + self.dut.send_expect("tx_vlan set 0 1","testpmd> ") + self.dut.send_expect("vlan set filter on 0","testpmd> ") + self.dut.send_expect("rx_vlan add 1 0","testpmd> ") + self.dut.send_expect("port start all","testpmd> ") + self.dut.send_expect("start","testpmd> ") + self.start_tcpdump(self.tx_iface) + self.tester.scapy_append('sendp([%s], iface=3D"%s")' % (packets_se= nt['no vlan'], self.tx_iface)) + self.tester.scapy_execute() + time.sleep(1) + out =3D self.pmd_output.execute_cmd("stop") + tcpdump_out =3D self.get_tcpdump_package() + receive_pkt =3D re.findall('vlan 1', tcpdump_out) + self.verify(len(receive_pkt) =3D=3D 1, 'vlan insertion failed') + =20 + def test_MAC_IPV4_L2TPv3_l2_tag(self): + self.create_testpmd_command(self.vf0_prop) + self.vlan_strip_insertion_verify(tv_MAC_IPV4_L2TPv3_vlan) + =20 + def test_MAC_IPV6_L2TPv3_l2_tag(self): + self.create_testpmd_command(self.vf0_prop) + self.vlan_strip_insertion_verify(tv_MAC_IPV6_L2TPv3_vlan) + =20 + def test_MAC_IPV4_ESP_l2_tag(self): + self.create_testpmd_command(self.vf0_prop) + self.vlan_strip_insertion_verify(tv_MAC_IPV4_ESP_vlan) + =20 + def test_MAC_IPV6_ESP_l2_tag(self): + self.create_testpmd_command(self.vf0_prop) + self.vlan_strip_insertion_verify(tv_MAC_IPV6_ESP_vlan) + =20 + def test_MAC_IPV4_AH_l2_tag(self): + self.create_testpmd_command(self.vf0_prop) + self.vlan_strip_insertion_verify(tv_MAC_IPV4_AH_vlan) + + def test_MAC_IPV6_AH_l2_tag(self): + self.create_testpmd_command(self.vf0_prop) + self.vlan_strip_insertion_verify(tv_MAC_IPV6_AH_vlan) + =20 + def test_MAC_IPV4_NAT_T_ESP_l2_tag(self): + self.create_testpmd_command(self.vf0_prop) + self.vlan_strip_insertion_verify(tv_MAC_IPV4_NAT_T_ESP_vlan) + =20 + def test_MAC_IPV6_NAT_T_ESP_l2_tag(self): + self.create_testpmd_command(self.vf0_prop) + self.vlan_strip_insertion_verify(tv_MAC_IPV6_NAT_T_ESP_vlan) + + def send_pkts_getouput(self, pkts, pf_id=3D0): + """ + if pkt_info is True, we need to get packet infomation to check the= RSS hash and FDIR. + if pkt_info is False, we just need to get the packet number and qu= eue number. + """ + self.send_packets(pkts, pf_id) + time.sleep(1) + out_info =3D self.dut.get_session_output(timeout=3D1) + out_pkt =3D self.pmd_output.execute_cmd("stop") + out =3D out_info + out_pkt + self.pmd_output.execute_cmd("start") + return out + + def send_packets(self, packets, pf_id=3D0): + self.pkt.update_pkt(packets) + tx_port =3D self.tx_iface + self.pkt.send_pkt(crb=3Dself.tester, tx_port=3Dtx_port) + + def test_MAC_IPV4_L2TPv3_HW_checksum_vlan_strip(self): + + self.create_testpmd_command(self.vf0_prop,rx_checksum=3D1) + # vlan strip on + self.dut.send_expect("vlan set filter on 0","testpmd> ") + self.dut.send_expect("vlan set strip on 0","testpmd> ") + self.dut.send_expect("rx_vlan add 1 0","testpmd> ") + + self.enable_hw_checksum() + #create rule + self.dut.send_expect("flow create 0 ingress pattern eth / ipv4 / l= 2tpv3oip session_id is 1 / end actions queue index 1 / mark id 4 / end","te= stpmd> ") + self.dut.send_expect("flow create 0 ingress pattern eth / ipv4 / l= 2tpv3oip session_id is 2 / end actions queue index 2 / mark id 3 / end","te= stpmd> ") + self.dut.send_expect("flow create 0 ingress pattern eth / ipv4 / l= 2tpv3oip session_id is 3 / end actions queue index 3 / mark id 2 / end","te= stpmd> ") + self.dut.send_expect("flow create 0 ingress pattern eth / ipv4 / l= 2tpv3oip session_id is 4 / end actions queue index 4 / mark id 1 / end","te= stpmd> ") + # matched vlan id + bad checksum + matched session id + pkts=3D"Ether(dst=3D'00:11:22:33:44:55')/Dot1Q(vlan=3D1)/IP(proto= =3D115,chksum=3D0x123)/L2TP('\\x00\\x00\\x00\\x01')/Raw('x'*480)" + self.start_tcpdump(self.tx_iface) + out =3D self.send_pkts_getouput(pkts) + # check the fdir rule + rfc.check_iavf_fdir_mark(out, pkt_num=3D1, check_param=3D{"port_id= ": 0, "queue": 1, "mark_id": 4}) + # check the rx checksum=20 + bad_ipcsum =3D self.pmd_output.get_pmd_value("Bad-ipcsum:", out) + self.verify(bad_ipcsum =3D=3D 1, "bad ip csum check error") + # check the vlan strip + tcpdump_out =3D self.get_tcpdump_package() + receive_pkt =3D re.findall('vlan 1', tcpdump_out) + self.verify(len(receive_pkt) =3D=3D 1, 'vlan id strip on failed') + # matched vlan id + bad checksum + mismatched session id + pkts=3D"Ether(dst=3D'00:11:22:33:44:55')/Dot1Q(vlan=3D1)/IP(proto= =3D115,chksum=3D0x123)/L2TP('\\x00\\x00\\x00\\x11')/Raw('x'*480)" + self.start_tcpdump(self.tx_iface) + out =3D self.send_pkts_getouput(pkts) + # check the fdir rule + rfc.check_iavf_fdir_mark(out, pkt_num=3D1, check_param=3D{"port_id= ": 0, "queue": 1, "mark_id": 4},stats=3DFalse) + # check the rx checksum=20 + bad_ipcsum =3D self.pmd_output.get_pmd_value("Bad-ipcsum:", out) + self.verify(bad_ipcsum =3D=3D 1, "bad ip csum check error") + # check the vlan strip + tcpdump_out =3D self.get_tcpdump_package() + receive_pkt =3D re.findall('vlan 1', tcpdump_out) + self.verify(len(receive_pkt) =3D=3D 1, 'vlan id strip on failed') + + # destroy rule + self.dut.send_expect("flow flush 0","testpmd> ") + # matched vlan id + bad checksum + matched session id + pkts=3D"Ether(dst=3D'00:11:22:33:44:55')/Dot1Q(vlan=3D1)/IP(proto= =3D115,chksum=3D0x123)/L2TP('\\x00\\x00\\x00\\x01')/Raw('x'*480)" + self.start_tcpdump(self.tx_iface) + out =3D self.send_pkts_getouput(pkts) + # check the fdir rule + rfc.check_iavf_fdir_mark(out, pkt_num=3D1, check_param=3D{"port_id= ": 0, "queue": 1, "mark_id": 4},stats=3DFalse) + # check the rx checksum=20 + bad_ipcsum =3D self.pmd_output.get_pmd_value("Bad-ipcsum:", out) + self.verify(bad_ipcsum =3D=3D 1, "bad ip csum check error") + # check the vlan strip + tcpdump_out =3D self.get_tcpdump_package() + receive_pkt =3D re.findall('vlan 1', tcpdump_out) + self.verify(len(receive_pkt) =3D=3D 1, 'vlan id strip on failed') + + def test_MAC_IPV4_L2TPv3_SW_checksum_vlan_insertion(self): + + self.create_testpmd_command(self.vf0_prop,rx_checksum=3D1) + # vlan insertion on + self.dut.send_expect("vlan set strip off 0","testpmd> ") + self.dut.send_expect("port stop all","testpmd> ") + self.dut.send_expect("tx_vlan set 0 1","testpmd> ") + self.dut.send_expect("vlan set filter on 0","testpmd> ") + self.dut.send_expect("rx_vlan add 1 0","testpmd> ") + self.dut.send_expect("port start all","testpmd> ") + self.dut.send_expect("set fwd mac","testpmd> ") + self.dut.send_expect("set verbose 1","testpmd> ") + self.dut.send_expect("start","testpmd> ") + + #create rule + self.dut.send_expect("flow create 0 ingress pattern eth / ipv4 / l= 2tpv3oip session_id is 1 / end actions queue index 1 / mark id 4 / end","te= stpmd> ") + self.dut.send_expect("flow create 0 ingress pattern eth / ipv4 / l= 2tpv3oip session_id is 2 / end actions queue index 2 / mark id 3 / end","te= stpmd> ") + self.dut.send_expect("flow create 0 ingress pattern eth / ipv4 / l= 2tpv3oip session_id is 3 / end actions queue index 3 / mark id 2 / end","te= stpmd> ") + self.dut.send_expect("flow create 0 ingress pattern eth / ipv4 / l= 2tpv3oip session_id is 4 / end actions queue index 4 / mark id 1 / end","te= stpmd> ") + # no vlan + matched session id + pkts=3D"Ether(dst=3D'00:11:22:33:44:55')/IP(proto=3D115)/L2TP('\\x= 00\\x00\\x00\\x01')/Raw('x'*480)" + self.start_tcpdump(self.tx_iface) + out =3D self.send_pkts_getouput(pkts) + time.sleep(1) + # check the fdir rule + rfc.check_iavf_fdir_mark(out, pkt_num=3D1, check_param=3D{"port_id= ": 0, "queue": 1, "mark_id": 4}) + # check the vlan insertion + tcpdump_out =3D self.get_tcpdump_package() + receive_pkt =3D re.findall('vlan 1', tcpdump_out) + self.verify(len(receive_pkt) =3D=3D 1, 'vlan insertion failed') + =20 + self.enable_sw_checksum() + # bad checksum + mismatched session id + pkts=3D"Ether(dst=3D'00:11:22:33:44:55')/IP(proto=3D115,chksum=3D0= x123)/L2TP('\\x00\\x00\\x00\\x11')/Raw('x'*480)" + self.start_tcpdump(self.tx_iface) + out =3D self.send_pkts_getouput(pkts) + # check the fdir rule + rfc.check_iavf_fdir_mark(out, pkt_num=3D1, check_param=3D{"port_id= ": 0, "queue": 1, "mark_id": 4},stats=3DFalse) + # check the rx checksum=20 + bad_ipcsum =3D self.pmd_output.get_pmd_value("Bad-ipcsum:", out) + self.verify(bad_ipcsum =3D=3D 1, "bad ip csum check error") + + # destroy rule + self.dut.send_expect("flow flush 0","testpmd> ") + # bad checksum + matched session id + pkts=3D"Ether(dst=3D'00:11:22:33:44:55')/IP(proto=3D115,chksum=3D0= x123)/L2TP('\\x00\\x00\\x00\\x01')/Raw('x'*480)" + self.start_tcpdump(self.tx_iface) + out =3D self.send_pkts_getouput(pkts) + # check the fdir rule + rfc.check_iavf_fdir_mark(out, pkt_num=3D1, check_param=3D{"port_id= ": 0, "queue": 1, "mark_id": 4},stats=3DFalse) + # check the rx checksum=20 + bad_ipcsum =3D self.pmd_output.get_pmd_value("Bad-ipcsum:", out) + self.verify(bad_ipcsum =3D=3D 1, "bad ip csum check error") + =20 + + def test_MAC_IPV4_ESP_HW_checksum_vlan_strip(self): + + self.create_testpmd_command(self.vf0_prop,rx_checksum=3D1) + # vlan strip on + self.dut.send_expect("vlan set filter on 0","testpmd> ") + self.dut.send_expect("vlan set strip on 0","testpmd> ") + self.dut.send_expect("rx_vlan add 1 0","testpmd> ") + + self.enable_hw_checksum() + #create rule + self.dut.send_expect("flow create 0 ingress pattern eth / ipv4 / e= sp spi is 1 / end actions queue index 1 / mark id 4 / end","testpmd> ") + self.dut.send_expect("flow create 0 ingress pattern eth / ipv4 / e= sp spi is 2 / end actions queue index 2 / mark id 3 / end","testpmd> ") + self.dut.send_expect("flow create 0 ingress pattern eth / ipv4 / e= sp spi is 3 / end actions queue index 3 / mark id 2 / end","testpmd> ") + self.dut.send_expect("flow create 0 ingress pattern eth / ipv4 / e= sp spi is 4 / end actions queue index 4 / mark id 1 / end","testpmd> ") + # matched vlan id + bad checksum + matched session id + pkts=3D"Ether(dst=3D'00:11:22:33:44:55')/Dot1Q(vlan=3D1)/IP(proto= =3D50,chksum=3D0x123)/ESP(spi=3D1)/Raw('x'*480)" + self.start_tcpdump(self.tx_iface) + out =3D self.send_pkts_getouput(pkts) + # check the fdir rule + rfc.check_iavf_fdir_mark(out, pkt_num=3D1, check_param=3D{"port_id= ": 0, "queue": 1, "mark_id": 4}) + # check the rx checksum=20 + bad_ipcsum =3D self.pmd_output.get_pmd_value("Bad-ipcsum:", out) + self.verify(bad_ipcsum =3D=3D 1, "bad ip csum check error") + # check the vlan strip + tcpdump_out =3D self.get_tcpdump_package() + receive_pkt =3D re.findall('vlan 1', tcpdump_out) + self.verify(len(receive_pkt) =3D=3D 1, 'vlan id strip on failed') + # matched vlan id + bad checksum + mismatched session id + pkts=3D"Ether(dst=3D'00:11:22:33:44:55')/Dot1Q(vlan=3D1)/IP(proto= =3D50,chksum=3D0x123)/ESP(spi=3D11)/Raw('x'*480)" + self.start_tcpdump(self.tx_iface) + out =3D self.send_pkts_getouput(pkts) + # check the fdir rule + rfc.check_iavf_fdir_mark(out, pkt_num=3D1, check_param=3D{"port_id= ": 0, "queue": 1, "mark_id": 4},stats=3DFalse) + # check the rx checksum=20 + bad_ipcsum =3D self.pmd_output.get_pmd_value("Bad-ipcsum:", out) + self.verify(bad_ipcsum =3D=3D 1, "bad ip csum check error") + # check the vlan strip + tcpdump_out =3D self.get_tcpdump_package() + receive_pkt =3D re.findall('vlan 1', tcpdump_out) + self.verify(len(receive_pkt) =3D=3D 1, 'vlan id strip on failed') + + # destroy rule + self.dut.send_expect("flow flush 0","testpmd> ") + # matched vlan id + bad checksum + matched session id + pkts=3D"Ether(dst=3D'00:11:22:33:44:55')/Dot1Q(vlan=3D1)/IP(proto= =3D50,chksum=3D0x123)/ESP(spi=3D1)/Raw('x'*480)" + self.start_tcpdump(self.tx_iface) + out =3D self.send_pkts_getouput(pkts) + # check the fdir rule + rfc.check_iavf_fdir_mark(out, pkt_num=3D1, check_param=3D{"port_id= ": 0, "queue": 1, "mark_id": 4},stats=3DFalse) + # check the rx checksum=20 + bad_ipcsum =3D self.pmd_output.get_pmd_value("Bad-ipcsum:", out) + self.verify(bad_ipcsum =3D=3D 1, "bad ip csum check error") + # check the vlan strip + tcpdump_out =3D self.get_tcpdump_package() + receive_pkt =3D re.findall('vlan 1', tcpdump_out) + self.verify(len(receive_pkt) =3D=3D 1, 'vlan id strip on failed') + + def test_MAC_IPV4_NAT_T_ESP_SW_checksum_vlan_insertion(self): + + self.create_testpmd_command(self.vf0_prop,rx_checksum=3D1) + # vlan insertion on + self.dut.send_expect("vlan set strip off 0","testpmd> ") + self.dut.send_expect("port stop all","testpmd> ") + self.dut.send_expect("tx_vlan set 0 1","testpmd> ") + self.dut.send_expect("vlan set filter on 0","testpmd> ") + self.dut.send_expect("rx_vlan add 1 0","testpmd> ") + self.dut.send_expect("port start all","testpmd> ") + self.dut.send_expect("set fwd mac","testpmd> ") + self.dut.send_expect("set verbose 1","testpmd> ") + self.dut.send_expect("start","testpmd> ") + + #create rule + self.dut.send_expect("flow create 0 ingress pattern eth / ipv4 / u= dp / esp spi is 1 / end actions queue index 1 / mark id 4 / end","testpmd> = ") + self.dut.send_expect("flow create 0 ingress pattern eth / ipv4 / u= dp / esp spi is 2 / end actions queue index 2 / mark id 3 / end","testpmd> = ") + self.dut.send_expect("flow create 0 ingress pattern eth / ipv4 / u= dp / esp spi is 3 / end actions queue index 3 / mark id 2 / end","testpmd> = ") + self.dut.send_expect("flow create 0 ingress pattern eth / ipv4 / u= dp / esp spi is 4 / end actions queue index 4 / mark id 1 / end","testpmd> = ") + # no vlan + matched session id + pkts=3D"Ether(dst=3D'00:11:22:33:44:55')/IP()/UDP(dport=3D4500)/ES= P(spi=3D1)/Raw('x'*480)" + self.start_tcpdump(self.tx_iface) + out =3D self.send_pkts_getouput(pkts) + # check the fdir rule + rfc.check_iavf_fdir_mark(out, pkt_num=3D1, check_param=3D{"port_id= ": 0, "queue": 1, "mark_id": 4}) + # check the vlan insertion + tcpdump_out =3D self.get_tcpdump_package() + receive_pkt =3D re.findall('vlan 1', tcpdump_out) + self.verify(len(receive_pkt) =3D=3D 1, 'vlan insertion failed') + =20 + self.enable_sw_checksum() + # bad checksum + mismatched session id + pkts=3D"Ether(dst=3D'00:11:22:33:44:55')/IP(chksum=3D0x123)/UDP(dp= ort=3D4500)/ESP(spi=3D11)/Raw('x'*480)" + self.start_tcpdump(self.tx_iface) + out =3D self.send_pkts_getouput(pkts) + # check the fdir rule + rfc.check_iavf_fdir_mark(out, pkt_num=3D1, check_param=3D{"port_id= ": 0, "queue": 1, "mark_id": 4},stats=3DFalse) + # check the rx checksum=20 + bad_ipcsum =3D self.pmd_output.get_pmd_value("Bad-ipcsum:", out) + self.verify(bad_ipcsum =3D=3D 1, "bad ip csum check error") + + # destroy rule + self.dut.send_expect("flow flush 0","testpmd> ") + # bad checksum + matched session id + pkts=3D"Ether(dst=3D'00:11:22:33:44:55')/IP(chksum=3D0x123)/UDP(dp= ort=3D4500)/ESP(spi=3D1)/Raw('x'*480)" + self.start_tcpdump(self.tx_iface) + out =3D self.send_pkts_getouput(pkts) + # check the fdir rule + rfc.check_iavf_fdir_mark(out, pkt_num=3D1, check_param=3D{"port_id= ": 0, "queue": 1, "mark_id": 4},stats=3DFalse) + # check the rx checksum=20 + bad_ipcsum =3D self.pmd_output.get_pmd_value("Bad-ipcsum:", out) + self.verify(bad_ipcsum =3D=3D 1, "bad ip csum check error") + + + + --=20 2.17.1