On Mon, Jun 29, 2015 at 10:53:27AM +0200, Gerd Hoffmann wrote:
Signed-off-by: Gerd Hoffmann kraxel@redhat.com
src/hw/virtio-pci.h | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++++ src/hw/virtio-ring.h | 5 +++++ 2 files changed, 64 insertions(+)
diff --git a/src/hw/virtio-pci.h b/src/hw/virtio-pci.h index 3cf0327..e6f9c0b 100644 --- a/src/hw/virtio-pci.h +++ b/src/hw/virtio-pci.h @@ -40,6 +40,65 @@ /* Virtio ABI version, this must match exactly */ #define VIRTIO_PCI_ABI_VERSION 0
+/* Common configuration */ +#define VIRTIO_PCI_CAP_COMMON_CFG 1 +/* Notifications */ +#define VIRTIO_PCI_CAP_NOTIFY_CFG 2 +/* ISR access */ +#define VIRTIO_PCI_CAP_ISR_CFG 3 +/* Device specific configuration */ +#define VIRTIO_PCI_CAP_DEVICE_CFG 4 +/* PCI configuration access */ +#define VIRTIO_PCI_CAP_PCI_CFG 5
+/* This is the PCI capability header: */ +struct virtio_pci_cap {
- u8 cap_vndr; /* Generic PCI field: PCI_CAP_ID_VNDR */
- u8 cap_next; /* Generic PCI field: next ptr. */
- u8 cap_len; /* Generic PCI field: capability length */
- u8 cfg_type; /* Identifies the structure. */
- u8 bar; /* Where to find it. */
- u8 padding[3]; /* Pad to full dword. */
- u32 offset; /* Offset within bar. */
- u32 length; /* Length of the structure, in bytes. */
+};
+struct virtio_pci_notify_cap {
- struct virtio_pci_cap cap;
- u32 notify_off_multiplier; /* Multiplier for queue_notify_off. */
+};
+typedef struct virtio_pci_common_cfg {
- /* About the whole device. */
- u32 device_feature_select; /* read-write */
If I understand these structs correctly, they don't reside in memory, but instead represent an interface layout and are used with offsetof() and sizeof(). If so, I think they should be marked with PACKED.
BTW, it would be nice (but certainly not required) to move these types of interface definitions to a new virtio header in the std/ directory.
-Kevin