From patchwork Fri Jun 17 01:33:52 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: do not send packet to nic if the packet will be dropped by nic Date: Thu, 16 Jun 2011 15:33:52 -0000 From: Wen Congyang X-Patchwork-Id: 100751 Message-Id: <4DFAAF00.900@cn.fujitsu.com> To: "Michael S. Tsirkin" , Kevin Wolf , Aurelien Jarno , qemu-devel 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.