All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Michael S. Tsirkin" <mst@redhat.com>
To: Cornelia Huck <cohuck@redhat.com>
Cc: virtio@lists.oasis-open.org, virtio-dev@lists.oasis-open.org,
	Halil Pasic <pasic@linux.vnet.ibm.com>,
	Tiwei Bie <tiwei.bie@intel.com>,
	Stefan Hajnoczi <stefanha@redhat.com>,
	"Dhanoa, Kully" <kully.dhanoa@intel.com>
Subject: [virtio] Re: [PATCH v9 14/16] VIRTIO_F_NOTIFICATION_DATA: extra data to devices
Date: Wed, 7 Mar 2018 16:09:33 +0200	[thread overview]
Message-ID: <20180307155530-mutt-send-email-mst@kernel.org> (raw)
In-Reply-To: <20180307121158.34829f6b.cohuck@redhat.com>

On Wed, Mar 07, 2018 at 12:11:58PM +0100, Cornelia Huck wrote:
> On Thu, 1 Mar 2018 01:31:37 +0200
> "Michael S. Tsirkin" <mst@redhat.com> wrote:
> 
> > Motivation for the new feature is included in the text.
> > 
> > Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
> > ---
> >  content.tex      | 141 ++++++++++++++++++++++++++++++++++++++++++++++++++++---
> >  introduction.tex |   4 +-
> >  notifications.c  |   3 ++
> >  3 files changed, 140 insertions(+), 8 deletions(-)
> >  create mode 100644 notifications.c
> > 
> > diff --git a/content.tex b/content.tex
> > index c57a918..4261913 100644
> > --- a/content.tex
> > +++ b/content.tex
> > @@ -283,9 +283,77 @@ Packed Virtqueues}).
> >  Every driver and device supports either the Packed or the Split
> >  Virtqueue format, or both.
> >  
> > +\subsection{Driver notifications} \label{sec:Virtqueues / Driver notifications}
> > +Driver is sometimes required to notify the device after
> > +making changes to the virtqueue.
> > +
> > +When VIRTIO_F_NOTIFICATION_DATA has not been negotiated,
> > +this notification involves sending the
> > +virtqueue number to the device (depending on the transport).
> > +
> > +However, some devices benefit from ability to find out the number of
> > +available descriptors in the ring, and whether to send
> > +interrupts to drivers without accessing virtqueue in memory:
> > +for efficiency or as a debugging aid.
> > +
> > +To help with these optimizations, when VIRTIO_F_NOTIFICATION_DATA
> > +has been negotiated, driver notifications to the device include
> > +the following information:
> > +
> > +\begin{description}
> > +\item [VQ number]
> > +\item [Offset]
> > +      Within the ring where the next available ring entry
> > +      will be written.
> > +      Without VIRTIO_F_RING_PACKED this refers to the
> > +      15 least significant bits of the available index.
> > +      With VIRTIO_F_RING_PACKED this refers to the offset
> > +      (in units of descritor entries)
> > +      within the descriptor ring where the next available
> > +      descriptor will be written.
> > +\item [Wrap Counter]
> > +      With VIRTIO_F_RING_PACKED this is the wrap counter
> > +      referring to the next available descriptor.
> > +      Without VIRTIO_F_RING_PACKED this is the most significant bit
> > +      of the available index.
> > +\end{description}
> > +
> > +Note that driver can trigger multiple notifications even without
> > +making any more changes to the ring. When VIRTIO_F_NOTIFICATION_DATA
> > +has been negotiated, these notifications would then have
> > +identical \field{Offset} and \field{Wrap Counter} values.
> > +
> >  \input{split-ring.tex}
> >  
> >  \input{packed-ring.tex}
> > +
> > +\subsubsection{Driver notifications}
> > +
> > +\label{sec:Packed Virtqueues / Driver notifications}
> > +Whenever not suppressed by Device Event Suppression,
> > +driver is required to notify the device after
> > +making changes to the virtqueue.
> > +
> > +Some devices benefit from ability to find out the number of
> > +available descriptors in the ring, and whether to send
> > +interrupts to drivers without accessing virtqueue in memory:
> > +for efficiency or as a debugging aid.
> > +
> > +To help with these optimizations, driver notifications
> > +to the device include the following information:
> > +
> > +\begin{itemize}
> > +\item VQ number
> > +\item Offset (in units of descriptor size) within the ring
> > +      where the next available descriptor will be written
> > +\item Wrap Counter referring to the next available
> > +      descriptor
> > +\end{itemize}
> > +
> > +Note that driver can trigger multiple notifications even without
> > +making any more changes to the ring. These would then have
> > +identical \field{Offset} and \field{Wrap Counter} values.
> 
> Isn't that duplicating the information for the generic case?
> 
> (And if you wanted to specify something specific for the packed case,
> shouldn't it go into packed-ring.tex?)

Right. Cut-n-pasted twice. Will drop.


> > +
> >  \chapter{General Initialization And Device Operation}\label{sec:General Initialization And Device Operation}
> >  
> >  We start with an overview of device initialization, then expand on the
> 
> (...)
> 
> > +When VIRTIO_F_NOTIFICATION_DATA has been negotiated,
> > +the driver notifies the device by writing the following
> > +32-bit value to the Queue Notify address:
> > +\begin{lstlisting}
> > +le32 vqn : 16,
> > +     next_off : 15,
> > +     next_wrap : 1;
> 
> Don't we want to write this as
> 
> le32 vqn : 16;
> le32 next_off :15;
> le32 next_wrap : 1;
> 
> ?

Same thing in C, but would be more confusing IMHO since it will be up to
the reader to figure out which fields comprise the 32 bit integer.


> > +\end{lstlisting}
> > +
> > +See \ref{sec:Virtqueues / Driver notifications}~\nameref{sec:Virtqueues / Driver notifications}
> > +for the definition of the components.
> > +
> > +See \ref{sec:Virtio Transport Options / Virtio Over PCI Bus / PCI Device Layout / Notification capability} for how to calculate the
> > +Queue Notify address.
> >  
> >  \subsubsection{Virtqueue Interrupts From The Device}\label{sec:Virtio Transport Options / Virtio Over PCI Bus / PCI-specific Initialization And Device Operation / Virtqueue Interrupts From The Device}
> >  
> > @@ -1500,8 +1604,19 @@ All register values are organized as Little Endian.
> >    }
> >    \hline 
> >    \mmioreg{QueueNotify}{Queue notifier}{0x050}{W}{%
> > -    Writing a queue index to this register notifies the device that
> > -    there are new buffers to process in the queue.
> > +    Writing a value this register notifies the device that
> > +    there are new buffers to process in a queue.
> > +
> > +    When VIRTIO_F_NOTIFICATION_DATA has not been negotiated,
> > +    the value written is the queue index.
> > +
> > +    When VIRTIO_F_NOTIFICATION_DATA has been negotiated,
> > +    the value has the following format:
> > +
> > +    \lstinputlisting{notifications.c}
> 
> Doesn't mmio require this to be le explicitly?

Oops you are right. The Latex I guess I will have to share with PCI instead.

> > +
> > +    See \ref{sec:Virtqueues / Driver notifications}~\nameref{sec:Virtqueues / Driver notifications}
> > +    for the definition of the components.
> >    }
> >    \hline 
> >    \mmioreg{InterruptStatus}{Interrupt status}{0x60}{R}{%
> > @@ -2340,12 +2455,22 @@ GPR  &   Input Value     & Output Value \\
> >  \hline
> >    2   &  Subchannel ID    & Host Cookie  \\
> >  \hline
> > -  3   & Virtqueue number  &              \\
> > +  3   & Notification data &              \\
> >  \hline
> >    4   &   Host Cookie     &              \\
> >  \hline
> >  \end{tabular}
> >  
> > +When VIRTIO_F_NOTIFICATION_DATA has not been negotiated,
> > +the \field{Notification data} includes the Virtqueue number.
> > +
> > +When VIRTIO_F_NOTIFICATION_DATA has been negotiated,
> > +the value has the following format:
> > +\lstinputlisting{notifications.c}
> 
> And we probably want to make this be explicitly.

Are you sure?
I looked at s390 code and it just uses VQ index in native
endian-ness, so I kept this consistent.
No skin off my nose but pls let me know.

> > +
> > +See \ref{sec:Virtqueues / Driver notifications}~\nameref{sec:Virtqueues / Driver notifications}
> > +for the definition of the components.
> > +
> >  \devicenormative{\paragraph}{Guest->Host Notification}{Virtio Transport Options / Virtio over channel I/O / Device Operation / Guest->Host Notification}
> >  The device MUST ignore bits 0-31 (counting from the left) of GPR2.
> >  This aligns passing the subchannel ID with the way it is passed
> > @@ -5260,6 +5385,10 @@ Descriptors} and \ref{sec:Packed Virtqueues / Indirect Flag: Scatter-Gather Supp
> >    \item[VIRTIO_F_IN_ORDER(35)] This feature indicates
> >    that all buffers are used by the device in the same
> >    order in which they have been made available.
> > +  \item[VIRTIO_F_NOTIFICATION_DATA(36)] This feature indicates
> > +  that drivers pass extra data (besides identifying the Virtqueue)
> > +  in their device notifications.
> > +  See \ref{sec:Virtqueues / Driver notifications}~\nameref{sec:Virtqueues / Driver notifications}.
> >  \end{description}
> >  
> >  \drivernormative{\section}{Reserved Feature Bits}{Reserved Feature Bits}
> > diff --git a/introduction.tex b/introduction.tex
> > index 3cb7a70..d0b770e 100644
> > --- a/introduction.tex
> > +++ b/introduction.tex
> > @@ -163,8 +163,8 @@ from the least significant to the most significant bit.
> >  
> >  For example:
> >  \begin{lstlisting}
> > -be16 A : 15;
> > -be16 B : 1;
> > +be16 A : 15,
> > +     B : 1;
> 
> Why are you dropping the second be16?

To make it clearer these two fields are part of the same
integer, without need to count bits.

> >  \end{lstlisting}
> >  documents the value A stored in the low 15 bit of a 16 bit
> >  integer and the value B stored in the high bit of the 16 bit
> > diff --git a/notifications.c b/notifications.c
> > new file mode 100644
> > index 0000000..2ae96d4
> > --- /dev/null
> > +++ b/notifications.c
> > @@ -0,0 +1,3 @@
> > +u32 vqn : 16,
> > +    next_off : 15,
> > +    next_wrap : 1;
> 
> I'm wondering how useful the u32 notation is here.

It says vqn in low 16 bits of a 32 bit counter, so e.g.
on LE system byte 0 and on BE system byte 3.
Compare to 

be32 vqn : 16,
     next_off : 15,
     next_wrap : 1;

where we say it's in low 16 bits of a 32 bit BE integer,
so byte 3.

-- 
MST

---------------------------------------------------------------------
To unsubscribe from this mail list, you must leave the OASIS TC that 
generates this mail.  Follow this link to all your TCs in OASIS at:
https://www.oasis-open.org/apps/org/workgroup/portal/my_workgroups.php 


  reply	other threads:[~2018-03-07 14:09 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-28 23:31 [virtio] [PATCH v9 00/16] packed ring layout spec Michael S. Tsirkin
2018-02-28 23:31 ` [virtio] [PATCH v9 01/16] introduction: document bitfield notation Michael S. Tsirkin
2018-02-28 23:31 ` [virtio] [PATCH v9 02/16] content: move 1.0 queue format out to a separate section Michael S. Tsirkin
2018-02-28 23:31 ` [virtio] [PATCH v9 03/16] content: move ring text out to a separate file Michael S. Tsirkin
2018-02-28 23:31 ` [virtio] [PATCH v9 04/16] content: move virtqueue operation description Michael S. Tsirkin
2018-02-28 23:31 ` [virtio] [PATCH v9 05/16] content: len -> used length, used ring -> vq Michael S. Tsirkin
2018-02-28 23:31 ` [virtio] [PATCH v9 06/16] content: generalize transport ring part naming Michael S. Tsirkin
2018-02-28 23:31 ` [virtio] [PATCH v9 07/16] content: generalize rest of text Michael S. Tsirkin
2018-02-28 23:31 ` [virtio] [PATCH v9 08/16] split-ring: generalize text Michael S. Tsirkin
2018-03-07 11:00   ` [virtio] " Cornelia Huck
2018-03-09 22:56     ` Michael S. Tsirkin
2018-02-28 23:31 ` [virtio] [PATCH v9 09/16] split-ring: typo: aligment Michael S. Tsirkin
2018-03-07 10:56   ` [virtio] " Cornelia Huck
2018-02-28 23:31 ` [virtio] [PATCH v9 11/16] content: in-order buffer use Michael S. Tsirkin
2018-02-28 23:31 ` [virtio] [PATCH v9 10/16] packed virtqueues: more efficient virtqueue layout Michael S. Tsirkin
2018-03-07 13:47   ` [virtio] " Michael S. Tsirkin
2018-02-28 23:31 ` [virtio] [PATCH v9 12/16] packed-ring: add in order support Michael S. Tsirkin
2018-02-28 23:31 ` [virtio] [PATCH v9 13/16] split-ring: in order feature Michael S. Tsirkin
2018-02-28 23:31 ` [virtio] [PATCH v9 14/16] VIRTIO_F_NOTIFICATION_DATA: extra data to devices Michael S. Tsirkin
2018-03-07 11:11   ` [virtio] " Cornelia Huck
2018-03-07 14:09     ` Michael S. Tsirkin [this message]
2018-03-07 14:49       ` Cornelia Huck
2018-03-07 15:10         ` Michael S. Tsirkin
2018-03-07 15:13           ` Cornelia Huck
2018-03-07 16:05         ` Halil Pasic
2018-03-07 16:14           ` Cornelia Huck
2018-03-07 19:53             ` Michael S. Tsirkin
2018-03-08 13:03               ` [virtio] Re: [virtio-dev] " Halil Pasic
2018-03-08 16:19                 ` Michael S. Tsirkin
2018-03-09  8:16                   ` Cornelia Huck
2018-03-09 12:25                   ` Halil Pasic
2018-03-09 16:52                     ` Michael S. Tsirkin
2018-03-07 19:27           ` Michael S. Tsirkin
2018-02-28 23:31 ` [virtio] [PATCH v9 15/16] makediff: update to show diff from master Michael S. Tsirkin
2018-02-28 23:31 ` [virtio] [PATCH dont commit v9 16/16] REVISION: set to 1.1 packed wd09 Michael S. Tsirkin
2018-03-09 17:06 ` [virtio] Re: [PATCH v9 00/16] packed ring layout spec Michael S. Tsirkin

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=20180307155530-mutt-send-email-mst@kernel.org \
    --to=mst@redhat.com \
    --cc=cohuck@redhat.com \
    --cc=kully.dhanoa@intel.com \
    --cc=pasic@linux.vnet.ibm.com \
    --cc=stefanha@redhat.com \
    --cc=tiwei.bie@intel.com \
    --cc=virtio-dev@lists.oasis-open.org \
    --cc=virtio@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 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.