From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by dpdk.org (Postfix) with ESMTP id 69308C34A for ; Fri, 22 May 2015 11:04:32 +0200 (CEST) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga102.fm.intel.com with ESMTP; 22 May 2015 02:04:31 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.13,474,1427785200"; d="scan'208";a="698791767" Received: from shvmail01.sh.intel.com ([10.239.29.42]) by orsmga001.jf.intel.com with ESMTP; 22 May 2015 02:04:30 -0700 Received: from shecgisg003.sh.intel.com (shecgisg003.sh.intel.com [10.239.29.90]) by shvmail01.sh.intel.com with ESMTP id t4M94SSJ002963; Fri, 22 May 2015 17:04:28 +0800 Received: from shecgisg003.sh.intel.com (localhost [127.0.0.1]) by shecgisg003.sh.intel.com (8.13.6/8.13.6/SuSE Linux 0.8) with ESMTP id t4M94Q3r014356; Fri, 22 May 2015 17:04:28 +0800 Received: (from yliu84x@localhost) by shecgisg003.sh.intel.com (8.13.6/8.13.6/Submit) id t4M94Qst014352; Fri, 22 May 2015 17:04:26 +0800 From: "Jiajia, Sun" To: dts@dpdk.org Date: Fri, 22 May 2015 17:03:58 +0800 Message-Id: <1432285452-14286-6-git-send-email-sunx.jiajia@intel.com> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1432285452-14286-1-git-send-email-sunx.jiajia@intel.com> References: <1432285452-14286-1-git-send-email-sunx.jiajia@intel.com> Subject: [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: Fri, 22 May 2015 09:04:33 -0000 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 = self.get_ip_address() + self.NAME = 'virtdut' + LOG_NAME_SEP + '%s' % self.vm_ip + # load port config from suite cfg + self.suite = suite + self.logger = getLogger(self.NAME) + self.logger.config_execution('vmdut') + self.session = 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 = SSHConnection(self.vm_ip, self.NAME + '_alt', + self.get_password()) + self.alt_session.init_log(self.logger) + + self.number_of_cores = 0 + self.tester = None + self.cores = [] + self.architecture = None + self.ports_info = None + self.ports_map = [] + + def set_nic_type(self, nic_type): + """ + Set CRB NICS ready to validated. + """ + self.nic_type = 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=" + target, "#") + self.send_expect("export RTE_SDK=`pwd`", "#") + + if not self.skip_setup: + self.build_install_dpdk(target) + + self.setup_memory(hugepages=512) + 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='ls --color=none'", "#") + + 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 = "%s:%s" % (pci_bus, pci_id) + if pci_id == "8086:100e": + return False + 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 = 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=''): + """ + Send ping6 packet from local port with destination ipv6 address. + """ + if self.ports_info[localPort]['type'] == 'ixia': + pass + else: + return self.send_expect("ping6 -w 1 -c 1 -A -I %s %s" % (self.ports_info[localPort]['intf'], ipv6), "# ", 10) -- 1.9.3