1
2
3
4
5
6
7
8
9
10#ifndef LIBQOS_VIRTIO_PCI_H
11#define LIBQOS_VIRTIO_PCI_H
12
13#include "virtio.h"
14#include "pci.h"
15#include "qgraph.h"
16
17typedef struct QVirtioPCIMSIXOps QVirtioPCIMSIXOps;
18
19typedef 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;
28
29 int bar_idx;
30
31
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;
37} QVirtioPCIDevice;
38
39struct QVirtioPCIMSIXOps {
40
41 void (*set_config_vector)(QVirtioPCIDevice *d, uint16_t entry);
42
43
44 void (*set_queue_vector)(QVirtioPCIDevice *d, uint16_t vq_idx,
45 uint16_t entry);
46};
47
48typedef struct QVirtQueuePCI {
49 QVirtQueue vq;
50 uint16_t msix_entry;
51 uint64_t msix_addr;
52 uint32_t msix_data;
53
54
55 uint64_t notify_offset;
56} QVirtQueuePCI;
57
58void virtio_pci_init(QVirtioPCIDevice *dev, QPCIBus *bus, QPCIAddress * addr);
59QVirtioPCIDevice *virtio_pci_new(QPCIBus *bus, QPCIAddress * addr);
60
61
62
63
64
65
66
67void qvirtio_pci_destructor(QOSGraphObject *obj);
68void qvirtio_pci_start_hw(QOSGraphObject *obj);
69
70
71void qvirtio_pci_device_enable(QVirtioPCIDevice *d);
72void qvirtio_pci_device_disable(QVirtioPCIDevice *d);
73
74void qvirtio_pci_set_msix_configuration_vector(QVirtioPCIDevice *d,
75 QGuestAllocator *alloc, uint16_t entry);
76void qvirtqueue_pci_msix_setup(QVirtioPCIDevice *d, QVirtQueuePCI *vqpci,
77 QGuestAllocator *alloc, uint16_t entry);
78
79
80QVirtQueue *qvirtio_pci_virtqueue_setup_common(QVirtioDevice *d,
81 QGuestAllocator *alloc,
82 uint16_t index);
83void qvirtio_pci_virtqueue_cleanup_common(QVirtQueue *vq,
84 QGuestAllocator *alloc);
85
86#endif
87