From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from alln-iport-1.cisco.com (alln-iport-1.cisco.com [173.37.142.88]) by dpdk.org (Postfix) with ESMTP id 4AEB6E72 for ; Tue, 13 Oct 2015 21:43:27 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=cisco.com; i=@cisco.com; l=2995; q=dns/txt; s=iport; t=1444765407; x=1445975007; h=subject:to:references:from:message-id:date:mime-version: in-reply-to:content-transfer-encoding; bh=uZyCSVLCz7rHjUpuuO/C+1/DLPIO7g7xoT2l4PnKH10=; b=Or7vgymKguycwtclvxZRBvf7rH0238kAlZ4UWgvQ1ObKB3vp6XRFwaTn j+FscrUbC6CYw4rrE2GlUkvncv23TlSWWPeddDYHfx6IUnmaHBStjTmB1 TzzN4AHrDy/Ihik8gpDZ2O3xQ0IzZzqruGcd+HOwvPyv8mxxiXuKvHlBs c=; X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A0DxAQAZXh1W/5pdJa1bA4MmVG65cYQiAQ2BWiGCHlSDCQKBSjgUAQEBAQEBAYEKhCcBAQQ4HSMRCxgJFg8JAwIBAgFFEwYCAQGIKg3CSgEBAQEGAQEBAR6GdYR+hCoRASsWFxIFhBcBBJYWAY0ZgViEOoMBI45jg28fAQFChB4iMwGFMIFAAQEB X-IronPort-AV: E=Sophos;i="5.17,679,1437436800"; d="scan'208";a="197758789" Received: from rcdn-core-3.cisco.com ([173.37.93.154]) by alln-iport-1.cisco.com with ESMTP/TLS/DHE-RSA-AES256-SHA; 13 Oct 2015 19:43:26 +0000 Received: from [10.150.217.104] ([10.150.217.104]) by rcdn-core-3.cisco.com (8.14.5/8.14.5) with ESMTP id t9DJhPLn029064 for ; Tue, 13 Oct 2015 19:43:26 GMT To: 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> <561BD4AE.4010704@gmail.com> From: "Roger B. Melton" Message-ID: <561D5EE5.2000507@cisco.com> Date: Tue, 13 Oct 2015 15:43:33 -0400 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:38.0) Gecko/20100101 Thunderbird/38.3.0 MIME-Version: 1.0 In-Reply-To: <561BD4AE.4010704@gmail.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: Tue, 13 Oct 2015 19:43:27 -0000 Agreed, this handles the off by one error on wrap around and should be faster. -Roger On 10/12/15 11:41 AM, Alexander Duyck wrote: > 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 > . > -- ____________________________________________________________________ |Roger B. Melton | | Cisco Systems | |CPP Software :|: :|: 7100 Kit Creek Rd | |+1.919.476.2332 phone :|||: :|||: RTP, NC 27709-4987 | |+1.919.392.1094 fax .:|||||||:..:|||||||:. rmelton@cisco.com | | | | This email may contain confidential and privileged material for the| | sole use of the intended recipient. Any review, use, distribution | | or disclosure by others is strictly prohibited. If you are not the | | intended recipient (or authorized to receive for the recipient), | | please contact the sender by reply email and delete all copies of | | this message. | | | | For corporate legal information go to: | | http://www.cisco.com/web/about/doing_business/legal/cri/index.html | |__________________________ http://www.cisco.com ____________________|