xref: /freebsd/sys/dev/virtio/pci/virtio_pci_if.m (revision 031beb4e239bfce798af17f5fe8dba8bcaf13d99)
1*9da9560cSBryan Venteicher#-
2*9da9560cSBryan Venteicher# Copyright (c) 2017, Bryan Venteicher <bryanv@FreeBSD.org>
3*9da9560cSBryan Venteicher# All rights reserved.
4*9da9560cSBryan Venteicher#
5*9da9560cSBryan Venteicher# Redistribution and use in source and binary forms, with or without
6*9da9560cSBryan Venteicher# modification, are permitted provided that the following conditions
7*9da9560cSBryan Venteicher# are met:
8*9da9560cSBryan Venteicher# 1. Redistributions of source code must retain the above copyright
9*9da9560cSBryan Venteicher#    notice, this list of conditions and the following disclaimer.
10*9da9560cSBryan Venteicher# 2. Redistributions in binary form must reproduce the above copyright
11*9da9560cSBryan Venteicher#    notice, this list of conditions and the following disclaimer in the
12*9da9560cSBryan Venteicher#    documentation and/or other materials provided with the distribution.
13*9da9560cSBryan Venteicher#
14*9da9560cSBryan Venteicher# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15*9da9560cSBryan Venteicher# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16*9da9560cSBryan Venteicher# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17*9da9560cSBryan Venteicher# ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18*9da9560cSBryan Venteicher# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19*9da9560cSBryan Venteicher# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20*9da9560cSBryan Venteicher# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21*9da9560cSBryan Venteicher# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22*9da9560cSBryan Venteicher# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23*9da9560cSBryan Venteicher# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24*9da9560cSBryan Venteicher# SUCH DAMAGE.
25*9da9560cSBryan Venteicher#
26*9da9560cSBryan Venteicher
27*9da9560cSBryan Venteicher#include <sys/bus.h>
28*9da9560cSBryan Venteicher#include <machine/bus.h>
29*9da9560cSBryan Venteicher
30*9da9560cSBryan VenteicherINTERFACE virtio_pci;
31*9da9560cSBryan Venteicher
32*9da9560cSBryan VenteicherHEADER {
33*9da9560cSBryan Venteicherstruct virtqueue;
34*9da9560cSBryan Venteicherstruct vtpci_interrupt;
35*9da9560cSBryan Venteicher};
36*9da9560cSBryan Venteicher
37*9da9560cSBryan VenteicherMETHOD uint8_t read_isr {
38*9da9560cSBryan Venteicher	device_t	dev;
39*9da9560cSBryan Venteicher};
40*9da9560cSBryan Venteicher
41*9da9560cSBryan VenteicherMETHOD uint16_t get_vq_size {
42*9da9560cSBryan Venteicher	device_t	dev;
43*9da9560cSBryan Venteicher	int		idx;
44*9da9560cSBryan Venteicher};
45*9da9560cSBryan Venteicher
46*9da9560cSBryan VenteicherMETHOD bus_size_t get_vq_notify_off {
47*9da9560cSBryan Venteicher	device_t	dev;
48*9da9560cSBryan Venteicher	int		idx;
49*9da9560cSBryan Venteicher};
50*9da9560cSBryan Venteicher
51*9da9560cSBryan VenteicherMETHOD void set_vq {
52*9da9560cSBryan Venteicher	device_t		dev;
53*9da9560cSBryan Venteicher	struct virtqueue	*vq;
54*9da9560cSBryan Venteicher};
55*9da9560cSBryan Venteicher
56*9da9560cSBryan VenteicherMETHOD void disable_vq {
57*9da9560cSBryan Venteicher	device_t		 dev;
58*9da9560cSBryan Venteicher	int			 idx;
59*9da9560cSBryan Venteicher};
60*9da9560cSBryan Venteicher
61*9da9560cSBryan VenteicherMETHOD int register_cfg_msix {
62*9da9560cSBryan Venteicher	device_t	dev;
63*9da9560cSBryan Venteicher	struct vtpci_interrupt *intr;
64*9da9560cSBryan Venteicher};
65*9da9560cSBryan Venteicher
66*9da9560cSBryan VenteicherMETHOD int register_vq_msix {
67*9da9560cSBryan Venteicher	device_t		dev;
68*9da9560cSBryan Venteicher	int			idx;
69*9da9560cSBryan Venteicher	struct vtpci_interrupt	*intr;
70*9da9560cSBryan Venteicher};
71