Gitweb:     
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=4179477f637caa730626bd597fdf28c5bad73565
Commit:     4179477f637caa730626bd597fdf28c5bad73565
Parent:     641b9e0e8b7f96425da6ce98f3361e3af0baee29
Author:     Patrick McHardy <[EMAIL PROTECTED]>
AuthorDate: Fri Mar 16 01:19:15 2007 -0700
Committer:  David S. Miller <[EMAIL PROTECTED]>
CommitDate: Wed Apr 25 22:26:05 2007 -0700

    [NET_SCHED]: Add hrtimer based qdisc watchdog
    
    Signed-off-by: Patrick McHardy <[EMAIL PROTECTED]>
    Signed-off-by: David S. Miller <[EMAIL PROTECTED]>
---
 include/net/pkt_sched.h |   10 ++++++++++
 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 1c12afd..b090d55 100644
--- a/include/net/pkt_sched.h
+++ b/include/net/pkt_sched.h
@@ -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;
 
diff --git a/net/sched/sch_api.c b/net/sched/sch_api.c
index d71bf79..6bc395c 100644
--- a/net/sched/sch_api.c
+++ b/net/sched/sch_api.c
@@ -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 */
 
-
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to