From: Jarek Poplawski <jarkao2@gmail.com>
To: David Miller <davem@davemloft.net>
Cc: Martin Devera <devik@cdi.cz>, Patrick McHardy <kaber@trash.net>,
netdev@vger.kernel.org
Subject: [PATCH 5/3] pkt_sched: sch_htb: Replace HTB_ACCNT() macro with inlines
Date: Wed, 3 Dec 2008 10:07:38 +0000 [thread overview]
Message-ID: <20081203100738.GA16755@ff.dom.local> (raw)
In-Reply-To: <20081202085648.GC10412@ff.dom.local>
Replace HTB_ACCNT() macro with inlines to make it more readable.
Signed-off-by: Jarek Poplawski <jarkao2@gmail.com>
---
net/sched/sch_htb.c | 38 +++++++++++++++++++++++++++++---------
1 files changed, 29 insertions(+), 9 deletions(-)
diff --git a/net/sched/sch_htb.c b/net/sched/sch_htb.c
index fcd06e2..f89fd71 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)
return NET_XMIT_SUCCESS;
}
+static inline void htb_accnt_tokens(struct htb_class *cl, int bytes, long diff)
+{
+ long toks = diff + cl->tokens;
+
+ if (toks > cl->buffer)
+ toks = cl->buffer;
+ toks -= (long) qdisc_l2t(cl->rate, bytes);
+ if (toks <= -cl->mbuffer)
+ toks = 1 - cl->mbuffer;
+
+ cl->tokens = toks;
+}
+
+static inline void htb_accnt_ctokens(struct htb_class *cl, int bytes, long diff)
+{
+ long toks = diff + cl->ctokens;
+
+ if (toks > cl->cbuffer)
+ toks = cl->cbuffer;
+ toks -= (long) qdisc_l2t(cl->ceil, bytes);
+ if (toks <= -cl->mbuffer)
+ toks = 1 - cl->mbuffer;
+
+ cl->ctokens = toks;
+}
+
/**
* htb_charge_class - charges amount "bytes" to leaf and ancestors
*
@@ -592,26 +618,20 @@ static void htb_charge_class(struct htb_sched *q, struct htb_class *cl,
int level, struct sk_buff *skb)
{
int bytes = qdisc_pkt_len(skb);
- long toks, diff;
enum htb_cmode old_mode;
-
-#define HTB_ACCNT(T,B,R) toks = diff + cl->T; \
- if (toks > cl->B) toks = cl->B; \
- toks -= (long) qdisc_l2t(cl->R, bytes); \
- if (toks <= -cl->mbuffer) toks = 1-cl->mbuffer; \
- cl->T = toks
+ long diff;
while (cl) {
diff = psched_tdiff_bounded(q->now, cl->t_c, cl->mbuffer);
if (cl->level >= level) {
if (cl->level == level)
cl->xstats.lends++;
- HTB_ACCNT(tokens, buffer, rate);
+ htb_accnt_tokens(cl, bytes, diff);
} else {
cl->xstats.borrows++;
cl->tokens += diff; /* we moved t_c; update tokens */
}
- HTB_ACCNT(ctokens, cbuffer, ceil);
+ htb_accnt_ctokens(cl, bytes, diff);
cl->t_c = q->now;
old_mode = cl->cmode;
next prev parent reply other threads:[~2008-12-03 10:07 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-12-02 8:56 [PATCH 3/3] pkt_sched: sch_htb: Clean htb_class prio and quantum fields Jarek Poplawski
2008-12-03 7:09 ` [PATCH 4/3] pkt_sched: sch_htb: Clean L2T() Jarek Poplawski
2008-12-03 7:25 ` David Miller
2008-12-03 7:54 ` [PATCH 4/3 v2] " Jarek Poplawski
2008-12-03 8:20 ` David Miller
2008-12-03 8:50 ` [PATCH 4/3 v3] " Jarek Poplawski
2008-12-04 5:17 ` David Miller
2008-12-03 10:07 ` Jarek Poplawski [this message]
2008-12-04 5:17 ` [PATCH 5/3] pkt_sched: sch_htb: Replace HTB_ACCNT() macro with inlines David Miller
2008-12-04 5:09 ` [PATCH 3/3] pkt_sched: sch_htb: Clean htb_class prio and quantum fields David Miller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20081203100738.GA16755@ff.dom.local \
--to=jarkao2@gmail.com \
--cc=davem@davemloft.net \
--cc=devik@cdi.cz \
--cc=kaber@trash.net \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.