aboutsummaryrefslogtreecommitdiffstats
path: root/net/mac80211
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
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')
-rw-r--r--net/mac80211/ieee80211.c336
-rw-r--r--net/mac80211/ieee80211_i.h14
-rw-r--r--net/mac80211/ieee80211_sta.c182
3 files changed, 530 insertions, 2 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);
diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h
index 72ecbf7bf962..8a24c2c6ebc1 100644
--- a/net/mac80211/ieee80211_i.h
+++ b/net/mac80211/ieee80211_i.h
@@ -407,6 +407,8 @@ struct ieee80211_sub_if_data *vif_to_sdata(struct ieee80211_vif *p)
407enum { 407enum {
408 IEEE80211_RX_MSG = 1, 408 IEEE80211_RX_MSG = 1,
409 IEEE80211_TX_STATUS_MSG = 2, 409 IEEE80211_TX_STATUS_MSG = 2,
410 IEEE80211_DELBA_MSG = 3,
411 IEEE80211_ADDBA_MSG = 4,
410}; 412};
411 413
412struct ieee80211_local { 414struct ieee80211_local {
@@ -627,6 +629,12 @@ struct ieee80211_local {
627#endif 629#endif
628}; 630};
629 631
632/* this struct represents 802.11n's RA/TID combination */
633struct ieee80211_ra_tid {
634 u8 ra[ETH_ALEN];
635 u16 tid;
636};
637
630static inline struct ieee80211_local *hw_to_local( 638static inline struct ieee80211_local *hw_to_local(
631 struct ieee80211_hw *hw) 639 struct ieee80211_hw *hw)
632{ 640{
@@ -782,9 +790,15 @@ int ieee80211_ht_cap_ie_to_ht_info(struct ieee80211_ht_cap *ht_cap_ie,
782int ieee80211_ht_addt_info_ie_to_ht_bss_info( 790int ieee80211_ht_addt_info_ie_to_ht_bss_info(
783 struct ieee80211_ht_addt_info *ht_add_info_ie, 791 struct ieee80211_ht_addt_info *ht_add_info_ie,
784 struct ieee80211_ht_bss_info *bss_info); 792 struct ieee80211_ht_bss_info *bss_info);
793void ieee80211_send_addba_request(struct net_device *dev, const u8 *da,
794 u16 tid, u8 dialog_token, u16 start_seq_num,
795 u16 agg_size, u16 timeout);
796void ieee80211_send_delba(struct net_device *dev, const u8 *da, u16 tid,
797 u16 initiator, u16 reason_code);
785void ieee80211_sta_stop_rx_ba_session(struct net_device *dev, u8 *da, 798void ieee80211_sta_stop_rx_ba_session(struct net_device *dev, u8 *da,
786 u16 tid, u16 initiator, u16 reason); 799 u16 tid, u16 initiator, u16 reason);
787void sta_rx_agg_session_timer_expired(unsigned long data); 800void sta_rx_agg_session_timer_expired(unsigned long data);
801void sta_addba_resp_timer_expired(unsigned long data);
788/* ieee80211_iface.c */ 802/* ieee80211_iface.c */
789int ieee80211_if_add(struct net_device *dev, const char *name, 803int ieee80211_if_add(struct net_device *dev, const char *name,
790 struct net_device **new_dev, int type); 804 struct net_device **new_dev, int type);
diff --git a/net/mac80211/ieee80211_sta.c b/net/mac80211/ieee80211_sta.c
index d5d5610db1bd..c4d57346eacf 100644
--- a/net/mac80211/ieee80211_sta.c
+++ b/net/mac80211/ieee80211_sta.c
@@ -1045,6 +1045,58 @@ static void ieee80211_send_addba_resp(struct net_device *dev, u8 *da, u16 tid,
1045 return; 1045 return;
1046} 1046}
1047 1047
1048void ieee80211_send_addba_request(struct net_device *dev, const u8 *da,
1049 u16 tid, u8 dialog_token, u16 start_seq_num,
1050 u16 agg_size, u16 timeout)
1051{
1052 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
1053 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1054 struct ieee80211_if_sta *ifsta = &sdata->u.sta;
1055 struct sk_buff *skb;
1056 struct ieee80211_mgmt *mgmt;
1057 u16 capab;
1058
1059 skb = dev_alloc_skb(sizeof(*mgmt) + local->hw.extra_tx_headroom + 1 +
1060 sizeof(mgmt->u.action.u.addba_req));
1061
1062
1063 if (!skb) {
1064 printk(KERN_ERR "%s: failed to allocate buffer "
1065 "for addba request frame\n", dev->name);
1066 return;
1067 }
1068 skb_reserve(skb, local->hw.extra_tx_headroom);
1069 mgmt = (struct ieee80211_mgmt *) skb_put(skb, 24);
1070 memset(mgmt, 0, 24);
1071 memcpy(mgmt->da, da, ETH_ALEN);
1072 memcpy(mgmt->sa, dev->dev_addr, ETH_ALEN);
1073 if (sdata->vif.type == IEEE80211_IF_TYPE_AP)
1074 memcpy(mgmt->bssid, dev->dev_addr, ETH_ALEN);
1075 else
1076 memcpy(mgmt->bssid, ifsta->bssid, ETH_ALEN);
1077
1078 mgmt->frame_control = IEEE80211_FC(IEEE80211_FTYPE_MGMT,
1079 IEEE80211_STYPE_ACTION);
1080
1081 skb_put(skb, 1 + sizeof(mgmt->u.action.u.addba_req));
1082
1083 mgmt->u.action.category = WLAN_CATEGORY_BACK;
1084 mgmt->u.action.u.addba_req.action_code = WLAN_ACTION_ADDBA_REQ;
1085
1086 mgmt->u.action.u.addba_req.dialog_token = dialog_token;
1087 capab = (u16)(1 << 1); /* bit 1 aggregation policy */
1088 capab |= (u16)(tid << 2); /* bit 5:2 TID number */
1089 capab |= (u16)(agg_size << 6); /* bit 15:6 max size of aggergation */
1090
1091 mgmt->u.action.u.addba_req.capab = cpu_to_le16(capab);
1092
1093 mgmt->u.action.u.addba_req.timeout = cpu_to_le16(timeout);
1094 mgmt->u.action.u.addba_req.start_seq_num =
1095 cpu_to_le16(start_seq_num << 4);
1096
1097 ieee80211_sta_tx(dev, skb, 0);
1098}
1099
1048static void ieee80211_sta_process_addba_request(struct net_device *dev, 1100static void ieee80211_sta_process_addba_request(struct net_device *dev,
1049 struct ieee80211_mgmt *mgmt, 1101 struct ieee80211_mgmt *mgmt,
1050 size_t len) 1102 size_t len)
@@ -1156,8 +1208,80 @@ end_no_lock:
1156 sta_info_put(sta); 1208 sta_info_put(sta);
1157} 1209}
1158 1210
1159static void ieee80211_send_delba(struct net_device *dev, const u8 *da, u16 tid, 1211static void ieee80211_sta_process_addba_resp(struct net_device *dev,
1160 u16 initiator, u16 reason_code) 1212 struct ieee80211_mgmt *mgmt,
1213 size_t len)
1214{
1215 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
1216 struct ieee80211_hw *hw = &local->hw;
1217 struct sta_info *sta;
1218 u16 capab;
1219 u16 tid;
1220 u8 *state;
1221
1222 sta = sta_info_get(local, mgmt->sa);
1223 if (!sta)
1224 return;
1225
1226 capab = le16_to_cpu(mgmt->u.action.u.addba_resp.capab);
1227 tid = (capab & IEEE80211_ADDBA_PARAM_TID_MASK) >> 2;
1228
1229 state = &sta->ampdu_mlme.tid_tx[tid].state;
1230
1231 spin_lock_bh(&sta->ampdu_mlme.ampdu_tx);
1232
1233 if (mgmt->u.action.u.addba_resp.dialog_token !=
1234 sta->ampdu_mlme.tid_tx[tid].dialog_token) {
1235 spin_unlock_bh(&sta->ampdu_mlme.ampdu_tx);
1236#ifdef CONFIG_MAC80211_HT_DEBUG
1237 printk(KERN_DEBUG "wrong addBA response token, tid %d\n", tid);
1238#endif /* CONFIG_MAC80211_HT_DEBUG */
1239 sta_info_put(sta);
1240 return;
1241 }
1242
1243 del_timer_sync(&sta->ampdu_mlme.tid_tx[tid].addba_resp_timer);
1244#ifdef CONFIG_MAC80211_HT_DEBUG
1245 printk(KERN_DEBUG "switched off addBA timer for tid %d \n", tid);
1246#endif /* CONFIG_MAC80211_HT_DEBUG */
1247 if (le16_to_cpu(mgmt->u.action.u.addba_resp.status)
1248 == WLAN_STATUS_SUCCESS) {
1249 if (!(*state & HT_ADDBA_REQUESTED_MSK)) {
1250 spin_unlock_bh(&sta->ampdu_mlme.ampdu_tx);
1251 printk(KERN_DEBUG "state not HT_ADDBA_REQUESTED_MSK:"
1252 "%d\n", *state);
1253 sta_info_put(sta);
1254 return;
1255 }
1256
1257 if (*state & HT_ADDBA_RECEIVED_MSK)
1258 printk(KERN_DEBUG "double addBA response\n");
1259
1260 *state |= HT_ADDBA_RECEIVED_MSK;
1261 sta->ampdu_mlme.tid_tx[tid].addba_req_num = 0;
1262
1263 if (*state == HT_AGG_STATE_OPERATIONAL) {
1264 printk(KERN_DEBUG "Aggregation on for tid %d \n", tid);
1265 ieee80211_wake_queue(hw, sta->tid_to_tx_q[tid]);
1266 }
1267
1268 spin_unlock_bh(&sta->ampdu_mlme.ampdu_tx);
1269 printk(KERN_DEBUG "recipient accepted agg: tid %d \n", tid);
1270 } else {
1271 printk(KERN_DEBUG "recipient rejected agg: tid %d \n", tid);
1272
1273 sta->ampdu_mlme.tid_tx[tid].addba_req_num++;
1274 /* this will allow the state check in stop_BA_session */
1275 *state = HT_AGG_STATE_OPERATIONAL;
1276 spin_unlock_bh(&sta->ampdu_mlme.ampdu_tx);
1277 ieee80211_stop_tx_ba_session(hw, sta->addr, tid,
1278 WLAN_BACK_INITIATOR);
1279 }
1280 sta_info_put(sta);
1281}
1282
1283void ieee80211_send_delba(struct net_device *dev, const u8 *da, u16 tid,
1284 u16 initiator, u16 reason_code)
1161{ 1285{
1162 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); 1286 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
1163 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); 1287 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
@@ -1259,6 +1383,7 @@ void ieee80211_sta_stop_rx_ba_session(struct net_device *dev, u8 *ra, u16 tid,
1259 sta_info_put(sta); 1383 sta_info_put(sta);
1260} 1384}
1261 1385
1386
1262static void ieee80211_sta_process_delba(struct net_device *dev, 1387static void ieee80211_sta_process_delba(struct net_device *dev,
1263 struct ieee80211_mgmt *mgmt, size_t len) 1388 struct ieee80211_mgmt *mgmt, size_t len)
1264{ 1389{
@@ -1290,6 +1415,53 @@ static void ieee80211_sta_process_delba(struct net_device *dev,
1290} 1415}
1291 1416
1292/* 1417/*
1418 * After sending add Block Ack request we activated a timer until
1419 * add Block Ack response will arrive from the recipient.
1420 * If this timer expires sta_addba_resp_timer_expired will be executed.
1421 */
1422void sta_addba_resp_timer_expired(unsigned long data)
1423{
1424 /* not an elegant detour, but there is no choice as the timer passes
1425 * only one argument, and both sta_info and TID are needed, so init
1426 * flow in sta_info_add gives the TID as data, while the timer_to_id
1427 * array gives the sta through container_of */
1428 u16 tid = *(int *)data;
1429 struct sta_info *temp_sta = container_of((void *)data,
1430 struct sta_info, timer_to_tid[tid]);
1431
1432 struct ieee80211_local *local = temp_sta->local;
1433 struct ieee80211_hw *hw = &local->hw;
1434 struct sta_info *sta;
1435 u8 *state;
1436
1437 sta = sta_info_get(local, temp_sta->addr);
1438 if (!sta)
1439 return;
1440
1441 state = &sta->ampdu_mlme.tid_tx[tid].state;
1442 /* check if the TID waits for addBA response */
1443 spin_lock_bh(&sta->ampdu_mlme.ampdu_tx);
1444 if (!(*state & HT_ADDBA_REQUESTED_MSK)) {
1445 spin_unlock_bh(&sta->ampdu_mlme.ampdu_tx);
1446 *state = HT_AGG_STATE_IDLE;
1447 printk(KERN_DEBUG "timer expired on tid %d but we are not "
1448 "expecting addBA response there", tid);
1449 goto timer_expired_exit;
1450 }
1451
1452 printk(KERN_DEBUG "addBA response timer expired on tid %d\n", tid);
1453
1454 /* go through the state check in stop_BA_session */
1455 *state = HT_AGG_STATE_OPERATIONAL;
1456 spin_unlock_bh(&sta->ampdu_mlme.ampdu_tx);
1457 ieee80211_stop_tx_ba_session(hw, temp_sta->addr, tid,
1458 WLAN_BACK_INITIATOR);
1459
1460timer_expired_exit:
1461 sta_info_put(sta);
1462}
1463
1464/*
1293 * After receiving Block Ack Request (BAR) we activated a 1465 * After receiving Block Ack Request (BAR) we activated a
1294 * timer after each frame arrives from the originator. 1466 * timer after each frame arrives from the originator.
1295 * if this timer expires ieee80211_sta_stop_rx_ba_session will be executed. 1467 * if this timer expires ieee80211_sta_stop_rx_ba_session will be executed.
@@ -2236,6 +2408,12 @@ static void ieee80211_rx_mgmt_action(struct net_device *dev,
2236 break; 2408 break;
2237 ieee80211_sta_process_addba_request(dev, mgmt, len); 2409 ieee80211_sta_process_addba_request(dev, mgmt, len);
2238 break; 2410 break;
2411 case WLAN_ACTION_ADDBA_RESP:
2412 if (len < (IEEE80211_MIN_ACTION_SIZE +
2413 sizeof(mgmt->u.action.u.addba_resp)))
2414 break;
2415 ieee80211_sta_process_addba_resp(dev, mgmt, len);
2416 break;
2239 case WLAN_ACTION_DELBA: 2417 case WLAN_ACTION_DELBA:
2240 if (len < (IEEE80211_MIN_ACTION_SIZE + 2418 if (len < (IEEE80211_MIN_ACTION_SIZE +
2241 sizeof(mgmt->u.action.u.delba))) 2419 sizeof(mgmt->u.action.u.delba)))