aboutsummaryrefslogtreecommitdiff
path: root/lib/libvirtio/virtio.code
diff options
context:
space:
mode:
authorNikunj A Dadhania <nikunj@linux.vnet.ibm.com>2017-08-03 15:44:59 +0530
committerAlexey Kardashevskiy <aik@ozlabs.ru>2017-08-07 18:24:58 +1000
commit685af54d8a47a42d9d06c51be45870f6f210a0dc (patch)
treedc2c0088436e627e85bbdc48e755f68fe5737d26 /lib/libvirtio/virtio.code
parent604d28cc3f791657414f8b21103921fa0147fc63 (diff)
downloadSLOF-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.code')
-rw-r--r--lib/libvirtio/virtio.code24
1 files changed, 13 insertions, 11 deletions
diff --git a/lib/libvirtio/virtio.code b/lib/libvirtio/virtio.code
index b8262ad..d52a47d 100644
--- a/lib/libvirtio/virtio.code
+++ b/lib/libvirtio/virtio.code
@@ -137,42 +137,44 @@ MIRP
/******** virtio-net ********/
-// : virtio-net-open ( dev -- false | [ driver true ] )
+// : virtio-net-open ( dev -- false | [ vnet true ] )
PRIM(virtio_X2d_net_X2d_open)
{
void *dev = TOS.a;
- net_driver_t *net_driver = virtionet_open(dev);
+ void *vnet = virtionet_open(dev);
- if (net_driver) {
- TOS.u = (unsigned long)net_driver; PUSH;
+ if (vnet) {
+ TOS.u = (unsigned long)vnet; PUSH;
TOS.n = -1;
} else
TOS.n = 0;
}
MIRP
-// : virtio-net-close ( driver -- )
+// : virtio-net-close ( vnet -- )
PRIM(virtio_X2d_net_X2d_close)
{
- net_driver_t *driver = TOS.a; POP;
- virtionet_close(driver);
+ void *vnet = TOS.a; POP;
+ virtionet_close(vnet);
}
MIRP
-// : virtio-net-read ( addr len -- actual )
+// : virtio-net-read ( addr len vnet -- actual )
PRIM(virtio_X2d_net_X2d_read)
{
+ void *vnet = TOS.a; POP;
int len = TOS.u; POP;
- TOS.n = virtionet_read(TOS.a, len);
+ TOS.n = virtionet_read(vnet, TOS.a, len);
}
MIRP
-// : virtio-net-write ( addr len -- actual )
+// : virtio-net-write ( addr len vnet -- actual )
PRIM(virtio_X2d_net_X2d_write)
{
+ void *vnet = TOS.a; POP;
int len = TOS.u; POP;
- TOS.n = virtionet_write(TOS.a, len);
+ TOS.n = virtionet_write(vnet, TOS.a, len);
}
MIRP