* [PATCH net 0/2] net: phy: broadcom: fix P2P timestamping @ 2026-11-27 9:50 James Clark 2026-11-27 9:50 ` [PATCH net 1/2] net: phy: broadcom: fix two-step " James Clark 2026-11-27 9:50 ` [PATCH net 2/2] net: phy: broadcom: fix one-step " James Clark 0 siblings, 2 replies; 7+ messages in thread From: James Clark @ 2026-11-27 9:50 UTC (permalink / raw) To: Florian Fainelli, Andrew Lunn, Heiner Kallweit, David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni, Richard Cochran Cc: Russell King, Broadcom internal kernel review list, Jonathan Lemon, netdev On a Raspberry Pi CM4 and CM5, the BCM54210PE PHY sends an incorrect Pdelay_Resp, so a peer using P2P measures a path delay that is tens of microseconds too large. This happens with both two-step and one-step P2P, for different reasons, and the two patches fix them separately. Users of the Raspberry Pi CM4 and CM5 reported the two-step problem: https://github.com/jclark/rpi-cm4-ptp-guide/issues/34 https://github.com/jclark/rpi-cm4-ptp-guide/issues/49 Patch 1 fixes two-step P2P, the common case. Patch 2 fixes one-step P2P, which the driver sets up as for two-step. PTP over UDPv6 does not work in either E2E or P2P mode, because when the PHY writes a timestamp into an outgoing message, it sets the UDP checksum to zero; this series does not change this. I used an LLM coding assistant to help prepare these patches. James Clark (2): net: phy: broadcom: fix two-step P2P timestamping net: phy: broadcom: fix one-step P2P timestamping drivers/net/phy/bcm-phy-ptp.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) base-commit: e1055cbfd6eb578417f3ce983cf44462e8465267 -- 2.56.1 ^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH net 1/2] net: phy: broadcom: fix two-step P2P timestamping 2026-11-27 9:50 [PATCH net 0/2] net: phy: broadcom: fix P2P timestamping James Clark @ 2026-11-27 9:50 ` James Clark 2026-12-02 9:53 ` Nicolai Buchwitz 2026-12-02 19:17 ` Florian Fainelli 2026-11-27 9:50 ` [PATCH net 2/2] net: phy: broadcom: fix one-step " James Clark 1 sibling, 2 replies; 7+ messages in thread From: James Clark @ 2026-11-27 9:50 UTC (permalink / raw) To: Florian Fainelli, Andrew Lunn, Heiner Kallweit, David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni, Richard Cochran Cc: Russell King, Broadcom internal kernel review list, Jonathan Lemon, netdev On a Raspberry Pi CM4 and CM5, with two-step P2P, the BCM54210PE PHY sends an incorrect Pdelay_Resp: its requestReceiptTimestamp is the time the Pdelay_Resp was sent, not the time the Pdelay_Req was received. This is because the driver puts every PTP event message in TX mode 3, in which the PHY writes the TX timestamp into the message. The peer then measures a path delay that is tens of microseconds too large. Use mode 0 for Pdelay_Resp, in which the PHY leaves the message unchanged and still captures the TX timestamp. With this patch, on the CM4, the path delay measured with P2P is the same as with E2E. Fixes: 39db6be781cd ("net: phy: broadcom: Add PTP support for some Broadcom PHYs.") Cc: stable@vger.kernel.org Signed-off-by: James Clark <jjc@jclark.com> --- drivers/net/phy/bcm-phy-ptp.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/net/phy/bcm-phy-ptp.c b/drivers/net/phy/bcm-phy-ptp.c index 443917c9d1bc..4b24ba7115d7 100644 --- a/drivers/net/phy/bcm-phy-ptp.c +++ b/drivers/net/phy/bcm-phy-ptp.c @@ -826,8 +826,7 @@ static int bcm_ptp_hwtstamp_set(struct mii_timestamper *mii_ts, mode = TX_MODE_SEL(PORT, SYNC, REPLACE_TS) | TX_MODE_SEL(PORT, DELAY_REQ, REPLACE_TS) | - TX_MODE_SEL(PORT, PDELAY_REQ, REPLACE_TS) | - TX_MODE_SEL(PORT, PDELAY_RESP, REPLACE_TS); + TX_MODE_SEL(PORT, PDELAY_REQ, REPLACE_TS); bcm_phy_write_exp(priv->phydev, TX_EVENT_MODE, mode); -- 2.56.1 ^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH net 1/2] net: phy: broadcom: fix two-step P2P timestamping 2026-11-27 9:50 ` [PATCH net 1/2] net: phy: broadcom: fix two-step " James Clark @ 2026-12-02 9:53 ` Nicolai Buchwitz 2026-12-02 19:17 ` Florian Fainelli 1 sibling, 0 replies; 7+ messages in thread From: Nicolai Buchwitz @ 2026-12-02 9:53 UTC (permalink / raw) To: James Clark Cc: Florian Fainelli, Andrew Lunn, Heiner Kallweit, David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni, Richard Cochran, Russell King, Broadcom internal kernel review list, Jonathan Lemon, netdev On 27.11.2026 10:50, James Clark wrote: > On a Raspberry Pi CM4 and CM5, with two-step P2P, the BCM54210PE PHY > sends an incorrect Pdelay_Resp: its requestReceiptTimestamp is the time > the Pdelay_Resp was sent, not the time the Pdelay_Req was received. > This is because the driver puts every PTP event message in TX mode 3, > in which the PHY writes the TX timestamp into the message. The peer > then measures a path delay that is tens of microseconds too large. > > Use mode 0 for Pdelay_Resp, in which the PHY leaves the message > unchanged and still captures the TX timestamp. > > With this patch, on the CM4, the path delay measured with P2P is the > same as with E2E. > > Fixes: 39db6be781cd ("net: phy: broadcom: Add PTP support for some > Broadcom PHYs.") > Cc: stable@vger.kernel.org > Signed-off-by: James Clark <jjc@jclark.com> > --- > drivers/net/phy/bcm-phy-ptp.c | 3 +-- > 1 file changed, 1 insertion(+), 2 deletions(-) > > diff --git a/drivers/net/phy/bcm-phy-ptp.c > b/drivers/net/phy/bcm-phy-ptp.c > index 443917c9d1bc..4b24ba7115d7 100644 > --- a/drivers/net/phy/bcm-phy-ptp.c > +++ b/drivers/net/phy/bcm-phy-ptp.c > @@ -826,8 +826,7 @@ static int bcm_ptp_hwtstamp_set(struct > mii_timestamper *mii_ts, > > mode = TX_MODE_SEL(PORT, SYNC, REPLACE_TS) | > TX_MODE_SEL(PORT, DELAY_REQ, REPLACE_TS) | > - TX_MODE_SEL(PORT, PDELAY_REQ, REPLACE_TS) | > - TX_MODE_SEL(PORT, PDELAY_RESP, REPLACE_TS); > + TX_MODE_SEL(PORT, PDELAY_REQ, REPLACE_TS); > > bcm_phy_write_exp(priv->phydev, TX_EVENT_MODE, mode); Tested-by: Nicolai Buchwitz <nb@tipi-net.de> # CM4, CM5 Reviewed-by: Nicolai Buchwitz <nb@tipi-net.de> Thanks, Nicolai ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH net 1/2] net: phy: broadcom: fix two-step P2P timestamping 2026-11-27 9:50 ` [PATCH net 1/2] net: phy: broadcom: fix two-step " James Clark 2026-12-02 9:53 ` Nicolai Buchwitz @ 2026-12-02 19:17 ` Florian Fainelli 1 sibling, 0 replies; 7+ messages in thread From: Florian Fainelli @ 2026-12-02 19:17 UTC (permalink / raw) To: James Clark, Andrew Lunn, Heiner Kallweit, David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni, Richard Cochran Cc: Russell King, Broadcom internal kernel review list, Jonathan Lemon, netdev On 11/27/26 01:50, James Clark wrote: > On a Raspberry Pi CM4 and CM5, with two-step P2P, the BCM54210PE PHY > sends an incorrect Pdelay_Resp: its requestReceiptTimestamp is the time > the Pdelay_Resp was sent, not the time the Pdelay_Req was received. > This is because the driver puts every PTP event message in TX mode 3, > in which the PHY writes the TX timestamp into the message. The peer > then measures a path delay that is tens of microseconds too large. > > Use mode 0 for Pdelay_Resp, in which the PHY leaves the message > unchanged and still captures the TX timestamp. > > With this patch, on the CM4, the path delay measured with P2P is the > same as with E2E. > > Fixes: 39db6be781cd ("net: phy: broadcom: Add PTP support for some Broadcom PHYs.") > Cc: stable@vger.kernel.org > Signed-off-by: James Clark <jjc@jclark.com> Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com> -- Florian ^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH net 2/2] net: phy: broadcom: fix one-step P2P timestamping 2026-11-27 9:50 [PATCH net 0/2] net: phy: broadcom: fix P2P timestamping James Clark 2026-11-27 9:50 ` [PATCH net 1/2] net: phy: broadcom: fix two-step " James Clark @ 2026-11-27 9:50 ` James Clark 2026-12-02 9:54 ` Nicolai Buchwitz 2026-12-02 19:17 ` Florian Fainelli 1 sibling, 2 replies; 7+ messages in thread From: James Clark @ 2026-11-27 9:50 UTC (permalink / raw) To: Florian Fainelli, Andrew Lunn, Heiner Kallweit, David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni, Richard Cochran Cc: Russell King, Broadcom internal kernel review list, Jonathan Lemon, netdev On a Raspberry Pi CM4 and CM5, with one-step P2P, the BCM54210PE PHY sends an incorrect Pdelay_Resp: its correctionField does not include the time between receiving the Pdelay_Req and sending the Pdelay_Resp. This is because the driver sets up the PHY as for two-step. The peer then measures a path delay that is tens of microseconds too large. With one-step P2P, use mode 1 for Pdelay_Req on receive and for Pdelay_Resp on transmit; in this mode the PHY adds the time between the two to the correctionField. Also skip the normal processing of an RX timestamp for a Pdelay_Req, since in this mode the PHY does not insert one. Reject one-step P2P when the filter is HWTSTAMP_FILTER_NONE, since that filter turns off the PHY's processing of received messages, which would make the correctionField of Pdelay_Resp be incorrect. With this patch, on the CM4, the path delay measured with one-step P2P is the same as with E2E, over L2 and UDPv4. The PHY keeps the UDP checksum of Pdelay_Resp valid over UDPv4 and UDPv6, still captures the TX timestamp of Pdelay_Resp, and handles a Pdelay_Req and Pdelay_Resp on either side of a second boundary. Fixes: 39db6be781cd ("net: phy: broadcom: Add PTP support for some Broadcom PHYs.") Cc: stable@vger.kernel.org Signed-off-by: James Clark <jjc@jclark.com> --- drivers/net/phy/bcm-phy-ptp.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/drivers/net/phy/bcm-phy-ptp.c b/drivers/net/phy/bcm-phy-ptp.c index 4b24ba7115d7..42bd280ec80c 100644 --- a/drivers/net/phy/bcm-phy-ptp.c +++ b/drivers/net/phy/bcm-phy-ptp.c @@ -399,6 +399,13 @@ static bool bcm_ptp_rxtstamp(struct mii_timestamper *mii_ts, if (!header) return false; + /* In one-step P2P, the PHY updates the correctionField of + * Pdelay_Req instead of inserting a timestamp. + */ + if (priv->tx_type == HWTSTAMP_TX_ONESTEP_P2P && + ptp_get_msgtype(header, type) == PTP_MSGTYPE_PDELAY_REQ) + return false; + data = (u8 *)(header + 1); sec = get_unaligned_be32(data); nsec = get_unaligned_be32(data + 4); @@ -801,6 +808,8 @@ static int bcm_ptp_hwtstamp_set(struct mii_timestamper *mii_ts, switch (cfg->rx_filter) { case HWTSTAMP_FILTER_NONE: + if (cfg->tx_type == HWTSTAMP_TX_ONESTEP_P2P) + return -ERANGE; priv->hwts_rx = false; break; case HWTSTAMP_FILTER_PTP_V2_L4_EVENT: @@ -827,13 +836,18 @@ static int bcm_ptp_hwtstamp_set(struct mii_timestamper *mii_ts, mode = TX_MODE_SEL(PORT, SYNC, REPLACE_TS) | TX_MODE_SEL(PORT, DELAY_REQ, REPLACE_TS) | TX_MODE_SEL(PORT, PDELAY_REQ, REPLACE_TS); + if (priv->tx_type == HWTSTAMP_TX_ONESTEP_P2P) + mode |= TX_MODE_SEL(PORT, PDELAY_RESP, UPDATE_CF); bcm_phy_write_exp(priv->phydev, TX_EVENT_MODE, mode); mode = RX_MODE_SEL(PORT, SYNC, INSERT_TS_64) | RX_MODE_SEL(PORT, DELAY_REQ, INSERT_TS_64) | - RX_MODE_SEL(PORT, PDELAY_REQ, INSERT_TS_64) | RX_MODE_SEL(PORT, PDELAY_RESP, INSERT_TS_64); + if (priv->tx_type == HWTSTAMP_TX_ONESTEP_P2P) + mode |= RX_MODE_SEL(PORT, PDELAY_REQ, UPDATE_CF); + else + mode |= RX_MODE_SEL(PORT, PDELAY_REQ, INSERT_TS_64); bcm_phy_write_exp(priv->phydev, RX_EVENT_MODE, mode); -- 2.56.1 ^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH net 2/2] net: phy: broadcom: fix one-step P2P timestamping 2026-11-27 9:50 ` [PATCH net 2/2] net: phy: broadcom: fix one-step " James Clark @ 2026-12-02 9:54 ` Nicolai Buchwitz 2026-12-02 19:17 ` Florian Fainelli 1 sibling, 0 replies; 7+ messages in thread From: Nicolai Buchwitz @ 2026-12-02 9:54 UTC (permalink / raw) To: James Clark Cc: Florian Fainelli, Andrew Lunn, Heiner Kallweit, David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni, Richard Cochran, Russell King, Broadcom internal kernel review list, Jonathan Lemon, netdev On 27.11.2026 10:50, James Clark wrote: > On a Raspberry Pi CM4 and CM5, with one-step P2P, the BCM54210PE PHY > sends an incorrect Pdelay_Resp: its correctionField does not include > the time between receiving the Pdelay_Req and sending the Pdelay_Resp. > This is because the driver sets up the PHY as for two-step. The peer > then measures a path delay that is tens of microseconds too large. > > With one-step P2P, use mode 1 for Pdelay_Req on receive and for > Pdelay_Resp on transmit; in this mode the PHY adds the time between the > two to the correctionField. Also skip the normal processing of an RX > timestamp for a Pdelay_Req, since in this mode the PHY does not insert > one. Reject one-step P2P when the filter is HWTSTAMP_FILTER_NONE, since > that filter turns off the PHY's processing of received messages, which > would make the correctionField of Pdelay_Resp be incorrect. > > With this patch, on the CM4, the path delay measured with one-step P2P > is the same as with E2E, over L2 and UDPv4. The PHY keeps the UDP > checksum of Pdelay_Resp valid over UDPv4 and UDPv6, still captures the > TX timestamp of Pdelay_Resp, and handles a Pdelay_Req and Pdelay_Resp > on > either side of a second boundary. > > Fixes: 39db6be781cd ("net: phy: broadcom: Add PTP support for some > Broadcom PHYs.") > Cc: stable@vger.kernel.org > Signed-off-by: James Clark <jjc@jclark.com> > [...] Tested-by: Nicolai Buchwitz <nb@tipi-net.de> # CM4, CM5 Reviewed-by: Nicolai Buchwitz <nb@tipi-net.de> Thanks, Nicolai ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH net 2/2] net: phy: broadcom: fix one-step P2P timestamping 2026-11-27 9:50 ` [PATCH net 2/2] net: phy: broadcom: fix one-step " James Clark 2026-12-02 9:54 ` Nicolai Buchwitz @ 2026-12-02 19:17 ` Florian Fainelli 1 sibling, 0 replies; 7+ messages in thread From: Florian Fainelli @ 2026-12-02 19:17 UTC (permalink / raw) To: James Clark, Andrew Lunn, Heiner Kallweit, David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni, Richard Cochran Cc: Russell King, Broadcom internal kernel review list, Jonathan Lemon, netdev On 11/27/26 01:50, James Clark wrote: > On a Raspberry Pi CM4 and CM5, with one-step P2P, the BCM54210PE PHY > sends an incorrect Pdelay_Resp: its correctionField does not include > the time between receiving the Pdelay_Req and sending the Pdelay_Resp. > This is because the driver sets up the PHY as for two-step. The peer > then measures a path delay that is tens of microseconds too large. > > With one-step P2P, use mode 1 for Pdelay_Req on receive and for > Pdelay_Resp on transmit; in this mode the PHY adds the time between the > two to the correctionField. Also skip the normal processing of an RX > timestamp for a Pdelay_Req, since in this mode the PHY does not insert > one. Reject one-step P2P when the filter is HWTSTAMP_FILTER_NONE, since > that filter turns off the PHY's processing of received messages, which > would make the correctionField of Pdelay_Resp be incorrect. > > With this patch, on the CM4, the path delay measured with one-step P2P > is the same as with E2E, over L2 and UDPv4. The PHY keeps the UDP > checksum of Pdelay_Resp valid over UDPv4 and UDPv6, still captures the > TX timestamp of Pdelay_Resp, and handles a Pdelay_Req and Pdelay_Resp on > either side of a second boundary. > > Fixes: 39db6be781cd ("net: phy: broadcom: Add PTP support for some Broadcom PHYs.") > Cc: stable@vger.kernel.org > Signed-off-by: James Clark <jjc@jclark.com> Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com> -- Florian ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2026-12-02 19:17 UTC | newest] Thread overview: 7+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2026-11-27 9:50 [PATCH net 0/2] net: phy: broadcom: fix P2P timestamping James Clark 2026-11-27 9:50 ` [PATCH net 1/2] net: phy: broadcom: fix two-step " James Clark 2026-12-02 9:53 ` Nicolai Buchwitz 2026-12-02 19:17 ` Florian Fainelli 2026-11-27 9:50 ` [PATCH net 2/2] net: phy: broadcom: fix one-step " James Clark 2026-12-02 9:54 ` Nicolai Buchwitz 2026-12-02 19:17 ` Florian Fainelli
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox