aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPatrick McHardy <kaber@trash.net>2007-03-16 04:20:07 -0400
committerDavid S. Miller <davem@sunset.davemloft.net>2007-04-26 01:26:07 -0400
commitf7f593e383145931cb2a65df62c31ce1bcc0cffc (patch)
tree7e6245fdc41bd0361995aacec96ac3b3cb84e2cf
parented2b229a97fd537857ad8441ab8b5996b15eadfd (diff)
[NET_SCHED]: sch_tbf: use hrtimer based watchdog
Signed-off-by: Patrick McHardy <kaber@trash.net> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--net/sched/sch_tbf.c31
1 files changed, 7 insertions, 24 deletions
diff --git a/net/sched/sch_tbf.c b/net/sched/sch_tbf.c
index 85da8daa61d2..f14692f3a14e 100644
--- a/net/sched/sch_tbf.c
+++ b/net/sched/sch_tbf.c
@@ -127,8 +127,8 @@ struct tbf_sched_data
127 long tokens; /* Current number of B tokens */ 127 long tokens; /* Current number of B tokens */
128 long ptokens; /* Current number of P tokens */ 128 long ptokens; /* Current number of P tokens */
129 psched_time_t t_c; /* Time check-point */ 129 psched_time_t t_c; /* Time check-point */
130 struct timer_list wd_timer; /* Watchdog timer */
131 struct Qdisc *qdisc; /* Inner qdisc, default - bfifo queue */ 130 struct Qdisc *qdisc; /* Inner qdisc, default - bfifo queue */
131 struct qdisc_watchdog watchdog; /* Watchdog timer */
132}; 132};
133 133
134#define L2T(q,L) ((q)->R_tab->data[(L)>>(q)->R_tab->rate.cell_log]) 134#define L2T(q,L) ((q)->R_tab->data[(L)>>(q)->R_tab->rate.cell_log])
@@ -185,14 +185,6 @@ static unsigned int tbf_drop(struct Qdisc* sch)
185 return len; 185 return len;
186} 186}
187 187
188static void tbf_watchdog(unsigned long arg)
189{
190 struct Qdisc *sch = (struct Qdisc*)arg;
191
192 sch->flags &= ~TCQ_F_THROTTLED;
193 netif_schedule(sch->dev);
194}
195
196static struct sk_buff *tbf_dequeue(struct Qdisc* sch) 188static struct sk_buff *tbf_dequeue(struct Qdisc* sch)
197{ 189{
198 struct tbf_sched_data *q = qdisc_priv(sch); 190 struct tbf_sched_data *q = qdisc_priv(sch);
@@ -202,7 +194,7 @@ static struct sk_buff *tbf_dequeue(struct Qdisc* sch)
202 194
203 if (skb) { 195 if (skb) {
204 psched_time_t now; 196 psched_time_t now;
205 long toks, delay; 197 long toks;
206 long ptoks = 0; 198 long ptoks = 0;
207 unsigned int len = skb->len; 199 unsigned int len = skb->len;
208 200
@@ -230,12 +222,8 @@ static struct sk_buff *tbf_dequeue(struct Qdisc* sch)
230 return skb; 222 return skb;
231 } 223 }
232 224
233 delay = PSCHED_US2JIFFIE(max_t(long, -toks, -ptoks)); 225 qdisc_watchdog_schedule(&q->watchdog,
234 226 now + max_t(long, -toks, -ptoks));
235 if (delay == 0)
236 delay = 1;
237
238 mod_timer(&q->wd_timer, jiffies+delay);
239 227
240 /* Maybe we have a shorter packet in the queue, 228 /* Maybe we have a shorter packet in the queue,
241 which can be sent now. It sounds cool, 229 which can be sent now. It sounds cool,
@@ -254,7 +242,6 @@ static struct sk_buff *tbf_dequeue(struct Qdisc* sch)
254 sch->qstats.drops++; 242 sch->qstats.drops++;
255 } 243 }
256 244
257 sch->flags |= TCQ_F_THROTTLED;
258 sch->qstats.overlimits++; 245 sch->qstats.overlimits++;
259 } 246 }
260 return NULL; 247 return NULL;
@@ -269,8 +256,7 @@ static void tbf_reset(struct Qdisc* sch)
269 PSCHED_GET_TIME(q->t_c); 256 PSCHED_GET_TIME(q->t_c);
270 q->tokens = q->buffer; 257 q->tokens = q->buffer;
271 q->ptokens = q->mtu; 258 q->ptokens = q->mtu;
272 sch->flags &= ~TCQ_F_THROTTLED; 259 qdisc_watchdog_cancel(&q->watchdog);
273 del_timer(&q->wd_timer);
274} 260}
275 261
276static struct Qdisc *tbf_create_dflt_qdisc(struct Qdisc *sch, u32 limit) 262static struct Qdisc *tbf_create_dflt_qdisc(struct Qdisc *sch, u32 limit)
@@ -378,10 +364,7 @@ static int tbf_init(struct Qdisc* sch, struct rtattr *opt)
378 return -EINVAL; 364 return -EINVAL;
379 365
380 PSCHED_GET_TIME(q->t_c); 366 PSCHED_GET_TIME(q->t_c);
381 init_timer(&q->wd_timer); 367 qdisc_watchdog_init(&q->watchdog, sch);
382 q->wd_timer.function = tbf_watchdog;
383 q->wd_timer.data = (unsigned long)sch;
384
385 q->qdisc = &noop_qdisc; 368 q->qdisc = &noop_qdisc;
386 369
387 return tbf_change(sch, opt); 370 return tbf_change(sch, opt);
@@ -391,7 +374,7 @@ static void tbf_destroy(struct Qdisc *sch)
391{ 374{
392 struct tbf_sched_data *q = qdisc_priv(sch); 375 struct tbf_sched_data *q = qdisc_priv(sch);
393 376
394 del_timer(&q->wd_timer); 377 qdisc_watchdog_cancel(&q->watchdog);
395 378
396 if (q->P_tab) 379 if (q->P_tab)
397 qdisc_put_rtab(q->P_tab); 380 qdisc_put_rtab(q->P_tab);