From patchwork Mon Jul 12 17:49:45 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 58637 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 6102AB6EF3 for ; Tue, 13 Jul 2010 03:56:19 +1000 (EST) Received: from localhost ([127.0.0.1]:40007 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OYNEm-00047W-Qo for incoming@patchwork.ozlabs.org; Mon, 12 Jul 2010 13:56:16 -0400 Received: from [140.186.70.92] (port=36415 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OYNDa-0003vl-Sn for qemu-devel@nongnu.org; Mon, 12 Jul 2010 13:55:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OYNDZ-0007xI-MT for qemu-devel@nongnu.org; Mon, 12 Jul 2010 13:55:02 -0400 Received: from mx1.redhat.com ([209.132.183.28]:11506) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OYNDZ-0007ww-FL for qemu-devel@nongnu.org; Mon, 12 Jul 2010 13:55:01 -0400 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.13.8/8.13.8) with ESMTP id o6CHsxcM012700 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 12 Jul 2010 13:54:59 -0400 Received: from redhat.com (vpn-6-140.tlv.redhat.com [10.35.6.140]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with SMTP id o6CHsv9q010972; Mon, 12 Jul 2010 13:54:58 -0400 Date: Mon, 12 Jul 2010 20:49:45 +0300 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org, Anthony Liguori , alex.williamson@redhat.com Message-ID: <20100712174945.GA11440@redhat.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-12-10) X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. Cc: Subject: [Qemu-devel] [PATCH RFC] e1000: secrc support 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 Add support for secrc field. Reportedly needed by old RHEL guests. Signed-off-by: Michael S. Tsirkin Acked-by: Alex Williamson --- hw/e1000.c | 11 ++++++++++- 1 files changed, 10 insertions(+), 1 deletions(-) Anthony, Alex, please review. diff --git a/hw/e1000.c b/hw/e1000.c index 70aba11..8d87492 100644 --- a/hw/e1000.c +++ b/hw/e1000.c @@ -344,6 +344,15 @@ is_vlan_txd(uint32_t txd_lower) return ((txd_lower & E1000_TXD_CMD_VLE) != 0); } +/* FCS aka Ethernet CRC-32. We don't get it from backends and can't + * fill it in, just pad descriptor length by 4 bytes unless guest + * told us to trip it off the packet. */ +static inline int +fcs_len(E1000State *s) +{ + return (s->mac_reg[RCTL] & E1000_RCTL_SECRC) ? 0 : 4; +} + static void xmit_seg(E1000State *s) { @@ -662,7 +671,7 @@ e1000_receive(VLANClientState *nc, const uint8_t *buf, size_t size) if (desc.buffer_addr) { cpu_physical_memory_write(le64_to_cpu(desc.buffer_addr), (void *)(buf + vlan_offset), size); - desc.length = cpu_to_le16(size + 4 /* for FCS */); + desc.length = cpu_to_le16(size + fcs_len(s)); desc.status |= E1000_RXD_STAT_EOP|E1000_RXD_STAT_IXSM; } else // as per intel docs; skip descriptors with null buf addr DBGOUT(RX, "Null RX descriptor!!\n");