All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Dr. David Alan Gilbert (git)" <dgilbert@redhat.com>
To: qemu-devel@nongnu.org
Cc: vgoyal@redhat.com, miklos@szeredi.hu, stefanha@redhat.com,
	sweil@redhat.com, swhiteho@redhat.com
Subject: [Qemu-devel] [RFC PATCH 1/7] virtio: Add shared memory capability
Date: Mon, 10 Dec 2018 17:31:45 +0000	[thread overview]
Message-ID: <20181210173151.16629-2-dgilbert@redhat.com> (raw)
In-Reply-To: <20181210173151.16629-1-dgilbert@redhat.com>

From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>

Define a new capability type 'VIRTIO_PCI_CAP_SHARED_MEMORY_CFG'
and the data structure 'virtio_pci_shm_cap' to go with it.
They 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@redhat.com>
---
 hw/virtio/virtio-pci.c                      | 20 ++++++++++++++++++++
 include/standard-headers/linux/virtio_pci.h |  9 +++++++++
 2 files changed, 29 insertions(+)

diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c
index a954799267..1e737531b5 100644
--- a/hw/virtio/virtio-pci.c
+++ b/hw/virtio/virtio-pci.c
@@ -1163,6 +1163,26 @@ static int virtio_pci_add_mem_cap(VirtIOPCIProxy *proxy,
     return offset;
 }
 
+static int virtio_pci_add_shm_cap(VirtIOPCIProxy *proxy,
+                                   uint8_t bar,
+                                   uint64_t offset, uint64_t length,
+                                   uint8_t id)
+{
+    struct virtio_pci_shm_cap cap = {
+        .cap.cap_len = sizeof cap,
+        .cap.cfg_type = VIRTIO_PCI_CAP_SHARED_MEMORY_CFG,
+    };
+    uint32_t mask32 = ~0;
+
+    cap.cap.bar = bar;
+    cap.cap.length = cpu_to_le32(length & mask32);
+    cap.length_hi = cpu_to_le32((length >> 32) & mask32);
+    cap.cap.offset = cpu_to_le32(offset & mask32);
+    cap.offset_hi = cpu_to_le32((offset >> 32) & mask32);
+    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/standard-headers/linux/virtio_pci.h b/include/standard-headers/linux/virtio_pci.h
index 9262acd130..745d7a1942 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
+/* Additional shared memory capability */
+#define VIRTIO_PCI_CAP_SHARED_MEMORY_CFG 8
 
 /* This is the PCI capability header: */
 struct virtio_pci_cap {
@@ -163,6 +165,13 @@ struct virtio_pci_cfg_cap {
 	uint8_t pci_cfg_data[4]; /* Data for BAR access. */
 };
 
+struct virtio_pci_shm_cap {
+	struct virtio_pci_cap cap;
+	uint32_t offset_hi;             /* Most sig 32 bits of offset */
+	uint32_t length_hi;             /* Most sig 32 bits of length */
+        uint8_t  id;                    /* To distinguish shm chunks */
+};
+
 /* Macro versions of offsets for the Old Timers! */
 #define VIRTIO_PCI_CAP_VNDR		0
 #define VIRTIO_PCI_CAP_NEXT		1
-- 
2.19.2

  reply	other threads:[~2018-12-10 17:32 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-10 17:31 [Qemu-devel] [RFC PATCH 0/7] virtio-fs: shared file system for virtual machines3 Dr. David Alan Gilbert (git)
2018-12-10 17:31 ` Dr. David Alan Gilbert (git) [this message]
2018-12-10 21:03   ` [Qemu-devel] [RFC PATCH 1/7] virtio: Add shared memory capability Eric Blake
2018-12-11 10:24     ` Dr. David Alan Gilbert
2018-12-10 17:31 ` [Qemu-devel] [RFC PATCH 2/7] virtio: add vhost-user-fs-pci device Dr. David Alan Gilbert (git)
2018-12-10 17:31 ` [Qemu-devel] [RFC PATCH 3/7] virtio-fs: Add cache BAR Dr. David Alan Gilbert (git)
2018-12-10 21:10   ` Eric Blake
2018-12-11 10:25     ` Dr. David Alan Gilbert
2018-12-10 17:31 ` [Qemu-devel] [RFC PATCH 4/7] virtio-fs: Add vhost-user slave commands for mapping Dr. David Alan Gilbert (git)
2018-12-10 17:31 ` [Qemu-devel] [RFC PATCH 5/7] virtio-fs: Fill in " Dr. David Alan Gilbert (git)
2018-12-10 17:31 ` [Qemu-devel] [RFC PATCH 6/7] virtio-fs: Allow mapping of meta data version table Dr. David Alan Gilbert (git)
2018-12-10 17:31 ` [Qemu-devel] [RFC PATCH 7/7] virtio-fs: Allow mapping of journal Dr. David Alan Gilbert (git)
2018-12-10 21:12   ` Eric Blake
2018-12-11 10:34     ` Dr. David Alan Gilbert
2018-12-10 20:26 ` [Qemu-devel] [RFC PATCH 0/7] virtio-fs: shared file system for virtual machines3 no-reply
2018-12-11 12:53 ` Stefan Hajnoczi
2018-12-12 12:30 ` Daniel P. Berrangé
2018-12-12 13:52   ` Dr. David Alan Gilbert
2018-12-12 13:58     ` Daniel P. Berrangé
2018-12-12 14:49       ` Stefan Hajnoczi
2018-12-22  9:27 ` jiangyiwen
2018-12-26 19:08   ` Vivek Goyal
2019-01-08  6:08     ` jiangyiwen
2019-04-04 13:24 ` Greg Kurz
2019-04-05  8:59   ` Dr. David Alan Gilbert
2019-04-05  8:59     ` Dr. David Alan Gilbert

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=20181210173151.16629-2-dgilbert@redhat.com \
    --to=dgilbert@redhat.com \
    --cc=miklos@szeredi.hu \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.com \
    --cc=sweil@redhat.com \
    --cc=swhiteho@redhat.com \
    --cc=vgoyal@redhat.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.