aboutsummaryrefslogtreecommitdiffstats
path: root/net/mac80211/ieee80211.c
diff options
context:
space:
mode:
authorRon Rindjunsky <ron.rindjunsky@intel.com>2008-01-28 07:07:17 -0500
committerJohn W. Linville <linville@tuxdriver.com>2008-02-29 15:19:14 -0500
commiteadc8d9e9047266a8914eb2ed4d36e797ce540d1 (patch)
treed4abb405e46c279aae81f32106000090f70e9a53 /net/mac80211/ieee80211.c
parent80656c20315558a9bc5c5b7f7c6949fa72277afd (diff)
mac80211: A-MPDU Tx adding basic functionality
This patch adds the following abilities to mac80211: - start A-MPDU Tx session - stop A-MPDU Tx session - call backs to start/stop A-MPDU Tx session - sending addBA request - processing addBA response Signed-off-by: Ron Rindjunsky <ron.rindjunsky@intel.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'net/mac80211/ieee80211.c')
-rw-r--r--net/mac80211/ieee80211.c336
1 files changed, 336 insertions, 0 deletions
diff --git a/net/mac80211/ieee80211.c b/net/mac80211/ieee80211.c
index 28bcdf9fc3df..c323c9af9b8f 100644
--- a/net/mac80211/ieee80211.c
+++ b/net/mac80211/ieee80211.c
@@ -414,6 +414,329 @@ static int ieee80211_stop(struct net_device *dev)
414 return 0; 414 return 0;
415} 415}
416 416
417int ieee80211_start_tx_ba_session(struct ieee80211_hw *hw, u8 *ra, u16 tid)
418{
419 struct ieee80211_local *local = hw_to_local(hw);
420 struct sta_info *sta;
421 struct ieee80211_sub_if_data *sdata;
422 u16 start_seq_num = 0;
423 u8 *state;
424 int ret;
425 DECLARE_MAC_BUF(mac);
426
427 if (tid >= STA_TID_NUM)
428 return -EINVAL;
429
430#ifdef CONFIG_MAC80211_HT_DEBUG
431 printk(KERN_DEBUG "Open BA session requested for %s tid %u\n",
432 print_mac(mac, ra), tid);
433#endif /* CONFIG_MAC80211_HT_DEBUG */
434
435 sta = sta_info_get(local, ra);
436 if (!sta) {
437 printk(KERN_DEBUG "Could not find the station\n");
438 return -ENOENT;
439 }
440
441 spin_lock_bh(&sta->ampdu_mlme.ampdu_tx);
442
443 /* we have tried too many times, receiver does not want A-MPDU */
444 if (sta->ampdu_mlme.tid_tx[tid].addba_req_num > HT_AGG_MAX_RETRIES) {
445 ret = -EBUSY;
446 goto start_ba_exit;
447 }
448
449 state = &sta->ampdu_mlme.tid_tx[tid].state;
450 /* check if the TID is not in aggregation flow already */
451 if (*state != HT_AGG_STATE_IDLE) {
452#ifdef CONFIG_MAC80211_HT_DEBUG
453 printk(KERN_DEBUG "BA request denied - session is not "
454 "idle on tid %u\n", tid);
455#endif /* CONFIG_MAC80211_HT_DEBUG */
456 ret = -EAGAIN;
457 goto start_ba_exit;
458 }
459
460 /* ensure that TX flow won't interrupt us
461 * until the end of the call to requeue function */
462 spin_lock_bh(&local->mdev->queue_lock);
463
464 /* create a new queue for this aggregation */
465 /* ret = ieee80211_ht_agg_queue_add(local, sta, tid); */
466
467 /* case no queue is available to aggregation
468 * don't switch to aggregation */
469 if (ret) {
470#ifdef CONFIG_MAC80211_HT_DEBUG
471 printk(KERN_DEBUG "BA request denied - no queue available for"
472 " tid %d\n", tid);
473#endif /* CONFIG_MAC80211_HT_DEBUG */
474 spin_unlock_bh(&local->mdev->queue_lock);
475 goto start_ba_exit;
476 }
477 sdata = IEEE80211_DEV_TO_SUB_IF(sta->dev);
478
479 /* Ok, the Addba frame hasn't been sent yet, but if the driver calls the
480 * call back right away, it must see that the flow has begun */
481 *state |= HT_ADDBA_REQUESTED_MSK;
482
483 if (local->ops->ampdu_action)
484 ret = local->ops->ampdu_action(hw, IEEE80211_AMPDU_TX_START,
485 ra, tid, &start_seq_num);
486
487 if (ret) {
488 /* No need to requeue the packets in the agg queue, since we
489 * held the tx lock: no packet could be enqueued to the newly
490 * allocated queue */
491 /* ieee80211_ht_agg_queue_remove(local, sta, tid, 0); */
492#ifdef CONFIG_MAC80211_HT_DEBUG
493 printk(KERN_DEBUG "BA request denied - HW or queue unavailable"
494 " for tid %d\n", tid);
495#endif /* CONFIG_MAC80211_HT_DEBUG */
496 spin_unlock_bh(&local->mdev->queue_lock);
497 *state = HT_AGG_STATE_IDLE;
498 goto start_ba_exit;
499 }
500
501 /* Will put all the packets in the new SW queue */
502 /* ieee80211_requeue(local, ieee802_1d_to_ac[tid]); */
503 spin_unlock_bh(&local->mdev->queue_lock);
504
505 /* We have most probably almost emptied the legacy queue */
506 /* ieee80211_wake_queue(local_to_hw(local), ieee802_1d_to_ac[tid]); */
507
508 /* send an addBA request */
509 sta->ampdu_mlme.dialog_token_allocator++;
510 sta->ampdu_mlme.tid_tx[tid].dialog_token =
511 sta->ampdu_mlme.dialog_token_allocator;
512 sta->ampdu_mlme.tid_tx[tid].ssn = start_seq_num;
513
514 ieee80211_send_addba_request(sta->dev, ra, tid,
515 sta->ampdu_mlme.tid_tx[tid].dialog_token,
516 sta->ampdu_mlme.tid_tx[tid].ssn,
517 0x40, 5000);
518
519 /* activate the timer for the recipient's addBA response */
520 sta->ampdu_mlme.tid_tx[tid].addba_resp_timer.expires =
521 jiffies + ADDBA_RESP_INTERVAL;
522 add_timer(&sta->ampdu_mlme.tid_tx[tid].addba_resp_timer);
523 printk(KERN_DEBUG "activated addBA response timer on tid %d\n", tid);
524
525start_ba_exit:
526 spin_unlock_bh(&sta->ampdu_mlme.ampdu_tx);
527 sta_info_put(sta);
528 return ret;
529}
530EXPORT_SYMBOL(ieee80211_start_tx_ba_session);
531
532int ieee80211_stop_tx_ba_session(struct ieee80211_hw *hw,
533 u8 *ra, u16 tid,
534 enum ieee80211_back_parties initiator)
535{
536 struct ieee80211_local *local = hw_to_local(hw);
537 struct sta_info *sta;
538 u8 *state;
539 int ret = 0;
540 DECLARE_MAC_BUF(mac);
541
542 if (tid >= STA_TID_NUM)
543 return -EINVAL;
544
545#ifdef CONFIG_MAC80211_HT_DEBUG
546 printk(KERN_DEBUG "Stop a BA session requested for %s tid %u\n",
547 print_mac(mac, ra), tid);
548#endif /* CONFIG_MAC80211_HT_DEBUG */
549
550 sta = sta_info_get(local, ra);
551 if (!sta)
552 return -ENOENT;
553
554 /* check if the TID is in aggregation */
555 state = &sta->ampdu_mlme.tid_tx[tid].state;
556 spin_lock_bh(&sta->ampdu_mlme.ampdu_tx);
557
558 if (*state != HT_AGG_STATE_OPERATIONAL) {
559#ifdef CONFIG_MAC80211_HT_DEBUG
560 printk(KERN_DEBUG "Try to stop Tx aggregation on"
561 " non active TID\n");
562#endif /* CONFIG_MAC80211_HT_DEBUG */
563 ret = -ENOENT;
564 goto stop_BA_exit;
565 }
566
567 ieee80211_stop_queue(hw, sta->tid_to_tx_q[tid]);
568
569 *state = HT_AGG_STATE_REQ_STOP_BA_MSK |
570 (initiator << HT_AGG_STATE_INITIATOR_SHIFT);
571
572 if (local->ops->ampdu_action)
573 ret = local->ops->ampdu_action(hw, IEEE80211_AMPDU_TX_STOP,
574 ra, tid, NULL);
575
576 /* case HW denied going back to legacy */
577 if (ret) {
578 WARN_ON(ret != -EBUSY);
579 *state = HT_AGG_STATE_OPERATIONAL;
580 ieee80211_wake_queue(hw, sta->tid_to_tx_q[tid]);
581 goto stop_BA_exit;
582 }
583
584stop_BA_exit:
585 spin_unlock_bh(&sta->ampdu_mlme.ampdu_tx);
586 sta_info_put(sta);
587 return ret;
588}
589EXPORT_SYMBOL(ieee80211_stop_tx_ba_session);
590
591void ieee80211_start_tx_ba_cb(struct ieee80211_hw *hw, u8 *ra, u16 tid)
592{
593 struct ieee80211_local *local = hw_to_local(hw);
594 struct sta_info *sta;
595 u8 *state;
596 DECLARE_MAC_BUF(mac);
597
598 if (tid >= STA_TID_NUM) {
599 printk(KERN_DEBUG "Bad TID value: tid = %d (>= %d)\n",
600 tid, STA_TID_NUM);
601 return;
602 }
603
604 sta = sta_info_get(local, ra);
605 if (!sta) {
606 printk(KERN_DEBUG "Could not find station: %s\n",
607 print_mac(mac, ra));
608 return;
609 }
610
611 state = &sta->ampdu_mlme.tid_tx[tid].state;
612 spin_lock_bh(&sta->ampdu_mlme.ampdu_tx);
613
614 if (!(*state & HT_ADDBA_REQUESTED_MSK)) {
615 printk(KERN_DEBUG "addBA was not requested yet, state is %d\n",
616 *state);
617 spin_unlock_bh(&sta->ampdu_mlme.ampdu_tx);
618 sta_info_put(sta);
619 return;
620 }
621
622 WARN_ON_ONCE(*state & HT_ADDBA_DRV_READY_MSK);
623
624 *state |= HT_ADDBA_DRV_READY_MSK;
625
626 if (*state == HT_AGG_STATE_OPERATIONAL) {
627 printk(KERN_DEBUG "Aggregation is on for tid %d \n", tid);
628 ieee80211_wake_queue(hw, sta->tid_to_tx_q[tid]);
629 }
630 spin_unlock_bh(&sta->ampdu_mlme.ampdu_tx);
631 sta_info_put(sta);
632}
633EXPORT_SYMBOL(ieee80211_start_tx_ba_cb);
634
635void ieee80211_stop_tx_ba_cb(struct ieee80211_hw *hw, u8 *ra, u8 tid)
636{
637 struct ieee80211_local *local = hw_to_local(hw);
638 struct sta_info *sta;
639 u8 *state;
640 int agg_queue;
641 DECLARE_MAC_BUF(mac);
642
643 if (tid >= STA_TID_NUM) {
644 printk(KERN_DEBUG "Bad TID value: tid = %d (>= %d)\n",
645 tid, STA_TID_NUM);
646 return;
647 }
648
649 printk(KERN_DEBUG "Stop a BA session requested on DA %s tid %d\n",
650 print_mac(mac, ra), tid);
651
652 sta = sta_info_get(local, ra);
653 if (!sta) {
654 printk(KERN_DEBUG "Could not find station: %s\n",
655 print_mac(mac, ra));
656 return;
657 }
658 state = &sta->ampdu_mlme.tid_tx[tid].state;
659
660 spin_lock_bh(&sta->ampdu_mlme.ampdu_tx);
661 if ((*state & HT_AGG_STATE_REQ_STOP_BA_MSK) == 0) {
662 printk(KERN_DEBUG "unexpected callback to A-MPDU stop\n");
663 sta_info_put(sta);
664 spin_unlock_bh(&sta->ampdu_mlme.ampdu_tx);
665 return;
666 }
667
668 if (*state & HT_AGG_STATE_INITIATOR_MSK)
669 ieee80211_send_delba(sta->dev, ra, tid,
670 WLAN_BACK_INITIATOR, WLAN_REASON_QSTA_NOT_USE);
671
672 agg_queue = sta->tid_to_tx_q[tid];
673
674 /* avoid ordering issues: we are the only one that can modify
675 * the content of the qdiscs */
676 spin_lock_bh(&local->mdev->queue_lock);
677 /* remove the queue for this aggregation */
678 /* ieee80211_ht_agg_queue_remove(local, sta, tid, 1); */
679 spin_unlock_bh(&local->mdev->queue_lock);
680
681 /* we just requeued the all the frames that were in the removed
682 * queue, and since we might miss a softirq we do netif_schedule.
683 * ieee80211_wake_queue is not used here as this queue is not
684 * necessarily stopped */
685 netif_schedule(local->mdev);
686 *state = HT_AGG_STATE_IDLE;
687 sta->ampdu_mlme.tid_tx[tid].addba_req_num = 0;
688 spin_unlock_bh(&sta->ampdu_mlme.ampdu_tx);
689
690 sta_info_put(sta);
691}
692EXPORT_SYMBOL(ieee80211_stop_tx_ba_cb);
693
694void ieee80211_start_tx_ba_cb_irqsafe(struct ieee80211_hw *hw,
695 const u8 *ra, u16 tid)
696{
697 struct ieee80211_local *local = hw_to_local(hw);
698 struct ieee80211_ra_tid *ra_tid;
699 struct sk_buff *skb = dev_alloc_skb(0);
700
701 if (unlikely(!skb)) {
702 if (net_ratelimit())
703 printk(KERN_WARNING "%s: Not enough memory, "
704 "dropping start BA session", skb->dev->name);
705 return;
706 }
707 ra_tid = (struct ieee80211_ra_tid *) &skb->cb;
708 memcpy(&ra_tid->ra, ra, ETH_ALEN);
709 ra_tid->tid = tid;
710
711 skb->pkt_type = IEEE80211_ADDBA_MSG;
712 skb_queue_tail(&local->skb_queue, skb);
713 tasklet_schedule(&local->tasklet);
714}
715EXPORT_SYMBOL(ieee80211_start_tx_ba_cb_irqsafe);
716
717void ieee80211_stop_tx_ba_cb_irqsafe(struct ieee80211_hw *hw,
718 const u8 *ra, u16 tid)
719{
720 struct ieee80211_local *local = hw_to_local(hw);
721 struct ieee80211_ra_tid *ra_tid;
722 struct sk_buff *skb = dev_alloc_skb(0);
723
724 if (unlikely(!skb)) {
725 if (net_ratelimit())
726 printk(KERN_WARNING "%s: Not enough memory, "
727 "dropping stop BA session", skb->dev->name);
728 return;
729 }
730 ra_tid = (struct ieee80211_ra_tid *) &skb->cb;
731 memcpy(&ra_tid->ra, ra, ETH_ALEN);
732 ra_tid->tid = tid;
733
734 skb->pkt_type = IEEE80211_DELBA_MSG;
735 skb_queue_tail(&local->skb_queue, skb);
736 tasklet_schedule(&local->tasklet);
737}
738EXPORT_SYMBOL(ieee80211_stop_tx_ba_cb_irqsafe);
739
417static void ieee80211_set_multicast_list(struct net_device *dev) 740static void ieee80211_set_multicast_list(struct net_device *dev)
418{ 741{
419 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); 742 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
@@ -713,6 +1036,7 @@ static void ieee80211_tasklet_handler(unsigned long data)
713 struct sk_buff *skb; 1036 struct sk_buff *skb;
714 struct ieee80211_rx_status rx_status; 1037 struct ieee80211_rx_status rx_status;
715 struct ieee80211_tx_status *tx_status; 1038 struct ieee80211_tx_status *tx_status;
1039 struct ieee80211_ra_tid *ra_tid;
716 1040
717 while ((skb = skb_dequeue(&local->skb_queue)) || 1041 while ((skb = skb_dequeue(&local->skb_queue)) ||
718 (skb = skb_dequeue(&local->skb_queue_unreliable))) { 1042 (skb = skb_dequeue(&local->skb_queue_unreliable))) {
@@ -733,6 +1057,18 @@ static void ieee80211_tasklet_handler(unsigned long data)
733 skb, tx_status); 1057 skb, tx_status);
734 kfree(tx_status); 1058 kfree(tx_status);
735 break; 1059 break;
1060 case IEEE80211_DELBA_MSG:
1061 ra_tid = (struct ieee80211_ra_tid *) &skb->cb;
1062 ieee80211_stop_tx_ba_cb(local_to_hw(local),
1063 ra_tid->ra, ra_tid->tid);
1064 dev_kfree_skb(skb);
1065 break;
1066 case IEEE80211_ADDBA_MSG:
1067 ra_tid = (struct ieee80211_ra_tid *) &skb->cb;
1068 ieee80211_start_tx_ba_cb(local_to_hw(local),
1069 ra_tid->ra, ra_tid->tid);
1070 dev_kfree_skb(skb);
1071 break ;
736 default: /* should never get here! */ 1072 default: /* should never get here! */
737 printk(KERN_ERR "%s: Unknown message type (%d)\n", 1073 printk(KERN_ERR "%s: Unknown message type (%d)\n",
738 wiphy_name(local->hw.wiphy), skb->pkt_type); 1074 wiphy_name(local->hw.wiphy), skb->pkt_type);