xref: /openbmc/qemu/include/hw/pci/msix.h (revision 35658f6e)
1 #ifndef QEMU_MSIX_H
2 #define QEMU_MSIX_H
3 
4 #include "qemu-common.h"
5 #include "hw/pci/pci.h"
6 
7 void msix_set_message(PCIDevice *dev, int vector, MSIMessage msg);
8 MSIMessage msix_get_message(PCIDevice *dev, unsigned int vector);
9 int msix_init(PCIDevice *dev, unsigned short nentries,
10               MemoryRegion *table_bar, uint8_t table_bar_nr,
11               unsigned table_offset, MemoryRegion *pba_bar,
12               uint8_t pba_bar_nr, unsigned pba_offset, uint8_t cap_pos);
13 int msix_init_exclusive_bar(PCIDevice *dev, unsigned short nentries,
14                             uint8_t bar_nr);
15 
16 void msix_write_config(PCIDevice *dev, uint32_t address, uint32_t val, int len);
17 
18 void msix_uninit(PCIDevice *dev, MemoryRegion *table_bar,
19                  MemoryRegion *pba_bar);
20 void msix_uninit_exclusive_bar(PCIDevice *dev);
21 
22 unsigned int msix_nr_vectors_allocated(const PCIDevice *dev);
23 
24 void msix_save(PCIDevice *dev, QEMUFile *f);
25 void msix_load(PCIDevice *dev, QEMUFile *f);
26 
27 int msix_enabled(PCIDevice *dev);
28 int msix_present(PCIDevice *dev);
29 
30 bool msix_is_masked(PCIDevice *dev, unsigned vector);
31 void msix_set_pending(PCIDevice *dev, unsigned vector);
32 void msix_clr_pending(PCIDevice *dev, int vector);
33 
34 int msix_vector_use(PCIDevice *dev, unsigned vector);
35 void msix_vector_unuse(PCIDevice *dev, unsigned vector);
36 void msix_unuse_all_vectors(PCIDevice *dev);
37 
38 void msix_notify(PCIDevice *dev, unsigned vector);
39 
40 void msix_reset(PCIDevice *dev);
41 
42 int msix_set_vector_notifiers(PCIDevice *dev,
43                               MSIVectorUseNotifier use_notifier,
44                               MSIVectorReleaseNotifier release_notifier,
45                               MSIVectorPollNotifier poll_notifier);
46 void msix_unset_vector_notifiers(PCIDevice *dev);
47 
48 extern const VMStateDescription vmstate_msix;
49 
50 #define VMSTATE_MSIX_TEST(_field, _state, _test) {                   \
51     .name         = (stringify(_field)),                             \
52     .size         = sizeof(PCIDevice),                               \
53     .vmsd         = &vmstate_msix,                                   \
54     .flags        = VMS_STRUCT,                                      \
55     .offset       = vmstate_offset_value(_state, _field, PCIDevice), \
56     .field_exists = (_test)                                          \
57 }
58 
59 #define VMSTATE_MSIX(_f, _s)                                         \
60     VMSTATE_MSIX_TEST(_f, _s, NULL)
61 
62 #endif
63