sch_mqprio.c (79e24da00b1137031245f3341828e4215b1b5b59) sch_mqprio.c (1f27cde313d72d6b44a73ba89c8b2c6a99c628cf)
1/*
2 * net/sched/sch_mqprio.c
3 *
4 * Copyright (c) 2010 John Fastabend <john.r.fastabend@intel.com>
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * version 2 as published by the Free Software Foundation.

--- 14 unchanged lines hidden (view full) ---

23 struct Qdisc **qdiscs;
24 int hw_owned;
25};
26
27static void mqprio_destroy(struct Qdisc *sch)
28{
29 struct net_device *dev = qdisc_dev(sch);
30 struct mqprio_sched *priv = qdisc_priv(sch);
1/*
2 * net/sched/sch_mqprio.c
3 *
4 * Copyright (c) 2010 John Fastabend <john.r.fastabend@intel.com>
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * version 2 as published by the Free Software Foundation.

--- 14 unchanged lines hidden (view full) ---

23 struct Qdisc **qdiscs;
24 int hw_owned;
25};
26
27static void mqprio_destroy(struct Qdisc *sch)
28{
29 struct net_device *dev = qdisc_dev(sch);
30 struct mqprio_sched *priv = qdisc_priv(sch);
31 struct tc_to_netdev tc = {.type = TC_SETUP_MQPRIO};
31 unsigned int ntx;
32
33 if (priv->qdiscs) {
34 for (ntx = 0;
35 ntx < dev->num_tx_queues && priv->qdiscs[ntx];
36 ntx++)
37 qdisc_destroy(priv->qdiscs[ntx]);
38 kfree(priv->qdiscs);
39 }
40
41 if (priv->hw_owned && dev->netdev_ops->ndo_setup_tc)
32 unsigned int ntx;
33
34 if (priv->qdiscs) {
35 for (ntx = 0;
36 ntx < dev->num_tx_queues && priv->qdiscs[ntx];
37 ntx++)
38 qdisc_destroy(priv->qdiscs[ntx]);
39 kfree(priv->qdiscs);
40 }
41
42 if (priv->hw_owned && dev->netdev_ops->ndo_setup_tc)
42 dev->netdev_ops->ndo_setup_tc(dev, 0);
43 dev->netdev_ops->ndo_setup_tc(dev, sch->handle, 0, &tc);
43 else
44 netdev_set_num_tc(dev, 0);
45}
46
47static int mqprio_parse_opt(struct net_device *dev, struct tc_mqprio_qopt *qopt)
48{
49 int i, j;
50

--- 68 unchanged lines hidden (view full) ---

119 GFP_KERNEL);
120 if (priv->qdiscs == NULL) {
121 err = -ENOMEM;
122 goto err;
123 }
124
125 for (i = 0; i < dev->num_tx_queues; i++) {
126 dev_queue = netdev_get_tx_queue(dev, i);
44 else
45 netdev_set_num_tc(dev, 0);
46}
47
48static int mqprio_parse_opt(struct net_device *dev, struct tc_mqprio_qopt *qopt)
49{
50 int i, j;
51

--- 68 unchanged lines hidden (view full) ---

120 GFP_KERNEL);
121 if (priv->qdiscs == NULL) {
122 err = -ENOMEM;
123 goto err;
124 }
125
126 for (i = 0; i < dev->num_tx_queues; i++) {
127 dev_queue = netdev_get_tx_queue(dev, i);
127 qdisc = qdisc_create_dflt(dev_queue, default_qdisc_ops,
128 qdisc = qdisc_create_dflt(dev_queue,
129 get_default_qdisc_ops(dev, i),
128 TC_H_MAKE(TC_H_MAJ(sch->handle),
129 TC_H_MIN(i + 1)));
130 if (qdisc == NULL) {
131 err = -ENOMEM;
132 goto err;
133 }
134 priv->qdiscs[i] = qdisc;
135 qdisc->flags |= TCQ_F_ONETXQUEUE | TCQ_F_NOPARENT;
136 }
137
138 /* If the mqprio options indicate that hardware should own
139 * the queue mapping then run ndo_setup_tc otherwise use the
140 * supplied and verified mapping
141 */
142 if (qopt->hw) {
130 TC_H_MAKE(TC_H_MAJ(sch->handle),
131 TC_H_MIN(i + 1)));
132 if (qdisc == NULL) {
133 err = -ENOMEM;
134 goto err;
135 }
136 priv->qdiscs[i] = qdisc;
137 qdisc->flags |= TCQ_F_ONETXQUEUE | TCQ_F_NOPARENT;
138 }
139
140 /* If the mqprio options indicate that hardware should own
141 * the queue mapping then run ndo_setup_tc otherwise use the
142 * supplied and verified mapping
143 */
144 if (qopt->hw) {
145 struct tc_to_netdev tc = {.type = TC_SETUP_MQPRIO,
146 { .tc = qopt->num_tc }};
147
143 priv->hw_owned = 1;
148 priv->hw_owned = 1;
144 err = dev->netdev_ops->ndo_setup_tc(dev, qopt->num_tc);
149 err = dev->netdev_ops->ndo_setup_tc(dev, sch->handle, 0, &tc);
145 if (err)
146 goto err;
147 } else {
148 netdev_set_num_tc(dev, qopt->num_tc);
149 for (i = 0; i < qopt->num_tc; i++)
150 netdev_set_tc_queue(dev, i,
151 qopt->count[i], qopt->offset[i]);
152 }

--- 276 unchanged lines hidden ---
150 if (err)
151 goto err;
152 } else {
153 netdev_set_num_tc(dev, qopt->num_tc);
154 for (i = 0; i < qopt->num_tc; i++)
155 netdev_set_tc_queue(dev, i,
156 qopt->count[i], qopt->offset[i]);
157 }

--- 276 unchanged lines hidden ---