All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stefan Hajnoczi <stefanha@gmail.com>
To: "zhunxun@gmail.com" <zhunxun@gmail.com>
Cc: jkhasdev <jkhasdev@gmail.com>, qemu <qemu-devel@nongnu.org>
Subject: Re: [Qemu-devel] virtIO question
Date: Thu, 10 Nov 2016 10:32:53 +0000	[thread overview]
Message-ID: <20161110103253.GC17332@stefanha-x1.localdomain> (raw)
In-Reply-To: <201611091858142738325@gmail.com>

[-- Attachment #1: Type: text/plain, Size: 1327 bytes --]

On Wed, Nov 09, 2016 at 06:58:16PM +0800, zhunxun@gmail.com wrote:
> I want to ask a another question,why a virt_queue in virtio include in_sgs and out_sgs,for example,send_queue of virtIO net driver have in_sgs and out_sgs,when transmit data,It add buffer to out_sgs of send_queue,but how it to use in_sgs??

You can think of every virtqueue buffer as having two scatter-gather
lists:
1. out_sgs are driver->device buffers (e.g. tx packet payload)
2. in_sgs are device->driver buffers (e.g. rx packet payload)

Look at the virtio-net ctrl virtqueue (see spec and
virtio_net_handle_ctrl() for details).  Each buffer has:

1. struct virtio_net_ctrl_hdr (out_sgs)
2. request-specific fields (out_sgs)
3. virtio_net_ctrl_ack status byte (in_sgs)

The device parses the request and performs the operation.  Then it fills
in the result (success or error code) in the status byte.

Processing ctrl virtqueue buffers therefore requires both guest memory
reads (out_sgs) and writes (in_sgs).  Most of the other virtio devices
also use bi-directional buffers.

This may not be obvious if you only consider the virtio-net tx
virtqueue, for example, where buffers use out_sgs only.

Hope this makes sense.  If not, look at the specification again and
think about how virtio-net ctrl request processing works.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 455 bytes --]

  reply	other threads:[~2016-11-10 10:39 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-05 10:50 [Qemu-devel] virtIO question zhunxun
2016-11-05 14:46 ` jitendra kumar khasdev
2016-11-05 15:04   ` Peter Maydell
2016-11-05 15:11     ` jitendra kumar khasdev
2016-11-09 10:58       ` zhunxun
2016-11-10 10:32         ` Stefan Hajnoczi [this message]
2016-11-10 12:16           ` zhunxun
2016-11-11 12:03             ` Stefan Hajnoczi
2016-11-12  8:43               ` zhunxun
2016-11-14 14:06                 ` Stefan Hajnoczi
2016-11-14  7:14               ` zhunxun
2016-11-05 15:23 jack
2016-11-11 14:17 jack
2016-11-14 12:36 zhunxun
2016-11-14 16:36 ` Stefan Hajnoczi

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=20161110103253.GC17332@stefanha-x1.localdomain \
    --to=stefanha@gmail.com \
    --cc=jkhasdev@gmail.com \
    --cc=qemu-devel@nongnu.org \
    --cc=zhunxun@gmail.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.