From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by dpdk.org (Postfix) with ESMTP id 413E8C53E for ; Thu, 18 Jun 2015 05:07:00 +0200 (CEST) Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga101.jf.intel.com with ESMTP; 17 Jun 2015 20:06:59 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.13,636,1427785200"; d="scan'208";a="589977873" Received: from shvmail01.sh.intel.com ([10.239.29.42]) by orsmga003.jf.intel.com with ESMTP; 17 Jun 2015 20:06:59 -0700 Received: from shecgisg003.sh.intel.com (shecgisg003.sh.intel.com [10.239.29.90]) by shvmail01.sh.intel.com with ESMTP id t5I36vAf009067; Thu, 18 Jun 2015 11:06:57 +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 t5I36tpf016910; Thu, 18 Jun 2015 11:06:57 +0800 Received: (from yliu84x@localhost) by shecgisg003.sh.intel.com (8.13.6/8.13.6/Submit) id t5I36tQx016906; Thu, 18 Jun 2015 11:06:55 +0800 From: Yong Liu To: dts@dpdk.org Date: Thu, 18 Jun 2015 11:06:39 +0800 Message-Id: <1434596804-16846-5-git-send-email-yong.liu@intel.com> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1434596804-16846-1-git-send-email-yong.liu@intel.com> References: <1434596804-16846-1-git-send-email-yong.liu@intel.com> Subject: [dts] [dts 4/9] Optimize network topology discovery routine in virtual scenario 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: Thu, 18 Jun 2015 03:07:00 -0000 From: Marvin Liu Signed-off-by: Marvin Liu diff --git a/framework/dut.py b/framework/dut.py index a9b4ed0..96c362b 100644 --- a/framework/dut.py +++ b/framework/dut.py @@ -781,10 +781,12 @@ class Dut(Crb): continue if getattr(self, 'send_ping6', None): - self.send_ping6( - dutPort, self.tester.ports_info[remotePort]['ipv6']) - out = self.tester.send_ping6( - remotePort, ipv6, self.get_mac_address(dutPort)) + out = self.send_ping6( + dutPort, self.tester.ports_info[remotePort]['ipv6'], + self.get_mac_address(dutPort)) + else: + out = self.tester.send_ping6( + remotePort, ipv6, self.get_mac_address(dutPort)) if ('64 bytes from' in out): self.logger.info("PORT MAP: [dut %d: tester %d]" % (dutPort, remotePort)) diff --git a/framework/virt_dut.py b/framework/virt_dut.py index b52109d..79ecc2a 100644 --- a/framework/virt_dut.py +++ b/framework/virt_dut.py @@ -35,7 +35,7 @@ import time import dts import settings from config import PortConf -from settings import NICS, LOG_NAME_SEP +from settings import NICS, LOG_NAME_SEP, get_netdev from ssh_connection import SSHConnection from project_dpdk import DPDKdut from dut import Dut @@ -54,7 +54,9 @@ class VirtDut(DPDKdut): or CRBBareMetal. """ - def __init__(self, crb, serializer, virttype, vm_name, suite): + def __init__(self, hyper, crb, serializer, virttype, vm_name, suite): + self.vm_name = vm_name + self.hyper = hyper super(Dut, self).__init__(crb, serializer) self.vm_ip = self.get_ip_address() self.NAME = 'virtdut' + LOG_NAME_SEP + '%s' % self.vm_ip @@ -96,8 +98,27 @@ class VirtDut(DPDKdut): """ Load port config for this virtual machine """ + self.conf = PortConf() + self.conf.load_ports_config(self.vm_name) + self.ports_cfg = self.conf.get_ports_config() + return + def create_portmap(self): + port_num = len(self.ports_info) + self.ports_map = [-1] * port_num + for key in self.ports_cfg.keys(): + index = int(key) + if index >= port_num: + print dts.RED("Can not found [%d ]port info" % index) + continue + + if 'peer' in self.ports_cfg[key].keys(): + tester_pci = self.ports_cfg[key]['peer'] + # find tester_pci index + pci_idx = self.tester.get_local_index(tester_pci) + self.ports_map[index] = pci_idx + def set_target(self, target): """ Set env variable, these have to be setup all the time. Some tests @@ -121,7 +142,7 @@ class VirtDut(DPDKdut): self.bind_interfaces_linux('igb_uio') - def prerequisites(self, pkgName, patch): + def prerequisites(self, pkgName, patch, auto_portmap): """ Prerequest function should be called before execute any test case. Will call function to scan all lcore's information which on DUT. @@ -153,13 +174,19 @@ class VirtDut(DPDKdut): # no need to rescan ports for guest os just bootup # load port infor from config file - self.load_portconf() + if auto_portmap is False: + self.load_portconf() # enable tester port ipv6 self.host_dut.enable_tester_ipv6() self.mount_procfs() - # auto detect network topology - self.map_available_ports() + + if auto_portmap: + # auto detect network topology + self.map_available_ports() + else: + self.create_portmap() + # disable tester port ipv6 self.host_dut.disable_tester_ipv6() @@ -167,6 +194,22 @@ class VirtDut(DPDKdut): for port_info in self.ports_info: self.logger.info(port_info) + def init_core_list(self): + self.cores = [] + cpuinfo = self.send_expect("grep --color=never \"processor\"" + " /proc/cpuinfo", "#", alt_session=False) + cpuinfo = cpuinfo.split('\r\n') + for line in cpuinfo: + m = re.search("processor\t: (\d+)", line) + if m: + thread = m.group(1) + socket = 0 + core = thread + self.cores.append( + {'thread': thread, 'socket': socket, 'core': core}) + + self.number_of_cores = len(self.cores) + def restore_interfaces_domu(self): """ Restore Linux interfaces. @@ -227,13 +270,66 @@ class VirtDut(DPDKdut): Load or generate network connection mapping list. """ self.map_available_ports_uncached() - self.logger.warning("DUT PORT MAP: " + str(self.ports_map)) + self.logger.warning("VM DUT PORT MAP: " + str(self.ports_map)) - def send_ping6(self, localPort, ipv6, mac=''): + def map_available_ports_uncached(self): """ - Send ping6 packet from local port with destination ipv6 address. + Generate network connection mapping list. """ - 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) + nrPorts = len(self.ports_info) + if nrPorts == 0: + return + + remove = [] + self.ports_map = [-1] * nrPorts + + hits = [False] * len(self.tester.ports_info) + + for dutPort in range(nrPorts): + peer = self.get_peer_pci(dutPort) + # if peer pci configured + if peer is not None: + for remotePort in range(len(self.tester.ports_info)): + if self.tester.ports_info[remotePort]['pci'] == peer: + hits[remotePort] = True + self.ports_map[dutPort] = remotePort + break + if self.ports_map[dutPort] == -1: + self.logger.error("CONFIGURED TESTER PORT CANNOT FOUND!!!") + else: + continue # skip ping6 map + + if hasattr(self.hyper, 'pt_devices'): + hostpci = self.hyper.pt_devices[dutPort] + netdev = get_netdev(self.host_dut, hostpci) + + # auto ping port map + for remotePort in range(len(self.tester.ports_info)): + # for two vfs connected to same tester port + # can't skip those teste ports even have hits + # need skip ping self vf port + remotepci = self.tester.ports_info[remotePort]['pci'] + remoteport = self.tester.ports_info[remotePort]['port'] + vfs = [] + # vm_dut and tester in same dut + host_ip = self.crb['IP'].split(':')[0] + if self.crb['tester IP'] == host_ip: + vfs = remoteport.get_sriov_vfs_pci() + # if hostpci is vf of tester port + if netdev.pci in vfs: + print dts.RED("Skip ping from PF device") + continue + + ipv6 = self.get_ipv6_address(dutPort) + if ipv6 == "Not connected": + continue + + out = self.tester.send_ping6( + remotePort, ipv6, self.get_mac_address(dutPort)) + + if ('64 bytes from' in out): + self.logger.info( + "PORT MAP: [dut %d: tester %d]" % (dutPort, remotePort)) + self.ports_map[dutPort] = remotePort + hits[remotePort] = True + continue -- 1.9.3