2
0

vfio-platform.h 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /*
  2. * vfio based device assignment support - platform devices
  3. *
  4. * Copyright Linaro Limited, 2014
  5. *
  6. * Authors:
  7. * Kim Phillips <kim.phillips@linaro.org>
  8. *
  9. * This work is licensed under the terms of the GNU GPL, version 2. See
  10. * the COPYING file in the top-level directory.
  11. *
  12. * Based on vfio based PCI device assignment support:
  13. * Copyright Red Hat, Inc. 2012
  14. */
  15. #ifndef HW_VFIO_VFIO_PLATFORM_H
  16. #define HW_VFIO_VFIO_PLATFORM_H
  17. #include "hw/sysbus.h"
  18. #include "hw/vfio/vfio-common.h"
  19. #include "qemu/event_notifier.h"
  20. #include "qemu/queue.h"
  21. #include "qom/object.h"
  22. #define TYPE_VFIO_PLATFORM "vfio-platform"
  23. enum {
  24. VFIO_IRQ_INACTIVE = 0,
  25. VFIO_IRQ_PENDING = 1,
  26. VFIO_IRQ_ACTIVE = 2,
  27. /* VFIO_IRQ_ACTIVE_AND_PENDING cannot happen with VFIO */
  28. };
  29. typedef struct VFIOINTp {
  30. QLIST_ENTRY(VFIOINTp) next; /* entry for IRQ list */
  31. QSIMPLEQ_ENTRY(VFIOINTp) pqnext; /* entry for pending IRQ queue */
  32. EventNotifier *interrupt; /* eventfd triggered on interrupt */
  33. EventNotifier *unmask; /* eventfd for unmask on QEMU bypass */
  34. qemu_irq qemuirq;
  35. struct VFIOPlatformDevice *vdev; /* back pointer to device */
  36. int state; /* inactive, pending, active */
  37. uint8_t pin; /* index */
  38. uint32_t flags; /* IRQ info flags */
  39. bool kvm_accel; /* set when QEMU bypass through KVM enabled */
  40. } VFIOINTp;
  41. /* function type for user side eventfd handler */
  42. typedef void (*eventfd_user_side_handler_t)(VFIOINTp *intp);
  43. struct VFIOPlatformDevice {
  44. SysBusDevice sbdev;
  45. VFIODevice vbasedev; /* not a QOM object */
  46. VFIORegion **regions;
  47. QLIST_HEAD(, VFIOINTp) intp_list; /* list of IRQs */
  48. /* queue of pending IRQs */
  49. QSIMPLEQ_HEAD(, VFIOINTp) pending_intp_queue;
  50. char *compat; /* DT compatible values, separated by NUL */
  51. unsigned int num_compat; /* number of compatible values */
  52. uint32_t mmap_timeout; /* delay to re-enable mmaps after interrupt */
  53. QEMUTimer *mmap_timer; /* allows fast-path resume after IRQ hit */
  54. QemuMutex intp_mutex; /* protect the intp_list IRQ state */
  55. bool irqfd_allowed; /* debug option to force irqfd on/off */
  56. };
  57. typedef struct VFIOPlatformDevice VFIOPlatformDevice;
  58. struct VFIOPlatformDeviceClass {
  59. /*< private >*/
  60. SysBusDeviceClass parent_class;
  61. /*< public >*/
  62. };
  63. typedef struct VFIOPlatformDeviceClass VFIOPlatformDeviceClass;
  64. DECLARE_OBJ_CHECKERS(VFIOPlatformDevice, VFIOPlatformDeviceClass,
  65. VFIO_PLATFORM_DEVICE, TYPE_VFIO_PLATFORM)
  66. #endif /* HW_VFIO_VFIO_PLATFORM_H */