{"id":809016,"url":"http://patchwork.ozlabs.org/api/patches/809016/?format=json","web_url":"http://patchwork.ozlabs.org/project/intel-wired-lan/patch/20170901012646.14939-2-vinicius.gomes@intel.com/","project":{"id":46,"url":"http://patchwork.ozlabs.org/api/projects/46/?format=json","name":"Intel Wired Ethernet development","link_name":"intel-wired-lan","list_id":"intel-wired-lan.osuosl.org","list_email":"intel-wired-lan@osuosl.org","web_url":"","scm_url":"","webscm_url":"","list_archive_url":"","list_archive_url_format":"","commit_url_format":""},"msgid":"<20170901012646.14939-2-vinicius.gomes@intel.com>","list_archive_url":null,"date":"2017-09-01T01:26:46","name":"[RFC,iproute2,2/2] tc: Add support for the CBS qdisc","commit_ref":null,"pull_url":null,"state":"rfc","archived":false,"hash":"c83637f255d6b6d1b2aa5e23a1610ba44c54873c","submitter":{"id":72272,"url":"http://patchwork.ozlabs.org/api/people/72272/?format=json","name":"Vinicius Costa Gomes","email":"vinicius.gomes@intel.com"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/intel-wired-lan/patch/20170901012646.14939-2-vinicius.gomes@intel.com/mbox/","series":[{"id":1121,"url":"http://patchwork.ozlabs.org/api/series/1121/?format=json","web_url":"http://patchwork.ozlabs.org/project/intel-wired-lan/list/?series=1121","date":"2017-09-01T01:26:45","name":"[RFC,iproute2,1/2] update headers with CBS API [RFC]","version":1,"mbox":"http://patchwork.ozlabs.org/series/1121/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/809016/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/809016/checks/","tags":{},"related":[],"headers":{"Return-Path":"<intel-wired-lan-bounces@osuosl.org>","X-Original-To":["incoming@patchwork.ozlabs.org","intel-wired-lan@lists.osuosl.org"],"Delivered-To":["patchwork-incoming@bilbo.ozlabs.org","intel-wired-lan@lists.osuosl.org"],"Authentication-Results":"ozlabs.org;\n\tspf=pass (mailfrom) smtp.mailfrom=osuosl.org\n\t(client-ip=140.211.166.136; helo=silver.osuosl.org;\n\tenvelope-from=intel-wired-lan-bounces@osuosl.org;\n\treceiver=<UNKNOWN>)","Received":["from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136])\n\t(using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3xkXMF4699z9sPt\n\tfor <incoming@patchwork.ozlabs.org>;\n\tSat,  2 Sep 2017 07:24:57 +1000 (AEST)","from localhost (localhost [127.0.0.1])\n\tby silver.osuosl.org (Postfix) with ESMTP id 1C0CB30BD0;\n\tFri,  1 Sep 2017 21:24:56 +0000 (UTC)","from silver.osuosl.org ([127.0.0.1])\n\tby localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024)\n\twith ESMTP id KEdNmi-S1zeQ; Fri,  1 Sep 2017 21:24:52 +0000 (UTC)","from ash.osuosl.org (ash.osuosl.org [140.211.166.34])\n\tby silver.osuosl.org (Postfix) with ESMTP id A8FCB30BD8;\n\tFri,  1 Sep 2017 21:24:49 +0000 (UTC)","from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137])\n\tby ash.osuosl.org (Postfix) with ESMTP id BD24F1CEAE4\n\tfor <intel-wired-lan@lists.osuosl.org>;\n\tFri,  1 Sep 2017 01:27:00 +0000 (UTC)","from localhost (localhost [127.0.0.1])\n\tby fraxinus.osuosl.org (Postfix) with ESMTP id B517F87A5D\n\tfor <intel-wired-lan@lists.osuosl.org>;\n\tFri,  1 Sep 2017 01:27:00 +0000 (UTC)","from fraxinus.osuosl.org ([127.0.0.1])\n\tby localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024)\n\twith ESMTP id kR7QKjgnmqIX for <intel-wired-lan@lists.osuosl.org>;\n\tFri,  1 Sep 2017 01:26:58 +0000 (UTC)","from mga04.intel.com (mga04.intel.com [192.55.52.120])\n\tby fraxinus.osuosl.org (Postfix) with ESMTPS id 6CF2487A9D\n\tfor <intel-wired-lan@lists.osuosl.org>;\n\tFri,  1 Sep 2017 01:26:58 +0000 (UTC)","from fmsmga006.fm.intel.com ([10.253.24.20])\n\tby fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384;\n\t31 Aug 2017 18:26:57 -0700","from ellie.jf.intel.com (HELO localhost.localdomain)\n\t([10.24.8.207])\n\tby fmsmga006.fm.intel.com with ESMTP; 31 Aug 2017 18:26:57 -0700"],"X-Virus-Scanned":["amavisd-new at osuosl.org","amavisd-new at osuosl.org"],"X-Greylist":"domain auto-whitelisted by SQLgrey-1.7.6","X-ExtLoop1":"1","X-IronPort-AV":"E=Sophos;i=\"5.41,456,1498546800\"; d=\"scan'208\";a=\"146934380\"","From":"Vinicius Costa Gomes <vinicius.gomes@intel.com>","To":"netdev@vger.kernel.org","Date":"Thu, 31 Aug 2017 18:26:46 -0700","Message-Id":"<20170901012646.14939-2-vinicius.gomes@intel.com>","X-Mailer":"git-send-email 2.14.1","In-Reply-To":"<20170901012646.14939-1-vinicius.gomes@intel.com>","References":"<20170901012646.14939-1-vinicius.gomes@intel.com>","X-Mailman-Approved-At":"Fri, 01 Sep 2017 21:24:44 +0000","Cc":"andre.guedes@intel.com, jiri@resnulli.us, ivan.briano@intel.com,\n\tVinicius Costa Gomes <vinicius.gomes@intel.com>,\n\trichardcochran@gmail.com, \n\tjhs@mojatatu.com, intel-wired-lan@lists.osuosl.org,\n\tboon.leong.ong@intel.com, \n\txiyou.wangcong@gmail.com, jesus.sanchez-palencia@intel.com","Subject":"[Intel-wired-lan] [RFC iproute2 2/2] tc: Add support for the CBS\n\tqdisc","X-BeenThere":"intel-wired-lan@osuosl.org","X-Mailman-Version":"2.1.18-1","Precedence":"list","List-Id":"Intel Wired Ethernet Linux Kernel Driver Development\n\t<intel-wired-lan.osuosl.org>","List-Unsubscribe":"<https://lists.osuosl.org/mailman/options/intel-wired-lan>, \n\t<mailto:intel-wired-lan-request@osuosl.org?subject=unsubscribe>","List-Archive":"<http://lists.osuosl.org/pipermail/intel-wired-lan/>","List-Post":"<mailto:intel-wired-lan@osuosl.org>","List-Help":"<mailto:intel-wired-lan-request@osuosl.org?subject=help>","List-Subscribe":"<https://lists.osuosl.org/mailman/listinfo/intel-wired-lan>, \n\t<mailto:intel-wired-lan-request@osuosl.org?subject=subscribe>","MIME-Version":"1.0","Content-Type":"text/plain; charset=\"us-ascii\"","Content-Transfer-Encoding":"7bit","Errors-To":"intel-wired-lan-bounces@osuosl.org","Sender":"\"Intel-wired-lan\" <intel-wired-lan-bounces@osuosl.org>"},"content":"The Credit Based Shaper (CBS) queueing discipline allows bandwidth\nreservation with sub-milisecond precision. It is defined by the\n802.1Q-2014 specification (section 8.6.8.2 and Annex L).\n\nThe syntax is:\n\ntc qdisc add dev DEV parent NODE cbs locredit <LOCREDIT> hicredit\n<HICREDIT> sendslope <SENDSLOPE> idleslope <IDLESLOPE>\n\nSigned-off-by: Vinicius Costa Gomes <vinicius.gomes@intel.com>\n---\n tc/Makefile |   1 +\n tc/q_cbs.c  | 134 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n 2 files changed, 135 insertions(+)\n create mode 100644 tc/q_cbs.c","diff":"diff --git a/tc/Makefile b/tc/Makefile\nindex a9b4b8e6..f0091217 100644\n--- a/tc/Makefile\n+++ b/tc/Makefile\n@@ -73,6 +73,7 @@ TCMODULES += q_hhf.o\n TCMODULES += q_clsact.o\n TCMODULES += e_bpf.o\n TCMODULES += f_matchall.o\n+TCMODULES += q_cbs.o\n \n TCSO :=\n ifeq ($(TC_CONFIG_ATM),y)\ndiff --git a/tc/q_cbs.c b/tc/q_cbs.c\nnew file mode 100644\nindex 00000000..0120e838\n--- /dev/null\n+++ b/tc/q_cbs.c\n@@ -0,0 +1,134 @@\n+/*\n+ * q_tbf.c\t\tTBF.\n+ *\n+ *\t\tThis program is free software; you can redistribute it and/or\n+ *\t\tmodify it under the terms of the GNU General Public License\n+ *\t\tas published by the Free Software Foundation; either version\n+ *\t\t2 of the License, or (at your option) any later version.\n+ *\n+ * Authors:\tAlexey Kuznetsov, <kuznet@ms2.inr.ac.ru>\n+ *\n+ */\n+\n+#include <stdio.h>\n+#include <stdlib.h>\n+#include <unistd.h>\n+#include <syslog.h>\n+#include <fcntl.h>\n+#include <sys/socket.h>\n+#include <netinet/in.h>\n+#include <arpa/inet.h>\n+#include <string.h>\n+\n+#include \"utils.h\"\n+#include \"tc_util.h\"\n+\n+static void explain(void)\n+{\n+\tfprintf(stderr, \"Usage: ... tbf hicredit BYTES locredit BYTES sendslope BPS idleslope BPS\\n\");\n+}\n+\n+static void explain1(const char *arg, const char *val)\n+{\n+\tfprintf(stderr, \"cbs: illegal value for \\\"%s\\\": \\\"%s\\\"\\n\", arg, val);\n+}\n+\n+static int cbs_parse_opt(struct qdisc_util *qu, int argc, char **argv, struct nlmsghdr *n)\n+{\n+\tint ok = 0;\n+\tstruct tc_cbs_qopt opt = {};\n+\tstruct rtattr *tail;\n+\n+\twhile (argc > 0) {\n+\t\tif (matches(*argv, \"hicredit\") == 0) {\n+\t\t\tNEXT_ARG();\n+\t\t\tif (opt.hicredit) {\n+\t\t\t\tfprintf(stderr, \"cbs: duplicate \\\"hicredit\\\" specification\\n\");\n+\t\t\t\treturn -1;\n+\t\t\t}\n+\t\t\tif (get_s32(&opt.hicredit, *argv, 0)) {\n+\t\t\t\texplain1(\"hicredit\", *argv);\n+\t\t\t\treturn -1;\n+\t\t\t}\n+\t\t\tok++;\n+\t\t} else if (matches(*argv, \"locredit\") == 0) {\n+\t\t\tNEXT_ARG();\n+\t\t\tif (opt.locredit) {\n+\t\t\t\tfprintf(stderr, \"cbs: duplicate \\\"locredit\\\" specification\\n\");\n+\t\t\t\treturn -1;\n+\t\t\t}\n+\t\t\tif (get_s32(&opt.locredit, *argv, 0)) {\n+\t\t\t\texplain1(\"locredit\", *argv);\n+\t\t\t\treturn -1;\n+\t\t\t}\n+\t\t\tok++;\n+\t\t} else if (matches(*argv, \"sendslope\") == 0) {\n+\t\t\tNEXT_ARG();\n+\t\t\tif (opt.sendslope) {\n+\t\t\t\tfprintf(stderr, \"cbs: duplicate \\\"sendslope\\\" specification\\n\");\n+\t\t\t\treturn -1;\n+\t\t\t}\n+\t\t\tif (get_s32(&opt.sendslope, *argv, 0)) {\n+\t\t\t\texplain1(\"sendslope\", *argv);\n+\t\t\t\treturn -1;\n+\t\t\t}\n+\t\t\tok++;\n+\t\t} else if (matches(*argv, \"idleslope\") == 0) {\n+\t\t\tNEXT_ARG();\n+\t\t\tif (opt.idleslope) {\n+\t\t\t\tfprintf(stderr, \"cbs: duplicate \\\"idleslope\\\" specification\\n\");\n+\t\t\t\treturn -1;\n+\t\t\t}\n+\t\t\tif (get_s32(&opt.idleslope, *argv, 0)) {\n+\t\t\t\texplain1(\"idleslope\", *argv);\n+\t\t\t\treturn -1;\n+\t\t\t}\n+\t\t\tok++;\n+\t\t} else if (strcmp(*argv, \"help\") == 0) {\n+\t\t\texplain();\n+\t\t\treturn -1;\n+\t\t} else {\n+\t\t\tfprintf(stderr, \"cbs: unknown parameter \\\"%s\\\"\\n\", *argv);\n+\t\t\texplain();\n+\t\t\treturn -1;\n+\t\t}\n+\t\targc--; argv++;\n+\t}\n+\n+\ttail = NLMSG_TAIL(n);\n+\taddattr_l(n, 1024, TCA_OPTIONS, NULL, 0);\n+\taddattr_l(n, 2024, TCA_CBS_PARMS, &opt, sizeof(opt));\n+\ttail->rta_len = (void *) NLMSG_TAIL(n) - (void *) tail;\n+\treturn 0;\n+}\n+\n+static int cbs_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt)\n+{\n+\tstruct rtattr *tb[TCA_TBF_MAX+1];\n+\tstruct tc_cbs_qopt *qopt;\n+\n+\tif (opt == NULL)\n+\t\treturn 0;\n+\n+\tparse_rtattr_nested(tb, TCA_CBS_MAX, opt);\n+\n+\tif (tb[TCA_CBS_PARMS] == NULL)\n+\t\treturn -1;\n+\n+\tqopt = RTA_DATA(tb[TCA_CBS_PARMS]);\n+\tif (RTA_PAYLOAD(tb[TCA_CBS_PARMS])  < sizeof(*qopt))\n+\t\treturn -1;\n+\n+\tfprintf(f, \"hicredit %d \", qopt->hicredit);\n+\tfprintf(f, \"locredit %d \", qopt->locredit);\n+\tfprintf(f, \"sendslope %d \", qopt->sendslope);\n+\tfprintf(f, \"idleslope %d \", qopt->idleslope);\n+\n+\treturn 0;\n+}\n+\n+struct qdisc_util cbs_qdisc_util = {\n+\t.id\t\t= \"cbs\",\n+\t.parse_qopt\t= cbs_parse_opt,\n+\t.print_qopt\t= cbs_print_opt,\n+};\n","prefixes":["RFC","iproute2","2/2"]}