diff options
-rw-r--r-- | include/net/pkt_sched.h | 10 | ||||
-rw-r--r-- | net/sched/sch_api.c | 36 |
2 files changed, 46 insertions, 0 deletions
diff --git a/include/net/pkt_sched.h b/include/net/pkt_sched.h index 1c12afd113d6..b090d55d5eb8 100644 --- a/include/net/pkt_sched.h +++ b/include/net/pkt_sched.h | |||
@@ -64,6 +64,16 @@ typedef long psched_tdiff_t; | |||
64 | #define PSCHED_IS_PASTPERFECT(t) ((t) == 0) | 64 | #define PSCHED_IS_PASTPERFECT(t) ((t) == 0) |
65 | #define PSCHED_AUDIT_TDIFF(t) | 65 | #define PSCHED_AUDIT_TDIFF(t) |
66 | 66 | ||
67 | struct qdisc_watchdog { | ||
68 | struct hrtimer timer; | ||
69 | struct Qdisc *qdisc; | ||
70 | }; | ||
71 | |||
72 | extern void qdisc_watchdog_init(struct qdisc_watchdog *wd, struct Qdisc *qdisc); | ||
73 | extern void qdisc_watchdog_schedule(struct qdisc_watchdog *wd, | ||
74 | psched_time_t expires); | ||
75 | extern void qdisc_watchdog_cancel(struct qdisc_watchdog *wd); | ||
76 | |||
67 | extern struct Qdisc_ops pfifo_qdisc_ops; | 77 | extern struct Qdisc_ops pfifo_qdisc_ops; |
68 | extern struct Qdisc_ops bfifo_qdisc_ops; | 78 | extern struct Qdisc_ops bfifo_qdisc_ops; |
69 | 79 | ||
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 | ||