[dts] [PATCH 5/6] framework:net_device : adding function get_interface_name_Mellanox to get the ConnectX_3_Pro interfaces

Raslan Darawsheh rasland at mellanox.com
Tue Oct 27 07:07:54 CET 2015


From: Raslsn Darawsheh <rdarawsheh at asaltech.com>

Signed-off-by: Raslsn Darawsheh <rdarawsheh at asaltech.com>
---
 framework/net_device.py | 39 ++++++++++++++++++++++++++++++++-------
 1 file changed, 32 insertions(+), 7 deletions(-)

diff --git a/framework/net_device.py b/framework/net_device.py
index 37495bd..ac121cc 100644
--- a/framework/net_device.py
+++ b/framework/net_device.py
@@ -127,17 +127,42 @@ class NetDevice(object):
         Get interface name of specified pci device.
         Cal this function will update intf_name everytime
         """
-        get_interface_name = getattr(
-            self, 'get_interface_name_%s' %
-            self.__get_os_type())
-        out = get_interface_name(self.bus_id, self.devfun_id, self.current_driver)
-        if "No such file or directory" in out:
-            self.intf_name = 'N/A'
+        if self.crb.isMellanox and self.crb.mellanoxCardType == "cx3":
+            self.intf_name = self.get_interface_name_Mellanox(self.bus_id,self.devfun_id)
         else:
-            self.intf_name = out
+            get_interface_name = getattr(
+                self, 'get_interface_name_%s' %
+                self.__get_os_type())
+            out = get_interface_name(self.bus_id, self.devfun_id, self.current_driver)
+            if "No such file or directory" in out:
+                self.intf_name = 'N/A'
+            else:
+                self.intf_name = out
 
         return self.intf_name
 
+    def get_interface_name_Mellanox(self,bus_id,devfun_id):
+        """
+        Get interface name of specified pci device for Mellanox.
+        """
+        command = 'ls --color=never /sys/bus/pci/devices/0000:%s:%s/net' % (bus_id, devfun_id)
+        out = self.crb.send_expect(command, '# ', verify=True)
+
+        if out == -1:
+            name = ""
+        else:
+            if self.crb.mellanoxPortCount == 0 :
+                name = out.split()[0]
+                self.crb.mellanoxPortCount = 1
+            else :
+                if len(out.split()) < 2 :
+                    self.crb.isMellanox = False
+                    name = out.split()[0]
+                    return name
+                name = out.split()[1]
+                self.crb.mellanoxPortCount = 0
+        return name
+
     def get_interface_name_linux(self, bus_id, devfun_id, driver):
         """
         Get interface name of specified pci device on linux.
-- 
1.8.3.1



More information about the dts mailing list