aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJarek Poplawski <jarkao2@gmail.com>2008-12-04 00:09:45 -0500
committerDavid S. Miller <davem@davemloft.net>2008-12-04 00:09:45 -0500
commitc19f7a34f7cc7543c62ad065952e146dc77d1a38 (patch)
treea4592d86565eb49600bd1b7e88ba46db43d6289c
parent633fe66ed8385ccf8b4a74a00a4c6eb40850d65f (diff)
pkt_sched: sch_htb: Clean htb_class prio and quantum fields
While implementing htb_parent_to_leaf() there where added backup prio and quantum struct htb_class fields to preserve these values for inner classes in case of their return to leaf. This patch cleans this a bit by removing union leaf duplicates. Signed-off-by: Jarek Poplawski <jarkao2@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--net/sched/sch_htb.c41
1 files changed, 16 insertions, 25 deletions
diff --git a/net/sched/sch_htb.c b/net/sched/sch_htb.c
index 7a71e9412e03..80cb94d9c299 100644
--- a/net/sched/sch_htb.c
+++ b/net/sched/sch_htb.c
@@ -84,11 +84,12 @@ struct htb_class {
84 unsigned int children; 84 unsigned int children;
85 struct htb_class *parent; /* parent class */ 85 struct htb_class *parent; /* parent class */
86 86
87 int prio; /* these two are used only by leaves... */
88 int quantum; /* but stored for parent-to-leaf return */
89
87 union { 90 union {
88 struct htb_class_leaf { 91 struct htb_class_leaf {
89 struct Qdisc *q; 92 struct Qdisc *q;
90 int prio;
91 int quantum;
92 int deficit[TC_HTB_MAXDEPTH]; 93 int deficit[TC_HTB_MAXDEPTH];
93 struct list_head drop_list; 94 struct list_head drop_list;
94 } leaf; 95 } leaf;
@@ -122,10 +123,6 @@ struct htb_class {
122 psched_tdiff_t mbuffer; /* max wait time */ 123 psched_tdiff_t mbuffer; /* max wait time */
123 long tokens, ctokens; /* current number of tokens */ 124 long tokens, ctokens; /* current number of tokens */
124 psched_time_t t_c; /* checkpoint time */ 125 psched_time_t t_c; /* checkpoint time */
125
126 int prio; /* For parent to leaf return possible here */
127 int quantum; /* we do backup. Finally full replacement */
128 /* of un.leaf originals should be done. */
129}; 126};
130 127
131static inline long L2T(struct htb_class *cl, struct qdisc_rate_table *rate, 128static inline long L2T(struct htb_class *cl, struct qdisc_rate_table *rate,
@@ -523,10 +520,10 @@ static inline void htb_activate(struct htb_sched *q, struct htb_class *cl)
523 WARN_ON(cl->level || !cl->un.leaf.q || !cl->un.leaf.q->q.qlen); 520 WARN_ON(cl->level || !cl->un.leaf.q || !cl->un.leaf.q->q.qlen);
524 521
525 if (!cl->prio_activity) { 522 if (!cl->prio_activity) {
526 cl->prio_activity = 1 << cl->un.leaf.prio; 523 cl->prio_activity = 1 << cl->prio;
527 htb_activate_prios(q, cl); 524 htb_activate_prios(q, cl);
528 list_add_tail(&cl->un.leaf.drop_list, 525 list_add_tail(&cl->un.leaf.drop_list,
529 q->drops + cl->un.leaf.prio); 526 q->drops + cl->prio);
530 } 527 }
531} 528}
532 529
@@ -816,7 +813,7 @@ next:
816 if (likely(skb != NULL)) { 813 if (likely(skb != NULL)) {
817 cl->un.leaf.deficit[level] -= qdisc_pkt_len(skb); 814 cl->un.leaf.deficit[level] -= qdisc_pkt_len(skb);
818 if (cl->un.leaf.deficit[level] < 0) { 815 if (cl->un.leaf.deficit[level] < 0) {
819 cl->un.leaf.deficit[level] += cl->un.leaf.quantum; 816 cl->un.leaf.deficit[level] += cl->quantum;
820 htb_next_rb_node((level ? cl->parent->un.inner.ptr : q-> 817 htb_next_rb_node((level ? cl->parent->un.inner.ptr : q->
821 ptr[0]) + prio); 818 ptr[0]) + prio);
822 } 819 }
@@ -1050,8 +1047,8 @@ static int htb_dump_class(struct Qdisc *sch, unsigned long arg,
1050 opt.buffer = cl->buffer; 1047 opt.buffer = cl->buffer;
1051 opt.ceil = cl->ceil->rate; 1048 opt.ceil = cl->ceil->rate;
1052 opt.cbuffer = cl->cbuffer; 1049 opt.cbuffer = cl->cbuffer;
1053 opt.quantum = cl->un.leaf.quantum; 1050 opt.quantum = cl->quantum;
1054 opt.prio = cl->un.leaf.prio; 1051 opt.prio = cl->prio;
1055 opt.level = cl->level; 1052 opt.level = cl->level;
1056 NLA_PUT(skb, TCA_HTB_PARMS, sizeof(opt), &opt); 1053 NLA_PUT(skb, TCA_HTB_PARMS, sizeof(opt), &opt);
1057 1054
@@ -1155,8 +1152,6 @@ static void htb_parent_to_leaf(struct htb_sched *q, struct htb_class *cl,
1155 memset(&parent->un.inner, 0, sizeof(parent->un.inner)); 1152 memset(&parent->un.inner, 0, sizeof(parent->un.inner));
1156 INIT_LIST_HEAD(&parent->un.leaf.drop_list); 1153 INIT_LIST_HEAD(&parent->un.leaf.drop_list);
1157 parent->un.leaf.q = new_q ? new_q : &noop_qdisc; 1154 parent->un.leaf.q = new_q ? new_q : &noop_qdisc;
1158 parent->un.leaf.quantum = parent->quantum;
1159 parent->un.leaf.prio = parent->prio;
1160 parent->tokens = parent->buffer; 1155 parent->tokens = parent->buffer;
1161 parent->ctokens = parent->cbuffer; 1156 parent->ctokens = parent->cbuffer;
1162 parent->t_c = psched_get_time(); 1157 parent->t_c = psched_get_time();
@@ -1400,27 +1395,23 @@ static int htb_change_class(struct Qdisc *sch, u32 classid,
1400 /* it used to be a nasty bug here, we have to check that node 1395 /* it used to be a nasty bug here, we have to check that node
1401 is really leaf before changing cl->un.leaf ! */ 1396 is really leaf before changing cl->un.leaf ! */
1402 if (!cl->level) { 1397 if (!cl->level) {
1403 cl->un.leaf.quantum = rtab->rate.rate / q->rate2quantum; 1398 cl->quantum = rtab->rate.rate / q->rate2quantum;
1404 if (!hopt->quantum && cl->un.leaf.quantum < 1000) { 1399 if (!hopt->quantum && cl->quantum < 1000) {
1405 printk(KERN_WARNING 1400 printk(KERN_WARNING
1406 "HTB: quantum of class %X is small. Consider r2q change.\n", 1401 "HTB: quantum of class %X is small. Consider r2q change.\n",
1407 cl->common.classid); 1402 cl->common.classid);
1408 cl->un.leaf.quantum = 1000; 1403 cl->quantum = 1000;
1409 } 1404 }
1410 if (!hopt->quantum && cl->un.leaf.quantum > 200000) { 1405 if (!hopt->quantum && cl->quantum > 200000) {
1411 printk(KERN_WARNING 1406 printk(KERN_WARNING
1412 "HTB: quantum of class %X is big. Consider r2q change.\n", 1407 "HTB: quantum of class %X is big. Consider r2q change.\n",
1413 cl->common.classid); 1408 cl->common.classid);
1414 cl->un.leaf.quantum = 200000; 1409 cl->quantum = 200000;
1415 } 1410 }
1416 if (hopt->quantum) 1411 if (hopt->quantum)
1417 cl->un.leaf.quantum = hopt->quantum; 1412 cl->quantum = hopt->quantum;
1418 if ((cl->un.leaf.prio = hopt->prio) >= TC_HTB_NUMPRIO) 1413 if ((cl->prio = hopt->prio) >= TC_HTB_NUMPRIO)
1419 cl->un.leaf.prio = TC_HTB_NUMPRIO - 1; 1414 cl->prio = TC_HTB_NUMPRIO - 1;
1420
1421 /* backup for htb_parent_to_leaf */
1422 cl->quantum = cl->un.leaf.quantum;
1423 cl->prio = cl->un.leaf.prio;
1424 } 1415 }
1425 1416
1426 cl->buffer = hopt->buffer; 1417 cl->buffer = hopt->buffer;