136f5dc91SSasha Levin #ifndef KVM__VIRTIO_PCI_H 236f5dc91SSasha Levin #define KVM__VIRTIO_PCI_H 336f5dc91SSasha Levin 421ff329dSWill Deacon #include "kvm/devices.h" 536f5dc91SSasha Levin #include "kvm/pci.h" 636f5dc91SSasha Levin 736f5dc91SSasha Levin #include <linux/types.h> 836f5dc91SSasha Levin 945d3b59eSSasha Levin #define VIRTIO_PCI_MAX_VQ 32 1014bba8a0SAsias He #define VIRTIO_PCI_MAX_CONFIG 1 1136f5dc91SSasha Levin 1236f5dc91SSasha Levin struct kvm; 1336f5dc91SSasha Levin 141599d724SSasha Levin struct virtio_pci_ioevent_param { 1502eca50cSAsias He struct virtio_device *vdev; 161599d724SSasha Levin u32 vq; 171599d724SSasha Levin }; 181599d724SSasha Levin 1943c81c74SSasha Levin #define VIRTIO_PCI_F_SIGNAL_MSI (1 << 0) 2043c81c74SSasha Levin 2136f5dc91SSasha Levin struct virtio_pci { 2236f5dc91SSasha Levin struct pci_device_header pci_hdr; 2321ff329dSWill Deacon struct device_header dev_hdr; 2436f5dc91SSasha Levin void *dev; 25a463650cSWill Deacon struct kvm *kvm; 2636f5dc91SSasha Levin 27*21c9bc74SJean-Philippe Brucker u32 doorbell_offset; 2836f5dc91SSasha Levin u8 status; 2936f5dc91SSasha Levin u8 isr; 3043c81c74SSasha Levin u32 features; 3136f5dc91SSasha Levin 32e9922aafSAndre Przywara /* 33e9922aafSAndre Przywara * We cannot rely on the INTERRUPT_LINE byte in the config space once 34e9922aafSAndre Przywara * we have run guest code, as the OS is allowed to use that field 35e9922aafSAndre Przywara * as a scratch pad to communicate between driver and PCI layer. 36e9922aafSAndre Przywara * So store our legacy interrupt line number in here for internal use. 37e9922aafSAndre Przywara */ 38e9922aafSAndre Przywara u8 legacy_irq_line; 39e9922aafSAndre Przywara 4036f5dc91SSasha Levin /* MSI-X */ 4136f5dc91SSasha Levin u16 config_vector; 4236f5dc91SSasha Levin u32 config_gsi; 4336f5dc91SSasha Levin u32 vq_vector[VIRTIO_PCI_MAX_VQ]; 4436f5dc91SSasha Levin u32 gsis[VIRTIO_PCI_MAX_VQ]; 4506f48103SSasha Levin u64 msix_pba; 4614bba8a0SAsias He struct msix_table msix_table[VIRTIO_PCI_MAX_VQ + VIRTIO_PCI_MAX_CONFIG]; 4736f5dc91SSasha Levin 4836f5dc91SSasha Levin /* virtio queue */ 4936f5dc91SSasha Levin u16 queue_selector; 501599d724SSasha Levin struct virtio_pci_ioevent_param ioeventfds[VIRTIO_PCI_MAX_VQ]; 5136f5dc91SSasha Levin }; 5236f5dc91SSasha Levin 5302eca50cSAsias He int virtio_pci__signal_vq(struct kvm *kvm, struct virtio_device *vdev, u32 vq); 5402eca50cSAsias He int virtio_pci__signal_config(struct kvm *kvm, struct virtio_device *vdev); 5502eca50cSAsias He int virtio_pci__exit(struct kvm *kvm, struct virtio_device *vdev); 56eb34a8c2SJean-Philippe Brucker int virtio_pci__reset(struct kvm *kvm, struct virtio_device *vdev); 5702eca50cSAsias He int virtio_pci__init(struct kvm *kvm, void *dev, struct virtio_device *vdev, 58507e02d8SAsias He int device_id, int subsys_id, int class); 5936f5dc91SSasha Levin 6036f5dc91SSasha Levin #endif 61