~ubuntu-branches/ubuntu/precise/iproute/precise

« back to all changes in this revision

Viewing changes to tc/q_tbf.c

  • Committer: Bazaar Package Importer
  • Author(s): Fabio M. Di Nitto
  • Date: 2007-06-11 13:31:12 UTC
  • mfrom: (1.1.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20070611133112-0rtfv32yfs8loo0r
Tags: 20070313-1ubuntu1
* Merge from debian unstable, remaining changes:
  - linux-kernel-headers -> linux-libc-dev B-D rename.
  - MAX_ROUNDS patch to ip/ipaddress.c
  - Ubuntu maintainer foobar.

Show diffs side-by-side

added added

removed removed

Lines of Context:
44
44
        __u32 rtab[256];
45
45
        __u32 ptab[256];
46
46
        unsigned buffer=0, mtu=0, mpu=0, latency=0;
47
 
        int Rcell_log=-1, Pcell_log = -1; 
 
47
        int Rcell_log=-1, Pcell_log = -1;
48
48
        struct rtattr *tail;
49
49
 
50
50
        memset(&opt, 0, sizeof(opt));
67
67
                                fprintf(stderr, "Double \"limit/latency\" spec\n");
68
68
                                return -1;
69
69
                        }
70
 
                        if (get_usecs(&latency, *argv)) {
 
70
                        if (get_time(&latency, *argv)) {
71
71
                                explain1("latency");
72
72
                                return -1;
73
73
                        }
161
161
        }
162
162
 
163
163
        if (opt.limit == 0) {
164
 
                double lim = opt.rate.rate*(double)latency/1000000 + buffer;
 
164
                double lim = opt.rate.rate*(double)latency/TIME_UNITS_PER_SEC + buffer;
165
165
                if (opt.peakrate.rate) {
166
 
                        double lim2 = opt.peakrate.rate*(double)latency/1000000 + mtu;
 
166
                        double lim2 = opt.peakrate.rate*(double)latency/TIME_UNITS_PER_SEC + mtu;
167
167
                        if (lim2 < lim)
168
168
                                lim = lim2;
169
169
                }
218
218
        if (RTA_PAYLOAD(tb[TCA_TBF_PARMS])  < sizeof(*qopt))
219
219
                return -1;
220
220
        fprintf(f, "rate %s ", sprint_rate(qopt->rate.rate, b1));
221
 
        buffer = ((double)qopt->rate.rate*tc_core_tick2usec(qopt->buffer))/1000000;
 
221
        buffer = tc_calc_xmitsize(qopt->rate.rate, qopt->buffer);
222
222
        if (show_details) {
223
223
                fprintf(f, "burst %s/%u mpu %s ", sprint_size(buffer, b1),
224
224
                        1<<qopt->rate.cell_log, sprint_size(qopt->rate.mpu, b2));
230
230
        if (qopt->peakrate.rate) {
231
231
                fprintf(f, "peakrate %s ", sprint_rate(qopt->peakrate.rate, b1));
232
232
                if (qopt->mtu || qopt->peakrate.mpu) {
233
 
                        mtu = ((double)qopt->peakrate.rate*tc_core_tick2usec(qopt->mtu))/1000000;
 
233
                        mtu = tc_calc_xmitsize(qopt->peakrate.rate, qopt->mtu);
234
234
                        if (show_details) {
235
235
                                fprintf(f, "mtu %s/%u mpu %s ", sprint_size(mtu, b1),
236
236
                                        1<<qopt->peakrate.cell_log, sprint_size(qopt->peakrate.mpu, b2));
245
245
        if (show_raw)
246
246
                fprintf(f, "limit %s ", sprint_size(qopt->limit, b1));
247
247
 
248
 
        latency = 1000000*(qopt->limit/(double)qopt->rate.rate) - tc_core_tick2usec(qopt->buffer);
 
248
        latency = TIME_UNITS_PER_SEC*(qopt->limit/(double)qopt->rate.rate) - tc_core_tick2time(qopt->buffer);
249
249
        if (qopt->peakrate.rate) {
250
 
                double lat2 = 1000000*(qopt->limit/(double)qopt->peakrate.rate) - tc_core_tick2usec(qopt->mtu);
 
250
                double lat2 = TIME_UNITS_PER_SEC*(qopt->limit/(double)qopt->peakrate.rate) - tc_core_tick2time(qopt->mtu);
251
251
                if (lat2 > latency)
252
252
                        latency = lat2;
253
253
        }
254
 
        fprintf(f, "lat %s ", sprint_usecs(tc_core_tick2usec(latency), b1));
 
254
        fprintf(f, "lat %s ", sprint_time(latency, b1));
255
255
 
256
256
        return 0;
257
257
}