]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/commitdiff
[NET_SCHED]: Add hrtimer based qdisc watchdog
authorPatrick McHardy <kaber@trash.net>
Fri, 16 Mar 2007 08:19:15 +0000 (01:19 -0700)
committerDavid S. Miller <davem@sunset.davemloft.net>
Thu, 26 Apr 2007 05:26:05 +0000 (22:26 -0700)
Signed-off-by: Patrick McHardy <kaber@trash.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/net/pkt_sched.h
net/sched/sch_api.c

index 1c12afd113d601d0451c5c24acf88645044917a6..b090d55d5eb883e7051f7d689be66e6803a5176e 100644 (file)
@@ -64,6 +64,16 @@ typedef long psched_tdiff_t;
 #define PSCHED_IS_PASTPERFECT(t)       ((t) == 0)
 #define        PSCHED_AUDIT_TDIFF(t)
 
+struct qdisc_watchdog {
+       struct hrtimer  timer;
+       struct Qdisc    *qdisc;
+};
+
+extern void qdisc_watchdog_init(struct qdisc_watchdog *wd, struct Qdisc *qdisc);
+extern void qdisc_watchdog_schedule(struct qdisc_watchdog *wd,
+                                   psched_time_t expires);
+extern void qdisc_watchdog_cancel(struct qdisc_watchdog *wd);
+
 extern struct Qdisc_ops pfifo_qdisc_ops;
 extern struct Qdisc_ops bfifo_qdisc_ops;
 
index d71bf79eb80b2fb1402d361436534372e7491f22..6bc395cb235be482b2c345d04ae8ab4d43b73830 100644 (file)
@@ -34,6 +34,7 @@
 #include <linux/kmod.h>
 #include <linux/list.h>
 #include <linux/bitops.h>
+#include <linux/hrtimer.h>
 
 #include <net/sock.h>
 #include <net/pkt_sched.h>
@@ -291,6 +292,41 @@ void qdisc_put_rtab(struct qdisc_rate_table *tab)
        }
 }
 
+static enum hrtimer_restart qdisc_watchdog(struct hrtimer *timer)
+{
+       struct qdisc_watchdog *wd = container_of(timer, struct qdisc_watchdog,
+                                                timer);
+
+       wd->qdisc->flags &= ~TCQ_F_THROTTLED;
+       netif_schedule(wd->qdisc->dev);
+       return HRTIMER_NORESTART;
+}
+
+void qdisc_watchdog_init(struct qdisc_watchdog *wd, struct Qdisc *qdisc)
+{
+       hrtimer_init(&wd->timer, CLOCK_MONOTONIC, HRTIMER_MODE_ABS);
+       wd->timer.function = qdisc_watchdog;
+       wd->qdisc = qdisc;
+}
+EXPORT_SYMBOL(qdisc_watchdog_init);
+
+void qdisc_watchdog_schedule(struct qdisc_watchdog *wd, psched_time_t expires)
+{
+       ktime_t time;
+
+       wd->qdisc->flags |= TCQ_F_THROTTLED;
+       time = ktime_set(0, 0);
+       time = ktime_add_ns(time, PSCHED_US2NS(expires));
+       hrtimer_start(&wd->timer, time, HRTIMER_MODE_ABS);
+}
+EXPORT_SYMBOL(qdisc_watchdog_schedule);
+
+void qdisc_watchdog_cancel(struct qdisc_watchdog *wd)
+{
+       hrtimer_cancel(&wd->timer);
+       wd->qdisc->flags &= ~TCQ_F_THROTTLED;
+}
+EXPORT_SYMBOL(qdisc_watchdog_cancel);
 
 /* Allocate an unique handle from space managed by kernel */