aboutsummaryrefslogtreecommitdiffstats
path: root/net/sched/sch_tbf.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/sched/sch_tbf.c')
-rw-r--r--net/sched/sch_tbf.c44
1 files changed, 19 insertions, 25 deletions
diff --git a/net/sched/sch_tbf.c b/net/sched/sch_tbf.c
index 94c61598b86a..a2f93c09f3cc 100644
--- a/net/sched/sch_tbf.c
+++ b/net/sched/sch_tbf.c
@@ -139,19 +139,6 @@ static int tbf_enqueue(struct sk_buff *skb, struct Qdisc* sch)
139 return 0; 139 return 0;
140} 140}
141 141
142static int tbf_requeue(struct sk_buff *skb, struct Qdisc* sch)
143{
144 struct tbf_sched_data *q = qdisc_priv(sch);
145 int ret;
146
147 if ((ret = q->qdisc->ops->requeue(skb, q->qdisc)) == 0) {
148 sch->q.qlen++;
149 sch->qstats.requeues++;
150 }
151
152 return ret;
153}
154
155static unsigned int tbf_drop(struct Qdisc* sch) 142static unsigned int tbf_drop(struct Qdisc* sch)
156{ 143{
157 struct tbf_sched_data *q = qdisc_priv(sch); 144 struct tbf_sched_data *q = qdisc_priv(sch);
@@ -169,7 +156,7 @@ static struct sk_buff *tbf_dequeue(struct Qdisc* sch)
169 struct tbf_sched_data *q = qdisc_priv(sch); 156 struct tbf_sched_data *q = qdisc_priv(sch);
170 struct sk_buff *skb; 157 struct sk_buff *skb;
171 158
172 skb = q->qdisc->dequeue(q->qdisc); 159 skb = q->qdisc->ops->peek(q->qdisc);
173 160
174 if (skb) { 161 if (skb) {
175 psched_time_t now; 162 psched_time_t now;
@@ -192,6 +179,10 @@ static struct sk_buff *tbf_dequeue(struct Qdisc* sch)
192 toks -= L2T(q, len); 179 toks -= L2T(q, len);
193 180
194 if ((toks|ptoks) >= 0) { 181 if ((toks|ptoks) >= 0) {
182 skb = qdisc_dequeue_peeked(q->qdisc);
183 if (unlikely(!skb))
184 return NULL;
185
195 q->t_c = now; 186 q->t_c = now;
196 q->tokens = toks; 187 q->tokens = toks;
197 q->ptokens = ptoks; 188 q->ptokens = ptoks;
@@ -214,12 +205,6 @@ static struct sk_buff *tbf_dequeue(struct Qdisc* sch)
214 (cf. CSZ, HPFQ, HFSC) 205 (cf. CSZ, HPFQ, HFSC)
215 */ 206 */
216 207
217 if (q->qdisc->ops->requeue(skb, q->qdisc) != NET_XMIT_SUCCESS) {
218 /* When requeue fails skb is dropped */
219 qdisc_tree_decrease_qlen(q->qdisc, 1);
220 sch->qstats.drops++;
221 }
222
223 sch->qstats.overlimits++; 208 sch->qstats.overlimits++;
224 } 209 }
225 return NULL; 210 return NULL;
@@ -251,6 +236,7 @@ static int tbf_change(struct Qdisc* sch, struct nlattr *opt)
251 struct tc_tbf_qopt *qopt; 236 struct tc_tbf_qopt *qopt;
252 struct qdisc_rate_table *rtab = NULL; 237 struct qdisc_rate_table *rtab = NULL;
253 struct qdisc_rate_table *ptab = NULL; 238 struct qdisc_rate_table *ptab = NULL;
239 struct qdisc_rate_table *tmp;
254 struct Qdisc *child = NULL; 240 struct Qdisc *child = NULL;
255 int max_size,n; 241 int max_size,n;
256 242
@@ -299,7 +285,8 @@ static int tbf_change(struct Qdisc* sch, struct nlattr *opt)
299 sch_tree_lock(sch); 285 sch_tree_lock(sch);
300 if (child) { 286 if (child) {
301 qdisc_tree_decrease_qlen(q->qdisc, q->qdisc->q.qlen); 287 qdisc_tree_decrease_qlen(q->qdisc, q->qdisc->q.qlen);
302 qdisc_destroy(xchg(&q->qdisc, child)); 288 qdisc_destroy(q->qdisc);
289 q->qdisc = child;
303 } 290 }
304 q->limit = qopt->limit; 291 q->limit = qopt->limit;
305 q->mtu = qopt->mtu; 292 q->mtu = qopt->mtu;
@@ -307,8 +294,14 @@ static int tbf_change(struct Qdisc* sch, struct nlattr *opt)
307 q->buffer = qopt->buffer; 294 q->buffer = qopt->buffer;
308 q->tokens = q->buffer; 295 q->tokens = q->buffer;
309 q->ptokens = q->mtu; 296 q->ptokens = q->mtu;
310 rtab = xchg(&q->R_tab, rtab); 297
311 ptab = xchg(&q->P_tab, ptab); 298 tmp = q->R_tab;
299 q->R_tab = rtab;
300 rtab = tmp;
301
302 tmp = q->P_tab;
303 q->P_tab = ptab;
304 ptab = tmp;
312 sch_tree_unlock(sch); 305 sch_tree_unlock(sch);
313 err = 0; 306 err = 0;
314done: 307done:
@@ -398,7 +391,8 @@ static int tbf_graft(struct Qdisc *sch, unsigned long arg, struct Qdisc *new,
398 new = &noop_qdisc; 391 new = &noop_qdisc;
399 392
400 sch_tree_lock(sch); 393 sch_tree_lock(sch);
401 *old = xchg(&q->qdisc, new); 394 *old = q->qdisc;
395 q->qdisc = new;
402 qdisc_tree_decrease_qlen(*old, (*old)->q.qlen); 396 qdisc_tree_decrease_qlen(*old, (*old)->q.qlen);
403 qdisc_reset(*old); 397 qdisc_reset(*old);
404 sch_tree_unlock(sch); 398 sch_tree_unlock(sch);
@@ -469,7 +463,7 @@ static struct Qdisc_ops tbf_qdisc_ops __read_mostly = {
469 .priv_size = sizeof(struct tbf_sched_data), 463 .priv_size = sizeof(struct tbf_sched_data),
470 .enqueue = tbf_enqueue, 464 .enqueue = tbf_enqueue,
471 .dequeue = tbf_dequeue, 465 .dequeue = tbf_dequeue,
472 .requeue = tbf_requeue, 466 .peek = qdisc_peek_dequeued,
473 .drop = tbf_drop, 467 .drop = tbf_drop,
474 .init = tbf_init, 468 .init = tbf_init,
475 .reset = tbf_reset, 469 .reset = tbf_reset,