11 #include <linux/types.h>
12 #include <linux/slab.h>
13 #include <linux/kernel.h>
14 #include <linux/string.h>
15 #include <linux/errno.h>
17 #include <linux/module.h>
27 static void mqprio_destroy(
struct Qdisc *
sch)
44 netdev_set_num_tc(dev, 0);
71 for (i = 0; i < qopt->
num_tc; i++) {
83 for (j = i + 1; j < qopt->
num_tc; j++) {
84 if (last > qopt->
offset[j])
107 if (!netif_is_multiqueue(dev))
110 if (!opt || nla_len(opt) <
sizeof(*qopt))
113 qopt = nla_data(opt);
114 if (mqprio_parse_opt(dev, qopt))
126 dev_queue = netdev_get_tx_queue(dev, i);
147 netdev_set_num_tc(dev, qopt->
num_tc);
148 for (i = 0; i < qopt->
num_tc; i++)
149 netdev_set_tc_queue(dev, i,
154 for (i = 0; i < TC_BITMASK + 1; i++)
155 netdev_set_prio_tc_map(dev, i, qopt->
prio_tc_map[i]);
165 static void mqprio_attach(
struct Qdisc *sch)
174 qdisc = priv->
qdiscs[ntx];
187 unsigned long ntx = cl - 1 - netdev_get_num_tc(dev);
191 return netdev_get_tx_queue(dev, ntx);
194 static int mqprio_graft(
struct Qdisc *sch,
unsigned long cl,
struct Qdisc *
new,
198 struct netdev_queue *dev_queue = mqprio_queue_get(sch, cl);
218 unsigned char *
b = skb_tail_pointer(skb);
228 qdisc = netdev_get_tx_queue(dev, i)->qdisc;
229 spin_lock_bh(qdisc_lock(qdisc));
230 sch->
q.qlen += qdisc->
q.qlen;
238 spin_unlock_bh(qdisc_lock(qdisc));
241 opt.
num_tc = netdev_get_num_tc(dev);
245 for (i = 0; i < netdev_get_num_tc(dev); i++) {
251 goto nla_put_failure;
259 static struct Qdisc *mqprio_leaf(
struct Qdisc *sch,
unsigned long cl)
261 struct netdev_queue *dev_queue = mqprio_queue_get(sch, cl);
269 static unsigned long mqprio_get(
struct Qdisc *sch,
u32 classid)
272 unsigned int ntx =
TC_H_MIN(classid);
279 static void mqprio_put(
struct Qdisc *sch,
unsigned long cl)
283 static int mqprio_dump_class(
struct Qdisc *sch,
unsigned long cl,
288 if (cl <= netdev_get_num_tc(dev)) {
295 dev_queue = mqprio_queue_get(sch, cl);
297 for (i = 0; i < netdev_get_num_tc(dev); i++) {
299 int q_idx = cl - netdev_get_num_tc(dev);
315 static int mqprio_dump_class_stats(
struct Qdisc *sch,
unsigned long cl,
322 if (cl <= netdev_get_num_tc(dev)) {
334 spin_unlock_bh(
d->lock);
337 qdisc = netdev_get_tx_queue(dev, i)->qdisc;
338 spin_lock_bh(qdisc_lock(qdisc));
346 spin_unlock_bh(qdisc_lock(qdisc));
349 spin_lock_bh(
d->lock);
354 struct netdev_queue *dev_queue = mqprio_queue_get(sch, cl);
357 sch->
qstats.qlen = sch->
q.qlen;
375 for (ntx = arg->
skip;
378 if (arg->
fn(sch, ntx + 1, arg) < 0) {
387 .graft = mqprio_graft,
392 .dump = mqprio_dump_class,
393 .dump_stats = mqprio_dump_class_stats,
397 .cl_ops = &mqprio_class_ops,
401 .destroy = mqprio_destroy,
402 .attach = mqprio_attach,
407 static int __init mqprio_module_init(
void)
412 static void __exit mqprio_module_exit(
void)