aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/ethernet/mellanox/mlx4/en_clock.c
diff options
context:
space:
mode:
authorAmir Vadai <amirv@mellanox.com>2013-04-23 02:06:51 -0400
committerDavid S. Miller <davem@davemloft.net>2013-04-24 16:30:14 -0400
commitb6c39bfcf1d7d6368b8c00081cc8e941041ff478 (patch)
treed30c1ecc0f3f625de964fd92a2030df556cdf017 /drivers/net/ethernet/mellanox/mlx4/en_clock.c
parenteb0cabbd1bebbf41858ded768c9cad8840708447 (diff)
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.c19
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 501c72f1fbeb..2f181219662e 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)
129 129
130 timecounter_init(&mdev->clock, &mdev->cycles, 130 timecounter_init(&mdev->clock, &mdev->cycles,
131 ktime_to_ns(ktime_get_real())); 131 ktime_to_ns(ktime_get_real()));
132
133 /* Calculate period in seconds to call the overflow watchdog - to make
134 * sure counter is checked at least once every wrap around.
135 */
136 mdev->overflow_period =
137 (cyclecounter_cyc2ns(&mdev->cycles,
138 mdev->cycles.mask) / NSEC_PER_SEC / 2)
139 * HZ;
140}
141
142void mlx4_en_ptp_overflow_check(struct mlx4_en_dev *mdev)
143{
144 bool timeout = time_is_before_jiffies(mdev->last_overflow_check +
145 mdev->overflow_period);
146
147 if (timeout) {
148 timecounter_read(&mdev->clock);
149 mdev->last_overflow_check = jiffies;
150 }
132} 151}