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