blob: 1f27658d352f2f7d469b930d0f94b31a0f4f7a32 [file] [log] [blame]
Michael S. Tsirkin02eb84d2009-06-21 19:49:54 +03001#ifndef QEMU_MSIX_H
2#define QEMU_MSIX_H
3
4#include "qemu-common.h"
Michael S. Tsirkinc759b242012-12-12 23:05:42 +02005#include "hw/pci/pci.h"
Michael S. Tsirkin02eb84d2009-06-21 19:49:54 +03006
Alexey Kardashevskiy932d4a42012-07-19 10:35:07 +10007void msix_set_message(PCIDevice *dev, int vector, MSIMessage msg);
Michael S. Tsirkin4c93bfa2012-12-21 00:27:02 +02008MSIMessage msix_get_message(PCIDevice *dev, unsigned int vector);
Alex Williamson5a2c2022012-06-14 12:16:47 -06009int msix_init(PCIDevice *dev, unsigned short nentries,
10 MemoryRegion *table_bar, uint8_t table_bar_nr,
11 unsigned table_offset, MemoryRegion *pba_bar,
Cao jinee640c62017-01-17 14:18:48 +080012 uint8_t pba_bar_nr, unsigned pba_offset, uint8_t cap_pos,
13 Error **errp);
Alex Williamson53f94922012-06-14 12:15:51 -060014int msix_init_exclusive_bar(PCIDevice *dev, unsigned short nentries,
Cao jinee640c62017-01-17 14:18:48 +080015 uint8_t bar_nr, Error **errp);
Michael S. Tsirkin02eb84d2009-06-21 19:49:54 +030016
Alex Williamson118f2c22012-06-13 22:52:06 -060017void msix_write_config(PCIDevice *dev, uint32_t address, uint32_t val, int len);
Michael S. Tsirkin02eb84d2009-06-21 19:49:54 +030018
Alex Williamson572992e2012-06-14 12:16:57 -060019void msix_uninit(PCIDevice *dev, MemoryRegion *table_bar,
20 MemoryRegion *pba_bar);
Alex Williamson53f94922012-06-14 12:15:51 -060021void msix_uninit_exclusive_bar(PCIDevice *dev);
Michael S. Tsirkin02eb84d2009-06-21 19:49:54 +030022
Jan Kiszkacb697aa2012-05-17 10:32:38 -030023unsigned int msix_nr_vectors_allocated(const PCIDevice *dev);
24
Michael S. Tsirkin02eb84d2009-06-21 19:49:54 +030025void msix_save(PCIDevice *dev, QEMUFile *f);
26void msix_load(PCIDevice *dev, QEMUFile *f);
27
28int msix_enabled(PCIDevice *dev);
29int msix_present(PCIDevice *dev);
30
Michael S. Tsirkin70f8ee32012-12-18 13:54:32 +020031bool msix_is_masked(PCIDevice *dev, unsigned vector);
32void msix_set_pending(PCIDevice *dev, unsigned vector);
Dmitry Fleytman3bdfaab2016-06-01 11:23:31 +030033void msix_clr_pending(PCIDevice *dev, int vector);
Michael S. Tsirkin70f8ee32012-12-18 13:54:32 +020034
Michael S. Tsirkin02eb84d2009-06-21 19:49:54 +030035int msix_vector_use(PCIDevice *dev, unsigned vector);
36void msix_vector_unuse(PCIDevice *dev, unsigned vector);
Michael S. Tsirkinb5f28bc2009-11-24 16:44:15 +020037void msix_unuse_all_vectors(PCIDevice *dev);
Michael S. Tsirkin02eb84d2009-06-21 19:49:54 +030038
39void msix_notify(PCIDevice *dev, unsigned vector);
40
41void msix_reset(PCIDevice *dev);
42
Jan Kiszka2cdfe532012-05-17 10:32:31 -030043int msix_set_vector_notifiers(PCIDevice *dev,
44 MSIVectorUseNotifier use_notifier,
Michael S. Tsirkinbbef8822012-12-12 16:10:02 +020045 MSIVectorReleaseNotifier release_notifier,
46 MSIVectorPollNotifier poll_notifier);
Jan Kiszka2cdfe532012-05-17 10:32:31 -030047void msix_unset_vector_notifiers(PCIDevice *dev);
Gerd Hoffmann340b50c2013-05-07 15:16:58 +020048
49extern const VMStateDescription vmstate_msix;
50
Marc-André Lureauc246a622015-06-18 14:05:13 +020051#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 Hoffmann340b50c2013-05-07 15:16:58 +020058}
59
Marc-André Lureauc246a622015-06-18 14:05:13 +020060#define VMSTATE_MSIX(_f, _s) \
61 VMSTATE_MSIX_TEST(_f, _s, NULL)
62
Michael S. Tsirkin02eb84d2009-06-21 19:49:54 +030063#endif