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 .prio_tc_map
= { 0, 1, 2, 3, 4, 5, 6, 7, 0, 1, 1, 1, 3, 3, 3, 3 },
46 if (strcmp(*argv
, "num_tc") == 0) {
48 if (get_u8(&opt
.num_tc
, *argv
, 10)) {
49 fprintf(stderr
, "Illegal \"num_tc\"\n");
52 } else if (strcmp(*argv
, "map") == 0) {
53 while (idx
< TC_QOPT_MAX_QUEUE
&& NEXT_ARG_OK()) {
55 if (get_u8(&opt
.prio_tc_map
[idx
], *argv
, 10)) {
61 for ( ; idx
< TC_QOPT_MAX_QUEUE
; idx
++)
62 opt
.prio_tc_map
[idx
] = 0;
63 } else if (strcmp(*argv
, "queues") == 0) {
66 while (idx
< TC_QOPT_MAX_QUEUE
&& NEXT_ARG_OK()) {
73 tok
= strtok(tmp
, "@");
74 if (get_u16(&opt
.count
[idx
], tok
, 10)) {
79 tok
= strtok(NULL
, "@");
80 if (get_u16(&opt
.offset
[idx
], tok
, 10)) {
88 } else if (strcmp(*argv
, "hw") == 0) {
90 if (get_u8(&opt
.hw
, *argv
, 10)) {
91 fprintf(stderr
, "Illegal \"hw\"\n");
95 } else if (strcmp(*argv
, "help") == 0) {
99 fprintf(stderr
, "Unknown argument\n");
105 addattr_l(n
, 1024, TCA_OPTIONS
, &opt
, sizeof(opt
));
109 static int mqprio_print_opt(struct qdisc_util
*qu
, FILE *f
, struct rtattr
*opt
)
112 struct tc_mqprio_qopt
*qopt
;
117 qopt
= RTA_DATA(opt
);
119 fprintf(f
, " tc %u map ", qopt
->num_tc
);
120 for (i
= 0; i
<= TC_PRIO_MAX
; i
++)
121 fprintf(f
, "%u ", qopt
->prio_tc_map
[i
]);
122 fprintf(f
, "\n queues:");
123 for (i
= 0; i
< qopt
->num_tc
; i
++)
124 fprintf(f
, "(%u:%u) ", qopt
->offset
[i
],
125 qopt
->offset
[i
] + qopt
->count
[i
] - 1);
129 struct qdisc_util mqprio_qdisc_util
= {
131 .parse_qopt
= mqprio_parse_opt
,
132 .print_qopt
= mqprio_print_opt
,