aboutsummaryrefslogtreecommitdiff
path: root/sys/dev/virtio/virtqueue.c
diff options
context:
space:
mode:
authorBryan Venteicher <bryanv@FreeBSD.org>2021-01-19 04:55:23 +0000
committerBryan Venteicher <bryanv@FreeBSD.org>2021-01-19 04:55:23 +0000
commit9da9560c4dd3556519cd391a04f0db157dc3c295 (patch)
tree3b0683487a19826301aae9fdf70ede862337e37d /sys/dev/virtio/virtqueue.c
parent1cd1ed3f5dd50ca070908468a3816f570448427b (diff)
virtio: Add VirtIO PCI modern (V1) support
Use the existing legacy PCI driver as the basis for shared code between the legacy and modern PCI drivers. The existing virtio_pci kernel module will contain both the legacy and modern drivers. Changes to the virtqueue and each device driver (network, block, etc) for V1 support come in later commits. Update the MMIO driver to reflect the VirtIO bus method changes, but the modern compliance can be improved on later. Note that the modern PCI driver requires bus_map_resource() to be implemented, which is not the case on all archs. The hw.virtio.pci.transitional tunable default value is zero so transitional devices will continue to be driven via the legacy driver. Reviewed by: grehan (mentor) Differential Revision: https://reviews.freebsd.org/D27856
Diffstat (limited to 'sys/dev/virtio/virtqueue.c')
-rw-r--r--sys/dev/virtio/virtqueue.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/sys/dev/virtio/virtqueue.c b/sys/dev/virtio/virtqueue.c
index e23d4d25c47f..da6e7bf89fd5 100644
--- a/sys/dev/virtio/virtqueue.c
+++ b/sys/dev/virtio/virtqueue.c
@@ -64,6 +64,7 @@ struct virtqueue {
#define VIRTQUEUE_FLAG_INDIRECT 0x0001
#define VIRTQUEUE_FLAG_EVENT_IDX 0x0002
+ bus_size_t vq_notify_offset;
int vq_alignment;
int vq_ring_size;
void *vq_ring_mem;
@@ -147,8 +148,9 @@ virtqueue_filter_features(uint64_t features)
}
int
-virtqueue_alloc(device_t dev, uint16_t queue, uint16_t size, int align,
- vm_paddr_t highaddr, struct vq_alloc_info *info, struct virtqueue **vqp)
+virtqueue_alloc(device_t dev, uint16_t queue, uint16_t size,
+ bus_size_t notify_offset, int align, vm_paddr_t highaddr,
+ struct vq_alloc_info *info, struct virtqueue **vqp)
{
struct virtqueue *vq;
int error;
@@ -184,6 +186,7 @@ virtqueue_alloc(device_t dev, uint16_t queue, uint16_t size, int align,
vq->vq_dev = dev;
strlcpy(vq->vq_name, info->vqai_name, sizeof(vq->vq_name));
vq->vq_queue_index = queue;
+ vq->vq_notify_offset = notify_offset;
vq->vq_alignment = align;
vq->vq_nentries = size;
vq->vq_free_cnt = size;
@@ -820,7 +823,8 @@ static void
vq_ring_notify_host(struct virtqueue *vq)
{
- VIRTIO_BUS_NOTIFY_VQ(vq->vq_dev, vq->vq_queue_index);
+ VIRTIO_BUS_NOTIFY_VQ(vq->vq_dev, vq->vq_queue_index,
+ vq->vq_notify_offset);
}
static void