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

[Minios-devel] [UNIKRAFT PATCH 7/9] plat/xen/drivers/9p: Add connection callbacks


  • To: "minios-devel@xxxxxxxxxxxxx" <minios-devel@xxxxxxxxxxxxx>
  • From: Vlad-Andrei BĂDOIU (78692) <vlad_andrei.badoiu@xxxxxxxxxxxxxxx>
  • Date: Sat, 7 Sep 2019 10:21:59 +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=qdxx2OkEpIsC3LUP76Vk/V6CZ91Qxx4AJhbrvgMCLFA=; b=iORZzISq9DU23zc4VOOojrB2WnMEaVWSglev1ZoNQMuqp9nI0IK6o/UCwUMAlYVHp/aJDrZg9nzZQ1iAmQp9vO8iUjJzfPjsb3BQ09vkdvx5SqE/m2cABW7vUcs0xLj5U/23psT5vaQxSA9sLivcT8KFqHTyExBCTJkNTYmhFrI5H+iBf8Jib1wAJL75keCO/fQ9nq6j25afkFOoY95/7f6PmXCnSvYoYUMUrKx5+eqznHTayoKYELPkAfiiDIA5K1/OV/dy90kGzQhGXHsUYRZ4nLNB4lsJlHMHMs6dQW8sHdu5SARlHzABeavcyRI4khWk2Tp69CjLD+X2a+ik6g==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=PbpcfNCafWCKcdcvRjfTEV/4iiSwyjAEUbkW/3RHy8M8rsEsjzyHqm2Rf6Eas67F2YRIZ+sZa/+w7aQ5i6vHuOSkTSBmM72A4K5PGRUuTv2EJ6INW3FxiRryIjNQ4Y834r4VRTjZ/pKFU2+bYx3GqvRhc5054zxKhtOFIwkPobtj9EHG9dYMEjuVX8EZuI03mkWdFX88b52b0uz24pSovFVMH5kjmpyHE1ccwV3yq3RsL1imlxs5H4HBfajJM9B7VSbWlfpH9xiPVdaDYBUfFDiZ231Brt0mVSp6OutBltaFjHVhKBuV/laxRrKXP9zC+b5W+CzpT+T1l7NvPMjaHA==
  • 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 10:22:35 +0000
  • List-id: Mini-os development list <minios-devel.lists.xenproject.org>
  • Thread-index: AQHVZWYVZlAXVEmC5kql6HuHs1YpBw==
  • Thread-topic: [UNIKRAFT PATCH 7/9] plat/xen/drivers/9p: Add connection callbacks

From: Cristian Banu <cristb@xxxxxxxxx>

This patch adds connection and disconnection callbacks to the xen 9P
transport driver.

Signed-off-by: Cristian Banu <cristb@xxxxxxxxx>
---
 plat/xen/drivers/9p/9pfront.c | 51 ++++++++++++++++++++++++++++++-----
 plat/xen/drivers/9p/9pfront.h |  3 ++-
 2 files changed, 47 insertions(+), 7 deletions(-)

diff --git a/plat/xen/drivers/9p/9pfront.c b/plat/xen/drivers/9p/9pfront.c
index 12591d07..1a8b49c5 100644
--- a/plat/xen/drivers/9p/9pfront.c
+++ b/plat/xen/drivers/9p/9pfront.c
@@ -190,15 +190,55 @@ out:
        return rc;
 }
 
-static int p9front_connect(struct uk_9pdev *p9dev __unused,
-                          const char *device_identifier __unused,
+static int p9front_connect(struct uk_9pdev *p9dev,
+                          const char *device_identifier,
                           const char *mount_args __unused)
 {
-       return 0;
+       struct p9front_dev *p9fdev = NULL;
+       int rc = 0;
+       int found = 0;
+
+       ukarch_spin_lock(&p9front_device_list_lock);
+       uk_list_for_each_entry(p9fdev, &p9front_device_list, _list) {
+               if (!strcmp(p9fdev->tag, device_identifier)) {
+                       if (p9fdev->p9dev != NULL) {
+                               rc = -EBUSY;
+                               goto out;
+                       }
+                       found = 1;
+                       break;
+               }
+       }
+
+       if (!found) {
+               rc = -ENODEV;
+               goto out;
+       }
+
+       /* The msize is given by the size of the flex ring. */
+       p9dev->max_msize = XEN_FLEX_RING_SIZE(p9fdev->ring_order);
+
+       p9fdev->p9dev = p9dev;
+       p9dev->priv = p9fdev;
+       rc = 0;
+       found = 1;
+
+out:
+       ukarch_spin_unlock(&p9front_device_list_lock);
+       return rc;
 }
 
 static int p9front_disconnect(struct uk_9pdev *p9dev __unused)
 {
+       struct p9front_dev *p9fdev;
+
+       UK_ASSERT(p9dev);
+       p9fdev = p9dev->priv;
+
+       ukarch_spin_lock(&p9front_device_list_lock);
+       p9fdev->p9dev = NULL;
+       ukarch_spin_unlock(&p9front_device_list_lock);
+
        return 0;
 }
 
@@ -236,7 +276,6 @@ static int p9front_add_dev(struct xenbus_device *xendev)
 {
        struct p9front_dev *p9fdev;
        int rc;
-       unsigned long flags;
 
        p9fdev = uk_calloc(a, 1, sizeof(*p9fdev));
        if (!p9fdev) {
@@ -271,9 +310,9 @@ static int p9front_add_dev(struct xenbus_device *xendev)
        }
 
        rc = 0;
-       ukplat_spin_lock_irqsave(&p9front_device_list_lock, flags);
+       ukarch_spin_lock(&p9front_device_list_lock);
        uk_list_add(&p9fdev->_list, &p9front_device_list);
-       ukplat_spin_unlock_irqrestore(&p9front_device_list_lock, flags);
+       ukarch_spin_unlock(&p9front_device_list_lock);
 
        uk_pr_info(DRIVER_NAME": Connected 9pfront dev: 
tag=%s,rings=%d,order=%d\n",
                p9fdev->tag, p9fdev->nb_rings, p9fdev->ring_order);
diff --git a/plat/xen/drivers/9p/9pfront.h b/plat/xen/drivers/9p/9pfront.h
index 97c986d8..7cea61c5 100644
--- a/plat/xen/drivers/9p/9pfront.h
+++ b/plat/xen/drivers/9p/9pfront.h
@@ -64,6 +64,8 @@ struct p9front_dev_ring {
 struct p9front_dev {
        /* Xenbus device. */
        struct xenbus_device *xendev;
+       /* 9P API device. */
+       struct uk_9pdev *p9dev;
        /* Entry within the 9pfront device list. */
        struct uk_list_head _list;
        /* Number of maximum rings, read from xenstore. */
@@ -72,7 +74,6 @@ struct p9front_dev {
        int max_ring_page_order;
        /* Mount tag for this device, read from xenstore. */
        char *tag;
-
        /* Number of rings to use. */
        int nb_rings;
        /* Ring page order. */
-- 
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®.