summaryrefslogtreecommitdiffstats
path: root/include/hw/virtio/virtio.h
Commit message (Collapse)AuthorAgeFilesLines
* virtio: add modern config accessorsMichael S. Tsirkin2015-06-101-0/+9
| | | | | | | | | | | | | | | | virtio 1.0 defines config space as LE, as opposed to pre-1.0 which was native endian. Add API for transports to execute word/dword accesses in little endian format - will be useful for mmio and pci (byte access is also wrapped, for completeness). For simplicity, we still keep config in host native endian format, byteswap to LE on guest access. Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
* virtio: generation counter supportMichael S. Tsirkin2015-06-101-0/+1
| | | | | | Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
* virtio: allow to fail setting statusCornelia Huck2015-06-101-1/+2
| | | | | | | | | | | | | virtio-1 allow setting of the FEATURES_OK status bit to fail if the negotiated feature bits are inconsistent: let's fail virtio_set_status() in that case and update virtio-ccw to post an error to the guest. Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
* virtio: allow virtio-1 queue layoutCornelia Huck2015-06-101-0/+3
| | | | | | | | | | | | For virtio-1 devices, we allow a more complex queue layout that doesn't require descriptor table and rings on a physically-contigous memory area: add virtio_queue_set_rings() to allow transports to set this up. Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
* virtio: endianness checks for virtio 1.0 devicesCornelia Huck2015-06-101-2/+6
| | | | | | | | | | | | Add code that checks for the VERSION_1 feature bit in order to make decisions about the device's endianness. This allows us to support transitional devices. Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
* virtio: 64bit features fixups.Gerd Hoffmann2015-06-031-5/+5
| | | | | | | | | | Commit "019a3ed virtio: make features 64bit wide" missed a few changes, as I've noticed while trying to rebase the virtio-1 branch to latest master. This patch adds them. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
* virtio: make features 64bit wideGerd Hoffmann2015-06-011-16/+16
| | | | | | | | | | | | | | Make features 64bit wide everywhere. On migration a full 64bit guest_features field is sent if one of the high bits is set, in addition to the lower 32bit guest_features field which must stay for compatibility reasons. That way we send the lower 32 feature bits twice, but the code is simpler because we don't have to split and compose the 64bit features into two 32bit fields. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
* virtio: increase the queue limit to 1024Jason Wang2015-05-311-1/+1
| | | | | | | | | | Increase the queue limit to 1024. But virtio-ccw and s390-virtio won't support this, this is done through failing device_plugged() for those two transports if the number of virtqueues is greater than 64. Signed-off-by: Jason Wang <jasowang@redhat.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
* virtio: rename VIRTIO_PCI_QUEUE_MAX to VIRTIO_QUEUE_MAXJason Wang2015-05-311-1/+1
| | | | | | | | | | VIRTIO_PCI_QUEUE_MAX is not only used for pci, so rename it be generic. Cc: Amit Shah <amit.shah@redhat.com> Cc: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Jason Wang <jasowang@redhat.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
* virtio: introduce virtio_get_num_queues()Jason Wang2015-05-311-0/+1
| | | | | | | | | This patch introduces virtio_get_num_queues() which iterates the vqs array and return the number of virtqueues used by device. Signed-off-by: Jason Wang <jasowang@redhat.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
* virtio: move VIRTIO_F_NOTIFY_ON_EMPTY into coreCornelia Huck2015-05-311-4/+6
| | | | | | | | | | | | | | Nearly all transports have been offering VIRTIO_F_NOTIFY_ON_EMPTY, s390-virtio being the exception. There's no reason why it shouldn't offer it as well, though (handling is done in core anyway), so let's move it to the common virtio features. While we're changing it anyway, fix the indentation for the DEFINE_VIRTIO_COMMON_FEATURES macro. Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
* virtio: move host_featuresCornelia Huck2015-05-311-0/+1
| | | | | | | | | | | | | | Move host_features from the individual transport proxies into the virtio device. Transports may continue to add feature bits during device plugging. This should it make easier to offer different sets of host features for virtio-1/transitional support. Tested-by: Shannon Zhao <shannon.zhao@linaro.org> Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
* virtio-input: core code & base class [device]Gerd Hoffmann2015-05-291-0/+1
| | | | | | | | | | | This patch adds virtio-input support to qemu. It brings a abstract base class providing core support, other classes can build on it to actually implement input devices. virtio-input basically sends linux input layer events (evdev) over virtio. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
* virtio: coding style tweakMichael S. Tsirkin2015-04-271-1/+1
| | | | | | no space needed after *. Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
* virtio: introduce vector to virtqueues mappingJason Wang2015-04-271-0/+3
| | | | | | | | | | | | | | | | | | | Currently we will try to traverse all virtqueues to find a subset that using a specific vector. This is sub optimal when we will support hundreds or even thousands of virtqueues. So this patch introduces a method which could be used by transport to get all virtqueues that using a same vector. This is done through QLISTs and the number of QLISTs was queried through a transport specific method. When guest setting vectors, the virtqueue will be linked and helpers for traverse the list was also introduced. The first user will be virtio pci which will use this to speed up MSI-X masking and unmasking handling. Cc: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Jason Wang <jasowang@redhat.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
* virtio: add feature checking helpersCornelia Huck2015-02-261-0/+11
| | | | | | | | | | | | Add a helper function for checking whether a bit is set in the guest features for a vdev as well as one that works on a feature bit set. Convert code that open-coded this: It cleans up the code and makes it easier to extend the guest feature bits. Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
* virtio: feature bit manipulation helpersCornelia Huck2015-02-261-0/+12
| | | | | | | | | | | | | | Add virtio_{add,clear}_feature helper functions for manipulating a feature bits variable. This has some benefits over open coding: - add check that the bit is in a sane range - make it obvious at a glance what is going on - have a central point to change when we want to extend feature bits Convert existing code manipulating features to use the new helpers. Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
* virtio: use standard-headersMichael S. Tsirkin2015-02-261-46/+2
| | | | | | | | | Drop a bunch of code duplicated from virtio_config.h and virtio_ring.h. This makes us rename event index accessors which conflict, as reusing the ones from virtio_ring.h isn't trivial. Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Reviewed-by: Thomas Huth <thuth@linux.vnet.ibm.com>
* virtio: remove useless declaration of virtio_net_init()Gonglei2014-12-101-3/+0
| | | | | | | | | | | commit 1773d9ee (virtio-net: cleanup: init and exit function) removed the definition of virtio_net_init(), but didn't remove its declaration in the header. Clean that up. Cc: Markus Armbruster <armbru@redhat.com> Signed-off-by: Gonglei <arei.gonglei@huawei.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
* virtio: add a wrapper for virtio-backend initializationGonglei2014-09-301-0/+3
| | | | | | | | | | For better code sharing, add a helper function that handles reference counting of the virtio backend for virtio proxy devices. Cc: Cornelia Huck <cornelia.huck@de.ibm.com> Cc: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Gonglei <arei.gonglei@huawei.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* virtio: add endian-ambivalent support to VirtIODeviceGreg Kurz2014-06-291-3/+10
| | | | | | | | | | | | | | | | | | | Some CPU families can dynamically change their endianness. This means we can have little endian ppc or big endian arm guests for example. This has an impact on legacy virtio data structures since they are target endian. We hence introduce a new property to track the endianness of each virtio device. It is reasonnably assumed that endianness won't change while the device is in use : we hence capture the device endianness when it gets reset. We migrate this property in a subsection, after the device descriptor. This means the load code must not rely on it until it is restored. As a consequence, the vring sanity checks had to be moved after the call to vmstate_load_state(). We enforce paranoia by poisoning the property at the begining of virtio_load(). Signed-off-by: Greg Kurz <gkurz@linux.vnet.ibm.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
* exec: introduce target_words_bigendian() helperGreg Kurz2014-06-291-0/+6
| | | | | | | | | | | | | | | | We currently have a virtio_is_big_endian() helper that provides the target endianness to the virtio code. As of today, the helper returns a fixed compile-time value. Of course, this will have to change if we want to support target endianness changes at run-time. Let's move the TARGET_WORDS_BIGENDIAN bits out to a new helper and have virtio_is_big_endian() implemented on top of it. This patch doesn't change any functionality. Signed-off-by: Greg Kurz <gkurz@linux.vnet.ibm.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
* virtio: introduce device specific migration callsGreg Kurz2014-06-291-1/+3
| | | | | | | | | | | | | In order to migrate virtio subsections, they should be streamed after the device itself. We need the device specific code to be called from the common migration code to achieve this. This patch introduces load and save methods for this purpose. Suggested-by: Andreas Färber <afaerber@suse.de> Signed-off-by: Greg Kurz <gkurz@linux.vnet.ibm.com> Reviewed-by: Alexander Graf <agraf@suse.de> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
* virtio: Convert exit to unrealizeAndreas Färber2013-12-091-1/+1
| | | | | Signed-off-by: Andreas Färber <afaerber@suse.de> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* virtio: Complete converting VirtioDevice to QOM realizeAndreas Färber2013-12-091-2/+3
| | | | | | | Drop VirtioDeviceClass::init. Signed-off-by: Andreas Färber <afaerber@suse.de> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* virtio: Start converting VirtioDevice to QOM realizeAndreas Färber2013-12-091-1/+3
| | | | | | | | | | Temporarily allow either VirtioDeviceClass::init or VirtioDeviceClass::realize. Introduce VirtioDeviceClass::unrealize for symmetry. Signed-off-by: Andreas Färber <afaerber@suse.de> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* virtio-bus: cleanup plug/unplug interfacePaolo Bonzini2013-12-091-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Right now we have these pairs: - virtio_bus_plug_device/virtio_bus_destroy_device. The first takes a VirtIODevice, the second takes a VirtioBusState - device_plugged/device_unplug callbacks in the VirtioBusClass (here it's just the naming that is inconsistent) - virtio_bus_destroy_device is not called by anyone (and since it calls qdev_free, it would be called by the proxies---but then the callback is useless since the proxies can do whatever they want before calling virtio_bus_destroy_device) And there is a k->init but no k->exit, hence virtio_device_exit is overwritten by subclasses (except virtio-9p). This cleans it up by: - renaming the device_unplug callback to device_unplugged - renaming virtio_bus_plug_device to virtio_bus_device_plugged, matching the callback name - renaming virtio_bus_destroy_device to virtio_bus_device_unplugged, removing the qdev_free, making it take a VirtIODevice and calling it from virtio_device_exit - adding a k->exit callback virtio_device_exit is still overwritten, the next patches will fix that. Cc: qemu-stable@nongnu.org Acked-by: Andreas Faerber <afaerber@suse.de> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* virtio: clear signalled_used_valid when switching from dataplaneStefan Hajnoczi2013-08-121-0/+1
| | | | | | | | | | | | | | When the dataplane thread stops, its vring.c implementation synchronizes vring state back to virtio.c so we can continue emulating the virtio device. This patch ensures that virtio.c's signalled_used_valid flag is reset so that we do not suppress guest notifications due to stale signalled_used values. Suggested-by: Kevin Wolf <kwolf@redhat.com> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
* virtio: Support transports which can specify the vring alignmentPeter Maydell2013-07-191-0/+1
| | | | | | | | | | | | | | | Support virtio transports which can specify the vring alignment (ie where the guest communicates this to the host) by providing a new virtio_queue_set_align() function. (The default alignment remains as before.) Transports which wish to make use of this must set the has_variable_vring_alignment field in their VirtioBusClass struct to true; they can then change the alignment via virtio_queue_set_align(). Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Message-id: 1373977512-28932-5-git-send-email-peter.maydell@linaro.org
* virtio: Add support for guest setting of queue sizePeter Maydell2013-07-191-0/+1
| | | | | | | | | The MMIO virtio transport spec allows the guest to tell the host how large the queue size is. Add virtio_queue_set_num() function which implements this in the QEMU common virtio support code. Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Message-id: 1373977512-28932-4-git-send-email-peter.maydell@linaro.org
* virtio-net: add feature bit for any header s/gMichael S. Tsirkin2013-07-151-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Old qemu versions required that 1st s/g entry is the header. Since QEMU 1.5, patchset titled "virtio-net: iovec handling cleanup" removed this limitation but a feature bit is needed so guests know it's safe to lay out header differently. This patch applies on top and adds such a feature bit to QEMU. It is set by default for virtio-net. virtio net header inline with the data is beneficial for latency and small packet bandwidth - guest driver code utilizing this feature has been acked but missed 3.11 by a narrow margin, it's pending for 3.12. This feature bit is cleared by default when compatibility with old machine types is requested. Other performance-sensitive devices (blk and scsi) don't yet support arbitrary s/g layouts, so we only set this bit for virtio-net for now. There are plans to allow arbitrary layouts there, but no code has been posted yet. Cc: Rusty Russell <rusty@rustcorp.com.au> Reviewed-by: Laszlo Ersek <lersek@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
* virtio: add virtio_device_set_child_bus_name.KONRAD Frederic2013-05-031-0/+4
| | | | | | | | | | | | Add virtio_device_set_child_bus_name function. It will be used with virtio-serial-x and virtio-scsi-x to set the child bus name before calling virtio-x-device's init. Signed-off-by: KONRAD Frederic <fred.konrad@greensocs.com> Tested-by: Cornelia Huck <cornelia.huck@de.ibm.com> Message-id: 1367330931-12994-3-git-send-email-fred.konrad@greensocs.com Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* virtio: drop unused function prototypes.KONRAD Frederic2013-04-241-10/+0
| | | | | | | | This removes the unused prototypes in virtio.h. Signed-off-by: KONRAD Frederic <fred.konrad@greensocs.com> Message-id: 1366791683-5350-8-git-send-email-fred.konrad@greensocs.com Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* virtio: cleanup: init and exit function.KONRAD Frederic2013-04-241-5/+1
| | | | | | | | | This clean the init and the exit functions and rename virtio_common_cleanup to virtio_cleanup. Signed-off-by: KONRAD Frederic <fred.konrad@greensocs.com> Message-id: 1366791683-5350-7-git-send-email-fred.konrad@greensocs.com Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* virtio: remove virtiobindings.KONRAD Frederic2013-04-241-19/+0
| | | | | | | | This remove virtio-bindings, and use class instead. Signed-off-by: KONRAD Frederic <fred.konrad@greensocs.com> Message-id: 1366791683-5350-6-git-send-email-fred.konrad@greensocs.com Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* virtio: remove the function pointer.KONRAD Frederic2013-04-241-24/+0
| | | | | | | | | This remove the function pointer in VirtIODevice, and use only VirtioDeviceClass function pointer. Signed-off-by: KONRAD Frederic <fred.konrad@greensocs.com> Message-id: 1366791683-5350-5-git-send-email-fred.konrad@greensocs.com Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* virtio-rng: cleanup: init and exit functions.KONRAD Frederic2013-04-241-2/+0
| | | | | | | | | | This remove old init and exit function as they are no longer needed. Signed-off-by: KONRAD Frederic <fred.konrad@greensocs.com> Tested-by: Cornelia Huck <cornelia.huck@de.ibm.com> Acked-by: Amit Shah <amit.shah@redhat.com> Message-id: 1366790881-3026-7-git-send-email-fred.konrad@greensocs.com Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* virtio.h: drop unused function prototypesLuiz Capitulino2013-04-191-2/+0
| | | | | | | They are unused since commit 5c7d0962f60498c3f11d402e1c857cb9d5d8568d. Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
* virtio: add two functions to VirtioDeviceClass.KONRAD Frederic2013-04-171-0/+12
| | | | | | | | | | Recent changes need two functions to VirtioDevice. This just add them into VirtioDeviceClass. Signed-off-by: KONRAD Frederic <fred.konrad@greensocs.com> Tested-by: Cornelia Huck <cornelia.huck@de.ibm.com> Message-id: 1365690602-22729-2-git-send-email-fred.konrad@greensocs.com Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* hw: move headers to include/Paolo Bonzini2013-04-081-0/+292
Many of these should be cleaned up with proper qdev-/QOM-ification. Right now there are many catch-all headers in include/hw/ARCH depending on cpu.h, and this makes it necessary to compile these files per-target. However, fixing this does not belong in these patches. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
OpenPOWER on IntegriCloud