]> git.ipfire.org Git - thirdparty/iproute2.git/commitdiff
Overhead calculation is now done in the kernel.
authorJesper Dangaard Brouer <hawk@comx.dk>
Tue, 11 Sep 2007 14:59:58 +0000 (16:59 +0200)
committerStephen Hemminger <stephen.hemminger@vyatta.com>
Mon, 31 Dec 2007 19:07:58 +0000 (11:07 -0800)
The only current user is HTB. HTB overhead argument is now passed on
to the kernel (in the struct tc_ratespec). Also correct the data
types.

Signed-off-by: Jesper Dangaard Brouer <hawk@comx.dk>
Signed-off-by: Stephen Hemminger <stephen.hemminger@vyatta.com>
tc/q_htb.c
tc/tc_core.c

index 53e3f787fc21a5449c45ffab3c1622b388c1cbc5..310d36d172f8dccab2c0461229ff8dcdb14a9277 100644 (file)
@@ -107,8 +107,9 @@ static int htb_parse_class_opt(struct qdisc_util *qu, int argc, char **argv, str
        __u32 rtab[256],ctab[256];
        unsigned buffer=0,cbuffer=0;
        int cell_log=-1,ccell_log = -1;
-       unsigned mtu, mpu;
-       unsigned char mpu8 = 0, overhead = 0;
+       unsigned mtu;
+       unsigned short mpu = 0;
+       unsigned short overhead = 0;
        struct rtattr *tail;
 
        memset(&opt, 0, sizeof(opt)); mtu = 1600; /* eth packet len */
@@ -127,12 +128,12 @@ static int htb_parse_class_opt(struct qdisc_util *qu, int argc, char **argv, str
                        }
                } else if (matches(*argv, "mpu") == 0) {
                        NEXT_ARG();
-                       if (get_u8(&mpu8, *argv, 10)) {
+                       if (get_u16(&mpu, *argv, 10)) {
                                explain1("mpu"); return -1;
                        }
                } else if (matches(*argv, "overhead") == 0) {
                        NEXT_ARG();
-                       if (get_u8(&overhead, *argv, 10)) {
+                       if (get_u16(&overhead, *argv, 10)) {
                                explain1("overhead"); return -1;
                        }
                } else if (matches(*argv, "quantum") == 0) {
@@ -206,9 +207,11 @@ static int htb_parse_class_opt(struct qdisc_util *qu, int argc, char **argv, str
        if (!buffer) buffer = opt.rate.rate / get_hz() + mtu;
        if (!cbuffer) cbuffer = opt.ceil.rate / get_hz() + mtu;
 
-/* encode overhead and mpu, 8 bits each, into lower 16 bits */
-       mpu = (unsigned)mpu8 | (unsigned)overhead << 8;
-       opt.ceil.mpu = mpu; opt.rate.mpu = mpu;
+       opt.ceil.overhead = overhead;
+       opt.rate.overhead = overhead;
+
+       opt.ceil.mpu = mpu;
+       opt.rate.mpu = mpu;
 
        if ((cell_log = tc_calc_rtable(opt.rate.rate, rtab, cell_log, mtu, mpu)) < 0) {
                fprintf(stderr, "htb: failed to calculate rate table.\n");
index 1365e081479a38c39f14051f4ab133c599f5a030..3908c8861ccf008276e8cc100c4a05dc9be99308 100644 (file)
@@ -73,8 +73,6 @@ int tc_calc_rtable(unsigned bps, __u32 *rtab, int cell_log, unsigned mtu,
                   unsigned mpu)
 {
        int i;
-       unsigned overhead = (mpu >> 8) & 0xFF;
-       mpu = mpu & 0xFF;
 
        if (mtu == 0)
                mtu = 2047;
@@ -86,8 +84,6 @@ int tc_calc_rtable(unsigned bps, __u32 *rtab, int cell_log, unsigned mtu,
        }
        for (i=0; i<256; i++) {
                unsigned sz = (i<<cell_log);
-               if (overhead)
-                       sz += overhead;
                if (sz < mpu)
                        sz = mpu;
                rtab[i] = tc_calc_xmittime(bps, sz);