From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pa0-f44.google.com (mail-pa0-f44.google.com [209.85.220.44]) by dpdk.org (Postfix) with ESMTP id B6F4C8E80 for ; Mon, 12 Oct 2015 17:41:36 +0200 (CEST) Received: by padhy16 with SMTP id hy16so156982608pad.1 for ; Mon, 12 Oct 2015 08:41:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-type:content-transfer-encoding; bh=h3CWiS9EKKzUKJW3Nzc2ybqgLM9FeDUgpAGnjHMeA9o=; b=CTbJEHZouCpav5bBYobfv3ZU6D3DoyrnhSGacUNPu3bQ+C10H/Sb0g3kTVeZ7pkPB0 +MPmuT3lWuZIORyUPFOrXHHP9Vcrfhy5lZOSxU7u2mVaf5EKdr2rh87h+V7o9Lc0JWH0 97whYhAERdSrLK9jYPU0DyVwbXaj8lyC/2gbGKDmwV1PQ0nUBGzWebK2L92HvKCd1AOz Cf9PXJazllHG0HwV4w9m3rQPx37lI+oDBCjxeLRmqmxO9kv6OruEisbopIFQ/4QC/1Cr c+mpyFaun9PBDMvk6QisNQ/TO+d9WKeSsYJK/W08EZfQlH4XvMAKLS1OBchhROoe3COy BP4Q== X-Received: by 10.66.97.73 with SMTP id dy9mr35009306pab.115.1444664496146; Mon, 12 Oct 2015 08:41:36 -0700 (PDT) Received: from [192.168.1.188] (static-50-53-21-5.bvtn.or.frontiernet.net. [50.53.21.5]) by smtp.googlemail.com with ESMTPSA id pq1sm18989296pbb.91.2015.10.12.08.41.35 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 12 Oct 2015 08:41:35 -0700 (PDT) To: Harry van Haaren , dev@dpdk.org References: <1444656823-717-1-git-send-email-harry.van.haaren@intel.com> <1444656823-717-2-git-send-email-harry.van.haaren@intel.com> From: Alexander Duyck Message-ID: <561BD4AE.4010704@gmail.com> Date: Mon, 12 Oct 2015 08:41:34 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.1.0 MIME-Version: 1.0 In-Reply-To: <1444656823-717-2-git-send-email-harry.van.haaren@intel.com> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [dpdk-dev] [PATCH 1/2] ixgbe: fix VF statistic wraparound handling macro X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 12 Oct 2015 15:41:37 -0000 On 10/12/2015 06:33 AM, Harry van Haaren wrote: > Fix a misinterpretation of VF stats in ixgbe > > Signed-off-by: Harry van Haaren > --- > drivers/net/ixgbe/ixgbe_ethdev.c | 8 ++++++-- > 1 file changed, 6 insertions(+), 2 deletions(-) > > diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c > index ec2918c..d226e8d 100644 > --- a/drivers/net/ixgbe/ixgbe_ethdev.c > +++ b/drivers/net/ixgbe/ixgbe_ethdev.c > @@ -329,10 +329,14 @@ static int ixgbe_timesync_read_tx_timestamp(struct rte_eth_dev *dev, > /* > * Define VF Stats MACRO for Non "cleared on read" register > */ > -#define UPDATE_VF_STAT(reg, last, cur) \ > +#define UPDATE_VF_STAT(reg, last, cur) \ > { \ > uint32_t latest = IXGBE_READ_REG(hw, reg); \ > - cur += latest - last; \ > + if(likely(latest > last)) { \ > + cur += latest - last; \ > + } else { \ > + cur += (UINT_MAX - last) + latest; \ > + } \ > last = latest; \ > } > From what I can tell your math is adding an off by one error. You should probably be using UINT_MAX as a mask for the result, not as a part of the calculation itself. So the correct way to compute this would be "cur += (latest - last) & UINT_MAX". Also the mask approach should be faster as it avoids any conditional jumps. - Alex