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

This allows a new parameter, flags, to be passed to taprio. Currently, it
only supports enabling the txtime-assist mode. But, we plan to add
different modes for taprio (e.g. hardware offloading) and this parameter
will be useful in enabling those modes.

Signed-off-by: Vinicius Costa Gomes <vinicius.go...@intel.com>
Signed-off-by: Vedang Patel <vedang.pa...@intel.com>
---
 tc/q_taprio.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/tc/q_taprio.c b/tc/q_taprio.c
index 62c8c591da99..930ecb9d1eef 100644
--- a/tc/q_taprio.c
+++ b/tc/q_taprio.c
@@ -154,6 +154,7 @@ static struct sched_entry *create_entry(uint32_t gatemask, 
uint32_t interval, ui
 static int taprio_parse_opt(struct qdisc_util *qu, int argc,
                            char **argv, struct nlmsghdr *n, const char *dev)
 {
+       __u32 taprio_flags = UINT32_MAX;
        __s32 clockid = CLOCKID_INVALID;
        struct tc_mqprio_qopt opt = { };
        __s64 cycle_time_extension = 0;
@@ -281,6 +282,17 @@ static int taprio_parse_opt(struct qdisc_util *qu, int 
argc,
                                explain_clockid(*argv);
                                return -1;
                        }
+               } else if (strcmp(*argv, "flags") == 0) {
+                       NEXT_ARG();
+                       if (taprio_flags != UINT32_MAX) {
+                               fprintf(stderr, "taprio: duplicate \"flags\" 
specification\n");
+                               return -1;
+                       }
+                       if (get_u32(&taprio_flags, *argv, 0)) {
+                               PREV_ARG();
+                               return -1;
+                       }
+
                } else if (strcmp(*argv, "help") == 0) {
                        explain();
                        return -1;
@@ -297,6 +309,9 @@ static int taprio_parse_opt(struct qdisc_util *qu, int argc,
        if (clockid != CLOCKID_INVALID)
                addattr_l(n, 1024, TCA_TAPRIO_ATTR_SCHED_CLOCKID, &clockid, 
sizeof(clockid));
 
+       if (taprio_flags != UINT32_MAX)
+               addattr_l(n, 1024, TCA_TAPRIO_ATTR_FLAGS, &taprio_flags, 
sizeof(taprio_flags));
+
        if (opt.num_tc > 0)
                addattr_l(n, 1024, TCA_TAPRIO_ATTR_PRIOMAP, &opt, sizeof(opt));
 
@@ -405,6 +420,7 @@ 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;
        __s32 clockid = CLOCKID_INVALID;
+       __u32 taprio_flags = 0;
        int i;
 
        if (opt == NULL)
@@ -442,6 +458,11 @@ static int taprio_print_opt(struct qdisc_util *qu, FILE 
*f, struct rtattr *opt)
 
        print_string(PRINT_ANY, "clockid", "clockid %s", 
get_clock_name(clockid));
 
+       if (tb[TCA_TAPRIO_ATTR_FLAGS]) {
+               taprio_flags = rta_getattr_u32(tb[TCA_TAPRIO_ATTR_FLAGS]);
+               print_uint(PRINT_ANY, "flags", " flags %x", taprio_flags);
+       }
+
        print_schedule(f, tb);
 
        if (tb[TCA_TAPRIO_ATTR_ADMIN_SCHED]) {
-- 
2.7.3

Reply via email to