ice: Don't put stale timestamps in the skb
authorKarol Kolacinski <karol.kolacinski@intel.com>
Tue, 16 Nov 2021 12:07:14 +0000 (13:07 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 22 Dec 2021 08:32:42 +0000 (09:32 +0100)
commita0dacf4bc3c58a441b2759e6b949173b7a042c09
treea6dc749cfa93d6baa8f3e0107199903fbae48916
parent89f9c880141eef84ee9001dd6969067be72145d0
ice: Don't put stale timestamps in the skb

[ Upstream commit 37e738b6fdb14529534dca441e0222313688fde3 ]

The driver has to check if it does not accidentally put the timestamp in
the SKB before previous timestamp gets overwritten.
Timestamp values in the PHY are read only and do not get cleared except
at hardware reset or when a new timestamp value is captured.
The cached_tstamp field is used to detect the case where a new timestamp
has not yet been captured, ensuring that we avoid sending stale
timestamp data to the stack.

Fixes: ea9b847cda64 ("ice: enable transmit timestamps for E810 devices")
Signed-off-by: Karol Kolacinski <karol.kolacinski@intel.com>
Tested-by: Gurucharan G <gurucharanx.g@intel.com>
Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/net/ethernet/intel/ice/ice_ptp.c
drivers/net/ethernet/intel/ice/ice_ptp.h