1 // SPDX-License-Identifier: GPL-2.0-only
3 * net/sched/sch_mqprio.c
5 * Copyright (c) 2010 John Fastabend <john.r.fastabend@intel.com>
8 #include <linux/ethtool_netlink.h>
9 #include <linux/types.h>
10 #include <linux/slab.h>
11 #include <linux/kernel.h>
12 #include <linux/string.h>
13 #include <linux/errno.h>
14 #include <linux/skbuff.h>
15 #include <linux/module.h>
16 #include <net/netlink.h>
17 #include <net/pkt_sched.h>
18 #include <net/sch_generic.h>
19 #include <net/pkt_cls.h>
21 #include "sch_mqprio_lib.h"
24 struct Qdisc **qdiscs;
29 u64 min_rate[TC_QOPT_MAX_QUEUE];
30 u64 max_rate[TC_QOPT_MAX_QUEUE];
31 u32 fp[TC_QOPT_MAX_QUEUE];
34 static int mqprio_enable_offload(struct Qdisc *sch,
35 const struct tc_mqprio_qopt *qopt,
36 struct netlink_ext_ack *extack)
38 struct mqprio_sched *priv = qdisc_priv(sch);
39 struct net_device *dev = qdisc_dev(sch);
40 struct tc_mqprio_qopt_offload mqprio = {
47 case TC_MQPRIO_MODE_DCB:
48 if (priv->shaper != TC_MQPRIO_SHAPER_DCB)
51 case TC_MQPRIO_MODE_CHANNEL:
52 mqprio.flags = priv->flags;
53 if (priv->flags & TC_MQPRIO_F_MODE)
54 mqprio.mode = priv->mode;
55 if (priv->flags & TC_MQPRIO_F_SHAPER)
56 mqprio.shaper = priv->shaper;
57 if (priv->flags & TC_MQPRIO_F_MIN_RATE)
58 for (i = 0; i < mqprio.qopt.num_tc; i++)
59 mqprio.min_rate[i] = priv->min_rate[i];
60 if (priv->flags & TC_MQPRIO_F_MAX_RATE)
61 for (i = 0; i < mqprio.qopt.num_tc; i++)
62 mqprio.max_rate[i] = priv->max_rate[i];
68 mqprio_fp_to_offload(priv->fp, &mqprio);
70 err = dev->netdev_ops->ndo_setup_tc(dev, TC_SETUP_QDISC_MQPRIO,
75 priv->hw_offload = mqprio.qopt.hw;
80 static void mqprio_disable_offload(struct Qdisc *sch)
82 struct tc_mqprio_qopt_offload mqprio = { { 0 } };
83 struct mqprio_sched *priv = qdisc_priv(sch);
84 struct net_device *dev = qdisc_dev(sch);
87 case TC_MQPRIO_MODE_DCB:
88 case TC_MQPRIO_MODE_CHANNEL:
89 dev->netdev_ops->ndo_setup_tc(dev, TC_SETUP_QDISC_MQPRIO,
95 static void mqprio_destroy(struct Qdisc *sch)
97 struct net_device *dev = qdisc_dev(sch);
98 struct mqprio_sched *priv = qdisc_priv(sch);
103 ntx < dev->num_tx_queues && priv->qdiscs[ntx];
105 qdisc_put(priv->qdiscs[ntx]);
109 if (priv->hw_offload && dev->netdev_ops->ndo_setup_tc)
110 mqprio_disable_offload(sch);
112 netdev_set_num_tc(dev, 0);
115 static int mqprio_parse_opt(struct net_device *dev, struct tc_mqprio_qopt *qopt,
116 const struct tc_mqprio_caps *caps,
117 struct netlink_ext_ack *extack)
121 /* Limit qopt->hw to maximum supported offload value. Drivers have
122 * the option of overriding this later if they don't support the a
123 * given offload type.
125 if (qopt->hw > TC_MQPRIO_HW_OFFLOAD_MAX)
126 qopt->hw = TC_MQPRIO_HW_OFFLOAD_MAX;
128 /* If hardware offload is requested, we will leave 3 options to the
130 * - populate the queue counts itself (and ignore what was requested)
131 * - validate the provided queue counts by itself (and apply them)
132 * - request queue count validation here (and apply them)
134 err = mqprio_validate_qopt(dev, qopt,
135 !qopt->hw || caps->validate_queue_counts,
140 /* If ndo_setup_tc is not present then hardware doesn't support offload
141 * and we should return an error.
143 if (qopt->hw && !dev->netdev_ops->ndo_setup_tc) {
144 NL_SET_ERR_MSG(extack,
145 "Device does not support hardware offload");
153 nla_policy mqprio_tc_entry_policy[TCA_MQPRIO_TC_ENTRY_MAX + 1] = {
154 [TCA_MQPRIO_TC_ENTRY_INDEX] = NLA_POLICY_MAX(NLA_U32,
156 [TCA_MQPRIO_TC_ENTRY_FP] = NLA_POLICY_RANGE(NLA_U32,
161 static const struct nla_policy mqprio_policy[TCA_MQPRIO_MAX + 1] = {
162 [TCA_MQPRIO_MODE] = { .len = sizeof(u16) },
163 [TCA_MQPRIO_SHAPER] = { .len = sizeof(u16) },
164 [TCA_MQPRIO_MIN_RATE64] = { .type = NLA_NESTED },
165 [TCA_MQPRIO_MAX_RATE64] = { .type = NLA_NESTED },
166 [TCA_MQPRIO_TC_ENTRY] = { .type = NLA_NESTED },
169 static int mqprio_parse_tc_entry(u32 fp[TC_QOPT_MAX_QUEUE],
171 unsigned long *seen_tcs,
172 struct netlink_ext_ack *extack)
174 struct nlattr *tb[TCA_MQPRIO_TC_ENTRY_MAX + 1];
177 err = nla_parse_nested(tb, TCA_MQPRIO_TC_ENTRY_MAX, opt,
178 mqprio_tc_entry_policy, extack);
182 if (NL_REQ_ATTR_CHECK(extack, opt, tb, TCA_MQPRIO_TC_ENTRY_INDEX)) {
183 NL_SET_ERR_MSG(extack, "TC entry index missing");
187 tc = nla_get_u32(tb[TCA_MQPRIO_TC_ENTRY_INDEX]);
188 if (*seen_tcs & BIT(tc)) {
189 NL_SET_ERR_MSG_ATTR(extack, tb[TCA_MQPRIO_TC_ENTRY_INDEX],
190 "Duplicate tc entry");
194 *seen_tcs |= BIT(tc);
196 if (tb[TCA_MQPRIO_TC_ENTRY_FP])
197 fp[tc] = nla_get_u32(tb[TCA_MQPRIO_TC_ENTRY_FP]);
202 static int mqprio_parse_tc_entries(struct Qdisc *sch, struct nlattr *nlattr_opt,
204 struct netlink_ext_ack *extack)
206 struct mqprio_sched *priv = qdisc_priv(sch);
207 struct net_device *dev = qdisc_dev(sch);
208 bool have_preemption = false;
209 unsigned long seen_tcs = 0;
210 u32 fp[TC_QOPT_MAX_QUEUE];
215 for (tc = 0; tc < TC_QOPT_MAX_QUEUE; tc++)
216 fp[tc] = priv->fp[tc];
218 nla_for_each_attr(n, nlattr_opt, nlattr_opt_len, rem) {
219 if (nla_type(n) != TCA_MQPRIO_TC_ENTRY)
222 err = mqprio_parse_tc_entry(fp, n, &seen_tcs, extack);
227 for (tc = 0; tc < TC_QOPT_MAX_QUEUE; tc++) {
228 priv->fp[tc] = fp[tc];
229 if (fp[tc] == TC_FP_PREEMPTIBLE)
230 have_preemption = true;
233 if (have_preemption && !ethtool_dev_mm_supported(dev)) {
234 NL_SET_ERR_MSG(extack, "Device does not support preemption");
241 /* Parse the other netlink attributes that represent the payload of
242 * TCA_OPTIONS, which are appended right after struct tc_mqprio_qopt.
244 static int mqprio_parse_nlattr(struct Qdisc *sch, struct tc_mqprio_qopt *qopt,
246 struct netlink_ext_ack *extack)
248 struct nlattr *nlattr_opt = nla_data(opt) + NLA_ALIGN(sizeof(*qopt));
249 int nlattr_opt_len = nla_len(opt) - NLA_ALIGN(sizeof(*qopt));
250 struct mqprio_sched *priv = qdisc_priv(sch);
251 struct nlattr *tb[TCA_MQPRIO_MAX + 1] = {};
255 if (nlattr_opt_len >= nla_attr_size(0)) {
256 err = nla_parse_deprecated(tb, TCA_MQPRIO_MAX, nlattr_opt,
257 nlattr_opt_len, mqprio_policy,
264 NL_SET_ERR_MSG(extack,
265 "mqprio TCA_OPTIONS can only contain netlink attributes in hardware mode");
269 if (tb[TCA_MQPRIO_MODE]) {
270 priv->flags |= TC_MQPRIO_F_MODE;
271 priv->mode = nla_get_u16(tb[TCA_MQPRIO_MODE]);
274 if (tb[TCA_MQPRIO_SHAPER]) {
275 priv->flags |= TC_MQPRIO_F_SHAPER;
276 priv->shaper = nla_get_u16(tb[TCA_MQPRIO_SHAPER]);
279 if (tb[TCA_MQPRIO_MIN_RATE64]) {
280 if (priv->shaper != TC_MQPRIO_SHAPER_BW_RATE) {
281 NL_SET_ERR_MSG_ATTR(extack, tb[TCA_MQPRIO_MIN_RATE64],
282 "min_rate accepted only when shaper is in bw_rlimit mode");
286 nla_for_each_nested(attr, tb[TCA_MQPRIO_MIN_RATE64],
288 if (nla_type(attr) != TCA_MQPRIO_MIN_RATE64) {
289 NL_SET_ERR_MSG_ATTR(extack, attr,
290 "Attribute type expected to be TCA_MQPRIO_MIN_RATE64");
294 if (nla_len(attr) != sizeof(u64)) {
295 NL_SET_ERR_MSG_ATTR(extack, attr,
296 "Attribute TCA_MQPRIO_MIN_RATE64 expected to have 8 bytes length");
300 if (i >= qopt->num_tc)
302 priv->min_rate[i] = nla_get_u64(attr);
305 priv->flags |= TC_MQPRIO_F_MIN_RATE;
308 if (tb[TCA_MQPRIO_MAX_RATE64]) {
309 if (priv->shaper != TC_MQPRIO_SHAPER_BW_RATE) {
310 NL_SET_ERR_MSG_ATTR(extack, tb[TCA_MQPRIO_MAX_RATE64],
311 "max_rate accepted only when shaper is in bw_rlimit mode");
315 nla_for_each_nested(attr, tb[TCA_MQPRIO_MAX_RATE64],
317 if (nla_type(attr) != TCA_MQPRIO_MAX_RATE64) {
318 NL_SET_ERR_MSG_ATTR(extack, attr,
319 "Attribute type expected to be TCA_MQPRIO_MAX_RATE64");
323 if (nla_len(attr) != sizeof(u64)) {
324 NL_SET_ERR_MSG_ATTR(extack, attr,
325 "Attribute TCA_MQPRIO_MAX_RATE64 expected to have 8 bytes length");
329 if (i >= qopt->num_tc)
331 priv->max_rate[i] = nla_get_u64(attr);
334 priv->flags |= TC_MQPRIO_F_MAX_RATE;
337 if (tb[TCA_MQPRIO_TC_ENTRY]) {
338 err = mqprio_parse_tc_entries(sch, nlattr_opt, nlattr_opt_len,
347 static int mqprio_init(struct Qdisc *sch, struct nlattr *opt,
348 struct netlink_ext_ack *extack)
350 struct net_device *dev = qdisc_dev(sch);
351 struct mqprio_sched *priv = qdisc_priv(sch);
352 struct netdev_queue *dev_queue;
354 int i, err = -EOPNOTSUPP;
355 struct tc_mqprio_qopt *qopt = NULL;
356 struct tc_mqprio_caps caps;
359 BUILD_BUG_ON(TC_MAX_QUEUE != TC_QOPT_MAX_QUEUE);
360 BUILD_BUG_ON(TC_BITMASK != TC_QOPT_BITMASK);
362 if (sch->parent != TC_H_ROOT)
365 if (!netif_is_multiqueue(dev))
368 /* make certain can allocate enough classids to handle queues */
369 if (dev->num_tx_queues >= TC_H_MIN_PRIORITY)
372 if (!opt || nla_len(opt) < sizeof(*qopt))
375 for (tc = 0; tc < TC_QOPT_MAX_QUEUE; tc++)
376 priv->fp[tc] = TC_FP_EXPRESS;
378 qdisc_offload_query_caps(dev, TC_SETUP_QDISC_MQPRIO,
379 &caps, sizeof(caps));
381 qopt = nla_data(opt);
382 if (mqprio_parse_opt(dev, qopt, &caps, extack))
385 len = nla_len(opt) - NLA_ALIGN(sizeof(*qopt));
387 err = mqprio_parse_nlattr(sch, qopt, opt, extack);
392 /* pre-allocate qdisc, attachment can't fail */
393 priv->qdiscs = kcalloc(dev->num_tx_queues, sizeof(priv->qdiscs[0]),
398 for (i = 0; i < dev->num_tx_queues; i++) {
399 dev_queue = netdev_get_tx_queue(dev, i);
400 qdisc = qdisc_create_dflt(dev_queue,
401 get_default_qdisc_ops(dev, i),
402 TC_H_MAKE(TC_H_MAJ(sch->handle),
403 TC_H_MIN(i + 1)), extack);
407 priv->qdiscs[i] = qdisc;
408 qdisc->flags |= TCQ_F_ONETXQUEUE | TCQ_F_NOPARENT;
411 /* If the mqprio options indicate that hardware should own
412 * the queue mapping then run ndo_setup_tc otherwise use the
413 * supplied and verified mapping
416 err = mqprio_enable_offload(sch, qopt, extack);
420 netdev_set_num_tc(dev, qopt->num_tc);
421 for (i = 0; i < qopt->num_tc; i++)
422 netdev_set_tc_queue(dev, i,
423 qopt->count[i], qopt->offset[i]);
426 /* Always use supplied priority mappings */
427 for (i = 0; i < TC_BITMASK + 1; i++)
428 netdev_set_prio_tc_map(dev, i, qopt->prio_tc_map[i]);
430 sch->flags |= TCQ_F_MQROOT;
434 static void mqprio_attach(struct Qdisc *sch)
436 struct net_device *dev = qdisc_dev(sch);
437 struct mqprio_sched *priv = qdisc_priv(sch);
438 struct Qdisc *qdisc, *old;
441 /* Attach underlying qdisc */
442 for (ntx = 0; ntx < dev->num_tx_queues; ntx++) {
443 qdisc = priv->qdiscs[ntx];
444 old = dev_graft_qdisc(qdisc->dev_queue, qdisc);
447 if (ntx < dev->real_num_tx_queues)
448 qdisc_hash_add(qdisc, false);
454 static struct netdev_queue *mqprio_queue_get(struct Qdisc *sch,
457 struct net_device *dev = qdisc_dev(sch);
458 unsigned long ntx = cl - 1;
460 if (ntx >= dev->num_tx_queues)
462 return netdev_get_tx_queue(dev, ntx);
465 static int mqprio_graft(struct Qdisc *sch, unsigned long cl, struct Qdisc *new,
466 struct Qdisc **old, struct netlink_ext_ack *extack)
468 struct net_device *dev = qdisc_dev(sch);
469 struct netdev_queue *dev_queue = mqprio_queue_get(sch, cl);
474 if (dev->flags & IFF_UP)
477 *old = dev_graft_qdisc(dev_queue, new);
480 new->flags |= TCQ_F_ONETXQUEUE | TCQ_F_NOPARENT;
482 if (dev->flags & IFF_UP)
488 static int dump_rates(struct mqprio_sched *priv,
489 struct tc_mqprio_qopt *opt, struct sk_buff *skb)
494 if (priv->flags & TC_MQPRIO_F_MIN_RATE) {
495 nest = nla_nest_start_noflag(skb, TCA_MQPRIO_MIN_RATE64);
497 goto nla_put_failure;
499 for (i = 0; i < opt->num_tc; i++) {
500 if (nla_put(skb, TCA_MQPRIO_MIN_RATE64,
501 sizeof(priv->min_rate[i]),
503 goto nla_put_failure;
505 nla_nest_end(skb, nest);
508 if (priv->flags & TC_MQPRIO_F_MAX_RATE) {
509 nest = nla_nest_start_noflag(skb, TCA_MQPRIO_MAX_RATE64);
511 goto nla_put_failure;
513 for (i = 0; i < opt->num_tc; i++) {
514 if (nla_put(skb, TCA_MQPRIO_MAX_RATE64,
515 sizeof(priv->max_rate[i]),
517 goto nla_put_failure;
519 nla_nest_end(skb, nest);
524 nla_nest_cancel(skb, nest);
528 static int mqprio_dump_tc_entries(struct mqprio_sched *priv,
534 for (tc = 0; tc < TC_QOPT_MAX_QUEUE; tc++) {
535 n = nla_nest_start(skb, TCA_MQPRIO_TC_ENTRY);
539 if (nla_put_u32(skb, TCA_MQPRIO_TC_ENTRY_INDEX, tc))
540 goto nla_put_failure;
542 if (nla_put_u32(skb, TCA_MQPRIO_TC_ENTRY_FP, priv->fp[tc]))
543 goto nla_put_failure;
545 nla_nest_end(skb, n);
551 nla_nest_cancel(skb, n);
555 static int mqprio_dump(struct Qdisc *sch, struct sk_buff *skb)
557 struct net_device *dev = qdisc_dev(sch);
558 struct mqprio_sched *priv = qdisc_priv(sch);
559 struct nlattr *nla = (struct nlattr *)skb_tail_pointer(skb);
560 struct tc_mqprio_qopt opt = { 0 };
565 gnet_stats_basic_sync_init(&sch->bstats);
566 memset(&sch->qstats, 0, sizeof(sch->qstats));
568 /* MQ supports lockless qdiscs. However, statistics accounting needs
569 * to account for all, none, or a mix of locked and unlocked child
570 * qdiscs. Percpu stats are added to counters in-band and locking
571 * qdisc totals are added at end.
573 for (ntx = 0; ntx < dev->num_tx_queues; ntx++) {
574 qdisc = rtnl_dereference(netdev_get_tx_queue(dev, ntx)->qdisc_sleeping);
575 spin_lock_bh(qdisc_lock(qdisc));
577 gnet_stats_add_basic(&sch->bstats, qdisc->cpu_bstats,
578 &qdisc->bstats, false);
579 gnet_stats_add_queue(&sch->qstats, qdisc->cpu_qstats,
581 sch->q.qlen += qdisc_qlen(qdisc);
583 spin_unlock_bh(qdisc_lock(qdisc));
586 mqprio_qopt_reconstruct(dev, &opt);
587 opt.hw = priv->hw_offload;
589 if (nla_put(skb, TCA_OPTIONS, sizeof(opt), &opt))
590 goto nla_put_failure;
592 if ((priv->flags & TC_MQPRIO_F_MODE) &&
593 nla_put_u16(skb, TCA_MQPRIO_MODE, priv->mode))
594 goto nla_put_failure;
596 if ((priv->flags & TC_MQPRIO_F_SHAPER) &&
597 nla_put_u16(skb, TCA_MQPRIO_SHAPER, priv->shaper))
598 goto nla_put_failure;
600 if ((priv->flags & TC_MQPRIO_F_MIN_RATE ||
601 priv->flags & TC_MQPRIO_F_MAX_RATE) &&
602 (dump_rates(priv, &opt, skb) != 0))
603 goto nla_put_failure;
605 if (mqprio_dump_tc_entries(priv, skb))
606 goto nla_put_failure;
608 return nla_nest_end(skb, nla);
610 nlmsg_trim(skb, nla);
614 static struct Qdisc *mqprio_leaf(struct Qdisc *sch, unsigned long cl)
616 struct netdev_queue *dev_queue = mqprio_queue_get(sch, cl);
621 return rtnl_dereference(dev_queue->qdisc_sleeping);
624 static unsigned long mqprio_find(struct Qdisc *sch, u32 classid)
626 struct net_device *dev = qdisc_dev(sch);
627 unsigned int ntx = TC_H_MIN(classid);
629 /* There are essentially two regions here that have valid classid
630 * values. The first region will have a classid value of 1 through
631 * num_tx_queues. All of these are backed by actual Qdiscs.
633 if (ntx < TC_H_MIN_PRIORITY)
634 return (ntx <= dev->num_tx_queues) ? ntx : 0;
636 /* The second region represents the hardware traffic classes. These
637 * are represented by classid values of TC_H_MIN_PRIORITY through
638 * TC_H_MIN_PRIORITY + netdev_get_num_tc - 1
640 return ((ntx - TC_H_MIN_PRIORITY) < netdev_get_num_tc(dev)) ? ntx : 0;
643 static int mqprio_dump_class(struct Qdisc *sch, unsigned long cl,
644 struct sk_buff *skb, struct tcmsg *tcm)
646 if (cl < TC_H_MIN_PRIORITY) {
647 struct netdev_queue *dev_queue = mqprio_queue_get(sch, cl);
648 struct net_device *dev = qdisc_dev(sch);
649 int tc = netdev_txq_to_tc(dev, cl - 1);
651 tcm->tcm_parent = (tc < 0) ? 0 :
652 TC_H_MAKE(TC_H_MAJ(sch->handle),
653 TC_H_MIN(tc + TC_H_MIN_PRIORITY));
654 tcm->tcm_info = rtnl_dereference(dev_queue->qdisc_sleeping)->handle;
656 tcm->tcm_parent = TC_H_ROOT;
659 tcm->tcm_handle |= TC_H_MIN(cl);
663 static int mqprio_dump_class_stats(struct Qdisc *sch, unsigned long cl,
668 if (cl >= TC_H_MIN_PRIORITY) {
671 struct gnet_stats_queue qstats = {0};
672 struct gnet_stats_basic_sync bstats;
673 struct net_device *dev = qdisc_dev(sch);
674 struct netdev_tc_txq tc = dev->tc_to_txq[cl & TC_BITMASK];
676 gnet_stats_basic_sync_init(&bstats);
677 /* Drop lock here it will be reclaimed before touching
678 * statistics this is required because the d->lock we
679 * hold here is the look on dev_queue->qdisc_sleeping
680 * also acquired below.
683 spin_unlock_bh(d->lock);
685 for (i = tc.offset; i < tc.offset + tc.count; i++) {
686 struct netdev_queue *q = netdev_get_tx_queue(dev, i);
687 struct Qdisc *qdisc = rtnl_dereference(q->qdisc);
689 spin_lock_bh(qdisc_lock(qdisc));
691 gnet_stats_add_basic(&bstats, qdisc->cpu_bstats,
692 &qdisc->bstats, false);
693 gnet_stats_add_queue(&qstats, qdisc->cpu_qstats,
695 sch->q.qlen += qdisc_qlen(qdisc);
697 spin_unlock_bh(qdisc_lock(qdisc));
699 qlen = qdisc_qlen(sch) + qstats.qlen;
701 /* Reclaim root sleeping lock before completing stats */
703 spin_lock_bh(d->lock);
704 if (gnet_stats_copy_basic(d, NULL, &bstats, false) < 0 ||
705 gnet_stats_copy_queue(d, NULL, &qstats, qlen) < 0)
708 struct netdev_queue *dev_queue = mqprio_queue_get(sch, cl);
710 sch = rtnl_dereference(dev_queue->qdisc_sleeping);
711 if (gnet_stats_copy_basic(d, sch->cpu_bstats,
712 &sch->bstats, true) < 0 ||
713 qdisc_qstats_copy(d, sch) < 0)
719 static void mqprio_walk(struct Qdisc *sch, struct qdisc_walker *arg)
721 struct net_device *dev = qdisc_dev(sch);
727 /* Walk hierarchy with a virtual class per tc */
728 arg->count = arg->skip;
729 for (ntx = arg->skip; ntx < netdev_get_num_tc(dev); ntx++) {
730 if (!tc_qdisc_stats_dump(sch, ntx + TC_H_MIN_PRIORITY, arg))
734 /* Pad the values and skip over unused traffic classes */
735 if (ntx < TC_MAX_QUEUE) {
736 arg->count = TC_MAX_QUEUE;
740 /* Reset offset, sort out remaining per-queue qdiscs */
741 for (ntx -= TC_MAX_QUEUE; ntx < dev->num_tx_queues; ntx++) {
742 if (arg->fn(sch, ntx + 1, arg) < 0) {
750 static struct netdev_queue *mqprio_select_queue(struct Qdisc *sch,
753 return mqprio_queue_get(sch, TC_H_MIN(tcm->tcm_parent));
756 static const struct Qdisc_class_ops mqprio_class_ops = {
757 .graft = mqprio_graft,
761 .dump = mqprio_dump_class,
762 .dump_stats = mqprio_dump_class_stats,
763 .select_queue = mqprio_select_queue,
766 static struct Qdisc_ops mqprio_qdisc_ops __read_mostly = {
767 .cl_ops = &mqprio_class_ops,
769 .priv_size = sizeof(struct mqprio_sched),
771 .destroy = mqprio_destroy,
772 .attach = mqprio_attach,
773 .change_real_num_tx = mq_change_real_num_tx,
775 .owner = THIS_MODULE,
778 static int __init mqprio_module_init(void)
780 return register_qdisc(&mqprio_qdisc_ops);
783 static void __exit mqprio_module_exit(void)
785 unregister_qdisc(&mqprio_qdisc_ops);
788 module_init(mqprio_module_init);
789 module_exit(mqprio_module_exit);
791 MODULE_LICENSE("GPL");