From patchwork Fri Jan 20 15:19:44 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Dumazet X-Patchwork-Id: 137038 X-Patchwork-Delegate: shemminger@vyatta.com Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3A8581007D5 for ; Sat, 21 Jan 2012 02:19:50 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753896Ab2ATPTs (ORCPT ); Fri, 20 Jan 2012 10:19:48 -0500 Received: from mail-wi0-f174.google.com ([209.85.212.174]:59420 "EHLO mail-wi0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753626Ab2ATPTr (ORCPT ); Fri, 20 Jan 2012 10:19:47 -0500 Received: by wics10 with SMTP id s10so504816wic.19 for ; Fri, 20 Jan 2012 07:19:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=message-id:subject:from:to:cc:date:content-type:x-mailer :content-transfer-encoding:mime-version; bh=MBKPCEyNhMN81SPef2JhGVoF5sORyho5bQgCBOEBFaA=; b=d0lxWiNlt7EurHmMeBwfd+XdEdDLE5DQRFOjK62amv9qOPfnZRhm51NVlR/5TUXhyh i52UmChdSpsF+YYf7yec0evtNFaOBYJSlAu+3kShzuQSIOdKcBROlQVgX2WH91p6zSFK rCW+21X0/ssuN/K5gEO8YlqNUL8OWFwvpWiKo= Received: by 10.180.109.77 with SMTP id hq13mr4551597wib.7.1327072786543; Fri, 20 Jan 2012 07:19:46 -0800 (PST) Received: from [10.150.51.219] (gw0.net.jmsp.net. [212.23.165.14]) by mx.google.com with ESMTPS id l2sm9982147wie.11.2012.01.20.07.19.45 (version=SSLv3 cipher=OTHER); Fri, 20 Jan 2012 07:19:45 -0800 (PST) Message-ID: <1327072784.12389.22.camel@edumazet-HP-Compaq-6005-Pro-SFF-PC> Subject: [PATCH iproute2] choke: support TCA_CHOKE_MAX_P From: Eric Dumazet To: Stephen Hemminger Cc: netdev Date: Fri, 20 Jan 2012 16:19:44 +0100 X-Mailer: Evolution 3.2.1- Mime-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org TCA_CHOKE_MAX_P permits to express high resolution RED probability. tc qdisc add dev $DEV parent 1:1 handle 10: est 1sec 8sec choke \ limit 90 ecn min 10 max 30 probability 0.05 bandwidth 10Mbit Before patch : tc -s -d qdisc show dev eth3 qdisc ... limit 90p min 10p max 30p ecn ewma 3 Plog 19 Scell_log 13 After : qdisc ... limit 90p min 10p max 30p ecn ewma 3 probability 0.05 Scell_log 13 Signed-off-by: Eric Dumazet --- tc/q_choke.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/tc/q_choke.c b/tc/q_choke.c index 7816f62..c616926 100644 --- a/tc/q_choke.c +++ b/tc/q_choke.c @@ -18,6 +18,7 @@ #include #include #include +#include #include "utils.h" #include "tc_util.h" @@ -41,6 +42,7 @@ static int choke_parse_opt(struct qdisc_util *qu, int argc, char **argv, int ecn_ok = 0; int wlog; __u8 sbuf[256]; + __u32 max_P; struct rtattr *tail; memset(&opt, 0, sizeof(opt)); @@ -156,25 +158,31 @@ static int choke_parse_opt(struct qdisc_util *qu, int argc, char **argv, addattr_l(n, 1024, TCA_OPTIONS, NULL, 0); addattr_l(n, 1024, TCA_CHOKE_PARMS, &opt, sizeof(opt)); addattr_l(n, 1024, TCA_CHOKE_STAB, sbuf, 256); + max_P = probability * pow(2, 32); + addattr_l(n, 1024, TCA_CHOKE_MAX_P, &max_P, sizeof(max_P)); tail->rta_len = (void *) NLMSG_TAIL(n) - (void *) tail; return 0; } static int choke_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt) { - struct rtattr *tb[TCA_CHOKE_STAB+1]; + struct rtattr *tb[TCA_CHOKE_MAX+1]; const struct tc_red_qopt *qopt; + __u32 max_P = 0; if (opt == NULL) return 0; - parse_rtattr_nested(tb, TCA_CHOKE_STAB, opt); + parse_rtattr_nested(tb, TCA_CHOKE_MAX, opt); if (tb[TCA_CHOKE_PARMS] == NULL) return -1; qopt = RTA_DATA(tb[TCA_CHOKE_PARMS]); if (RTA_PAYLOAD(tb[TCA_CHOKE_PARMS]) < sizeof(*qopt)) return -1; + if (tb[TCA_CHOKE_MAX_P] && + RTA_PAYLOAD(tb[TCA_CHOKE_MAX_P]) >= sizeof(__u32)) + max_P = *(__u32 *)RTA_DATA(tb[TCA_CHOKE_MAX_P]); fprintf(f, "limit %up min %up max %up ", qopt->limit, qopt->qth_min, qopt->qth_max); @@ -183,8 +191,12 @@ static int choke_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt) fprintf(f, "ecn "); 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 %g ", max_P / pow(2, 32)); + else + fprintf(f, "Plog %u ", qopt->Plog); + fprintf(f, "Scell_log %u", qopt->Scell_log); } return 0; }