aboutsummaryrefslogtreecommitdiffstats
path: root/src/include/ipxe/virtio-pci.h
diff options
context:
space:
mode:
authorLadi Prosek <lprosek@redhat.com>2016-04-11 11:26:57 +0200
committerMichael Brown <mcb30@ipxe.org>2016-04-15 17:28:06 +0100
commit7b499f849edc79f30b27dfe8143c04e90e3154c9 (patch)
tree2cdcf8be0f2c03c502709f9b27d4347aafab4971 /src/include/ipxe/virtio-pci.h
parent237949491860bf1ca6f704e586bf723b7d8001e7 (diff)
downloadipxe-7b499f849edc79f30b27dfe8143c04e90e3154c9.tar.gz
[virtio] Add virtio 1.0 constants and data structures
Virtio 1.0 introduces new constants and data structures, common to all devices as well as specific to virtio-net. This commit adds a subset of these to be able to drive the virtio-net 1.0 network device. Signed-off-by: Ladi Prosek <lprosek@redhat.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/include/ipxe/virtio-pci.h')
-rw-r--r--src/include/ipxe/virtio-pci.h60
1 files changed, 60 insertions, 0 deletions
diff --git a/src/include/ipxe/virtio-pci.h b/src/include/ipxe/virtio-pci.h
index a09c46316..8076f20c8 100644
--- a/src/include/ipxe/virtio-pci.h
+++ b/src/include/ipxe/virtio-pci.h
@@ -37,6 +37,66 @@
/* Virtio ABI version, this must match exactly */
#define VIRTIO_PCI_ABI_VERSION 0
+/* PCI capability types: */
+#define VIRTIO_PCI_CAP_COMMON_CFG 1 /* Common configuration */
+#define VIRTIO_PCI_CAP_NOTIFY_CFG 2 /* Notifications */
+#define VIRTIO_PCI_CAP_ISR_CFG 3 /* ISR access */
+#define VIRTIO_PCI_CAP_DEVICE_CFG 4 /* Device specific configuration */
+#define VIRTIO_PCI_CAP_PCI_CFG 5 /* PCI configuration access */
+
+#define __u8 uint8_t
+#define __le16 uint16_t
+#define __le32 uint32_t
+#define __le64 uint64_t
+
+/* 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. */
+ __le32 offset; /* Offset within bar. */
+ __le32 length; /* Length of the structure, in bytes. */
+};
+
+struct virtio_pci_notify_cap {
+ struct virtio_pci_cap cap;
+ __le32 notify_off_multiplier; /* Multiplier for queue_notify_off. */
+};
+
+struct virtio_pci_cfg_cap {
+ struct virtio_pci_cap cap;
+ __u8 pci_cfg_data[4]; /* Data for BAR access. */
+};
+
+/* Fields in VIRTIO_PCI_CAP_COMMON_CFG: */
+struct virtio_pci_common_cfg {
+ /* About the whole device. */
+ __le32 device_feature_select; /* read-write */
+ __le32 device_feature; /* read-only */
+ __le32 guest_feature_select; /* read-write */
+ __le32 guest_feature; /* read-write */
+ __le16 msix_config; /* read-write */
+ __le16 num_queues; /* read-only */
+ __u8 device_status; /* read-write */
+ __u8 config_generation; /* read-only */
+
+ /* About a specific virtqueue. */
+ __le16 queue_select; /* read-write */
+ __le16 queue_size; /* read-write, power of 2. */
+ __le16 queue_msix_vector; /* read-write */
+ __le16 queue_enable; /* read-write */
+ __le16 queue_notify_off; /* read-only */
+ __le32 queue_desc_lo; /* read-write */
+ __le32 queue_desc_hi; /* read-write */
+ __le32 queue_avail_lo; /* read-write */
+ __le32 queue_avail_hi; /* read-write */
+ __le32 queue_used_lo; /* read-write */
+ __le32 queue_used_hi; /* read-write */
+};
+
static inline u32 vp_get_features(unsigned int ioaddr)
{
return inl(ioaddr + VIRTIO_PCI_HOST_FEATURES);