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