2 * q_mqprio.c MQ prio qdisc
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version
7 * 2 of the License, or (at your option) any later version.
9 * Author: John Fastabend, <john.r.fastabend@intel.com>
17 #include <sys/socket.h>
18 #include <netinet/in.h>
19 #include <arpa/inet.h>
25 static void explain(void)
27 fprintf(stderr, "Usage: ... mqprio [num_tc NUMBER] [map P0 P1 ...]\n");
28 fprintf(stderr, " [queues count1@offset1 count2@offset2 ...] ");
29 fprintf(stderr, "[hw 1|0]\n");
32 static int mqprio_parse_opt(struct qdisc_util *qu, int argc,
33 char **argv, struct nlmsghdr *n)
36 struct tc_mqprio_qopt opt = {
38 {0, 1, 2, 3, 4, 5, 6, 7, 0, 1, 1, 1, 3, 3, 3, 3},
44 if (strcmp(*argv, "num_tc") == 0) {
46 if (get_u8(&opt.num_tc, *argv, 10)) {
47 fprintf(stderr, "Illegal \"num_tc\"\n");
50 } else if (strcmp(*argv, "map") == 0) {
51 while (idx < TC_QOPT_MAX_QUEUE && NEXT_ARG_OK()) {
53 if (get_u8(&opt.prio_tc_map[idx], *argv, 10)) {
59 for ( ; idx < TC_QOPT_MAX_QUEUE; idx++)
60 opt.prio_tc_map[idx] = 0;
61 } else if (strcmp(*argv, "queues") == 0) {
64 while (idx < TC_QOPT_MAX_QUEUE && NEXT_ARG_OK()) {
71 tok = strtok(tmp, "@");
72 if (get_u16(&opt.count[idx], tok, 10)) {
77 tok = strtok(NULL, "@");
78 if (get_u16(&opt.offset[idx], tok, 10)) {
86 } else if (strcmp(*argv, "hw") == 0) {
88 if (get_u8(&opt.hw, *argv, 10)) {
89 fprintf(stderr, "Illegal \"hw\"\n");
93 } else if (strcmp(*argv, "help") == 0) {
97 fprintf(stderr, "Unknown argument\n");
103 addattr_l(n, 1024, TCA_OPTIONS, &opt, sizeof(opt));
107 int mqprio_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt)
110 struct tc_mqprio_qopt *qopt;
115 qopt = RTA_DATA(opt);
117 fprintf(f, " tc %u map ", qopt->num_tc);
118 for (i = 0; i <= TC_PRIO_MAX; i++)
119 fprintf(f, "%u ", qopt->prio_tc_map[i]);
120 fprintf(f, "\n queues:");
121 for (i = 0; i < qopt->num_tc; i++)
122 fprintf(f, "(%u:%u) ", qopt->offset[i],
123 qopt->offset[i] + qopt->count[i] - 1);
127 struct qdisc_util mqprio_qdisc_util = {
129 .parse_qopt = mqprio_parse_opt,
130 .print_qopt = mqprio_print_opt,