sfc: fix timestamp reconstruction at 16-bit rollover points
authorAlex Maftei (amaftei) <amaftei@solarflare.com>
Wed, 26 Feb 2020 17:33:19 +0000 (17:33 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 20 Mar 2020 10:55:56 +0000 (11:55 +0100)
commit04a244c8e61f043d22207a0451c6175d86b3b30d
tree772312c12438250d57fcffd64a65b6dc88e2f7e8
parent5043d35d37381cff1d37ae32e5fc3be070ee4e50
sfc: fix timestamp reconstruction at 16-bit rollover points

[ Upstream commit 23797b98909f34b75fd130369bde86f760db69d0 ]

We can't just use the top bits of the last sync event as they could be
off-by-one every 65,536 seconds, giving an error in reconstruction of
65,536 seconds.

This patch uses the difference in the bottom 16 bits (mod 2^16) to
calculate an offset that needs to be applied to the last sync event to
get to the current time.

Signed-off-by: Alexandru-Mihai Maftei <amaftei@solarflare.com>
Acked-by: Martin Habets <mhabets@solarflare.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/net/ethernet/sfc/ptp.c