root / hw / vfio_pci_int.h @ fa2ddcb4
History | View | Annotate | Download (3.2 kB)
1 |
/*
|
---|---|
2 |
* vfio based device assignment support
|
3 |
*
|
4 |
* Copyright Red Hat, Inc. 2012
|
5 |
*
|
6 |
* Authors:
|
7 |
* Alex Williamson <alex.williamson@redhat.com>
|
8 |
*
|
9 |
* This work is licensed under the terms of the GNU GPL, version 2. See
|
10 |
* the COPYING file in the top-level directory.
|
11 |
*/
|
12 |
|
13 |
#ifndef HW_VFIO_PCI_INT_H
|
14 |
#define HW_VFIO_PCI_INT_H
|
15 |
|
16 |
#include "qemu-common.h" |
17 |
#include "qemu-queue.h" |
18 |
#include "pci.h" |
19 |
#include "event_notifier.h" |
20 |
|
21 |
typedef struct VFIOBAR { |
22 |
off_t fd_offset; /* offset of BAR within device fd */
|
23 |
int fd; /* device fd, allows us to pass VFIOBAR as opaque data */ |
24 |
MemoryRegion mem; /* slow, read/write access */
|
25 |
MemoryRegion mmap_mem; /* direct mapped access */
|
26 |
void *mmap;
|
27 |
size_t size; |
28 |
uint32_t flags; /* VFIO region flags (rd/wr/mmap) */
|
29 |
uint8_t nr; /* cache the BAR number for debug */
|
30 |
} VFIOBAR; |
31 |
|
32 |
typedef struct VFIOINTx { |
33 |
bool pending; /* interrupt pending */ |
34 |
bool kvm_accel; /* set when QEMU bypass through KVM enabled */ |
35 |
uint8_t pin; /* which pin to pull for qemu_set_irq */
|
36 |
EventNotifier interrupt; /* eventfd triggered on interrupt */
|
37 |
EventNotifier unmask; /* eventfd for unmask on QEMU bypass */
|
38 |
PCIINTxRoute route; /* routing info for QEMU bypass */
|
39 |
bool disabled;
|
40 |
char *intx;
|
41 |
} VFIOINTx; |
42 |
|
43 |
struct VFIODevice;
|
44 |
|
45 |
typedef struct VFIOMSIVector { |
46 |
EventNotifier interrupt; /* eventfd triggered on interrupt */
|
47 |
struct VFIODevice *vdev; /* back pointer to device */ |
48 |
int virq; /* KVM irqchip route for QEMU bypass */ |
49 |
bool use;
|
50 |
} VFIOMSIVector; |
51 |
|
52 |
enum {
|
53 |
VFIO_INT_NONE = 0,
|
54 |
VFIO_INT_INTx = 1,
|
55 |
VFIO_INT_MSI = 2,
|
56 |
VFIO_INT_MSIX = 3,
|
57 |
}; |
58 |
|
59 |
struct VFIOGroup;
|
60 |
|
61 |
typedef struct VFIOContainer { |
62 |
int fd; /* /dev/vfio/vfio, empowered by the attached groups */ |
63 |
struct {
|
64 |
/* enable abstraction to support various iommu backends */
|
65 |
union {
|
66 |
MemoryListener listener; /* Used by type1 iommu */
|
67 |
}; |
68 |
void (*release)(struct VFIOContainer *); |
69 |
} iommu_data; |
70 |
QLIST_HEAD(, VFIOGroup) group_list; |
71 |
QLIST_ENTRY(VFIOContainer) next; |
72 |
} VFIOContainer; |
73 |
|
74 |
/* Cache of MSI-X setup plus extra mmap and memory region for split BAR map */
|
75 |
typedef struct VFIOMSIXInfo { |
76 |
uint8_t table_bar; |
77 |
uint8_t pba_bar; |
78 |
uint16_t entries; |
79 |
uint32_t table_offset; |
80 |
uint32_t pba_offset; |
81 |
MemoryRegion mmap_mem; |
82 |
void *mmap;
|
83 |
} VFIOMSIXInfo; |
84 |
|
85 |
typedef struct VFIODevice { |
86 |
PCIDevice pdev; |
87 |
int fd;
|
88 |
VFIOINTx intx; |
89 |
unsigned int config_size; |
90 |
off_t config_offset; /* Offset of config space region within device fd */
|
91 |
unsigned int rom_size; |
92 |
off_t rom_offset; /* Offset of ROM region within device fd */
|
93 |
int msi_cap_size;
|
94 |
VFIOMSIVector *msi_vectors; |
95 |
VFIOMSIXInfo *msix; |
96 |
int nr_vectors; /* Number of MSI/MSIX vectors currently in use */ |
97 |
int interrupt; /* Current interrupt type */ |
98 |
VFIOBAR bars[PCI_NUM_REGIONS - 1]; /* No ROM */ |
99 |
PCIHostDeviceAddress host; |
100 |
QLIST_ENTRY(VFIODevice) next; |
101 |
struct VFIOGroup *group;
|
102 |
bool reset_works;
|
103 |
} VFIODevice; |
104 |
|
105 |
typedef struct VFIOGroup { |
106 |
int fd;
|
107 |
int groupid;
|
108 |
VFIOContainer *container; |
109 |
QLIST_HEAD(, VFIODevice) device_list; |
110 |
QLIST_ENTRY(VFIOGroup) next; |
111 |
QLIST_ENTRY(VFIOGroup) container_next; |
112 |
} VFIOGroup; |
113 |
|
114 |
#endif /* HW_VFIO_PCI_INT_H */ |