aboutsummaryrefslogtreecommitdiffstats
path: root/net/sched
diff options
context:
space:
mode:
authorJarek Poplawski <jarkao2@gmail.com>2008-12-04 00:17:27 -0500
committerDavid S. Miller <davem@davemloft.net>2008-12-04 00:17:27 -0500
commit59e4220a1112bf65924bc2e47b5757911b6f349b (patch)
tree345aae3b790634312f32e84db504ff89b080b166 /net/sched
parent23cb913d25b20ed88b36a26f337cfdb4605e63f4 (diff)
pkt_sched: sch_htb: Replace HTB_ACCNT() macro with inlines
Replace HTB_ACCNT() macro with inlines to make it more readable. Signed-off-by: Jarek Poplawski <jarkao2@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/sched')
-rw-r--r--net/sched/sch_htb.c38
1 files changed, 29 insertions, 9 deletions
diff --git a/net/sched/sch_htb.c b/net/sched/sch_htb.c
index fcd06e29e8b3..f89fd71ce92f 100644
--- a/net/sched/sch_htb.c
+++ b/net/sched/sch_htb.c
@@ -577,6 +577,32 @@ static int htb_enqueue(struct sk_buff *skb, struct Qdisc *sch)
577 return NET_XMIT_SUCCESS; 577 return NET_XMIT_SUCCESS;
578} 578}
579 579
580static inline void htb_accnt_tokens(struct htb_class *cl, int bytes, long diff)
581{
582 long toks = diff + cl->tokens;
583
584 if (toks > cl->buffer)
585 toks = cl->buffer;
586 toks -= (long) qdisc_l2t(cl->rate, bytes);
587 if (toks <= -cl->mbuffer)
588 toks = 1 - cl->mbuffer;
589
590 cl->tokens = toks;
591}
592
593static inline void htb_accnt_ctokens(struct htb_class *cl, int bytes, long diff)
594{
595 long toks = diff + cl->ctokens;
596
597 if (toks > cl->cbuffer)
598 toks = cl->cbuffer;
599 toks -= (long) qdisc_l2t(cl->ceil, bytes);
600 if (toks <= -cl->mbuffer)
601 toks = 1 - cl->mbuffer;
602
603 cl->ctokens = toks;
604}
605
580/** 606/**
581 * htb_charge_class - charges amount "bytes" to leaf and ancestors 607 * htb_charge_class - charges amount "bytes" to leaf and ancestors
582 * 608 *
@@ -592,26 +618,20 @@ static void htb_charge_class(struct htb_sched *q, struct htb_class *cl,
592 int level, struct sk_buff *skb) 618 int level, struct sk_buff *skb)
593{ 619{
594 int bytes = qdisc_pkt_len(skb); 620 int bytes = qdisc_pkt_len(skb);
595 long toks, diff;
596 enum htb_cmode old_mode; 621 enum htb_cmode old_mode;
597 622 long diff;
598#define HTB_ACCNT(T,B,R) toks = diff + cl->T; \
599 if (toks > cl->B) toks = cl->B; \
600 toks -= (long) qdisc_l2t(cl->R, bytes); \
601 if (toks <= -cl->mbuffer) toks = 1-cl->mbuffer; \
602 cl->T = toks
603 623
604 while (cl) { 624 while (cl) {
605 diff = psched_tdiff_bounded(q->now, cl->t_c, cl->mbuffer); 625 diff = psched_tdiff_bounded(q->now, cl->t_c, cl->mbuffer);
606 if (cl->level >= level) { 626 if (cl->level >= level) {
607 if (cl->level == level) 627 if (cl->level == level)
608 cl->xstats.lends++; 628 cl->xstats.lends++;
609 HTB_ACCNT(tokens, buffer, rate); 629 htb_accnt_tokens(cl, bytes, diff);
610 } else { 630 } else {
611 cl->xstats.borrows++; 631 cl->xstats.borrows++;
612 cl->tokens += diff; /* we moved t_c; update tokens */ 632 cl->tokens += diff; /* we moved t_c; update tokens */
613 } 633 }
614 HTB_ACCNT(ctokens, cbuffer, ceil); 634 htb_accnt_ctokens(cl, bytes, diff);
615 cl->t_c = q->now; 635 cl->t_c = q->now;
616 636
617 old_mode = cl->cmode; 637 old_mode = cl->cmode;