xref: /freebsd/sys/dev/virtio/pci/virtio_pci_legacy_var.h (revision dd41de95a84d979615a2ef11df6850622bf6184e)
1 /*-
2  * SPDX-License-Identifier: BSD-3-Clause
3  *
4  * Copyright IBM Corp. 2007
5  *
6  * Authors:
7  *  Anthony Liguori  <aliguori@us.ibm.com>
8  *
9  * This header is BSD licensed so anyone can use the definitions to implement
10  * compatible drivers/servers.
11  *
12  * Redistribution and use in source and binary forms, with or without
13  * modification, are permitted provided that the following conditions
14  * are met:
15  * 1. Redistributions of source code must retain the above copyright
16  *    notice, this list of conditions and the following disclaimer.
17  * 2. Redistributions in binary form must reproduce the above copyright
18  *    notice, this list of conditions and the following disclaimer in the
19  *    documentation and/or other materials provided with the distribution.
20  * 3. Neither the name of IBM nor the names of its contributors
21  *    may be used to endorse or promote products derived from this software
22  *    without specific prior written permission.
23  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
25  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
26  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL IBM OR CONTRIBUTORS BE LIABLE
27  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33  * SUCH DAMAGE.
34  *
35  * $FreeBSD$
36  */
37 
38 #ifndef _VIRTIO_PCI_LEGACY_VAR_H
39 #define _VIRTIO_PCI_LEGACY_VAR_H
40 
41 #include <dev/virtio/pci/virtio_pci_var.h>
42 
43 /* VirtIO ABI version, this must match exactly. */
44 #define VIRTIO_PCI_ABI_VERSION	0
45 
46 /*
47  * VirtIO Header, located in BAR 0.
48  */
49 #define VIRTIO_PCI_HOST_FEATURES  0  /* host's supported features (32bit, RO)*/
50 #define VIRTIO_PCI_GUEST_FEATURES 4  /* guest's supported features (32, RW) */
51 #define VIRTIO_PCI_QUEUE_PFN      8  /* physical address of VQ (32, RW) */
52 #define VIRTIO_PCI_QUEUE_NUM      12 /* number of ring entries (16, RO) */
53 #define VIRTIO_PCI_QUEUE_SEL      14 /* current VQ selection (16, RW) */
54 #define VIRTIO_PCI_QUEUE_NOTIFY	  16 /* notify host regarding VQ (16, RW) */
55 #define VIRTIO_PCI_STATUS         18 /* device status register (8, RW) */
56 #define VIRTIO_PCI_ISR            19 /* interrupt status register, reading
57 				      * also clears the register (8, RO) */
58 /* Only if MSIX is enabled: */
59 #define VIRTIO_MSI_CONFIG_VECTOR  20 /* configuration change vector (16, RW) */
60 #define VIRTIO_MSI_QUEUE_VECTOR   22 /* vector for selected VQ notifications
61 					(16, RW) */
62 
63 /*
64  * The remaining space is defined by each driver as the per-driver
65  * configuration space.
66  */
67 #define VIRTIO_PCI_CONFIG_OFF(msix_enabled)     ((msix_enabled) ? 24 : 20)
68 
69 /*
70  * How many bits to shift physical queue address written to QUEUE_PFN.
71  * 12 is historical, and due to x86 page size.
72  */
73 #define VIRTIO_PCI_QUEUE_ADDR_SHIFT	12
74 
75 /* The alignment to use between consumer and producer parts of vring. */
76 #define VIRTIO_PCI_VRING_ALIGN	4096
77 
78 #endif /* _VIRTIO_PCI_LEGACY_VAR_H */
79