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 B40D5A052F; Sun, 26 Jan 2020 18:13:13 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 62C3E493D; Sun, 26 Jan 2020 18:13:12 +0100 (CET) Received: from mail-pj1-f66.google.com (mail-pj1-f66.google.com [209.85.216.66]) by dpdk.org (Postfix) with ESMTP id AAED037B1 for ; Sun, 26 Jan 2020 18:13:10 +0100 (CET) Received: by mail-pj1-f66.google.com with SMTP id e11so2125855pjt.4 for ; Sun, 26 Jan 2020 09:13:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=K8I67gm4j6UijRQTwayf6Ff9pXOA3mxw3b8ryiU1QlA=; b=x8mKdxE20fW5UqC85c3WMile6m42jcBnC7bnK0Df9/SYMSy6xAOVaqm3kLA+dY9znQ PCiN5F5XR9W4NSpUaUz2how3XXTyF5CZz8ilWXSn+YgHlDiPz/EaEM5CEZjmeMakXsFe HZngS7nZflctDIm9tHASw2ngsM53q3wSJ9TmMI1TDGsrGseCpZuxcal6tWjyvc8otYqz LnoB/eDBoPT22DLJ0r2y6GubllQAG8I+/2DAAlfP+lOGg3F2iPmexnLzZeDlG1OQbxl9 fA62hiGdv0h2ctC2P9gv4biQw0uyl5BaXzrf9/P13ncOKtFb5gZfEC4EjVK0ymHSjN2j YUbA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=K8I67gm4j6UijRQTwayf6Ff9pXOA3mxw3b8ryiU1QlA=; b=ECQdToCWPHYZNGibV0+mUoxrMQO2GDa8s/btaF9g4GYcnB0Wga9YUYIte8lXab0SC+ eslFuUTCNxhfM0E5Mfe6CSrOuZwMBygnFeUHgi1lLt5UTdZHvC1+2sPoqLGZ/DeJNwnH k3SvKSp/myR0+B6YVBwpCp1AwAU80j5OoHP6TOxycfC3vZ1bkg7lH4gG5kNis19PoCLT +mUe0I/OTNoqwcLLm5sl62iAaniJcFWy2KA6nqVq/hg5RSvOSR4H91skB2qY8S1hn7Yv KkKQChFgoVMaJKZt5xcXtKNwN7IFiBqsWTVrtJWmhwLGxsYVCKnIWmEx/24sKUk0qKOM a8DQ== X-Gm-Message-State: APjAAAVj5GRN2L4waGUIrF1iVaq4YRM7pJItfI5nafP9PKGSILx//wPP 5sf+K+9/gg4/C450hhkvIx+FHw== X-Google-Smtp-Source: APXvYqxeyo6/yH+3T//GHkgwdnO1TMPdoksZmHHU/T1NHuyIq7B6GzQPS16Hixj495dujXB98udBIA== X-Received: by 2002:a17:902:9f88:: with SMTP id g8mr14020706plq.100.1580058789687; Sun, 26 Jan 2020 09:13:09 -0800 (PST) Received: from hermes.lan (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id j125sm12347414pfg.160.2020.01.26.09.13.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Jan 2020 09:13:09 -0800 (PST) Date: Sun, 26 Jan 2020 09:13:01 -0800 From: Stephen Hemminger To: David Harton Cc: dev@dpdk.org, wenzhuo.lu@intel.com, konstantin.ananyev@intel.com Message-ID: <20200126091301.1b739325@hermes.lan> In-Reply-To: <20191211023836.16272-1-dharton@cisco.com> References: <20191211023836.16272-1-dharton@cisco.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Subject: Re: [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" On Tue, 10 Dec 2019 21:38:36 -0500 David Harton wrote: > 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; \ > } The overall approach looks fine. The code is now long enough the macro should turn into an inline. Also lots of (extra) parenthesis