diff options
-rw-r--r-- | sys/dev/pci/virtio_pci.c | 3 | ||||
-rw-r--r-- | sys/dev/pci/virtio_pcireg.h | 39 | ||||
-rw-r--r-- | sys/dev/pv/virtioreg.h | 50 |
3 files changed, 60 insertions, 32 deletions
diff --git a/sys/dev/pci/virtio_pci.c b/sys/dev/pci/virtio_pci.c index 15a2e0611ec..d9c8d144e21 100644 --- a/sys/dev/pci/virtio_pci.c +++ b/sys/dev/pci/virtio_pci.c @@ -1,4 +1,4 @@ -/* $OpenBSD: virtio_pci.c,v 1.19 2019/01/10 18:05:43 sf Exp $ */ +/* $OpenBSD: virtio_pci.c,v 1.20 2019/01/10 18:11:42 sf Exp $ */ /* $NetBSD: virtio.c,v 1.3 2011/11/02 23:05:52 njoly Exp $ */ /* @@ -38,6 +38,7 @@ #include <dev/pv/virtioreg.h> #include <dev/pv/virtiovar.h> +#include <dev/pci/virtio_pcireg.h> /* * XXX: Before being used on big endian arches, the access to config registers diff --git a/sys/dev/pci/virtio_pcireg.h b/sys/dev/pci/virtio_pcireg.h new file mode 100644 index 00000000000..dc838f38d59 --- /dev/null +++ b/sys/dev/pci/virtio_pcireg.h @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2019 Stefan Fritsch <sf@openbsd.org> + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#ifndef _DEV_PCI_VIRTIO_PCIREG_H_ +#define _DEV_PCI_VIRTIO_PCIREG_H_ + +/* Virtio 0.9 config space */ +#define VIRTIO_CONFIG_DEVICE_FEATURES 0 /* 32bit */ +#define VIRTIO_CONFIG_GUEST_FEATURES 4 /* 32bit */ +#define VIRTIO_CONFIG_QUEUE_ADDRESS 8 /* 32bit */ +#define VIRTIO_CONFIG_QUEUE_SIZE 12 /* 16bit */ +#define VIRTIO_CONFIG_QUEUE_SELECT 14 /* 16bit */ +#define VIRTIO_CONFIG_QUEUE_NOTIFY 16 /* 16bit */ +#define VIRTIO_CONFIG_DEVICE_STATUS 18 /* 8bit */ +#define VIRTIO_CONFIG_ISR_STATUS 19 /* 8bit */ +#define VIRTIO_CONFIG_ISR_CONFIG_CHANGE 2 +#define VIRTIO_CONFIG_DEVICE_CONFIG_NOMSI 20 +/* Only if MSIX is enabled: */ +#define VIRTIO_MSI_CONFIG_VECTOR 20 /* 16bit, optional */ +#define VIRTIO_MSI_QUEUE_VECTOR 22 /* 16bit, optional */ +#define VIRTIO_CONFIG_DEVICE_CONFIG_MSI 24 + +#define VIRTIO_MSI_NO_VECTOR 0xffff + + +#endif /* _DEV_PCI_VIRTIO_PCIREG_H_ */ diff --git a/sys/dev/pv/virtioreg.h b/sys/dev/pv/virtioreg.h index d316523be74..1eb215419f6 100644 --- a/sys/dev/pv/virtioreg.h +++ b/sys/dev/pv/virtioreg.h @@ -1,4 +1,4 @@ -/* $OpenBSD: virtioreg.h,v 1.1 2017/01/21 11:23:06 reyk Exp $ */ +/* $OpenBSD: virtioreg.h,v 1.2 2019/01/10 18:11:42 sf Exp $ */ /* $NetBSD: virtioreg.h,v 1.1 2011/10/30 12:12:21 hannken Exp $ */ /* @@ -64,8 +64,8 @@ */ -#ifndef _DEV_PCI_VIRTIOREG_H_ -#define _DEV_PCI_VIRTIOREG_H_ +#ifndef _DEV_PV_VIRTIOREG_H_ +#define _DEV_PV_VIRTIOREG_H_ #include <sys/types.h> @@ -82,33 +82,21 @@ #define PCI_PRODUCT_VIRTIO_MAC80211 10 #define PCI_PRODUCT_VIRTIO_VMMCI 65535 /* private id */ -/* Virtio header */ -#define VIRTIO_CONFIG_DEVICE_FEATURES 0 /* 32bit */ -#define VIRTIO_CONFIG_GUEST_FEATURES 4 /* 32bit */ -#define VIRTIO_F_NOTIFY_ON_EMPTY (1<<24) -#define VIRTIO_F_RING_INDIRECT_DESC (1<<28) -#define VIRTIO_F_RING_EVENT_IDX (1<<29) -#define VIRTIO_F_BAD_FEATURE (1<<30) -#define VIRTIO_CONFIG_QUEUE_ADDRESS 8 /* 32bit */ -#define VIRTIO_CONFIG_QUEUE_SIZE 12 /* 16bit */ -#define VIRTIO_CONFIG_QUEUE_SELECT 14 /* 16bit */ -#define VIRTIO_CONFIG_QUEUE_NOTIFY 16 /* 16bit */ -#define VIRTIO_CONFIG_DEVICE_STATUS 18 /* 8bit */ -#define VIRTIO_CONFIG_DEVICE_STATUS_RESET 0 -#define VIRTIO_CONFIG_DEVICE_STATUS_ACK 1 -#define VIRTIO_CONFIG_DEVICE_STATUS_DRIVER 2 -#define VIRTIO_CONFIG_DEVICE_STATUS_DRIVER_OK 4 -#define VIRTIO_CONFIG_DEVICE_STATUS_FAILED 128 -#define VIRTIO_CONFIG_ISR_STATUS 19 /* 8bit */ -#define VIRTIO_CONFIG_ISR_CONFIG_CHANGE 2 -#define VIRTIO_CONFIG_DEVICE_CONFIG_NOMSI 20 -/* Only if MSIX is enabled: */ -#define VIRTIO_MSI_CONFIG_VECTOR 20 /* 16bit, optional */ -#define VIRTIO_MSI_QUEUE_VECTOR 22 /* 16bit, optional */ -#define VIRTIO_CONFIG_DEVICE_CONFIG_MSI 24 - -#define VIRTIO_MSI_NO_VECTOR 0xffff - +/* device-independent feature bits */ +#define VIRTIO_F_NOTIFY_ON_EMPTY 24 +#define VIRTIO_F_RING_INDIRECT_DESC 28 +#define VIRTIO_F_RING_EVENT_IDX 29 +#define VIRTIO_F_BAD_FEATURE 30 +#define VIRTIO_F_VERSION_1 32 + +/* device status bits */ +#define VIRTIO_CONFIG_DEVICE_STATUS_RESET 0 +#define VIRTIO_CONFIG_DEVICE_STATUS_ACK 1 +#define VIRTIO_CONFIG_DEVICE_STATUS_DRIVER 2 +#define VIRTIO_CONFIG_DEVICE_STATUS_DRIVER_OK 4 +#define VIRTIO_CONFIG_DEVICE_STATUS_FEATURES_OK 8 +#define VIRTIO_CONFIG_DEVICE_STATUS_DEVICE_NEEDS_RESET 64 +#define VIRTIO_CONFIG_DEVICE_STATUS_FAILED 128 /* Virtqueue */ /* This marks a buffer as continuing via the next field. */ @@ -195,4 +183,4 @@ struct vring_used { #define VIRTIO_PAGE_SIZE (4096) -#endif /* _DEV_PCI_VIRTIOREG_H_ */ +#endif /* _DEV_PV_VIRTIOREG_H_ */ |