From patchwork Fri Jun 17 01:33:52 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wen Congyang X-Patchwork-Id: 100751 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id E5BB4B6F7E for ; Fri, 17 Jun 2011 11:39:17 +1000 (EST) Received: from localhost ([::1]:45819 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QXO1g-0005qQ-EV for incoming@patchwork.ozlabs.org; Thu, 16 Jun 2011 21:39:12 -0400 Received: from eggs.gnu.org ([140.186.70.92]:44015) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QXNz0-0005q2-Lq for qemu-devel@nongnu.org; Thu, 16 Jun 2011 21:36:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QXNyy-00034F-12 for qemu-devel@nongnu.org; Thu, 16 Jun 2011 21:36:26 -0400 Received: from [222.73.24.84] (port=59234 helo=song.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QXNyx-00033X-6u for qemu-devel@nongnu.org; Thu, 16 Jun 2011 21:36:23 -0400 Received: from tang.cn.fujitsu.com (tang.cn.fujitsu.com [10.167.250.3]) by song.cn.fujitsu.com (Postfix) with ESMTP id 2631117011F; Fri, 17 Jun 2011 09:36:11 +0800 (CST) Received: from mailserver.fnst.cn.fujitsu.com (tang.cn.fujitsu.com [127.0.0.1]) by tang.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id p5H1a9RP003013; Fri, 17 Jun 2011 09:36:09 +0800 Received: from [10.167.225.226] ([10.167.225.226]) by mailserver.fnst.cn.fujitsu.com (Lotus Domino Release 8.5.1FP4) with ESMTP id 2011061709355028-595794 ; Fri, 17 Jun 2011 09:35:50 +0800 Message-ID: <4DFAAF00.900@cn.fujitsu.com> Date: Fri, 17 Jun 2011 09:33:52 +0800 From: Wen Congyang User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.9) Gecko/20100413 Fedora/3.0.4-2.fc13 Thunderbird/3.0.4 MIME-Version: 1.0 To: "Michael S. Tsirkin" , Kevin Wolf , Aurelien Jarno , qemu-devel References: <4DF9BD9C.1060307@cn.fujitsu.com> <4DF9DD77.5040401@redhat.com> <20110616124651.GD14583@redhat.com> In-Reply-To: <20110616124651.GD14583@redhat.com> X-MIMETrack: Itemize by SMTP Server on mailserver/fnst(Release 8.5.1FP4|July 25, 2010) at 2011-06-17 09:35:50, Serialize by Router on mailserver/fnst(Release 8.5.1FP4|July 25, 2010) at 2011-06-17 09:35:51, Serialize complete at 2011-06-17 09:35:51 X-detected-operating-system: by eggs.gnu.org: FreeBSD 6.x (1) X-Received-From: 222.73.24.84 Subject: [Qemu-devel] [PATCH] do not send packet to nic if the packet will be dropped by nic 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 If !s->clock_enabled or !rtl8139_receiver_enabled(s), it means that the nic will drop all packets from host. So qemu will keep getting packets from host and wasting CPU on dropping packets. This seems worse than packets that should be dropped but aren't. Signed-off-by: Wen Congyang --- hw/rtl8139.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) -- 1.7.1 diff --git a/hw/rtl8139.c b/hw/rtl8139.c index 2f8db58..9084678 100644 --- a/hw/rtl8139.c +++ b/hw/rtl8139.c @@ -810,9 +810,9 @@ static int rtl8139_can_receive(VLANClientState *nc) /* Receive (drop) packets if card is disabled. */ if (!s->clock_enabled) - return 1; + return 0; if (!rtl8139_receiver_enabled(s)) - return 1; + return 0; if (rtl8139_cp_receiver_enabled(s)) { /* ??? Flow control not implemented in c+ mode.