* [PATCH iproute2] red: harddrop support and cleanups
@ 2011-12-08 23:11 Eric Dumazet
2011-12-09 0:44 ` Stephen Hemminger
0 siblings, 1 reply; 10+ messages in thread
From: Eric Dumazet @ 2011-12-08 23:11 UTC (permalink / raw)
To: Stephen Hemminger; +Cc: netdev
Add harddrop support (kernel support added a long time ago), and various
cleanups.
min BYTES, max BYTES are now optional and follow Sally Floyd's
recommendations.
By the way, our default 2% probability is a bit low, Sally recommends
10%.
Not a big deal if upcoming adaptative algo is deployed.
Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
---
tc/q_red.c | 41 ++++++++++++++++++++---------------------
1 file changed, 20 insertions(+), 21 deletions(-)
diff --git a/tc/q_red.c b/tc/q_red.c
index 6e58d7a..90c8573 100644
--- a/tc/q_red.c
+++ b/tc/q_red.c
@@ -27,8 +27,8 @@
static void explain(void)
{
- fprintf(stderr, "Usage: ... red limit BYTES min BYTES max BYTES avpkt BYTES burst PACKETS\n");
- fprintf(stderr, " probability PROBABILITY bandwidth KBPS [ ecn ]\n");
+ fprintf(stderr, "Usage: ... red limit BYTES [min BYTES] [max BYTES] avpkt BYTES [burst PACKETS]\n");
+ fprintf(stderr, " [probability PROBABILITY] bandwidth KBPS [ecn] [harddrop]\n");
}
static int red_parse_opt(struct qdisc_util *qu, int argc, char **argv, struct nlmsghdr *n)
@@ -38,7 +38,6 @@ static int red_parse_opt(struct qdisc_util *qu, int argc, char **argv, struct nl
unsigned avpkt = 0;
double probability = 0.02;
unsigned rate = 0;
- int ecn_ok = 0;
int wlog;
__u8 sbuf[256];
struct rtattr *tail;
@@ -89,7 +88,9 @@ static int red_parse_opt(struct qdisc_util *qu, int argc, char **argv, struct nl
return -1;
}
} else if (strcmp(*argv, "ecn") == 0) {
- ecn_ok = 1;
+ opt.flags |= TC_RED_ECN;
+ } else if (strcmp(*argv, "harddrop") == 0) {
+ opt.flags |= TC_RED_HARDDROP;
} else if (strcmp(*argv, "help") == 0) {
explain();
return -1;
@@ -104,14 +105,20 @@ static int red_parse_opt(struct qdisc_util *qu, int argc, char **argv, struct nl
if (rate == 0)
get_rate(&rate, "10Mbit");
- if (!opt.qth_min || !opt.qth_max || !opt.limit || !avpkt) {
- fprintf(stderr, "RED: Required parameter (min, max, limit, avpkt) is missing\n");
+ if (!opt.limit || !avpkt) {
+ fprintf(stderr, "RED: Required parameter (limit, avpkt) is missing\n");
return -1;
}
- if (!burst) {
+ /* Compute default min/max thresholds based on
+ * Sally Floyd's recommendations:
+ * http://www.icir.org/floyd/REDparameters.txt
+ */
+ if (!opt.qth_max)
+ opt.qth_max = opt.qth_min ? opt.qth_min * 3 : opt.limit / 4;
+ if (!opt.qth_min)
+ opt.qth_min = opt.qth_max / 3;
+ if (!burst)
burst = (2 * opt.qth_min + opt.qth_max) / (3 * avpkt);
- fprintf(stderr, "RED: set burst to %u\n", burst);
- }
if ((wlog = tc_red_eval_ewma(opt.qth_min, burst, avpkt)) < 0) {
fprintf(stderr, "RED: failed to calculate EWMA constant.\n");
return -1;
@@ -129,14 +136,6 @@ static int red_parse_opt(struct qdisc_util *qu, int argc, char **argv, struct nl
return -1;
}
opt.Scell_log = wlog;
- if (ecn_ok) {
-#ifdef TC_RED_ECN
- opt.flags |= TC_RED_ECN;
-#else
- fprintf(stderr, "RED: ECN support is missing in this binary.\n");
- return -1;
-#endif
- }
tail = NLMSG_TAIL(n);
addattr_l(n, 1024, TCA_OPTIONS, NULL, 0);
@@ -148,7 +147,7 @@ static int red_parse_opt(struct qdisc_util *qu, int argc, char **argv, struct nl
static int red_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt)
{
- struct rtattr *tb[TCA_RED_STAB+1];
+ struct rtattr *tb[TCA_RED_MAX + 1];
struct tc_red_qopt *qopt;
SPRINT_BUF(b1);
SPRINT_BUF(b2);
@@ -157,7 +156,7 @@ static int red_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt)
if (opt == NULL)
return 0;
- parse_rtattr_nested(tb, TCA_RED_STAB, opt);
+ parse_rtattr_nested(tb, TCA_RED_MAX, opt);
if (tb[TCA_RED_PARMS] == NULL)
return -1;
@@ -168,10 +167,10 @@ static int red_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt)
sprint_size(qopt->limit, b1),
sprint_size(qopt->qth_min, b2),
sprint_size(qopt->qth_max, b3));
-#ifdef TC_RED_ECN
if (qopt->flags & TC_RED_ECN)
fprintf(f, "ecn ");
-#endif
+ if (qopt->flags & TC_RED_HARDDROP)
+ fprintf(f, "harddrop ");
if (show_details) {
fprintf(f, "ewma %u Plog %u Scell_log %u",
qopt->Wlog, qopt->Plog, qopt->Scell_log);
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH iproute2] red: harddrop support and cleanups
2011-12-08 23:11 [PATCH iproute2] red: harddrop support and cleanups Eric Dumazet
@ 2011-12-09 0:44 ` Stephen Hemminger
2011-12-09 4:10 ` Eric Dumazet
0 siblings, 1 reply; 10+ messages in thread
From: Stephen Hemminger @ 2011-12-09 0:44 UTC (permalink / raw)
To: Eric Dumazet; +Cc: netdev
On Fri, 09 Dec 2011 00:11:40 +0100
Eric Dumazet <eric.dumazet@gmail.com> wrote:
> Add harddrop support (kernel support added a long time ago), and various
> cleanups.
>
> min BYTES, max BYTES are now optional and follow Sally Floyd's
> recommendations.
>
> By the way, our default 2% probability is a bit low, Sally recommends
> 10%.
> Not a big deal if upcoming adaptative algo is deployed.
>
> Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
Applied (minor whitespace cleanup).
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH iproute2] red: harddrop support and cleanups
2011-12-09 0:44 ` Stephen Hemminger
@ 2011-12-09 4:10 ` Eric Dumazet
2011-12-09 17:33 ` Stephen Hemminger
0 siblings, 1 reply; 10+ messages in thread
From: Eric Dumazet @ 2011-12-09 4:10 UTC (permalink / raw)
To: Stephen Hemminger; +Cc: netdev
Le jeudi 08 décembre 2011 à 16:44 -0800, Stephen Hemminger a écrit :
> Applied (minor whitespace cleanup).
Thanks Stephen !
Could you push the final patch so that I add the adaptative part on top
of it ?
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH iproute2] red: harddrop support and cleanups
2011-12-09 4:10 ` Eric Dumazet
@ 2011-12-09 17:33 ` Stephen Hemminger
2011-12-09 18:30 ` [PATCH iproute2] red: Add adaptative algo Eric Dumazet
0 siblings, 1 reply; 10+ messages in thread
From: Stephen Hemminger @ 2011-12-09 17:33 UTC (permalink / raw)
To: Eric Dumazet; +Cc: netdev
On Fri, 09 Dec 2011 05:10:37 +0100
Eric Dumazet <eric.dumazet@gmail.com> wrote:
> Le jeudi 08 décembre 2011 à 16:44 -0800, Stephen Hemminger a écrit :
>
> > Applied (minor whitespace cleanup).
>
> Thanks Stephen !
>
> Could you push the final patch so that I add the adaptative part on top
> of it ?
>
>
>
done
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH iproute2] red: Add adaptative algo
2011-12-09 17:33 ` Stephen Hemminger
@ 2011-12-09 18:30 ` Eric Dumazet
2012-01-19 22:47 ` Stephen Hemminger
0 siblings, 1 reply; 10+ messages in thread
From: Eric Dumazet @ 2011-12-09 18:30 UTC (permalink / raw)
To: Stephen Hemminger; +Cc: netdev
Enable Adaptative RED algo, using :
tc qdisc ... red limit BYTES ... adaptative ...
Support of high precision probability/max_p setting and reporting, with
support of old kernels.
With a new kernel, "Plog ..." is replaced in tc output by "probability
value" :
qdisc red 10: dev eth3 parent 1:1 limit 360Kb min 30Kb max 90Kb ecn ewma
5 probability 0.09 Scell_log 15
Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
---
include/linux/pkt_sched.h | 17 ++++++++++++-----
tc/q_red.c | 24 +++++++++++++++++++++---
2 files changed, 33 insertions(+), 8 deletions(-)
diff --git a/include/linux/pkt_sched.h b/include/linux/pkt_sched.h
index c533670..e41e0d4 100644
--- a/include/linux/pkt_sched.h
+++ b/include/linux/pkt_sched.h
@@ -30,7 +30,7 @@
*/
struct tc_stats {
- __u64 bytes; /* NUmber of enqueues bytes */
+ __u64 bytes; /* Number of enqueued bytes */
__u32 packets; /* Number of enqueued packets */
__u32 drops; /* Packets dropped because of lack of resources */
__u32 overlimits; /* Number of throttle events when this
@@ -181,6 +181,7 @@ enum {
TCA_RED_UNSPEC,
TCA_RED_PARMS,
TCA_RED_STAB,
+ TCA_RED_MAX_P,
__TCA_RED_MAX,
};
@@ -194,8 +195,9 @@ struct tc_red_qopt {
unsigned char Plog; /* log(P_max/(qth_max-qth_min)) */
unsigned char Scell_log; /* cell size for idle damping */
unsigned char flags;
-#define TC_RED_ECN 1
-#define TC_RED_HARDDROP 2
+#define TC_RED_ECN 1
+#define TC_RED_HARDDROP 2
+#define TC_RED_ADAPTATIVE 4
};
struct tc_red_xstats {
@@ -297,7 +299,7 @@ struct tc_htb_glob {
__u32 debug; /* debug flags */
/* stats */
- __u32 direct_pkts; /* count of non shapped packets */
+ __u32 direct_pkts; /* count of non shaped packets */
};
enum {
TCA_HTB_UNSPEC,
@@ -465,6 +467,7 @@ enum {
TCA_NETEM_REORDER,
TCA_NETEM_CORRUPT,
TCA_NETEM_LOSS,
+ TCA_NETEM_RATE,
__TCA_NETEM_MAX,
};
@@ -495,6 +498,10 @@ struct tc_netem_corrupt {
__u32 correlation;
};
+struct tc_netem_rate {
+ __u32 rate; /* byte/s */
+};
+
enum {
NETEM_LOSS_UNSPEC,
NETEM_LOSS_GI, /* General Intuitive - 4 state model */
@@ -503,7 +510,7 @@ enum {
};
#define NETEM_LOSS_MAX (__NETEM_LOSS_MAX - 1)
-/* State transition probablities for 4 state model */
+/* State transition probabilities for 4 state model */
struct tc_netem_gimodel {
__u32 p13;
__u32 p31;
diff --git a/tc/q_red.c b/tc/q_red.c
index 18020d7..0e5d228 100644
--- a/tc/q_red.c
+++ b/tc/q_red.c
@@ -28,7 +28,8 @@
static void explain(void)
{
fprintf(stderr, "Usage: ... red limit BYTES [min BYTES] [max BYTES] avpkt BYTES [burst PACKETS]\n");
- fprintf(stderr, " [probability PROBABILITY] bandwidth KBPS [ecn] [harddrop]\n");
+ fprintf(stderr, " [adaptative] [probability PROBABILITY] bandwidth KBPS\n");
+ fprintf(stderr, " [ecn] [harddrop]\n");
}
static int red_parse_opt(struct qdisc_util *qu, int argc, char **argv, struct nlmsghdr *n)
@@ -40,6 +41,7 @@ static int red_parse_opt(struct qdisc_util *qu, int argc, char **argv, struct nl
unsigned rate = 0;
int wlog;
__u8 sbuf[256];
+ __u32 max_P;
struct rtattr *tail;
memset(&opt, 0, sizeof(opt));
@@ -91,6 +93,8 @@ static int red_parse_opt(struct qdisc_util *qu, int argc, char **argv, struct nl
opt.flags |= TC_RED_ECN;
} else if (strcmp(*argv, "harddrop") == 0) {
opt.flags |= TC_RED_HARDDROP;
+ } else if (strcmp(*argv, "adaptative") == 0) {
+ opt.flags |= TC_RED_ADAPTATIVE;
} else if (strcmp(*argv, "help") == 0) {
explain();
return -1;
@@ -141,6 +145,8 @@ static int red_parse_opt(struct qdisc_util *qu, int argc, char **argv, struct nl
addattr_l(n, 1024, TCA_OPTIONS, NULL, 0);
addattr_l(n, 1024, TCA_RED_PARMS, &opt, sizeof(opt));
addattr_l(n, 1024, TCA_RED_STAB, sbuf, 256);
+ max_P = probability * pow(2, 32);
+ addattr_l(n, 1024, TCA_RED_MAX_P, &max_P, sizeof(max_P));
tail->rta_len = (void *) NLMSG_TAIL(n) - (void *) tail;
return 0;
}
@@ -149,6 +155,7 @@ static int red_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt)
{
struct rtattr *tb[TCA_RED_MAX + 1];
struct tc_red_qopt *qopt;
+ __u32 max_P = 0;
SPRINT_BUF(b1);
SPRINT_BUF(b2);
SPRINT_BUF(b3);
@@ -163,6 +170,11 @@ static int red_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt)
qopt = RTA_DATA(tb[TCA_RED_PARMS]);
if (RTA_PAYLOAD(tb[TCA_RED_PARMS]) < sizeof(*qopt))
return -1;
+
+ if (tb[TCA_RED_MAX_P] &&
+ RTA_PAYLOAD(tb[TCA_RED_MAX_P]) >= sizeof(__u32))
+ max_P = *(__u32 *)RTA_DATA(tb[TCA_RED_MAX_P]);
+
fprintf(f, "limit %s min %s max %s ",
sprint_size(qopt->limit, b1),
sprint_size(qopt->qth_min, b2),
@@ -171,9 +183,15 @@ static int red_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt)
fprintf(f, "ecn ");
if (qopt->flags & TC_RED_HARDDROP)
fprintf(f, "harddrop ");
+ if (qopt->flags & TC_RED_ADAPTATIVE)
+ fprintf(f, "adaptative ");
if (show_details) {
- fprintf(f, "ewma %u Plog %u Scell_log %u",
- qopt->Wlog, qopt->Plog, qopt->Scell_log);
+ fprintf(f, "ewma %u ", qopt->Wlog);
+ if (max_P)
+ fprintf(f, "probability %lg ", max_P / pow(2, 32));
+ else
+ fprintf(f, "Plog %u ", qopt->Plog);
+ fprintf(f, "Scell_log %u", qopt->Scell_log);
}
return 0;
}
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH iproute2] red: Add adaptative algo
2011-12-09 18:30 ` [PATCH iproute2] red: Add adaptative algo Eric Dumazet
@ 2012-01-19 22:47 ` Stephen Hemminger
2012-01-20 1:33 ` Jesse Brandeburg
0 siblings, 1 reply; 10+ messages in thread
From: Stephen Hemminger @ 2012-01-19 22:47 UTC (permalink / raw)
To: Eric Dumazet; +Cc: netdev
On Fri, 09 Dec 2011 19:30:59 +0100
Eric Dumazet <eric.dumazet@gmail.com> wrote:
> Enable Adaptative RED algo, using :
>
> tc qdisc ... red limit BYTES ... adaptative ...
>
> Support of high precision probability/max_p setting and reporting, with
> support of old kernels.
>
> With a new kernel, "Plog ..." is replaced in tc output by "probability
> value" :
>
> qdisc red 10: dev eth3 parent 1:1 limit 360Kb min 30Kb max 90Kb ecn ewma
> 5 probability 0.09 Scell_log 15
>
> Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
Applied, but man page also needs update!
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH iproute2] red: Add adaptative algo
2012-01-19 22:47 ` Stephen Hemminger
@ 2012-01-20 1:33 ` Jesse Brandeburg
2012-01-20 3:21 ` Stephen Hemminger
2012-01-20 6:29 ` [PATCH iproute2] red: Add adaptative algo Eric Dumazet
0 siblings, 2 replies; 10+ messages in thread
From: Jesse Brandeburg @ 2012-01-20 1:33 UTC (permalink / raw)
To: Stephen Hemminger; +Cc: Eric Dumazet, netdev
On Thu, 19 Jan 2012 14:47:11 -0800
Stephen Hemminger <shemminger@vyatta.com> wrote:
> On Fri, 09 Dec 2011 19:30:59 +0100
> Eric Dumazet <eric.dumazet@gmail.com> wrote:
>
> > Enable Adaptative RED algo, using :
> >
> > tc qdisc ... red limit BYTES ... adaptative ...
...
>
> Applied, but man page also needs update!
nit, but, if at all possible can you please spell "adaptive" correctly
especially since this is in a user interface. I can send a patch but
was not going to get to it immediately and wanted to mention it.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH iproute2] red: Add adaptative algo
2012-01-20 1:33 ` Jesse Brandeburg
@ 2012-01-20 3:21 ` Stephen Hemminger
2012-01-20 15:10 ` [PATCH iproute2] red: fix adaptive spelling Eric Dumazet
2012-01-20 6:29 ` [PATCH iproute2] red: Add adaptative algo Eric Dumazet
1 sibling, 1 reply; 10+ messages in thread
From: Stephen Hemminger @ 2012-01-20 3:21 UTC (permalink / raw)
To: Jesse Brandeburg; +Cc: Eric Dumazet, netdev
On Thu, 19 Jan 2012 17:33:18 -0800
Jesse Brandeburg <jesse.brandeburg@intel.com> wrote:
> On Thu, 19 Jan 2012 14:47:11 -0800
> Stephen Hemminger <shemminger@vyatta.com> wrote:
>
> > On Fri, 09 Dec 2011 19:30:59 +0100
> > Eric Dumazet <eric.dumazet@gmail.com> wrote:
> >
> > > Enable Adaptative RED algo, using :
> > >
> > > tc qdisc ... red limit BYTES ... adaptative ...
>
> ...
>
> >
> > Applied, but man page also needs update!
>
> nit, but, if at all possible can you please spell "adaptive" correctly
> especially since this is in a user interface. I can send a patch but
> was not going to get to it immediately and wanted to mention it.
I will fix the doc, but spellun came from original submission.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH iproute2] red: Add adaptative algo
2012-01-20 1:33 ` Jesse Brandeburg
2012-01-20 3:21 ` Stephen Hemminger
@ 2012-01-20 6:29 ` Eric Dumazet
1 sibling, 0 replies; 10+ messages in thread
From: Eric Dumazet @ 2012-01-20 6:29 UTC (permalink / raw)
To: Jesse Brandeburg; +Cc: Stephen Hemminger, netdev
Le jeudi 19 janvier 2012 à 17:33 -0800, Jesse Brandeburg a écrit :
> nit, but, if at all possible can you please spell "adaptive" correctly
> especially since this is in a user interface. I can send a patch but
> was not going to get to it immediately and wanted to mention it.
Sure we can do that before first release.
Sorry, in French we say "adaptatif" (or adaptative depending on gender)
and I didnt really check english spelling.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH iproute2] red: fix adaptive spelling
2012-01-20 3:21 ` Stephen Hemminger
@ 2012-01-20 15:10 ` Eric Dumazet
0 siblings, 0 replies; 10+ messages in thread
From: Eric Dumazet @ 2012-01-20 15:10 UTC (permalink / raw)
To: Stephen Hemminger; +Cc: Jesse Brandeburg, netdev
Reported-by: Jesse Brandeburg <jesse.brandeburg@intel.com>
Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
---
tc/q_red.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/tc/q_red.c b/tc/q_red.c
index 0e5d228..a4b5175 100644
--- a/tc/q_red.c
+++ b/tc/q_red.c
@@ -28,7 +28,7 @@
static void explain(void)
{
fprintf(stderr, "Usage: ... red limit BYTES [min BYTES] [max BYTES] avpkt BYTES [burst PACKETS]\n");
- fprintf(stderr, " [adaptative] [probability PROBABILITY] bandwidth KBPS\n");
+ fprintf(stderr, " [adaptive] [probability PROBABILITY] bandwidth KBPS\n");
fprintf(stderr, " [ecn] [harddrop]\n");
}
@@ -95,6 +95,8 @@ static int red_parse_opt(struct qdisc_util *qu, int argc, char **argv, struct nl
opt.flags |= TC_RED_HARDDROP;
} else if (strcmp(*argv, "adaptative") == 0) {
opt.flags |= TC_RED_ADAPTATIVE;
+ } else if (strcmp(*argv, "adaptive") == 0) {
+ opt.flags |= TC_RED_ADAPTATIVE;
} else if (strcmp(*argv, "help") == 0) {
explain();
return -1;
@@ -184,7 +186,7 @@ static int red_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt)
if (qopt->flags & TC_RED_HARDDROP)
fprintf(f, "harddrop ");
if (qopt->flags & TC_RED_ADAPTATIVE)
- fprintf(f, "adaptative ");
+ fprintf(f, "adaptive ");
if (show_details) {
fprintf(f, "ewma %u ", qopt->Wlog);
if (max_P)
^ permalink raw reply related [flat|nested] 10+ messages in thread
end of thread, other threads:[~2012-01-20 15:10 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-12-08 23:11 [PATCH iproute2] red: harddrop support and cleanups Eric Dumazet
2011-12-09 0:44 ` Stephen Hemminger
2011-12-09 4:10 ` Eric Dumazet
2011-12-09 17:33 ` Stephen Hemminger
2011-12-09 18:30 ` [PATCH iproute2] red: Add adaptative algo Eric Dumazet
2012-01-19 22:47 ` Stephen Hemminger
2012-01-20 1:33 ` Jesse Brandeburg
2012-01-20 3:21 ` Stephen Hemminger
2012-01-20 15:10 ` [PATCH iproute2] red: fix adaptive spelling Eric Dumazet
2012-01-20 6:29 ` [PATCH iproute2] red: Add adaptative algo Eric Dumazet
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).