Skip to content

Commit 6467d07

Browse files
ksatya-devAlex Williamson
authored andcommitted
vfio/pci: Add DVSEC PCI Extended Config Capability to user visible list.
The Designated Vendor-Specific Extended Capability (DVSEC Capability) is an optional Extended Capability that is permitted to be implemented by any PCI Express Function. This allows PCI Express component vendors to use the Extended Capability mechanism to expose vendor-specific registers that can be present in components by a variety of vendors. A DVSEC Capability structure can tell vendor-specific software which features a particular component supports. An example usage of DVSEC is Intel Platform Monitoring Technology (PMT) for enumerating and accessing hardware monitoring capabilities on a device. PMT encompasses three device monitoring features, Telemetry (device metrics), Watcher (sampling/tracing), and Crashlog. The DVSEC is used to discover these features and provide a BAR offset to their registers with the Intel vendor code. The current VFIO driver does not pass DVSEC capabilities to Virtual Machine (VM) which makes PMT not to work inside the virtual machine. This series adds DVSEC capability to user visible list to allow its use with VFIO. VFIO supports passing of Vendor Specific Extended Capability (VSEC) and raw write access to device. DVSEC also passed to VM in the same way as of VSEC. Signed-off-by: K V P Satyanarayana <satyanarayana.k.v.p@intel.com> Link: https://lore.kernel.org/r/20230317082222.3355912-1-satyanarayana.k.v.p@intel.com Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
1 parent 09a9639 commit 6467d07

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

drivers/vfio/pci/vfio_pci_config.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ static const u16 pci_ext_cap_length[PCI_EXT_CAP_ID_MAX + 1] = {
9696
[PCI_EXT_CAP_ID_SECPCI] = 0, /* not yet */
9797
[PCI_EXT_CAP_ID_PMUX] = 0, /* not yet */
9898
[PCI_EXT_CAP_ID_PASID] = 0, /* not yet */
99+
[PCI_EXT_CAP_ID_DVSEC] = 0xFF,
99100
};
100101

101102
/*
@@ -1101,6 +1102,7 @@ int __init vfio_pci_init_perm_bits(void)
11011102
ret |= init_pci_ext_cap_err_perm(&ecap_perms[PCI_EXT_CAP_ID_ERR]);
11021103
ret |= init_pci_ext_cap_pwr_perm(&ecap_perms[PCI_EXT_CAP_ID_PWR]);
11031104
ecap_perms[PCI_EXT_CAP_ID_VNDR].writefn = vfio_raw_config_write;
1105+
ecap_perms[PCI_EXT_CAP_ID_DVSEC].writefn = vfio_raw_config_write;
11041106

11051107
if (ret)
11061108
vfio_pci_uninit_perm_bits();
@@ -1440,6 +1442,11 @@ static int vfio_ext_cap_len(struct vfio_pci_core_device *vdev, u16 ecap, u16 epo
14401442
return PCI_TPH_BASE_SIZEOF + (sts * 2) + 2;
14411443
}
14421444
return PCI_TPH_BASE_SIZEOF;
1445+
case PCI_EXT_CAP_ID_DVSEC:
1446+
ret = pci_read_config_dword(pdev, epos + PCI_DVSEC_HEADER1, &dword);
1447+
if (ret)
1448+
return pcibios_err_to_errno(ret);
1449+
return PCI_DVSEC_HEADER1_LEN(dword);
14431450
default:
14441451
pci_warn(pdev, "%s: unknown length for PCI ecap %#x@%#x\n",
14451452
__func__, ecap, epos);

0 commit comments

Comments
 (0)