All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Michael S. Tsirkin" <mst@redhat.com>
To: Xuan Zhuo <xuanzhuo@linux.alibaba.com>
Cc: qemu-devel@nongnu.org, Jason Wang <jasowang@redhat.com>
Subject: Re: [PATCH 1/3] virtio: move struct VirtQueue to include file
Date: Sat, 28 Jan 2023 05:23:46 -0500	[thread overview]
Message-ID: <20230128052212-mutt-send-email-mst@kernel.org> (raw)
In-Reply-To: <20230128071724.33677-2-xuanzhuo@linux.alibaba.com>

On Sat, Jan 28, 2023 at 03:17:22PM +0800, Xuan Zhuo wrote:
> This patch move struct VirtQueue into virtio.h.
> 
> In order to implement Queue Reset, we have to record the queue reset
> status of in struct VirtQueue and provide it to device.
> 
> Signed-off-by: Xuan Zhuo <xuanzhuo@linux.alibaba.com>

So add an API please, no need to move the struct.
This patch will go away then.

> ---
>  hw/virtio/virtio.c         | 49 -----------------------------------
>  include/hw/virtio/virtio.h | 52 ++++++++++++++++++++++++++++++++++++--
>  2 files changed, 50 insertions(+), 51 deletions(-)
> 
> diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c
> index f35178f5fc..03077b2ecf 100644
> --- a/hw/virtio/virtio.c
> +++ b/hw/virtio/virtio.c
> @@ -101,60 +101,11 @@ typedef struct VRingMemoryRegionCaches {
>      MemoryRegionCache used;
>  } VRingMemoryRegionCaches;
>  
> -typedef struct VRing
> -{
> -    unsigned int num;
> -    unsigned int num_default;
> -    unsigned int align;
> -    hwaddr desc;
> -    hwaddr avail;
> -    hwaddr used;
> -    VRingMemoryRegionCaches *caches;
> -} VRing;
> -
>  typedef struct VRingPackedDescEvent {
>      uint16_t off_wrap;
>      uint16_t flags;
>  } VRingPackedDescEvent ;
>  
> -struct VirtQueue
> -{
> -    VRing vring;
> -    VirtQueueElement *used_elems;
> -
> -    /* Next head to pop */
> -    uint16_t last_avail_idx;
> -    bool last_avail_wrap_counter;
> -
> -    /* Last avail_idx read from VQ. */
> -    uint16_t shadow_avail_idx;
> -    bool shadow_avail_wrap_counter;
> -
> -    uint16_t used_idx;
> -    bool used_wrap_counter;
> -
> -    /* Last used index value we have signalled on */
> -    uint16_t signalled_used;
> -
> -    /* Last used index value we have signalled on */
> -    bool signalled_used_valid;
> -
> -    /* Notification enabled? */
> -    bool notification;
> -
> -    uint16_t queue_index;
> -
> -    unsigned int inuse;
> -
> -    uint16_t vector;
> -    VirtIOHandleOutput handle_output;
> -    VirtIODevice *vdev;
> -    EventNotifier guest_notifier;
> -    EventNotifier host_notifier;
> -    bool host_notifier_enabled;
> -    QLIST_ENTRY(VirtQueue) node;
> -};
> -
>  const char *virtio_device_names[] = {
>      [VIRTIO_ID_NET] = "virtio-net",
>      [VIRTIO_ID_BLOCK] = "virtio-blk",
> diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h
> index 77c6c55929..1c0d77c670 100644
> --- a/include/hw/virtio/virtio.h
> +++ b/include/hw/virtio/virtio.h
> @@ -214,6 +214,56 @@ struct VirtioDeviceClass {
>      struct vhost_dev *(*get_vhost)(VirtIODevice *vdev);
>  };
>  
> +typedef struct VRingMemoryRegionCaches VRingMemoryRegionCaches;
> +typedef void (*VirtIOHandleOutput)(VirtIODevice *, VirtQueue *);
> +
> +typedef struct VRing {
> +    unsigned int num;
> +    unsigned int num_default;
> +    unsigned int align;
> +    hwaddr desc;
> +    hwaddr avail;
> +    hwaddr used;
> +    VRingMemoryRegionCaches *caches;
> +} VRing;
> +
> +struct VirtQueue {
> +    VRing vring;
> +    VirtQueueElement *used_elems;
> +
> +    /* Next head to pop */
> +    uint16_t last_avail_idx;
> +    bool last_avail_wrap_counter;
> +
> +    /* Last avail_idx read from VQ. */
> +    uint16_t shadow_avail_idx;
> +    bool shadow_avail_wrap_counter;
> +
> +    uint16_t used_idx;
> +    bool used_wrap_counter;
> +
> +    /* Last used index value we have signalled on */
> +    uint16_t signalled_used;
> +
> +    /* Last used index value we have signalled on */
> +    bool signalled_used_valid;
> +
> +    /* Notification enabled? */
> +    bool notification;
> +
> +    uint16_t queue_index;
> +
> +    unsigned int inuse;
> +
> +    uint16_t vector;
> +    VirtIOHandleOutput handle_output;
> +    VirtIODevice *vdev;
> +    EventNotifier guest_notifier;
> +    EventNotifier host_notifier;
> +    bool host_notifier_enabled;
> +    QLIST_ENTRY(VirtQueue) node;
> +};
> +
>  void virtio_instance_init_common(Object *proxy_obj, void *data,
>                                   size_t vdev_size, const char *vdev_name);
>  
> @@ -226,8 +276,6 @@ void virtio_error(VirtIODevice *vdev, const char *fmt, ...) G_GNUC_PRINTF(2, 3);
>  /* Set the child bus name. */
>  void virtio_device_set_child_bus_name(VirtIODevice *vdev, char *bus_name);
>  
> -typedef void (*VirtIOHandleOutput)(VirtIODevice *, VirtQueue *);
> -
>  VirtQueue *virtio_add_queue(VirtIODevice *vdev, int queue_size,
>                              VirtIOHandleOutput handle_output);
>  
> -- 
> 2.32.0.3.g01195cf9f



  reply	other threads:[~2023-01-28 10:24 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-28  7:17 [PATCH 0/3] virtio: fix for assertion failure: virtio_net_get_subqueue(nc)->async_tx.elem failed Xuan Zhuo
2023-01-28  7:17 ` [PATCH 1/3] virtio: move struct VirtQueue to include file Xuan Zhuo
2023-01-28 10:23   ` Michael S. Tsirkin [this message]
2023-01-28 10:37     ` Xuan Zhuo
2023-01-28  7:17 ` [PATCH 2/3] virtio: struct VirtQueue introduce reset Xuan Zhuo
2023-01-28 10:22   ` Michael S. Tsirkin
2023-01-28 10:41     ` Xuan Zhuo
2023-01-28 11:19       ` Michael S. Tsirkin
2023-01-28  7:17 ` [PATCH 3/3] virtio-net: virtio_net_flush_tx() check for per-queue reset Xuan Zhuo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230128052212-mutt-send-email-mst@kernel.org \
    --to=mst@redhat.com \
    --cc=jasowang@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=xuanzhuo@linux.alibaba.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.