]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
net/mlx4_en: Choose time-stamping shift value according to HW frequency
authorEugenia Emantayev <eugenia@mellanox.com>
Wed, 17 Feb 2016 15:24:23 +0000 (17:24 +0200)
committerJiri Slaby <jslaby@suse.cz>
Wed, 2 Mar 2016 15:29:12 +0000 (16:29 +0100)
commit63b7b33c7c4ae9dc71c2eef673611039aadbe87a
tree020b1c2a09cef915b375e8bb2ebc2e755b46fd35
parent866a0f55010d2d2c93c06cc3be423cd37ab12531
net/mlx4_en: Choose time-stamping shift value according to HW frequency

[ Upstream commit 31c128b66e5b28f468076e4f3ca3025c35342041 ]

Previously, the shift value used for time-stamping was constant and didn't
depend on the HW chip frequency. Change that to take the frequency into account
and calculate the maximal value in cycles per wraparound of ten seconds. This
time slot was chosen since it gives a good accuracy in time synchronization.

Algorithm for shift value calculation:
 * Round up the maximal value in cycles to nearest power of two

 * Calculate maximal multiplier by division of all 64 bits set
   to above result

 * Then, invert the function clocksource_khz2mult() to get the shift from
   maximal mult value

Fixes: ec693d47010e ('net/mlx4_en: Add HW timestamping (TS) support')
Signed-off-by: Eugenia Emantayev <eugenia@mellanox.com>
Reviewed-by: Matan Barak <matanb@mellanox.com>
Signed-off-by: Or Gerlitz <ogerlitz@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
drivers/net/ethernet/mellanox/mlx4/en_clock.c