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

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



Reviewed-by: Costin Lupu <costin.lupu@xxxxxxxxx>

On 9/7/19 1:21 PM, Vlad-Andrei BĂDOIU (78692) wrote:
> 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. */
> 

_______________________________________________
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®.