From mboxrd@z Thu Jan 1 00:00:00 1970 From: David Ahern Subject: Re: [PATCH iproute2 net-next v1 5/6] tc: Add support for configuring the taprio scheduler Date: Wed, 3 Oct 2018 10:36:11 -0600 Message-ID: References: <20180929011050.14056-1-vinicius.gomes@intel.com> <20180929011050.14056-6-vinicius.gomes@intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Cc: jhs@mojatatu.com, xiyou.wangcong@gmail.com, jiri@resnulli.us, jesus.sanchez-palencia@intel.com, ilias.apalodimas@linaro.org, simon.fok@baesystems.com To: Vinicius Costa Gomes , netdev@vger.kernel.org Return-path: Received: from mail-pf1-f194.google.com ([209.85.210.194]:43815 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726835AbeJCXZW (ORCPT ); Wed, 3 Oct 2018 19:25:22 -0400 Received: by mail-pf1-f194.google.com with SMTP id p24-v6so1936417pff.10 for ; Wed, 03 Oct 2018 09:36:14 -0700 (PDT) In-Reply-To: <20180929011050.14056-6-vinicius.gomes@intel.com> Content-Language: en-US Sender: netdev-owner@vger.kernel.org List-ID: On 9/28/18 7:10 PM, Vinicius Costa Gomes wrote: > This traffic scheduler allows traffic classes states (transmission > allowed/not allowed, in the simplest case) to be scheduled, according > to a pre-generated time sequence. This is the basis of the IEEE > 802.1Qbv specification. > > Example configuration: > > tc qdisc replace dev enp3s0 parent root handle 100 taprio \ > num_tc 3 \ > map 2 2 1 0 2 2 2 2 2 2 2 2 2 2 2 2 \ > queues 1@0 1@1 2@2 \ > base-time 1528743495910289987 \ > sched-entry S 01 300000 \ > sched-entry S 02 300000 \ > sched-entry S 04 300000 \ > clockid CLOCK_TAI > > The configuration format is similar to mqprio. The main difference is > the presence of a schedule, built by multiple "sched-entry" > definitions, each entry has the following format: > > sched-entry > > The only supported is "S", which means "SetGateStates", ... > +static int str_to_entry_cmd(const char *str) > +{ > + if (strcmp(str, "S") == 0) > + return TC_TAPRIO_CMD_SET_GATES; > + > + if (strcmp(str, "H") == 0) > + return TC_TAPRIO_CMD_SET_AND_HOLD; > + > + if (strcmp(str, "R") == 0) > + return TC_TAPRIO_CMD_SET_AND_RELEASE; If 'S' is the only supported command, what are 'H' and 'R'? > + > + return -1; > +} > + > + > +static const char *command_to_str(__u8 cmd) > +{ > + switch (cmd) { > + case TC_TAPRIO_CMD_SET_GATES: > + return "S"; > + case TC_TAPRIO_CMD_SET_AND_HOLD: > + return "H"; > + case TC_TAPRIO_CMD_SET_AND_RELEASE: > + return "R"; > + default: > + return "Invalid"; > + } > +} And can you keep str-to-command and command-to-str helpers close together in the code.