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