netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Gerhard Engleder <gerhard@engleder-embedded.com>
To: Vinicius Costa Gomes <vinicius.gomes@intel.com>
Cc: Richard Cochran <richardcochran@gmail.com>,
	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 v1 0/6] ptp: Support hardware clocks with additional free running time
Date: Fri, 25 Mar 2022 23:01:41 +0100	[thread overview]
Message-ID: <CANr-f5zGHiQuGH=P1GddRyFStNFJnVWwbeJJeU2sfOf4aRt4-g@mail.gmail.com> (raw)
In-Reply-To: <87tubm5289.fsf@intel.com>

> Hi,
>
> Gerhard Engleder <gerhard@engleder-embedded.com> writes:
>
> > ptp vclocks require a clock with free running time for the timecounter.
> > Currently only a physical clock forced to free running is supported.
> > If vclocks are used, then the physical clock cannot be synchronized
> > anymore. The synchronized time is not available in hardware in this
> > case. As a result, timed transmission with TAPRIO hardware support
> > is not possible anymore.
> >
> > If hardware would support a free running time additionally to the
> > physical clock, then the physical clock does not need to be forced to
> > free running. Thus, the physical clocks can still be synchronized while
> > vclocks are in use.
> >
> > The physical clock could be used to synchronize the time domain of the
> > TSN network and trigger TAPRIO. In parallel vclocks can be used to
> > synchronize other time domains.
> >
> > One year ago I thought for two time domains within a TSN network also
> > two physical clocks are required. This would lead to new kernel
> > interfaces for asking for the second clock, ... . But actually for a
> > time triggered system like TSN there can be only one time domain that
> > controls the system itself. All other time domains belong to other
> > layers, but not to the time triggered system itself. So other time
> > domains can be based on a free running counter if similar mechanisms
> > like 2 step synchroisation are used.
>
> I tried to look at this series from the point of view of the Intel i225
> NIC and its 4 sets of timer registers, and thinking how adding support
> for the "extra" 4 timers would fit with this proposal.

I was hoping that there are other devices out there, which could also implement
that feature. At least in the TSN niche I expect that others have
similar requirements.

> From what I could gather, the idea that would make more sense would be
> exposing the other(s?) i225 timers as vclocks. That sounds neat to me,
> i.e. the extra timer registers are indeed other "views" to the same
> clock (the name "virtual" makes sense).

The other i225 timer would be exposed as vclock, yes. But it would be exposed
in a restricted way. Only as free running time which forms the base for the
vclocks. The actual time of the vclocks would not be available in the
extra timer
registers. So transformation of the "view" is done in software and not
in hardware.
Only one additional timer register set would be used.

> When retrieving the timestamps from packets (we can timestamp each
> packet with two timers), the driver knows what timestamp (and what to do
> with it) the user is interested in.

Yes, the driver knows it. For TX it is known in advance. For RX the
driver does not
know before reception which timestamp the user is interested in. So
the driver must
keep two timestamps (of physical clock and new free running time)
until the packet
is assigned to a socket.

As the i225 also supports two timestamps, my suggestion would be to use one
timestamp for the physical clock which would also trigger TAPRIO and the other
timestamp as base for an unlimited number of vclocks.

> Is this what you (and others) had in mind?

If one additional timer register set is used as free running time,
then I would say yes.

If you expect to export additional functions of the 4 timer register
sets with vclocks, then
I would say no. At least not with current vclock implementation, which
requires/supports
only a free running time in hardware and nothing else. But others may
know better how
vclocks could evolve in the future. These changes could be seen as a
first step, which
enhances the functionality of vclocks if additional hardware support
is available. The i225
timer register sets may allow further enhancements.

> If so, API-wise this series looks good to me. I will take a closer look
> at the code tomorrow.

Looking forward to your feedback!

Gerhard


On Fri, Mar 25, 2022 at 1:02 AM Vinicius Costa Gomes
<vinicius.gomes@intel.com> wrote:
>
> Hi,
>
> Gerhard Engleder <gerhard@engleder-embedded.com> writes:
>
> > ptp vclocks require a clock with free running time for the timecounter.
> > Currently only a physical clock forced to free running is supported.
> > If vclocks are used, then the physical clock cannot be synchronized
> > anymore. The synchronized time is not available in hardware in this
> > case. As a result, timed transmission with TAPRIO hardware support
> > is not possible anymore.
> >
> > If hardware would support a free running time additionally to the
> > physical clock, then the physical clock does not need to be forced to
> > free running. Thus, the physical clocks can still be synchronized while
> > vclocks are in use.
> >
> > The physical clock could be used to synchronize the time domain of the
> > TSN network and trigger TAPRIO. In parallel vclocks can be used to
> > synchronize other time domains.
> >
> > One year ago I thought for two time domains within a TSN network also
> > two physical clocks are required. This would lead to new kernel
> > interfaces for asking for the second clock, ... . But actually for a
> > time triggered system like TSN there can be only one time domain that
> > controls the system itself. All other time domains belong to other
> > layers, but not to the time triggered system itself. So other time
> > domains can be based on a free running counter if similar mechanisms
> > like 2 step synchroisation are used.
>
> I tried to look at this series from the point of view of the Intel i225
> NIC and its 4 sets of timer registers, and thinking how adding support
> for the "extra" 4 timers would fit with this proposal.
>
> From what I could gather, the idea that would make more sense would be
> exposing the other(s?) i225 timers as vclocks. That sounds neat to me,
> i.e. the extra timer registers are indeed other "views" to the same
> clock (the name "virtual" makes sense).
>
> When retrieving the timestamps from packets (we can timestamp each
> packet with two timers), the driver knows what timestamp (and what to do
> with it) the user is interested in.
>
> Is this what you (and others) had in mind?
>
> If so, API-wise this series looks good to me. I will take a closer look
> at the code tomorrow.
>
> >
> > Synchronisation was tested with two time domains between two directly
> > connected hosts. Each host run two ptp4l instances, the first used the
> > physical clock and the second used the virtual clock. I used my FPGA
> > based network controller as network device. ptp4l was used in
> > combination with the virtual clock support patches from Miroslav
> > Lichvar.
> >
> > v1:
> > - comlete rework based on feedback to RFC (Richard Cochran)
> >
> > Gerhard Engleder (6):
> >   ptp: Add cycles support for virtual clocks
> >   ptp: Request cycles for TX timestamp
> >   ptp: Pass hwtstamp to ptp_convert_timestamp()
> >   ethtool: Add kernel API for PHC index
> >   ptp: Support late timestamp determination
> >   tsnep: Add physical clock cycles support
> >
> >  drivers/net/ethernet/engleder/tsnep_hw.h   |  9 ++-
> >  drivers/net/ethernet/engleder/tsnep_main.c | 27 ++++++---
> >  drivers/net/ethernet/engleder/tsnep_ptp.c  | 44 ++++++++++++++
> >  drivers/ptp/ptp_clock.c                    | 58 +++++++++++++++++--
> >  drivers/ptp/ptp_private.h                  | 10 ++++
> >  drivers/ptp/ptp_sysfs.c                    | 10 ++--
> >  drivers/ptp/ptp_vclock.c                   | 18 +++---
> >  include/linux/ethtool.h                    |  8 +++
> >  include/linux/ptp_clock_kernel.h           | 67 ++++++++++++++++++++--
> >  include/linux/skbuff.h                     | 11 +++-
> >  net/core/skbuff.c                          |  2 +
> >  net/ethtool/common.c                       | 13 +++++
> >  net/socket.c                               | 45 +++++++++++----
> >  13 files changed, 275 insertions(+), 47 deletions(-)
> >
> > --
> > 2.20.1
> >
>
> --
> Vinicius

      reply	other threads:[~2022-03-25 22:01 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-22 21:07 [PATCH net-next v1 0/6] ptp: Support hardware clocks with additional free running time Gerhard Engleder
2022-03-22 21:07 ` [PATCH net-next v1 1/6] ptp: Add cycles support for virtual clocks Gerhard Engleder
2022-03-24 13:43   ` Richard Cochran
2022-03-24 19:39     ` Gerhard Engleder
2022-03-22 21:07 ` [PATCH net-next v1 2/6] ptp: Request cycles for TX timestamp Gerhard Engleder
2022-03-24 13:49   ` Richard Cochran
2022-03-24 13:55     ` Miroslav Lichvar
2022-03-24 19:43     ` Gerhard Engleder
2022-03-22 21:07 ` [PATCH net-next v1 3/6] ptp: Pass hwtstamp to ptp_convert_timestamp() Gerhard Engleder
2022-03-24 13:50   ` Richard Cochran
2022-03-22 21:07 ` [PATCH net-next v1 4/6] ethtool: Add kernel API for PHC index Gerhard Engleder
2022-03-24 13:51   ` Richard Cochran
2022-03-22 21:07 ` [PATCH net-next v1 5/6] ptp: Support late timestamp determination Gerhard Engleder
2022-03-23  0:54   ` kernel test robot
2022-03-23  1:05   ` kernel test robot
2022-03-23  2:06   ` kernel test robot
2022-03-24 14:01   ` Richard Cochran
2022-03-24 19:52     ` Gerhard Engleder
2022-03-25  0:04       ` Richard Cochran
2022-03-25  0:08         ` Richard Cochran
2022-03-25 20:51           ` Gerhard Engleder
2022-03-26  0:27   ` Vinicius Costa Gomes
2022-03-22 21:07 ` [PATCH net-next v1 6/6] tsnep: Add physical clock cycles support Gerhard Engleder
2022-03-25  0:01 ` [PATCH net-next v1 0/6] ptp: Support hardware clocks with additional free running time Vinicius Costa Gomes
2022-03-25 22:01   ` Gerhard Engleder [this message]

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='CANr-f5zGHiQuGH=P1GddRyFStNFJnVWwbeJJeU2sfOf4aRt4-g@mail.gmail.com' \
    --to=gerhard@engleder-embedded.com \
    --cc=davem@davemloft.net \
    --cc=kuba@kernel.org \
    --cc=mlichvar@redhat.com \
    --cc=netdev@vger.kernel.org \
    --cc=richardcochran@gmail.com \
    --cc=vinicius.gomes@intel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).