[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[RFC QEMU PATCH 01/18] virtio: Add shared memory capability
- To: Gerd Hoffmann <kraxel@xxxxxxxxxx>, "Michael S . Tsirkin" <mst@xxxxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Anthony PERARD <anthony.perard@xxxxxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, Jan Beulich <jbeulich@xxxxxxxx>, Antonio Caggiano <antonio.caggiano@xxxxxxxxxxxxx>, "Dr . David Alan Gilbert" <dgilbert@xxxxxxxxxx>, Robert Beckett <bob.beckett@xxxxxxxxxxxxx>, <qemu-devel@xxxxxxxxxx>, <xen-devel@xxxxxxxxxxxxxxxxxxxx>
- From: Huang Rui <ray.huang@xxxxxxx>
- Date: Sun, 12 Mar 2023 17:22:27 +0800
- Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=redhat.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none
- Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=MySP99NL4Cc5eNFlOLDdl3uxiv6CT1oGstfJsAE3Zaw=; b=EPJ6KKMRtHz443HHu2OKfl36iVa9458gL+ud6eLEKO13FeoyeHFpU1/TLGvsSrA4Utf3G7f1O2wjPLRoMbHdjmE97u6Z6nLtomTUS83RhsUPJq3k5Zpa/JJ6DFoTBtIfesBQC1uPkvPxsslNIBOd2lg9j1DhXeE5TArwPaOK6oRp6gRAfmBssYIMDpTECUnj+SmXmKyRJeW4YDISGtYVY3/p3bJe1pzJucnZL+DgfpqihQCkyD+ZNroKjzoS0SuW1vcfBgtNJMin6jufFIV3hDgTJfK/Iw7FBFU8rYtOTKLebQgsraoE7/99nV0Q0DjQ+YplFIMno1l705sUo5AV4A==
- Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=iUxCE7eyuR8ZKzC6jQVUJJf8lEHwqBFeQ22rRNEsREPenq+303Q91LmB4YK5HNoJH1b4TmaQyC5nhjhgzRvsevZJSLfL66X5uzE5g1oOKZoUL96JglIajvdyO7pteZW0MGR0gBP3ij54F8UKzp9InNbN4khsppnr0nQd165mp4L0hQdmoHD6rXTM7QfXBndokfL5YllrKExcDVVgj0t5SO64S4LnKefA451FPbmh/sNZN/lgMTh2sdsXE9Qmzu1+i2WHjBeMTugI7OTA7S/dbVpcS8OIQ/vsGBhO8WYFd2olDHYBYpZUFd7OR/eNbGtAYapsAMKEPIJ7boF8LsmZMw==
- Cc: Alex Deucher <alexander.deucher@xxxxxxx>, Christian König <christian.koenig@xxxxxxx>, "Stewart Hildebrand" <Stewart.Hildebrand@xxxxxxx>, Xenia Ragiadakou <burzalodowa@xxxxxxxxx>, Honglei Huang <honglei1.huang@xxxxxxx>, Julia Zhang <julia.zhang@xxxxxxx>, Chen Jiqian <Jiqian.Chen@xxxxxxx>
- Delivery-date: Sun, 12 Mar 2023 09:23:31 +0000
- List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
From: "Dr. David Alan Gilbert" <dgilbert@xxxxxxxxxx>
Define a new capability type 'VIRTIO_PCI_CAP_SHARED_MEMORY_CFG' to allow
defining shared memory regions with sizes and offsets of 2^32 and more.
Multiple instances of the capability are allowed and distinguished
by a device-specific 'id'.
Signed-off-by: Dr. David Alan Gilbert <dgilbert@xxxxxxxxxx>
Signed-off-by: Antonio Caggiano <antonio.caggiano@xxxxxxxxxxxxx>
---
hw/virtio/virtio-pci.c | 18 ++++++++++++++++++
include/hw/virtio/virtio-pci.h | 4 ++++
2 files changed, 22 insertions(+)
diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c
index a1c9dfa7bb..ae4c29cb96 100644
--- a/hw/virtio/virtio-pci.c
+++ b/hw/virtio/virtio-pci.c
@@ -1191,6 +1191,24 @@ static int virtio_pci_add_mem_cap(VirtIOPCIProxy *proxy,
return offset;
}
+int virtio_pci_add_shm_cap(VirtIOPCIProxy *proxy,
+ uint8_t bar, uint64_t offset, uint64_t length,
+ uint8_t id)
+{
+ struct virtio_pci_cap64 cap = {
+ .cap.cap_len = sizeof cap,
+ .cap.cfg_type = VIRTIO_PCI_CAP_SHARED_MEMORY_CFG,
+ };
+
+ cap.cap.bar = bar;
+ cap.cap.length = cpu_to_le32(length);
+ cap.length_hi = cpu_to_le32(length >> 32);
+ cap.cap.offset = cpu_to_le32(offset);
+ cap.offset_hi = cpu_to_le32(offset >> 32);
+ cap.cap.id = id;
+ return virtio_pci_add_mem_cap(proxy, &cap.cap);
+}
+
static uint64_t virtio_pci_common_read(void *opaque, hwaddr addr,
unsigned size)
{
diff --git a/include/hw/virtio/virtio-pci.h b/include/hw/virtio/virtio-pci.h
index 938799e8f6..e67fe422a1 100644
--- a/include/hw/virtio/virtio-pci.h
+++ b/include/hw/virtio/virtio-pci.h
@@ -257,4 +257,8 @@ void virtio_pci_types_register(const
VirtioPCIDeviceTypeInfo *t);
*/
unsigned virtio_pci_optimal_num_queues(unsigned fixed_queues);
+int virtio_pci_add_shm_cap(VirtIOPCIProxy *proxy,
+ uint8_t bar, uint64_t offset, uint64_t length,
+ uint8_t id);
+
#endif
--
2.25.1
|