From patchwork Mon Feb 7 12:30:26 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: 82183 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 0B0C7B70E3 for ; Tue, 8 Feb 2011 09:31:20 +1100 (EST) Received: from localhost ([127.0.0.1]:59963 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PmQGm-0007ot-Oa for incoming@patchwork.ozlabs.org; Mon, 07 Feb 2011 07:32:40 -0500 Received: from [140.186.70.92] (port=60253 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PmQF2-0006hx-KO for qemu-devel@nongnu.org; Mon, 07 Feb 2011 07:30:53 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PmQF1-0006Fd-3Q for qemu-devel@nongnu.org; Mon, 07 Feb 2011 07:30:52 -0500 Received: from mx1.redhat.com ([209.132.183.28]:50401) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PmQF0-0006F8-SC for qemu-devel@nongnu.org; Mon, 07 Feb 2011 07:30:51 -0500 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p17CUdEo030227 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 7 Feb 2011 07:30:39 -0500 Received: from redhat.com (vpn-200-1.tlv.redhat.com [10.35.200.1]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id p17CUZ9P015392; Mon, 7 Feb 2011 07:30:36 -0500 Date: Mon, 7 Feb 2011 14:30:26 +0200 From: "Michael S. Tsirkin" To: agraf@suse.de, Jes.Sorensen@redhat.com, Alex Williamson , stefanha@linux.vnet.ibm.com, Juan Quintela Message-ID: <20110207123026.GA18830@redhat.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-MIME-Autoconverted: from 8bit to quoted-printable by mx1.redhat.com id p17CUdEo030227 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.132.183.28 Cc: qemu-devel@nongnu.org Subject: [Qemu-devel] [PATCH] 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 reviewed-by: Juan Quintela Reviewed-by: Stefan Hajnoczi --- hw/e1000.c | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-) diff --git a/hw/e1000.c b/hw/e1000.c index 3427ff3..7853c12 100644 --- a/hw/e1000.c +++ b/hw/e1000.c @@ -694,6 +694,9 @@ e1000_receive(VLANClientState *nc, const uint8_t *buf, size_t size) desc.length = cpu_to_le16(desc_size + fcs_len(s)); desc.status |= E1000_RXD_STAT_EOP | E1000_RXD_STAT_IXSM; } else { + /* Guest zeroing out status is not a hardware requirement. + Clear EOP in case guest didn't do it. */ + desc.status &= ~E1000_RXD_STAT_EOP; desc.length = cpu_to_le16(desc_size); } } else { // as per intel docs; skip descriptors with null buf addr