[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CACKFLi=0fq26Su6wBwEG-8bhPuEU0JB7O=mUtZ=01KLKOyYxsg@mail.gmail.com>
Date: Fri, 28 May 2021 19:31:30 -0700
From: Michael Chan <michael.chan@...adcom.com>
To: Jakub Kicinski <kuba@...nel.org>
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, 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.
>
> > + *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.
Download attachment "smime.p7s" of type "application/pkcs7-signature" (4209 bytes)
Powered by blists - more mailing lists