From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by dpdk.org (Postfix) with ESMTP id 2213AC7C6 for ; Fri, 26 Jun 2015 07:27:57 +0200 (CEST) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga101.fm.intel.com with ESMTP; 25 Jun 2015 22:27:56 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.13,682,1427785200"; d="scan'208";a="753516699" Received: from shvmail01.sh.intel.com ([10.239.29.42]) by orsmga002.jf.intel.com with ESMTP; 25 Jun 2015 22:27:56 -0700 Received: from shecgisg003.sh.intel.com (shecgisg003.sh.intel.com [10.239.29.90]) by shvmail01.sh.intel.com with ESMTP id t5Q5Rsnm008824; Fri, 26 Jun 2015 13:27:54 +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 t5Q5Rpco025670; Fri, 26 Jun 2015 13:27:53 +0800 Received: (from yliu84x@localhost) by shecgisg003.sh.intel.com (8.13.6/8.13.6/Submit) id t5Q5RpSO025665; Fri, 26 Jun 2015 13:27:51 +0800 From: Yong Liu To: dts@dpdk.org Date: Fri, 26 Jun 2015 13:27:50 +0800 Message-Id: <1435296470-25633-1-git-send-email-yong.liu@intel.com> X-Mailer: git-send-email 1.7.4.1 Subject: [dts] [PATCH] fix strip virtio-pci device information failure 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, 26 Jun 2015 05:27:58 -0000 From: Marvin Liu Signed-off-by: Marvin Liu diff --git a/framework/dut.py b/framework/dut.py index 7a47fe3..662b570 100644 --- a/framework/dut.py +++ b/framework/dut.py @@ -519,12 +519,7 @@ class Dut(Crb): unknow_interface = RED('Skipped: unknow_interface') for port_info in self.ports_info: - pci_bus = port_info['pci'] - addr_array = pci_bus.split(':') - bus_id = addr_array[0] - devfun_id = addr_array[1] - - port = NetDevice(self, bus_id, devfun_id) + port = port_info['port'] intf = port.get_interface_name() if "No such file" in intf: self.logger.info("DUT: [0000:%s] %s" % (pci_bus, unknow_interface)) @@ -598,7 +593,7 @@ class Dut(Crb): devfun_id = addr_array[1] port = NetDevice(self, bus_id, devfun_id) - numa = self.get_device_numa(bus_id, devfun_id) + numa = port.socket # store the port info to port mapping self.ports_info.append( {'port': port, 'pci': pci_bus, 'type': pci_id, 'numa': numa}) diff --git a/framework/net_device.py b/framework/net_device.py index b8d785e..2681785 100644 --- a/framework/net_device.py +++ b/framework/net_device.py @@ -136,11 +136,12 @@ class NetDevice(object): """ Get interface name of specified pci device on linux. """ + driver_alias = driver.replace('-', '_') try: get_interface_name_linux = getattr( self, 'get_interface_name_linux_%s' % - driver) + driver_alias) except Exception as e: generic_driver = 'generic' get_interface_name_linux = getattr(self, @@ -148,6 +149,14 @@ class NetDevice(object): return get_interface_name_linux(bus_id, devfun_id) + def get_interface_name_linux_virtio_pci(self, bus_id, devfun_id): + """ + Get virtio device interface name by the default way on linux. + """ + command = 'ls --color=never /sys/bus/pci/devices/0000\:%s\:%s/virtio*/net' % ( + bus_id, devfun_id) + return self.__send_expect(command, '# ') + def get_interface_name_linux_generic(self, bus_id, devfun_id): """ Get the interface name by the default way on linux. @@ -192,11 +201,12 @@ class NetDevice(object): """ Get mac address of specified pci device on linux. """ + driver_alias = driver.replace('-', '_') try: get_mac_addr_linux = getattr( self, 'get_mac_addr_linux_%s' % - driver) + driver_alias) except Exception as e: generic_driver = 'generic' get_mac_addr_linux = getattr( @@ -225,6 +235,18 @@ class NetDevice(object): (bus_id, devfun_id, intf)) return self.__send_expect(command, '# ') + def get_mac_addr_linux_virtio_pci(self, intf, bus_id, devfun_id, driver): + """ + Get MAC by the default way on linux. + """ + virtio_cmd = ('ls /sys/bus/pci/devices/0000\:%s\:%s/ | grep --color=never virtio' % + (bus_id, devfun_id)) + virtio = self.__send_expect(virtio_cmd, '# ') + + command = ('cat /sys/bus/pci/devices/0000\:%s\:%s/%s/net/%s/address' % + (bus_id, devfun_id, virtio, intf)) + return self.__send_expect(command, '# ') + def get_mac_addr_freebsd(self, intf, bus_id, devfun_id, driver): """ Get mac address of specified pci device on Freebsd. diff --git a/framework/settings.py b/framework/settings.py index 9923b0c..42667bb 100644 --- a/framework/settings.py +++ b/framework/settings.py @@ -90,7 +90,7 @@ DRIVERS = { '82540EM': 'igb', 'springville': 'igb', 'springfountain': 'ixgbe', - 'virtio': 'igb', + 'virtio': 'virtio-pci', 'avoton': 'igb', 'avoton2c5': 'igb', 'I217V': 'igb', -- 1.9.3