diff options
Diffstat (limited to 'net/sched')
-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 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 | ||
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 | ||