From patchwork Thu Nov 12 08:32:24 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Wang X-Patchwork-Id: 543275 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4095E1413F0 for ; Thu, 12 Nov 2015 19:37:08 +1100 (AEDT) Received: from localhost ([::1]:45233 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZwnNS-0007Qt-AM for incoming@patchwork.ozlabs.org; Thu, 12 Nov 2015 03:37:06 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36617) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZwnJj-0000hZ-8b for qemu-devel@nongnu.org; Thu, 12 Nov 2015 03:33:16 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZwnJf-0001qB-8f for qemu-devel@nongnu.org; Thu, 12 Nov 2015 03:33:15 -0500 Received: from mx1.redhat.com ([209.132.183.28]:35580) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZwnJf-0001pr-4A for qemu-devel@nongnu.org; Thu, 12 Nov 2015 03:33:11 -0500 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id D2B938E901; Thu, 12 Nov 2015 08:33:10 +0000 (UTC) Received: from jason-ThinkPad-T430s.nay.redhat.com (dhcp-14-168.nay.redhat.com [10.66.14.168]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id tAC8WWl1029417; Thu, 12 Nov 2015 03:33:05 -0500 From: Jason Wang To: peter.maydell@linaro.org, qemu-devel@nongnu.org Date: Thu, 12 Nov 2015 16:32:24 +0800 Message-Id: <1447317150-31076-7-git-send-email-jasowang@redhat.com> In-Reply-To: <1447317150-31076-1-git-send-email-jasowang@redhat.com> References: <1447317150-31076-1-git-send-email-jasowang@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Leonid Bloch , Jason Wang , Dmitry Fleytman Subject: [Qemu-devel] [PULL v2 06/12] e1000: Fixing the received/transmitted packets' counters 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 From: Leonid Bloch According to Intel's specs, these counters (as the other Statistic registers) stick at 0xffffffff when this maximal value is reached. Previously, they would reset after the max. value. Signed-off-by: Leonid Bloch Signed-off-by: Dmitry Fleytman Signed-off-by: Jason Wang --- hw/net/e1000.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/hw/net/e1000.c b/hw/net/e1000.c index 767490c..57a61f6 100644 --- a/hw/net/e1000.c +++ b/hw/net/e1000.c @@ -580,6 +580,14 @@ putsum(uint8_t *data, uint32_t n, uint32_t sloc, uint32_t css, uint32_t cse) } } +static inline void +inc_reg_if_not_full(E1000State *s, int index) +{ + if (s->mac_reg[index] != 0xffffffff) { + s->mac_reg[index]++; + } +} + static inline int vlan_enabled(E1000State *s) { @@ -677,8 +685,8 @@ xmit_seg(E1000State *s) e1000_send_packet(s, tp->data, tp->size); } - s->mac_reg[TPT]++; - s->mac_reg[GPTC]++; + inc_reg_if_not_full(s, TPT); + s->mac_reg[GPTC] = s->mac_reg[TPT]; n = s->mac_reg[TOTL]; if ((s->mac_reg[TOTL] += s->tx.size) < n) s->mac_reg[TOTH]++; @@ -1091,8 +1099,8 @@ e1000_receive_iov(NetClientState *nc, const struct iovec *iov, int iovcnt) } } while (desc_offset < total_size); - s->mac_reg[GPRC]++; - s->mac_reg[TPR]++; + inc_reg_if_not_full(s, TPR); + s->mac_reg[GPRC] = s->mac_reg[TPR]; /* TOR - Total Octets Received: * This register includes bytes received in a packet from the field through the field, inclusively.