also ignore env directory
[openwrt.git] / package / iproute2 / patches / 003-iproute2-htb_overhead.patch
1 Index: iproute2-2.6.25/tc/q_htb.c
2 ===================================================================
3 --- iproute2-2.6.25.orig/tc/q_htb.c 2008-05-01 00:37:50.000000000 +0100
4 +++ iproute2-2.6.25/tc/q_htb.c 2008-05-01 20:30:28.000000000 +0100
5 @@ -35,10 +35,14 @@ static void explain(void)
6 " default minor id of class to which unclassified packets are sent {0}\n"
7 " r2q DRR quantums are computed as rate in Bps/r2q {10}\n"
8 " debug string of 16 numbers each 0-3 {0}\n\n"
9 - "... class add ... htb rate R1 burst B1 [prio P] [slot S] [pslot PS]\n"
10 + "... class add ... htb rate R1 [burst B1] [mpu B] [overhead O]\n"
11 + " [prio P] [slot S] [pslot PS]\n"
12 " [ceil R2] [cburst B2] [mtu MTU] [quantum Q]\n"
13 " rate rate allocated to this class (class can still borrow)\n"
14 " burst max bytes burst which can be accumulated during idle period {computed}\n"
15 + " mpu minimum packet size used in rate computations\n"
16 + " overhead per-packet size overhead used in rate computations\n"
17 +
18 " ceil definite upper class rate (no borrows) {rate}\n"
19 " cburst burst but for ceil {computed}\n"
20 " mtu max packet size we create rate map for {1600}\n"
21 @@ -103,7 +107,9 @@ static int htb_parse_class_opt(struct qd
22 struct tc_htb_opt opt;
23 __u32 rtab[256],ctab[256];
24 unsigned buffer=0,cbuffer=0;
25 - int cell_log=-1,ccell_log = -1,mtu;
26 + int cell_log=-1,ccell_log = -1;
27 + unsigned mtu, mpu;
28 + unsigned char mpu8 = 0, overhead = 0;
29 struct rtattr *tail;
30
31 memset(&opt, 0, sizeof(opt)); mtu = 1600; /* eth packet len */
32 @@ -120,6 +126,16 @@ static int htb_parse_class_opt(struct qd
33 if (get_u32(&mtu, *argv, 10)) {
34 explain1("mtu"); return -1;
35 }
36 + } else if (matches(*argv, "mpu") == 0) {
37 + NEXT_ARG();
38 + if (get_u8(&mpu8, *argv, 10)) {
39 + explain1("mpu"); return -1;
40 + }
41 + } else if (matches(*argv, "overhead") == 0) {
42 + NEXT_ARG();
43 + if (get_u8(&overhead, *argv, 10)) {
44 + explain1("overhead"); return -1;
45 + }
46 } else if (matches(*argv, "quantum") == 0) {
47 NEXT_ARG();
48 if (get_u32(&opt.quantum, *argv, 10)) {
49 @@ -191,14 +207,18 @@ static int htb_parse_class_opt(struct qd
50 if (!buffer) buffer = opt.rate.rate / HZ + mtu;
51 if (!cbuffer) cbuffer = opt.ceil.rate / HZ + mtu;
52
53 - if ((cell_log = tc_calc_rtable(opt.rate.rate, rtab, cell_log, mtu, 0)) < 0) {
54 +/* encode overhead and mpu, 8 bits each, into lower 16 bits */
55 + mpu = (unsigned)mpu8 | (unsigned)overhead << 8;
56 + opt.ceil.mpu = mpu; opt.rate.mpu = mpu;
57 +
58 + if ((cell_log = tc_calc_rtable(opt.rate.rate, rtab, cell_log, mtu, mpu)) < 0) {
59 fprintf(stderr, "htb: failed to calculate rate table.\n");
60 return -1;
61 }
62 opt.buffer = tc_calc_xmittime(opt.rate.rate, buffer);
63 opt.rate.cell_log = cell_log;
64
65 - if ((ccell_log = tc_calc_rtable(opt.ceil.rate, ctab, cell_log, mtu, 0)) < 0) {
66 + if ((ccell_log = tc_calc_rtable(opt.ceil.rate, ctab, cell_log, mtu, mpu)) < 0) {
67 fprintf(stderr, "htb: failed to calculate ceil rate table.\n");
68 return -1;
69 }
70 @@ -222,6 +242,7 @@ static int htb_print_opt(struct qdisc_ut
71 double buffer,cbuffer;
72 SPRINT_BUF(b1);
73 SPRINT_BUF(b2);
74 + SPRINT_BUF(b3);
75
76 if (opt == NULL)
77 return 0;
78 @@ -244,10 +265,16 @@ static int htb_print_opt(struct qdisc_ut
79 fprintf(f, "ceil %s ", sprint_rate(hopt->ceil.rate, b1));
80 cbuffer = ((double)hopt->ceil.rate*tc_core_tick2usec(hopt->cbuffer))/1000000;
81 if (show_details) {
82 - fprintf(f, "burst %s/%u mpu %s ", sprint_size(buffer, b1),
83 - 1<<hopt->rate.cell_log, sprint_size(hopt->rate.mpu, b2));
84 - fprintf(f, "cburst %s/%u mpu %s ", sprint_size(cbuffer, b1),
85 - 1<<hopt->ceil.cell_log, sprint_size(hopt->ceil.mpu, b2));
86 + fprintf(f, "burst %s/%u mpu %s overhead %s ",
87 + sprint_size(buffer, b1),
88 + 1<<hopt->rate.cell_log,
89 + sprint_size(hopt->rate.mpu&0xFF, b2),
90 + sprint_size((hopt->rate.mpu>>8)&0xFF, b3));
91 + fprintf(f, "cburst %s/%u mpu %s overhead %s ",
92 + sprint_size(cbuffer, b1),
93 + 1<<hopt->ceil.cell_log,
94 + sprint_size(hopt->ceil.mpu&0xFF, b2),
95 + sprint_size((hopt->ceil.mpu>>8)&0xFF, b3));
96 fprintf(f, "level %d ", (int)hopt->level);
97 } else {
98 fprintf(f, "burst %s ", sprint_size(buffer, b1));
This page took 0.047286 seconds and 5 git commands to generate.