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 7CAA3A04F1; Wed, 11 Dec 2019 03:38:47 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id C89091B13C; Wed, 11 Dec 2019 03:38:46 +0100 (CET) Received: from rcdn-iport-4.cisco.com (rcdn-iport-4.cisco.com [173.37.86.75]) by dpdk.org (Postfix) with ESMTP id 5C2D637A2 for ; Wed, 11 Dec 2019 03:38:45 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=cisco.com; i=@cisco.com; l=1837; q=dns/txt; s=iport; t=1576031925; x=1577241525; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=dDM1m5IlgxWkILwM78QYKQI06T3WC5oCc7rS7I9ifM4=; b=VUVDyQvpuPmq9wl73xkr2OW+OgB7oU1izgEoycq6ZWXGMshkGSC+C9H6 drlrAkVMDAd/1GgqwqvgvWc9LVD9ajzV9X+ib7vQc7mPDY0ATPDkNpKfw fsoWnergKJVkLmgVtTt5csRIpKgFPfmQHXzbde6SbY13plTw4LZUQZ8Lw 0=; X-IronPort-AV: E=Sophos;i="5.69,301,1571702400"; d="scan'208";a="681722585" Received: from rcdn-core-9.cisco.com ([173.37.93.145]) by rcdn-iport-4.cisco.com with ESMTP/TLS/DHE-RSA-SEED-SHA; 11 Dec 2019 02:38:44 +0000 Received: from cpp-rtpbld-31.cisco.com (cpp-rtpbld-31.cisco.com [172.18.5.114]) by rcdn-core-9.cisco.com (8.15.2/8.15.2) with ESMTP id xBB2cih1018458; Wed, 11 Dec 2019 02:38:44 GMT Received: by cpp-rtpbld-31.cisco.com (Postfix, from userid 140087) id EE953C50; Tue, 10 Dec 2019 21:38:43 -0500 (EST) From: David Harton To: dev@dpdk.org, wenzhuo.lu@intel.com, konstantin.ananyev@intel.com Cc: David Harton Date: Tue, 10 Dec 2019 21:38:36 -0500 Message-Id: <20191211023836.16272-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-9.cisco.com Subject: [dpdk-dev] [PATCH] 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. 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