Introduce tc_calc_xmitsize and use where appropriate
[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> Signed-off-by: Stephen Hemminger <shemminger@linux-foundation.org>
This commit is contained in:
parent
476daa7278
commit
76dc0aa28f
|
|
@ -331,7 +331,7 @@ print_police(struct action_util *a, FILE *f, struct rtattr *arg)
|
||||||
|
|
||||||
fprintf(f, " police 0x%x ", p->index);
|
fprintf(f, " police 0x%x ", p->index);
|
||||||
fprintf(f, "rate %s ", sprint_rate(p->rate.rate, b1));
|
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, "burst %s ", sprint_size(buffer, b1));
|
||||||
fprintf(f, "mtu %s ", sprint_size(p->mtu, b1));
|
fprintf(f, "mtu %s ", sprint_size(p->mtu, b1));
|
||||||
if (show_raw)
|
if (show_raw)
|
||||||
|
|
|
||||||
|
|
@ -259,9 +259,9 @@ static int htb_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt)
|
||||||
fprintf(f, "quantum %d ", (int)hopt->quantum);
|
fprintf(f, "quantum %d ", (int)hopt->quantum);
|
||||||
}
|
}
|
||||||
fprintf(f, "rate %s ", sprint_rate(hopt->rate.rate, b1));
|
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));
|
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) {
|
if (show_details) {
|
||||||
fprintf(f, "burst %s/%u mpu %s overhead %s ",
|
fprintf(f, "burst %s/%u mpu %s overhead %s ",
|
||||||
sprint_size(buffer, b1),
|
sprint_size(buffer, b1),
|
||||||
|
|
|
||||||
|
|
@ -218,7 +218,7 @@ static int tbf_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt)
|
||||||
if (RTA_PAYLOAD(tb[TCA_TBF_PARMS]) < sizeof(*qopt))
|
if (RTA_PAYLOAD(tb[TCA_TBF_PARMS]) < sizeof(*qopt))
|
||||||
return -1;
|
return -1;
|
||||||
fprintf(f, "rate %s ", sprint_rate(qopt->rate.rate, b1));
|
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) {
|
if (show_details) {
|
||||||
fprintf(f, "burst %s/%u mpu %s ", sprint_size(buffer, b1),
|
fprintf(f, "burst %s/%u mpu %s ", sprint_size(buffer, b1),
|
||||||
1<<qopt->rate.cell_log, sprint_size(qopt->rate.mpu, b2));
|
1<<qopt->rate.cell_log, sprint_size(qopt->rate.mpu, b2));
|
||||||
|
|
@ -230,7 +230,7 @@ static int tbf_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt)
|
||||||
if (qopt->peakrate.rate) {
|
if (qopt->peakrate.rate) {
|
||||||
fprintf(f, "peakrate %s ", sprint_rate(qopt->peakrate.rate, b1));
|
fprintf(f, "peakrate %s ", sprint_rate(qopt->peakrate.rate, b1));
|
||||||
if (qopt->mtu || qopt->peakrate.mpu) {
|
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) {
|
if (show_details) {
|
||||||
fprintf(f, "mtu %s/%u mpu %s ", sprint_size(mtu, b1),
|
fprintf(f, "mtu %s/%u mpu %s ", sprint_size(mtu, b1),
|
||||||
1<<qopt->peakrate.cell_log, sprint_size(qopt->peakrate.mpu, b2));
|
1<<qopt->peakrate.cell_log, sprint_size(qopt->peakrate.mpu, b2));
|
||||||
|
|
|
||||||
|
|
@ -51,6 +51,11 @@ unsigned tc_calc_xmittime(unsigned rate, unsigned size)
|
||||||
return tc_core_usec2tick(1000000*((double)size/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
|
rtab[pkt_len>>cell_log] = pkt_xmit_time
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@ int tc_core_usec2big(long usec);
|
||||||
long tc_core_usec2tick(long usec);
|
long tc_core_usec2tick(long usec);
|
||||||
long tc_core_tick2usec(long tick);
|
long tc_core_tick2usec(long tick);
|
||||||
unsigned tc_calc_xmittime(unsigned rate, unsigned size);
|
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_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);
|
int tc_setup_estimator(unsigned A, unsigned time_const, struct tc_estimator *est);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue