net/ice/base: support starting PHY in bypass mode
authorQi Zhang <qi.z.zhang@intel.com>
Tue, 10 Aug 2021 02:51:23 +0000 (10:51 +0800)
committerQi Zhang <qi.z.zhang@intel.com>
Wed, 11 Aug 2021 02:24:18 +0000 (04:24 +0200)
commit6f71d4978ab842bc1e577af9ac4f703ed116fec9
tree59a89c5b9200a892df06e94c656c7aad5d98f2d5
parenta3f1d0e4fc2b0abf63e5f04e099541aa27ee69dc
net/ice/base: support starting PHY in bypass mode

After starting the timestamping block, hardware begins calculating
precise offsets through a process of vernier calibration. This process
measures the effective phase offset of the various internal clocks used
in the PHY.

Once hardware completes these measurements, the P_REG_TX_OV_STATUS and
P_REG_RX_OV_STATUS registers are updated to indicate that the hardware
offset measurements are done.

This process does not happen immediately, but requires that at least one
packet be sent or received in order for the offset in that direction to
be calculated.

This poses a problem in some setups, because software expects the first
packet sent to be timestamped. This most often occurs if the clock time
is set by an application during startup. This set time command triggers
a PHY restart. Because of this, the timestamping block is reset, and
timestamps are not enabled until vernier calibration is complete. Since
this process won't complete until at least one packet is sent through
the PHY, timestamps of the very first packet sent will not be obtained.

This can result in the application failing due to missing timestamps.

To avoid this, allow starting the PHY in bypass mode. This mode enables
timestamps immediately, and skips adding the precise offset measurement.
This reduces the accuracy of the timestamp slightly, but ensures that we
get a reasonable value for the first packet.

The driver can continue monitoring the P_REG_TX_OV_STATUS and
P_REG_RX_OV_STATUS registers and exit bypass mode once the total
calibration is completed. In this way, once calibration is complete, the
timestamps will have the precise offset, but we do not break
applications which expect to be able to timestamp immediately.

Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
Signed-off-by: Qi Zhang <qi.z.zhang@intel.com>
Acked-by: Junfeng Guo <junfeng.guo@intel.com>
drivers/net/ice/base/ice_ptp_hw.c
drivers/net/ice/base/ice_ptp_hw.h