linux-stable/drivers/net/phy
Vladimir Oltean 661fef5698 net: phy: nxp-c45-tja11xx: express timestamp wraparound interval in terms of TS_SEC_MASK
nxp_c45_reconstruct_ts() takes a partial hardware timestamp in @hwts,
with 2 bits of the 'seconds' portion, and a full PTP time in @ts.

It patches in the lower bits of @hwts into @ts, and to ensure that the
reconstructed timestamp is correct, it checks whether the lower 2 bits
of @hwts are not in fact higher than the lower 2 bits of @ts. This is
not logically possible because, according to the calling convention, @ts
was collected later in time than @hwts, but due to two's complement
arithmetic it can actually happen, because the current PTP time might
have wrapped around between when @hwts was collected and when @ts was,
yielding the lower 2 bits of @ts smaller than those of @hwts.

To correct for that situation which is expected to happen under normal
conditions, the driver subtracts exactly one wraparound interval from
the reconstructed timestamp, since the upper bits of that need to
correspond to what the upper bits of @hwts were, not to what the upper
bits of @ts were.

Readers might be confused because the driver denotes the amount of bits
that the partial hardware timestamp has to offer as TS_SEC_MASK
(timestamp mask for seconds). But it subtracts a seemingly unrelated
BIT(2), which is in fact more subtle: if the hardware timestamp provides
2 bits of partial 'seconds' timestamp, then the wraparound interval is
2^2 == BIT(2).

But nonetheless, it is better to express the wraparound interval in
terms of a definition we already have, so replace BIT(2) with
1 + GENMASK(1, 0) which produces the same result but is clearer.

Suggested-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
Cc: Richard Cochran <richardcochran@gmail.com>
Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Reviewed-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
Signed-off-by: David S. Miller <davem@davemloft.net>
2021-06-14 13:12:59 -07:00
..
mscc net: phy: mscc: coma mode disabled for VSC8584 2021-03-19 12:17:30 -07:00
adin.c net: phy: Demote non-compliant kernel-doc headers 2021-05-17 14:12:39 -07:00
amd.c net: phy: amd: remove the use of .ack_interrupt() 2020-11-17 11:37:00 -08:00
aquantia.h
aquantia_hwmon.c
aquantia_main.c
at803x.c net: phy: add support for qca8k switch internal PHY in at803x 2021-05-14 15:30:23 -07:00
ax88796b.c net: usb/phy: asix: add support for ax88772A/C PHYs 2021-06-07 13:23:02 -07:00
bcm-cygnus.c
bcm-phy-lib.c net: phy: broadcom: Only advertise EEE for supported modes 2021-03-30 17:39:23 -07:00
bcm-phy-lib.h
bcm7xxx.c net: phy: bcm7xxx: Add an entry for BCM72116 2021-01-07 14:46:09 -08:00
bcm63xx.c
bcm87xx.c
bcm54140.c
bcm84881.c
broadcom.c net: phy: broadcom: Add statistics for all Gigabit PHYs 2021-04-01 15:59:26 -07:00
cicada.c
cortina.c
davicom.c
dp83tc811.c net: phy: ti: take into account all possible interrupt sources 2021-03-01 11:46:55 -08:00
dp83640.c net: phy: dp83640: use new PTP_MSGTYPE_SYNC define 2020-11-25 12:23:06 -08:00
dp83640_reg.h
dp83822.c net: phy: ti: take into account all possible interrupt sources 2021-03-01 11:46:55 -08:00
dp83848.c net: phy: ti: remove the use of .ack_interrupt() 2020-11-25 11:18:38 -08:00
dp83867.c net: phy: ti: remove the use of .ack_interrupt() 2020-11-25 11:18:38 -08:00
dp83869.c net: phy: introduce phydev->port 2021-02-11 13:09:58 -08:00
et1011c.c
fixed_phy.c
icplus.c net: phy: icplus: call phy_restore_page() when phy_select_page() fails 2021-02-22 18:47:48 -08:00
intel-xway.c net: phy: intel-xway: enable integrated led functions 2021-04-21 10:59:17 -07:00
Kconfig net: phy: add driver for Motorcomm yt8511 phy 2021-05-21 13:19:11 -07:00
linkmode.c
lxt.c net: phy: introduce phydev->port 2021-02-11 13:09:58 -08:00
Makefile net: phy: add driver for Motorcomm yt8511 phy 2021-05-21 13:19:11 -07:00
marvell-88x2222.c net: phy: marvell-88x2222: enable autoneg by default 2021-04-27 14:05:41 -07:00
marvell.c net: phy: marvell: use phy_modify_changed() for marvell_set_polarity() 2021-06-03 15:24:34 -07:00
marvell10g.c net: phy: marvell10g: change module description 2021-04-08 13:15:34 -07:00
mdio-boardinfo.c net: phy: Correct function name mdiobus_register_board_info() in comment 2021-03-29 13:42:44 -07:00
mdio-boardinfo.h
mdio_bus.c net: mdiobus: get rid of a BUG_ON() 2021-05-17 15:50:58 -07:00
mdio_device.c
mdio_devres.c
mediatek-ge.c net: phy: add MediaTek Gigabit Ethernet PHY driver 2021-05-19 13:27:42 -07:00
meson-gxl.c net: phy: meson-gxl: remove the use of .ack_callback() 2020-11-25 11:18:37 -08:00
micrel.c net: phy: micrel: ksz886x/ksz8081: add cabletest support 2021-06-14 12:54:43 -07:00
microchip.c
microchip_t1.c
mii_timestamper.c net: mii_timestamper: check NULL in unregister_mii_timestamper() 2021-06-11 13:08:52 -07:00
motorcomm.c net: phy: abort loading yt8511 driver in unsupported modes 2021-05-30 14:24:38 -07:00
national.c net: phy: national: remove definition of DEBUG 2021-01-18 20:03:01 -08:00
nxp-c45-tja11xx.c net: phy: nxp-c45-tja11xx: express timestamp wraparound interval in terms of TS_SEC_MASK 2021-06-14 13:12:59 -07:00
nxp-tja11xx.c
phy-c45.c net: phy: add genphy_c45_pma_suspend/resume 2021-04-19 16:19:44 -07:00
phy-core.c
phy.c net: phy: do not print dump stack if device was removed 2021-06-07 13:23:02 -07:00
phy_device.c net: mii_timestamper: check NULL in unregister_mii_timestamper() 2021-06-11 13:08:52 -07:00
phy_led_triggers.c
phylink.c net: phylink: Add 25G BASE-R support 2021-06-12 13:08:58 -07:00
qsemi.c net: phy: qsemi: remove the use of .ack_interrupt() 2020-11-25 11:18:38 -08:00
realtek.c net: phy: realtek: net: Fix less than zero comparison of a u16 2021-06-09 15:32:08 -07:00
rockchip.c net: phy: Demote non-compliant kernel-doc headers 2021-05-17 14:12:39 -07:00
sfp-bus.c net: sfp: add support for 25G BASE-R SFPs 2021-06-12 13:08:57 -07:00
sfp.c phy: sfp: add netlink SFP support to generic SFP code 2021-04-11 16:34:56 -07:00
sfp.h phy: sfp: add netlink SFP support to generic SFP code 2021-04-11 16:34:56 -07:00
smsc.c net: phy: lan87xx: fix access to wrong register of LAN87xx 2021-03-30 13:13:08 -07:00
spi_ks8995.c
ste10Xp.c net: phy: ste10Xp: remove the use of .ack_interrupt() 2020-11-17 11:37:00 -08:00
swphy.c
swphy.h
teranetics.c
uPD60620.c
vitesse.c
xilinx_gmii2rgmii.c