[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Minios-devel] [UNIKRAFT PATCH v2 3/5] plat/drivers: Allocate virtqueue for virtio 9P


  • To: "minios-devel@xxxxxxxxxxxxx" <minios-devel@xxxxxxxxxxxxx>
  • From: Vlad-Andrei BĂDOIU (78692) <vlad_andrei.badoiu@xxxxxxxxxxxxxxx>
  • Date: Sat, 7 Sep 2019 09:45:29 +0000
  • Accept-language: en-US
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=stud.acs.upb.ro; dmarc=pass action=none header.from=stud.acs.upb.ro; dkim=pass header.d=stud.acs.upb.ro; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=R9lGeIq4sCE5xayuBoTwctinxTxc80tap8FBy9mrdd0=; b=TRqhihuYchYrYnzjM9TajI8pcJx7f6h+LRgUGca5q3psd96nkwVVloskKGlGxKzpdJc+OcEw0CYO2dwLlXuwbR3g5LYEx1xM9UXAXB2EqoAVoKJmyPiQNwR3UzZoFnakmPZE4w5an4HnPAJSJI+ZwSS5V1EyhMpWkm4ZY3431Xl4NPtgO7julgsWTjHewLBZ/wkeMQgSarkUj43Wva8ELTi/wqM2Nxzwz7VLUL0MP3Pp5MgXre512X2K0KLRuezI07zP12UyPNOV8j4RiS3IXqNv36VebP6BKfl8xsEoYcq+/qg8071bAiTQq4C1gyM1vauPQRgjRLEglrOJZHGa9Q==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jknaXvjrbjoFkVYFtl53QYMrOrpCmd832n5/d1HJ9dFeW9xkNcDwQpU122oGBUVEwORgx5nuJj2lKm/aRxF8tCGDVGFtZq39EMAvN36oSGUQggKV69NS0IyGueabf2aUej3rTfc6R3OkgvEkjdyzAbV4sf5p0P0S5yuFLAhgPod7rEEONHCgTO1rxamcEl6tvMUVk2xXRDjdWa3zTEYAURAAgh+GYNiJiDpMEvUSCzzPNyD/+LR9qwJtez0HxOEDowvdDlrLr/H2rCBgDScqDr/fzS8vO7nnUHDzIz5Epz7LRgXz3Qvo3SgSHOEmQwJ18q/lgRdx+J92sC64fzkjhg==
  • Authentication-results: spf=none (sender IP is ) smtp.mailfrom=vlad_andrei.badoiu@xxxxxxxxxxxxxxx;
  • Cc: "costin.lupu@xxxxxxxxx" <costin.lupu@xxxxxxxxx>, Cristian Banu <cristb@xxxxxxxxx>
  • Delivery-date: Sat, 07 Sep 2019 09:45:48 +0000
  • List-id: Mini-os development list <minios-devel.lists.xenproject.org>
  • Thread-index: AQHVZWD7nrkVqrStkke1Yjp1N//tXQ==
  • Thread-topic: [UNIKRAFT PATCH v2 3/5] plat/drivers: Allocate virtqueue for virtio 9P

From: Cristian Banu <cristb@xxxxxxxxx>

This patch implements virtqueue allocation with a stubbed interrupt
handler for virtio 9P devices.

Signed-off-by: Cristian Banu <cristb@xxxxxxxxx>
---
 plat/drivers/virtio/virtio_9p.c | 57 +++++++++++++++++++++++++++++++++
 1 file changed, 57 insertions(+)

diff --git a/plat/drivers/virtio/virtio_9p.c b/plat/drivers/virtio/virtio_9p.c
index 798ebe90..ab3a1b16 100644
--- a/plat/drivers/virtio/virtio_9p.c
+++ b/plat/drivers/virtio/virtio_9p.c
@@ -32,6 +32,7 @@
  * THIS HEADER MAY NOT BE EXTRACTED OR MODIFIED IN ANY WAY.
  */
 
+#include <inttypes.h>
 #include <uk/alloc.h>
 #include <uk/essentials.h>
 #include <virtio/virtio_bus.h>
@@ -39,6 +40,7 @@
 #include <uk/plat/spinlock.h>
 
 #define DRIVER_NAME    "virtio-9p"
+#define NUM_SEGMENTS   128 /** The number of virtqueue descriptors. */
 static struct uk_alloc *a;
 
 /* List of initialized virtio 9p devices. */
@@ -52,8 +54,56 @@ struct virtio_9p_device {
        char *tag;
        /* Entry within the virtio devices' list. */
        struct uk_list_head _list;
+       /* Virtqueue reference. */
+       struct virtqueue *vq;
+       /* Hw queue identifier. */
+       uint16_t hwvq_id;
 };
 
+static int virtio_9p_recv(struct virtqueue *vq __unused, void *priv __unused)
+{
+       return 0;
+}
+
+static int virtio_9p_vq_alloc(struct virtio_9p_device *d)
+{
+       int vq_avail = 0;
+       int rc = 0;
+       __u16 qdesc_size;
+
+       vq_avail = virtio_find_vqs(d->vdev, 1, &qdesc_size);
+       if (unlikely(vq_avail != 1)) {
+               uk_pr_err(DRIVER_NAME": Expected: %d queues, found %d\n",
+                         1, vq_avail);
+               rc = -ENOMEM;
+               goto exit;
+       }
+
+       d->hwvq_id = 0;
+       if (unlikely(qdesc_size != NUM_SEGMENTS)) {
+               uk_pr_err(DRIVER_NAME": Expected %d descriptors, found %d 
(virtqueue %"
+                         PRIu16")\n", NUM_SEGMENTS, qdesc_size, d->hwvq_id);
+               rc = -EINVAL;
+               goto exit;
+       }
+
+       d->vq = virtio_vqueue_setup(d->vdev,
+                                   d->hwvq_id,
+                                   qdesc_size,
+                                   virtio_9p_recv,
+                                   a);
+       if (unlikely(PTRISERR(d->vq))) {
+               uk_pr_err(DRIVER_NAME": Failed to set up virtqueue %"PRIu16"\n",
+                         d->hwvq_id);
+               rc = PTR2ERR(d->vq);
+       }
+
+       d->vq->priv = d;
+
+exit:
+       return rc;
+}
+
 static int virtio_9p_feature_negotiate(struct virtio_9p_device *d)
 {
        __u64 host_features;
@@ -107,6 +157,12 @@ static int virtio_9p_configure(struct virtio_9p_device *d)
                goto out_status_fail;
        }
 
+       rc = virtio_9p_vq_alloc(d);
+       if (rc) {
+               uk_pr_err(DRIVER_NAME": Could not allocate virtqueue\n");
+               goto out_status_fail;
+       }
+
        uk_pr_info(DRIVER_NAME": Configured: features=0x%lx tag=%s\n",
                        d->vdev->features, d->tag);
 out:
@@ -119,6 +175,7 @@ out_status_fail:
 
 static int virtio_9p_start(struct virtio_9p_device *d)
 {
+       virtqueue_intr_enable(d->vq);
        virtio_dev_drv_up(d->vdev);
        uk_pr_info(DRIVER_NAME": %s started\n", d->tag);
 
-- 
2.20.1


_______________________________________________
Minios-devel mailing list
Minios-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/minios-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.