kernel: remove a bunch of trailing whitespaces
[openwrt/openwrt.git] / target / linux / generic / hack-5.4 / 662-remove_pfifo_fast.patch
1 From b531d492d5ef1cf9dba0f4888eb5fd8624a6d762 Mon Sep 17 00:00:00 2001
2 From: Felix Fietkau <nbd@nbd.name>
3 Date: Fri, 7 Jul 2017 17:23:42 +0200
4 Subject: net: sched: switch default qdisc from pfifo_fast to fq_codel and remove pfifo_fast
5
6 Signed-off-by: Felix Fietkau <nbd@nbd.name>
7 ---
8 net/sched/sch_generic.c | 140 ------------------------------------------------
9 1 file changed, 140 deletions(-)
10
11 --- a/net/sched/sch_generic.c
12 +++ b/net/sched/sch_generic.c
13 @@ -594,211 +594,6 @@ struct Qdisc_ops noqueue_qdisc_ops __rea
14 .owner = THIS_MODULE,
15 };
16
17 -static const u8 prio2band[TC_PRIO_MAX + 1] = {
18 - 1, 2, 2, 2, 1, 2, 0, 0 , 1, 1, 1, 1, 1, 1, 1, 1
19 -};
20 -
21 -/* 3-band FIFO queue: old style, but should be a bit faster than
22 - generic prio+fifo combination.
23 - */
24 -
25 -#define PFIFO_FAST_BANDS 3
26 -
27 -/*
28 - * Private data for a pfifo_fast scheduler containing:
29 - * - rings for priority bands
30 - */
31 -struct pfifo_fast_priv {
32 - struct skb_array q[PFIFO_FAST_BANDS];
33 -};
34 -
35 -static inline struct skb_array *band2list(struct pfifo_fast_priv *priv,
36 - int band)
37 -{
38 - return &priv->q[band];
39 -}
40 -
41 -static int pfifo_fast_enqueue(struct sk_buff *skb, struct Qdisc *qdisc,
42 - struct sk_buff **to_free)
43 -{
44 - int band = prio2band[skb->priority & TC_PRIO_MAX];
45 - struct pfifo_fast_priv *priv = qdisc_priv(qdisc);
46 - struct skb_array *q = band2list(priv, band);
47 - unsigned int pkt_len = qdisc_pkt_len(skb);
48 - int err;
49 -
50 - err = skb_array_produce(q, skb);
51 -
52 - if (unlikely(err)) {
53 - if (qdisc_is_percpu_stats(qdisc))
54 - return qdisc_drop_cpu(skb, qdisc, to_free);
55 - else
56 - return qdisc_drop(skb, qdisc, to_free);
57 - }
58 -
59 - qdisc_update_stats_at_enqueue(qdisc, pkt_len);
60 - return NET_XMIT_SUCCESS;
61 -}
62 -
63 -static struct sk_buff *pfifo_fast_dequeue(struct Qdisc *qdisc)
64 -{
65 - struct pfifo_fast_priv *priv = qdisc_priv(qdisc);
66 - struct sk_buff *skb = NULL;
67 - int band;
68 -
69 - for (band = 0; band < PFIFO_FAST_BANDS && !skb; band++) {
70 - struct skb_array *q = band2list(priv, band);
71 -
72 - if (__skb_array_empty(q))
73 - continue;
74 -
75 - skb = __skb_array_consume(q);
76 - }
77 - if (likely(skb)) {
78 - qdisc_update_stats_at_dequeue(qdisc, skb);
79 - } else {
80 - WRITE_ONCE(qdisc->empty, true);
81 - }
82 -
83 - return skb;
84 -}
85 -
86 -static struct sk_buff *pfifo_fast_peek(struct Qdisc *qdisc)
87 -{
88 - struct pfifo_fast_priv *priv = qdisc_priv(qdisc);
89 - struct sk_buff *skb = NULL;
90 - int band;
91 -
92 - for (band = 0; band < PFIFO_FAST_BANDS && !skb; band++) {
93 - struct skb_array *q = band2list(priv, band);
94 -
95 - skb = __skb_array_peek(q);
96 - }
97 -
98 - return skb;
99 -}
100 -
101 -static void pfifo_fast_reset(struct Qdisc *qdisc)
102 -{
103 - int i, band;
104 - struct pfifo_fast_priv *priv = qdisc_priv(qdisc);
105 -
106 - for (band = 0; band < PFIFO_FAST_BANDS; band++) {
107 - struct skb_array *q = band2list(priv, band);
108 - struct sk_buff *skb;
109 -
110 - /* NULL ring is possible if destroy path is due to a failed
111 - * skb_array_init() in pfifo_fast_init() case.
112 - */
113 - if (!q->ring.queue)
114 - continue;
115 -
116 - while ((skb = __skb_array_consume(q)) != NULL)
117 - kfree_skb(skb);
118 - }
119 -
120 - if (qdisc_is_percpu_stats(qdisc)) {
121 - for_each_possible_cpu(i) {
122 - struct gnet_stats_queue *q;
123 -
124 - q = per_cpu_ptr(qdisc->cpu_qstats, i);
125 - q->backlog = 0;
126 - q->qlen = 0;
127 - }
128 - }
129 -}
130 -
131 -static int pfifo_fast_dump(struct Qdisc *qdisc, struct sk_buff *skb)
132 -{
133 - struct tc_prio_qopt opt = { .bands = PFIFO_FAST_BANDS };
134 -
135 - memcpy(&opt.priomap, prio2band, TC_PRIO_MAX + 1);
136 - if (nla_put(skb, TCA_OPTIONS, sizeof(opt), &opt))
137 - goto nla_put_failure;
138 - return skb->len;
139 -
140 -nla_put_failure:
141 - return -1;
142 -}
143 -
144 -static int pfifo_fast_init(struct Qdisc *qdisc, struct nlattr *opt,
145 - struct netlink_ext_ack *extack)
146 -{
147 - unsigned int qlen = qdisc_dev(qdisc)->tx_queue_len;
148 - struct pfifo_fast_priv *priv = qdisc_priv(qdisc);
149 - int prio;
150 -
151 - /* guard against zero length rings */
152 - if (!qlen)
153 - return -EINVAL;
154 -
155 - for (prio = 0; prio < PFIFO_FAST_BANDS; prio++) {
156 - struct skb_array *q = band2list(priv, prio);
157 - int err;
158 -
159 - err = skb_array_init(q, qlen, GFP_KERNEL);
160 - if (err)
161 - return -ENOMEM;
162 - }
163 -
164 - /* Can by-pass the queue discipline */
165 - qdisc->flags |= TCQ_F_CAN_BYPASS;
166 - return 0;
167 -}
168 -
169 -static void pfifo_fast_destroy(struct Qdisc *sch)
170 -{
171 - struct pfifo_fast_priv *priv = qdisc_priv(sch);
172 - int prio;
173 -
174 - for (prio = 0; prio < PFIFO_FAST_BANDS; prio++) {
175 - struct skb_array *q = band2list(priv, prio);
176 -
177 - /* NULL ring is possible if destroy path is due to a failed
178 - * skb_array_init() in pfifo_fast_init() case.
179 - */
180 - if (!q->ring.queue)
181 - continue;
182 - /* Destroy ring but no need to kfree_skb because a call to
183 - * pfifo_fast_reset() has already done that work.
184 - */
185 - ptr_ring_cleanup(&q->ring, NULL);
186 - }
187 -}
188 -
189 -static int pfifo_fast_change_tx_queue_len(struct Qdisc *sch,
190 - unsigned int new_len)
191 -{
192 - struct pfifo_fast_priv *priv = qdisc_priv(sch);
193 - struct skb_array *bands[PFIFO_FAST_BANDS];
194 - int prio;
195 -
196 - for (prio = 0; prio < PFIFO_FAST_BANDS; prio++) {
197 - struct skb_array *q = band2list(priv, prio);
198 -
199 - bands[prio] = q;
200 - }
201 -
202 - return skb_array_resize_multiple(bands, PFIFO_FAST_BANDS, new_len,
203 - GFP_KERNEL);
204 -}
205 -
206 -struct Qdisc_ops pfifo_fast_ops __read_mostly = {
207 - .id = "pfifo_fast",
208 - .priv_size = sizeof(struct pfifo_fast_priv),
209 - .enqueue = pfifo_fast_enqueue,
210 - .dequeue = pfifo_fast_dequeue,
211 - .peek = pfifo_fast_peek,
212 - .init = pfifo_fast_init,
213 - .destroy = pfifo_fast_destroy,
214 - .reset = pfifo_fast_reset,
215 - .dump = pfifo_fast_dump,
216 - .change_tx_queue_len = pfifo_fast_change_tx_queue_len,
217 - .owner = THIS_MODULE,
218 - .static_flags = TCQ_F_NOLOCK | TCQ_F_CPUSTATS,
219 -};
220 -EXPORT_SYMBOL(pfifo_fast_ops);
221 -
222 struct Qdisc *qdisc_alloc(struct netdev_queue *dev_queue,
223 const struct Qdisc_ops *ops,
224 struct netlink_ext_ack *extack)