From patchwork Tue Feb 15 16:27:52 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 83268 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 84E12B70AB for ; Wed, 16 Feb 2011 03:29:44 +1100 (EST) Received: from localhost ([127.0.0.1]:49563 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PpNmX-0006OB-Te for incoming@patchwork.ozlabs.org; Tue, 15 Feb 2011 11:29:41 -0500 Received: from [140.186.70.92] (port=33645 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PpNlK-0006L2-Kh for qemu-devel@nongnu.org; Tue, 15 Feb 2011 11:28:28 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PpNlI-00076n-Vx for qemu-devel@nongnu.org; Tue, 15 Feb 2011 11:28:26 -0500 Received: from mx1.redhat.com ([209.132.183.28]:29744) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PpNlI-00076G-Nh for qemu-devel@nongnu.org; Tue, 15 Feb 2011 11:28:24 -0500 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p1FGSJuW006903 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 15 Feb 2011 11:28:20 -0500 Received: from redhat.com (vpn-200-13.tlv.redhat.com [10.35.200.13]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id p1FGSHVi004355; Tue, 15 Feb 2011 11:28:17 -0500 Date: Tue, 15 Feb 2011 18:27:52 +0200 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org, Anthony Liguori Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mutt-Fcc: =sent User-Agent: Mutt/1.5.21 (2010-09-15) X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11 X-MIME-Autoconverted: from 8bit to quoted-printable by mx1.redhat.com id p1FGSJuW006903 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, Jes.Sorensen@redhat.com, Alex Williamson , agraf@suse.de, stefanha@linux.vnet.ibm.com Subject: [Qemu-devel] [PATCHv2 2/3] e1000: clear EOP for multi-buffer descriptors X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org The e1000 spec says: if software statically allocates buffers, and uses memory read to check for completed descriptors, it simply has to zero the status byte in the descriptor to make it ready for reuse by hardware. This is not a hardware requirement (moving the hardware tail pointer is), but is necessary for performing an in–memory scan. Thus the guest does not have to clear the status byte. In case it doesn't we need to clear EOP for all descriptors except the last. While I don't know of any such guests, it's probably a good idea to stick to the spec. Signed-off-by: Michael S. Tsirkin Reported-by: Juan Quintela --- hw/e1000.c | 6 ++++-- 1 files changed, 4 insertions(+), 2 deletions(-) diff --git a/hw/e1000.c b/hw/e1000.c index 050ce02..2943a1a 100644 --- a/hw/e1000.c +++ b/hw/e1000.c @@ -698,11 +698,13 @@ e1000_receive(VLANClientState *nc, const uint8_t *buf, size_t size) copy_size); } desc_offset += desc_size; + desc.length = cpu_to_le16(desc_size); if (desc_offset >= total_size) { - desc.length = cpu_to_le16(desc_size); desc.status |= E1000_RXD_STAT_EOP | E1000_RXD_STAT_IXSM; } else { - desc.length = cpu_to_le16(desc_size); + /* Guest zeroing out status is not a hardware requirement. + Clear EOP in case guest didn't do it. */ + desc.status &= ~E1000_RXD_STAT_EOP; } } else { // as per intel docs; skip descriptors with null buf addr DBGOUT(RX, "Null RX descriptor!!\n");