Discussion of the VIRTIO specification
 help / color / mirror / Atom feed
From: "Michael S. Tsirkin" <mst@redhat.com>
To: Zhu Lingshan <lingshan.zhu@intel.com>
Cc: jasowang@redhat.com, eperezma@redhat.com, cohuck@redhat.com,
	stefanha@redhat.com, virtio-comment@lists.oasis-open.org,
	virtio-dev@lists.oasis-open.org
Subject: Re: [virtio-comment] [PATCH 1/5] virtio: introduce vq state as basic facility
Date: Wed, 6 Sep 2023 04:28:27 -0400	[thread overview]
Message-ID: <20230906042034-mutt-send-email-mst@kernel.org> (raw)
In-Reply-To: <20230906081637.32185-2-lingshan.zhu@intel.com>

On Wed, Sep 06, 2023 at 04:16:33PM +0800, Zhu Lingshan wrote:
> This patch adds new device facility to save and restore virtqueue
> state. The virtqueue state is split into two parts:
> 
> - The available state: The state that is used for read the next
>   available buffer.
> - The used state: The state that is used for make buffer used.
> 
> This will simply the transport specific method implementation. E.g two
> le16 could be used instead of a single le32). For split virtqueue, we
> only need the available state since the used state is implemented in
> the virtqueue itself (the used index). For packed virtqueue, we need
> both the available state and the used state.
> 
> Those states are required to implement live migration support for
> virtio device.
> 
> Signed-off-by: Zhu Lingshan <lingshan.zhu@intel.com>
> Signed-off-by: Jason Wang <jasowang@redhat.com>
> Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
> ---
>  content.tex | 65 +++++++++++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 65 insertions(+)
> 
> diff --git a/content.tex b/content.tex
> index 0a62dce..0e492cd 100644
> --- a/content.tex
> +++ b/content.tex
> @@ -502,6 +502,71 @@ \section{Exporting Objects}\label{sec:Basic Facilities of a Virtio Device / Expo
>  types. It is RECOMMENDED that devices generate version 4
>  UUIDs as specified by \hyperref[intro:rfc4122]{[RFC4122]}.
>  
> +\section{Virtqueue State}\label{sec:Virtqueues / Virtqueue State}
> +
> +When VIRTIO_F_QUEUE_STATE has been negotiated, the driver can set and
> +get the device internal virtqueue state through the following
> +fields. The implementation of the interfaces is transport specific.


virtqueue state can not, generally, be described by two 16 bit
indices.

Consider an example: these buffers available: A B C D
After device used descriptors A and C, what is its state and
how do you describe it using a single index?


> +
> +\subsection{\field{Available State} Field}
> +
> +The available state field is two bytes of virtqueue state that is used by
> +the device to read the next available buffer.
> +
> +When VIRTIO_RING_F_PACKED is not negotiated, it contains:
> +
> +\begin{lstlisting}
> +le16 last_avail_idx;
> +\end{lstlisting}
> +
> +The \field{last_avail_idx} field is the free-running available ring
> +index where the device will read the next available head of a
> +descriptor chain.

next after what?

> +
> +See also \ref{sec:Basic Facilities of a Virtio Device / Virtqueues / The Virtqueue Available Ring}.
> +
> +When VIRTIO_RING_F_PACKED is negotiated, it contains:
> +
> +\begin{lstlisting}
> +le16 {
> +  last_avail_idx : 15;
> +  last_avail_wrap_counter : 1;
> +};
> +\end{lstlisting}
> +
> +The \field{last_avail_idx} field is the free-running location
> +where the device read the next descriptor from the virtqueue descriptor ring.
> +
> +The \field{last_avail_wrap_counter} field is the last driver ring wrap
> +counter that was observed by the device.
> +
> +See also \ref{sec:Packed Virtqueues / Driver and Device Ring Wrap Counters}.
> +
> +\subsection{\field{Used State} Field}
> +
> +The used state field is two bytes of virtqueue state that is used by
> +the device when marking a buffer used.
> +
> +When VIRTIO_RING_F_PACKED is negotiated, the used state contains:
> +
> +\begin{lstlisting}
> +le16 {
> +  used_idx : 15;
> +  used_wrap_counter : 1;
> +};
> +\end{lstlisting}
> +
> +The \field{used_idx} field is the free-running location where the device write the next
> +used descriptor to the descriptor ring.

I don't get what good does this used_idx do - used descriptors are written in
order so just check which ones are valid?
And driver does of course know what the used_wrap_counter is
otherwise it can't work.
Or is this for some kind of
split driver setup where looking at the ring is impossible?


> +
> +The \field{used_wrap_counter} field is the wrap counter that is used
> +by the device.
> +
> +See also \ref{sec:Packed Virtqueues / Driver and Device Ring Wrap Counters}.
> +
> +When VIRTIO_RING_F_PACKED is not negotiated, the 16-bit value of \field{used_idx}
> +is always 0
> +
>  \input{admin.tex}
>  
>  \chapter{General Initialization And Device Operation}\label{sec:General Initialization And Device Operation}
> -- 
> 2.35.3
> 
> 
> This publicly archived list offers a means to provide input to the
> OASIS Virtual I/O Device (VIRTIO) TC.
> 
> In order to verify user consent to the Feedback License terms and
> to minimize spam in the list archive, subscription is required
> before posting.
> 
> Subscribe: virtio-comment-subscribe@lists.oasis-open.org
> Unsubscribe: virtio-comment-unsubscribe@lists.oasis-open.org
> List help: virtio-comment-help@lists.oasis-open.org
> List archive: https://lists.oasis-open.org/archives/virtio-comment/
> Feedback License: https://www.oasis-open.org/who/ipr/feedback_license.pdf
> List Guidelines: https://www.oasis-open.org/policies-guidelines/mailing-lists
> Committee: https://www.oasis-open.org/committees/virtio/
> Join OASIS: https://www.oasis-open.org/join/
> 


This publicly archived list offers a means to provide input to the
OASIS Virtual I/O Device (VIRTIO) TC.

In order to verify user consent to the Feedback License terms and
to minimize spam in the list archive, subscription is required
before posting.

Subscribe: virtio-comment-subscribe@lists.oasis-open.org
Unsubscribe: virtio-comment-unsubscribe@lists.oasis-open.org
List help: virtio-comment-help@lists.oasis-open.org
List archive: https://lists.oasis-open.org/archives/virtio-comment/
Feedback License: https://www.oasis-open.org/who/ipr/feedback_license.pdf
List Guidelines: https://www.oasis-open.org/policies-guidelines/mailing-lists
Committee: https://www.oasis-open.org/committees/virtio/
Join OASIS: https://www.oasis-open.org/join/


  reply	other threads:[~2023-09-06  8:28 UTC|newest]

Thread overview: 148+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-06  8:16 [virtio-comment] [PATCH 0/5] virtio: introduce SUSPEND bit and vq state Zhu Lingshan
2023-09-06  8:16 ` [virtio-comment] [PATCH 1/5] virtio: introduce vq state as basic facility Zhu Lingshan
2023-09-06  8:28   ` Michael S. Tsirkin [this message]
2023-09-06  9:43     ` Zhu, Lingshan
2023-09-14 11:25   ` Michael S. Tsirkin
2023-09-15  2:46     ` Zhu, Lingshan
2023-09-06  8:16 ` [virtio-comment] [PATCH 2/5] virtio: introduce SUSPEND bit in device status Zhu Lingshan
2023-09-14 11:34   ` [virtio-comment] " Michael S. Tsirkin
2023-09-15  2:57     ` Zhu, Lingshan
2023-09-15 11:10       ` Michael S. Tsirkin
2023-09-18  2:56         ` Zhu, Lingshan
2023-09-18  4:42           ` Parav Pandit
2023-09-18  5:14             ` Zhu, Lingshan
2023-09-18  6:17               ` Parav Pandit
2023-09-18  6:38                 ` Zhu, Lingshan
2023-09-18  6:46                   ` Parav Pandit
2023-09-18  6:49                     ` Zhu, Lingshan
2023-09-18  6:50           ` Zhu, Lingshan
2023-09-06  8:16 ` [virtio-comment] [PATCH 3/5] virtqueue: constraints for virtqueue state Zhu Lingshan
2023-09-14 11:30   ` [virtio-comment] " Michael S. Tsirkin
2023-09-15  2:59     ` Zhu, Lingshan
2023-09-15 11:16       ` Michael S. Tsirkin
2023-09-18  3:02         ` Zhu, Lingshan
2023-09-18 17:30           ` Michael S. Tsirkin
2023-09-19  7:56             ` Zhu, Lingshan
2023-09-06  8:16 ` [virtio-comment] [PATCH 4/5] virtqueue: ignore resetting vqs when SUSPEND Zhu Lingshan
2023-09-14 11:09   ` [virtio-comment] " Michael S. Tsirkin
2023-09-15  4:06     ` Zhu, Lingshan
2023-09-06  8:16 ` [virtio-comment] [PATCH 5/5] virtio-pci: implement VIRTIO_F_QUEUE_STATE Zhu Lingshan
2023-09-06  8:32   ` Michael S. Tsirkin
2023-09-06  8:37     ` Parav Pandit
2023-09-06  9:37     ` Zhu, Lingshan
2023-09-11  3:01     ` Jason Wang
2023-09-11  4:11       ` Parav Pandit
2023-09-11  6:30         ` Jason Wang
2023-09-11  6:47           ` Parav Pandit
2023-09-11  6:58             ` Zhu, Lingshan
2023-09-11  7:07               ` Parav Pandit
2023-09-11  7:18                 ` Zhu, Lingshan
2023-09-11  7:30                   ` Parav Pandit
2023-09-11  7:58                     ` Zhu, Lingshan
2023-09-11  8:12                       ` Parav Pandit
2023-09-11  8:46                         ` Zhu, Lingshan
2023-09-11  9:05                           ` Parav Pandit
2023-09-11  9:32                             ` Zhu, Lingshan
2023-09-11 10:21                               ` Parav Pandit
2023-09-12  4:06                                 ` Zhu, Lingshan
2023-09-12  5:58                                   ` Parav Pandit
2023-09-12  6:33                                     ` Zhu, Lingshan
2023-09-12  6:47                                       ` Parav Pandit
2023-09-12  7:27                                         ` Zhu, Lingshan
2023-09-12  7:40                                           ` Parav Pandit
2023-09-12  9:02                                             ` Zhu, Lingshan
2023-09-12  9:21                                               ` Parav Pandit
2023-09-12 13:03                                                 ` Zhu, Lingshan
2023-09-12 13:43                                                   ` Parav Pandit
2023-09-13  4:01                                                     ` Zhu, Lingshan
2023-09-13  4:12                                                       ` Parav Pandit
2023-09-13  4:20                                                         ` Zhu, Lingshan
2023-09-13  4:36                                                           ` Parav Pandit
2023-09-14  8:19                                                             ` Zhu, Lingshan
2023-09-11 11:50                               ` Parav Pandit
2023-09-12  3:43                                 ` Jason Wang
2023-09-12  5:50                                   ` Parav Pandit
2023-09-13  4:44                                     ` Jason Wang
2023-09-13  6:05                                       ` Parav Pandit
2023-09-14  3:11                                         ` Jason Wang
2023-09-17  5:22                                           ` Parav Pandit
2023-09-19  4:35                                             ` Jason Wang
2023-09-19  7:33                                               ` Parav Pandit
2023-09-12  3:48                                 ` Zhu, Lingshan
2023-09-12  5:51                                   ` Parav Pandit
2023-09-12  6:37                                     ` Zhu, Lingshan
2023-09-12  6:49                                       ` Parav Pandit
2023-09-12  7:29                                         ` Zhu, Lingshan
2023-09-12  7:53                                           ` Parav Pandit
2023-09-12  9:06                                             ` Zhu, Lingshan
2023-09-12  9:08                                               ` Zhu, Lingshan
2023-09-12  9:35                                                 ` Parav Pandit
2023-09-12 10:14                                                   ` Zhu, Lingshan
2023-09-12 10:16                                                     ` Parav Pandit
2023-09-12 10:28                                                       ` Zhu, Lingshan
2023-09-13  2:23                                                     ` Parav Pandit
2023-09-13  4:03                                                       ` Zhu, Lingshan
2023-09-13  4:15                                                         ` Parav Pandit
2023-09-13  4:21                                                           ` Zhu, Lingshan
2023-09-13  4:37                                                             ` Parav Pandit
2023-09-14  3:11                                                               ` Jason Wang
2023-09-17  5:25                                                                 ` Parav Pandit
2023-09-19  4:34                                                                   ` Jason Wang
2023-09-19  7:32                                                                     ` Parav Pandit
2023-09-14  8:22                                                               ` Zhu, Lingshan
2023-09-12  9:28                                               ` Parav Pandit
2023-09-12 10:17                                                 ` Zhu, Lingshan
2023-09-12 10:25                                                   ` Parav Pandit
2023-09-12 10:32                                                     ` Zhu, Lingshan
2023-09-12 10:40                                                       ` Parav Pandit
2023-09-12 13:04                                                         ` Zhu, Lingshan
2023-09-12 13:36                                                           ` Parav Pandit
2023-09-12  4:10                         ` Jason Wang
2023-09-12  6:05                           ` Parav Pandit
2023-09-13  4:45                             ` Jason Wang
2023-09-13  6:39                               ` Parav Pandit
2023-09-14  3:08                                 ` Jason Wang
2023-09-17  5:22                                   ` Parav Pandit
2023-09-19  4:32                                     ` Jason Wang
2023-09-19  7:32                                       ` Parav Pandit
2023-09-13  8:27                               ` Michael S. Tsirkin
2023-09-14  3:11                                 ` Jason Wang
2023-09-12  4:18             ` Jason Wang
2023-09-12  6:11               ` Parav Pandit
2023-09-12  6:43                 ` Zhu, Lingshan
2023-09-12  6:52                   ` Parav Pandit
2023-09-12  7:36                     ` Zhu, Lingshan
2023-09-12  7:43                       ` Parav Pandit
2023-09-12 10:27                         ` Zhu, Lingshan
2023-09-12 10:33                           ` Parav Pandit
2023-09-12 10:35                             ` Zhu, Lingshan
2023-09-12 10:41                               ` Parav Pandit
2023-09-12 13:09                                 ` Zhu, Lingshan
2023-09-12 13:35                                   ` Parav Pandit
2023-09-13  4:13                                     ` Zhu, Lingshan
2023-09-13  4:19                                       ` Parav Pandit
2023-09-13  4:22                                         ` Zhu, Lingshan
2023-09-13  4:39                                           ` Parav Pandit
2023-09-14  8:24                                             ` Zhu, Lingshan
2023-09-13  4:56                                         ` Jason Wang
2023-09-13  4:43                 ` Jason Wang
2023-09-13  4:46                   ` Parav Pandit
2023-09-14  3:12                     ` Jason Wang
2023-09-17  5:29                       ` Parav Pandit
2023-09-19  4:25                         ` Jason Wang
2023-09-19  7:32                           ` Parav Pandit
2023-09-11  6:59           ` Parav Pandit
2023-09-11 10:15           ` Michael S. Tsirkin
2023-09-12  3:35             ` Jason Wang
2023-09-12  3:43               ` Zhu, Lingshan
2023-09-14 11:27   ` Michael S. Tsirkin
2023-09-15  4:13     ` Zhu, Lingshan
2023-09-06  8:29 ` [virtio-comment] [PATCH 0/5] virtio: introduce SUSPEND bit and vq state Michael S. Tsirkin
2023-09-06  8:38   ` Zhu, Lingshan
2023-09-06 13:49     ` Michael S. Tsirkin
2023-09-07  1:51       ` Zhu, Lingshan
2023-09-07 10:57       ` Eugenio Perez Martin
2023-09-07 19:55         ` Michael S. Tsirkin
2023-09-14 11:14 ` [virtio-comment] " Michael S. Tsirkin
2023-09-14 11:37 ` Michael S. Tsirkin
2023-09-15  4:41   ` [virtio-comment] Re: [virtio-dev] " Zhu, Lingshan

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=20230906042034-mutt-send-email-mst@kernel.org \
    --to=mst@redhat.com \
    --cc=cohuck@redhat.com \
    --cc=eperezma@redhat.com \
    --cc=jasowang@redhat.com \
    --cc=lingshan.zhu@intel.com \
    --cc=stefanha@redhat.com \
    --cc=virtio-comment@lists.oasis-open.org \
    --cc=virtio-dev@lists.oasis-open.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox