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 AD681ADA3 for ; Wed, 4 Feb 2015 06:24:24 +0100 (CET) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga101.jf.intel.com with ESMTP; 03 Feb 2015 21:24:23 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.09,517,1418112000"; d="scan'208";a="672429660" Received: from kmsmsx151.gar.corp.intel.com ([172.21.73.86]) by fmsmga002.fm.intel.com with ESMTP; 03 Feb 2015 21:24:20 -0800 Received: from shsmsx104.ccr.corp.intel.com (10.239.4.70) by KMSMSX151.gar.corp.intel.com (172.21.73.86) with Microsoft SMTP Server (TLS) id 14.3.195.1; Wed, 4 Feb 2015 13:24:20 +0800 Received: from shsmsx103.ccr.corp.intel.com ([169.254.4.91]) by SHSMSX104.ccr.corp.intel.com ([169.254.5.161]) with mapi id 14.03.0195.001; Wed, 4 Feb 2015 13:24:19 +0800 From: "Liu, Yong" To: "Qiu, Michael" , "dts@dpdk.org" Thread-Topic: [dts] [PATCH 3/4] framework: reorganize DUT and Tester port initialize sequence Thread-Index: AQHQNuZ7sYmrj054RUugvFW8swp625zgAeog Date: Wed, 4 Feb 2015 05:24:19 +0000 Message-ID: <86228AFD5BCD8E4EBFD2B90117B5E81E10D6A48F@SHSMSX103.ccr.corp.intel.com> References: <1422001619-27112-1-git-send-email-yong.liu@intel.com> <1422001619-27112-4-git-send-email-yong.liu@intel.com> <533710CFB86FA344BFBF2D6802E60286CD430D@SHSMSX101.ccr.corp.intel.com> In-Reply-To: <533710CFB86FA344BFBF2D6802E60286CD430D@SHSMSX101.ccr.corp.intel.com> Accept-Language: zh-CN, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: 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 3/4] framework: reorganize DUT and Tester port initialize sequence 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: Wed, 04 Feb 2015 05:24:25 -0000 Michael, thanks for your comments. > -----Original Message----- > From: Qiu, Michael > Sent: Wednesday, February 04, 2015 11:56 AM > To: Liu, Yong; dts@dpdk.org > Subject: Re: [dts] [PATCH 3/4] framework: reorganize DUT and Tester port > initialize sequence >=20 > On 1/23/2015 4:27 PM, Marvin Liu wrote: > > From: Yong Liu > > > > DUT port initialization sequence: scan,restore,rescan,load config > > Test port initialization sequence: modprobe, interface up > > Separate restore interface function from DUT and Tester. > > > > Signed-off-by: Marvinliu > > --- > > framework/crb.py | 53 ++++---------- > > framework/dut.py | 181 +++++++++++++++++++++++++++++++++++---= - > ------- > > framework/project_dpdk.py | 22 ++---- > > framework/tester.py | 30 ++++++++ > > 4 files changed, 190 insertions(+), 96 deletions(-) > > >=20 > [...] >=20 > > @@ -494,3 +531,61 @@ class Dut(Crb): > > # store the port info to port mapping > > self.ports_info.append({'pci': pci_str, 'type': pci_id, > 'intf': > > intf, 'mac': macaddr, 'ipv6': ipv6= , > 'numa': -1}) > > + > > + def restore_interfaces(self): > > + """ > > + Restore Linux interfaces. > > + """ > > + for port in self.ports_info: > > + pci_bus =3D port['pci'] > > + pci_id =3D port['type'] > > + # get device driver > > + driver =3D dts.get_nic_driver(pci_id) > > + if driver is not None: > > + # unbind device driver > > + addr_array =3D pci_bus.split(':') > > + bus_id =3D addr_array[0] > > + devfun_id =3D addr_array[1] > > + > > + self.send_expect('echo 0000:%s > > /sys/bus/pci/devices/0000\:%s\:%s/driver/unbind' >=20 > Here if this devices has no driver binded, will failed, but seems no > affect for logic, but at least should give some log message I think. >=20 > Thanks, > Michael Michael, here is just our logic. If there's no driver available for this ni= c, DTS will keep it untouched and load config for it.=20 It's better to add some message for remind user DTS will not restore this n= ic.=20 > > + % (pci_bus, bus_id, devfun_id), '# ') > > + # bind to linux kernel driver > > + self.send_expect('modprobe %s' % driver, '# ') > > + self.send_expect('echo 0000:%s > > /sys/bus/pci/drivers/%s/bind' > > + % (pci_bus, driver), '# ') > > + itf =3D self.get_interface_name(addr_array[0], > addr_array[1]) > > + self.send_expect("ifconfig %s up" % itf, "# ") > > + > > + def load_portconf(self): > > + """ > > + Load port configurations for ports_info. If manually configure= d > infor > > + not same as auto scanned, still use infor in configuration fil= e. > > + """ > > + for port in self.ports_info: > > + pci_bus =3D port['pci'] > > + if pci_bus in self.conf.ports_cfg: > > + port_cfg =3D self.conf.ports_cfg[pci_bus] > > + port_cfg['source'] =3D 'cfg' > > + else: > > + port_cfg =3D {} > > + > > + if 'intf' in port_cfg: > > + if 'intf' in port: > > + if port_cfg['intf'] !=3D port['intf']: > > + self.logger.warning("CONFIGURED INTERFACE NOT > SAME AS SCANNED!!!") > > + port['intf'] =3D port_cfg['intf'] > > + > > + if 'mac' in port_cfg: > > + if 'mac' in port: > > + if port_cfg['mac'] !=3D port['mac']: > > + self.logger.warning("CONFIGURED MACADDRESS NOT > SAME AS SCANNED!!!") > > + port['mac'] =3D port_cfg['mac'] > > + > > + if 'numa' in port_cfg: > > + if 'numa' in port: > > + if port_cfg['numa'] !=3D port['numa']: > > + self.logger.warning("CONFIGURED NUMA NOT SAME > AS SCANNED!!!") > > + port['numa'] =3D port_cfg['numa'] > > + > > + if 'numa' in port_cfg: > > + port['peer'] =3D port_cfg['peer'] >=20 > Why "if 'numa' in port_cfg:" twice here? >=20 > Also it is almost the same for those: >=20 > if key in port_cfg: >=20 > So can we do a iteration here?Like below: >=20 > for key in port_cfg: > if key in port: > if port_cfg['intf'] !=3D port['intf']: > self.logger.warning("CONFIGURED INTERFACE NOT SAME AS > SCANNED!!!") > port[key] =3D port_cfg[key] >=20 >=20 > Thanks, > Michael >=20 Thanks for this catch, the second "numa" should be "peer". Will implement one function replace of these duplicate codes. =20 > > diff --git a/framework/project_dpdk.py b/framework/project_dpdk.py > > index 6e25f1f..13be836 100644 > > --- a/framework/project_dpdk.py > > +++ b/framework/project_dpdk.py > > @@ -234,13 +234,10 @@ class DPDKdut(Dut): > > binding_list =3D '--bind=3D%s ' % driver > > > > current_nic =3D 0 > > - for (pci_bus, pci_id) in self.pci_devices_info: > > - if dts.accepted_nic(pci_id): > > - > > - if nics_to_bind is None or current_nic in nics_to_bind= : > > - binding_list +=3D '%s ' % (pci_bus) > > - > > - current_nic +=3D 1 > > + for port_info in self.ports_info: > > + if nics_to_bind is None or current_nic in nics_to_bind: > > + binding_list +=3D '%s ' % (port_info['pci']) > > + current_nic +=3D 1 > > > > self.send_expect('tools/dpdk_nic_bind.py %s' % binding_list, '= # > ') > > > > @@ -252,13 +249,10 @@ class DPDKdut(Dut): > > binding_list =3D '-u ' > > > > current_nic =3D 0 > > - for (pci_bus, pci_id) in self.pci_devices_info: > > - if dts.accepted_nic(pci_id): > > - > > - if nics_to_bind is None or current_nic in nics_to_bind= : > > - binding_list +=3D '%s ' % (pci_bus) > > - > > - current_nic +=3D 1 > > + for port_info in self.ports_info: > > + if nics_to_bind is None or current_nic in nics_to_bind: > > + binding_list +=3D '%s ' % (port_info['pci']) > > + current_nic +=3D 1 > > > > self.send_expect('tools/dpdk_nic_bind.py %s' % binding_list, '= # > ', 30) > > > > diff --git a/framework/tester.py b/framework/tester.py > > index 2c023dd..345ab41 100644 > > --- a/framework/tester.py > > +++ b/framework/tester.py > > @@ -170,6 +170,24 @@ class Tester(Crb): > > else: > > return 'down' > > > > + def restore_interfaces(self): > > + """ > > + Restore Linux interfaces. > > + """ > > + self.send_expect("modprobe igb", "# ", 20) > > + self.send_expect("modprobe ixgbe", "# ", 20) > > + self.send_expect("modprobe e1000e", "# ", 20) > > + self.send_expect("modprobe e1000", "# ", 20) > > + > > + try: > > + for (pci_bus, pci_id) in self.pci_devices_info: > > + addr_array =3D pci_bus.split(':') > > + itf =3D self.get_interface_name(addr_array[0], > addr_array[1]) > > + self.send_expect("ifconfig %s up" % itf, "# ") > > + > > + except Exception as e: > > + self.logger.error(" !!! Restore ITF: " + e.message) > > + > > def scan_ports(self): > > """ > > Scan all ports on tester and save port's pci/mac/interface. > > @@ -253,6 +271,18 @@ class Tester(Crb): > > hits =3D [False] * len(self.ports_info) > > > > for dutPort in range(nrPorts): > > + peer =3D self.dut.get_peer_pci(dutPort) > > + 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