mirror of
https://git.proxmox.com/git/pve-common
synced 2025-07-15 04:06:52 +00:00
SysFSTools: add verbose flag to pci_device_info
to also get the subsystem_vendor and device, as well as the iommu group and mediated device support Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
This commit is contained in:
parent
a03e5b39e1
commit
aa59b1121c
@ -197,20 +197,22 @@ sub file_write {
|
|||||||
}
|
}
|
||||||
|
|
||||||
sub pci_device_info {
|
sub pci_device_info {
|
||||||
my ($name) = @_;
|
my ($name, $verbose) = @_;
|
||||||
|
|
||||||
my $res;
|
my $res;
|
||||||
|
|
||||||
return undef if $name !~ m/^${pciregex}$/;
|
return undef if $name !~ m/^${pciregex}$/;
|
||||||
my ($domain, $bus, $slot, $func) = ($1, $2, $3, $4);
|
my ($domain, $bus, $slot, $func) = ($1, $2, $3, $4);
|
||||||
|
|
||||||
my $irq = file_read_firstline("$pcisysfs/devices/$name/irq");
|
my $devdir = "$pcisysfs/devices/$name";
|
||||||
|
|
||||||
|
my $irq = file_read_firstline("$devdir/irq");
|
||||||
return undef if !defined($irq) || $irq !~ m/^\d+$/;
|
return undef if !defined($irq) || $irq !~ m/^\d+$/;
|
||||||
|
|
||||||
my $vendor = file_read_firstline("$pcisysfs/devices/$name/vendor");
|
my $vendor = file_read_firstline("$devdir/vendor");
|
||||||
return undef if !defined($vendor) || $vendor !~ s/^0x//;
|
return undef if !defined($vendor) || $vendor !~ s/^0x//;
|
||||||
|
|
||||||
my $product = file_read_firstline("$pcisysfs/devices/$name/device");
|
my $product = file_read_firstline("$devdir/device");
|
||||||
return undef if !defined($product) || $product !~ s/^0x//;
|
return undef if !defined($product) || $product !~ s/^0x//;
|
||||||
|
|
||||||
$res = {
|
$res = {
|
||||||
@ -225,6 +227,25 @@ sub pci_device_info {
|
|||||||
has_fl_reset => -f "$pcisysfs/devices/$name/reset" || 0,
|
has_fl_reset => -f "$pcisysfs/devices/$name/reset" || 0,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if ($verbose) {
|
||||||
|
my $sub_vendor = file_read_firstline("$devdir/subsystem_vendor");
|
||||||
|
$sub_vendor =~ s/^0x// if defined($sub_vendor);
|
||||||
|
my $sub_device = file_read_firstline("$devdir/subsystem_device");
|
||||||
|
$sub_device =~ s/^0x// if defined($sub_device);
|
||||||
|
|
||||||
|
$res->{subsystem_vendor} = $sub_vendor if defined($sub_vendor);
|
||||||
|
$res->{subsystem_device} = $sub_device if defined($sub_device);
|
||||||
|
|
||||||
|
if (-e "$devdir/iommu_group") {
|
||||||
|
my ($iommugroup) = (readlink("$devdir/iommu_group") =~ m/\/(\d+)$/);
|
||||||
|
$res->{iommugroup} = int($iommugroup);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (-d "$devdir/mdev_supported_types") {
|
||||||
|
$res->{mdev} = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return $res;
|
return $res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user