Re: [PATCH net-next v5 08/16] net: ethtool: Add a command to expose current time stamping layer

From: Köry Maincent
Date: Mon Oct 16 2023 - 12:39:47 EST


On Mon, 16 Oct 2023 08:43:46 -0700
Jakub Kicinski <kuba@xxxxxxxxxx> wrote:

> On Mon, 16 Oct 2023 17:00:27 +0200 Köry Maincent wrote:
> > On Mon, 16 Oct 2023 07:22:04 -0700
> > Jakub Kicinski <kuba@xxxxxxxxxx> wrote:
>
> > Ok, but there might be quality difference in case of several timestamp
> > configuration done in the MAC. Like the timestamping precision vs frequency
> > precision. In that case how ethtool would tell the driver to switch between
> > them?
>
> What's the reason for timestamp precision differences?
> My understanding so far was the the differences come from:
> 1. different stamping device (i.e. separate "piece of silicon",
> accessed over a different bus, with different PHC etc.)
> 2. different stamping point (MAC vs DMA)
>
> I don't think any "integrated" device would support stamps which
> differ under category 1.

It was a case reported by Maxime on v3:
https://lore.kernel.org/netdev/20230324112541.0b3dd38a@xxxxxxxxx/


> > My solution could work for this case by simply adding new values to the
> > enum:
> >
> > enum {
> > NETDEV_TIMESTAMPING = (1 << 0),
> > PHYLIB_TIMESTAMPING = (1 << 1),
> > MAC_TS_PRECISION = (1 << 2)|(1 << 0),
> > MAC_FREQ_PRECISION = (2 << 2)|(1 << 0),
> > }
> >
> > Automatically Linux will go through the netdev implementation and could pass
> > the enum value to the netdev driver.
>
> We can add multiple fields to netlink. Why use the magic encoding?

To simplify the Linux code to go under either netdev or phylib implementation
without needing describing all the enum possibility in the condition:
if (ts_layer & PHYLIB_TIMESTAMPING)
...
if (ts_layer & NETDEV_TIMESTAMPING)
...

We also could add "is_phylib" and "is_netdev" functions with a simple switch
case in it, but we have to be careful to always update these functions when new
enum values will appear.

>
> > > But there is a big difference between MAC/PHY and DMA which would
> > > both fall under NETDEV?
> >
> > Currently there is no DMA timestamping support right?
>
> Kinda. Some devices pass DMA stamps as "HW stamps", and pretend they
> are "good enough". But yes, there's no distinction at API level.

Ok. I did suppose this when writing my last reply.

> > In that case we will have MAC and DMA under netdev and PHY under phylib and
> > we won't have to do anything more than this timestamping management patch:
> > https://lore.kernel.org/netdev/20231009155138.86458-14-kory.maincent@xxxxxxxxxxx/
> >
>
> Maybe we should start with a doc describing what APIs are at play,
> what questions they answer, and what hard use cases we have.
>
> I'm not opposed to the ethool API reporting just the differences
> from my point 1. (in the first paragraph). But then we shouldn't
> call that "layer", IMO, but device or source or such.

I am open to change the naming to fit the best for our current and future usage.
If we take into account the Maxime case of several timestamps on a device then
maybe source could work.