1*36f5dc91SSasha Levin #ifndef KVM__VIRTIO_PCI_H 2*36f5dc91SSasha Levin #define KVM__VIRTIO_PCI_H 3*36f5dc91SSasha Levin 4*36f5dc91SSasha Levin #include "kvm/pci.h" 5*36f5dc91SSasha Levin 6*36f5dc91SSasha Levin #include <linux/types.h> 7*36f5dc91SSasha Levin 8*36f5dc91SSasha Levin #define VIRTIO_PCI_MAX_VQ 3 9*36f5dc91SSasha Levin 10*36f5dc91SSasha Levin struct kvm; 11*36f5dc91SSasha Levin 12*36f5dc91SSasha Levin struct virtio_pci_ops { 13*36f5dc91SSasha Levin void (*set_config)(struct kvm *kvm, void *dev, u8 data, u32 offset); 14*36f5dc91SSasha Levin u8 (*get_config)(struct kvm *kvm, void *dev, u32 offset); 15*36f5dc91SSasha Levin 16*36f5dc91SSasha Levin u32 (*get_host_features)(struct kvm *kvm, void *dev); 17*36f5dc91SSasha Levin void (*set_guest_features)(struct kvm *kvm, void *dev, u32 features); 18*36f5dc91SSasha Levin 19*36f5dc91SSasha Levin int (*init_vq)(struct kvm *kvm, void *dev, u32 vq, u32 pfn); 20*36f5dc91SSasha Levin int (*notify_vq)(struct kvm *kvm, void *dev, u32 vq); 21*36f5dc91SSasha Levin int (*get_pfn_vq)(struct kvm *kvm, void *dev, u32 vq); 22*36f5dc91SSasha Levin int (*get_size_vq)(struct kvm *kvm, void *dev, u32 vq); 23*36f5dc91SSasha Levin }; 24*36f5dc91SSasha Levin 25*36f5dc91SSasha Levin struct virtio_pci { 26*36f5dc91SSasha Levin struct pci_device_header pci_hdr; 27*36f5dc91SSasha Levin struct virtio_pci_ops ops; 28*36f5dc91SSasha Levin void *dev; 29*36f5dc91SSasha Levin 30*36f5dc91SSasha Levin u16 base_addr; 31*36f5dc91SSasha Levin u8 status; 32*36f5dc91SSasha Levin u8 isr; 33*36f5dc91SSasha Levin 34*36f5dc91SSasha Levin /* MSI-X */ 35*36f5dc91SSasha Levin u16 config_vector; 36*36f5dc91SSasha Levin u32 config_gsi; 37*36f5dc91SSasha Levin u32 vq_vector[VIRTIO_PCI_MAX_VQ]; 38*36f5dc91SSasha Levin u32 gsis[VIRTIO_PCI_MAX_VQ]; 39*36f5dc91SSasha Levin u32 msix_io_block; 40*36f5dc91SSasha Levin int msix_enabled; 41*36f5dc91SSasha Levin 42*36f5dc91SSasha Levin /* virtio queue */ 43*36f5dc91SSasha Levin u16 queue_selector; 44*36f5dc91SSasha Levin }; 45*36f5dc91SSasha Levin 46*36f5dc91SSasha Levin int virtio_pci__init(struct kvm *kvm, struct virtio_pci *vpci, void *dev, 47*36f5dc91SSasha Levin int device_id, int subsys_id); 48*36f5dc91SSasha Levin int virtio_pci__signal_vq(struct kvm *kvm, struct virtio_pci *vpci, u32 vq); 49*36f5dc91SSasha Levin int virtio_pci__signal_config(struct kvm *kvm, struct virtio_pci *vpci); 50*36f5dc91SSasha Levin 51*36f5dc91SSasha Levin #endif 52