This patch deletes all code related to supporting assigned
virtio driver functionality. The idea with the "assigned virtio" API
was a new API to let the user-space application interact directly with
the virtio ring, without kernel involvement. This would allow a user-space
TCP/IP implementation bypass OSv's TCP/IP implementation. The only
app using this API was Seastar, but Seastar cannot run on OSv anymore
and nobody else maintains this API. Given that this API cannot be
tested without Seastar and it gets in a way of upgrading virtio
layer to support modern PCI devices and virtio MMIO devices,
we have decided to remove it from OSv codebase.

In future if somebody finds it useful again we will bring it back
and adjust accordingly.

Signed-off-by: Waldemar Kozaczuk <jwkozac...@gmail.com>
---
 Makefile                     |   1 -
 arch/x64/arch-setup.cc       |   9 +-
 drivers/virtio-assign.cc     | 177 -----------------------------------
 drivers/virtio-assign.hh     |  20 ----
 include/osv/virtio-assign.hh |  43 ---------
 loader.cc                    |   5 -
 6 files changed, 1 insertion(+), 254 deletions(-)
 delete mode 100644 drivers/virtio-assign.cc
 delete mode 100644 drivers/virtio-assign.hh
 delete mode 100644 include/osv/virtio-assign.hh

diff --git a/Makefile b/Makefile
index 68043485..ea126f10 100644
--- a/Makefile
+++ b/Makefile
@@ -821,7 +821,6 @@ drivers += arch/$(arch)/pvclock-abi.o
 drivers += drivers/virtio.o
 drivers += drivers/virtio-vring.o
 drivers += drivers/virtio-net.o
-drivers += drivers/virtio-assign.o
 drivers += drivers/vmxnet3.o
 drivers += drivers/vmxnet3-queues.o
 drivers += drivers/virtio-blk.o
diff --git a/arch/x64/arch-setup.cc b/arch/x64/arch-setup.cc
index 6e4833cf..50500662 100644
--- a/arch/x64/arch-setup.cc
+++ b/arch/x64/arch-setup.cc
@@ -258,7 +258,6 @@ void arch_init_premain()
 #include "drivers/virtio-blk.hh"
 #include "drivers/virtio-scsi.hh"
 #include "drivers/virtio-net.hh"
-#include "drivers/virtio-assign.hh"
 #include "drivers/virtio-rng.hh"
 #include "drivers/xenplatform-pci.hh"
 #include "drivers/ahci.hh"
@@ -266,8 +265,6 @@ void arch_init_premain()
 #include "drivers/vmxnet3.hh"
 #include "drivers/ide.hh"
 
-extern bool opt_assign_net;
-
 void arch_init_drivers()
 {
     // initialize panic drivers
@@ -282,11 +279,7 @@ void arch_init_drivers()
     hw::driver_manager* drvman = hw::driver_manager::instance();
     drvman->register_driver(virtio::blk::probe);
     drvman->register_driver(virtio::scsi::probe);
-    if (opt_assign_net) {
-        drvman->register_driver(virtio::assigned::probe_net);
-    } else {
-        drvman->register_driver(virtio::net::probe);
-    }
+    drvman->register_driver(virtio::net::probe);
     drvman->register_driver(virtio::rng::probe);
     drvman->register_driver(xenfront::xenplatform_pci::probe);
     drvman->register_driver(ahci::hba::probe);
diff --git a/drivers/virtio-assign.cc b/drivers/virtio-assign.cc
deleted file mode 100644
index 8a128d5e..00000000
--- a/drivers/virtio-assign.cc
+++ /dev/null
@@ -1,177 +0,0 @@
-/*
- * Copyright (C) 2014 Cloudius Systems, Ltd.
- *
- * This work is open source software, licensed under the terms of the
- * BSD license as described in the LICENSE file in the top-level directory.
- */
-
-
-#include <osv/virtio-assign.hh>
-#include <drivers/virtio-net.hh>
-
-// Currently we support only one assigned virtio device, but more could
-// easily be added later.
-static osv::assigned_virtio *the_assigned_virtio_device = nullptr;
-namespace osv {
-assigned_virtio *assigned_virtio::get() {
-    return the_assigned_virtio_device;
-}
-}
-
-// "impl" is a subclass of virtio::virtio_driver which also implements the
-// API we export applications: osv::assigned_virtio.
-class impl : public osv::assigned_virtio, public virtio::virtio_driver {
-public:
-    static hw_driver* probe_net(hw_device* dev);
-    explicit impl(pci::device& dev)
-        : virtio_driver(dev)
-    {
-        assert(!the_assigned_virtio_device);
-        the_assigned_virtio_device = this;
-    }
-
-    virtual ~impl() {
-    }
-
-    virtual std::string get_name() const override {
-        return "virtio-assigned";
-    }
-    virtual u32 get_driver_features() override {
-        return _driver_features;
-    }
-
-    // osv::assigned_virtio API implementation:
-
-    virtual void kick(int queue) override {
-        virtio_driver::kick(queue);
-    }
-
-    virtual u32 queue_size(int queue) override
-    {
-        virtio_conf_writew(virtio::VIRTIO_PCI_QUEUE_SEL, queue);
-        return virtio_conf_readw(virtio::VIRTIO_PCI_QUEUE_NUM);
-
-    }
-    virtual u32 init_features(u32 driver_features) override
-    {
-        _driver_features = driver_features;
-        setup_features();
-        return get_guest_features();
-    }
-
-    virtual void enable_interrupt(unsigned int queue, 
std::function<void(void)> handler) override
-    {
-        // Hack to enable_interrupt's handler in a separate thread instead of
-        // directly at the interrupt context. We need this when the tries to
-        // signal and eventfd, which involves a mutex and not allowed in 
interrupt
-        // context. In the future we must get rid of this ugliess, and make the
-        // handler code lock-free and allowed at interrupt context!
-        _hack_threads.emplace_back(handler);
-        auto *ht = &_hack_threads.back(); // assumes object won't move later
-        handler = [ht] { ht->wake(); };
-
-        // OSv's generic virtio driver has already set the device to msix, and 
set
-        // the VIRTIO_MSI_QUEUE_VECTOR of its queue to its number.
-        assert(_dev.is_msix());
-        virtio_conf_writew(virtio::VIRTIO_PCI_QUEUE_SEL, queue);
-        assert(virtio_conf_readw(virtio::VIRTIO_MSI_QUEUE_VECTOR) == queue);
-        if (!_dev.is_msix_enabled()) {
-            _dev.msix_enable();
-        }
-        auto vectors = _msi.request_vectors(1);
-        assert(vectors.size() == 1);
-        auto vec = vectors[0];
-        // TODO: in _msi.easy_register() we also have code for moving the
-        // interrupt's affinity to where the handling thread is. We should
-        // probably do this here too.
-        _msi.assign_isr(vec, handler);
-        auto ok = _msi.setup_entry(queue, vec);
-        assert(ok);
-        vec->msix_unmask_entries();
-    }
-
-    virtual void set_queue_pfn(int queue, u64 phys) override
-    {
-        virtio_conf_writew(virtio::VIRTIO_PCI_QUEUE_SEL, queue);
-        // Tell host about pfn
-        u64 pfn = phys >> virtio::VIRTIO_PCI_QUEUE_ADDR_SHIFT;
-        // A bug in virtio's design... on large memory, this can actually 
happen
-        assert(pfn <= std::numeric_limits<u32>::max());
-        virtio_conf_writel(virtio::VIRTIO_PCI_QUEUE_PFN, (u32)pfn);
-    }
-
-    virtual void set_driver_ok() override
-    {
-        add_dev_status(virtio::VIRTIO_CONFIG_S_DRIVER_OK);
-    }
-
-    virtual void conf_read(void *buf, int length) override
-    {
-        virtio_conf_read(virtio_pci_config_offset(), buf, length);
-    }
-
-private:
-    u32 _driver_features;
-
-    // This is an inefficient hack, to run enable_interrupt's handler in a
-    // separate thread instead of directly at the interrupt context.
-    // We need this when the tries to signal and eventfd, which involves a
-    // mutex and not allowed in interrupt context. In the future we must get
-    // rid of this ugliess, and make the handler code lock-free and allowed
-    // at interrupt context!
-    class hack_thread {
-    private:
-        std::atomic<bool> _stop {false};
-        std::atomic<bool> _wake {false};
-        std::function<void(void)> _handler;
-        std::unique_ptr<sched::thread> _thread;
-        void stop() {
-            _stop.store(true, std::memory_order_relaxed);
-            wake();
-            _thread = nullptr; // join and clean up the thread
-        }
-        bool wait() {
-            sched::thread::wait_until([&] { return 
_wake.load(std::memory_order_relaxed); });
-            _wake.store(false, std::memory_order_relaxed);
-            return _stop.load(std::memory_order_relaxed);
-        }
-    public:
-        void wake() {
-            _wake.store(true, std::memory_order_relaxed);
-            _thread->wake();
-        }
-        explicit hack_thread(std::function<void(void)> handler)
-                : _handler(handler) {
-            _thread = std::unique_ptr<sched::thread>(sched::thread::make([&] {
-                while (!_stop.load(std::memory_order_relaxed)) {
-                    wait();
-                    _handler();
-                }
-            }));
-            _thread->start();
-        }
-        ~hack_thread() {
-            stop();
-        }
-    };
-    std::list<hack_thread> _hack_threads;
-};
-
-
-namespace osv {
-mmu::phys assigned_virtio::virt_to_phys(void* p)
-{
-    return mmu::virt_to_phys(p);
-}
-assigned_virtio::~assigned_virtio() {
-}
-}
-
-namespace virtio {
-namespace assigned {
-hw_driver* probe_net(hw_device* dev)
-{
-    return virtio::probe<impl, virtio::net::VIRTIO_NET_DEVICE_ID>(dev);
-}
-}
-}
diff --git a/drivers/virtio-assign.hh b/drivers/virtio-assign.hh
deleted file mode 100644
index 1da0c819..00000000
--- a/drivers/virtio-assign.hh
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright (C) 2014 Cloudius Systems, Ltd.
- *
- * This work is open source software, licensed under the terms of the
- * BSD license as described in the LICENSE file in the top-level directory.
- */
-
-#ifndef VIRTIO_ASSIGNED_DRIVER_H
-#define VIRTIO_ASSIGNED_DRIVER_H
-
-#include <drivers/driver.hh>
-
-namespace virtio {
-namespace assigned {
-hw_driver* probe_net(hw_device* dev);
-}
-}
-
-#endif
-
diff --git a/include/osv/virtio-assign.hh b/include/osv/virtio-assign.hh
deleted file mode 100644
index b81f41ae..00000000
--- a/include/osv/virtio-assign.hh
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright (C) 2014 Cloudius Systems, Ltd.
- *
- * This work is open source software, licensed under the terms of the
- * BSD license as described in the LICENSE file in the top-level directory.
- */
-
-#ifndef VIRTIO_ASSIGNED_API_H
-#define VIRTIO_ASSIGNED_API_H
-
-#include <functional>
-#include <stdint.h>
-
-namespace osv {
-
-class assigned_virtio {
-public:
-    // API for getting one assigned virtio device. This function is marked
-    // "weak" so an application can check for its existance (it won't exist,
-    // of course, on Linux).
-    // TODO: provide a way to get one of multiple assigned virtio devices.
-    static assigned_virtio *get() __attribute__((weak));
-
-    virtual void kick(int queue) = 0;
-    virtual uint32_t queue_size(int queue) = 0;
-    virtual void enable_interrupt(unsigned int queue,
-            std::function<void(void)> handler) = 0;
-    virtual void set_queue_pfn(int queue, uint64_t phys) = 0;
-    virtual uint32_t init_features(uint32_t driver_features) = 0;
-    virtual void set_driver_ok() = 0;
-    virtual void conf_read(void *buf, int length) = 0;
-
-    virtual ~assigned_virtio();
-
-    // virt_to_phys is static, as it does not depend on which device was
-    // assigned. We can even make it inline for a bit of extra speed.
-    static uint64_t virt_to_phys(void* p) __attribute__((weak));
-};
-
-}
-
-#endif
-
diff --git a/loader.cc b/loader.cc
index 3f88ebda..c29bf4c4 100644
--- a/loader.cc
+++ b/loader.cc
@@ -141,7 +141,6 @@ static std::string opt_defaultgw;
 static std::string opt_nameserver;
 static std::string opt_redirect;
 static std::chrono::nanoseconds boot_delay;
-bool opt_assign_net = false;
 bool opt_maxnic = false;
 int maxnic;
 
@@ -216,10 +215,6 @@ void parse_options(int loader_argc, char** loader_argv)
         opt_power_off_on_abort = true;
     }
 
-    if (vars.count("assign-net")) {
-        opt_assign_net = true;
-    }
-
     if (vars.count("maxnic")) {
         opt_maxnic = true;
         maxnic = vars["maxnic"].as<int>();
-- 
2.19.1

-- 
You received this message because you are subscribed to the Google Groups "OSv 
Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to osv-dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to