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 15 #ifndef QEMU_VIRTIO_PCI_H 16 #define QEMU_VIRTIO_PCI_H 17 18 #include "hw/pci/msi.h" 19 #include "virtio-blk.h" 20 #include "virtio-net.h" 21 #include "virtio-rng.h" 22 #include "virtio-serial.h" 23 #include "virtio-scsi.h" 24 #include "virtio-bus.h" 25 26 /* virtio-pci-bus */ 27 28 typedef struct VirtioBusState VirtioPCIBusState; 29 typedef struct VirtioBusClass VirtioPCIBusClass; 30 31 #define TYPE_VIRTIO_PCI_BUS "virtio-pci-bus" 32 #define VIRTIO_PCI_BUS(obj) \ 33 OBJECT_CHECK(VirtioPCIBusState, (obj), TYPE_VIRTIO_PCI_BUS) 34 #define VIRTIO_PCI_BUS_GET_CLASS(obj) \ 35 OBJECT_GET_CLASS(VirtioPCIBusClass, obj, TYPE_VIRTIO_PCI_BUS) 36 #define VIRTIO_PCI_BUS_CLASS(klass) \ 37 OBJECT_CLASS_CHECK(VirtioPCIBusClass, klass, TYPE_VIRTIO_PCI_BUS) 38 39 /* Performance improves when virtqueue kick processing is decoupled from the 40 * vcpu thread using ioeventfd for some devices. */ 41 #define VIRTIO_PCI_FLAG_USE_IOEVENTFD_BIT 1 42 #define VIRTIO_PCI_FLAG_USE_IOEVENTFD (1 << VIRTIO_PCI_FLAG_USE_IOEVENTFD_BIT) 43 44 typedef struct { 45 MSIMessage msg; 46 int virq; 47 unsigned int users; 48 } VirtIOIRQFD; 49 50 typedef struct { 51 PCIDevice pci_dev; 52 VirtIODevice *vdev; 53 MemoryRegion bar; 54 uint32_t flags; 55 uint32_t class_code; 56 uint32_t nvectors; 57 VirtIOBlkConf blk; 58 NICConf nic; 59 uint32_t host_features; 60 #ifdef CONFIG_LINUX 61 V9fsConf fsconf; 62 #endif 63 virtio_serial_conf serial; 64 virtio_net_conf net; 65 VirtIOSCSIConf scsi; 66 VirtIORNGConf rng; 67 bool ioeventfd_disabled; 68 bool ioeventfd_started; 69 VirtIOIRQFD *vector_irqfd; 70 int nvqs_with_notifiers; 71 } VirtIOPCIProxy; 72 73 void virtio_init_pci(VirtIOPCIProxy *proxy, VirtIODevice *vdev); 74 void virtio_pci_reset(DeviceState *d); 75 void virtio_pci_bus_new(VirtioBusState *bus, VirtIOPCIProxy *dev); 76 77 /* Virtio ABI version, if we increment this, we break the guest driver. */ 78 #define VIRTIO_PCI_ABI_VERSION 0 79 80 #endif 81