From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wi0-f181.google.com (mail-wi0-f181.google.com [209.85.212.181]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority" (verified OK)) by huchra.bufferbloat.net (Postfix) with ESMTPS id 43BBC200B1B for ; Thu, 3 May 2012 10:59:04 -0700 (PDT) Received: by wibhn14 with SMTP id hn14so285542wib.10 for ; Thu, 03 May 2012 10:59:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; bh=7XQu3Ur1bNFta1qCsqu1bqQxdslkZhgZuajiyFKmTl0=; b=Pt4sY7APP+VPwl3LTnEsPlH4D+85iR+uWhT33GapAXyIfR7hMMvXhnSaM7NIaLqbxW A2kcCbG0nFkwh2hqBbAdoGmDrfJ5QMgYt7lMUGECpIdoH/KgOmVSpzbLdwIgxgWUUXl8 hFgKTQSv4FEvd7ffdQCUXiLvr9xvg8ht3FANt6qGCVg5wj2rqVlhL5MQ9TjK0zFH9Nqu qUTFUwPKo8VXv0pZmXPlmlvcFqjdxffUN8t+hwTsNXU75WncajZsCZ+YSmZSYXZQnHzq bhQbGx2DCme3rUJ1lmHWE2Mx8uEIpozKnTMVnYAKsTbOLEtnuupdVCsd/PxtIJnGXhRp EPPw== MIME-Version: 1.0 Received: by 10.180.94.7 with SMTP id cy7mr6330229wib.3.1336067941561; Thu, 03 May 2012 10:59:01 -0700 (PDT) Received: by 10.223.112.66 with HTTP; Thu, 3 May 2012 10:59:01 -0700 (PDT) In-Reply-To: <1336067533-16923-1-git-send-email-dave.taht@bufferbloat.net> References: <1336067533-16923-1-git-send-email-dave.taht@bufferbloat.net> Date: Thu, 3 May 2012 10:59:01 -0700 Message-ID: From: Dave Taht To: =?ISO-8859-1?Q?Dave_T=E4ht?= Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Cc: codel@lists.bufferbloat.net Subject: Re: [Codel] [PATCH] iproute2: added preliminary codel support X-BeenThere: codel@lists.bufferbloat.net X-Mailman-Version: 2.1.13 Precedence: list List-Id: CoDel AQM discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 May 2012 17:59:05 -0000 I should have prepended 'RFC' to these two posts. While this code compiles, and indeed lets you insert and use the codel kernel module... I appear to have goofed on the netlink implementation. I get back: !!!Deficit 20, rta_len=3D24 so I'm confused about the correct usage of the PARM parameter. certainly a little code review from the more knowledgable is highly desired. Or, I'll get back on it after a major nap. On Thu, May 3, 2012 at 10:52 AM, Dave T=E4ht wr= ote: > this makes certain constants in the code variables, but > has seemingly good defaults. > > target and interval can be specified with a ms, s, or us parameter > mtu is in bytes > > ecn, while part of the api, is not enabled in the code > --- > =A0include/linux/pkt_sched.h | =A0 28 ++++++++++ > =A0tc/Makefile =A0 =A0 =A0 =A0 =A0 =A0 =A0 | =A0 =A01 + > =A0tc/q_codel.c =A0 =A0 =A0 =A0 =A0 =A0 =A0| =A0135 +++++++++++++++++++++= ++++++++++++++++++++++++ > =A03 files changed, 164 insertions(+) > =A0create mode 100644 tc/q_codel.c > > diff --git a/include/linux/pkt_sched.h b/include/linux/pkt_sched.h > index 410b33d..150aee9 100644 > --- a/include/linux/pkt_sched.h > +++ b/include/linux/pkt_sched.h > @@ -654,4 +654,32 @@ struct tc_qfq_stats { > =A0 =A0 =A0 =A0__u32 lmax; > =A0}; > > +/* CODEL */ > + > +enum { > + =A0 =A0 =A0 TCA_CODEL_UNSPEC, > + =A0 =A0 =A0 TCA_CODEL_PARMS, > + =A0 =A0 =A0 TCA_CODEL_TARGET, > + =A0 =A0 =A0 TCA_CODEL_DEPTH, > + =A0 =A0 =A0 TCA_CODEL_MINBYTES, > + =A0 =A0 =A0 TCA_CODEL_INTERVAL, > + =A0 =A0 =A0 __TCA_CODEL_MAX > +}; > + > +#define TCA_CODEL_MAX =A0(__TCA_CODEL_MAX - 1) > +#define TC_CODEL_ECN 1 > + > +struct tc_codel_qopt { > + =A0 =A0 =A0 =A0__u32 flags; =A0 /* flags (e.g. ecn) */ > + =A0 =A0 =A0 __u32 target; =A0 /* max delay, in us */ > + =A0 =A0 =A0 =A0__u32 depth; =A0 /* queue depth in packets */ > + =A0 =A0 =A0 =A0__u32 minbytes; =A0 =A0 =A0 =A0/* MTU (usually) */ > + =A0 =A0 =A0 =A0__u32 interval; =A0 =A0 =A0 =A0/* Sliding min time windo= w width (us) */ > +}; > + > +struct tc_codel_stats { > + =A0 =A0 =A0 __u64 drops; > + =A0 =A0 =A0 __u64 marks; > +}; > + > =A0#endif > diff --git a/tc/Makefile b/tc/Makefile > index be8cd5a..8a7cc8d 100644 > --- a/tc/Makefile > +++ b/tc/Makefile > @@ -47,6 +47,7 @@ TCMODULES +=3D em_cmp.o > =A0TCMODULES +=3D em_u32.o > =A0TCMODULES +=3D em_meta.o > =A0TCMODULES +=3D q_mqprio.o > +TCMODULES +=3D q_codel.o > > =A0TCSO :=3D > =A0ifeq ($(TC_CONFIG_ATM),y) > diff --git a/tc/q_codel.c b/tc/q_codel.c > new file mode 100644 > index 0000000..2ff51a1 > --- /dev/null > +++ b/tc/q_codel.c > @@ -0,0 +1,135 @@ > +/* > + * q_codel.c =A0 Controlled Delay > + * > + * =A0 =A0 =A0 =A0 =A0 =A0 This program is free software; you can redist= ribute it and/or > + * =A0 =A0 =A0 =A0 =A0 =A0 modify it under the terms of the GNU General = Public License > + * =A0 =A0 =A0 =A0 =A0 =A0 as published by the Free Software Foundation;= either version > + * =A0 =A0 =A0 =A0 =A0 =A0 2 of the License, or (at your option) any lat= er version. > + * > + * Authors: =A0 =A0Dave Taht > + * > + */ > + > + > + > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > + > +#include "utils.h" > +#include "tc_util.h" > + > +static void explain(void) > +{ > + =A0 =A0 =A0 fprintf(stderr, > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 "Usage: ... codel [target MAX_DELAY] [depth= PACKETS]" > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0" [mtu MINBYTES]\n =A0 =A0 =A0 =A0 =A0 = =A0 =A0 =A0 " > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 "[interval INTEGRATION_TIME] [ecn]\n" ); > +} > + > +static int codel_parse_opt(struct qdisc_util *qu, int argc, char **argv, > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0struct nlmsghdr *n) > +{ > + =A0 =A0 =A0 struct tc_codel_qopt opt; > + =A0 =A0 =A0 struct rtattr *tail; > + > + =A0 =A0 =A0 memset(&opt, 0, sizeof(opt)); > + =A0 =A0 =A0 opt.target =3D 5000; > + =A0 =A0 =A0 opt.depth =3D 1000; > + =A0 =A0 =A0 opt.interval =3D 1000*100; > + =A0 =A0 =A0 opt.minbytes =3D 1500; > + =A0 =A0 =A0 opt.flags =3D 0; > + > + =A0 =A0 =A0 while (argc > 0) { > + =A0 =A0 =A0 =A0 =A0 if (strcmp(*argv, "target") =3D=3D 0) { > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 NEXT_ARG(); > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (get_time(&opt.target, *= argv)) { > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 fprintf(std= err, "Illegal \"target\"\n"); > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 return -1; > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 } > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 } else if (strcmp(*argv, "depth") =3D=3D 0)= { > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 NEXT_ARG(); > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (get_u32(&opt.depth, *ar= gv, 0)) { > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 fprintf(std= err, "Illegal \"depth\"\n"); > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 return -1; > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 } > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 } else if (strcmp(*argv, "interval") =3D=3D= 0) { > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 NEXT_ARG(); > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (get_time(&opt.interval,= *argv)) { > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 fprintf(std= err, "Illegal \"interval\"\n"); > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 return -1; > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 } > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 } else if (strcmp(*argv, "mtu") =3D=3D 0) { > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 NEXT_ARG(); > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (get_u32(&opt.minbytes, = *argv, 0)) { > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 fprintf(std= err, "Illegal \"mtu\"\n"); > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 return -1; > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 } > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 } else if (strcmp(*argv, "ecn") =3D=3D 0) { > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 opt.flags |=3D TC_CODEL_ECN= ; > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 } else { > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 fprintf(stderr, "What is \"= %s\"?\n", *argv); > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 explain(); > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 return -1; > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 } > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 argc--; argv++; > + =A0 =A0 =A0 } > + > + =A0 =A0 =A0 tail =3D NLMSG_TAIL(n); > + =A0 =A0 =A0 addattr_l(n, 1024, TCA_OPTIONS, NULL, 0); > + =A0 =A0 =A0 addattr_l(n, 1024, TCA_CODEL_PARMS, &opt, sizeof(opt)); > + =A0 =A0 =A0 tail->rta_len =3D (void *) NLMSG_TAIL(n) - (void *) tail; > + =A0 =A0 =A0 return 0; > +} > + > +static int codel_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr= *opt) > +{ > + =A0 =A0 =A0 struct rtattr *tb[__TCA_CODEL_MAX]; > + =A0 =A0 =A0 struct tc_codel_qopt *qopt; > + > + =A0 =A0 =A0 if (opt =3D=3D NULL) > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 return 0; > + > + =A0 =A0 =A0 parse_rtattr_nested(tb, TCA_CODEL_MAX, opt); > + =A0 =A0 =A0 if (tb[TCA_CODEL_PARMS] =3D=3D NULL) > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 return -1; > + =A0 =A0 =A0 qopt =3D RTA_DATA(tb[TCA_CODEL_PARMS]); > + =A0 =A0 =A0 if (RTA_PAYLOAD(tb[TCA_CODEL_PARMS]) < sizeof(*qopt)) > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 return -1; > + =A0 =A0 =A0 fprintf(f," target %dus depth %d mtu %d interval %dus %s\n"= , > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 qopt->target, qopt->depth, qopt->minbytes, > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 qopt->interval, (qopt->flags & TC_CODEL_ECN= ) ? "ecn" : ""); > + > + =A0 =A0 =A0 return 0; > +} > + > +static int codel_print_xstats(struct qdisc_util *qu, FILE *f, > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 struct rtattr *xsta= ts) > +{ > + =A0 =A0struct tc_codel_stats *st; > + > + =A0 =A0if (xstats =3D=3D NULL) > + =A0 =A0 =A0 =A0 =A0 return 0; > + > + =A0 =A0if (RTA_PAYLOAD(xstats) < sizeof(*st)) > + =A0 =A0 =A0 =A0 =A0 return -1; > + > + =A0 =A0st =3D RTA_DATA(xstats); > + =A0 =A0fprintf(f, " =A0dropped %lu marked %lu ", > + =A0 =A0 =A0 =A0 =A0 st->drops, st->marks); > + > + =A0 =A0return 0; > +} > + > +struct qdisc_util codel_qdisc_util =3D { > + =A0 =A0 =A0 .id =A0 =A0 =A0 =A0 =A0 =A0 =3D "codel", > + =A0 =A0 =A0 .parse_qopt =A0 =A0 =3D codel_parse_opt, > + =A0 =A0 =A0 .print_qopt =A0 =A0 =3D codel_print_opt, > + =A0 =A0 =A0 .print_xstats =A0 =3D codel_print_xstats, > +}; > -- > 1.7.9.5 > > _______________________________________________ > Codel mailing list > Codel@lists.bufferbloat.net > https://lists.bufferbloat.net/listinfo/codel --=20 Dave T=E4ht SKYPE: davetaht US Tel: 1-239-829-5608 http://www.bufferbloat.net