From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by dpdk.org (Postfix) with ESMTP id 4DDB99A92 for ; Mon, 25 May 2015 08:12:55 +0200 (CEST) Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga102.jf.intel.com with ESMTP; 24 May 2015 23:12:51 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.13,489,1427785200"; d="scan'208";a="497836163" Received: from pgsmsx107.gar.corp.intel.com ([10.221.44.105]) by FMSMGA003.fm.intel.com with ESMTP; 24 May 2015 23:12:50 -0700 Received: from kmsmsx154.gar.corp.intel.com (172.21.73.14) by PGSMSX107.gar.corp.intel.com (10.221.44.105) with Microsoft SMTP Server (TLS) id 14.3.224.2; Mon, 25 May 2015 14:10:34 +0800 Received: from shsmsx103.ccr.corp.intel.com (10.239.110.14) by KMSMSX154.gar.corp.intel.com (172.21.73.14) with Microsoft SMTP Server (TLS) id 14.3.224.2; Mon, 25 May 2015 14:10:33 +0800 Received: from shsmsx101.ccr.corp.intel.com ([169.254.1.120]) by SHSMSX103.ccr.corp.intel.com ([169.254.4.23]) with mapi id 14.03.0224.002; Mon, 25 May 2015 14:10:32 +0800 From: "Qiu, Michael" To: "Jiajia, SunX" , "dts@dpdk.org" Thread-Topic: [dts] [PATCH v2 05/19] Add a module to instantiate the VM Thread-Index: AQHQlG5Y94MyDweWsUuuhuMPNyQ7Xw== Date: Mon, 25 May 2015 06:10:31 +0000 Message-ID: <533710CFB86FA344BFBF2D6802E6028604680F0A@SHSMSX101.ccr.corp.intel.com> References: <1432285452-14286-1-git-send-email-sunx.jiajia@intel.com> <1432285452-14286-6-git-send-email-sunx.jiajia@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 v2 05/19] Add a module to instantiate the VM 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 May 2015 06:12:56 -0000 On 5/22/2015 5:04 PM, Jiajia, Sun wrote:=0A= > From: sjiajiax =0A= >=0A= > Added module: virt_dut.py=0A= >=0A= > Signed-off-by: sjiajiax =0A= > ---=0A= > framework/virt_dut.py | 202 ++++++++++++++++++++++++++++++++++++++++++++= ++++++=0A= > 1 file changed, 202 insertions(+)=0A= > create mode 100644 framework/virt_dut.py=0A= >=0A= > diff --git a/framework/virt_dut.py b/framework/virt_dut.py=0A= > new file mode 100644=0A= > index 0000000..273b29e=0A= > --- /dev/null=0A= > +++ b/framework/virt_dut.py=0A= > @@ -0,0 +1,202 @@=0A= > +# BSD LICENSE=0A= > +#=0A= > +# Copyright(c) 2010-2015 Intel Corporation. All rights reserved.=0A= > +# All rights reserved.=0A= > +#=0A= > +# Redistribution and use in source and binary forms, with or without=0A= > +# modification, are permitted provided that the following conditions=0A= > +# are met:=0A= > +#=0A= > +# * Redistributions of source code must retain the above copyright=0A= > +# notice, this list of conditions and the following disclaimer.=0A= > +# * Redistributions in binary form must reproduce the above copyright= =0A= > +# notice, this list of conditions and the following disclaimer in=0A= > +# the documentation and/or other materials provided with the=0A= > +# distribution.=0A= > +# * Neither the name of Intel Corporation nor the names of its=0A= > +# contributors may be used to endorse or promote products derived=0A= > +# from this software without specific prior written permission.=0A= > +#=0A= > +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS=0A= > +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT=0A= > +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR= =0A= > +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT= =0A= > +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,= =0A= > +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT=0A= > +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,= =0A= > +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY= =0A= > +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT=0A= > +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE= =0A= > +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.= =0A= > +=0A= > +import os=0A= > +import re=0A= > +import time=0A= > +import dts=0A= > +import settings=0A= > +from config import PortConf=0A= > +from settings import NICS, LOG_NAME_SEP=0A= > +from ssh_connection import SSHConnection=0A= > +from project_dpdk import DPDKdut=0A= > +from dut import Dut=0A= > +from net_device import NetDevice=0A= > +from logger import getLogger=0A= > +=0A= > +=0A= > +class VirtDut(DPDKdut):=0A= > +=0A= > + """=0A= > + A connection to the CRB under test.=0A= > + This class sends commands to the CRB and validates the responses. It= is=0A= > + implemented using either ssh for linuxapp or the terminal server for= =0A= > + baremetal.=0A= > + All operations are in fact delegated to an instance of either CRBLin= uxApp=0A= > + or CRBBareMetal.=0A= > + """=0A= > +=0A= > + def __init__(self, crb, serializer, vm_name, suite):=0A= > + super(Dut, self).__init__(crb, serializer)=0A= > + self.vm_ip =3D self.get_ip_address()=0A= > + self.NAME =3D 'virtdut' + LOG_NAME_SEP + '%s' % self.vm_ip=0A= > + # load port config from suite cfg=0A= > + self.suite =3D suite=0A= > + self.logger =3D getLogger(self.NAME)=0A= > + self.logger.config_execution('vmdut')=0A= > + self.session =3D SSHConnection(self.vm_ip, self.NAME,=0A= > + self.get_password())=0A= > + self.session.init_log(self.logger)=0A= > +=0A= > + # if redirect ssh port, there's only one session enabled=0A= > + self.alt_session =3D SSHConnection(self.vm_ip, self.NAME + '_alt= ',=0A= > + self.get_password())=0A= > + self.alt_session.init_log(self.logger)=0A= > +=0A= > + self.number_of_cores =3D 0=0A= > + self.tester =3D None=0A= > + self.cores =3D []=0A= > + self.architecture =3D None=0A= > + self.ports_info =3D None=0A= > + self.ports_map =3D []=0A= > +=0A= > + def set_nic_type(self, nic_type):=0A= > + """=0A= > + Set CRB NICS ready to validated.=0A= > + """=0A= > + self.nic_type =3D nic_type=0A= > + # vm_dut config will load from vm configuration file=0A= > +=0A= > + def load_portconf(self):=0A= > + """=0A= > + Load port config for this virtual machine=0A= > + """=0A= > + return=0A= > +=0A= > + def set_target(self, target):=0A= > + """=0A= > + Set env variable, these have to be setup all the time. Some test= s=0A= > + need to compile example apps by themselves and will fail otherwi= se.=0A= > + Set hugepage on DUT and install modules required by DPDK.=0A= > + Configure default ixgbe PMD function.=0A= > + """=0A= > + self.set_toolchain(target)=0A= > +=0A= > + # set env variable=0A= > + # These have to be setup all the time. Some tests need to compil= e=0A= > + # example apps by themselves and will fail otherwise.=0A= > + self.send_expect("export RTE_TARGET=3D" + target, "#")=0A= > + self.send_expect("export RTE_SDK=3D`pwd`", "#")=0A= =0A= Could "RTE_SDK" be configed in config file?=0A= =0A= > +=0A= > + if not self.skip_setup:=0A= > + self.build_install_dpdk(target)=0A= > +=0A= > + self.setup_memory(hugepages=3D512)=0A= > + self.setup_modules(target)=0A= > +=0A= > + self.bind_interfaces_linux('igb_uio')=0A= > +=0A= > + def prerequisites(self, pkgName, patch):=0A= > + """=0A= > + Prerequest function should be called before execute any test cas= e.=0A= > + Will call function to scan all lcore's information which on DUT.= =0A= > + Then call pci scan function to collect nic device information.= =0A= > + At last setup DUT' environment for validation.=0A= > + """=0A= > + self.prepare_package(pkgName, patch)=0A= > +=0A= > + self.send_expect("cd %s" % self.base_dir, "# ")=0A= > + self.host_session.send_expect("cd %s" % self.base_dir, "# ")=0A= > + self.send_expect("alias ls=3D'ls --color=3Dnone'", "#")=0A= > +=0A= > + self.init_core_list()=0A= > + self.pci_devices_information()=0A= > +=0A= > + # scan ports before restore interface=0A= > + self.scan_ports()=0A= > + # restore dut ports to kernel=0A= > + self.restore_interfaces()=0A= > + # rescan ports after interface up=0A= > + self.rescan_ports()=0A= > +=0A= > + # no need to rescan ports for guest os just bootup=0A= > + # load port infor from config file=0A= > + self.load_portconf()=0A= > +=0A= > + # enable tester port ipv6=0A= > + self.host_dut.enable_tester_ipv6()=0A= > + self.mount_procfs()=0A= > + # auto detect network topology=0A= > + self.map_available_ports()=0A= > + # disable tester port ipv6=0A= > + self.host_dut.disable_tester_ipv6()=0A= > +=0A= > + # print latest ports_info=0A= > + for port_info in self.ports_info:=0A= > + self.logger.info(port_info)=0A= > +=0A= > + def pci_devices_information(self):=0A= > + self.pci_devices_information_uncached()=0A= > +=0A= > + def get_memory_channels(self):=0A= > + """=0A= > + Virtual machine has no memory channel concept, so always return = 1=0A= > + """=0A= > + return 1=0A= > +=0A= > + def check_ports_available(self, pci_bus, pci_id):=0A= > + """=0A= > + Check that whether auto scanned ports ready to use=0A= > + """=0A= > + pci_addr =3D "%s:%s" % (pci_bus, pci_id)=0A= > + if pci_id =3D=3D "8086:100e":=0A= > + return False=0A= =0A= Why here return false? better to give some comments.=0A= =0A= Also pci_id here should be pci_addr I think.=0A= =0A= > + return True=0A= > +=0A= > + def scan_ports(self):=0A= > + """=0A= > + Scan ports information, for vm will always scan=0A= > + """=0A= > + self.scan_ports_uncached()=0A= > +=0A= > + def scan_ports_uncached(self):=0A= > + """=0A= > + Scan ports and collect port's pci id, mac adress, ipv6 address.= =0A= > + """=0A= > + scan_ports_uncached =3D getattr(=0A= > + self, 'scan_ports_uncached_%s' % self.get_os_type())=0A= > + return scan_ports_uncached()=0A= > +=0A= > + def map_available_ports(self):=0A= > + """=0A= > + Load or generate network connection mapping list.=0A= > + """=0A= > + self.map_available_ports_uncached()=0A= > + self.logger.warning("DUT PORT MAP: " + str(self.ports_map))=0A= > +=0A= > + def send_ping6(self, localPort, ipv6, mac=3D''):=0A= > + """=0A= > + Send ping6 packet from local port with destination ipv6 address.= =0A= > + """=0A= > + if self.ports_info[localPort]['type'] =3D=3D 'ixia':=0A= > + pass=0A= > + else:=0A= > + return self.send_expect("ping6 -w 1 -c 1 -A -I %s %s" % (sel= f.ports_info[localPort]['intf'], ipv6), "# ", 10)=0A= =0A=