netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Vadim Fedorenko <vadim.fedorenko@linux.dev>
To: Kory Maincent <kory.maincent@bootlin.com>
Cc: Andrew Lunn <andrew+netdev@lunn.ch>,
	Florian Fainelli <florian.fainelli@broadcom.com>,
	Russell King <linux@armlinux.org.uk>,
	Heiner Kallweit <hkallweit1@gmail.com>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	Andrei Botila <andrei.botila@oss.nxp.com>,
	Richard Cochran <richardcochran@gmail.com>,
	Andrew Lunn <andrew@lunn.ch>, Simon Horman <horms@kernel.org>,
	Vladimir Oltean <vladimir.oltean@nxp.com>,
	Jacob Keller <jacob.e.keller@intel.com>,
	bcm-kernel-feedback-list@broadcom.com, netdev@vger.kernel.org
Subject: Re: [PATCH net-next v3 5/9] net: phy: micrel: add HW timestamp configuration reporting
Date: Wed, 19 Nov 2025 15:10:27 +0000	[thread overview]
Message-ID: <5a1cab05-bc20-43ae-b5e7-3fd22b7feed6@linux.dev> (raw)
In-Reply-To: <20251119154448.2ca40ac9@kmaincent-XPS-13-7390>

On 19/11/2025 14:44, Kory Maincent wrote:
> On Wed, 19 Nov 2025 12:47:21 +0000
> Vadim Fedorenko <vadim.fedorenko@linux.dev> wrote:
> 
>> The driver stores HW timestamping configuration and can technically
>> report it. Add callback to do it.
>>
>> Signed-off-by: Vadim Fedorenko <vadim.fedorenko@linux.dev>
>> ---
>>   drivers/net/phy/micrel.c | 27 +++++++++++++++++++++++++++
>>   1 file changed, 27 insertions(+)
>>
>> diff --git a/drivers/net/phy/micrel.c b/drivers/net/phy/micrel.c
>> index 05de68b9f719..b149d539aec3 100644
>> --- a/drivers/net/phy/micrel.c
>> +++ b/drivers/net/phy/micrel.c
>> @@ -3147,6 +3147,18 @@ static void lan8814_flush_fifo(struct phy_device
>> *phydev, bool egress) lanphy_read_page_reg(phydev, LAN8814_PAGE_PORT_REGS,
>> PTP_TSU_INT_STS); }
>>   
>> +static int lan8814_hwtstamp_get(struct mii_timestamper *mii_ts,
>> +				struct kernel_hwtstamp_config *config)
>> +{
>> +	struct kszphy_ptp_priv *ptp_priv =
>> +			  container_of(mii_ts, struct kszphy_ptp_priv,
>> mii_ts); +
>> +	config->tx_type = ptp_priv->hwts_tx_type;
>> +	config->rx_filter = ptp_priv->rx_filter;
>> +
>> +	return 0;
>> +}
>> +
>>   static int lan8814_hwtstamp_set(struct mii_timestamper *mii_ts,
>>   				struct kernel_hwtstamp_config *config,
>>   				struct netlink_ext_ack *extack)
>> @@ -4390,6 +4402,7 @@ static void lan8814_ptp_init(struct phy_device *phydev)
>>   	ptp_priv->mii_ts.rxtstamp = lan8814_rxtstamp;
>>   	ptp_priv->mii_ts.txtstamp = lan8814_txtstamp;
>>   	ptp_priv->mii_ts.hwtstamp_set = lan8814_hwtstamp_set;
>> +	ptp_priv->mii_ts.hwtstamp_get = lan8814_hwtstamp_get;
>>   	ptp_priv->mii_ts.ts_info  = lan8814_ts_info;
>>   
>>   	phydev->mii_ts = &ptp_priv->mii_ts;
>> @@ -5042,6 +5055,19 @@ static void lan8841_ptp_enable_processing(struct
>> kszphy_ptp_priv *ptp_priv, #define LAN8841_PTP_TX_TIMESTAMP_EN
>> 443 #define LAN8841_PTP_TX_MOD			445
>>   
>> +static int lan8841_hwtstamp_get(struct mii_timestamper *mii_ts,
>> +				struct kernel_hwtstamp_config *config)
>> +{
>> +	struct kszphy_ptp_priv *ptp_priv;
>> +
>> +	ptp_priv = container_of(mii_ts, struct kszphy_ptp_priv, mii_ts);
>> +
>> +	config->tx_type = ptp_priv->hwts_tx_type;
>> +	config->rx_filter = ptp_priv->rx_filter;
> 
> Something related to this patch, it seems there is an issue in the set
> callback:
> https://elixir.bootlin.com/linux/v6.18-rc6/source/drivers/net/phy/micrel.c#L3056
> 
> The priv->rx_filter and priv->hwts_tx_type are set before the switch condition.
> The hwtstamp_get can then report something that is not supported.
> Also HWTSTAMP_TX_ONESTEP_P2P is not managed by the driver but not returning
> -ERANGE either so if we set this config the hwtstamp_get will report something
> wrong as not supported.
> I think you will need to add a new patch here to fix the hwtstamp_set ops.

I agree, that there is a problem in the flow, but such change is out of
scope of this patch set. I'm going to provide some logic improvements on
per-driver basis as follow up work.

> Maybe we should update net_hwtstamp_validate to check on the capabilities
> reported by ts_info but that is a bigger change.

In this case we have to introduce validation callback and implement it
in drivers. Some drivers do downgrade filter values if provided value is
not in the list of what was provided in ethtool::ts_info. And we have to
keep this logic as otherwise it may be considered as API breakage.

> 
>> +
>> +	return 0;
>> +}
>> +
>>   static int lan8841_hwtstamp_set(struct mii_timestamper *mii_ts,
>>   				struct kernel_hwtstamp_config *config,
>>   				struct netlink_ext_ack *extack)
>> @@ -5925,6 +5951,7 @@ static int lan8841_probe(struct phy_device *phydev)
>>   	ptp_priv->mii_ts.rxtstamp = lan8841_rxtstamp;
>>   	ptp_priv->mii_ts.txtstamp = lan8814_txtstamp;
>>   	ptp_priv->mii_ts.hwtstamp_set = lan8841_hwtstamp_set;
>> +	ptp_priv->mii_ts.hwtstamp_get = lan8841_hwtstamp_get;
>>   	ptp_priv->mii_ts.ts_info = lan8841_ts_info;
>>   
>>   	phydev->mii_ts = &ptp_priv->mii_ts;
> 
> 
> 


  reply	other threads:[~2025-11-19 15:11 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-19 12:47 [PATCH net-next v3 0/9] add hwtstamp_get callback to phy drivers Vadim Fedorenko
2025-11-19 12:47 ` [PATCH net-next v3 1/9] phy: rename hwtstamp callback to hwtstamp_set Vadim Fedorenko
2025-11-19 13:23   ` Russell King (Oracle)
2025-11-19 13:50   ` Kory Maincent
2025-11-19 12:47 ` [PATCH net-next v3 2/9] phy: add hwtstamp_get callback to phy drivers Vadim Fedorenko
2025-11-19 13:24   ` Russell King (Oracle)
2025-11-19 14:09   ` Kory Maincent
2025-11-19 12:47 ` [PATCH net-next v3 3/9] net: phy: broadcom: add HW timestamp configuration reporting Vadim Fedorenko
2025-11-19 14:12   ` Kory Maincent
2025-11-19 12:47 ` [PATCH net-next v3 4/9] net: phy: dp83640: " Vadim Fedorenko
2025-11-19 14:13   ` Kory Maincent
2025-11-19 12:47 ` [PATCH net-next v3 5/9] net: phy: micrel: " Vadim Fedorenko
2025-11-19 14:44   ` Kory Maincent
2025-11-19 15:10     ` Vadim Fedorenko [this message]
2025-11-19 15:26       ` Kory Maincent
2025-11-19 12:47 ` [PATCH net-next v3 6/9] net: phy: microchip_rds_ptp: " Vadim Fedorenko
2025-11-19 14:46   ` Kory Maincent
2025-11-19 12:47 ` [PATCH net-next v3 7/9] phy: mscc: " Vadim Fedorenko
2025-11-19 14:48   ` Kory Maincent
2025-11-19 12:47 ` [PATCH net-next v3 8/9] net: phy: nxp-c45-tja11xx: " Vadim Fedorenko
2025-11-19 14:50   ` Kory Maincent
2025-11-19 12:47 ` [PATCH net-next v3 9/9] ptp: ptp_ines: " Vadim Fedorenko
2025-11-19 14:59   ` Kory Maincent
2025-11-19 15:14     ` Vadim Fedorenko

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=5a1cab05-bc20-43ae-b5e7-3fd22b7feed6@linux.dev \
    --to=vadim.fedorenko@linux.dev \
    --cc=andrei.botila@oss.nxp.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=andrew@lunn.ch \
    --cc=bcm-kernel-feedback-list@broadcom.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=florian.fainelli@broadcom.com \
    --cc=hkallweit1@gmail.com \
    --cc=horms@kernel.org \
    --cc=jacob.e.keller@intel.com \
    --cc=kory.maincent@bootlin.com \
    --cc=kuba@kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=richardcochran@gmail.com \
    --cc=vladimir.oltean@nxp.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).