-
Notifications
You must be signed in to change notification settings - Fork 130
lsvpd validation for spyre #3078
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -418,3 +418,76 @@ def test_pci_lscfg(self): | |
| error.append(pci_addr + " : pci_config_space") | ||
| if error: | ||
| self.fail(f"Errors for above pci addresses: {error}") | ||
|
|
||
| def test_spyre_lsvpd_validation(self): | ||
| if process.system("vpdupdate", ignore_status=True, shell=True): | ||
| self.fail("vpdupate failed") | ||
|
|
||
| spyre_devices = [] | ||
| for dev in os.listdir('/sys/bus/pci/devices'): | ||
| cls = f"/sys/bus/pci/devices/{dev}/class" | ||
| try: | ||
| with open(cls) as f: | ||
| if f.read().strip().startswith('0x1200'): | ||
| spyre_devices.append(dev) | ||
| except Exception: | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Reuse the avocado utils get_pci_class method |
||
| pass | ||
|
|
||
| if not spyre_devices: | ||
| self.cancel("Spyre accelerator not present") | ||
|
|
||
| lsvpd_out = self.run_cmd_out("lsvpd").upper() | ||
| lscfg_out = self.run_cmd_out("lscfg -VP").upper() | ||
|
|
||
| for dev in spyre_devices: | ||
| sysfs_vendor = self.run_cmd_out( | ||
| f"cat /sys/bus/pci/devices/{dev}/vendor").strip() | ||
| sysfs_device = self.run_cmd_out( | ||
| f"cat /sys/bus/pci/devices/{dev}/device").strip() | ||
| sysfs_subvendor = self.run_cmd_out( | ||
| f"cat /sys/bus/pci/devices/{dev}/subsystem_vendor").strip() | ||
| sysfs_subdevice = self.run_cmd_out( | ||
| f"cat /sys/bus/pci/devices/{dev}/subsystem_device").strip() | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. reuse pci utils |
||
|
|
||
| location_code = None | ||
| for line in lscfg_out.splitlines(): | ||
| if dev in line: | ||
| parts = line.split() | ||
| if len(parts) > 1: | ||
| location_code = parts[-1] | ||
| break | ||
|
|
||
| if not location_code: | ||
| self.fail(f"Unable to find location code for Spyre device {dev}") | ||
|
|
||
| spyre_block = [] | ||
| capture = False | ||
| for line in lsvpd_out.splitlines(): | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. indent messed up |
||
| if location_code in line: | ||
| capture = True | ||
| if capture: | ||
| if line.strip() == "" and spyre_block: | ||
| break | ||
| spyre_block.append(line) | ||
|
|
||
| if not spyre_block: | ||
| self.fail(f"No lsvpd entry found for Spyre device {dev}") | ||
|
|
||
| spyre_lsvpd = "\n".join(spyre_block) | ||
|
|
||
| ccin_vpd = self._extract_vpd_value(spyre_lsvpd, 'CCIN') | ||
| fc_vpd = self._extract_vpd_value(spyre_lsvpd, 'FC') | ||
| ec_vpd = self._extract_vpd_value(spyre_lsvpd, 'EC') | ||
| fw_vpd = self._extract_vpd_value(spyre_lsvpd, 'FW') | ||
|
|
||
| if not ccin_vpd: | ||
| self.fail(f"CCIN missing in lsvpd for Spyre device {dev}") | ||
|
|
||
| if not fc_vpd: | ||
| self.fail(f"Invalid FC value for Spyre device {dev}") | ||
|
|
||
| if not ec_vpd: | ||
| self.fail(f"Invalid EC value for Spyre device {dev}") | ||
|
|
||
| if not fw_vpd: | ||
| self.fail(f"Firmware value missing for Spyre device {dev}") | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. optimize .. may be loop ? |
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indentation messed up.. please fix it