public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
* [RFC v3 iproute2 1/3] include: Add ptp_clock.h to linux uapi
@ 2018-03-07  1:16 Jesus Sanchez-Palencia
  2018-03-07  1:16 ` [RFC v3 iproute2 2/3] uapi pkt_sched: Add tbs info - DO NOT COMMIT Jesus Sanchez-Palencia
  2018-03-07  1:16 ` [RFC v3 iproute2 3/3] tc: Add support for the TBS Qdisc Jesus Sanchez-Palencia
  0 siblings, 2 replies; 6+ messages in thread
From: Jesus Sanchez-Palencia @ 2018-03-07  1:16 UTC (permalink / raw)
  To: netdev; +Cc: jhs, xiyou.wangcong, jiri, Jesus Sanchez-Palencia

This header will be used by the new tc-tbs qdisc.
It was copied from kernel tag 4.16.0-rc2.

Signed-off-by: Jesus Sanchez-Palencia <jesus.sanchez-palencia@intel.com>
---
 include/uapi/linux/ptp_clock.h | 147 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 147 insertions(+)
 create mode 100644 include/uapi/linux/ptp_clock.h

diff --git a/include/uapi/linux/ptp_clock.h b/include/uapi/linux/ptp_clock.h
new file mode 100644
index 00000000..3039bf6a
--- /dev/null
+++ b/include/uapi/linux/ptp_clock.h
@@ -0,0 +1,147 @@
+/* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */
+/*
+ * PTP 1588 clock support - user space interface
+ *
+ * Copyright (C) 2010 OMICRON electronics GmbH
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#ifndef _PTP_CLOCK_H_
+#define _PTP_CLOCK_H_
+
+#include <linux/ioctl.h>
+#include <linux/types.h>
+
+/* PTP_xxx bits, for the flags field within the request structures. */
+#define PTP_ENABLE_FEATURE (1<<0)
+#define PTP_RISING_EDGE    (1<<1)
+#define PTP_FALLING_EDGE   (1<<2)
+
+/*
+ * struct ptp_clock_time - represents a time value
+ *
+ * The sign of the seconds field applies to the whole value. The
+ * nanoseconds field is always unsigned. The reserved field is
+ * included for sub-nanosecond resolution, should the demand for
+ * this ever appear.
+ *
+ */
+struct ptp_clock_time {
+	__s64 sec;  /* seconds */
+	__u32 nsec; /* nanoseconds */
+	__u32 reserved;
+};
+
+struct ptp_clock_caps {
+	int max_adj;   /* Maximum frequency adjustment in parts per billon. */
+	int n_alarm;   /* Number of programmable alarms. */
+	int n_ext_ts;  /* Number of external time stamp channels. */
+	int n_per_out; /* Number of programmable periodic signals. */
+	int pps;       /* Whether the clock supports a PPS callback. */
+	int n_pins;    /* Number of input/output pins. */
+	/* Whether the clock supports precise system-device cross timestamps */
+	int cross_timestamping;
+	int rsv[13];   /* Reserved for future use. */
+};
+
+struct ptp_extts_request {
+	unsigned int index;  /* Which channel to configure. */
+	unsigned int flags;  /* Bit field for PTP_xxx flags. */
+	unsigned int rsv[2]; /* Reserved for future use. */
+};
+
+struct ptp_perout_request {
+	struct ptp_clock_time start;  /* Absolute start time. */
+	struct ptp_clock_time period; /* Desired period, zero means disable. */
+	unsigned int index;           /* Which channel to configure. */
+	unsigned int flags;           /* Reserved for future use. */
+	unsigned int rsv[4];          /* Reserved for future use. */
+};
+
+#define PTP_MAX_SAMPLES 25 /* Maximum allowed offset measurement samples. */
+
+struct ptp_sys_offset {
+	unsigned int n_samples; /* Desired number of measurements. */
+	unsigned int rsv[3];    /* Reserved for future use. */
+	/*
+	 * Array of interleaved system/phc time stamps. The kernel
+	 * will provide 2*n_samples + 1 time stamps, with the last
+	 * one as a system time stamp.
+	 */
+	struct ptp_clock_time ts[2 * PTP_MAX_SAMPLES + 1];
+};
+
+struct ptp_sys_offset_precise {
+	struct ptp_clock_time device;
+	struct ptp_clock_time sys_realtime;
+	struct ptp_clock_time sys_monoraw;
+	unsigned int rsv[4];    /* Reserved for future use. */
+};
+
+enum ptp_pin_function {
+	PTP_PF_NONE,
+	PTP_PF_EXTTS,
+	PTP_PF_PEROUT,
+	PTP_PF_PHYSYNC,
+};
+
+struct ptp_pin_desc {
+	/*
+	 * Hardware specific human readable pin name. This field is
+	 * set by the kernel during the PTP_PIN_GETFUNC ioctl and is
+	 * ignored for the PTP_PIN_SETFUNC ioctl.
+	 */
+	char name[64];
+	/*
+	 * Pin index in the range of zero to ptp_clock_caps.n_pins - 1.
+	 */
+	unsigned int index;
+	/*
+	 * Which of the PTP_PF_xxx functions to use on this pin.
+	 */
+	unsigned int func;
+	/*
+	 * The specific channel to use for this function.
+	 * This corresponds to the 'index' field of the
+	 * PTP_EXTTS_REQUEST and PTP_PEROUT_REQUEST ioctls.
+	 */
+	unsigned int chan;
+	/*
+	 * Reserved for future use.
+	 */
+	unsigned int rsv[5];
+};
+
+#define PTP_CLK_MAGIC '='
+
+#define PTP_CLOCK_GETCAPS  _IOR(PTP_CLK_MAGIC, 1, struct ptp_clock_caps)
+#define PTP_EXTTS_REQUEST  _IOW(PTP_CLK_MAGIC, 2, struct ptp_extts_request)
+#define PTP_PEROUT_REQUEST _IOW(PTP_CLK_MAGIC, 3, struct ptp_perout_request)
+#define PTP_ENABLE_PPS     _IOW(PTP_CLK_MAGIC, 4, int)
+#define PTP_SYS_OFFSET     _IOW(PTP_CLK_MAGIC, 5, struct ptp_sys_offset)
+#define PTP_PIN_GETFUNC    _IOWR(PTP_CLK_MAGIC, 6, struct ptp_pin_desc)
+#define PTP_PIN_SETFUNC    _IOW(PTP_CLK_MAGIC, 7, struct ptp_pin_desc)
+#define PTP_SYS_OFFSET_PRECISE \
+	_IOWR(PTP_CLK_MAGIC, 8, struct ptp_sys_offset_precise)
+
+struct ptp_extts_event {
+	struct ptp_clock_time t; /* Time event occured. */
+	unsigned int index;      /* Which channel produced the event. */
+	unsigned int flags;      /* Reserved for future use. */
+	unsigned int rsv[2];     /* Reserved for future use. */
+};
+
+#endif
-- 
2.16.2

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [RFC v3 iproute2 2/3] uapi pkt_sched: Add tbs info - DO NOT COMMIT
  2018-03-07  1:16 [RFC v3 iproute2 1/3] include: Add ptp_clock.h to linux uapi Jesus Sanchez-Palencia
@ 2018-03-07  1:16 ` Jesus Sanchez-Palencia
  2018-03-07  1:16 ` [RFC v3 iproute2 3/3] tc: Add support for the TBS Qdisc Jesus Sanchez-Palencia
  1 sibling, 0 replies; 6+ messages in thread
From: Jesus Sanchez-Palencia @ 2018-03-07  1:16 UTC (permalink / raw)
  To: netdev; +Cc: jhs, xiyou.wangcong, jiri, Jesus Sanchez-Palencia

This should come from the next uapi headers update.
Sending it now just as a convenience so anyone can build tc with tbs
support.

Signed-off-by: Jesus Sanchez-Palencia <jesus.sanchez-palencia@intel.com>
---
 include/uapi/linux/pkt_sched.h | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/include/uapi/linux/pkt_sched.h b/include/uapi/linux/pkt_sched.h
index 37b5096a..92af9fa4 100644
--- a/include/uapi/linux/pkt_sched.h
+++ b/include/uapi/linux/pkt_sched.h
@@ -934,4 +934,22 @@ enum {
 
 #define TCA_CBS_MAX (__TCA_CBS_MAX - 1)
 
+
+/* TBS */
+struct tc_tbs_qopt {
+	__s32 delta;
+	__s32 clockid;
+	__u32 flags;
+#define TC_TBS_SORTING_ON BIT(0)
+#define TC_TBS_OFFLOAD_ON BIT(1)
+};
+
+enum {
+	TCA_TBS_UNSPEC,
+	TCA_TBS_PARMS,
+	__TCA_TBS_MAX,
+};
+
+#define TCA_TBS_MAX (__TCA_TBS_MAX - 1)
+
 #endif
-- 
2.16.2

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [RFC v3 iproute2 3/3] tc: Add support for the TBS Qdisc
  2018-03-07  1:16 [RFC v3 iproute2 1/3] include: Add ptp_clock.h to linux uapi Jesus Sanchez-Palencia
  2018-03-07  1:16 ` [RFC v3 iproute2 2/3] uapi pkt_sched: Add tbs info - DO NOT COMMIT Jesus Sanchez-Palencia
@ 2018-03-07  1:16 ` Jesus Sanchez-Palencia
  2018-03-07  1:51   ` Stephen Hemminger
  1 sibling, 1 reply; 6+ messages in thread
From: Jesus Sanchez-Palencia @ 2018-03-07  1:16 UTC (permalink / raw)
  To: netdev
  Cc: jhs, xiyou.wangcong, jiri, Vinicius Costa Gomes,
	Jesus Sanchez-Palencia

From: Vinicius Costa Gomes <vinicius.gomes@intel.com>

The Time Based Scheduler (TBS) queueing discipline allows precise
control of the transmission time of packets.

The syntax is:

tc qdisc add dev DEV parent NODE tbs delta <DELTA>
                     clockid <CLOCKID> [offload] [sorting]

Signed-off-by: Vinicius Costa Gomes <vinicius.gomes@intel.com>
Signed-off-by: Jesus Sanchez-Palencia <jesus.sanchez-palencia@intel.com>
---
 tc/Makefile |   1 +
 tc/q_tbs.c  | 200 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 201 insertions(+)
 create mode 100644 tc/q_tbs.c

diff --git a/tc/Makefile b/tc/Makefile
index 3716dd6a..3c87b0dc 100644
--- a/tc/Makefile
+++ b/tc/Makefile
@@ -71,6 +71,7 @@ TCMODULES += q_clsact.o
 TCMODULES += e_bpf.o
 TCMODULES += f_matchall.o
 TCMODULES += q_cbs.o
+TCMODULES += q_tbs.o
 
 TCSO :=
 ifeq ($(TC_CONFIG_ATM),y)
diff --git a/tc/q_tbs.c b/tc/q_tbs.c
new file mode 100644
index 00000000..b0823dc9
--- /dev/null
+++ b/tc/q_tbs.c
@@ -0,0 +1,200 @@
+/*
+ * q_tbs.c		TBS.
+ *
+ *		This program is free software; you can redistribute it and/or
+ *		modify it under the terms of the GNU General Public License
+ *		as published by the Free Software Foundation; either version
+ *		2 of the License, or (at your option) any later version.
+ *
+ * Authors:	Vinicius Costa Gomes <vinicius.gomes@intel.com>
+ *		Jesus Sanchez-Palencia <jesus.sanchez-palencia@intel.com>
+ *
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <sys/ioctl.h>
+#include <sys/socket.h>
+#include <linux/ptp_clock.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+#include <string.h>
+
+#include "utils.h"
+#include "tc_util.h"
+
+/* clockid is invalid if bits 0, 1, 2 are set as described by posix-timers.h */
+#define CLOCKID_INVALID (BIT(0) | BIT(1) | BIT(2))
+#define PTP_MAX_DEV_PATH 16
+
+/* fd to clockid helpers. Copied from posix-timers.h. */
+#define CLOCKFD 3
+static inline clockid_t make_process_cpuclock(const unsigned int pid,
+                const clockid_t clock)
+{
+        return ((~pid) << 3) | clock;
+}
+
+static inline clockid_t fd_to_clockid(const int fd)
+{
+        return make_process_cpuclock((unsigned int) fd, CLOCKFD);
+}
+
+static void explain(void)
+{
+	fprintf(stderr, "Usage: ... tbs delta NANOS clockid CLOCKID [offload] [sorting]\n");
+	fprintf(stderr, "CLOCKID must be a valid SYS-V id (i.e. CLOCK_TAI) or \
+			 a dynamic clock (i.e. /dev/ptp0).\n");
+}
+
+static void explain1(const char *arg, const char *val)
+{
+	fprintf(stderr, "tbs: illegal value for \"%s\": \"%s\"\n", arg, val);
+}
+
+static void explain_clockid(const char *val)
+{
+	fprintf(stderr, "tbs: illegal value for \"clockid\": \"%s\".\n", val);
+	fprintf(stderr, "It must be a valid SYS-V id (i.e. CLOCK_TAI) or "\
+			"dynamic clock (i.e. /dev/ptp0).\n");
+}
+
+static int get_clockid(__s32 *val, const char *arg)
+{
+	const struct static_clockid {
+		const char *name;
+		clockid_t clockid;
+	} clockids_sysv[] = {
+		{ "CLOCK_REALTIME", CLOCK_REALTIME },
+		{ "CLOCK_TAI", CLOCK_TAI },
+		{ "CLOCK_BOOTTIME", CLOCK_BOOTTIME },
+		{ "CLOCK_MONOTONIC", CLOCK_MONOTONIC },
+		{ NULL }
+	};
+
+	struct ptp_clock_caps capabilities;
+	char ptp_path[PTP_MAX_DEV_PATH];
+	const struct static_clockid *c;
+	int fd_ptp;
+
+	for (c = clockids_sysv; c->name; c++) {
+		if (strncasecmp(c->name, arg, 25) == 0) {
+			*val = c->clockid;
+
+			return 0;
+		}
+	}
+
+	snprintf(ptp_path, sizeof(ptp_path), "%s", arg);
+	fd_ptp = open(ptp_path, O_RDONLY);
+
+	/* Make sure the path provided points to a PTP chardev. */
+	if (fd_ptp < 0 || ioctl(fd_ptp, PTP_CLOCK_GETCAPS, &capabilities) < 0) {
+		return -1;
+	}
+
+	*val = fd_to_clockid(fd_ptp);
+	return 0;
+}
+
+
+static int tbs_parse_opt(struct qdisc_util *qu, int argc,
+			 char **argv, struct nlmsghdr *n, const char *dev)
+{
+	struct tc_tbs_qopt opt = {
+		.clockid = CLOCKID_INVALID,
+	};
+	struct rtattr *tail;
+
+	while (argc > 0) {
+		if (matches(*argv, "offload") == 0) {
+			if (opt.flags & TC_TBS_OFFLOAD_ON) {
+				fprintf(stderr, "tbs: duplicate \"offload\" specification\n");
+				return -1;
+			}
+
+			opt.flags |= TC_TBS_OFFLOAD_ON;
+		} else if (matches(*argv, "sorting") == 0) {
+			if (opt.flags & TC_TBS_SORTING_ON) {
+				fprintf(stderr, "tbs: duplicate \"sorting\" specification\n");
+				return -1;
+			}
+
+			opt.flags |= TC_TBS_SORTING_ON;
+		} else if (matches(*argv, "delta") == 0) {
+			NEXT_ARG();
+			if (opt.delta) {
+				fprintf(stderr, "tbs: duplicate \"delta\" specification\n");
+				return -1;
+			}
+			if (get_s32(&opt.delta, *argv, 0)) {
+				explain1("delta", *argv);
+				return -1;
+			}
+		} else if (matches(*argv, "clockid") == 0) {
+			NEXT_ARG();
+			if (opt.clockid != CLOCKID_INVALID) {
+				fprintf(stderr, "tbs: duplicate \"clockid\" specification\n");
+				return -1;
+			}
+			if (get_clockid(&opt.clockid, *argv)) {
+				explain_clockid(*argv);
+				return -1;
+			}
+		} else if (strcmp(*argv, "help") == 0) {
+			explain();
+			return -1;
+		} else {
+			fprintf(stderr, "tbs: unknown parameter \"%s\"\n", *argv);
+			explain();
+			return -1;
+		}
+		argc--; argv++;
+	}
+
+	tail = NLMSG_TAIL(n);
+	addattr_l(n, 1024, TCA_OPTIONS, NULL, 0);
+	addattr_l(n, 2024, TCA_TBS_PARMS, &opt, sizeof(opt));
+	tail->rta_len = (void *) NLMSG_TAIL(n) - (void *) tail;
+	return 0;
+}
+
+static int tbs_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt)
+{
+	struct rtattr *tb[TCA_TBS_MAX+1];
+	struct tc_tbs_qopt *qopt;
+
+	if (opt == NULL)
+		return 0;
+
+	parse_rtattr_nested(tb, TCA_TBS_MAX, opt);
+
+	if (tb[TCA_TBS_PARMS] == NULL)
+		return -1;
+
+	qopt = RTA_DATA(tb[TCA_TBS_PARMS]);
+	if (RTA_PAYLOAD(tb[TCA_TBS_PARMS])  < sizeof(*qopt))
+		return -1;
+
+	fprintf(f, "clockid ");
+	if (qopt->clockid == CLOCKID_INVALID)
+		fprintf(f, "invalid ");
+	else
+		fprintf(f, "%d ", qopt->clockid);
+
+	fprintf(f, "delta %d ", qopt->delta);
+	fprintf(f, "offload %s ", (qopt->flags & TC_TBS_OFFLOAD_ON) ?
+					"on" : "off");
+	fprintf(f, "sorting %s", (qopt->flags & TC_TBS_SORTING_ON) ?
+					"on" : "off");
+
+	return 0;
+}
+
+struct qdisc_util tbs_qdisc_util = {
+	.id		= "tbs",
+	.parse_qopt	= tbs_parse_opt,
+	.print_qopt	= tbs_print_opt,
+};
-- 
2.16.2

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [RFC v3 iproute2 3/3] tc: Add support for the TBS Qdisc
  2018-03-07  1:16 ` [RFC v3 iproute2 3/3] tc: Add support for the TBS Qdisc Jesus Sanchez-Palencia
@ 2018-03-07  1:51   ` Stephen Hemminger
  2018-03-07 22:29     ` Jesus Sanchez-Palencia
  0 siblings, 1 reply; 6+ messages in thread
From: Stephen Hemminger @ 2018-03-07  1:51 UTC (permalink / raw)
  To: Jesus Sanchez-Palencia
  Cc: netdev, jhs, xiyou.wangcong, jiri, Vinicius Costa Gomes

On Tue,  6 Mar 2018 17:16:08 -0800
Jesus Sanchez-Palencia <jesus.sanchez-palencia@intel.com> wrote:

> atic int tbs_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt)
> +{
> +	struct rtattr *tb[TCA_TBS_MAX+1];
> +	struct tc_tbs_qopt *qopt;
> +
> +	if (opt == NULL)
> +		return 0;
> +
> +	parse_rtattr_nested(tb, TCA_TBS_MAX, opt);
> +
> +	if (tb[TCA_TBS_PARMS] == NULL)
> +		return -1;
> +
> +	qopt = RTA_DATA(tb[TCA_TBS_PARMS]);
> +	if (RTA_PAYLOAD(tb[TCA_TBS_PARMS])  < sizeof(*qopt))
> +		return -1;
> +
> +	fprintf(f, "clockid ");
> +	if (qopt->clockid == CLOCKID_INVALID)
> +		fprintf(f, "invalid ");
> +	else
> +		fprintf(f, "%d ", qopt->clockid);
> +
> +	fprintf(f, "delta %d ", qopt->delta);
> +	fprintf(f, "offload %s ", (qopt->flags & TC_TBS_OFFLOAD_ON) ?
> +					"on" : "off");
> +	fprintf(f, "sorting %s", (qopt->flags & TC_TBS_SORTING_ON) ?
> +					"on" : "off");
> +
> +	return 0;
> +}

All new print code in iproute2 should support JSON output.
Look at other code using json_print.h for simple way to handle this.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [RFC v3 iproute2 3/3] tc: Add support for the TBS Qdisc
  2018-03-07  1:51   ` Stephen Hemminger
@ 2018-03-07 22:29     ` Jesus Sanchez-Palencia
  2018-03-07 22:53       ` Stephen Hemminger
  0 siblings, 1 reply; 6+ messages in thread
From: Jesus Sanchez-Palencia @ 2018-03-07 22:29 UTC (permalink / raw)
  To: Stephen Hemminger; +Cc: netdev, jhs, xiyou.wangcong, jiri, Vinicius Costa Gomes

Hi,


On 03/06/2018 05:51 PM, Stephen Hemminger wrote:
> On Tue,  6 Mar 2018 17:16:08 -0800
> Jesus Sanchez-Palencia <jesus.sanchez-palencia@intel.com> wrote:
> 
>> atic int tbs_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt)
>> +{
>> +	struct rtattr *tb[TCA_TBS_MAX+1];
>> +	struct tc_tbs_qopt *qopt;
>> +
>> +	if (opt == NULL)
>> +		return 0;
>> +
>> +	parse_rtattr_nested(tb, TCA_TBS_MAX, opt);
>> +
>> +	if (tb[TCA_TBS_PARMS] == NULL)
>> +		return -1;
>> +
>> +	qopt = RTA_DATA(tb[TCA_TBS_PARMS]);
>> +	if (RTA_PAYLOAD(tb[TCA_TBS_PARMS])  < sizeof(*qopt))
>> +		return -1;
>> +
>> +	fprintf(f, "clockid ");
>> +	if (qopt->clockid == CLOCKID_INVALID)
>> +		fprintf(f, "invalid ");
>> +	else
>> +		fprintf(f, "%d ", qopt->clockid);
>> +
>> +	fprintf(f, "delta %d ", qopt->delta);
>> +	fprintf(f, "offload %s ", (qopt->flags & TC_TBS_OFFLOAD_ON) ?
>> +					"on" : "off");
>> +	fprintf(f, "sorting %s", (qopt->flags & TC_TBS_SORTING_ON) ?
>> +					"on" : "off");
>> +
>> +	return 0;
>> +}
> 
> All new print code in iproute2 should support JSON output.
> Look at other code using json_print.h for simple way to handle this.
> 


Fixed, thanks. I'm assuming that only applies to print code from print_qopt()
implementations. Please let me know if otherwise.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [RFC v3 iproute2 3/3] tc: Add support for the TBS Qdisc
  2018-03-07 22:29     ` Jesus Sanchez-Palencia
@ 2018-03-07 22:53       ` Stephen Hemminger
  0 siblings, 0 replies; 6+ messages in thread
From: Stephen Hemminger @ 2018-03-07 22:53 UTC (permalink / raw)
  To: Jesus Sanchez-Palencia
  Cc: netdev, jhs, xiyou.wangcong, jiri, Vinicius Costa Gomes

On Wed, 7 Mar 2018 14:29:23 -0800
Jesus Sanchez-Palencia <jesus.sanchez-palencia@intel.com> wrote:

> Hi,
> 
> 
> On 03/06/2018 05:51 PM, Stephen Hemminger wrote:
> > On Tue,  6 Mar 2018 17:16:08 -0800
> > Jesus Sanchez-Palencia <jesus.sanchez-palencia@intel.com> wrote:
> >   
> >> atic int tbs_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt)
> >> +{
> >> +	struct rtattr *tb[TCA_TBS_MAX+1];
> >> +	struct tc_tbs_qopt *qopt;
> >> +
> >> +	if (opt == NULL)
> >> +		return 0;
> >> +
> >> +	parse_rtattr_nested(tb, TCA_TBS_MAX, opt);
> >> +
> >> +	if (tb[TCA_TBS_PARMS] == NULL)
> >> +		return -1;
> >> +
> >> +	qopt = RTA_DATA(tb[TCA_TBS_PARMS]);
> >> +	if (RTA_PAYLOAD(tb[TCA_TBS_PARMS])  < sizeof(*qopt))
> >> +		return -1;
> >> +
> >> +	fprintf(f, "clockid ");
> >> +	if (qopt->clockid == CLOCKID_INVALID)
> >> +		fprintf(f, "invalid ");
> >> +	else
> >> +		fprintf(f, "%d ", qopt->clockid);
> >> +
> >> +	fprintf(f, "delta %d ", qopt->delta);
> >> +	fprintf(f, "offload %s ", (qopt->flags & TC_TBS_OFFLOAD_ON) ?
> >> +					"on" : "off");
> >> +	fprintf(f, "sorting %s", (qopt->flags & TC_TBS_SORTING_ON) ?
> >> +					"on" : "off");
> >> +
> >> +	return 0;
> >> +}  
> > 
> > All new print code in iproute2 should support JSON output.
> > Look at other code using json_print.h for simple way to handle this.
> >   
> 
> 
> Fixed, thanks. I'm assuming that only applies to print code from print_qopt()
> implementations. Please let me know if otherwise.
> 

Yes. that is what gets invoked by 'tc qdisc show'.
Not everything is updated, but want to get there soon.

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2018-03-07 22:53 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-03-07  1:16 [RFC v3 iproute2 1/3] include: Add ptp_clock.h to linux uapi Jesus Sanchez-Palencia
2018-03-07  1:16 ` [RFC v3 iproute2 2/3] uapi pkt_sched: Add tbs info - DO NOT COMMIT Jesus Sanchez-Palencia
2018-03-07  1:16 ` [RFC v3 iproute2 3/3] tc: Add support for the TBS Qdisc Jesus Sanchez-Palencia
2018-03-07  1:51   ` Stephen Hemminger
2018-03-07 22:29     ` Jesus Sanchez-Palencia
2018-03-07 22:53       ` Stephen Hemminger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox