aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/net/pkt_sched.h10
-rw-r--r--net/sched/sch_api.c36
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
67struct qdisc_watchdog {
68 struct hrtimer timer;
69 struct Qdisc *qdisc;
70};
71
72extern void qdisc_watchdog_init(struct qdisc_watchdog *wd, struct Qdisc *qdisc);
73extern void qdisc_watchdog_schedule(struct qdisc_watchdog *wd,
74 psched_time_t expires);
75extern void qdisc_watchdog_cancel(struct qdisc_watchdog *wd);
76
67extern struct Qdisc_ops pfifo_qdisc_ops; 77extern struct Qdisc_ops pfifo_qdisc_ops;
68extern struct Qdisc_ops bfifo_qdisc_ops; 78extern 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
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