blob: 782393149456346c6914934dbc9af7d64ad4bfdd [file] [log] [blame]
Alexander Duyckfe1a34f2008-12-05 14:16:42 -08001/*
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 *
Stephen Hemminger4d98ab02013-12-06 15:05:07 -080015 * 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>.
Alexander Duyckfe1a34f2008-12-05 14:16:42 -080017 *
18 * Author: Alexander Duyck <alexander.h.duyck@intel.com>
19 *
20 * Original Authors: PJ Waskiewicz, <peter.p.waskiewicz.jr@intel.com> (RR)
Stephen Hemminger3d0b7432014-12-20 15:47:17 -080021 * Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru> (from PRIO)
Alexander Duyckfe1a34f2008-12-05 14:16:42 -080022 *
23 */
24
25#include <stdio.h>
26#include <stdlib.h>
27#include <unistd.h>
28#include <syslog.h>
29#include <fcntl.h>
30#include <sys/socket.h>
31#include <netinet/in.h>
32#include <arpa/inet.h>
33#include <string.h>
34
35#include "utils.h"
36#include "tc_util.h"
37
38static void explain(void)
39{
40 fprintf(stderr, "Usage: ... multiq [help]\n");
41}
42
Alexander Duyckfe1a34f2008-12-05 14:16:42 -080043static int multiq_parse_opt(struct qdisc_util *qu, int argc, char **argv,
44 struct nlmsghdr *n)
45{
46 struct tc_multiq_qopt opt;
47
Petr Sabata5582c0c2011-06-10 03:19:07 +000048 if (argc) {
Alexander Duyckfe1a34f2008-12-05 14:16:42 -080049 if (strcmp(*argv, "help") == 0) {
50 explain();
51 return -1;
52 } else {
53 fprintf(stderr, "What is \"%s\"?\n", *argv);
54 explain();
55 return -1;
56 }
Alexander Duyckfe1a34f2008-12-05 14:16:42 -080057 }
58
59 addattr_l(n, 1024, TCA_OPTIONS, &opt, sizeof(opt));
60 return 0;
61}
62
Stephen Hemmingerd1f28cf2013-02-12 11:09:03 -080063static int multiq_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt)
Alexander Duyckfe1a34f2008-12-05 14:16:42 -080064{
65 struct tc_multiq_qopt *qopt;
66
67 if (opt == NULL)
68 return 0;
69 if (RTA_PAYLOAD(opt) < sizeof(*qopt))
70 return 0;
71
72 qopt = RTA_DATA(opt);
73
74 fprintf(f, "bands %u/%u ", qopt->bands, qopt->max_bands);
75
76 return 0;
77}
78
79struct qdisc_util multiq_qdisc_util = {
Stephen Hemminger32a121c2016-03-21 11:48:36 -070080 .id = "multiq",
Alexander Duyckfe1a34f2008-12-05 14:16:42 -080081 .parse_qopt = multiq_parse_opt,
82 .print_qopt = multiq_print_opt,
83};