From 4ccaed7de7260a856043f194c2c5237279fc2a7d Mon Sep 17 00:00:00 2001 From: Dor Laor <dor@cloudius-systems.com> Date: Sun, 20 Jan 2013 18:12:49 +0200 Subject: [PATCH] Add kick function (notify the host on pending buffers) and improve the host side reset calls --- drivers/virtio.cc | 18 +++++++++++++++++- drivers/virtio.hh | 2 ++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/drivers/virtio.cc b/drivers/virtio.cc index 38e4ab660..28289bd6f 100644 --- a/drivers/virtio.cc +++ b/drivers/virtio.cc @@ -21,6 +21,8 @@ namespace virtio { virtio_driver::~virtio_driver() { + reset_host_side(); + for (int i=0; i < max_virtqueues_nr; i++) { if (NULL != _queues[i]) { delete (_queues[i]); @@ -28,6 +30,11 @@ namespace virtio { } } + void virtio_driver::reset_host_side() { + set_dev_status(0); + pci_conf_write(VIRTIO_PCI_QUEUE_PFN,(u32)0); + } + bool virtio_driver::earlyInitChecks() { if (!Driver::earlyInitChecks()) { @@ -58,6 +65,9 @@ namespace virtio { debug(fmt("Virtio:Init %x:%x") % _vid % _id); + //make sure the queue is reset + reset_host_side(); + // Acknowledge device add_dev_status(VIRTIO_CONFIG_S_ACKNOWLEDGE | VIRTIO_CONFIG_S_DRIVER); @@ -74,6 +84,12 @@ namespace virtio { return true; } + bool virtio_driver::kick(int queue) + { + set_virtio_config(VIRTIO_PCI_QUEUE_NOTIFY, queue); + return true; + } + bool virtio_driver::probe_virt_queues(void) { u16 queuesel = 0; @@ -93,7 +109,7 @@ namespace virtio { } // Init a new queue - vring * queue = new vring(qsize); + vring * queue = new vring(this, qsize, queuesel); _queues[queuesel++] = queue; // Tell host about pfn diff --git a/drivers/virtio.hh b/drivers/virtio.hh index 9ffbeeb1c..608244f80 100644 --- a/drivers/virtio.hh +++ b/drivers/virtio.hh @@ -102,6 +102,8 @@ namespace virtio { virtual bool Init(Device *d); virtual void dumpConfig() const; + bool kick(int queue); + void reset_host_side(); protected: -- GitLab