diff options
author | Nikunj A Dadhania <nikunj@linux.vnet.ibm.com> | 2017-08-03 15:44:59 +0530 |
---|---|---|
committer | Alexey Kardashevskiy <aik@ozlabs.ru> | 2017-08-07 18:24:58 +1000 |
commit | 685af54d8a47a42d9d06c51be45870f6f210a0dc (patch) | |
tree | dc2c0088436e627e85bbdc48e755f68fe5737d26 /lib/libvirtio/virtio.c | |
parent | 604d28cc3f791657414f8b21103921fa0147fc63 (diff) | |
download | SLOF-685af54d8a47a42d9d06c51be45870f6f210a0dc.zip SLOF-685af54d8a47a42d9d06c51be45870f6f210a0dc.tar.gz SLOF-685af54d8a47a42d9d06c51be45870f6f210a0dc.tar.bz2 |
virtio-net: rework the driver to support multiple open
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>
Diffstat (limited to 'lib/libvirtio/virtio.c')
-rw-r--r-- | lib/libvirtio/virtio.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/lib/libvirtio/virtio.c b/lib/libvirtio/virtio.c index f189941..02cfed9 100644 --- a/lib/libvirtio/virtio.c +++ b/lib/libvirtio/virtio.c @@ -401,6 +401,13 @@ int virtio_queue_init_vq(struct virtio_device *dev, struct vqs *vq, unsigned int return 0; } +void virtio_queue_term_vq(struct virtio_device *dev, struct vqs *vq, unsigned int id) +{ + if (vq->desc) + SLOF_free_mem(vq->desc, virtio_vring_size(vq->size)); + memset(vq, 0, sizeof(*vq)); +} + /** * Set device status bits */ |