Commit c19f7a34 authored by Jarek Poplawski's avatar Jarek Poplawski Committed by David S. Miller

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: default avatarJarek Poplawski <jarkao2@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 633fe66e
...@@ -84,11 +84,12 @@ struct htb_class { ...@@ -84,11 +84,12 @@ struct htb_class {
unsigned int children; unsigned int children;
struct htb_class *parent; /* parent class */ struct htb_class *parent; /* parent class */
int prio; /* these two are used only by leaves... */
int quantum; /* but stored for parent-to-leaf return */
union { union {
struct htb_class_leaf { struct htb_class_leaf {
struct Qdisc *q; struct Qdisc *q;
int prio;
int quantum;
int deficit[TC_HTB_MAXDEPTH]; int deficit[TC_HTB_MAXDEPTH];
struct list_head drop_list; struct list_head drop_list;
} leaf; } leaf;
...@@ -122,10 +123,6 @@ struct htb_class { ...@@ -122,10 +123,6 @@ struct htb_class {
psched_tdiff_t mbuffer; /* max wait time */ psched_tdiff_t mbuffer; /* max wait time */
long tokens, ctokens; /* current number of tokens */ long tokens, ctokens; /* current number of tokens */
psched_time_t t_c; /* checkpoint time */ psched_time_t t_c; /* checkpoint time */
int prio; /* For parent to leaf return possible here */
int quantum; /* we do backup. Finally full replacement */
/* of un.leaf originals should be done. */
}; };
static inline long L2T(struct htb_class *cl, struct qdisc_rate_table *rate, static 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,10 +520,10 @@ static inline void htb_activate(struct htb_sched *q, struct htb_class *cl)
WARN_ON(cl->level || !cl->un.leaf.q || !cl->un.leaf.q->q.qlen); WARN_ON(cl->level || !cl->un.leaf.q || !cl->un.leaf.q->q.qlen);
if (!cl->prio_activity) { if (!cl->prio_activity) {
cl->prio_activity = 1 << cl->un.leaf.prio; cl->prio_activity = 1 << cl->prio;
htb_activate_prios(q, cl); htb_activate_prios(q, cl);
list_add_tail(&cl->un.leaf.drop_list, list_add_tail(&cl->un.leaf.drop_list,
q->drops + cl->un.leaf.prio); q->drops + cl->prio);
} }
} }
...@@ -816,7 +813,7 @@ static struct sk_buff *htb_dequeue_tree(struct htb_sched *q, int prio, ...@@ -816,7 +813,7 @@ static struct sk_buff *htb_dequeue_tree(struct htb_sched *q, int prio,
if (likely(skb != NULL)) { if (likely(skb != NULL)) {
cl->un.leaf.deficit[level] -= qdisc_pkt_len(skb); cl->un.leaf.deficit[level] -= qdisc_pkt_len(skb);
if (cl->un.leaf.deficit[level] < 0) { if (cl->un.leaf.deficit[level] < 0) {
cl->un.leaf.deficit[level] += cl->un.leaf.quantum; cl->un.leaf.deficit[level] += cl->quantum;
htb_next_rb_node((level ? cl->parent->un.inner.ptr : q-> htb_next_rb_node((level ? cl->parent->un.inner.ptr : q->
ptr[0]) + prio); ptr[0]) + prio);
} }
...@@ -1050,8 +1047,8 @@ static int htb_dump_class(struct Qdisc *sch, unsigned long arg, ...@@ -1050,8 +1047,8 @@ static int htb_dump_class(struct Qdisc *sch, unsigned long arg,
opt.buffer = cl->buffer; opt.buffer = cl->buffer;
opt.ceil = cl->ceil->rate; opt.ceil = cl->ceil->rate;
opt.cbuffer = cl->cbuffer; opt.cbuffer = cl->cbuffer;
opt.quantum = cl->un.leaf.quantum; opt.quantum = cl->quantum;
opt.prio = cl->un.leaf.prio; opt.prio = cl->prio;
opt.level = cl->level; opt.level = cl->level;
NLA_PUT(skb, TCA_HTB_PARMS, sizeof(opt), &opt); NLA_PUT(skb, TCA_HTB_PARMS, sizeof(opt), &opt);
...@@ -1155,8 +1152,6 @@ static void htb_parent_to_leaf(struct htb_sched *q, struct htb_class *cl, ...@@ -1155,8 +1152,6 @@ static void htb_parent_to_leaf(struct htb_sched *q, struct htb_class *cl,
memset(&parent->un.inner, 0, sizeof(parent->un.inner)); memset(&parent->un.inner, 0, sizeof(parent->un.inner));
INIT_LIST_HEAD(&parent->un.leaf.drop_list); INIT_LIST_HEAD(&parent->un.leaf.drop_list);
parent->un.leaf.q = new_q ? new_q : &noop_qdisc; parent->un.leaf.q = new_q ? new_q : &noop_qdisc;
parent->un.leaf.quantum = parent->quantum;
parent->un.leaf.prio = parent->prio;
parent->tokens = parent->buffer; parent->tokens = parent->buffer;
parent->ctokens = parent->cbuffer; parent->ctokens = parent->cbuffer;
parent->t_c = psched_get_time(); parent->t_c = psched_get_time();
...@@ -1400,27 +1395,23 @@ static int htb_change_class(struct Qdisc *sch, u32 classid, ...@@ -1400,27 +1395,23 @@ static int htb_change_class(struct Qdisc *sch, u32 classid,
/* it used to be a nasty bug here, we have to check that node /* it used to be a nasty bug here, we have to check that node
is really leaf before changing cl->un.leaf ! */ is really leaf before changing cl->un.leaf ! */
if (!cl->level) { if (!cl->level) {
cl->un.leaf.quantum = rtab->rate.rate / q->rate2quantum; cl->quantum = rtab->rate.rate / q->rate2quantum;
if (!hopt->quantum && cl->un.leaf.quantum < 1000) { if (!hopt->quantum && cl->quantum < 1000) {
printk(KERN_WARNING printk(KERN_WARNING
"HTB: quantum of class %X is small. Consider r2q change.\n", "HTB: quantum of class %X is small. Consider r2q change.\n",
cl->common.classid); cl->common.classid);
cl->un.leaf.quantum = 1000; cl->quantum = 1000;
} }
if (!hopt->quantum && cl->un.leaf.quantum > 200000) { if (!hopt->quantum && cl->quantum > 200000) {
printk(KERN_WARNING printk(KERN_WARNING
"HTB: quantum of class %X is big. Consider r2q change.\n", "HTB: quantum of class %X is big. Consider r2q change.\n",
cl->common.classid); cl->common.classid);
cl->un.leaf.quantum = 200000; cl->quantum = 200000;
} }
if (hopt->quantum) if (hopt->quantum)
cl->un.leaf.quantum = hopt->quantum; cl->quantum = hopt->quantum;
if ((cl->un.leaf.prio = hopt->prio) >= TC_HTB_NUMPRIO) if ((cl->prio = hopt->prio) >= TC_HTB_NUMPRIO)
cl->un.leaf.prio = TC_HTB_NUMPRIO - 1; cl->prio = TC_HTB_NUMPRIO - 1;
/* backup for htb_parent_to_leaf */
cl->quantum = cl->un.leaf.quantum;
cl->prio = cl->un.leaf.prio;
} }
cl->buffer = hopt->buffer; cl->buffer = hopt->buffer;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment