xref: /openbmc/qemu/include/hw/virtio/vhost-vdpa.h (revision 44602af8)
1 /*
2  * vhost-vdpa.h
3  *
4  * Copyright(c) 2017-2018 Intel Corporation.
5  * Copyright(c) 2020 Red Hat, Inc.
6  *
7  * This work is licensed under the terms of the GNU GPL, version 2 or later.
8  * See the COPYING file in the top-level directory.
9  *
10  */
11 
12 #ifndef HW_VIRTIO_VHOST_VDPA_H
13 #define HW_VIRTIO_VHOST_VDPA_H
14 
15 #include <gmodule.h>
16 
17 #include "hw/virtio/vhost-iova-tree.h"
18 #include "hw/virtio/vhost-shadow-virtqueue.h"
19 #include "hw/virtio/virtio.h"
20 #include "standard-headers/linux/vhost_types.h"
21 
22 typedef struct VhostVDPAHostNotifier {
23     MemoryRegion mr;
24     void *addr;
25 } VhostVDPAHostNotifier;
26 
27 typedef struct vhost_vdpa {
28     int device_fd;
29     int index;
30     uint32_t msg_type;
31     bool iotlb_batch_begin_sent;
32     MemoryListener listener;
33     struct vhost_vdpa_iova_range iova_range;
34     uint64_t acked_features;
35     bool shadow_vqs_enabled;
36     /* IOVA mapping used by the Shadow Virtqueue */
37     VhostIOVATree *iova_tree;
38     Error *migration_blocker;
39     GPtrArray *shadow_vqs;
40     const VhostShadowVirtqueueOps *shadow_vq_ops;
41     void *shadow_vq_ops_opaque;
42     struct vhost_dev *dev;
43     VhostVDPAHostNotifier notifier[VIRTIO_QUEUE_MAX];
44 } VhostVDPA;
45 
46 int vhost_vdpa_dma_map(struct vhost_vdpa *v, hwaddr iova, hwaddr size,
47                        void *vaddr, bool readonly);
48 int vhost_vdpa_dma_unmap(struct vhost_vdpa *v, hwaddr iova, hwaddr size);
49 
50 #endif
51