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 A2B32A052F; Sun, 26 Jan 2020 18:25:57 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id E203F493D; Sun, 26 Jan 2020 18:25:56 +0100 (CET) Received: from rcdn-iport-3.cisco.com (rcdn-iport-3.cisco.com [173.37.86.74]) by dpdk.org (Postfix) with ESMTP id 513E51B53 for ; Sun, 26 Jan 2020 18:25:56 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=cisco.com; i=@cisco.com; l=1482; q=dns/txt; s=iport; t=1580059556; x=1581269156; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ppCwLNSPdgV9ZKQdc/gxJH965terpmBXlRC6xAo2B/Y=; b=J6kXPqHaZ9fhPovCU6kgx3C18ta7JANRHGNiS/giH8nLwwDXgkbT1D4G fli9DuUCRevQXlOx40rTg7Y0H2P90fPTHhaNQtTdouirwRN5QeDqqWyQw pgbFoFuVQYeReskm2YxW40iayqVkw82b0CKuOwuP6QfRLZyCt/BvSPCtQ g=; X-IronPort-AV: E=Sophos;i="5.70,366,1574121600"; d="scan'208";a="695109538" Received: from alln-core-12.cisco.com ([173.36.13.134]) by rcdn-iport-3.cisco.com with ESMTP/TLS/DHE-RSA-SEED-SHA; 26 Jan 2020 17:25:55 +0000 Received: from cpp-rtpbld-31.cisco.com (cpp-rtpbld-31.cisco.com [172.18.5.114]) by alln-core-12.cisco.com (8.15.2/8.15.2) with ESMTP id 00QHPskB030636; Sun, 26 Jan 2020 17:25:55 GMT Received: by cpp-rtpbld-31.cisco.com (Postfix, from userid 140087) id B9EC0A9E; Sun, 26 Jan 2020 12:25:54 -0500 (EST) From: David Harton To: dev@dpdk.org Cc: wenzhuo.lu@intel.com, konstantin.ananyev@intel.com, xiaolong.ye@intel.com, David Harton , intel.com@cisco.com Date: Sun, 26 Jan 2020 12:25:48 -0500 Message-Id: <20200126172548.23327-1-dharton@cisco.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20191211024802.17978-1-dharton@cisco.com> References: <20191211024802.17978-1-dharton@cisco.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Outbound-SMTP-Client: 172.18.5.114, cpp-rtpbld-31.cisco.com X-Outbound-Node: alln-core-12.cisco.com Subject: [dpdk-dev] [PATCH v2] 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. Fixes: d82170d27918 ("igb: add VF support") Cc: intel.com 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