package/ov51x-jpeg:
[openwrt.git] / package / iproute2 / patches / 006-iproute2-tc_esfq.patch
1 diff -urN --exclude=.svn iproute2-2.6.11-050330/include/linux/pkt_sched.h iproute2-2.6.11-050330/include/linux/pkt_sched.h
2 --- iproute2-2.6.11-050330/include/linux/pkt_sched.h 2007-05-04 22:21:48.000000000 -0400
3 +++ iproute2-2.6.11-050330/include/linux/pkt_sched.h 2007-05-04 22:27:12.000000000 -0400
4 @@ -174,8 +174,38 @@
5 *
6 * The only reason for this is efficiency, it is possible
7 * to change these parameters in compile time.
8 + *
9 + * If you need to play with these values use esfq instead.
10 */
11
12 +/* ESFQ section */
13 +
14 +enum
15 +{
16 + /* traditional */
17 + TCA_SFQ_HASH_CLASSIC,
18 + TCA_SFQ_HASH_DST,
19 + TCA_SFQ_HASH_SRC,
20 + /* conntrack */
21 + TCA_SFQ_HASH_CTORIGDST,
22 + TCA_SFQ_HASH_CTORIGSRC,
23 + TCA_SFQ_HASH_CTREPLDST,
24 + TCA_SFQ_HASH_CTREPLSRC,
25 + TCA_SFQ_HASH_CTNATCHG,
26 +};
27 +
28 +struct tc_esfq_qopt
29 +{
30 + unsigned quantum; /* Bytes per round allocated to flow */
31 + int perturb_period; /* Period of hash perturbation */
32 + __u32 limit; /* Maximal packets in queue */
33 + unsigned divisor; /* Hash divisor */
34 + unsigned flows; /* Maximal number of flows */
35 + unsigned hash_kind; /* Hash function to use for flow identification */
36 +};
37 +
38 +
39 +
40 /* RED section */
41
42 enum
43 @@ -551,8 +580,37 @@
44 *
45 * The only reason for this is efficiency, it is possible
46 * to change these parameters in compile time.
47 + *
48 + * If you need to play with these values use esfq instead.
49 */
50
51 +/* ESFQ section */
52 +
53 +enum
54 +{
55 + /* traditional */
56 + TCA_SFQ_HASH_CLASSIC,
57 + TCA_SFQ_HASH_DST,
58 + TCA_SFQ_HASH_SRC,
59 + /* conntrack */
60 + TCA_SFQ_HASH_CTORIGDST,
61 + TCA_SFQ_HASH_CTORIGSRC,
62 + TCA_SFQ_HASH_CTREPLDST,
63 + TCA_SFQ_HASH_CTREPLSRC,
64 + TCA_SFQ_HASH_CTNATCHG,
65 +};
66 +
67 +struct tc_esfq_qopt
68 +{
69 + unsigned quantum; /* Bytes per round allocated to flow */
70 + int perturb_period; /* Period of hash perturbation */
71 + __u32 limit; /* Maximal packets in queue */
72 + unsigned divisor; /* Hash divisor */
73 + unsigned flows; /* Maximal number of flows */
74 + unsigned hash_kind; /* Hash function to use for flow identification */
75 +};
76 +
77 +
78 /* RED section */
79
80 enum
81 diff -urN --exclude=.svn iproute2-2.6.11-050330/tc/Makefile iproute2-2.6.11-050330/tc/Makefile
82 --- iproute2-2.6.11-050330/tc/Makefile 2007-05-04 22:21:48.000000000 -0400
83 +++ iproute2-2.6.11-050330/tc/Makefile 2007-05-04 22:27:37.000000000 -0400
84 @@ -6,6 +6,7 @@
85 TCMODULES :=
86 TCMODULES += q_fifo.o
87 TCMODULES += q_sfq.o
88 +TCMODULES += q_esfq.o
89 TCMODULES += q_red.o
90 TCMODULES += q_prio.o
91 TCMODULES += q_tbf.o
92 diff -urN --exclude=.svn iproute2-2.6.11-050330/tc/q_esfq.c iproute2-2.6.11-050330/tc/q_esfq.c
93 --- iproute2-2.6.11-050330/tc/q_esfq.c 1969-12-31 19:00:00.000000000 -0500
94 +++ iproute2-2.6.11-050330/tc/q_esfq.c 2007-05-04 22:37:54.000000000 -0400
95 @@ -0,0 +1,200 @@
96 +/*
97 + * q_esfq.c ESFQ.
98 + *
99 + * This program is free software; you can redistribute it and/or
100 + * modify it under the terms of the GNU General Public License
101 + * as published by the Free Software Foundation; either version
102 + * 2 of the License, or (at your option) any later version.
103 + *
104 + * Authors: Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru>
105 + *
106 + * Changes: Alexander Atanasov, <alex@ssi.bg>
107 + * Alexander Clouter, <alex@digriz.org.uk>
108 + * Corey Hickey, <bugfood-c@fatooh.org>
109 + *
110 + */
111 +
112 +#include <stdio.h>
113 +#include <stdlib.h>
114 +#include <unistd.h>
115 +#include <syslog.h>
116 +#include <fcntl.h>
117 +#include <math.h>
118 +#include <sys/socket.h>
119 +#include <netinet/in.h>
120 +#include <arpa/inet.h>
121 +#include <string.h>
122 +
123 +#include "utils.h"
124 +#include "tc_util.h"
125 +
126 +static void explain(void)
127 +{
128 + fprintf(stderr, "Usage: ... esfq [ perturb SECS ] [ quantum BYTES ] [ depth FLOWS ]\n\t[ divisor HASHBITS ] [ limit PKTS ] [ hash HASHTYPE]\n");
129 + fprintf(stderr,"Where: \n");
130 + fprintf(stderr,"HASHTYPE := { classic | src | dst | ctorigdst | ctorigsrc | ctrepldst | ctreplsrc | ctnatchg }\n");
131 +}
132 +
133 +#define usage() return(-1)
134 +
135 +static int esfq_parse_opt(struct qdisc_util *qu, int argc, char **argv, struct nlmsghdr *n)
136 +{
137 + int ok=0;
138 + struct tc_esfq_qopt opt;
139 +
140 + memset(&opt, 0, sizeof(opt));
141 +
142 + opt.hash_kind= TCA_SFQ_HASH_CLASSIC;
143 +
144 + while (argc > 0) {
145 + if (strcmp(*argv, "quantum") == 0) {
146 + NEXT_ARG();
147 + if (get_size(&opt.quantum, *argv)) {
148 + fprintf(stderr, "Illegal \"quantum\"\n");
149 + return -1;
150 + }
151 + ok++;
152 + } else if (strcmp(*argv, "perturb") == 0) {
153 + NEXT_ARG();
154 + if (get_integer(&opt.perturb_period, *argv, 0)) {
155 + fprintf(stderr, "Illegal \"perturb\"\n");
156 + return -1;
157 + }
158 + ok++;
159 + } else if (strcmp(*argv, "depth") == 0) {
160 + NEXT_ARG();
161 + if (get_integer((int *) &opt.flows, *argv, 0)) {
162 + fprintf(stderr, "Illegal \"depth\"\n");
163 + return -1;
164 + }
165 + ok++;
166 + } else if (strcmp(*argv, "divisor") == 0) {
167 + NEXT_ARG();
168 + if (get_integer((int *) &opt.divisor, *argv, 0)) {
169 + fprintf(stderr, "Illegal \"divisor\"\n");
170 + return -1;
171 + }
172 + if(opt.divisor >= 14) {
173 + fprintf(stderr, "Illegal \"divisor\": must be < 14\n");
174 + return -1;
175 + }
176 + opt.divisor=pow(2,opt.divisor);
177 + ok++;
178 + } else if (strcmp(*argv, "limit") == 0) {
179 + NEXT_ARG();
180 + if (get_integer((int *) &opt.limit, *argv, 0)) {
181 + fprintf(stderr, "Illegal \"limit\"\n");
182 + return -1;
183 + }
184 + ok++;
185 + } else if (strcmp(*argv, "hash") == 0) {
186 + NEXT_ARG();
187 + if(strcmp(*argv, "classic") == 0) {
188 + opt.hash_kind= TCA_SFQ_HASH_CLASSIC;
189 + } else
190 + if(strcmp(*argv, "dst") == 0) {
191 + opt.hash_kind= TCA_SFQ_HASH_DST;
192 + } else
193 + if(strcmp(*argv, "src") == 0) {
194 + opt.hash_kind= TCA_SFQ_HASH_SRC;
195 + } else
196 + if(strcmp(*argv, "ctorigsrc") == 0) {
197 + opt.hash_kind= TCA_SFQ_HASH_CTORIGSRC;
198 + } else
199 + if(strcmp(*argv, "ctorigdst") == 0) {
200 + opt.hash_kind= TCA_SFQ_HASH_CTORIGDST;
201 + } else
202 + if(strcmp(*argv, "ctreplsrc") == 0) {
203 + opt.hash_kind= TCA_SFQ_HASH_CTREPLSRC;
204 + } else
205 + if(strcmp(*argv, "ctrepldst") == 0) {
206 + opt.hash_kind= TCA_SFQ_HASH_CTREPLDST;
207 + } else
208 + if(strcmp(*argv, "ctnatchg") == 0) {
209 + opt.hash_kind= TCA_SFQ_HASH_CTNATCHG;
210 + } else {
211 + fprintf(stderr, "Illegal \"hash\"\n");
212 + explain();
213 + return -1;
214 + }
215 + ok++;
216 + } else if (strcmp(*argv, "help") == 0) {
217 + explain();
218 + return -1;
219 + } else {
220 + fprintf(stderr, "What is \"%s\"?\n", *argv);
221 + explain();
222 + return -1;
223 + }
224 + argc--; argv++;
225 + }
226 +
227 + if (ok)
228 + addattr_l(n, 1024, TCA_OPTIONS, &opt, sizeof(opt));
229 + return 0;
230 +}
231 +
232 +static int esfq_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt)
233 +{
234 + struct tc_esfq_qopt *qopt;
235 + SPRINT_BUF(b1);
236 +
237 + if (opt == NULL)
238 + return 0;
239 +
240 + if (RTA_PAYLOAD(opt) < sizeof(*qopt))
241 + return -1;
242 + qopt = RTA_DATA(opt);
243 + fprintf(f, "quantum %s ", sprint_size(qopt->quantum, b1));
244 + if (show_details) {
245 + fprintf(f, "limit %up flows %u/%u ",
246 + qopt->limit, qopt->flows, qopt->divisor);
247 + }
248 + if (qopt->perturb_period)
249 + fprintf(f, "perturb %dsec ", qopt->perturb_period);
250 +
251 + fprintf(f,"hash: ");
252 + switch(qopt->hash_kind)
253 + {
254 + case TCA_SFQ_HASH_CLASSIC:
255 + fprintf(f,"classic");
256 + break;
257 + case TCA_SFQ_HASH_DST:
258 + fprintf(f,"dst");
259 + break;
260 + case TCA_SFQ_HASH_SRC:
261 + fprintf(f,"src");
262 + break;
263 + case TCA_SFQ_HASH_CTORIGSRC:
264 + fprintf(f,"ctorigsrc");
265 + break;
266 + case TCA_SFQ_HASH_CTORIGDST:
267 + fprintf(f,"ctorigdst");
268 + break;
269 + case TCA_SFQ_HASH_CTREPLSRC:
270 + fprintf(f,"ctreplsrc");
271 + break;
272 + case TCA_SFQ_HASH_CTREPLDST:
273 + fprintf(f,"ctrepldst");
274 + break;
275 + case TCA_SFQ_HASH_CTNATCHG:
276 + fprintf(f,"ctnatchg");
277 + break;
278 + default:
279 + fprintf(f,"Unknown");
280 + }
281 + return 0;
282 +}
283 +
284 +static int esfq_print_xstats(struct qdisc_util *qu, FILE *f, struct rtattr *xstats)
285 +{
286 + return 0;
287 +}
288 +
289 +
290 +struct qdisc_util esfq_qdisc_util = {
291 + .id = "esfq",
292 + .parse_qopt = esfq_parse_opt,
293 + .print_qopt = esfq_print_opt,
294 + .print_xstats = esfq_print_xstats,
295 +};
This page took 0.054795 seconds and 5 git commands to generate.