]> git.ipfire.org Git - thirdparty/qemu.git/commitdiff
pcie: Helper functions to check to check if PRI is enabled
authorCLEMENT MATHIEU--DRIF <clement.mathieu--drif@eviden.com>
Tue, 20 May 2025 07:18:57 +0000 (07:18 +0000)
committerMichael S. Tsirkin <mst@redhat.com>
Sun, 1 Jun 2025 10:38:53 +0000 (06:38 -0400)
pri_enabled can be used to check whether the capability is present and
enabled on a PCIe device

Signed-off-by: Clement Mathieu--Drif <clement.mathieu--drif@eviden.com>
Message-Id: <20250520071823.764266-6-clement.mathieu--drif@eviden.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
hw/pci/pcie.c
include/hw/pci/pcie.h

index 542172b3fac812bc54b77c9fdbd41826c961a26a..eaeb68894e6ecc69ca93243ae57c4a38438c3e1b 100644 (file)
@@ -1266,6 +1266,15 @@ void pcie_pri_init(PCIDevice *dev, uint16_t offset, uint32_t outstanding_pr_cap,
     dev->exp.pri_cap = offset;
 }
 
+bool pcie_pri_enabled(const PCIDevice *dev)
+{
+    if (!pci_is_express(dev) || !dev->exp.pri_cap) {
+        return false;
+    }
+    return (pci_get_word(dev->config + dev->exp.pri_cap + PCI_PRI_CTRL) &
+                PCI_PRI_CTRL_ENABLE) != 0;
+}
+
 bool pcie_pasid_enabled(const PCIDevice *dev)
 {
     if (!pci_is_express(dev) || !dev->exp.pasid_cap) {
index 17f06cd5d6a8c50076d9f36fdd9bbf8184baeb60..ff6ce08e135a4f7bc488d22f6ef79a282a3aaf73 100644 (file)
@@ -158,6 +158,7 @@ void pcie_pasid_init(PCIDevice *dev, uint16_t offset, uint8_t pasid_width,
 void pcie_pri_init(PCIDevice *dev, uint16_t offset, uint32_t outstanding_pr_cap,
                    bool prg_response_pasid_req);
 
+bool pcie_pri_enabled(const PCIDevice *dev);
 bool pcie_pasid_enabled(const PCIDevice *dev);
 bool pcie_ats_enabled(const PCIDevice *dev);
 #endif /* QEMU_PCIE_H */