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 C03C9CF9 for ; Fri, 22 May 2015 11:04:56 +0200 (CEST) Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga102.fm.intel.com with ESMTP; 22 May 2015 02:04:55 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.13,474,1427785200"; d="scan'208";a="496956701" Received: from shvmail01.sh.intel.com ([10.239.29.42]) by FMSMGA003.fm.intel.com with ESMTP; 22 May 2015 02:04:55 -0700 Received: from shecgisg003.sh.intel.com (shecgisg003.sh.intel.com [10.239.29.90]) by shvmail01.sh.intel.com with ESMTP id t4M94pfR004107; Fri, 22 May 2015 17:04:51 +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 t4M94nmG014427; Fri, 22 May 2015 17:04:51 +0800 Received: (from yliu84x@localhost) by shecgisg003.sh.intel.com (8.13.6/8.13.6/Submit) id t4M94nMH014423; Fri, 22 May 2015 17:04:49 +0800 From: "Jiajia, Sun" To: dts@dpdk.org Date: Fri, 22 May 2015 17:04:08 +0800 Message-Id: <1432285452-14286-16-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 15/19] Add some codes to support network instantiation in the tester module 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:57 -0000 From: sjiajiax Signed-off-by: sjiajiax --- framework/tester.py | 51 +++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 43 insertions(+), 8 deletions(-) diff --git a/framework/tester.py b/framework/tester.py index aba0356..ce136e4 100644 --- a/framework/tester.py +++ b/framework/tester.py @@ -38,6 +38,7 @@ from time import sleep from settings import NICS from ssh_connection import SSHConnection from crb import Crb +from net_device import NetDevice from etgen import IxiaPacketGenerator, SoftwarePacketGenerator from logger import getLogger from settings import IXIA @@ -152,6 +153,7 @@ class Tester(Crb): index += 1 if pci == port['pci']: return index + return -1 def get_pci(self, localPort): """ @@ -163,6 +165,9 @@ class Tester(Crb): """ Return tester local port interface name. """ + if 'intf' not in self.ports_info[localPort]: + return 'N/A' + return self.ports_info[localPort]['intf'] def get_mac(self, localPort): @@ -202,26 +207,51 @@ class Tester(Crb): try: for (pci_bus, pci_id) in self.pci_devices_info: addr_array = pci_bus.split(':') - itf = self.get_interface_name(addr_array[0], addr_array[1]) + port = NetDevice(self, addr_array[0], addr_array[1]) + itf = port.get_interface_name() + self.enable_ipv6(itf) self.send_expect("ifconfig %s up" % itf, "# ") except Exception as e: self.logger.error(" !!! Restore ITF: " + e.message) + sleep(2) + + def load_serializer_ports(self): + self.ports_info = [] + cached_ports_info = self.serializer.load(self.PORT_INFO_CACHE_KEY) + if cached_ports_info is None: + return + + # now not save netdev object, will implemented later + self.ports_info = cached_ports_info + + def save_serializer_ports(self): + cached_ports_info = [] + for port in self.ports_info: + port_info = {} + for key in port.keys(): + if type(port[key]) is str: + port_info[key] = port[key] + # need save netdev objects + cached_ports_info.append(port_info) + self.serializer.save(self.PORT_INFO_CACHE_KEY, cached_ports_info) + def scan_ports(self): """ Scan all ports on tester and save port's pci/mac/interface. """ if self.read_cache: - self.ports_info = self.serializer.load(self.PORT_INFO_CACHE_KEY) + self.load_serializer_ports() if not self.read_cache or self.ports_info is None: self.scan_ports_uncached() if self.it_uses_external_generator(): self.ports_info.extend(self.ixia_packet_gen.get_ports()) - self.serializer.save(self.PORT_INFO_CACHE_KEY, self.ports_info) + self.save_serializer_ports() - self.logger.info(self.ports_info) + for port_info in self.ports_info: + self.logger.info(port_info) def scan_ports_uncached(self): """ @@ -240,7 +270,8 @@ class Tester(Crb): bus_id = addr_array[0] devfun_id = addr_array[1] - intf = self.get_interface_name(bus_id, devfun_id) + port = NetDevice(self, bus_id, devfun_id) + intf = port.get_interface_name() if "No such file" in intf: self.logger.info("Tester: [000:%s %s] %s" % (pci_bus, pci_id, @@ -248,13 +279,17 @@ class Tester(Crb): continue self.logger.info("Tester: [000:%s %s] %s" % (pci_bus, pci_id, intf)) - macaddr = self.get_mac_addr(intf, bus_id, devfun_id) + macaddr = port.get_mac_addr() + + ipv6 = port.get_ipv6_addr() # store the port info to port mapping - self.ports_info.append({'pci': pci_bus, + self.ports_info.append({'port': port, + 'pci': pci_bus, 'type': pci_id, 'intf': intf, - 'mac': macaddr}) + 'mac': macaddr, + 'ipv6': ipv6}) def send_ping6(self, localPort, ipv6, mac): """ -- 1.9.3