From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 3BD7EA04F1; Wed, 11 Dec 2019 03:48:46 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 9667023D; Wed, 11 Dec 2019 03:48:45 +0100 (CET) Received: from alln-iport-3.cisco.com (alln-iport-3.cisco.com [173.37.142.90]) by dpdk.org (Postfix) with ESMTP id A00681F5 for ; Wed, 11 Dec 2019 03:48:43 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=cisco.com; i=@cisco.com; l=1420; q=dns/txt; s=iport; t=1576032523; x=1577242123; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=Ggn4J8Lm0siOIvfl7VF/TVUCDfEuiEPYoUyk22T2enc=; b=M62UmyAdaTt0MdpxtLXGd5XDwRZpiIDeO1YlzMUYtXAmQk/LNzMoT1s9 av4hf+vyoL+7tS/rZzZeYpz65UdyvvTcOGffwGFJciyVnLauPAbsxivWh OXzyk6R/FO10Ls+/1poMFv5HWLtD/5/Mer2lMxyo3M7G4MryFgi5BnE0p o=; X-IronPort-AV: E=Sophos;i="5.69,164,1571702400"; d="scan'208";a="398951033" Received: from rcdn-core-4.cisco.com ([173.37.93.155]) by alln-iport-3.cisco.com with ESMTP/TLS/DHE-RSA-SEED-SHA; 11 Dec 2019 02:48:42 +0000 Received: from cpp-rtpbld-31.cisco.com (cpp-rtpbld-31.cisco.com [172.18.5.114]) by rcdn-core-4.cisco.com (8.15.2/8.15.2) with ESMTP id xBB2mgZL029683; Wed, 11 Dec 2019 02:48:42 GMT Received: by cpp-rtpbld-31.cisco.com (Postfix, from userid 140087) id 2A4F3C50; Tue, 10 Dec 2019 21:48:42 -0500 (EST) From: David Harton To: dev@dpdk.org, wenzhuo.lu@intel.com Cc: David Harton Date: Tue, 10 Dec 2019 21:48:02 -0500 Message-Id: <20191211024802.17978-1-dharton@cisco.com> X-Mailer: git-send-email 2.19.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Outbound-SMTP-Client: 172.18.5.114, cpp-rtpbld-31.cisco.com X-Outbound-Node: rcdn-core-4.cisco.com Subject: [dpdk-dev] [PATCH] net/e1000: update UPDATE_VF_STAT to handle rollover X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Modified UPDATE_VF_STAT to properly handle rollover conditions. Signed-off-by: David Harton --- drivers/net/e1000/igb_ethdev.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/drivers/net/e1000/igb_ethdev.c b/drivers/net/e1000/igb_ethdev.c index a3e30dbe5..825663267 100644 --- a/drivers/net/e1000/igb_ethdev.c +++ b/drivers/net/e1000/igb_ethdev.c @@ -261,11 +261,15 @@ static int igb_filter_restore(struct rte_eth_dev *dev); /* * Define VF Stats MACRO for Non "cleared on read" register */ -#define UPDATE_VF_STAT(reg, last, cur) \ -{ \ - u32 latest = E1000_READ_REG(hw, reg); \ - cur += (latest - last) & UINT_MAX; \ - last = latest; \ +#define UPDATE_VF_STAT(reg, last, cur) \ +{ \ + u32 latest = E1000_READ_REG(hw, reg); \ + if (latest >= last) \ + cur += (latest - last); \ + else \ + cur += ((latest + ((uint64_t)1 << 32)) - last); \ + cur &= UINT_MAX; \ + last = latest; \ } #define IGB_FC_PAUSE_TIME 0x0680 -- 2.19.1