]>
git.proxmox.com Git - mirror_iproute2.git/blob - tc/q_rr.c
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 * Authors: PJ Waskiewicz, <peter.p.waskiewicz.jr@intel.com>
10 * Original Authors: Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru> (from PRIO)
18 #include <sys/socket.h>
19 #include <netinet/in.h>
20 #include <arpa/inet.h>
26 static void explain(void)
28 fprintf(stderr
, "Usage: ... rr bands NUMBER priomap P1 P2... [multiqueue]\n");
32 static int rr_parse_opt(struct qdisc_util
*qu
, int argc
, char **argv
, struct nlmsghdr
*n
)
36 struct tc_prio_qopt opt
={3,{ 1, 2, 2, 2, 1, 2, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1 }};
41 if (strcmp(*argv
, "bands") == 0) {
45 if (get_integer(&opt
.bands
, *argv
, 10)) {
46 fprintf(stderr
, "Illegal \"bands\"\n");
49 } else if (strcmp(*argv
, "priomap") == 0) {
51 fprintf(stderr
, "Error: duplicate priomap\n");
55 } else if (strcmp(*argv
, "help") == 0) {
58 } else if (strcmp(*argv
, "multiqueue") == 0) {
63 fprintf(stderr
, "What is \"%s\"?\n", *argv
);
67 if (get_unsigned(&band
, *argv
, 10)) {
68 fprintf(stderr
, "Illegal \"priomap\" element\n");
71 if (band
> opt
.bands
) {
72 fprintf(stderr
, "\"priomap\" element is out of bands\n");
75 if (idx
> TC_PRIO_MAX
) {
76 fprintf(stderr
, "\"priomap\" index > TC_RR_MAX=%u\n", TC_PRIO_MAX
);
79 opt
.priomap
[idx
++] = band
;
84 nest
= addattr_nest_compat(n
, 1024, TCA_OPTIONS
, &opt
, sizeof(opt
));
86 addattr_l(n
, 1024, TCA_PRIO_MQ
, NULL
, 0);
87 addattr_nest_compat_end(n
, nest
);
91 static int rr_print_opt(struct qdisc_util
*qu
, FILE *f
, struct rtattr
*opt
)
94 struct tc_prio_qopt
*qopt
;
95 struct rtattr
*tb
[TCA_PRIO_MAX
+ 1];
100 if (parse_rtattr_nested_compat(tb
, TCA_PRIO_MAX
, opt
, qopt
,
104 fprintf(f
, "bands %u priomap ", qopt
->bands
);
105 for (i
=0; i
<= TC_PRIO_MAX
; i
++)
106 fprintf(f
, " %d", qopt
->priomap
[i
]);
109 fprintf(f
, " multiqueue: %s ",
110 rta_getattr_u8(tb
[TCA_PRIO_MQ
]) ? "on" : "off");
115 struct qdisc_util rr_qdisc_util
= {
117 .parse_qopt
= rr_parse_opt
,
118 .print_qopt
= rr_print_opt
,