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

Re: [Minios-devel] [UNIKRAFT PATCH v3 07/14] plat/drivers: Create virtio-block queues


  • To: Roxana Nicolescu <nicolescu.roxana1996@xxxxxxxxx>, "minios-devel@xxxxxxxxxxxxx" <minios-devel@xxxxxxxxxxxxx>
  • From: Justin He <Justin.He@xxxxxxx>
  • Date: Wed, 11 Mar 2020 02:41:11 +0000
  • Accept-language: en-US, zh-CN
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; 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=jqzoGHQkzg49N0RvhmVIn1wd0zHIAlxB54SHQpvKV0c=; b=Xm7dC+T9qClvGHB4UVtVNVqQ2sEaT5Ktx4tLJZokWCRwjhbcsv/PAiepwZTXrk9SQdTWkj7iZooZ1HgRd3BUFsJoVlSYlBwc9Ifa1LKBGtzZyRO/x8RAFcb0ZuGR6jWoKRdvwA32iEFPOuzoRlfd/kRhYQrUFKSJ/wG6ihpyURBeCVE3oST0CrSEecyLvWqNr55uVPChSe5jKYASdPTPPHkbHasDpjmHbCDv1U/egykGbJW85oxIv+t56cdYkZSeIDTTGrY0GIpnYbrXJTjXIxbxRZXimady54TbR6aahhfmaJhdrYiOJxBrqQHE6auWPKOQIeSQ6YVzej4bngZRVA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=dpwos+id5F4X0YP9aE/kIPk3x8YMf4y+YI9oHmSaSTKkufKvt/k9rcxPVW4jsJp6KVkKgO8K5ADbJJjSiWUvfjWhpu4+B6K7fIEcWdMKRDgZioua1KW4rxLN5MsK7ojRseFMg0rtObqBhFvOFLjWT3z3ycUOQeBYcTTjMb4t+sNzoHinJQSeAct3XEK6XLZbuzMHJjTcxkQQcTeLtaT17qtq8MYWEIzYDqf4pevE5dRlg2O9VhYvHqcIl4CUn9uyf/5SlRYaw9tYPdjew8hw51iiCarF6syLFLMAP/EunmA5vXrXnyrePb+UhYN1GwcMsBBjyXb0KzwTAGGpzGjKrw==
  • Authentication-results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; lists.xen.org; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;lists.xen.org; dmarc=bestguesspass action=none header.from=arm.com;
  • Authentication-results-original: spf=none (sender IP is ) smtp.mailfrom=Justin.He@xxxxxxx;
  • Delivery-date: Wed, 11 Mar 2020 02:41:26 +0000
  • List-id: Mini-os development list <minios-devel.lists.xenproject.org>
  • Nodisclaimer: true
  • Original-authentication-results: spf=none (sender IP is ) smtp.mailfrom=Justin.He@xxxxxxx;
  • Thread-index: AQHV8yzycrWqwS7pxkmbKtGA2DyllqhCtpog
  • Thread-topic: [UNIKRAFT PATCH v3 07/14] plat/drivers: Create virtio-block queues

LGTM.
Reviewed-by: Jia He <justin.he@xxxxxxx>

> -----Original Message-----
> From: Roxana Nicolescu <nicolescu.roxana1996@xxxxxxxxx>
> Sent: Friday, March 6, 2020 4:30 AM
> To: minios-devel@xxxxxxxxxxxxx
> Cc: Justin He <Justin.He@xxxxxxx>; Roxana Nicolescu
> <nicolescu.roxana1996@xxxxxxxxx>
> Subject: [UNIKRAFT PATCH v3 07/14] plat/drivers: Create virtio-block queues
>
> This patch allocates the queues used for communication with the device.
> One queue is responsible for handling both requests and responses
> to/from device.
>
> Signed-off-by: Roxana Nicolescu <nicolescu.roxana1996@xxxxxxxxx>
> ---
>  plat/drivers/virtio/virtio_blk.c | 74 ++++++++++++++++++++++++++++++++
>  1 file changed, 74 insertions(+)
>
> diff --git a/plat/drivers/virtio/virtio_blk.c 
> b/plat/drivers/virtio/virtio_blk.c
> index b7a31121..077daf35 100644
> --- a/plat/drivers/virtio/virtio_blk.c
> +++ b/plat/drivers/virtio/virtio_blk.c
> @@ -56,10 +56,74 @@ struct virtio_blk_device {
>  __u16 uid;
>  /* Virtio Device */
>  struct virtio_dev *vdev;
> +/* List of all the virtqueue in the pci device */
> +struct virtqueue *vq;
>  /* Nb of max_queues supported by device */
>  __u16 max_vqueue_pairs;
> +/* This is used when the user has decided the nb_queues to use */
> +__u16    nb_queues;
> +/* List of queues */
> +struct   uk_blkdev_queue *qs;
>  };
>
> +struct uk_blkdev_queue {
> +/* The virtqueue reference */
> +struct virtqueue *vq;
> +/* The libukblkdev queue identifier */
> +/* It is also the virtqueue identifier */
> +uint16_t lqueue_id;
> +/* Allocator */
> +struct uk_alloc *a;
> +/* The nr. of descriptor limit */
> +uint16_t max_nb_desc;
> +/* Reference to virtio_blk_device  */
> +struct virtio_blk_device *vbd;
> +};
> +
> +
> +static int virtio_blkdev_queues_alloc(struct virtio_blk_device *vbdev,
> +    const struct uk_blkdev_conf *conf)
> +{
> +int rc = 0;
> +uint16_t i = 0;
> +int vq_avail = 0;
> +__u16 qdesc_size[conf->nb_queues];
> +
> +if (conf->nb_queues > vbdev->max_vqueue_pairs) {
> +uk_pr_err("Queue number not supported: %"__PRIu16"\n",
> +conf->nb_queues);
> +return -ENOTSUP;
> +}
> +
> +vbdev->nb_queues = conf->nb_queues;
> +vq_avail = virtio_find_vqs(vbdev->vdev, conf->nb_queues,
> qdesc_size);
> +if (unlikely(vq_avail != conf->nb_queues)) {
> +uk_pr_err("Expected: %d queues, Found: %d queues\n",
> +conf->nb_queues, vq_avail);
> +rc = -ENOMEM;
> +goto exit;
> +}
> +
> +/**
> + * TODO:
> + * The virtio device management data structure are allocated using
> the
> + * allocator from the blkdev configuration. In the future it might be
> + * wiser to move it to the allocator of each individual queue. This
> + * would better considering NUMA support.
> + */
> +vbdev->qs = uk_calloc(a, conf->nb_queues, sizeof(*vbdev->qs));
> +if (unlikely(vbdev->qs == NULL)) {
> +uk_pr_err("Failed to allocate memory for queue
> management\n");
> +rc = -ENOMEM;
> +goto exit;
> +}
> +
> +for (i = 0; i < conf->nb_queues; ++i)
> +vbdev->qs[i].max_nb_desc = qdesc_size[i];
> +
> +exit:
> +return rc;
> +}
>
>  static int virtio_blkdev_configure(struct uk_blkdev *dev,
>  const struct uk_blkdev_conf *conf)
> @@ -71,14 +135,24 @@ static int virtio_blkdev_configure(struct uk_blkdev
> *dev,
>  UK_ASSERT(conf != NULL);
>
>  vbdev = to_virtioblkdev(dev);
> +rc = virtio_blkdev_queues_alloc(vbdev, conf);
> +if (rc) {
> +uk_pr_err("Failed to allocate the queues %d\n", rc);
> +goto exit;
> +}
>
>  uk_pr_info(DRIVER_NAME": %"__PRIu16" configured\n", vbdev->uid);
> +exit:
>  return rc;
>  }
>
>  static int virtio_blkdev_unconfigure(struct uk_blkdev *dev)
>  {
> +struct virtio_blk_device *d;
> +
>  UK_ASSERT(dev != NULL);
> +d = to_virtioblkdev(dev);
> +uk_free(a, d->qs);
>
>  return 0;
>  }
> --
> 2.17.1

IMPORTANT NOTICE: The contents of this email and any attachments are 
confidential and may also be privileged. If you are not the intended recipient, 
please notify the sender immediately and do not disclose the contents to any 
other person, use it for any purpose, or store or copy the information in any 
medium. Thank you.

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