aboutsummaryrefslogtreecommitdiffstats
path: root/net/mac80211/wme.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/mac80211/wme.c')
-rw-r--r--net/mac80211/wme.c677
1 files changed, 124 insertions, 553 deletions
diff --git a/net/mac80211/wme.c b/net/mac80211/wme.c
index 635b996c8c35..07edda0b8a5c 100644
--- a/net/mac80211/wme.c
+++ b/net/mac80211/wme.c
@@ -18,61 +18,42 @@
18#include "ieee80211_i.h" 18#include "ieee80211_i.h"
19#include "wme.h" 19#include "wme.h"
20 20
21/* maximum number of hardware queues we support. */ 21/* Default mapping in classifier to work with default
22#define TC_80211_MAX_QUEUES 16 22 * queue setup.
23 23 */
24const int ieee802_1d_to_ac[8] = { 2, 3, 3, 2, 1, 1, 0, 0 }; 24const int ieee802_1d_to_ac[8] = { 2, 3, 3, 2, 1, 1, 0, 0 };
25 25
26struct ieee80211_sched_data
27{
28 unsigned long qdisc_pool[BITS_TO_LONGS(TC_80211_MAX_QUEUES)];
29 struct tcf_proto *filter_list;
30 struct Qdisc *queues[TC_80211_MAX_QUEUES];
31 struct sk_buff_head requeued[TC_80211_MAX_QUEUES];
32};
33
34static const char llc_ip_hdr[8] = {0xAA, 0xAA, 0x3, 0, 0, 0, 0x08, 0}; 26static const char llc_ip_hdr[8] = {0xAA, 0xAA, 0x3, 0, 0, 0, 0x08, 0};
35 27
36/* given a data frame determine the 802.1p/1d tag to use */ 28/* Given a data frame determine the 802.1p/1d tag to use. */
37static inline unsigned classify_1d(struct sk_buff *skb, struct Qdisc *qd) 29static unsigned int classify_1d(struct sk_buff *skb)
38{ 30{
39 struct iphdr *ip; 31 unsigned int dscp;
40 int dscp;
41 int offset;
42
43 struct ieee80211_sched_data *q = qdisc_priv(qd);
44 struct tcf_result res = { -1, 0 };
45
46 /* if there is a user set filter list, call out to that */
47 if (q->filter_list) {
48 tc_classify(skb, q->filter_list, &res);
49 if (res.class != -1)
50 return res.class;
51 }
52 32
53 /* skb->priority values from 256->263 are magic values to 33 /* skb->priority values from 256->263 are magic values to
54 * directly indicate a specific 802.1d priority. 34 * directly indicate a specific 802.1d priority. This is used
55 * This is used to allow 802.1d priority to be passed directly in 35 * to allow 802.1d priority to be passed directly in from VLAN
56 * from VLAN tags, etc. */ 36 * tags, etc.
37 */
57 if (skb->priority >= 256 && skb->priority <= 263) 38 if (skb->priority >= 256 && skb->priority <= 263)
58 return skb->priority - 256; 39 return skb->priority - 256;
59 40
60 /* check there is a valid IP header present */ 41 switch (skb->protocol) {
61 offset = ieee80211_get_hdrlen_from_skb(skb); 42 case __constant_htons(ETH_P_IP):
62 if (skb->len < offset + sizeof(llc_ip_hdr) + sizeof(*ip) || 43 dscp = ip_hdr(skb)->tos & 0xfc;
63 memcmp(skb->data + offset, llc_ip_hdr, sizeof(llc_ip_hdr))) 44 break;
64 return 0;
65 45
66 ip = (struct iphdr *) (skb->data + offset + sizeof(llc_ip_hdr)); 46 default:
47 return 0;
48 }
67 49
68 dscp = ip->tos & 0xfc;
69 if (dscp & 0x1c) 50 if (dscp & 0x1c)
70 return 0; 51 return 0;
71 return dscp >> 5; 52 return dscp >> 5;
72} 53}
73 54
74 55
75static inline int wme_downgrade_ac(struct sk_buff *skb) 56static int wme_downgrade_ac(struct sk_buff *skb)
76{ 57{
77 switch (skb->priority) { 58 switch (skb->priority) {
78 case 6: 59 case 6:
@@ -93,43 +74,38 @@ static inline int wme_downgrade_ac(struct sk_buff *skb)
93} 74}
94 75
95 76
96/* positive return value indicates which queue to use 77/* Indicate which queue to use. */
97 * negative return value indicates to drop the frame */ 78static u16 classify80211(struct sk_buff *skb, struct net_device *dev)
98static inline int classify80211(struct sk_buff *skb, struct Qdisc *qd)
99{ 79{
100 struct ieee80211_local *local = wdev_priv(qd->dev->ieee80211_ptr); 80 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
101 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; 81 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
102 unsigned short fc = le16_to_cpu(hdr->frame_control);
103 int qos;
104 82
105 /* see if frame is data or non data frame */ 83 if (!ieee80211_is_data(hdr->frame_control)) {
106 if (unlikely((fc & IEEE80211_FCTL_FTYPE) != IEEE80211_FTYPE_DATA)) {
107 /* management frames go on AC_VO queue, but are sent 84 /* management frames go on AC_VO queue, but are sent
108 * without QoS control fields */ 85 * without QoS control fields */
109 return IEEE80211_TX_QUEUE_DATA0; 86 return 0;
110 } 87 }
111 88
112 if (0 /* injected */) { 89 if (0 /* injected */) {
113 /* use AC from radiotap */ 90 /* use AC from radiotap */
114 } 91 }
115 92
116 /* is this a QoS frame? */ 93 if (!ieee80211_is_data_qos(hdr->frame_control)) {
117 qos = fc & IEEE80211_STYPE_QOS_DATA;
118
119 if (!qos) {
120 skb->priority = 0; /* required for correct WPA/11i MIC */ 94 skb->priority = 0; /* required for correct WPA/11i MIC */
121 return ieee802_1d_to_ac[skb->priority]; 95 return ieee802_1d_to_ac[skb->priority];
122 } 96 }
123 97
124 /* use the data classifier to determine what 802.1d tag the 98 /* use the data classifier to determine what 802.1d tag the
125 * data frame has */ 99 * data frame has */
126 skb->priority = classify_1d(skb, qd); 100 skb->priority = classify_1d(skb);
127 101
128 /* in case we are a client verify acm is not set for this ac */ 102 /* in case we are a client verify acm is not set for this ac */
129 while (unlikely(local->wmm_acm & BIT(skb->priority))) { 103 while (unlikely(local->wmm_acm & BIT(skb->priority))) {
130 if (wme_downgrade_ac(skb)) { 104 if (wme_downgrade_ac(skb)) {
131 /* No AC with lower priority has acm=0, drop packet. */ 105 /* The old code would drop the packet in this
132 return -1; 106 * case.
107 */
108 return 0;
133 } 109 }
134 } 110 }
135 111
@@ -137,55 +113,52 @@ static inline int classify80211(struct sk_buff *skb, struct Qdisc *qd)
137 return ieee802_1d_to_ac[skb->priority]; 113 return ieee802_1d_to_ac[skb->priority];
138} 114}
139 115
140 116u16 ieee80211_select_queue(struct net_device *dev, struct sk_buff *skb)
141static int wme_qdiscop_enqueue(struct sk_buff *skb, struct Qdisc* qd)
142{ 117{
143 struct ieee80211_local *local = wdev_priv(qd->dev->ieee80211_ptr);
144 struct ieee80211_sched_data *q = qdisc_priv(qd);
145 struct ieee80211_tx_packet_data *pkt_data =
146 (struct ieee80211_tx_packet_data *) skb->cb;
147 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; 118 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
148 unsigned short fc = le16_to_cpu(hdr->frame_control); 119 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
149 struct Qdisc *qdisc; 120 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
150 int err, queue;
151 struct sta_info *sta; 121 struct sta_info *sta;
122 u16 queue;
152 u8 tid; 123 u8 tid;
153 124
154 if (pkt_data->flags & IEEE80211_TXPD_REQUEUE) { 125 queue = classify80211(skb, dev);
155 queue = pkt_data->queue; 126 if (unlikely(queue >= local->hw.queues))
127 queue = local->hw.queues - 1;
128
129 if (info->flags & IEEE80211_TX_CTL_REQUEUE) {
156 rcu_read_lock(); 130 rcu_read_lock();
157 sta = sta_info_get(local, hdr->addr1); 131 sta = sta_info_get(local, hdr->addr1);
158 tid = skb->priority & QOS_CONTROL_TAG1D_MASK; 132 tid = skb->priority & IEEE80211_QOS_CTL_TAG1D_MASK;
159 if (sta) { 133 if (sta) {
134 struct ieee80211_hw *hw = &local->hw;
160 int ampdu_queue = sta->tid_to_tx_q[tid]; 135 int ampdu_queue = sta->tid_to_tx_q[tid];
161 if ((ampdu_queue < local->hw.queues) && 136
162 test_bit(ampdu_queue, q->qdisc_pool)) { 137 if ((ampdu_queue < ieee80211_num_queues(hw)) &&
138 test_bit(ampdu_queue, local->queue_pool)) {
163 queue = ampdu_queue; 139 queue = ampdu_queue;
164 pkt_data->flags |= IEEE80211_TXPD_AMPDU; 140 info->flags |= IEEE80211_TX_CTL_AMPDU;
165 } else { 141 } else {
166 pkt_data->flags &= ~IEEE80211_TXPD_AMPDU; 142 info->flags &= ~IEEE80211_TX_CTL_AMPDU;
167 } 143 }
168 } 144 }
169 rcu_read_unlock(); 145 rcu_read_unlock();
170 skb_queue_tail(&q->requeued[queue], skb);
171 qd->q.qlen++;
172 return 0;
173 }
174 146
175 queue = classify80211(skb, qd); 147 return queue;
148 }
176 149
177 /* now we know the 1d priority, fill in the QoS header if there is one 150 /* Now we know the 1d priority, fill in the QoS header if
151 * there is one.
178 */ 152 */
179 if (WLAN_FC_IS_QOS_DATA(fc)) { 153 if (ieee80211_is_data_qos(hdr->frame_control)) {
180 u8 *p = skb->data + ieee80211_get_hdrlen(fc) - 2; 154 u8 *p = ieee80211_get_qos_ctl(hdr);
181 u8 ack_policy = 0; 155 u8 ack_policy = 0;
182 tid = skb->priority & QOS_CONTROL_TAG1D_MASK; 156 tid = skb->priority & IEEE80211_QOS_CTL_TAG1D_MASK;
183 if (local->wifi_wme_noack_test) 157 if (local->wifi_wme_noack_test)
184 ack_policy |= QOS_CONTROL_ACK_POLICY_NOACK << 158 ack_policy |= QOS_CONTROL_ACK_POLICY_NOACK <<
185 QOS_CONTROL_ACK_POLICY_SHIFT; 159 QOS_CONTROL_ACK_POLICY_SHIFT;
186 /* qos header is 2 bytes, second reserved */ 160 /* qos header is 2 bytes, second reserved */
187 *p = ack_policy | tid; 161 *p++ = ack_policy | tid;
188 p++;
189 *p = 0; 162 *p = 0;
190 163
191 rcu_read_lock(); 164 rcu_read_lock();
@@ -193,476 +166,37 @@ static int wme_qdiscop_enqueue(struct sk_buff *skb, struct Qdisc* qd)
193 sta = sta_info_get(local, hdr->addr1); 166 sta = sta_info_get(local, hdr->addr1);
194 if (sta) { 167 if (sta) {
195 int ampdu_queue = sta->tid_to_tx_q[tid]; 168 int ampdu_queue = sta->tid_to_tx_q[tid];
196 if ((ampdu_queue < local->hw.queues) && 169 struct ieee80211_hw *hw = &local->hw;
197 test_bit(ampdu_queue, q->qdisc_pool)) { 170
171 if ((ampdu_queue < ieee80211_num_queues(hw)) &&
172 test_bit(ampdu_queue, local->queue_pool)) {
198 queue = ampdu_queue; 173 queue = ampdu_queue;
199 pkt_data->flags |= IEEE80211_TXPD_AMPDU; 174 info->flags |= IEEE80211_TX_CTL_AMPDU;
200 } else { 175 } else {
201 pkt_data->flags &= ~IEEE80211_TXPD_AMPDU; 176 info->flags &= ~IEEE80211_TX_CTL_AMPDU;
202 } 177 }
203 } 178 }
204 179
205 rcu_read_unlock(); 180 rcu_read_unlock();
206 } 181 }
207 182
208 if (unlikely(queue >= local->hw.queues)) {
209#if 0
210 if (net_ratelimit()) {
211 printk(KERN_DEBUG "%s - queue=%d (hw does not "
212 "support) -> %d\n",
213 __func__, queue, local->hw.queues - 1);
214 }
215#endif
216 queue = local->hw.queues - 1;
217 }
218
219 if (unlikely(queue < 0)) {
220 kfree_skb(skb);
221 err = NET_XMIT_DROP;
222 } else {
223 tid = skb->priority & QOS_CONTROL_TAG1D_MASK;
224 pkt_data->queue = (unsigned int) queue;
225 qdisc = q->queues[queue];
226 err = qdisc->enqueue(skb, qdisc);
227 if (err == NET_XMIT_SUCCESS) {
228 qd->q.qlen++;
229 qd->bstats.bytes += skb->len;
230 qd->bstats.packets++;
231 return NET_XMIT_SUCCESS;
232 }
233 }
234 qd->qstats.drops++;
235 return err;
236}
237
238
239/* TODO: clean up the cases where master_hard_start_xmit
240 * returns non 0 - it shouldn't ever do that. Once done we
241 * can remove this function */
242static int wme_qdiscop_requeue(struct sk_buff *skb, struct Qdisc* qd)
243{
244 struct ieee80211_sched_data *q = qdisc_priv(qd);
245 struct ieee80211_tx_packet_data *pkt_data =
246 (struct ieee80211_tx_packet_data *) skb->cb;
247 struct Qdisc *qdisc;
248 int err;
249
250 /* we recorded which queue to use earlier! */
251 qdisc = q->queues[pkt_data->queue];
252
253 if ((err = qdisc->ops->requeue(skb, qdisc)) == 0) {
254 qd->q.qlen++;
255 return 0;
256 }
257 qd->qstats.drops++;
258 return err;
259}
260
261
262static struct sk_buff *wme_qdiscop_dequeue(struct Qdisc* qd)
263{
264 struct ieee80211_sched_data *q = qdisc_priv(qd);
265 struct net_device *dev = qd->dev;
266 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
267 struct ieee80211_hw *hw = &local->hw;
268 struct sk_buff *skb;
269 struct Qdisc *qdisc;
270 int queue;
271
272 /* check all the h/w queues in numeric/priority order */
273 for (queue = 0; queue < hw->queues; queue++) {
274 /* see if there is room in this hardware queue */
275 if ((test_bit(IEEE80211_LINK_STATE_XOFF,
276 &local->state[queue])) ||
277 (test_bit(IEEE80211_LINK_STATE_PENDING,
278 &local->state[queue])) ||
279 (!test_bit(queue, q->qdisc_pool)))
280 continue;
281
282 /* there is space - try and get a frame */
283 skb = skb_dequeue(&q->requeued[queue]);
284 if (skb) {
285 qd->q.qlen--;
286 return skb;
287 }
288
289 qdisc = q->queues[queue];
290 skb = qdisc->dequeue(qdisc);
291 if (skb) {
292 qd->q.qlen--;
293 return skb;
294 }
295 }
296 /* returning a NULL here when all the h/w queues are full means we
297 * never need to call netif_stop_queue in the driver */
298 return NULL;
299}
300
301
302static void wme_qdiscop_reset(struct Qdisc* qd)
303{
304 struct ieee80211_sched_data *q = qdisc_priv(qd);
305 struct ieee80211_local *local = wdev_priv(qd->dev->ieee80211_ptr);
306 struct ieee80211_hw *hw = &local->hw;
307 int queue;
308
309 /* QUESTION: should we have some hardware flush functionality here? */
310
311 for (queue = 0; queue < hw->queues; queue++) {
312 skb_queue_purge(&q->requeued[queue]);
313 qdisc_reset(q->queues[queue]);
314 }
315 qd->q.qlen = 0;
316}
317
318
319static void wme_qdiscop_destroy(struct Qdisc* qd)
320{
321 struct ieee80211_sched_data *q = qdisc_priv(qd);
322 struct ieee80211_local *local = wdev_priv(qd->dev->ieee80211_ptr);
323 struct ieee80211_hw *hw = &local->hw;
324 int queue;
325
326 tcf_destroy_chain(q->filter_list);
327 q->filter_list = NULL;
328
329 for (queue=0; queue < hw->queues; queue++) {
330 skb_queue_purge(&q->requeued[queue]);
331 qdisc_destroy(q->queues[queue]);
332 q->queues[queue] = &noop_qdisc;
333 }
334}
335
336
337/* called whenever parameters are updated on existing qdisc */
338static int wme_qdiscop_tune(struct Qdisc *qd, struct nlattr *opt)
339{
340/* struct ieee80211_sched_data *q = qdisc_priv(qd);
341*/
342 /* check our options block is the right size */
343 /* copy any options to our local structure */
344/* Ignore options block for now - always use static mapping
345 struct tc_ieee80211_qopt *qopt = nla_data(opt);
346
347 if (opt->nla_len < nla_attr_size(sizeof(*qopt)))
348 return -EINVAL;
349 memcpy(q->tag2queue, qopt->tag2queue, sizeof(qopt->tag2queue));
350*/
351 return 0;
352}
353
354
355/* called during initial creation of qdisc on device */
356static int wme_qdiscop_init(struct Qdisc *qd, struct nlattr *opt)
357{
358 struct ieee80211_sched_data *q = qdisc_priv(qd);
359 struct net_device *dev = qd->dev;
360 struct ieee80211_local *local;
361 int queues;
362 int err = 0, i;
363
364 /* check that device is a mac80211 device */
365 if (!dev->ieee80211_ptr ||
366 dev->ieee80211_ptr->wiphy->privid != mac80211_wiphy_privid)
367 return -EINVAL;
368
369 /* check this device is an ieee80211 master type device */
370 if (dev->type != ARPHRD_IEEE80211)
371 return -EINVAL;
372
373 /* check that there is no qdisc currently attached to device
374 * this ensures that we will be the root qdisc. (I can't find a better
375 * way to test this explicitly) */
376 if (dev->qdisc_sleeping != &noop_qdisc)
377 return -EINVAL;
378
379 if (qd->flags & TCQ_F_INGRESS)
380 return -EINVAL;
381
382 local = wdev_priv(dev->ieee80211_ptr);
383 queues = local->hw.queues;
384
385 /* if options were passed in, set them */
386 if (opt) {
387 err = wme_qdiscop_tune(qd, opt);
388 }
389
390 /* create child queues */
391 for (i = 0; i < queues; i++) {
392 skb_queue_head_init(&q->requeued[i]);
393 q->queues[i] = qdisc_create_dflt(qd->dev, &pfifo_qdisc_ops,
394 qd->handle);
395 if (!q->queues[i]) {
396 q->queues[i] = &noop_qdisc;
397 printk(KERN_ERR "%s child qdisc %i creation failed\n",
398 dev->name, i);
399 }
400 }
401
402 /* reserve all legacy QoS queues */
403 for (i = 0; i < min(IEEE80211_TX_QUEUE_DATA4, queues); i++)
404 set_bit(i, q->qdisc_pool);
405
406 return err;
407}
408
409static int wme_qdiscop_dump(struct Qdisc *qd, struct sk_buff *skb)
410{
411/* struct ieee80211_sched_data *q = qdisc_priv(qd);
412 unsigned char *p = skb->tail;
413 struct tc_ieee80211_qopt opt;
414
415 memcpy(&opt.tag2queue, q->tag2queue, TC_80211_MAX_TAG + 1);
416 NLA_PUT(skb, TCA_OPTIONS, sizeof(opt), &opt);
417*/ return skb->len;
418/*
419nla_put_failure:
420 skb_trim(skb, p - skb->data);*/
421 return -1;
422}
423
424
425static int wme_classop_graft(struct Qdisc *qd, unsigned long arg,
426 struct Qdisc *new, struct Qdisc **old)
427{
428 struct ieee80211_sched_data *q = qdisc_priv(qd);
429 struct ieee80211_local *local = wdev_priv(qd->dev->ieee80211_ptr);
430 struct ieee80211_hw *hw = &local->hw;
431 unsigned long queue = arg - 1;
432
433 if (queue >= hw->queues)
434 return -EINVAL;
435
436 if (!new)
437 new = &noop_qdisc;
438
439 sch_tree_lock(qd);
440 *old = q->queues[queue];
441 q->queues[queue] = new;
442 qdisc_reset(*old);
443 sch_tree_unlock(qd);
444
445 return 0;
446}
447
448
449static struct Qdisc *
450wme_classop_leaf(struct Qdisc *qd, unsigned long arg)
451{
452 struct ieee80211_sched_data *q = qdisc_priv(qd);
453 struct ieee80211_local *local = wdev_priv(qd->dev->ieee80211_ptr);
454 struct ieee80211_hw *hw = &local->hw;
455 unsigned long queue = arg - 1;
456
457 if (queue >= hw->queues)
458 return NULL;
459
460 return q->queues[queue];
461}
462
463
464static unsigned long wme_classop_get(struct Qdisc *qd, u32 classid)
465{
466 struct ieee80211_local *local = wdev_priv(qd->dev->ieee80211_ptr);
467 struct ieee80211_hw *hw = &local->hw;
468 unsigned long queue = TC_H_MIN(classid);
469
470 if (queue - 1 >= hw->queues)
471 return 0;
472
473 return queue; 183 return queue;
474} 184}
475 185
476
477static unsigned long wme_classop_bind(struct Qdisc *qd, unsigned long parent,
478 u32 classid)
479{
480 return wme_classop_get(qd, classid);
481}
482
483
484static void wme_classop_put(struct Qdisc *q, unsigned long cl)
485{
486}
487
488
489static int wme_classop_change(struct Qdisc *qd, u32 handle, u32 parent,
490 struct nlattr **tca, unsigned long *arg)
491{
492 unsigned long cl = *arg;
493 struct ieee80211_local *local = wdev_priv(qd->dev->ieee80211_ptr);
494 struct ieee80211_hw *hw = &local->hw;
495
496 if (cl - 1 > hw->queues)
497 return -ENOENT;
498
499 /* TODO: put code to program hardware queue parameters here,
500 * to allow programming from tc command line */
501
502 return 0;
503}
504
505
506/* we don't support deleting hardware queues
507 * when we add WMM-SA support - TSPECs may be deleted here */
508static int wme_classop_delete(struct Qdisc *qd, unsigned long cl)
509{
510 struct ieee80211_local *local = wdev_priv(qd->dev->ieee80211_ptr);
511 struct ieee80211_hw *hw = &local->hw;
512
513 if (cl - 1 > hw->queues)
514 return -ENOENT;
515 return 0;
516}
517
518
519static int wme_classop_dump_class(struct Qdisc *qd, unsigned long cl,
520 struct sk_buff *skb, struct tcmsg *tcm)
521{
522 struct ieee80211_sched_data *q = qdisc_priv(qd);
523 struct ieee80211_local *local = wdev_priv(qd->dev->ieee80211_ptr);
524 struct ieee80211_hw *hw = &local->hw;
525
526 if (cl - 1 > hw->queues)
527 return -ENOENT;
528 tcm->tcm_handle = TC_H_MIN(cl);
529 tcm->tcm_parent = qd->handle;
530 tcm->tcm_info = q->queues[cl-1]->handle; /* do we need this? */
531 return 0;
532}
533
534
535static void wme_classop_walk(struct Qdisc *qd, struct qdisc_walker *arg)
536{
537 struct ieee80211_local *local = wdev_priv(qd->dev->ieee80211_ptr);
538 struct ieee80211_hw *hw = &local->hw;
539 int queue;
540
541 if (arg->stop)
542 return;
543
544 for (queue = 0; queue < hw->queues; queue++) {
545 if (arg->count < arg->skip) {
546 arg->count++;
547 continue;
548 }
549 /* we should return classids for our internal queues here
550 * as well as the external ones */
551 if (arg->fn(qd, queue+1, arg) < 0) {
552 arg->stop = 1;
553 break;
554 }
555 arg->count++;
556 }
557}
558
559
560static struct tcf_proto ** wme_classop_find_tcf(struct Qdisc *qd,
561 unsigned long cl)
562{
563 struct ieee80211_sched_data *q = qdisc_priv(qd);
564
565 if (cl)
566 return NULL;
567
568 return &q->filter_list;
569}
570
571
572/* this qdisc is classful (i.e. has classes, some of which may have leaf qdiscs attached)
573 * - these are the operations on the classes */
574static const struct Qdisc_class_ops class_ops =
575{
576 .graft = wme_classop_graft,
577 .leaf = wme_classop_leaf,
578
579 .get = wme_classop_get,
580 .put = wme_classop_put,
581 .change = wme_classop_change,
582 .delete = wme_classop_delete,
583 .walk = wme_classop_walk,
584
585 .tcf_chain = wme_classop_find_tcf,
586 .bind_tcf = wme_classop_bind,
587 .unbind_tcf = wme_classop_put,
588
589 .dump = wme_classop_dump_class,
590};
591
592
593/* queueing discipline operations */
594static struct Qdisc_ops wme_qdisc_ops __read_mostly =
595{
596 .next = NULL,
597 .cl_ops = &class_ops,
598 .id = "ieee80211",
599 .priv_size = sizeof(struct ieee80211_sched_data),
600
601 .enqueue = wme_qdiscop_enqueue,
602 .dequeue = wme_qdiscop_dequeue,
603 .requeue = wme_qdiscop_requeue,
604 .drop = NULL, /* drop not needed since we are always the root qdisc */
605
606 .init = wme_qdiscop_init,
607 .reset = wme_qdiscop_reset,
608 .destroy = wme_qdiscop_destroy,
609 .change = wme_qdiscop_tune,
610
611 .dump = wme_qdiscop_dump,
612};
613
614
615void ieee80211_install_qdisc(struct net_device *dev)
616{
617 struct Qdisc *qdisc;
618
619 qdisc = qdisc_create_dflt(dev, &wme_qdisc_ops, TC_H_ROOT);
620 if (!qdisc) {
621 printk(KERN_ERR "%s: qdisc installation failed\n", dev->name);
622 return;
623 }
624
625 /* same handle as would be allocated by qdisc_alloc_handle() */
626 qdisc->handle = 0x80010000;
627
628 qdisc_lock_tree(dev);
629 list_add_tail(&qdisc->list, &dev->qdisc_list);
630 dev->qdisc_sleeping = qdisc;
631 qdisc_unlock_tree(dev);
632}
633
634
635int ieee80211_qdisc_installed(struct net_device *dev)
636{
637 return dev->qdisc_sleeping->ops == &wme_qdisc_ops;
638}
639
640
641int ieee80211_wme_register(void)
642{
643 return register_qdisc(&wme_qdisc_ops);
644}
645
646
647void ieee80211_wme_unregister(void)
648{
649 unregister_qdisc(&wme_qdisc_ops);
650}
651
652int ieee80211_ht_agg_queue_add(struct ieee80211_local *local, 186int ieee80211_ht_agg_queue_add(struct ieee80211_local *local,
653 struct sta_info *sta, u16 tid) 187 struct sta_info *sta, u16 tid)
654{ 188{
655 int i; 189 int i;
656 struct ieee80211_sched_data *q =
657 qdisc_priv(local->mdev->qdisc_sleeping);
658 DECLARE_MAC_BUF(mac);
659 190
660 /* prepare the filter and save it for the SW queue 191 /* prepare the filter and save it for the SW queue
661 * matching the recieved HW queue */ 192 * matching the received HW queue */
193
194 if (!local->hw.ampdu_queues)
195 return -EPERM;
662 196
663 /* try to get a Qdisc from the pool */ 197 /* try to get a Qdisc from the pool */
664 for (i = IEEE80211_TX_QUEUE_BEACON; i < local->hw.queues; i++) 198 for (i = local->hw.queues; i < ieee80211_num_queues(&local->hw); i++)
665 if (!test_and_set_bit(i, q->qdisc_pool)) { 199 if (!test_and_set_bit(i, local->queue_pool)) {
666 ieee80211_stop_queue(local_to_hw(local), i); 200 ieee80211_stop_queue(local_to_hw(local), i);
667 sta->tid_to_tx_q[tid] = i; 201 sta->tid_to_tx_q[tid] = i;
668 202
@@ -671,11 +205,13 @@ int ieee80211_ht_agg_queue_add(struct ieee80211_local *local,
671 * on the previous queue 205 * on the previous queue
672 * since HT is strict in order */ 206 * since HT is strict in order */
673#ifdef CONFIG_MAC80211_HT_DEBUG 207#ifdef CONFIG_MAC80211_HT_DEBUG
674 if (net_ratelimit()) 208 if (net_ratelimit()) {
209 DECLARE_MAC_BUF(mac);
675 printk(KERN_DEBUG "allocated aggregation queue" 210 printk(KERN_DEBUG "allocated aggregation queue"
676 " %d tid %d addr %s pool=0x%lX\n", 211 " %d tid %d addr %s pool=0x%lX\n",
677 i, tid, print_mac(mac, sta->addr), 212 i, tid, print_mac(mac, sta->addr),
678 q->qdisc_pool[0]); 213 local->queue_pool[0]);
214 }
679#endif /* CONFIG_MAC80211_HT_DEBUG */ 215#endif /* CONFIG_MAC80211_HT_DEBUG */
680 return 0; 216 return 0;
681 } 217 }
@@ -684,44 +220,79 @@ int ieee80211_ht_agg_queue_add(struct ieee80211_local *local,
684} 220}
685 221
686/** 222/**
687 * the caller needs to hold local->mdev->queue_lock 223 * the caller needs to hold netdev_get_tx_queue(local->mdev, X)->lock
688 */ 224 */
689void ieee80211_ht_agg_queue_remove(struct ieee80211_local *local, 225void ieee80211_ht_agg_queue_remove(struct ieee80211_local *local,
690 struct sta_info *sta, u16 tid, 226 struct sta_info *sta, u16 tid,
691 u8 requeue) 227 u8 requeue)
692{ 228{
693 struct ieee80211_sched_data *q =
694 qdisc_priv(local->mdev->qdisc_sleeping);
695 int agg_queue = sta->tid_to_tx_q[tid]; 229 int agg_queue = sta->tid_to_tx_q[tid];
230 struct ieee80211_hw *hw = &local->hw;
696 231
697 /* return the qdisc to the pool */ 232 /* return the qdisc to the pool */
698 clear_bit(agg_queue, q->qdisc_pool); 233 clear_bit(agg_queue, local->queue_pool);
699 sta->tid_to_tx_q[tid] = local->hw.queues; 234 sta->tid_to_tx_q[tid] = ieee80211_num_queues(hw);
700 235
701 if (requeue) 236 if (requeue) {
702 ieee80211_requeue(local, agg_queue); 237 ieee80211_requeue(local, agg_queue);
703 else 238 } else {
704 q->queues[agg_queue]->ops->reset(q->queues[agg_queue]); 239 struct netdev_queue *txq;
240 spinlock_t *root_lock;
241
242 txq = netdev_get_tx_queue(local->mdev, agg_queue);
243 root_lock = qdisc_root_lock(txq->qdisc);
244
245 spin_lock_bh(root_lock);
246 qdisc_reset(txq->qdisc);
247 spin_unlock_bh(root_lock);
248 }
705} 249}
706 250
707void ieee80211_requeue(struct ieee80211_local *local, int queue) 251void ieee80211_requeue(struct ieee80211_local *local, int queue)
708{ 252{
709 struct Qdisc *root_qd = local->mdev->qdisc_sleeping; 253 struct netdev_queue *txq = netdev_get_tx_queue(local->mdev, queue);
710 struct ieee80211_sched_data *q = qdisc_priv(root_qd); 254 struct sk_buff_head list;
711 struct Qdisc *qdisc = q->queues[queue]; 255 spinlock_t *root_lock;
712 struct sk_buff *skb = NULL; 256 struct Qdisc *qdisc;
713 u32 len; 257 u32 len;
714 258
259 rcu_read_lock_bh();
260
261 qdisc = rcu_dereference(txq->qdisc);
715 if (!qdisc || !qdisc->dequeue) 262 if (!qdisc || !qdisc->dequeue)
716 return; 263 goto out_unlock;
264
265 skb_queue_head_init(&list);
717 266
718 printk(KERN_DEBUG "requeue: qlen = %d\n", qdisc->q.qlen); 267 root_lock = qdisc_root_lock(qdisc);
268 spin_lock(root_lock);
719 for (len = qdisc->q.qlen; len > 0; len--) { 269 for (len = qdisc->q.qlen; len > 0; len--) {
720 skb = qdisc->dequeue(qdisc); 270 struct sk_buff *skb = qdisc->dequeue(qdisc);
721 root_qd->q.qlen--; 271
722 /* packet will be classified again and */
723 /* skb->packet_data->queue will be overridden if needed */
724 if (skb) 272 if (skb)
725 wme_qdiscop_enqueue(skb, root_qd); 273 __skb_queue_tail(&list, skb);
274 }
275 spin_unlock(root_lock);
276
277 for (len = list.qlen; len > 0; len--) {
278 struct sk_buff *skb = __skb_dequeue(&list);
279 u16 new_queue;
280
281 BUG_ON(!skb);
282 new_queue = ieee80211_select_queue(local->mdev, skb);
283 skb_set_queue_mapping(skb, new_queue);
284
285 txq = netdev_get_tx_queue(local->mdev, new_queue);
286
287
288 qdisc = rcu_dereference(txq->qdisc);
289 root_lock = qdisc_root_lock(qdisc);
290
291 spin_lock(root_lock);
292 qdisc_enqueue_root(skb, qdisc);
293 spin_unlock(root_lock);
726 } 294 }
295
296out_unlock:
297 rcu_read_unlock_bh();
727} 298}