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.
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
{
24 const QVirtioPCIMSIXOps
*msix_ops
;
25 uint16_t config_msix_entry
;
26 uint64_t config_msix_addr
;
27 uint32_t config_msix_data
;
32 uint32_t common_cfg_offset
;
33 uint32_t notify_cfg_offset
;
34 uint32_t notify_off_multiplier
;
35 uint32_t isr_cfg_offset
;
36 uint32_t device_cfg_offset
;
39 struct QVirtioPCIMSIXOps
{
40 /* Set the Configuration Vector for MSI-X */
41 void (*set_config_vector
)(QVirtioPCIDevice
*d
, uint16_t entry
);
43 /* Set the Queue Vector for MSI-X */
44 void (*set_queue_vector
)(QVirtioPCIDevice
*d
, uint16_t vq_idx
,
48 typedef struct QVirtQueuePCI
{
55 uint64_t notify_offset
;
58 void virtio_pci_init(QVirtioPCIDevice
*dev
, QPCIBus
*bus
, QPCIAddress
* addr
);
59 QVirtioPCIDevice
*virtio_pci_new(QPCIBus
*bus
, QPCIAddress
* addr
);
61 /* virtio-pci object functions available for subclasses that
62 * override the original start_hw and destroy
63 * function. All virtio-xxx-pci subclass that override must
64 * take care of calling these two functions in the respective
67 void qvirtio_pci_destructor(QOSGraphObject
*obj
);
68 void qvirtio_pci_start_hw(QOSGraphObject
*obj
);
71 void qvirtio_pci_device_enable(QVirtioPCIDevice
*d
);
72 void qvirtio_pci_device_disable(QVirtioPCIDevice
*d
);
74 void qvirtio_pci_set_msix_configuration_vector(QVirtioPCIDevice
*d
,
75 QGuestAllocator
*alloc
, uint16_t entry
);
76 void qvirtqueue_pci_msix_setup(QVirtioPCIDevice
*d
, QVirtQueuePCI
*vqpci
,
77 QGuestAllocator
*alloc
, uint16_t entry
);
79 /* Used by Legacy and Modern virtio-pci code */
80 QVirtQueue
*qvirtio_pci_virtqueue_setup_common(QVirtioDevice
*d
,
81 QGuestAllocator
*alloc
,
83 void qvirtio_pci_virtqueue_cleanup_common(QVirtQueue
*vq
,
84 QGuestAllocator
*alloc
);