From patchwork Mon Nov 9 14:59:27 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leonid Bloch X-Patchwork-Id: 541793 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 EE1F81409F8 for ; Tue, 10 Nov 2015 02:03:00 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=ravellosystems_com.20150623.gappssmtp.com header.i=@ravellosystems_com.20150623.gappssmtp.com header.b=GCKZeR3w; dkim-atps=neutral Received: from localhost ([::1]:53279 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZvnyF-0002RU-4W for incoming@patchwork.ozlabs.org; Mon, 09 Nov 2015 10:02:59 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45201) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zvnvi-0006pO-SD for qemu-devel@nongnu.org; Mon, 09 Nov 2015 10:00:27 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zvnvf-0007FI-2E for qemu-devel@nongnu.org; Mon, 09 Nov 2015 10:00:22 -0500 Received: from mail-wm0-x232.google.com ([2a00:1450:400c:c09::232]:36699) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zvnve-0007F3-Sj for qemu-devel@nongnu.org; Mon, 09 Nov 2015 10:00:18 -0500 Received: by wmww144 with SMTP id w144so79782177wmw.1 for ; Mon, 09 Nov 2015 07:00:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ravellosystems_com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=pOrWDCRLIZkGN0pzbopA3nsnaNtXciptPjt7lDQcN6E=; b=GCKZeR3w/xojyA0xPL2fzmO0glEqtRww+bzbKuDo86PTGPDDG+BQLGkugoYc1Vx+Np mlBZvePtWSfTRP+GaPOUVxdyuDreYdia19oRubjtVFWhXM1wfbEyynsXEgCWlOJnBQg7 m0k3lUcRssHy0BY3Wh5AExW3k0RiZTMa9VXvj+mF4uVCFKY9EGZ+oTZBYIb26XLPGp/Y A4wTgw0sTfrdHL0OdeEyayG9TYDbvdXALt9NMmHDwwnwc3CvYiXKmMsPjA0cB+sVnFUI TbaHRnthunhfqZZ3WPCd3LR1qCCqqakXRrfpergi7oGsz2wySLUpo+xC+rnYxNSWVUFK XDtA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=pOrWDCRLIZkGN0pzbopA3nsnaNtXciptPjt7lDQcN6E=; b=P+vo+jkWzcjhG3kXizzS3Wzg1HB8ZvskNzCxviS1soGrcjXWClmS5FGhpWpe8NwJrL TznaMGKldwWhEVg8GCqLWpJA5HtX4RPty0rrGmCrwz91W4rjg/ZyHqigqcjKTCJ1e4TA k6n8Y46+Hsiq/hSrPJV8RAQ52ozjZn/uiyzI4oVYHVbsk7mxgj5NNZHWD+3V2Ce8m3Gc ARrjh8h40s/MtOqRcjlK+pd8zuR7VKmgYjs5UvUwmAOQjHcvbSONo1ZJRvyolEsq+9ba hFiawYpZoqmXPndwBra+TYYdDh6eEDLbCjMYf2r1BLMX05wyEHaNmvQYdIzvGFuDsVO2 ylaA== X-Gm-Message-State: ALoCoQniLHy0mQXGr9/pY/T826t3bFoxOsASKjZ0vEO6HXhbfQdDKbbKWInNUc4CImDdpDwM7o0T X-Received: by 10.194.201.202 with SMTP id kc10mr34941011wjc.84.1447081217921; Mon, 09 Nov 2015 07:00:17 -0800 (PST) Received: from bark.daynix ([5.102.236.99]) by smtp.gmail.com with ESMTPSA id it4sm15895100wjb.0.2015.11.09.07.00.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 09 Nov 2015 07:00:16 -0800 (PST) From: Leonid Bloch To: qemu-devel@nongnu.org Date: Mon, 9 Nov 2015 16:59:27 +0200 Message-Id: <1447081170-11614-6-git-send-email-leonid.bloch@ravellosystems.com> X-Mailer: git-send-email 2.4.3 In-Reply-To: <1447081170-11614-1-git-send-email-leonid.bloch@ravellosystems.com> References: <1447081170-11614-1-git-send-email-leonid.bloch@ravellosystems.com> X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:400c:c09::232 Cc: Dmitry Fleytman , Jason Wang , Leonid Bloch , Shmulik Ladkani Subject: [Qemu-devel] [PATCH v5 5/8] 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 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 --- 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 28fa59c..c301637 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.