]>
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)
14 * Ole Husgaard <sparre@login.dknet.dk>: 990513: prio2band map was always reset.
15 * J Hadi Salim <hadi@cyberus.ca>: 990609: priomap fix.
23 #include <sys/socket.h>
24 #include <netinet/in.h>
25 #include <arpa/inet.h>
31 static void explain(void)
33 fprintf(stderr
, "Usage: ... rr bands NUMBER priomap P1 P2... [multiqueue]\n");
36 #define usage() return(-1)
38 static int rr_parse_opt(struct qdisc_util
*qu
, int argc
, char **argv
, struct nlmsghdr
*n
)
43 struct tc_prio_qopt opt
={3,{ 1, 2, 2, 2, 1, 2, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1 }};
48 if (strcmp(*argv
, "bands") == 0) {
52 if (get_integer(&opt
.bands
, *argv
, 10)) {
53 fprintf(stderr
, "Illegal \"bands\"\n");
57 } else if (strcmp(*argv
, "priomap") == 0) {
59 fprintf(stderr
, "Error: duplicate priomap\n");
63 } else if (strcmp(*argv
, "help") == 0) {
66 } else if (strcmp(*argv
, "multiqueue") == 0) {
71 fprintf(stderr
, "What is \"%s\"?\n", *argv
);
75 if (get_unsigned(&band
, *argv
, 10)) {
76 fprintf(stderr
, "Illegal \"priomap\" element\n");
79 if (band
> opt
.bands
) {
80 fprintf(stderr
, "\"priomap\" element is out of bands\n");
83 if (idx
> TC_PRIO_MAX
) {
84 fprintf(stderr
, "\"priomap\" index > TC_RR_MAX=%u\n", TC_PRIO_MAX
);
87 opt
.priomap
[idx
++] = band
;
92 nest
= addattr_nest_compat(n
, 1024, TCA_OPTIONS
, &opt
, sizeof(opt
));
94 addattr_l(n
, 1024, TCA_PRIO_MQ
, NULL
, 0);
95 addattr_nest_compat_end(n
, nest
);
99 int rr_print_opt(struct qdisc_util
*qu
, FILE *f
, struct rtattr
*opt
)
102 struct tc_prio_qopt
*qopt
;
103 struct rtattr
*tb
[TCA_PRIO_MAX
+ 1];
108 if (parse_rtattr_nested_compat(tb
, TCA_PRIO_MAX
, opt
, qopt
,
112 fprintf(f
, "bands %u priomap ", qopt
->bands
);
113 for (i
=0; i
<= TC_PRIO_MAX
; i
++)
114 fprintf(f
, " %d", qopt
->priomap
[i
]);
117 fprintf(f
, " multiqueue: %s ",
118 *(unsigned char *)RTA_DATA(tb
[TCA_PRIO_MQ
]) ? "on" : "off");
123 struct qdisc_util rr_qdisc_util
= {
125 .parse_qopt
= rr_parse_opt
,
126 .print_qopt
= rr_print_opt
,