From: Alex Williamson <alex.williamson@redhat.com>
To: robin@streamhpc.com, mst@redhat.com, marcel.apfelbaum@gmail.com
Cc: Alex Williamson <alex.williamson@redhat.com>,
qemu-devel@nongnu.org, clg@redhat.com
Subject: [RFC PATCH v2 3/4] pcie: Add a PCIe capability version helper
Date: Fri, 26 May 2023 17:15:57 -0600 [thread overview]
Message-ID: <20230526231558.1660396-4-alex.williamson@redhat.com> (raw)
In-Reply-To: <20230526231558.1660396-1-alex.williamson@redhat.com>
Report the PCIe capability version for a device
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
---
hw/pci/pcie.c | 7 +++++++
include/hw/pci/pcie.h | 1 +
2 files changed, 8 insertions(+)
diff --git a/hw/pci/pcie.c b/hw/pci/pcie.c
index b8c24cf45f7e..b7f107ed8dd4 100644
--- a/hw/pci/pcie.c
+++ b/hw/pci/pcie.c
@@ -274,6 +274,13 @@ uint8_t pcie_cap_get_type(const PCIDevice *dev)
PCI_EXP_FLAGS_TYPE) >> PCI_EXP_FLAGS_TYPE_SHIFT;
}
+uint8_t pcie_cap_get_version(const PCIDevice *dev)
+{
+ uint32_t pos = dev->exp.exp_cap;
+ assert(pos > 0);
+ return pci_get_word(dev->config + pos + PCI_EXP_FLAGS) & PCI_EXP_FLAGS_VERS;
+}
+
/* MSI/MSI-X */
/* pci express interrupt message number */
/* 7.8.2 PCI Express Capabilities Register: Interrupt Message Number */
diff --git a/include/hw/pci/pcie.h b/include/hw/pci/pcie.h
index 3cc2b159570f..51ab57bc3c50 100644
--- a/include/hw/pci/pcie.h
+++ b/include/hw/pci/pcie.h
@@ -93,6 +93,7 @@ void pcie_cap_exit(PCIDevice *dev);
int pcie_endpoint_cap_v1_init(PCIDevice *dev, uint8_t offset);
void pcie_cap_v1_exit(PCIDevice *dev);
uint8_t pcie_cap_get_type(const PCIDevice *dev);
+uint8_t pcie_cap_get_version(const PCIDevice *dev);
void pcie_cap_flags_set_vector(PCIDevice *dev, uint8_t vector);
uint8_t pcie_cap_flags_get_vector(PCIDevice *dev);
--
2.39.2
next prev parent reply other threads:[~2023-05-26 23:16 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-26 23:15 [RFC PATCH v2 0/4] vfio/pci: Atomic Ops completer support Alex Williamson
2023-05-26 23:15 ` [RFC PATCH v2 1/4] linux-headers: Update for vfio capability reporting AtomicOps Alex Williamson
2023-05-30 13:19 ` Cédric Le Goater
2023-05-26 23:15 ` [RFC PATCH v2 2/4] vfio: Implement a common device info helper Alex Williamson
2023-05-31 10:18 ` Robin Voetter
2023-05-26 23:15 ` Alex Williamson [this message]
2023-05-30 12:30 ` [RFC PATCH v2 3/4] pcie: Add a PCIe capability version helper Cédric Le Goater
2023-05-31 22:02 ` Robin Voetter
2023-05-31 22:19 ` Philippe Mathieu-Daudé
2023-05-26 23:15 ` [RFC PATCH v2 4/4] vfio/pci: Enable AtomicOps completers on root ports Alex Williamson
2023-05-30 13:36 ` Cédric Le Goater
2023-05-31 22:03 ` Robin Voetter
2023-05-31 22:28 ` Philippe Mathieu-Daudé
2023-05-31 21:55 ` [RFC PATCH v2 0/4] vfio/pci: Atomic Ops completer support Robin Voetter
2023-05-31 22:24 ` Alex Williamson
2023-05-31 22:29 ` Philippe Mathieu-Daudé
2023-06-02 14:02 ` Philippe Mathieu-Daudé
2023-06-01 8:15 ` Robin Voetter
2023-05-31 22:31 ` Philippe Mathieu-Daudé
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230526231558.1660396-4-alex.williamson@redhat.com \
--to=alex.williamson@redhat.com \
--cc=clg@redhat.com \
--cc=marcel.apfelbaum@gmail.com \
--cc=mst@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=robin@streamhpc.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).