From: Kory Maincent <kory.maincent@bootlin.com>
To: Jakub Kicinski <kuba@kernel.org>
Cc: Andrew Lunn <andrew@lunn.ch>,
Donald Hunter <donald.hunter@gmail.com>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Paolo Abeni <pabeni@redhat.com>, Simon Horman <horms@kernel.org>,
Willem de Bruijn <willemdebruijn.kernel@gmail.com>,
Jason Xing <kernelxing@tencent.com>,
Richard Cochran <richardcochran@gmail.com>,
Thomas Petazzoni <thomas.petazzoni@bootlin.com>,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
Maxime Chevallier <maxime.chevallier@bootlin.com>,
"Russell King (Oracle)" <linux@armlinux.org.uk>
Subject: Re: [PATCH net-next] net: Add support for providing the PTP hardware source in tsinfo
Date: Tue, 6 May 2025 00:17:58 +0200 [thread overview]
Message-ID: <20250506001758.297449f1@kmaincent-XPS-13-7390> (raw)
In-Reply-To: <20250429150657.1f32a10c@kernel.org>
Thanks for the review!
On Tue, 29 Apr 2025 15:06:57 -0700
Jakub Kicinski <kuba@kernel.org> wrote:
> On Fri, 25 Apr 2025 19:42:43 +0200 Kory Maincent wrote:
> > Multi-PTP source support within a network topology has been merged,
> > but the hardware timestamp source is not yet exposed to users.
> > Currently, users only see the PTP index, which does not indicate
> > whether the timestamp comes from a PHY or a MAC.
> >
> > Add support for reporting the hwtstamp source using a
> > hwtstamp-source field, alongside hwtstamp-phyindex, to describe
> > the origin of the hardware timestamp.
> >
> > Signed-off-by: Kory Maincent <kory.maincent@bootlin.com>
> > ---
> > Not sure moving the hwtstamp_source enum to uapi/linux/net_tstamp.h and
> > adding this header to ynl/Makefile.deps is the best choice. Maybe it is
> > better to move the enum directly to ethtool.h header.
>
> Weak preference for the YAML and therefore ethtool.h from my side.
> That way the doc strings will propagate to more places, like the HTML
> docs.
Ack.
> > diff --git a/include/linux/net_tstamp.h b/include/linux/net_tstamp.h
> > index
> > ff0758e88ea1008efe533cde003b12719bf4fcd3..1414aed0b6adeae15b56e7a99a7d9eeb43ba0b6c
> > 100644 --- a/include/linux/net_tstamp.h +++ b/include/linux/net_tstamp.h
> > @@ -13,12 +13,6 @@
> > SOF_TIMESTAMPING_TX_HARDWARE | \
> > SOF_TIMESTAMPING_RAW_HARDWARE)
> >
> > -enum hwtstamp_source {
> > - HWTSTAMP_SOURCE_UNSPEC,
>
> when is unspec used in practice? Only path I could spot that may not
> set it is if we fetch the data by PHC index?
Indeed it is not used. I think it get merged in one of the several version
tackling the "make PTP selectable support" work. As it is finally not used we
could drop it.
> > - HWTSTAMP_SOURCE_NETDEV,
> > - HWTSTAMP_SOURCE_PHYLIB,
> > -};
> > -
> > /**
> > * struct hwtstamp_provider_desc - hwtstamp provider description
> > *
>
> > diff --git a/include/uapi/linux/net_tstamp.h
> > b/include/uapi/linux/net_tstamp.h index
> > a93e6ea37fb3a69f331b1c90851d4e68cb659a83..bf5fb9f7acf5c03aaa121e0cda3c0b1d83e49f71
> > 100644 --- a/include/uapi/linux/net_tstamp.h +++
> > b/include/uapi/linux/net_tstamp.h @@ -13,6 +13,19 @@
> > #include <linux/types.h>
> > #include <linux/socket.h> /* for SO_TIMESTAMPING */
> >
> > +/**
> > + * enum hwtstamp_source - Source of the hardware timestamp
> > + * @HWTSTAMP_SOURCE_UNSPEC: Source not specified or unknown
> > + * @HWTSTAMP_SOURCE_NETDEV: Hardware timestamp comes from the net device
>
> We should probably document that netdev here means that the timestamp
> comes from a MAC or device which has MAC and PHY integrated together?
Yes, I will.
>
> > + * @HWTSTAMP_SOURCE_PHYLIB: Hardware timestamp comes from one of the PHY
> > + * devices of the network topology
> > + */
> > +enum hwtstamp_source {
> > + HWTSTAMP_SOURCE_UNSPEC,
> > + HWTSTAMP_SOURCE_NETDEV,
> > + HWTSTAMP_SOURCE_PHYLIB,
> > +};
>
> > --- a/net/ethtool/common.c
> > +++ b/net/ethtool/common.c
> > @@ -920,12 +920,20 @@ int ethtool_get_ts_info_by_phc(struct net_device *dev,
> > struct phy_device *phy;
> >
> > phy = ethtool_phy_get_ts_info_by_phc(dev, info,
> > hwprov_desc);
> > - if (IS_ERR(phy))
> > + if (IS_ERR(phy)) {
> > err = PTR_ERR(phy);
> > - else
> > - err = 0;
> > + goto out;
> > + }
> > +
> > + info->phc_source = HWTSTAMP_SOURCE_PHYLIB;
> > + info->phc_phyindex = phy->phyindex;
> > + err = 0;
> > + goto out;
>
> The goto before the else looks a bit odd now.
> Can we return directly in the error cases?
> There is no cleanup to be done.
Yes indeed.
> > + } else {
> > + info->phc_source = HWTSTAMP_SOURCE_NETDEV;
> > }
> >
> > +out:
> > info->so_timestamping |= SOF_TIMESTAMPING_RX_SOFTWARE |
> > SOF_TIMESTAMPING_SOFTWARE;
> >
> > @@ -947,10 +955,14 @@ int __ethtool_get_ts_info(struct net_device *dev,
> >
> > ethtool_init_tsinfo(info);
> > if (phy_is_default_hwtstamp(phydev) &&
> > - phy_has_tsinfo(phydev))
> > + phy_has_tsinfo(phydev)) {
> > err = phy_ts_info(phydev, info);
> > - else if (ops->get_ts_info)
> > + info->phc_source = HWTSTAMP_SOURCE_PHYLIB;
> > + info->phc_phyindex = phydev->phyindex;
> > + } else if (ops->get_ts_info) {
> > err = ops->get_ts_info(dev, info);
> > + info->phc_source = HWTSTAMP_SOURCE_NETDEV;
>
> Let's move the assignment before the calls if we can?
> Otherwise someone adding code below may miss the fact that err may
> already be carrying an unhandled error.
Ack.
--
Köry Maincent, Bootlin
Embedded Linux and kernel engineering
https://bootlin.com
prev parent reply other threads:[~2025-05-05 22:18 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-25 17:42 [PATCH net-next] net: Add support for providing the PTP hardware source in tsinfo Kory Maincent
2025-04-27 0:26 ` Jason Xing
2025-04-27 12:46 ` Kory Maincent
2025-04-29 22:06 ` Jakub Kicinski
2025-05-05 22:17 ` Kory Maincent [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=20250506001758.297449f1@kmaincent-XPS-13-7390 \
--to=kory.maincent@bootlin.com \
--cc=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=donald.hunter@gmail.com \
--cc=edumazet@google.com \
--cc=horms@kernel.org \
--cc=kernelxing@tencent.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=maxime.chevallier@bootlin.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=richardcochran@gmail.com \
--cc=thomas.petazzoni@bootlin.com \
--cc=willemdebruijn.kernel@gmail.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