# Re: \[PATCH RFC net-next v8 04/13\] net: Change the API of PHY default timestamp to MAC

- From: Köry Maincent \<kory.maincent@bootlin.com\>
- Date: 2024-02-19 13:29:42 
- List: netdev
- Page: https://ratatoskr.run/netdev/2024/02/2501769
- Thread: https://ratatoskr.run/netdev/2024/02/2499394/t.md

```text
On Fri, 16 Feb 2024 10:09:36 -0800
Rahul Rameshbabu [ref] wrote:

> On Fri, 16 Feb, 2024 16:52:22 +0100 Kory Maincent [ref]
> wrote:
> > Change the API to select MAC default time stamping instead of the PHY.
> > Indeed the PHY is closer to the wire therefore theoretically it has less
> > delay than the MAC timestamping but the reality is different. Due to lower
> > time stamping clock frequency, latency in the MDIO bus and no PHC hardware
> > synchronization between different PHY, the PHY PTP is often less precise
> > than the MAC. The exception is for PHY designed specially for PTP case but
> > these devices are not very widespread. For not breaking the compatibility
> > default_timestamp flag has been introduced in phy_device that is set by
> > the phy driver to know we are using the old API behavior.
> >
> > Signed-off-by: Kory Maincent <kory.maincent@bootlin.com>
> > ---  
> 
> Overall, I agree with the motivation and reasoning behind the patch. It
> takes dedicated effort to build a good phy timestamping mechanism, so
> this approach is good. I do have a question though. In this patch if we
> set the phy as the default timestamp mechanism, does that mean for even
> non-PTP applications, the phy will be used for timestamping when
> hardware timestamping is enabled? If so, I think this might need some
> thought because there are timing applications in general when a
> timestamp closest to the MAC layer would be best.

This patch comes from a request from Russell due to incompatibility between MAC
and PHY timestamping when both were supported.
https://lore.kernel.org/netdev/Y%2F4DZIDm1d74MuFJ@shell.armlinux.org.uk/

His point was adding PTP support to a PHY driver would select timestamp from it
by default even if we had a better timestamp with the MAC which is often the
case. This is an unwanted behavior.
https://lore.kernel.org/netdev/Y%2F6Cxf6EAAg22GOL@shell.armlinux.org.uk/

In fact, with the new support of NDOs hwtstamp and the
dev_get/set_hwtstamp_phylib functions, alongside this series which make
timestamp selectable, changing the default timestamp may be not necessary
anymore.

Russell any thought about it? 

Regards,
-- 
Köry Maincent, Bootlin
Embedded Linux and kernel engineering
https://bootlin.com
```
