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 5EAE92BB3 for ; Wed, 7 Dec 2016 03:18:22 +0100 (CET) Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga104.fm.intel.com with ESMTP; 06 Dec 2016 18:18:21 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.33,310,1477983600"; d="scan'208";a="39808186" Received: from fmsmsx103.amr.corp.intel.com ([10.18.124.201]) by fmsmga006.fm.intel.com with ESMTP; 06 Dec 2016 18:18:21 -0800 Received: from fmsmsx116.amr.corp.intel.com (10.18.116.20) by FMSMSX103.amr.corp.intel.com (10.18.124.201) with Microsoft SMTP Server (TLS) id 14.3.248.2; Tue, 6 Dec 2016 18:18:21 -0800 Received: from shsmsx104.ccr.corp.intel.com (10.239.4.70) by fmsmsx116.amr.corp.intel.com (10.18.116.20) with Microsoft SMTP Server (TLS) id 14.3.248.2; Tue, 6 Dec 2016 18:18:20 -0800 Received: from shsmsx103.ccr.corp.intel.com ([169.254.4.96]) by SHSMSX104.ccr.corp.intel.com ([169.254.5.142]) with mapi id 14.03.0248.002; Wed, 7 Dec 2016 10:18:18 +0800 From: "Liu, Yong" To: "Peng, Yuan" , "dts@dpdk.org" CC: "Peng, Yuan" Thread-Topic: [dts] [PATCH] tests: add TestSuite_veb_switch.py Thread-Index: AQHST5NYt6WfDjIykkC6AyRXxd6GSqD7urkg Date: Wed, 7 Dec 2016 02:18:17 +0000 Message-ID: <86228AFD5BCD8E4EBFD2B90117B5E81E6033BB81@SHSMSX103.ccr.corp.intel.com> References: <1481009779-24005-1-git-send-email-yuan.peng@intel.com> <1481009779-24005-4-git-send-email-yuan.peng@intel.com> In-Reply-To: <1481009779-24005-4-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: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiNTA3MTg1MzQtZDQ2Ni00NWNmLTlhM2MtMWYzMGQzNDRkMjBkIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX0lDIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE1LjkuNi42IiwiVHJ1c3RlZExhYmVsSGFzaCI6IkpaKzFtaDNYQUJ1QzhwSTg0U09kRUVobFozUnd0dWxuQW9uNnNRYnJxaGc9In0= x-ctpclassification: CTP_IC 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_veb_switch.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: Wed, 07 Dec 2016 02:18:22 -0000 Yuan, some comments below. > -----Original Message----- > From: dts [mailto:dts-bounces@dpdk.org] On Behalf Of peng,yuan > Sent: Tuesday, December 06, 2016 3:36 PM > To: dts@dpdk.org > Cc: Peng, Yuan > Subject: [dts] [PATCH] tests: add TestSuite_veb_switch.py >=20 > From: Peng Yuan >=20 > Signed-off-by: Peng Yuan >=20 > diff --git a/tests/TestSuite_veb_switch.py b/tests/TestSuite_veb_switch.p= y > new file mode 100644 > index 0000000..3492579 > --- /dev/null > +++ b/tests/TestSuite_veb_switch.py > @@ -0,0 +1,523 @@ > +# BSD LICENSE > +# > +# Copyright(c) 2010-2014 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. > + > +Test VEB Switch and floating VEB Features by Poll Mode Drivers. > +""" > + > +import re > +import time > + > +from virt_dut import VirtDut > +from project_dpdk import DPDKdut > +from dut import Dut > +from net_device import GetNicObj > +from net_device import RemoveNicObj There's no need to import those two functions. > +from test_case import TestCase > +from pmd_output import PmdOutput > +from settings import HEADER_SIZE > +from packet import Packet > +from utils import RED > + > + > + > + def send_packet(self, vf_mac, itf, tran_type=3D""): > + """ > + Send 1 packet > + """ > + self.tester.scapy_foreground() > + self.tester.scapy_append('sys.path.append("./")') > + self.dut.send_expect("start", "testpmd>") > + mac =3D self.dut.get_mac_address(0) > + > + if tran_type =3D=3D "vlan": > + packet =3D r'sendp([Ether(dst=3D"%s", > src=3Dget_if_hwaddr("%s"))/Dot1Q(vlan=3D1)/IP(src=3D"192.168.0.1", > dst=3D"192.168.0.2")], iface=3D"%s")' % (vf_mac, itf, itf) > + self.tester.scapy_append(packet) > + self.tester.scapy_execute() > + time.sleep(.5) > + else: > + packet =3D r'sendp([Ether(dst=3D"%s", > src=3Dget_if_hwaddr("%s"))/IP(src=3D"192.168.0.1", dst=3D"192.168.0.2")], > iface=3D"%s")' % (vf_mac, itf, itf) > + self.tester.scapy_append(packet) > + self.tester.scapy_execute() > + time.sleep(.5) > + Recommend to use packet module function replace of scapy command. It will b= e helpful in later efficiency improvement. > + def set_up(self): > + """ > + This is to clear up environment before the case run. > + """ > + self.dut.kill_all() > + > + def setup_1pf_ddriver_2vf_env(self, driver=3D'default'): > + self.dut.generate_sriov_vfs_by_port(self.used_dut_port, 2, > driver=3D'igb_uio') > + self.sriov_vfs_port =3D > self.dut.ports_info[self.used_dut_port]['vfs_port'] > + self.dut.send_expect("./tools/dpdk-devbind.py -s", "# ", 3) Remove useless code here, it only waste the time and can't help on anything= .=20 > + try: > + > + for port in self.sriov_vfs_port: > + self.dut.send_expect("./tools/dpdk-devbind.py -b > igb_uio %s" % (port.pci), "# ", 3) Use self.drivername replace of igb_uio, igb_uio may not be the driver requi= red to test. There're other choices like vfio-pci. > + self.dut.send_expect("./tools/dpdk-devbind.py -s", "# ", 3) Remove useless code here, it only waste the time and can't help on anything= . > + time.sleep(1) > + for port_id in self.dut_ports: > + if port_id =3D=3D self.used_dut_port: > + continue > + port =3D self.dut.ports_info[port_id]['port'] > + port.bind_driver() > + Why need to bind other PF device to default kernel driver? If only want to use some devices, you can use whitelist parameter.=20 > + self.setup_1pf_ddriver_2vf_env_flag =3D 1 > + except Exception as e: > + self.destroy_1pf_ddriver_2vf_env() > + raise Exception(e) > + > + def destroy_1pf_ddriver_2vf_env(self): > + self.session_third.send_expect("quit", "# ") > + time.sleep(2) > + self.session_secondary.send_expect("quit", "# ") > + time.sleep(2) > + self.dut.send_expect("quit", "# ") > + time.sleep(2) > + self.dut.destroy_sriov_vfs_by_port(self.used_dut_port) > + port =3D self.dut.ports_info[self.used_dut_port]['port'] > + port.bind_driver() > + self.setup_1pf_ddriver_2vf_env_flag =3D 0 > + > + def setup_1pf_ddriver_1vf_env(self, driver=3D'default'): Most part of this function look like function setup_1pf_kdriver_2vf_env, pl= ease combine these functions and just use parameter to distinguish the diff= erence. > + > + def test_VEB_switching_inter_vfs(self): > + """ > + Kernel PF, then create 2VFs. VFs running dpdk testpmd, send > traffic to VF1, and set the packet's DEST MAC to VF2, check if VF2 can > receive the packets. Check Inter VF-VF MAC switch. > + """ > + self.setup_1pf_kdriver_2vf_env(driver=3D'') > + self.dut.send_expect("./x86_64-native-linuxapp-gcc/app/testpmd -= c > 0xf -n 4 --socket-mem 1024,1024 -w %s --file-prefix=3Dtest1 -- -i --crc- > strip --eth-peer=3D0,%s" % (self.sriov_vfs_port[0].pci, self.vf1_mac), > "testpmd>", 120) Please not hard code DPDK target, in test suite you can use self.target. > + > + def tear_down_all(self): > + """ > + Run after each test suite. > + """ > + self.dut.kill_all() > + self.dut.close_session(self.session_secondary) > + self.dut.close_session(self.session_third) > + # Marvin recommended that all the dut ports should be bound to > igb_uio. > + for port_id in self.dut_ports: > + port =3D self.dut.ports_info[port_id]['port'] > + port.bind_driver(driver=3D'igb_uio') > + Only need to used port back. > + pass > -- > 2.5.0