- * [IPROUTE 01/05]: Use tc_calc_xmittime where appropriate
  2006-06-23 18:06 [RFC IPROUTE 00/05]: Time cleanups Patrick McHardy
@ 2006-06-23 18:06 ` Patrick McHardy
  2006-06-23 18:28   ` Patrick McHardy
  2006-06-23 18:06 ` [IPROUTE 02/05]: Introduce tc_calc_xmitsize and use " Patrick McHardy
                   ` (4 subsequent siblings)
  5 siblings, 1 reply; 12+ messages in thread
From: Patrick McHardy @ 2006-06-23 18:06 UTC (permalink / raw)
  To: hemminger; +Cc: netdev, Patrick McHardy, hadi
[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 c25b0a7730d72f266e46fee3cfd53ce9f2a15c2f
tree 39c6fbd3395e8a41170739d6cff8d3a00d31a915
parent 8f8a36487119a3cd1afe86a9649704aca088567b
author Patrick McHardy <kaber@trash.net> Fri, 23 Jun 2006 19:02:46 +0200
committer Patrick McHardy <kaber@trash.net> Fri, 23 Jun 2006 19:02:46 +0200
 tc/q_cbq.c   |    2 +-
 tc/q_tbf.c   |    4 ++--
 tc/tc_core.c |    2 +-
 tc/tc_red.c  |    2 +-
 4 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/tc/q_cbq.c b/tc/q_cbq.c
index a456eda..045c377 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/q_tbf.c b/tc/q_tbf.c
index 6ed5e0b..87b1b29 100644
--- a/tc/q_tbf.c
+++ b/tc/q_tbf.c
@@ -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 = tc_calc_xmittime(qopt->rate.rate, qopt->limit) - 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 = tc_calc_xmittime(qopt->peakrate.rate, qopt->limit) - tc_core_tick2usec(qopt->mtu);
 		if (lat2 > latency)
 			latency = lat2;
 	}
diff --git a/tc/tc_core.c b/tc/tc_core.c
index 07cf2fa..8688b63 100644
--- a/tc/tc_core.c
+++ b/tc/tc_core.c
@@ -67,7 +67,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] 12+ messages in thread
- * Re: [IPROUTE 01/05]: Use tc_calc_xmittime where appropriate
  2006-06-23 18:06 ` [IPROUTE 01/05]: Use tc_calc_xmittime where appropriate Patrick McHardy
@ 2006-06-23 18:28   ` Patrick McHardy
  0 siblings, 0 replies; 12+ messages in thread
From: Patrick McHardy @ 2006-06-23 18:28 UTC (permalink / raw)
  To: shemminger; +Cc: netdev, hadi
[-- Attachment #1: Type: text/plain, Size: 966 bytes --]
Patrick McHardy wrote:
> [IPROUTE]: Use tc_calc_xmittime where appropriate
> 
> diff --git a/tc/q_tbf.c b/tc/q_tbf.c
> index 6ed5e0b..87b1b29 100644
> --- a/tc/q_tbf.c
> +++ b/tc/q_tbf.c
> @@ -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 = tc_calc_xmittime(qopt->rate.rate, qopt->limit) - 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 = tc_calc_xmittime(qopt->peakrate.rate, qopt->limit) - tc_core_tick2usec(qopt->mtu);
>  		if (lat2 > latency)
I think I should start reviewing my own patches in a mail client :)
The two cases above are wrong, tc_calc_xmittime does an additional
tc_core_usec2tick(). Corrected patch attached.
[-- Attachment #2: 01.diff --]
[-- Type: text/plain, Size: 2034 bytes --]
[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 c25b0a7730d72f266e46fee3cfd53ce9f2a15c2f
tree 39c6fbd3395e8a41170739d6cff8d3a00d31a915
parent 8f8a36487119a3cd1afe86a9649704aca088567b
author Patrick McHardy <kaber@trash.net> Fri, 23 Jun 2006 19:02:46 +0200
committer Patrick McHardy <kaber@trash.net> Fri, 23 Jun 2006 19:02:46 +0200
 tc/q_cbq.c   |    2 +-
 tc/q_tbf.c   |    4 ++--
 tc/tc_core.c |    2 +-
 tc/tc_red.c  |    2 +-
 4 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/tc/q_cbq.c b/tc/q_cbq.c
index a456eda..045c377 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 07cf2fa..8688b63 100644
--- a/tc/tc_core.c
+++ b/tc/tc_core.c
@@ -67,7 +67,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] 12+ messages in thread
 
- * [IPROUTE 02/05]: Introduce tc_calc_xmitsize and use where appropriate
  2006-06-23 18:06 [RFC IPROUTE 00/05]: Time cleanups Patrick McHardy
  2006-06-23 18:06 ` [IPROUTE 01/05]: Use tc_calc_xmittime where appropriate Patrick McHardy
@ 2006-06-23 18:06 ` Patrick McHardy
  2006-06-23 18:06 ` [IPROUTE 03/05]: Introduce TIME_UNITS_PER_SEC to represent internal clock resulution Patrick McHardy
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 12+ messages in thread
From: Patrick McHardy @ 2006-06-23 18:06 UTC (permalink / raw)
  To: hemminger; +Cc: netdev, Patrick McHardy, hadi
[IPROUTE]: Introduce tc_calc_xmitsize and use where appropriate
Add tc_calc_xmitsize() as complement to tc_calc_xmittime(), which calculates
the size than 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 06a5350c47d028448850788031625ac1961d722b
tree 23eb5f6dbbb4a864e524c048f006842733924c9e
parent c25b0a7730d72f266e46fee3cfd53ce9f2a15c2f
author Patrick McHardy <kaber@trash.net> Fri, 23 Jun 2006 19:13:09 +0200
committer Patrick McHardy <kaber@trash.net> Fri, 23 Jun 2006 19:13:09 +0200
 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 71adb59..c3d2eeb 100644
--- a/tc/m_police.c
+++ b/tc/m_police.c
@@ -334,7 +334,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 828d4b1..9a7755f 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 87b1b29..bb13d77 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 8688b63..7d6dd7d 100644
--- a/tc/tc_core.c
+++ b/tc/tc_core.c
@@ -42,6 +42,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 1537f95..d97c011 100644
--- a/tc/tc_core.h
+++ b/tc/tc_core.h
@@ -7,6 +7,7 @@ #include <linux/pkt_sched.h>
 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] 12+ messages in thread
- * [IPROUTE 03/05]: Introduce TIME_UNITS_PER_SEC to represent internal clock resulution
  2006-06-23 18:06 [RFC IPROUTE 00/05]: Time cleanups Patrick McHardy
  2006-06-23 18:06 ` [IPROUTE 01/05]: Use tc_calc_xmittime where appropriate Patrick McHardy
  2006-06-23 18:06 ` [IPROUTE 02/05]: Introduce tc_calc_xmitsize and use " Patrick McHardy
@ 2006-06-23 18:06 ` Patrick McHardy
  2006-06-23 18:06 ` [IPROUTE 04/05]: Replace "usec" by "time" in function names Patrick McHardy
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 12+ messages in thread
From: Patrick McHardy @ 2006-06-23 18:06 UTC (permalink / raw)
  To: hemminger; +Cc: netdev, Patrick McHardy, hadi
[IPROUTE]: Introduce TIME_UNITS_PER_SEC to represent internal clock resulution
Introduce TIME_UNITS_PER_SEC and conversion functions between internal
resulution and resulution 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 8e2cc14ba6fb8f940de72f307e67eb9040a5d4f7
tree da8e068525029b6571f95e7eeffcbab901f2e1be
parent 06a5350c47d028448850788031625ac1961d722b
author Patrick McHardy <kaber@trash.net> Fri, 23 Jun 2006 19:40:34 +0200
committer Patrick McHardy <kaber@trash.net> Fri, 23 Jun 2006 19:40:34 +0200
 tc/q_hfsc.c       |   12 ++++++------
 tc/q_tbf.c        |    4 ++--
 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, 34 insertions(+), 20 deletions(-)
diff --git a/tc/q_hfsc.c b/tc/q_hfsc.c
index f09c606..be0587f 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 bb13d77..f2ffb7e 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;
 		}
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 7d6dd7d..cf49d83 100644
--- a/tc/tc_core.c
+++ b/tc/tc_core.c
@@ -37,14 +37,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 d97c011..720b6d6 100644
--- a/tc/tc_core.h
+++ b/tc/tc_core.h
@@ -4,8 +4,12 @@ #define _TC_CORE_H_ 1
 #include <asm/types.h>
 #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_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 9cde144..2ceb631 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] 12+ 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
                   ` (2 preceding siblings ...)
  2006-06-23 18:06 ` [IPROUTE 03/05]: Introduce TIME_UNITS_PER_SEC to represent internal clock resulution Patrick McHardy
@ 2006-06-23 18:06 ` Patrick McHardy
  2006-06-23 18:06 ` [IPROUTE 05/05]: Add sprint_ticks() function and use in CBQ Patrick McHardy
  2006-06-23 18:09 ` [RFC IPROUTE 00/05]: Time cleanups Patrick McHardy
  5 siblings, 0 replies; 12+ 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] 12+ messages in thread
- * [IPROUTE 05/05]: Add sprint_ticks() function and use in CBQ
  2006-06-23 18:06 [RFC IPROUTE 00/05]: Time cleanups Patrick McHardy
                   ` (3 preceding siblings ...)
  2006-06-23 18:06 ` [IPROUTE 04/05]: Replace "usec" by "time" in function names Patrick McHardy
@ 2006-06-23 18:06 ` Patrick McHardy
  2006-06-23 18:09 ` [RFC IPROUTE 00/05]: Time cleanups Patrick McHardy
  5 siblings, 0 replies; 12+ messages in thread
From: Patrick McHardy @ 2006-06-23 18:06 UTC (permalink / raw)
  To: hemminger; +Cc: netdev, Patrick McHardy, hadi
[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 182666ac89f3089a1771564620998fb4f315bd87
tree ce7c3109b7e8ff9a4665e175490a62f8c300ea33
parent 67edfb2c86323a1c52a60538f677310f6c75efdf
author Patrick McHardy <kaber@trash.net> Fri, 23 Jun 2006 19:52:11 +0200
committer Patrick McHardy <kaber@trash.net> Fri, 23 Jun 2006 19:52:11 +0200
 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 648acd0..abf0468 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 cc16a28..0d7f4d5 100644
--- a/tc/q_netem.c
+++ b/tc/q_netem.c
@@ -115,12 +115,6 @@ static int get_ticks(__u32 *ticks, const
 	return 0;
 }
 
-static char *sprint_ticks(__u32 ticks, char *buf)
-{
-	return sprint_time(tc_core_tick2time(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 321bac0..c1e02f4 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 aba4adb..17e7b99 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] 12+ messages in thread
- * Re: [RFC IPROUTE 00/05]: Time cleanups
  2006-06-23 18:06 [RFC IPROUTE 00/05]: Time cleanups Patrick McHardy
                   ` (4 preceding siblings ...)
  2006-06-23 18:06 ` [IPROUTE 05/05]: Add sprint_ticks() function and use in CBQ Patrick McHardy
@ 2006-06-23 18:09 ` Patrick McHardy
  2006-06-23 20:01   ` David Miller
  5 siblings, 1 reply; 12+ messages in thread
From: Patrick McHardy @ 2006-06-23 18:09 UTC (permalink / raw)
  To: shemminger; +Cc: netdev, hadi
D'oh, got Stephen's address wrong. Please fix it (add 's' in front) in
replies to this thread.
Patrick McHardy wrote:
> I'm currently adding support for ktime as clocksource to the qdisc layer and
> in the course of doing that cleaned up the iproute time handling a bit to
> make it easier to use a different internal clock resultion and audit for
> integer overflows.
> 
> Increasing iproutes internal clock resolution is necessary for all token bucket
> based schedulers to take advantage of a higher kernel clock resolution because
> the kernel only does lookups and additions/subtractions, which can never result
> in values that have a higher precision that those passed from userspace.
> 
> The way I imagine it we have to keep the old clock sources around for userspace
> compatibility since they can't deal with the higher precision values. iproute is
> changed to use nsec internally and reads the kernel clock resulution from
> /proc/net/psched (third value, currently assumed to always be 10^6) to convert
> it's internal resolution to that of the kernel. With ktime as clocksource the
> kernel will report a resulution of 10^9. The downside is that distributors can't
> enable ktime unless they want to break compatibility with old iproute versions.
> Any better suggestions are welcome of course.
> 
> 
>  tc/m_estimator.c  |    4 ++--
>  tc/m_police.c     |    2 +-
>  tc/q_cbq.c        |   15 ++++++++-------
>  tc/q_hfsc.c       |   18 +++++++++---------
>  tc/q_htb.c        |    4 ++--
>  tc/q_netem.c      |   12 +++---------
>  tc/q_tbf.c        |   20 ++++++++++----------
>  tc/tc_cbq.c       |    8 ++++----
>  tc/tc_core.c      |   31 +++++++++++++++++++++++--------
>  tc/tc_core.h      |    9 +++++++--
>  tc/tc_estimator.c |    2 +-
>  tc/tc_red.c       |    2 +-
>  tc/tc_util.c      |   33 +++++++++++++++++++--------------
>  tc/tc_util.h      |    7 ++++---
>  14 files changed, 94 insertions(+), 73 deletions(-)
> 
> Patrick McHardy:
>       [IPROUTE]: Use tc_calc_xmittime where appropriate
>       [IPROUTE]: Introduce tc_calc_xmitsize and use where appropriate
>       [IPROUTE]: Introduce TIME_UNITS_PER_SEC to represent internal clock resulution
>       [IPROUTE]: Replace "usec" by "time" in function names
>       [IPROUTE]: Add sprint_ticks() function and use in CBQ
^ permalink raw reply	[flat|nested] 12+ messages in thread
- * [IPROUTE 04/05]: Replace "usec" by "time" in function names
  2007-01-10 10:01 [IPROUTE " Patrick McHardy
@ 2007-01-10 10:01 ` Patrick McHardy
  2007-01-15 10:17   ` Jarek Poplawski
  0 siblings, 1 reply; 12+ 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] 12+ 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; 12+ 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] 12+ 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; 12+ 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] 12+ messages in thread