1 --- a/include/linux/pkt_sched.h
2 +++ b/include/linux/pkt_sched.h
3 @@ -174,8 +174,38 @@ struct tc_sfq_qopt
5 * The only reason for this is efficiency, it is possible
6 * to change these parameters in compile time.
8 + * If you need to play with these values use esfq instead.
16 + TCA_SFQ_HASH_CLASSIC,
20 + TCA_SFQ_HASH_CTORIGDST,
21 + TCA_SFQ_HASH_CTORIGSRC,
22 + TCA_SFQ_HASH_CTREPLDST,
23 + TCA_SFQ_HASH_CTREPLSRC,
24 + TCA_SFQ_HASH_CTNATCHG,
29 + unsigned quantum; /* Bytes per round allocated to flow */
30 + int perturb_period; /* Period of hash perturbation */
31 + __u32 limit; /* Maximal packets in queue */
32 + unsigned divisor; /* Hash divisor */
33 + unsigned flows; /* Maximal number of flows */
34 + unsigned hash_kind; /* Hash function to use for flow identification */
42 @@ -588,8 +618,37 @@ struct tc_sfq_xstats
44 * The only reason for this is efficiency, it is possible
45 * to change these parameters in compile time.
47 + * If you need to play with these values use esfq instead.
55 + TCA_SFQ_HASH_CLASSIC,
59 + TCA_SFQ_HASH_CTORIGDST,
60 + TCA_SFQ_HASH_CTORIGSRC,
61 + TCA_SFQ_HASH_CTREPLDST,
62 + TCA_SFQ_HASH_CTREPLSRC,
63 + TCA_SFQ_HASH_CTNATCHG,
68 + unsigned quantum; /* Bytes per round allocated to flow */
69 + int perturb_period; /* Period of hash perturbation */
70 + __u32 limit; /* Maximal packets in queue */
71 + unsigned divisor; /* Hash divisor */
72 + unsigned flows; /* Maximal number of flows */
73 + unsigned hash_kind; /* Hash function to use for flow identification */
82 @@ -8,6 +8,7 @@ SHARED_LIBS ?= y
86 +TCMODULES += q_esfq.o
96 + * This program is free software; you can redistribute it and/or
97 + * modify it under the terms of the GNU General Public License
98 + * as published by the Free Software Foundation; either version
99 + * 2 of the License, or (at your option) any later version.
101 + * Authors: Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru>
103 + * Changes: Alexander Atanasov, <alex@ssi.bg>
104 + * Alexander Clouter, <alex@digriz.org.uk>
105 + * Corey Hickey, <bugfood-c@fatooh.org>
115 +#include <sys/socket.h>
116 +#include <netinet/in.h>
117 +#include <arpa/inet.h>
121 +#include "tc_util.h"
123 +static void explain(void)
125 + fprintf(stderr, "Usage: ... esfq [ perturb SECS ] [ quantum BYTES ] [ depth FLOWS ]\n\t[ divisor HASHBITS ] [ limit PKTS ] [ hash HASHTYPE]\n");
126 + fprintf(stderr,"Where: \n");
127 + fprintf(stderr,"HASHTYPE := { classic | src | dst | ctorigdst | ctorigsrc | ctrepldst | ctreplsrc | ctnatchg }\n");
130 +#define usage() return(-1)
132 +static int esfq_parse_opt(struct qdisc_util *qu, int argc, char **argv, struct nlmsghdr *n)
135 + struct tc_esfq_qopt opt;
137 + memset(&opt, 0, sizeof(opt));
139 + opt.hash_kind= TCA_SFQ_HASH_CLASSIC;
142 + if (strcmp(*argv, "quantum") == 0) {
144 + if (get_size(&opt.quantum, *argv)) {
145 + fprintf(stderr, "Illegal \"quantum\"\n");
149 + } else if (strcmp(*argv, "perturb") == 0) {
151 + if (get_integer(&opt.perturb_period, *argv, 0)) {
152 + fprintf(stderr, "Illegal \"perturb\"\n");
156 + } else if (strcmp(*argv, "depth") == 0) {
158 + if (get_integer((int *) &opt.flows, *argv, 0)) {
159 + fprintf(stderr, "Illegal \"depth\"\n");
163 + } else if (strcmp(*argv, "divisor") == 0) {
165 + if (get_integer((int *) &opt.divisor, *argv, 0)) {
166 + fprintf(stderr, "Illegal \"divisor\"\n");
169 + if(opt.divisor >= 14) {
170 + fprintf(stderr, "Illegal \"divisor\": must be < 14\n");
173 + opt.divisor=pow(2,opt.divisor);
175 + } else if (strcmp(*argv, "limit") == 0) {
177 + if (get_integer((int *) &opt.limit, *argv, 0)) {
178 + fprintf(stderr, "Illegal \"limit\"\n");
182 + } else if (strcmp(*argv, "hash") == 0) {
184 + if(strcmp(*argv, "classic") == 0) {
185 + opt.hash_kind= TCA_SFQ_HASH_CLASSIC;
187 + if(strcmp(*argv, "dst") == 0) {
188 + opt.hash_kind= TCA_SFQ_HASH_DST;
190 + if(strcmp(*argv, "src") == 0) {
191 + opt.hash_kind= TCA_SFQ_HASH_SRC;
193 + if(strcmp(*argv, "ctorigsrc") == 0) {
194 + opt.hash_kind= TCA_SFQ_HASH_CTORIGSRC;
196 + if(strcmp(*argv, "ctorigdst") == 0) {
197 + opt.hash_kind= TCA_SFQ_HASH_CTORIGDST;
199 + if(strcmp(*argv, "ctreplsrc") == 0) {
200 + opt.hash_kind= TCA_SFQ_HASH_CTREPLSRC;
202 + if(strcmp(*argv, "ctrepldst") == 0) {
203 + opt.hash_kind= TCA_SFQ_HASH_CTREPLDST;
205 + if(strcmp(*argv, "ctnatchg") == 0) {
206 + opt.hash_kind= TCA_SFQ_HASH_CTNATCHG;
208 + fprintf(stderr, "Illegal \"hash\"\n");
213 + } else if (strcmp(*argv, "help") == 0) {
217 + fprintf(stderr, "What is \"%s\"?\n", *argv);
225 + addattr_l(n, 1024, TCA_OPTIONS, &opt, sizeof(opt));
229 +static int esfq_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt)
231 + struct tc_esfq_qopt *qopt;
237 + if (RTA_PAYLOAD(opt) < sizeof(*qopt))
239 + qopt = RTA_DATA(opt);
240 + fprintf(f, "quantum %s ", sprint_size(qopt->quantum, b1));
241 + if (show_details) {
242 + fprintf(f, "limit %up flows %u/%u ",
243 + qopt->limit, qopt->flows, qopt->divisor);
245 + if (qopt->perturb_period)
246 + fprintf(f, "perturb %dsec ", qopt->perturb_period);
248 + fprintf(f,"hash: ");
249 + switch(qopt->hash_kind)
251 + case TCA_SFQ_HASH_CLASSIC:
252 + fprintf(f,"classic");
254 + case TCA_SFQ_HASH_DST:
257 + case TCA_SFQ_HASH_SRC:
260 + case TCA_SFQ_HASH_CTORIGSRC:
261 + fprintf(f,"ctorigsrc");
263 + case TCA_SFQ_HASH_CTORIGDST:
264 + fprintf(f,"ctorigdst");
266 + case TCA_SFQ_HASH_CTREPLSRC:
267 + fprintf(f,"ctreplsrc");
269 + case TCA_SFQ_HASH_CTREPLDST:
270 + fprintf(f,"ctrepldst");
272 + case TCA_SFQ_HASH_CTNATCHG:
273 + fprintf(f,"ctnatchg");
276 + fprintf(f,"Unknown");
281 +static int esfq_print_xstats(struct qdisc_util *qu, FILE *f, struct rtattr *xstats)
287 +struct qdisc_util esfq_qdisc_util = {
289 + .parse_qopt = esfq_parse_opt,
290 + .print_qopt = esfq_print_opt,
291 + .print_xstats = esfq_print_xstats,