aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorFlorian Freudiger <25648113+FlorianFreudiger@users.noreply.github.com>2023-08-15 13:24:23 +0200
committerGitHub <noreply@github.com>2023-08-15 12:24:23 +0100
commit1cca91aeb8ae8f531f9c3b9c59d83630e9941a5e (patch)
treea0b700608a3f29be7cc8cb14060eb2b703edf59c /include
parent852ca25f41bf7be8a6a2a8b30c0e2374c10b480e (diff)
downloadlibvfio-user-1cca91aeb8ae8f531f9c3b9c59d83630e9941a5e.zip
libvfio-user-1cca91aeb8ae8f531f9c3b9c59d83630e9941a5e.tar.gz
libvfio-user-1cca91aeb8ae8f531f9c3b9c59d83630e9941a5e.tar.bz2
Allow adding MSI capability via vfu_pci_add_capability (#758)
Signed-off-by: Florian Freudiger <25648113+FlorianFreudiger@users.noreply.github.com>
Diffstat (limited to 'include')
-rw-r--r--include/libvfio-user.h1
-rw-r--r--include/pci_caps/msi.h33
2 files changed, 20 insertions, 14 deletions
diff --git a/include/libvfio-user.h b/include/libvfio-user.h
index 7cd28b5..72369b6 100644
--- a/include/libvfio-user.h
+++ b/include/libvfio-user.h
@@ -981,6 +981,7 @@ vfu_pci_get_config_space(vfu_ctx_t *vfu_ctx);
* Certain standard capabilities are handled entirely within the library:
*
* PCI_CAP_ID_EXP (pxcap)
+ * PCI_CAP_ID_MSI (msicap)
* PCI_CAP_ID_MSIX (msixcap)
* PCI_CAP_ID_PM (pmcap)
*
diff --git a/include/pci_caps/msi.h b/include/pci_caps/msi.h
index c148c9e..481abee 100644
--- a/include/pci_caps/msi.h
+++ b/include/pci_caps/msi.h
@@ -39,33 +39,38 @@
extern "C" {
#endif
+/* Message Control for MSI */
struct mc {
- unsigned int msie:1;
- unsigned int mmc:3;
- unsigned int mme:3;
- unsigned int c64:1;
- unsigned int pvm:1;
- unsigned int res1:7;
+ unsigned int msie:1; /* RW */
+ unsigned int mmc:3; /* RO */
+ unsigned int mme:3; /* RW */
+ unsigned int c64:1; /* RO */
+ unsigned int pvm:1; /* RO */
+ unsigned int res1:7; /* not implemented, extended message data control */
} __attribute__ ((packed));
_Static_assert(sizeof(struct mc) == 0x2, "bad MC size");
+/* Message Address for MSI */
struct ma {
- unsigned int res1:2;
- unsigned int addr:30;
+ unsigned int res1:2; /* read must return 0, write has no effect */
+ unsigned int addr:30; /* RW */
} __attribute__ ((packed));
_Static_assert(sizeof(struct ma) == 0x4, "bad MA size");
+#define VFIO_USER_PCI_CAP_MSI_SIZEOF (0x18)
+
struct msicap {
struct cap_hdr hdr;
struct mc mc;
struct ma ma;
- uint32_t mua;
- uint16_t md;
- uint16_t padding;
- uint32_t mmask;
- uint32_t mpend;
+ uint32_t mua; /* RW */
+ uint16_t md; /* RW */
+ uint16_t padding; /* not implemented, extended message data */
+ uint32_t mmask; /* RW */
+ uint32_t mpend; /* RO */
} __attribute__ ((packed));
-_Static_assert(sizeof(struct msicap) == 0x18, "bad MSICAP size");
+_Static_assert(sizeof(struct msicap) == VFIO_USER_PCI_CAP_MSI_SIZEOF,
+ "bad MSICAP size");
_Static_assert(offsetof(struct msicap, hdr) == 0, "bad offset");
#ifdef __cplusplus