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 u8 status; 28 u8 isr; 29 u32 features; 30 31 /* 32 * We cannot rely on the INTERRUPT_LINE byte in the config space once 33 * we have run guest code, as the OS is allowed to use that field 34 * as a scratch pad to communicate between driver and PCI layer. 35 * So store our legacy interrupt line number in here for internal use. 36 */ 37 u8 legacy_irq_line; 38 39 /* MSI-X */ 40 u16 config_vector; 41 u32 config_gsi; 42 u32 vq_vector[VIRTIO_PCI_MAX_VQ]; 43 u32 gsis[VIRTIO_PCI_MAX_VQ]; 44 u64 msix_pba; 45 struct msix_table msix_table[VIRTIO_PCI_MAX_VQ + VIRTIO_PCI_MAX_CONFIG]; 46 47 /* virtio queue */ 48 u16 queue_selector; 49 struct virtio_pci_ioevent_param ioeventfds[VIRTIO_PCI_MAX_VQ]; 50 }; 51 52 int virtio_pci__signal_vq(struct kvm *kvm, struct virtio_device *vdev, u32 vq); 53 int virtio_pci__signal_config(struct kvm *kvm, struct virtio_device *vdev); 54 int virtio_pci__exit(struct kvm *kvm, struct virtio_device *vdev); 55 int virtio_pci__reset(struct kvm *kvm, struct virtio_device *vdev); 56 int virtio_pci__init(struct kvm *kvm, void *dev, struct virtio_device *vdev, 57 int device_id, int subsys_id, int class); 58 59 #endif 60