From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by dpdk.org (Postfix) with ESMTP id 0E58C5A45 for ; Mon, 25 May 2015 11:14:58 +0200 (CEST) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga101.fm.intel.com with ESMTP; 25 May 2015 02:14:57 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.13,491,1427785200"; d="scan'208";a="731252245" Received: from pgsmsx101.gar.corp.intel.com ([10.221.44.78]) by fmsmga002.fm.intel.com with ESMTP; 25 May 2015 02:14:56 -0700 Received: from shsmsx103.ccr.corp.intel.com (10.239.4.69) by PGSMSX101.gar.corp.intel.com (10.221.44.78) with Microsoft SMTP Server (TLS) id 14.3.224.2; Mon, 25 May 2015 17:14:56 +0800 Received: from shsmsx104.ccr.corp.intel.com ([169.254.5.94]) by SHSMSX103.ccr.corp.intel.com ([169.254.4.23]) with mapi id 14.03.0224.002; Mon, 25 May 2015 17:14:55 +0800 From: "Jiajia, SunX" To: "Qiu, Michael" , "dts@dpdk.org" Thread-Topic: [dts] [PATCH v2 05/19] Add a module to instantiate the VM Thread-Index: AQHQlrGB1EgmBGknOU29zeQhHNJgkZ2MaAbQ Date: Mon, 25 May 2015 09:14:53 +0000 Message-ID: References: <1432285452-14286-1-git-send-email-sunx.jiajia@intel.com> <1432285452-14286-6-git-send-email-sunx.jiajia@intel.com> <533710CFB86FA344BFBF2D6802E6028604680F0A@SHSMSX101.ccr.corp.intel.com> In-Reply-To: <533710CFB86FA344BFBF2D6802E6028604680F0A@SHSMSX101.ccr.corp.intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-cr-hashedpuzzle: A0xf CByt CKxY CT0D CXlG CpZs EIhG E5Vt GF0K Hpom IVd5 Jpbq Juru KD3h KUjI L6fj; 1; ZAB0AHMAQABkAHAAZABrAC4AbwByAGcA; Sosha1_v1; 7; {05146D5F-BA68-441E-9BF5-657A2F7A9205}; cwB1AG4AeAAuAGoAaQBhAGoAaQBhAEAAaQBuAHQAZQBsAC4AYwBvAG0A; Mon, 25 May 2015 09:14:51 GMT; UgBFADoAIABbAGQAdABzAF0AIABbAFAAQQBUAEMASAAgAHYAMgAgADAANQAvADEAOQBdACAAQQBkAGQAIABhACAAbQBvAGQAdQBsAGUAIAB0AG8AIABpAG4AcwB0AGEAbgB0AGkAYQB0AGUAIAB0AGgAZQAgAFYATQA= x-cr-puzzleid: {05146D5F-BA68-441E-9BF5-657A2F7A9205} 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 09:14:59 -0000 Hi Michael, Please see the comments below. > -----Original Message----- > From: Qiu, Michael > Sent: Monday, May 25, 2015 2:11 PM > To: Jiajia, SunX; dts@dpdk.org > Subject: Re: [dts] [PATCH v2 05/19] Add a module to instantiate the VM >=20 > On 5/22/2015 5:04 PM, Jiajia, Sun wrote: > > From: sjiajiax > > > > Added module: virt_dut.py > > > > Signed-off-by: sjiajiax > > --- > > framework/virt_dut.py | 202 > ++++++++++++++++++++++++++++++++++++++++++++++++++ > > 1 file changed, 202 insertions(+) > > create mode 100644 framework/virt_dut.py > > > > diff --git a/framework/virt_dut.py b/framework/virt_dut.py > > new file mode 100644 > > index 0000000..273b29e > > --- /dev/null > > +++ b/framework/virt_dut.py > > @@ -0,0 +1,202 @@ > > +# 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 > 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. > > + > > +import os > > +import re > > +import time > > +import dts > > +import settings > > +from config import PortConf > > +from settings import NICS, LOG_NAME_SEP > > +from ssh_connection import SSHConnection > > +from project_dpdk import DPDKdut > > +from dut import Dut > > +from net_device import NetDevice > > +from logger import getLogger > > + > > + > > +class VirtDut(DPDKdut): > > + > > + """ > > + A connection to the CRB under test. > > + This class sends commands to the CRB and validates the responses. > It is > > + implemented using either ssh for linuxapp or the terminal server > for > > + baremetal. > > + All operations are in fact delegated to an instance of either > CRBLinuxApp > > + or CRBBareMetal. > > + """ > > + > > + def __init__(self, crb, serializer, vm_name, suite): > > + super(Dut, self).__init__(crb, serializer) > > + self.vm_ip =3D self.get_ip_address() > > + self.NAME =3D 'virtdut' + LOG_NAME_SEP + '%s' % self.vm_ip > > + # load port config from suite cfg > > + self.suite =3D suite > > + self.logger =3D getLogger(self.NAME) > > + self.logger.config_execution('vmdut') > > + self.session =3D SSHConnection(self.vm_ip, self.NAME, > > + self.get_password()) > > + self.session.init_log(self.logger) > > + > > + # if redirect ssh port, there's only one session enabled > > + self.alt_session =3D SSHConnection(self.vm_ip, self.NAME + > '_alt', > > + self.get_password()) > > + self.alt_session.init_log(self.logger) > > + > > + self.number_of_cores =3D 0 > > + self.tester =3D None > > + self.cores =3D [] > > + self.architecture =3D None > > + self.ports_info =3D None > > + self.ports_map =3D [] > > + > > + def set_nic_type(self, nic_type): > > + """ > > + Set CRB NICS ready to validated. > > + """ > > + self.nic_type =3D nic_type > > + # vm_dut config will load from vm configuration file > > + > > + def load_portconf(self): > > + """ > > + Load port config for this virtual machine > > + """ > > + return > > + > > + def set_target(self, target): > > + """ > > + Set env variable, these have to be setup all the time. Some > tests > > + need to compile example apps by themselves and will fail > otherwise. > > + Set hugepage on DUT and install modules required by DPDK. > > + Configure default ixgbe PMD function. > > + """ > > + self.set_toolchain(target) > > + > > + # set env variable > > + # These have to be setup all the time. Some tests need to > compile > > + # example apps by themselves and will fail otherwise. > > + self.send_expect("export RTE_TARGET=3D" + target, "#") > > + self.send_expect("export RTE_SDK=3D`pwd`", "#") >=20 > Could "RTE_SDK" be configed in config file? Now it cannot be configured in the configure file, but I think if it is needed, doing some changes will be okay. >=20 > > + > > + if not self.skip_setup: > > + self.build_install_dpdk(target) > > + > > + self.setup_memory(hugepages=3D512) > > + self.setup_modules(target) > > + > > + self.bind_interfaces_linux('igb_uio') > > + > > + def prerequisites(self, pkgName, patch): > > + """ > > + Prerequest function should be called before execute any test > case. > > + Will call function to scan all lcore's information which on > DUT. > > + Then call pci scan function to collect nic device > information. > > + At last setup DUT' environment for validation. > > + """ > > + self.prepare_package(pkgName, patch) > > + > > + self.send_expect("cd %s" % self.base_dir, "# ") > > + self.host_session.send_expect("cd %s" % self.base_dir, "# ") > > + self.send_expect("alias ls=3D'ls --color=3Dnone'", "#") > > + > > + self.init_core_list() > > + self.pci_devices_information() > > + > > + # scan ports before restore interface > > + self.scan_ports() > > + # restore dut ports to kernel > > + self.restore_interfaces() > > + # rescan ports after interface up > > + self.rescan_ports() > > + > > + # no need to rescan ports for guest os just bootup > > + # load port infor from config file > > + self.load_portconf() > > + > > + # enable tester port ipv6 > > + self.host_dut.enable_tester_ipv6() > > + self.mount_procfs() > > + # auto detect network topology > > + self.map_available_ports() > > + # disable tester port ipv6 > > + self.host_dut.disable_tester_ipv6() > > + > > + # print latest ports_info > > + for port_info in self.ports_info: > > + self.logger.info(port_info) > > + > > + def pci_devices_information(self): > > + self.pci_devices_information_uncached() > > + > > + def get_memory_channels(self): > > + """ > > + Virtual machine has no memory channel concept, so always > return 1 > > + """ > > + return 1 > > + > > + def check_ports_available(self, pci_bus, pci_id): > > + """ > > + Check that whether auto scanned ports ready to use > > + """ > > + pci_addr =3D "%s:%s" % (pci_bus, pci_id) > > + if pci_id =3D=3D "8086:100e": > > + return False >=20 > Why here return false? better to give some comments. >=20 > Also pci_id here should be pci_addr I think. Because the e1000 network is commonly the control port for tester, So it will be ignored defaultly. >=20 > > + return True > > + > > + def scan_ports(self): > > + """ > > + Scan ports information, for vm will always scan > > + """ > > + self.scan_ports_uncached() > > + > > + def scan_ports_uncached(self): > > + """ > > + Scan ports and collect port's pci id, mac adress, ipv6 > address. > > + """ > > + scan_ports_uncached =3D getattr( > > + self, 'scan_ports_uncached_%s' % self.get_os_type()) > > + return scan_ports_uncached() > > + > > + def map_available_ports(self): > > + """ > > + Load or generate network connection mapping list. > > + """ > > + self.map_available_ports_uncached() > > + self.logger.warning("DUT PORT MAP: " + str(self.ports_map)) > > + > > + def send_ping6(self, localPort, ipv6, mac=3D''): > > + """ > > + Send ping6 packet from local port with destination ipv6 > address. > > + """ > > + if self.ports_info[localPort]['type'] =3D=3D 'ixia': > > + pass > > + else: > > + return self.send_expect("ping6 -w 1 -c 1 -A -I %s %s" % > (self.ports_info[localPort]['intf'], ipv6), "# ", 10)