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
1diff --git a/checkbox_support/lib/pci.py b/checkbox_support/lib/pci.py
2index 2cb7355..94983c7 100644
3--- a/checkbox_support/lib/pci.py
4+++ b/checkbox_support/lib/pci.py
5@@ -39,6 +39,10 @@ class Pci(object):
6 CLASS_NETWORK_TOKEN_RING = 1
7 CLASS_NETWORK_FDDI = 2
8 CLASS_NETWORK_ATM = 3
9+ CLASS_NETWORK_ISDN = 4
10+ CLASS_NETWORK_WORLDFIP = 5
11+ CLASS_NETWORK_PICMG = 6
12+ CLASS_NETWORK_INFINIBAND = 7
13 CLASS_NETWORK_OTHER = 80
14 CLASS_NETWORK_WIRELESS = 128
15
16diff --git a/checkbox_support/parsers/udevadm.py b/checkbox_support/parsers/udevadm.py
17index 55efe46..e1a5289 100644
18--- a/checkbox_support/parsers/udevadm.py
19+++ b/checkbox_support/parsers/udevadm.py
20@@ -232,6 +232,22 @@ class UdevadmDevice(object):
21 self._environment["INTERFACE"].startswith('wlan')
22 )):
23 return "WIRELESS"
24+ if self._stack:
25+ parent = self._stack[-1]
26+ if "PCI_CLASS" in parent._environment:
27+ pci_class_string = parent._environment["PCI_CLASS"]
28+ pci_class = int(pci_class_string, 16)
29+
30+ # Strip prog_if if defined
31+ if pci_class > 0xFFFF:
32+ pci_class >>= 8
33+
34+ subclass_id = pci_class & 0xFF
35+ class_id = (pci_class >> 8) & 0xFF
36+
37+ if class_id == Pci.BASE_CLASS_NETWORK:
38+ if subclass_id == Pci.CLASS_NETWORK_INFINIBAND:
39+ return "INFINIBAND"
40 return "NETWORK"
41
42 if self.bus == "bluetooth":
43@@ -881,7 +897,7 @@ class UdevadmDevice(object):
44 def interface(self):
45 if self._interface is not None:
46 return self._interface
47- if self.category in ("NETWORK", "WIRELESS", "WWAN"):
48+ if self.category in ("INFINIBAND", "NETWORK", "WIRELESS", "WWAN"):
49 if "INTERFACE" in self._environment:
50 return self._environment["INTERFACE"]
51 else:
52@@ -892,7 +908,7 @@ class UdevadmDevice(object):
53 def mac(self):
54 if self._mac is not None:
55 return self._mac
56- if self.category in ("NETWORK", "WIRELESS", "WWAN"):
57+ if self.category in ("INFINIBAND", "NETWORK", "WIRELESS", "WWAN"):
58 if "ID_NET_NAME_MAC" in self._environment:
59 mac = self._environment["ID_NET_NAME_MAC"][3:]
60 return ':'.join([mac[i:i+2] for i in range(0, len(mac), 2)])
61@@ -1125,10 +1141,12 @@ class UdevadmParser(object):
62 dev_mapper_devices.append(d)
63
64 for device in list(self.devices.values()):
65- if device.category in ("NETWORK", "WIRELESS", "WWAN", "OTHER"):
66+ if device.category in ("INFINIBAND", "NETWORK",
67+ "WIRELESS", "WWAN", "OTHER"):
68 dev_interface = [
69 d for d in self.devices.values()
70- if d.category in ("NETWORK", "WIRELESS", "WWAN") and
71+ if d.category in ("INFINIBAND", "NETWORK",
72+ "WIRELESS", "WWAN") and
73 device._raw_path != d._raw_path and
74 device._raw_path + '/' in d._raw_path
75 ]

Subscribers

People subscribed via source and target branches