• Johannes Zink's avatar
    net: stmmac: correct MAC propagation delay · 26cfb838
    Johannes Zink authored
    The IEEE1588 Standard specifies that the timestamps of Packets must be
    captured when the PTP message timestamp point (leading edge of first
    octet after the start of frame delimiter) crosses the boundary between
    the node and the network. As the MAC latches the timestamp at an
    internal point, the captured timestamp must be corrected for the
    additional data transmission latency, as described in the publicly
    available datasheet [1].
    
    This patch only corrects for the MAC-Internal delay, which can be read
    out from the MAC_Ingress_Timestamp_Latency register on DWMAC version 5,
    since the Phy framework currently does not support querying the Phy
    ingress and egress latency. The Closs Domain Crossing Circuits errors as
    indicated in [1] are already being accounted in the
    stmmac_get_tx_hwtstamp() function and are not corrected here.
    
    As the Latency varies for different link speeds and MII
    modes of operation, the correction value needs to be updated on each
    link state change.
    
    As the delay also causes a phase shift in the timestamp counter compared
    to the rest of the network, this correction will also reduce phase error
    when generating PPS outputs from the timestamp counter.
    
    Since the correction registers may be unavailable on some hardware and
    no feature bits are documented for dynamically detection of the MAC
    propagation delay readout, introduce a feature bit to explicitely enable
    MAC delay Correction in the gluecode driver.
    
    [1] i.MX8MP Reference Manual, rev.1 Section 11.7.2.5.3 "Timestamp
    correction"
    Signed-off-by: default avatarJohannes Zink <j.zink@pengutronix.de>
    Link: https://lore.kernel.org/r/20230719-stmmac_correct_mac_delay-v2-1-3366f38ee9a6@pengutronix.de
    Link: https://lore.kernel.org/r/20230719-stmmac_correct_mac_delay-v3-1-61e63427735e@pengutronix.deSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
    26cfb838
stmmac_ptp.h 4.1 KB