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

Re: [Minios-devel] [UNIKRAFT PATCH v3 13/14] plat/drivers: Handle responses from backend for virtio block


  • To: Roxana Nicolescu <nicolescu.roxana1996@xxxxxxxxx>, "minios-devel@xxxxxxxxxxxxx" <minios-devel@xxxxxxxxxxxxx>
  • From: Justin He <Justin.He@xxxxxxx>
  • Date: Wed, 11 Mar 2020 05:04:04 +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=Mtw4HeveKScT9xVcvyr5QVJkPdRSVQ16K/TfPXG96kY=; b=AkuJP00m3EobUh/X7Hydf28KdICf9VrFQtpokPJN5Senj+SUOm/d+47bEZH1JEwzSdOpnK+ZosdAb/y8o/HoQFNvDZAxY0kL0Ix+lC049kwF+fduVGTTvJvZK6pGuEgdwcy/+9Jy83sXYhPfh4xVEljlloI1+qotJa6SGfB8hjTi9w4GJcvXjGnDKzjZHyqixJFrlQ5enUe8dcGfJT+BqfNWHE+FW2t8vLCAi82T73Eekph1JPBG+Bq/93EkcQlNf0AipoWzWPGZPfZwWnB74f8JIHyTSo5rjjFWPVEMwmaGM4lFPUd3cvpaI5iOsr79smHWlRfMehQdMcgYFf5zRg==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=UOR5QTNOz2FUK3Q1xKgkTwBnJqjFJrOB1v8CdFKZASF/0g73GZsQmBGyGWNBDpSwumrg7xdDslL1UpYAEu26l+dLTO1Jv4VLYZ0MuKGxodttuZ3aP51uPIQveW0CO0qrPhxmCFZcUG90Xl5PvwK1GpOlzUeUQu4lCKav/n9A9CayhbCGQ6MOQgZ2BVcp+KIhLDVUhgbKjsc6twqEF6H72L4SXdaSkNEuuyLdV8GSRzvkJv7/pEwTDyPp8iA5n+Ht3rVBMj85am0+TLPien0AVL9RLuMkCigRj9DrvuR8ZMBU2WkgqP+2zEuVLNF5AOTstALg3StN/iJEEhtCo2TYjw==
  • 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 05:04:18 +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: AQHV8yz38inwDvTGE0GltjRdeVzKJKhC3nsA
  • Thread-topic: [UNIKRAFT PATCH v3 13/14] plat/drivers: Handle responses from backend for virtio block

LGTM.
Reviewed-by: Jia He <justin.he@xxxxxxx>
--
Cheers,
Justin (Jia He)



> -----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 13/14] plat/drivers: Handle responses from
> backend for virtio block
>
> This patch introduces the function responsible of processing
> responses from the queue.
> Responses are popped out from queue until there is nothing to process.
>
> Signed-off-by: Roxana Nicolescu <nicolescu.roxana1996@xxxxxxxxx>
> ---
>  plat/drivers/include/virtio/virtio_blk.h |  4 ++
>  plat/drivers/virtio/virtio_blk.c         | 73 ++++++++++++++++++++++++
>  2 files changed, 77 insertions(+)
>
> diff --git a/plat/drivers/include/virtio/virtio_blk.h
> b/plat/drivers/include/virtio/virtio_blk.h
> index 662418c6..d56c1e13 100644
> --- a/plat/drivers/include/virtio/virtio_blk.h
> +++ b/plat/drivers/include/virtio/virtio_blk.h
> @@ -93,4 +93,8 @@ struct virtio_blk_outhdr {
>  __virtio_le64 sector;
>  };
>
> +/* And this is the final byte of the write scatter-gather list. */
> +#define VIRTIO_BLK_S_OK0
> +#define VIRTIO_BLK_S_IOERR1
> +
>  #endif /* __PLAT_DRV_VIRTIO_BLK_H */
> diff --git a/plat/drivers/virtio/virtio_blk.c 
> b/plat/drivers/virtio/virtio_blk.c
> index 520cdfbe..85f40ba6 100644
> --- a/plat/drivers/virtio/virtio_blk.c
> +++ b/plat/drivers/virtio/virtio_blk.c
> @@ -338,6 +338,78 @@ err:
>  return rc;
>  }
>
> +static int virtio_blkdev_queue_dequeue(struct uk_blkdev_queue *queue,
> +struct uk_blkreq **req)
> +{
> +int ret = 0;
> +__u32 len;
> +struct virtio_blkdev_request *response_req;
> +
> +UK_ASSERT(req);
> +*req = NULL;
> +
> +ret = virtqueue_buffer_dequeue(queue->vq, (void **)
> &response_req,
> +&len);
> +if (ret < 0) {
> +uk_pr_info("No data available in the queue\n");
> +return 0;
> +}
> +
> +/* We need at least one byte for the result status */
> +if (unlikely(len < 1)) {
> +uk_pr_err("Received invalid response size: %u\n", len);
> +ret = -EINVAL;
> +goto out;
> +}
> +
> +*req = response_req->req;
> +(*req)->result = -response_req->status;
> +
> +out:
> +uk_free(a, response_req);
> +return ret;
> +}
> +
> +static int virtio_blkdev_complete_reqs(struct uk_blkdev *dev,
> +struct uk_blkdev_queue *queue)
> +{
> +struct uk_blkreq *req;
> +int rc = 0;
> +
> +UK_ASSERT(dev);
> +
> +/* Queue interrupts have to be off when calling receive */
> +UK_ASSERT(!(queue->intr_enabled & VTBLK_INTR_EN));
> +
> +moretodo:
> +for (;;) {
> +rc = virtio_blkdev_queue_dequeue(queue, &req);
> +if (unlikely(rc < 0)) {
> +uk_pr_err("Failed to dequeue the request: %d\n", rc);
> +goto err_exit;
> +}
> +
> +if (!req)
> +break;
> +
> +uk_blkreq_finished(req);
> +if (req->cb)
> +req->cb(req, req->cb_cookie);
> +}
> +
> +/* Enable interrupt only when user had previously enabled it */
> +if (queue->intr_enabled & VTBLK_INTR_USR_EN_MASK) {
> +rc = virtqueue_intr_enable(queue->vq);
> +if (rc == 1)
> +goto moretodo;
> +}
> +
> +return 0;
> +
> +err_exit:
> +return rc;
> +}
> +
>  static int virtio_blkdev_recv_done(struct virtqueue *vq, void *priv)
>  {
>  struct uk_blkdev_queue *queue = NULL;
> @@ -811,6 +883,7 @@ static int virtio_blk_add_dev(struct virtio_dev *vdev)
>  return -ENOMEM;
>
>  vbdev->vdev = vdev;
> +vbdev->blkdev.finish_reqs = virtio_blkdev_complete_reqs;
>  vbdev->blkdev.submit_one = virtio_blkdev_submit_request;
>  vbdev->blkdev.dev_ops = &virtio_blkdev_ops;
>
> --
> 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®.