From mboxrd@z Thu Jan 1 00:00:00 1970 From: Stephen Hemminger Subject: Re: [RFC iproute2-next v1 5/5] tc: Add support for configuring the taprio scheduler Date: Sat, 14 Jul 2018 12:19:21 -0700 Message-ID: <20180714121921.09af3017@shemminger-XPS-13-9360> References: <20180714000611.1179-1-vinicius.gomes@intel.com> <20180714000611.1179-6-vinicius.gomes@intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Cc: netdev@vger.kernel.org, jhs@mojatatu.com, xiyou.wangcong@gmail.com, jiri@resnulli.us, jesus.sanchez-palencia@intel.com To: Vinicius Costa Gomes Return-path: Received: from mail-pl0-f67.google.com ([209.85.160.67]:35327 "EHLO mail-pl0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727315AbeGNTkG (ORCPT ); Sat, 14 Jul 2018 15:40:06 -0400 Received: by mail-pl0-f67.google.com with SMTP id w3-v6so447720plq.2 for ; Sat, 14 Jul 2018 12:20:04 -0700 (PDT) In-Reply-To: <20180714000611.1179-6-vinicius.gomes@intel.com> Sender: netdev-owner@vger.kernel.org List-ID: On Fri, 13 Jul 2018 17:06:11 -0700 Vinicius Costa Gomes wrote: > + while (fscanf(f, "%ms %x %" PRIu32 "\n", &cmd_str, &gatemask, &interval) != EOF) { > + struct rtattr *entry; > + > + err = str_to_entry_cmd(cmd_str); > + free(cmd_str); > + > + if (err < 0) > + return err; > + > + cmd = err; > + > + entry = addattr_nest(n, 1024, TCA_TAPRIO_SCHED_ENTRY); > + > + addattr_l(n, 1024, TCA_TAPRIO_SCHED_ENTRY_INDEX, &index, sizeof(index)); > + addattr_l(n, 1024, TCA_TAPRIO_SCHED_ENTRY_CMD, &cmd, sizeof(cmd)); > + addattr_l(n, 1024, TCA_TAPRIO_SCHED_ENTRY_GATE_MASK, &gatemask, sizeof(gatemask)); > + addattr_l(n, 1024, TCA_TAPRIO_SCHED_ENTRY_INTERVAL, &interval, sizeof(interval)); > + > + addattr_nest_end(n, entry); > + } > + Why not just use batch mode? Introducing another input mode in tc that is only in one qdisc seems like a bad idea. > + > +static int taprio_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt) > +{ > + struct rtattr *tb[TCA_TAPRIO_ATTR_MAX + 1]; > + struct tc_mqprio_qopt *qopt = 0; > + __s64 cycle_time = 0, extension_time = 0, base_time = 0; > + __s32 clockid = CLOCKID_INVALID; > + __u32 preempt_mask = 0; > + int i; > + > + if (opt == NULL) > + return 0; > + > + parse_rtattr_nested(tb, TCA_TAPRIO_ATTR_MAX, opt); > + > + if (tb[TCA_TAPRIO_ATTR_PRIOMAP] == NULL) > + return -1; > + > + qopt = RTA_DATA(tb[TCA_TAPRIO_ATTR_PRIOMAP]); > + > + fprintf(f, "tc %u map ", qopt->num_tc); > + for (i = 0; i <= TC_PRIO_MAX; i++) > + fprintf(f, "%u ", qopt->prio_tc_map[i]); > + fprintf(f, "\n queues:"); > + for (i = 0; i < qopt->num_tc; i++) > + fprintf(f, "(%u:%u) ", qopt->offset[i], > + qopt->offset[i] + qopt->count[i] - 1); > + > + if (tb[TCA_TAPRIO_ATTR_SCHED_CYCLE_TIME]) > + cycle_time = rta_getattr_s64(tb[TCA_TAPRIO_ATTR_SCHED_CYCLE_TIME]); > + > + if (tb[TCA_TAPRIO_ATTR_SCHED_EXTENSION_TIME]) > + extension_time = rta_getattr_s64(tb[TCA_TAPRIO_ATTR_SCHED_EXTENSION_TIME]); > + > + if (tb[TCA_TAPRIO_ATTR_SCHED_BASE_TIME]) > + base_time = rta_getattr_s64(tb[TCA_TAPRIO_ATTR_SCHED_BASE_TIME]); > + > + if (tb[TCA_TAPRIO_ATTR_PREEMPT_MASK]) > + preempt_mask = rta_getattr_s64(tb[TCA_TAPRIO_ATTR_PREEMPT_MASK]); > + > + if (tb[TCA_TAPRIO_ATTR_SCHED_CLOCKID]) > + clockid = rta_getattr_s32(tb[TCA_TAPRIO_ATTR_SCHED_CLOCKID]); > + > + fprintf(f, "\n clockid %s ", get_clock_name(clockid)); > + > + fprintf(f, "\n base-time %lld cycle-time %lld extension-time %lld ", > + base_time, cycle_time, extension_time); > + > + fprintf(f, "\n preempt-mask 0x%x ", preempt_mask); > + > + return print_sched_list(f, tb[TCA_TAPRIO_ATTR_SCHED_ENTRY_LIST]); Please implement JSON output using json_print functions.