From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:32867) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c4mld-00020J-FE for qemu-devel@nongnu.org; Thu, 10 Nov 2016 05:39:42 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1c4mlZ-0005Nq-Ie for qemu-devel@nongnu.org; Thu, 10 Nov 2016 05:39:37 -0500 Received: from mail-wm0-x241.google.com ([2a00:1450:400c:c09::241]:36784) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1c4mlZ-0005Mb-Bs for qemu-devel@nongnu.org; Thu, 10 Nov 2016 05:39:33 -0500 Received: by mail-wm0-x241.google.com with SMTP id m203so574422wma.3 for ; Thu, 10 Nov 2016 02:39:32 -0800 (PST) Date: Thu, 10 Nov 2016 10:32:53 +0000 From: Stefan Hajnoczi Message-ID: <20161110103253.GC17332@stefanha-x1.localdomain> References: <201611051850530152761@gmail.com> <201611091858142738325@gmail.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="Qbvjkv9qwOGw/5Fx" Content-Disposition: inline In-Reply-To: <201611091858142738325@gmail.com> Subject: Re: [Qemu-devel] virtIO question List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "zhunxun@gmail.com" Cc: jkhasdev , qemu --Qbvjkv9qwOGw/5Fx Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable 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_sg= s and out_sgs,for example,send_queue of virtIO net driver have in_sgs and o= ut_sgs=EF=BC=8Cwhen transmit data,It add buffer to out_sgs of send_queue,bu= t 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. --Qbvjkv9qwOGw/5Fx Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEcBAEBAgAGBQJYJEzVAAoJEJykq7OBq3PIda4H/1R5JK8Yf9eEP7gj7bSYmorU hZQ7U9XnpRo/fz+Oy00zELCoFtKm0tCGFjZHHcnH/Enty9/G9yXRsmGLgCVyWCZE QKo+KMxkmEwIT3q1gRdbUmeovrV3knBt47ieDYEb5x+VxGtKQlVDPE+DRDkkateW y3XNIMWyItACcCYhNHF8GKCgGfNfxPZgpZUutndjbqRYud7IogySepXNtU6wjRty 48p/UxdbA0Cv5t4M+KXwfZ/hgmdn87cqJs+hi0Wk86BscaFz4nqeV/7eDVVw3YaQ ThIP2RDGqRIm5IEEtk+erljHss8ndFHmAdLmXQinXXw+XP2C6bnEMNGJdhS02Bo= =pLKr -----END PGP SIGNATURE----- --Qbvjkv9qwOGw/5Fx--