Merge ~sylvain-pineau/checkbox-support:udev_infiniband into checkbox-support:master

Proposed by Sylvain Pineau
Status: Merged
Approved by: Sylvain Pineau
Approved revision: 349d729b7b5f1f7b24cc11e892298c97dd95938b
Merged at revision: 93f654b77a2d67485e4ff26d6cc2976b0689533b
Proposed branch: ~sylvain-pineau/checkbox-support:udev_infiniband
Merge into: checkbox-support:master
Diff against target: 75 lines (+26/-4)
2 files modified
checkbox_support/lib/pci.py (+4/-0)
checkbox_support/parsers/udevadm.py (+22/-4)
Reviewer Review Type Date Requested Status
Paul Larson Approve
Review via email: mp+333978@code.launchpad.net

Description of the change

Add a new category for INFINIBAND controllers, to avoid having them under NETWORK alongside Ethernet controllers.

To post a comment you must log in.
Revision history for this message
Paul Larson (pwlars) wrote :

+1

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
diff --git a/checkbox_support/lib/pci.py b/checkbox_support/lib/pci.py
index 2cb7355..94983c7 100644
--- a/checkbox_support/lib/pci.py
+++ b/checkbox_support/lib/pci.py
@@ -39,6 +39,10 @@ class Pci(object):
39 CLASS_NETWORK_TOKEN_RING = 139 CLASS_NETWORK_TOKEN_RING = 1
40 CLASS_NETWORK_FDDI = 240 CLASS_NETWORK_FDDI = 2
41 CLASS_NETWORK_ATM = 341 CLASS_NETWORK_ATM = 3
42 CLASS_NETWORK_ISDN = 4
43 CLASS_NETWORK_WORLDFIP = 5
44 CLASS_NETWORK_PICMG = 6
45 CLASS_NETWORK_INFINIBAND = 7
42 CLASS_NETWORK_OTHER = 8046 CLASS_NETWORK_OTHER = 80
43 CLASS_NETWORK_WIRELESS = 12847 CLASS_NETWORK_WIRELESS = 128
4448
diff --git a/checkbox_support/parsers/udevadm.py b/checkbox_support/parsers/udevadm.py
index 55efe46..e1a5289 100644
--- a/checkbox_support/parsers/udevadm.py
+++ b/checkbox_support/parsers/udevadm.py
@@ -232,6 +232,22 @@ class UdevadmDevice(object):
232 self._environment["INTERFACE"].startswith('wlan')232 self._environment["INTERFACE"].startswith('wlan')
233 )):233 )):
234 return "WIRELESS"234 return "WIRELESS"
235 if self._stack:
236 parent = self._stack[-1]
237 if "PCI_CLASS" in parent._environment:
238 pci_class_string = parent._environment["PCI_CLASS"]
239 pci_class = int(pci_class_string, 16)
240
241 # Strip prog_if if defined
242 if pci_class > 0xFFFF:
243 pci_class >>= 8
244
245 subclass_id = pci_class & 0xFF
246 class_id = (pci_class >> 8) & 0xFF
247
248 if class_id == Pci.BASE_CLASS_NETWORK:
249 if subclass_id == Pci.CLASS_NETWORK_INFINIBAND:
250 return "INFINIBAND"
235 return "NETWORK"251 return "NETWORK"
236252
237 if self.bus == "bluetooth":253 if self.bus == "bluetooth":
@@ -881,7 +897,7 @@ class UdevadmDevice(object):
881 def interface(self):897 def interface(self):
882 if self._interface is not None:898 if self._interface is not None:
883 return self._interface899 return self._interface
884 if self.category in ("NETWORK", "WIRELESS", "WWAN"):900 if self.category in ("INFINIBAND", "NETWORK", "WIRELESS", "WWAN"):
885 if "INTERFACE" in self._environment:901 if "INTERFACE" in self._environment:
886 return self._environment["INTERFACE"]902 return self._environment["INTERFACE"]
887 else:903 else:
@@ -892,7 +908,7 @@ class UdevadmDevice(object):
892 def mac(self):908 def mac(self):
893 if self._mac is not None:909 if self._mac is not None:
894 return self._mac910 return self._mac
895 if self.category in ("NETWORK", "WIRELESS", "WWAN"):911 if self.category in ("INFINIBAND", "NETWORK", "WIRELESS", "WWAN"):
896 if "ID_NET_NAME_MAC" in self._environment:912 if "ID_NET_NAME_MAC" in self._environment:
897 mac = self._environment["ID_NET_NAME_MAC"][3:]913 mac = self._environment["ID_NET_NAME_MAC"][3:]
898 return ':'.join([mac[i:i+2] for i in range(0, len(mac), 2)])914 return ':'.join([mac[i:i+2] for i in range(0, len(mac), 2)])
@@ -1125,10 +1141,12 @@ class UdevadmParser(object):
1125 dev_mapper_devices.append(d)1141 dev_mapper_devices.append(d)
11261142
1127 for device in list(self.devices.values()):1143 for device in list(self.devices.values()):
1128 if device.category in ("NETWORK", "WIRELESS", "WWAN", "OTHER"):1144 if device.category in ("INFINIBAND", "NETWORK",
1145 "WIRELESS", "WWAN", "OTHER"):
1129 dev_interface = [1146 dev_interface = [
1130 d for d in self.devices.values()1147 d for d in self.devices.values()
1131 if d.category in ("NETWORK", "WIRELESS", "WWAN") and1148 if d.category in ("INFINIBAND", "NETWORK",
1149 "WIRELESS", "WWAN") and
1132 device._raw_path != d._raw_path and1150 device._raw_path != d._raw_path and
1133 device._raw_path + '/' in d._raw_path1151 device._raw_path + '/' in d._raw_path
1134 ]1152 ]

Subscribers

People subscribed via source and target branches