summaryrefslogtreecommitdiffstats
path: root/tc/tc_core.c
diff options
context:
space:
mode:
authorPatrick McHardy <kaber@trash.net>2007-03-04 20:14:56 +0100
committerStephen Hemminger <shemminger@linux-foundation.org>2007-03-13 14:42:14 -0700
commit476daa7278aaf324f6cef27981f81187afce8836 (patch)
tree8217c5bac4c41a7623c4322438e95c6d315a4664 /tc/tc_core.c
parent7b77c0caa6479aaf8e1e473a24372965f3315190 (diff)
Use tc_calc_xmittime() where appropriate
[IPROUTE]: Use tc_calc_xmittime() where appropriate Replace expressions of the form "tc_core_usec2tick(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(): unsigned tc_cbq_calc_maxidle(...) { double g = 1.0 - 1.0/(1<<ewma_log); double xmt = (double)avpkt/bndw; maxidle = xmt*(1-g); if (bndw != rate && maxburst) { ... } return tc_core_usec2tick(maxidle*(1<<ewma_log)*1000000); } which comes down to: maxidle = xmt * (1 - g) = xmt * (1 - (1.0 - 1.0/(1 << ewma_log)) = xmt * (1.0/(1 << ewma_log)) so: maxidle * (1 << ewma_log) * 1000000 = xmt * (1.0/(1 << ewma_log)) * (1 << ewma_log) * 1000000 = xmt * 1000000 = avpkt/bndw * 1000000 Which means tc_core_usec2tick(maxidle*(1<<ewma_log)*1000000) is identical to tc_calc_xmittime(bndw, avpkt). Use it directly since its a lot easier to understand its limits. Signed-off-by: Patrick McHardy <kaber@trash.net> Signed-off-by: Stephen Hemminger <shemminger@linux-foundation.org>
Diffstat (limited to 'tc/tc_core.c')
-rw-r--r--tc/tc_core.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/tc/tc_core.c b/tc/tc_core.c
index 10c375ef..90a097d3 100644
--- a/tc/tc_core.c
+++ b/tc/tc_core.c
@@ -76,7 +76,7 @@ int tc_calc_rtable(unsigned bps, __u32 *rtab, int cell_log, unsigned mtu,
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;
}