From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by dpdk.org (Postfix) with ESMTP id 2A7BA3237 for ; Tue, 14 Jun 2016 04:41:34 +0200 (CEST) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga104.fm.intel.com with ESMTP; 13 Jun 2016 19:41:32 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.26,469,1459839600"; d="scan'208";a="975036339" Received: from fmsmsx104.amr.corp.intel.com ([10.18.124.202]) by orsmga001.jf.intel.com with ESMTP; 13 Jun 2016 19:41:33 -0700 Received: from fmsmsx156.amr.corp.intel.com (10.18.116.74) by fmsmsx104.amr.corp.intel.com (10.18.124.202) with Microsoft SMTP Server (TLS) id 14.3.248.2; Mon, 13 Jun 2016 19:41:32 -0700 Received: from shsmsx151.ccr.corp.intel.com (10.239.6.50) by fmsmsx156.amr.corp.intel.com (10.18.116.74) with Microsoft SMTP Server (TLS) id 14.3.248.2; Mon, 13 Jun 2016 19:41:31 -0700 Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.147]) by SHSMSX151.ccr.corp.intel.com ([169.254.3.230]) with mapi id 14.03.0248.002; Tue, 14 Jun 2016 10:41:30 +0800 From: "Tu, LijuanX A" To: "Liu, Yong" , "Pei, Yulong" , "dts@dpdk.org" Thread-Topic: [dts] [PATCH]tests: add VLAN ethertype script Thread-Index: AQHRxVHm0/ySexJfGE6LHMBFqFqfsp/oKnuQgAAT5qA= Date: Tue, 14 Jun 2016 02:41:29 +0000 Message-ID: <38D041F150D4184C8114E499040E6234072C9B55@shsmsx102.ccr.corp.intel.com> References: <1465808081-14293-1-git-send-email-lijuanx.a.tu@intel.com> <86228AFD5BCD8E4EBFD2B90117B5E81E2223A74B@SHSMSX103.ccr.corp.intel.com> In-Reply-To: <86228AFD5BCD8E4EBFD2B90117B5E81E2223A74B@SHSMSX103.ccr.corp.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 VLAN ethertype script X-BeenThere: dts@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: test suite reviews and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 14 Jun 2016 02:41:34 -0000 Hi yong, > -----Original Message----- > From: Liu, Yong > Sent: Tuesday, June 14, 2016 9:23 AM > To: Tu, LijuanX A; Pei, Yulong; dts@dpdk.org > Cc: Tu, LijuanX A > Subject: RE: [dts] [PATCH]tests: add VLAN ethertype script >=20 > Hi Lijuan, > Please check my comments below. >=20 > > -----Original Message----- > > From: dts [mailto:dts-bounces@dpdk.org] On Behalf Of Lijuan Tu > > Sent: Monday, June 13, 2016 4:55 PM > > To: Pei, Yulong; dts@dpdk.org > > Cc: Tu, LijuanX A > > Subject: [dts] [PATCH]tests: add VLAN ethertype script > > > > Signed-off-by: Lijuan Tu > > --- > > tests/TestSuite_vlan_ethertype_config.py | 293 > > +++++++++++++++++++++++++++++++ > > 1 file changed, 293 insertions(+) > > create mode 100644 tests/TestSuite_vlan_ethertype_config.py > > > > diff --git a/tests/TestSuite_vlan_ethertype_config.py > > b/tests/TestSuite_vlan_ethertype_config.py > > new file mode 100644 > > index 0000000..99d7752 > > --- /dev/null > > +++ b/tests/TestSuite_vlan_ethertype_config.py > > @@ -0,0 +1,293 @@ > > +# BSD LICENSE > > +# > > +# Copyright(c) 2010-2015 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 copyrig= ht > > +# notice, this list of conditions and the following disclaimer in > > +# the documentation and/or other materials provided with the > > +# distribution. > > +# * Neither the name of Intel Corporation nor the names of its > > +# contributors may be used to endorse or promote products derived > > +# from this software without specific prior written permission. > > +# > > +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS > > +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT # > > +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR > > +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE > > +COPYRIGHT # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, > > +INCIDENTAL, # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES > > +(INCLUDING, BUT NOT # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR > > +SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) > > +HOWEVER CAUSED AND ON ANY # THEORY OF LIABILITY, WHETHER IN CONTRACT, > > +STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) > > +ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED= OF > THE POSSIBILITY OF SUCH DAMAGE. > > + > > + > > +""" > > +DPDK Test suite. > > + > > +Test the support of VLAN Offload Features by Poll Mode Drivers. > > + > > +""" > > + > > +import dts > > +import time > > + > > + > > +from test_case import TestCase > > +from pmd_output import PmdOutput > > +from packet import Packet, sniff_packets, load_sniff_packets from > > +scapy.utils import struct, socket, wrpcap, rdpcap #from scapy.all > > +import * class TestVlan(TestCase): > > + > > + def set_up_all(self): > > + """ > > + Run at the start of each test suite. > > + > > + > > + Vlan Prerequistites > > + """ > > + global dutRxPortId > > + global dutTxPortId > > + > > + # 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") > > + > > + valports =3D [_ for _ in ports if self.tester.get_local_port(= _) > > + !=3D > > -1] > > + dutRxPortId =3D valports[0] > > + dutTxPortId =3D valports[1] > > + port =3D self.tester.get_local_port(dutTxPortId) > > + self.rxItf =3D self.tester.get_interface(port) > > + > > + self.portmask =3D dts.create_mask(valports[:2]) > > + >=20 >=20 > You can strip packet just by function load_sniff_packets(inst). > This function will return packet object and easy to retrieve different > layers' content. > There's no need to start and stop tcpdump and then analyze the pcap file= . [lijuan] If I change tpid , scapy can't identify vlan packets, it only can = identify tpid=3D"8100" So , I use tcpdump to get packets ,and identify vlan from hex string that p= rint by tcpdump. >=20 > > + > > + def start_tcpdump(self, rxItf): > > + > > + self.tester.alt_session.send_expect("rm -rf > > /tmp/getPkgByTcpdump_%s.cap" % rxItf, "#") > > + self.tester.alt_session.send_expect("tcpdump -i %s -w > > /tmp/getPkgByTcpdump_%s.cap" % (rxItf, rxItf), "listening on") > > + > > + def get_tcpdump_package(self, rxItf): > > + out =3D self.tester.alt_session.send_expect("^C", "#") > > + out =3D self.tester.send_expect("tcpdump -nn -e -v -r > > /tmp/getPkgByTcpdump_%s.cap 2> /dev/null" % rxItf, "#") > > + return out > > + > > + def vlan_send_packet(self, vid, tpid=3D"8100", num=3D1): > > + """ > > + Send $num of packet to portid, if vid is -1, it means send > > pakcage not include vlan id. > > + """ > > + # The package stream : testTxPort->dutRxPort->dutTxport- > > >testRxPort > > + port =3D self.tester.get_local_port(dutRxPortId) > > + self.txItf =3D self.tester.get_interface(port) > > + self.smac =3D self.tester.get_mac(port) > > + > > + port =3D self.tester.get_local_port(dutTxPortId) > > + self.rxItf =3D self.tester.get_interface(port) > > + > > + # the package dect mac must is dut tx port id when the port > > promisc is off > > + self.dmac =3D self.dut.get_mac_address(dutRxPortId) > > + > > + self.inst =3D sniff_packets(self.rxItf) > > + # FIXME send a burst with only num packet > > + if vid =3D=3D -1: > > + pkt =3D Packet(pkt_type=3D'UDP') > > + pkt.config_layer('ether', {'dst': self.dmac, 'src': > > self.smac}) > > + else: > > + pkt =3D Packet(pkt_type=3D'VLAN_UDP') > > + pkt.config_layer('ether', {'dst': self.dmac, 'src': > > self.smac}) > > + pkt.config_layer('vlan', {'vlan': vid}) > > + if tpid !=3D "8100": > > + self.tpid_ori_file =3D "/tmp/tpid_ori.pcap" > > + self.tpid_new_file =3D "/tmp/tpid_new.pcap" > > + pkt.pktgen.write_pcap("%s" % self.tpid_ori_file) > > + fmt =3D '1/1 "%02x"' > > + out =3D self.tester.send_expect("hexdump -ve '%s' '%s= ' > > + |sed > > 's/8100/%s/' |xxd -r -p > '%s'" % (fmt, self.tpid_ori_file, tpid, > > self.tpid_new_file),"# ") > > + pkt.pktgen.pkt =3D pkt.pktgen.read_pcap("%s" % > > self.tpid_new_file) > > + > > + pkt.send_pkt(tx_port=3Dself.txItf) > > + > > + def set_up(self): > > + """ > > + Run before each test case. > > + """ > > + self.vlan =3D 51 > > + self.tpid =3D "8100" > > + self.pmdout =3D PmdOutput(self.dut) > > + self.pmdout.start_testpmd("Default", "--portmask=3D%s" % > > self.portmask) > > + self.dut.send_expect("vlan set outer tpid 0x%s %s" % > > + (self.tpid, > > dutRxPortId), "testpmd> ") > > + > > + def test_vlan_change_tpid(self): > > + """ > > + Test Case 1: change VLAN TPID > > + """ > > + if self.kdriver =3D=3D "fm10k": > > + print dts.RED("fm10k not support this case\n") > > + return >=20 > FM10k totally not support tpid, I think you can add the information to t= he > check excel file. [lijuan] I will remove this judgment >=20 > > + self.dut.send_expect("set fwd rxonly", "testpmd> ") > > + self.dut.send_expect("set verbose 1", "testpmd> ") > > + self.dut.send_expect("start", "testpmd> ") > > + self.dut.send_expect("vlan set filter off %s" % dutRxPortId, > > "testpmd> ") > > + self.dut.send_expect("vlan set strip on %s" % dutRxPortId, > > "testpmd> ", 20) > > + self.tpid =3D "a100" > > + self.dut.send_expect("vlan set outer tpid 0x%s %s" % > > + (self.tpid, > > dutRxPortId), "testpmd> ") > > + self.vlan_send_packet(self.vlan, self.tpid) > > + out =3D self.dut.get_session_output() > > + self.verify("PKT_RX_VLAN_PKT" in out, "Wrong vlan:" + > > + str(out)) > > + > > + def test_vlan_filter_on_off(self): > > + """ > > + Disable receipt of VLAN packets > > + """ > > + self.dut.send_expect("set fwd mac", "testpmd> ") > > + self.dut.send_expect("start", "testpmd> ") > > + self.dut.send_expect("vlan set strip off %s" % dutRxPortId, > > "testpmd> ", 20) > > + # test vlan filter on > > + self.dut.send_expect("vlan set filter on %s" % dutRxPortId, > > "testpmd> ") > > + > > + self.start_tcpdump(self.rxItf) > > + self.vlan_send_packet(self.vlan, self.tpid) > > + out =3D self.get_tcpdump_package(self.rxItf) > > + self.verify(self.tpid not in out, "Wrong vlan:" + str(out)) > > + > > + # test vlan filter off > > + self.dut.send_expect("vlan set filter off %s" % dutRxPortId, > > "testpmd> ") > > + self.start_tcpdump(self.rxItf) > > + self.vlan_send_packet(self.vlan, self.tpid) > > + out =3D self.get_tcpdump_package(self.rxItf) > > + self.verify("%s" %self.tpid in out, "Wrong vlan:" + str(out)) > > + > > + def test_vlan_add_vlan_tag(self): > > + """ > > + test adding VLAN Tag Identifier with changing VLAN TPID > > + """ > > + self.dut.send_expect("set fwd mac", "testpmd> ") > > + self.dut.send_expect("vlan set filter on %s" % dutRxPortId, > > "testpmd> ") > > + self.dut.send_expect("rx_vlan add %d %s" % (self.vlan, > > dutRxPortId), "testpmd> ") > > + self.dut.send_expect("vlan set strip off %s" % dutRxPortId, > > "testpmd> ", 20) > > + self.dut.send_expect("start", "testpmd> ") > > + > > + self.tpid =3D "8100" > > + self.dut.send_expect("vlan set outer tpid 0x%s %s" % > > + (self.tpid, > > dutRxPortId), "testpmd> ") > > + self.start_tcpdump(self.rxItf) > > + self.vlan_send_packet(self.vlan, self.tpid) > > + out =3D self.get_tcpdump_package(self.rxItf) > > + > > + self.verify("%s" %self.vlan in out, "Vlan not found:" + str(o= ut)) > > + self.verify("%s" %self.tpid in out, "Wrong vlan:" + str(out)) > > + > > + self.tpid =3D "a100" > > + self.dut.send_expect("vlan set outer tpid 0x%s %s" % > > + (self.tpid, > > dutRxPortId), "testpmd> ") > > + self.start_tcpdump(self.rxItf) > > + self.vlan_send_packet(self.vlan, self.tpid) > > + out =3D self.get_tcpdump_package(self.rxItf) > > + self.verify("%s" %self.tpid in out, "Wrong vlan:" + str(out)) > > + self.verify("%x" %self.vlan in out, "Vlan not found:" + str(o= ut)) > > + self.dut.send_expect("rx_vlan rm %d %d" % (self.vlan, > > dutRxPortId), "testpmd> ", 30) > > + self.dut.send_expect("stop", "testpmd> ", 30) > > + > > + > > + def test_vlan_strip(self): > > + """ > > + Test Case 4: test VLAN header striping with changing VLAN TPI= D > > + """ > > + self.dut.send_expect("set fwd mac", "testpmd> ") > > + self.dut.send_expect("vlan set filter off %s" % dutRxPortId, > > "testpmd> ") > > + self.dut.send_expect("vlan set strip on %s" % dutRxPortId, > > "testpmd> ", 20) > > + self.dut.send_expect("start", "testpmd> ", 20) > > + self.start_tcpdump(self.rxItf) > > + self.vlan_send_packet(self.vlan, self.tpid) > > + out =3D self.get_tcpdump_package(self.rxItf) > > + self.verify(self.tpid not in out, "Wrong vlan:" + str(out)) > > + > > + self.tpid =3D "a100" > > + self.dut.send_expect("vlan set outer tpid 0x%s %s" % > > + (self.tpid, > > dutRxPortId), "testpmd> ") > > + self.start_tcpdump(self.rxItf) > > + self.vlan_send_packet(self.vlan, self.tpid) > > + out =3D self.get_tcpdump_package(self.rxItf) > > + self.verify(self.tpid not in out, "Wrong vlan:" + str(out)) > > + > > + self.dut.send_expect("vlan set strip off %s" % dutRxPortId, > > "testpmd> ", 20) > > + self.start_tcpdump(self.rxItf) > > + self.vlan_send_packet(self.vlan, self.tpid) > > + out =3D self.get_tcpdump_package(self.rxItf) > > + self.verify("%x" %self.vlan in out, "Vlan not found:" + > > + str(out)) > > + > > + def test_vlan_enable_vlan_insertion(self): > > + """ > > + test VLAN header inserting with changing VLAN TPID > > + """ > > + self.dut.send_expect("set fwd mac", "testpmd> ") > > + self.dut.send_expect("vlan set filter off %s" % dutRxPortId, > > "testpmd> ") > > + self.dut.send_expect("vlan set strip off %s" % dutRxPortId, > > "testpmd> ", 20) > > + self.dut.send_expect("start", "testpmd> ") > > + self.dut.send_expect("tx_vlan set %s %d" % (dutTxPortId, > > self.vlan), "testpmd> ") > > + > > + self.tpid =3D "8100" > > + self.dut.send_expect("vlan set outer tpid 0x%s %s" % > > + (self.tpid, > > dutRxPortId), "testpmd> ") > > + self.start_tcpdump(self.rxItf) > > + self.vlan_send_packet(-1) > > + out =3D self.get_tcpdump_package(self.rxItf) > > + self.verify(self.tpid in out, "Wrong vlan:" + str(out)) > > + self.verify("%s" % self.vlan in out, "Vlan not found:" + > > + str(out)) > > + > > + self.tpid =3D "a100" > > + self.dut.send_expect("vlan set outer tpid 0x%s %s" % > > + (self.tpid, > > dutRxPortId), "testpmd> ") > > + self.start_tcpdump(self.rxItf) > > + self.vlan_send_packet(-1) > > + out =3D self.get_tcpdump_package(self.rxItf) > > + self.verify(self.tpid in out, "Wrong vlan:" + str(out)) > > + self.verify("%x" % self.vlan in out, "Vlan not found:" + > > + str(out)) > > + > > + self.dut.send_expect("tx_vlan reset %s" % dutTxPortId, > > + "testpmd> > > ", 30) > > + self.start_tcpdump(self.rxItf) > > + self.vlan_send_packet(-1) > > + out =3D self.get_tcpdump_package(self.rxItf) > > + self.verify(self.tpid not in out, "Wrong vlan:" + str(out)) > > + > > + if self.kdriver =3D=3D "fm10k": > > + netobj =3D self.dut.ports_info[dutTxPortId]['port'] > > + # not delete vlan for self.vlan will used later > > + netobj.delete_txvlan(vlan_id =3D self.vlan) > > + > > + def _test_vlan_qinq_tpid(self): > > + """ > > + Test Case 6: Change S-Tag and C-Tag within QinQ > > + """ > > + self.dut.send_expect("vlan set qinq on %d" %dutTxPortId, > > + "testpmd> > > ", 20) > > + self.dut.send_expect("set verbose 1", "testpmd> ") > > + self.dut.send_expect("set fwd rxonly", "testpmd> ") > > + self.dut.send_expect("start", "testpmd> ") > > + self.dut.send_expect("rx_vlan add %d %s" % (self.vlan, > > dutRxPortId), "testpmd> ") > > + self.dut.send_expect("vlan set outer tpid 0x%s %s" % > > + (self.tpid, > > dutRxPortId), "testpmd> ") > > + self.dut.send_expect("vlan set filter off %s" % dutRxPortId, > > "testpmd> ") > > + self.dut.send_expect("vlan set strip off %s" % dutRxPortId, > > "testpmd> ", 20) > > + > > + > > + def tear_down(self): > > + """ > > + Run after each test case. > > + """ > > + self.dut.send_expect("stop", "testpmd> ", 30) > > + self.dut.send_expect("quit", "# ", 30) > > + pass > > + > > + def tear_down_all(self): > > + """ > > + Run after each test suite. > > + """ > > + self.dut.kill_all() > > + if self.kdriver =3D=3D "fm10k": > > + netobj =3D self.dut.ports_info[dutRxPortId]['port'] > > + netobj.delete_txvlan(vlan_id =3D self.vlan) > > + netobj.delete_vlan(vlan_id =3D self.vlan) > > -- > > 1.9.3