diff options
author | Amir Vadai <amirv@mellanox.com> | 2013-04-23 06:06:51 +0000 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2013-04-24 16:30:14 -0400 |
commit | b6c39bfcf1d7d6368b8c00081cc8e941041ff478 (patch) | |
tree | d30c1ecc0f3f625de964fd92a2030df556cdf017 /drivers/net/ethernet/mellanox/mlx4/en_clock.c | |
parent | eb0cabbd1bebbf41858ded768c9cad8840708447 (diff) | |
download | op-kernel-dev-b6c39bfcf1d7d6368b8c00081cc8e941041ff478.zip op-kernel-dev-b6c39bfcf1d7d6368b8c00081cc8e941041ff478.tar.gz |
net/mlx4_en: Add a service task
Add a service task to run tasks that needed to be executed periodically.
Currently the only task is a watchdog to catch NIC clock overflow, to make
timestamping accurate.
Will move the statistics task into this framework in a later patch.
Signed-off-by: Amir Vadai <amirv@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/ethernet/mellanox/mlx4/en_clock.c')
-rw-r--r-- | drivers/net/ethernet/mellanox/mlx4/en_clock.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/drivers/net/ethernet/mellanox/mlx4/en_clock.c b/drivers/net/ethernet/mellanox/mlx4/en_clock.c index 501c72f..2f18121 100644 --- a/drivers/net/ethernet/mellanox/mlx4/en_clock.c +++ b/drivers/net/ethernet/mellanox/mlx4/en_clock.c @@ -129,4 +129,23 @@ void mlx4_en_init_timestamp(struct mlx4_en_dev *mdev) timecounter_init(&mdev->clock, &mdev->cycles, ktime_to_ns(ktime_get_real())); + + /* Calculate period in seconds to call the overflow watchdog - to make + * sure counter is checked at least once every wrap around. + */ + mdev->overflow_period = + (cyclecounter_cyc2ns(&mdev->cycles, + mdev->cycles.mask) / NSEC_PER_SEC / 2) + * HZ; +} + +void mlx4_en_ptp_overflow_check(struct mlx4_en_dev *mdev) +{ + bool timeout = time_is_before_jiffies(mdev->last_overflow_check + + mdev->overflow_period); + + if (timeout) { + timecounter_read(&mdev->clock); + mdev->last_overflow_check = jiffies; + } } |