{"id":808511,"url":"http://patchwork.ozlabs.org/api/patches/808511/?format=json","web_url":"http://patchwork.ozlabs.org/project/netdev/patch/20170901012646.14939-2-vinicius.gomes@intel.com/","project":{"id":7,"url":"http://patchwork.ozlabs.org/api/projects/7/?format=json","name":"Linux network development","link_name":"netdev","list_id":"netdev.vger.kernel.org","list_email":"netdev@vger.kernel.org","web_url":null,"scm_url":null,"webscm_url":null,"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":true,"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":{"id":389,"url":"http://patchwork.ozlabs.org/api/users/389/?format=json","username":"shemminger","first_name":"stephen","last_name":"hemminger","email":"shemminger@vyatta.com"},"mbox":"http://patchwork.ozlabs.org/project/netdev/patch/20170901012646.14939-2-vinicius.gomes@intel.com/mbox/","series":[{"id":936,"url":"http://patchwork.ozlabs.org/api/series/936/?format=json","web_url":"http://patchwork.ozlabs.org/project/netdev/list/?series=936","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/936/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/808511/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/808511/checks/","tags":{},"related":[],"headers":{"Return-Path":"<netdev-owner@vger.kernel.org>","X-Original-To":"patchwork-incoming@ozlabs.org","Delivered-To":"patchwork-incoming@ozlabs.org","Authentication-Results":"ozlabs.org;\n\tspf=none (mailfrom) smtp.mailfrom=vger.kernel.org\n\t(client-ip=209.132.180.67; helo=vger.kernel.org;\n\tenvelope-from=netdev-owner@vger.kernel.org;\n\treceiver=<UNKNOWN>)","Received":["from vger.kernel.org (vger.kernel.org [209.132.180.67])\n\tby ozlabs.org (Postfix) with ESMTP id 3xk1n21KY6z9sMN\n\tfor <patchwork-incoming@ozlabs.org>;\n\tFri,  1 Sep 2017 11:27:02 +1000 (AEST)","(majordomo@vger.kernel.org) by vger.kernel.org via listexpand\n\tid S1751431AbdIAB1A (ORCPT <rfc822;patchwork-incoming@ozlabs.org>);\n\tThu, 31 Aug 2017 21:27:00 -0400","from mga07.intel.com ([134.134.136.100]:15457 \"EHLO\n\tmga07.intel.com\"\n\trhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP\n\tid S1751409AbdIAB06 (ORCPT <rfc822;netdev@vger.kernel.org>);\n\tThu, 31 Aug 2017 21:26:58 -0400","from fmsmga006.fm.intel.com ([10.253.24.20])\n\tby orsmga105.jf.intel.com with ESMTP; 31 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-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","Cc":"Vinicius Costa Gomes <vinicius.gomes@intel.com>, jhs@mojatatu.com,\n\txiyou.wangcong@gmail.com, jiri@resnulli.us,\n\tintel-wired-lan@lists.osuosl.org, andre.guedes@intel.com,\n\tivan.briano@intel.com, jesus.sanchez-palencia@intel.com,\n\tboon.leong.ong@intel.com, richardcochran@gmail.com","Subject":"[RFC iproute2 2/2] tc: Add support for the CBS qdisc","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>","Sender":"netdev-owner@vger.kernel.org","Precedence":"bulk","List-ID":"<netdev.vger.kernel.org>","X-Mailing-List":"netdev@vger.kernel.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"]}