aaa0d768430cee00feb8b808a1b0c1592b0a2be3
[openwrt/openwrt.git] / target / linux / generic / hack-4.9 / 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 diff --git a/net/sched/sch_generic.c b/net/sched/sch_generic.c
12 index 97de97e3c5e2..a62de9e4e897 100644
13 --- a/net/sched/sch_generic.c
14 +++ b/net/sched/sch_generic.c
15 @@ -449,146 +449,6 @@ struct Qdisc_ops noqueue_qdisc_ops __read_mostly = {
16 .owner = THIS_MODULE,
17 };
18
19 -static const u8 prio2band[TC_PRIO_MAX + 1] = {
20 - 1, 2, 2, 2, 1, 2, 0, 0 , 1, 1, 1, 1, 1, 1, 1, 1
21 -};
22 -
23 -/* 3-band FIFO queue: old style, but should be a bit faster than
24 - generic prio+fifo combination.
25 - */
26 -
27 -#define PFIFO_FAST_BANDS 3
28 -
29 -/*
30 - * Private data for a pfifo_fast scheduler containing:
31 - * - queues for the three band
32 - * - bitmap indicating which of the bands contain skbs
33 - */
34 -struct pfifo_fast_priv {
35 - u32 bitmap;
36 - struct qdisc_skb_head q[PFIFO_FAST_BANDS];
37 -};
38 -
39 -/*
40 - * Convert a bitmap to the first band number where an skb is queued, where:
41 - * bitmap=0 means there are no skbs on any band.
42 - * bitmap=1 means there is an skb on band 0.
43 - * bitmap=7 means there are skbs on all 3 bands, etc.
44 - */
45 -static const int bitmap2band[] = {-1, 0, 1, 0, 2, 0, 1, 0};
46 -
47 -static inline struct qdisc_skb_head *band2list(struct pfifo_fast_priv *priv,
48 - int band)
49 -{
50 - return priv->q + band;
51 -}
52 -
53 -static int pfifo_fast_enqueue(struct sk_buff *skb, struct Qdisc *qdisc,
54 - struct sk_buff **to_free)
55 -{
56 - if (qdisc->q.qlen < qdisc_dev(qdisc)->tx_queue_len) {
57 - int band = prio2band[skb->priority & TC_PRIO_MAX];
58 - struct pfifo_fast_priv *priv = qdisc_priv(qdisc);
59 - struct qdisc_skb_head *list = band2list(priv, band);
60 -
61 - priv->bitmap |= (1 << band);
62 - qdisc->q.qlen++;
63 - return __qdisc_enqueue_tail(skb, qdisc, list);
64 - }
65 -
66 - return qdisc_drop(skb, qdisc, to_free);
67 -}
68 -
69 -static struct sk_buff *pfifo_fast_dequeue(struct Qdisc *qdisc)
70 -{
71 - struct pfifo_fast_priv *priv = qdisc_priv(qdisc);
72 - int band = bitmap2band[priv->bitmap];
73 -
74 - if (likely(band >= 0)) {
75 - struct qdisc_skb_head *qh = band2list(priv, band);
76 - struct sk_buff *skb = __qdisc_dequeue_head(qh);
77 -
78 - if (likely(skb != NULL)) {
79 - qdisc_qstats_backlog_dec(qdisc, skb);
80 - qdisc_bstats_update(qdisc, skb);
81 - }
82 -
83 - qdisc->q.qlen--;
84 - if (qh->qlen == 0)
85 - priv->bitmap &= ~(1 << band);
86 -
87 - return skb;
88 - }
89 -
90 - return NULL;
91 -}
92 -
93 -static struct sk_buff *pfifo_fast_peek(struct Qdisc *qdisc)
94 -{
95 - struct pfifo_fast_priv *priv = qdisc_priv(qdisc);
96 - int band = bitmap2band[priv->bitmap];
97 -
98 - if (band >= 0) {
99 - struct qdisc_skb_head *qh = band2list(priv, band);
100 -
101 - return qh->head;
102 - }
103 -
104 - return NULL;
105 -}
106 -
107 -static void pfifo_fast_reset(struct Qdisc *qdisc)
108 -{
109 - int prio;
110 - struct pfifo_fast_priv *priv = qdisc_priv(qdisc);
111 -
112 - for (prio = 0; prio < PFIFO_FAST_BANDS; prio++)
113 - __qdisc_reset_queue(band2list(priv, prio));
114 -
115 - priv->bitmap = 0;
116 - qdisc->qstats.backlog = 0;
117 - qdisc->q.qlen = 0;
118 -}
119 -
120 -static int pfifo_fast_dump(struct Qdisc *qdisc, struct sk_buff *skb)
121 -{
122 - struct tc_prio_qopt opt = { .bands = PFIFO_FAST_BANDS };
123 -
124 - memcpy(&opt.priomap, prio2band, TC_PRIO_MAX + 1);
125 - if (nla_put(skb, TCA_OPTIONS, sizeof(opt), &opt))
126 - goto nla_put_failure;
127 - return skb->len;
128 -
129 -nla_put_failure:
130 - return -1;
131 -}
132 -
133 -static int pfifo_fast_init(struct Qdisc *qdisc, struct nlattr *opt)
134 -{
135 - int prio;
136 - struct pfifo_fast_priv *priv = qdisc_priv(qdisc);
137 -
138 - for (prio = 0; prio < PFIFO_FAST_BANDS; prio++)
139 - qdisc_skb_head_init(band2list(priv, prio));
140 -
141 - /* Can by-pass the queue discipline */
142 - qdisc->flags |= TCQ_F_CAN_BYPASS;
143 - return 0;
144 -}
145 -
146 -struct Qdisc_ops pfifo_fast_ops __read_mostly = {
147 - .id = "pfifo_fast",
148 - .priv_size = sizeof(struct pfifo_fast_priv),
149 - .enqueue = pfifo_fast_enqueue,
150 - .dequeue = pfifo_fast_dequeue,
151 - .peek = pfifo_fast_peek,
152 - .init = pfifo_fast_init,
153 - .reset = pfifo_fast_reset,
154 - .dump = pfifo_fast_dump,
155 - .owner = THIS_MODULE,
156 -};
157 -EXPORT_SYMBOL(pfifo_fast_ops);
158 -
159 static struct lock_class_key qdisc_tx_busylock;
160 static struct lock_class_key qdisc_running_key;
161
162 --
163 2.11.0
164