[dts] [PATCH 2/3] nics/net_device: add a function to get nic speed

Ali Alnubani alialnu at mellanox.com
Thu Mar 29 16:09:58 CEST 2018


Needed to differentiate between nics with same
device identifier, but with different speeds.

Signed-off-by: Ali Alnubani <alialnu at mellanox.com>
---
 nics/net_device.py | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/nics/net_device.py b/nics/net_device.py
index 4861145..037956e 100644
--- a/nics/net_device.py
+++ b/nics/net_device.py
@@ -539,6 +539,19 @@ class NetDevice(object):
         """
         return self.crb.get_pci_dev_id(self.domain_id, self.bus_id, self.devfun_id)
 
+    def get_nic_speed(self):
+        """
+        Get the speed of specified pci device.
+        """
+        command = ('cat /sys/bus/pci/devices/%s\:%s\:%s/net/*/speed' % ( \
+                self.domain_id, self.bus_id, self.devfun_id))
+        try:
+            nic_speed = self.__send_expect(command, '# ')
+        except Exception as e:
+            print 'Failed to get the speed of the pci device [%s:%s:%s]: %s' \
+                    % (self.domain_id, self.bus_id, self.devfun_id, e)
+        return self.__send_expect(command, '# ')
+
     @nic_has_driver
     def get_sriov_vfs_pci(self):
         """
-- 
2.7.4



More information about the dts mailing list