Discussion of the implementations of VIRTIO specification
 help / color / mirror / Atom feed
From: "Michael S. Tsirkin" <mst@redhat.com>
To: Tiwei Bie <tiwei.bie@intel.com>
Cc: virtio@lists.oasis-open.org, virtio-dev@lists.oasis-open.org,
	Cornelia Huck <cohuck@redhat.com>,
	Halil Pasic <pasic@linux.vnet.ibm.com>,
	Stefan Hajnoczi <stefanha@redhat.com>,
	"Dhanoa, Kully" <kully.dhanoa@intel.com>
Subject: [virtio] Re: [virtio-dev] Re: [PATCH v8 08/16] packed virtqueues: more efficient virtqueue layout
Date: Tue, 27 Feb 2018 22:17:17 +0200	[thread overview]
Message-ID: <20180227221208-mutt-send-email-mst@kernel.org> (raw)
In-Reply-To: <20180227014928.ujlres3uuw6rb6vu@debian>

On Tue, Feb 27, 2018 at 09:49:28AM +0800, Tiwei Bie wrote:
> On Mon, Feb 26, 2018 at 10:38:13PM +0200, Michael S. Tsirkin wrote:
> > On Mon, Feb 26, 2018 at 06:51:11PM +0800, Tiwei Bie wrote:
> > > On Sun, Feb 25, 2018 at 08:49:10PM +0200, Michael S. Tsirkin wrote:
> > > > On Sat, Feb 24, 2018 at 01:17:08PM +0800, Tiwei Bie wrote:
> > > > > On Fri, Feb 16, 2018 at 09:24:12AM +0200, Michael S. Tsirkin wrote:
> > > [...]
> > > > > > +\subsection{Event Suppression Structure Format}\label{sec:Basic
> > > > > > +Facilities of a Virtio Device / Packed Virtqueues / Event Suppression Structure
> > > > > > +Format}
> > > > > > +
> > > > > > +The following structure is used to reduce the number of
> > > > > > +notifications sent between driver and device.
> > > > > > +
> > > > > > +\begin{lstlisting}
> > > > > > +__le16 desc_event_off : 15; /* Descriptor Event Offset */
> > > > > > +int    desc_event_wrap : 1; /* Descriptor Event Wrap Counter */
> > > > > 
> > > > > Is this `int` a typo?
> > > > 
> > > > It's a single bit so I think it does not matter.
> > > > What type would you like me to use instead?
> > > 
> > > It looks a bit strange to use different types here, and
> > > that's why I asked. If there is no particular reason to
> > > use `int` here, maybe it's better to keep using __le16.
> > > 
> > > Besides, just for fun. For C language, I checked gcc and
> > > clang. It seems that `int desc_event_wrap:1;` is a signed
> > > type. So, e.g. `p->desc_event_wrap == 1` is always false.
> > > 
> > > Best regards,
> > > Tiwei Bie
> > 
> > I'll switch to u8 here, IMHO le16 for a single bit
> > is really confusing. There's no byte order for a single byte.
> 
> Sorry, I just realized that I misunderstood your point
> previously.. Just to double check, `desc_event_off` and
> `desc_event_wrap` are not in the same 2 bytes?
> 
> Previously I thought both of them are in the first 2
> bytes. As it said it's a structure, and the fields are
> defined in a way very similar to the bit field in C.
> 
> In C,
> 
> struct {
> 	__le16 desc_event_off : 15;
> 	int    desc_event_wrap : 1;
> 	__le16 desc_event_flags : 2;
> };
> 
> struct {
> 	__le16 desc_event_off : 15;
> 	__le16 desc_event_wrap : 1;
> 	__le16 desc_event_flags : 2;
> };
> 
> struct {
> 	__le16 desc_event_off : 15,
> 	       desc_event_wrap : 1;
> 	__le16 desc_event_flags : 2;
> };
> 
> All above means `desc_event_off` and `desc_event_wrap`
> are in the first 2 bytes. So I thought the `int` is a
> typo. And I thought they are in the first 2 bytes (which
> is little-endian).
>
> Best regards,
> Tiwei Bie

Yes but desc_event_wrap itself is completely within the
second byte. So the question of byte-order does not arise.

Right, and above is also identical to:

 struct {
 	__le16 desc_event_off : 15,
 	u8     desc_event_wrap : 1;
 	__le16 desc_event_flags : 2;
 };

introduction explains:

\item[u8, u16, u32, u64] An unsigned integer of the specified length in bits.

\item[le16, le32, le64] An unsigned integer of the specified length in bits,
in little-endian byte order.



> > 
> > > > 
> > > > > > +__le16 desc_event_flags : 2; /* Descriptor Event Flags */
> > > > > > +\end{lstlisting}
> > > [...]

---------------------------------------------------------------------
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-02-27 20:17 UTC|newest]

Thread overview: 45+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1518765602-8739-1-git-send-email-mst@redhat.com>
2018-02-16  7:21 ` [PATCH v8 01/16] content: move 1.0 queue format out to a separate section Michael S. Tsirkin
2018-02-16  7:21 ` [PATCH v8 02/16] content: move ring text out to a separate file Michael S. Tsirkin
2018-02-16  7:21 ` [PATCH v8 03/16] content: move virtqueue operation description Michael S. Tsirkin
2018-02-16  7:22 ` [PATCH v8 04/16] content: replace mentions of len with used length Michael S. Tsirkin
2018-02-16 16:35   ` [virtio] " Cornelia Huck
2018-02-16  7:22 ` [PATCH v8 05/16] content: generalize transport ring part naming Michael S. Tsirkin
2018-02-16  7:24 ` [PATCH v8 08/16] packed virtqueues: more efficient virtqueue layout Michael S. Tsirkin
2018-02-16 17:01   ` [virtio] " Cornelia Huck
2018-02-24  5:17   ` [virtio-dev] " Tiwei Bie
2018-02-25 18:49     ` [virtio] " Michael S. Tsirkin
2018-02-26 10:51       ` [virtio-dev] " Tiwei Bie
2018-02-26 20:38         ` [virtio] " Michael S. Tsirkin
2018-02-27  1:49           ` Tiwei Bie
2018-02-27 20:17             ` Michael S. Tsirkin [this message]
2018-02-28  9:19               ` Tiwei Bie
2018-02-28 15:20                 ` [virtio] " Michael S. Tsirkin
2018-02-28 16:09                   ` Cornelia Huck
2018-02-28 20:35             ` Michael S. Tsirkin
2018-02-26 17:19   ` [virtio] " Halil Pasic
2018-02-26 21:05     ` Michael S. Tsirkin
2018-02-27 10:23       ` [virtio-dev] " Jens Freimann
2018-02-27 11:29         ` [virtio] " Halil Pasic
2018-02-28 13:42           ` Jens Freimann
2018-02-28 13:59             ` [virtio] " Halil Pasic
2018-02-28 15:40               ` Michael S. Tsirkin
2018-02-28 16:29                 ` Halil Pasic
2018-02-28 22:03               ` Michael S. Tsirkin
2018-02-28 22:01           ` Michael S. Tsirkin
2018-02-27 11:53       ` [virtio] " Halil Pasic
2018-02-27 14:11         ` Michael S. Tsirkin
2018-02-27 17:03           ` Halil Pasic
2018-02-28 13:25             ` [virtio-dev] " Jens Freimann
2018-02-28 22:10             ` [virtio] " Michael S. Tsirkin
2018-02-16  7:24 ` [PATCH v8 09/16] content: in-order buffer use Michael S. Tsirkin
2018-02-16  7:25 ` [PATCH v8 10/16] packed-ring: add in order support Michael S. Tsirkin
2018-02-16  7:25 ` [PATCH v8 11/16] split-ring: in order feature Michael S. Tsirkin
2018-02-16  7:25 ` [PATCH v8 12/16] makediff: update to show diff from master Michael S. Tsirkin
2018-02-16 16:45   ` [virtio] " Cornelia Huck
2018-02-16  7:26 ` [PATCH v8 13/16] REVISION: set to 1.1 wd07 Michael S. Tsirkin
2018-02-16  7:26 ` [PATCH v8 14/16] VIRTIO_F_NOTIFICATION_DATA: extra data to devices Michael S. Tsirkin
2018-02-16 17:00   ` [virtio] " Cornelia Huck
2018-02-16  7:26 ` [PATCH v8 15/16] conformance: link the new conformance clause Michael S. Tsirkin
2018-02-16 16:46   ` [virtio] " Cornelia Huck
2018-02-16  7:27 ` [PATCH v8 16/16] REVISION: set for packed-wd07.pdf Michael S. Tsirkin
2018-02-16 16:47   ` [virtio] " Cornelia Huck

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=20180227221208-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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox