2 include/linux/pkt_sched.h | 59 +++++++++++++
4 tc/q_esfq.c | 200 ++++++++++++++++++++++++++++++++++++++++++++++
5 3 files changed, 260 insertions(+)
7 --- a/include/linux/pkt_sched.h
8 +++ b/include/linux/pkt_sched.h
9 @@ -174,8 +174,38 @@ struct tc_sfq_qopt
11 * The only reason for this is efficiency, it is possible
12 * to change these parameters in compile time.
14 + * If you need to play with these values use esfq instead.
22 + TCA_SFQ_HASH_CLASSIC,
26 + TCA_SFQ_HASH_CTORIGDST,
27 + TCA_SFQ_HASH_CTORIGSRC,
28 + TCA_SFQ_HASH_CTREPLDST,
29 + TCA_SFQ_HASH_CTREPLSRC,
30 + TCA_SFQ_HASH_CTNATCHG,
35 + unsigned quantum; /* Bytes per round allocated to flow */
36 + int perturb_period; /* Period of hash perturbation */
37 + __u32 limit; /* Maximal packets in queue */
38 + unsigned divisor; /* Hash divisor */
39 + unsigned flows; /* Maximal number of flows */
40 + unsigned hash_kind; /* Hash function to use for flow identification */
48 @@ -579,8 +609,37 @@ struct tc_sfq_xstats {
50 * The only reason for this is efficiency, it is possible
51 * to change these parameters in compile time.
53 + * If you need to play with these values use esfq instead.
61 + TCA_SFQ_HASH_CLASSIC,
65 + TCA_SFQ_HASH_CTORIGDST,
66 + TCA_SFQ_HASH_CTORIGSRC,
67 + TCA_SFQ_HASH_CTREPLDST,
68 + TCA_SFQ_HASH_CTREPLSRC,
69 + TCA_SFQ_HASH_CTNATCHG,
74 + unsigned quantum; /* Bytes per round allocated to flow */
75 + int perturb_period; /* Period of hash perturbation */
76 + __u32 limit; /* Maximal packets in queue */
77 + unsigned divisor; /* Hash divisor */
78 + unsigned flows; /* Maximal number of flows */
79 + unsigned hash_kind; /* Hash function to use for flow identification */
88 @@ -8,6 +8,7 @@ SHARED_LIBS ?= y
92 +TCMODULES += q_esfq.o
102 + * This program is free software; you can redistribute it and/or
103 + * modify it under the terms of the GNU General Public License
104 + * as published by the Free Software Foundation; either version
105 + * 2 of the License, or (at your option) any later version.
107 + * Authors: Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru>
109 + * Changes: Alexander Atanasov, <alex@ssi.bg>
110 + * Alexander Clouter, <alex@digriz.org.uk>
111 + * Corey Hickey, <bugfood-c@fatooh.org>
121 +#include <sys/socket.h>
122 +#include <netinet/in.h>
123 +#include <arpa/inet.h>
127 +#include "tc_util.h"
129 +static void explain(void)
131 + fprintf(stderr, "Usage: ... esfq [ perturb SECS ] [ quantum BYTES ] [ depth FLOWS ]\n\t[ divisor HASHBITS ] [ limit PKTS ] [ hash HASHTYPE]\n");
132 + fprintf(stderr,"Where: \n");
133 + fprintf(stderr,"HASHTYPE := { classic | src | dst | ctorigdst | ctorigsrc | ctrepldst | ctreplsrc | ctnatchg }\n");
136 +#define usage() return(-1)
138 +static int esfq_parse_opt(struct qdisc_util *qu, int argc, char **argv, struct nlmsghdr *n)
141 + struct tc_esfq_qopt opt;
143 + memset(&opt, 0, sizeof(opt));
145 + opt.hash_kind= TCA_SFQ_HASH_CLASSIC;
148 + if (strcmp(*argv, "quantum") == 0) {
150 + if (get_size(&opt.quantum, *argv)) {
151 + fprintf(stderr, "Illegal \"quantum\"\n");
155 + } else if (strcmp(*argv, "perturb") == 0) {
157 + if (get_integer(&opt.perturb_period, *argv, 0)) {
158 + fprintf(stderr, "Illegal \"perturb\"\n");
162 + } else if (strcmp(*argv, "depth") == 0) {
164 + if (get_integer((int *) &opt.flows, *argv, 0)) {
165 + fprintf(stderr, "Illegal \"depth\"\n");
169 + } else if (strcmp(*argv, "divisor") == 0) {
171 + if (get_integer((int *) &opt.divisor, *argv, 0)) {
172 + fprintf(stderr, "Illegal \"divisor\"\n");
175 + if(opt.divisor >= 14) {
176 + fprintf(stderr, "Illegal \"divisor\": must be < 14\n");
179 + opt.divisor=pow(2,opt.divisor);
181 + } else if (strcmp(*argv, "limit") == 0) {
183 + if (get_integer((int *) &opt.limit, *argv, 0)) {
184 + fprintf(stderr, "Illegal \"limit\"\n");
188 + } else if (strcmp(*argv, "hash") == 0) {
190 + if(strcmp(*argv, "classic") == 0) {
191 + opt.hash_kind= TCA_SFQ_HASH_CLASSIC;
193 + if(strcmp(*argv, "dst") == 0) {
194 + opt.hash_kind= TCA_SFQ_HASH_DST;
196 + if(strcmp(*argv, "src") == 0) {
197 + opt.hash_kind= TCA_SFQ_HASH_SRC;
199 + if(strcmp(*argv, "ctorigsrc") == 0) {
200 + opt.hash_kind= TCA_SFQ_HASH_CTORIGSRC;
202 + if(strcmp(*argv, "ctorigdst") == 0) {
203 + opt.hash_kind= TCA_SFQ_HASH_CTORIGDST;
205 + if(strcmp(*argv, "ctreplsrc") == 0) {
206 + opt.hash_kind= TCA_SFQ_HASH_CTREPLSRC;
208 + if(strcmp(*argv, "ctrepldst") == 0) {
209 + opt.hash_kind= TCA_SFQ_HASH_CTREPLDST;
211 + if(strcmp(*argv, "ctnatchg") == 0) {
212 + opt.hash_kind= TCA_SFQ_HASH_CTNATCHG;
214 + fprintf(stderr, "Illegal \"hash\"\n");
219 + } else if (strcmp(*argv, "help") == 0) {
223 + fprintf(stderr, "What is \"%s\"?\n", *argv);
231 + addattr_l(n, 1024, TCA_OPTIONS, &opt, sizeof(opt));
235 +static int esfq_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt)
237 + struct tc_esfq_qopt *qopt;
243 + if (RTA_PAYLOAD(opt) < sizeof(*qopt))
245 + qopt = RTA_DATA(opt);
246 + fprintf(f, "quantum %s ", sprint_size(qopt->quantum, b1));
247 + if (show_details) {
248 + fprintf(f, "limit %up flows %u/%u ",
249 + qopt->limit, qopt->flows, qopt->divisor);
251 + if (qopt->perturb_period)
252 + fprintf(f, "perturb %dsec ", qopt->perturb_period);
254 + fprintf(f,"hash: ");
255 + switch(qopt->hash_kind)
257 + case TCA_SFQ_HASH_CLASSIC:
258 + fprintf(f,"classic");
260 + case TCA_SFQ_HASH_DST:
263 + case TCA_SFQ_HASH_SRC:
266 + case TCA_SFQ_HASH_CTORIGSRC:
267 + fprintf(f,"ctorigsrc");
269 + case TCA_SFQ_HASH_CTORIGDST:
270 + fprintf(f,"ctorigdst");
272 + case TCA_SFQ_HASH_CTREPLSRC:
273 + fprintf(f,"ctreplsrc");
275 + case TCA_SFQ_HASH_CTREPLDST:
276 + fprintf(f,"ctrepldst");
278 + case TCA_SFQ_HASH_CTNATCHG:
279 + fprintf(f,"ctnatchg");
282 + fprintf(f,"Unknown");
287 +static int esfq_print_xstats(struct qdisc_util *qu, FILE *f, struct rtattr *xstats)
293 +struct qdisc_util esfq_qdisc_util = {
295 + .parse_qopt = esfq_parse_opt,
296 + .print_qopt = esfq_print_opt,
297 + .print_xstats = esfq_print_xstats,