IDPF allows to access the clock through virtchnl messages, or directly, through PCI BAR registers. Registers offsets are negotiated with the Control Plane during driver initialization process.
This series adds support for the direct mode, in which the main timer is disciplined and the Tx timestamps are read straight from the BAR registers, instead of sending a virtchnl message to the Control Plane. Patch 1 adds the direct access to discipline the main timer. Patch 2 adds the direct readout of the Tx timestamps. The latches are collected by a timer that runs for as long as the Tx timestamping is enabled, so no register access is added to the Tx and the Tx completion paths. Latches whose timestamp does not show up within 500 ms are reclaimed and counted as lost in the HW timestamping statistics. v2: * Use explicit spin_lock()/spin_unlock() instead of guard() (patches 1, 2). * Do not drop the mapped cmd_sync address when the cross timestamp one fails to map, so direct mode never writes to a NULL register (patch 1). * Check the Tx timestamping state under the latches lock when handing out a latch, to close the race with disabling it (patch 2). * Stop the timer and flush the pending latches when the Tx timestamping is disabled or the vport is stopped, restart it on open (patch 2). Przemyslaw Korba (2): idpf: add direct access to discipline the main timer idpf: add direct Tx timestamp readout drivers/net/ethernet/intel/idpf/idpf.h | 6 + drivers/net/ethernet/intel/idpf/idpf_dev.c | 9 +- .../net/ethernet/intel/idpf/idpf_ethtool.c | 8 +- .../ethernet/intel/idpf/idpf_lan_pf_regs.h | 3 + drivers/net/ethernet/intel/idpf/idpf_lib.c | 2 + drivers/net/ethernet/intel/idpf/idpf_ptp.c | 664 ++++++++++++++++-- drivers/net/ethernet/intel/idpf/idpf_ptp.h | 130 +++- drivers/net/ethernet/intel/idpf/idpf_txrx.c | 23 +- .../net/ethernet/intel/idpf/idpf_virtchnl.c | 12 +- .../ethernet/intel/idpf/idpf_virtchnl_ptp.c | 201 +++++- include/linux/net/intel/virtchnl2.h | 6 +- 11 files changed, 926 insertions(+), 138 deletions(-) base-commit: 4150d6f3a7b7b533257fbb2d1edbcea031aa9e72 -- 2.47.3
