From patchwork Wed Dec 5 18:31:30 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Contreras X-Patchwork-Id: 203921 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id DD5552C00BA for ; Thu, 6 Dec 2012 05:32:56 +1100 (EST) Received: from localhost ([::1]:34932 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TgJm6-0001Jc-Rh for incoming@patchwork.ozlabs.org; Wed, 05 Dec 2012 13:32:50 -0500 Received: from eggs.gnu.org ([208.118.235.92]:42838) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TgJlz-0001IS-4D for qemu-devel@nongnu.org; Wed, 05 Dec 2012 13:32:45 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TgJlx-00014H-SL for qemu-devel@nongnu.org; Wed, 05 Dec 2012 13:32:42 -0500 Received: from 70-88-178-169-atlanta.hfc.comcastbusiness.net ([70.88.178.169]:32808 helo=mail.inetric.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TgJlw-000140-MS for qemu-devel@nongnu.org; Wed, 05 Dec 2012 13:32:41 -0500 Received: from web0.inetric.com (localhost [127.0.0.1]) by mail.inetric.com (8.14.4/8.14.4) with ESMTP id qB5IVVVk026253 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 5 Dec 2012 13:31:31 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=inetric.com; s=inetric; t=1354732291; bh=nvhLQa4EzEjtHmJsXTuV1UXAZj8BAwJY0mZfDIo9Rmk=; h=Date:From:To:Cc:Subject:Message-ID:MIME-Version:Content-Type: In-Reply-To; b=KGEVJwp5FuhxxQ60vbDA5sKJV+iUYvE+d7rfWParvYI+sfiFfkX6H/jVCqWm7YITE xKtneLWvSR3Dilp9wJ+2q/KpefiSu45AF27LcM2M1Sc82GhFoguvLerP/FObKMWmrG /asNtiZKtlmPCHdg9ZK7yTPLOx8cUEuQwsY7lDYQ= Received: (from michael@localhost) by web0.inetric.com (8.14.4/8.14.4/Submit) id qB5IVVqc026252; Wed, 5 Dec 2012 13:31:31 -0500 Date: Wed, 5 Dec 2012 13:31:30 -0500 From: Michael Contreras To: qemu-devel@nongnu.org Message-ID: <20121205183130.GA26052@inetric.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20121205121317.GC6887@stefanha-thinkpad.redhat.com> User-Agent: Mutt/1.5.20 (2009-12-10) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 70.88.178.169 Cc: Michael Contreras , Stefan Hajnoczi , Andreas Faerber , Anthony Liguori Subject: [Qemu-devel] [PATCH] e1000: Discard oversized packets based on SBP|LPE X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Discard packets longer than 16384 when !SBP to match the hardware behavior. Signed-off-by: Michael Contreras --- hw/e1000.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/hw/e1000.c b/hw/e1000.c index 5537ad2..e772c8e 100644 --- a/hw/e1000.c +++ b/hw/e1000.c @@ -61,6 +61,8 @@ static int debugflags = DBGBIT(TXERR) | DBGBIT(GENERAL); /* this is the size past which hardware will drop packets when setting LPE=0 */ #define MAXIMUM_ETHERNET_VLAN_SIZE 1522 +/* this is the size past which hardware will drop packets when setting LPE=1 */ +#define MAXIMUM_ETHERNET_LPE_SIZE 16384 /* * HW models: @@ -809,8 +811,9 @@ e1000_receive(NetClientState *nc, const uint8_t *buf, size_t size) } /* Discard oversized packets if !LPE and !SBP. */ - if (size > MAXIMUM_ETHERNET_VLAN_SIZE - && !(s->mac_reg[RCTL] & E1000_RCTL_LPE) + if ((size > MAXIMUM_ETHERNET_LPE_SIZE || + (size > MAXIMUM_ETHERNET_VLAN_SIZE + && !(s->mac_reg[RCTL] & E1000_RCTL_LPE))) && !(s->mac_reg[RCTL] & E1000_RCTL_SBP)) { return size; }