Michael S. Tsirkin | 02eb84d | 2009-06-21 19:49:54 +0300 | [diff] [blame] | 1 | #ifndef QEMU_MSIX_H |
| 2 | #define QEMU_MSIX_H |
| 3 | |
| 4 | #include "qemu-common.h" |
Michael S. Tsirkin | c759b24 | 2012-12-12 23:05:42 +0200 | [diff] [blame] | 5 | #include "hw/pci/pci.h" |
Michael S. Tsirkin | 02eb84d | 2009-06-21 19:49:54 +0300 | [diff] [blame] | 6 | |
Alexey Kardashevskiy | 932d4a4 | 2012-07-19 10:35:07 +1000 | [diff] [blame] | 7 | void msix_set_message(PCIDevice *dev, int vector, MSIMessage msg); |
Michael S. Tsirkin | 4c93bfa | 2012-12-21 00:27:02 +0200 | [diff] [blame] | 8 | MSIMessage msix_get_message(PCIDevice *dev, unsigned int vector); |
Alex Williamson | 5a2c202 | 2012-06-14 12:16:47 -0600 | [diff] [blame] | 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, |
Cao jin | ee640c6 | 2017-01-17 14:18:48 +0800 | [diff] [blame] | 12 | uint8_t pba_bar_nr, unsigned pba_offset, uint8_t cap_pos, |
| 13 | Error **errp); |
Alex Williamson | 53f9492 | 2012-06-14 12:15:51 -0600 | [diff] [blame] | 14 | int msix_init_exclusive_bar(PCIDevice *dev, unsigned short nentries, |
Cao jin | ee640c6 | 2017-01-17 14:18:48 +0800 | [diff] [blame] | 15 | uint8_t bar_nr, Error **errp); |
Michael S. Tsirkin | 02eb84d | 2009-06-21 19:49:54 +0300 | [diff] [blame] | 16 | |
Alex Williamson | 118f2c2 | 2012-06-13 22:52:06 -0600 | [diff] [blame] | 17 | void msix_write_config(PCIDevice *dev, uint32_t address, uint32_t val, int len); |
Michael S. Tsirkin | 02eb84d | 2009-06-21 19:49:54 +0300 | [diff] [blame] | 18 | |
Alex Williamson | 572992e | 2012-06-14 12:16:57 -0600 | [diff] [blame] | 19 | void msix_uninit(PCIDevice *dev, MemoryRegion *table_bar, |
| 20 | MemoryRegion *pba_bar); |
Alex Williamson | 53f9492 | 2012-06-14 12:15:51 -0600 | [diff] [blame] | 21 | void msix_uninit_exclusive_bar(PCIDevice *dev); |
Michael S. Tsirkin | 02eb84d | 2009-06-21 19:49:54 +0300 | [diff] [blame] | 22 | |
Jan Kiszka | cb697aa | 2012-05-17 10:32:38 -0300 | [diff] [blame] | 23 | unsigned int msix_nr_vectors_allocated(const PCIDevice *dev); |
| 24 | |
Michael S. Tsirkin | 02eb84d | 2009-06-21 19:49:54 +0300 | [diff] [blame] | 25 | void msix_save(PCIDevice *dev, QEMUFile *f); |
| 26 | void msix_load(PCIDevice *dev, QEMUFile *f); |
| 27 | |
| 28 | int msix_enabled(PCIDevice *dev); |
| 29 | int msix_present(PCIDevice *dev); |
| 30 | |
Michael S. Tsirkin | 70f8ee3 | 2012-12-18 13:54:32 +0200 | [diff] [blame] | 31 | bool msix_is_masked(PCIDevice *dev, unsigned vector); |
| 32 | void msix_set_pending(PCIDevice *dev, unsigned vector); |
Dmitry Fleytman | 3bdfaab | 2016-06-01 11:23:31 +0300 | [diff] [blame] | 33 | void msix_clr_pending(PCIDevice *dev, int vector); |
Michael S. Tsirkin | 70f8ee3 | 2012-12-18 13:54:32 +0200 | [diff] [blame] | 34 | |
Michael S. Tsirkin | 02eb84d | 2009-06-21 19:49:54 +0300 | [diff] [blame] | 35 | int msix_vector_use(PCIDevice *dev, unsigned vector); |
| 36 | void msix_vector_unuse(PCIDevice *dev, unsigned vector); |
Michael S. Tsirkin | b5f28bc | 2009-11-24 16:44:15 +0200 | [diff] [blame] | 37 | void msix_unuse_all_vectors(PCIDevice *dev); |
Michael S. Tsirkin | 02eb84d | 2009-06-21 19:49:54 +0300 | [diff] [blame] | 38 | |
| 39 | void msix_notify(PCIDevice *dev, unsigned vector); |
| 40 | |
| 41 | void msix_reset(PCIDevice *dev); |
| 42 | |
Jan Kiszka | 2cdfe53 | 2012-05-17 10:32:31 -0300 | [diff] [blame] | 43 | int msix_set_vector_notifiers(PCIDevice *dev, |
| 44 | MSIVectorUseNotifier use_notifier, |
Michael S. Tsirkin | bbef882 | 2012-12-12 16:10:02 +0200 | [diff] [blame] | 45 | MSIVectorReleaseNotifier release_notifier, |
| 46 | MSIVectorPollNotifier poll_notifier); |
Jan Kiszka | 2cdfe53 | 2012-05-17 10:32:31 -0300 | [diff] [blame] | 47 | void msix_unset_vector_notifiers(PCIDevice *dev); |
Gerd Hoffmann | 340b50c | 2013-05-07 15:16:58 +0200 | [diff] [blame] | 48 | |
| 49 | extern const VMStateDescription vmstate_msix; |
| 50 | |
Marc-André Lureau | c246a62 | 2015-06-18 14:05:13 +0200 | [diff] [blame] | 51 | #define VMSTATE_MSIX_TEST(_field, _state, _test) { \ |
| 52 | .name = (stringify(_field)), \ |
| 53 | .size = sizeof(PCIDevice), \ |
| 54 | .vmsd = &vmstate_msix, \ |
| 55 | .flags = VMS_STRUCT, \ |
| 56 | .offset = vmstate_offset_value(_state, _field, PCIDevice), \ |
| 57 | .field_exists = (_test) \ |
Gerd Hoffmann | 340b50c | 2013-05-07 15:16:58 +0200 | [diff] [blame] | 58 | } |
| 59 | |
Marc-André Lureau | c246a62 | 2015-06-18 14:05:13 +0200 | [diff] [blame] | 60 | #define VMSTATE_MSIX(_f, _s) \ |
| 61 | VMSTATE_MSIX_TEST(_f, _s, NULL) |
| 62 | |
Michael S. Tsirkin | 02eb84d | 2009-06-21 19:49:54 +0300 | [diff] [blame] | 63 | #endif |