* [IPROUTE 01/05]: Use tc_calc_xmittime where appropriate
2007-01-10 10:01 [IPROUTE 00/05]: Time cleanups Patrick McHardy
@ 2007-01-10 10:01 ` Patrick McHardy
2007-01-16 8:56 ` Jarek Poplawski
2007-01-10 10:01 ` [IPROUTE 02/05]: Introduce tc_calc_xmitsize and use " Patrick McHardy
` (3 subsequent siblings)
4 siblings, 1 reply; 16+ messages in thread
From: Patrick McHardy @ 2007-01-10 10:01 UTC (permalink / raw)
To: shemminger; +Cc: netdev, Patrick McHardy
[IPROUTE]: Use tc_calc_xmittime where appropriate
Replace expressions of the form "1000000 * size/rate" by tc_calc_xmittime().
The CBQ case deserves an extra comment: when called with bnwd=rate
tc_cbq_calc_maxidle behaves identical to tc_calc_xmittime, so use it
for clarity.
Signed-off-by: Patrick McHardy <kaber@trash.net>
---
commit d786eedd7b3e9ceb381ee602efcbe002afc7be73
tree 4db59786df1da875f9c3956000496dd8455d5af6
parent 40076f622e0aacb2b792d3ac1b5d12aa97c4da9c
author Patrick McHardy <kaber@trash.net> Wed, 10 Jan 2007 10:40:05 +0100
committer Patrick McHardy <kaber@trash.net> Wed, 10 Jan 2007 10:40:05 +0100
tc/q_cbq.c | 2 +-
tc/tc_core.c | 2 +-
tc/tc_red.c | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/tc/q_cbq.c b/tc/q_cbq.c
index bc7e8ba..0000a56 100644
--- a/tc/q_cbq.c
+++ b/tc/q_cbq.c
@@ -147,7 +147,7 @@ static int cbq_parse_opt(struct qdisc_ut
if (ewma_log < 0)
ewma_log = TC_CBQ_DEF_EWMA;
lss.ewma_log = ewma_log;
- lss.maxidle = tc_cbq_calc_maxidle(r.rate, r.rate, avpkt, lss.ewma_log, 0);
+ lss.maxidle = tc_calc_xmittime(r.rate, avpkt);
lss.change = TCF_CBQ_LSS_MAXIDLE|TCF_CBQ_LSS_EWMA|TCF_CBQ_LSS_AVPKT;
lss.avpkt = avpkt;
diff --git a/tc/tc_core.c b/tc/tc_core.c
index 10c375e..90a097d 100644
--- a/tc/tc_core.c
+++ b/tc/tc_core.c
@@ -76,7 +76,7 @@ int tc_calc_rtable(unsigned bps, __u32 *
sz += overhead;
if (sz < mpu)
sz = mpu;
- rtab[i] = tc_core_usec2tick(1000000*((double)sz/bps));
+ rtab[i] = tc_calc_xmittime(bps, sz);
}
return cell_log;
}
diff --git a/tc/tc_red.c b/tc/tc_red.c
index 385e7af..8f9bde0 100644
--- a/tc/tc_red.c
+++ b/tc/tc_red.c
@@ -71,7 +71,7 @@ int tc_red_eval_ewma(unsigned qmin, unsi
int tc_red_eval_idle_damping(int Wlog, unsigned avpkt, unsigned bps, __u8 *sbuf)
{
- double xmit_time = tc_core_usec2tick(1000000*(double)avpkt/bps);
+ double xmit_time = tc_calc_xmittime(bps, avpkt);
double lW = -log(1.0 - 1.0/(1<<Wlog))/xmit_time;
double maxtime = 31/lW;
int clog;
^ permalink raw reply related [flat|nested] 16+ messages in thread* Re: [IPROUTE 01/05]: Use tc_calc_xmittime where appropriate
2007-01-10 10:01 ` [IPROUTE 01/05]: Use tc_calc_xmittime where appropriate Patrick McHardy
@ 2007-01-16 8:56 ` Jarek Poplawski
2007-01-16 10:19 ` Patrick McHardy
0 siblings, 1 reply; 16+ messages in thread
From: Jarek Poplawski @ 2007-01-16 8:56 UTC (permalink / raw)
To: Patrick McHardy; +Cc: netdev, shemminger
On 10-01-2007 11:01, Patrick McHardy wrote:
> [IPROUTE]: Use tc_calc_xmittime where appropriate
>
> Replace expressions of the form "1000000 * size/rate" by tc_calc_xmittime().
> The CBQ case deserves an extra comment: when called with bnwd=rate
> tc_cbq_calc_maxidle behaves identical to tc_calc_xmittime, so use it
> for clarity.
>
> Signed-off-by: Patrick McHardy <kaber@trash.net>
>
> ---
...
> diff --git a/tc/tc_red.c b/tc/tc_red.c
> index 385e7af..8f9bde0 100644
> --- a/tc/tc_red.c
> +++ b/tc/tc_red.c
> @@ -71,7 +71,7 @@ int tc_red_eval_ewma(unsigned qmin, unsi
>
> int tc_red_eval_idle_damping(int Wlog, unsigned avpkt, unsigned bps, __u8 *sbuf)
> {
> - double xmit_time = tc_core_usec2tick(1000000*(double)avpkt/bps);
> + double xmit_time = tc_calc_xmittime(bps, avpkt);
Return value changed to unsigned here.
(According to iproute2-2.6.19-061214.)
> double lW = -log(1.0 - 1.0/(1<<Wlog))/xmit_time;
> double maxtime = 31/lW;
> int clog;
^ permalink raw reply [flat|nested] 16+ messages in thread* Re: [IPROUTE 01/05]: Use tc_calc_xmittime where appropriate
2007-01-16 8:56 ` Jarek Poplawski
@ 2007-01-16 10:19 ` Patrick McHardy
2007-01-16 11:02 ` Jarek Poplawski
0 siblings, 1 reply; 16+ messages in thread
From: Patrick McHardy @ 2007-01-16 10:19 UTC (permalink / raw)
To: Jarek Poplawski; +Cc: netdev, shemminger
Jarek Poplawski wrote:
> On 10-01-2007 11:01, Patrick McHardy wrote:
>
>>[IPROUTE]: Use tc_calc_xmittime where appropriate
>>
>>diff --git a/tc/tc_red.c b/tc/tc_red.c
>>index 385e7af..8f9bde0 100644
>>--- a/tc/tc_red.c
>>+++ b/tc/tc_red.c
>>@@ -71,7 +71,7 @@ int tc_red_eval_ewma(unsigned qmin, unsi
>>
>> int tc_red_eval_idle_damping(int Wlog, unsigned avpkt, unsigned bps, __u8 *sbuf)
>> {
>>- double xmit_time = tc_core_usec2tick(1000000*(double)avpkt/bps);
>>+ double xmit_time = tc_calc_xmittime(bps, avpkt);
>
>
> Return value changed to unsigned here.
> (According to iproute2-2.6.19-061214.)
Right, this changes it from long (tc_core_usec2tick) to unsigned
int. It doesn't make any difference though, with 32 bit we can
represent transmission times up to ~1 hour (for a single packet),
which is far more than needed.
^ permalink raw reply [flat|nested] 16+ messages in thread* Re: [IPROUTE 01/05]: Use tc_calc_xmittime where appropriate
2007-01-16 10:19 ` Patrick McHardy
@ 2007-01-16 11:02 ` Jarek Poplawski
2007-01-16 12:28 ` Patrick McHardy
0 siblings, 1 reply; 16+ messages in thread
From: Jarek Poplawski @ 2007-01-16 11:02 UTC (permalink / raw)
To: Patrick McHardy; +Cc: netdev, shemminger
On Tue, Jan 16, 2007 at 11:19:34AM +0100, Patrick McHardy wrote:
...
> Right, this changes it from long (tc_core_usec2tick) to unsigned
> int. It doesn't make any difference though, ...
... if we count out reading_time_2tick, of course.
Jarek P.
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [IPROUTE 01/05]: Use tc_calc_xmittime where appropriate
2007-01-16 11:02 ` Jarek Poplawski
@ 2007-01-16 12:28 ` Patrick McHardy
2007-01-16 12:48 ` Jarek Poplawski
0 siblings, 1 reply; 16+ messages in thread
From: Patrick McHardy @ 2007-01-16 12:28 UTC (permalink / raw)
To: Jarek Poplawski; +Cc: netdev, shemminger
Jarek Poplawski wrote:
> On Tue, Jan 16, 2007 at 11:19:34AM +0100, Patrick McHardy wrote:
> ...
>
>>Right, this changes it from long (tc_core_usec2tick) to unsigned
>>int. It doesn't make any difference though, ...
>
>
> ... if we count out reading_time_2tick, of course.
And this is a problem why? In the worst case (NET_SCH_CLK_CPU,
max rate 1/0.5us) it allows us to represent a transmission time
of 2^32/1000000/2s (where 2 is tick_in_usec), which is roughly
2147s.
If you still have doubts, please use numbers to demonstrate the
problem.
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [IPROUTE 01/05]: Use tc_calc_xmittime where appropriate
2007-01-16 12:28 ` Patrick McHardy
@ 2007-01-16 12:48 ` Jarek Poplawski
0 siblings, 0 replies; 16+ messages in thread
From: Jarek Poplawski @ 2007-01-16 12:48 UTC (permalink / raw)
To: Patrick McHardy; +Cc: netdev, shemminger
On Tue, Jan 16, 2007 at 01:28:52PM +0100, Patrick McHardy wrote:
> Jarek Poplawski wrote:
> > On Tue, Jan 16, 2007 at 11:19:34AM +0100, Patrick McHardy wrote:
> > ...
> >
> >>Right, this changes it from long (tc_core_usec2tick) to unsigned
> >>int. It doesn't make any difference though, ...
> >
> >
> > ... if we count out reading_time_2tick, of course.
>
> And this is a problem why? In the worst case (NET_SCH_CLK_CPU,
> max rate 1/0.5us) it allows us to represent a transmission time
> of 2^32/1000000/2s (where 2 is tick_in_usec), which is roughly
> 2147s.
>
> If you still have doubts, please use numbers to demonstrate the
> problem.
Sorry, I probably forgot to add "the face".
The only problem is that when reading a patch you have
to guess if this was considered by the author or as in
other place to check all next uses of double variable
to see they actually always store unsigned.
But probably I should correct readability of my posts,
too.
Jarek P.
^ permalink raw reply [flat|nested] 16+ messages in thread
* [IPROUTE 02/05]: Introduce tc_calc_xmitsize and use where appropriate
2007-01-10 10:01 [IPROUTE 00/05]: Time cleanups Patrick McHardy
2007-01-10 10:01 ` [IPROUTE 01/05]: Use tc_calc_xmittime where appropriate Patrick McHardy
@ 2007-01-10 10:01 ` Patrick McHardy
2007-01-15 12:35 ` Jarek Poplawski
2007-01-10 10:01 ` [IPROUTE 03/05]: Introduce TIME_UNITS_PER_SEC to represent internal clock resolution Patrick McHardy
` (2 subsequent siblings)
4 siblings, 1 reply; 16+ messages in thread
From: Patrick McHardy @ 2007-01-10 10:01 UTC (permalink / raw)
To: shemminger; +Cc: netdev, Patrick McHardy
[IPROUTE]: Introduce tc_calc_xmitsize and use where appropriate
Add tc_calc_xmitsize() as complement to tc_calc_xmittime(), which calculates
the size that can be transmitted at a given rate during a given time.
Replace all expressions of the form "size = rate*tc_core_tick2usec(time))/1000000"
by tc_calc_xmitsize() calls.
Signed-off-by: Patrick McHardy <kaber@trash.net>
---
commit f5eaed98ecc93f088bed8d3f6d9f6b74ca32ddde
tree 1429737f32d4e68e55d1d7ce57dd0ab881acafca
parent d786eedd7b3e9ceb381ee602efcbe002afc7be73
author Patrick McHardy <kaber@trash.net> Wed, 10 Jan 2007 10:40:07 +0100
committer Patrick McHardy <kaber@trash.net> Wed, 10 Jan 2007 10:40:07 +0100
tc/m_police.c | 2 +-
tc/q_htb.c | 4 ++--
tc/q_tbf.c | 4 ++--
tc/tc_core.c | 5 +++++
tc/tc_core.h | 1 +
5 files changed, 11 insertions(+), 5 deletions(-)
diff --git a/tc/m_police.c b/tc/m_police.c
index 93f317c..36a7719 100644
--- a/tc/m_police.c
+++ b/tc/m_police.c
@@ -331,7 +331,7 @@ #endif
fprintf(f, " police 0x%x ", p->index);
fprintf(f, "rate %s ", sprint_rate(p->rate.rate, b1));
- buffer = ((double)p->rate.rate*tc_core_tick2usec(p->burst))/1000000;
+ buffer = tc_calc_xmitsize(p->rate.rate, p->burst);
fprintf(f, "burst %s ", sprint_size(buffer, b1));
fprintf(f, "mtu %s ", sprint_size(p->mtu, b1));
if (show_raw)
diff --git a/tc/q_htb.c b/tc/q_htb.c
index d5f85c3..53e3f78 100644
--- a/tc/q_htb.c
+++ b/tc/q_htb.c
@@ -259,9 +259,9 @@ static int htb_print_opt(struct qdisc_ut
fprintf(f, "quantum %d ", (int)hopt->quantum);
}
fprintf(f, "rate %s ", sprint_rate(hopt->rate.rate, b1));
- buffer = ((double)hopt->rate.rate*tc_core_tick2usec(hopt->buffer))/1000000;
+ buffer = tc_calc_xmitsize(hopt->rate.rate, hopt->buffer);
fprintf(f, "ceil %s ", sprint_rate(hopt->ceil.rate, b1));
- cbuffer = ((double)hopt->ceil.rate*tc_core_tick2usec(hopt->cbuffer))/1000000;
+ cbuffer = tc_calc_xmitsize(hopt->ceil.rate, hopt->cbuffer);
if (show_details) {
fprintf(f, "burst %s/%u mpu %s overhead %s ",
sprint_size(buffer, b1),
diff --git a/tc/q_tbf.c b/tc/q_tbf.c
index b8251cb..45c21a7 100644
--- a/tc/q_tbf.c
+++ b/tc/q_tbf.c
@@ -218,7 +218,7 @@ static int tbf_print_opt(struct qdisc_ut
if (RTA_PAYLOAD(tb[TCA_TBF_PARMS]) < sizeof(*qopt))
return -1;
fprintf(f, "rate %s ", sprint_rate(qopt->rate.rate, b1));
- buffer = ((double)qopt->rate.rate*tc_core_tick2usec(qopt->buffer))/1000000;
+ buffer = tc_calc_xmitsize(qopt->rate.rate, qopt->buffer);
if (show_details) {
fprintf(f, "burst %s/%u mpu %s ", sprint_size(buffer, b1),
1<<qopt->rate.cell_log, sprint_size(qopt->rate.mpu, b2));
@@ -230,7 +230,7 @@ static int tbf_print_opt(struct qdisc_ut
if (qopt->peakrate.rate) {
fprintf(f, "peakrate %s ", sprint_rate(qopt->peakrate.rate, b1));
if (qopt->mtu || qopt->peakrate.mpu) {
- mtu = ((double)qopt->peakrate.rate*tc_core_tick2usec(qopt->mtu))/1000000;
+ mtu = tc_calc_xmitsize(qopt->peakrate.rate, qopt->mtu);
if (show_details) {
fprintf(f, "mtu %s/%u mpu %s ", sprint_size(mtu, b1),
1<<qopt->peakrate.cell_log, sprint_size(qopt->peakrate.mpu, b2));
diff --git a/tc/tc_core.c b/tc/tc_core.c
index 90a097d..1ca4583 100644
--- a/tc/tc_core.c
+++ b/tc/tc_core.c
@@ -51,6 +51,11 @@ unsigned tc_calc_xmittime(unsigned rate,
return tc_core_usec2tick(1000000*((double)size/rate));
}
+unsigned tc_calc_xmitsize(unsigned rate, unsigned ticks)
+{
+ return ((double)rate*tc_core_tick2usec(ticks))/1000000;
+}
+
/*
rtab[pkt_len>>cell_log] = pkt_xmit_time
*/
diff --git a/tc/tc_core.h b/tc/tc_core.h
index 65611b6..ff00f92 100644
--- a/tc/tc_core.h
+++ b/tc/tc_core.h
@@ -8,6 +8,7 @@ int tc_core_usec2big(long usec);
long tc_core_usec2tick(long usec);
long tc_core_tick2usec(long tick);
unsigned tc_calc_xmittime(unsigned rate, unsigned size);
+unsigned tc_calc_xmitsize(unsigned rate, unsigned ticks);
int tc_calc_rtable(unsigned bps, __u32 *rtab, int cell_log, unsigned mtu, unsigned mpu);
int tc_setup_estimator(unsigned A, unsigned time_const, struct tc_estimator *est);
^ permalink raw reply related [flat|nested] 16+ messages in thread* Re: [IPROUTE 02/05]: Introduce tc_calc_xmitsize and use where appropriate
2007-01-10 10:01 ` [IPROUTE 02/05]: Introduce tc_calc_xmitsize and use " Patrick McHardy
@ 2007-01-15 12:35 ` Jarek Poplawski
2007-01-15 15:07 ` Patrick McHardy
0 siblings, 1 reply; 16+ messages in thread
From: Jarek Poplawski @ 2007-01-15 12:35 UTC (permalink / raw)
To: Patrick McHardy; +Cc: netdev, Stephen Hemminger
On 10-01-2007 11:01, Patrick McHardy wrote:
> [IPROUTE]: Introduce tc_calc_xmitsize and use where appropriate
>
> Add tc_calc_xmitsize() as complement to tc_calc_xmittime(), which calculates
> the size that can be transmitted at a given rate during a given time.
>
> Replace all expressions of the form "size = rate*tc_core_tick2usec(time))/1000000"
> by tc_calc_xmitsize() calls.
>
> Signed-off-by: Patrick McHardy <kaber@trash.net>
>
> ---
...
> +unsigned tc_calc_xmitsize(unsigned rate, unsigned ticks)
> +{
> + return ((double)rate*tc_core_tick2usec(ticks))/1000000;
> +}
> +
Actually, besides of replacing the expression, this function
changes its type to unsigned also.
Regards,
Jarek P.
^ permalink raw reply [flat|nested] 16+ messages in thread* Re: [IPROUTE 02/05]: Introduce tc_calc_xmitsize and use where appropriate
2007-01-15 12:35 ` Jarek Poplawski
@ 2007-01-15 15:07 ` Patrick McHardy
0 siblings, 0 replies; 16+ messages in thread
From: Patrick McHardy @ 2007-01-15 15:07 UTC (permalink / raw)
To: Jarek Poplawski; +Cc: netdev, Stephen Hemminger
Jarek Poplawski wrote:
> On 10-01-2007 11:01, Patrick McHardy wrote:
>
>>[IPROUTE]: Introduce tc_calc_xmitsize and use where appropriate
>>
>>Add tc_calc_xmitsize() as complement to tc_calc_xmittime(), which calculates
>>the size that can be transmitted at a given rate during a given time.
>>
>>Replace all expressions of the form "size = rate*tc_core_tick2usec(time))/1000000"
>>by tc_calc_xmitsize() calls.
>>
>>Signed-off-by: Patrick McHardy <kaber@trash.net>
>>
>>---
>
> ...
>
>>+unsigned tc_calc_xmitsize(unsigned rate, unsigned ticks)
>>+{
>>+ return ((double)rate*tc_core_tick2usec(ticks))/1000000;
>>+}
>>+
>
>
> Actually, besides of replacing the expression, this function
> changes its type to unsigned also.
It doesn't change it, all expressions I replaced were directly
assigned to an unsigned int variable.
^ permalink raw reply [flat|nested] 16+ messages in thread
* [IPROUTE 03/05]: Introduce TIME_UNITS_PER_SEC to represent internal clock resolution
2007-01-10 10:01 [IPROUTE 00/05]: Time cleanups Patrick McHardy
2007-01-10 10:01 ` [IPROUTE 01/05]: Use tc_calc_xmittime where appropriate Patrick McHardy
2007-01-10 10:01 ` [IPROUTE 02/05]: Introduce tc_calc_xmitsize and use " Patrick McHardy
@ 2007-01-10 10:01 ` Patrick McHardy
2007-01-10 10:01 ` [IPROUTE 04/05]: Replace "usec" by "time" in function names Patrick McHardy
2007-01-10 10:01 ` [IPROUTE 05/05]: Add sprint_ticks() function and use in CBQ Patrick McHardy
4 siblings, 0 replies; 16+ messages in thread
From: Patrick McHardy @ 2007-01-10 10:01 UTC (permalink / raw)
To: shemminger; +Cc: netdev, Patrick McHardy
[IPROUTE]: Introduce TIME_UNITS_PER_SEC to represent internal clock resolution
Introduce TIME_UNITS_PER_SEC and conversion functions between internal
resolution and resolution expected by the kernel (currently implemented as
NOPs, only needed by HFSC, which currently always uses microseconds).
Signed-off-by: Patrick McHardy <kaber@trash.net>
---
commit df1c304ddaedfd5bfa6ca39cc66560c1618e2928
tree 3f915c2e1cd453f7ef0a2bf69cdf3425243dcd23
parent f5eaed98ecc93f088bed8d3f6d9f6b74ca32ddde
author Patrick McHardy <kaber@trash.net> Wed, 10 Jan 2007 10:42:26 +0100
committer Patrick McHardy <kaber@trash.net> Wed, 10 Jan 2007 10:42:26 +0100
tc/q_hfsc.c | 12 ++++++------
tc/q_tbf.c | 8 ++++----
tc/tc_cbq.c | 4 ++--
tc/tc_core.c | 14 ++++++++++++--
tc/tc_core.h | 4 ++++
tc/tc_estimator.c | 2 +-
tc/tc_util.c | 14 +++++++-------
7 files changed, 36 insertions(+), 22 deletions(-)
diff --git a/tc/q_hfsc.c b/tc/q_hfsc.c
index 4e8c09b..f7a30f2 100644
--- a/tc/q_hfsc.c
+++ b/tc/q_hfsc.c
@@ -226,7 +226,7 @@ hfsc_print_sc(FILE *f, char *name, struc
fprintf(f, "%s ", name);
fprintf(f, "m1 %s ", sprint_rate(sc->m1, b1));
- fprintf(f, "d %s ", sprint_usecs(sc->d, b1));
+ fprintf(f, "d %s ", sprint_usecs(tc_core_ktime2time(sc->d), b1));
fprintf(f, "m2 %s ", sprint_rate(sc->m2, b1));
}
@@ -320,7 +320,7 @@ hfsc_get_sc1(int *argcp, char ***argvp,
return -1;
sc->m1 = m1;
- sc->d = d;
+ sc->d = tc_core_time2ktime(d);
sc->m2 = m2;
*argvp = argv;
@@ -367,13 +367,13 @@ hfsc_get_sc2(int *argcp, char ***argvp,
return -1;
}
- if (dmax != 0 && ceil(umax * 1000000.0 / dmax) > rate) {
+ if (dmax != 0 && ceil(1.0 * umax * TIME_UNITS_PER_SEC / dmax) > rate) {
/*
* concave curve, slope of first segment is umax/dmax,
* intersection is at dmax
*/
- sc->m1 = ceil(umax * 1000000.0 / dmax); /* in bps */
- sc->d = dmax;
+ sc->m1 = ceil(1.0 * umax * TIME_UNITS_PER_SEC / dmax); /* in bps */
+ sc->d = tc_core_time2ktime(dmax);
sc->m2 = rate;
} else {
/*
@@ -381,7 +381,7 @@ hfsc_get_sc2(int *argcp, char ***argvp,
* is at dmax - umax / rate
*/
sc->m1 = 0;
- sc->d = ceil(dmax - umax * 1000000.0 / rate); /* in usec */
+ sc->d = tc_core_time2ktime(ceil(dmax - umax * TIME_UNITS_PER_SEC / rate));
sc->m2 = rate;
}
diff --git a/tc/q_tbf.c b/tc/q_tbf.c
index 45c21a7..5ba3631 100644
--- a/tc/q_tbf.c
+++ b/tc/q_tbf.c
@@ -161,9 +161,9 @@ static int tbf_parse_opt(struct qdisc_ut
}
if (opt.limit == 0) {
- double lim = opt.rate.rate*(double)latency/1000000 + buffer;
+ double lim = opt.rate.rate*(double)latency/TIME_UNITS_PER_SEC + buffer;
if (opt.peakrate.rate) {
- double lim2 = opt.peakrate.rate*(double)latency/1000000 + mtu;
+ double lim2 = opt.peakrate.rate*(double)latency/TIME_UNITS_PER_SEC + mtu;
if (lim2 < lim)
lim = lim2;
}
@@ -245,9 +245,9 @@ static int tbf_print_opt(struct qdisc_ut
if (show_raw)
fprintf(f, "limit %s ", sprint_size(qopt->limit, b1));
- latency = 1000000*(qopt->limit/(double)qopt->rate.rate) - tc_core_tick2usec(qopt->buffer);
+ latency = TIME_UNITS_PER_SEC*(qopt->limit/(double)qopt->rate.rate) - tc_core_tick2usec(qopt->buffer);
if (qopt->peakrate.rate) {
- double lat2 = 1000000*(qopt->limit/(double)qopt->peakrate.rate) - tc_core_tick2usec(qopt->mtu);
+ double lat2 = TIME_UNITS_PER_SEC*(qopt->limit/(double)qopt->peakrate.rate) - tc_core_tick2usec(qopt->mtu);
if (lat2 > latency)
latency = lat2;
}
diff --git a/tc/tc_cbq.c b/tc/tc_cbq.c
index 0abcc9d..c7b3a2d 100644
--- a/tc/tc_cbq.c
+++ b/tc/tc_cbq.c
@@ -38,7 +38,7 @@ unsigned tc_cbq_calc_maxidle(unsigned bn
if (vxmt > maxidle)
maxidle = vxmt;
}
- return tc_core_usec2tick(maxidle*(1<<ewma_log)*1000000);
+ return tc_core_usec2tick(maxidle*(1<<ewma_log)*TIME_UNITS_PER_SEC);
}
unsigned tc_cbq_calc_offtime(unsigned bndw, unsigned rate, unsigned avpkt,
@@ -53,5 +53,5 @@ unsigned tc_cbq_calc_offtime(unsigned bn
offtime *= pow(g, -(double)minburst) - 1;
else
offtime *= 1 + (pow(g, -(double)(minburst-1)) - 1)/(1-g);
- return tc_core_usec2tick(offtime*1000000);
+ return tc_core_usec2tick(offtime*TIME_UNITS_PER_SEC);
}
diff --git a/tc/tc_core.c b/tc/tc_core.c
index 1ca4583..07dc4ba 100644
--- a/tc/tc_core.c
+++ b/tc/tc_core.c
@@ -46,14 +46,24 @@ long tc_core_tick2usec(long tick)
return tick/tick_in_usec;
}
+long tc_core_time2ktime(long time)
+{
+ return time;
+}
+
+long tc_core_ktime2time(long ktime)
+{
+ return ktime;
+}
+
unsigned tc_calc_xmittime(unsigned rate, unsigned size)
{
- return tc_core_usec2tick(1000000*((double)size/rate));
+ return tc_core_usec2tick(TIME_UNITS_PER_SEC*((double)size/rate));
}
unsigned tc_calc_xmitsize(unsigned rate, unsigned ticks)
{
- return ((double)rate*tc_core_tick2usec(ticks))/1000000;
+ return ((double)rate*tc_core_tick2usec(ticks))/TIME_UNITS_PER_SEC;
}
/*
diff --git a/tc/tc_core.h b/tc/tc_core.h
index ff00f92..b31813d 100644
--- a/tc/tc_core.h
+++ b/tc/tc_core.h
@@ -4,9 +4,13 @@ #define _TC_CORE_H_ 1
#include <asm/types.h>
#include <linux/pkt_sched.h>
+#define TIME_UNITS_PER_SEC 1000000
+
int tc_core_usec2big(long usec);
long tc_core_usec2tick(long usec);
long tc_core_tick2usec(long tick);
+long tc_core_time2ktime(long time);
+long tc_core_ktime2time(long ktime);
unsigned tc_calc_xmittime(unsigned rate, unsigned size);
unsigned tc_calc_xmitsize(unsigned rate, unsigned ticks);
int tc_calc_rtable(unsigned bps, __u32 *rtab, int cell_log, unsigned mtu, unsigned mpu);
diff --git a/tc/tc_estimator.c b/tc/tc_estimator.c
index 434db0f..e559add 100644
--- a/tc/tc_estimator.c
+++ b/tc/tc_estimator.c
@@ -26,7 +26,7 @@ #include "tc_core.h"
int tc_setup_estimator(unsigned A, unsigned time_const, struct tc_estimator *est)
{
for (est->interval=0; est->interval<=5; est->interval++) {
- if (A <= (1<<est->interval)*(1000000/4))
+ if (A <= (1<<est->interval)*(TIME_UNITS_PER_SEC/4))
break;
}
if (est->interval > 5)
diff --git a/tc/tc_util.c b/tc/tc_util.c
index 8cdb9a1..62113fc 100644
--- a/tc/tc_util.c
+++ b/tc/tc_util.c
@@ -221,13 +221,13 @@ int get_usecs(unsigned *usecs, const cha
if (*p) {
if (strcasecmp(p, "s") == 0 || strcasecmp(p, "sec")==0 ||
strcasecmp(p, "secs")==0)
- t *= 1000000;
+ t *= TIME_UNITS_PER_SEC;
else if (strcasecmp(p, "ms") == 0 || strcasecmp(p, "msec")==0 ||
strcasecmp(p, "msecs") == 0)
- t *= 1000;
+ t *= TIME_UNITS_PER_SEC/1000;
else if (strcasecmp(p, "us") == 0 || strcasecmp(p, "usec")==0 ||
strcasecmp(p, "usecs") == 0)
- t *= 1;
+ t *= TIME_UNITS_PER_SEC/1000000;
else
return -1;
}
@@ -241,10 +241,10 @@ void print_usecs(char *buf, int len, __u
{
double tmp = usec;
- if (tmp >= 1000000)
- snprintf(buf, len, "%.1fs", tmp/1000000);
- else if (tmp >= 1000)
- snprintf(buf, len, "%.1fms", tmp/1000);
+ if (tmp >= TIME_UNITS_PER_SEC)
+ snprintf(buf, len, "%.1fs", tmp/TIME_UNITS_PER_SEC);
+ else if (tmp >= TIME_UNITS_PER_SEC/1000)
+ snprintf(buf, len, "%.1fms", tmp/(TIME_UNITS_PER_SEC/1000));
else
snprintf(buf, len, "%uus", usec);
}
^ permalink raw reply related [flat|nested] 16+ messages in thread* [IPROUTE 04/05]: Replace "usec" by "time" in function names
2007-01-10 10:01 [IPROUTE 00/05]: Time cleanups Patrick McHardy
` (2 preceding siblings ...)
2007-01-10 10:01 ` [IPROUTE 03/05]: Introduce TIME_UNITS_PER_SEC to represent internal clock resolution Patrick McHardy
@ 2007-01-10 10:01 ` Patrick McHardy
2007-01-15 10:17 ` Jarek Poplawski
2007-01-10 10:01 ` [IPROUTE 05/05]: Add sprint_ticks() function and use in CBQ Patrick McHardy
4 siblings, 1 reply; 16+ messages in thread
From: Patrick McHardy @ 2007-01-10 10:01 UTC (permalink / raw)
To: shemminger; +Cc: netdev, Patrick McHardy
[IPROUTE]: Replace "usec" by "time" in function names
Rename functions containing "usec" since they don't necessarily return
usec units anymore.
Signed-off-by: Patrick McHardy <kaber@trash.net>
---
commit d1980613b2921fcc288858f4c63727f28ca49607
tree b67f63e36a80cad46173635c5c7ba65305fa8aed
parent df1c304ddaedfd5bfa6ca39cc66560c1618e2928
author Patrick McHardy <kaber@trash.net> Wed, 10 Jan 2007 10:43:00 +0100
committer Patrick McHardy <kaber@trash.net> Wed, 10 Jan 2007 10:43:00 +0100
tc/m_estimator.c | 4 ++--
tc/q_cbq.c | 6 +++---
tc/q_hfsc.c | 6 +++---
tc/q_netem.c | 6 +++---
tc/q_tbf.c | 8 ++++----
tc/tc_cbq.c | 4 ++--
tc/tc_core.c | 14 +++++++-------
tc/tc_core.h | 6 +++---
tc/tc_util.c | 14 +++++++-------
tc/tc_util.h | 6 +++---
10 files changed, 37 insertions(+), 37 deletions(-)
diff --git a/tc/m_estimator.c b/tc/m_estimator.c
index d931551..a9e5dbc 100644
--- a/tc/m_estimator.c
+++ b/tc/m_estimator.c
@@ -45,12 +45,12 @@ int parse_estimator(int *p_argc, char **
duparg("estimator", *argv);
if (matches(*argv, "help") == 0)
est_help();
- if (get_usecs(&A, *argv))
+ if (get_time(&A, *argv))
invarg("estimator", "invalid estimator interval");
NEXT_ARG();
if (matches(*argv, "help") == 0)
est_help();
- if (get_usecs(&time_const, *argv))
+ if (get_time(&time_const, *argv))
invarg("estimator", "invalid estimator time constant");
if (tc_setup_estimator(A, time_const, est) < 0) {
fprintf(stderr, "Error: estimator parameters are out of range.\n");
diff --git a/tc/q_cbq.c b/tc/q_cbq.c
index 0000a56..913b26a 100644
--- a/tc/q_cbq.c
+++ b/tc/q_cbq.c
@@ -500,17 +500,17 @@ static int cbq_print_opt(struct qdisc_ut
if (lss && show_details) {
fprintf(f, "\nlevel %u ewma %u avpkt %ub ", lss->level, lss->ewma_log, lss->avpkt);
if (lss->maxidle) {
- fprintf(f, "maxidle %luus ", tc_core_tick2usec(lss->maxidle>>lss->ewma_log));
+ fprintf(f, "maxidle %luus ", tc_core_tick2time(lss->maxidle>>lss->ewma_log));
if (show_raw)
fprintf(f, "[%08x] ", lss->maxidle);
}
if (lss->minidle!=0x7fffffff) {
- fprintf(f, "minidle %luus ", tc_core_tick2usec(lss->minidle>>lss->ewma_log));
+ fprintf(f, "minidle %luus ", tc_core_tick2time(lss->minidle>>lss->ewma_log));
if (show_raw)
fprintf(f, "[%08x] ", lss->minidle);
}
if (lss->offtime) {
- fprintf(f, "offtime %luus ", tc_core_tick2usec(lss->offtime));
+ fprintf(f, "offtime %luus ", tc_core_tick2time(lss->offtime));
if (show_raw)
fprintf(f, "[%08x] ", lss->offtime);
}
diff --git a/tc/q_hfsc.c b/tc/q_hfsc.c
index f7a30f2..b190c71 100644
--- a/tc/q_hfsc.c
+++ b/tc/q_hfsc.c
@@ -226,7 +226,7 @@ hfsc_print_sc(FILE *f, char *name, struc
fprintf(f, "%s ", name);
fprintf(f, "m1 %s ", sprint_rate(sc->m1, b1));
- fprintf(f, "d %s ", sprint_usecs(tc_core_ktime2time(sc->d), b1));
+ fprintf(f, "d %s ", sprint_time(tc_core_ktime2time(sc->d), b1));
fprintf(f, "m2 %s ", sprint_rate(sc->m2, b1));
}
@@ -303,7 +303,7 @@ hfsc_get_sc1(int *argcp, char ***argvp,
if (matches(*argv, "d") == 0) {
NEXT_ARG();
- if (get_usecs(&d, *argv) < 0) {
+ if (get_time(&d, *argv) < 0) {
explain1("d");
return -1;
}
@@ -346,7 +346,7 @@ hfsc_get_sc2(int *argcp, char ***argvp,
if (matches(*argv, "dmax") == 0) {
NEXT_ARG();
- if (get_usecs(&dmax, *argv) < 0) {
+ if (get_time(&dmax, *argv) < 0) {
explain1("dmax");
return -1;
}
diff --git a/tc/q_netem.c b/tc/q_netem.c
index cfd1799..24fb95e 100644
--- a/tc/q_netem.c
+++ b/tc/q_netem.c
@@ -108,15 +108,15 @@ static int get_ticks(__u32 *ticks, const
{
unsigned t;
- if(get_usecs(&t, str))
+ if(get_time(&t, str))
return -1;
- if (tc_core_usec2big(t)) {
+ if (tc_core_time2big(t)) {
fprintf(stderr, "Illegal %d usecs (too large)\n", t);
return -1;
}
- *ticks = tc_core_usec2tick(t);
+ *ticks = tc_core_time2tick(t);
return 0;
}
diff --git a/tc/q_tbf.c b/tc/q_tbf.c
index 5ba3631..566afa0 100644
--- a/tc/q_tbf.c
+++ b/tc/q_tbf.c
@@ -67,7 +67,7 @@ static int tbf_parse_opt(struct qdisc_ut
fprintf(stderr, "Double \"limit/latency\" spec\n");
return -1;
}
- if (get_usecs(&latency, *argv)) {
+ if (get_time(&latency, *argv)) {
explain1("latency");
return -1;
}
@@ -245,13 +245,13 @@ static int tbf_print_opt(struct qdisc_ut
if (show_raw)
fprintf(f, "limit %s ", sprint_size(qopt->limit, b1));
- latency = TIME_UNITS_PER_SEC*(qopt->limit/(double)qopt->rate.rate) - tc_core_tick2usec(qopt->buffer);
+ latency = TIME_UNITS_PER_SEC*(qopt->limit/(double)qopt->rate.rate) - tc_core_tick2time(qopt->buffer);
if (qopt->peakrate.rate) {
- double lat2 = TIME_UNITS_PER_SEC*(qopt->limit/(double)qopt->peakrate.rate) - tc_core_tick2usec(qopt->mtu);
+ double lat2 = TIME_UNITS_PER_SEC*(qopt->limit/(double)qopt->peakrate.rate) - tc_core_tick2time(qopt->mtu);
if (lat2 > latency)
latency = lat2;
}
- fprintf(f, "lat %s ", sprint_usecs(tc_core_tick2usec(latency), b1));
+ fprintf(f, "lat %s ", sprint_time(tc_core_tick2time(latency), b1));
return 0;
}
diff --git a/tc/tc_cbq.c b/tc/tc_cbq.c
index c7b3a2d..0bb262e 100644
--- a/tc/tc_cbq.c
+++ b/tc/tc_cbq.c
@@ -38,7 +38,7 @@ unsigned tc_cbq_calc_maxidle(unsigned bn
if (vxmt > maxidle)
maxidle = vxmt;
}
- return tc_core_usec2tick(maxidle*(1<<ewma_log)*TIME_UNITS_PER_SEC);
+ return tc_core_time2tick(maxidle*(1<<ewma_log)*TIME_UNITS_PER_SEC);
}
unsigned tc_cbq_calc_offtime(unsigned bndw, unsigned rate, unsigned avpkt,
@@ -53,5 +53,5 @@ unsigned tc_cbq_calc_offtime(unsigned bn
offtime *= pow(g, -(double)minburst) - 1;
else
offtime *= 1 + (pow(g, -(double)(minburst-1)) - 1)/(1-g);
- return tc_core_usec2tick(offtime*TIME_UNITS_PER_SEC);
+ return tc_core_time2tick(offtime*TIME_UNITS_PER_SEC);
}
diff --git a/tc/tc_core.c b/tc/tc_core.c
index 07dc4ba..e27254e 100644
--- a/tc/tc_core.c
+++ b/tc/tc_core.c
@@ -27,21 +27,21 @@ static __u32 t2us=1;
static __u32 us2t=1;
static double tick_in_usec = 1;
-int tc_core_usec2big(long usec)
+int tc_core_time2big(long time)
{
- __u64 t = usec;
+ __u64 t = time;
t *= tick_in_usec;
return (t >> 32) != 0;
}
-long tc_core_usec2tick(long usec)
+long tc_core_time2tick(long time)
{
- return usec*tick_in_usec;
+ return time*tick_in_usec;
}
-long tc_core_tick2usec(long tick)
+long tc_core_tick2time(long tick)
{
return tick/tick_in_usec;
}
@@ -58,12 +58,12 @@ long tc_core_ktime2time(long ktime)
unsigned tc_calc_xmittime(unsigned rate, unsigned size)
{
- return tc_core_usec2tick(TIME_UNITS_PER_SEC*((double)size/rate));
+ return tc_core_time2tick(TIME_UNITS_PER_SEC*((double)size/rate));
}
unsigned tc_calc_xmitsize(unsigned rate, unsigned ticks)
{
- return ((double)rate*tc_core_tick2usec(ticks))/TIME_UNITS_PER_SEC;
+ return ((double)rate*tc_core_tick2time(ticks))/TIME_UNITS_PER_SEC;
}
/*
diff --git a/tc/tc_core.h b/tc/tc_core.h
index b31813d..a139da6 100644
--- a/tc/tc_core.h
+++ b/tc/tc_core.h
@@ -6,9 +6,9 @@ #include <linux/pkt_sched.h>
#define TIME_UNITS_PER_SEC 1000000
-int tc_core_usec2big(long usec);
-long tc_core_usec2tick(long usec);
-long tc_core_tick2usec(long tick);
+int tc_core_time2big(long time);
+long tc_core_time2tick(long time);
+long tc_core_tick2time(long tick);
long tc_core_time2ktime(long time);
long tc_core_ktime2time(long ktime);
unsigned tc_calc_xmittime(unsigned rate, unsigned size);
diff --git a/tc/tc_util.c b/tc/tc_util.c
index 62113fc..b73fae9 100644
--- a/tc/tc_util.c
+++ b/tc/tc_util.c
@@ -209,7 +209,7 @@ char * sprint_rate(__u32 rate, char *buf
return buf;
}
-int get_usecs(unsigned *usecs, const char *str)
+int get_time(unsigned *time, const char *str)
{
double t;
char *p;
@@ -232,26 +232,26 @@ int get_usecs(unsigned *usecs, const cha
return -1;
}
- *usecs = t;
+ *time = t;
return 0;
}
-void print_usecs(char *buf, int len, __u32 usec)
+void print_time(char *buf, int len, __u32 time)
{
- double tmp = usec;
+ double tmp = time;
if (tmp >= TIME_UNITS_PER_SEC)
snprintf(buf, len, "%.1fs", tmp/TIME_UNITS_PER_SEC);
else if (tmp >= TIME_UNITS_PER_SEC/1000)
snprintf(buf, len, "%.1fms", tmp/(TIME_UNITS_PER_SEC/1000));
else
- snprintf(buf, len, "%uus", usec);
+ snprintf(buf, len, "%uus", time);
}
-char * sprint_usecs(__u32 usecs, char *buf)
+char * sprint_time(__u32 time, char *buf)
{
- print_usecs(buf, SPRINT_BSIZE-1, usecs);
+ print_time(buf, SPRINT_BSIZE-1, time);
return buf;
}
diff --git a/tc/tc_util.h b/tc/tc_util.h
index 0778693..b713cf1 100644
--- a/tc/tc_util.h
+++ b/tc/tc_util.h
@@ -46,17 +46,17 @@ extern int get_rate(unsigned *rate, cons
extern int get_percent(unsigned *percent, const char *str);
extern int get_size(unsigned *size, const char *str);
extern int get_size_and_cell(unsigned *size, int *cell_log, char *str);
-extern int get_usecs(unsigned *usecs, const char *str);
+extern int get_time(unsigned *time, const char *str);
extern void print_rate(char *buf, int len, __u32 rate);
extern void print_size(char *buf, int len, __u32 size);
extern void print_percent(char *buf, int len, __u32 percent);
extern void print_qdisc_handle(char *buf, int len, __u32 h);
-extern void print_usecs(char *buf, int len, __u32 usecs);
+extern void print_time(char *buf, int len, __u32 time);
extern char * sprint_rate(__u32 rate, char *buf);
extern char * sprint_size(__u32 size, char *buf);
extern char * sprint_qdisc_handle(__u32 h, char *buf);
extern char * sprint_tc_classid(__u32 h, char *buf);
-extern char * sprint_usecs(__u32 usecs, char *buf);
+extern char * sprint_time(__u32 time, char *buf);
extern char * sprint_percent(__u32 percent, char *buf);
extern void print_tcstats_attr(FILE *fp, struct rtattr *tb[], char *prefix, struct rtattr **xstats);
^ permalink raw reply related [flat|nested] 16+ messages in thread* Re: [IPROUTE 04/05]: Replace "usec" by "time" in function names
2007-01-10 10:01 ` [IPROUTE 04/05]: Replace "usec" by "time" in function names Patrick McHardy
@ 2007-01-15 10:17 ` Jarek Poplawski
2007-01-16 13:42 ` Patrick McHardy
0 siblings, 1 reply; 16+ messages in thread
From: Jarek Poplawski @ 2007-01-15 10:17 UTC (permalink / raw)
To: Patrick McHardy; +Cc: netdev
On 10-01-2007 11:01, Patrick McHardy wrote:
> [IPROUTE]: Replace "usec" by "time" in function names
>
> Rename functions containing "usec" since they don't necessarily return
> usec units anymore.
>
> Signed-off-by: Patrick McHardy <kaber@trash.net>
>
> ---
...
> diff --git a/tc/q_cbq.c b/tc/q_cbq.c
> index 0000a56..913b26a 100644
> --- a/tc/q_cbq.c
> +++ b/tc/q_cbq.c
> @@ -500,17 +500,17 @@ static int cbq_print_opt(struct qdisc_ut
> if (lss && show_details) {
> fprintf(f, "\nlevel %u ewma %u avpkt %ub ", lss->level, lss->ewma_log, lss->avpkt);
> if (lss->maxidle) {
> - fprintf(f, "maxidle %luus ", tc_core_tick2usec(lss->maxidle>>lss->ewma_log));
> + fprintf(f, "maxidle %luus ", tc_core_tick2time(lss->maxidle>>lss->ewma_log));
If not necessarily usec, "%luus" could be misleading
here and later.
...
> diff --git a/tc/q_netem.c b/tc/q_netem.c
> index cfd1799..24fb95e 100644
> --- a/tc/q_netem.c
> +++ b/tc/q_netem.c
> @@ -108,15 +108,15 @@ static int get_ticks(__u32 *ticks, const
> {
> unsigned t;
>
> - if(get_usecs(&t, str))
> + if(get_time(&t, str))
> return -1;
>
> - if (tc_core_usec2big(t)) {
> + if (tc_core_time2big(t)) {
> fprintf(stderr, "Illegal %d usecs (too large)\n", t);
Like above but usecs.
...
> diff --git a/tc/tc_core.c b/tc/tc_core.c
> index 07dc4ba..e27254e 100644
> --- a/tc/tc_core.c
> +++ b/tc/tc_core.c
> @@ -27,21 +27,21 @@ static __u32 t2us=1;
> static __u32 us2t=1;
> static double tick_in_usec = 1;
>
> -int tc_core_usec2big(long usec)
> +int tc_core_time2big(long time)
> {
> - __u64 t = usec;
> + __u64 t = time;
>
> t *= tick_in_usec;
> return (t >> 32) != 0;
> }
>
>
> -long tc_core_usec2tick(long usec)
> +long tc_core_time2tick(long time)
> {
> - return usec*tick_in_usec;
> + return time*tick_in_usec;
> }
>
> -long tc_core_tick2usec(long tick)
> +long tc_core_tick2time(long tick)
> {
> return tick/tick_in_usec;
> }
Similarly (tick_in_time)?
Regards,
Jarek P.
^ permalink raw reply [flat|nested] 16+ messages in thread* Re: [IPROUTE 04/05]: Replace "usec" by "time" in function names
2007-01-15 10:17 ` Jarek Poplawski
@ 2007-01-16 13:42 ` Patrick McHardy
0 siblings, 0 replies; 16+ messages in thread
From: Patrick McHardy @ 2007-01-16 13:42 UTC (permalink / raw)
To: Jarek Poplawski; +Cc: netdev
[-- Attachment #1: Type: text/plain, Size: 2045 bytes --]
Jarek Poplawski wrote:
> On 10-01-2007 11:01, Patrick McHardy wrote:
>
>>[IPROUTE]: Replace "usec" by "time" in function names
>>
>>Rename functions containing "usec" since they don't necessarily return
>>usec units anymore.
>>
>>diff --git a/tc/q_cbq.c b/tc/q_cbq.c
>>index 0000a56..913b26a 100644
>>--- a/tc/q_cbq.c
>>+++ b/tc/q_cbq.c
>>@@ -500,17 +500,17 @@ static int cbq_print_opt(struct qdisc_ut
>> if (lss && show_details) {
>> fprintf(f, "\nlevel %u ewma %u avpkt %ub ", lss->level, lss->ewma_log, lss->avpkt);
>> if (lss->maxidle) {
>>- fprintf(f, "maxidle %luus ", tc_core_tick2usec(lss->maxidle>>lss->ewma_log));
>>+ fprintf(f, "maxidle %luus ", tc_core_tick2time(lss->maxidle>>lss->ewma_log));
>
>
> If not necessarily usec, "%luus" could be misleading
> here and later.
The next patch replaces it by sprint_time.
>>diff --git a/tc/q_netem.c b/tc/q_netem.c
>>index cfd1799..24fb95e 100644
>>--- a/tc/q_netem.c
>>+++ b/tc/q_netem.c
>>@@ -108,15 +108,15 @@ static int get_ticks(__u32 *ticks, const
>> {
>> unsigned t;
>>
>>- if(get_usecs(&t, str))
>>+ if(get_time(&t, str))
>> return -1;
>>
>>- if (tc_core_usec2big(t)) {
>>+ if (tc_core_time2big(t)) {
>> fprintf(stderr, "Illegal %d usecs (too large)\n", t);
>
>
> Like above but usecs.
Fixed, thanks.
>>diff --git a/tc/tc_core.c b/tc/tc_core.c
>>index 07dc4ba..e27254e 100644
>>--- a/tc/tc_core.c
>>+++ b/tc/tc_core.c
>>@@ -27,21 +27,21 @@ static __u32 t2us=1;
>> static __u32 us2t=1;
>> static double tick_in_usec = 1;
>>
>>-int tc_core_usec2big(long usec)
>>+int tc_core_time2big(long time)
>> {
>>- __u64 t = usec;
>>+ __u64 t = time;
>>
>> t *= tick_in_usec;
>> return (t >> 32) != 0;
>> }
>>
>>
>>-long tc_core_usec2tick(long usec)
>>+long tc_core_time2tick(long time)
>> {
>>- return usec*tick_in_usec;
>>+ return time*tick_in_usec;
>> }
>>
>>-long tc_core_tick2usec(long tick)
>>+long tc_core_tick2time(long tick)
>> {
>> return tick/tick_in_usec;
>> }
>
>
> Similarly (tick_in_time)?
Something like that will be done in a followup patch.
[-- Attachment #2: 04.diff --]
[-- Type: text/x-diff, Size: 9872 bytes --]
[IPROUTE]: Replace "usec" by "time" in function names
Rename functions containing "usec" since they don't necessarily return
usec units anymore.
Signed-off-by: Patrick McHardy <kaber@trash.net>
---
commit 64f96b38ae91faad5baff052715114a0704a844e
tree b5c87b9834652fa695c9b6463b05ec17754b7003
parent df1c304ddaedfd5bfa6ca39cc66560c1618e2928
author Patrick McHardy <kaber@trash.net> Tue, 16 Jan 2007 14:40:30 +0100
committer Patrick McHardy <kaber@trash.net> Tue, 16 Jan 2007 14:40:30 +0100
tc/m_estimator.c | 4 ++--
tc/q_cbq.c | 6 +++---
tc/q_hfsc.c | 6 +++---
tc/q_netem.c | 8 ++++----
tc/q_tbf.c | 8 ++++----
tc/tc_cbq.c | 4 ++--
tc/tc_core.c | 14 +++++++-------
tc/tc_core.h | 6 +++---
tc/tc_util.c | 14 +++++++-------
tc/tc_util.h | 6 +++---
10 files changed, 38 insertions(+), 38 deletions(-)
diff --git a/tc/m_estimator.c b/tc/m_estimator.c
index d931551..a9e5dbc 100644
--- a/tc/m_estimator.c
+++ b/tc/m_estimator.c
@@ -45,12 +45,12 @@ int parse_estimator(int *p_argc, char **
duparg("estimator", *argv);
if (matches(*argv, "help") == 0)
est_help();
- if (get_usecs(&A, *argv))
+ if (get_time(&A, *argv))
invarg("estimator", "invalid estimator interval");
NEXT_ARG();
if (matches(*argv, "help") == 0)
est_help();
- if (get_usecs(&time_const, *argv))
+ if (get_time(&time_const, *argv))
invarg("estimator", "invalid estimator time constant");
if (tc_setup_estimator(A, time_const, est) < 0) {
fprintf(stderr, "Error: estimator parameters are out of range.\n");
diff --git a/tc/q_cbq.c b/tc/q_cbq.c
index 0000a56..913b26a 100644
--- a/tc/q_cbq.c
+++ b/tc/q_cbq.c
@@ -500,17 +500,17 @@ static int cbq_print_opt(struct qdisc_ut
if (lss && show_details) {
fprintf(f, "\nlevel %u ewma %u avpkt %ub ", lss->level, lss->ewma_log, lss->avpkt);
if (lss->maxidle) {
- fprintf(f, "maxidle %luus ", tc_core_tick2usec(lss->maxidle>>lss->ewma_log));
+ fprintf(f, "maxidle %luus ", tc_core_tick2time(lss->maxidle>>lss->ewma_log));
if (show_raw)
fprintf(f, "[%08x] ", lss->maxidle);
}
if (lss->minidle!=0x7fffffff) {
- fprintf(f, "minidle %luus ", tc_core_tick2usec(lss->minidle>>lss->ewma_log));
+ fprintf(f, "minidle %luus ", tc_core_tick2time(lss->minidle>>lss->ewma_log));
if (show_raw)
fprintf(f, "[%08x] ", lss->minidle);
}
if (lss->offtime) {
- fprintf(f, "offtime %luus ", tc_core_tick2usec(lss->offtime));
+ fprintf(f, "offtime %luus ", tc_core_tick2time(lss->offtime));
if (show_raw)
fprintf(f, "[%08x] ", lss->offtime);
}
diff --git a/tc/q_hfsc.c b/tc/q_hfsc.c
index f7a30f2..b190c71 100644
--- a/tc/q_hfsc.c
+++ b/tc/q_hfsc.c
@@ -226,7 +226,7 @@ hfsc_print_sc(FILE *f, char *name, struc
fprintf(f, "%s ", name);
fprintf(f, "m1 %s ", sprint_rate(sc->m1, b1));
- fprintf(f, "d %s ", sprint_usecs(tc_core_ktime2time(sc->d), b1));
+ fprintf(f, "d %s ", sprint_time(tc_core_ktime2time(sc->d), b1));
fprintf(f, "m2 %s ", sprint_rate(sc->m2, b1));
}
@@ -303,7 +303,7 @@ hfsc_get_sc1(int *argcp, char ***argvp,
if (matches(*argv, "d") == 0) {
NEXT_ARG();
- if (get_usecs(&d, *argv) < 0) {
+ if (get_time(&d, *argv) < 0) {
explain1("d");
return -1;
}
@@ -346,7 +346,7 @@ hfsc_get_sc2(int *argcp, char ***argvp,
if (matches(*argv, "dmax") == 0) {
NEXT_ARG();
- if (get_usecs(&dmax, *argv) < 0) {
+ if (get_time(&dmax, *argv) < 0) {
explain1("dmax");
return -1;
}
diff --git a/tc/q_netem.c b/tc/q_netem.c
index cfd1799..6035c4f 100644
--- a/tc/q_netem.c
+++ b/tc/q_netem.c
@@ -108,15 +108,15 @@ static int get_ticks(__u32 *ticks, const
{
unsigned t;
- if(get_usecs(&t, str))
+ if(get_time(&t, str))
return -1;
- if (tc_core_usec2big(t)) {
- fprintf(stderr, "Illegal %d usecs (too large)\n", t);
+ if (tc_core_time2big(t)) {
+ fprintf(stderr, "Illegal %u time (too large)\n", t);
return -1;
}
- *ticks = tc_core_usec2tick(t);
+ *ticks = tc_core_time2tick(t);
return 0;
}
diff --git a/tc/q_tbf.c b/tc/q_tbf.c
index 5ba3631..566afa0 100644
--- a/tc/q_tbf.c
+++ b/tc/q_tbf.c
@@ -67,7 +67,7 @@ static int tbf_parse_opt(struct qdisc_ut
fprintf(stderr, "Double \"limit/latency\" spec\n");
return -1;
}
- if (get_usecs(&latency, *argv)) {
+ if (get_time(&latency, *argv)) {
explain1("latency");
return -1;
}
@@ -245,13 +245,13 @@ static int tbf_print_opt(struct qdisc_ut
if (show_raw)
fprintf(f, "limit %s ", sprint_size(qopt->limit, b1));
- latency = TIME_UNITS_PER_SEC*(qopt->limit/(double)qopt->rate.rate) - tc_core_tick2usec(qopt->buffer);
+ latency = TIME_UNITS_PER_SEC*(qopt->limit/(double)qopt->rate.rate) - tc_core_tick2time(qopt->buffer);
if (qopt->peakrate.rate) {
- double lat2 = TIME_UNITS_PER_SEC*(qopt->limit/(double)qopt->peakrate.rate) - tc_core_tick2usec(qopt->mtu);
+ double lat2 = TIME_UNITS_PER_SEC*(qopt->limit/(double)qopt->peakrate.rate) - tc_core_tick2time(qopt->mtu);
if (lat2 > latency)
latency = lat2;
}
- fprintf(f, "lat %s ", sprint_usecs(tc_core_tick2usec(latency), b1));
+ fprintf(f, "lat %s ", sprint_time(tc_core_tick2time(latency), b1));
return 0;
}
diff --git a/tc/tc_cbq.c b/tc/tc_cbq.c
index c7b3a2d..0bb262e 100644
--- a/tc/tc_cbq.c
+++ b/tc/tc_cbq.c
@@ -38,7 +38,7 @@ unsigned tc_cbq_calc_maxidle(unsigned bn
if (vxmt > maxidle)
maxidle = vxmt;
}
- return tc_core_usec2tick(maxidle*(1<<ewma_log)*TIME_UNITS_PER_SEC);
+ return tc_core_time2tick(maxidle*(1<<ewma_log)*TIME_UNITS_PER_SEC);
}
unsigned tc_cbq_calc_offtime(unsigned bndw, unsigned rate, unsigned avpkt,
@@ -53,5 +53,5 @@ unsigned tc_cbq_calc_offtime(unsigned bn
offtime *= pow(g, -(double)minburst) - 1;
else
offtime *= 1 + (pow(g, -(double)(minburst-1)) - 1)/(1-g);
- return tc_core_usec2tick(offtime*TIME_UNITS_PER_SEC);
+ return tc_core_time2tick(offtime*TIME_UNITS_PER_SEC);
}
diff --git a/tc/tc_core.c b/tc/tc_core.c
index 07dc4ba..e27254e 100644
--- a/tc/tc_core.c
+++ b/tc/tc_core.c
@@ -27,21 +27,21 @@ static __u32 t2us=1;
static __u32 us2t=1;
static double tick_in_usec = 1;
-int tc_core_usec2big(long usec)
+int tc_core_time2big(long time)
{
- __u64 t = usec;
+ __u64 t = time;
t *= tick_in_usec;
return (t >> 32) != 0;
}
-long tc_core_usec2tick(long usec)
+long tc_core_time2tick(long time)
{
- return usec*tick_in_usec;
+ return time*tick_in_usec;
}
-long tc_core_tick2usec(long tick)
+long tc_core_tick2time(long tick)
{
return tick/tick_in_usec;
}
@@ -58,12 +58,12 @@ long tc_core_ktime2time(long ktime)
unsigned tc_calc_xmittime(unsigned rate, unsigned size)
{
- return tc_core_usec2tick(TIME_UNITS_PER_SEC*((double)size/rate));
+ return tc_core_time2tick(TIME_UNITS_PER_SEC*((double)size/rate));
}
unsigned tc_calc_xmitsize(unsigned rate, unsigned ticks)
{
- return ((double)rate*tc_core_tick2usec(ticks))/TIME_UNITS_PER_SEC;
+ return ((double)rate*tc_core_tick2time(ticks))/TIME_UNITS_PER_SEC;
}
/*
diff --git a/tc/tc_core.h b/tc/tc_core.h
index b31813d..a139da6 100644
--- a/tc/tc_core.h
+++ b/tc/tc_core.h
@@ -6,9 +6,9 @@ #include <linux/pkt_sched.h>
#define TIME_UNITS_PER_SEC 1000000
-int tc_core_usec2big(long usec);
-long tc_core_usec2tick(long usec);
-long tc_core_tick2usec(long tick);
+int tc_core_time2big(long time);
+long tc_core_time2tick(long time);
+long tc_core_tick2time(long tick);
long tc_core_time2ktime(long time);
long tc_core_ktime2time(long ktime);
unsigned tc_calc_xmittime(unsigned rate, unsigned size);
diff --git a/tc/tc_util.c b/tc/tc_util.c
index 62113fc..b73fae9 100644
--- a/tc/tc_util.c
+++ b/tc/tc_util.c
@@ -209,7 +209,7 @@ char * sprint_rate(__u32 rate, char *buf
return buf;
}
-int get_usecs(unsigned *usecs, const char *str)
+int get_time(unsigned *time, const char *str)
{
double t;
char *p;
@@ -232,26 +232,26 @@ int get_usecs(unsigned *usecs, const cha
return -1;
}
- *usecs = t;
+ *time = t;
return 0;
}
-void print_usecs(char *buf, int len, __u32 usec)
+void print_time(char *buf, int len, __u32 time)
{
- double tmp = usec;
+ double tmp = time;
if (tmp >= TIME_UNITS_PER_SEC)
snprintf(buf, len, "%.1fs", tmp/TIME_UNITS_PER_SEC);
else if (tmp >= TIME_UNITS_PER_SEC/1000)
snprintf(buf, len, "%.1fms", tmp/(TIME_UNITS_PER_SEC/1000));
else
- snprintf(buf, len, "%uus", usec);
+ snprintf(buf, len, "%uus", time);
}
-char * sprint_usecs(__u32 usecs, char *buf)
+char * sprint_time(__u32 time, char *buf)
{
- print_usecs(buf, SPRINT_BSIZE-1, usecs);
+ print_time(buf, SPRINT_BSIZE-1, time);
return buf;
}
diff --git a/tc/tc_util.h b/tc/tc_util.h
index 0778693..b713cf1 100644
--- a/tc/tc_util.h
+++ b/tc/tc_util.h
@@ -46,17 +46,17 @@ extern int get_rate(unsigned *rate, cons
extern int get_percent(unsigned *percent, const char *str);
extern int get_size(unsigned *size, const char *str);
extern int get_size_and_cell(unsigned *size, int *cell_log, char *str);
-extern int get_usecs(unsigned *usecs, const char *str);
+extern int get_time(unsigned *time, const char *str);
extern void print_rate(char *buf, int len, __u32 rate);
extern void print_size(char *buf, int len, __u32 size);
extern void print_percent(char *buf, int len, __u32 percent);
extern void print_qdisc_handle(char *buf, int len, __u32 h);
-extern void print_usecs(char *buf, int len, __u32 usecs);
+extern void print_time(char *buf, int len, __u32 time);
extern char * sprint_rate(__u32 rate, char *buf);
extern char * sprint_size(__u32 size, char *buf);
extern char * sprint_qdisc_handle(__u32 h, char *buf);
extern char * sprint_tc_classid(__u32 h, char *buf);
-extern char * sprint_usecs(__u32 usecs, char *buf);
+extern char * sprint_time(__u32 time, char *buf);
extern char * sprint_percent(__u32 percent, char *buf);
extern void print_tcstats_attr(FILE *fp, struct rtattr *tb[], char *prefix, struct rtattr **xstats);
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [IPROUTE 05/05]: Add sprint_ticks() function and use in CBQ
2007-01-10 10:01 [IPROUTE 00/05]: Time cleanups Patrick McHardy
` (3 preceding siblings ...)
2007-01-10 10:01 ` [IPROUTE 04/05]: Replace "usec" by "time" in function names Patrick McHardy
@ 2007-01-10 10:01 ` Patrick McHardy
4 siblings, 0 replies; 16+ messages in thread
From: Patrick McHardy @ 2007-01-10 10:01 UTC (permalink / raw)
To: shemminger; +Cc: netdev, Patrick McHardy
[IPROUTE]: Add sprint_ticks() function and use in CBQ
Add helper function to print ticks to avoid assumptions about clock
resolution in CBQ.
Signed-off-by: Patrick McHardy <kaber@trash.net>
---
commit 408fb739030c2667bbc02187018c9e504384cdec
tree 21d2f5117d7f6f1fe18b5e7b5fa1a0627d1b7efc
parent d1980613b2921fcc288858f4c63727f28ca49607
author Patrick McHardy <kaber@trash.net> Wed, 10 Jan 2007 10:43:03 +0100
committer Patrick McHardy <kaber@trash.net> Wed, 10 Jan 2007 10:43:03 +0100
tc/q_cbq.c | 7 ++++---
tc/q_netem.c | 6 ------
tc/tc_util.c | 5 +++++
tc/tc_util.h | 1 +
4 files changed, 10 insertions(+), 9 deletions(-)
diff --git a/tc/q_cbq.c b/tc/q_cbq.c
index 913b26a..f2b4ce8 100644
--- a/tc/q_cbq.c
+++ b/tc/q_cbq.c
@@ -418,6 +418,7 @@ static int cbq_print_opt(struct qdisc_ut
struct tc_cbq_wrropt *wrr = NULL;
struct tc_cbq_fopt *fopt = NULL;
struct tc_cbq_ovl *ovl = NULL;
+ SPRINT_BUF(b1);
if (opt == NULL)
return 0;
@@ -500,17 +501,17 @@ static int cbq_print_opt(struct qdisc_ut
if (lss && show_details) {
fprintf(f, "\nlevel %u ewma %u avpkt %ub ", lss->level, lss->ewma_log, lss->avpkt);
if (lss->maxidle) {
- fprintf(f, "maxidle %luus ", tc_core_tick2time(lss->maxidle>>lss->ewma_log));
+ fprintf(f, "maxidle %s ", sprint_ticks(lss->maxidle>>lss->ewma_log, b1));
if (show_raw)
fprintf(f, "[%08x] ", lss->maxidle);
}
if (lss->minidle!=0x7fffffff) {
- fprintf(f, "minidle %luus ", tc_core_tick2time(lss->minidle>>lss->ewma_log));
+ fprintf(f, "minidle %s ", sprint_ticks(lss->minidle>>lss->ewma_log, b1));
if (show_raw)
fprintf(f, "[%08x] ", lss->minidle);
}
if (lss->offtime) {
- fprintf(f, "offtime %luus ", tc_core_tick2time(lss->offtime));
+ fprintf(f, "offtime %s ", sprint_ticks(lss->offtime, b1));
if (show_raw)
fprintf(f, "[%08x] ", lss->offtime);
}
diff --git a/tc/q_netem.c b/tc/q_netem.c
index 24fb95e..94ce6bb 100644
--- a/tc/q_netem.c
+++ b/tc/q_netem.c
@@ -120,12 +120,6 @@ static int get_ticks(__u32 *ticks, const
return 0;
}
-static char *sprint_ticks(__u32 ticks, char *buf)
-{
- return sprint_usecs(tc_core_tick2usec(ticks), buf);
-}
-
-
static int netem_parse_opt(struct qdisc_util *qu, int argc, char **argv,
struct nlmsghdr *n)
{
diff --git a/tc/tc_util.c b/tc/tc_util.c
index b73fae9..a7e4257 100644
--- a/tc/tc_util.c
+++ b/tc/tc_util.c
@@ -255,6 +255,11 @@ char * sprint_time(__u32 time, char *buf
return buf;
}
+char * sprint_ticks(__u32 ticks, char *buf)
+{
+ return sprint_time(tc_core_tick2time(ticks), buf);
+}
+
int get_size(unsigned *size, const char *str)
{
double sz;
diff --git a/tc/tc_util.h b/tc/tc_util.h
index b713cf1..eade72d 100644
--- a/tc/tc_util.h
+++ b/tc/tc_util.h
@@ -57,6 +57,7 @@ extern char * sprint_size(__u32 size, ch
extern char * sprint_qdisc_handle(__u32 h, char *buf);
extern char * sprint_tc_classid(__u32 h, char *buf);
extern char * sprint_time(__u32 time, char *buf);
+extern char * sprint_ticks(__u32 ticks, char *buf);
extern char * sprint_percent(__u32 percent, char *buf);
extern void print_tcstats_attr(FILE *fp, struct rtattr *tb[], char *prefix, struct rtattr **xstats);
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [IPROUTE 04/05]: Replace "usec" by "time" in function names
2006-06-23 18:06 [RFC IPROUTE 00/05]: Time cleanups Patrick McHardy
@ 2006-06-23 18:06 ` Patrick McHardy
0 siblings, 0 replies; 16+ messages in thread
From: Patrick McHardy @ 2006-06-23 18:06 UTC (permalink / raw)
To: hemminger; +Cc: netdev, Patrick McHardy, hadi
[IPROUTE]: Replace "usec" by "time" in function names
Rename functions containing "usec" since they don't necessarily return
usec units anymore.
Signed-off-by: Patrick McHardy <kaber@trash.net>
---
commit 67edfb2c86323a1c52a60538f677310f6c75efdf
tree 37302dfd036340aac8c7f2070ebcbc570fd634ed
parent 8e2cc14ba6fb8f940de72f307e67eb9040a5d4f7
author Patrick McHardy <kaber@trash.net> Fri, 23 Jun 2006 19:47:14 +0200
committer Patrick McHardy <kaber@trash.net> Fri, 23 Jun 2006 19:47:14 +0200
tc/m_estimator.c | 4 ++--
tc/q_cbq.c | 6 +++---
tc/q_hfsc.c | 6 +++---
tc/q_netem.c | 6 +++---
tc/q_tbf.c | 8 ++++----
tc/tc_cbq.c | 4 ++--
tc/tc_core.c | 10 +++++-----
tc/tc_core.h | 4 ++--
tc/tc_util.c | 14 +++++++-------
tc/tc_util.h | 6 +++---
10 files changed, 34 insertions(+), 34 deletions(-)
diff --git a/tc/m_estimator.c b/tc/m_estimator.c
index 78eda7a..898ff80 100644
--- a/tc/m_estimator.c
+++ b/tc/m_estimator.c
@@ -45,12 +45,12 @@ int parse_estimator(int *p_argc, char **
duparg("estimator", *argv);
if (matches(*argv, "help") == 0)
est_help();
- if (get_usecs(&A, *argv))
+ if (get_time(&A, *argv))
invarg("estimator", "invalid estimator interval");
NEXT_ARG();
if (matches(*argv, "help") == 0)
est_help();
- if (get_usecs(&time_const, *argv))
+ if (get_time(&time_const, *argv))
invarg("estimator", "invalid estimator time constant");
if (tc_setup_estimator(A, time_const, est) < 0) {
fprintf(stderr, "Error: estimator parameters are out of range.\n");
diff --git a/tc/q_cbq.c b/tc/q_cbq.c
index 045c377..648acd0 100644
--- a/tc/q_cbq.c
+++ b/tc/q_cbq.c
@@ -500,17 +500,17 @@ static int cbq_print_opt(struct qdisc_ut
if (lss && show_details) {
fprintf(f, "\nlevel %u ewma %u avpkt %ub ", lss->level, lss->ewma_log, lss->avpkt);
if (lss->maxidle) {
- fprintf(f, "maxidle %luus ", tc_core_tick2usec(lss->maxidle>>lss->ewma_log));
+ fprintf(f, "maxidle %luus ", tc_core_tick2time(lss->maxidle>>lss->ewma_log));
if (show_raw)
fprintf(f, "[%08x] ", lss->maxidle);
}
if (lss->minidle!=0x7fffffff) {
- fprintf(f, "minidle %luus ", tc_core_tick2usec(lss->minidle>>lss->ewma_log));
+ fprintf(f, "minidle %luus ", tc_core_tick2time(lss->minidle>>lss->ewma_log));
if (show_raw)
fprintf(f, "[%08x] ", lss->minidle);
}
if (lss->offtime) {
- fprintf(f, "offtime %luus ", tc_core_tick2usec(lss->offtime));
+ fprintf(f, "offtime %luus ", tc_core_tick2time(lss->offtime));
if (show_raw)
fprintf(f, "[%08x] ", lss->offtime);
}
diff --git a/tc/q_hfsc.c b/tc/q_hfsc.c
index be0587f..6c160c9 100644
--- a/tc/q_hfsc.c
+++ b/tc/q_hfsc.c
@@ -226,7 +226,7 @@ hfsc_print_sc(FILE *f, char *name, struc
fprintf(f, "%s ", name);
fprintf(f, "m1 %s ", sprint_rate(sc->m1, b1));
- fprintf(f, "d %s ", sprint_usecs(tc_core_ktime2time(sc->d), b1));
+ fprintf(f, "d %s ", sprint_time(tc_core_ktime2time(sc->d), b1));
fprintf(f, "m2 %s ", sprint_rate(sc->m2, b1));
}
@@ -303,7 +303,7 @@ hfsc_get_sc1(int *argcp, char ***argvp,
if (matches(*argv, "d") == 0) {
NEXT_ARG();
- if (get_usecs(&d, *argv) < 0) {
+ if (get_time(&d, *argv) < 0) {
explain1("d");
return -1;
}
@@ -346,7 +346,7 @@ hfsc_get_sc2(int *argcp, char ***argvp,
if (matches(*argv, "dmax") == 0) {
NEXT_ARG();
- if (get_usecs(&dmax, *argv) < 0) {
+ if (get_time(&dmax, *argv) < 0) {
explain1("dmax");
return -1;
}
diff --git a/tc/q_netem.c b/tc/q_netem.c
index 757edca..cc16a28 100644
--- a/tc/q_netem.c
+++ b/tc/q_netem.c
@@ -108,16 +108,16 @@ static int get_ticks(__u32 *ticks, const
{
unsigned t;
- if(get_usecs(&t, str))
+ if(get_time(&t, str))
return -1;
- *ticks = tc_core_usec2tick(t);
+ *ticks = tc_core_time2tick(t);
return 0;
}
static char *sprint_ticks(__u32 ticks, char *buf)
{
- return sprint_usecs(tc_core_tick2usec(ticks), buf);
+ return sprint_time(tc_core_tick2time(ticks), buf);
}
diff --git a/tc/q_tbf.c b/tc/q_tbf.c
index f2ffb7e..4db4b44 100644
--- a/tc/q_tbf.c
+++ b/tc/q_tbf.c
@@ -67,7 +67,7 @@ static int tbf_parse_opt(struct qdisc_ut
fprintf(stderr, "Double \"limit/latency\" spec\n");
return -1;
}
- if (get_usecs(&latency, *argv)) {
+ if (get_time(&latency, *argv)) {
explain1("latency");
return -1;
}
@@ -245,13 +245,13 @@ static int tbf_print_opt(struct qdisc_ut
if (show_raw)
fprintf(f, "limit %s ", sprint_size(qopt->limit, b1));
- latency = tc_calc_xmittime(qopt->rate.rate, qopt->limit) - tc_core_tick2usec(qopt->buffer);
+ latency = tc_calc_xmittime(qopt->rate.rate, qopt->limit) - tc_core_tick2time(qopt->buffer);
if (qopt->peakrate.rate) {
- double lat2 = tc_calc_xmittime(qopt->peakrate.rate, qopt->limit) - tc_core_tick2usec(qopt->mtu);
+ double lat2 = tc_calc_xmittime(qopt->peakrate.rate, qopt->limit) - tc_core_tick2time(qopt->mtu);
if (lat2 > latency)
latency = lat2;
}
- fprintf(f, "lat %s ", sprint_usecs(tc_core_tick2usec(latency), b1));
+ fprintf(f, "lat %s ", sprint_time(tc_core_tick2time(latency), b1));
return 0;
}
diff --git a/tc/tc_cbq.c b/tc/tc_cbq.c
index c7b3a2d..0bb262e 100644
--- a/tc/tc_cbq.c
+++ b/tc/tc_cbq.c
@@ -38,7 +38,7 @@ unsigned tc_cbq_calc_maxidle(unsigned bn
if (vxmt > maxidle)
maxidle = vxmt;
}
- return tc_core_usec2tick(maxidle*(1<<ewma_log)*TIME_UNITS_PER_SEC);
+ return tc_core_time2tick(maxidle*(1<<ewma_log)*TIME_UNITS_PER_SEC);
}
unsigned tc_cbq_calc_offtime(unsigned bndw, unsigned rate, unsigned avpkt,
@@ -53,5 +53,5 @@ unsigned tc_cbq_calc_offtime(unsigned bn
offtime *= pow(g, -(double)minburst) - 1;
else
offtime *= 1 + (pow(g, -(double)(minburst-1)) - 1)/(1-g);
- return tc_core_usec2tick(offtime*TIME_UNITS_PER_SEC);
+ return tc_core_time2tick(offtime*TIME_UNITS_PER_SEC);
}
diff --git a/tc/tc_core.c b/tc/tc_core.c
index cf49d83..063995c 100644
--- a/tc/tc_core.c
+++ b/tc/tc_core.c
@@ -27,12 +27,12 @@ static __u32 t2us=1;
static __u32 us2t=1;
static double tick_in_usec = 1;
-long tc_core_usec2tick(long usec)
+long tc_core_time2tick(long time)
{
- return usec*tick_in_usec;
+ return time*tick_in_usec;
}
-long tc_core_tick2usec(long tick)
+long tc_core_tick2time(long tick)
{
return tick/tick_in_usec;
}
@@ -49,12 +49,12 @@ long tc_core_ktime2time(long ktime)
unsigned tc_calc_xmittime(unsigned rate, unsigned size)
{
- return tc_core_usec2tick(TIME_UNITS_PER_SEC*((double)size/rate));
+ return tc_core_time2tick(TIME_UNITS_PER_SEC*((double)size/rate));
}
unsigned tc_calc_xmitsize(unsigned rate, unsigned ticks)
{
- return ((double)rate*tc_core_tick2usec(ticks))/TIME_UNITS_PER_SEC;
+ return ((double)rate*tc_core_tick2time(ticks))/TIME_UNITS_PER_SEC;
}
/*
diff --git a/tc/tc_core.h b/tc/tc_core.h
index 720b6d6..52954be 100644
--- a/tc/tc_core.h
+++ b/tc/tc_core.h
@@ -6,8 +6,8 @@ #include <linux/pkt_sched.h>
#define TIME_UNITS_PER_SEC 1000000
-long tc_core_usec2tick(long usec);
-long tc_core_tick2usec(long tick);
+long tc_core_time2tick(long time);
+long tc_core_tick2time(long tick);
long tc_core_time2ktime(long time);
long tc_core_ktime2time(long ktime);
unsigned tc_calc_xmittime(unsigned rate, unsigned size);
diff --git a/tc/tc_util.c b/tc/tc_util.c
index 2ceb631..321bac0 100644
--- a/tc/tc_util.c
+++ b/tc/tc_util.c
@@ -209,7 +209,7 @@ char * sprint_rate(__u32 rate, char *buf
return buf;
}
-int get_usecs(unsigned *usecs, const char *str)
+int get_time(unsigned *time, const char *str)
{
double t;
char *p;
@@ -232,26 +232,26 @@ int get_usecs(unsigned *usecs, const cha
return -1;
}
- *usecs = t;
+ *time = t;
return 0;
}
-void print_usecs(char *buf, int len, __u32 usec)
+void print_time(char *buf, int len, __u32 time)
{
- double tmp = usec;
+ double tmp = time;
if (tmp >= TIME_UNITS_PER_SEC)
snprintf(buf, len, "%.1fs", tmp/TIME_UNITS_PER_SEC);
else if (tmp >= TIME_UNITS_PER_SEC/1000)
snprintf(buf, len, "%.1fms", tmp/(TIME_UNITS_PER_SEC/1000));
else
- snprintf(buf, len, "%uus", usec);
+ snprintf(buf, len, "%uus", time);
}
-char * sprint_usecs(__u32 usecs, char *buf)
+char * sprint_time(__u32 time, char *buf)
{
- print_usecs(buf, SPRINT_BSIZE-1, usecs);
+ print_time(buf, SPRINT_BSIZE-1, time);
return buf;
}
diff --git a/tc/tc_util.h b/tc/tc_util.h
index 1aa1bda..aba4adb 100644
--- a/tc/tc_util.h
+++ b/tc/tc_util.h
@@ -46,17 +46,17 @@ extern int get_rate(unsigned *rate, cons
extern int get_percent(unsigned *percent, const char *str);
extern int get_size(unsigned *size, const char *str);
extern int get_size_and_cell(unsigned *size, int *cell_log, char *str);
-extern int get_usecs(unsigned *usecs, const char *str);
+extern int get_time(unsigned *time, const char *str);
extern void print_rate(char *buf, int len, __u32 rate);
extern void print_size(char *buf, int len, __u32 size);
extern void print_percent(char *buf, int len, __u32 percent);
extern void print_qdisc_handle(char *buf, int len, __u32 h);
-extern void print_usecs(char *buf, int len, __u32 usecs);
+extern void print_time(char *buf, int len, __u32 time);
extern char * sprint_rate(__u32 rate, char *buf);
extern char * sprint_size(__u32 size, char *buf);
extern char * sprint_qdisc_handle(__u32 h, char *buf);
extern char * sprint_tc_classid(__u32 h, char *buf);
-extern char * sprint_usecs(__u32 usecs, char *buf);
+extern char * sprint_time(__u32 time, char *buf);
extern char * sprint_percent(__u32 percent, char *buf);
extern void print_tcstats_attr(FILE *fp, struct rtattr *tb[], char *prefix, struct rtattr **xstats);
^ permalink raw reply related [flat|nested] 16+ messages in thread