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));
}
return -1;
sc->m1 = m1;
- sc->d = d;
+ sc->d = tc_core_time2ktime(d);
sc->m2 = m2;
*argvp = argv;
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 {
/*
* 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;
}
}
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;
}
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;
}
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,
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);
}
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;
}
/*
#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);
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)
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;
}
{
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);
}