aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPatrick McHardy <kaber@trash.net>2007-03-23 14:29:11 -0400
committerDavid S. Miller <davem@sunset.davemloft.net>2007-04-26 01:27:54 -0400
commit03cc45c0a5b9b7f74768feb43b9a2525d203bbdb (patch)
treeacb5b1d692c9fdf526863f641547744b0a2d38a0
parent8edc0c31d6b7849b0fb50db86824830769241939 (diff)
[NET_SCHED]: turn PSCHED_TDIFF_SAFE into inline function
Also rename to psched_tdiff_bounded. Signed-off-by: Patrick McHardy <kaber@trash.net> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--include/net/pkt_sched.h8
-rw-r--r--include/net/red.h2
-rw-r--r--net/sched/act_police.c8
-rw-r--r--net/sched/sch_htb.c4
-rw-r--r--net/sched/sch_tbf.c2
5 files changed, 14 insertions, 10 deletions
diff --git a/include/net/pkt_sched.h b/include/net/pkt_sched.h
index 163973740207..e6b1da050d32 100644
--- a/include/net/pkt_sched.h
+++ b/include/net/pkt_sched.h
@@ -51,10 +51,14 @@ typedef long psched_tdiff_t;
51#define PSCHED_GET_TIME(stamp) \ 51#define PSCHED_GET_TIME(stamp) \
52 ((stamp) = PSCHED_NS2US(ktime_to_ns(ktime_get()))) 52 ((stamp) = PSCHED_NS2US(ktime_to_ns(ktime_get())))
53 53
54#define PSCHED_TDIFF_SAFE(tv1, tv2, bound) \
55 min_t(long long, (tv1) - (tv2), bound)
56#define PSCHED_PASTPERFECT 0 54#define PSCHED_PASTPERFECT 0
57 55
56static inline psched_tdiff_t
57psched_tdiff_bounded(psched_time_t tv1, psched_time_t tv2, psched_time_t bound)
58{
59 return min(tv1 - tv2, bound);
60}
61
58struct qdisc_watchdog { 62struct qdisc_watchdog {
59 struct hrtimer timer; 63 struct hrtimer timer;
60 struct Qdisc *qdisc; 64 struct Qdisc *qdisc;
diff --git a/include/net/red.h b/include/net/red.h
index d9e1149a2bca..0bc16913fdd7 100644
--- a/include/net/red.h
+++ b/include/net/red.h
@@ -178,7 +178,7 @@ static inline unsigned long red_calc_qavg_from_idle_time(struct red_parms *p)
178 int shift; 178 int shift;
179 179
180 PSCHED_GET_TIME(now); 180 PSCHED_GET_TIME(now);
181 us_idle = PSCHED_TDIFF_SAFE(now, p->qidlestart, p->Scell_max); 181 us_idle = psched_tdiff_bounded(now, p->qidlestart, p->Scell_max);
182 182
183 /* 183 /*
184 * The problem: ideally, average length queue recalcultion should 184 * The problem: ideally, average length queue recalcultion should
diff --git a/net/sched/act_police.c b/net/sched/act_police.c
index 0a5679ea6c64..65d60a3f7761 100644
--- a/net/sched/act_police.c
+++ b/net/sched/act_police.c
@@ -298,8 +298,8 @@ static int tcf_act_police(struct sk_buff *skb, struct tc_action *a,
298 298
299 PSCHED_GET_TIME(now); 299 PSCHED_GET_TIME(now);
300 300
301 toks = PSCHED_TDIFF_SAFE(now, police->tcfp_t_c, 301 toks = psched_tdiff_bounded(now, police->tcfp_t_c,
302 police->tcfp_burst); 302 police->tcfp_burst);
303 if (police->tcfp_P_tab) { 303 if (police->tcfp_P_tab) {
304 ptoks = toks + police->tcfp_ptoks; 304 ptoks = toks + police->tcfp_ptoks;
305 if (ptoks > (long)L2T_P(police, police->tcfp_mtu)) 305 if (ptoks > (long)L2T_P(police, police->tcfp_mtu))
@@ -544,8 +544,8 @@ int tcf_police(struct sk_buff *skb, struct tcf_police *police)
544 } 544 }
545 545
546 PSCHED_GET_TIME(now); 546 PSCHED_GET_TIME(now);
547 toks = PSCHED_TDIFF_SAFE(now, police->tcfp_t_c, 547 toks = psched_tdiff_bounded(now, police->tcfp_t_c,
548 police->tcfp_burst); 548 police->tcfp_burst);
549 if (police->tcfp_P_tab) { 549 if (police->tcfp_P_tab) {
550 ptoks = toks + police->tcfp_ptoks; 550 ptoks = toks + police->tcfp_ptoks;
551 if (ptoks > (long)L2T_P(police, police->tcfp_mtu)) 551 if (ptoks > (long)L2T_P(police, police->tcfp_mtu))
diff --git a/net/sched/sch_htb.c b/net/sched/sch_htb.c
index b7abd0ae676a..71e4c92b7e87 100644
--- a/net/sched/sch_htb.c
+++ b/net/sched/sch_htb.c
@@ -729,7 +729,7 @@ static void htb_charge_class(struct htb_sched *q, struct htb_class *cl,
729 cl->T = toks 729 cl->T = toks
730 730
731 while (cl) { 731 while (cl) {
732 diff = PSCHED_TDIFF_SAFE(q->now, cl->t_c, (u32) cl->mbuffer); 732 diff = psched_tdiff_bounded(q->now, cl->t_c, cl->mbuffer);
733 if (cl->level >= level) { 733 if (cl->level >= level) {
734 if (cl->level == level) 734 if (cl->level == level)
735 cl->xstats.lends++; 735 cl->xstats.lends++;
@@ -789,7 +789,7 @@ static psched_time_t htb_do_events(struct htb_sched *q, int level)
789 return cl->pq_key; 789 return cl->pq_key;
790 790
791 htb_safe_rb_erase(p, q->wait_pq + level); 791 htb_safe_rb_erase(p, q->wait_pq + level);
792 diff = PSCHED_TDIFF_SAFE(q->now, cl->t_c, (u32) cl->mbuffer); 792 diff = psched_tdiff_bounded(q->now, cl->t_c, cl->mbuffer);
793 htb_change_class_mode(q, cl, &diff); 793 htb_change_class_mode(q, cl, &diff);
794 if (cl->cmode != HTB_CAN_SEND) 794 if (cl->cmode != HTB_CAN_SEND)
795 htb_add_to_wait_tree(q, cl, diff); 795 htb_add_to_wait_tree(q, cl, diff);
diff --git a/net/sched/sch_tbf.c b/net/sched/sch_tbf.c
index 626ce96800fe..da9f40e54447 100644
--- a/net/sched/sch_tbf.c
+++ b/net/sched/sch_tbf.c
@@ -201,7 +201,7 @@ static struct sk_buff *tbf_dequeue(struct Qdisc* sch)
201 201
202 PSCHED_GET_TIME(now); 202 PSCHED_GET_TIME(now);
203 203
204 toks = PSCHED_TDIFF_SAFE(now, q->t_c, q->buffer); 204 toks = psched_tdiff_bounded(now, q->t_c, q->buffer);
205 205
206 if (q->P_tab) { 206 if (q->P_tab) {
207 ptoks = toks + q->ptokens; 207 ptoks = toks + q->ptokens;