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

Re: [Minios-devel] [UNIKRAFT PATCH v3 06/14] plat/drivers: Configure virtio block device


  • To: Roxana Nicolescu <nicolescu.roxana1996@xxxxxxxxx>, "minios-devel@xxxxxxxxxxxxx" <minios-devel@xxxxxxxxxxxxx>
  • From: Justin He <Justin.He@xxxxxxx>
  • Date: Wed, 11 Mar 2020 02:27:39 +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=j/nfQ9zk+VnOD9hbT/8uOjdlAHKkVeD+kBWeGV7DJRc=; b=dtr88+VqIRyKcGWl7XTEEd4V3dTc0J9mBp3Qn7SkT9lBod+QEQ3dmYXltC8kGQoqJ4kA5gaiMepml2/qFo18RdTXjQgYuMtjPKb36SnDYbjdbBxBsdrsYW5v6x5a/maX3HkSUPF/iloqvJWhtCzF+i0A/AAAWAj9vrkKJNap4nh/WYic3THr+yguFEBtjDZYhyZkbuXhXZZDX2IImEhgjtZN1X31WW1mgu5YfGHN01znLfmQA10imFgm1VYgbZCzupPidNOAM2/gjaaTI73F5PChZ/5ditYPCKTlX6FaPxIdbRF6hdcSUu2ZspaqhMpL9otqTSqW7w476ESLiud7EQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cUVQa9u7BoCft4+kBsZhscPsaeTjTRMjGx4/UrZW1wevgMEkanJecW9WpbZUGQTH03yQPqwyNS34GkwwaeD2bWO2LCZLP4wFBHQ8yECjjIu61HjHw85/legw6wyZUvJ2+mo++YCgDe9xsX66EQmXJbP0UNTfdwH2j7a1kF4YvO9vrPiMotekXv5Atle2H1ckrdYKzk9G5++1mYWH+auFbyJTSoh152tgvWv3q7NeRb1peZCw//wwFMLTjvVKmAUMSfOi6LQ4d1LY4ZoDgw0wiC2Ho505PT6LBI0mxUshyEC2Kippxjq1ckEeVZu1iDUhhCbET9hs8tL7CTxvSuF6CQ==
  • 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:27:53 +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: AQHV8yzy3Q05vb4ZAEeTeWLOWpqVTqhCr9bg
  • Thread-topic: [UNIKRAFT PATCH v3 06/14] plat/drivers: Configure virtio block device

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 06/14] plat/drivers: Configure virtio block
> device
>
> This patch introduces the configuration of block device consisting of:
> -> finding multi-queue-max-queue number provided by Backend;
> -> setting the number of queues to be used (between 1 and max)
>
> Signed-off-by: Roxana Nicolescu <nicolescu.roxana1996@xxxxxxxxx>
> ---
>  plat/drivers/include/virtio/virtio_blk.h |  5 ++
>  plat/drivers/virtio/virtio_blk.c         | 67 +++++++++++++++++++++++-
>  2 files changed, 71 insertions(+), 1 deletion(-)
>
> diff --git a/plat/drivers/include/virtio/virtio_blk.h
> b/plat/drivers/include/virtio/virtio_blk.h
> index 48625258..0efb5ba9 100644
> --- a/plat/drivers/include/virtio/virtio_blk.h
> +++ b/plat/drivers/include/virtio/virtio_blk.h
> @@ -41,12 +41,17 @@
>  /* Feature bits */
>  #define VIRTIO_BLK_F_RO5/* Disk is read-only */
>  #define VIRTIO_BLK_F_BLK_SIZE6/* Block size of disk is
> available*/
> +#define VIRTIO_BLK_F_MQ12/* support more than one vq
> */
>
>  struct virtio_blk_config {
>  /* The capacity (in 512-byte sectors). */
>  __u64 capacity;
> +
>  /* block size of device (if VIRTIO_BLK_F_BLK_SIZE) */
>  __u32 blk_size;
> +
> +/* number of vqs, only available when VIRTIO_BLK_F_MQ is set */
> +__u16 num_queues;
>  } __packed;
>
>  #endif /* __PLAT_DRV_VIRTIO_BLK_H */
> diff --git a/plat/drivers/virtio/virtio_blk.c 
> b/plat/drivers/virtio/virtio_blk.c
> index 2dfe8f27..b7a31121 100644
> --- a/plat/drivers/virtio/virtio_blk.c
> +++ b/plat/drivers/virtio/virtio_blk.c
> @@ -40,10 +40,11 @@
>  /* Features are:
>   *Access Mode
>   *Sector_size;
> + *Multi-queue,
>   **/
>  #define VIRTIO_BLK_DRV_FEATURES(features) \
>  (VIRTIO_FEATURES_UPDATE(features, VIRTIO_BLK_F_RO | \
> -VIRTIO_BLK_F_BLK_SIZE))
> +VIRTIO_BLK_F_BLK_SIZE | VIRTIO_BLK_F_MQ))
>
>  static struct uk_alloc *a;
>  static const char *drv_name = DRIVER_NAME;
> @@ -55,8 +56,45 @@ struct virtio_blk_device {
>  __u16 uid;
>  /* Virtio Device */
>  struct virtio_dev *vdev;
> +/* Nb of max_queues supported by device */
> +__u16 max_vqueue_pairs;
>  };
>
> +
> +static int virtio_blkdev_configure(struct uk_blkdev *dev,
> +const struct uk_blkdev_conf *conf)
> +{
> +int rc = 0;
> +struct virtio_blk_device *vbdev = NULL;
> +
> +UK_ASSERT(dev != NULL);
> +UK_ASSERT(conf != NULL);
> +
> +vbdev = to_virtioblkdev(dev);
> +
> +uk_pr_info(DRIVER_NAME": %"__PRIu16" configured\n", vbdev->uid);
> +return rc;
> +}
> +
> +static int virtio_blkdev_unconfigure(struct uk_blkdev *dev)
> +{
> +UK_ASSERT(dev != NULL);
> +
> +return 0;
> +}
> +
> +static void virtio_blkdev_get_info(struct uk_blkdev *dev,
> +struct uk_blkdev_info *dev_info)
> +{
> +struct virtio_blk_device *vbdev = NULL;
> +
> +UK_ASSERT(dev != NULL);
> +UK_ASSERT(dev_info != NULL);
> +
> +vbdev = to_virtioblkdev(dev);
> +dev_info->max_queues = vbdev->max_vqueue_pairs;
> +}
> +
>  static int virtio_blkdev_feature_negotiate(struct virtio_blk_device *vbdev)
>  {
>  struct uk_blkdev_cap *cap;
> @@ -64,6 +102,7 @@ static int virtio_blkdev_feature_negotiate(struct
> virtio_blk_device *vbdev)
>  int bytes_to_read;
>  __sector sectors;
>  __sector ssize;
> +__u16 num_queues;
>  int rc = 0;
>
>  UK_ASSERT(vbdev);
> @@ -98,12 +137,31 @@ static int virtio_blkdev_feature_negotiate(struct
> virtio_blk_device *vbdev)
>  }
>  }
>
> +/* If the device does not support multi-queues,
> + * we will use only one queue.
> + */
> +if (virtio_has_features(host_features, VIRTIO_BLK_F_MQ)) {
> +bytes_to_read = virtio_config_get(vbdev->vdev,
> +__offsetof(struct virtio_blk_config,
> +num_queues),
> +&num_queues,
> +sizeof(num_queues),
> +1);
> +if (bytes_to_read != sizeof(num_queues)) {
> +uk_pr_err("Failed to read max-queues\n");
> +rc = -EAGAIN;
> +goto exit;
> +}
> +} else
> +num_queues = 1;
>  cap->ssize = ssize;
>  cap->sectors = sectors;
>  cap->ioalign = sizeof(void *);
>  cap->mode = (virtio_has_features(
>  host_features, VIRTIO_BLK_F_RO)) ? O_RDONLY :
> O_RDWR;
>
> +vbdev->max_vqueue_pairs = num_queues;
> +
>  /**
>   * Mask out features supported by both driver and device.
>   */
> @@ -122,6 +180,12 @@ static inline void virtio_blkdev_feature_set(struct
> virtio_blk_device *vbdev)
>  VIRTIO_BLK_DRV_FEATURES(vbdev->vdev->features);
>  }
>
> +static const struct uk_blkdev_ops virtio_blkdev_ops = {
> +.get_info = virtio_blkdev_get_info,
> +.dev_configure = virtio_blkdev_configure,
> +.dev_unconfigure = virtio_blkdev_unconfigure,
> +};
> +
>  static int virtio_blk_add_dev(struct virtio_dev *vdev)
>  {
>  struct virtio_blk_device *vbdev;
> @@ -134,6 +198,7 @@ static int virtio_blk_add_dev(struct virtio_dev *vdev)
>  return -ENOMEM;
>
>  vbdev->vdev = vdev;
> +vbdev->blkdev.dev_ops = &virtio_blkdev_ops;
>
>  rc = uk_blkdev_drv_register(&vbdev->blkdev, a, drv_name);
>  if (rc < 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®.