diff options
Diffstat (limited to 'hw/dataplane')
-rw-r--r-- | hw/dataplane/hostmem.c | 2 | ||||
-rw-r--r-- | hw/dataplane/hostmem.h | 57 | ||||
-rw-r--r-- | hw/dataplane/virtio-blk.c | 6 | ||||
-rw-r--r-- | hw/dataplane/virtio-blk.h | 2 | ||||
-rw-r--r-- | hw/dataplane/vring.c | 2 | ||||
-rw-r--r-- | hw/dataplane/vring.h | 62 |
6 files changed, 6 insertions, 125 deletions
diff --git a/hw/dataplane/hostmem.c b/hw/dataplane/hostmem.c index 380537e06d..37292ffd00 100644 --- a/hw/dataplane/hostmem.c +++ b/hw/dataplane/hostmem.c @@ -12,7 +12,7 @@ */ #include "exec/address-spaces.h" -#include "hostmem.h" +#include "hw/virtio/dataplane/hostmem.h" static int hostmem_lookup_cmp(const void *phys_, const void *region_) { diff --git a/hw/dataplane/hostmem.h b/hw/dataplane/hostmem.h deleted file mode 100644 index b2cf09333f..0000000000 --- a/hw/dataplane/hostmem.h +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Thread-safe guest to host memory mapping - * - * Copyright 2012 Red Hat, Inc. and/or its affiliates - * - * Authors: - * Stefan Hajnoczi <stefanha@redhat.com> - * - * This work is licensed under the terms of the GNU GPL, version 2 or later. - * See the COPYING file in the top-level directory. - * - */ - -#ifndef HOSTMEM_H -#define HOSTMEM_H - -#include "exec/memory.h" -#include "qemu/thread.h" - -typedef struct { - void *host_addr; - hwaddr guest_addr; - uint64_t size; - bool readonly; -} HostMemRegion; - -typedef struct { - /* The listener is invoked when regions change and a new list of regions is - * built up completely before they are installed. - */ - MemoryListener listener; - HostMemRegion *new_regions; - size_t num_new_regions; - - /* Current regions are accessed from multiple threads either to lookup - * addresses or to install a new list of regions. The lock protects the - * pointer and the regions. - */ - QemuMutex current_regions_lock; - HostMemRegion *current_regions; - size_t num_current_regions; -} HostMem; - -void hostmem_init(HostMem *hostmem); -void hostmem_finalize(HostMem *hostmem); - -/** - * Map a guest physical address to a pointer - * - * Note that there is map/unmap mechanism here. The caller must ensure that - * mapped memory is no longer used across events like hot memory unplug. This - * can be done with other mechanisms like bdrv_drain_all() that quiesce - * in-flight I/O. - */ -void *hostmem_lookup(HostMem *hostmem, hwaddr phys, hwaddr len, bool is_write); - -#endif /* HOSTMEM_H */ diff --git a/hw/dataplane/virtio-blk.c b/hw/dataplane/virtio-blk.c index 1242d61e71..5baef2391a 100644 --- a/hw/dataplane/virtio-blk.c +++ b/hw/dataplane/virtio-blk.c @@ -16,12 +16,12 @@ #include "qemu/iov.h" #include "qemu/thread.h" #include "qemu/error-report.h" -#include "vring.h" +#include "hw/virtio/dataplane/vring.h" #include "ioq.h" #include "migration/migration.h" #include "block/block.h" -#include "hw/virtio-blk.h" -#include "hw/dataplane/virtio-blk.h" +#include "hw/virtio/virtio-blk.h" +#include "virtio-blk.h" #include "block/aio.h" enum { diff --git a/hw/dataplane/virtio-blk.h b/hw/dataplane/virtio-blk.h index 1e8fdfe418..c90e99f48f 100644 --- a/hw/dataplane/virtio-blk.h +++ b/hw/dataplane/virtio-blk.h @@ -15,7 +15,7 @@ #ifndef HW_DATAPLANE_VIRTIO_BLK_H #define HW_DATAPLANE_VIRTIO_BLK_H -#include "hw/virtio.h" +#include "hw/virtio/virtio.h" typedef struct VirtIOBlockDataPlane VirtIOBlockDataPlane; diff --git a/hw/dataplane/vring.c b/hw/dataplane/vring.c index e3b225315f..e0d6e83625 100644 --- a/hw/dataplane/vring.c +++ b/hw/dataplane/vring.c @@ -15,7 +15,7 @@ */ #include "trace.h" -#include "vring.h" +#include "hw/virtio/dataplane/vring.h" #include "qemu/error-report.h" /* Map the guest's vring to host memory */ diff --git a/hw/dataplane/vring.h b/hw/dataplane/vring.h deleted file mode 100644 index defb1efcda..0000000000 --- a/hw/dataplane/vring.h +++ /dev/null @@ -1,62 +0,0 @@ -/* Copyright 2012 Red Hat, Inc. and/or its affiliates - * Copyright IBM, Corp. 2012 - * - * Based on Linux 2.6.39 vhost code: - * Copyright (C) 2009 Red Hat, Inc. - * Copyright (C) 2006 Rusty Russell IBM Corporation - * - * Author: Michael S. Tsirkin <mst@redhat.com> - * Stefan Hajnoczi <stefanha@redhat.com> - * - * Inspiration, some code, and most witty comments come from - * Documentation/virtual/lguest/lguest.c, by Rusty Russell - * - * This work is licensed under the terms of the GNU GPL, version 2. - */ - -#ifndef VRING_H -#define VRING_H - -#include <linux/virtio_ring.h> -#include "qemu-common.h" -#include "hostmem.h" -#include "hw/virtio.h" - -typedef struct { - HostMem hostmem; /* guest memory mapper */ - struct vring vr; /* virtqueue vring mapped to host memory */ - uint16_t last_avail_idx; /* last processed avail ring index */ - uint16_t last_used_idx; /* last processed used ring index */ - uint16_t signalled_used; /* EVENT_IDX state */ - bool signalled_used_valid; - bool broken; /* was there a fatal error? */ -} Vring; - -static inline unsigned int vring_get_num(Vring *vring) -{ - return vring->vr.num; -} - -/* Are there more descriptors available? */ -static inline bool vring_more_avail(Vring *vring) -{ - return vring->vr.avail->idx != vring->last_avail_idx; -} - -/* Fail future vring_pop() and vring_push() calls until reset */ -static inline void vring_set_broken(Vring *vring) -{ - vring->broken = true; -} - -bool vring_setup(Vring *vring, VirtIODevice *vdev, int n); -void vring_teardown(Vring *vring); -void vring_disable_notification(VirtIODevice *vdev, Vring *vring); -bool vring_enable_notification(VirtIODevice *vdev, Vring *vring); -bool vring_should_notify(VirtIODevice *vdev, Vring *vring); -int vring_pop(VirtIODevice *vdev, Vring *vring, - struct iovec iov[], struct iovec *iov_end, - unsigned int *out_num, unsigned int *in_num); -void vring_push(Vring *vring, unsigned int head, int len); - -#endif /* VRING_H */ |