1228301Sgrehan/*- 2227652Sgrehan * Copyright IBM Corp. 2007 3227652Sgrehan * 4227652Sgrehan * Authors: 5227652Sgrehan * Anthony Liguori <aliguori@us.ibm.com> 6227652Sgrehan * 7227652Sgrehan * This header is BSD licensed so anyone can use the definitions to implement 8227652Sgrehan * compatible drivers/servers. 9227652Sgrehan * 10228301Sgrehan * Redistribution and use in source and binary forms, with or without 11228301Sgrehan * modification, are permitted provided that the following conditions 12228301Sgrehan * are met: 13228301Sgrehan * 1. Redistributions of source code must retain the above copyright 14228301Sgrehan * notice, this list of conditions and the following disclaimer. 15228301Sgrehan * 2. Redistributions in binary form must reproduce the above copyright 16228301Sgrehan * notice, this list of conditions and the following disclaimer in the 17228301Sgrehan * documentation and/or other materials provided with the distribution. 18228301Sgrehan * 3. Neither the name of IBM nor the names of its contributors 19228301Sgrehan * may be used to endorse or promote products derived from this software 20228301Sgrehan * without specific prior written permission. 21228301Sgrehan * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 22228301Sgrehan * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 23228301Sgrehan * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 24228301Sgrehan * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL IBM OR CONTRIBUTORS BE LIABLE 25228301Sgrehan * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26228301Sgrehan * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27228301Sgrehan * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28228301Sgrehan * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29228301Sgrehan * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30228301Sgrehan * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31228301Sgrehan * SUCH DAMAGE. 32228301Sgrehan * 33227652Sgrehan * $FreeBSD$ 34227652Sgrehan */ 35227652Sgrehan 36227652Sgrehan#ifndef _VIRTIO_PCI_H 37227652Sgrehan#define _VIRTIO_PCI_H 38227652Sgrehan 39227652Sgrehan/* VirtIO PCI vendor/device ID. */ 40227652Sgrehan#define VIRTIO_PCI_VENDORID 0x1AF4 41227652Sgrehan#define VIRTIO_PCI_DEVICEID_MIN 0x1000 42227652Sgrehan#define VIRTIO_PCI_DEVICEID_MAX 0x103F 43227652Sgrehan 44227652Sgrehan/* VirtIO ABI version, this must match exactly. */ 45227652Sgrehan#define VIRTIO_PCI_ABI_VERSION 0 46227652Sgrehan 47227652Sgrehan/* 48227652Sgrehan * VirtIO Header, located in BAR 0. 49227652Sgrehan */ 50227652Sgrehan#define VIRTIO_PCI_HOST_FEATURES 0 /* host's supported features (32bit, RO)*/ 51227652Sgrehan#define VIRTIO_PCI_GUEST_FEATURES 4 /* guest's supported features (32, RW) */ 52227652Sgrehan#define VIRTIO_PCI_QUEUE_PFN 8 /* physical address of VQ (32, RW) */ 53227652Sgrehan#define VIRTIO_PCI_QUEUE_NUM 12 /* number of ring entries (16, RO) */ 54227652Sgrehan#define VIRTIO_PCI_QUEUE_SEL 14 /* current VQ selection (16, RW) */ 55227652Sgrehan#define VIRTIO_PCI_QUEUE_NOTIFY 16 /* notify host regarding VQ (16, RW) */ 56227652Sgrehan#define VIRTIO_PCI_STATUS 18 /* device status register (8, RW) */ 57227652Sgrehan#define VIRTIO_PCI_ISR 19 /* interrupt status register, reading 58227652Sgrehan * also clears the register (8, RO) */ 59227652Sgrehan/* Only if MSIX is enabled: */ 60227652Sgrehan#define VIRTIO_MSI_CONFIG_VECTOR 20 /* configuration change vector (16, RW) */ 61227652Sgrehan#define VIRTIO_MSI_QUEUE_VECTOR 22 /* vector for selected VQ notifications 62227652Sgrehan (16, RW) */ 63227652Sgrehan 64227652Sgrehan/* The bit of the ISR which indicates a device has an interrupt. */ 65227652Sgrehan#define VIRTIO_PCI_ISR_INTR 0x1 66227652Sgrehan/* The bit of the ISR which indicates a device configuration change. */ 67227652Sgrehan#define VIRTIO_PCI_ISR_CONFIG 0x2 68227652Sgrehan/* Vector value used to disable MSI for queue. */ 69227652Sgrehan#define VIRTIO_MSI_NO_VECTOR 0xFFFF 70227652Sgrehan 71227652Sgrehan/* 72227652Sgrehan * The remaining space is defined by each driver as the per-driver 73227652Sgrehan * configuration space. 74227652Sgrehan */ 75268010Sbryanv#define VIRTIO_PCI_CONFIG_OFF(msix_enabled) ((msix_enabled) ? 24 : 20) 76227652Sgrehan 77227652Sgrehan/* 78227652Sgrehan * How many bits to shift physical queue address written to QUEUE_PFN. 79227652Sgrehan * 12 is historical, and due to x86 page size. 80227652Sgrehan */ 81227652Sgrehan#define VIRTIO_PCI_QUEUE_ADDR_SHIFT 12 82227652Sgrehan 83227652Sgrehan/* The alignment to use between consumer and producer parts of vring. */ 84227652Sgrehan#define VIRTIO_PCI_VRING_ALIGN 4096 85227652Sgrehan 86227652Sgrehan#endif /* _VIRTIO_PCI_H */ 87