netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Michael Walle <michael@walle.cc>
To: linux@armlinux.org.uk
Cc: andrew@lunn.ch, davem@davemloft.net, f.fainelli@gmail.com,
	hkallweit1@gmail.com, kory.maincent@bootlin.com, kuba@kernel.org,
	maxime.chevallier@bootlin.com, netdev@vger.kernel.org,
	richardcochran@gmail.com, thomas.petazzoni@bootlin.com,
	Michael Walle <michael@walle.cc>
Subject: Re: [PATCH RFC net-next] net: phy: add Marvell PHY PTP support [multicast/DSA issues]
Date: Fri,  3 Mar 2023 11:20:05 +0100	[thread overview]
Message-ID: <20230303102005.442331-1-michael@walle.cc> (raw)
In-Reply-To: <ZADcSwvmwt8jYxWD@shell.armlinux.org.uk>

> > > (In essence, because of all the noise when trying the Marvell PHY with
> > > ptp4l, I came to the conlusion that NTP was a far better solution to
> > > time synchronisation between machines than PTP would ever be due to
> > > the nose induced by MDIO access. However, I should also state that I
> > > basically gave up with PTP in the end because hardware support is
> > > overall poor, and NTP just works - and I'd still have to run NTP for
> > > the machines that have no PTP capabilities. PTP probably only makes
> > > sense if one has a nice expensive grand master PTP clock on ones
> > > network, and all the machines one wants to synchronise have decent
> > > PTP implementations.)
> > 
> > Don't wanna waste too much of your time with the questions since
> > I haven't done much research but - wouldn't MAC timestamp be a better
> > choice more often (as long as it's a real, to-spec PTP stamp)? 
> > Are we picking PHY for historical reasons?
> > 
> > Not that flipping the default would address the problem of regressing
> > some setups..

Another thing I pointed out some time ago is that you might have a
working setup with MAC timestamping. Then comes along a patch which
adds PHY timestamping for the PHY you are using and it might break your
setup, because of the "PHY timestamping first" rule.

> There is the argument in PTP that having the PHY do the timestamping
> results in the timestamps being "closer to the wire" meaning that
> they will not be subject to any delays between the packet leaving
> the MAC and being transmitted on the wire. Some PHYs have FIFOs or
> other buffering which introduces a delay which PTP doesn't desire.
> 
> TI has a blog on this:
> 
> https://e2e.ti.com/blogs_/b/analogwire/posts/how-to-implement-ieee-1588-time-stamping-in-an-ethernet-transceiver
> 
> However, what is failed to be mentioned there is that yes, doing
> PTP at the PHY means one can accurately trigger a capture of the
> timestamp from the PHC when the SFD is detected on the media. That
> is a great advantage, but is really only half the story.
> 
> If the PHC (hardware counter) in the PHY can't be accurately
> synchronised, for example, it has a 1.5ppm second-to-second
> variability, then the resulting timestamps will also have that
> same variability. Another way to look at it is they will appear to
> have 1.5ppm of noise. If this noise is random, then it becomes
> difficult to filter that noise out, and results in jitter.

Exactly this.

> However, timestamping at the MAC may have only 40ppb of variability,
> but have a resulting delay through the PHY. The delay through the
> PHY will likely be constant, so the timestamps gathered at the MAC
> will have a constant error but have much less noise.

One thing to consider is also the quality of the oscillator of each
part. E.g. we design boards which have special temperture controlled
oscillators. How would you know where that one is connected to, MAC?
PHY? Both?

> Things change if one can use hardware signals to synchronise the
> PHC, because then we become less reliant on a variable latency
> accessing the PHY over the MDIO bus. The hardware event capture
> allows the PHC to be captured on a hardware signal, software can
> then read that timestamp, and if the hardware event is a PPS,
> then that can be used to ensure that the PHC is ticking at the
> correct rate. If the PPS is also aligned to a second boundary,
> then the hardware PHC can also be aligned. With both, the latency
> of the MDIO bus becomes irrelevant, and PTP at the PHY becomes a
> far more preferable option.
> 
> Note that things which can influence the latency over the MDIO bus
> include how many PHYs or other devices are also on it, and the
> rate at which accesses to those PHYs are performed. Then there's
> latency from kernel locking and scheduling. Maybe interrupt
> latency if the MDIO bus driver uses interrupts.
> 
> When I created the generic Marvell PHY PTP layer (my patch set
> for Marvell PHYs) I tried very hard to eliminate as many of these
> sources of variable latency as possible - such as avoiding taking
> and releasing locks on every MDIO bus access. Even with that, I
> could not get the PHY's PHC to synchronise any better than 1.5ppm,
> vs 40ppb for the PP2 MAC's PHC.
> 
> The last bit of consideration is whether the PHCs can be synchronised
> in hardware. If one has multiple ethernet interfaces, no hardware
> synchronisation of PHY PHCs, but also have MAC PTP support which is
> shared across the ethernet interfaces, why would one want to use the
> PHY with software based synchronisation of their individual PHCs.
> 
> So, to wrap this email up... if one has hardware purposely designed
> for PTP support, which uses the PTP hardware signals from the
> various PHCs, then one would want to use the PHY based timestamping.
> If one doesn't have that, then one would want to use something that
> gives the best timestamps, which may not necessarily be the PHY.

Which would make that a property of the board and not something
the software could figure out most of the time.

IMHO it really depends on how precise one want to go. Just saying
PHY timestamping is better isn't true. Vendors might go great
lengths to design their boards to do very well regarding precision
including PHY timestamping and maybe some kind of synchronization.

But in genernal, MAC timestamping - if available and not totally
broken - is the better choice IMHO. If it wasn't for the legacy rule,
I'd prefer MAC timestamping and just use PHY timestamping if MAC
timestamping is not available. If both are available, PHY
timestamping should be an opt-in.

-michael

  reply	other threads:[~2023-03-03 10:20 UTC|newest]

Thread overview: 74+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-14 16:26 [PATCH RFC net-next] net: phy: add Marvell PHY PTP support Russell King
2020-07-15 18:38 ` Andrew Lunn
2020-07-15 18:56   ` Russell King - ARM Linux admin
2020-07-16 11:33     ` Russell King - ARM Linux admin
2020-07-16 20:53       ` Richard Cochran
2020-07-16 20:48 ` Richard Cochran
2020-07-17  7:54   ` Kurt Kanzenbach
2020-07-18  2:24     ` Richard Cochran
2020-07-20 14:21       ` Richard Cochran
2020-07-20 14:37         ` Kurt Kanzenbach
2020-07-26 23:48 ` Russell King - ARM Linux admin
2020-07-29 10:58 ` Russell King - ARM Linux admin
2020-07-29 13:19   ` Richard Cochran
2020-07-29 13:28     ` Russell King - ARM Linux admin
2020-07-29 22:07       ` Russell King - ARM Linux admin
2020-07-29 22:53         ` Vladimir Oltean
2020-07-30 15:53         ` Richard Cochran
2020-07-30 18:38           ` Russell King - ARM Linux admin
2020-07-30 19:32             ` Richard Cochran
2020-07-30 19:44               ` Russell King - ARM Linux admin
2020-07-30 11:06     ` [PATCH RFC net-next] net: phy: add Marvell PHY PTP support [multicast/DSA issues] Russell King - ARM Linux admin
2020-07-30 11:54       ` Russell King - ARM Linux admin
2020-07-30 12:47         ` Russell King - ARM Linux admin
2023-02-27 14:40           ` Köry Maincent
2023-02-27 15:20             ` Russell King (Oracle)
2023-02-27 17:30               ` Köry Maincent
2023-02-27 17:42                 ` Russell King (Oracle)
2023-02-27 19:45               ` Richard Cochran
2023-02-27 20:09                 ` Russell King (Oracle)
2023-02-27 20:19                   ` Richard Cochran
2023-02-28 12:07                     ` Russell King (Oracle)
2023-02-28 13:16                       ` Köry Maincent
2023-02-28 13:36                         ` Russell King (Oracle)
2023-02-28 14:50                           ` Köry Maincent
2023-02-28 15:16                         ` Richard Cochran
2023-02-28 15:33                           ` Andrew Lunn
2023-02-28 21:13                             ` Richard Cochran
2023-02-28 16:27                           ` Russell King (Oracle)
2023-02-28 16:44                             ` Michael Walle
2023-02-28 16:58                               ` Russell King (Oracle)
2023-02-28 20:13                                 ` Michael Walle
2023-02-28 21:11                                   ` Richard Cochran
2023-02-28 21:24                             ` Richard Cochran
2023-02-28 22:26                             ` Jakub Kicinski
2023-02-28 22:40                               ` Russell King (Oracle)
2023-02-28 22:59                                 ` Jakub Kicinski
2023-03-01 16:04                                   ` Köry Maincent
2023-03-02  4:36                                     ` Richard Cochran
2023-03-02 11:49                                       ` Russell King (Oracle)
2023-03-02 16:49                                         ` Jakub Kicinski
2023-03-02 17:06                                           ` Köry Maincent
2023-03-02 17:23                                             ` Jakub Kicinski
2023-03-03 13:12                                               ` Köry Maincent
2023-03-03 23:28                                                 ` Jakub Kicinski
2023-03-02 17:26                                           ` Russell King (Oracle)
2023-03-03 10:20                                             ` Michael Walle [this message]
2023-03-03 13:20                                               ` Andrew Lunn
2023-03-03 13:34                                                 ` Köry Maincent
2023-03-03 13:59                                                   ` Andrew Lunn
2023-03-03 14:03                                                 ` Russell King (Oracle)
2023-03-03 16:34                                                   ` Andrew Lunn
2023-03-03 17:32                                                     ` Richard Cochran
2023-03-03 17:35                                                       ` Richard Cochran
2023-03-03 23:40                                                   ` Jakub Kicinski
2023-03-02 21:28                                           ` Richard Cochran
2023-03-02 21:19                                         ` Richard Cochran
2023-04-27 15:13               ` Köry Maincent
2023-04-27 16:50                 ` Andrew Lunn
2023-04-28  8:51                   ` Köry Maincent
2020-07-30 15:50         ` Richard Cochran
2020-07-31 14:41         ` Andrew Lunn
2023-03-02 10:37   ` [PATCH RFC net-next] net: phy: add Marvell PHY PTP support Köry Maincent
2023-03-02 17:38     ` Russell King (Oracle)
2023-03-02 21:35     ` 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=20230303102005.442331-1-michael@walle.cc \
    --to=michael@walle.cc \
    --cc=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=f.fainelli@gmail.com \
    --cc=hkallweit1@gmail.com \
    --cc=kory.maincent@bootlin.com \
    --cc=kuba@kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=maxime.chevallier@bootlin.com \
    --cc=netdev@vger.kernel.org \
    --cc=richardcochran@gmail.com \
    --cc=thomas.petazzoni@bootlin.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).