libqos: make the virtio-pci BAR index configurable
[qemu/kevin.git] / tests / libqos / virtio-pci.h
blob78a1c15c2aeba670e00b3b11a2e08999d9f8fdfc
1 /*
2 * libqos virtio PCI definitions
4 * Copyright (c) 2014 Marc MarĂ­
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 */
10 #ifndef LIBQOS_VIRTIO_PCI_H
11 #define LIBQOS_VIRTIO_PCI_H
13 #include "libqos/virtio.h"
14 #include "libqos/pci.h"
15 #include "libqos/qgraph.h"
17 typedef struct QVirtioPCIMSIXOps QVirtioPCIMSIXOps;
19 typedef struct QVirtioPCIDevice {
20 QOSGraphObject obj;
21 QVirtioDevice vdev;
22 QPCIDevice *pdev;
23 QPCIBar bar;
24 const QVirtioPCIMSIXOps *msix_ops;
25 uint16_t config_msix_entry;
26 uint64_t config_msix_addr;
27 uint32_t config_msix_data;
29 int bar_idx;
30 } QVirtioPCIDevice;
32 struct QVirtioPCIMSIXOps {
33 /* Set the Configuration Vector for MSI-X */
34 void (*set_config_vector)(QVirtioPCIDevice *d, uint16_t entry);
36 /* Set the Queue Vector for MSI-X */
37 void (*set_queue_vector)(QVirtioPCIDevice *d, uint16_t vq_idx,
38 uint16_t entry);
41 typedef struct QVirtQueuePCI {
42 QVirtQueue vq;
43 uint16_t msix_entry;
44 uint64_t msix_addr;
45 uint32_t msix_data;
46 } QVirtQueuePCI;
48 extern const QVirtioBus qvirtio_pci;
50 void virtio_pci_init(QVirtioPCIDevice *dev, QPCIBus *bus, QPCIAddress * addr);
51 QVirtioPCIDevice *virtio_pci_new(QPCIBus *bus, QPCIAddress * addr);
53 /* virtio-pci object functions available for subclasses that
54 * override the original start_hw and destroy
55 * function. All virtio-xxx-pci subclass that override must
56 * take care of calling these two functions in the respective
57 * places
59 void qvirtio_pci_destructor(QOSGraphObject *obj);
60 void qvirtio_pci_start_hw(QOSGraphObject *obj);
63 void qvirtio_pci_device_enable(QVirtioPCIDevice *d);
64 void qvirtio_pci_device_disable(QVirtioPCIDevice *d);
66 void qvirtio_pci_set_msix_configuration_vector(QVirtioPCIDevice *d,
67 QGuestAllocator *alloc, uint16_t entry);
68 void qvirtqueue_pci_msix_setup(QVirtioPCIDevice *d, QVirtQueuePCI *vqpci,
69 QGuestAllocator *alloc, uint16_t entry);
71 /* Used by Legacy and Modern virtio-pci code */
72 QVirtQueue *qvirtio_pci_virtqueue_setup_common(QVirtioDevice *d,
73 QGuestAllocator *alloc,
74 uint16_t index);
75 void qvirtio_pci_virtqueue_cleanup_common(QVirtQueue *vq,
76 QGuestAllocator *alloc);
78 #endif