aboutsummaryrefslogtreecommitdiff
path: root/lib/libvirtio/virtio.h
AgeCommit message (Collapse)AuthorFilesLines
2019-12-05virtio: Enable IOMMUAlexey Kardashevskiy1-0/+5
When QEMU is started with iommu_platform=on, the guest driver must accept it or the device will fail. This enables IOMMU support for virtio-net, -scsi, -block, -serial, -9p devices. -serial and -9p are only compile tested though. For virtio-net we map all RX buffers once and TX when xmit() is called and unmap older pages when we are about to reuse the VQ descriptor. As all other devices are synchronous, we unmap IOMMU pages right after completion of a transaction. This depends on QEMU's: https://patchwork.ozlabs.org/patch/1194067/ Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru> Tested-by: Michael Roth <mdroth@linux.vnet.ibm.com> --- Changes: v5: * fixed queue size calculation * reworked virtio_free_desc() to only unmap what is has mapped v4: * ditched vqs->id in virtio_queue_init_vq v2: * added Mike's fs/dma-instance-function.fs * total rework
2019-12-05virtio: Store queue descriptors in virtio_deviceAlexey Kardashevskiy1-13/+12
At the moment desc/avail/used pointers are read from the device every time we need them. This works for now unless iommu_platform=on is used, desc/avail/used stored in the config space are bus addresses while SLOF should keep using the guest physical addresses. virtio-net stores queue descriptors already, virtio-serial does it in global statics, move them into virtio_device. The next patch will use this to allow IOMMU. While at this, move repeating avail->flags/idx setup into virtio_queue_init_vq() except virtio-serial which vq_rx->avail->idx is setup differently. Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru> Reviewed-by: Michael Roth <mdroth@linux.vnet.ibm.com> --- Changes: v4: * removed vqs::id as it is not really used * replaced vq_size with vq->size in virtio-serial.c
2019-11-11virtio: Make virtio_set_qaddr staticAlexey Kardashevskiy1-1/+0
It is never called outside of virtio, make it static. Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
2017-08-07virtio-net: rework the driver to support multiple openNikunj A Dadhania1-0/+1
Found that virtio-net is using a around 200K receive buffer per device, if we connect more than 40 virtio-net devices the heap(8MB) gets over. Because of which allocation starts failing and the VM does not boot. Moreover, the driver did not support opening multiple device, which is possible using the OF client interface. As it was using globals to store the state information of the driver. Now the driver allocates a virtio_net structure during device open stage and fills in the state information. This details are used during various device functions and finally for cleaning up on close operation. Now as the buffer memory is allocated during open and freed during the close operations the heap usage is contained. Reported-by: Satheesh Rajendran <sathnaga@linux.vnet.ibm.com> Signed-off-by: Nikunj A Dadhania <nikunj@linux.vnet.ibm.com> Reviewed-by: Thomas Huth <thuth@redhat.com> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
2016-02-08virtio: add and enable 1.0 device setupNikunj A Dadhania1-4/+3
Introduce parsing routines for virtio capabilities. This would also determine whether we need to function in legacy mode or virtio 1.0. Update routine to start using the base address from the updated legacy structure. With the removal for base address setting in the Forth code and most of the device setup happening in C code, code in virtio.fs is redundant. Remove virtio.fs and move the allocation of the virtio_device structure to the C code instead of the Forth code in individual files. Also, drop the packed attribute for the virtio_{device,cap} structure. The structure is not shared anymore. Drivers need to negotiate the 1.0 feature capability before starting to use 1.0. Disable it in all the drivers until 1.0 is enabled. Signed-off-by: Nikunj A Dadhania <nikunj@linux.vnet.ibm.com> Reviewed-by: Thomas Huth <thuth@redhat.com> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
2016-02-08virtio: 1.0 guest features negotiationNikunj A Dadhania1-0/+2
With virtio 1.0, there feature negotiation step needs to be completed before starting to notify the device. This includes following steps: * Read host supported features * Check if virtio 1.0 is supported * Set guest supported features * Read host features and compare with the guest features. * Write FEATURES_OK and check it back to confirm. Add virtio_get_status supporting routine. Signed-off-by: Nikunj A Dadhania <nikunj@linux.vnet.ibm.com> Reviewed-by: Thomas Huth <thuth@redhat.com> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
2016-02-08virtio: update features set/get register accessorNikunj A Dadhania1-2/+2
The new specification has a 64-bit feature register, change the signature and update the routine to handle them. Signed-off-by: Nikunj A Dadhania <nikunj@linux.vnet.ibm.com> Reviewed-by: Thomas Huth <thuth@redhat.com> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
2016-02-08virtio: make all virtio apis 1.0 awareNikunj A Dadhania1-1/+1
Convert the following routines: virtio_get_qsize virtio_vring_desc virtio_get_vring_avail virtio_get_vring_used virtio_set_status: also use it in device reset. virtio_queue_notify virtio_set_qaddr virtio_{get,read}_config virtio_fill_desc Signed-off-by: Nikunj A Dadhania <nikunj@linux.vnet.ibm.com> Reviewed-by: Thomas Huth <thuth@redhat.com> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
2016-02-08virtio: add virtio 1.0 related struct and definesNikunj A Dadhania1-1/+27
Traditionally, struct virtio_device is shared between SLOF and C code. This still remains shared with the addition of virtio_cap structure as well. Now both virtio_device and virtio_cap structures are shared. Signed-off-by: Nikunj A Dadhania <nikunj@linux.vnet.ibm.com> Reviewed-by: Thomas Huth <thuth@redhat.com> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
2016-02-08virtio: get rid of type variable in virtio_deviceNikunj A Dadhania1-2/+0
virtio device structure carries a type variable indicating whether virtio is over PCI or VIO. While VIO is not there and no plan to introduce other transport, there is no purpose of having this variable around and checking for PCI. Signed-off-by: Nikunj A Dadhania <nikunj@linux.vnet.ibm.com> Reviewed-by: Thomas Huth <thuth@redhat.com> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
2016-02-08virtio-blk: add helpers for filling descriptorsNikunj A Dadhania1-0/+4
Enable virtio_fill_desc/fill_blk_hdr with legacy and modern mode for further use Signed-off-by: Nikunj A Dadhania <nikunj@linux.vnet.ibm.com> Reviewed-by: Thomas Huth <thuth@redhat.com> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
2016-02-08virtio: introduce helper for initializing virt queueNikunj A Dadhania1-1/+11
The routine takes care to allocate and set the queue address in the device. Add these calls in virtio-net, virtio-blk and virtio-9p. With the lack of this routine, devices like virtio-blk and virtio-9p did not do a device reset in the driver initialization code. This helper will fix that problem Change the signature of virtio_set_qaddr, accepting queue address as unsigned long argument. Signed-off-by: Nikunj A Dadhania <nikunj@linux.vnet.ibm.com> Reviewed-by: Thomas Huth <thuth@redhat.com> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
2016-02-08virtio: fix code style/design issues.Nikunj A Dadhania1-3/+2
The patch does not make any functional changes. Signed-off-by: Nikunj A Dadhania <nikunj@linux.vnet.ibm.com> Reviewed-by: Thomas Huth <thuth@redhat.com> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
2014-04-25virtio-blk: support variable block sizeNikunj A Dadhania1-0/+1
Current code only works with 512 bytes read. Moreover, Qemu ignores the guest set features request. In the set features request SLOF indicates to qemu that it is not support VIRTIO_BLK_F_BLK_SIZE feature. Code in qemu suggests that virtio-blk is not implementing set_guest_feature. Tested-by: Bharata B Rao <bharata@linux.ibm.com> Reviewed-by: Thomas Huth <thuth@linux.vnet.ibm.com> Signed-off-by: Nikunj A Dadhania <nikunj@linux.vnet.ibm.com>
2013-11-18virtio: timeout after 5secNikunj A Dadhania1-0/+2
Remove adhoc timer and put 5sec timeout. On a busy host, code hits this. Signed-off-by: Nikunj A Dadhania <nikunj@linux.vnet.ibm.com>
2013-05-21virtio: Add a virtio-set-qaddr helperNikunj A. Dadhania1-0/+1
A simple function that can be used from forth code for setting virtqueue address. virito-scsi has multiple virtqueues(atleast 3) and need to use set queue address for all the 3 queues. Signed-off-by: Nikunj A. Dadhania <nikunj@linux.vnet.ibm.com> Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
2012-01-19Add virtfs supportBenjamin Herrenschmidt1-0/+2
Code originally written by Timothy Rule and reworked & bug fixed by myself Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
2012-01-19Move virtio to a separate libraryBenjamin Herrenschmidt1-0/+84
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>