1 #ifndef KVM__VIRTIO_PCI_H 2 #define KVM__VIRTIO_PCI_H 3 4 #include "kvm/devices.h" 5 #include "kvm/pci.h" 6 7 #include <linux/types.h> 8 9 #define VIRTIO_PCI_MAX_VQ 32 10 #define VIRTIO_PCI_MAX_CONFIG 1 11 12 struct kvm; 13 14 struct virtio_pci_ioevent_param { 15 struct virtio_device *vdev; 16 u32 vq; 17 }; 18 19 #define VIRTIO_PCI_F_SIGNAL_MSI (1 << 0) 20 21 struct virtio_pci { 22 struct pci_device_header pci_hdr; 23 struct device_header dev_hdr; 24 void *dev; 25 struct kvm *kvm; 26 27 u16 port_addr; 28 u32 mmio_addr; 29 u8 status; 30 u8 isr; 31 u32 features; 32 33 /* 34 * We cannot rely on the INTERRUPT_LINE byte in the config space once 35 * we have run guest code, as the OS is allowed to use that field 36 * as a scratch pad to communicate between driver and PCI layer. 37 * So store our legacy interrupt line number in here for internal use. 38 */ 39 u8 legacy_irq_line; 40 41 /* MSI-X */ 42 u16 config_vector; 43 u32 config_gsi; 44 u32 vq_vector[VIRTIO_PCI_MAX_VQ]; 45 u32 gsis[VIRTIO_PCI_MAX_VQ]; 46 u32 msix_io_block; 47 u64 msix_pba; 48 struct msix_table msix_table[VIRTIO_PCI_MAX_VQ + VIRTIO_PCI_MAX_CONFIG]; 49 50 /* virtio queue */ 51 u16 queue_selector; 52 struct virtio_pci_ioevent_param ioeventfds[VIRTIO_PCI_MAX_VQ]; 53 }; 54 55 int virtio_pci__signal_vq(struct kvm *kvm, struct virtio_device *vdev, u32 vq); 56 int virtio_pci__signal_config(struct kvm *kvm, struct virtio_device *vdev); 57 int virtio_pci__exit(struct kvm *kvm, struct virtio_device *vdev); 58 int virtio_pci__init(struct kvm *kvm, void *dev, struct virtio_device *vdev, 59 int device_id, int subsys_id, int class); 60 61 #endif 62