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.c120
1 files changed, 50 insertions, 70 deletions
diff --git a/net/mac80211/wme.c b/net/mac80211/wme.c
index 64faa3dc488f..5eddf1f32ed9 100644
--- a/net/mac80211/wme.c
+++ b/net/mac80211/wme.c
@@ -19,16 +19,22 @@
19#include "wme.h" 19#include "wme.h"
20 20
21/* maximum number of hardware queues we support. */ 21/* maximum number of hardware queues we support. */
22#define TC_80211_MAX_QUEUES 16 22#define QD_MAX_QUEUES (IEEE80211_MAX_AMPDU_QUEUES + IEEE80211_MAX_QUEUES)
23/* current number of hardware queues we support. */
24#define QD_NUM(hw) ((hw)->queues + (hw)->ampdu_queues)
23 25
26/*
27 * Default mapping in classifier to work with default
28 * queue setup.
29 */
24const int ieee802_1d_to_ac[8] = { 2, 3, 3, 2, 1, 1, 0, 0 }; 30const int ieee802_1d_to_ac[8] = { 2, 3, 3, 2, 1, 1, 0, 0 };
25 31
26struct ieee80211_sched_data 32struct ieee80211_sched_data
27{ 33{
28 unsigned long qdisc_pool[BITS_TO_LONGS(TC_80211_MAX_QUEUES)]; 34 unsigned long qdisc_pool[BITS_TO_LONGS(QD_MAX_QUEUES)];
29 struct tcf_proto *filter_list; 35 struct tcf_proto *filter_list;
30 struct Qdisc *queues[TC_80211_MAX_QUEUES]; 36 struct Qdisc *queues[QD_MAX_QUEUES];
31 struct sk_buff_head requeued[TC_80211_MAX_QUEUES]; 37 struct sk_buff_head requeued[QD_MAX_QUEUES];
32}; 38};
33 39
34static const char llc_ip_hdr[8] = {0xAA, 0xAA, 0x3, 0, 0, 0, 0x08, 0}; 40static const char llc_ip_hdr[8] = {0xAA, 0xAA, 0x3, 0, 0, 0, 0x08, 0};
@@ -95,7 +101,7 @@ static inline int wme_downgrade_ac(struct sk_buff *skb)
95 101
96/* positive return value indicates which queue to use 102/* positive return value indicates which queue to use
97 * negative return value indicates to drop the frame */ 103 * negative return value indicates to drop the frame */
98static inline int classify80211(struct sk_buff *skb, struct Qdisc *qd) 104static int classify80211(struct sk_buff *skb, struct Qdisc *qd)
99{ 105{
100 struct ieee80211_local *local = wdev_priv(qd->dev->ieee80211_ptr); 106 struct ieee80211_local *local = wdev_priv(qd->dev->ieee80211_ptr);
101 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; 107 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
@@ -106,7 +112,7 @@ static inline int classify80211(struct sk_buff *skb, struct Qdisc *qd)
106 if (unlikely((fc & IEEE80211_FCTL_FTYPE) != IEEE80211_FTYPE_DATA)) { 112 if (unlikely((fc & IEEE80211_FCTL_FTYPE) != IEEE80211_FTYPE_DATA)) {
107 /* management frames go on AC_VO queue, but are sent 113 /* management frames go on AC_VO queue, but are sent
108 * without QoS control fields */ 114 * without QoS control fields */
109 return IEEE80211_TX_QUEUE_DATA0; 115 return 0;
110 } 116 }
111 117
112 if (0 /* injected */) { 118 if (0 /* injected */) {
@@ -141,14 +147,16 @@ static inline int classify80211(struct sk_buff *skb, struct Qdisc *qd)
141static int wme_qdiscop_enqueue(struct sk_buff *skb, struct Qdisc* qd) 147static int wme_qdiscop_enqueue(struct sk_buff *skb, struct Qdisc* qd)
142{ 148{
143 struct ieee80211_local *local = wdev_priv(qd->dev->ieee80211_ptr); 149 struct ieee80211_local *local = wdev_priv(qd->dev->ieee80211_ptr);
150 struct ieee80211_hw *hw = &local->hw;
144 struct ieee80211_sched_data *q = qdisc_priv(qd); 151 struct ieee80211_sched_data *q = qdisc_priv(qd);
145 struct ieee80211_tx_packet_data *pkt_data = 152 struct ieee80211_tx_packet_data *pkt_data =
146 (struct ieee80211_tx_packet_data *) skb->cb; 153 (struct ieee80211_tx_packet_data *) skb->cb;
147 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; 154 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
148 unsigned short fc = le16_to_cpu(hdr->frame_control); 155 unsigned short fc = le16_to_cpu(hdr->frame_control);
149 struct Qdisc *qdisc; 156 struct Qdisc *qdisc;
150 int err, queue;
151 struct sta_info *sta; 157 struct sta_info *sta;
158 int err;
159 u16 queue;
152 u8 tid; 160 u8 tid;
153 161
154 if (pkt_data->flags & IEEE80211_TXPD_REQUEUE) { 162 if (pkt_data->flags & IEEE80211_TXPD_REQUEUE) {
@@ -158,7 +166,7 @@ static int wme_qdiscop_enqueue(struct sk_buff *skb, struct Qdisc* qd)
158 tid = skb->priority & QOS_CONTROL_TAG1D_MASK; 166 tid = skb->priority & QOS_CONTROL_TAG1D_MASK;
159 if (sta) { 167 if (sta) {
160 int ampdu_queue = sta->tid_to_tx_q[tid]; 168 int ampdu_queue = sta->tid_to_tx_q[tid];
161 if ((ampdu_queue < local->hw.queues) && 169 if ((ampdu_queue < QD_NUM(hw)) &&
162 test_bit(ampdu_queue, q->qdisc_pool)) { 170 test_bit(ampdu_queue, q->qdisc_pool)) {
163 queue = ampdu_queue; 171 queue = ampdu_queue;
164 pkt_data->flags |= IEEE80211_TXPD_AMPDU; 172 pkt_data->flags |= IEEE80211_TXPD_AMPDU;
@@ -174,6 +182,9 @@ static int wme_qdiscop_enqueue(struct sk_buff *skb, struct Qdisc* qd)
174 182
175 queue = classify80211(skb, qd); 183 queue = classify80211(skb, qd);
176 184
185 if (unlikely(queue >= local->hw.queues))
186 queue = local->hw.queues - 1;
187
177 /* now we know the 1d priority, fill in the QoS header if there is one 188 /* now we know the 1d priority, fill in the QoS header if there is one
178 */ 189 */
179 if (WLAN_FC_IS_QOS_DATA(fc)) { 190 if (WLAN_FC_IS_QOS_DATA(fc)) {
@@ -193,8 +204,8 @@ static int wme_qdiscop_enqueue(struct sk_buff *skb, struct Qdisc* qd)
193 sta = sta_info_get(local, hdr->addr1); 204 sta = sta_info_get(local, hdr->addr1);
194 if (sta) { 205 if (sta) {
195 int ampdu_queue = sta->tid_to_tx_q[tid]; 206 int ampdu_queue = sta->tid_to_tx_q[tid];
196 if ((ampdu_queue < local->hw.queues) && 207 if ((ampdu_queue < QD_NUM(hw)) &&
197 test_bit(ampdu_queue, q->qdisc_pool)) { 208 test_bit(ampdu_queue, q->qdisc_pool)) {
198 queue = ampdu_queue; 209 queue = ampdu_queue;
199 pkt_data->flags |= IEEE80211_TXPD_AMPDU; 210 pkt_data->flags |= IEEE80211_TXPD_AMPDU;
200 } else { 211 } else {
@@ -205,17 +216,6 @@ static int wme_qdiscop_enqueue(struct sk_buff *skb, struct Qdisc* qd)
205 rcu_read_unlock(); 216 rcu_read_unlock();
206 } 217 }
207 218
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)) { 219 if (unlikely(queue < 0)) {
220 kfree_skb(skb); 220 kfree_skb(skb);
221 err = NET_XMIT_DROP; 221 err = NET_XMIT_DROP;
@@ -270,7 +270,7 @@ static struct sk_buff *wme_qdiscop_dequeue(struct Qdisc* qd)
270 int queue; 270 int queue;
271 271
272 /* check all the h/w queues in numeric/priority order */ 272 /* check all the h/w queues in numeric/priority order */
273 for (queue = 0; queue < hw->queues; queue++) { 273 for (queue = 0; queue < QD_NUM(hw); queue++) {
274 /* see if there is room in this hardware queue */ 274 /* see if there is room in this hardware queue */
275 if ((test_bit(IEEE80211_LINK_STATE_XOFF, 275 if ((test_bit(IEEE80211_LINK_STATE_XOFF,
276 &local->state[queue])) || 276 &local->state[queue])) ||
@@ -308,7 +308,7 @@ static void wme_qdiscop_reset(struct Qdisc* qd)
308 308
309 /* QUESTION: should we have some hardware flush functionality here? */ 309 /* QUESTION: should we have some hardware flush functionality here? */
310 310
311 for (queue = 0; queue < hw->queues; queue++) { 311 for (queue = 0; queue < QD_NUM(hw); queue++) {
312 skb_queue_purge(&q->requeued[queue]); 312 skb_queue_purge(&q->requeued[queue]);
313 qdisc_reset(q->queues[queue]); 313 qdisc_reset(q->queues[queue]);
314 } 314 }
@@ -326,7 +326,7 @@ static void wme_qdiscop_destroy(struct Qdisc* qd)
326 tcf_destroy_chain(q->filter_list); 326 tcf_destroy_chain(q->filter_list);
327 q->filter_list = NULL; 327 q->filter_list = NULL;
328 328
329 for (queue=0; queue < hw->queues; queue++) { 329 for (queue = 0; queue < QD_NUM(hw); queue++) {
330 skb_queue_purge(&q->requeued[queue]); 330 skb_queue_purge(&q->requeued[queue]);
331 qdisc_destroy(q->queues[queue]); 331 qdisc_destroy(q->queues[queue]);
332 q->queues[queue] = &noop_qdisc; 332 q->queues[queue] = &noop_qdisc;
@@ -337,17 +337,6 @@ static void wme_qdiscop_destroy(struct Qdisc* qd)
337/* called whenever parameters are updated on existing qdisc */ 337/* called whenever parameters are updated on existing qdisc */
338static int wme_qdiscop_tune(struct Qdisc *qd, struct nlattr *opt) 338static int wme_qdiscop_tune(struct Qdisc *qd, struct nlattr *opt)
339{ 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; 340 return 0;
352} 341}
353 342
@@ -358,7 +347,7 @@ static int wme_qdiscop_init(struct Qdisc *qd, struct nlattr *opt)
358 struct ieee80211_sched_data *q = qdisc_priv(qd); 347 struct ieee80211_sched_data *q = qdisc_priv(qd);
359 struct net_device *dev = qd->dev; 348 struct net_device *dev = qd->dev;
360 struct ieee80211_local *local; 349 struct ieee80211_local *local;
361 int queues; 350 struct ieee80211_hw *hw;
362 int err = 0, i; 351 int err = 0, i;
363 352
364 /* check that device is a mac80211 device */ 353 /* check that device is a mac80211 device */
@@ -366,29 +355,26 @@ static int wme_qdiscop_init(struct Qdisc *qd, struct nlattr *opt)
366 dev->ieee80211_ptr->wiphy->privid != mac80211_wiphy_privid) 355 dev->ieee80211_ptr->wiphy->privid != mac80211_wiphy_privid)
367 return -EINVAL; 356 return -EINVAL;
368 357
369 /* check this device is an ieee80211 master type device */ 358 local = wdev_priv(dev->ieee80211_ptr);
370 if (dev->type != ARPHRD_IEEE80211) 359 hw = &local->hw;
360
361 /* only allow on master dev */
362 if (dev != local->mdev)
371 return -EINVAL; 363 return -EINVAL;
372 364
373 /* check that there is no qdisc currently attached to device 365 /* ensure that we are root qdisc */
374 * this ensures that we will be the root qdisc. (I can't find a better 366 if (qd->parent != TC_H_ROOT)
375 * way to test this explicitly) */
376 if (dev->qdisc_sleeping != &noop_qdisc)
377 return -EINVAL; 367 return -EINVAL;
378 368
379 if (qd->flags & TCQ_F_INGRESS) 369 if (qd->flags & TCQ_F_INGRESS)
380 return -EINVAL; 370 return -EINVAL;
381 371
382 local = wdev_priv(dev->ieee80211_ptr);
383 queues = local->hw.queues;
384
385 /* if options were passed in, set them */ 372 /* if options were passed in, set them */
386 if (opt) { 373 if (opt)
387 err = wme_qdiscop_tune(qd, opt); 374 err = wme_qdiscop_tune(qd, opt);
388 }
389 375
390 /* create child queues */ 376 /* create child queues */
391 for (i = 0; i < queues; i++) { 377 for (i = 0; i < QD_NUM(hw); i++) {
392 skb_queue_head_init(&q->requeued[i]); 378 skb_queue_head_init(&q->requeued[i]);
393 q->queues[i] = qdisc_create_dflt(qd->dev, &pfifo_qdisc_ops, 379 q->queues[i] = qdisc_create_dflt(qd->dev, &pfifo_qdisc_ops,
394 qd->handle); 380 qd->handle);
@@ -398,8 +384,8 @@ static int wme_qdiscop_init(struct Qdisc *qd, struct nlattr *opt)
398 } 384 }
399 } 385 }
400 386
401 /* reserve all legacy QoS queues */ 387 /* non-aggregation queues: reserve/mark as used */
402 for (i = 0; i < min(IEEE80211_TX_QUEUE_DATA4, queues); i++) 388 for (i = 0; i < local->hw.queues; i++)
403 set_bit(i, q->qdisc_pool); 389 set_bit(i, q->qdisc_pool);
404 390
405 return err; 391 return err;
@@ -407,16 +393,6 @@ static int wme_qdiscop_init(struct Qdisc *qd, struct nlattr *opt)
407 393
408static int wme_qdiscop_dump(struct Qdisc *qd, struct sk_buff *skb) 394static int wme_qdiscop_dump(struct Qdisc *qd, struct sk_buff *skb)
409{ 395{
410/* struct ieee80211_sched_data *q = qdisc_priv(qd);
411 unsigned char *p = skb->tail;
412 struct tc_ieee80211_qopt opt;
413
414 memcpy(&opt.tag2queue, q->tag2queue, TC_80211_MAX_TAG + 1);
415 NLA_PUT(skb, TCA_OPTIONS, sizeof(opt), &opt);
416*/ return skb->len;
417/*
418nla_put_failure:
419 skb_trim(skb, p - skb->data);*/
420 return -1; 396 return -1;
421} 397}
422 398
@@ -429,7 +405,7 @@ static int wme_classop_graft(struct Qdisc *qd, unsigned long arg,
429 struct ieee80211_hw *hw = &local->hw; 405 struct ieee80211_hw *hw = &local->hw;
430 unsigned long queue = arg - 1; 406 unsigned long queue = arg - 1;
431 407
432 if (queue >= hw->queues) 408 if (queue >= QD_NUM(hw))
433 return -EINVAL; 409 return -EINVAL;
434 410
435 if (!new) 411 if (!new)
@@ -453,7 +429,7 @@ wme_classop_leaf(struct Qdisc *qd, unsigned long arg)
453 struct ieee80211_hw *hw = &local->hw; 429 struct ieee80211_hw *hw = &local->hw;
454 unsigned long queue = arg - 1; 430 unsigned long queue = arg - 1;
455 431
456 if (queue >= hw->queues) 432 if (queue >= QD_NUM(hw))
457 return NULL; 433 return NULL;
458 434
459 return q->queues[queue]; 435 return q->queues[queue];
@@ -466,7 +442,7 @@ static unsigned long wme_classop_get(struct Qdisc *qd, u32 classid)
466 struct ieee80211_hw *hw = &local->hw; 442 struct ieee80211_hw *hw = &local->hw;
467 unsigned long queue = TC_H_MIN(classid); 443 unsigned long queue = TC_H_MIN(classid);
468 444
469 if (queue - 1 >= hw->queues) 445 if (queue - 1 >= QD_NUM(hw))
470 return 0; 446 return 0;
471 447
472 return queue; 448 return queue;
@@ -492,7 +468,7 @@ static int wme_classop_change(struct Qdisc *qd, u32 handle, u32 parent,
492 struct ieee80211_local *local = wdev_priv(qd->dev->ieee80211_ptr); 468 struct ieee80211_local *local = wdev_priv(qd->dev->ieee80211_ptr);
493 struct ieee80211_hw *hw = &local->hw; 469 struct ieee80211_hw *hw = &local->hw;
494 470
495 if (cl - 1 > hw->queues) 471 if (cl - 1 > QD_NUM(hw))
496 return -ENOENT; 472 return -ENOENT;
497 473
498 /* TODO: put code to program hardware queue parameters here, 474 /* TODO: put code to program hardware queue parameters here,
@@ -509,7 +485,7 @@ static int wme_classop_delete(struct Qdisc *qd, unsigned long cl)
509 struct ieee80211_local *local = wdev_priv(qd->dev->ieee80211_ptr); 485 struct ieee80211_local *local = wdev_priv(qd->dev->ieee80211_ptr);
510 struct ieee80211_hw *hw = &local->hw; 486 struct ieee80211_hw *hw = &local->hw;
511 487
512 if (cl - 1 > hw->queues) 488 if (cl - 1 > QD_NUM(hw))
513 return -ENOENT; 489 return -ENOENT;
514 return 0; 490 return 0;
515} 491}
@@ -522,7 +498,7 @@ static int wme_classop_dump_class(struct Qdisc *qd, unsigned long cl,
522 struct ieee80211_local *local = wdev_priv(qd->dev->ieee80211_ptr); 498 struct ieee80211_local *local = wdev_priv(qd->dev->ieee80211_ptr);
523 struct ieee80211_hw *hw = &local->hw; 499 struct ieee80211_hw *hw = &local->hw;
524 500
525 if (cl - 1 > hw->queues) 501 if (cl - 1 > QD_NUM(hw))
526 return -ENOENT; 502 return -ENOENT;
527 tcm->tcm_handle = TC_H_MIN(cl); 503 tcm->tcm_handle = TC_H_MIN(cl);
528 tcm->tcm_parent = qd->handle; 504 tcm->tcm_parent = qd->handle;
@@ -540,7 +516,7 @@ static void wme_classop_walk(struct Qdisc *qd, struct qdisc_walker *arg)
540 if (arg->stop) 516 if (arg->stop)
541 return; 517 return;
542 518
543 for (queue = 0; queue < hw->queues; queue++) { 519 for (queue = 0; queue < QD_NUM(hw); queue++) {
544 if (arg->count < arg->skip) { 520 if (arg->count < arg->skip) {
545 arg->count++; 521 arg->count++;
546 continue; 522 continue;
@@ -657,10 +633,13 @@ int ieee80211_ht_agg_queue_add(struct ieee80211_local *local,
657 DECLARE_MAC_BUF(mac); 633 DECLARE_MAC_BUF(mac);
658 634
659 /* prepare the filter and save it for the SW queue 635 /* prepare the filter and save it for the SW queue
660 * matching the recieved HW queue */ 636 * matching the received HW queue */
637
638 if (!local->hw.ampdu_queues)
639 return -EPERM;
661 640
662 /* try to get a Qdisc from the pool */ 641 /* try to get a Qdisc from the pool */
663 for (i = IEEE80211_TX_QUEUE_BEACON; i < local->hw.queues; i++) 642 for (i = local->hw.queues; i < QD_NUM(&local->hw); i++)
664 if (!test_and_set_bit(i, q->qdisc_pool)) { 643 if (!test_and_set_bit(i, q->qdisc_pool)) {
665 ieee80211_stop_queue(local_to_hw(local), i); 644 ieee80211_stop_queue(local_to_hw(local), i);
666 sta->tid_to_tx_q[tid] = i; 645 sta->tid_to_tx_q[tid] = i;
@@ -689,13 +668,14 @@ void ieee80211_ht_agg_queue_remove(struct ieee80211_local *local,
689 struct sta_info *sta, u16 tid, 668 struct sta_info *sta, u16 tid,
690 u8 requeue) 669 u8 requeue)
691{ 670{
671 struct ieee80211_hw *hw = &local->hw;
692 struct ieee80211_sched_data *q = 672 struct ieee80211_sched_data *q =
693 qdisc_priv(local->mdev->qdisc_sleeping); 673 qdisc_priv(local->mdev->qdisc_sleeping);
694 int agg_queue = sta->tid_to_tx_q[tid]; 674 int agg_queue = sta->tid_to_tx_q[tid];
695 675
696 /* return the qdisc to the pool */ 676 /* return the qdisc to the pool */
697 clear_bit(agg_queue, q->qdisc_pool); 677 clear_bit(agg_queue, q->qdisc_pool);
698 sta->tid_to_tx_q[tid] = local->hw.queues; 678 sta->tid_to_tx_q[tid] = QD_NUM(hw);
699 679
700 if (requeue) 680 if (requeue)
701 ieee80211_requeue(local, agg_queue); 681 ieee80211_requeue(local, agg_queue);