From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by dpdk.org (Postfix) with ESMTP id 9937EB517 for ; Sun, 15 Feb 2015 03:29:47 +0100 (CET) Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga103.jf.intel.com with ESMTP; 14 Feb 2015 18:24:34 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.09,578,1418112000"; d="scan'208";a="527708275" Received: from pgsmsx106.gar.corp.intel.com ([10.221.44.98]) by orsmga003.jf.intel.com with ESMTP; 14 Feb 2015 18:21:21 -0800 Received: from shsmsx152.ccr.corp.intel.com (10.239.6.52) by PGSMSX106.gar.corp.intel.com (10.221.44.98) with Microsoft SMTP Server (TLS) id 14.3.195.1; Sun, 15 Feb 2015 10:29:43 +0800 Received: from shsmsx101.ccr.corp.intel.com ([169.254.1.192]) by SHSMSX152.ccr.corp.intel.com ([169.254.6.46]) with mapi id 14.03.0195.001; Sun, 15 Feb 2015 10:29:42 +0800 From: "Xu, HuilongX" To: "Liu, Yong" , "dts@dpdk.org" Thread-Topic: [dts] [PATCH] framework: port map owner changed from tester to DUT Thread-Index: AQHQR2cfuHum1ouMwkSFKgcPWUgcOJzw/4NA Date: Sun, 15 Feb 2015 02:29:41 +0000 Message-ID: References: <1423816109-18492-1-git-send-email-yong.liu@intel.com> In-Reply-To: <1423816109-18492-1-git-send-email-yong.liu@intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-cr-hashedpuzzle: CoSA C6ya DTrJ DuuB EaPR EyIs E2Ja FQQ6 FjEr IIGS JGk6 JPgt J2X6 J/cg KgzP LE9u; 1; ZAB0AHMAQABkAHAAZABrAC4AbwByAGcA; Sosha1_v1; 7; {4CB38C40-E11E-47EC-92B7-1B1E3B7B5B28}; aAB1AGkAbABvAG4AZwB4AC4AeAB1AEAAaQBuAHQAZQBsAC4AYwBvAG0A; Sun, 15 Feb 2015 02:29:39 GMT; UgBFADoAIABbAGQAdABzAF0AIABbAFAAQQBUAEMASABdACAAZgByAGEAbQBlAHcAbwByAGsAOgAgAHAAbwByAHQAIABtAGEAcAAgAG8AdwBuAGUAcgAgAGMAaABhAG4AZwBlAGQAIABmAHIAbwBtACAAdABlAHMAdABlAHIAIAB0AG8AIABEAFUAVAA= x-cr-puzzleid: {4CB38C40-E11E-47EC-92B7-1B1E3B7B5B28} 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] 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: Sun, 15 Feb 2015 02:29:48 -0000 Acked-by: huilong xu -----Original Message----- From: dts [mailto:dts-bounces@dpdk.org] On Behalf Of Yong Liu Sent: Friday, February 13, 2015 4:28 PM To: dts@dpdk.org Subject: [dts] [PATCH] framework: port map owner changed from tester to DUT Network topology will be scanned automatically and save port map as one=20 attribute of DUT crb. Port map saved in DUT crb will be convienient for lat= er=20 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) =20 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. """ =20 + PORT_MAP_CACHE_KEY =3D 'dut_port_map' PORT_INFO_CACHE_KEY =3D 'dut_port_info' NUMBER_CORES_CACHE_KEY =3D 'dut_number_cores' CORE_LIST_CACHE_KEY =3D 'dut_core_list' @@ -72,6 +73,7 @@ class Dut(Crb): self.architecture =3D None self.ports_info =3D None self.conf =3D UserConf() + self.ports_map =3D [] =20 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) =3D=3D 0: + raise ValueError("ports_map should not be empty, please check = all links") + =20 def restore_interfaces(self): """ @@ -574,3 +581,63 @@ class Dut(Crb): if key in port and port_cfg[key] !=3D port[key]: self.logger.warning("CONGGURED %s NOT SAME AS SCAN= NED!!!" % (key.upper())) port[key] =3D port_cfg[key] + + def map_available_ports(self): + """ + Load or generate network connection mapping list. + """ + if self.read_cache: + self.ports_map =3D self.serializer.load(self.PORT_MAP_CACHE_KE= Y) + + 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 =3D len(self.ports_info) + if nrPorts =3D=3D 0: + return + + self.ports_map =3D [-1] * nrPorts + + hits =3D [False] * len(self.tester.ports_info) + + for dutPort in range(nrPorts): + peer =3D self.get_peer_pci(dutPort) + dutpci =3D 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'] =3D=3D pee= r: + hits[remotePort] =3D True + self.ports_map[dutPort] =3D remotePort + break + if self.ports_map[dutPort] =3D=3D -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 =3D self.tester.ports_info[remotePort]['pci'] + if (self.crb['IP'] =3D=3D self.crb['tester IP']) and (dutp= ci =3D=3D remotepci): + continue + + ipv6 =3D self.get_ipv6_address(dutPort) + if ipv6 =3D=3D "Not connected": + continue + + out =3D 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]" % (du= tPort, remotePort)) + hits[remotePort] =3D True + self.ports_map[dutPort] =3D 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 =3D 'tester_port_map' PORT_INFO_CACHE_KEY =3D 'tester_port_info' CORE_LIST_CACHE_KEY =3D 'tester_core_list' NUMBER_CORES_CACHE_KEY =3D 'tester_number_cores' @@ -68,7 +67,6 @@ class Tester(Crb): self.NAME, self.get_password()) self.alt_session.init_log(self.logger) =20 - self.ports_map =3D [] self.bgProcIsRunning =3D False self.dut =3D None self.inBg =3D 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) =3D=3D 0: - raise ValueError("ports_map should not be empty, please check = all links") =20 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] =20 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) =20 - def map_available_ports(self): - """ - Load or generate network connection mapping list. - """ - if self.read_cache: - self.ports_map =3D self.serializer.load(self.PORT_MAP_CACHE_KE= Y) - - 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 =3D len(self.dut.ports_info) - if nrPorts =3D=3D 0: - return - - self.ports_map =3D [-1] * nrPorts - - hits =3D [False] * len(self.ports_info) - - for dutPort in range(nrPorts): - peer =3D self.dut.get_peer_pci(dutPort) - dutpci =3D 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'] =3D=3D peer: - hits[localPort] =3D True - self.ports_map[dutPort] =3D localPort - break - if self.ports_map[dutPort] =3D=3D -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 =3D self.ports_info[localPort]['pci'] - if (self.crb['IP'] =3D=3D self.crb['tester IP']) and (dutp= ci =3D=3D localpci): - continue - - ipv6 =3D self.dut.get_ipv6_address(dutPort) - if ipv6 =3D=3D "Not connected": - continue - - out =3D 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]" % (loc= alPort, dutPort)) - hits[localPort] =3D True - self.ports_map[dutPort] =3D localPort - break - def get_port_numa(self, port): """ Return tester local port numa. --=20 1.9.3