| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * Copyright (c) 2008, Intel Corporation. |
|---|
| 3 | | - * |
|---|
| 4 | | - * This program is free software; you can redistribute it and/or modify it |
|---|
| 5 | | - * under the terms and conditions of the GNU General Public License, |
|---|
| 6 | | - * version 2, as published by the Free Software Foundation. |
|---|
| 7 | | - * |
|---|
| 8 | | - * This program is distributed in the hope it will be useful, but WITHOUT |
|---|
| 9 | | - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|---|
| 10 | | - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
|---|
| 11 | | - * more details. |
|---|
| 12 | | - * |
|---|
| 13 | | - * You should have received a copy of the GNU General Public License along with |
|---|
| 14 | | - * this program; if not, see <http://www.gnu.org/licenses/>. |
|---|
| 15 | 4 | * |
|---|
| 16 | 5 | * Author: Alexander Duyck <alexander.h.duyck@intel.com> |
|---|
| 17 | 6 | */ |
|---|
| .. | .. |
|---|
| 54 | 43 | case TC_ACT_QUEUED: |
|---|
| 55 | 44 | case TC_ACT_TRAP: |
|---|
| 56 | 45 | *qerr = NET_XMIT_SUCCESS | __NET_XMIT_STOLEN; |
|---|
| 57 | | - /* fall through */ |
|---|
| 46 | + fallthrough; |
|---|
| 58 | 47 | case TC_ACT_SHOT: |
|---|
| 59 | 48 | return NULL; |
|---|
| 60 | 49 | } |
|---|
| .. | .. |
|---|
| 163 | 152 | |
|---|
| 164 | 153 | for (band = 0; band < q->bands; band++) |
|---|
| 165 | 154 | qdisc_reset(q->queues[band]); |
|---|
| 166 | | - sch->q.qlen = 0; |
|---|
| 167 | 155 | q->curband = 0; |
|---|
| 168 | 156 | } |
|---|
| 169 | 157 | |
|---|
| .. | .. |
|---|
| 185 | 173 | { |
|---|
| 186 | 174 | struct multiq_sched_data *q = qdisc_priv(sch); |
|---|
| 187 | 175 | struct tc_multiq_qopt *qopt; |
|---|
| 188 | | - int i; |
|---|
| 176 | + struct Qdisc **removed; |
|---|
| 177 | + int i, n_removed = 0; |
|---|
| 189 | 178 | |
|---|
| 190 | 179 | if (!netif_is_multiqueue(qdisc_dev(sch))) |
|---|
| 191 | 180 | return -EOPNOTSUPP; |
|---|
| .. | .. |
|---|
| 196 | 185 | |
|---|
| 197 | 186 | qopt->bands = qdisc_dev(sch)->real_num_tx_queues; |
|---|
| 198 | 187 | |
|---|
| 188 | + removed = kmalloc(sizeof(*removed) * (q->max_bands - q->bands), |
|---|
| 189 | + GFP_KERNEL); |
|---|
| 190 | + if (!removed) |
|---|
| 191 | + return -ENOMEM; |
|---|
| 192 | + |
|---|
| 199 | 193 | sch_tree_lock(sch); |
|---|
| 200 | 194 | q->bands = qopt->bands; |
|---|
| 201 | 195 | for (i = q->bands; i < q->max_bands; i++) { |
|---|
| 202 | 196 | if (q->queues[i] != &noop_qdisc) { |
|---|
| 203 | 197 | struct Qdisc *child = q->queues[i]; |
|---|
| 198 | + |
|---|
| 204 | 199 | q->queues[i] = &noop_qdisc; |
|---|
| 205 | | - qdisc_tree_reduce_backlog(child, child->q.qlen, |
|---|
| 206 | | - child->qstats.backlog); |
|---|
| 207 | | - qdisc_put(child); |
|---|
| 200 | + qdisc_purge_queue(child); |
|---|
| 201 | + removed[n_removed++] = child; |
|---|
| 208 | 202 | } |
|---|
| 209 | 203 | } |
|---|
| 210 | 204 | |
|---|
| 211 | 205 | sch_tree_unlock(sch); |
|---|
| 206 | + |
|---|
| 207 | + for (i = 0; i < n_removed; i++) |
|---|
| 208 | + qdisc_put(removed[i]); |
|---|
| 209 | + kfree(removed); |
|---|
| 212 | 210 | |
|---|
| 213 | 211 | for (i = 0; i < q->bands; i++) { |
|---|
| 214 | 212 | if (q->queues[i] == &noop_qdisc) { |
|---|
| .. | .. |
|---|
| 224 | 222 | if (child != &noop_qdisc) |
|---|
| 225 | 223 | qdisc_hash_add(child, true); |
|---|
| 226 | 224 | |
|---|
| 227 | | - if (old != &noop_qdisc) { |
|---|
| 228 | | - qdisc_tree_reduce_backlog(old, |
|---|
| 229 | | - old->q.qlen, |
|---|
| 230 | | - old->qstats.backlog); |
|---|
| 231 | | - qdisc_put(old); |
|---|
| 232 | | - } |
|---|
| 225 | + if (old != &noop_qdisc) |
|---|
| 226 | + qdisc_purge_queue(old); |
|---|
| 233 | 227 | sch_tree_unlock(sch); |
|---|
| 228 | + qdisc_put(old); |
|---|
| 234 | 229 | } |
|---|
| 235 | 230 | } |
|---|
| 236 | 231 | } |
|---|
| .. | .. |
|---|
| 344 | 339 | cl_q = q->queues[cl - 1]; |
|---|
| 345 | 340 | if (gnet_stats_copy_basic(qdisc_root_sleeping_running(sch), |
|---|
| 346 | 341 | d, cl_q->cpu_bstats, &cl_q->bstats) < 0 || |
|---|
| 347 | | - gnet_stats_copy_queue(d, NULL, &cl_q->qstats, cl_q->q.qlen) < 0) |
|---|
| 342 | + qdisc_qstats_copy(d, cl_q) < 0) |
|---|
| 348 | 343 | return -1; |
|---|
| 349 | 344 | |
|---|
| 350 | 345 | return 0; |
|---|