1 /* 2 * libqos virtio PCI definitions 3 * 4 * Copyright (c) 2014 Marc Marí 5 * 6 * This work is licensed under the terms of the GNU GPL, version 2 or later. 7 * See the COPYING file in the top-level directory. 8 */ 9 10 #ifndef LIBQOS_VIRTIO_PCI_H 11 #define LIBQOS_VIRTIO_PCI_H 12 13 #include "libqos/virtio.h" 14 #include "libqos/pci.h" 15 16 #define QVIRTIO_PCI_DEVICE_FEATURES 0x00 17 #define QVIRTIO_PCI_GUEST_FEATURES 0x04 18 #define QVIRTIO_PCI_QUEUE_ADDRESS 0x08 19 #define QVIRTIO_PCI_QUEUE_SIZE 0x0C 20 #define QVIRTIO_PCI_QUEUE_SELECT 0x0E 21 #define QVIRTIO_PCI_QUEUE_NOTIFY 0x10 22 #define QVIRTIO_PCI_DEVICE_STATUS 0x12 23 #define QVIRTIO_PCI_ISR_STATUS 0x13 24 #define QVIRTIO_PCI_MSIX_CONF_VECTOR 0x14 25 #define QVIRTIO_PCI_MSIX_QUEUE_VECTOR 0x16 26 #define QVIRTIO_PCI_DEVICE_SPECIFIC_MSIX 0x18 27 #define QVIRTIO_PCI_DEVICE_SPECIFIC_NO_MSIX 0x14 28 29 #define QVIRTIO_PCI_ALIGN 4096 30 31 #define QVIRTIO_MSI_NO_VECTOR 0xFFFF 32 33 typedef struct QVirtioPCIDevice { 34 QVirtioDevice vdev; 35 QPCIDevice *pdev; 36 void *addr; 37 uint16_t config_msix_entry; 38 uint64_t config_msix_addr; 39 uint32_t config_msix_data; 40 } QVirtioPCIDevice; 41 42 typedef struct QVirtQueuePCI { 43 QVirtQueue vq; 44 uint16_t msix_entry; 45 uint64_t msix_addr; 46 uint32_t msix_data; 47 } QVirtQueuePCI; 48 49 extern const QVirtioBus qvirtio_pci; 50 51 void qvirtio_pci_foreach(QPCIBus *bus, uint16_t device_type, 52 void (*func)(QVirtioDevice *d, void *data), void *data); 53 QVirtioPCIDevice *qvirtio_pci_device_find(QPCIBus *bus, uint16_t device_type); 54 void qvirtio_pci_device_enable(QVirtioPCIDevice *d); 55 void qvirtio_pci_device_disable(QVirtioPCIDevice *d); 56 57 void qvirtio_pci_set_msix_configuration_vector(QVirtioPCIDevice *d, 58 QGuestAllocator *alloc, uint16_t entry); 59 void qvirtqueue_pci_msix_setup(QVirtioPCIDevice *d, QVirtQueuePCI *vqpci, 60 QGuestAllocator *alloc, uint16_t entry); 61 #endif 62