virtio-pci.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. /*
  2. * Virtio PCI Bindings
  3. *
  4. * Copyright IBM, Corp. 2007
  5. * Copyright (c) 2009 CodeSourcery
  6. *
  7. * Authors:
  8. * Anthony Liguori <aliguori@us.ibm.com>
  9. * Paul Brook <paul@codesourcery.com>
  10. *
  11. * This work is licensed under the terms of the GNU GPL, version 2. See
  12. * the COPYING file in the top-level directory.
  13. */
  14. #ifndef QEMU_VIRTIO_PCI_H
  15. #define QEMU_VIRTIO_PCI_H
  16. #include "hw/pci/msi.h"
  17. #include "virtio-blk.h"
  18. #include "virtio-net.h"
  19. #include "virtio-rng.h"
  20. #include "virtio-serial.h"
  21. #include "virtio-scsi.h"
  22. #include "virtio-bus.h"
  23. typedef struct VirtIOPCIProxy VirtIOPCIProxy;
  24. /* virtio-pci-bus */
  25. typedef struct VirtioBusState VirtioPCIBusState;
  26. typedef struct VirtioBusClass VirtioPCIBusClass;
  27. #define TYPE_VIRTIO_PCI_BUS "virtio-pci-bus"
  28. #define VIRTIO_PCI_BUS(obj) \
  29. OBJECT_CHECK(VirtioPCIBusState, (obj), TYPE_VIRTIO_PCI_BUS)
  30. #define VIRTIO_PCI_BUS_GET_CLASS(obj) \
  31. OBJECT_GET_CLASS(VirtioPCIBusClass, obj, TYPE_VIRTIO_PCI_BUS)
  32. #define VIRTIO_PCI_BUS_CLASS(klass) \
  33. OBJECT_CLASS_CHECK(VirtioPCIBusClass, klass, TYPE_VIRTIO_PCI_BUS)
  34. /* Performance improves when virtqueue kick processing is decoupled from the
  35. * vcpu thread using ioeventfd for some devices. */
  36. #define VIRTIO_PCI_FLAG_USE_IOEVENTFD_BIT 1
  37. #define VIRTIO_PCI_FLAG_USE_IOEVENTFD (1 << VIRTIO_PCI_FLAG_USE_IOEVENTFD_BIT)
  38. typedef struct {
  39. MSIMessage msg;
  40. int virq;
  41. unsigned int users;
  42. } VirtIOIRQFD;
  43. /*
  44. * virtio-pci: This is the PCIDevice which has a virtio-pci-bus.
  45. */
  46. #define TYPE_VIRTIO_PCI "virtio-pci"
  47. #define VIRTIO_PCI_GET_CLASS(obj) \
  48. OBJECT_GET_CLASS(VirtioPCIClass, obj, TYPE_VIRTIO_PCI)
  49. #define VIRTIO_PCI_CLASS(klass) \
  50. OBJECT_CLASS_CHECK(VirtioPCIClass, klass, TYPE_VIRTIO_PCI)
  51. #define VIRTIO_PCI(obj) \
  52. OBJECT_CHECK(VirtIOPCIProxy, (obj), TYPE_VIRTIO_PCI)
  53. typedef struct VirtioPCIClass {
  54. PCIDeviceClass parent_class;
  55. int (*init)(VirtIOPCIProxy *vpci_dev);
  56. } VirtioPCIClass;
  57. struct VirtIOPCIProxy {
  58. PCIDevice pci_dev;
  59. VirtIODevice *vdev;
  60. MemoryRegion bar;
  61. uint32_t flags;
  62. uint32_t class_code;
  63. uint32_t nvectors;
  64. VirtIOBlkConf blk;
  65. NICConf nic;
  66. uint32_t host_features;
  67. #ifdef CONFIG_LINUX
  68. V9fsConf fsconf;
  69. #endif
  70. virtio_serial_conf serial;
  71. virtio_net_conf net;
  72. VirtIOSCSIConf scsi;
  73. VirtIORNGConf rng;
  74. bool ioeventfd_disabled;
  75. bool ioeventfd_started;
  76. VirtIOIRQFD *vector_irqfd;
  77. int nvqs_with_notifiers;
  78. VirtioBusState bus;
  79. };
  80. void virtio_init_pci(VirtIOPCIProxy *proxy, VirtIODevice *vdev);
  81. void virtio_pci_reset(DeviceState *d);
  82. void virtio_pci_bus_new(VirtioBusState *bus, VirtIOPCIProxy *dev);
  83. /* Virtio ABI version, if we increment this, we break the guest driver. */
  84. #define VIRTIO_PCI_ABI_VERSION 0
  85. #endif