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 102F6DE4 for ; Wed, 4 Feb 2015 04:56:09 +0100 (CET) Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga102.fm.intel.com with ESMTP; 03 Feb 2015 19:56:07 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.09,517,1418112000"; d="scan'208";a="522222336" Received: from kmsmsx153.gar.corp.intel.com ([172.21.73.88]) by orsmga003.jf.intel.com with ESMTP; 03 Feb 2015 19:48:29 -0800 Received: from shsmsx152.ccr.corp.intel.com (10.239.6.52) by KMSMSX153.gar.corp.intel.com (172.21.73.88) with Microsoft SMTP Server (TLS) id 14.3.195.1; Wed, 4 Feb 2015 11:56:04 +0800 Received: from shsmsx101.ccr.corp.intel.com ([169.254.1.253]) by SHSMSX152.ccr.corp.intel.com ([169.254.6.129]) with mapi id 14.03.0195.001; Wed, 4 Feb 2015 11:56:04 +0800 From: "Qiu, Michael" To: "Liu, Yong" , "dts@dpdk.org" Thread-Topic: [dts] [PATCH 3/4] framework: reorganize DUT and Tester port initialize sequence Thread-Index: AQHQNuZ7sYmrj054RUugvFW8swp62w== Date: Wed, 4 Feb 2015 03:56:02 +0000 Message-ID: <533710CFB86FA344BFBF2D6802E60286CD430D@SHSMSX101.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> Accept-Language: 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 03:56:10 -0000 On 1/23/2015 4:27 PM, Marvin Liu wrote:=0A= > From: Yong Liu =0A= >=0A= > DUT port initialization sequence: scan,restore,rescan,load config=0A= > Test port initialization sequence: modprobe, interface up=0A= > Separate restore interface function from DUT and Tester.=0A= >=0A= > Signed-off-by: Marvinliu =0A= > ---=0A= > framework/crb.py | 53 ++++----------=0A= > framework/dut.py | 181 +++++++++++++++++++++++++++++++++++-----= ------=0A= > framework/project_dpdk.py | 22 ++----=0A= > framework/tester.py | 30 ++++++++=0A= > 4 files changed, 190 insertions(+), 96 deletions(-)=0A= >=0A= =0A= [...]=0A= =0A= > @@ -494,3 +531,61 @@ class Dut(Crb):=0A= > # store the port info to port mapping=0A= > self.ports_info.append({'pci': pci_str, 'type': pci_id, 'int= f':=0A= > intf, 'mac': macaddr, 'ipv6': ipv6, = 'numa': -1})=0A= > +=0A= > + def restore_interfaces(self):=0A= > + """=0A= > + Restore Linux interfaces.=0A= > + """=0A= > + for port in self.ports_info:=0A= > + pci_bus =3D port['pci']=0A= > + pci_id =3D port['type']=0A= > + # get device driver=0A= > + driver =3D dts.get_nic_driver(pci_id)=0A= > + if driver is not None:=0A= > + # unbind device driver=0A= > + addr_array =3D pci_bus.split(':')=0A= > + bus_id =3D addr_array[0]=0A= > + devfun_id =3D addr_array[1]=0A= > +=0A= > + self.send_expect('echo 0000:%s > /sys/bus/pci/devices/00= 00\:%s\:%s/driver/unbind'=0A= =0A= Here if this devices has no driver binded, will failed, but seems no=0A= affect for logic, but at least should give some log message I think.=0A= =0A= Thanks,=0A= Michael=0A= > + % (pci_bus, bus_id, devfun_id), '# ')= =0A= > + # bind to linux kernel driver=0A= > + self.send_expect('modprobe %s' % driver, '# ')=0A= > + self.send_expect('echo 0000:%s > /sys/bus/pci/drivers/%s= /bind'=0A= > + % (pci_bus, driver), '# ')=0A= > + itf =3D self.get_interface_name(addr_array[0], addr_arra= y[1])=0A= > + self.send_expect("ifconfig %s up" % itf, "# ")=0A= > +=0A= > + def load_portconf(self):=0A= > + """=0A= > + Load port configurations for ports_info. If manually configured = infor=0A= > + not same as auto scanned, still use infor in configuration file.= =0A= > + """=0A= > + for port in self.ports_info:=0A= > + pci_bus =3D port['pci']=0A= > + if pci_bus in self.conf.ports_cfg:=0A= > + port_cfg =3D self.conf.ports_cfg[pci_bus]=0A= > + port_cfg['source'] =3D 'cfg'=0A= > + else:=0A= > + port_cfg =3D {}=0A= > +=0A= > + if 'intf' in port_cfg:=0A= > + if 'intf' in port:=0A= > + if port_cfg['intf'] !=3D port['intf']:=0A= > + self.logger.warning("CONFIGURED INTERFACE NOT SA= ME AS SCANNED!!!")=0A= > + port['intf'] =3D port_cfg['intf']=0A= > +=0A= > + if 'mac' in port_cfg:=0A= > + if 'mac' in port:=0A= > + if port_cfg['mac'] !=3D port['mac']:=0A= > + self.logger.warning("CONFIGURED MACADDRESS NOT S= AME AS SCANNED!!!")=0A= > + port['mac'] =3D port_cfg['mac']=0A= > +=0A= > + if 'numa' in port_cfg:=0A= > + if 'numa' in port:=0A= > + if port_cfg['numa'] !=3D port['numa']:=0A= > + self.logger.warning("CONFIGURED NUMA NOT SAME AS= SCANNED!!!")=0A= > + port['numa'] =3D port_cfg['numa']=0A= > +=0A= > + if 'numa' in port_cfg:=0A= > + port['peer'] =3D port_cfg['peer']=0A= =0A= Why "if 'numa' in port_cfg:" twice here?=0A= =0A= Also it is almost the same for those:=0A= =0A= if key in port_cfg:=0A= =0A= So can we do a iteration here?Like below:=0A= =0A= for key in port_cfg:=0A= if key in port:=0A= if port_cfg['intf'] !=3D port['intf']:=0A= self.logger.warning("CONFIGURED INTERFACE NOT SAME AS=0A= SCANNED!!!")=0A= port[key] =3D port_cfg[key]=0A= =0A= =0A= Thanks,=0A= Michael=0A= =0A= > diff --git a/framework/project_dpdk.py b/framework/project_dpdk.py=0A= > index 6e25f1f..13be836 100644=0A= > --- a/framework/project_dpdk.py=0A= > +++ b/framework/project_dpdk.py=0A= > @@ -234,13 +234,10 @@ class DPDKdut(Dut):=0A= > binding_list =3D '--bind=3D%s ' % driver=0A= > =0A= > current_nic =3D 0=0A= > - for (pci_bus, pci_id) in self.pci_devices_info:=0A= > - if dts.accepted_nic(pci_id):=0A= > -=0A= > - if nics_to_bind is None or current_nic in nics_to_bind:= =0A= > - binding_list +=3D '%s ' % (pci_bus)=0A= > -=0A= > - current_nic +=3D 1=0A= > + for port_info in self.ports_info:=0A= > + if nics_to_bind is None or current_nic in nics_to_bind:=0A= > + binding_list +=3D '%s ' % (port_info['pci'])=0A= > + current_nic +=3D 1=0A= > =0A= > self.send_expect('tools/dpdk_nic_bind.py %s' % binding_list, '# = ')=0A= > =0A= > @@ -252,13 +249,10 @@ class DPDKdut(Dut):=0A= > binding_list =3D '-u '=0A= > =0A= > current_nic =3D 0=0A= > - for (pci_bus, pci_id) in self.pci_devices_info:=0A= > - if dts.accepted_nic(pci_id):=0A= > -=0A= > - if nics_to_bind is None or current_nic in nics_to_bind:= =0A= > - binding_list +=3D '%s ' % (pci_bus)=0A= > -=0A= > - current_nic +=3D 1=0A= > + for port_info in self.ports_info:=0A= > + if nics_to_bind is None or current_nic in nics_to_bind:=0A= > + binding_list +=3D '%s ' % (port_info['pci'])=0A= > + current_nic +=3D 1=0A= > =0A= > self.send_expect('tools/dpdk_nic_bind.py %s' % binding_list, '# = ', 30)=0A= > =0A= > diff --git a/framework/tester.py b/framework/tester.py=0A= > index 2c023dd..345ab41 100644=0A= > --- a/framework/tester.py=0A= > +++ b/framework/tester.py=0A= > @@ -170,6 +170,24 @@ class Tester(Crb):=0A= > else:=0A= > return 'down'=0A= > =0A= > + def restore_interfaces(self):=0A= > + """=0A= > + Restore Linux interfaces.=0A= > + """=0A= > + self.send_expect("modprobe igb", "# ", 20)=0A= > + self.send_expect("modprobe ixgbe", "# ", 20)=0A= > + self.send_expect("modprobe e1000e", "# ", 20)=0A= > + self.send_expect("modprobe e1000", "# ", 20)=0A= > +=0A= > + try:=0A= > + for (pci_bus, pci_id) in self.pci_devices_info:=0A= > + addr_array =3D pci_bus.split(':')=0A= > + itf =3D self.get_interface_name(addr_array[0], addr_arra= y[1])=0A= > + self.send_expect("ifconfig %s up" % itf, "# ")=0A= > +=0A= > + except Exception as e:=0A= > + self.logger.error(" !!! Restore ITF: " + e.message)=0A= > +=0A= > def scan_ports(self):=0A= > """=0A= > Scan all ports on tester and save port's pci/mac/interface.=0A= > @@ -253,6 +271,18 @@ class Tester(Crb):=0A= > hits =3D [False] * len(self.ports_info)=0A= > =0A= > for dutPort in range(nrPorts):=0A= > + peer =3D self.dut.get_peer_pci(dutPort)=0A= > + if peer is not None:=0A= > + for localPort in range(len(self.ports_info)):=0A= > + if self.ports_info[localPort]['pci'] =3D=3D peer:=0A= > + hits[localPort] =3D True=0A= > + self.ports_map[dutPort] =3D localPort=0A= > + break=0A= > + if self.ports_map[dutPort] =3D=3D -1:=0A= > + self.logger.error("CONFIGURED TESTER PORT CANNOT FOU= ND!!!")=0A= > + else:=0A= > + continue # skip ping6 map=0A= > +=0A= > for localPort in range(len(self.ports_info)):=0A= > if hits[localPort]:=0A= > continue=0A= =0A=