]> Git Repo - qemu.git/blame - hw/vfio/pci.h
vfio/pci: Fixup VFIOMSIXInfo comment
[qemu.git] / hw / vfio / pci.h
CommitLineData
78f33d2b
AW
1/*
2 * vfio based device assignment support - PCI devices
3 *
4 * Copyright Red Hat, Inc. 2012-2015
5 *
6 * Authors:
7 * Alex Williamson <[email protected]>
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#ifndef HW_VFIO_VFIO_PCI_H
13#define HW_VFIO_VFIO_PCI_H
14
15#include "qemu-common.h"
16#include "exec/memory.h"
17#include "hw/pci/pci.h"
18#include "hw/vfio/vfio-common.h"
19#include "qemu/event_notifier.h"
20#include "qemu/queue.h"
21#include "qemu/timer.h"
22
89dcccc5
AW
23#define PCI_ANY_ID (~0)
24
78f33d2b
AW
25struct VFIOPCIDevice;
26
8c4f2348
AW
27typedef struct VFIOQuirk {
28 QLIST_ENTRY(VFIOQuirk) next;
29 void *data;
30 int nr_mem;
31 MemoryRegion *mem;
78f33d2b
AW
32} VFIOQuirk;
33
34typedef struct VFIOBAR {
35 VFIORegion region;
36 bool ioport;
37 bool mem64;
38 QLIST_HEAD(, VFIOQuirk) quirks;
39} VFIOBAR;
40
41typedef struct VFIOVGARegion {
42 MemoryRegion mem;
43 off_t offset;
44 int nr;
45 QLIST_HEAD(, VFIOQuirk) quirks;
46} VFIOVGARegion;
47
48typedef struct VFIOVGA {
49 off_t fd_offset;
50 int fd;
51 VFIOVGARegion region[QEMU_PCI_VGA_NUM_REGIONS];
52} VFIOVGA;
53
54typedef struct VFIOINTx {
55 bool pending; /* interrupt pending */
56 bool kvm_accel; /* set when QEMU bypass through KVM enabled */
57 uint8_t pin; /* which pin to pull for qemu_set_irq */
58 EventNotifier interrupt; /* eventfd triggered on interrupt */
59 EventNotifier unmask; /* eventfd for unmask on QEMU bypass */
60 PCIINTxRoute route; /* routing info for QEMU bypass */
61 uint32_t mmap_timeout; /* delay to re-enable mmaps after interrupt */
62 QEMUTimer *mmap_timer; /* enable mmaps after periods w/o interrupts */
63} VFIOINTx;
64
65typedef struct VFIOMSIVector {
66 /*
67 * Two interrupt paths are configured per vector. The first, is only used
68 * for interrupts injected via QEMU. This is typically the non-accel path,
69 * but may also be used when we want QEMU to handle masking and pending
70 * bits. The KVM path bypasses QEMU and is therefore higher performance,
71 * but requires masking at the device. virq is used to track the MSI route
72 * through KVM, thus kvm_interrupt is only available when virq is set to a
73 * valid (>= 0) value.
74 */
75 EventNotifier interrupt;
76 EventNotifier kvm_interrupt;
77 struct VFIOPCIDevice *vdev; /* back pointer to device */
78 int virq;
79 bool use;
80} VFIOMSIVector;
81
82enum {
83 VFIO_INT_NONE = 0,
84 VFIO_INT_INTx = 1,
85 VFIO_INT_MSI = 2,
86 VFIO_INT_MSIX = 3,
87};
88
edd09278 89/* Cache of MSI-X setup */
78f33d2b
AW
90typedef struct VFIOMSIXInfo {
91 uint8_t table_bar;
92 uint8_t pba_bar;
93 uint16_t entries;
94 uint32_t table_offset;
95 uint32_t pba_offset;
95239e16 96 unsigned long *pending;
78f33d2b
AW
97} VFIOMSIXInfo;
98
99typedef struct VFIOPCIDevice {
100 PCIDevice pdev;
101 VFIODevice vbasedev;
102 VFIOINTx intx;
103 unsigned int config_size;
104 uint8_t *emulated_config_bits; /* QEMU emulated bits, little-endian */
105 off_t config_offset; /* Offset of config space region within device fd */
106 unsigned int rom_size;
107 off_t rom_offset; /* Offset of ROM region within device fd */
108 void *rom;
109 int msi_cap_size;
110 VFIOMSIVector *msi_vectors;
111 VFIOMSIXInfo *msix;
112 int nr_vectors; /* Number of MSI/MSIX vectors currently in use */
113 int interrupt; /* Current interrupt type */
114 VFIOBAR bars[PCI_NUM_REGIONS - 1]; /* No ROM */
2d82f8a3 115 VFIOVGA *vga; /* 0xa0000, 0x3b0, 0x3c0 */
c4c45e94 116 void *igd_opregion;
78f33d2b
AW
117 PCIHostDeviceAddress host;
118 EventNotifier err_notifier;
119 EventNotifier req_notifier;
120 int (*resetfn)(struct VFIOPCIDevice *);
89dcccc5
AW
121 uint32_t vendor_id;
122 uint32_t device_id;
123 uint32_t sub_vendor_id;
124 uint32_t sub_device_id;
78f33d2b
AW
125 uint32_t features;
126#define VFIO_FEATURE_ENABLE_VGA_BIT 0
127#define VFIO_FEATURE_ENABLE_VGA (1 << VFIO_FEATURE_ENABLE_VGA_BIT)
128#define VFIO_FEATURE_ENABLE_REQ_BIT 1
129#define VFIO_FEATURE_ENABLE_REQ (1 << VFIO_FEATURE_ENABLE_REQ_BIT)
6ced0bba
AW
130#define VFIO_FEATURE_ENABLE_IGD_OPREGION_BIT 2
131#define VFIO_FEATURE_ENABLE_IGD_OPREGION \
132 (1 << VFIO_FEATURE_ENABLE_IGD_OPREGION_BIT)
78f33d2b 133 int32_t bootindex;
c4c45e94 134 uint32_t igd_gms;
78f33d2b 135 uint8_t pm_cap;
dfbee78d 136 uint8_t nv_gpudirect_clique;
78f33d2b
AW
137 bool pci_aer;
138 bool req_enabled;
139 bool has_flr;
140 bool has_pm_reset;
141 bool rom_read_failed;
142 bool no_kvm_intx;
143 bool no_kvm_msi;
144 bool no_kvm_msix;
145} VFIOPCIDevice;
146
c00d61d8
AW
147uint32_t vfio_pci_read_config(PCIDevice *pdev, uint32_t addr, int len);
148void vfio_pci_write_config(PCIDevice *pdev,
149 uint32_t addr, uint32_t val, int len);
150
151uint64_t vfio_vga_read(void *opaque, hwaddr addr, unsigned size);
152void vfio_vga_write(void *opaque, hwaddr addr, uint64_t data, unsigned size);
153
154bool vfio_blacklist_opt_rom(VFIOPCIDevice *vdev);
155void vfio_vga_quirk_setup(VFIOPCIDevice *vdev);
2d82f8a3
AW
156void vfio_vga_quirk_exit(VFIOPCIDevice *vdev);
157void vfio_vga_quirk_finalize(VFIOPCIDevice *vdev);
c00d61d8 158void vfio_bar_quirk_setup(VFIOPCIDevice *vdev, int nr);
2d82f8a3
AW
159void vfio_bar_quirk_exit(VFIOPCIDevice *vdev, int nr);
160void vfio_bar_quirk_finalize(VFIOPCIDevice *vdev, int nr);
c9c50009 161void vfio_setup_resetfn_quirk(VFIOPCIDevice *vdev);
e3f79f3b 162int vfio_add_virt_caps(VFIOPCIDevice *vdev, Error **errp);
c00d61d8 163
dfbee78d
AW
164extern const PropertyInfo qdev_prop_nv_gpudirect_clique;
165
cde4279b 166int vfio_populate_vga(VFIOPCIDevice *vdev, Error **errp);
e593c021 167
6ced0bba 168int vfio_pci_igd_opregion_init(VFIOPCIDevice *vdev,
7237011d
EA
169 struct vfio_region_info *info,
170 Error **errp);
6ced0bba 171
78f33d2b 172#endif /* HW_VFIO_VFIO_PCI_H */
This page took 0.189268 seconds and 4 git commands to generate.