]> git.proxmox.com Git - mirror_iproute2.git/blob - tc/q_multiq.c
tc: B.W limits can now be specified in %.
[mirror_iproute2.git] / tc / q_multiq.c
1 /*
2 * q_multiq.c Multiqueue aware qdisc
3 *
4 * Copyright (c) 2008, Intel Corporation.
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms and conditions of the GNU General Public License,
8 * version 2, as published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 * more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, see <http://www.gnu.org/licenses>.
17 *
18 * Author: Alexander Duyck <alexander.h.duyck@intel.com>
19 *
20 * Original Authors: PJ Waskiewicz, <peter.p.waskiewicz.jr@intel.com> (RR)
21 * Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru> (from PRIO)
22 *
23 */
24
25 #include <stdio.h>
26 #include <stdlib.h>
27 #include <unistd.h>
28 #include <fcntl.h>
29 #include <sys/socket.h>
30 #include <netinet/in.h>
31 #include <arpa/inet.h>
32 #include <string.h>
33
34 #include "utils.h"
35 #include "tc_util.h"
36
37 static void explain(void)
38 {
39 fprintf(stderr, "Usage: ... multiq [help]\n");
40 }
41
42 static int multiq_parse_opt(struct qdisc_util *qu, int argc, char **argv,
43 struct nlmsghdr *n, const char *dev)
44 {
45 struct tc_multiq_qopt opt = {};
46
47 if (argc) {
48 if (strcmp(*argv, "help") == 0) {
49 explain();
50 return -1;
51 } else {
52 fprintf(stderr, "What is \"%s\"?\n", *argv);
53 explain();
54 return -1;
55 }
56 }
57
58 addattr_l(n, 1024, TCA_OPTIONS, &opt, sizeof(opt));
59 return 0;
60 }
61
62 static int multiq_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt)
63 {
64 struct tc_multiq_qopt *qopt;
65
66 if (opt == NULL)
67 return 0;
68 if (RTA_PAYLOAD(opt) < sizeof(*qopt))
69 return 0;
70
71 qopt = RTA_DATA(opt);
72
73 fprintf(f, "bands %u/%u ", qopt->bands, qopt->max_bands);
74
75 return 0;
76 }
77
78 struct qdisc_util multiq_qdisc_util = {
79 .id = "multiq",
80 .parse_qopt = multiq_parse_opt,
81 .print_qopt = multiq_print_opt,
82 };