diff options
Diffstat (limited to 'net/sched/sch_prio.c')
-rw-r--r-- | net/sched/sch_prio.c | 39 |
1 files changed, 19 insertions, 20 deletions
diff --git a/net/sched/sch_prio.c b/net/sched/sch_prio.c index 0748fb1e3a49..2a318f2dc3e5 100644 --- a/net/sched/sch_prio.c +++ b/net/sched/sch_prio.c | |||
@@ -22,8 +22,7 @@ | |||
22 | #include <net/pkt_sched.h> | 22 | #include <net/pkt_sched.h> |
23 | 23 | ||
24 | 24 | ||
25 | struct prio_sched_data | 25 | struct prio_sched_data { |
26 | { | ||
27 | int bands; | 26 | int bands; |
28 | struct tcf_proto *filter_list; | 27 | struct tcf_proto *filter_list; |
29 | u8 prio2band[TC_PRIO_MAX+1]; | 28 | u8 prio2band[TC_PRIO_MAX+1]; |
@@ -54,7 +53,7 @@ prio_classify(struct sk_buff *skb, struct Qdisc *sch, int *qerr) | |||
54 | if (!q->filter_list || err < 0) { | 53 | if (!q->filter_list || err < 0) { |
55 | if (TC_H_MAJ(band)) | 54 | if (TC_H_MAJ(band)) |
56 | band = 0; | 55 | band = 0; |
57 | return q->queues[q->prio2band[band&TC_PRIO_MAX]]; | 56 | return q->queues[q->prio2band[band & TC_PRIO_MAX]]; |
58 | } | 57 | } |
59 | band = res.classid; | 58 | band = res.classid; |
60 | } | 59 | } |
@@ -84,8 +83,6 @@ prio_enqueue(struct sk_buff *skb, struct Qdisc *sch) | |||
84 | 83 | ||
85 | ret = qdisc_enqueue(skb, qdisc); | 84 | ret = qdisc_enqueue(skb, qdisc); |
86 | if (ret == NET_XMIT_SUCCESS) { | 85 | if (ret == NET_XMIT_SUCCESS) { |
87 | sch->bstats.bytes += qdisc_pkt_len(skb); | ||
88 | sch->bstats.packets++; | ||
89 | sch->q.qlen++; | 86 | sch->q.qlen++; |
90 | return NET_XMIT_SUCCESS; | 87 | return NET_XMIT_SUCCESS; |
91 | } | 88 | } |
@@ -108,7 +105,7 @@ static struct sk_buff *prio_peek(struct Qdisc *sch) | |||
108 | return NULL; | 105 | return NULL; |
109 | } | 106 | } |
110 | 107 | ||
111 | static struct sk_buff *prio_dequeue(struct Qdisc* sch) | 108 | static struct sk_buff *prio_dequeue(struct Qdisc *sch) |
112 | { | 109 | { |
113 | struct prio_sched_data *q = qdisc_priv(sch); | 110 | struct prio_sched_data *q = qdisc_priv(sch); |
114 | int prio; | 111 | int prio; |
@@ -117,6 +114,7 @@ static struct sk_buff *prio_dequeue(struct Qdisc* sch) | |||
117 | struct Qdisc *qdisc = q->queues[prio]; | 114 | struct Qdisc *qdisc = q->queues[prio]; |
118 | struct sk_buff *skb = qdisc->dequeue(qdisc); | 115 | struct sk_buff *skb = qdisc->dequeue(qdisc); |
119 | if (skb) { | 116 | if (skb) { |
117 | qdisc_bstats_update(sch, skb); | ||
120 | sch->q.qlen--; | 118 | sch->q.qlen--; |
121 | return skb; | 119 | return skb; |
122 | } | 120 | } |
@@ -125,7 +123,7 @@ static struct sk_buff *prio_dequeue(struct Qdisc* sch) | |||
125 | 123 | ||
126 | } | 124 | } |
127 | 125 | ||
128 | static unsigned int prio_drop(struct Qdisc* sch) | 126 | static unsigned int prio_drop(struct Qdisc *sch) |
129 | { | 127 | { |
130 | struct prio_sched_data *q = qdisc_priv(sch); | 128 | struct prio_sched_data *q = qdisc_priv(sch); |
131 | int prio; | 129 | int prio; |
@@ -144,24 +142,24 @@ static unsigned int prio_drop(struct Qdisc* sch) | |||
144 | 142 | ||
145 | 143 | ||
146 | static void | 144 | static void |
147 | prio_reset(struct Qdisc* sch) | 145 | prio_reset(struct Qdisc *sch) |
148 | { | 146 | { |
149 | int prio; | 147 | int prio; |
150 | struct prio_sched_data *q = qdisc_priv(sch); | 148 | struct prio_sched_data *q = qdisc_priv(sch); |
151 | 149 | ||
152 | for (prio=0; prio<q->bands; prio++) | 150 | for (prio = 0; prio < q->bands; prio++) |
153 | qdisc_reset(q->queues[prio]); | 151 | qdisc_reset(q->queues[prio]); |
154 | sch->q.qlen = 0; | 152 | sch->q.qlen = 0; |
155 | } | 153 | } |
156 | 154 | ||
157 | static void | 155 | static void |
158 | prio_destroy(struct Qdisc* sch) | 156 | prio_destroy(struct Qdisc *sch) |
159 | { | 157 | { |
160 | int prio; | 158 | int prio; |
161 | struct prio_sched_data *q = qdisc_priv(sch); | 159 | struct prio_sched_data *q = qdisc_priv(sch); |
162 | 160 | ||
163 | tcf_destroy_chain(&q->filter_list); | 161 | tcf_destroy_chain(&q->filter_list); |
164 | for (prio=0; prio<q->bands; prio++) | 162 | for (prio = 0; prio < q->bands; prio++) |
165 | qdisc_destroy(q->queues[prio]); | 163 | qdisc_destroy(q->queues[prio]); |
166 | } | 164 | } |
167 | 165 | ||
@@ -178,7 +176,7 @@ static int prio_tune(struct Qdisc *sch, struct nlattr *opt) | |||
178 | if (qopt->bands > TCQ_PRIO_BANDS || qopt->bands < 2) | 176 | if (qopt->bands > TCQ_PRIO_BANDS || qopt->bands < 2) |
179 | return -EINVAL; | 177 | return -EINVAL; |
180 | 178 | ||
181 | for (i=0; i<=TC_PRIO_MAX; i++) { | 179 | for (i = 0; i <= TC_PRIO_MAX; i++) { |
182 | if (qopt->priomap[i] >= qopt->bands) | 180 | if (qopt->priomap[i] >= qopt->bands) |
183 | return -EINVAL; | 181 | return -EINVAL; |
184 | } | 182 | } |
@@ -187,7 +185,7 @@ static int prio_tune(struct Qdisc *sch, struct nlattr *opt) | |||
187 | q->bands = qopt->bands; | 185 | q->bands = qopt->bands; |
188 | memcpy(q->prio2band, qopt->priomap, TC_PRIO_MAX+1); | 186 | memcpy(q->prio2band, qopt->priomap, TC_PRIO_MAX+1); |
189 | 187 | ||
190 | for (i=q->bands; i<TCQ_PRIO_BANDS; i++) { | 188 | for (i = q->bands; i < TCQ_PRIO_BANDS; i++) { |
191 | struct Qdisc *child = q->queues[i]; | 189 | struct Qdisc *child = q->queues[i]; |
192 | q->queues[i] = &noop_qdisc; | 190 | q->queues[i] = &noop_qdisc; |
193 | if (child != &noop_qdisc) { | 191 | if (child != &noop_qdisc) { |
@@ -197,10 +195,11 @@ static int prio_tune(struct Qdisc *sch, struct nlattr *opt) | |||
197 | } | 195 | } |
198 | sch_tree_unlock(sch); | 196 | sch_tree_unlock(sch); |
199 | 197 | ||
200 | for (i=0; i<q->bands; i++) { | 198 | for (i = 0; i < q->bands; i++) { |
201 | if (q->queues[i] == &noop_qdisc) { | 199 | if (q->queues[i] == &noop_qdisc) { |
202 | struct Qdisc *child, *old; | 200 | struct Qdisc *child, *old; |
203 | child = qdisc_create_dflt(qdisc_dev(sch), sch->dev_queue, | 201 | |
202 | child = qdisc_create_dflt(sch->dev_queue, | ||
204 | &pfifo_qdisc_ops, | 203 | &pfifo_qdisc_ops, |
205 | TC_H_MAKE(sch->handle, i + 1)); | 204 | TC_H_MAKE(sch->handle, i + 1)); |
206 | if (child) { | 205 | if (child) { |
@@ -225,7 +224,7 @@ static int prio_init(struct Qdisc *sch, struct nlattr *opt) | |||
225 | struct prio_sched_data *q = qdisc_priv(sch); | 224 | struct prio_sched_data *q = qdisc_priv(sch); |
226 | int i; | 225 | int i; |
227 | 226 | ||
228 | for (i=0; i<TCQ_PRIO_BANDS; i++) | 227 | for (i = 0; i < TCQ_PRIO_BANDS; i++) |
229 | q->queues[i] = &noop_qdisc; | 228 | q->queues[i] = &noop_qdisc; |
230 | 229 | ||
231 | if (opt == NULL) { | 230 | if (opt == NULL) { |
@@ -233,7 +232,7 @@ static int prio_init(struct Qdisc *sch, struct nlattr *opt) | |||
233 | } else { | 232 | } else { |
234 | int err; | 233 | int err; |
235 | 234 | ||
236 | if ((err= prio_tune(sch, opt)) != 0) | 235 | if ((err = prio_tune(sch, opt)) != 0) |
237 | return err; | 236 | return err; |
238 | } | 237 | } |
239 | return 0; | 238 | return 0; |
@@ -246,7 +245,7 @@ static int prio_dump(struct Qdisc *sch, struct sk_buff *skb) | |||
246 | struct tc_prio_qopt opt; | 245 | struct tc_prio_qopt opt; |
247 | 246 | ||
248 | opt.bands = q->bands; | 247 | opt.bands = q->bands; |
249 | memcpy(&opt.priomap, q->prio2band, TC_PRIO_MAX+1); | 248 | memcpy(&opt.priomap, q->prio2band, TC_PRIO_MAX + 1); |
250 | 249 | ||
251 | NLA_PUT(skb, TCA_OPTIONS, sizeof(opt), &opt); | 250 | NLA_PUT(skb, TCA_OPTIONS, sizeof(opt), &opt); |
252 | 251 | ||
@@ -343,7 +342,7 @@ static void prio_walk(struct Qdisc *sch, struct qdisc_walker *arg) | |||
343 | arg->count++; | 342 | arg->count++; |
344 | continue; | 343 | continue; |
345 | } | 344 | } |
346 | if (arg->fn(sch, prio+1, arg) < 0) { | 345 | if (arg->fn(sch, prio + 1, arg) < 0) { |
347 | arg->stop = 1; | 346 | arg->stop = 1; |
348 | break; | 347 | break; |
349 | } | 348 | } |
@@ -351,7 +350,7 @@ static void prio_walk(struct Qdisc *sch, struct qdisc_walker *arg) | |||
351 | } | 350 | } |
352 | } | 351 | } |
353 | 352 | ||
354 | static struct tcf_proto ** prio_find_tcf(struct Qdisc *sch, unsigned long cl) | 353 | static struct tcf_proto **prio_find_tcf(struct Qdisc *sch, unsigned long cl) |
355 | { | 354 | { |
356 | struct prio_sched_data *q = qdisc_priv(sch); | 355 | struct prio_sched_data *q = qdisc_priv(sch); |
357 | 356 | ||