test suite reviews and discussions
 help / color / mirror / Atom feed
* [dts] [PATCH] fix strip virtio-pci device information failure
@ 2015-06-26  5:27 Yong Liu
  0 siblings, 0 replies; only message in thread
From: Yong Liu @ 2015-06-26  5:27 UTC (permalink / raw)
  To: dts

From: Marvin Liu <yong.liu@intel.com>

Signed-off-by: Marvin Liu <yong.liu@intel.com>

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

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2015-06-26  5:27 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-06-26  5:27 [dts] [PATCH] fix strip virtio-pci device information failure Yong Liu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).