[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v2 3/4] Add "Group Identifier" support to Red Hat PC
From: |
Venu Busireddy |
Subject: |
[Qemu-devel] [PATCH v2 3/4] Add "Group Identifier" support to Red Hat PCI bridge. |
Date: |
Tue, 26 Jun 2018 22:49:33 -0500 |
Add the "Vendor-Specific" capability to the Red Hat PCI bridge device
"pci-bridge", to contain the "Group Identifier" (UUID) that will be
used to pair a virtio device with the passthrough device attached to
that bridge.
This capability is added to the bridge iff the "uuid" option is specified
for the bridge.
Signed-off-by: Venu Busireddy <address@hidden>
---
hw/pci-bridge/pci_bridge_dev.c | 8 ++++++++
hw/pci/pci_bridge.c | 26 ++++++++++++++++++++++++++
include/hw/pci/pcie.h | 1 +
3 files changed, 35 insertions(+)
diff --git a/hw/pci-bridge/pci_bridge_dev.c b/hw/pci-bridge/pci_bridge_dev.c
index b2d861d216..bbbc6fa1c6 100644
--- a/hw/pci-bridge/pci_bridge_dev.c
+++ b/hw/pci-bridge/pci_bridge_dev.c
@@ -71,6 +71,12 @@ static void pci_bridge_dev_realize(PCIDevice *dev, Error
**errp)
bridge_dev->msi = ON_OFF_AUTO_OFF;
}
+ err = pci_bridge_vendor_init(dev, 0, errp);
+ if (err < 0) {
+ error_append_hint(errp, "Can't init group ID, error %d\n", err);
+ goto vendor_cap_err;
+ }
+
err = slotid_cap_init(dev, 0, bridge_dev->chassis_nr, 0, errp);
if (err) {
goto slotid_error;
@@ -109,6 +115,7 @@ slotid_error:
if (shpc_present(dev)) {
shpc_cleanup(dev, &bridge_dev->bar);
}
+vendor_cap_err:
shpc_error:
pci_bridge_exitfn(dev);
}
@@ -162,6 +169,7 @@ static Property pci_bridge_dev_properties[] = {
ON_OFF_AUTO_AUTO),
DEFINE_PROP_BIT(PCI_BRIDGE_DEV_PROP_SHPC, PCIBridgeDev, flags,
PCI_BRIDGE_DEV_F_SHPC_REQ, true),
+ DEFINE_PROP_UUID(COMPAT_PROP_UUID, PCIDevice, uuid, false),
DEFINE_PROP_END_OF_LIST(),
};
diff --git a/hw/pci/pci_bridge.c b/hw/pci/pci_bridge.c
index 40a39f57cb..cb8b3dad2a 100644
--- a/hw/pci/pci_bridge.c
+++ b/hw/pci/pci_bridge.c
@@ -34,12 +34,17 @@
#include "hw/pci/pci_bus.h"
#include "qemu/range.h"
#include "qapi/error.h"
+#include "qemu/uuid.h"
/* PCI bridge subsystem vendor ID helper functions */
#define PCI_SSVID_SIZEOF 8
#define PCI_SSVID_SVID 4
#define PCI_SSVID_SSID 6
+#define PCI_VENDOR_SIZEOF 20
+#define PCI_VENDOR_CAP_LEN_OFFSET 2
+#define PCI_VENDOR_GROUP_ID_OFFSET 4
+
int pci_bridge_ssvid_init(PCIDevice *dev, uint8_t offset,
uint16_t svid, uint16_t ssid,
Error **errp)
@@ -57,6 +62,27 @@ int pci_bridge_ssvid_init(PCIDevice *dev, uint8_t offset,
return pos;
}
+int pci_bridge_vendor_init(PCIDevice *d, uint8_t offset, Error **errp)
+{
+ int pos;
+
+ if (qemu_uuid_is_null(&d->uuid)) {
+ return 0;
+ }
+
+ pos = pci_add_capability(d, PCI_CAP_ID_VNDR, offset, PCI_VENDOR_SIZEOF,
+ errp);
+ if (pos < 0) {
+ return pos;
+ }
+
+ pci_set_word(d->config + pos + PCI_VENDOR_CAP_LEN_OFFSET,
+ PCI_VENDOR_SIZEOF);
+ memcpy(d->config + pos + PCI_VENDOR_GROUP_ID_OFFSET, &d->uuid,
+ sizeof(QemuUUID));
+ return pos;
+}
+
/* Accessor function to get parent bridge device from pci bus. */
PCIDevice *pci_bridge_get_device(PCIBus *bus)
{
diff --git a/include/hw/pci/pcie.h b/include/hw/pci/pcie.h
index b71e369703..b4189d0ce3 100644
--- a/include/hw/pci/pcie.h
+++ b/include/hw/pci/pcie.h
@@ -82,6 +82,7 @@ struct PCIExpressDevice {
};
#define COMPAT_PROP_PCP "power_controller_present"
+#define COMPAT_PROP_UUID "uuid"
/* PCI express capability helper functions */
int pcie_cap_init(PCIDevice *dev, uint8_t offset, uint8_t type,
- [Qemu-devel] [PATCH v2 0/4] Use of unique identifier for pairing virtio and passthrough devices..., Venu Busireddy, 2018/06/26
- [Qemu-devel] [PATCH v2 1/4] Add a true or false option to the DEFINE_PROP_UUID macro., Venu Busireddy, 2018/06/26
- [Qemu-devel] [PATCH v2 2/4] Add "Group Identifier" support to virtio devices., Venu Busireddy, 2018/06/26
- [Qemu-devel] [PATCH v2 3/4] Add "Group Identifier" support to Red Hat PCI bridge.,
Venu Busireddy <=
- Re: [Qemu-devel] [PATCH v2 3/4] Add "Group Identifier" support to Red Hat PCI bridge., Michael S. Tsirkin, 2018/06/27
- Re: [Qemu-devel] [virtio-dev] Re: [PATCH v2 3/4] Add "Group Identifier" support to Red Hat PCI bridge., Venu Busireddy, 2018/06/27
- Re: [Qemu-devel] [virtio-dev] Re: [PATCH v2 3/4] Add "Group Identifier" support to Red Hat PCI bridge., Venu Busireddy, 2018/06/27
- Re: [Qemu-devel] [virtio-dev] Re: [PATCH v2 3/4] Add "Group Identifier" support to Red Hat PCI bridge., Michael S. Tsirkin, 2018/06/27
- Re: [Qemu-devel] [virtio-dev] Re: [PATCH v2 3/4] Add "Group Identifier" support to Red Hat PCI bridge., Venu Busireddy, 2018/06/27
- Re: [Qemu-devel] [virtio-dev] Re: [PATCH v2 3/4] Add "Group Identifier" support to Red Hat PCI bridge., Siwei Liu, 2018/06/28
- Re: [Qemu-devel] [PATCH v2 3/4] Add "Group Identifier" support to Red Hat PCI bridge., Daniel P . Berrangé, 2018/06/28
- [Qemu-devel] Retrieving configuration metadata from hypervisor (was: Re: [PATCH v2 3/4] Add "Group Identifier" support to Red Hat PCI bridge.), Cornelia Huck, 2018/06/28
[Qemu-devel] [PATCH v2 4/4] Add "Group Identifier" support to Red Hat PCI Express bridge., Venu Busireddy, 2018/06/26
[Qemu-devel] [PATCH v2 virtio 1/1] Add "Group Identifier" to virtio PCI capabilities., Venu Busireddy, 2018/06/26