Hi Javen
On 1.12.2026 10:44, javen wrote:
> From: Javen Xu <jave…@realsil.com.cn>
>
> The PTP block of the RTL8127a internal PHY also timestamps PTPv2 event
> messages over UDP in both directions. Register a mii_timestamper for it,
> so the PHY can provide hardware timestamps without any support from the
> MAC driver.
>
> The timestamps are read out over MDIO, which may sleep, so this is done
> from the PTP aux worker. Received packets are queued until their
> timestamp has been read, transmitted packets are completed once the
> hardware reports their timestamp.
>
> The hardware only keeps the most recent timestamp per message type and
> direction and does not record the sequenceId. Hence only one TX
> timestamp can be pending at a time, it is dropped if nothing arrives
> within 15 seconds, and an RX timestamp may be overwritten by a later
> message of the same type before it has been read.
>
> Signed-off-by: Javen Xu <jave…@realsil.com.cn>
> ---
> [...]
> +void rtl8127a_ptp_link_change_notify(struct phy_device *phydev)
> +{
> + struct rtl8127a_ptp *ptp = phydev->priv;
> + int ret = 0;
> +
> + if (!ptp || !phydev->link)
> + return;
> +
> + mutex_lock(&ptp->lock);
> + /* Restore timestamping in case the PTP block was reset. */
> + if (ptp->hw_enabled) {
> + ret = rtl8127a_ptp_read(ptp, RTL8127A_PTP_CTL);
> + if (ret >= 0 && !(ret & RTL8127A_PTP_CTL_EN))
> + ret = __rtl8127a_ptp_hwtstamp_enable(ptp, true);
phy_detach() clears dev->hwprov on down/up, so the PHY is no longer the
selected after that. Should this still turn timestamping back on?
> [...]
> +static int rtl8127a_ptp_ts_info(struct mii_timestamper *mii_ts,
> + struct kernel_ethtool_ts_info *info)
> +{
> + struct rtl8127a_ptp *ptp = container_of(mii_ts, struct rtl8127a_ptp,
> + mii_ts);
> +
> + info->so_timestamping = SOF_TIMESTAMPING_TX_SOFTWARE |
Please drop TX_SOFTWARE, that's for the MAC to report.
> [...]
Thanks,
Nicolai