From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <dev-bounces@dpdk.org>
Received: from dpdk.org (dpdk.org [92.243.14.124])
	by inbox.dpdk.org (Postfix) with ESMTP id 06086A04B1;
	Tue, 24 Nov 2020 11:08:08 +0100 (CET)
Received: from [92.243.14.124] (localhost [127.0.0.1])
	by dpdk.org (Postfix) with ESMTP id B3BE8C926;
	Tue, 24 Nov 2020 11:08:04 +0100 (CET)
Received: from mail-wr1-f68.google.com (mail-wr1-f68.google.com
 [209.85.221.68]) by dpdk.org (Postfix) with ESMTP id 8E10AC90C
 for <dev@dpdk.org>; Tue, 24 Nov 2020 11:08:03 +0100 (CET)
Received: by mail-wr1-f68.google.com with SMTP id p8so21690764wrx.5
 for <dev@dpdk.org>; Tue, 24 Nov 2020 02:08:03 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=nfware-com.20150623.gappssmtp.com; s=20150623;
 h=mime-version:references:in-reply-to:from:date:message-id:subject:to
 :cc; bh=RxcMNh405qnEJB50V6QhJhfx7OlnXQU3DQgBDM9ES2c=;
 b=m9UfDbuGR3VtQYKCDxPuv/pnrj4xj71BDB2N+A59OIb4NX1rv/QdekAenB45dIxRwz
 wcCzxBeB1rfTlKFCT9fezFing+1p2SBysPAUORFrrFsHCLP8hikQEcWtnHxu0W1SX3iQ
 3M2k/49nToEC7ERc1meC/BU6uIPNTV9NuhbGzgZH3AJDeCT2kFjujFCaSCi+NvcZW80w
 JnFgfbPhNkBuFNpoJ0UhNnto+2wdiiU/dFz/nW6xuJNTm9YQMLKMxOfY4wJ7VPOOJNll
 t6jqC9OBTbH0HDiftbb6AcTCyfZ5R9rntbXK+sUZQYrw8TKOGFG01ko7LWst+VEC8fa4
 CbAQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20161025;
 h=x-gm-message-state:mime-version:references:in-reply-to:from:date
 :message-id:subject:to:cc;
 bh=RxcMNh405qnEJB50V6QhJhfx7OlnXQU3DQgBDM9ES2c=;
 b=r0SmhZvS7NaZ4B3uQSAD562igTQwo/40U9CJEz5jvJOnvyfO3UAn6zWOmEajgnF09d
 NkSzvBAyTArgHPlhwaiBCQ/jM0W8/f2trYY44YQFRdfyw10PPjEZR6Y6n2ttCUTxUxHp
 IkHvvtRMfOU5ut7vcRiYFn6j5+rewCV1uLelE9eJxwpj9qQz/wbVkQOdMqrQg8QalWTC
 gg3/gk6P/XQXQYhs5jZ67fZguYW112LVFb9CosLGxNh1v3uDh2wSEiRXbTGFdekNaKnr
 mNCLRRldyobKcmbz2Vyg1bGYGkL1Zb2nhjYAx2hqYpQb515v2NgZ69qHkEuG65/H/06a
 Vd1Q==
X-Gm-Message-State: AOAM531SwQCrPTUcCc03t7/BO+wh7VT8753m2n5w4CrdwXy2WR7PF2fu
 FfdtH3FiUUnvjQGTsRi4V/T9yKAqCudgf1w7ymrAkg==
X-Google-Smtp-Source: ABdhPJz9Vwl4d9ZY9nW7eagrpQu9y9CMEqCL/eUpkcl70Dsdz8dModq0q9JJKbVPS3Zi1ygVgmPKfU13dqpVlWl7z4U=
X-Received: by 2002:a05:6000:45:: with SMTP id
 k5mr2312402wrx.108.1606212482112; 
 Tue, 24 Nov 2020 02:08:02 -0800 (PST)
MIME-Version: 1.0
References: <20201117085639.40307-1-iryzhov@nfware.com>
 <CAF+s_Fw5hTj4RFYH96jih8Qa2Fs0NDPqUhXqyuAYqgmkkpAoZg@mail.gmail.com>
 <2ada7ab1daa242ae8e256b8432141d32@intel.com> <2232269.sFVF7DV9YO@thomas>
 <7958eb303ef7422bb1f7bac77b914d49@intel.com>
In-Reply-To: <7958eb303ef7422bb1f7bac77b914d49@intel.com>
From: Igor Ryzhov <iryzhov@nfware.com>
Date: Tue, 24 Nov 2020 13:07:51 +0300
Message-ID: <CAF+s_FwEC=DKEQnGHae5YjrRi3_Omm-arrmFf1m-1-RisWFy6w@mail.gmail.com>
To: "Zhang, Qi Z" <qi.z.zhang@intel.com>
Cc: Thomas Monjalon <thomas@monjalon.net>, dev <dev@dpdk.org>, "Guo,
 Jia" <jia.guo@intel.com>, 
 dpdk stable <stable@dpdk.org>, "Xing, Beilei" <beilei.xing@intel.com>, 
 "Yigit, Ferruh" <ferruh.yigit@intel.com>
Content-Type: text/plain; charset="UTF-8"
X-Content-Filtered-By: Mailman/MimeDel 2.1.15
Subject: Re: [dpdk-dev] [PATCH] net/i40e: fix counters
X-BeenThere: dev@dpdk.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: DPDK patches and discussions <dev.dpdk.org>
List-Unsubscribe: <https://mails.dpdk.org/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://mails.dpdk.org/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <https://mails.dpdk.org/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
Errors-To: dev-bounces@dpdk.org
Sender: "dev" <dev-bounces@dpdk.org>

This code is just ported from the Linux kernel where it is used for around
7 years, so I suppose it is pretty safe.
But of course, take your time to test it, I am fine with getting this in
the next LTS release.

Igor

On Tue, Nov 24, 2020 at 12:43 PM Zhang, Qi Z <qi.z.zhang@intel.com> wrote:

>
>
> > -----Original Message-----
> > From: dev <dev-bounces@dpdk.org> On Behalf Of Thomas Monjalon
> > Sent: Tuesday, November 24, 2020 4:25 PM
> > To: Igor Ryzhov <iryzhov@nfware.com>; dev <dev@dpdk.org>; Guo, Jia
> > <jia.guo@intel.com>
> > Cc: dpdk stable <stable@dpdk.org>; Xing, Beilei <beilei.xing@intel.com>;
> Yigit,
> > Ferruh <ferruh.yigit@intel.com>
> > Subject: Re: [dpdk-dev] [PATCH] net/i40e: fix counters
> >
> > I will follow the recommendation of Ferruh and i40e maintainers.
> > It is risky but it can be applied just before the release.
>
> I will suggest not to merge this patch in this release cycle, we need time
> to fully test it and it can always be captured in following LTS release if
> no issue be found.
>
> Thanks
> Qi
> >
> >
> > 24/11/2020 04:34, Guo, Jia:
> > > hi, igor ryzhov and Thomas
> > >
> > > Since this remain issue is report recently and we need to reproduce
> > > the issue and evaluate the patch and guaranty no side affect for other
> case, so
> > I am not sure even I don't think it still have time window to hit 20.11.
> But
> > whatever we have begin to check your patch for now on. What do you think
> so?
> > >
> > >
> > > From: Igor Ryzhov <iryzhov@nfware.com>
> > > Sent: Friday, November 20, 2020 2:27 AM
> > > To: dev <dev@dpdk.org>
> > > Cc: dpdk stable <stable@dpdk.org>; Xing, Beilei
> > > <beilei.xing@intel.com>; Guo, Jia <jia.guo@intel.com>; Thomas Monjalon
> > > <thomas@monjalon.net>
> > > Subject: Re: [PATCH] net/i40e: fix counters
> > >
> > > CC maintainers and Thomas.
> > >
> > > This fix should be 20.11. The issue is seen multiple times a day under
> ~20G
> > traffic with stats collection once per second.
> > >
> > > Igor
> > >
> > > On Tue, Nov 17, 2020 at 11:56 AM Igor Ryzhov
> > <iryzhov@nfware.com<mailto:iryzhov@nfware.com>> wrote:
> > > When low and high registers are read separately, this opens the door
> > > to a race condition:
> > > - low register is read
> > > - NIC updates the registers
> > > - high register is read
> > >
> > > Because of this, we may end up with an incorrect counter value.
> > > Let's read the registers in one shot, as it is done in Linux kernel
> > > since the introduction of the i40e driver.
> > >
> > > Fixes: 4861cde46116 ("i40e: new poll mode driver")
> > > Cc: stable@dpdk.org<mailto:stable@dpdk.org>
> > > Signed-off-by: Igor Ryzhov
> > > <iryzhov@nfware.com<mailto:iryzhov@nfware.com>>
> > > ---
> > >  drivers/net/i40e/base/i40e_osdep.h | 10 ++++++++++
> > >  drivers/net/i40e/i40e_ethdev.c     | 10 +++++++---
> > >  2 files changed, 17 insertions(+), 3 deletions(-)
> > >
> > > diff --git a/drivers/net/i40e/base/i40e_osdep.h
> > > b/drivers/net/i40e/base/i40e_osdep.h
> > > index 64b15e1b6138..ebd687240006 100644
> > > --- a/drivers/net/i40e/base/i40e_osdep.h
> > > +++ b/drivers/net/i40e/base/i40e_osdep.h
> > > @@ -133,6 +133,14 @@ static inline uint32_t i40e_read_addr(volatile
> void
> > *addr)
> > >         return rte_le_to_cpu_32(I40E_PCI_REG(addr));
> > >  }
> > >
> > > +#define I40E_PCI_REG64(reg)            rte_read64(reg)
> > > +#define I40E_PCI_REG64_ADDR(a, reg) \
> > > +       ((volatile uint64_t *)((char *)(a)->hw_addr + (reg))) static
> > > +inline uint64_t i40e_read64_addr(volatile void *addr) {
> > > +       return rte_le_to_cpu_64(I40E_PCI_REG64(addr));
> > > +}
> > > +
> > >  #define I40E_PCI_REG_WRITE(reg, value)         \
> > >         rte_write32((rte_cpu_to_le_32(value)), reg)  #define
> > > I40E_PCI_REG_WRITE_RELAXED(reg, value) \ @@ -145,6 +153,8 @@ static
> > > inline uint32_t i40e_read_addr(volatile void *addr)  #define
> > > I40E_WRITE_REG(hw, reg, value) \
> > >         I40E_PCI_REG_WRITE(I40E_PCI_REG_ADDR((hw), (reg)), (value))
> > >
> > > +#define I40E_READ_REG64(hw, reg)
> > > +i40e_read64_addr(I40E_PCI_REG64_ADDR((hw), (reg)))
> > > +
> > >  #define rd32(a, reg) i40e_read_addr(I40E_PCI_REG_ADDR((a), (reg)))
> > > #define wr32(a, reg, value) \
> > >         I40E_PCI_REG_WRITE(I40E_PCI_REG_ADDR((a), (reg)), (value))
> > > diff --git a/drivers/net/i40e/i40e_ethdev.c
> > > b/drivers/net/i40e/i40e_ethdev.c index 74f4ac1f9d4e..53b1e9b9e067
> > > 100644
> > > --- a/drivers/net/i40e/i40e_ethdev.c
> > > +++ b/drivers/net/i40e/i40e_ethdev.c
> > > @@ -6451,9 +6451,13 @@ i40e_stat_update_48(struct i40e_hw *hw,  {
> > >         uint64_t new_data;
> > >
> > > -       new_data = (uint64_t)I40E_READ_REG(hw, loreg);
> > > -       new_data |= ((uint64_t)(I40E_READ_REG(hw, hireg) &
> > > -                       I40E_16_BIT_MASK)) << I40E_32_BIT_WIDTH;
> > > +       if (hw->device_id == I40E_DEV_ID_QEMU) {
> > > +               new_data = (uint64_t)I40E_READ_REG(hw, loreg);
> > > +               new_data |= ((uint64_t)(I40E_READ_REG(hw, hireg) &
> > > +                               I40E_16_BIT_MASK)) <<
> > I40E_32_BIT_WIDTH;
> > > +       } else {
> > > +               new_data = I40E_READ_REG64(hw, loreg);
> > > +       }
> > >
> > >         if (!offset_loaded)
> > >                 *offset = new_data;
> > > --
> > > 2.29.2
> > >
> >
> >
> >
> >
>
>