All of lore.kernel.org
 help / color / mirror / Atom feed
From: Vinicius Costa Gomes <vinicius.gomes@intel.com>
To: Gerhard Engleder <gerhard@engleder-embedded.com>,
	Richard Cochran <richardcochran@gmail.com>
Cc: yangbo.lu@nxp.com, David Miller <davem@davemloft.net>,
	Jakub Kicinski <kuba@kernel.org>,
	mlichvar@redhat.com, netdev <netdev@vger.kernel.org>
Subject: Re: [PATCH net-next v2 4/5] ptp: Support late timestamp determination
Date: Tue, 12 Apr 2022 14:05:02 -0700	[thread overview]
Message-ID: <87sfqiypvl.fsf@intel.com> (raw)
In-Reply-To: <CANr-f5yn9LzMQ8yAP8Py-EP_NyifFyj1uXBNo+kuGY1p8t0CFw@mail.gmail.com>

Gerhard Engleder <gerhard@engleder-embedded.com> writes:

>> > > > > @@ -887,18 +885,28 @@ void __sock_recv_timestamp(struct msghdr *msg, struct sock *sk,
>> > > > >       if (shhwtstamps &&
>> > > > >           (sk->sk_tsflags & SOF_TIMESTAMPING_RAW_HARDWARE) &&
>> > > > >           !skb_is_swtx_tstamp(skb, false_tstamp)) {
>> > > > > +             rcu_read_lock();
>> > > > > +             orig_dev = dev_get_by_napi_id(skb_napi_id(skb));
>> > > >
>> > > > __sock_recv_timestamp() is hot path.
>> > > >
>> > > > No need to call dev_get_by_napi_id() for the vast majority of cases
>> > > > using plain old MAC time stamping.
>> > >
>> > > Isn't dev_get_by_napi_id() called most of the time anyway in put_ts_pktinfo()?
>> >
>> > No.  Only when SOF_TIMESTAMPING_OPT_PKTINFO is requested.
>>
>> You are right, my fault.
>>
>> > > That's the reason for the removal of a separate flag, which signals the need to
>> > > timestamp determination based on address/cookie. I thought there is no need
>> > > for that flag, as netdev is already available later in the existing code.
>> > >
>> > > > Make this conditional on (sk->sk_tsflags & SOF_TIMESTAMPING_BIND_PHC).
>> > >
>> > > This flag tells netdev_get_tstamp() which timestamp is required. If it
>> > > is not set, then
>> > > netdev_get_tstamp() has to deliver the normal timestamp as always. But
>> > > this normal
>> > > timestamp is only available via address/cookie. So netdev_get_tstamp() must be
>> > > called.
>> >
>> > It should be this:
>> >
>> > - normal, non-vclock:   use hwtstamps->hwtstamp directly
>> > - vclock:               use slower path with lookup
>> >
>> > I don't see why you can't implement that.
>>
>> I will try to implement it that way.
>
> I'm thinking about why there should be a slow path with lookup. If the
> address/cookie
> points to a defined data structure with two timestamps, then no lookup
> for the phc or
> netdev is necessary. It should be possible for every driver to
> allocate a skbuff with enough
> space for this structure in front of the received Ethernet frame. The
> structure could be:
>
> struct skb_inline_hwtstamps {
>         ktime_t hwtstamp;
>         ktime_t hwcstamp;
> };
>
> Actually my device and igc are storing the timestamps in front of the
> received Ethernet
> frame. In my opinion it is obvious to the store metadata of received
> Ethernet frames in
> front of it, because it eliminates the need for another DMA transfer.
> What is your opinion
> Vinicius?

If I am understanding this right, the idea is providing both "cycles"
(free running cycles measurement) and PHC timestamp for all packets, for
igc, it will work fine for RX (the HW already writes the timestamps for
two timer registers in the host memory), but for TX it's going be
awkward/slow (I would have to read two extra registers), but I think
it's still possible.

But it would be best to avoid the overhead, and only providing the
"extra" (the cycles one) measurement if necessary for TX, so
SKBTX_HW_TSTAMP_USE_CYCLES would still be needed.

So, in short, I am fine with it, as long as I can get away with only
providing the cycles measurement for TX if necessary.

>
> Gerhard

Cheers,
-- 
Vinicius

  reply	other threads:[~2022-04-12 23:36 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-03 17:55 [PATCH net-next v2 0/5] ptp: Support hardware clocks with additional free running cycle counter Gerhard Engleder
2022-04-03 17:55 ` [PATCH net-next v2 1/5] ptp: Add cycles support for virtual clocks Gerhard Engleder
2022-04-10  6:26   ` Richard Cochran
2022-04-10 12:32     ` Gerhard Engleder
2022-04-03 17:55 ` [PATCH net-next v2 2/5] ptp: Request cycles for TX timestamp Gerhard Engleder
2022-04-10  6:47   ` Richard Cochran
2022-04-10 12:40     ` Gerhard Engleder
2022-04-03 17:55 ` [PATCH net-next v2 3/5] ptp: Pass hwtstamp to ptp_convert_timestamp() Gerhard Engleder
2022-04-03 17:55 ` [PATCH net-next v2 4/5] ptp: Support late timestamp determination Gerhard Engleder
2022-04-10  7:29   ` Richard Cochran
2022-04-10 12:54     ` Gerhard Engleder
2022-04-10 13:42       ` Richard Cochran
2022-04-10 14:42         ` Gerhard Engleder
2022-04-12 19:24           ` Gerhard Engleder
2022-04-12 21:05             ` Vinicius Costa Gomes [this message]
2022-04-13 20:28               ` Gerhard Engleder
2022-04-12 21:46             ` Richard Cochran
2022-04-13 20:51               ` Gerhard Engleder
2022-04-14  6:36                 ` Richard Cochran
2022-04-15 22:04                   ` Gerhard Engleder
2022-04-16 16:58                     ` Richard Cochran
2022-04-03 17:55 ` [PATCH net-next v2 5/5] tsnep: Add free running cycle counter support Gerhard Engleder
2022-04-06 23:04 ` [PATCH net-next v2 0/5] ptp: Support hardware clocks with additional free running cycle counter Richard Cochran

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87sfqiypvl.fsf@intel.com \
    --to=vinicius.gomes@intel.com \
    --cc=davem@davemloft.net \
    --cc=gerhard@engleder-embedded.com \
    --cc=kuba@kernel.org \
    --cc=mlichvar@redhat.com \
    --cc=netdev@vger.kernel.org \
    --cc=richardcochran@gmail.com \
    --cc=yangbo.lu@nxp.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.