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 D7D8DADD8 for ; Fri, 13 Feb 2015 09:28:40 +0100 (CET) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga101.jf.intel.com with ESMTP; 13 Feb 2015 00:28:36 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.09,569,1418112000"; d="scan'208";a="685203502" Received: from shvmail01.sh.intel.com ([10.239.29.42]) by orsmga002.jf.intel.com with ESMTP; 13 Feb 2015 00:28:35 -0800 Received: from shecgisg003.sh.intel.com (shecgisg003.sh.intel.com [10.239.29.90]) by shvmail01.sh.intel.com with ESMTP id t1D8SWsx028061; Fri, 13 Feb 2015 16:28:32 +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 t1D8SUTl018528; Fri, 13 Feb 2015 16:28:32 +0800 Received: (from yliu84x@localhost) by shecgisg003.sh.intel.com (8.13.6/8.13.6/Submit) id t1D8SUL4018524; Fri, 13 Feb 2015 16:28:30 +0800 From: Yong Liu To: dts@dpdk.org Date: Fri, 13 Feb 2015 16:28:29 +0800 Message-Id: <1423816109-18492-1-git-send-email-yong.liu@intel.com> X-Mailer: git-send-email 1.7.4.1 Subject: [dts] [PATCH] framework: port map owner changed from tester to DUT 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, 13 Feb 2015 08:28:41 -0000 Network topology will be scanned automatically and save port map as one attribute of DUT crb. Port map saved in DUT crb will be convienient for later enhancement. Like create new VM, create VF device and etc. Signed-off-by: Marvinliu --- framework/dts.py | 2 +- framework/dut.py | 67 +++++++++++++++++++++++++++++++++++++++++++++++++++++ framework/tester.py | 67 +---------------------------------------------------- 3 files changed, 69 insertions(+), 67 deletions(-) diff --git a/framework/dts.py b/framework/dts.py index bddbe33..87fe649 100644 --- a/framework/dts.py +++ b/framework/dts.py @@ -303,8 +303,8 @@ def dts_run_prerequisties(pkgName, patch): Run dts prerequisties function. """ try: - dut.prerequisites(pkgName, patch) tester.prerequisites(performance_only) + dut.prerequisites(pkgName, patch) serializer.save_to_file() except Exception as ex: diff --git a/framework/dut.py b/framework/dut.py index e095d86..b574229 100644 --- a/framework/dut.py +++ b/framework/dut.py @@ -51,6 +51,7 @@ class Dut(Crb): or CRBBareMetal. """ + PORT_MAP_CACHE_KEY = 'dut_port_map' PORT_INFO_CACHE_KEY = 'dut_port_info' NUMBER_CORES_CACHE_KEY = 'dut_number_cores' CORE_LIST_CACHE_KEY = 'dut_core_list' @@ -72,6 +73,7 @@ class Dut(Crb): self.architecture = None self.ports_info = None self.conf = UserConf() + self.ports_map = [] def change_config_option(self, target, parameter, value): """ @@ -163,6 +165,11 @@ class Dut(Crb): # load port infor from config file self.load_portconf() self.mount_procfs() + # auto detect network topology + self.map_available_ports() + if self.ports_map is None or len(self.ports_map) == 0: + raise ValueError("ports_map should not be empty, please check all links") + def restore_interfaces(self): """ @@ -574,3 +581,63 @@ class Dut(Crb): if key in port and port_cfg[key] != port[key]: self.logger.warning("CONGGURED %s NOT SAME AS SCANNED!!!" % (key.upper())) port[key] = port_cfg[key] + + def map_available_ports(self): + """ + Load or generate network connection mapping list. + """ + if self.read_cache: + self.ports_map = self.serializer.load(self.PORT_MAP_CACHE_KEY) + + if not self.read_cache or self.ports_map is None: + self.map_available_ports_uncached() + self.serializer.save(self.PORT_MAP_CACHE_KEY, self.ports_map) + self.logger.warning("DUT PORT MAP: " + str(self.ports_map)) + + def map_available_ports_uncached(self): + """ + Generate network connection mapping list. + """ + + nrPorts = len(self.ports_info) + if nrPorts == 0: + return + + self.ports_map = [-1] * nrPorts + + hits = [False] * len(self.tester.ports_info) + + for dutPort in range(nrPorts): + peer = self.get_peer_pci(dutPort) + dutpci = self.ports_info[dutPort]['pci'] + if peer is not None: + for remotePort in range(len(self.tester.ports_info)): + if self.tester.ports_info[localPort]['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 + + for remotePort in range(len(self.tester.ports_info)): + if hits[remotePort]: + continue + + # skip ping self port + remotepci = self.tester.ports_info[remotePort]['pci'] + if (self.crb['IP'] == self.crb['tester IP']) and (dutpci == remotepci): + 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)) + hits[remotePort] = True + self.ports_map[dutPort] = remotePort + break diff --git a/framework/tester.py b/framework/tester.py index 68fec69..2834d77 100644 --- a/framework/tester.py +++ b/framework/tester.py @@ -50,7 +50,6 @@ class Tester(Crb): A config file and pcap file must have previously been copied to this machine. """ - PORT_MAP_CACHE_KEY = 'tester_port_map' PORT_INFO_CACHE_KEY = 'tester_port_info' CORE_LIST_CACHE_KEY = 'tester_core_list' NUMBER_CORES_CACHE_KEY = 'tester_number_cores' @@ -68,7 +67,6 @@ class Tester(Crb): self.NAME, self.get_password()) self.alt_session.init_log(self.logger) - self.ports_map = [] self.bgProcIsRunning = False self.dut = None self.inBg = 0 @@ -132,15 +130,12 @@ class Tester(Crb): self.pci_devices_information() self.restore_interfaces() self.scan_ports() - self.map_available_ports() - if self.ports_map is None or len(self.ports_map) == 0: - raise ValueError("ports_map should not be empty, please check all links") def get_local_port(self, remotePort): """ Return tester local port connect to specified dut port. """ - return self.ports_map[remotePort] + return self.dut.ports_map[remotePort] def get_local_port_type(self, remotePort): """ @@ -254,66 +249,6 @@ class Tester(Crb): else: return self.send_expect("ping6 -w 5 -c 5 -A -I %s %s" % (self.ports_info[localPort]['intf'], ipv6), "# ", 10) - def map_available_ports(self): - """ - Load or generate network connection mapping list. - """ - if self.read_cache: - self.ports_map = self.serializer.load(self.PORT_MAP_CACHE_KEY) - - if not self.read_cache or self.ports_map is None: - self.map_available_ports_uncached() - self.serializer.save(self.PORT_MAP_CACHE_KEY, self.ports_map) - self.logger.warning("DUT PORT MAP: " + str(self.ports_map)) - - def map_available_ports_uncached(self): - """ - Generate network connection mapping list. - """ - - nrPorts = len(self.dut.ports_info) - if nrPorts == 0: - return - - self.ports_map = [-1] * nrPorts - - hits = [False] * len(self.ports_info) - - for dutPort in range(nrPorts): - peer = self.dut.get_peer_pci(dutPort) - dutpci = self.dut.ports_info[dutPort]['pci'] - if peer is not None: - for localPort in range(len(self.ports_info)): - if self.ports_info[localPort]['pci'] == peer: - hits[localPort] = True - self.ports_map[dutPort] = localPort - break - if self.ports_map[dutPort] == -1: - self.logger.error("CONFIGURED TESTER PORT CANNOT FOUND!!!") - else: - continue # skip ping6 map - - for localPort in range(len(self.ports_info)): - if hits[localPort]: - continue - - # skip ping self port - localpci = self.ports_info[localPort]['pci'] - if (self.crb['IP'] == self.crb['tester IP']) and (dutpci == localpci): - continue - - ipv6 = self.dut.get_ipv6_address(dutPort) - if ipv6 == "Not connected": - continue - - out = self.send_ping6(localPort, ipv6, self.dut.get_mac_address(dutPort)) - - if ('64 bytes from' in out): - self.logger.info("PORT MAP: [local %d: dut %d]" % (localPort, dutPort)) - hits[localPort] = True - self.ports_map[dutPort] = localPort - break - def get_port_numa(self, port): """ Return tester local port numa. -- 1.9.3