diff options
author | Patrick McHardy <kaber@trash.net> | 2007-03-16 04:19:15 -0400 |
---|---|---|
committer | David S. Miller <davem@sunset.davemloft.net> | 2007-04-26 01:26:05 -0400 |
commit | 4179477f637caa730626bd597fdf28c5bad73565 (patch) | |
tree | cdaeaf817b34ee03b0f4b4203d675272f152947a /net/sched/sch_api.c | |
parent | 641b9e0e8b7f96425da6ce98f3361e3af0baee29 (diff) |
[NET_SCHED]: Add hrtimer based qdisc watchdog
Signed-off-by: Patrick McHardy <kaber@trash.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/sched/sch_api.c')
-rw-r--r-- | net/sched/sch_api.c | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/net/sched/sch_api.c b/net/sched/sch_api.c index d71bf79eb80..6bc395cb235 100644 --- a/net/sched/sch_api.c +++ b/net/sched/sch_api.c | |||
@@ -34,6 +34,7 @@ | |||
34 | #include <linux/kmod.h> | 34 | #include <linux/kmod.h> |
35 | #include <linux/list.h> | 35 | #include <linux/list.h> |
36 | #include <linux/bitops.h> | 36 | #include <linux/bitops.h> |
37 | #include <linux/hrtimer.h> | ||
37 | 38 | ||
38 | #include <net/sock.h> | 39 | #include <net/sock.h> |
39 | #include <net/pkt_sched.h> | 40 | #include <net/pkt_sched.h> |
@@ -291,6 +292,41 @@ void qdisc_put_rtab(struct qdisc_rate_table *tab) | |||
291 | } | 292 | } |
292 | } | 293 | } |
293 | 294 | ||
295 | static enum hrtimer_restart qdisc_watchdog(struct hrtimer *timer) | ||
296 | { | ||
297 | struct qdisc_watchdog *wd = container_of(timer, struct qdisc_watchdog, | ||
298 | timer); | ||
299 | |||
300 | wd->qdisc->flags &= ~TCQ_F_THROTTLED; | ||
301 | netif_schedule(wd->qdisc->dev); | ||
302 | return HRTIMER_NORESTART; | ||
303 | } | ||
304 | |||
305 | void qdisc_watchdog_init(struct qdisc_watchdog *wd, struct Qdisc *qdisc) | ||
306 | { | ||
307 | hrtimer_init(&wd->timer, CLOCK_MONOTONIC, HRTIMER_MODE_ABS); | ||
308 | wd->timer.function = qdisc_watchdog; | ||
309 | wd->qdisc = qdisc; | ||
310 | } | ||
311 | EXPORT_SYMBOL(qdisc_watchdog_init); | ||
312 | |||
313 | void qdisc_watchdog_schedule(struct qdisc_watchdog *wd, psched_time_t expires) | ||
314 | { | ||
315 | ktime_t time; | ||
316 | |||
317 | wd->qdisc->flags |= TCQ_F_THROTTLED; | ||
318 | time = ktime_set(0, 0); | ||
319 | time = ktime_add_ns(time, PSCHED_US2NS(expires)); | ||
320 | hrtimer_start(&wd->timer, time, HRTIMER_MODE_ABS); | ||
321 | } | ||
322 | EXPORT_SYMBOL(qdisc_watchdog_schedule); | ||
323 | |||
324 | void qdisc_watchdog_cancel(struct qdisc_watchdog *wd) | ||
325 | { | ||
326 | hrtimer_cancel(&wd->timer); | ||
327 | wd->qdisc->flags &= ~TCQ_F_THROTTLED; | ||
328 | } | ||
329 | EXPORT_SYMBOL(qdisc_watchdog_cancel); | ||
294 | 330 | ||
295 | /* Allocate an unique handle from space managed by kernel */ | 331 | /* Allocate an unique handle from space managed by kernel */ |
296 | 332 | ||