lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20210528211100.70cd916f@kicinski-fedora-PC1C0HJN.hsd1.ca.comcast.net>
Date:   Fri, 28 May 2021 21:11:00 -0700
From:   Jakub Kicinski <kuba@...nel.org>
To:     Michael Chan <michael.chan@...adcom.com>
Cc:     David Miller <davem@...emloft.net>,
        Netdev <netdev@...r.kernel.org>,
        Andrew Gospodarek <gospo@...adcom.com>,
        richardcochran@...il.com, Pavan Chebbi <pavan.chebbi@...adcom.com>,
        Edwin Peer <edwin.peer@...adcom.com>
Subject: Re: [PATCH net-next 5/7] bnxt_en: Get the RX packet timestamp.

On Fri, 28 May 2021 19:31:30 -0700 Michael Chan wrote:
> On Fri, May 28, 2021 at 6:39 PM Jakub Kicinski <kuba@...nel.org> wrote:
> > On Fri, 28 May 2021 20:53:19 -0400 Michael Chan wrote:  
> > > +     struct bnxt_ptp_cfg *ptp = bp->ptp_cfg;
> > > +     u64 time;
> > > +
> > > +     if (!ptp)
> > > +             return -ENODEV;
> > > +
> > > +     time = READ_ONCE(ptp->old_time);  
> >
> > READ_ONCE() on a u64? That's not gonna prevent tearing the read on 32
> > bit architectures, right?  
> 
> Right, we should add a conditional lock for 32-bit architectures.

Or only store the top 32 bit of the full counter. I don't think you 
need the bottom 16.

> > > +     *ts = (time & BNXT_HI_TIMER_MASK) | pkt_ts;
> > > +     if (pkt_ts < (time & BNXT_LO_TIMER_MASK))
> > > +             *ts += BNXT_LO_TIMER_MASK + 1;  
> >
> > The stamp is from the MAC, I hope, or otherwise packet which could have
> > been sitting on the ring for some approximation of eternity. You can
> > easily see a packet stamp older than the value stashed in ptp->old_time
> > if you run soon after the refresh.  
> 
> The hardware returns the low 32-bit timestamp of the packet.
> ptp->old_time contains the full 48-bit of the time counter that we
> sample periodically.  We're getting the upper 16-bit from
> ptp->old_time to form the complete timestamp for the packet.
> ptp->old_time is between 1 and 2 sampling periods before the current
> time.  The sampling period should be 1 second.
> 
> Yeah, if the RX packet is older than 1 to 2 seconds, the upper part
> can potentially be wrong if it has wrapped around.

Ah, you're comparing to the previous sample, I see.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ