ramips: convert the remaining subtargets to 4.4
[openwrt/svn-archive/archive.git] / target / linux / generic / patches-4.3 / 663-remove_pfifo_fast.patch
1 --- a/net/sched/sch_generic.c
2 +++ b/net/sched/sch_generic.c
3 @@ -435,139 +435,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 sk_buff_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 sk_buff_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 -{
43 - if (skb_queue_len(&qdisc->q) < qdisc_dev(qdisc)->tx_queue_len) {
44 - int band = prio2band[skb->priority & TC_PRIO_MAX];
45 - struct pfifo_fast_priv *priv = qdisc_priv(qdisc);
46 - struct sk_buff_head *list = band2list(priv, band);
47 -
48 - priv->bitmap |= (1 << band);
49 - qdisc->q.qlen++;
50 - return __qdisc_enqueue_tail(skb, qdisc, list);
51 - }
52 -
53 - return qdisc_drop(skb, qdisc);
54 -}
55 -
56 -static struct sk_buff *pfifo_fast_dequeue(struct Qdisc *qdisc)
57 -{
58 - struct pfifo_fast_priv *priv = qdisc_priv(qdisc);
59 - int band = bitmap2band[priv->bitmap];
60 -
61 - if (likely(band >= 0)) {
62 - struct sk_buff_head *list = band2list(priv, band);
63 - struct sk_buff *skb = __qdisc_dequeue_head(qdisc, list);
64 -
65 - qdisc->q.qlen--;
66 - if (skb_queue_empty(list))
67 - priv->bitmap &= ~(1 << band);
68 -
69 - return skb;
70 - }
71 -
72 - return NULL;
73 -}
74 -
75 -static struct sk_buff *pfifo_fast_peek(struct Qdisc *qdisc)
76 -{
77 - struct pfifo_fast_priv *priv = qdisc_priv(qdisc);
78 - int band = bitmap2band[priv->bitmap];
79 -
80 - if (band >= 0) {
81 - struct sk_buff_head *list = band2list(priv, band);
82 -
83 - return skb_peek(list);
84 - }
85 -
86 - return NULL;
87 -}
88 -
89 -static void pfifo_fast_reset(struct Qdisc *qdisc)
90 -{
91 - int prio;
92 - struct pfifo_fast_priv *priv = qdisc_priv(qdisc);
93 -
94 - for (prio = 0; prio < PFIFO_FAST_BANDS; prio++)
95 - __qdisc_reset_queue(qdisc, band2list(priv, prio));
96 -
97 - priv->bitmap = 0;
98 - qdisc->qstats.backlog = 0;
99 - qdisc->q.qlen = 0;
100 -}
101 -
102 -static int pfifo_fast_dump(struct Qdisc *qdisc, struct sk_buff *skb)
103 -{
104 - struct tc_prio_qopt opt = { .bands = PFIFO_FAST_BANDS };
105 -
106 - memcpy(&opt.priomap, prio2band, TC_PRIO_MAX + 1);
107 - if (nla_put(skb, TCA_OPTIONS, sizeof(opt), &opt))
108 - goto nla_put_failure;
109 - return skb->len;
110 -
111 -nla_put_failure:
112 - return -1;
113 -}
114 -
115 -static int pfifo_fast_init(struct Qdisc *qdisc, struct nlattr *opt)
116 -{
117 - int prio;
118 - struct pfifo_fast_priv *priv = qdisc_priv(qdisc);
119 -
120 - for (prio = 0; prio < PFIFO_FAST_BANDS; prio++)
121 - __skb_queue_head_init(band2list(priv, prio));
122 -
123 - /* Can by-pass the queue discipline */
124 - qdisc->flags |= TCQ_F_CAN_BYPASS;
125 - return 0;
126 -}
127 -
128 -struct Qdisc_ops pfifo_fast_ops __read_mostly = {
129 - .id = "pfifo_fast",
130 - .priv_size = sizeof(struct pfifo_fast_priv),
131 - .enqueue = pfifo_fast_enqueue,
132 - .dequeue = pfifo_fast_dequeue,
133 - .peek = pfifo_fast_peek,
134 - .init = pfifo_fast_init,
135 - .reset = pfifo_fast_reset,
136 - .dump = pfifo_fast_dump,
137 - .owner = THIS_MODULE,
138 -};
139 -
140 static struct lock_class_key qdisc_tx_busylock;
141
142 struct Qdisc *qdisc_alloc(struct netdev_queue *dev_queue,