2015-06-08 17:25:25 +02:00
|
|
|
/*
|
|
|
|
* vfio based device assignment support - platform devices
|
|
|
|
*
|
|
|
|
* Copyright Linaro Limited, 2014
|
|
|
|
*
|
|
|
|
* Authors:
|
|
|
|
* Kim Phillips <kim.phillips@linaro.org>
|
|
|
|
*
|
|
|
|
* This work is licensed under the terms of the GNU GPL, version 2. See
|
|
|
|
* the COPYING file in the top-level directory.
|
|
|
|
*
|
|
|
|
* Based on vfio based PCI device assignment support:
|
|
|
|
* Copyright Red Hat, Inc. 2012
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef HW_VFIO_VFIO_PLATFORM_H
|
|
|
|
#define HW_VFIO_VFIO_PLATFORM_H
|
|
|
|
|
|
|
|
#include "hw/sysbus.h"
|
|
|
|
#include "hw/vfio/vfio-common.h"
|
2015-06-08 17:25:26 +02:00
|
|
|
#include "qemu/event_notifier.h"
|
|
|
|
#include "qemu/queue.h"
|
2020-09-03 22:43:22 +02:00
|
|
|
#include "qom/object.h"
|
2015-06-08 17:25:25 +02:00
|
|
|
|
|
|
|
#define TYPE_VFIO_PLATFORM "vfio-platform"
|
|
|
|
|
2015-06-08 17:25:26 +02:00
|
|
|
enum {
|
|
|
|
VFIO_IRQ_INACTIVE = 0,
|
|
|
|
VFIO_IRQ_PENDING = 1,
|
|
|
|
VFIO_IRQ_ACTIVE = 2,
|
|
|
|
/* VFIO_IRQ_ACTIVE_AND_PENDING cannot happen with VFIO */
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef struct VFIOINTp {
|
|
|
|
QLIST_ENTRY(VFIOINTp) next; /* entry for IRQ list */
|
|
|
|
QSIMPLEQ_ENTRY(VFIOINTp) pqnext; /* entry for pending IRQ queue */
|
2015-10-05 20:30:12 +02:00
|
|
|
EventNotifier *interrupt; /* eventfd triggered on interrupt */
|
|
|
|
EventNotifier *unmask; /* eventfd for unmask on QEMU bypass */
|
2015-06-08 17:25:26 +02:00
|
|
|
qemu_irq qemuirq;
|
|
|
|
struct VFIOPlatformDevice *vdev; /* back pointer to device */
|
|
|
|
int state; /* inactive, pending, active */
|
|
|
|
uint8_t pin; /* index */
|
|
|
|
uint32_t flags; /* IRQ info flags */
|
2015-07-06 20:15:14 +02:00
|
|
|
bool kvm_accel; /* set when QEMU bypass through KVM enabled */
|
2015-06-08 17:25:26 +02:00
|
|
|
} VFIOINTp;
|
|
|
|
|
|
|
|
/* function type for user side eventfd handler */
|
|
|
|
typedef void (*eventfd_user_side_handler_t)(VFIOINTp *intp);
|
|
|
|
|
2020-09-03 22:43:22 +02:00
|
|
|
struct VFIOPlatformDevice {
|
2015-06-08 17:25:25 +02:00
|
|
|
SysBusDevice sbdev;
|
|
|
|
VFIODevice vbasedev; /* not a QOM object */
|
|
|
|
VFIORegion **regions;
|
2015-06-08 17:25:26 +02:00
|
|
|
QLIST_HEAD(, VFIOINTp) intp_list; /* list of IRQs */
|
|
|
|
/* queue of pending IRQs */
|
2018-12-06 11:58:10 +01:00
|
|
|
QSIMPLEQ_HEAD(, VFIOINTp) pending_intp_queue;
|
2018-10-15 18:52:09 +02:00
|
|
|
char *compat; /* DT compatible values, separated by NUL */
|
|
|
|
unsigned int num_compat; /* number of compatible values */
|
2015-06-08 17:25:26 +02:00
|
|
|
uint32_t mmap_timeout; /* delay to re-enable mmaps after interrupt */
|
|
|
|
QEMUTimer *mmap_timer; /* allows fast-path resume after IRQ hit */
|
|
|
|
QemuMutex intp_mutex; /* protect the intp_list IRQ state */
|
2015-07-06 20:15:14 +02:00
|
|
|
bool irqfd_allowed; /* debug option to force irqfd on/off */
|
2020-09-03 22:43:22 +02:00
|
|
|
};
|
|
|
|
typedef struct VFIOPlatformDevice VFIOPlatformDevice;
|
2015-06-08 17:25:25 +02:00
|
|
|
|
2020-09-03 22:43:22 +02:00
|
|
|
struct VFIOPlatformDeviceClass {
|
2015-06-08 17:25:25 +02:00
|
|
|
/*< private >*/
|
|
|
|
SysBusDeviceClass parent_class;
|
|
|
|
/*< public >*/
|
2020-09-03 22:43:22 +02:00
|
|
|
};
|
|
|
|
typedef struct VFIOPlatformDeviceClass VFIOPlatformDeviceClass;
|
2015-06-08 17:25:25 +02:00
|
|
|
|
2020-08-31 23:07:33 +02:00
|
|
|
DECLARE_OBJ_CHECKERS(VFIOPlatformDevice, VFIOPlatformDeviceClass,
|
|
|
|
VFIO_PLATFORM_DEVICE, TYPE_VFIO_PLATFORM)
|
2015-06-08 17:25:25 +02:00
|
|
|
|
2016-06-29 15:29:06 +02:00
|
|
|
#endif /* HW_VFIO_VFIO_PLATFORM_H */
|