![]() |
|
|||
0001 /* 0002 * Virtio PCI driver 0003 * 0004 * This module allows virtio devices to be used over a virtual PCI device. 0005 * This can be used with QEMU based VMMs like KVM or Xen. 0006 * 0007 * Copyright IBM Corp. 2007 0008 * 0009 * Authors: 0010 * Anthony Liguori <aliguori@us.ibm.com> 0011 * 0012 * This header is BSD licensed so anyone can use the definitions to implement 0013 * compatible drivers/servers. 0014 * 0015 * Redistribution and use in source and binary forms, with or without 0016 * modification, are permitted provided that the following conditions 0017 * are met: 0018 * 1. Redistributions of source code must retain the above copyright 0019 * notice, this list of conditions and the following disclaimer. 0020 * 2. Redistributions in binary form must reproduce the above copyright 0021 * notice, this list of conditions and the following disclaimer in the 0022 * documentation and/or other materials provided with the distribution. 0023 * 3. Neither the name of IBM nor the names of its contributors 0024 * may be used to endorse or promote products derived from this software 0025 * without specific prior written permission. 0026 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND 0027 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 0028 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 0029 * ARE DISCLAIMED. IN NO EVENT SHALL IBM OR CONTRIBUTORS BE LIABLE 0030 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 0031 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 0032 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 0033 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 0034 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 0035 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 0036 * SUCH DAMAGE. 0037 */ 0038 0039 #ifndef _LINUX_VIRTIO_PCI_H 0040 #define _LINUX_VIRTIO_PCI_H 0041 0042 #include <linux/types.h> 0043 0044 #ifndef VIRTIO_PCI_NO_LEGACY 0045 0046 /* A 32-bit r/o bitmask of the features supported by the host */ 0047 #define VIRTIO_PCI_HOST_FEATURES 0 0048 0049 /* A 32-bit r/w bitmask of features activated by the guest */ 0050 #define VIRTIO_PCI_GUEST_FEATURES 4 0051 0052 /* A 32-bit r/w PFN for the currently selected queue */ 0053 #define VIRTIO_PCI_QUEUE_PFN 8 0054 0055 /* A 16-bit r/o queue size for the currently selected queue */ 0056 #define VIRTIO_PCI_QUEUE_NUM 12 0057 0058 /* A 16-bit r/w queue selector */ 0059 #define VIRTIO_PCI_QUEUE_SEL 14 0060 0061 /* A 16-bit r/w queue notifier */ 0062 #define VIRTIO_PCI_QUEUE_NOTIFY 16 0063 0064 /* An 8-bit device status register. */ 0065 #define VIRTIO_PCI_STATUS 18 0066 0067 /* An 8-bit r/o interrupt status register. Reading the value will return the 0068 * current contents of the ISR and will also clear it. This is effectively 0069 * a read-and-acknowledge. */ 0070 #define VIRTIO_PCI_ISR 19 0071 0072 /* MSI-X registers: only enabled if MSI-X is enabled. */ 0073 /* A 16-bit vector for configuration changes. */ 0074 #define VIRTIO_MSI_CONFIG_VECTOR 20 0075 /* A 16-bit vector for selected queue notifications. */ 0076 #define VIRTIO_MSI_QUEUE_VECTOR 22 0077 0078 /* The remaining space is defined by each driver as the per-driver 0079 * configuration space */ 0080 #define VIRTIO_PCI_CONFIG_OFF(msix_enabled) ((msix_enabled) ? 24 : 20) 0081 /* Deprecated: please use VIRTIO_PCI_CONFIG_OFF instead */ 0082 #define VIRTIO_PCI_CONFIG(dev) VIRTIO_PCI_CONFIG_OFF((dev)->msix_enabled) 0083 0084 /* Virtio ABI version, this must match exactly */ 0085 #define VIRTIO_PCI_ABI_VERSION 0 0086 0087 /* How many bits to shift physical queue address written to QUEUE_PFN. 0088 * 12 is historical, and due to x86 page size. */ 0089 #define VIRTIO_PCI_QUEUE_ADDR_SHIFT 12 0090 0091 /* The alignment to use between consumer and producer parts of vring. 0092 * x86 pagesize again. */ 0093 #define VIRTIO_PCI_VRING_ALIGN 4096 0094 0095 #endif /* VIRTIO_PCI_NO_LEGACY */ 0096 0097 /* The bit of the ISR which indicates a device configuration change. */ 0098 #define VIRTIO_PCI_ISR_CONFIG 0x2 0099 /* Vector value used to disable MSI for queue */ 0100 #define VIRTIO_MSI_NO_VECTOR 0xffff 0101 0102 #ifndef VIRTIO_PCI_NO_MODERN 0103 0104 /* IDs for different capabilities. Must all exist. */ 0105 0106 /* Common configuration */ 0107 #define VIRTIO_PCI_CAP_COMMON_CFG 1 0108 /* Notifications */ 0109 #define VIRTIO_PCI_CAP_NOTIFY_CFG 2 0110 /* ISR access */ 0111 #define VIRTIO_PCI_CAP_ISR_CFG 3 0112 /* Device specific configuration */ 0113 #define VIRTIO_PCI_CAP_DEVICE_CFG 4 0114 /* PCI configuration access */ 0115 #define VIRTIO_PCI_CAP_PCI_CFG 5 0116 /* Additional shared memory capability */ 0117 #define VIRTIO_PCI_CAP_SHARED_MEMORY_CFG 8 0118 0119 /* This is the PCI capability header: */ 0120 struct virtio_pci_cap { 0121 __u8 cap_vndr; /* Generic PCI field: PCI_CAP_ID_VNDR */ 0122 __u8 cap_next; /* Generic PCI field: next ptr. */ 0123 __u8 cap_len; /* Generic PCI field: capability length */ 0124 __u8 cfg_type; /* Identifies the structure. */ 0125 __u8 bar; /* Where to find it. */ 0126 __u8 id; /* Multiple capabilities of the same type */ 0127 __u8 padding[2]; /* Pad to full dword. */ 0128 __le32 offset; /* Offset within bar. */ 0129 __le32 length; /* Length of the structure, in bytes. */ 0130 }; 0131 0132 struct virtio_pci_cap64 { 0133 struct virtio_pci_cap cap; 0134 __le32 offset_hi; /* Most sig 32 bits of offset */ 0135 __le32 length_hi; /* Most sig 32 bits of length */ 0136 }; 0137 0138 struct virtio_pci_notify_cap { 0139 struct virtio_pci_cap cap; 0140 __le32 notify_off_multiplier; /* Multiplier for queue_notify_off. */ 0141 }; 0142 0143 /* Fields in VIRTIO_PCI_CAP_COMMON_CFG: */ 0144 struct virtio_pci_common_cfg { 0145 /* About the whole device. */ 0146 __le32 device_feature_select; /* read-write */ 0147 __le32 device_feature; /* read-only */ 0148 __le32 guest_feature_select; /* read-write */ 0149 __le32 guest_feature; /* read-write */ 0150 __le16 msix_config; /* read-write */ 0151 __le16 num_queues; /* read-only */ 0152 __u8 device_status; /* read-write */ 0153 __u8 config_generation; /* read-only */ 0154 0155 /* About a specific virtqueue. */ 0156 __le16 queue_select; /* read-write */ 0157 __le16 queue_size; /* read-write, power of 2. */ 0158 __le16 queue_msix_vector; /* read-write */ 0159 __le16 queue_enable; /* read-write */ 0160 __le16 queue_notify_off; /* read-only */ 0161 __le32 queue_desc_lo; /* read-write */ 0162 __le32 queue_desc_hi; /* read-write */ 0163 __le32 queue_avail_lo; /* read-write */ 0164 __le32 queue_avail_hi; /* read-write */ 0165 __le32 queue_used_lo; /* read-write */ 0166 __le32 queue_used_hi; /* read-write */ 0167 }; 0168 0169 /* Fields in VIRTIO_PCI_CAP_PCI_CFG: */ 0170 struct virtio_pci_cfg_cap { 0171 struct virtio_pci_cap cap; 0172 __u8 pci_cfg_data[4]; /* Data for BAR access. */ 0173 }; 0174 0175 /* Macro versions of offsets for the Old Timers! */ 0176 #define VIRTIO_PCI_CAP_VNDR 0 0177 #define VIRTIO_PCI_CAP_NEXT 1 0178 #define VIRTIO_PCI_CAP_LEN 2 0179 #define VIRTIO_PCI_CAP_CFG_TYPE 3 0180 #define VIRTIO_PCI_CAP_BAR 4 0181 #define VIRTIO_PCI_CAP_OFFSET 8 0182 #define VIRTIO_PCI_CAP_LENGTH 12 0183 0184 #define VIRTIO_PCI_NOTIFY_CAP_MULT 16 0185 0186 #define VIRTIO_PCI_COMMON_DFSELECT 0 0187 #define VIRTIO_PCI_COMMON_DF 4 0188 #define VIRTIO_PCI_COMMON_GFSELECT 8 0189 #define VIRTIO_PCI_COMMON_GF 12 0190 #define VIRTIO_PCI_COMMON_MSIX 16 0191 #define VIRTIO_PCI_COMMON_NUMQ 18 0192 #define VIRTIO_PCI_COMMON_STATUS 20 0193 #define VIRTIO_PCI_COMMON_CFGGENERATION 21 0194 #define VIRTIO_PCI_COMMON_Q_SELECT 22 0195 #define VIRTIO_PCI_COMMON_Q_SIZE 24 0196 #define VIRTIO_PCI_COMMON_Q_MSIX 26 0197 #define VIRTIO_PCI_COMMON_Q_ENABLE 28 0198 #define VIRTIO_PCI_COMMON_Q_NOFF 30 0199 #define VIRTIO_PCI_COMMON_Q_DESCLO 32 0200 #define VIRTIO_PCI_COMMON_Q_DESCHI 36 0201 #define VIRTIO_PCI_COMMON_Q_AVAILLO 40 0202 #define VIRTIO_PCI_COMMON_Q_AVAILHI 44 0203 #define VIRTIO_PCI_COMMON_Q_USEDLO 48 0204 #define VIRTIO_PCI_COMMON_Q_USEDHI 52 0205 #define VIRTIO_PCI_COMMON_Q_NDATA 56 0206 #define VIRTIO_PCI_COMMON_Q_RESET 58 0207 0208 #endif /* VIRTIO_PCI_NO_MODERN */ 0209 0210 #endif
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.1.0 LXR engine. The LXR team |
![]() ![]() |