[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <12c8b9e9-4375-4d52-b8f4-afccba49448c@linux.dev>
Date: Thu, 13 Nov 2025 12:12:44 +0000
From: Vadim Fedorenko <vadim.fedorenko@...ux.dev>
To: "Russell King (Oracle)" <linux@...linux.org.uk>
Cc: Andrew Lunn <andrew+netdev@...n.ch>,
Florian Fainelli <florian.fainelli@...adcom.com>,
Heiner Kallweit <hkallweit1@...il.com>, "David S. Miller"
<davem@...emloft.net>, Eric Dumazet <edumazet@...gle.com>,
Jakub Kicinski <kuba@...nel.org>, Paolo Abeni <pabeni@...hat.com>,
Andrei Botila <andrei.botila@....nxp.com>,
Richard Cochran <richardcochran@...il.com>, Andrew Lunn <andrew@...n.ch>,
Simon Horman <horms@...nel.org>, Vladimir Oltean <vladimir.oltean@....com>,
Jacob Keller <jacob.e.keller@...el.com>,
Kory Maincent <kory.maincent@...tlin.com>,
bcm-kernel-feedback-list@...adcom.com, netdev@...r.kernel.org
Subject: Re: [PATCH net-next v2 2/9] phy: add hwtstamp_get callback to phy
drivers
On 13/11/2025 12:02, Russell King (Oracle) wrote:
> On Thu, Nov 13, 2025 at 11:32:00AM +0000, Vadim Fedorenko wrote:
>> PHY devices had lack of hwtstamp_get callback even though most of them
>> are tracking configuration info. Introduce new call back to
>> mii_timestamper.
>>
>> Signed-off-by: Vadim Fedorenko <vadim.fedorenko@...ux.dev>
>
> As part of my Marvell PTP work, I have a similar patch, but it's
> way simpler. Is this not sufficient?
>
> __phy_hwtstamp_get() is called via phylib_stubs struct and
> phy_hwtstamp_get(), dev_get_hwtstamp_phylib(), dev_get_hwtstamp(),
> and dev_ifsioc().
>
> Using the phylib ioctl handler means we're implementing a path that
> is already marked as legacy - see dev_get_hwtstamp():
>
> if (!ops->ndo_hwtstamp_get)
> return dev_eth_ioctl(dev, ifr, SIOCGHWTSTAMP); /* legacy */
>
> So, I think the below would be the preferred implementation.
You mean do not add SIOCGHWTSTAMP case in phy_mii_ioctl() as we should
never reach this legacy option? Technically, some drivers are (yet) not
converted to ndo_hwtstamp callbacks and this part can potentially work
for bnx2x driver, until the other series lands.
I was planning to remove SIOCSHWTSTAMP/SIOCGHWTSTAMP dev_eth_ioctl calls
later once everything has landed and we have tests confirming that ioctl
and netlink interfaces work exactly the same way.
>
> 8<===
> From: "Russell King (Oracle)" <rmk+kernel@...linux.org.uk>
> Subject: [PATCH net-next] net: phy: add hwtstamp_get() method for mii
> timestampers
>
> Add the missing hwtstamp_get() method for mii timestampers so PHYs can
> report their configuration back to userspace.
>
> Signed-off-by: Russell King (Oracle) <rmk+kernel@...linux.org.uk>
> ---
> drivers/net/phy/phy.c | 3 +++
> include/linux/mii_timestamper.h | 5 +++++
> 2 files changed, 8 insertions(+)
>
> diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
> index 02da4a203ddd..b6fae9299b36 100644
> --- a/drivers/net/phy/phy.c
> +++ b/drivers/net/phy/phy.c
> @@ -476,6 +476,9 @@ int __phy_hwtstamp_get(struct phy_device *phydev,
> if (!phydev)
> return -ENODEV;
>
> + if (phydev->mii_ts && phydev->mii_ts->hwtstamp_get)
> + return phydev->mii_ts->hwtstamp_get(phydev->mii_ts, config);
> +
> return -EOPNOTSUPP;
> }
>
> diff --git a/include/linux/mii_timestamper.h b/include/linux/mii_timestamper.h
> index 995db62570f9..b6485f602eb9 100644
> --- a/include/linux/mii_timestamper.h
> +++ b/include/linux/mii_timestamper.h
> @@ -29,6 +29,8 @@ struct phy_device;
> *
> * @hwtstamp: Handles SIOCSHWTSTAMP ioctl for hardware time stamping.
> *
> + * @hwtstamp_get: Handles SIOCGHWTSTAMP ioctl for hardware time stamping.
> + *
> * @link_state: Allows the device to respond to changes in the link
> * state. The caller invokes this function while holding
> * the phy_device mutex.
> @@ -55,6 +57,9 @@ struct mii_timestamper {
> struct kernel_hwtstamp_config *kernel_config,
> struct netlink_ext_ack *extack);
>
> + int (*hwtstamp_get)(struct mii_timestamper *mii_ts,
> + struct kernel_hwtstamp_config *kernel_config);
> +
> void (*link_state)(struct mii_timestamper *mii_ts,
> struct phy_device *phydev);
>
Powered by blists - more mailing lists