From: Venu Busireddy <venu.busireddy@oracle.com>
To: venu.busireddy@oracle.com, "Michael S . Tsirkin" <mst@redhat.com>,
Marcel Apfelbaum <marcel@redhat.com>
Cc: virtio-dev@lists.oasis-open.org, qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH 3/3] Add "Group Identifier" support to virtio devices.
Date: Tue, 19 Jun 2018 11:32:27 -0500 [thread overview]
Message-ID: <20180619163228.13790-4-venu.busireddy@oracle.com> (raw)
In-Reply-To: <20180619163228.13790-1-venu.busireddy@oracle.com>
Use the virtio PCI capability "VIRTIO_PCI_CAP_GROUP_ID_CFG" to store the
"Group Identifier" (UUID) specified via the command line option "uuid"
for the virtio device. The capability will be present in the virtio
device's configuration space iff the "uuid" option is specified.
Group Identifier is used to pair a virtio device with a passthrough
device.
Signed-off-by: Venu Busireddy <venu.busireddy@oracle.com>
---
hw/virtio/virtio-pci.c | 15 +++++++++++++++
hw/virtio/virtio-pci.h | 3 ++-
include/standard-headers/linux/virtio_pci.h | 8 ++++++++
3 files changed, 25 insertions(+), 1 deletion(-)
diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c
index 3a01fe90f0..9c2ef16773 100644
--- a/hw/virtio/virtio-pci.c
+++ b/hw/virtio/virtio-pci.c
@@ -36,6 +36,7 @@
#include "qemu/range.h"
#include "hw/virtio/virtio-bus.h"
#include "qapi/visitor.h"
+#include "qemu/uuid.h"
#define VIRTIO_PCI_REGION_SIZE(dev) VIRTIO_PCI_CONFIG_OFF(msix_present(dev))
@@ -1638,6 +1639,10 @@ static void virtio_pci_device_plugged(DeviceState *d, Error **errp)
.cap.cap_len = sizeof cfg,
.cap.cfg_type = VIRTIO_PCI_CAP_PCI_CFG,
};
+ struct virtio_pci_group_id_cap group = {
+ .cap.cap_len = sizeof group,
+ .cap.cfg_type = VIRTIO_PCI_CAP_GROUP_ID_CFG,
+ };
struct virtio_pci_notify_cap notify_pio = {
.cap.cap_len = sizeof notify,
.notify_off_multiplier = cpu_to_le32(0x0),
@@ -1647,6 +1652,11 @@ static void virtio_pci_device_plugged(DeviceState *d, Error **errp)
virtio_pci_modern_regions_init(proxy);
+ if (!qemu_uuid_is_null(&proxy->pci_dev.uuid)) {
+ memcpy(group.group_id, &proxy->pci_dev.uuid, sizeof(QemuUUID));
+ virtio_pci_modern_mem_region_map(proxy, &proxy->group, &group.cap);
+ }
+
virtio_pci_modern_mem_region_map(proxy, &proxy->common, &cap);
virtio_pci_modern_mem_region_map(proxy, &proxy->isr, &cap);
virtio_pci_modern_mem_region_map(proxy, &proxy->device, &cap);
@@ -1763,6 +1773,10 @@ static void virtio_pci_realize(PCIDevice *pci_dev, Error **errp)
proxy->device.size = 0x1000;
proxy->device.type = VIRTIO_PCI_CAP_DEVICE_CFG;
+ proxy->group.offset = 0;
+ proxy->group.size = 0;
+ proxy->group.type = VIRTIO_PCI_CAP_GROUP_ID_CFG;
+
proxy->notify.offset = 0x3000;
proxy->notify.size = virtio_pci_queue_mem_mult(proxy) * VIRTIO_QUEUE_MAX;
proxy->notify.type = VIRTIO_PCI_CAP_NOTIFY_CFG;
@@ -1898,6 +1912,7 @@ static Property virtio_pci_properties[] = {
VIRTIO_PCI_FLAG_INIT_LNKCTL_BIT, true),
DEFINE_PROP_BIT("x-pcie-pm-init", VirtIOPCIProxy, flags,
VIRTIO_PCI_FLAG_INIT_PM_BIT, true),
+ DEFINE_PROP_UUID("uuid", PCIDevice, uuid, false),
DEFINE_PROP_END_OF_LIST(),
};
diff --git a/hw/virtio/virtio-pci.h b/hw/virtio/virtio-pci.h
index 813082b0d7..e4592e90bf 100644
--- a/hw/virtio/virtio-pci.h
+++ b/hw/virtio/virtio-pci.h
@@ -164,10 +164,11 @@ struct VirtIOPCIProxy {
VirtIOPCIRegion common;
VirtIOPCIRegion isr;
VirtIOPCIRegion device;
+ VirtIOPCIRegion group;
VirtIOPCIRegion notify;
VirtIOPCIRegion notify_pio;
};
- VirtIOPCIRegion regs[5];
+ VirtIOPCIRegion regs[6];
};
MemoryRegion modern_bar;
MemoryRegion io_bar;
diff --git a/include/standard-headers/linux/virtio_pci.h b/include/standard-headers/linux/virtio_pci.h
index 9262acd130..e5b6c6f3a6 100644
--- a/include/standard-headers/linux/virtio_pci.h
+++ b/include/standard-headers/linux/virtio_pci.h
@@ -113,6 +113,8 @@
#define VIRTIO_PCI_CAP_DEVICE_CFG 4
/* PCI configuration access */
#define VIRTIO_PCI_CAP_PCI_CFG 5
+/* Group Identifier */
+#define VIRTIO_PCI_CAP_GROUP_ID_CFG 6
/* This is the PCI capability header: */
struct virtio_pci_cap {
@@ -163,6 +165,12 @@ struct virtio_pci_cfg_cap {
uint8_t pci_cfg_data[4]; /* Data for BAR access. */
};
+/* Fields in VIRTIO_PCI_CAP_GROUP_ID_CFG: */
+struct virtio_pci_group_id_cap {
+ struct virtio_pci_cap cap;
+ uint8_t group_id[16];
+};
+
/* Macro versions of offsets for the Old Timers! */
#define VIRTIO_PCI_CAP_VNDR 0
#define VIRTIO_PCI_CAP_NEXT 1
next prev parent reply other threads:[~2018-06-19 16:33 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-06-19 16:32 [Qemu-devel] [PATCH 0/3] Use of unique identifier for pairing virtio and passthrough devices Venu Busireddy
2018-06-19 16:32 ` [Qemu-devel] [PATCH 1/3] Add a true or false option to the DEFINE_PROP_UUID macro Venu Busireddy
2018-06-19 16:32 ` [Qemu-devel] [PATCH 2/3] Add "Group Identifier" support to PCIe bridges Venu Busireddy
2018-06-19 17:24 ` Michael S. Tsirkin
2018-06-19 18:14 ` [Qemu-devel] [virtio-dev] " Venu Busireddy
2018-06-19 18:21 ` Michael S. Tsirkin
2018-06-19 18:36 ` Venu Busireddy
2018-06-19 18:53 ` Michael S. Tsirkin
2018-06-19 19:02 ` Venu Busireddy
2018-06-19 19:10 ` Michael S. Tsirkin
2018-06-19 16:32 ` Venu Busireddy [this message]
2018-06-19 16:32 ` [Qemu-devel] [PATCH virtio 1/1] Add "Group Identifier" support to virtio PCI capabilities Venu Busireddy
2018-06-19 17:30 ` Michael S. Tsirkin
2018-06-19 17:54 ` [Qemu-devel] [virtio-dev] " Venu Busireddy
2018-06-19 18:12 ` Michael S. Tsirkin
2018-06-19 18:18 ` Venu Busireddy
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=20180619163228.13790-4-venu.busireddy@oracle.com \
--to=venu.busireddy@oracle.com \
--cc=marcel@redhat.com \
--cc=mst@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=virtio-dev@lists.oasis-open.org \
/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).