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