qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Cindy Lu <lulu@redhat.com>
To: lulu@redhat.com, mst@redhat.com, jasowang@redhat.com,
	qemu-devel@nongnu.org
Subject: [RFC 3/7] virtio : add a ptr for vdpa_iommufd in VirtIODevice
Date: Wed,  3 May 2023 17:13:33 +0800	[thread overview]
Message-ID: <20230503091337.2130631-4-lulu@redhat.com> (raw)
In-Reply-To: <20230503091337.2130631-1-lulu@redhat.com>

To support iommufd, vdpa needs to save the ioas_id and the ASID,
which need to be shared between all vhost_vdpa devices.
So Add a pointer in VirtIODevice.

vdpa device need to init it when the dev start, Add all the vdpa device
will read/write this same ptr. TODO: need to add a lock for
read and write

Signed-off-by: Cindy Lu <lulu@redhat.com>
---
 include/hw/virtio/vhost-vdpa.h | 23 +++++++++++++++++++++++
 include/hw/virtio/virtio.h     |  5 +++++
 2 files changed, 28 insertions(+)

diff --git a/include/hw/virtio/vhost-vdpa.h b/include/hw/virtio/vhost-vdpa.h
index 7997f09a8d..309d4ffc70 100644
--- a/include/hw/virtio/vhost-vdpa.h
+++ b/include/hw/virtio/vhost-vdpa.h
@@ -18,6 +18,10 @@
 #include "hw/virtio/vhost-shadow-virtqueue.h"
 #include "hw/virtio/virtio.h"
 #include "standard-headers/linux/vhost_types.h"
+//#include "sysemu/iommufd.h"
+#include "qemu/osdep.h"
+#include "sysemu/sysemu.h"
+
 
 /*
  * ASID dedicated to map guest's addresses.  If SVQ is disabled it maps GPA to
@@ -30,6 +34,8 @@ typedef struct VhostVDPAHostNotifier {
     void *addr;
 } VhostVDPAHostNotifier;
 
+typedef struct IOMMUFDBackend IOMMUFDBackend;
+
 typedef struct vhost_vdpa {
     int device_fd;
     int index;
@@ -51,6 +57,23 @@ typedef struct vhost_vdpa {
     VhostVDPAHostNotifier notifier[VIRTIO_QUEUE_MAX];
 } VhostVDPA;
 
+
+typedef struct vdpa_iommufd {
+    IOMMUFDBackend *iommufd;
+    struct vhost_dev *dev;
+    /*ioas_id get from IOMMUFD, iommufd need to use this id to map,unmap*/
+    uint32_t ioas_id;
+    /*ASID used for vq*/
+    uint32_t asid;
+    __u32 devid; /*not use */
+    __u32 hwptid; /*not use*/
+    AddressSpace *as;
+    struct vdpa_iommufd *next;
+    // QLIST_ENTRY(vdpa_iommufd) iommufd_next;
+
+} VDPAIOMMUFDState;
+
+
 int vhost_vdpa_get_iova_range(int fd, struct vhost_vdpa_iova_range *iova_range);
 
 int vhost_vdpa_dma_map(struct vhost_vdpa *v, uint32_t asid, hwaddr iova,
diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h
index 77c6c55929..36b4783466 100644
--- a/include/hw/virtio/virtio.h
+++ b/include/hw/virtio/virtio.h
@@ -152,6 +152,11 @@ struct VirtIODevice
     uint8_t device_endian;
     bool use_guest_notifier_mask;
     AddressSpace *dma_as;
+    /*this is an ptr point to struct vdpa_iommufd, will change to QLIST if
+     * needed*/
+    /*in this struct saved the ioas_id/ASID that we need to use in iommufd
+    map/unmap, this ioas_id/ASID will share between vqs,so we add the ptr here*/
+    void *iommufd_ptr;
     QLIST_HEAD(, VirtQueue) *vector_queues;
     QTAILQ_ENTRY(VirtIODevice) next;
     EventNotifier config_notifier;
-- 
2.34.3



  parent reply	other threads:[~2023-05-03  9:17 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-03  9:13 [RFC 0/7] vhost-vdpa: add support for iommufd Cindy Lu
2023-05-03  9:13 ` [RFC 1/7] vhost: introduce new UAPI to support IOMMUFD Cindy Lu
2023-05-03  9:13 ` [RFC 2/7] qapi: support iommufd in vdpa Cindy Lu
2023-05-03  9:13 ` Cindy Lu [this message]
2023-05-03  9:13 ` [RFC 4/7] net/vhost-vdpa: Add the check for iommufd Cindy Lu
2023-05-03  9:13 ` [RFC 5/7] vhost-vdpa: Add the iommufd support in the map/unmap function Cindy Lu
2023-05-03  9:13 ` [RFC 6/7] vhost-vdpa: init iommufd function in vhost_vdpa start Cindy Lu
2023-05-03  9:13 ` [RFC 7/7] vhost-vdpa-iommufd: Add iommufd support for vdpa Cindy Lu
2023-05-05  3:29 ` [RFC 0/7] vhost-vdpa: add support for iommufd Jason Wang
2023-05-05  6:29   ` Cindy Lu
2023-06-05  5:41     ` Michael S. Tsirkin
2023-06-05  8:04       ` Cindy Lu
2023-09-13 13:31 ` Michael S. Tsirkin
2023-09-14  5:44   ` Cindy Lu

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=20230503091337.2130631-4-lulu@redhat.com \
    --to=lulu@redhat.com \
    --cc=jasowang@redhat.com \
    --cc=mst@redhat.com \
    --cc=qemu-devel@nongnu.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).