]> git.baikalelectronics.ru Git - kernel.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)
committerDavid S. Miller <davem@davemloft.net>
Wed, 17 Feb 2016 15:29:25 +0000 (10:29 -0500)
commitc1125f0d7e67d3aa4e9d74b23daff8b8abd9c796
treee01cf006212bcda4c37ca8053799ca64a7c4e096
parenta1ae3fb06e3452064029f28dd281ffdf52a75544
net/mlx4_en: Choose time-stamping shift value according to HW frequency

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: af5a0bb2bab5 ('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>
drivers/net/ethernet/mellanox/mlx4/en_clock.c