aboutsummaryrefslogtreecommitdiffstats
path: root/net/sched/sch_red.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/sched/sch_red.c')
-rw-r--r--net/sched/sch_red.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/net/sched/sch_red.c b/net/sched/sch_red.c
index d617161f8dd3..8f5a85bf9d10 100644
--- a/net/sched/sch_red.c
+++ b/net/sched/sch_red.c
@@ -39,6 +39,7 @@
39struct red_sched_data { 39struct red_sched_data {
40 u32 limit; /* HARD maximal queue length */ 40 u32 limit; /* HARD maximal queue length */
41 unsigned char flags; 41 unsigned char flags;
42 struct timer_list adapt_timer;
42 struct red_parms parms; 43 struct red_parms parms;
43 struct red_stats stats; 44 struct red_stats stats;
44 struct Qdisc *qdisc; 45 struct Qdisc *qdisc;
@@ -161,6 +162,8 @@ static void red_reset(struct Qdisc *sch)
161static void red_destroy(struct Qdisc *sch) 162static void red_destroy(struct Qdisc *sch)
162{ 163{
163 struct red_sched_data *q = qdisc_priv(sch); 164 struct red_sched_data *q = qdisc_priv(sch);
165
166 del_timer_sync(&q->adapt_timer);
164 qdisc_destroy(q->qdisc); 167 qdisc_destroy(q->qdisc);
165} 168}
166 169
@@ -209,6 +212,10 @@ static int red_change(struct Qdisc *sch, struct nlattr *opt)
209 ctl->Plog, ctl->Scell_log, 212 ctl->Plog, ctl->Scell_log,
210 nla_data(tb[TCA_RED_STAB])); 213 nla_data(tb[TCA_RED_STAB]));
211 214
215 del_timer(&q->adapt_timer);
216 if (ctl->flags & TC_RED_ADAPTATIVE)
217 mod_timer(&q->adapt_timer, jiffies + HZ/2);
218
212 if (!q->qdisc->q.qlen) 219 if (!q->qdisc->q.qlen)
213 red_start_of_idle_period(&q->parms); 220 red_start_of_idle_period(&q->parms);
214 221
@@ -216,11 +223,24 @@ static int red_change(struct Qdisc *sch, struct nlattr *opt)
216 return 0; 223 return 0;
217} 224}
218 225
226static inline void red_adaptative_timer(unsigned long arg)
227{
228 struct Qdisc *sch = (struct Qdisc *)arg;
229 struct red_sched_data *q = qdisc_priv(sch);
230 spinlock_t *root_lock = qdisc_lock(qdisc_root_sleeping(sch));
231
232 spin_lock(root_lock);
233 red_adaptative_algo(&q->parms);
234 mod_timer(&q->adapt_timer, jiffies + HZ/2);
235 spin_unlock(root_lock);
236}
237
219static int red_init(struct Qdisc *sch, struct nlattr *opt) 238static int red_init(struct Qdisc *sch, struct nlattr *opt)
220{ 239{
221 struct red_sched_data *q = qdisc_priv(sch); 240 struct red_sched_data *q = qdisc_priv(sch);
222 241
223 q->qdisc = &noop_qdisc; 242 q->qdisc = &noop_qdisc;
243 setup_timer(&q->adapt_timer, red_adaptative_timer, (unsigned long)sch);
224 return red_change(sch, opt); 244 return red_change(sch, opt);
225} 245}
226 246
@@ -243,6 +263,7 @@ static int red_dump(struct Qdisc *sch, struct sk_buff *skb)
243 if (opts == NULL) 263 if (opts == NULL)
244 goto nla_put_failure; 264 goto nla_put_failure;
245 NLA_PUT(skb, TCA_RED_PARMS, sizeof(opt), &opt); 265 NLA_PUT(skb, TCA_RED_PARMS, sizeof(opt), &opt);
266 NLA_PUT_U32(skb, TCA_RED_MAX_P, q->parms.max_P);
246 return nla_nest_end(skb, opts); 267 return nla_nest_end(skb, opts);
247 268
248nla_put_failure: 269nla_put_failure: