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

[Minios-devel] [UNIKRAFT PATCH v2 4/5] plat/drivers: Add 9P transport 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:30 +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=GsvvvocVns4HH11YiERAV2r0rfUgdDKnXCDUugDjxQ8=; b=eCJ+OLle+biSx5NjYWU/+bqfpxDKF5U3Ohuh37+G9YC5y2ic2f57wvLbpx3yMZLf48aqfSaHKbi6zrLaNEkLhCp5xlXhDH/YmTN0lGt0ZpHnGR1e88VE14X10l1yCGY3j9J8l6T1YarxSANMrzX2iBlXnEWcYiKJn3sAy+VGtmVm3NU9BMLMR4LfazB/E1ypWZwu0LUrCYbDddtk5uNJUB0dhbne/7x9/tgNmB8T4q5DCd43e/roOKt3QXR882yGQvNCW6laIjpL1acm/rYYIFCe/d4ihUXjeLozlexTyw75Nztx1pgb3eAQ046FOtGSnFl7rxgtUjZftLX6QWZs7A==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GPedtPdisQ48fS8GqSVyfE3XevqvJhHmRvL1e9cpTcmApgYHNwNNeMSeoKd0jULMMYQJLWYxoO+T5dMrx8VjwkbF1l5cKh4QoJwvs+3BcyLOX7won463ySF3swcMncr1m6ImoM/iDMYa+EqJXzOrMqLj20q8Dp8DAlSOikhn14jiH125rY96NoDnsB4HbrG1vqizfjgZBbkg2GqI1sDf156RvxHtXJKGC33kV2KpzJokuS3iLeclukH7vWkLovzsTzxfZpvWljKr5YsYcPg1F0tGaEvNAeIDh8MGHjCbHbp4066ii7lLMVh3xjTOZ2jcq9LL602OCb+X47NTnAdelg==
  • 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:53 +0000
  • List-id: Mini-os development list <minios-devel.lists.xenproject.org>
  • Thread-index: AQHVZWD81wyG3ttaokuvr4iTFFpCwg==
  • Thread-topic: [UNIKRAFT PATCH v2 4/5] plat/drivers: Add 9P transport for virtio 9P

From: Cristian Banu <cristb@xxxxxxxxx>

This patch adds the 9P transport driver skeleton for virtio 9P devices,
by providing the required connect, disconnect and request callbacks. The
request callback is left as a stub to be implemented in the following
patches.

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

diff --git a/plat/drivers/virtio/virtio_9p.c b/plat/drivers/virtio/virtio_9p.c
index ab3a1b16..8094ec70 100644
--- a/plat/drivers/virtio/virtio_9p.c
+++ b/plat/drivers/virtio/virtio_9p.c
@@ -35,6 +35,7 @@
 #include <inttypes.h>
 #include <uk/alloc.h>
 #include <uk/essentials.h>
+#include <uk/9pdev_trans.h>
 #include <virtio/virtio_bus.h>
 #include <virtio/virtio_9p.h>
 #include <uk/plat/spinlock.h>
@@ -58,6 +59,83 @@ struct virtio_9p_device {
        struct virtqueue *vq;
        /* Hw queue identifier. */
        uint16_t hwvq_id;
+       /* libuk9p associated device (NULL if the device is not in use). */
+       struct uk_9pdev *p9dev;
+};
+
+static int virtio_9p_connect(struct uk_9pdev *p9dev,
+                            const char *device_identifier,
+                            const char *mount_args __unused)
+{
+       struct virtio_9p_device *dev = NULL;
+       int rc = 0;
+       int found = 0;
+
+       ukarch_spin_lock(&virtio_9p_device_list_lock);
+       uk_list_for_each_entry(dev, &virtio_9p_device_list, _list) {
+               if (!strcmp(dev->tag, device_identifier)) {
+                       if (dev->p9dev != NULL) {
+                               rc = -EBUSY;
+                               goto out;
+                       }
+                       found = 1;
+                       break;
+               }
+       }
+
+       if (!found) {
+               rc = -EINVAL;
+               goto out;
+       }
+
+       /*
+        * The maximum message size is given by the number of segments.
+        *
+        * For read requests, the reply will be able to make use of the large
+        * msize, and the request will not exceed one segment.
+        * Similarly for write requests, but in reverse. Other requests should
+        * not exceed one page for both recv and xmit fcalls.
+        */
+       p9dev->max_msize = (NUM_SEGMENTS - 1) * __PAGE_SIZE;
+
+       dev->p9dev = p9dev;
+       p9dev->priv = dev;
+
+out:
+       ukarch_spin_unlock(&virtio_9p_device_list_lock);
+       return rc;
+}
+
+static int virtio_9p_disconnect(struct uk_9pdev *p9dev)
+{
+       struct virtio_9p_device *dev;
+
+       UK_ASSERT(p9dev);
+       dev = p9dev->priv;
+
+       ukarch_spin_lock(&virtio_9p_device_list_lock);
+       dev->p9dev = NULL;
+       ukarch_spin_unlock(&virtio_9p_device_list_lock);
+
+       return 0;
+}
+
+static int virtio_9p_request(struct uk_9pdev *p9dev __unused,
+                            struct uk_9preq *req __unused)
+{
+       return -EOPNOTSUPP;
+}
+
+static const struct uk_9pdev_trans_ops v9p_trans_ops = {
+       .connect        = virtio_9p_connect,
+       .disconnect     = virtio_9p_disconnect,
+       .request        = virtio_9p_request
+};
+
+static struct uk_9pdev_trans v9p_trans = {
+       .name           = "virtio",
+       .ops            = &v9p_trans_ops,
+       .a              = NULL /* Set by the driver initialization. */
 };
 
 static int virtio_9p_recv(struct virtqueue *vq __unused, void *priv __unused)
@@ -185,7 +263,6 @@ static int virtio_9p_start(struct virtio_9p_device *d)
 static int virtio_9p_add_dev(struct virtio_dev *vdev)
 {
        struct virtio_9p_device *d;
-       unsigned long flags;
        int rc = 0;
 
        UK_ASSERT(vdev != NULL);
@@ -204,9 +281,9 @@ static int virtio_9p_add_dev(struct virtio_dev *vdev)
        if (rc)
                goto out_free;
 
-       ukplat_spin_lock_irqsave(&virtio_9p_device_list_lock, flags);
+       ukarch_spin_lock(&virtio_9p_device_list_lock);
        uk_list_add(&d->_list, &virtio_9p_device_list);
-       ukplat_spin_unlock_irqrestore(&virtio_9p_device_list_lock, flags);
+       ukarch_spin_unlock(&virtio_9p_device_list_lock);
 out:
        return rc;
 out_free:
@@ -224,6 +301,9 @@ static int virtio_9p_drv_init(struct uk_alloc 
*drv_allocator)
        }
 
        a = drv_allocator;
+       v9p_trans.a = a;
+
+       rc = uk_9pdev_trans_register(&v9p_trans);
 out:
        return rc;
 }
-- 
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®.