diff options
author | Patrick McHardy <kaber@trash.net> | 2007-03-23 14:29:25 -0400 |
---|---|---|
committer | David S. Miller <davem@sunset.davemloft.net> | 2007-04-26 01:27:55 -0400 |
commit | 3bebcda28077375470dd60545b71bba2f83335fd (patch) | |
tree | a0d610788ccfe8d3b50d6ebf3df014e98f6387bc | |
parent | 03cc45c0a5b9b7f74768feb43b9a2525d203bbdb (diff) |
[NET_SCHED]: turn PSCHED_GET_TIME into inline function
Signed-off-by: Patrick McHardy <kaber@trash.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | include/net/pkt_sched.h | 8 | ||||
-rw-r--r-- | include/net/red.h | 4 | ||||
-rw-r--r-- | net/sched/act_police.c | 9 | ||||
-rw-r--r-- | net/sched/sch_cbq.c | 10 | ||||
-rw-r--r-- | net/sched/sch_hfsc.c | 10 | ||||
-rw-r--r-- | net/sched/sch_htb.c | 6 | ||||
-rw-r--r-- | net/sched/sch_netem.c | 8 | ||||
-rw-r--r-- | net/sched/sch_tbf.c | 7 |
8 files changed, 29 insertions, 33 deletions
diff --git a/include/net/pkt_sched.h b/include/net/pkt_sched.h index e6b1da050d32..b2cc9a8ed4e7 100644 --- a/include/net/pkt_sched.h +++ b/include/net/pkt_sched.h | |||
@@ -48,11 +48,13 @@ typedef long psched_tdiff_t; | |||
48 | #define PSCHED_NS2US(x) ((x) >> 10) | 48 | #define PSCHED_NS2US(x) ((x) >> 10) |
49 | 49 | ||
50 | #define PSCHED_TICKS_PER_SEC PSCHED_NS2US(NSEC_PER_SEC) | 50 | #define PSCHED_TICKS_PER_SEC PSCHED_NS2US(NSEC_PER_SEC) |
51 | #define PSCHED_GET_TIME(stamp) \ | ||
52 | ((stamp) = PSCHED_NS2US(ktime_to_ns(ktime_get()))) | ||
53 | |||
54 | #define PSCHED_PASTPERFECT 0 | 51 | #define PSCHED_PASTPERFECT 0 |
55 | 52 | ||
53 | static inline psched_time_t psched_get_time(void) | ||
54 | { | ||
55 | return PSCHED_NS2US(ktime_to_ns(ktime_get())); | ||
56 | } | ||
57 | |||
56 | static inline psched_tdiff_t | 58 | static inline psched_tdiff_t |
57 | psched_tdiff_bounded(psched_time_t tv1, psched_time_t tv2, psched_time_t bound) | 59 | psched_tdiff_bounded(psched_time_t tv1, psched_time_t tv2, psched_time_t bound) |
58 | { | 60 | { |
diff --git a/include/net/red.h b/include/net/red.h index 0bc16913fdd7..3cf31d466a81 100644 --- a/include/net/red.h +++ b/include/net/red.h | |||
@@ -156,7 +156,7 @@ static inline int red_is_idling(struct red_parms *p) | |||
156 | 156 | ||
157 | static inline void red_start_of_idle_period(struct red_parms *p) | 157 | static inline void red_start_of_idle_period(struct red_parms *p) |
158 | { | 158 | { |
159 | PSCHED_GET_TIME(p->qidlestart); | 159 | p->qidlestart = psched_get_time(); |
160 | } | 160 | } |
161 | 161 | ||
162 | static inline void red_end_of_idle_period(struct red_parms *p) | 162 | static inline void red_end_of_idle_period(struct red_parms *p) |
@@ -177,7 +177,7 @@ static inline unsigned long red_calc_qavg_from_idle_time(struct red_parms *p) | |||
177 | long us_idle; | 177 | long us_idle; |
178 | int shift; | 178 | int shift; |
179 | 179 | ||
180 | PSCHED_GET_TIME(now); | 180 | now = psched_get_time(); |
181 | us_idle = psched_tdiff_bounded(now, p->qidlestart, p->Scell_max); | 181 | us_idle = psched_tdiff_bounded(now, p->qidlestart, p->Scell_max); |
182 | 182 | ||
183 | /* | 183 | /* |
diff --git a/net/sched/act_police.c b/net/sched/act_police.c index 65d60a3f7761..616f465f407e 100644 --- a/net/sched/act_police.c +++ b/net/sched/act_police.c | |||
@@ -241,7 +241,7 @@ override: | |||
241 | if (ret != ACT_P_CREATED) | 241 | if (ret != ACT_P_CREATED) |
242 | return ret; | 242 | return ret; |
243 | 243 | ||
244 | PSCHED_GET_TIME(police->tcfp_t_c); | 244 | police->tcfp_t_c = psched_get_time(); |
245 | police->tcf_index = parm->index ? parm->index : | 245 | police->tcf_index = parm->index ? parm->index : |
246 | tcf_hash_new_index(&police_idx_gen, &police_hash_info); | 246 | tcf_hash_new_index(&police_idx_gen, &police_hash_info); |
247 | h = tcf_hash(police->tcf_index, POL_TAB_MASK); | 247 | h = tcf_hash(police->tcf_index, POL_TAB_MASK); |
@@ -296,8 +296,7 @@ static int tcf_act_police(struct sk_buff *skb, struct tc_action *a, | |||
296 | return police->tcfp_result; | 296 | return police->tcfp_result; |
297 | } | 297 | } |
298 | 298 | ||
299 | PSCHED_GET_TIME(now); | 299 | now = psched_get_time(); |
300 | |||
301 | toks = psched_tdiff_bounded(now, police->tcfp_t_c, | 300 | toks = psched_tdiff_bounded(now, police->tcfp_t_c, |
302 | police->tcfp_burst); | 301 | police->tcfp_burst); |
303 | if (police->tcfp_P_tab) { | 302 | if (police->tcfp_P_tab) { |
@@ -495,7 +494,7 @@ struct tcf_police *tcf_police_locate(struct rtattr *rta, struct rtattr *est) | |||
495 | } | 494 | } |
496 | if (police->tcfp_P_tab) | 495 | if (police->tcfp_P_tab) |
497 | police->tcfp_ptoks = L2T_P(police, police->tcfp_mtu); | 496 | police->tcfp_ptoks = L2T_P(police, police->tcfp_mtu); |
498 | PSCHED_GET_TIME(police->tcfp_t_c); | 497 | police->tcfp_t_c = psched_get_time(); |
499 | police->tcf_index = parm->index ? parm->index : | 498 | police->tcf_index = parm->index ? parm->index : |
500 | tcf_police_new_index(); | 499 | tcf_police_new_index(); |
501 | police->tcf_action = parm->action; | 500 | police->tcf_action = parm->action; |
@@ -543,7 +542,7 @@ int tcf_police(struct sk_buff *skb, struct tcf_police *police) | |||
543 | return police->tcfp_result; | 542 | return police->tcfp_result; |
544 | } | 543 | } |
545 | 544 | ||
546 | PSCHED_GET_TIME(now); | 545 | now = psched_get_time(); |
547 | toks = psched_tdiff_bounded(now, police->tcfp_t_c, | 546 | toks = psched_tdiff_bounded(now, police->tcfp_t_c, |
548 | police->tcfp_burst); | 547 | police->tcfp_burst); |
549 | if (police->tcfp_P_tab) { | 548 | if (police->tcfp_P_tab) { |
diff --git a/net/sched/sch_cbq.c b/net/sched/sch_cbq.c index f9e8403c5222..414a97c962f1 100644 --- a/net/sched/sch_cbq.c +++ b/net/sched/sch_cbq.c | |||
@@ -385,7 +385,7 @@ cbq_mark_toplevel(struct cbq_sched_data *q, struct cbq_class *cl) | |||
385 | psched_time_t now; | 385 | psched_time_t now; |
386 | psched_tdiff_t incr; | 386 | psched_tdiff_t incr; |
387 | 387 | ||
388 | PSCHED_GET_TIME(now); | 388 | now = psched_get_time(); |
389 | incr = now - q->now_rt; | 389 | incr = now - q->now_rt; |
390 | now = q->now + incr; | 390 | now = q->now + incr; |
391 | 391 | ||
@@ -654,7 +654,7 @@ static enum hrtimer_restart cbq_undelay(struct hrtimer *timer) | |||
654 | psched_tdiff_t delay = 0; | 654 | psched_tdiff_t delay = 0; |
655 | unsigned pmask; | 655 | unsigned pmask; |
656 | 656 | ||
657 | PSCHED_GET_TIME(now); | 657 | now = psched_get_time(); |
658 | 658 | ||
659 | pmask = q->pmask; | 659 | pmask = q->pmask; |
660 | q->pmask = 0; | 660 | q->pmask = 0; |
@@ -1003,7 +1003,7 @@ cbq_dequeue(struct Qdisc *sch) | |||
1003 | psched_time_t now; | 1003 | psched_time_t now; |
1004 | psched_tdiff_t incr; | 1004 | psched_tdiff_t incr; |
1005 | 1005 | ||
1006 | PSCHED_GET_TIME(now); | 1006 | now = psched_get_time(); |
1007 | incr = now - q->now_rt; | 1007 | incr = now - q->now_rt; |
1008 | 1008 | ||
1009 | if (q->tx_class) { | 1009 | if (q->tx_class) { |
@@ -1277,7 +1277,7 @@ cbq_reset(struct Qdisc* sch) | |||
1277 | qdisc_watchdog_cancel(&q->watchdog); | 1277 | qdisc_watchdog_cancel(&q->watchdog); |
1278 | hrtimer_cancel(&q->delay_timer); | 1278 | hrtimer_cancel(&q->delay_timer); |
1279 | q->toplevel = TC_CBQ_MAXLEVEL; | 1279 | q->toplevel = TC_CBQ_MAXLEVEL; |
1280 | PSCHED_GET_TIME(q->now); | 1280 | q->now = psched_get_time(); |
1281 | q->now_rt = q->now; | 1281 | q->now_rt = q->now; |
1282 | 1282 | ||
1283 | for (prio = 0; prio <= TC_CBQ_MAXPRIO; prio++) | 1283 | for (prio = 0; prio <= TC_CBQ_MAXPRIO; prio++) |
@@ -1448,7 +1448,7 @@ static int cbq_init(struct Qdisc *sch, struct rtattr *opt) | |||
1448 | hrtimer_init(&q->delay_timer, CLOCK_MONOTONIC, HRTIMER_MODE_ABS); | 1448 | hrtimer_init(&q->delay_timer, CLOCK_MONOTONIC, HRTIMER_MODE_ABS); |
1449 | q->delay_timer.function = cbq_undelay; | 1449 | q->delay_timer.function = cbq_undelay; |
1450 | q->toplevel = TC_CBQ_MAXLEVEL; | 1450 | q->toplevel = TC_CBQ_MAXLEVEL; |
1451 | PSCHED_GET_TIME(q->now); | 1451 | q->now = psched_get_time(); |
1452 | q->now_rt = q->now; | 1452 | q->now_rt = q->now; |
1453 | 1453 | ||
1454 | cbq_link_class(&q->link); | 1454 | cbq_link_class(&q->link); |
diff --git a/net/sched/sch_hfsc.c b/net/sched/sch_hfsc.c index 6a762cf781d7..7d51d0d6a70e 100644 --- a/net/sched/sch_hfsc.c +++ b/net/sched/sch_hfsc.c | |||
@@ -629,9 +629,7 @@ rtsc_min(struct runtime_sc *rtsc, struct internal_sc *isc, u64 x, u64 y) | |||
629 | static void | 629 | static void |
630 | init_ed(struct hfsc_class *cl, unsigned int next_len) | 630 | init_ed(struct hfsc_class *cl, unsigned int next_len) |
631 | { | 631 | { |
632 | u64 cur_time; | 632 | u64 cur_time = psched_get_time(); |
633 | |||
634 | PSCHED_GET_TIME(cur_time); | ||
635 | 633 | ||
636 | /* update the deadline curve */ | 634 | /* update the deadline curve */ |
637 | rtsc_min(&cl->cl_deadline, &cl->cl_rsc, cur_time, cl->cl_cumul); | 635 | rtsc_min(&cl->cl_deadline, &cl->cl_rsc, cur_time, cl->cl_cumul); |
@@ -754,7 +752,7 @@ init_vf(struct hfsc_class *cl, unsigned int len) | |||
754 | if (cl->cl_flags & HFSC_USC) { | 752 | if (cl->cl_flags & HFSC_USC) { |
755 | /* class has upper limit curve */ | 753 | /* class has upper limit curve */ |
756 | if (cur_time == 0) | 754 | if (cur_time == 0) |
757 | PSCHED_GET_TIME(cur_time); | 755 | cur_time = psched_get_time(); |
758 | 756 | ||
759 | /* update the ulimit curve */ | 757 | /* update the ulimit curve */ |
760 | rtsc_min(&cl->cl_ulimit, &cl->cl_usc, cur_time, | 758 | rtsc_min(&cl->cl_ulimit, &cl->cl_usc, cur_time, |
@@ -1038,7 +1036,7 @@ hfsc_change_class(struct Qdisc *sch, u32 classid, u32 parentid, | |||
1038 | if (cl->cl_parent == NULL && parentid != TC_H_ROOT) | 1036 | if (cl->cl_parent == NULL && parentid != TC_H_ROOT) |
1039 | return -EINVAL; | 1037 | return -EINVAL; |
1040 | } | 1038 | } |
1041 | PSCHED_GET_TIME(cur_time); | 1039 | cur_time = psched_get_time(); |
1042 | 1040 | ||
1043 | sch_tree_lock(sch); | 1041 | sch_tree_lock(sch); |
1044 | if (rsc != NULL) | 1042 | if (rsc != NULL) |
@@ -1639,7 +1637,7 @@ hfsc_dequeue(struct Qdisc *sch) | |||
1639 | if ((skb = __skb_dequeue(&q->requeue))) | 1637 | if ((skb = __skb_dequeue(&q->requeue))) |
1640 | goto out; | 1638 | goto out; |
1641 | 1639 | ||
1642 | PSCHED_GET_TIME(cur_time); | 1640 | cur_time = psched_get_time(); |
1643 | 1641 | ||
1644 | /* | 1642 | /* |
1645 | * if there are eligible classes, use real-time criteria. | 1643 | * if there are eligible classes, use real-time criteria. |
diff --git a/net/sched/sch_htb.c b/net/sched/sch_htb.c index 71e4c92b7e87..3f528554b0d4 100644 --- a/net/sched/sch_htb.c +++ b/net/sched/sch_htb.c | |||
@@ -965,7 +965,7 @@ static struct sk_buff *htb_dequeue(struct Qdisc *sch) | |||
965 | 965 | ||
966 | if (!sch->q.qlen) | 966 | if (!sch->q.qlen) |
967 | goto fin; | 967 | goto fin; |
968 | PSCHED_GET_TIME(q->now); | 968 | q->now = psched_get_time(); |
969 | 969 | ||
970 | next_event = q->now + 5 * PSCHED_TICKS_PER_SEC; | 970 | next_event = q->now + 5 * PSCHED_TICKS_PER_SEC; |
971 | q->nwc_hit = 0; | 971 | q->nwc_hit = 0; |
@@ -1274,7 +1274,7 @@ static void htb_parent_to_leaf(struct htb_class *cl, struct Qdisc *new_q) | |||
1274 | parent->un.leaf.prio = parent->prio; | 1274 | parent->un.leaf.prio = parent->prio; |
1275 | parent->tokens = parent->buffer; | 1275 | parent->tokens = parent->buffer; |
1276 | parent->ctokens = parent->cbuffer; | 1276 | parent->ctokens = parent->cbuffer; |
1277 | PSCHED_GET_TIME(parent->t_c); | 1277 | parent->t_c = psched_get_time(); |
1278 | parent->cmode = HTB_CAN_SEND; | 1278 | parent->cmode = HTB_CAN_SEND; |
1279 | } | 1279 | } |
1280 | 1280 | ||
@@ -1471,7 +1471,7 @@ static int htb_change_class(struct Qdisc *sch, u32 classid, | |||
1471 | cl->tokens = hopt->buffer; | 1471 | cl->tokens = hopt->buffer; |
1472 | cl->ctokens = hopt->cbuffer; | 1472 | cl->ctokens = hopt->cbuffer; |
1473 | cl->mbuffer = 60 * PSCHED_TICKS_PER_SEC; /* 1min */ | 1473 | cl->mbuffer = 60 * PSCHED_TICKS_PER_SEC; /* 1min */ |
1474 | PSCHED_GET_TIME(cl->t_c); | 1474 | cl->t_c = psched_get_time(); |
1475 | cl->cmode = HTB_CAN_SEND; | 1475 | cl->cmode = HTB_CAN_SEND; |
1476 | 1476 | ||
1477 | /* attach to the hash list and parent's family */ | 1477 | /* attach to the hash list and parent's family */ |
diff --git a/net/sched/sch_netem.c b/net/sched/sch_netem.c index 1e88301f505c..5d9d8bc9cc3a 100644 --- a/net/sched/sch_netem.c +++ b/net/sched/sch_netem.c | |||
@@ -217,7 +217,7 @@ static int netem_enqueue(struct sk_buff *skb, struct Qdisc *sch) | |||
217 | delay = tabledist(q->latency, q->jitter, | 217 | delay = tabledist(q->latency, q->jitter, |
218 | &q->delay_cor, q->delay_dist); | 218 | &q->delay_cor, q->delay_dist); |
219 | 219 | ||
220 | PSCHED_GET_TIME(now); | 220 | now = psched_get_time(); |
221 | cb->time_to_send = now + delay; | 221 | cb->time_to_send = now + delay; |
222 | ++q->counter; | 222 | ++q->counter; |
223 | ret = q->qdisc->enqueue(skb, q->qdisc); | 223 | ret = q->qdisc->enqueue(skb, q->qdisc); |
@@ -226,7 +226,7 @@ static int netem_enqueue(struct sk_buff *skb, struct Qdisc *sch) | |||
226 | * Do re-ordering by putting one out of N packets at the front | 226 | * Do re-ordering by putting one out of N packets at the front |
227 | * of the queue. | 227 | * of the queue. |
228 | */ | 228 | */ |
229 | PSCHED_GET_TIME(cb->time_to_send); | 229 | cb->time_to_send = psched_get_time(); |
230 | q->counter = 0; | 230 | q->counter = 0; |
231 | ret = q->qdisc->ops->requeue(skb, q->qdisc); | 231 | ret = q->qdisc->ops->requeue(skb, q->qdisc); |
232 | } | 232 | } |
@@ -281,11 +281,9 @@ static struct sk_buff *netem_dequeue(struct Qdisc *sch) | |||
281 | if (skb) { | 281 | if (skb) { |
282 | const struct netem_skb_cb *cb | 282 | const struct netem_skb_cb *cb |
283 | = (const struct netem_skb_cb *)skb->cb; | 283 | = (const struct netem_skb_cb *)skb->cb; |
284 | psched_time_t now; | 284 | psched_time_t now = psched_get_time(); |
285 | 285 | ||
286 | /* if more time remaining? */ | 286 | /* if more time remaining? */ |
287 | PSCHED_GET_TIME(now); | ||
288 | |||
289 | if (cb->time_to_send <= now) { | 287 | if (cb->time_to_send <= now) { |
290 | pr_debug("netem_dequeue: return skb=%p\n", skb); | 288 | pr_debug("netem_dequeue: return skb=%p\n", skb); |
291 | sch->q.qlen--; | 289 | sch->q.qlen--; |
diff --git a/net/sched/sch_tbf.c b/net/sched/sch_tbf.c index da9f40e54447..53862953baaf 100644 --- a/net/sched/sch_tbf.c +++ b/net/sched/sch_tbf.c | |||
@@ -199,8 +199,7 @@ static struct sk_buff *tbf_dequeue(struct Qdisc* sch) | |||
199 | long ptoks = 0; | 199 | long ptoks = 0; |
200 | unsigned int len = skb->len; | 200 | unsigned int len = skb->len; |
201 | 201 | ||
202 | PSCHED_GET_TIME(now); | 202 | now = psched_get_time(); |
203 | |||
204 | toks = psched_tdiff_bounded(now, q->t_c, q->buffer); | 203 | toks = psched_tdiff_bounded(now, q->t_c, q->buffer); |
205 | 204 | ||
206 | if (q->P_tab) { | 205 | if (q->P_tab) { |
@@ -254,7 +253,7 @@ static void tbf_reset(struct Qdisc* sch) | |||
254 | 253 | ||
255 | qdisc_reset(q->qdisc); | 254 | qdisc_reset(q->qdisc); |
256 | sch->q.qlen = 0; | 255 | sch->q.qlen = 0; |
257 | PSCHED_GET_TIME(q->t_c); | 256 | q->t_c = psched_get_time(); |
258 | q->tokens = q->buffer; | 257 | q->tokens = q->buffer; |
259 | q->ptokens = q->mtu; | 258 | q->ptokens = q->mtu; |
260 | qdisc_watchdog_cancel(&q->watchdog); | 259 | qdisc_watchdog_cancel(&q->watchdog); |
@@ -364,7 +363,7 @@ static int tbf_init(struct Qdisc* sch, struct rtattr *opt) | |||
364 | if (opt == NULL) | 363 | if (opt == NULL) |
365 | return -EINVAL; | 364 | return -EINVAL; |
366 | 365 | ||
367 | PSCHED_GET_TIME(q->t_c); | 366 | q->t_c = psched_get_time(); |
368 | qdisc_watchdog_init(&q->watchdog, sch); | 367 | qdisc_watchdog_init(&q->watchdog, sch); |
369 | q->qdisc = &noop_qdisc; | 368 | q->qdisc = &noop_qdisc; |
370 | 369 | ||