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 3FE43A052F; Sun, 26 Jan 2020 18:32:10 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id E503F493D; Sun, 26 Jan 2020 18:32:08 +0100 (CET) Received: from rcdn-iport-8.cisco.com (rcdn-iport-8.cisco.com [173.37.86.79]) by dpdk.org (Postfix) with ESMTP id 724D137B1 for ; Sun, 26 Jan 2020 18:32:07 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=cisco.com; i=@cisco.com; l=1900; q=dns/txt; s=iport; t=1580059927; x=1581269527; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=cVDcQzggYVGtbSfn6A5zkj5EdaKW/r7vSC+GZT3Dpeo=; b=OsGxmZNvdn7tl3cpXssjSw5bsO+hWUn8QhCQdBOYSYDCDX87557Y7UXD bpGjK1Q1m/o1DreOgKZqOo07dfAWIe6uihNMO6yzSxN1opg7CzfL9de83 2iuFQKxyVJYnArlgUoVIU1jH01FuZ3JTymerFcvw2kq4UBwu+R2BzCWgo M=; X-IronPort-AV: E=Sophos;i="5.70,366,1574121600"; d="scan'208";a="708093543" Received: from alln-core-6.cisco.com ([173.36.13.139]) by rcdn-iport-8.cisco.com with ESMTP/TLS/DHE-RSA-SEED-SHA; 26 Jan 2020 17:32:05 +0000 Received: from cpp-rtpbld-31.cisco.com (cpp-rtpbld-31.cisco.com [172.18.5.114]) by alln-core-6.cisco.com (8.15.2/8.15.2) with ESMTP id 00QHW4pW005117; Sun, 26 Jan 2020 17:32:05 GMT Received: by cpp-rtpbld-31.cisco.com (Postfix, from userid 140087) id 061DCA9E; Sun, 26 Jan 2020 12:32:03 -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:32:01 -0500 Message-Id: <20200126173201.19433-1-dharton@cisco.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20191211023836.16272-1-dharton@cisco.com> References: <20191211023836.16272-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-6.cisco.com Subject: [dpdk-dev] [PATCH v2] net/ixgbevf: update VF_STAT macros 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" Added rollover logic to UPDATE_VF_STAT and UPDATE_VF_STAT_36BIT macros. Fixes: af75078fece3 ("first public release") Cc: intel.com Signed-off-by: David Harton --- drivers/net/ixgbe/ixgbe_ethdev.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c index 49285ce53..bc73ad195 100644 --- a/drivers/net/ixgbe/ixgbe_ethdev.c +++ b/drivers/net/ixgbe/ixgbe_ethdev.c @@ -385,7 +385,11 @@ static void ixgbe_l2_tunnel_conf(struct rte_eth_dev *dev); #define UPDATE_VF_STAT(reg, last, cur) \ { \ uint32_t latest = IXGBE_READ_REG(hw, reg); \ - cur += (latest - last) & UINT_MAX; \ + if (latest >= last) \ + cur += (latest - last); \ + else \ + cur += ((latest + ((uint64_t)1 << 32)) - last); \ + cur &= UINT_MAX; \ last = latest; \ } @@ -394,7 +398,11 @@ static void ixgbe_l2_tunnel_conf(struct rte_eth_dev *dev); u64 new_lsb = IXGBE_READ_REG(hw, lsb); \ u64 new_msb = IXGBE_READ_REG(hw, msb); \ u64 latest = ((new_msb << 32) | new_lsb); \ - cur += (0x1000000000LL + latest - last) & 0xFFFFFFFFFLL; \ + if (latest >= last) \ + cur += (latest - last); \ + else \ + cur += ((latest + ((u64)1 << 36)) - last); \ + cur &= 0xFFFFFFFFFLL; \ last = latest; \ } -- 2.19.1