Commit 0f7f463d authored by Kory Maincent's avatar Kory Maincent Committed by David S. Miller
Browse files

net: Change the API of PHY default timestamp to MAC



Change the API to select MAC default time stamping instead of the PHY.
Indeed the PHY is closer to the wire therefore theoretically it has less
delay than the MAC timestamping but the reality is different. Due to lower
time stamping clock frequency, latency in the MDIO bus and no PHC hardware
synchronization between different PHY, the PHY PTP is often less precise
than the MAC. The exception is for PHY designed specially for PTP case but
these devices are not very widespread. For not breaking the compatibility I
introduce a default_timestamp flag in phy_device that is set by the phy
driver to know we are using the old API behavior.

The phy_set_timestamp function is called at each call of phy_attach_direct.
In case of MAC driver using phylink this function is called when the
interface is turned up. Then if the interface goes down and up again the
last choice of timestamp will be overwritten by the default choice.
A solution could be to cache the timestamp status but it can bring other
issues. In case of SFP, if we change the module, it doesn't make sense to
blindly re-set the timestamp back to PHY, if the new module has a PHY with
mediocre timestamping capabilities.

Signed-off-by: default avatarKory Maincent <kory.maincent@bootlin.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 51bdf316
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -931,6 +931,9 @@ struct bcm_ptp_private *bcm_ptp_probe(struct phy_device *phydev)
		return ERR_CAST(clock);
	priv->ptp_clock = clock;

	/* Timestamp selected by default to keep legacy API */
	phydev->default_timestamp = true;

	priv->phydev = phydev;
	bcm_ptp_init(priv);

+3 −0
Original line number Diff line number Diff line
@@ -1450,6 +1450,9 @@ static int dp83640_probe(struct phy_device *phydev)
	phydev->mii_ts = &dp83640->mii_ts;
	phydev->priv = dp83640;

	/* Timestamp selected by default to keep legacy API */
	phydev->default_timestamp = true;

	spin_lock_init(&dp83640->rx_lock);
	skb_queue_head_init(&dp83640->rx_queue);
	skb_queue_head_init(&dp83640->tx_queue);
+6 −0
Original line number Diff line number Diff line
@@ -3158,6 +3158,9 @@ static void lan8814_ptp_init(struct phy_device *phydev)
	ptp_priv->mii_ts.ts_info  = lan8814_ts_info;

	phydev->mii_ts = &ptp_priv->mii_ts;

	/* Timestamp selected by default to keep legacy API */
	phydev->default_timestamp = true;
}

static int lan8814_ptp_probe_once(struct phy_device *phydev)
@@ -4586,6 +4589,9 @@ static int lan8841_probe(struct phy_device *phydev)

	phydev->mii_ts = &ptp_priv->mii_ts;

	/* Timestamp selected by default to keep legacy API */
	phydev->default_timestamp = true;

	return 0;
}

+2 −0
Original line number Diff line number Diff line
@@ -1570,6 +1570,8 @@ int vsc8584_ptp_probe(struct phy_device *phydev)
		return PTR_ERR(vsc8531->load_save);
	}

	/* Timestamp selected by default to keep legacy API */
	phydev->default_timestamp = true;
	vsc8531->ptp->phydev = phydev;

	return 0;
+3 −0
Original line number Diff line number Diff line
@@ -1658,6 +1658,9 @@ static int nxp_c45_probe(struct phy_device *phydev)
		priv->mii_ts.ts_info = nxp_c45_ts_info;
		phydev->mii_ts = &priv->mii_ts;
		ret = nxp_c45_init_ptp_clock(priv);

		/* Timestamp selected by default to keep legacy API */
		phydev->default_timestamp = true;
	} else {
		phydev_dbg(phydev, "PTP support not enabled even if the phy supports it");
	}
Loading