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