aboutsummaryrefslogtreecommitdiffstats
path: root/net/sched
diff options
context:
space:
mode:
authorPatrick McHardy <kaber@trash.net>2007-03-16 04:19:15 -0400
committerDavid S. Miller <davem@sunset.davemloft.net>2007-04-26 01:26:05 -0400
commit4179477f637caa730626bd597fdf28c5bad73565 (patch)
treecdaeaf817b34ee03b0f4b4203d675272f152947a /net/sched
parent641b9e0e8b7f96425da6ce98f3361e3af0baee29 (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')
-rw-r--r--net/sched/sch_api.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/net/sched/sch_api.c b/net/sched/sch_api.c
index d71bf79eb80b..6bc395cb235b 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
295static 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
305void 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}
311EXPORT_SYMBOL(qdisc_watchdog_init);
312
313void 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}
322EXPORT_SYMBOL(qdisc_watchdog_schedule);
323
324void qdisc_watchdog_cancel(struct qdisc_watchdog *wd)
325{
326 hrtimer_cancel(&wd->timer);
327 wd->qdisc->flags &= ~TCQ_F_THROTTLED;
328}
329EXPORT_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