From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by dpdk.space (Postfix) with ESMTP id 4C159A0096 for ; Wed, 5 Jun 2019 10:14:29 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 205311B99C; Wed, 5 Jun 2019 10:14:29 +0200 (CEST) Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by dpdk.org (Postfix) with ESMTP id CF69A1B946 for ; Wed, 5 Jun 2019 10:14:26 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 05 Jun 2019 01:14:25 -0700 X-ExtLoop1: 1 Received: from fmsmsx108.amr.corp.intel.com ([10.18.124.206]) by FMSMGA003.fm.intel.com with ESMTP; 05 Jun 2019 01:14:25 -0700 Received: from fmsmsx117.amr.corp.intel.com (10.18.116.17) by FMSMSX108.amr.corp.intel.com (10.18.124.206) with Microsoft SMTP Server (TLS) id 14.3.408.0; Wed, 5 Jun 2019 01:14:25 -0700 Received: from shsmsx152.ccr.corp.intel.com (10.239.6.52) by fmsmsx117.amr.corp.intel.com (10.18.116.17) with Microsoft SMTP Server (TLS) id 14.3.408.0; Wed, 5 Jun 2019 01:14:25 -0700 Received: from shsmsx101.ccr.corp.intel.com ([169.254.1.10]) by SHSMSX152.ccr.corp.intel.com ([169.254.6.187]) with mapi id 14.03.0415.000; Wed, 5 Jun 2019 16:14:22 +0800 From: "Zhang, Yuwei1" To: "Zhao, MeijuanX" , "dts@dpdk.org" CC: "Zhao, MeijuanX" Thread-Topic: [dts] [PATCH V1] tests add new testsuite vxlan gpe support in i40e Thread-Index: AQHVG05tBX18IbzUhEiH9E3wo/eYDqaMtquQ Date: Wed, 5 Jun 2019 08:14:21 +0000 Message-ID: References: <20190605112612.23599-1-meijuanx.zhao@intel.com> In-Reply-To: <20190605112612.23599-1-meijuanx.zhao@intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ctpclassification: CTP_NT x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiOGI0MzM5NTItZWNmZS00MmFjLWIyMWYtYjQ0ZThlZDFkY2FmIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoiY3VNTHNNdWZ6V01mMlwvRXc4c014RUFtWTJiR0E2Mk5lY3cydHhyYTlVRTFWdVBNSDhKOHdBbVRMK0pSdnp2NGUifQ== dlp-product: dlpe-windows dlp-version: 11.0.600.7 dlp-reaction: no-action 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 V1] tests add new testsuite vxlan gpe support in i40e 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" Acked-by: Yuwei Zhang -----Original Message----- From: dts [mailto:dts-bounces@dpdk.org] On Behalf Of zhaomeijuan Sent: Wednesday, June 5, 2019 12:26 PM To: dts@dpdk.org Cc: Zhao, MeijuanX Subject: [dts] [PATCH V1] tests add new testsuite vxlan gpe support in i40e Signed-off-by: zhaomeijuan --- tests/TestSuite_vxlan_gpe_support_in_i40e.py | 320 +++++++++++++++++++ 1 file changed, 320 insertions(+) create mode 100644 tests/TestSuite_vxlan_gpe_support_in_i40e.py diff --git a/tests/TestSuite_vxlan_gpe_support_in_i40e.py b/tests/TestSuite= _vxlan_gpe_support_in_i40e.py new file mode 100644 index 0000000..f87c541 --- /dev/null +++ b/tests/TestSuite_vxlan_gpe_support_in_i40e.py @@ -0,0 +1,320 @@ +# BSD LICENSE +# +# Copyright(c) <2019> 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. + +Test VXLAN-GPE behaviour in DPDK. + +""" + +import utils +import os +import re +from pmd_output import PmdOutput +from scapy.utils import wrpcap, rdpcap +from scapy.layers.inet import Ether, IP, UDP from scapy.layers.l2=20 +import Dot1Q from vxlan import Vxlan from scapy.config import conf from=20 +test_case import TestCase from settings import FOLDERS + +# +# +# Test class. +# + +VXLAN_GPE_PORT =3D 4790 + + +class VxlanGpeTestConfig(object): + + """ + Module for config/create/transmit vxlan packet + """ + + def __init__(self, test_case, **kwargs): + self.test_case =3D test_case + self.init() + for name in kwargs: + setattr(self, name, kwargs[name]) + + def init(self): + self.packets_config() + + def packets_config(self): + """ + Default vxlan packet format + """ + self.pcap_file =3D '/root/vxlan_gpe.pcap' + self.outer_mac_dst =3D '11:22:33:44:55:66' + self.outer_ip_dst =3D '192.168.1.2' + self.outer_udp_dst =3D VXLAN_GPE_PORT + self.vni =3D 1 + self.inner_mac_dst =3D '00:00:20:00:00:01' + self.inner_vlan =3D 'N/A' + self.inner_ip_dst =3D '192.168.2.2' + self.payload_size =3D 18 + + def create_pcap(self): + """ + Create pcap file and copy it to tester + """ + self.inner_payload =3D ("X" * self.payload_size) + + if self.inner_vlan !=3D 'N/A': + inner =3D Ether() / Dot1Q() / IP() / UDP() / self.inner_payloa= d + inner[Dot1Q].vlan =3D self.inner_vlan + else: + inner =3D Ether() / IP() / UDP() / self.inner_payload + + inner[IP().name].dst =3D self.inner_ip_dst + + inner[Ether].dst =3D self.inner_mac_dst + + outer =3D Ether() / IP() / UDP() + + outer[Ether].dst =3D self.outer_mac_dst + + outer[IP().name].dst =3D self.outer_ip_dst + + outer[UDP].dport =3D self.outer_udp_dst + + if self.outer_udp_dst =3D=3D VXLAN_GPE_PORT: + self.pkt =3D outer / Vxlan(vni=3Dself.vni) / inner + else: + self.pkt =3D outer / ("X" * self.payload_size) + + wrpcap(self.pcap_file, self.pkt) + + def send_pcap(self, iface=3D""): + """ + Send vxlan pcap file by iface + """ + # load vxlan module to scapy + cwd =3D os.getcwd() + dir_vxlan_module =3D cwd + r'/' + FOLDERS['Depends'] + self.test_case.tester.scapy_append("sys.path.append('%s')" % dir_v= xlan_module) + self.test_case.tester.scapy_append("from vxlan import Vxlan") + self.test_case.tester.scapy_append( + 'pcap =3D rdpcap("%s")' % self.pcap_file) + self.test_case.tester.scapy_append( + 'sendp(pcap, iface=3D"%s")' % iface) + self.test_case.tester.scapy_execute() + + +class TestVxlanGpeSupportInI40e(TestCase): + + def set_up_all(self): + """ + vxlan Prerequisites + """ + # this feature only enable in FVL now + if self.nic not in ["fortville_eagle", "fortville_spirit", "fortvi= lle_spirit_single", "fortville_25g"]: + self.verify(False, "%s not support this vxlan-gpe" % self.nic) + # Based on h/w type, choose how many ports to use + ports =3D self.dut.get_ports() + + # Verify that enough ports are available + self.verify(len(ports) >=3D 2, "Insufficient ports for testing") + global valports + valports =3D [_ for _ in ports if self.tester.get_local_port(_)=20 + !=3D -1] + + self.portMask =3D utils.create_mask(valports[:2]) + + # Verify that enough threads are available + netdev =3D self.dut.ports_info[ports[0]]['port'] + self.ports_socket =3D netdev.socket + cores =3D self.dut.get_core_list("all", socket=3Dself.ports_socket= ) + self.verify(cores is not None, "Insufficient cores for speed testi= ng") + self.coremask =3D utils.create_mask(cores) + + # start testpmd + self.pmdout =3D PmdOutput(self.dut) + + # init port config + self.dut_port =3D valports[0] + self.dut_port_mac =3D self.dut.get_mac_address(self.dut_port) + tester_port =3D self.tester.get_local_port(self.dut_port) + self.tester_iface =3D self.tester.get_interface(tester_port) + + def set_up(self): + """ + Run before each test case. + """ + pass + + def filter_and_check(self, filter_type=3D"imac-ivlan", queue_id=3D3, + vlan=3DFalse, remove=3DFalse): + """ + send vxlan packet and check whether receive packet in assigned que= ue + """ + if vlan is not False: + config =3D VxlanGpeTestConfig(self, inner_vlan=3Dvlan) + vlan_id =3D vlan + else: + config =3D VxlanGpeTestConfig(self) + vlan_id =3D 1 + + # now cloud filter will default enable L2 mac filter, so dst mac m= ust + # be same + config.outer_mac_dst =3D self.dut_port_mac + + args =3D [self.dut_port, config.outer_mac_dst, config.inner_mac_ds= t, + config.inner_ip_dst, vlan_id, filter_type, config.vni, + queue_id] + + self.tunnel_filter_add(*args) + + # invalid case request to remove tunnel filter + if remove is True: + queue_id =3D 0 + args =3D [self.dut_port, config.outer_mac_dst, config.inner_ma= c_dst, + config.inner_ip_dst, vlan_id, filter_type, config.vni, + queue_id] + self.tunnel_filter_del(*args) + + # send vxlan packet + config.create_pcap() + self.dut.send_expect("start", "testpmd>", 10) + config.send_pcap(self.tester_iface) + out =3D self.dut.get_session_output(timeout=3D2) + + queue =3D -1 + pattern =3D re.compile("- Receive queue=3D0x(\d)") + m =3D pattern.search(out) + if m is not None: + queue =3D m.group(1) + + # verify received in expected queue + self.verify(queue_id =3D=3D int(queue), "invalid receive queue") + + self.dut.send_expect("stop", "testpmd>", 10) + + def test_vxlan_gpe_ipv4_detect(self): + self.pmdout.start_testpmd('all') + self.pmdout.execute_cmd('set fwd io') + self.pmdout.execute_cmd('set verbose 1') + # add VXLAN-GPE packet type + self.pmdout.execute_cmd('port config 0 udp_tunnel_port add vxlan-g= pe %s' % VXLAN_GPE_PORT) + self.pmdout.execute_cmd('start') + mac =3D self.pmdout.get_port_mac(0) + # send one VXLAN-GPE type packet + packet =3D 'sendp([Ether(dst=3D"%s")/IP(src=3D"18.0.0.1")/UDP(dpor= t=3D%d, sport=3D43)/' % (mac, VXLAN_GPE_PORT) + \ + 'VXLAN(flags=3D12)/IP(src=3D"10.0.0.1")], iface=3D"%s", c= ount=3D1)' % self.tester_iface + self.tester.scapy_append(packet) + self.tester.scapy_execute() + out =3D self.dut.get_session_output(timeout=3D5) + print out + self.verify('L3_IPV4_EXT_UNKNOWN' in out and '%s' %=20 + VXLAN_GPE_PORT in out, 'no detect vxlan-gpe packet') + + # delete the VXLAN-GPE packet type, testpmd should treat the packe= t as a normal UDP packet + self.pmdout.execute_cmd('port config 0 udp_tunnel_port rm vxlan-gp= e %s' % VXLAN_GPE_PORT) + self.tester.scapy_append(packet) + self.tester.scapy_execute() + out =3D self.dut.get_session_output(timeout=3D5) + print out + self.pmdout.execute_cmd('quit', '#') + self.verify('L3_IPV4_EXT_UNKNOWN' in out and '%s' %=20 + VXLAN_GPE_PORT not in out, 'no detect vxlan-gpe packet') + + def test_tunnel_filter_vxlan_gpe(self): + """ + verify tunnel filter feature + """ + pmd_temp =3D "./%(TARGET)s/app/testpmd -c %(COREMASK)s -n " + \ + "%(CHANNEL)d -- -i --disable-rss --rxq=3D4 --txq=3D4" + \ + " --nb-cores=3D4 --portmask=3D%(PORT)s" + pmd_cmd =3D pmd_temp % {'TARGET': self.target, + 'COREMASK': self.coremask, + 'CHANNEL': self.dut.get_memory_channels(), + 'PORT': self.portMask} + self.dut.send_expect(pmd_cmd, "testpmd>", 30) + + self.dut.send_expect("set fwd rxonly", "testpmd>", 10) + self.dut.send_expect("set verbose 1", "testpmd>", 10) + self.enable_vxlan(self.dut_port) + + # check inner mac + inner vlan filter can work + self.filter_and_check(filter_type=3D"imac-ivlan", vlan=3D1) + # check inner mac + inner vlan + tunnel id filter can work + self.filter_and_check(filter_type=3D"imac-ivlan-tenid", vlan=3D1) + # check inner mac + tunnel id filter can work + self.filter_and_check(filter_type=3D"imac-tenid") + # check inner mac filter can work + self.filter_and_check(filter_type=3D"imac") + # check outer mac + inner mac + tunnel id filter can work + self.filter_and_check(filter_type=3D"omac-imac-tenid") + # iip not supported by now + self.filter_and_check(filter_type=3D"iip") + + self.dut.send_expect("quit", "#", 10) + + def enable_vxlan(self, port): + self.dut.send_expect("rx_vxlan_port add %d %d" + % (VXLAN_GPE_PORT, port), + "testpmd>", 10) + + def tunnel_filter_add(self, *args): + # tunnel_filter add port_id outer_mac inner_mac ip inner_vlan + # tunnel_type(vxlan) + # filter_type + # (imac-ivlan|imac-ivlan-tenid|imac-tenid|imac|omac-imac-tenid|iip= ) + # tenant_id queue_num + out =3D self.dut.send_expect("tunnel_filter add %d " % args[0] + + "%s %s %s " % (args[1], args[2], args[3= ]) + + "%d vxlan-gpe %s " % (args[4], args[5])= + + "%d %d" % (args[6], args[7]), + "testpmd>", 10) + self.verify("Bad arguments" not in out, "Failed to add tunnel filt= er") + self.verify("error" not in out, "Failed to add tunnel filter") + + def tunnel_filter_del(self, *args): + out =3D self.dut.send_expect("tunnel_filter rm %d " % args[0] + + "%s %s %s " % (args[1], args[2], args[3= ]) + + "%d vxlan-gpe %s " % (args[4], args[5])= + + "%d %d" % (args[6], args[7]), + "testpmd>", 10) + self.verify("Bad arguments" not in out, + "Failed to remove tunnel filter") + self.verify("error" not in out, "Failed to remove tunnel=20 + filter") + + def tear_down(self): + """ + Run after each test case. + """ + self.dut.kill_all() + + def tear_down_all(self): + """ + Run after each test suite. + """ + pass -- 2.17.1